doc-src/IsarRef/Thy/document/HOL_Specific.tex
author wenzelm
Mon, 02 May 2011 01:05:50 +0200
changeset 43467 6c621a9d612a
parent 43082 de9d43c427ae
child 43488 77d239840285
permissions -rw-r--r--
modernized rail diagrams using @{rail} antiquotation;
wenzelm@26840
     1
%
wenzelm@26840
     2
\begin{isabellebody}%
wenzelm@40685
     3
\def\isabellecontext{HOL{\isaliteral{5F}{\isacharunderscore}}Specific}%
wenzelm@26840
     4
%
wenzelm@26840
     5
\isadelimtheory
wenzelm@26840
     6
%
wenzelm@26840
     7
\endisadelimtheory
wenzelm@26840
     8
%
wenzelm@26840
     9
\isatagtheory
wenzelm@26840
    10
\isacommand{theory}\isamarkupfalse%
wenzelm@40685
    11
\ HOL{\isaliteral{5F}{\isacharunderscore}}Specific\isanewline
wenzelm@26849
    12
\isakeyword{imports}\ Main\isanewline
wenzelm@26849
    13
\isakeyword{begin}%
wenzelm@26849
    14
\endisatagtheory
wenzelm@26849
    15
{\isafoldtheory}%
wenzelm@26849
    16
%
wenzelm@26849
    17
\isadelimtheory
wenzelm@26849
    18
%
wenzelm@26849
    19
\endisadelimtheory
wenzelm@26849
    20
%
wenzelm@26852
    21
\isamarkupchapter{Isabelle/HOL \label{ch:hol}%
wenzelm@26849
    22
}
wenzelm@26849
    23
\isamarkuptrue%
wenzelm@26849
    24
%
wenzelm@35757
    25
\isamarkupsection{Typedef axiomatization \label{sec:hol-typedef}%
wenzelm@26849
    26
}
wenzelm@26849
    27
\isamarkuptrue%
wenzelm@26849
    28
%
wenzelm@26849
    29
\begin{isamarkuptext}%
wenzelm@26849
    30
\begin{matharray}{rcl}
wenzelm@40685
    31
    \indexdef{HOL}{command}{typedef}\hypertarget{command.HOL.typedef}{\hyperlink{command.HOL.typedef}{\mbox{\isa{\isacommand{typedef}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ proof{\isaliteral{28}{\isacharparenleft}}prove{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@26849
    32
  \end{matharray}
wenzelm@26849
    33
wenzelm@43467
    34
  \begin{railoutput}
wenzelm@43467
    35
\rail@begin{2}{\isa{}}
wenzelm@43467
    36
\rail@term{\hyperlink{command.HOL.typedef}{\mbox{\isa{\isacommand{typedef}}}}}[]
wenzelm@43467
    37
\rail@bar
wenzelm@43467
    38
\rail@nextbar{1}
wenzelm@43467
    39
\rail@nont{\isa{altname}}[]
wenzelm@43467
    40
\rail@endbar
wenzelm@43467
    41
\rail@nont{\isa{abstype}}[]
wenzelm@43467
    42
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43467
    43
\rail@nont{\isa{repset}}[]
wenzelm@43467
    44
\rail@end
wenzelm@43467
    45
\rail@begin{3}{\isa{altname}}
wenzelm@43467
    46
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
    47
\rail@bar
wenzelm@43467
    48
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
    49
\rail@nextbar{1}
wenzelm@43467
    50
\rail@term{\isa{\isakeyword{open}}}[]
wenzelm@43467
    51
\rail@nextbar{2}
wenzelm@43467
    52
\rail@term{\isa{\isakeyword{open}}}[]
wenzelm@43467
    53
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
    54
\rail@endbar
wenzelm@43467
    55
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
    56
\rail@end
wenzelm@43467
    57
\rail@begin{2}{\isa{abstype}}
wenzelm@43467
    58
\rail@nont{\hyperlink{syntax.typespecsorts}{\mbox{\isa{typespecsorts}}}}[]
wenzelm@43467
    59
\rail@bar
wenzelm@43467
    60
\rail@nextbar{1}
wenzelm@43467
    61
\rail@nont{\hyperlink{syntax.mixfix}{\mbox{\isa{mixfix}}}}[]
wenzelm@43467
    62
\rail@endbar
wenzelm@43467
    63
\rail@end
wenzelm@43467
    64
\rail@begin{2}{\isa{repset}}
wenzelm@43467
    65
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
    66
\rail@bar
wenzelm@43467
    67
\rail@nextbar{1}
wenzelm@43467
    68
\rail@term{\isa{\isakeyword{morphisms}}}[]
wenzelm@43467
    69
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
    70
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
    71
\rail@endbar
wenzelm@43467
    72
\rail@end
wenzelm@43467
    73
\end{railoutput}
wenzelm@26849
    74
wenzelm@26849
    75
wenzelm@28788
    76
  \begin{description}
wenzelm@42994
    77
wenzelm@40685
    78
  \item \hyperlink{command.HOL.typedef}{\mbox{\isa{\isacommand{typedef}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}\ t\ {\isaliteral{3D}{\isacharequal}}\ A{\isaliteral{22}{\isachardoublequote}}}
wenzelm@35757
    79
  axiomatizes a Gordon/HOL-style type definition in the background
wenzelm@35757
    80
  theory of the current context, depending on a non-emptiness result
wenzelm@35757
    81
  of the set \isa{A} (which needs to be proven interactively).
wenzelm@35757
    82
wenzelm@35757
    83
  The raw type may not depend on parameters or assumptions of the
wenzelm@35757
    84
  context --- this is logically impossible in Isabelle/HOL --- but the
wenzelm@35757
    85
  non-emptiness property can be local, potentially resulting in
wenzelm@35757
    86
  multiple interpretations in target contexts.  Thus the established
wenzelm@35757
    87
  bijection between the representing set \isa{A} and the new type
wenzelm@35757
    88
  \isa{t} may semantically depend on local assumptions.
wenzelm@42994
    89
wenzelm@35757
    90
  By default, \hyperlink{command.HOL.typedef}{\mbox{\isa{\isacommand{typedef}}}} defines both a type \isa{t}
wenzelm@35757
    91
  and a set (term constant) of the same name, unless an alternative
wenzelm@40685
    92
  base name is given in parentheses, or the ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}open{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}}''
wenzelm@35757
    93
  declaration is used to suppress a separate constant definition
wenzelm@40685
    94
  altogether.  The injection from type to set is called \isa{Rep{\isaliteral{5F}{\isacharunderscore}}t},
wenzelm@40685
    95
  its inverse \isa{Abs{\isaliteral{5F}{\isacharunderscore}}t} --- this may be changed via an explicit
wenzelm@35757
    96
  \hyperlink{keyword.HOL.morphisms}{\mbox{\isa{\isakeyword{morphisms}}}} declaration.
wenzelm@42994
    97
wenzelm@40685
    98
  Theorems \isa{Rep{\isaliteral{5F}{\isacharunderscore}}t}, \isa{Rep{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}inverse}, and \isa{Abs{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}inverse} provide the most basic characterization as a
wenzelm@26849
    99
  corresponding injection/surjection pair (in both directions).  Rules
wenzelm@40685
   100
  \isa{Rep{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}inject} and \isa{Abs{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}inject} provide a slightly
wenzelm@26849
   101
  more convenient view on the injectivity part, suitable for automated
wenzelm@26902
   102
  proof tools (e.g.\ in \hyperlink{attribute.simp}{\mbox{\isa{simp}}} or \hyperlink{attribute.iff}{\mbox{\isa{iff}}}
wenzelm@40685
   103
  declarations).  Rules \isa{Rep{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}cases}/\isa{Rep{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}induct}, and
wenzelm@40685
   104
  \isa{Abs{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}cases}/\isa{Abs{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}induct} provide alternative views
wenzelm@26895
   105
  on surjectivity; these are already declared as set or type rules for
wenzelm@26902
   106
  the generic \hyperlink{method.cases}{\mbox{\isa{cases}}} and \hyperlink{method.induct}{\mbox{\isa{induct}}} methods.
wenzelm@42994
   107
wenzelm@35757
   108
  An alternative name for the set definition (and other derived
wenzelm@35757
   109
  entities) may be specified in parentheses; the default is to use
wenzelm@35757
   110
  \isa{t} as indicated before.
wenzelm@26849
   111
wenzelm@35757
   112
  \end{description}%
wenzelm@26849
   113
\end{isamarkuptext}%
wenzelm@26849
   114
\isamarkuptrue%
wenzelm@26849
   115
%
wenzelm@26849
   116
\isamarkupsection{Adhoc tuples%
wenzelm@26849
   117
}
wenzelm@26849
   118
\isamarkuptrue%
wenzelm@26849
   119
%
wenzelm@26849
   120
\begin{isamarkuptext}%
wenzelm@26849
   121
\begin{matharray}{rcl}
wenzelm@43467
   122
    \indexdef{HOL}{attribute}{split\_format}\hypertarget{attribute.HOL.split-format}{\hyperlink{attribute.HOL.split-format}{\mbox{\isa{split{\isaliteral{5F}{\isacharunderscore}}format}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{attribute} \\
wenzelm@26849
   123
  \end{matharray}
wenzelm@26849
   124
wenzelm@43467
   125
  \begin{railoutput}
wenzelm@43467
   126
\rail@begin{2}{\isa{}}
wenzelm@43467
   127
\rail@term{\hyperlink{attribute.HOL.split-format}{\mbox{\isa{split{\isaliteral{5F}{\isacharunderscore}}format}}}}[]
wenzelm@43467
   128
\rail@bar
wenzelm@43467
   129
\rail@nextbar{1}
wenzelm@43467
   130
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
   131
\rail@term{\isa{complete}}[]
wenzelm@43467
   132
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
   133
\rail@endbar
wenzelm@43467
   134
\rail@end
wenzelm@43467
   135
\end{railoutput}
wenzelm@43467
   136
wenzelm@26849
   137
wenzelm@28788
   138
  \begin{description}
wenzelm@42994
   139
wenzelm@40685
   140
  \item \hyperlink{attribute.HOL.split-format}{\mbox{\isa{split{\isaliteral{5F}{\isacharunderscore}}format}}}\ \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}complete{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} causes
wenzelm@28788
   141
  arguments in function applications to be represented canonically
wenzelm@28788
   142
  according to their tuple type structure.
wenzelm@26849
   143
krauss@40634
   144
  Note that this operation tends to invent funny names for new local
krauss@40634
   145
  parameters introduced.
wenzelm@26849
   146
wenzelm@28788
   147
  \end{description}%
wenzelm@26849
   148
\end{isamarkuptext}%
wenzelm@26849
   149
\isamarkuptrue%
wenzelm@26849
   150
%
wenzelm@26849
   151
\isamarkupsection{Records \label{sec:hol-record}%
wenzelm@26849
   152
}
wenzelm@26849
   153
\isamarkuptrue%
wenzelm@26849
   154
%
wenzelm@26849
   155
\begin{isamarkuptext}%
wenzelm@26849
   156
In principle, records merely generalize the concept of tuples, where
wenzelm@26849
   157
  components may be addressed by labels instead of just position.  The
wenzelm@26849
   158
  logical infrastructure of records in Isabelle/HOL is slightly more
wenzelm@26849
   159
  advanced, though, supporting truly extensible record schemes.  This
wenzelm@26849
   160
  admits operations that are polymorphic with respect to record
wenzelm@26849
   161
  extension, yielding ``object-oriented'' effects like (single)
wenzelm@26849
   162
  inheritance.  See also \cite{NaraschewskiW-TPHOLs98} for more
wenzelm@26849
   163
  details on object-oriented verification and record subtyping in HOL.%
wenzelm@26849
   164
\end{isamarkuptext}%
wenzelm@26849
   165
\isamarkuptrue%
wenzelm@26849
   166
%
wenzelm@26849
   167
\isamarkupsubsection{Basic concepts%
wenzelm@26849
   168
}
wenzelm@26849
   169
\isamarkuptrue%
wenzelm@26849
   170
%
wenzelm@26849
   171
\begin{isamarkuptext}%
wenzelm@26849
   172
Isabelle/HOL supports both \emph{fixed} and \emph{schematic} records
wenzelm@26849
   173
  at the level of terms and types.  The notation is as follows:
wenzelm@26849
   174
wenzelm@26849
   175
  \begin{center}
wenzelm@26849
   176
  \begin{tabular}{l|l|l}
wenzelm@26849
   177
    & record terms & record types \\ \hline
wenzelm@40685
   178
    fixed & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3D}{\isacharequal}}\ a{\isaliteral{2C}{\isacharcomma}}\ y\ {\isaliteral{3D}{\isacharequal}}\ b{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ A{\isaliteral{2C}{\isacharcomma}}\ y\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ B{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   179
    schematic & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3D}{\isacharequal}}\ a{\isaliteral{2C}{\isacharcomma}}\ y\ {\isaliteral{3D}{\isacharequal}}\ b{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3D}{\isacharequal}}\ m{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} &
wenzelm@40685
   180
      \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ A{\isaliteral{2C}{\isacharcomma}}\ y\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ B{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ M{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@26849
   181
  \end{tabular}
wenzelm@26849
   182
  \end{center}
wenzelm@26849
   183
wenzelm@40685
   184
  \noindent The ASCII representation of \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3D}{\isacharequal}}\ a{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} is \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{7C}{\isacharbar}}\ x\ {\isaliteral{3D}{\isacharequal}}\ a\ {\isaliteral{7C}{\isacharbar}}{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@26849
   185
wenzelm@40685
   186
  A fixed record \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3D}{\isacharequal}}\ a{\isaliteral{2C}{\isacharcomma}}\ y\ {\isaliteral{3D}{\isacharequal}}\ b{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} has field \isa{x} of value
wenzelm@26849
   187
  \isa{a} and field \isa{y} of value \isa{b}.  The corresponding
wenzelm@40685
   188
  type is \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ A{\isaliteral{2C}{\isacharcomma}}\ y\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ B{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}}, assuming that \isa{{\isaliteral{22}{\isachardoublequote}}a\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ A{\isaliteral{22}{\isachardoublequote}}}
wenzelm@40685
   189
  and \isa{{\isaliteral{22}{\isachardoublequote}}b\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ B{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@26849
   190
wenzelm@40685
   191
  A record scheme like \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3D}{\isacharequal}}\ a{\isaliteral{2C}{\isacharcomma}}\ y\ {\isaliteral{3D}{\isacharequal}}\ b{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3D}{\isacharequal}}\ m{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} contains fields
wenzelm@26849
   192
  \isa{x} and \isa{y} as before, but also possibly further fields
wenzelm@40685
   193
  as indicated by the ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{22}{\isachardoublequote}}}'' notation (which is actually part
wenzelm@40685
   194
  of the syntax).  The improper field ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{22}{\isachardoublequote}}}'' of a record
wenzelm@26849
   195
  scheme is called the \emph{more part}.  Logically it is just a free
wenzelm@26849
   196
  variable, which is occasionally referred to as ``row variable'' in
wenzelm@26849
   197
  the literature.  The more part of a record scheme may be
wenzelm@26849
   198
  instantiated by zero or more further components.  For example, the
wenzelm@40685
   199
  previous scheme may get instantiated to \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3D}{\isacharequal}}\ a{\isaliteral{2C}{\isacharcomma}}\ y\ {\isaliteral{3D}{\isacharequal}}\ b{\isaliteral{2C}{\isacharcomma}}\ z\ {\isaliteral{3D}{\isacharequal}}\ c{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3D}{\isacharequal}}\ m{\isaliteral{27}{\isacharprime}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}}, where \isa{m{\isaliteral{27}{\isacharprime}}} refers to a different more part.
wenzelm@26849
   200
  Fixed records are special instances of record schemes, where
wenzelm@40685
   201
  ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{22}{\isachardoublequote}}}'' is properly terminated by the \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ unit{\isaliteral{22}{\isachardoublequote}}}
wenzelm@40685
   202
  element.  In fact, \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3D}{\isacharequal}}\ a{\isaliteral{2C}{\isacharcomma}}\ y\ {\isaliteral{3D}{\isacharequal}}\ b{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} is just an abbreviation
wenzelm@40685
   203
  for \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3D}{\isacharequal}}\ a{\isaliteral{2C}{\isacharcomma}}\ y\ {\isaliteral{3D}{\isacharequal}}\ b{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3D}{\isacharequal}}\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{29}{\isacharparenright}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@42994
   204
wenzelm@26849
   205
  \medskip Two key observations make extensible records in a simply
wenzelm@26849
   206
  typed language like HOL work out:
wenzelm@26849
   207
wenzelm@26849
   208
  \begin{enumerate}
wenzelm@26849
   209
wenzelm@26849
   210
  \item the more part is internalized, as a free term or type
wenzelm@26849
   211
  variable,
wenzelm@26849
   212
wenzelm@26852
   213
  \item field names are externalized, they cannot be accessed within
wenzelm@26852
   214
  the logic as first-class values.
wenzelm@26849
   215
wenzelm@26849
   216
  \end{enumerate}
wenzelm@26849
   217
wenzelm@26849
   218
  \medskip In Isabelle/HOL record types have to be defined explicitly,
wenzelm@26849
   219
  fixing their field names and types, and their (optional) parent
wenzelm@26849
   220
  record.  Afterwards, records may be formed using above syntax, while
wenzelm@26849
   221
  obeying the canonical order of fields as given by their declaration.
wenzelm@26849
   222
  The record package provides several standard operations like
wenzelm@26849
   223
  selectors and updates.  The common setup for various generic proof
wenzelm@26849
   224
  tools enable succinct reasoning patterns.  See also the Isabelle/HOL
wenzelm@26849
   225
  tutorial \cite{isabelle-hol-book} for further instructions on using
wenzelm@26849
   226
  records in practice.%
wenzelm@26849
   227
\end{isamarkuptext}%
wenzelm@26849
   228
\isamarkuptrue%
wenzelm@26849
   229
%
wenzelm@26849
   230
\isamarkupsubsection{Record specifications%
wenzelm@26849
   231
}
wenzelm@26849
   232
\isamarkuptrue%
wenzelm@26849
   233
%
wenzelm@26849
   234
\begin{isamarkuptext}%
wenzelm@26849
   235
\begin{matharray}{rcl}
wenzelm@40685
   236
    \indexdef{HOL}{command}{record}\hypertarget{command.HOL.record}{\hyperlink{command.HOL.record}{\mbox{\isa{\isacommand{record}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@26849
   237
  \end{matharray}
wenzelm@26849
   238
wenzelm@43467
   239
  \begin{railoutput}
wenzelm@43467
   240
\rail@begin{2}{\isa{}}
wenzelm@43467
   241
\rail@term{\hyperlink{command.HOL.record}{\mbox{\isa{\isacommand{record}}}}}[]
wenzelm@43467
   242
\rail@nont{\hyperlink{syntax.typespecsorts}{\mbox{\isa{typespecsorts}}}}[]
wenzelm@43467
   243
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43467
   244
\rail@bar
wenzelm@43467
   245
\rail@nextbar{1}
wenzelm@43467
   246
\rail@nont{\hyperlink{syntax.type}{\mbox{\isa{type}}}}[]
wenzelm@43467
   247
\rail@term{\isa{{\isaliteral{2B}{\isacharplus}}}}[]
wenzelm@43467
   248
\rail@endbar
wenzelm@43467
   249
\rail@plus
wenzelm@43467
   250
\rail@nont{\hyperlink{syntax.constdecl}{\mbox{\isa{constdecl}}}}[]
wenzelm@43467
   251
\rail@nextplus{1}
wenzelm@43467
   252
\rail@endplus
wenzelm@43467
   253
\rail@end
wenzelm@43467
   254
\end{railoutput}
wenzelm@43467
   255
wenzelm@26849
   256
wenzelm@28788
   257
  \begin{description}
wenzelm@26849
   258
wenzelm@40685
   259
  \item \hyperlink{command.HOL.record}{\mbox{\isa{\isacommand{record}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub m{\isaliteral{29}{\isacharparenright}}\ t\ {\isaliteral{3D}{\isacharequal}}\ {\isaliteral{5C3C7461753E}{\isasymtau}}\ {\isaliteral{2B}{\isacharplus}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub n\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{22}{\isachardoublequote}}} defines extensible record type \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub m{\isaliteral{29}{\isacharparenright}}\ t{\isaliteral{22}{\isachardoublequote}}},
wenzelm@40685
   260
  derived from the optional parent record \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7461753E}{\isasymtau}}{\isaliteral{22}{\isachardoublequote}}} by adding new
wenzelm@40685
   261
  field components \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub i\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub i{\isaliteral{22}{\isachardoublequote}}} etc.
wenzelm@26849
   262
wenzelm@40685
   263
  The type variables of \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7461753E}{\isasymtau}}{\isaliteral{22}{\isachardoublequote}}} and \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub i{\isaliteral{22}{\isachardoublequote}}} need to be
wenzelm@40685
   264
  covered by the (distinct) parameters \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub m{\isaliteral{22}{\isachardoublequote}}}.  Type constructor \isa{t} has to be new, while \isa{{\isaliteral{5C3C7461753E}{\isasymtau}}} needs to specify an instance of an existing record type.  At
wenzelm@40685
   265
  least one new field \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub i{\isaliteral{22}{\isachardoublequote}}} has to be specified.
wenzelm@26849
   266
  Basically, field names need to belong to a unique record.  This is
wenzelm@26849
   267
  not a real restriction in practice, since fields are qualified by
wenzelm@26849
   268
  the record name internally.
wenzelm@26849
   269
wenzelm@40685
   270
  The parent record specification \isa{{\isaliteral{5C3C7461753E}{\isasymtau}}} is optional; if omitted
wenzelm@26849
   271
  \isa{t} becomes a root record.  The hierarchy of all records
wenzelm@26849
   272
  declared within a theory context forms a forest structure, i.e.\ a
wenzelm@26849
   273
  set of trees starting with a root record each.  There is no way to
wenzelm@26849
   274
  merge multiple parent records!
wenzelm@26849
   275
wenzelm@40685
   276
  For convenience, \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub m{\isaliteral{29}{\isacharparenright}}\ t{\isaliteral{22}{\isachardoublequote}}} is made a
wenzelm@40685
   277
  type abbreviation for the fixed record type \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub n\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}}, likewise is \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub m{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C7A6574613E}{\isasymzeta}}{\isaliteral{29}{\isacharparenright}}\ t{\isaliteral{5F}{\isacharunderscore}}scheme{\isaliteral{22}{\isachardoublequote}}} made an abbreviation for
wenzelm@40685
   278
  \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub n\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7A6574613E}{\isasymzeta}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@26849
   279
wenzelm@28788
   280
  \end{description}%
wenzelm@26849
   281
\end{isamarkuptext}%
wenzelm@26849
   282
\isamarkuptrue%
wenzelm@26849
   283
%
wenzelm@26849
   284
\isamarkupsubsection{Record operations%
wenzelm@26849
   285
}
wenzelm@26849
   286
\isamarkuptrue%
wenzelm@26849
   287
%
wenzelm@26849
   288
\begin{isamarkuptext}%
wenzelm@26849
   289
Any record definition of the form presented above produces certain
wenzelm@26849
   290
  standard operations.  Selectors and updates are provided for any
wenzelm@26849
   291
  field, including the improper one ``\isa{more}''.  There are also
wenzelm@26849
   292
  cumulative record constructor functions.  To simplify the
wenzelm@40685
   293
  presentation below, we assume for now that \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub m{\isaliteral{29}{\isacharparenright}}\ t{\isaliteral{22}{\isachardoublequote}}} is a root record with fields \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub n\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@26849
   294
wenzelm@26849
   295
  \medskip \textbf{Selectors} and \textbf{updates} are available for
wenzelm@26849
   296
  any field (including ``\isa{more}''):
wenzelm@26849
   297
wenzelm@26849
   298
  \begin{matharray}{lll}
wenzelm@40685
   299
    \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub i{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}\isaliteral{5C3C5E7665633E}{}\isactrlvec c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7A6574613E}{\isasymzeta}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub i{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   300
    \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub i{\isaliteral{5F}{\isacharunderscore}}update{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C6C706172723E}{\isasymlparr}}\isaliteral{5C3C5E7665633E}{}\isactrlvec c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7A6574613E}{\isasymzeta}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C6C706172723E}{\isasymlparr}}\isaliteral{5C3C5E7665633E}{}\isactrlvec c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7A6574613E}{\isasymzeta}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@26849
   301
  \end{matharray}
