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
40 lines
712 B
\item \self
|
|
Let $x$ and $y$ be two 32-bit vector variables.
|
|
Complete the script such that it checks whether $abs(x)$
|
|
can be computed in the following way:
|
|
\begin{equation}
|
|
y = x >> 31 \\
|
|
\end{equation}
|
|
\begin{equation} \label{eq:equivalence}
|
|
abs(x) = (x \lxor y) - y
|
|
\end{equation}
|
|
|
|
The script should compare the result with the built-in function \texttt{Abs(x)} from z3.
|
|
|
|
% Complete the following python code constraint statements, such that the call to \texttt{solver.check()} checks the equivalence of Equation~\ref{eq:equivalence}.
|
|
|
|
|
|
\begin{pythonSourceCode}
|
|
from z3 import *
|
|
|
|
solver = Solver()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = solver.check()
|
|
print(result)
|
|
|
|
|
|
\end{pythonSourceCode}
|