I want to implement a constraint which requires AND logic in Z3Py. Suppose we have two variables a
and b
, I just want to add one constraint which requires a == 0
and b == 1
. There should be several ways which can do this in Z3, like s.add(a == 0, b == 0)
or s.add(And(a==0, b==0)
. However, I tried one method which is s.add(a == 0 and b == 0)
. This method doesn't work, the code is:
from z3 import *
a = Int('a')
b = Int('b')
s = Solver()
#s.add(a == 0, b ==1)
#s.add(And(a == 0, b == 1))
s.add(a == 0 and b == 1)
print(s.check())
print(s.model())
The output of this file is a = 0
, which means b is ignored... Can someone explain why does this happen? It seems And(a == 0, b == 1)
and a == 0 and b == 1
are different in Z3Py.