wenzelm@26849
   302
wenzelm@40685
   303
  There is special syntax for application of updates: \isa{{\isaliteral{22}{\isachardoublequote}}r{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3D}{\isacharequal}}\ a{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} abbreviates term \isa{{\isaliteral{22}{\isachardoublequote}}x{\isaliteral{5F}{\isacharunderscore}}update\ a\ r{\isaliteral{22}{\isachardoublequote}}}.  Further notation for
wenzelm@40685
   304
  repeated updates is also available: \isa{{\isaliteral{22}{\isachardoublequote}}r{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3D}{\isacharequal}}\ a{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}y\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3D}{\isacharequal}}\ b{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}z\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3D}{\isacharequal}}\ c{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} may be written \isa{{\isaliteral{22}{\isachardoublequote}}r{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3D}{\isacharequal}}\ a{\isaliteral{2C}{\isacharcomma}}\ y\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3D}{\isacharequal}}\ b{\isaliteral{2C}{\isacharcomma}}\ z\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3D}{\isacharequal}}\ c{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}}.  Note that
wenzelm@26849
   305
  because of postfix notation the order of fields shown here is
wenzelm@26849
   306
  reverse than in the actual term.  Since repeated updates are just
wenzelm@40685
   307
  function applications, fields may be freely permuted in \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}x\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3D}{\isacharequal}}\ a{\isaliteral{2C}{\isacharcomma}}\ y\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3D}{\isacharequal}}\ b{\isaliteral{2C}{\isacharcomma}}\ z\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3D}{\isacharequal}}\ c{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}}, as far as logical equality is concerned.
wenzelm@26849
   308
  Thus commutativity of independent updates can be proven within the
wenzelm@26849
   309
  logic for any two fields, but not as a general theorem.
wenzelm@26849
   310
wenzelm@26849
   311
  \medskip The \textbf{make} operation provides a cumulative record
wenzelm@26849
   312
  constructor function:
wenzelm@26849
   313
wenzelm@26849
   314
  \begin{matharray}{lll}
wenzelm@40685
   315
    \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}make{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C6C706172723E}{\isasymlparr}}\isaliteral{5C3C5E7665633E}{}\isactrlvec c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@26849
   316
  \end{matharray}
wenzelm@26849
   317
wenzelm@26849
   318
  \medskip We now reconsider the case of non-root records, which are
wenzelm@26849
   319
  derived of some parent.  In general, the latter may depend on
wenzelm@26849
   320
  another parent as well, resulting in a list of \emph{ancestor
wenzelm@26849
   321
  records}.  Appending the lists of fields of all ancestors results in
wenzelm@26849
   322
  a certain field prefix.  The record package automatically takes care
wenzelm@26849
   323
  of this by lifting operations over this context of ancestor fields.
wenzelm@40685
   324
  Assuming that \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub m{\isaliteral{29}{\isacharparenright}}\ t{\isaliteral{22}{\isachardoublequote}}} has ancestor
wenzelm@40685
   325
  fields \isa{{\isaliteral{22}{\isachardoublequote}}b\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C72686F3E}{\isasymrho}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ b\isaliteral{5C3C5E7375623E}{}\isactrlsub k\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C72686F3E}{\isasymrho}}\isaliteral{5C3C5E7375623E}{}\isactrlsub k{\isaliteral{22}{\isachardoublequote}}},
wenzelm@26849
   326
  the above record operations will get the following types:
wenzelm@26849
   327
wenzelm@26852
   328
  \medskip
wenzelm@26852
   329
  \begin{tabular}{lll}
wenzelm@40685
   330
    \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub i{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}\isaliteral{5C3C5E7665633E}{}\isactrlvec b\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C72686F3E}{\isasymrho}}{\isaliteral{2C}{\isacharcomma}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7A6574613E}{\isasymzeta}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub i{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   331
    \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub i{\isaliteral{5F}{\isacharunderscore}}update{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub i\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C6C706172723E}{\isasymlparr}}\isaliteral{5C3C5E7665633E}{}\isactrlvec b\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C72686F3E}{\isasymrho}}{\isaliteral{2C}{\isacharcomma}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7A6574613E}{\isasymzeta}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C6C706172723E}{\isasymlparr}}\isaliteral{5C3C5E7665633E}{}\isactrlvec b\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C72686F3E}{\isasymrho}}{\isaliteral{2C}{\isacharcomma}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7A6574613E}{\isasymzeta}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   332
    \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}make{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C72686F3E}{\isasymrho}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{5C3C72686F3E}{\isasymrho}}\isaliteral{5C3C5E7375623E}{}\isactrlsub k\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C6C706172723E}{\isasymlparr}}\isaliteral{5C3C5E7665633E}{}\isactrlvec b\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C72686F3E}{\isasymrho}}{\isaliteral{2C}{\isacharcomma}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@26852
   333
  \end{tabular}
wenzelm@26852
   334
  \medskip
wenzelm@26849
   335
wenzelm@26852
   336
  \noindent Some further operations address the extension aspect of a
wenzelm@40685
   337
  derived record scheme specifically: \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}fields{\isaliteral{22}{\isachardoublequote}}} produces a
wenzelm@26849
   338
  record fragment consisting of exactly the new fields introduced here
wenzelm@40685
   339
  (the result may serve as a more part elsewhere); \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}extend{\isaliteral{22}{\isachardoublequote}}}
wenzelm@40685
   340
  takes a fixed record and adds a given more part; \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}truncate{\isaliteral{22}{\isachardoublequote}}} restricts a record scheme to a fixed record.
wenzelm@26849
   341
wenzelm@26852
   342
  \medskip
wenzelm@26852
   343
  \begin{tabular}{lll}
wenzelm@40685
   344
    \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}fields{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C6C706172723E}{\isasymlparr}}\isaliteral{5C3C5E7665633E}{}\isactrlvec c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   345
    \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}extend{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}\isaliteral{5C3C5E7665633E}{}\isactrlvec b\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C72686F3E}{\isasymrho}}{\isaliteral{2C}{\isacharcomma}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C7A6574613E}{\isasymzeta}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C6C706172723E}{\isasymlparr}}\isaliteral{5C3C5E7665633E}{}\isactrlvec b\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C72686F3E}{\isasymrho}}{\isaliteral{2C}{\isacharcomma}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7A6574613E}{\isasymzeta}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   346
    \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}truncate{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C706172723E}{\isasymlparr}}\isaliteral{5C3C5E7665633E}{}\isactrlvec b\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C72686F3E}{\isasymrho}}{\isaliteral{2C}{\isacharcomma}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7A6574613E}{\isasymzeta}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C6C706172723E}{\isasymlparr}}\isaliteral{5C3C5E7665633E}{}\isactrlvec b\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C72686F3E}{\isasymrho}}{\isaliteral{2C}{\isacharcomma}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{5C3C72706172723E}{\isasymrparr}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@26852
   347
  \end{tabular}
wenzelm@26852
   348
  \medskip
wenzelm@26849
   349
wenzelm@40685
   350
  \noindent Note that \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}make{\isaliteral{22}{\isachardoublequote}}} and \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}fields{\isaliteral{22}{\isachardoublequote}}} coincide
wenzelm@26849
   351
  for root records.%
wenzelm@26849
   352
\end{isamarkuptext}%
wenzelm@26849
   353
\isamarkuptrue%
wenzelm@26849
   354
%
wenzelm@26849
   355
\isamarkupsubsection{Derived rules and proof tools%
wenzelm@26849
   356
}
wenzelm@26849
   357
\isamarkuptrue%
wenzelm@26849
   358
%
wenzelm@26849
   359
\begin{isamarkuptext}%
wenzelm@26849
   360
The record package proves several results internally, declaring
wenzelm@26849
   361
  these facts to appropriate proof tools.  This enables users to
wenzelm@26849
   362
  reason about record structures quite conveniently.  Assume that
wenzelm@26849
   363
  \isa{t} is a record type as specified above.
wenzelm@26849
   364
wenzelm@26849
   365
  \begin{enumerate}
wenzelm@42994
   366
wenzelm@26849
   367
  \item Standard conversions for selectors or updates applied to
wenzelm@26849
   368
  record constructor terms are made part of the default Simplifier
wenzelm@26849
   369
  context; thus proofs by reduction of basic operations merely require
wenzelm@26902
   370
  the \hyperlink{method.simp}{\mbox{\isa{simp}}} method without further arguments.  These rules
wenzelm@40685
   371
  are available as \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}simps{\isaliteral{22}{\isachardoublequote}}}, too.
wenzelm@42994
   372
wenzelm@26849
   373
  \item Selectors applied to updated records are automatically reduced
wenzelm@26849
   374
  by an internal simplification procedure, which is also part of the
wenzelm@26849
   375
  standard Simplifier setup.
wenzelm@26849
   376
wenzelm@40685
   377
  \item Inject equations of a form analogous to \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}x{\isaliteral{2C}{\isacharcomma}}\ y{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{3D}{\isacharequal}}\ {\isaliteral{28}{\isacharparenleft}}x{\isaliteral{27}{\isacharprime}}{\isaliteral{2C}{\isacharcomma}}\ y{\isaliteral{27}{\isacharprime}}{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ x\ {\isaliteral{3D}{\isacharequal}}\ x{\isaliteral{27}{\isacharprime}}\ {\isaliteral{5C3C616E643E}{\isasymand}}\ y\ {\isaliteral{3D}{\isacharequal}}\ y{\isaliteral{27}{\isacharprime}}{\isaliteral{22}{\isachardoublequote}}} are declared to the Simplifier and Classical
wenzelm@26902
   378
  Reasoner as \hyperlink{attribute.iff}{\mbox{\isa{iff}}} rules.  These rules are available as
wenzelm@40685
   379
  \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}iffs{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@26849
   380
wenzelm@40685
   381
  \item The introduction rule for record equality analogous to \isa{{\isaliteral{22}{\isachardoublequote}}x\ r\ {\isaliteral{3D}{\isacharequal}}\ x\ r{\isaliteral{27}{\isacharprime}}\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ y\ r\ {\isaliteral{3D}{\isacharequal}}\ y\ r{\isaliteral{27}{\isacharprime}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ r\ {\isaliteral{3D}{\isacharequal}}\ r{\isaliteral{27}{\isacharprime}}{\isaliteral{22}{\isachardoublequote}}} is declared to the Simplifier,
wenzelm@40685
   382
  and as the basic rule context as ``\hyperlink{attribute.intro}{\mbox{\isa{intro}}}\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3F}{\isacharquery}}{\isaliteral{22}{\isachardoublequote}}}''.
wenzelm@40685
   383
  The rule is called \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}equality{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@26849
   384
wenzelm@26849
   385
  \item Representations of arbitrary record expressions as canonical
wenzelm@26902
   386
  constructor terms are provided both in \hyperlink{method.cases}{\mbox{\isa{cases}}} and \hyperlink{method.induct}{\mbox{\isa{induct}}} format (cf.\ the generic proof methods of the same name,
wenzelm@26849
   387
  \secref{sec:cases-induct}).  Several variations are available, for
wenzelm@26849
   388
  fixed records, record schemes, more parts etc.
wenzelm@42994
   389
wenzelm@26849
   390
  The generic proof methods are sufficiently smart to pick the most
wenzelm@26849
   391
  sensible rule according to the type of the indicated record
wenzelm@40685
   392
  expression: users just need to apply something like ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}cases\ r{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}}'' to a certain proof problem.
wenzelm@26849
   393
wenzelm@40685
   394
  \item The derived record operations \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}make{\isaliteral{22}{\isachardoublequote}}}, \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}fields{\isaliteral{22}{\isachardoublequote}}}, \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}extend{\isaliteral{22}{\isachardoublequote}}}, \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}truncate{\isaliteral{22}{\isachardoublequote}}} are \emph{not}
wenzelm@26849
   395
  treated automatically, but usually need to be expanded by hand,
wenzelm@40685
   396
  using the collective fact \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}defs{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@26849
   397
wenzelm@26849
   398
  \end{enumerate}%
wenzelm@26849
   399
\end{isamarkuptext}%
wenzelm@26849
   400
\isamarkuptrue%
wenzelm@26849
   401
%
wenzelm@26849
   402
\isamarkupsection{Datatypes \label{sec:hol-datatype}%
wenzelm@26849
   403
}
wenzelm@26849
   404
\isamarkuptrue%
wenzelm@26849
   405
%
wenzelm@26849
   406
\begin{isamarkuptext}%
wenzelm@26849
   407
\begin{matharray}{rcl}
wenzelm@40685
   408
    \indexdef{HOL}{command}{datatype}\hypertarget{command.HOL.datatype}{\hyperlink{command.HOL.datatype}{\mbox{\isa{\isacommand{datatype}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
haftmann@41644
   409
    \indexdef{HOL}{command}{rep\_datatype}\hypertarget{command.HOL.rep-datatype}{\hyperlink{command.HOL.rep-datatype}{\mbox{\isa{\isacommand{rep{\isaliteral{5F}{\isacharunderscore}}datatype}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ proof{\isaliteral{28}{\isacharparenleft}}prove{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@26849
   410
  \end{matharray}
wenzelm@26849
   411
wenzelm@43467
   412
  \begin{railoutput}
wenzelm@43467
   413
\rail@begin{2}{\isa{}}
wenzelm@43467
   414
\rail@term{\hyperlink{command.HOL.datatype}{\mbox{\isa{\isacommand{datatype}}}}}[]
wenzelm@43467
   415
\rail@plus
wenzelm@43467
   416
\rail@nont{\isa{dtspec}}[]
wenzelm@43467
   417
\rail@nextplus{1}
wenzelm@43467
   418
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
   419
\rail@endplus
wenzelm@43467
   420
\rail@end
wenzelm@43467
   421
\rail@begin{3}{\isa{}}
wenzelm@43467
   422
\rail@term{\hyperlink{command.HOL.rep-datatype}{\mbox{\isa{\isacommand{rep{\isaliteral{5F}{\isacharunderscore}}datatype}}}}}[]
wenzelm@43467
   423
\rail@bar
wenzelm@43467
   424
\rail@nextbar{1}
wenzelm@43467
   425
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
   426
\rail@plus
wenzelm@43467
   427
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
   428
\rail@nextplus{2}
wenzelm@43467
   429
\rail@endplus
wenzelm@43467
   430
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
   431
\rail@endbar
wenzelm@43467
   432
\rail@plus
wenzelm@43467
   433
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
   434
\rail@nextplus{1}
wenzelm@43467
   435
\rail@endplus
wenzelm@43467
   436
\rail@end
wenzelm@43467
   437
\rail@begin{2}{\isa{dtspec}}
wenzelm@43467
   438
\rail@bar
wenzelm@43467
   439
\rail@nextbar{1}
wenzelm@43467
   440
\rail@nont{\hyperlink{syntax.parname}{\mbox{\isa{parname}}}}[]
wenzelm@43467
   441
\rail@endbar
wenzelm@43467
   442
\rail@nont{\hyperlink{syntax.typespec}{\mbox{\isa{typespec}}}}[]
wenzelm@43467
   443
\rail@bar
wenzelm@43467
   444
\rail@nextbar{1}
wenzelm@43467
   445
\rail@nont{\hyperlink{syntax.mixfix}{\mbox{\isa{mixfix}}}}[]
wenzelm@43467
   446
\rail@endbar
wenzelm@43467
   447
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43467
   448
\rail@plus
wenzelm@43467
   449
\rail@nont{\isa{cons}}[]
wenzelm@43467
   450
\rail@nextplus{1}
wenzelm@43467
   451
\rail@cterm{\isa{{\isaliteral{7C}{\isacharbar}}}}[]
wenzelm@43467
   452
\rail@endplus
wenzelm@43467
   453
\rail@end
wenzelm@43467
   454
\rail@begin{2}{\isa{cons}}
wenzelm@43467
   455
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
   456
\rail@plus
wenzelm@43467
   457
\rail@nextplus{1}
wenzelm@43467
   458
\rail@cnont{\hyperlink{syntax.type}{\mbox{\isa{type}}}}[]
wenzelm@43467
   459
\rail@endplus
wenzelm@43467
   460
\rail@bar
wenzelm@43467
   461
\rail@nextbar{1}
wenzelm@43467
   462
\rail@nont{\hyperlink{syntax.mixfix}{\mbox{\isa{mixfix}}}}[]
wenzelm@43467
   463
\rail@endbar
wenzelm@43467
   464
\rail@end
wenzelm@43467
   465
\end{railoutput}
wenzelm@26849
   466
wenzelm@26849
   467
wenzelm@28788
   468
  \begin{description}
wenzelm@26849
   469
wenzelm@28788
   470
  \item \hyperlink{command.HOL.datatype}{\mbox{\isa{\isacommand{datatype}}}} defines inductive datatypes in
wenzelm@26849
   471
  HOL.
wenzelm@26849
   472
wenzelm@40685
   473
  \item \hyperlink{command.HOL.rep-datatype}{\mbox{\isa{\isacommand{rep{\isaliteral{5F}{\isacharunderscore}}datatype}}}} represents existing types as
wenzelm@26849
   474
  inductive ones, generating the standard infrastructure of derived
wenzelm@26849
   475
  concepts (primitive recursion etc.).
wenzelm@26849
   476
wenzelm@28788
   477
  \end{description}
wenzelm@26849
   478
wenzelm@26849
   479
  The induction and exhaustion theorems generated provide case names
wenzelm@26849
   480
  according to the constructors involved, while parameters are named
wenzelm@26849
   481
  after the types (see also \secref{sec:cases-induct}).
wenzelm@26849
   482
wenzelm@26849
   483
  See \cite{isabelle-HOL} for more details on datatypes, but beware of
wenzelm@26849
   484
  the old-style theory syntax being used there!  Apart from proper
wenzelm@26849
   485
  proof methods for case-analysis and induction, there are also
wenzelm@40685
   486
  emulations of ML tactics \hyperlink{method.HOL.case-tac}{\mbox{\isa{case{\isaliteral{5F}{\isacharunderscore}}tac}}} and \hyperlink{method.HOL.induct-tac}{\mbox{\isa{induct{\isaliteral{5F}{\isacharunderscore}}tac}}} available, see \secref{sec:hol-induct-tac}; these admit
wenzelm@26849
   487
  to refer directly to the internal structure of subgoals (including
wenzelm@26849
   488
  internally bound parameters).%
wenzelm@26849
   489
\end{isamarkuptext}%
wenzelm@26849
   490
\isamarkuptrue%
wenzelm@26849
   491
%
haftmann@41644
   492
\isamarkupsection{Functorial structure of types%
haftmann@41644
   493
}
haftmann@41644
   494
\isamarkuptrue%
haftmann@41644
   495
%
haftmann@41644
   496
\begin{isamarkuptext}%
haftmann@41644
   497
\begin{matharray}{rcl}
haftmann@41753
   498
    \indexdef{HOL}{command}{enriched\_type}\hypertarget{command.HOL.enriched-type}{\hyperlink{command.HOL.enriched-type}{\mbox{\isa{\isacommand{enriched{\isaliteral{5F}{\isacharunderscore}}type}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ proof{\isaliteral{28}{\isacharparenleft}}prove{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}}
haftmann@41644
   499
  \end{matharray}
haftmann@41644
   500
wenzelm@43467
   501
  \begin{railoutput}
wenzelm@43467
   502
\rail@begin{2}{\isa{}}
wenzelm@43467
   503
\rail@term{\hyperlink{command.HOL.enriched-type}{\mbox{\isa{\isacommand{enriched{\isaliteral{5F}{\isacharunderscore}}type}}}}}[]
wenzelm@43467
   504
\rail@bar
wenzelm@43467
   505
\rail@nextbar{1}
wenzelm@43467
   506
\rail@nont{\isa{prefix}}[]
wenzelm@43467
   507
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
   508
\rail@endbar
wenzelm@43467
   509
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
   510
\rail@end
wenzelm@43467
   511
\end{railoutput}
wenzelm@43467
   512
 % FIXME check prefix
haftmann@41644
   513
haftmann@41644
   514
  \begin{description}
haftmann@41644
   515
haftmann@41753
   516
  \item \hyperlink{command.HOL.enriched-type}{\mbox{\isa{\isacommand{enriched{\isaliteral{5F}{\isacharunderscore}}type}}}} allows to prove and register
haftmann@41753
   517
  properties about the functorial structure of type constructors;
haftmann@41753
   518
  these properties then can be used by other packages to
haftmann@41644
   519
  deal with those type constructors in certain type constructions.
haftmann@41644
   520
  Characteristic theorems are noted in the current local theory; by
haftmann@41753
   521
  default, they are prefixed with the base name of the type constructor,
haftmann@41644
   522
  an explicit prefix can be given alternatively.
haftmann@41644
   523
haftmann@41644
   524
  The given term \isa{{\isaliteral{22}{\isachardoublequote}}m{\isaliteral{22}{\isachardoublequote}}} is considered as \emph{mapper} for the
haftmann@41644
   525
  corresponding type constructor and must conform to the following
haftmann@41644
   526
  type pattern:
haftmann@41644
   527
haftmann@41644
   528
  \begin{matharray}{lll}
haftmann@41644
   529
    \isa{{\isaliteral{22}{\isachardoublequote}}m{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}} &
haftmann@41644
   530
      \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E697375623E}{}\isactrlisub {\isadigit{1}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E697375623E}{}\isactrlisub k\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{28}{\isacharparenleft}}\isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E697375623E}{}\isactrlisub n{\isaliteral{29}{\isacharparenright}}\ t\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{28}{\isacharparenleft}}\isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C626574613E}{\isasymbeta}}\isaliteral{5C3C5E697375623E}{}\isactrlisub n{\isaliteral{29}{\isacharparenright}}\ t{\isaliteral{22}{\isachardoublequote}}} \\
haftmann@41644
   531
  \end{matharray}
haftmann@41644
   532
haftmann@41644
   533
  \noindent where \isa{t} is the type constructor, \isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E697375623E}{}\isactrlisub n{\isaliteral{22}{\isachardoublequote}}} and \isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7665633E}{}\isactrlvec {\isaliteral{5C3C626574613E}{\isasymbeta}}\isaliteral{5C3C5E697375623E}{}\isactrlisub n{\isaliteral{22}{\isachardoublequote}}} are distinct
haftmann@41644
   534
  type variables free in the local theory and \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E697375623E}{}\isactrlisub {\isadigit{1}}{\isaliteral{22}{\isachardoublequote}}},
haftmann@41644
   535
  \ldots, \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7369676D613E}{\isasymsigma}}\isaliteral{5C3C5E697375623E}{}\isactrlisub k{\isaliteral{22}{\isachardoublequote}}} is a subsequence of \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E697375623E}{}\isactrlisub {\isadigit{1}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C626574613E}{\isasymbeta}}\isaliteral{5C3C5E697375623E}{}\isactrlisub {\isadigit{1}}{\isaliteral{22}{\isachardoublequote}}}, \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C626574613E}{\isasymbeta}}\isaliteral{5C3C5E697375623E}{}\isactrlisub {\isadigit{1}}\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E697375623E}{}\isactrlisub {\isadigit{1}}{\isaliteral{22}{\isachardoublequote}}}, \ldots,
haftmann@41644
   536
  \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E697375623E}{}\isactrlisub n\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C626574613E}{\isasymbeta}}\isaliteral{5C3C5E697375623E}{}\isactrlisub n{\isaliteral{22}{\isachardoublequote}}}, \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C626574613E}{\isasymbeta}}\isaliteral{5C3C5E697375623E}{}\isactrlisub n\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E697375623E}{}\isactrlisub n{\isaliteral{22}{\isachardoublequote}}}.
haftmann@41644
   537
haftmann@41644
   538
  \end{description}%
haftmann@41644
   539
\end{isamarkuptext}%
haftmann@41644
   540
\isamarkuptrue%
haftmann@41644
   541
%
wenzelm@26849
   542
\isamarkupsection{Recursive functions \label{sec:recursion}%
wenzelm@26849
   543
}
wenzelm@26849
   544
\isamarkuptrue%
wenzelm@26849
   545
%
wenzelm@26849
   546
\begin{isamarkuptext}%
wenzelm@26849
   547
