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.

40 lines
712 B

7 months ago
  1. \item \self
  2. Let $x$ and $y$ be two 32-bit vector variables.
  3. Complete the script such that it checks whether $abs(x)$
  4. can be computed in the following way:
  5. \begin{equation}
  6. y = x >> 31 \\
  7. \end{equation}
  8. \begin{equation} \label{eq:equivalence}
  9. abs(x) = (x \lxor y) - y
  10. \end{equation}
  11. The script should compare the result with the built-in function \texttt{Abs(x)} from z3.
  12. % Complete the following python code constraint statements, such that the call to \texttt{solver.check()} checks the equivalence of Equation~\ref{eq:equivalence}.
  13. \begin{pythonSourceCode}
  14. from z3 import *
  15. solver = Solver()
  16. result = solver.check()
  17. print(result)
  18. \end{pythonSourceCode}