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.

32 lines
792 B

  1. # coding: utf-8
  2. from z3 import *
  3. ################################# Burglars ##################################
  4. # create the solver
  5. solver = Solver()
  6. #############################################################################
  7. # (1) Ed: "Fred did it, and Ted is innocent".
  8. # (2) Fred: "If Ed is guilty , then so is Ted".
  9. # (3) Ted: "Im innocent, but at least one of the others is guilty".
  10. #############################################################################
  11. # TODO
  12. # Create boolean variables for each of the culprits
  13. # TODO
  14. # Add constraints to the solver representing the statements from above
  15. res = solver.check()
  16. if res != sat:
  17. print("unsat")
  18. sys.exit(1)
  19. print(solver)
  20. m = solver.model()
  21. for d in m.decls():
  22. print("%s -> %s" % (d, m[d]))
  23. print("\n" + str(m))