\begin{matharray}{rcl}
wenzelm@40685
   548
    \indexdef{HOL}{command}{primrec}\hypertarget{command.HOL.primrec}{\hyperlink{command.HOL.primrec}{\mbox{\isa{\isacommand{primrec}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   549
    \indexdef{HOL}{command}{fun}\hypertarget{command.HOL.fun}{\hyperlink{command.HOL.fun}{\mbox{\isa{\isacommand{fun}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   550
    \indexdef{HOL}{command}{function}\hypertarget{command.HOL.function}{\hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ proof{\isaliteral{28}{\isacharparenleft}}prove{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   551
    \indexdef{HOL}{command}{termination}\hypertarget{command.HOL.termination}{\hyperlink{command.HOL.termination}{\mbox{\isa{\isacommand{termination}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ proof{\isaliteral{28}{\isacharparenleft}}prove{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@26849
   552
  \end{matharray}
wenzelm@26849
   553
wenzelm@43467
   554
  \begin{railoutput}
wenzelm@43467
   555
\rail@begin{2}{\isa{}}
wenzelm@43467
   556
\rail@term{\hyperlink{command.HOL.primrec}{\mbox{\isa{\isacommand{primrec}}}}}[]
wenzelm@43467
   557
\rail@bar
wenzelm@43467
   558
\rail@nextbar{1}
wenzelm@43467
   559
\rail@nont{\hyperlink{syntax.target}{\mbox{\isa{target}}}}[]
wenzelm@43467
   560
\rail@endbar
wenzelm@43467
   561
\rail@nont{\hyperlink{syntax.fixes}{\mbox{\isa{fixes}}}}[]
wenzelm@43467
   562
\rail@term{\isa{\isakeyword{where}}}[]
wenzelm@43467
   563
\rail@nont{\isa{equations}}[]
wenzelm@43467
   564
\rail@end
wenzelm@43467
   565
\rail@begin{4}{\isa{}}
wenzelm@43467
   566
\rail@bar
wenzelm@43467
   567
\rail@term{\hyperlink{command.HOL.fun}{\mbox{\isa{\isacommand{fun}}}}}[]
wenzelm@43467
   568
\rail@nextbar{1}
wenzelm@43467
   569
\rail@term{\hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}}}[]
wenzelm@43467
   570
\rail@endbar
wenzelm@43467
   571
\rail@bar
wenzelm@43467
   572
\rail@nextbar{1}
wenzelm@43467
   573
\rail@nont{\hyperlink{syntax.target}{\mbox{\isa{target}}}}[]
wenzelm@43467
   574
\rail@endbar
wenzelm@43467
   575
\rail@bar
wenzelm@43467
   576
\rail@nextbar{1}
wenzelm@43467
   577
\rail@nont{\isa{functionopts}}[]
wenzelm@43467
   578
\rail@endbar
wenzelm@43467
   579
\rail@nont{\hyperlink{syntax.fixes}{\mbox{\isa{fixes}}}}[]
wenzelm@43467
   580
\rail@cr{3}
wenzelm@43467
   581
\rail@term{\isa{\isakeyword{where}}}[]
wenzelm@43467
   582
\rail@nont{\isa{equations}}[]
wenzelm@43467
   583
\rail@end
wenzelm@43467
   584
\rail@begin{3}{\isa{equations}}
wenzelm@43467
   585
\rail@plus
wenzelm@43467
   586
\rail@bar
wenzelm@43467
   587
\rail@nextbar{1}
wenzelm@43467
   588
\rail@nont{\hyperlink{syntax.thmdecl}{\mbox{\isa{thmdecl}}}}[]
wenzelm@43467
   589
\rail@endbar
wenzelm@43467
   590
\rail@nont{\hyperlink{syntax.prop}{\mbox{\isa{prop}}}}[]
wenzelm@43467
   591
\rail@nextplus{2}
wenzelm@43467
   592
\rail@cterm{\isa{{\isaliteral{7C}{\isacharbar}}}}[]
wenzelm@43467
   593
\rail@endplus
wenzelm@43467
   594
\rail@end
wenzelm@43467
   595
\rail@begin{3}{\isa{functionopts}}
wenzelm@43467
   596
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
   597
\rail@plus
wenzelm@43467
   598
\rail@bar
wenzelm@43467
   599
\rail@term{\isa{sequential}}[]
wenzelm@43467
   600
\rail@nextbar{1}
wenzelm@43467
   601
\rail@term{\isa{domintros}}[]
wenzelm@43467
   602
\rail@endbar
wenzelm@43467
   603
\rail@nextplus{2}
wenzelm@43467
   604
\rail@cterm{\isa{{\isaliteral{2C}{\isacharcomma}}}}[]
wenzelm@43467
   605
\rail@endplus
wenzelm@43467
   606
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
   607
\rail@end
wenzelm@43467
   608
\rail@begin{2}{\isa{}}
wenzelm@43467
   609
\rail@term{\hyperlink{command.HOL.termination}{\mbox{\isa{\isacommand{termination}}}}}[]
wenzelm@43467
   610
\rail@bar
wenzelm@43467
   611
\rail@nextbar{1}
wenzelm@43467
   612
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
   613
\rail@endbar
wenzelm@43467
   614
\rail@end
wenzelm@43467
   615
\end{railoutput}
wenzelm@43467
   616
wenzelm@26849
   617
wenzelm@28788
   618
  \begin{description}
wenzelm@26849
   619
wenzelm@28788
   620
  \item \hyperlink{command.HOL.primrec}{\mbox{\isa{\isacommand{primrec}}}} defines primitive recursive
wenzelm@26849
   621
  functions over datatypes, see also \cite{isabelle-HOL}.
wenzelm@26849
   622
wenzelm@28788
   623
  \item \hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}} defines functions by general
wenzelm@26849
   624
  wellfounded recursion. A detailed description with examples can be
wenzelm@26849
   625
  found in \cite{isabelle-function}. The function is specified by a
wenzelm@26849
   626
  set of (possibly conditional) recursive equations with arbitrary
wenzelm@26849
   627
  pattern matching. The command generates proof obligations for the
wenzelm@26849
   628
  completeness and the compatibility of patterns.
wenzelm@26849
   629
wenzelm@26849
   630
  The defined function is considered partial, and the resulting
wenzelm@40685
   631
  simplification rules (named \isa{{\isaliteral{22}{\isachardoublequote}}f{\isaliteral{2E}{\isachardot}}psimps{\isaliteral{22}{\isachardoublequote}}}) and induction rule
wenzelm@40685
   632
  (named \isa{{\isaliteral{22}{\isachardoublequote}}f{\isaliteral{2E}{\isachardot}}pinduct{\isaliteral{22}{\isachardoublequote}}}) are guarded by a generated domain
wenzelm@40685
   633
  predicate \isa{{\isaliteral{22}{\isachardoublequote}}f{\isaliteral{5F}{\isacharunderscore}}dom{\isaliteral{22}{\isachardoublequote}}}. The \hyperlink{command.HOL.termination}{\mbox{\isa{\isacommand{termination}}}}
wenzelm@26849
   634
  command can then be used to establish that the function is total.
wenzelm@26849
   635
wenzelm@40685
   636
  \item \hyperlink{command.HOL.fun}{\mbox{\isa{\isacommand{fun}}}} is a shorthand notation for ``\hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}sequential{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}}, followed by automated
wenzelm@28788
   637
  proof attempts regarding pattern matching and termination.  See
wenzelm@28788
   638
  \cite{isabelle-function} for further details.
wenzelm@26849
   639
wenzelm@28788
   640
  \item \hyperlink{command.HOL.termination}{\mbox{\isa{\isacommand{termination}}}}~\isa{f} commences a
wenzelm@26849
   641
  termination proof for the previously defined function \isa{f}.  If
wenzelm@26849
   642
  this is omitted, the command refers to the most recent function
wenzelm@26849
   643
  definition.  After the proof is closed, the recursive equations and
wenzelm@26849
   644
  the induction principle is established.
wenzelm@26849
   645
wenzelm@28788
   646
  \end{description}
wenzelm@26849
   647
haftmann@27452
   648
  Recursive definitions introduced by the \hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}}
haftmann@27452
   649
  command accommodate
wenzelm@40685
   650
  reasoning by induction (cf.\ \secref{sec:cases-induct}): rule \isa{{\isaliteral{22}{\isachardoublequote}}c{\isaliteral{2E}{\isachardot}}induct{\isaliteral{22}{\isachardoublequote}}} (where \isa{c} is the name of the function definition)
wenzelm@26849
   651
  refers to a specific induction rule, with parameters named according
krauss@33857
   652
  to the user-specified equations. Cases are numbered (starting from 1).
krauss@33857
   653
krauss@33857
   654
  For \hyperlink{command.HOL.primrec}{\mbox{\isa{\isacommand{primrec}}}}, the induction principle coincides
haftmann@27452
   655
  with structural recursion on the datatype the recursion is carried
haftmann@27452
   656
  out.
wenzelm@26849
   657
wenzelm@26849
   658
  The equations provided by these packages may be referred later as
wenzelm@40685
   659
  theorem list \isa{{\isaliteral{22}{\isachardoublequote}}f{\isaliteral{2E}{\isachardot}}simps{\isaliteral{22}{\isachardoublequote}}}, where \isa{f} is the (collective)
wenzelm@26849
   660
  name of the functions defined.  Individual equations may be named
wenzelm@26849
   661
  explicitly as well.
wenzelm@26849
   662
wenzelm@26902
   663
  The \hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}} command accepts the following
wenzelm@26849
   664
  options.
wenzelm@26849
   665
wenzelm@28788
   666
  \begin{description}
wenzelm@26849
   667
wenzelm@28788
   668
  \item \isa{sequential} enables a preprocessor which disambiguates
wenzelm@28788
   669
  overlapping patterns by making them mutually disjoint.  Earlier
wenzelm@28788
   670
  equations take precedence over later ones.  This allows to give the
wenzelm@28788
   671
  specification in a format very similar to functional programming.
wenzelm@28788
   672
  Note that the resulting simplification and induction rules
wenzelm@28788
   673
  correspond to the transformed specification, not the one given
wenzelm@26849
   674
  originally. This usually means that each equation given by the user
hoelzl@36137
   675
  may result in several theorems.  Also note that this automatic
wenzelm@26849
   676
  transformation only works for ML-style datatype patterns.
wenzelm@26849
   677
wenzelm@28788
   678
  \item \isa{domintros} enables the automated generation of
wenzelm@26849
   679
  introduction rules for the domain predicate. While mostly not
wenzelm@26849
   680
  needed, they can be helpful in some proofs about partial functions.
wenzelm@26849
   681
wenzelm@28788
   682
  \end{description}%
wenzelm@26849
   683
\end{isamarkuptext}%
wenzelm@26849
   684
\isamarkuptrue%
wenzelm@26849
   685
%
wenzelm@26849
   686
\isamarkupsubsection{Proof methods related to recursive definitions%
wenzelm@26849
   687
}
wenzelm@26849
   688
\isamarkuptrue%
wenzelm@26849
   689
%
wenzelm@26849
   690
\begin{isamarkuptext}%
wenzelm@26849
   691
\begin{matharray}{rcl}
wenzelm@40685
   692
    \indexdef{HOL}{method}{pat\_completeness}\hypertarget{method.HOL.pat-completeness}{\hyperlink{method.HOL.pat-completeness}{\mbox{\isa{pat{\isaliteral{5F}{\isacharunderscore}}completeness}}}} & : & \isa{method} \\
wenzelm@28788
   693
    \indexdef{HOL}{method}{relation}\hypertarget{method.HOL.relation}{\hyperlink{method.HOL.relation}{\mbox{\isa{relation}}}} & : & \isa{method} \\
wenzelm@40685
   694
    \indexdef{HOL}{method}{lexicographic\_order}\hypertarget{method.HOL.lexicographic-order}{\hyperlink{method.HOL.lexicographic-order}{\mbox{\isa{lexicographic{\isaliteral{5F}{\isacharunderscore}}order}}}} & : & \isa{method} \\
wenzelm@40685
   695
    \indexdef{HOL}{method}{size\_change}\hypertarget{method.HOL.size-change}{\hyperlink{method.HOL.size-change}{\mbox{\isa{size{\isaliteral{5F}{\isacharunderscore}}change}}}} & : & \isa{method} \\
wenzelm@26849
   696
  \end{matharray}
wenzelm@26849
   697
wenzelm@43467
   698
  \begin{railoutput}
wenzelm@43467
   699
\rail@begin{1}{\isa{}}
wenzelm@43467
   700
\rail@term{\hyperlink{method.HOL.relation}{\mbox{\isa{relation}}}}[]
wenzelm@43467
   701
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
   702
\rail@end
wenzelm@43467
   703
\rail@begin{2}{\isa{}}
wenzelm@43467
   704
\rail@term{\hyperlink{method.HOL.lexicographic-order}{\mbox{\isa{lexicographic{\isaliteral{5F}{\isacharunderscore}}order}}}}[]
wenzelm@43467
   705
\rail@plus
wenzelm@43467
   706
\rail@nextplus{1}
wenzelm@43467
   707
\rail@cnont{\hyperlink{syntax.clasimpmod}{\mbox{\isa{clasimpmod}}}}[]
wenzelm@43467
   708
\rail@endplus
wenzelm@43467
   709
\rail@end
wenzelm@43467
   710
\rail@begin{2}{\isa{}}
wenzelm@43467
   711
\rail@term{\hyperlink{method.HOL.size-change}{\mbox{\isa{size{\isaliteral{5F}{\isacharunderscore}}change}}}}[]
wenzelm@43467
   712
\rail@nont{\isa{orders}}[]
wenzelm@43467
   713
\rail@plus
wenzelm@43467
   714
\rail@nextplus{1}
wenzelm@43467
   715
\rail@cnont{\hyperlink{syntax.clasimpmod}{\mbox{\isa{clasimpmod}}}}[]
wenzelm@43467
   716
\rail@endplus
wenzelm@43467
   717
\rail@end
wenzelm@43467
   718
\rail@begin{4}{\isa{orders}}
wenzelm@43467
   719
\rail@plus
wenzelm@43467
   720
\rail@nextplus{1}
wenzelm@43467
   721
\rail@bar
wenzelm@43467
   722
\rail@term{\isa{max}}[]
wenzelm@43467
   723
\rail@nextbar{2}
wenzelm@43467
   724
\rail@term{\isa{min}}[]
wenzelm@43467
   725
\rail@nextbar{3}
wenzelm@43467
   726
\rail@term{\isa{ms}}[]
wenzelm@43467
   727
\rail@endbar
wenzelm@43467
   728
\rail@endplus
wenzelm@43467
   729
\rail@end
wenzelm@43467
   730
\end{railoutput}
wenzelm@43467
   731
wenzelm@26849
   732
wenzelm@28788
   733
  \begin{description}
wenzelm@26849
   734
wenzelm@40685
   735
  \item \hyperlink{method.HOL.pat-completeness}{\mbox{\isa{pat{\isaliteral{5F}{\isacharunderscore}}completeness}}} is a specialized method to
wenzelm@26849
   736
  solve goals regarding the completeness of pattern matching, as
wenzelm@26902
   737
  required by the \hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}} package (cf.\
wenzelm@26849
   738
  \cite{isabelle-function}).
wenzelm@26849
   739
wenzelm@28788
   740
  \item \hyperlink{method.HOL.relation}{\mbox{\isa{relation}}}~\isa{R} introduces a termination
wenzelm@26849
   741
  proof using the relation \isa{R}.  The resulting proof state will
wenzelm@26849
   742
  contain goals expressing that \isa{R} is wellfounded, and that the
wenzelm@26849
   743
  arguments of recursive calls decrease with respect to \isa{R}.
wenzelm@26849
   744
  Usually, this method is used as the initial proof step of manual
wenzelm@26849
   745
  termination proofs.
wenzelm@26849
   746
wenzelm@40685
   747
  \item \hyperlink{method.HOL.lexicographic-order}{\mbox{\isa{lexicographic{\isaliteral{5F}{\isacharunderscore}}order}}} attempts a fully
wenzelm@26849
   748
  automated termination proof by searching for a lexicographic
wenzelm@26849
   749
  combination of size measures on the arguments of the function. The
wenzelm@26902
   750
  method accepts the same arguments as the \hyperlink{method.auto}{\mbox{\isa{auto}}} method,
wenzelm@26849
   751
  which it uses internally to prove local descents.  The same context
wenzelm@26902
   752
  modifiers as for \hyperlink{method.auto}{\mbox{\isa{auto}}} are accepted, see
wenzelm@26849
   753
  \secref{sec:clasimp}.
wenzelm@26849
   754
wenzelm@26849
   755
  In case of failure, extensive information is printed, which can help
wenzelm@26849
   756
  to analyse the situation (cf.\ \cite{isabelle-function}).
wenzelm@26849
   757
wenzelm@40685
   758
  \item \hyperlink{method.HOL.size-change}{\mbox{\isa{size{\isaliteral{5F}{\isacharunderscore}}change}}} also works on termination goals,
krauss@33858
   759
  using a variation of the size-change principle, together with a
krauss@33858
   760
  graph decomposition technique (see \cite{krauss_phd} for details).
krauss@33858
   761
  Three kinds of orders are used internally: \isa{max}, \isa{min},
krauss@33858
   762
  and \isa{ms} (multiset), which is only available when the theory
krauss@33858
   763
  \isa{Multiset} is loaded. When no order kinds are given, they are
krauss@33858
   764
  tried in order. The search for a termination proof uses SAT solving
krauss@33858
   765
  internally.
krauss@33858
   766
krauss@33858
   767
 For local descent proofs, the same context modifiers as for \hyperlink{method.auto}{\mbox{\isa{auto}}} are accepted, see \secref{sec:clasimp}.
krauss@33858
   768
wenzelm@28788
   769
  \end{description}%
wenzelm@26849
   770
\end{isamarkuptext}%
wenzelm@26849
   771
\isamarkuptrue%
wenzelm@26849
   772
%
krauss@40412
   773
\isamarkupsubsection{Functions with explicit partiality%
krauss@40412
   774
}
krauss@40412
   775
\isamarkuptrue%
krauss@40412
   776
%
krauss@40412
   777
\begin{isamarkuptext}%
krauss@40412
   778
\begin{matharray}{rcl}
wenzelm@40685
   779
    \indexdef{HOL}{command}{partial\_function}\hypertarget{command.HOL.partial-function}{\hyperlink{command.HOL.partial-function}{\mbox{\isa{\isacommand{partial{\isaliteral{5F}{\isacharunderscore}}function}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   780
    \indexdef{HOL}{attribute}{partial\_function\_mono}\hypertarget{attribute.HOL.partial-function-mono}{\hyperlink{attribute.HOL.partial-function-mono}{\mbox{\isa{partial{\isaliteral{5F}{\isacharunderscore}}function{\isaliteral{5F}{\isacharunderscore}}mono}}}} & : & \isa{attribute} \\
krauss@40412
   781
  \end{matharray}
krauss@40412
   782
wenzelm@43467
   783
  \begin{railoutput}
wenzelm@43467
   784
\rail@begin{5}{\isa{}}
wenzelm@43467
   785
\rail@term{\hyperlink{command.HOL.partial-function}{\mbox{\isa{\isacommand{partial{\isaliteral{5F}{\isacharunderscore}}function}}}}}[]
wenzelm@43467
   786
\rail@bar
wenzelm@43467
   787
\rail@nextbar{1}
wenzelm@43467
   788
\rail@nont{\hyperlink{syntax.target}{\mbox{\isa{target}}}}[]
wenzelm@43467
   789
\rail@endbar
wenzelm@43467
   790
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
   791
\rail@nont{\isa{mode}}[]
wenzelm@43467
   792
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
   793
\rail@nont{\hyperlink{syntax.fixes}{\mbox{\isa{fixes}}}}[]
wenzelm@43467
   794
\rail@cr{3}
wenzelm@43467
   795
\rail@term{\isa{\isakeyword{where}}}[]
wenzelm@43467
   796
\rail@bar
wenzelm@43467
   797
\rail@nextbar{4}
wenzelm@43467
   798
\rail@nont{\hyperlink{syntax.thmdecl}{\mbox{\isa{thmdecl}}}}[]
wenzelm@43467
   799
\rail@endbar
wenzelm@43467
   800
\rail@nont{\hyperlink{syntax.prop}{\mbox{\isa{prop}}}}[]
wenzelm@43467
   801
\rail@end
wenzelm@43467
   802
\end{railoutput}
wenzelm@43467
   803
 % FIXME check mode
krauss@40412
   804
krauss@40412
   805
  \begin{description}
krauss@40412
   806
wenzelm@40685
   807
  \item \hyperlink{command.HOL.partial-function}{\mbox{\isa{\isacommand{partial{\isaliteral{5F}{\isacharunderscore}}function}}}} defines recursive
krauss@40412
   808
  functions based on fixpoints in complete partial orders. No
krauss@40412
   809
  termination proof is required from the user or constructed
krauss@40412
   810
  internally. Instead, the possibility of non-termination is modelled
krauss@40412
   811
  explicitly in the result type, which contains an explicit bottom
krauss@40412
   812
  element.
krauss@40412
   813
krauss@40412
   814
  Pattern matching and mutual recursion are currently not supported.
krauss@40412
   815
  Thus, the specification consists of a single function described by a
krauss@40412
   816
  single recursive equation.
krauss@40412
   817
krauss@40412
   818
  There are no fixed syntactic restrictions on the body of the
krauss@40412
   819
  function, but the induced functional must be provably monotonic
krauss@40412
   820
  wrt.\ the underlying order.  The monotonicitity proof is performed
krauss@40412
   821
  internally, and the definition is rejected when it fails. The proof
krauss@40412
   822
  can be influenced by declaring hints using the
wenzelm@40685
   823
  \hyperlink{attribute.HOL.partial-function-mono}{\mbox{\isa{partial{\isaliteral{5F}{\isacharunderscore}}function{\isaliteral{5F}{\isacharunderscore}}mono}}} attribute.
krauss@40412
   824
krauss@40412
   825
  The mandatory \isa{mode} argument specifies the mode of operation
krauss@40412
   826
  of the command, which directly corresponds to a complete partial
krauss@40412
   827
  order on the result type. By default, the following modes are
wenzelm@42994
   828
  defined:
krauss@40412
   829
krauss@40412
   830
  \begin{description}
krauss@40412
   831
  \item \isa{option} defines functions that map into the \isa{option} type. Here, the value \isa{None} is used to model a
krauss@40412
   832
  non-terminating computation. Monotonicity requires that if \isa{None} is returned by a recursive call, then the overall result
krauss@40412
   833
  must also be \isa{None}. This is best achieved through the use of
wenzelm@40685
   834
  the monadic operator \isa{{\isaliteral{22}{\isachardoublequote}}Option{\isaliteral{2E}{\isachardot}}bind{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@42994
   835
krauss@40412
   836
  \item \isa{tailrec} defines functions with an arbitrary result
wenzelm@40685
   837
  type and uses the slightly degenerated partial order where \isa{{\isaliteral{22}{\isachardoublequote}}undefined{\isaliteral{22}{\isachardoublequote}}} is the bottom element.  Now, monotonicity requires that
krauss@40412
   838
  if \isa{undefined} is returned by a recursive call, then the
krauss@40412
   839
  overall result must also be \isa{undefined}. In practice, this is
krauss@40412
   840
  only satisfied when each recursive call is a tail call, whose result
krauss@40412
   841
  is directly returned. Thus, this mode of operation allows the
krauss@40412
   842
  definition of arbitrary tail-recursive functions.
krauss@40412
   843
  \end{description}
krauss@40412
   844
krauss@40412
   845
  Experienced users may define new modes by instantiating the locale
wenzelm@40685
   846
  \isa{{\isaliteral{22}{\isachardoublequote}}partial{\isaliteral{5F}{\isacharunderscore}}function{\isaliteral{5F}{\isacharunderscore}}definitions{\isaliteral{22}{\isachardoublequote}}} appropriately.
krauss@40412
   847
wenzelm@40685
   848
  \item \hyperlink{attribute.HOL.partial-function-mono}{\mbox{\isa{partial{\isaliteral{5F}{\isacharunderscore}}function{\isaliteral{5F}{\isacharunderscore}}mono}}} declares rules for
krauss@40412
   849
  use in the internal monononicity proofs of partial function
krauss@40412
   850
  definitions.
krauss@40412
   851
krauss@40412
   852
  \end{description}%
krauss@40412
   853
\end{isamarkuptext}%
krauss@40412
   854
\isamarkuptrue%
krauss@40412
   855
%
wenzelm@26849
   856
\isamarkupsubsection{Old-style recursive function definitions (TFL)%
wenzelm@26849
   857
}
wenzelm@26849
   858
\isamarkuptrue%
wenzelm@26849
   859
%
wenzelm@26849
   860
\begin{isamarkuptext}%
wenzelm@40685
   861
The old TFL commands \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} and \hyperlink{command.HOL.recdef-tc}{\mbox{\isa{\isacommand{recdef{\isaliteral{5F}{\isacharunderscore}}tc}}}} for defining recursive are mostly obsolete; \hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}} or \hyperlink{command.HOL.fun}{\mbox{\isa{\isacommand{fun}}}} should be used instead.
wenzelm@26849
   862
wenzelm@26849
   863
  \begin{matharray}{rcl}
wenzelm@40685
   864
    \indexdef{HOL}{command}{recdef}\hypertarget{command.HOL.recdef}{\hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   865
    \indexdef{HOL}{command}{recdef\_tc}\hypertarget{command.HOL.recdef-tc}{\hyperlink{command.HOL.recdef-tc}{\mbox{\isa{\isacommand{recdef{\isaliteral{5F}{\isacharunderscore}}tc}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ proof{\isaliteral{28}{\isacharparenleft}}prove{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@26849
   866
  \end{matharray}
wenzelm@26849
   867
wenzelm@43467
   868
  \begin{railoutput}
wenzelm@43467
   869
\rail@begin{5}{\isa{}}
wenzelm@43467
   870
\rail@term{\hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}}}[]
wenzelm@43467
   871
\rail@bar
wenzelm@43467
   872
\rail@nextbar{1}
wenzelm@43467
   873
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
   874
\rail@term{\isa{\isakeyword{permissive}}}[]
wenzelm@43467
   875
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
   876
\rail@endbar
wenzelm@43467
   877
\rail@cr{3}
wenzelm@43467
   878
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
   879
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
   880
\rail@plus
wenzelm@43467
   881
\rail@nont{\hyperlink{syntax.prop}{\mbox{\isa{prop}}}}[]
wenzelm@43467
   882
\rail@nextplus{4}
wenzelm@43467
   883
\rail@endplus
wenzelm@43467
   884
\rail@bar
wenzelm@43467
   885
\rail@nextbar{4}
wenzelm@43467
   886
\rail@nont{\isa{hints}}[]
wenzelm@43467
   887
\rail@endbar
wenzelm@43467
   888
\rail@end
wenzelm@43467
   889
\rail@begin{2}{\isa{}}
wenzelm@43467
   890
\rail@nont{\isa{recdeftc}}[]
wenzelm@43467
   891
\rail@bar
wenzelm@43467
   892
\rail@nextbar{1}
wenzelm@43467
   893
\rail@nont{\hyperlink{syntax.thmdecl}{\mbox{\isa{thmdecl}}}}[]
wenzelm@43467
   894
\rail@endbar
wenzelm@43467
   895
\rail@nont{\isa{tc}}[]
wenzelm@43467
   896
\rail@end
wenzelm@43467
   897
\rail@begin{2}{\isa{hints}}
wenzelm@43467
   898
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
   899
\rail@term{\isa{\isakeyword{hints}}}[]
wenzelm@43467
   900
\rail@plus
wenzelm@43467
   901
\rail@nextplus{1}
wenzelm@43467
   902
\rail@cnont{\isa{recdefmod}}[]
wenzelm@43467
   903
\rail@endplus
wenzelm@43467
   904
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
   905
\rail@end
wenzelm@43467
   906
\rail@begin{4}{\isa{recdefmod}}
wenzelm@43467
   907
\rail@bar
wenzelm@43467
   908
\rail@bar
wenzelm@43467
   909
\rail@term{\isa{recdef{\isaliteral{5F}{\isacharunderscore}}simp}}[]
wenzelm@43467
   910
\rail@nextbar{1}
wenzelm@43467
   911
\rail@term{\isa{recdef{\isaliteral{5F}{\isacharunderscore}}cong}}[]
wenzelm@43467
   912
\rail@nextbar{2}
wenzelm@43467
   913
\rail@term{\isa{recdef{\isaliteral{5F}{\isacharunderscore}}wf}}[]
wenzelm@43467
   914
\rail@endbar
wenzelm@43467
   915
\rail@bar
wenzelm@43467
   916
\rail@nextbar{1}
wenzelm@43467
   917
\rail@term{\isa{add}}[]
wenzelm@43467
   918
\rail@nextbar{2}
wenzelm@43467
   919
\rail@term{\isa{del}}[]
wenzelm@43467
   920
\rail@endbar
wenzelm@43467
   921
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
   922
\rail@nont{\hyperlink{syntax.thmrefs}{\mbox{\isa{thmrefs}}}}[]
wenzelm@43467
   923
\rail@nextbar{3}
wenzelm@43467
   924
\rail@nont{\hyperlink{syntax.clasimpmod}{\mbox{\isa{clasimpmod}}}}[]
wenzelm@43467
   925
\rail@endbar
wenzelm@43467
   926
\rail@end
wenzelm@43467
   927
\rail@begin{2}{\isa{tc}}
wenzelm@43467
   928
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
   929
\rail@bar
wenzelm@43467
   930
\rail@nextbar{1}
wenzelm@43467
   931
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
   932
\rail@nont{\hyperlink{syntax.nat}{\mbox{\isa{nat}}}}[]
wenzelm@43467
   933
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
   934
\rail@endbar
wenzelm@43467
   935
\rail@end
wenzelm@43467
   936
\end{railoutput}
wenzelm@43467
   937
wenzelm@26849
   938
wenzelm@28788
   939
  \begin{description}
wenzelm@42994
   940
wenzelm@28788
   941
  \item \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} defines general well-founded
wenzelm@26849
   942
  recursive functions (using the TFL package), see also
wenzelm@40685
   943
  \cite{isabelle-HOL}.  The ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}permissive{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}}'' option tells
wenzelm@26849
   944
  TFL to recover from failed proof attempts, returning unfinished
wenzelm@40685
   945
  results.  The \isa{recdef{\isaliteral{5F}{\isacharunderscore}}simp}, \isa{recdef{\isaliteral{5F}{\isacharunderscore}}cong}, and \isa{recdef{\isaliteral{5F}{\isacharunderscore}}wf} hints refer to auxiliary rules to be used in the internal
wenzelm@26902
   946
  automated proof process of TFL.  Additional \hyperlink{syntax.clasimpmod}{\mbox{\isa{clasimpmod}}}
wenzelm@26849
   947
  declarations (cf.\ \secref{sec:clasimp}) may be given to tune the
wenzelm@26849
   948
  context of the Simplifier (cf.\ \secref{sec:simplifier}) and
wenzelm@26849
   949
  Classical reasoner (cf.\ \secref{sec:classical}).
wenzelm@42994
   950
wenzelm@40685
   951
  \item \hyperlink{command.HOL.recdef-tc}{\mbox{\isa{\isacommand{recdef{\isaliteral{5F}{\isacharunderscore}}tc}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{28}{\isacharparenleft}}i{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} recommences the
wenzelm@26849
   952
  proof for leftover termination condition number \isa{i} (default
wenzelm@26902
   953
  1) as generated by a \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} definition of
wenzelm@26849
   954
  constant \isa{c}.
wenzelm@42994
   955
wenzelm@26902
   956
  Note that in most cases, \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} is able to finish
wenzelm@26849
   957
  its internal proofs without manual intervention.
wenzelm@26849
   958
wenzelm@28788
   959
  \end{description}
wenzelm@26849
   960
wenzelm@26902
   961
  \medskip Hints for \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} may be also declared
wenzelm@26849
   962
  globally, using the following attributes.
wenzelm@26849
   963
wenzelm@26849
   964
  \begin{matharray}{rcl}
wenzelm@40685
   965
    \indexdef{HOL}{attribute}{recdef\_simp}\hypertarget{attribute.HOL.recdef-simp}{\hyperlink{attribute.HOL.recdef-simp}{\mbox{\isa{recdef{\isaliteral{5F}{\isacharunderscore}}simp}}}} & : & \isa{attribute} \\
wenzelm@40685
   966
    \indexdef{HOL}{attribute}{recdef\_cong}\hypertarget{attribute.HOL.recdef-cong}{\hyperlink{attribute.HOL.recdef-cong}{\mbox{\isa{recdef{\isaliteral{5F}{\isacharunderscore}}cong}}}} & : & \isa{attribute} \\
wenzelm@40685
   967
    \indexdef{HOL}{attribute}{recdef\_wf}\hypertarget{attribute.HOL.recdef-wf}{\hyperlink{attribute.HOL.recdef-wf}{\mbox{\isa{recdef{\isaliteral{5F}{\isacharunderscore}}wf}}}} & : & \isa{attribute} \\
wenzelm@26849
   968
  \end{matharray}
wenzelm@26849
   969
wenzelm@43467
   970
  \begin{railoutput}
wenzelm@43467
   971
\rail@begin{3}{\isa{}}
wenzelm@43467
   972
\rail@bar
wenzelm@43467
   973
\rail@term{\hyperlink{attribute.HOL.recdef-simp}{\mbox{\isa{recdef{\isaliteral{5F}{\isacharunderscore}}simp}}}}[]
wenzelm@43467
   974
\rail@nextbar{1}
wenzelm@43467
   975
\rail@term{\hyperlink{attribute.HOL.recdef-cong}{\mbox{\isa{recdef{\isaliteral{5F}{\isacharunderscore}}cong}}}}[]
wenzelm@43467
   976
\rail@nextbar{2}
wenzelm@43467
   977
\rail@term{\hyperlink{attribute.HOL.recdef-wf}{\mbox{\isa{recdef{\isaliteral{5F}{\isacharunderscore}}wf}}}}[]
wenzelm@43467
   978
\rail@endbar
wenzelm@43467
   979
\rail@bar
wenzelm@43467
   980
\rail@nextbar{1}
wenzelm@43467
   981
\rail@term{\isa{add}}[]
wenzelm@43467
   982
\rail@nextbar{2}
wenzelm@43467
   983
\rail@term{\isa{del}}[]
wenzelm@43467
   984
\rail@endbar
wenzelm@43467
   985
\rail@end
wenzelm@43467
   986
\end{railoutput}%
wenzelm@26849
   987
\end{isamarkuptext}%
wenzelm@26849
   988
\isamarkuptrue%
wenzelm@26849
   989
%
wenzelm@26849
   990
\isamarkupsection{Inductive and coinductive definitions \label{sec:hol-inductive}%
wenzelm@26849
   991
}
wenzelm@26849
   992
\isamarkuptrue%
wenzelm@26849
   993
%
wenzelm@26849
   994
\begin{isamarkuptext}%
wenzelm@26849
   995
An \textbf{inductive definition} specifies the least predicate (or
wenzelm@26849
   996
  set) \isa{R} closed under given rules: applying a rule to elements
wenzelm@26849
   997
  of \isa{R} yields a result within \isa{R}.  For example, a
wenzelm@26849
   998
  structural operational semantics is an inductive definition of an
wenzelm@26849
   999
  evaluation relation.
wenzelm@26849
  1000
wenzelm@26849
  1001
  Dually, a \textbf{coinductive definition} specifies the greatest
wenzelm@26849
  1002
  predicate~/ set \isa{R} that is consistent with given rules: every
wenzelm@26849
  1003
  element of \isa{R} can be seen as arising by applying a rule to
wenzelm@26849
  1004
  elements of \isa{R}.  An important example is using bisimulation
wenzelm@26849
  1005
  relations to formalise equivalence of processes and infinite data
wenzelm@26849
  1006
  structures.
wenzelm@26849
  1007
wenzelm@26849
  1008
  \medskip The HOL package is related to the ZF one, which is
wenzelm@26849
  1009
  described in a separate paper,\footnote{It appeared in CADE
wenzelm@26849
  1010
  \cite{paulson-CADE}; a longer version is distributed with Isabelle.}
wenzelm@26849
  1011
  which you should refer to in case of difficulties.  The package is
wenzelm@26849
  1012
  simpler than that of ZF thanks to implicit type-checking in HOL.
wenzelm@26849
  1013
  The types of the (co)inductive predicates (or sets) determine the
wenzelm@26849
  1014
  domain of the fixedpoint definition, and the package does not have
wenzelm@26849
  1015
  to use inference rules for type-checking.
wenzelm@26849
  1016
wenzelm@26849
  1017
  \begin{matharray}{rcl}
wenzelm@40685
  1018
    \indexdef{HOL}{command}{inductive}\hypertarget{command.HOL.inductive}{\hyperlink{command.HOL.inductive}{\mbox{\isa{\isacommand{inductive}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1019
    \indexdef{HOL}{command}{inductive\_set}\hypertarget{command.HOL.inductive-set}{\hyperlink{command.HOL.inductive-set}{\mbox{\isa{\isacommand{inductive{\isaliteral{5F}{\isacharunderscore}}set}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1020
    \indexdef{HOL}{command}{coinductive}\hypertarget{command.HOL.coinductive}{\hyperlink{command.HOL.coinductive}{\mbox{\isa{\isacommand{coinductive}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1021
    \indexdef{HOL}{command}{coinductive\_set}\hypertarget{command.HOL.coinductive-set}{\hyperlink{command.HOL.coinductive-set}{\mbox{\isa{\isacommand{coinductive{\isaliteral{5F}{\isacharunderscore}}set}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@28788
  1022
    \indexdef{HOL}{attribute}{mono}\hypertarget{attribute.HOL.mono}{\hyperlink{attribute.HOL.mono}{\mbox{\isa{mono}}}} & : & \isa{attribute} \\
wenzelm@26849
  1023
  \end{matharray}
wenzelm@26849
  1024
wenzelm@43467
  1025
  \begin{railoutput}
wenzelm@43467
  1026
\rail@begin{7}{\isa{}}
wenzelm@43467
  1027
\rail@bar
wenzelm@43467
  1028
\rail@term{\hyperlink{command.HOL.inductive}{\mbox{\isa{\isacommand{inductive}}}}}[]
wenzelm@43467
  1029
\rail@nextbar{1}
wenzelm@43467
  1030
\rail@term{\hyperlink{command.HOL.inductive-set}{\mbox{\isa{\isacommand{inductive{\isaliteral{5F}{\isacharunderscore}}set}}}}}[]
wenzelm@43467
  1031
\rail@nextbar{2}
wenzelm@43467
  1032
\rail@term{\hyperlink{command.HOL.coinductive}{\mbox{\isa{\isacommand{coinductive}}}}}[]
wenzelm@43467
  1033
\rail@nextbar{3}
wenzelm@43467
  1034
\rail@term{\hyperlink{command.HOL.coinductive-set}{\mbox{\isa{\isacommand{coinductive{\isaliteral{5F}{\isacharunderscore}}set}}}}}[]
wenzelm@43467
  1035
\rail@endbar
wenzelm@43467
  1036
\rail@bar
wenzelm@43467
  1037
\rail@nextbar{1}
wenzelm@43467
  1038
\rail@nont{\hyperlink{syntax.target}{\mbox{\isa{target}}}}[]
wenzelm@43467
  1039
\rail@endbar
wenzelm@43467
  1040
\rail@nont{\hyperlink{syntax.fixes}{\mbox{\isa{fixes}}}}[]
wenzelm@43467
  1041
\rail@bar
wenzelm@43467
  1042
\rail@nextbar{1}
wenzelm@43467
  1043
\rail@term{\isa{\isakeyword{for}}}[]
wenzelm@43467
  1044
\rail@nont{\hyperlink{syntax.fixes}{\mbox{\isa{fixes}}}}[]
wenzelm@43467
  1045
\rail@endbar
wenzelm@43467
  1046
\rail@cr{5}
wenzelm@43467
  1047
\rail@bar
wenzelm@43467
  1048
\rail@nextbar{6}
wenzelm@43467
  1049
\rail@term{\isa{\isakeyword{where}}}[]
wenzelm@43467
  1050
\rail@nont{\isa{clauses}}[]
wenzelm@43467
  1051
\rail@endbar
wenzelm@43467
  1052
\rail@bar
wenzelm@43467
  1053
\rail@nextbar{6}
wenzelm@43467
  1054
\rail@term{\isa{\isakeyword{monos}}}[]
wenzelm@43467
  1055
\rail@nont{\hyperlink{syntax.thmrefs}{\mbox{\isa{thmrefs}}}}[]
wenzelm@43467
  1056
\rail@endbar
wenzelm@43467
  1057
\rail@end
wenzelm@43467
  1058
\rail@begin{3}{\isa{clauses}}
wenzelm@43467
  1059
\rail@plus
wenzelm@43467
  1060
\rail@bar
wenzelm@43467
  1061
\rail@nextbar{1}
wenzelm@43467
  1062
\rail@nont{\hyperlink{syntax.thmdecl}{\mbox{\isa{thmdecl}}}}[]
wenzelm@43467
  1063
\rail@endbar
wenzelm@43467
  1064
\rail@nont{\hyperlink{syntax.prop}{\mbox{\isa{prop}}}}[]
wenzelm@43467
  1065
\rail@nextplus{2}
wenzelm@43467
  1066
\rail@cterm{\isa{{\isaliteral{7C}{\isacharbar}}}}[]
wenzelm@43467
  1067
\rail@endplus
wenzelm@43467
  1068
\rail@end
wenzelm@43467
  1069
\rail@begin{3}{\isa{}}
wenzelm@43467
  1070
\rail@term{\hyperlink{attribute.HOL.mono}{\mbox{\isa{mono}}}}[]
wenzelm@43467
  1071
\rail@bar
wenzelm@43467
  1072
\rail@nextbar{1}
wenzelm@43467
  1073
\rail@term{\isa{add}}[]
wenzelm@43467
  1074
\rail@nextbar{2}
wenzelm@43467
  1075
\rail@term{\isa{del}}[]
wenzelm@43467
  1076
\rail@endbar
wenzelm@43467
  1077
\rail@end
wenzelm@43467
  1078
\end{railoutput}
wenzelm@43467
  1079
wenzelm@26849
  1080
wenzelm@28788
  1081
  \begin{description}
wenzelm@26849
  1082
wenzelm@28788
  1083
  \item \hyperlink{command.HOL.inductive}{\mbox{\isa{\isacommand{inductive}}}} and \hyperlink{command.HOL.coinductive}{\mbox{\isa{\isacommand{coinductive}}}} define (co)inductive predicates from the
wenzelm@26902
  1084
  introduction rules given in the \hyperlink{keyword.where}{\mbox{\isa{\isakeyword{where}}}} part.  The
wenzelm@26902
  1085
  optional \hyperlink{keyword.for}{\mbox{\isa{\isakeyword{for}}}} part contains a list of parameters of the
wenzelm@26849
  1086
  (co)inductive predicates that remain fixed throughout the
wenzelm@26902
  1087
  definition.  The optional \hyperlink{keyword.monos}{\mbox{\isa{\isakeyword{monos}}}} section contains
wenzelm@26849
  1088
  \emph{monotonicity theorems}, which are required for each operator
wenzelm@26849
  1089
  applied to a recursive set in the introduction rules.  There
wenzelm@40685
  1090
  \emph{must} be a theorem of the form \isa{{\isaliteral{22}{\isachardoublequote}}A\ {\isaliteral{5C3C6C653E}{\isasymle}}\ B\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ M\ A\ {\isaliteral{5C3C6C653E}{\isasymle}}\ M\ B{\isaliteral{22}{\isachardoublequote}}},
wenzelm@40685
  1091
  for each premise \isa{{\isaliteral{22}{\isachardoublequote}}M\ R\isaliteral{5C3C5E7375623E}{}\isactrlsub i\ t{\isaliteral{22}{\isachardoublequote}}} in an introduction rule!
wenzelm@26849
  1092
wenzelm@40685
  1093
  \item \hyperlink{command.HOL.inductive-set}{\mbox{\isa{\isacommand{inductive{\isaliteral{5F}{\isacharunderscore}}set}}}} and \hyperlink{command.HOL.coinductive-set}{\mbox{\isa{\isacommand{coinductive{\isaliteral{5F}{\isacharunderscore}}set}}}} are wrappers for to the previous commands,
wenzelm@26849
  1094
  allowing the definition of (co)inductive sets.
wenzelm@26849
  1095
wenzelm@28788
  1096
  \item \hyperlink{attribute.HOL.mono}{\mbox{\isa{mono}}} declares monotonicity rules.  These
wenzelm@26902
  1097
  rule are involved in the automated monotonicity proof of \hyperlink{command.HOL.inductive}{\mbox{\isa{\isacommand{inductive}}}}.
wenzelm@26849
  1098
wenzelm@28788
  1099
  \end{description}%
wenzelm@26849
  1100
\end{isamarkuptext}%
wenzelm@26849
  1101
\isamarkuptrue%
wenzelm@26849
  1102
%
wenzelm@26849
  1103
\isamarkupsubsection{Derived rules%
wenzelm@26849
  1104
}
wenzelm@26849
  1105
\isamarkuptrue%
wenzelm@26849
  1106
%
wenzelm@26849
  1107
\begin{isamarkuptext}%
wenzelm@26849
  1108
Each (co)inductive definition \isa{R} adds definitions to the
wenzelm@26849
  1109
  theory and also proves some theorems:
wenzelm@26849
  1110
wenzelm@26849
  1111
  \begin{description}
wenzelm@26849
  1112
wenzelm@40685
  1113
  \item \isa{R{\isaliteral{2E}{\isachardot}}intros} is the list of introduction rules as proven
wenzelm@26849
  1114
  theorems, for the recursive predicates (or sets).  The rules are
wenzelm@26849
  1115
  also available individually, using the names given them in the
wenzelm@26849
  1116
  theory file;
wenzelm@26849
  1117
wenzelm@40685
  1118
  \item \isa{R{\isaliteral{2E}{\isachardot}}cases} is the case analysis (or elimination) rule;
wenzelm@26849
  1119
wenzelm@40685
  1120
  \item \isa{R{\isaliteral{2E}{\isachardot}}induct} or \isa{R{\isaliteral{2E}{\isachardot}}coinduct} is the (co)induction
wenzelm@26849
  1121
  rule.
wenzelm@26849
  1122
wenzelm@26849
  1123
  \end{description}
wenzelm@26849
  1124
wenzelm@40685
  1125
  When several predicates \isa{{\isaliteral{22}{\isachardoublequote}}R\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ R\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{22}{\isachardoublequote}}} are
wenzelm@26849
  1126
  defined simultaneously, the list of introduction rules is called
wenzelm@40685
  1127
  \isa{{\isaliteral{22}{\isachardoublequote}}R\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{5F}{\isacharunderscore}}{\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{5F}{\isacharunderscore}}R\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{2E}{\isachardot}}intros{\isaliteral{22}{\isachardoublequote}}}, the case analysis rules are
wenzelm@40685
  1128
  called \isa{{\isaliteral{22}{\isachardoublequote}}R\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2E}{\isachardot}}cases{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ R\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{2E}{\isachardot}}cases{\isaliteral{22}{\isachardoublequote}}}, and the list
wenzelm@40685
  1129
  of mutual induction rules is called \isa{{\isaliteral{22}{\isachardoublequote}}R\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{5F}{\isacharunderscore}}{\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{5F}{\isacharunderscore}}R\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{2E}{\isachardot}}inducts{\isaliteral{22}{\isachardoublequote}}}.%
wenzelm@26849
  1130
\end{isamarkuptext}%
wenzelm@26849
  1131
\isamarkuptrue%
wenzelm@26849
  1132
%
wenzelm@26849
  1133
\isamarkupsubsection{Monotonicity theorems%
wenzelm@26849
  1134
}
wenzelm@26849
  1135
\isamarkuptrue%
wenzelm@26849
  1136
%
wenzelm@26849
  1137
\begin{isamarkuptext}%
wenzelm@26849
  1138
Each theory contains a default set of theorems that are used in
wenzelm@26849
  1139
  monotonicity proofs.  New rules can be added to this set via the
wenzelm@26902
  1140
  \hyperlink{attribute.HOL.mono}{\mbox{\isa{mono}}} attribute.  The HOL theory \isa{Inductive}
wenzelm@26849
  1141
  shows how this is done.  In general, the following monotonicity
wenzelm@26849
  1142
  theorems may be added:
wenzelm@26849
  1143
wenzelm@26849
  1144
  \begin{itemize}
wenzelm@26849
  1145
wenzelm@40685
  1146
  \item Theorems of the form \isa{{\isaliteral{22}{\isachardoublequote}}A\ {\isaliteral{5C3C6C653E}{\isasymle}}\ B\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ M\ A\ {\isaliteral{5C3C6C653E}{\isasymle}}\ M\ B{\isaliteral{22}{\isachardoublequote}}}, for proving
wenzelm@26849
  1147
  monotonicity of inductive definitions whose introduction rules have
wenzelm@40685
  1148
  premises involving terms such as \isa{{\isaliteral{22}{\isachardoublequote}}M\ R\isaliteral{5C3C5E7375623E}{}\isactrlsub i\ t{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@26849
  1149
wenzelm@26849
  1150
  \item Monotonicity theorems for logical operators, which are of the
wenzelm@40685
  1151
  general form \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{5C3C6C6F6E6772696768746172726F773E}{\isasymlongrightarrow}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{5C3C6C6F6E6772696768746172726F773E}{\isasymlongrightarrow}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{5C3C6C6F6E6772696768746172726F773E}{\isasymlongrightarrow}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{22}{\isachardoublequote}}}.  For example, in
wenzelm@40685
  1152
  the case of the operator \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6F723E}{\isasymor}}{\isaliteral{22}{\isachardoublequote}}}, the corresponding theorem is
wenzelm@26849
  1153
  \[
wenzelm@40685
  1154
  \infer{\isa{{\isaliteral{22}{\isachardoublequote}}P\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C6F723E}{\isasymor}}\ P\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}\ {\isaliteral{5C3C6C6F6E6772696768746172726F773E}{\isasymlongrightarrow}}\ Q\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C6F723E}{\isasymor}}\ Q\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}{\isaliteral{22}{\isachardoublequote}}}}{\isa{{\isaliteral{22}{\isachardoublequote}}P\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C6C6F6E6772696768746172726F773E}{\isasymlongrightarrow}}\ Q\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{22}{\isachardoublequote}}} & \isa{{\isaliteral{22}{\isachardoublequote}}P\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}\ {\isaliteral{5C3C6C6F6E6772696768746172726F773E}{\isasymlongrightarrow}}\ Q\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}{\isaliteral{22}{\isachardoublequote}}}}
wenzelm@26849
  1155
  \]
wenzelm@26849
  1156
wenzelm@26849
  1157
  \item De Morgan style equations for reasoning about the ``polarity''
wenzelm@26849
  1158
  of expressions, e.g.
wenzelm@26849
  1159
  \[
wenzelm@40685
  1160
  \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6E6F743E}{\isasymnot}}\ {\isaliteral{5C3C6E6F743E}{\isasymnot}}\ P\ {\isaliteral{5C3C6C6F6E676C65667472696768746172726F773E}{\isasymlongleftrightarrow}}\ P{\isaliteral{22}{\isachardoublequote}}} \qquad\qquad
