Note the following Z3-Py code:
x, y = Ints('x y')
negS0= (x >= 2)
s1 = (y > 1)
s2 = (y <= x)
s = Solver()
phi = Exists([y],ForAll([x], Implies(negS0, And(s1,s2))))
s.add(phi)
print(s.check())
print(s.model())
This prints:
sat
[]
My question is: why is the model empty? I mean, I think y=2 should be a model...
Note that the same result happens with x and y being Real.
z3 will not include any quantified variable (in your case neither
ynorx) in its model. Note that you cannot putxin a model anyhow, because the formula is true for allx: That's the meaning of universal quantification. For the outer-most existentials (like youry), z3 can indeed print the model value for that, but it chooses not to do so since it can be confusing: Imagine you had aphi2, which also had an outer-most existential namedy: How would you know whichyit would be that it prints in the model?So, z3 keeps things simple and simply prints the top-level declared variables in the model. And since a top-level declaration is equivalent to an outermost existential, you can simply drop it:
This prints:
like you predicted. Note that this
yis unambiguous, since it's declared at the top-level. (Of course, you can redefine it to be something else due to the loosely typed nature of Python bindings and still get yourself confused, but that's a different discussion.)