Once I have a constraint problem, I would like to see if it is satisfiable. Based on the returned model (when it is sat) I would like to add assertions and then run the solver again. However, it seems like I am misunderstanding some of the types/values contained in the returned model. Consider the following example:
solv = z3.Solver()
n = z3.Int("n")
solv.add(n >= 42)
solv.check() # This is satisfiable
model = solv.model()
for var in model:
# do something
solv.add(var == model[var])
solv.check() # This is unsat
I would expect that after the loop i essentially have the two constraints n >= 42
and n == 42
, assuming of course that z3 produces the model n=42 in the first call. Despite this, in the second call check()
returns unsat. What am I missing?
Sidenote: when replacing solv.add(var == model[var])
with solv.add(var >= model[var])
I get a z3.z3types.Z3Exception: Python value cannot be used as a Z3 integer
. Why is that?