wenzelm@40685
  1161
  \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6E6F743E}{\isasymnot}}\ {\isaliteral{28}{\isacharparenleft}}P\ {\isaliteral{5C3C616E643E}{\isasymand}}\ Q{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{5C3C6C6F6E676C65667472696768746172726F773E}{\isasymlongleftrightarrow}}\ {\isaliteral{5C3C6E6F743E}{\isasymnot}}\ P\ {\isaliteral{5C3C6F723E}{\isasymor}}\ {\isaliteral{5C3C6E6F743E}{\isasymnot}}\ Q{\isaliteral{22}{\isachardoublequote}}}
wenzelm@26849
  1162
  \]
wenzelm@26849
  1163
wenzelm@26849
  1164
  \item Equations for reducing complex operators to more primitive
wenzelm@26849
  1165
  ones whose monotonicity can easily be proved, e.g.
wenzelm@26849
  1166
  \[
wenzelm@40685
  1167
  \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}P\ {\isaliteral{5C3C6C6F6E6772696768746172726F773E}{\isasymlongrightarrow}}\ Q{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{5C3C6C6F6E676C65667472696768746172726F773E}{\isasymlongleftrightarrow}}\ {\isaliteral{5C3C6E6F743E}{\isasymnot}}\ P\ {\isaliteral{5C3C6F723E}{\isasymor}}\ Q{\isaliteral{22}{\isachardoublequote}}} \qquad\qquad
