Why is z3.check () slow when immediately preceded by z3.push ()?
The below Python snippet illustrates the performance behavior of ZD. Without calling push()
z3, checks the formula in 0.1 s. For push()
(and without additional statements) z3 takes 0.8 s. A similar result occurs even after replacing s.append(f)
and s.push()
.
import time
import z3
f = z3.parse_smt2_file("smt-lib/QF_BV/RWS/Example_1.txt.smt2")
s = z3.Solver()
s.append(f)
t1 = time.time()
s.check() # 0.10693597793579102 seconds
print(time.time() - t1)
s = z3.Solver()
t1 = time.time()
s.append(f)
s.push()
s.check() # 0.830916166305542 seconds
print(time.time() - t1)
Any idea why this slowdown is happening? And how can this be solved?
I am using z3-4.3.2.bb56885147e4-x64-osx-10.9.2.
source to share
Your example uses "push" on the second instance. This makes a huge difference. The Z3 bit vector solver is (not yet) available for incremental use via the API. It only works for standing assertions and does not interact with scopes (push / pop). The first call uses the bit vector SAT solver. "Push / pop" doesn't happen. The second call follows the call to "press". Z3 then determines that it should use an incremental SMT kernel to track volume dependencies, which does not benefit from a more efficient bit vector solver.
source to share