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.
|
|
from z3 import * s = Solver() bv_size = 4 a, b = BitVecs('a b', bv_size) x = BitVec('x', bv_size) lhs,rhs = BitVecs('lhs rhs', bv_size)
s.add(lhs == ((x+a)^b)-a) s.add(rhs == ((x-a)^b)+a) s.push() s.add(ForAll(x, lhs == rhs)) # 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, lhs != rhs)) result = s.check() print(result) if result == sat: print(f"Example where lhs != rhs: {s.model()}")
|