wenzelm@40685
  1168
  \isa{{\isaliteral{22}{\isachardoublequote}}Ball\ A\ P\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ {\isaliteral{5C3C666F72616C6C3E}{\isasymforall}}x{\isaliteral{2E}{\isachardot}}\ x\ {\isaliteral{5C3C696E3E}{\isasymin}}\ A\ {\isaliteral{5C3C6C6F6E6772696768746172726F773E}{\isasymlongrightarrow}}\ P\ x{\isaliteral{22}{\isachardoublequote}}}
wenzelm@26849
  1169
  \]
wenzelm@26849
  1170
wenzelm@26849
  1171
  \end{itemize}
wenzelm@26849
  1172
wenzelm@26849
  1173
  %FIXME: Example of an inductive definition%
wenzelm@26849
  1174
\end{isamarkuptext}%
wenzelm@26849
  1175
\isamarkuptrue%
wenzelm@26849
  1176
%
wenzelm@26849
  1177
\isamarkupsection{Arithmetic proof support%
wenzelm@26849
  1178
}
wenzelm@26849
  1179
\isamarkuptrue%
wenzelm@26849
  1180
%
wenzelm@26849
  1181
\begin{isamarkuptext}%
wenzelm@26849
  1182
\begin{matharray}{rcl}
wenzelm@28788
  1183
    \indexdef{HOL}{method}{arith}\hypertarget{method.HOL.arith}{\hyperlink{method.HOL.arith}{\mbox{\isa{arith}}}} & : & \isa{method} \\
nipkow@30863
  1184
    \indexdef{HOL}{attribute}{arith}\hypertarget{attribute.HOL.arith}{\hyperlink{attribute.HOL.arith}{\mbox{\isa{arith}}}} & : & \isa{attribute} \\
wenzelm@40685
  1185
    \indexdef{HOL}{attribute}{arith\_split}\hypertarget{attribute.HOL.arith-split}{\hyperlink{attribute.HOL.arith-split}{\mbox{\isa{arith{\isaliteral{5F}{\isacharunderscore}}split}}}} & : & \isa{attribute} \\
wenzelm@26849
  1186
  \end{matharray}
wenzelm@26849
  1187
wenzelm@26902
  1188
  The \hyperlink{method.HOL.arith}{\mbox{\isa{arith}}} method decides linear arithmetic problems
wenzelm@26849
  1189
  (on types \isa{nat}, \isa{int}, \isa{real}).  Any current
wenzelm@26849
  1190
  facts are inserted into the goal before running the procedure.
wenzelm@26849
  1191
nipkow@30863
  1192
  The \hyperlink{attribute.HOL.arith}{\mbox{\isa{arith}}} attribute declares facts that are
nipkow@30863
  1193
  always supplied to the arithmetic provers implicitly.
nipkow@30863
  1194
wenzelm@40685
  1195
  The \hyperlink{attribute.HOL.arith-split}{\mbox{\isa{arith{\isaliteral{5F}{\isacharunderscore}}split}}} attribute declares case split
wenzelm@30865
  1196
  rules to be expanded before \hyperlink{method.HOL.arith}{\mbox{\isa{arith}}} is invoked.
wenzelm@26849
  1197
nipkow@30863
  1198
  Note that a simpler (but faster) arithmetic prover is
nipkow@30863
  1199
  already invoked by the Simplifier.%
wenzelm@26849
  1200
\end{isamarkuptext}%
wenzelm@26849
  1201
\isamarkuptrue%
wenzelm@26849
  1202
%
wenzelm@30172
  1203
\isamarkupsection{Intuitionistic proof search%
wenzelm@30172
  1204
}
wenzelm@30172
  1205
\isamarkuptrue%
wenzelm@30172
  1206
%
wenzelm@30172
  1207
\begin{isamarkuptext}%
wenzelm@30172
  1208
\begin{matharray}{rcl}
wenzelm@30172
  1209
    \indexdef{HOL}{method}{iprover}\hypertarget{method.HOL.iprover}{\hyperlink{method.HOL.iprover}{\mbox{\isa{iprover}}}} & : & \isa{method} \\
wenzelm@30172
  1210
  \end{matharray}
wenzelm@30172
  1211
wenzelm@43467
  1212
  \begin{railoutput}
wenzelm@43467
  1213
\rail@begin{2}{\isa{}}
wenzelm@43467
  1214
\rail@term{\hyperlink{method.HOL.iprover}{\mbox{\isa{iprover}}}}[]
wenzelm@43467
  1215
\rail@plus
wenzelm@43467
  1216
\rail@nextplus{1}
wenzelm@43467
  1217
\rail@cnont{\hyperlink{syntax.rulemod}{\mbox{\isa{rulemod}}}}[]
wenzelm@43467
  1218
\rail@endplus
wenzelm@43467
  1219
\rail@end
wenzelm@43467
  1220
\end{railoutput}
wenzelm@43467
  1221
wenzelm@30172
  1222
wenzelm@30172
  1223
  The \hyperlink{method.HOL.iprover}{\mbox{\isa{iprover}}} method performs intuitionistic proof
wenzelm@30172
  1224
  search, depending on specifically declared rules from the context,
wenzelm@30172
  1225
  or given as explicit arguments.  Chained facts are inserted into the
wenzelm@35613
  1226
  goal before commencing proof search.
wenzelm@35613
  1227
wenzelm@30172
  1228
  Rules need to be classified as \hyperlink{attribute.Pure.intro}{\mbox{\isa{intro}}},
wenzelm@30172
  1229
  \hyperlink{attribute.Pure.elim}{\mbox{\isa{elim}}}, or \hyperlink{attribute.Pure.dest}{\mbox{\isa{dest}}}; here the
wenzelm@40685
  1230
  ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{21}{\isacharbang}}{\isaliteral{22}{\isachardoublequote}}}'' indicator refers to ``safe'' rules, which may be
wenzelm@30172
  1231
  applied aggressively (without considering back-tracking later).
wenzelm@40685
  1232
  Rules declared with ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3F}{\isacharquery}}{\isaliteral{22}{\isachardoublequote}}}'' are ignored in proof search (the
wenzelm@30172
  1233
  single-step \hyperlink{method.rule}{\mbox{\isa{rule}}} method still observes these).  An
wenzelm@30172
  1234
  explicit weight annotation may be given as well; otherwise the
wenzelm@30172
  1235
  number of rule premises will be taken into account here.%
wenzelm@30172
  1236
\end{isamarkuptext}%
wenzelm@30172
  1237
\isamarkuptrue%
wenzelm@30172
  1238
%
wenzelm@30172
  1239
\isamarkupsection{Coherent Logic%
wenzelm@30172
  1240
}
wenzelm@30172
  1241
\isamarkuptrue%
wenzelm@30172
  1242
%
wenzelm@30172
  1243
\begin{isamarkuptext}%
wenzelm@30172
  1244
\begin{matharray}{rcl}
wenzelm@30172
  1245
    \indexdef{HOL}{method}{coherent}\hypertarget{method.HOL.coherent}{\hyperlink{method.HOL.coherent}{\mbox{\isa{coherent}}}} & : & \isa{method} \\
wenzelm@30172
  1246
  \end{matharray}
wenzelm@30172
  1247
wenzelm@43467
  1248
  \begin{railoutput}
wenzelm@43467
  1249
\rail@begin{2}{\isa{}}
wenzelm@43467
  1250
\rail@term{\hyperlink{method.HOL.coherent}{\mbox{\isa{coherent}}}}[]
wenzelm@43467
  1251
\rail@bar
wenzelm@43467
  1252
\rail@nextbar{1}
wenzelm@43467
  1253
\rail@nont{\hyperlink{syntax.thmrefs}{\mbox{\isa{thmrefs}}}}[]
wenzelm@43467
  1254
\rail@endbar
wenzelm@43467
  1255
\rail@end
wenzelm@43467
  1256
\end{railoutput}
wenzelm@43467
  1257
wenzelm@30172
  1258
wenzelm@30172
  1259
  The \hyperlink{method.HOL.coherent}{\mbox{\isa{coherent}}} method solves problems of
wenzelm@30172
  1260
  \emph{Coherent Logic} \cite{Bezem-Coquand:2005}, which covers
wenzelm@30172
  1261
  applications in confluence theory, lattice theory and projective
wenzelm@41052
  1262
  geometry.  See \verb|~~/src/HOL/ex/Coherent.thy| for some
wenzelm@30172
  1263
  examples.%
wenzelm@30172
  1264
\end{isamarkuptext}%
wenzelm@30172
  1265
\isamarkuptrue%
wenzelm@30172
  1266
%
blanchet@43082
  1267
\isamarkupsection{Proving propositions%
blanchet@43082
  1268
}
blanchet@43082
  1269
\isamarkuptrue%
blanchet@43082
  1270
%
blanchet@43082
  1271
\begin{isamarkuptext}%
blanchet@43082
  1272
In addition to the standard proof methods, a number of diagnosis
blanchet@43082
  1273
  tools search for proofs and provide an Isar proof snippet on success.
blanchet@43082
  1274
  These tools are available via the following commands.
blanchet@43082
  1275
blanchet@43082
  1276
  \begin{matharray}{rcl}
