doc-src/Exercises/2002/a3/generated/a3.tex
author obua
Sun, 09 May 2004 23:04:36 +0200
changeset 14722 8e739a6eaf11
parent 13841 ed4e97874454
permissions -rw-r--r--
replaced apply-style proof for instance Multiset :: plus_ac0 by recommended Isar proof style
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13841
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     1
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     2
\begin{isabellebody}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     3
\def\isabellecontext{a{\isadigit{3}}}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     4
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     5
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     6
\isamarkupsubsection{Compilation%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     7
}
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     8
\isamarkuptrue%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     9
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    10
\begin{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    11
This exercise deals with the compiler example in section~3.3
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    12
of \cite{isabelle-tutorial}. The simple side effect free expressions
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    13
are extended with side effects.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    14
\begin{enumerate}
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    15
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    16
\item Read sections 3.3 and 8.2 of \cite{isabelle-tutorial}.  Study
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    17
the section about \isa{fun{\isacharunderscore}upd} in theory \isa{Fun} of HOL:
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    18
\isa{fun{\isacharunderscore}upd\ f\ x\ y}, written \isa{f{\isacharparenleft}x{\isacharcolon}{\isacharequal}y{\isacharparenright}}, is \isa{f}
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    19
updated at \isa{x} with new value \isa{y}.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    20
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    21
\item Extend data type \isa{{\isacharparenleft}{\isacharprime}a{\isacharcomma}\ {\isacharprime}v{\isacharparenright}\ expr} with a new alternative
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    22
\isa{Assign\ x\ e} that shall represent an assignment \isa{x\ {\isacharequal}\ e} of the value of the expression \isa{e} to the variable \isa{x}.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    23
The value of an assignment shall be the value of \isa{e}.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    24
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    25
\item Modify the evaluation function \isa{value} such that it can
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    26
deal with assignments. Note that since the evaluation of an expression
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    27
may now change the environment, it no longer suffices to return only
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    28
the value from the evaluation of an expression.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    29
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    30
Define a function \isa{se{\isacharunderscore}free\ {\isacharcolon}{\isacharcolon}\ expr\ {\isasymRightarrow}\ bool} that
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    31
identifies side effect free expressions. Show that \isa{se{\isacharunderscore}free\ e}
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    32
implies that evaluation of \isa{e} does not change the environment.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    33
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    34
\item Extend data type \isa{{\isacharparenleft}{\isacharprime}a{\isacharcomma}\ {\isacharprime}v{\isacharparenright}\ instr} with a new instruction
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    35
\isa{Store\ x} that stores the topmost element on the stack in
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    36
address/variable \isa{x}, without removing it from the stack.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    37
Update the machine semantics \isa{exec} accordingly. You will face
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    38
the same problem as in the extension of \isa{value}.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    39
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    40
\item Modify the compiler \isa{comp} and its correctness proof to
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    41
accommodate the above changes.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    42
\end{enumerate}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    43
\end{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    44
\isamarkuptrue%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    45
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    46
\end{isabellebody}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    47
%%% Local Variables:
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    48
%%% mode: latex
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    49
%%% TeX-master: "root"
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    50
%%% End: