| 
9722
 | 
     1  | 
%
  | 
| 
 | 
     2  | 
\begin{isabellebody}%
 | 
| 
10267
 | 
     3  | 
\def\isabellecontext{Nested{\isadigit{0}}}%
 | 
| 
17056
 | 
     4  | 
%
  | 
| 
 | 
     5  | 
\isadelimtheory
  | 
| 
 | 
     6  | 
%
  | 
| 
 | 
     7  | 
\endisadelimtheory
  | 
| 
 | 
     8  | 
%
  | 
| 
 | 
     9  | 
\isatagtheory
  | 
| 
 | 
    10  | 
%
  | 
| 
 | 
    11  | 
\endisatagtheory
  | 
| 
 | 
    12  | 
{\isafoldtheory}%
 | 
| 
 | 
    13  | 
%
  | 
| 
 | 
    14  | 
\isadelimtheory
  | 
| 
 | 
    15  | 
%
  | 
| 
 | 
    16  | 
\endisadelimtheory
  | 
| 
9698
 | 
    17  | 
%
  | 
| 
 | 
    18  | 
\begin{isamarkuptext}%
 | 
| 
11494
 | 
    19  | 
\index{datatypes!nested}%
 | 
| 
9698
 | 
    20  | 
In \S\ref{sec:nested-datatype} we defined the datatype of terms%
 | 
| 
 | 
    21  | 
\end{isamarkuptext}%
 | 
| 
17175
 | 
    22  | 
\isamarkuptrue%
  | 
| 
 | 
    23  | 
\isacommand{datatype}\isamarkupfalse%
 | 
| 
 | 
    24  | 
\ {\isacharparenleft}{\isacharprime}a{\isacharcomma}{\isacharprime}b{\isacharparenright}{\isachardoublequoteopen}term{\isachardoublequoteclose}\ {\isacharequal}\ Var\ {\isacharprime}a\ {\isacharbar}\ App\ {\isacharprime}b\ {\isachardoublequoteopen}{\isacharparenleft}{\isacharprime}a{\isacharcomma}{\isacharprime}b{\isacharparenright}term\ list{\isachardoublequoteclose}%
 | 
| 
9698
 | 
    25  | 
\begin{isamarkuptext}%
 | 
| 
 | 
    26  | 
\noindent
  | 
| 
 | 
    27  | 
and closed with the observation that the associated schema for the definition
  | 
| 
 | 
    28  | 
of primitive recursive functions leads to overly verbose definitions. Moreover,
  | 
| 
 | 
    29  | 
if you have worked exercise~\ref{ex:trev-trev} you will have noticed that
 | 
| 
10878
 | 
    30  | 
you needed to declare essentially the same function as \isa{rev}
 | 
| 
11196
 | 
    31  | 
and prove many standard properties of list reversal all over again. 
  | 
| 
10878
 | 
    32  | 
We will now show you how \isacommand{recdef} can simplify
 | 
| 
9698
 | 
    33  | 
definitions and proofs about nested recursive datatypes. As an example we
  | 
| 
9754
 | 
    34  | 
choose exercise~\ref{ex:trev-trev}:%
 | 
| 
9698
 | 
    35  | 
\end{isamarkuptext}%
 | 
| 
17175
 | 
    36  | 
\isamarkuptrue%
  | 
| 
 | 
    37  | 
\isacommand{consts}\isamarkupfalse%
 | 
| 
 | 
    38  | 
\ trev\ \ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharparenleft}{\isacharprime}a{\isacharcomma}{\isacharprime}b{\isacharparenright}term\ {\isasymRightarrow}\ {\isacharparenleft}{\isacharprime}a{\isacharcomma}{\isacharprime}b{\isacharparenright}term{\isachardoublequoteclose}%
 | 
| 
17056
 | 
    39  | 
\isadelimtheory
  | 
| 
 | 
    40  | 
%
  | 
| 
 | 
    41  | 
\endisadelimtheory
  | 
| 
 | 
    42  | 
%
  | 
| 
 | 
    43  | 
\isatagtheory
  | 
| 
 | 
    44  | 
%
  | 
| 
 | 
    45  | 
\endisatagtheory
  | 
| 
 | 
    46  | 
{\isafoldtheory}%
 | 
| 
 | 
    47  | 
%
  | 
| 
 | 
    48  | 
\isadelimtheory
  | 
| 
 | 
    49  | 
%
  | 
| 
 | 
    50  | 
\endisadelimtheory
  | 
| 
11866
 | 
    51  | 
\end{isabellebody}%
 | 
| 
9698
 | 
    52  | 
%%% Local Variables:
  | 
| 
 | 
    53  | 
%%% mode: latex
  | 
| 
 | 
    54  | 
%%% TeX-master: "root"
  | 
| 
 | 
    55  | 
%%% End:
  |