blanchet@43082
  1277
    \indexdef{HOL}{command}{solve\_direct}\hypertarget{command.HOL.solve-direct}{\hyperlink{command.HOL.solve-direct}{\mbox{\isa{\isacommand{solve{\isaliteral{5F}{\isacharunderscore}}direct}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}proof\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
blanchet@43082
  1278
    \indexdef{HOL}{command}{try}\hypertarget{command.HOL.try}{\hyperlink{command.HOL.try}{\mbox{\isa{\isacommand{try}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}proof\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
blanchet@43082
  1279
    \indexdef{HOL}{command}{sledgehammer}\hypertarget{command.HOL.sledgehammer}{\hyperlink{command.HOL.sledgehammer}{\mbox{\isa{\isacommand{sledgehammer}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}proof\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
blanchet@43082
  1280
    \indexdef{HOL}{command}{sledgehammer\_params}\hypertarget{command.HOL.sledgehammer-params}{\hyperlink{command.HOL.sledgehammer-params}{\mbox{\isa{\isacommand{sledgehammer{\isaliteral{5F}{\isacharunderscore}}params}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}}
blanchet@43082
  1281
  \end{matharray}
blanchet@43082
  1282
wenzelm@43467
  1283
  \begin{railoutput}
wenzelm@43467
  1284
\rail@begin{6}{\isa{}}
wenzelm@43467
  1285
\rail@term{\hyperlink{command.HOL.try}{\mbox{\isa{\isacommand{try}}}}}[]
wenzelm@43467
  1286
\rail@bar
wenzelm@43467
  1287
\rail@nextbar{1}
wenzelm@43467
  1288
\rail@plus
wenzelm@43467
  1289
\rail@bar
wenzelm@43467
  1290
\rail@term{\isa{simp}}[]
wenzelm@43467
  1291
\rail@nextbar{2}
wenzelm@43467
  1292
\rail@term{\isa{intro}}[]
wenzelm@43467
  1293
\rail@nextbar{3}
wenzelm@43467
  1294
\rail@term{\isa{elim}}[]
wenzelm@43467
  1295
\rail@nextbar{4}
wenzelm@43467
  1296
\rail@term{\isa{dest}}[]
wenzelm@43467
  1297
\rail@endbar
wenzelm@43467
  1298
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
  1299
\rail@nont{\hyperlink{syntax.thmrefs}{\mbox{\isa{thmrefs}}}}[]
wenzelm@43467
  1300
\rail@nextplus{5}
wenzelm@43467
  1301
\rail@endplus
wenzelm@43467
  1302
\rail@endbar
wenzelm@43467
  1303
\rail@bar
wenzelm@43467
  1304
\rail@nextbar{1}
wenzelm@43467
  1305
\rail@nont{\hyperlink{syntax.nat}{\mbox{\isa{nat}}}}[]
wenzelm@43467
  1306
\rail@endbar
wenzelm@43467
  1307
\rail@end
wenzelm@43467
  1308
\rail@begin{2}{\isa{}}
wenzelm@43467
  1309
\rail@term{\hyperlink{command.HOL.sledgehammer}{\mbox{\isa{\isacommand{sledgehammer}}}}}[]
wenzelm@43467
  1310
\rail@bar
wenzelm@43467
  1311
\rail@nextbar{1}
wenzelm@43467
  1312
\rail@term{\isa{{\isaliteral{5B}{\isacharbrackleft}}}}[]
wenzelm@43467
  1313
\rail@nont{\isa{args}}[]
wenzelm@43467
  1314
\rail@term{\isa{{\isaliteral{5D}{\isacharbrackright}}}}[]
wenzelm@43467
  1315
\rail@endbar
wenzelm@43467
  1316
\rail@bar
wenzelm@43467
  1317
\rail@nextbar{1}
wenzelm@43467
  1318
\rail@nont{\isa{facts}}[]
wenzelm@43467
  1319
\rail@endbar
wenzelm@43467
  1320
\rail@bar
wenzelm@43467
  1321
\rail@nextbar{1}
wenzelm@43467
  1322
\rail@nont{\hyperlink{syntax.nat}{\mbox{\isa{nat}}}}[]
wenzelm@43467
  1323
\rail@endbar
wenzelm@43467
  1324
\rail@end
wenzelm@43467
  1325
\rail@begin{2}{\isa{}}
wenzelm@43467
  1326
\rail@term{\hyperlink{command.HOL.sledgehammer-params}{\mbox{\isa{\isacommand{sledgehammer{\isaliteral{5F}{\isacharunderscore}}params}}}}}[]
wenzelm@43467
  1327
\rail@bar
wenzelm@43467
  1328
\rail@nextbar{1}
wenzelm@43467
  1329
\rail@term{\isa{{\isaliteral{5B}{\isacharbrackleft}}}}[]
wenzelm@43467
  1330
\rail@nont{\isa{args}}[]
wenzelm@43467
  1331
\rail@term{\isa{{\isaliteral{5D}{\isacharbrackright}}}}[]
wenzelm@43467
  1332
\rail@endbar
wenzelm@43467
  1333
\rail@end
wenzelm@43467
  1334
\rail@begin{2}{\isa{args}}
wenzelm@43467
  1335
\rail@plus
wenzelm@43467
  1336
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  1337
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43467
  1338
\rail@nont{\isa{value}}[]
wenzelm@43467
  1339
\rail@nextplus{1}
wenzelm@43467
  1340
\rail@cterm{\isa{{\isaliteral{2C}{\isacharcomma}}}}[]
wenzelm@43467
  1341
\rail@endplus
wenzelm@43467
  1342
\rail@end
wenzelm@43467
  1343
\rail@begin{5}{\isa{facts}}
wenzelm@43467
  1344
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  1345
\rail@bar
wenzelm@43467
  1346
\rail@nextbar{1}
wenzelm@43467
  1347
\rail@plus
wenzelm@43467
  1348
\rail@bar
wenzelm@43467
  1349
\rail@nextbar{2}
wenzelm@43467
  1350
\rail@bar
wenzelm@43467
  1351
\rail@term{\isa{add}}[]
wenzelm@43467
  1352
\rail@nextbar{3}
wenzelm@43467
  1353
\rail@term{\isa{del}}[]
wenzelm@43467
  1354
\rail@endbar
wenzelm@43467
  1355
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
  1356
\rail@endbar
wenzelm@43467
  1357
\rail@nont{\hyperlink{syntax.thmrefs}{\mbox{\isa{thmrefs}}}}[]
wenzelm@43467
  1358
\rail@nextplus{4}
wenzelm@43467
  1359
\rail@endplus
wenzelm@43467
  1360
\rail@endbar
wenzelm@43467
  1361
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  1362
\rail@end
wenzelm@43467
  1363
\end{railoutput}
wenzelm@43467
  1364
 % FIXME try: proper clasimpmod!?
wenzelm@43467
  1365
  % FIXME check args "value"
blanchet@43082
  1366
blanchet@43082
  1367
  \begin{description}
blanchet@43082
  1368
blanchet@43082
  1369
  \item \hyperlink{command.HOL.solve-direct}{\mbox{\isa{\isacommand{solve{\isaliteral{5F}{\isacharunderscore}}direct}}}} checks whether the current subgoals can
blanchet@43082
  1370
    be solved directly by an existing theorem. Duplicate lemmas can be detected
blanchet@43082
  1371
    in this way.
blanchet@43082
  1372
blanchet@43082
  1373
  \item \hyperlink{command.HOL.try}{\mbox{\isa{\isacommand{try}}}} attempts to prove a subgoal using a combination
blanchet@43082
  1374
    of standard proof methods (\isa{auto}, \isa{simp}, \isa{blast}, etc.).
blanchet@43082
  1375
    Additional facts supplied via \isa{{\isaliteral{22}{\isachardoublequote}}simp{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}}, \isa{{\isaliteral{22}{\isachardoublequote}}intro{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}},
blanchet@43082
  1376
    \isa{{\isaliteral{22}{\isachardoublequote}}elim{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}}, and \isa{{\isaliteral{22}{\isachardoublequote}}dest{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}} are passed to the appropriate proof
blanchet@43082
  1377
    methods.
blanchet@43082
  1378
blanchet@43082
  1379
  \item \hyperlink{command.HOL.sledgehammer}{\mbox{\isa{\isacommand{sledgehammer}}}} attempts to prove a subgoal using external
blanchet@43082
  1380
    automatic provers (resolution provers and SMT solvers). See the Sledgehammer
blanchet@43082
  1381
    manual \cite{isabelle-sledgehammer} for details.
blanchet@43082
  1382
blanchet@43082
  1383
  \item \hyperlink{command.HOL.sledgehammer-params}{\mbox{\isa{\isacommand{sledgehammer{\isaliteral{5F}{\isacharunderscore}}params}}}} changes
blanchet@43082
  1384
    \hyperlink{command.HOL.sledgehammer}{\mbox{\isa{\isacommand{sledgehammer}}}} configuration options persistently.
blanchet@43082
  1385
blanchet@43082
  1386
  \end{description}%
blanchet@43082
  1387
\end{isamarkuptext}%
blanchet@43082
  1388
\isamarkuptrue%
blanchet@43082
  1389
%
haftmann@31907
  1390
\isamarkupsection{Checking and refuting propositions%
haftmann@31907
  1391
}
haftmann@31907
  1392
\isamarkuptrue%
haftmann@31907
  1393
%
haftmann@31907
  1394
\begin{isamarkuptext}%
haftmann@31907
  1395
Identifying incorrect propositions usually involves evaluation of
blanchet@43082
  1396
  particular assignments and systematic counterexample search.  This
haftmann@31907
  1397
  is supported by the following commands.
haftmann@31907
  1398
haftmann@31907
  1399
  \begin{matharray}{rcl}
wenzelm@40685
  1400
    \indexdef{HOL}{command}{value}\hypertarget{command.HOL.value}{\hyperlink{command.HOL.value}{\mbox{\isa{\isacommand{value}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}context\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1401
    \indexdef{HOL}{command}{quickcheck}\hypertarget{command.HOL.quickcheck}{\hyperlink{command.HOL.quickcheck}{\mbox{\isa{\isacommand{quickcheck}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}proof\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
blanchet@43082
  1402
    \indexdef{HOL}{command}{refute}\hypertarget{command.HOL.refute}{\hyperlink{command.HOL.refute}{\mbox{\isa{\isacommand{refute}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}proof\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
blanchet@43082
  1403
    \indexdef{HOL}{command}{nitpick}\hypertarget{command.HOL.nitpick}{\hyperlink{command.HOL.nitpick}{\mbox{\isa{\isacommand{nitpick}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}proof\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
blanchet@43082
  1404
    \indexdef{HOL}{command}{quickcheck\_params}\hypertarget{command.HOL.quickcheck-params}{\hyperlink{command.HOL.quickcheck-params}{\mbox{\isa{\isacommand{quickcheck{\isaliteral{5F}{\isacharunderscore}}params}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
blanchet@43082
  1405
    \indexdef{HOL}{command}{refute\_params}\hypertarget{command.HOL.refute-params}{\hyperlink{command.HOL.refute-params}{\mbox{\isa{\isacommand{refute{\isaliteral{5F}{\isacharunderscore}}params}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
blanchet@43082
  1406
    \indexdef{HOL}{command}{nitpick\_params}\hypertarget{command.HOL.nitpick-params}{\hyperlink{command.HOL.nitpick-params}{\mbox{\isa{\isacommand{nitpick{\isaliteral{5F}{\isacharunderscore}}params}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}}
haftmann@31907
  1407
  \end{matharray}
haftmann@31907
  1408
wenzelm@43467
  1409
  \begin{railoutput}
wenzelm@43467
  1410
\rail@begin{2}{\isa{}}
wenzelm@43467
  1411
\rail@term{\hyperlink{command.HOL.value}{\mbox{\isa{\isacommand{value}}}}}[]
wenzelm@43467
  1412
\rail@bar
wenzelm@43467
  1413
\rail@nextbar{1}
wenzelm@43467
  1414
\rail@term{\isa{{\isaliteral{5B}{\isacharbrackleft}}}}[]
wenzelm@43467
  1415
\rail@nont{\isa{name}}[]
wenzelm@43467
  1416
\rail@term{\isa{{\isaliteral{5D}{\isacharbrackright}}}}[]
wenzelm@43467
  1417
\rail@endbar
wenzelm@43467
  1418
\rail@bar
wenzelm@43467
  1419
\rail@nextbar{1}
wenzelm@43467
  1420
\rail@nont{\isa{modes}}[]
wenzelm@43467
  1421
\rail@endbar
wenzelm@43467
  1422
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
  1423
\rail@end
wenzelm@43467
  1424
\rail@begin{3}{\isa{}}
wenzelm@43467
  1425
\rail@bar
wenzelm@43467
  1426
\rail@term{\hyperlink{command.HOL.quickcheck}{\mbox{\isa{\isacommand{quickcheck}}}}}[]
wenzelm@43467
  1427
\rail@nextbar{1}
wenzelm@43467
  1428
\rail@term{\hyperlink{command.HOL.refute}{\mbox{\isa{\isacommand{refute}}}}}[]
wenzelm@43467
  1429
\rail@nextbar{2}
wenzelm@43467
  1430
\rail@term{\hyperlink{command.HOL.nitpick}{\mbox{\isa{\isacommand{nitpick}}}}}[]
wenzelm@43467
  1431
\rail@endbar
wenzelm@43467
  1432
\rail@bar
wenzelm@43467
  1433
\rail@nextbar{1}
wenzelm@43467
  1434
\rail@term{\isa{{\isaliteral{5B}{\isacharbrackleft}}}}[]
wenzelm@43467
  1435
\rail@nont{\isa{args}}[]
wenzelm@43467
  1436
\rail@term{\isa{{\isaliteral{5D}{\isacharbrackright}}}}[]
wenzelm@43467
  1437
\rail@endbar
wenzelm@43467
  1438
\rail@bar
wenzelm@43467
  1439
\rail@nextbar{1}
wenzelm@43467
  1440
\rail@nont{\hyperlink{syntax.nat}{\mbox{\isa{nat}}}}[]
wenzelm@43467
  1441
\rail@endbar
wenzelm@43467
  1442
\rail@end
wenzelm@43467
  1443
\rail@begin{3}{\isa{}}
wenzelm@43467
  1444
\rail@bar
wenzelm@43467
  1445
\rail@term{\hyperlink{command.HOL.quickcheck-params}{\mbox{\isa{\isacommand{quickcheck{\isaliteral{5F}{\isacharunderscore}}params}}}}}[]
wenzelm@43467
  1446
\rail@nextbar{1}
wenzelm@43467
  1447
\rail@term{\hyperlink{command.HOL.refute-params}{\mbox{\isa{\isacommand{refute{\isaliteral{5F}{\isacharunderscore}}params}}}}}[]
wenzelm@43467
  1448
\rail@nextbar{2}
wenzelm@43467
  1449
\rail@term{\hyperlink{command.HOL.nitpick-params}{\mbox{\isa{\isacommand{nitpick{\isaliteral{5F}{\isacharunderscore}}params}}}}}[]
wenzelm@43467
  1450
\rail@endbar
wenzelm@43467
  1451
\rail@bar
wenzelm@43467
  1452
\rail@nextbar{1}
wenzelm@43467
  1453
\rail@term{\isa{{\isaliteral{5B}{\isacharbrackleft}}}}[]
wenzelm@43467
  1454
\rail@nont{\isa{args}}[]
wenzelm@43467
  1455
\rail@term{\isa{{\isaliteral{5D}{\isacharbrackright}}}}[]
wenzelm@43467
  1456
\rail@endbar
wenzelm@43467
  1457
\rail@end
wenzelm@43467
  1458
\rail@begin{2}{\isa{modes}}
wenzelm@43467
  1459
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  1460
\rail@plus
wenzelm@43467
  1461
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  1462
\rail@nextplus{1}
wenzelm@43467
  1463
\rail@endplus
wenzelm@43467
  1464
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  1465
\rail@end
wenzelm@43467
  1466
\rail@begin{2}{\isa{args}}
wenzelm@43467
  1467
\rail@plus
wenzelm@43467
  1468
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  1469
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43467
  1470
\rail@nont{\isa{value}}[]
wenzelm@43467
  1471
\rail@nextplus{1}
wenzelm@43467
  1472
\rail@cterm{\isa{{\isaliteral{2C}{\isacharcomma}}}}[]
wenzelm@43467
  1473
\rail@endplus
wenzelm@43467
  1474
\rail@end
wenzelm@43467
  1475
\end{railoutput}
wenzelm@43467
  1476
 % FIXME check "value"
haftmann@31907
  1477
haftmann@31907
  1478
  \begin{description}
haftmann@31907
  1479
haftmann@31907
  1480
  \item \hyperlink{command.HOL.value}{\mbox{\isa{\isacommand{value}}}}~\isa{t} evaluates and prints a
haftmann@31907
  1481
    term; optionally \isa{modes} can be specified, which are
haftmann@31907
  1482
    appended to the current print mode (see also \cite{isabelle-ref}).
haftmann@31907
  1483
    Internally, the evaluation is performed by registered evaluators,
haftmann@31907
  1484
    which are invoked sequentially until a result is returned.
haftmann@31907
  1485
    Alternatively a specific evaluator can be selected using square
haftmann@37419
  1486
    brackets; typical evaluators use the current set of code equations
haftmann@37419
  1487
    to normalize and include \isa{simp} for fully symbolic evaluation
haftmann@37419
  1488
    using the simplifier, \isa{nbe} for \emph{normalization by evaluation}
haftmann@37419
  1489
    and \emph{code} for code generation in SML.
haftmann@31907
  1490
haftmann@31907
  1491
  \item \hyperlink{command.HOL.quickcheck}{\mbox{\isa{\isacommand{quickcheck}}}} tests the current goal for
blanchet@43082
  1492
    counterexamples using a series of assignments for its
haftmann@31907
  1493
    free variables; by default the first subgoal is tested, an other
haftmann@31907
  1494
    can be selected explicitly using an optional goal index.
wenzelm@41185
  1495
    Assignments can be chosen exhausting the search space upto a given
wenzelm@41185
  1496
    size or using a fixed number of random assignments in the search space.
wenzelm@41185
  1497
    By default, quickcheck uses exhaustive testing.
haftmann@31907
  1498
    A number of configuration options are supported for
haftmann@31907
  1499
    \hyperlink{command.HOL.quickcheck}{\mbox{\isa{\isacommand{quickcheck}}}}, notably:
haftmann@31907
  1500
haftmann@31907
  1501
    \begin{description}
haftmann@31907
  1502
wenzelm@41185
  1503
    \item[\isa{tester}] specifies how to explore the search space
wenzelm@41185
  1504
      (e.g. exhaustive or random).
wenzelm@41185
  1505
      An unknown configuration option is treated as an argument to tester,
wenzelm@41185
  1506
      making \isa{{\isaliteral{22}{\isachardoublequote}}tester\ {\isaliteral{3D}{\isacharequal}}{\isaliteral{22}{\isachardoublequote}}} optional.
wenzelm@40515
  1507
    \item[\isa{size}] specifies the maximum size of the search space
wenzelm@40515
  1508
    for assignment values.
haftmann@31907
  1509
wenzelm@42994
  1510
    \item[\isa{eval}] takes a term or a list of terms and evaluates
wenzelm@42994
  1511
      these terms under the variable assignment found by quickcheck.
wenzelm@42994
  1512
wenzelm@40515
  1513
    \item[\isa{iterations}] sets how many sets of assignments are
wenzelm@40515
  1514
    generated for each particular size.
haftmann@31907
  1515
wenzelm@40685
  1516
    \item[\isa{no{\isaliteral{5F}{\isacharunderscore}}assms}] specifies whether assumptions in
wenzelm@40515
  1517
    structured proofs should be ignored.
wenzelm@40515
  1518
wenzelm@40515
  1519
    \item[\isa{timeout}] sets the time limit in seconds.
wenzelm@40515
  1520
wenzelm@40685
  1521
    \item[\isa{default{\isaliteral{5F}{\isacharunderscore}}type}] sets the type(s) generally used to
wenzelm@40515
  1522
    instantiate type variables.
wenzelm@40515
  1523
wenzelm@40515
  1524
    \item[\isa{report}] if set quickcheck reports how many tests
wenzelm@40515
  1525
    fulfilled the preconditions.
wenzelm@40515
  1526
wenzelm@40515
  1527
    \item[\isa{quiet}] if not set quickcheck informs about the
wenzelm@40515
  1528
    current size for assignment values.
wenzelm@40515
  1529
wenzelm@40515
  1530
    \item[\isa{expect}] can be used to check if the user's
wenzelm@40685
  1531
    expectation was met (\isa{no{\isaliteral{5F}{\isacharunderscore}}expectation}, \isa{no{\isaliteral{5F}{\isacharunderscore}}counterexample}, or \isa{counterexample}).
wenzelm@35352
  1532
haftmann@31907
  1533
    \end{description}
haftmann@31907
  1534
haftmann@31907
  1535
    These option can be given within square brackets.
haftmann@31907
  1536
blanchet@43082
  1537
  \item \hyperlink{command.HOL.quickcheck-params}{\mbox{\isa{\isacommand{quickcheck{\isaliteral{5F}{\isacharunderscore}}params}}}} changes
blanchet@43082
  1538
    \hyperlink{command.HOL.quickcheck}{\mbox{\isa{\isacommand{quickcheck}}}} configuration options persistently.
blanchet@43082
  1539
blanchet@43082
  1540
  \item \hyperlink{command.HOL.refute}{\mbox{\isa{\isacommand{refute}}}} tests the current goal for
blanchet@43082
  1541
    counterexamples using a reduction to SAT. The following configuration
blanchet@43082
  1542
    options are supported:
blanchet@43082
  1543
blanchet@43082
  1544
    \begin{description}
blanchet@43082
  1545
blanchet@43082
  1546
    \item[\isa{minsize}] specifies the minimum size (cardinality) of the
blanchet@43082
  1547
      models to search for.
blanchet@43082
  1548
blanchet@43082
  1549
    \item[\isa{maxsize}] specifies the maximum size (cardinality) of the
blanchet@43082
  1550
      models to search for. Nonpositive values mean $\infty$.
blanchet@43082
  1551
blanchet@43082
  1552
    \item[\isa{maxvars}] specifies the maximum number of Boolean variables
blanchet@43082
  1553
    to use when transforming the term into a propositional formula.
blanchet@43082
  1554
    Nonpositive values mean $\infty$.
blanchet@43082
  1555
blanchet@43082
  1556
    \item[\isa{satsolver}] specifies the SAT solver to use.
blanchet@43082
  1557
blanchet@43082
  1558
    \item[\isa{no{\isaliteral{5F}{\isacharunderscore}}assms}] specifies whether assumptions in
blanchet@43082
  1559
    structured proofs should be ignored.
blanchet@43082
  1560
blanchet@43082
  1561
    \item[\isa{maxtime}] sets the time limit in seconds.
blanchet@43082
  1562
blanchet@43082
  1563
    \item[\isa{expect}] can be used to check if the user's
blanchet@43082
  1564
    expectation was met (\isa{genuine}, \isa{potential},
blanchet@43082
  1565
    \isa{none}, or \isa{unknown}).
blanchet@43082
  1566
blanchet@43082
  1567
    \end{description}
blanchet@43082
  1568
blanchet@43082
  1569
    These option can be given within square brackets.
blanchet@43082
  1570
blanchet@43082
  1571
  \item \hyperlink{command.HOL.refute-params}{\mbox{\isa{\isacommand{refute{\isaliteral{5F}{\isacharunderscore}}params}}}} changes
blanchet@43082
  1572
    \hyperlink{command.HOL.refute}{\mbox{\isa{\isacommand{refute}}}} configuration options persistently.
blanchet@43082
  1573
blanchet@43082
  1574
  \item \hyperlink{command.HOL.nitpick}{\mbox{\isa{\isacommand{nitpick}}}} tests the current goal for counterexamples
blanchet@43082
  1575
    using a reduction to first-order relational logic. See the Nitpick manual
blanchet@43082
  1576
    \cite{isabelle-nitpick} for details.
blanchet@43082
  1577
blanchet@43082
  1578
  \item \hyperlink{command.HOL.nitpick-params}{\mbox{\isa{\isacommand{nitpick{\isaliteral{5F}{\isacharunderscore}}params}}}} changes
blanchet@43082
  1579
    \hyperlink{command.HOL.nitpick}{\mbox{\isa{\isacommand{nitpick}}}} configuration options persistently.
haftmann@31907
  1580
haftmann@31907
  1581
  \end{description}%
haftmann@31907
  1582
\end{isamarkuptext}%
haftmann@31907
  1583
\isamarkuptrue%
haftmann@31907
  1584
%
wenzelm@28788
  1585
\isamarkupsection{Unstructured case analysis and induction \label{sec:hol-induct-tac}%
wenzelm@26849
  1586
}
wenzelm@26849
  1587
\isamarkuptrue%
wenzelm@26849
  1588
%
wenzelm@26849
  1589
\begin{isamarkuptext}%
wenzelm@27124
  1590
The following tools of Isabelle/HOL support cases analysis and
wenzelm@27124
  1591
  induction in unstructured tactic scripts; see also
wenzelm@27124
  1592
  \secref{sec:cases-induct} for proper Isar versions of similar ideas.
wenzelm@26849
  1593
wenzelm@26849
  1594
  \begin{matharray}{rcl}
wenzelm@40685
  1595
    \indexdef{HOL}{method}{case\_tac}\hypertarget{method.HOL.case-tac}{\hyperlink{method.HOL.case-tac}{\mbox{\isa{case{\isaliteral{5F}{\isacharunderscore}}tac}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{method} \\
wenzelm@40685
  1596
    \indexdef{HOL}{method}{induct\_tac}\hypertarget{method.HOL.induct-tac}{\hyperlink{method.HOL.induct-tac}{\mbox{\isa{induct{\isaliteral{5F}{\isacharunderscore}}tac}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{method} \\
wenzelm@40685
  1597
    \indexdef{HOL}{method}{ind\_cases}\hypertarget{method.HOL.ind-cases}{\hyperlink{method.HOL.ind-cases}{\mbox{\isa{ind{\isaliteral{5F}{\isacharunderscore}}cases}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{method} \\
wenzelm@40685
  1598
    \indexdef{HOL}{command}{inductive\_cases}\hypertarget{command.HOL.inductive-cases}{\hyperlink{command.HOL.inductive-cases}{\mbox{\isa{\isacommand{inductive{\isaliteral{5F}{\isacharunderscore}}cases}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@26849
  1599
  \end{matharray}
wenzelm@26849
  1600
wenzelm@43467
  1601
  \begin{railoutput}
wenzelm@43467
  1602
\rail@begin{2}{\isa{}}
wenzelm@43467
  1603
\rail@term{\hyperlink{method.HOL.case-tac}{\mbox{\isa{case{\isaliteral{5F}{\isacharunderscore}}tac}}}}[]
wenzelm@43467
  1604
\rail@bar
wenzelm@43467
  1605
\rail@nextbar{1}
wenzelm@43467
  1606
\rail@nont{\hyperlink{syntax.goalspec}{\mbox{\isa{goalspec}}}}[]
wenzelm@43467
  1607
\rail@endbar
wenzelm@43467
  1608
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
  1609
\rail@bar
wenzelm@43467
  1610
\rail@nextbar{1}
wenzelm@43467
  1611
\rail@nont{\isa{rule}}[]
wenzelm@43467
  1612
\rail@endbar
wenzelm@43467
  1613
\rail@end
wenzelm@43467
  1614
\rail@begin{3}{\isa{}}
wenzelm@43467
  1615
\rail@term{\hyperlink{method.HOL.induct-tac}{\mbox{\isa{induct{\isaliteral{5F}{\isacharunderscore}}tac}}}}[]
wenzelm@43467
  1616
\rail@bar
wenzelm@43467
  1617
\rail@nextbar{1}
wenzelm@43467
  1618
\rail@nont{\hyperlink{syntax.goalspec}{\mbox{\isa{goalspec}}}}[]
wenzelm@43467
  1619
\rail@endbar
wenzelm@43467
  1620
\rail@bar
wenzelm@43467
  1621
\rail@nextbar{1}
wenzelm@43467
  1622
\rail@plus
wenzelm@43467
  1623
\rail@nont{\hyperlink{syntax.insts}{\mbox{\isa{insts}}}}[]
wenzelm@43467
  1624
\rail@nextplus{2}
wenzelm@43467
  1625
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1626
\rail@endplus
wenzelm@43467
  1627
\rail@endbar
wenzelm@43467
  1628
\rail@bar
wenzelm@43467
  1629
\rail@nextbar{1}
wenzelm@43467
  1630
\rail@nont{\isa{rule}}[]
wenzelm@43467
  1631
\rail@endbar
wenzelm@43467
  1632
\rail@end
wenzelm@43467
  1633
\rail@begin{3}{\isa{}}
wenzelm@43467
  1634
\rail@term{\hyperlink{method.HOL.ind-cases}{\mbox{\isa{ind{\isaliteral{5F}{\isacharunderscore}}cases}}}}[]
wenzelm@43467
  1635
\rail@plus
wenzelm@43467
  1636
\rail@nont{\hyperlink{syntax.prop}{\mbox{\isa{prop}}}}[]
wenzelm@43467
  1637
\rail@nextplus{1}
wenzelm@43467
  1638
\rail@endplus
wenzelm@43467
  1639
\rail@bar
wenzelm@43467
  1640
\rail@nextbar{1}
wenzelm@43467
  1641
\rail@term{\isa{\isakeyword{for}}}[]
wenzelm@43467
  1642
\rail@plus
wenzelm@43467
  1643
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  1644
\rail@nextplus{2}
wenzelm@43467
  1645
\rail@endplus
wenzelm@43467
  1646
\rail@endbar
wenzelm@43467
  1647
\rail@end
wenzelm@43467
  1648
\rail@begin{3}{\isa{}}
wenzelm@43467
  1649
\rail@term{\hyperlink{command.HOL.inductive-cases}{\mbox{\isa{\isacommand{inductive{\isaliteral{5F}{\isacharunderscore}}cases}}}}}[]
wenzelm@43467
  1650
\rail@plus
wenzelm@43467
  1651
\rail@bar
wenzelm@43467
  1652
\rail@nextbar{1}
wenzelm@43467
  1653
\rail@nont{\hyperlink{syntax.thmdecl}{\mbox{\isa{thmdecl}}}}[]
wenzelm@43467
  1654
\rail@endbar
wenzelm@43467
  1655
\rail@plus
wenzelm@43467
  1656
\rail@nont{\hyperlink{syntax.prop}{\mbox{\isa{prop}}}}[]
wenzelm@43467
  1657
\rail@nextplus{1}
wenzelm@43467
  1658
\rail@endplus
wenzelm@43467
  1659
\rail@nextplus{2}
wenzelm@43467
  1660
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1661
\rail@endplus
wenzelm@43467
  1662
\rail@end
wenzelm@43467
  1663
\rail@begin{1}{\isa{rule}}
wenzelm@43467
  1664
\rail@term{\isa{rule}}[]
wenzelm@43467
  1665
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
  1666
\rail@nont{\hyperlink{syntax.thmref}{\mbox{\isa{thmref}}}}[]
wenzelm@43467
  1667
\rail@end
wenzelm@43467
  1668
\end{railoutput}
wenzelm@26849
  1669
wenzelm@26849
  1670
wenzelm@28788
  1671
  \begin{description}
wenzelm@26849
  1672
wenzelm@40685
  1673
  \item \hyperlink{method.HOL.case-tac}{\mbox{\isa{case{\isaliteral{5F}{\isacharunderscore}}tac}}} and \hyperlink{method.HOL.induct-tac}{\mbox{\isa{induct{\isaliteral{5F}{\isacharunderscore}}tac}}} admit
wenzelm@28788
  1674
  to reason about inductive types.  Rules are selected according to
wenzelm@28788
  1675
  the declarations by the \hyperlink{attribute.cases}{\mbox{\isa{cases}}} and \hyperlink{attribute.induct}{\mbox{\isa{induct}}}
wenzelm@28788
  1676
  attributes, cf.\ \secref{sec:cases-induct}.  The \hyperlink{command.HOL.datatype}{\mbox{\isa{\isacommand{datatype}}}} package already takes care of this.
wenzelm@27124
  1677
wenzelm@27124
  1678
  These unstructured tactics feature both goal addressing and dynamic
wenzelm@26849
  1679
  instantiation.  Note that named rule cases are \emph{not} provided
wenzelm@27124
  1680
  as would be by the proper \hyperlink{method.cases}{\mbox{\isa{cases}}} and \hyperlink{method.induct}{\mbox{\isa{induct}}} proof
wenzelm@40685
  1681
  methods (see \secref{sec:cases-induct}).  Unlike the \hyperlink{method.induct}{\mbox{\isa{induct}}} method, \hyperlink{method.induct-tac}{\mbox{\isa{induct{\isaliteral{5F}{\isacharunderscore}}tac}}} does not handle structured rule
wenzelm@27124
  1682
  statements, only the compact object-logic conclusion of the subgoal
wenzelm@27124
  1683
  being addressed.
wenzelm@42994
  1684
wenzelm@40685
  1685
  \item \hyperlink{method.HOL.ind-cases}{\mbox{\isa{ind{\isaliteral{5F}{\isacharunderscore}}cases}}} and \hyperlink{command.HOL.inductive-cases}{\mbox{\isa{\isacommand{inductive{\isaliteral{5F}{\isacharunderscore}}cases}}}} provide an interface to the internal \verb|mk_cases| operation.  Rules are simplified in an unrestricted
wenzelm@26861
  1686
  forward manner.
wenzelm@26849
  1687
wenzelm@40685
  1688
  While \hyperlink{method.HOL.ind-cases}{\mbox{\isa{ind{\isaliteral{5F}{\isacharunderscore}}cases}}} is a proof method to apply the
wenzelm@40685
  1689
  result immediately as elimination rules, \hyperlink{command.HOL.inductive-cases}{\mbox{\isa{\isacommand{inductive{\isaliteral{5F}{\isacharunderscore}}cases}}}} provides case split theorems at the theory level
wenzelm@40685
  1690
  for later use.  The \hyperlink{keyword.for}{\mbox{\isa{\isakeyword{for}}}} argument of the \hyperlink{method.HOL.ind-cases}{\mbox{\isa{ind{\isaliteral{5F}{\isacharunderscore}}cases}}} method allows to specify a list of variables that should
wenzelm@26849
  1691
  be generalized before applying the resulting rule.
wenzelm@26849
  1692
wenzelm@28788
  1693
  \end{description}%
wenzelm@26849
  1694
\end{isamarkuptext}%
wenzelm@26849
  1695
\isamarkuptrue%
wenzelm@26849
  1696
%
wenzelm@26849
  1697
\isamarkupsection{Executable code%
wenzelm@26849
  1698
}
wenzelm@26849
  1699
\isamarkuptrue%
wenzelm@26849
  1700
%
wenzelm@26849
  1701
\begin{isamarkuptext}%
wenzelm@26849
  1702
Isabelle/Pure provides two generic frameworks to support code
wenzelm@26849
  1703
  generation from executable specifications.  Isabelle/HOL
wenzelm@26849
  1704
  instantiates these mechanisms in a way that is amenable to end-user
wenzelm@26849
  1705
  applications.
wenzelm@26849
  1706
haftmann@37397
  1707
  \medskip One framework generates code from functional programs
haftmann@37397
  1708
  (including overloading using type classes) to SML \cite{SML}, OCaml
haftmann@39048
  1709
  \cite{OCaml}, Haskell \cite{haskell-revised-report} and Scala
haftmann@39048
  1710
  \cite{scala-overview-tech-report}.
haftmann@37397
  1711
  Conceptually, code generation is split up in three steps:
haftmann@37397
  1712
  \emph{selection} of code theorems, \emph{translation} into an
haftmann@37397
  1713
  abstract executable view and \emph{serialization} to a specific
haftmann@37397
  1714
  \emph{target language}.  Inductive specifications can be executed
haftmann@37397
  1715
  using the predicate compiler which operates within HOL.
haftmann@37397
  1716
  See \cite{isabelle-codegen} for an introduction.
haftmann@37397
  1717
haftmann@37397
  1718
  \begin{matharray}{rcl}
wenzelm@40685
  1719
    \indexdef{HOL}{command}{export\_code}\hypertarget{command.HOL.export-code}{\hyperlink{command.HOL.export-code}{\mbox{\isa{\isacommand{export{\isaliteral{5F}{\isacharunderscore}}code}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}context\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
haftmann@37397
  1720
    \indexdef{HOL}{attribute}{code}\hypertarget{attribute.HOL.code}{\hyperlink{attribute.HOL.code}{\mbox{\isa{code}}}} & : & \isa{attribute} \\
wenzelm@40685
  1721
    \indexdef{HOL}{command}{code\_abort}\hypertarget{command.HOL.code-abort}{\hyperlink{command.HOL.code-abort}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}abort}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1722
    \indexdef{HOL}{command}{code\_datatype}\hypertarget{command.HOL.code-datatype}{\hyperlink{command.HOL.code-datatype}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}datatype}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1723
    \indexdef{HOL}{command}{print\_codesetup}\hypertarget{command.HOL.print-codesetup}{\hyperlink{command.HOL.print-codesetup}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}codesetup}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}context\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1724
    \indexdef{HOL}{attribute}{code\_inline}\hypertarget{attribute.HOL.code-inline}{\hyperlink{attribute.HOL.code-inline}{\mbox{\isa{code{\isaliteral{5F}{\isacharunderscore}}inline}}}} & : & \isa{attribute} \\
wenzelm@40685
  1725
    \indexdef{HOL}{attribute}{code\_post}\hypertarget{attribute.HOL.code-post}{\hyperlink{attribute.HOL.code-post}{\mbox{\isa{code{\isaliteral{5F}{\isacharunderscore}}post}}}} & : & \isa{attribute} \\
wenzelm@40685
  1726
    \indexdef{HOL}{command}{print\_codeproc}\hypertarget{command.HOL.print-codeproc}{\hyperlink{command.HOL.print-codeproc}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}codeproc}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}context\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1727
    \indexdef{HOL}{command}{code\_thms}\hypertarget{command.HOL.code-thms}{\hyperlink{command.HOL.code-thms}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}thms}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}context\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1728
    \indexdef{HOL}{command}{code\_deps}\hypertarget{command.HOL.code-deps}{\hyperlink{command.HOL.code-deps}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}deps}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}context\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1729
    \indexdef{HOL}{command}{code\_const}\hypertarget{command.HOL.code-const}{\hyperlink{command.HOL.code-const}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}const}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1730
    \indexdef{HOL}{command}{code\_type}\hypertarget{command.HOL.code-type}{\hyperlink{command.HOL.code-type}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}type}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1731
    \indexdef{HOL}{command}{code\_class}\hypertarget{command.HOL.code-class}{\hyperlink{command.HOL.code-class}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}class}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1732
    \indexdef{HOL}{command}{code\_instance}\hypertarget{command.HOL.code-instance}{\hyperlink{command.HOL.code-instance}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}instance}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1733
    \indexdef{HOL}{command}{code\_reserved}\hypertarget{command.HOL.code-reserved}{\hyperlink{command.HOL.code-reserved}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}reserved}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1734
    \indexdef{HOL}{command}{code\_monad}\hypertarget{command.HOL.code-monad}{\hyperlink{command.HOL.code-monad}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}monad}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1735
    \indexdef{HOL}{command}{code\_include}\hypertarget{command.HOL.code-include}{\hyperlink{command.HOL.code-include}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}include}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1736
    \indexdef{HOL}{command}{code\_modulename}\hypertarget{command.HOL.code-modulename}{\hyperlink{command.HOL.code-modulename}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}modulename}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1737
    \indexdef{HOL}{command}{code\_reflect}\hypertarget{command.HOL.code-reflect}{\hyperlink{command.HOL.code-reflect}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}reflect}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}}
haftmann@37397
  1738
  \end{matharray}
haftmann@37397
  1739
wenzelm@43467
  1740
  \begin{railoutput}
wenzelm@43467
  1741
\rail@begin{11}{\isa{}}
wenzelm@43467
  1742
\rail@term{\hyperlink{command.HOL.export-code}{\mbox{\isa{\isacommand{export{\isaliteral{5F}{\isacharunderscore}}code}}}}}[]
wenzelm@43467
  1743
\rail@plus
wenzelm@43467
  1744
\rail@nont{\isa{constexpr}}[]
wenzelm@43467
  1745
\rail@nextplus{1}
wenzelm@43467
  1746
\rail@endplus
wenzelm@43467
  1747
\rail@cr{3}
wenzelm@43467
  1748
\rail@bar
wenzelm@43467
  1749
\rail@nextbar{4}
wenzelm@43467
  1750
\rail@plus
wenzelm@43467
  1751
\rail@term{\isa{\isakeyword{in}}}[]
wenzelm@43467
  1752
\rail@nont{\isa{target}}[]
wenzelm@43467
  1753
\rail@bar
wenzelm@43467
  1754
\rail@nextbar{5}
wenzelm@43467
  1755
\rail@term{\isa{\isakeyword{module{\isaliteral{5F}{\isacharunderscore}}name}}}[]
wenzelm@43467
  1756
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  1757
\rail@endbar
wenzelm@43467
  1758
\rail@cr{7}
wenzelm@43467
  1759
\rail@bar
wenzelm@43467
  1760
\rail@nextbar{8}
wenzelm@43467
  1761
\rail@term{\isa{\isakeyword{file}}}[]
wenzelm@43467
  1762
\rail@bar
wenzelm@43467
  1763
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  1764
\rail@nextbar{9}
wenzelm@43467
  1765
\rail@term{\isa{{\isaliteral{2D}{\isacharminus}}}}[]
wenzelm@43467
  1766
\rail@endbar
wenzelm@43467
  1767
\rail@endbar
wenzelm@43467
  1768
\rail@bar
wenzelm@43467
  1769
\rail@nextbar{8}
wenzelm@43467
  1770
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  1771
\rail@nont{\isa{args}}[]
wenzelm@43467
  1772
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  1773
\rail@endbar
wenzelm@43467
  1774
\rail@nextplus{10}
wenzelm@43467
  1775
\rail@endplus
wenzelm@43467
  1776
\rail@endbar
wenzelm@43467
  1777
\rail@end
wenzelm@43467
  1778
\rail@begin{1}{\isa{const}}
wenzelm@43467
  1779
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
  1780
\rail@end
wenzelm@43467
  1781
\rail@begin{3}{\isa{constexpr}}
wenzelm@43467
  1782
\rail@bar
wenzelm@43467
  1783
\rail@nont{\isa{const}}[]
wenzelm@43467
  1784
\rail@nextbar{1}
wenzelm@43467
  1785
\rail@term{\isa{name{\isaliteral{2E}{\isachardot}}{\isaliteral{5F}{\isacharunderscore}}}}[]
wenzelm@43467
  1786
\rail@nextbar{2}
wenzelm@43467
  1787
\rail@term{\isa{{\isaliteral{5F}{\isacharunderscore}}}}[]
wenzelm@43467
  1788
\rail@endbar
wenzelm@43467
  1789
\rail@end
wenzelm@43467
  1790
\rail@begin{1}{\isa{typeconstructor}}
wenzelm@43467
  1791
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
  1792
\rail@end
wenzelm@43467
  1793
\rail@begin{1}{\isa{class}}
wenzelm@43467
  1794
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
  1795
\rail@end
wenzelm@43467
  1796
\rail@begin{4}{\isa{target}}
wenzelm@43467
  1797
\rail@bar
wenzelm@43467
  1798
\rail@term{\isa{SML}}[]
wenzelm@43467
  1799
\rail@nextbar{1}
wenzelm@43467
  1800
\rail@term{\isa{OCaml}}[]
wenzelm@43467
  1801
\rail@nextbar{2}
wenzelm@43467
  1802
\rail@term{\isa{Haskell}}[]
wenzelm@43467
  1803
\rail@nextbar{3}
wenzelm@43467
  1804
\rail@term{\isa{Scala}}[]
wenzelm@43467
  1805
\rail@endbar
wenzelm@43467
  1806
\rail@end
wenzelm@43467
  1807
\rail@begin{4}{\isa{}}
wenzelm@43467
  1808
\rail@term{\hyperlink{attribute.HOL.code}{\mbox{\isa{code}}}}[]
wenzelm@43467
  1809
\rail@bar
wenzelm@43467
  1810
\rail@nextbar{1}
wenzelm@43467
  1811
\rail@bar
wenzelm@43467
  1812
\rail@term{\isa{del}}[]
wenzelm@43467
  1813
\rail@nextbar{2}
wenzelm@43467
  1814
\rail@term{\isa{abstype}}[]
wenzelm@43467
  1815
\rail@nextbar{3}
wenzelm@43467
  1816
\rail@term{\isa{abstract}}[]
wenzelm@43467
  1817
\rail@endbar
wenzelm@43467
  1818
\rail@endbar
wenzelm@43467
  1819
\rail@end
wenzelm@43467
  1820
\rail@begin{2}{\isa{}}
wenzelm@43467
  1821
\rail@term{\hyperlink{command.HOL.code-abort}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}abort}}}}}[]
wenzelm@43467
  1822
\rail@plus
wenzelm@43467
  1823
\rail@nont{\isa{const}}[]
wenzelm@43467
  1824
\rail@nextplus{1}
wenzelm@43467
  1825
\rail@endplus
wenzelm@43467
  1826
\rail@end
wenzelm@43467
  1827
\rail@begin{2}{\isa{}}
wenzelm@43467
  1828
\rail@term{\hyperlink{command.HOL.code-datatype}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}datatype}}}}}[]
wenzelm@43467
  1829
\rail@plus
wenzelm@43467
  1830
\rail@nont{\isa{const}}[]
wenzelm@43467
  1831
\rail@nextplus{1}
wenzelm@43467
  1832
\rail@endplus
wenzelm@43467
  1833
\rail@end
wenzelm@43467
  1834
\rail@begin{2}{\isa{}}
wenzelm@43467
  1835
\rail@term{\hyperlink{attribute.HOL.code-inline}{\mbox{\isa{code{\isaliteral{5F}{\isacharunderscore}}inline}}}}[]
wenzelm@43467
  1836
\rail@bar
wenzelm@43467
  1837
\rail@nextbar{1}
wenzelm@43467
  1838
\rail@term{\isa{del}}[]
wenzelm@43467
  1839
\rail@endbar
wenzelm@43467
  1840
\rail@end
wenzelm@43467
  1841
\rail@begin{2}{\isa{}}
wenzelm@43467
  1842
\rail@term{\hyperlink{attribute.HOL.code-post}{\mbox{\isa{code{\isaliteral{5F}{\isacharunderscore}}post}}}}[]
wenzelm@43467
  1843
\rail@bar
wenzelm@43467
  1844
\rail@nextbar{1}
wenzelm@43467
  1845
\rail@term{\isa{del}}[]
wenzelm@43467
  1846
\rail@endbar
wenzelm@43467
  1847
\rail@end
wenzelm@43467
  1848
\rail@begin{3}{\isa{}}
wenzelm@43467
  1849
\rail@term{\hyperlink{command.HOL.code-thms}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}thms}}}}}[]
wenzelm@43467
  1850
\rail@bar
wenzelm@43467
  1851
\rail@nextbar{1}
wenzelm@43467
  1852
\rail@plus
wenzelm@43467
  1853
\rail@nont{\isa{constexpr}}[]
wenzelm@43467
  1854
\rail@nextplus{2}
wenzelm@43467
  1855
\rail@endplus
wenzelm@43467
  1856
\rail@endbar
wenzelm@43467
  1857
\rail@end
wenzelm@43467
  1858
\rail@begin{3}{\isa{}}
wenzelm@43467
  1859
\rail@term{\hyperlink{command.HOL.code-deps}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}deps}}}}}[]
wenzelm@43467
  1860
\rail@bar
wenzelm@43467
  1861
\rail@nextbar{1}
wenzelm@43467
  1862
\rail@plus
wenzelm@43467
  1863
\rail@nont{\isa{constexpr}}[]
wenzelm@43467
  1864
\rail@nextplus{2}
wenzelm@43467
  1865
\rail@endplus
wenzelm@43467
  1866
\rail@endbar
wenzelm@43467
  1867
\rail@end
wenzelm@43467
  1868
\rail@begin{7}{\isa{}}
wenzelm@43467
  1869
\rail@term{\hyperlink{command.HOL.code-const}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}const}}}}}[]
wenzelm@43467
  1870
\rail@plus
wenzelm@43467
  1871
\rail@nont{\isa{const}}[]
wenzelm@43467
  1872
\rail@nextplus{1}
wenzelm@43467
  1873
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1874
\rail@endplus
wenzelm@43467
  1875
\rail@cr{3}
wenzelm@43467
  1876
\rail@plus
wenzelm@43467
  1877
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  1878
\rail@nont{\isa{target}}[]
wenzelm@43467
  1879
\rail@plus
wenzelm@43467
  1880
\rail@bar
wenzelm@43467
  1881
\rail@nextbar{4}
wenzelm@43467
  1882
\rail@nont{\isa{syntax}}[]
wenzelm@43467
  1883
\rail@endbar
wenzelm@43467
  1884
\rail@nextplus{5}
wenzelm@43467
  1885
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1886
\rail@endplus
wenzelm@43467
  1887
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  1888
\rail@nextplus{6}
wenzelm@43467
  1889
\rail@endplus
wenzelm@43467
  1890
\rail@end
wenzelm@43467
  1891
\rail@begin{7}{\isa{}}
wenzelm@43467
  1892
\rail@term{\hyperlink{command.HOL.code-type}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}type}}}}}[]
wenzelm@43467
  1893
