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.

25 lines
634 B

7 months ago
  1. \item \lect
  2. Given a 2-bit bitvector $x$, we want to check whether it is possible that $x + 1 < x - 1$.
  3. The following python script returns \texttt{sat}. Explain the error in the script and expand it such that it correctly prints \texttt{unsat}.
  4. \vskip7em
  5. \begin{pythonSourceCode}
  6. from z3 import *
  7. solver = Solver()
  8. bvX = BitVec("bvX", 2)
  9. solver.add(bvX + 1 < bvX - 1)
  10. solver.add(BVAddNoOverflow(bvX, 1, True))
  11. solver.add(BVSubNoUnderflow(bvX, 1, True))
  12. result = solver.check()
  13. print(result)
  14. if result == sat:
  15. print(solver.model())
  16. \end{pythonSourceCode}