3

Sometimes, evaluating a boolean expression in a model doesn't return a concrete boolean value even when the expression clearly has a concrete value. I've been able to reduce this to cases involving array expressions such as this test case:

from z3 import *

x = K(IntSort(), 0)
s = Solver()
s.check()
m = s.model()
print m.evaluate(x == Store(x, 0, 1), model_completion=True)

I would expect this to print False, but instead it prints K(Int, 0) == Store(K(Int, 0), 0, 1). Other examples produce similar results. Replacing the first line with x = Array('x', IntSort(), IntSort()) gives the same result (though that's up to the default interpretation). Interestingly, replacing the first line with x = Store(K(IntSort(), 0), 0, 1) causes the example to print True.

Is there a way to force Z3 to evaluate such expressions to concrete values?

Malte Schwerhoff
  • 12,684
  • 4
  • 41
  • 71
  • This may be nontrivial to do as per our comments and your example with temporary model assignments, so your best bet may be to do the equivalent of this: http://stackoverflow.com/questions/11652069/casting-a-z3-integer-expression-to-a-c-c-int – Taylor T. Johnson Aug 07 '13 at 15:17
  • Did you ever get an answer to this? I, too, want to evaluate expressions that contain array equalities, but they are deeply nested expressions, so I can't easily hoist the equality out. – EfForEffort May 06 '15 at 21:28
  • After thinking about this a bit, I think the issue is that it doesn't make sense to ask the model to evaluate array extensionality (?) statements. So, suppose you want to know whether A==B in a model where A is K(Int, 0) and B is Store(K(Int, 0), 0, 1). What you're asking is, "Is there an index i, such that A[i]!=B[i]? If not, A==B." The index i is implicit, but, I think it essentially turns the evaluation into a satisfiability problem, so, you have to invoke the solver to get the answer. I think. – EfForEffort May 07 '15 at 03:40

0 Answers0