\rail@plus
wenzelm@43467
  1894
\rail@nont{\isa{typeconstructor}}[]
wenzelm@43467
  1895
\rail@nextplus{1}
wenzelm@43467
  1896
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1897
\rail@endplus
wenzelm@43467
  1898
\rail@cr{3}
wenzelm@43467
  1899
\rail@plus
wenzelm@43467
  1900
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  1901
\rail@nont{\isa{target}}[]
wenzelm@43467
  1902
\rail@plus
wenzelm@43467
  1903
\rail@bar
wenzelm@43467
  1904
\rail@nextbar{4}
wenzelm@43467
  1905
\rail@nont{\isa{syntax}}[]
wenzelm@43467
  1906
\rail@endbar
wenzelm@43467
  1907
\rail@nextplus{5}
wenzelm@43467
  1908
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1909
\rail@endplus
wenzelm@43467
  1910
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  1911
\rail@nextplus{6}
wenzelm@43467
  1912
\rail@endplus
wenzelm@43467
  1913
\rail@end
wenzelm@43467
  1914
\rail@begin{9}{\isa{}}
wenzelm@43467
  1915
\rail@term{\hyperlink{command.HOL.code-class}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}class}}}}}[]
wenzelm@43467
  1916
\rail@plus
wenzelm@43467
  1917
\rail@nont{\isa{class}}[]
wenzelm@43467
  1918
\rail@nextplus{1}
wenzelm@43467
  1919
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1920
\rail@endplus
wenzelm@43467
  1921
\rail@cr{3}
wenzelm@43467
  1922
\rail@plus
wenzelm@43467
  1923
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  1924
\rail@nont{\isa{target}}[]
wenzelm@43467
  1925
\rail@cr{5}
wenzelm@43467
  1926
\rail@plus
wenzelm@43467
  1927
\rail@bar
wenzelm@43467
  1928
\rail@nextbar{6}
wenzelm@43467
  1929
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  1930
\rail@endbar
wenzelm@43467
  1931
\rail@nextplus{7}
wenzelm@43467
  1932
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1933
\rail@endplus
wenzelm@43467
  1934
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  1935
\rail@nextplus{8}
wenzelm@43467
  1936
\rail@endplus
wenzelm@43467
  1937
\rail@end
wenzelm@43467
  1938
\rail@begin{7}{\isa{}}
wenzelm@43467
  1939
\rail@term{\hyperlink{command.HOL.code-instance}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}instance}}}}}[]
wenzelm@43467
  1940
\rail@plus
wenzelm@43467
  1941
\rail@nont{\isa{typeconstructor}}[]
wenzelm@43467
  1942
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
  1943
\rail@nont{\isa{class}}[]
wenzelm@43467
  1944
\rail@nextplus{1}
wenzelm@43467
  1945
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1946
\rail@endplus
wenzelm@43467
  1947
\rail@cr{3}
wenzelm@43467
  1948
\rail@plus
wenzelm@43467
  1949
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  1950
\rail@nont{\isa{target}}[]
wenzelm@43467
  1951
\rail@plus
wenzelm@43467
  1952
\rail@bar
wenzelm@43467
  1953
\rail@nextbar{4}
wenzelm@43467
  1954
\rail@term{\isa{{\isaliteral{2D}{\isacharminus}}}}[]
wenzelm@43467
  1955
\rail@endbar
wenzelm@43467
  1956
\rail@nextplus{5}
wenzelm@43467
  1957
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1958
\rail@endplus
wenzelm@43467
  1959
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  1960
\rail@nextplus{6}
wenzelm@43467
  1961
\rail@endplus
wenzelm@43467
  1962
\rail@end
wenzelm@43467
  1963
\rail@begin{2}{\isa{}}
wenzelm@43467
  1964
\rail@term{\hyperlink{command.HOL.code-reserved}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}reserved}}}}}[]
wenzelm@43467
  1965
\rail@nont{\isa{target}}[]
wenzelm@43467
  1966
\rail@plus
wenzelm@43467
  1967
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  1968
\rail@nextplus{1}
wenzelm@43467
  1969
\rail@endplus
wenzelm@43467
  1970
\rail@end
wenzelm@43467
  1971
\rail@begin{1}{\isa{}}
wenzelm@43467
  1972
\rail@term{\hyperlink{command.HOL.code-monad}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}monad}}}}}[]
wenzelm@43467
  1973
\rail@nont{\isa{const}}[]
wenzelm@43467
  1974
\rail@nont{\isa{const}}[]
wenzelm@43467
  1975
\rail@nont{\isa{target}}[]
wenzelm@43467
  1976
\rail@end
wenzelm@43467
  1977
\rail@begin{2}{\isa{}}
wenzelm@43467
  1978
\rail@term{\hyperlink{command.HOL.code-include}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}include}}}}}[]
wenzelm@43467
  1979
\rail@nont{\isa{target}}[]
wenzelm@43467
  1980
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  1981
\rail@bar
wenzelm@43467
  1982
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  1983
\rail@nextbar{1}
wenzelm@43467
  1984
\rail@term{\isa{{\isaliteral{2D}{\isacharminus}}}}[]
wenzelm@43467
  1985
\rail@endbar
wenzelm@43467
  1986
\rail@end
wenzelm@43467
  1987
\rail@begin{2}{\isa{}}
wenzelm@43467
  1988
\rail@term{\hyperlink{command.HOL.code-modulename}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}modulename}}}}}[]
wenzelm@43467
  1989
\rail@nont{\isa{target}}[]
wenzelm@43467
  1990
\rail@plus
wenzelm@43467
  1991
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  1992
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  1993
\rail@nextplus{1}
wenzelm@43467
  1994
\rail@endplus
wenzelm@43467
  1995
\rail@end
wenzelm@43467
  1996
\rail@begin{11}{\isa{}}
wenzelm@43467
  1997
\rail@term{\hyperlink{command.HOL.code-reflect}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}reflect}}}}}[]
wenzelm@43467
  1998
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  1999
\rail@cr{2}
wenzelm@43467
  2000
\rail@bar
wenzelm@43467
  2001
\rail@nextbar{3}
wenzelm@43467
  2002
\rail@term{\isa{\isakeyword{datatypes}}}[]
wenzelm@43467
  2003
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  2004
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43467
  2005
\rail@bar
wenzelm@43467
  2006
\rail@term{\isa{{\isaliteral{5F}{\isacharunderscore}}}}[]
wenzelm@43467
  2007
\rail@nextbar{4}
wenzelm@43467
  2008
\rail@plus
wenzelm@43467
  2009
\rail@plus
wenzelm@43467
  2010
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  2011
\rail@nextplus{5}
wenzelm@43467
  2012
\rail@cterm{\isa{{\isaliteral{7C}{\isacharbar}}}}[]
wenzelm@43467
  2013
\rail@endplus
wenzelm@43467
  2014
\rail@nextplus{6}
wenzelm@43467
  2015
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  2016
\rail@endplus
wenzelm@43467
  2017
\rail@endbar
wenzelm@43467
  2018
\rail@endbar
wenzelm@43467
  2019
\rail@cr{8}
wenzelm@43467
  2020
\rail@bar
wenzelm@43467
  2021
\rail@nextbar{9}
wenzelm@43467
  2022
\rail@term{\isa{\isakeyword{functions}}}[]
wenzelm@43467
  2023
\rail@plus
wenzelm@43467
  2024
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  2025
\rail@nextplus{10}
wenzelm@43467
  2026
\rail@endplus
wenzelm@43467
  2027
\rail@endbar
wenzelm@43467
  2028
\rail@bar
wenzelm@43467
  2029
\rail@nextbar{9}
wenzelm@43467
  2030
\rail@term{\isa{\isakeyword{file}}}[]
wenzelm@43467
  2031
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  2032
\rail@endbar
wenzelm@43467
  2033
\rail@end
wenzelm@43467
  2034
\rail@begin{4}{\isa{syntax}}
wenzelm@43467
  2035
\rail@bar
wenzelm@43467
  2036
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  2037
\rail@nextbar{1}
wenzelm@43467
  2038
\rail@bar
wenzelm@43467
  2039
\rail@term{\isa{\isakeyword{infix}}}[]
wenzelm@43467
  2040
\rail@nextbar{2}
wenzelm@43467
  2041
\rail@term{\isa{\isakeyword{infixl}}}[]
wenzelm@43467
  2042
\rail@nextbar{3}
wenzelm@43467
  2043
\rail@term{\isa{\isakeyword{infixr}}}[]
wenzelm@43467
  2044
\rail@endbar
wenzelm@43467
  2045
\rail@nont{\hyperlink{syntax.nat}{\mbox{\isa{nat}}}}[]
wenzelm@43467
  2046
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  2047
\rail@endbar
wenzelm@43467
  2048
\rail@end
wenzelm@43467
  2049
\end{railoutput}
haftmann@37397
  2050
haftmann@37397
  2051
haftmann@37397
  2052
  \begin{description}
haftmann@37397
  2053
wenzelm@40685
  2054
  \item \hyperlink{command.HOL.export-code}{\mbox{\isa{\isacommand{export{\isaliteral{5F}{\isacharunderscore}}code}}}} generates code for a given list
haftmann@39832
  2055
  of constants in the specified target language(s).  If no
haftmann@39832
  2056
  serialization instruction is given, only abstract code is generated
haftmann@39832
  2057
  internally.
haftmann@37397
  2058
haftmann@37397
  2059
  Constants may be specified by giving them literally, referring to
wenzelm@40685
  2060
  all executable contants within a certain theory by giving \isa{{\isaliteral{22}{\isachardoublequote}}name{\isaliteral{2E}{\isachardot}}{\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}}, or referring to \emph{all} executable constants currently
wenzelm@40685
  2061
  available by giving \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}}.
haftmann@37397
  2062
haftmann@37397
  2063
  By default, for each involved theory one corresponding name space
haftmann@37397
  2064
  module is generated.  Alternativly, a module name may be specified
wenzelm@40685
  2065
  after the \hyperlink{keyword.module-name}{\mbox{\isa{\isakeyword{module{\isaliteral{5F}{\isacharunderscore}}name}}}} keyword; then \emph{all} code is
