I am running Z3 on UFBV queries. Currently the query contains 2 calls check-sat
.
If I put push 1
just after check-sat
, Z3 solves the query in 30sec. If I don't put any push 1
at all, thus have two calls check-sat
without any push 1
between them, then Z3 solves it in 200sec.
Interesting. Any specific reasons or just a coincidence?
Z3 3.x has a "strategy specification language" based on tactics and tacticals. I'm not "advertising" that yet because it is working in progress.
The basic idea is described in this slide deck.
We have a different built-in strategy for each logic. The strategies usually do not support incremental solving, because they may apply transformations that use a "closed-world" assumption. Example, we have transformations that map 0-1 linear integer arithmetic into SAT. Whenever Z3 detects that the user "wants" incremental solving (e.g., multiple check-sat
commands, push
&pop
commands), it switches to a general purpose solver. In future versions, we will provide more features for controlling Z3 behavior.
BTW, if you have two consecutive (check-sat) (check-sat)
commands, Z3 not necessarily enters in incremental mode. It will enter only if there is an assert
or push
command between the two calls.
Now, suppose your query is of the form: (check-sat) <assertions> (check-sat)
, and your second query is of the form (check-sat) <assertions> (push) (check-sat)
. In both cases, Z3 will be in incremental mode in the second (check-sat)
. However, the behavior is still not the same. The incremental solver "compiles" the asserted formulas to an internal format, and its behavior is affected if a push
command has been executed. For example, it will use a more efficient encoding of binary clauses only if there is no user scope. By user scope, I mean, the number of push
commands - number of pop
commands. It does that because the data-structure used in the more efficient encoding does not have an efficient undo/inverse operation.