You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

31 lines
585 B

from z3 import *
s = Solver()
a, b = BitVecs('a b', 4)
x = BitVec('x', 4)
s.push()
s.add(ForAll(x, ((x+a)^b)-a == ((x-a)^b)+a ))
# enumerate all possible solutions:
results=[]
while True:
if s.check() == sat:
m = s.model()
print (m)
results.append(m)
block = []
block = [a != m[a].as_long(), b != m[b].as_long()]
s.add(Or(block))
else:
print ("results total=", len(results))
break
#print(s.sexpr())
s.pop()
s.add(Exists(x, ((x+a)^b)-a != ((x-a)^b)+a ))
result = s.check()
print(result)
print(s.sexpr())
if result == sat:
print(s.model())