haftmann@37397
  2066
  placed in this module.
haftmann@37397
  2067
haftmann@39832
  2068
  For \emph{SML}, \emph{OCaml} and \emph{Scala} the file specification
haftmann@39832
  2069
  refers to a single file; for \emph{Haskell}, it refers to a whole
haftmann@39832
  2070
  directory, where code is generated in multiple files reflecting the
haftmann@39832
  2071
  module hierarchy.  Omitting the file specification denotes standard
haftmann@37748
  2072
  output.
haftmann@37397
  2073
haftmann@37397
  2074
  Serializers take an optional list of arguments in parentheses.  For
wenzelm@40685
  2075
  \emph{SML} and \emph{OCaml}, ``\isa{no{\isaliteral{5F}{\isacharunderscore}}signatures}`` omits
haftmann@37397
  2076
  explicit module signatures.
wenzelm@42994
  2077
haftmann@39832
  2078
  For \emph{Haskell} a module name prefix may be given using the
wenzelm@40685
  2079
  ``\isa{{\isaliteral{22}{\isachardoublequote}}root{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}}'' argument; ``\isa{string{\isaliteral{5F}{\isacharunderscore}}classes}'' adds a
haftmann@39832
  2080
  ``\verb|deriving (Read, Show)|'' clause to each appropriate
haftmann@39832
  2081
  datatype declaration.
haftmann@37397
  2082
haftmann@37397
  2083
  \item \hyperlink{attribute.HOL.code}{\mbox{\isa{code}}} explicitly selects (or with option
wenzelm@40685
  2084
  ``\isa{{\isaliteral{22}{\isachardoublequote}}del{\isaliteral{22}{\isachardoublequote}}}'' deselects) a code equation for code generation.
haftmann@38706
  2085
  Usually packages introducing code equations provide a reasonable
wenzelm@40685
  2086
  default setup for selection.  Variants \isa{{\isaliteral{22}{\isachardoublequote}}code\ abstype{\isaliteral{22}{\isachardoublequote}}} and
wenzelm@40685
  2087
  \isa{{\isaliteral{22}{\isachardoublequote}}code\ abstract{\isaliteral{22}{\isachardoublequote}}} declare abstract datatype certificates or
haftmann@38706
  2088
  code equations on abstract datatype representations respectively.
haftmann@37397
  2089
wenzelm@40685
  2090
  \item \hyperlink{command.HOL.code-abort}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}abort}}}} declares constants which are not
haftmann@39832
  2091
  required to have a definition by means of code equations; if needed
haftmann@39832
  2092
  these are implemented by program abort instead.
haftmann@37397
  2093
wenzelm@40685
  2094
  \item \hyperlink{command.HOL.code-datatype}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}datatype}}}} specifies a constructor set
haftmann@37397
  2095
  for a logical type.
haftmann@37397
  2096
wenzelm@40685
  2097
  \item \hyperlink{command.HOL.print-codesetup}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}codesetup}}}} gives an overview on
haftmann@37397
  2098
  selected code equations and code generator datatypes.
haftmann@37397
  2099
wenzelm@40685
  2100
  \item \hyperlink{attribute.HOL.code-inline}{\mbox{\isa{code{\isaliteral{5F}{\isacharunderscore}}inline}}} declares (or with option
wenzelm@40685
  2101
  ``\isa{{\isaliteral{22}{\isachardoublequote}}del{\isaliteral{22}{\isachardoublequote}}}'' removes) inlining theorems which are applied as
haftmann@39832
  2102
  rewrite rules to any code equation during preprocessing.
haftmann@37397
  2103
wenzelm@40685
  2104
  \item \hyperlink{attribute.HOL.code-post}{\mbox{\isa{code{\isaliteral{5F}{\isacharunderscore}}post}}} declares (or with option ``\isa{{\isaliteral{22}{\isachardoublequote}}del{\isaliteral{22}{\isachardoublequote}}}'' removes) theorems which are applied as rewrite rules to any
haftmann@39832
  2105
  result of an evaluation.
haftmann@37397
  2106
wenzelm@40685
  2107
  \item \hyperlink{command.HOL.print-codeproc}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}codeproc}}}} prints the setup of the code
haftmann@39832
  2108
  generator preprocessor.
haftmann@37397
  2109
wenzelm@40685
  2110
  \item \hyperlink{command.HOL.code-thms}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}thms}}}} prints a list of theorems
haftmann@37397
  2111
  representing the corresponding program containing all given
haftmann@37397
  2112
  constants after preprocessing.
haftmann@37397
  2113
wenzelm@40685
  2114
  \item \hyperlink{command.HOL.code-deps}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}deps}}}} visualizes dependencies of
haftmann@37397
  2115
  theorems representing the corresponding program containing all given
haftmann@37397
  2116
  constants after preprocessing.
haftmann@37397
  2117
wenzelm@40685
  2118
  \item \hyperlink{command.HOL.code-const}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}const}}}} associates a list of constants
haftmann@37397
  2119
  with target-specific serializations; omitting a serialization
haftmann@37397
  2120
  deletes an existing serialization.
haftmann@37397
  2121
wenzelm@40685
  2122
  \item \hyperlink{command.HOL.code-type}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}type}}}} associates a list of type
haftmann@37397
  2123
  constructors with target-specific serializations; omitting a
haftmann@37397
  2124
  serialization deletes an existing serialization.
haftmann@37397
  2125
wenzelm@40685
  2126
  \item \hyperlink{command.HOL.code-class}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}class}}}} associates a list of classes
haftmann@37397
  2127
  with target-specific class names; omitting a serialization deletes
haftmann@37397
  2128
  an existing serialization.  This applies only to \emph{Haskell}.
haftmann@37397
  2129
wenzelm@40685
  2130
  \item \hyperlink{command.HOL.code-instance}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}instance}}}} declares a list of type
haftmann@37397
  2131
  constructor / class instance relations as ``already present'' for a
wenzelm@40685
  2132
  given target.  Omitting a ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{2D}{\isacharminus}}{\isaliteral{22}{\isachardoublequote}}}'' deletes an existing
haftmann@37397
  2133
  ``already present'' declaration.  This applies only to
haftmann@37397
  2134
  \emph{Haskell}.
haftmann@37397
  2135
wenzelm@40685
  2136
  \item \hyperlink{command.HOL.code-reserved}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}reserved}}}} declares a list of names as
haftmann@37397
  2137
  reserved for a given target, preventing it to be shadowed by any
haftmann@37397
  2138
  generated code.
haftmann@37397
  2139
wenzelm@40685
  2140
  \item \hyperlink{command.HOL.code-monad}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}monad}}}} provides an auxiliary mechanism
haftmann@37397
  2141
  to generate monadic code for Haskell.
haftmann@37397
  2142
wenzelm@40685
  2143
  \item \hyperlink{command.HOL.code-include}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}include}}}} adds arbitrary named content
wenzelm@40685
  2144
  (``include'') to generated code.  A ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{2D}{\isacharminus}}{\isaliteral{22}{\isachardoublequote}}}'' as last argument
haftmann@37397
  2145
  will remove an already added ``include''.
haftmann@37397
  2146
wenzelm@40685
  2147
  \item \hyperlink{command.HOL.code-modulename}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}modulename}}}} declares aliasings from one
haftmann@37397
  2148
  module name onto another.
haftmann@37397
  2149
wenzelm@40685
  2150
  \item \hyperlink{command.HOL.code-reflect}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}reflect}}}} without a ``\isa{{\isaliteral{22}{\isachardoublequote}}file{\isaliteral{22}{\isachardoublequote}}}''
haftmann@39832
  2151
  argument compiles code into the system runtime environment and
haftmann@39832
  2152
  modifies the code generator setup that future invocations of system
wenzelm@40685
  2153
  runtime code generation referring to one of the ``\isa{{\isaliteral{22}{\isachardoublequote}}datatypes{\isaliteral{22}{\isachardoublequote}}}'' or ``\isa{{\isaliteral{22}{\isachardoublequote}}functions{\isaliteral{22}{\isachardoublequote}}}'' entities use these precompiled
wenzelm@40685
  2154
  entities.  With a ``\isa{{\isaliteral{22}{\isachardoublequote}}file{\isaliteral{22}{\isachardoublequote}}}'' argument, the corresponding code
haftmann@39832
  2155
  is generated into that specified file without modifying the code
haftmann@39832
  2156
  generator setup.
haftmann@39832
  2157
haftmann@37397
  2158
  \end{description}
haftmann@37397
  2159
haftmann@39832
  2160
  The other framework generates code from both functional and
haftmann@39832
  2161
  relational programs to SML.  See \cite{isabelle-HOL} for further
haftmann@39832
  2162
  information (this actually covers the new-style theory format as
haftmann@39832
  2163
  well).
wenzelm@26849
  2164
wenzelm@26849
  2165
  \begin{matharray}{rcl}
wenzelm@40685
  2166
    \indexdef{HOL}{command}{code\_module}\hypertarget{command.HOL.code-module}{\hyperlink{command.HOL.code-module}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}module}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  2167
    \indexdef{HOL}{command}{code\_library}\hypertarget{command.HOL.code-library}{\hyperlink{command.HOL.code-library}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}library}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  2168
    \indexdef{HOL}{command}{consts\_code}\hypertarget{command.HOL.consts-code}{\hyperlink{command.HOL.consts-code}{\mbox{\isa{\isacommand{consts{\isaliteral{5F}{\isacharunderscore}}code}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@42994
  2169
    \indexdef{HOL}{command}{types\_code}\hypertarget{command.HOL.types-code}{\hyperlink{command.HOL.types-code}{\mbox{\isa{\isacommand{types{\isaliteral{5F}{\isacharunderscore}}code}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@28788
  2170
    \indexdef{HOL}{attribute}{code}\hypertarget{attribute.HOL.code}{\hyperlink{attribute.HOL.code}{\mbox{\isa{code}}}} & : & \isa{attribute} \\
wenzelm@26849
  2171
  \end{matharray}
wenzelm@26849
  2172
wenzelm@43467
  2173
  \begin{railoutput}
wenzelm@43467
  2174
\rail@begin{11}{\isa{}}
wenzelm@43467
  2175
\rail@bar
wenzelm@43467
  2176
\rail@term{\hyperlink{command.HOL.code-module}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}module}}}}}[]
wenzelm@43467
  2177
\rail@nextbar{1}
wenzelm@43467
  2178
\rail@term{\hyperlink{command.HOL.code-library}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}library}}}}}[]
wenzelm@43467
  2179
\rail@endbar
wenzelm@43467
  2180
\rail@bar
wenzelm@43467
  2181
\rail@nextbar{1}
wenzelm@43467
  2182
\rail@nont{\isa{modespec}}[]
wenzelm@43467
  2183
\rail@endbar
wenzelm@43467
  2184
\rail@bar
wenzelm@43467
  2185
\rail@nextbar{1}
wenzelm@43467
  2186
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  2187
\rail@endbar
wenzelm@43467
  2188
\rail@cr{3}
wenzelm@43467
  2189
\rail@bar
wenzelm@43467
  2190
\rail@nextbar{4}
wenzelm@43467
  2191
\rail@term{\isa{\isakeyword{file}}}[]
wenzelm@43467
  2192
\rail@nont{\isa{name}}[]
wenzelm@43467
  2193
\rail@endbar
wenzelm@43467
  2194
\rail@bar
wenzelm@43467
  2195
\rail@nextbar{4}
wenzelm@43467
  2196
\rail@term{\isa{\isakeyword{imports}}}[]
wenzelm@43467
  2197
\rail@plus
wenzelm@43467
  2198
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  2199
\rail@nextplus{5}
wenzelm@43467
  2200
\rail@endplus
wenzelm@43467
  2201
\rail@endbar
wenzelm@43467
  2202
\rail@cr{7}
wenzelm@43467
  2203
\rail@term{\isa{\isakeyword{contains}}}[]
wenzelm@43467
  2204
\rail@bar
wenzelm@43467
  2205
\rail@plus
wenzelm@43467
  2206
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  2207
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43467
  2208
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
  2209
\rail@nextplus{8}
wenzelm@43467
  2210
\rail@endplus
wenzelm@43467
  2211
\rail@nextbar{9}
wenzelm@43467
  2212
\rail@plus
wenzelm@43467
  2213
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
  2214
\rail@nextplus{10}
wenzelm@43467
  2215
\rail@endplus
wenzelm@43467
  2216
\rail@endbar
wenzelm@43467
  2217
\rail@end
wenzelm@43467
  2218
\rail@begin{2}{\isa{modespec}}
wenzelm@43467
  2219
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  2220
\rail@plus
wenzelm@43467
  2221
\rail@nextplus{1}
wenzelm@43467
  2222
\rail@cnont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  2223
\rail@endplus
wenzelm@43467
  2224
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  2225
\rail@end
wenzelm@43467
  2226
\rail@begin{2}{\isa{}}
wenzelm@43467
  2227
\rail@term{\hyperlink{command.HOL.consts-code}{\mbox{\isa{\isacommand{consts{\isaliteral{5F}{\isacharunderscore}}code}}}}}[]
wenzelm@43467
  2228
\rail@plus
wenzelm@43467
  2229
\rail@nont{\isa{codespec}}[]
wenzelm@43467
  2230
\rail@nextplus{1}
wenzelm@43467
  2231
\rail@endplus
wenzelm@43467
  2232
\rail@end
wenzelm@43467
  2233
\rail@begin{2}{\isa{codespec}}
wenzelm@43467
  2234
\rail@nont{\isa{const}}[]
wenzelm@43467
  2235
\rail@nont{\isa{template}}[]
wenzelm@43467
  2236
\rail@bar
wenzelm@43467
  2237
\rail@nextbar{1}
wenzelm@43467
  2238
\rail@nont{\isa{attachment}}[]
wenzelm@43467
  2239
\rail@endbar
wenzelm@43467
  2240
\rail@end
wenzelm@43467
  2241
\rail@begin{2}{\isa{}}
wenzelm@43467
  2242
\rail@term{\hyperlink{command.HOL.types-code}{\mbox{\isa{\isacommand{types{\isaliteral{5F}{\isacharunderscore}}code}}}}}[]
wenzelm@43467
  2243
\rail@plus
wenzelm@43467
  2244
\rail@nont{\isa{tycodespec}}[]
wenzelm@43467
  2245
\rail@nextplus{1}
wenzelm@43467
  2246
\rail@endplus
wenzelm@43467
  2247
\rail@end
wenzelm@43467
  2248
\rail@begin{2}{\isa{tycodespec}}
wenzelm@43467
  2249
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  2250
\rail@nont{\isa{template}}[]
wenzelm@43467
  2251
\rail@bar
wenzelm@43467
  2252
\rail@nextbar{1}
wenzelm@43467
  2253
\rail@nont{\isa{attachment}}[]
wenzelm@43467
  2254
\rail@endbar
wenzelm@43467
  2255
\rail@end
wenzelm@43467
  2256
\rail@begin{1}{\isa{const}}
wenzelm@43467
  2257
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
  2258
\rail@end
wenzelm@43467
  2259
\rail@begin{1}{\isa{template}}
wenzelm@43467
  2260
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  2261
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@43467
  2262
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  2263
\rail@end
wenzelm@43467
  2264
\rail@begin{2}{\isa{attachment}}
wenzelm@43467
  2265
\rail@term{\isa{attach}}[]
wenzelm@43467
  2266
\rail@bar
wenzelm@43467
  2267
\rail@nextbar{1}
wenzelm@43467
  2268
\rail@nont{\isa{modespec}}[]
wenzelm@43467
  2269
\rail@endbar
wenzelm@43467
  2270
\rail@term{\isa{{\isaliteral{7B}{\isacharbraceleft}}}}[]
wenzelm@43467
  2271
\rail@nont{\hyperlink{syntax.text}{\mbox{\isa{text}}}}[]
wenzelm@43467
  2272
\rail@term{\isa{{\isaliteral{7D}{\isacharbraceright}}}}[]
wenzelm@43467
  2273
\rail@end
wenzelm@43467
  2274
\rail@begin{2}{\isa{}}
wenzelm@43467
  2275
\rail@term{\hyperlink{attribute.HOL.code}{\mbox{\isa{code}}}}[]
wenzelm@43467
  2276
\rail@bar
wenzelm@43467
  2277
\rail@nextbar{1}
wenzelm@43467
  2278
\rail@nont{\isa{name}}[]
wenzelm@43467
  2279
\rail@endbar
wenzelm@43467
  2280
\rail@end
wenzelm@43467
  2281
\end{railoutput}%
wenzelm@26849
  2282
\end{isamarkuptext}%
wenzelm@26849
  2283
\isamarkuptrue%
wenzelm@26849
  2284
%
wenzelm@27047
  2285
\isamarkupsection{Definition by specification \label{sec:hol-specification}%
wenzelm@27047
  2286
}
wenzelm@27047
  2287
\isamarkuptrue%
wenzelm@27047
  2288
%
wenzelm@27047
  2289
\begin{isamarkuptext}%
wenzelm@27047
  2290
\begin{matharray}{rcl}
wenzelm@40685
  2291
    \indexdef{HOL}{command}{specification}\hypertarget{command.HOL.specification}{\hyperlink{command.HOL.specification}{\mbox{\isa{\isacommand{specification}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ proof{\isaliteral{28}{\isacharparenleft}}prove{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  2292
    \indexdef{HOL}{command}{ax\_specification}\hypertarget{command.HOL.ax-specification}{\hyperlink{command.HOL.ax-specification}{\mbox{\isa{\isacommand{ax{\isaliteral{5F}{\isacharunderscore}}specification}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ proof{\isaliteral{28}{\isacharparenleft}}prove{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@27047
  2293
  \end{matharray}
wenzelm@27047
  2294
wenzelm@43467
  2295
  \begin{railoutput}
wenzelm@43467
  2296
\rail@begin{6}{\isa{}}
wenzelm@43467
  2297
\rail@bar
wenzelm@43467
  2298
\rail@term{\hyperlink{command.HOL.specification}{\mbox{\isa{\isacommand{specification}}}}}[]
wenzelm@43467
  2299
\rail@nextbar{1}
wenzelm@43467
  2300
\rail@term{\hyperlink{command.HOL.ax-specification}{\mbox{\isa{\isacommand{ax{\isaliteral{5F}{\isacharunderscore}}specification}}}}}[]
wenzelm@43467
  2301
\rail@endbar
wenzelm@43467
  2302
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  2303
\rail@plus
wenzelm@43467
  2304
\rail@nont{\isa{decl}}[]
wenzelm@43467
  2305
\rail@nextplus{1}
wenzelm@43467
  2306
\rail@endplus
wenzelm@43467
  2307
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  2308
\rail@cr{3}
wenzelm@43467
  2309
\rail@plus
wenzelm@43467
  2310
\rail@bar
wenzelm@43467
  2311
\rail@nextbar{4}
wenzelm@43467
  2312
\rail@nont{\hyperlink{syntax.thmdecl}{\mbox{\isa{thmdecl}}}}[]
wenzelm@43467
  2313
\rail@endbar
wenzelm@43467
  2314
\rail@nont{\hyperlink{syntax.prop}{\mbox{\isa{prop}}}}[]
wenzelm@43467
  2315
\rail@nextplus{5}
wenzelm@43467
  2316
\rail@endplus
wenzelm@43467
  2317
\rail@end
wenzelm@43467
  2318
\rail@begin{2}{\isa{decl}}
wenzelm@43467
  2319
\rail@bar
wenzelm@43467
  2320
\rail@nextbar{1}
wenzelm@43467
  2321
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  2322
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
  2323
\rail@endbar
wenzelm@43467
  2324
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
  2325
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  2326
\rail@term{\isa{\isakeyword{overloaded}}}[]
wenzelm@43467
  2327
\rail@bar
wenzelm@43467
  2328
\rail@nextbar{1}
wenzelm@43467
  2329
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  2330
\rail@endbar
wenzelm@43467
  2331
\rail@end
wenzelm@43467
  2332
\end{railoutput}
wenzelm@43467
  2333
wenzelm@27047
  2334
wenzelm@28788
  2335
  \begin{description}
wenzelm@27047
  2336
wenzelm@40685
  2337
  \item \hyperlink{command.HOL.specification}{\mbox{\isa{\isacommand{specification}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}decls\ {\isaliteral{5C3C7068693E}{\isasymphi}}{\isaliteral{22}{\isachardoublequote}}} sets up a
wenzelm@27047
  2338
  goal stating the existence of terms with the properties specified to
wenzelm@27047
  2339
  hold for the constants given in \isa{decls}.  After finishing the
wenzelm@27047
  2340
  proof, the theory will be augmented with definitions for the given
wenzelm@27047
  2341
  constants, as well as with theorems stating the properties for these
wenzelm@27047
  2342
  constants.
wenzelm@27047
  2343
wenzelm@40685
  2344
  \item \hyperlink{command.HOL.ax-specification}{\mbox{\isa{\isacommand{ax{\isaliteral{5F}{\isacharunderscore}}specification}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}decls\ {\isaliteral{5C3C7068693E}{\isasymphi}}{\isaliteral{22}{\isachardoublequote}}} sets up
wenzelm@28788
  2345
  a goal stating the existence of terms with the properties specified
wenzelm@28788
  2346
  to hold for the constants given in \isa{decls}.  After finishing
wenzelm@28788
  2347
  the proof, the theory will be augmented with axioms expressing the
wenzelm@28788
  2348
  properties given in the first place.
wenzelm@27047
  2349
wenzelm@28788
  2350
  \item \isa{decl} declares a constant to be defined by the
wenzelm@27047
  2351
  specification given.  The definition for the constant \isa{c} is
wenzelm@40685
  2352
  bound to the name \isa{c{\isaliteral{5F}{\isacharunderscore}}def} unless a theorem name is given in
wenzelm@27047
  2353
  the declaration.  Overloaded constants should be declared as such.
wenzelm@27047
  2354
wenzelm@28788
  2355
  \end{description}
wenzelm@27047
  2356
wenzelm@40685
  2357
  Whether to use \hyperlink{command.HOL.specification}{\mbox{\isa{\isacommand{specification}}}} or \hyperlink{command.HOL.ax-specification}{\mbox{\isa{\isacommand{ax{\isaliteral{5F}{\isacharunderscore}}specification}}}} is to some extent a matter of style.  \hyperlink{command.HOL.specification}{\mbox{\isa{\isacommand{specification}}}} introduces no new axioms, and so by
wenzelm@40685
  2358
  construction cannot introduce inconsistencies, whereas \hyperlink{command.HOL.ax-specification}{\mbox{\isa{\isacommand{ax{\isaliteral{5F}{\isacharunderscore}}specification}}}} does introduce axioms, but only after the
wenzelm@27047
  2359
  user has explicitly proven it to be safe.  A practical issue must be
wenzelm@27047
  2360
  considered, though: After introducing two constants with the same
wenzelm@27047
  2361
  properties using \hyperlink{command.HOL.specification}{\mbox{\isa{\isacommand{specification}}}}, one can prove
wenzelm@27047
  2362
  that the two constants are, in fact, equal.  If this might be a
wenzelm@40685
  2363
  problem, one should use \hyperlink{command.HOL.ax-specification}{\mbox{\isa{\isacommand{ax{\isaliteral{5F}{\isacharunderscore}}specification}}}}.%
wenzelm@27047
  2364
\end{isamarkuptext}%
wenzelm@27047
  2365
\isamarkuptrue%
wenzelm@27047
  2366
%
wenzelm@26849
  2367
\isadelimtheory
wenzelm@26849
  2368
%
wenzelm@26849
  2369
\endisadelimtheory
wenzelm@26849
  2370
%
wenzelm@26849
  2371
\isatagtheory
wenzelm@26840
  2372
\isacommand{end}\isamarkupfalse%
wenzelm@26840
  2373
%
wenzelm@26840
  2374
\endisatagtheory
wenzelm@26840
  2375
{\isafoldtheory}%
wenzelm@26840
  2376
%
wenzelm@26840
  2377
\isadelimtheory
wenzelm@26840
  2378
%
wenzelm@26840
  2379
\endisadelimtheory
wenzelm@26849
  2380
\isanewline
wenzelm@26840
  2381
\end{isabellebody}%
wenzelm@26840
  2382
%%% Local Variables:
wenzelm@26840
  2383
%%% mode: latex
wenzelm@26840
  2384
%%% TeX-master: "root"
wenzelm@26840
  2385
%%% End: