doc-src/Codegen/Thy/document/Inductive_Predicate.tex
author bulwahn
Tue, 08 May 2012 14:31:03 +0200
changeset 47893 4cf901b1089a
parent 46523 7ca897381b26
permissions -rw-r--r--
specialised fact in the Record theory should not be appear in proofs discovered by sledgehammer
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
     1
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
     2
\begin{isabellebody}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
     3
\def\isabellecontext{Inductive{\isaliteral{5F}{\isacharunderscore}}Predicate}%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
     4
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
     5
\isadelimtheory
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
     6
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
     7
\endisadelimtheory
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
     8
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
     9
\isatagtheory
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    10
\isacommand{theory}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
    11
\ Inductive{\isaliteral{5F}{\isacharunderscore}}Predicate\isanewline
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    12
\isakeyword{imports}\ Setup\isanewline
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    13
\isakeyword{begin}\isanewline
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    14
%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    15
\endisatagtheory
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    16
{\isafoldtheory}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    17
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    18
\isadelimtheory
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    19
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    20
\endisadelimtheory
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    21
%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    22
\isadeliminvisible
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    23
%
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    24
\endisadeliminvisible
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    25
%
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    26
\isataginvisible
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    27
%
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    28
\endisataginvisible
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    29
{\isafoldinvisible}%
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    30
%
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    31
\isadeliminvisible
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    32
%
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    33
\endisadeliminvisible
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    34
%
38437
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    35
\isamarkupsection{Inductive Predicates \label{sec:inductive}%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    36
}
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    37
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    38
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    39
\begin{isamarkuptext}%
38509
9cea8a0e925a updated generated document
haftmann
parents: 38441
diff changeset
    40
The \isa{predicate\ compiler} is an extension of the code generator
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    41
  which turns inductive specifications into equational ones, from
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    42
  which in turn executable code can be generated.  The mechanisms of
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    43
  this compiler are described in detail in
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    44
  \cite{Berghofer-Bulwahn-Haftmann:2009:TPHOL}.
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    45
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    46
  Consider the simple predicate \isa{append} given by these two
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    47
  introduction rules:%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    48
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    49
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    50
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    51
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    52
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    53
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    54
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    55
\isatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    56
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    57
\begin{isamarkuptext}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
    58
\isa{append\ {\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{5D}{\isacharbrackright}}\ ys\ ys} \\
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
    59
  \isa{append\ xs\ ys\ zs\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ append\ {\isaliteral{28}{\isacharparenleft}}x\ {\isaliteral{23}{\isacharhash}}\ xs{\isaliteral{29}{\isacharparenright}}\ ys\ {\isaliteral{28}{\isacharparenleft}}x\ {\isaliteral{23}{\isacharhash}}\ zs{\isaliteral{29}{\isacharparenright}}}%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    60
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    61
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    62
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    63
\endisatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    64
{\isafoldquote}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    65
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    66
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    67
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    68
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    69
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    70
\begin{isamarkuptext}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
    71
\noindent To invoke the compiler, simply use \indexdef{}{command}{code\_pred}\hypertarget{command.code-pred}{\hyperlink{command.code-pred}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}pred}}}}}:%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    72
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    73
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    74
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    75
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    76
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    77
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    78
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    79
\isatagquote
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
    80
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}pred}\isamarkupfalse%
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
    81
\ append\ \isacommand{{\isaliteral{2E}{\isachardot}}}\isamarkupfalse%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    82
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    83
\endisatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    84
{\isafoldquote}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    85
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    86
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    87
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    88
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    89
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    90
\begin{isamarkuptext}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
    91
