(*File: IMP.thy*) (*Authors: Lennart Beringer and Martin Hofmann, LMU Munich 2008*) theory IMP imports Main begin section‹The language IMP›
text‹\label{sec:IMP}In this section we define a simple imperative programming
. Syntax and operational semantics are as in cite‹"Winskel93"›,
that we enrich the language with a single unnamed,
procedure. Both, this section and the following one
set the basis for the development described in the later
and largely follow the approach to formalize program logics
by Kleymann, Nipkow, and others - see for example cite‹"KleymannPhD" and "Nipkow-CSL02" and "Nipkow-AFP-AHL"›.›
subsection‹Syntax›
text‹We start from unspecified categories of program variables and
.›
typedecl Var typedecl Val
text‹Arithmetic expressions are inductively built up from variables,
, and binary operators which are modeled as meta-logical
over values. Similarly, boolean expressions are built up
arithmetic expressions using binary boolean operators which are
as functions of the ambient logic HOL.›
datatype Expr =
varE Var
| valE Val
| opE "Val ==> Val ==> Val" Expr Expr
text‹Commands are the usual ones for an imperative language, plus the
$\mathit{Call}$ which stands for the invocation of a single
unnamed, parameterless) procedure.›
text‹The body of this procedure is identified by the following
.›
consts body :: IMP
subsection‹Dynamic semantics›
text‹States are given by stores - in our case, HOL functions
program variables to values.›
type_synonym State = "Var ==> Val"
definition update :: "State ==> Var ==> Val ==> State" where"update s x v = (λ y . if x=y then v else s y)"
text‹The evaluation of expressions is defined inductively, as
.›
primrec evalE::"Expr ==> State ==> Val" where "evalE (varE x) s = s x" | "evalE (valE v) s = v" | "evalE (opE f e1 e2) s = f (evalE e1 s) (evalE e2 s)"
primrec evalB::"BExpr ==> State ==> bool" where "evalB (compB f e1 e2) s = f (evalE e1 s) (evalE e2 s)"
text‹The operational semantics is a standard big-step relation, with
height index that facilitates the Kleymann-Nipkow-style~cite‹"KleymannPhD" and "Nipkow-CSL02"›
proof of the program logic.›
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.