\documentclass[11pt]{article}
\usepackage{palatino}
\usepackage{latexsym}
\usepackage{verbatim}
\usepackage{alltt}
\usepackage{amsmath,proof,amsthm,amssymb,enumerate}
\usepackage{math-cmds}

% FIXME be more precise about parens in question 2

\newcommand{\question}[2]
  {\bigskip \noindent
   {\bf Question #1} (#2 points).}

\newcommand{\extracreditquestion}[1]
  {\bigskip \noindent
   {\bf Question #1} (EXTRA CREDIT).}

\newcommand{\definition}[2]
  {\bigskip
   \begin{tabular}{p{1.5in}p{4.0in}}
        \textbf{#1} & #2 \\
        \end{tabular}
  }

\def\prop{\textsf{\,\,prop}}
\def\thm{\textsf{\,\,thm}}
\def\implies{\Rightarrow}

\title{Lecture Notes:\\
Dataflow Analysis Notation}
\author{17-654/17-754: Analysis of Software Artifacts \\
        Jonathan Aldrich ({\tt jonathan.aldrich@cs.cmu.edu})}
\date{Lectures 6-9}

\begin{document}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}

\maketitle


\newcommand{\join}{\sqcup}
% \alap for At Least As Precise
\newcommand{\alap}{\sqsubseteq}


\[
\begin{array}{ll}
\sigma & \mbox{Used to represent dataflow information (a lattice element)} \\[1ex]

[x {\mapsto} \textit{NZ}, y {\mapsto} Z] & \mbox{An element of a tuple lattice for zero analysis} \\
& \mbox{where the sub-lattice element for $x$ is \textit{NZ} and for $y$ is \textit{Z}}\\[1ex]

[x {\mapsto} \textit{NZ}] \sigma & \mbox{The tuple lattice that is the same as $\sigma$ except that $x$ is \textit{NZ}}\\[1ex]

\bot & \mbox{Bottom, the most precise element of a lattice.  Bottom is}\\
     & \mbox{assumed to be the initial dataflow value along back edges}\\[1ex]

\top & \mbox{Top, the least precise element of a lattice}\\[1ex]

\sigma_1 \alap \sigma_2 & \mbox{$\sigma_1$ is at least as precise as $\sigma_2$}\\[1ex]

\sigma_1 \sqsupseteq \sigma_2 & \mbox{$\sigma_1$ is at least as general as $\sigma_2$ (inverse of $\alap$)}\\[1ex]

\sigma_1 \join \sigma_2 & \mbox{The least upper bound (join) of $\sigma_1$ and $\sigma_2$}\\[1ex]

\iota & \mbox{The initial dataflow analysis information that is injected}\\
 & \mbox{at the beginning of a function (the end for backwards analyses)}\\[1ex]

\alpha_\textit{ZI}(n) & \mbox{The abstraction function for the integer zero sub-lattice}\\
& \mbox{Maps an integer to a lattice element}\\[1ex]

\alpha_\textit{ZA}(\eta) & \mbox{The abstraction function for the integer zero sub-lattice}\\
& \mbox{Maps a program state $\eta$ to a tuple lattice mapping}\\
& \mbox{each variable to an alement of the component lattice}\\[1ex]


\end{array}
\]

\[
\begin{array}{ll}

\{ ~i~ | ~0 \le i \le 5 \} & \mbox{Set comprehension notation: denotes the set of all integers $i$}\\
& \mbox{such that the condition $0 \le i \le 5$ is true}\\[1ex]

\emptyset & \mbox{The empty set}\\[1ex]

s_1 \cup s_2 & \mbox{The union of sets $s_1$ and $s_2$}\\[1ex]

s_1 \cap s_2 & \mbox{The intersection of sets $s_1$ and $s_2$}\\[1ex]

s_1 - s_2 & \mbox{The set difference of $s_1$ and $s_2$ (all elements in $s_1$ but not in $s_2$)}\\[1ex]

s_1 \subseteq s_2 & \mbox{$s_1$ is a subset of (or is equal to) $s_2$}\\[1ex]

\mathcal{P}^S & \mbox{The powerset (set of all subsets) of $S$}\\[1ex]

f_\textit{DF}^*(\sigma,\textit{exp}) & \mbox{Transitively applies the flow function $f_\textit{DF}$ to all subexpressions of \textit{exp}}\\[1ex]



\end{array}
\]

Below, we define the flow function $f_{\mbox{\tiny{ZA}}}(\sigma, [...]_k)$
for zero analysis (\textit{ZA}).  A flow function maps dataflow information
$\sigma$ from before a AST node $[...]_k$ to dataflow information afterwards.
We define the flow function by cases, as might be done using pattern matching
function definitions in the ML language.  Think of the pattern matching as
equivalent to an if statement testing whether the AST node matches
each piece of syntax in turn--and the right hand side is used to compute
the value of the flow function for the first syntax match.

To define separate cases for when a conditional evalutes the true and false cases, we just use tne notation $f_{\mbox{\tiny{ZA}}}^T$ and $f_{\mbox{\tiny{ZA}}}^F$.

\[
\begin{array}{l}

f_{\mbox{\tiny{ZA}}}(\sigma, [x]_k) = [t_k {\mapsto} \sigma(x)] ~\sigma\\[1ex]

f_{\mbox{\tiny{ZA}}}(\sigma, [n]_k) = \mbox{if $n=0$ then $[t_k {\mapsto} \textit{Z}] ~\sigma$ else $[t_k {\mapsto} \textit{NZ}] ~\sigma$}\\[1ex]

f_{\mbox{\tiny{ZA}}}(\sigma, [x := [...]_n]_k) =  [x {\mapsto} \sigma(t_n)] ~\sigma\\[1ex]

f_{\mbox{\tiny{ZA}}}^T(\sigma, [[x]_n = [0]_m]_k) = [x {\mapsto} Z]~ \sigma \\[1ex]

f_{\mbox{\tiny{ZA}}}^F(\sigma, [[x]_n = [0]_m]_k) = [x {\mapsto} \mbox{\textit{NZ}}]~ \sigma \\[1ex]

f_{\mbox{\tiny{ZA}}}(\sigma, [[...]_n \textit{op} [...]_m]_k ) =  [t_k {\mapsto} \textit{MZ}] ~\sigma\\[1ex]

f_{\mbox{\tiny{ZA}}}(\sigma, ...) = \sigma\\[1ex]

\end{array}
\]

\end{document}
