\documentclass[11pt,twoside]{scrartcl}
%opening
\newcommand{\lecid}{15-414}
\newcommand{\leccourse}{Bug Catching: Automated Program Verification}
\newcommand{\lecdate}{} %e.g. {October 21, 2013}
\newcommand{\lecnum}{8}
\newcommand{\lectitle}{Arrays with Updates}
\newcommand{\lecturer}{Matt Fredrikson}
\usepackage{lecnotes}
\usepackage[irlabel]{bugcatch}
\usepackage{xcolor}
\usepackage{listings}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{backgray}{gray}{0.95}
\lstdefinestyle{customjava}{
belowcaptionskip=1\baselineskip,
breaklines=true,
language=Java,
showstringspaces=false,
numbers=left,
xleftmargin=2em,
framexleftmargin=1.5em,
numbersep=5pt,
numberstyle=\tiny\color{mygray},
basicstyle=\footnotesize\ttfamily,
keywordstyle=\color{blue},
commentstyle=\itshape\color{purple!40!black},
tabsize=2,
backgroundcolor=\color{backgray},
escapechar=\%
}
\begin{document}
\maketitle
\thispagestyle{empty}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}
In the previous lecture, we introduced arrays into the language. We modeled arrays as functions, and updated the semantics of terms to account for their behavior. We got plenty of practice using array terms in a proof, as we verified the functionality of the familiar binary search routine. Through a fairly lengthy derivation, we arrived at a suitable loop invariant, and proved its correctness.
This entire discussion was missing something crucial about arrays, namely that they can be updated as the program executes and subsequently read. In this lecture, we will continue defining the semantics of arrays, focusing on updates. We will introduce a notion of function updating that we will use to model array updates, and see that this allows us to avoid the tricky matter of aliasing to some extent. We will then introduce axioms to help us reason about programs that update arrays, and gain some further experience using the axioms on a non-trivial program.
%%%%%%%%%%%%%%%%%%%%
\section{Recall: Arrays as Functions}
Last lecture we introduced arrays into our language. Syntactically, this was not a huge change, and involved adding a new term for array lookup, as well as a new statement form for array assignment. However, in order to distinguish between variables that store constant values and those that store arrays, we need to assume that all variable symbols are already defined for either arrays or variables. Importantly, this means that there are new sorts of ill-formed terms, for example if $x$ is a variable symbol then $x(1)$ is not a valid term. Similarly, array symbols can only appear in indexed lookup terms, so if $a$ is an array symbol then $a$, $a+a$, $a