Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomly incorrect result using only Booleans #5808

Closed
onethreeseven opened this issue Feb 3, 2022 · 5 comments
Closed

Randomly incorrect result using only Booleans #5808

onethreeseven opened this issue Feb 3, 2022 · 5 comments

Comments

@onethreeseven
Copy link

I discovered this when a puzzle solver I'm building broke unexpectedly:

$ ./z3 --version
Z3 version 4.8.15 - 64 bit
$ ./z3 smt.random_seed=13 random_unsound_result.smt2 
sat
sat
sat
$ ./z3 smt.random_seed=14 random_unsound_result.smt2 
sat
sat
unsat

(All three results should be sat.) I get the incorrect result about 1% of the time. The problem uses only Bool, not, and, or, and pb_eq.

I apologize for the size of the test case; I'll try to reduce it if I find time but for now it's basically the problem I was working on.

Tested on 4.8.14 and current master (6a412f7).

@onethreeseven
Copy link
Author

Is there a way to replicate the behavior of Python's SimpleSolver() from the command line tool? I'm having (slightly) more luck reducing my test case using the simple solver but I can't figure out how to save the result.

@onethreeseven
Copy link
Author

onethreeseven commented Feb 7, 2022

I managed to get similar results by calling .check() right after instantiating the solver so it is incremental the whole way. As a result I have a slightly reduced case (use seeds 62 and 63) that only needs one round of incremental assertions to trigger the bug. I'm still struggling to make a truly minimal case, though.

@onethreeseven
Copy link
Author

I am sad to report that I tried out this change and upon searching over random seeds the misbehavior actually seems to happen more often. Here's a new pair of seeds on my updated test case:

~/code/z3/build$ ./z3 smt.random_seed=15 ../../z3-tests/random_unsound_result_2.smt2 
sat
sat
sat
~/code/z3/build$ ./z3 smt.random_seed=16 ../../z3-tests/random_unsound_result_2.smt2 
sat
sat
unsat

@onethreeseven
Copy link
Author

I've added the crude bash script I was using to search for misbehaving random seeds. Tomorrow if I can I will continue trying to find a truly minimal test case.

@onethreeseven
Copy link
Author

Tested against both the canned SMT file and my original application, all looks 👍! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants