Theory First_Example
chapter ‹First Example›
theory %invisible First_Example
imports Main
begin
text ‹\label{chap:exampleI}›
text ‹Pop-refinement is illustrated via a simple derivation,
in Isabelle/HOL,
of a program that includes non-functional aspects.›
section ‹Target Programming Language›
text ‹\label{sec:targetI}›
text ‹In the target language used in this example,
a program consists of
a list of distinct variables (the parameters of the program)
and an arithmetic expression (the body of the program).
The body is built out of
parameters,
non-negative integer constants,
addition operations,
and doubling (i.e.\ multiplication by 2) operations.
The program is executed
by supplying non-negative integers to the parameters
and evaluating the body to obtain a non-negative integer result.›
text ‹For instance, executing the program
\begin{verbatim}
prog (a,b) {3 + 2 * (a + b)}
\end{verbatim}
with 5 and 7 supplied to \verb|a| and \verb|b| yields 27.
The syntax and semantics of this language are formalized as follows.›
subsection ‹Syntax›
text ‹\label{sec:syntaxI}›
text ‹Variables are identified by names.›
type_synonym name = string
text ‹Expressions are built out of
constants, variables, doubling operations, and addition operations.›