Theory Chapter2_HoareHeap
theory Chapter2_HoareHeap
imports "AutoCorres2.AutoCorres"
begin
section ‹More Complex Functions with AutoCorres›
text ‹
In the previous section we saw how to use the C-Parser and AutoCorres
to prove properties about some very simple C programs.
Real life C programs tend to be far more complex however; they
read and write to local variables, have loops and use pointers to
access the heap. In this section we will look at some simple programs
which use loops and access the heap to show how AutoCorres can
allow such constructs to be reasoned about.
›
subsection ‹A simple loop: \texttt{mult\_by\_add}›
text ‹
Our C function \texttt{mult\_by\_add} implements a multiply operation
by successive additions:
\lstinputlisting[language=C, firstline=11]{mult_by_add.c}
We start by translating the program using the C parser and AutoCorres,
and entering the generated locale \texttt{mult\_by\_add}.
›