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
659 B

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