\noindent The \hyperlink{command.code-pred}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}pred}}}} command takes the name of the
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    92
  inductive predicate and then you put a period to discharge a trivial
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    93
  correctness proof.  The compiler infers possible modes for the
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    94
  predicate and produces the derived code equations.  Modes annotate
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    95
  which (parts of the) arguments are to be taken as input, and which
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    96
  output. Modes are similar to types, but use the notation \isa{i}
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    97
  for input and \isa{o} for output.
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
    98
 
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
    99
  For \isa{append}, the compiler can infer the following modes:
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   100
  \begin{itemize}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   101
    \item \isa{i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool}
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   102
    \item \isa{i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool}
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   103
    \item \isa{o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool}
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   104
  \end{itemize}
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   105
  You can compute sets of predicates using \indexdef{}{command}{values}\hypertarget{command.values}{\hyperlink{command.values}{\mbox{\isa{\isacommand{values}}}}}:%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   106
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   107
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   108
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   109
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   110
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   111
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   112
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   113
\isatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   114
\isacommand{values}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   115
\ {\isaliteral{22}{\isachardoublequoteopen}}{\isaliteral{7B}{\isacharbraceleft}}zs{\isaliteral{2E}{\isachardot}}\ append\ {\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{28}{\isacharparenleft}}{\isadigit{1}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}nat{\isaliteral{29}{\isacharparenright}}{\isaliteral{2C}{\isacharcomma}}{\isadigit{2}}{\isaliteral{2C}{\isacharcomma}}{\isadigit{3}}{\isaliteral{5D}{\isacharbrackright}}\ {\isaliteral{5B}{\isacharbrackleft}}{\isadigit{4}}{\isaliteral{2C}{\isacharcomma}}{\isadigit{5}}{\isaliteral{5D}{\isacharbrackright}}\ zs{\isaliteral{7D}{\isacharbraceright}}{\isaliteral{22}{\isachardoublequoteclose}}%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   116
\endisatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   117
{\isafoldquote}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   118
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   119
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   120
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   121
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   122
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   123
\begin{isamarkuptext}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   124
\noindent outputs \isa{{\isaliteral{7B}{\isacharbraceleft}}{\isaliteral{5B}{\isacharbrackleft}}{\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isadigit{2}}{\isaliteral{2C}{\isacharcomma}}\ {\isadigit{3}}{\isaliteral{2C}{\isacharcomma}}\ {\isadigit{4}}{\isaliteral{2C}{\isacharcomma}}\ {\isadigit{5}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{7D}{\isacharbraceright}}}, and%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   125
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   126
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   127
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   128
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   129
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   130
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   131
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   132
\isatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   133
\isacommand{values}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   134
\ {\isaliteral{22}{\isachardoublequoteopen}}{\isaliteral{7B}{\isacharbraceleft}}{\isaliteral{28}{\isacharparenleft}}xs{\isaliteral{2C}{\isacharcomma}}\ ys{\isaliteral{29}{\isacharparenright}}{\isaliteral{2E}{\isachardot}}\ append\ xs\ ys\ {\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{28}{\isacharparenleft}}{\isadigit{2}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}nat{\isaliteral{29}{\isacharparenright}}{\isaliteral{2C}{\isacharcomma}}{\isadigit{3}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{7D}{\isacharbraceright}}{\isaliteral{22}{\isachardoublequoteclose}}%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   135
\endisatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   136
{\isafoldquote}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   137
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   138
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   139
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   140
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   141
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   142
\begin{isamarkuptext}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   143
\noindent outputs \isa{{\isaliteral{7B}{\isacharbraceleft}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5B}{\isacharbrackleft}}{\isadigit{2}}{\isaliteral{2C}{\isacharcomma}}\ {\isadigit{3}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{29}{\isacharparenright}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{5B}{\isacharbrackleft}}{\isadigit{2}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5B}{\isacharbrackleft}}{\isadigit{3}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{29}{\isacharparenright}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{5B}{\isacharbrackleft}}{\isadigit{2}}{\isaliteral{2C}{\isacharcomma}}\ {\isadigit{3}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{29}{\isacharparenright}}{\isaliteral{7D}{\isacharbraceright}}}.%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   144
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   145
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   146
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   147
\begin{isamarkuptext}%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   148
\noindent If you are only interested in the first elements of the
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   149
  set comprehension (with respect to a depth-first search on the
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   150
  introduction rules), you can pass an argument to \hyperlink{command.values}{\mbox{\isa{\isacommand{values}}}}
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   151
  to specify the number of elements you want:%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   152
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   153
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   154
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   155
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   156
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   157
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   158
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   159
\isatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   160
\isacommand{values}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   161
\ {\isadigit{1}}\ {\isaliteral{22}{\isachardoublequoteopen}}{\isaliteral{7B}{\isacharbraceleft}}{\isaliteral{28}{\isacharparenleft}}xs{\isaliteral{2C}{\isacharcomma}}\ ys{\isaliteral{29}{\isacharparenright}}{\isaliteral{2E}{\isachardot}}\ append\ xs\ ys\ {\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{28}{\isacharparenleft}}{\isadigit{1}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}nat{\isaliteral{29}{\isacharparenright}}{\isaliteral{2C}{\isacharcomma}}\ {\isadigit{2}}{\isaliteral{2C}{\isacharcomma}}\ {\isadigit{3}}{\isaliteral{2C}{\isacharcomma}}\ {\isadigit{4}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{7D}{\isacharbraceright}}{\isaliteral{22}{\isachardoublequoteclose}}\isanewline
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   162
\isacommand{values}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   163
\ {\isadigit{3}}\ {\isaliteral{22}{\isachardoublequoteopen}}{\isaliteral{7B}{\isacharbraceleft}}{\isaliteral{28}{\isacharparenleft}}xs{\isaliteral{2C}{\isacharcomma}}\ ys{\isaliteral{29}{\isacharparenright}}{\isaliteral{2E}{\isachardot}}\ append\ xs\ ys\ {\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{28}{\isacharparenleft}}{\isadigit{1}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}nat{\isaliteral{29}{\isacharparenright}}{\isaliteral{2C}{\isacharcomma}}\ {\isadigit{2}}{\isaliteral{2C}{\isacharcomma}}\ {\isadigit{3}}{\isaliteral{2C}{\isacharcomma}}\ {\isadigit{4}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{7D}{\isacharbraceright}}{\isaliteral{22}{\isachardoublequoteclose}}%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   164
\endisatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   165
{\isafoldquote}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   166
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   167
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   168
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   169
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   170
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   171
\begin{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   172
\noindent The \hyperlink{command.values}{\mbox{\isa{\isacommand{values}}}} command can only compute set
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   173
  comprehensions for which a mode has been inferred.
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   174
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   175
  The code equations for a predicate are made available as theorems with
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   176
  the suffix \isa{equation}, and can be inspected with:%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   177
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   178
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   179
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   180
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   181
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   182
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   183
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   184
\isatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   185
\isacommand{thm}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   186
\ append{\isaliteral{2E}{\isachardot}}equation%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   187
\endisatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   188
{\isafoldquote}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   189
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   190
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   191
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   192
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   193
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   194
\begin{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   195
\noindent More advanced options are described in the following subsections.%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   196
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   197
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   198
%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   199
\isamarkupsubsection{Alternative names for functions%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   200
}
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   201
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   202
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   203
\begin{isamarkuptext}%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   204
By default, the functions generated from a predicate are named after
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   205
  the predicate with the mode mangled into the name (e.g., \isa{append{\isaliteral{5F}{\isacharunderscore}}i{\isaliteral{5F}{\isacharunderscore}}i{\isaliteral{5F}{\isacharunderscore}}o}).  You can specify your own names as follows:%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   206
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   207
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   208
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   209
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   210
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   211
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   212
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   213
\isatagquote
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   214
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}pred}\isamarkupfalse%
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   215
\ {\isaliteral{28}{\isacharparenleft}}modes{\isaliteral{3A}{\isacharcolon}}\ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool\ as\ concat{\isaliteral{2C}{\isacharcomma}}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   216
\ \ o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool\ as\ split{\isaliteral{2C}{\isacharcomma}}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   217
\ \ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool\ as\ suffix{\isaliteral{29}{\isacharparenright}}\ append\ \isacommand{{\isaliteral{2E}{\isachardot}}}\isamarkupfalse%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   218
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   219
\endisatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   220
{\isafoldquote}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   221
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   222
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   223
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   224
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   225
%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   226
\isamarkupsubsection{Alternative introduction rules%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   227
}
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   228
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   229
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   230
\begin{isamarkuptext}%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   231
Sometimes the introduction rules of an predicate are not executable
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   232
  because they contain non-executable constants or specific modes
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   233
  could not be inferred.  It is also possible that the introduction
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   234
  rules yield a function that loops forever due to the execution in a
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   235
  depth-first search manner.  Therefore, you can declare alternative
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   236
  introduction rules for predicates with the attribute \hyperlink{attribute.code-pred-intro}{\mbox{\isa{code{\isaliteral{5F}{\isacharunderscore}}pred{\isaliteral{5F}{\isacharunderscore}}intro}}}.  For example, the transitive closure is defined
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   237
  by:%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   238
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   239
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   240
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   241
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   242
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   243
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   244
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   245
\isatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   246
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   247
\begin{isamarkuptext}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   248
\isa{{\isaliteral{22}{\isachardoublequote}}r\ a\ b\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ tranclp\ r\ a\ b{\isaliteral{22}{\isachardoublequote}}}\\
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   249
  \isa{{\isaliteral{22}{\isachardoublequote}}tranclp\ r\ a\ b\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ r\ b\ c\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ tranclp\ r\ a\ c{\isaliteral{22}{\isachardoublequote}}}%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   250
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   251
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   252
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   253
\endisatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   254
{\isafoldquote}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   255
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   256
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   257
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   258
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   259
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   260
\begin{isamarkuptext}%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   261
\noindent These rules do not suit well for executing the transitive
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   262
  closure with the mode \isa{{\isaliteral{28}{\isacharparenleft}}i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool}, as
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   263
  the second rule will cause an infinite loop in the recursive call.
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   264
  This can be avoided using the following alternative rules which are
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   265
  declared to the predicate compiler by the attribute \hyperlink{attribute.code-pred-intro}{\mbox{\isa{code{\isaliteral{5F}{\isacharunderscore}}pred{\isaliteral{5F}{\isacharunderscore}}intro}}}:%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   266
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   267
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   268
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   269
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   270
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   271
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   272
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   273
\isatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   274
\isacommand{lemma}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   275
\ {\isaliteral{5B}{\isacharbrackleft}}code{\isaliteral{5F}{\isacharunderscore}}pred{\isaliteral{5F}{\isacharunderscore}}intro{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{3A}{\isacharcolon}}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   276
\ \ {\isaliteral{22}{\isachardoublequoteopen}}r\ a\ b\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ tranclp\ r\ a\ b{\isaliteral{22}{\isachardoublequoteclose}}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   277
\ \ {\isaliteral{22}{\isachardoublequoteopen}}r\ a\ b\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ tranclp\ r\ b\ c\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ tranclp\ r\ a\ c{\isaliteral{22}{\isachardoublequoteclose}}\isanewline
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   278
\isacommand{by}\isamarkupfalse%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   279
\ auto%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   280
\endisatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   281
{\isafoldquote}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   282
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   283
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   284
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   285
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   286
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   287
\begin{isamarkuptext}%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   288
\noindent After declaring all alternative rules for the transitive
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   289
  closure, you invoke \hyperlink{command.code-pred}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}pred}}}} as usual.  As you have
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   290
  declared alternative rules for the predicate, you are urged to prove
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   291
  that these introduction rules are complete, i.e., that you can
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   292
  derive an elimination rule for the alternative rules:%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   293
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   294
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   295
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   296
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   297
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   298
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   299
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   300
\isatagquote
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   301
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}pred}\isamarkupfalse%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   302
\ tranclp\isanewline
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   303
\isacommand{proof}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   304
\ {\isaliteral{2D}{\isacharminus}}\isanewline
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   305
\ \ \isacommand{case}\isamarkupfalse%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   306
\ tranclp\isanewline
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   307
\ \ \isacommand{from}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   308
\ this\ converse{\isaliteral{5F}{\isacharunderscore}}tranclpE\ {\isaliteral{5B}{\isacharbrackleft}}OF\ tranclp{\isaliteral{2E}{\isachardot}}prems{\isaliteral{5D}{\isacharbrackright}}\ \isacommand{show}\isamarkupfalse%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   309
\ thesis\ \isacommand{by}\isamarkupfalse%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   310
\ metis\isanewline
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   311
\isacommand{qed}\isamarkupfalse%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   312
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   313
\endisatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   314
{\isafoldquote}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   315
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   316
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   317
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   318
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   319
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   320
\begin{isamarkuptext}%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   321
\noindent Alternative rules can also be used for constants that have
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   322
  not been defined inductively. For example, the lexicographic order
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   323
  which is defined as:%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   324
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   325
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   326
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   327
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   328
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   329
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   330
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   331
\isatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   332
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   333
\begin{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   334
\begin{isabelle}%
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   335
lexordp\ r\ {\isaliteral{3F}{\isacharquery}}xs\ {\isaliteral{3F}{\isacharquery}}ys\ {\isaliteral{5C3C6C6F6E676C65667472696768746172726F773E}{\isasymlongleftrightarrow}}\isanewline
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   336
{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C6578697374733E}{\isasymexists}}a\ v{\isaliteral{2E}{\isachardot}}\ {\isaliteral{3F}{\isacharquery}}ys\ {\isaliteral{3D}{\isacharequal}}\ {\isaliteral{3F}{\isacharquery}}xs\ {\isaliteral{40}{\isacharat}}\ a\ {\isaliteral{23}{\isacharhash}}\ v\ {\isaliteral{5C3C6F723E}{\isasymor}}\isanewline
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   337
\isaindent{{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C6578697374733E}{\isasymexists}}a\ v{\isaliteral{2E}{\isachardot}}\ }{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C6578697374733E}{\isasymexists}}u\ a\ b\ v\ w{\isaliteral{2E}{\isachardot}}\ r\ a\ b\ {\isaliteral{5C3C616E643E}{\isasymand}}\ {\isaliteral{3F}{\isacharquery}}xs\ {\isaliteral{3D}{\isacharequal}}\ u\ {\isaliteral{40}{\isacharat}}\ a\ {\isaliteral{23}{\isacharhash}}\ v\ {\isaliteral{5C3C616E643E}{\isasymand}}\ {\isaliteral{3F}{\isacharquery}}ys\ {\isaliteral{3D}{\isacharequal}}\ u\ {\isaliteral{40}{\isacharat}}\ b\ {\isaliteral{23}{\isacharhash}}\ w{\isaliteral{29}{\isacharparenright}}{\isaliteral{29}{\isacharparenright}}%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   338
\end{isabelle}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   339
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   340
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   341
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   342
\endisatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   343
{\isafoldquote}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   344
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   345
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   346
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   347
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   348
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   349
\begin{isamarkuptext}%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   350
\noindent To make it executable, you can derive the following two
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   351
  rules and prove the elimination rule:%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   352
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   353
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   354
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   355
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   356
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   357
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   358
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   359
\isatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   360
\isacommand{lemma}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   361
\ {\isaliteral{5B}{\isacharbrackleft}}code{\isaliteral{5F}{\isacharunderscore}}pred{\isaliteral{5F}{\isacharunderscore}}intro{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{3A}{\isacharcolon}}\isanewline
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   362
\ \ {\isaliteral{22}{\isachardoublequoteopen}}append\ xs\ {\isaliteral{28}{\isacharparenleft}}a\ {\isaliteral{23}{\isacharhash}}\ v{\isaliteral{29}{\isacharparenright}}\ ys\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ lexordp\ r\ xs\ ys{\isaliteral{22}{\isachardoublequoteclose}}\isanewline
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   363
\isacommand{lemma}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   364
\ {\isaliteral{5B}{\isacharbrackleft}}code{\isaliteral{5F}{\isacharunderscore}}pred{\isaliteral{5F}{\isacharunderscore}}intro{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{3A}{\isacharcolon}}\isanewline
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   365
\ \ {\isaliteral{22}{\isachardoublequoteopen}}append\ u\ {\isaliteral{28}{\isacharparenleft}}a\ {\isaliteral{23}{\isacharhash}}\ v{\isaliteral{29}{\isacharparenright}}\ xs\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ append\ u\ {\isaliteral{28}{\isacharparenleft}}b\ {\isaliteral{23}{\isacharhash}}\ w{\isaliteral{29}{\isacharparenright}}\ ys\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ r\ a\ b\isanewline
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   366
\ \ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ lexordp\ r\ xs\ ys{\isaliteral{22}{\isachardoublequoteclose}}\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   367
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}pred}\isamarkupfalse%
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   368
\ lexordp%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   369
\endisatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   370
{\isafoldquote}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   371
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   372
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   373
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   374
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   375
%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   376
\isamarkupsubsection{Options for values%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   377
}
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   378
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   379
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   380
\begin{isamarkuptext}%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   381
In the presence of higher-order predicates, multiple modes for some
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   382
  predicate could be inferred that are not disambiguated by the
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   383
  pattern of the set comprehension.  To disambiguate the modes for the
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   384
  arguments of a predicate, you can state the modes explicitly in the
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   385
  \hyperlink{command.values}{\mbox{\isa{\isacommand{values}}}} command.  Consider the simple predicate \isa{succ}:%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   386
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   387
\isamarkuptrue%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   388
%
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   389
\isadelimquote
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   390
%
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   391
\endisadelimquote
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   392
%
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   393
\isatagquote
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   394
\isacommand{inductive}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   395
\ succ\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{22}{\isachardoublequoteopen}}nat\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ nat\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool{\isaliteral{22}{\isachardoublequoteclose}}\ \isakeyword{where}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   396
\ \ {\isaliteral{22}{\isachardoublequoteopen}}succ\ {\isadigit{0}}\ {\isaliteral{28}{\isacharparenleft}}Suc\ {\isadigit{0}}{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequoteclose}}\isanewline
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   397
{\isaliteral{7C}{\isacharbar}}\ {\isaliteral{22}{\isachardoublequoteopen}}succ\ x\ y\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ succ\ {\isaliteral{28}{\isacharparenleft}}Suc\ x{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{28}{\isacharparenleft}}Suc\ y{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequoteclose}}\isanewline
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   398
\isanewline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   399
\isacommand{code{\isaliteral{5F}{\isacharunderscore}}pred}\isamarkupfalse%
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   400
\ succ\ \isacommand{{\isaliteral{2E}{\isachardot}}}\isamarkupfalse%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   401
%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   402
\endisatagquote
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   403
{\isafoldquote}%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   404
%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   405
\isadelimquote
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   406
%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   407
\endisadelimquote
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   408
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   409
\begin{isamarkuptext}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   410
\noindent For this, the predicate compiler can infer modes \isa{o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool}, \isa{i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool}, \isa{o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool} and
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   411
  \isa{i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool}.  The invocation of \hyperlink{command.values}{\mbox{\isa{\isacommand{values}}}}
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   412
  \isa{{\isaliteral{7B}{\isacharbraceleft}}n{\isaliteral{2E}{\isachardot}}\ tranclp\ succ\ {\isadigit{1}}{\isadigit{0}}\ n{\isaliteral{7D}{\isacharbraceright}}} loops, as multiple modes for the
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   413
  predicate \isa{succ} are possible and here the first mode \isa{o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool} is chosen. To choose another mode for the argument,
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   414
  you can declare the mode for the argument between the \hyperlink{command.values}{\mbox{\isa{\isacommand{values}}}} and the number of elements.%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   415
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   416
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   417
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   418
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   419
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   420
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   421
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   422
\isatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   423
\isacommand{values}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   424
\ {\isaliteral{5B}{\isacharbrackleft}}mode{\isaliteral{3A}{\isacharcolon}}\ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool{\isaliteral{5D}{\isacharbrackright}}\ {\isadigit{1}}\ {\isaliteral{22}{\isachardoublequoteopen}}{\isaliteral{7B}{\isacharbraceleft}}n{\isaliteral{2E}{\isachardot}}\ tranclp\ succ\ {\isadigit{1}}{\isadigit{0}}\ n{\isaliteral{7D}{\isacharbraceright}}{\isaliteral{22}{\isachardoublequoteclose}}\ \isanewline
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   425
\isacommand{values}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   426
\ {\isaliteral{5B}{\isacharbrackleft}}mode{\isaliteral{3A}{\isacharcolon}}\ o\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool{\isaliteral{5D}{\isacharbrackright}}\ {\isadigit{1}}\ {\isaliteral{22}{\isachardoublequoteopen}}{\isaliteral{7B}{\isacharbraceleft}}n{\isaliteral{2E}{\isachardot}}\ tranclp\ succ\ n\ {\isadigit{1}}{\isadigit{0}}{\isaliteral{7D}{\isacharbraceright}}{\isaliteral{22}{\isachardoublequoteclose}}%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   427
\endisatagquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   428
{\isafoldquote}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   429
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   430
\isadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   431
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   432
\endisadelimquote
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   433
%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   434
\isamarkupsubsection{Embedding into functional code within Isabelle/HOL%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   435
}
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   436
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   437
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   438
\begin{isamarkuptext}%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   439
To embed the computation of an inductive predicate into functions
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   440
  that are defined in Isabelle/HOL, you have a number of options:
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   442
  \begin{itemize}
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   443
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   444
    \item You want to use the first-order predicate with the mode
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   445
      where all arguments are input. Then you can use the predicate directly, e.g.
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   446
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   447
      \begin{quote}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   448
        \isa{valid{\isaliteral{5F}{\isacharunderscore}}suffix\ ys\ zs\ {\isaliteral{3D}{\isacharequal}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   449
        \isa{{\isaliteral{28}{\isacharparenleft}}if\ append\ {\isaliteral{5B}{\isacharbrackleft}}Suc\ {\isadigit{0}}{\isaliteral{2C}{\isacharcomma}}\ {\isadigit{2}}{\isaliteral{5D}{\isacharbrackright}}\ ys\ zs\ then\ Some\ ys\ else\ None{\isaliteral{29}{\isacharparenright}}}
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   450
      \end{quote}
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   451
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   452
    \item If you know that the execution returns only one value (it is
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   453
      deterministic), then you can use the combinator \isa{Predicate{\isaliteral{2E}{\isachardot}}the}, e.g., a functional concatenation of lists is
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   454
      defined with
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   455
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   456
      \begin{quote}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   457
        \isa{functional{\isaliteral{5F}{\isacharunderscore}}concat\ xs\ ys\ {\isaliteral{3D}{\isacharequal}}\ Predicate{\isaliteral{2E}{\isachardot}}the\ {\isaliteral{28}{\isacharparenleft}}append{\isaliteral{5F}{\isacharunderscore}}i{\isaliteral{5F}{\isacharunderscore}}i{\isaliteral{5F}{\isacharunderscore}}o\ xs\ ys{\isaliteral{29}{\isacharparenright}}}
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   458
      \end{quote}
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   459
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   460
      Note that if the evaluation does not return a unique value, it
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   461
      raises a run-time error \isa{not{\isaliteral{5F}{\isacharunderscore}}unique}.
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   462
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   463
  \end{itemize}%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   464
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   465
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   466
%
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   467
\isamarkupsubsection{Further Examples%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   468
}
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   469
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   470
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   471
\begin{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   472
Further examples for compiling inductive predicates can be found in
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   473
  the \isa{HOL{\isaliteral{2F}{\isacharslash}}ex{\isaliteral{2F}{\isacharslash}}Predicate{\isaliteral{5F}{\isacharunderscore}}Compile{\isaliteral{5F}{\isacharunderscore}}ex{\isaliteral{2E}{\isachardot}}thy} theory file.  There are
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   474
  also some examples in the Archive of Formal Proofs, notably in the
40406
313a24b66a8d updated generated files;
wenzelm
parents: 39682
diff changeset
   475
  \isa{POPLmark{\isaliteral{2D}{\isacharminus}}deBruijn} and the \isa{FeatherweightJava}
38441
2fffd5ac487f tuned section on predicate compiler
haftmann
parents: 38437
diff changeset
   476
  sessions.%
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   477
\end{isamarkuptext}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   478
\isamarkuptrue%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   479
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   480
\isadelimtheory
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   481
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   482
\endisadelimtheory
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   483
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   484
\isatagtheory
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   485
\isacommand{end}\isamarkupfalse%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   486
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   487
\endisatagtheory
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   488
{\isafoldtheory}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   489
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   490
\isadelimtheory
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   491
%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   492
\endisadelimtheory
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   493
\isanewline
46523
7ca897381b26 update of generated documents
haftmann
parents: 40406
diff changeset
   494
\isanewline
37614
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   495
\end{isabellebody}%
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   496
%%% Local Variables:
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   497
%%% mode: latex
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   498
%%% TeX-master: "root"
d804c8b9c2dc split off predicate compiler into separate theory
haftmann
parents:
diff changeset
   499
%%% End: