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.

30 lines
761 B

3 months ago
  1. \item \self
  2. Consider the following script. What are the outputs of the
  3. two calls to \texttt{solver.check()}? Explain your answers.
  4. In particular, elaborate the difference of using an \texttt{Int()} and a \texttt{BitVec()} for the variables.
  5. \vskip7em
  6. \begin{pythonSourceCode}
  7. from z3 import *
  8. solver = Solver()
  9. intX = Int("intX")
  10. bvX = BitVec("bvX", 2)
  11. solver.push()
  12. solver.add(bvX + 1 < bvX - 1)
  13. result = solver.check()
  14. print(result)
  15. if result == sat:
  16. print(solver.model())
  17. solver.pop()
  18. solver.push()
  19. solver.add(intX + 1 < intX - 1)
  20. result = solver.check()
  21. print(result)
  22. if result == sat:
  23. print(solver.model())
  24. \end{pythonSourceCode}