Binary file slides/slides09.pdf has changed
--- a/slides/slides09.tex Tue Nov 25 11:48:16 2014 +0000
+++ b/slides/slides09.tex Tue Nov 25 15:54:28 2014 +0000
@@ -1165,7 +1165,7 @@
\begin{columns}
- \begin{column}{4cm}
+ \begin{column}{3cm}
\begin{tabular}{cc|l}
$e_1$ & $e_2$ & $e_1 + e_2$\\\hline{}
- & - & -\\
@@ -1178,7 +1178,7 @@
\end{tabular}
\end{column}
- \begin{column}{4cm}
+ \begin{column}{3cm}
\begin{tabular}{cc|l}
$e_1$ & $e_2$ & $e_1 * e_2$\\\hline{}
- & - & +\\
@@ -1195,6 +1195,69 @@
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[fragile]
+\mbox{}\\[-13mm]\mbox{}
+
+\small
+\begin{center}
+\bl{\begin{tabular}{lcl}
+$[n]_{env}$ & $\dn$ &
+$\begin{cases}
+\{+\} & \text{if}\; n > 0\\
+\{-\} & \text{if}\; n < 0\\
+\{0\} & \text{if}\; n = 0
+\end{cases}$\\
+$[x]_{env}$ & $\dn$ & $env(x)$\\
+$[e_1 + e_2]_{env}$ & $\dn$ & $[e_1]_{env} \oplus [e_2]_{env}$\\
+$[e_1 * e_2]_{env}$ & $\dn$ & $[e_1]_{env} \otimes [e_2]_{env}$\\
+$[e_1 = e_2]_{env}$ & $\dn$ & $\{0, +\}$\\
+\end{tabular}}
+\end{center}
+
+\scriptsize
+\begin{lstlisting}[language=Scala,numbers=none,xleftmargin=-5mm]
+def aeval_exp(e: Exp, aenv: AEnv) : Set[Abst] = e match {
+ case Num(0) => Set(Zero)
+ case Num(n) if (n < 0) => Set(Neg)
+ case Num(n) if (n > 0) => Set(Pos)
+ case Var(x) => aenv(x)
+ case Plus(e1, e2) =>
+ aplus(aeval_exp(e1, aenv), aeval_exp(e2, aenv))
+ case Times(e1, e2) =>
+ atimes(aeval_exp(e1, aenv), aeval_exp(e2, aenv))
+ case Equ(e1, e2) => Set(Zero, Pos)
+}
+\end{lstlisting}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \begin{frame}[c]
+ \frametitle{Sign Analysis}
+
+ \begin{itemize}
+ \item We want to find out whether \texttt{a} and \texttt{n}
+ are always positive?\medskip
+ \item After a few optimisations, we can indeed find this out.
+ \begin{itemize}
+ \item \texttt{if} returns \texttt{+} or \texttt{0}
+ \item branch into only one dircection if you know
+ \item if $x$ is \texttt{+}, then $x + \texttt{-1}$
+ cannot be negative
+ \end{itemize}\bigskip
+
+ \item What is this good for? Well, you do not need
+ underflow checks (in order to prevent buffer-overflow
+ attacks).
+ \end{itemize}
+
+ \end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
\end{document}