Probably a basic question related to Z3: i am trying to get all solutions of a boolean expression, e.g. for a OR b
, i want to get {(true, true),(false,true),(true,false)}
Based on other responses found, e.g. Z3: finding all satisfying models, i have the following code:
a = Bool('a')
b = Bool('b')
f1=Or(a,b)
s=Solver()
s.add(f1)
while s.check() == sat:
print s
s.add(Not(And(a == s.model()[a], b == s.model()[b])))
The issue is that it enters an infinite loop as at the second iteration: the constraint a == s.model()[a]
is evaluated to false b/c s.model()[a]
does not exist anymore.
Can someone tell what i am doing wrong?