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.

26 lines
377 B

  1. #!/usr/bin/python
  2. from z3 import *
  3. x = BitVec('x', 32)
  4. y = BitVec('y', 32)
  5. s = Solver()
  6. s.add(Distinct(((y & x)* -2) + (y + x), x^y))
  7. result = s.check()
  8. print(result)
  9. if result == sat:
  10. print(s.model())
  11. ### A 'different' way ###
  12. s = Solver()
  13. l = (y & x)*-2 + (y+x)
  14. r = x^y
  15. s.add(Distinct(l, r))
  16. result = s.check()
  17. print(result)
  18. if result == sat:
  19. print(s.model())