doc-src/IsarRef/Thy/document/HOL_Specific.tex
author huffman
Mon, 20 Dec 2010 07:50:47 -0800
changeset 41320 4953e21ac76c
parent 40937 e2e0ef28d3f8
child 41396 5379e4a85a66
permissions -rw-r--r--
replace list_map function with an abbreviation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26840
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
     1
%
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
     2
\begin{isabellebody}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
     3
\def\isabellecontext{HOL{\isaliteral{5F}{\isacharunderscore}}Specific}%
26840
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
     4
%
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
     5
\isadelimtheory
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
     6
%
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
     7
\endisadelimtheory
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
     8
%
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
     9
\isatagtheory
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
    10
\isacommand{theory}\isamarkupfalse%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
    11
\ HOL{\isaliteral{5F}{\isacharunderscore}}Specific\isanewline
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    12
\isakeyword{imports}\ Main\isanewline
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    13
\isakeyword{begin}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    14
\endisatagtheory
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    15
{\isafoldtheory}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    16
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    17
\isadelimtheory
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    18
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    19
\endisadelimtheory
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    20
%
26852
a31203f58b20 misc tuning;
wenzelm
parents: 26849
diff changeset
    21
\isamarkupchapter{Isabelle/HOL \label{ch:hol}%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    22
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    23
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    24
%
35744
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    25
\isamarkupsection{Typedef axiomatization \label{sec:hol-typedef}%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    26
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    27
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    28
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    29
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    30
\begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
    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}}} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    32
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    33
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    34
  \begin{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    35
    'typedef' altname? abstype '=' repset
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    36
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    37
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    38
    altname: '(' (name | 'open' | 'open' name) ')'
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    39
    ;
35841
94f901e4969a allow sort constraints in HOL/typedef;
wenzelm
parents: 35744
diff changeset
    40
    abstype: typespecsorts mixfix?
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    41
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    42
    repset: term ('morphisms' name name)?
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    43
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    44
  \end{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    45
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
    46
  \begin{description}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    47
  
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
    48
  \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}}}
35744
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    49
  axiomatizes a Gordon/HOL-style type definition in the background
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    50
  theory of the current context, depending on a non-emptiness result
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    51
  of the set \isa{A} (which needs to be proven interactively).
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    52
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    53
  The raw type may not depend on parameters or assumptions of the
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    54
  context --- this is logically impossible in Isabelle/HOL --- but the
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    55
  non-emptiness property can be local, potentially resulting in
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    56
  multiple interpretations in target contexts.  Thus the established
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    57
  bijection between the representing set \isa{A} and the new type
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    58
  \isa{t} may semantically depend on local assumptions.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    59
  
35744
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    60
  By default, \hyperlink{command.HOL.typedef}{\mbox{\isa{\isacommand{typedef}}}} defines both a type \isa{t}
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    61
  and a set (term constant) of the same name, unless an alternative
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
    62
  base name is given in parentheses, or the ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}open{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}}''
35744
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    63
  declaration is used to suppress a separate constant definition
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
    64
  altogether.  The injection from type to set is called \isa{Rep{\isaliteral{5F}{\isacharunderscore}}t},
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
    65
  its inverse \isa{Abs{\isaliteral{5F}{\isacharunderscore}}t} --- this may be changed via an explicit
35744
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    66
  \hyperlink{keyword.HOL.morphisms}{\mbox{\isa{\isakeyword{morphisms}}}} declaration.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    67
  
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
    68
  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
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    69
  corresponding injection/surjection pair (in both directions).  Rules
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
    70
  \isa{Rep{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}inject} and \isa{Abs{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}inject} provide a slightly
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    71
  more convenient view on the injectivity part, suitable for automated
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
    72
  proof tools (e.g.\ in \hyperlink{attribute.simp}{\mbox{\isa{simp}}} or \hyperlink{attribute.iff}{\mbox{\isa{iff}}}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
    73
  declarations).  Rules \isa{Rep{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}cases}/\isa{Rep{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}induct}, and
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
    74
  \isa{Abs{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}cases}/\isa{Abs{\isaliteral{5F}{\isacharunderscore}}t{\isaliteral{5F}{\isacharunderscore}}induct} provide alternative views
26895
d066f9db833b updated generated file;
wenzelm
parents: 26861
diff changeset
    75
  on surjectivity; these are already declared as set or type rules for
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
    76
  the generic \hyperlink{method.cases}{\mbox{\isa{cases}}} and \hyperlink{method.induct}{\mbox{\isa{induct}}} methods.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    77
  
35744
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    78
  An alternative name for the set definition (and other derived
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    79
  entities) may be specified in parentheses; the default is to use
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    80
  \isa{t} as indicated before.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    81
35744
93603d7b8ee9 removed obsolete HOL 'typedecl';
wenzelm
parents: 35613
diff changeset
    82
  \end{description}%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    83
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    84
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    85
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    86
\isamarkupsection{Adhoc tuples%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    87
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    88
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    89
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    90
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    91
\begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
    92
    \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} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    93
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    94
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    95
  \begin{rail}
40388
cb9fd7dd641c abolished obscure goal variant of [split_format] -- unused (cf. d1c14898fd04), unrelated to '(complete)' variant, and not at all canonical
krauss
parents: 40380
diff changeset
    96
    'split_format' '(' 'complete' ')'
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    97
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    98
  \end{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
    99
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   100
  \begin{description}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   101
  
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   102
  \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
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   103
  arguments in function applications to be represented canonically
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   104
  according to their tuple type structure.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   105
40388
cb9fd7dd641c abolished obscure goal variant of [split_format] -- unused (cf. d1c14898fd04), unrelated to '(complete)' variant, and not at all canonical
krauss
parents: 40380
diff changeset
   106
  Note that this operation tends to invent funny names for new local
cb9fd7dd641c abolished obscure goal variant of [split_format] -- unused (cf. d1c14898fd04), unrelated to '(complete)' variant, and not at all canonical
krauss
parents: 40380
diff changeset
   107
  parameters introduced.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   108
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   109
  \end{description}%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   110
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   111
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   112
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   113
\isamarkupsection{Records \label{sec:hol-record}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   114
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   115
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   116
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   117
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   118
In principle, records merely generalize the concept of tuples, where
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   119
  components may be addressed by labels instead of just position.  The
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   120
  logical infrastructure of records in Isabelle/HOL is slightly more
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   121
  advanced, though, supporting truly extensible record schemes.  This
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   122
  admits operations that are polymorphic with respect to record
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   123
  extension, yielding ``object-oriented'' effects like (single)
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   124
  inheritance.  See also \cite{NaraschewskiW-TPHOLs98} for more
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   125
  details on object-oriented verification and record subtyping in HOL.%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   126
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   127
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   128
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   129
\isamarkupsubsection{Basic concepts%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   130
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   131
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   132
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   133
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   134
Isabelle/HOL supports both \emph{fixed} and \emph{schematic} records
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   135
  at the level of terms and types.  The notation is as follows:
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   136
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   137
  \begin{center}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   138
  \begin{tabular}{l|l|l}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   139
    & record terms & record types \\ \hline
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   140
    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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   141
    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}}} &
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   142
      \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}}} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   143
  \end{tabular}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   144
  \end{center}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   145
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   146
  \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}}}.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   147
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   148
  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
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   149
  \isa{a} and field \isa{y} of value \isa{b}.  The corresponding
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   150
  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}}}
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   151
  and \isa{{\isaliteral{22}{\isachardoublequote}}b\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ B{\isaliteral{22}{\isachardoublequote}}}.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   152
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   153
  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
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   154
  \isa{x} and \isa{y} as before, but also possibly further fields
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   155
  as indicated by the ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{22}{\isachardoublequote}}}'' notation (which is actually part
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   156
  of the syntax).  The improper field ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{22}{\isachardoublequote}}}'' of a record
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   157
  scheme is called the \emph{more part}.  Logically it is just a free
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   158
  variable, which is occasionally referred to as ``row variable'' in
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   159
  the literature.  The more part of a record scheme may be
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   160
  instantiated by zero or more further components.  For example, the
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   161
  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.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   162
  Fixed records are special instances of record schemes, where
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   163
  ``\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}}}
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   164
  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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   165
  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}}}.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   166
  
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   167
  \medskip Two key observations make extensible records in a simply
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   168
  typed language like HOL work out:
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   169
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   170
  \begin{enumerate}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   171
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   172
  \item the more part is internalized, as a free term or type
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   173
  variable,
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   174
26852
a31203f58b20 misc tuning;
wenzelm
parents: 26849
diff changeset
   175
  \item field names are externalized, they cannot be accessed within
a31203f58b20 misc tuning;
wenzelm
parents: 26849
diff changeset
   176
  the logic as first-class values.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   177
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   178
  \end{enumerate}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   179
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   180
  \medskip In Isabelle/HOL record types have to be defined explicitly,
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   181
  fixing their field names and types, and their (optional) parent
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   182
  record.  Afterwards, records may be formed using above syntax, while
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   183
  obeying the canonical order of fields as given by their declaration.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   184
  The record package provides several standard operations like
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   185
  selectors and updates.  The common setup for various generic proof
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   186
  tools enable succinct reasoning patterns.  See also the Isabelle/HOL
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   187
  tutorial \cite{isabelle-hol-book} for further instructions on using
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   188
  records in practice.%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   189
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   190
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   191
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   192
\isamarkupsubsection{Record specifications%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   193
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   194
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   195
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   196
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   197
\begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   198
    \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}}} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   199
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   200
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   201
  \begin{rail}
36158
d2ad76e374d3 HOL record: explicitly allow sort constraints;
wenzelm
parents: 36139
diff changeset
   202
    'record' typespecsorts '=' (type '+')? (constdecl +)
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   203
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   204
  \end{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   205
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   206
  \begin{description}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   207
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   208
  \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}}},
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   209
  derived from the optional parent record \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7461753E}{\isasymtau}}{\isaliteral{22}{\isachardoublequote}}} by adding new
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   210
  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.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   211
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   212
  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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   213
  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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   214
  least one new field \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub i{\isaliteral{22}{\isachardoublequote}}} has to be specified.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   215
  Basically, field names need to belong to a unique record.  This is
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   216
  not a real restriction in practice, since fields are qualified by
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   217
  the record name internally.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   218
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   219
  The parent record specification \isa{{\isaliteral{5C3C7461753E}{\isasymtau}}} is optional; if omitted
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   220
  \isa{t} becomes a root record.  The hierarchy of all records
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   221
  declared within a theory context forms a forest structure, i.e.\ a
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   222
  set of trees starting with a root record each.  There is no way to
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   223
  merge multiple parent records!
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   224
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   225
  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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   226
  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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   227
  \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}}}.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   228
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   229
  \end{description}%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   230
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   231
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   232
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   233
\isamarkupsubsection{Record operations%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   234
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   235
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   236
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   237
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   238
Any record definition of the form presented above produces certain
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   239
  standard operations.  Selectors and updates are provided for any
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   240
  field, including the improper one ``\isa{more}''.  There are also
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   241
  cumulative record constructor functions.  To simplify the
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   242
  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}}}.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   243
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   244
  \medskip \textbf{Selectors} and \textbf{updates} are available for
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   245
  any field (including ``\isa{more}''):
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   246
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   247
  \begin{matharray}{lll}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   248
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   249
    \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}}} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   250
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   251
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   252
  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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   253
  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
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   254
  because of postfix notation the order of fields shown here is
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   255
  reverse than in the actual term.  Since repeated updates are just
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   256
  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.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   257
  Thus commutativity of independent updates can be proven within the
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   258
  logic for any two fields, but not as a general theorem.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   259
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   260
  \medskip The \textbf{make} operation provides a cumulative record
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   261
  constructor function:
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   262
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   263
  \begin{matharray}{lll}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   264
    \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}}} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   265
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   266
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   267
  \medskip We now reconsider the case of non-root records, which are
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   268
  derived of some parent.  In general, the latter may depend on
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   269
  another parent as well, resulting in a list of \emph{ancestor
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   270
  records}.  Appending the lists of fields of all ancestors results in
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   271
  a certain field prefix.  The record package automatically takes care
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   272
  of this by lifting operations over this context of ancestor fields.
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   273
  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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   274
  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}}},
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   275
  the above record operations will get the following types:
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   276
26852
a31203f58b20 misc tuning;
wenzelm
parents: 26849
diff changeset
   277
  \medskip
a31203f58b20 misc tuning;
wenzelm
parents: 26849
diff changeset
   278
  \begin{tabular}{lll}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   279
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   280
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   281
    \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}}} \\
26852
a31203f58b20 misc tuning;
wenzelm
parents: 26849
diff changeset
   282
  \end{tabular}
a31203f58b20 misc tuning;
wenzelm
parents: 26849
diff changeset
   283
  \medskip
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   284
26852
a31203f58b20 misc tuning;
wenzelm
parents: 26849
diff changeset
   285
  \noindent Some further operations address the extension aspect of a
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   286
  derived record scheme specifically: \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}fields{\isaliteral{22}{\isachardoublequote}}} produces a
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   287
  record fragment consisting of exactly the new fields introduced here
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   288
  (the result may serve as a more part elsewhere); \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}extend{\isaliteral{22}{\isachardoublequote}}}
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   289
  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.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   290
26852
a31203f58b20 misc tuning;
wenzelm
parents: 26849
diff changeset
   291
  \medskip
a31203f58b20 misc tuning;
wenzelm
parents: 26849
diff changeset
   292
  \begin{tabular}{lll}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   293
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   294
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   295
    \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}}} \\
26852
a31203f58b20 misc tuning;
wenzelm
parents: 26849
diff changeset
   296
  \end{tabular}
a31203f58b20 misc tuning;
wenzelm
parents: 26849
diff changeset
   297
  \medskip
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   298
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   299
  \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
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   300
  for root records.%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   301
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   302
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   303
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   304
\isamarkupsubsection{Derived rules and proof tools%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   305
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   306
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   307
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   308
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   309
The record package proves several results internally, declaring
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   310
  these facts to appropriate proof tools.  This enables users to
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   311
  reason about record structures quite conveniently.  Assume that
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   312
  \isa{t} is a record type as specified above.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   313
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   314
  \begin{enumerate}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   315
  
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   316
  \item Standard conversions for selectors or updates applied to
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   317
  record constructor terms are made part of the default Simplifier
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   318
  context; thus proofs by reduction of basic operations merely require
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   319
  the \hyperlink{method.simp}{\mbox{\isa{simp}}} method without further arguments.  These rules
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   320
  are available as \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}simps{\isaliteral{22}{\isachardoublequote}}}, too.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   321
  
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   322
  \item Selectors applied to updated records are automatically reduced
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   323
  by an internal simplification procedure, which is also part of the
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   324
  standard Simplifier setup.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   325
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   326
  \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
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   327
  Reasoner as \hyperlink{attribute.iff}{\mbox{\isa{iff}}} rules.  These rules are available as
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   328
  \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}iffs{\isaliteral{22}{\isachardoublequote}}}.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   329
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   330
  \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,
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   331
  and as the basic rule context as ``\hyperlink{attribute.intro}{\mbox{\isa{intro}}}\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3F}{\isacharquery}}{\isaliteral{22}{\isachardoublequote}}}''.
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   332
  The rule is called \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}equality{\isaliteral{22}{\isachardoublequote}}}.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   333
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   334
  \item Representations of arbitrary record expressions as canonical
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   335
  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,
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   336
  \secref{sec:cases-induct}).  Several variations are available, for
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   337
  fixed records, record schemes, more parts etc.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   338
  
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   339
  The generic proof methods are sufficiently smart to pick the most
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   340
  sensible rule according to the type of the indicated record
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   341
  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.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   342
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   343
  \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}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   344
  treated automatically, but usually need to be expanded by hand,
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   345
  using the collective fact \isa{{\isaliteral{22}{\isachardoublequote}}t{\isaliteral{2E}{\isachardot}}defs{\isaliteral{22}{\isachardoublequote}}}.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   346
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   347
  \end{enumerate}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   348
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   349
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   350
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   351
\isamarkupsection{Datatypes \label{sec:hol-datatype}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   352
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   353
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   354
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   355
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   356
\begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   357
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   358
  \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}}} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   359
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   360
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   361
  \begin{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   362
    'datatype' (dtspec + 'and')
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   363
    ;
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
   364
    'rep_datatype' ('(' (name +) ')')? (term +)
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   365
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   366
35351
7425aece4ee3 allow general mixfix syntax for type constructors;
wenzelm
parents: 34172
diff changeset
   367
    dtspec: parname? typespec mixfix? '=' (cons + '|')
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   368
    ;
31913
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   369
    cons: name ( type * ) mixfix?
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   370
  \end{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   371
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   372
  \begin{description}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   373
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   374
  \item \hyperlink{command.HOL.datatype}{\mbox{\isa{\isacommand{datatype}}}} defines inductive datatypes in
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   375
  HOL.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   376
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   377
  \item \hyperlink{command.HOL.rep-datatype}{\mbox{\isa{\isacommand{rep{\isaliteral{5F}{\isacharunderscore}}datatype}}}} represents existing types as
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   378
  inductive ones, generating the standard infrastructure of derived
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   379
  concepts (primitive recursion etc.).
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   380
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   381
  \end{description}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   382
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   383
  The induction and exhaustion theorems generated provide case names
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   384
  according to the constructors involved, while parameters are named
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   385
  after the types (see also \secref{sec:cases-induct}).
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   386
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   387
  See \cite{isabelle-HOL} for more details on datatypes, but beware of
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   388
  the old-style theory syntax being used there!  Apart from proper
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   389
  proof methods for case-analysis and induction, there are also
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   390
  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
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   391
  to refer directly to the internal structure of subgoals (including
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   392
  internally bound parameters).%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   393
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   394
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   395
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   396
\isamarkupsection{Recursive functions \label{sec:recursion}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   397
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   398
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   399
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   400
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   401
\begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   402
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   403
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   404
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   405
    \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}}} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   406
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   407
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   408
  \begin{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   409
    'primrec' target? fixes 'where' equations
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   410
    ;
40170
751121d5ca35 remove outdated "(otherwise)" syntax from manual
krauss
parents: 39608
diff changeset
   411
    ('fun' | 'function') target? functionopts? fixes \\ 'where' equations
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   412
    ;
40170
751121d5ca35 remove outdated "(otherwise)" syntax from manual
krauss
parents: 39608
diff changeset
   413
    equations: (thmdecl? prop + '|')
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   414
    ;
26987
978cefd606ad updated generated file;
wenzelm
parents: 26907
diff changeset
   415
    functionopts: '(' (('sequential' | 'domintros' | 'tailrec' | 'default' term) + ',') ')'
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   416
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   417
    'termination' ( term )?
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   418
  \end{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   419
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   420
  \begin{description}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   421
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   422
  \item \hyperlink{command.HOL.primrec}{\mbox{\isa{\isacommand{primrec}}}} defines primitive recursive
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   423
  functions over datatypes, see also \cite{isabelle-HOL}.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   424
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   425
  \item \hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}} defines functions by general
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   426
  wellfounded recursion. A detailed description with examples can be
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   427
  found in \cite{isabelle-function}. The function is specified by a
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   428
  set of (possibly conditional) recursive equations with arbitrary
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   429
  pattern matching. The command generates proof obligations for the
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   430
  completeness and the compatibility of patterns.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   431
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   432
  The defined function is considered partial, and the resulting
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   433
  simplification rules (named \isa{{\isaliteral{22}{\isachardoublequote}}f{\isaliteral{2E}{\isachardot}}psimps{\isaliteral{22}{\isachardoublequote}}}) and induction rule
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   434
  (named \isa{{\isaliteral{22}{\isachardoublequote}}f{\isaliteral{2E}{\isachardot}}pinduct{\isaliteral{22}{\isachardoublequote}}}) are guarded by a generated domain
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   435
  predicate \isa{{\isaliteral{22}{\isachardoublequote}}f{\isaliteral{5F}{\isacharunderscore}}dom{\isaliteral{22}{\isachardoublequote}}}. The \hyperlink{command.HOL.termination}{\mbox{\isa{\isacommand{termination}}}}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   436
  command can then be used to establish that the function is total.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   437
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   438
  \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
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   439
  proof attempts regarding pattern matching and termination.  See
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   440
  \cite{isabelle-function} for further details.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   441
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   442
  \item \hyperlink{command.HOL.termination}{\mbox{\isa{\isacommand{termination}}}}~\isa{f} commences a
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   443
  termination proof for the previously defined function \isa{f}.  If
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   444
  this is omitted, the command refers to the most recent function
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   445
  definition.  After the proof is closed, the recursive equations and
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   446
  the induction principle is established.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   447
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   448
  \end{description}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   449
27452
5c1fb7d262bf adjusted rep_datatype
haftmann
parents: 27124
diff changeset
   450
  Recursive definitions introduced by the \hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}}
5c1fb7d262bf adjusted rep_datatype
haftmann
parents: 27124
diff changeset
   451
  command accommodate
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   452
  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)
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   453
  refers to a specific induction rule, with parameters named according
33857
0cb5002c52db clarified; checked
krauss
parents: 31998
diff changeset
   454
  to the user-specified equations. Cases are numbered (starting from 1).
0cb5002c52db clarified; checked
krauss
parents: 31998
diff changeset
   455
0cb5002c52db clarified; checked
krauss
parents: 31998
diff changeset
   456
  For \hyperlink{command.HOL.primrec}{\mbox{\isa{\isacommand{primrec}}}}, the induction principle coincides
27452
5c1fb7d262bf adjusted rep_datatype
haftmann
parents: 27124
diff changeset
   457
  with structural recursion on the datatype the recursion is carried
5c1fb7d262bf adjusted rep_datatype
haftmann
parents: 27124
diff changeset
   458
  out.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   459
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   460
  The equations provided by these packages may be referred later as
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   461
  theorem list \isa{{\isaliteral{22}{\isachardoublequote}}f{\isaliteral{2E}{\isachardot}}simps{\isaliteral{22}{\isachardoublequote}}}, where \isa{f} is the (collective)
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   462
  name of the functions defined.  Individual equations may be named
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   463
  explicitly as well.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   464
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   465
  The \hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}} command accepts the following
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   466
  options.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   467
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   468
  \begin{description}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   469
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   470
  \item \isa{sequential} enables a preprocessor which disambiguates
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   471
  overlapping patterns by making them mutually disjoint.  Earlier
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   472
  equations take precedence over later ones.  This allows to give the
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   473
  specification in a format very similar to functional programming.
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   474
  Note that the resulting simplification and induction rules
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   475
  correspond to the transformed specification, not the one given
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   476
  originally. This usually means that each equation given by the user
36139
0c2538afe8e8 Spelling error: theroems -> theorems
hoelzl
parents: 35841
diff changeset
   477
  may result in several theorems.  Also note that this automatic
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   478
  transformation only works for ML-style datatype patterns.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   479
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   480
  \item \isa{domintros} enables the automated generation of
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   481
  introduction rules for the domain predicate. While mostly not
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   482
  needed, they can be helpful in some proofs about partial functions.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   483
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   484
  \item \isa{tailrec} generates the unconstrained recursive
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   485
  equations even without a termination proof, provided that the
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   486
  function is tail-recursive. This currently only works
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   487
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   488
  \item \isa{{\isaliteral{22}{\isachardoublequote}}default\ d{\isaliteral{22}{\isachardoublequote}}} allows to specify a default value for a
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   489
  (partial) function, which will ensure that \isa{{\isaliteral{22}{\isachardoublequote}}f\ x\ {\isaliteral{3D}{\isacharequal}}\ d\ x{\isaliteral{22}{\isachardoublequote}}}
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   490
  whenever \isa{{\isaliteral{22}{\isachardoublequote}}x\ {\isaliteral{5C3C6E6F74696E3E}{\isasymnotin}}\ f{\isaliteral{5F}{\isacharunderscore}}dom{\isaliteral{22}{\isachardoublequote}}}.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   491
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   492
  \end{description}%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   493
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   494
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   495
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   496
\isamarkupsubsection{Proof methods related to recursive definitions%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   497
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   498
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   499
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   500
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   501
\begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   502
    \indexdef{HOL}{method}{pat\_completeness}\hypertarget{method.HOL.pat-completeness}{\hyperlink{method.HOL.pat-completeness}{\mbox{\isa{pat{\isaliteral{5F}{\isacharunderscore}}completeness}}}} & : & \isa{method} \\
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   503
    \indexdef{HOL}{method}{relation}\hypertarget{method.HOL.relation}{\hyperlink{method.HOL.relation}{\mbox{\isa{relation}}}} & : & \isa{method} \\
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   504
    \indexdef{HOL}{method}{lexicographic\_order}\hypertarget{method.HOL.lexicographic-order}{\hyperlink{method.HOL.lexicographic-order}{\mbox{\isa{lexicographic{\isaliteral{5F}{\isacharunderscore}}order}}}} & : & \isa{method} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   505
    \indexdef{HOL}{method}{size\_change}\hypertarget{method.HOL.size-change}{\hyperlink{method.HOL.size-change}{\mbox{\isa{size{\isaliteral{5F}{\isacharunderscore}}change}}}} & : & \isa{method} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   506
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   507
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   508
  \begin{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   509
    'relation' term
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   510
    ;
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
   511
    'lexicographic_order' ( clasimpmod * )
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   512
    ;
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
   513
    'size_change' ( orders ( clasimpmod * ) )
33858
0c348f7997f7 documented size_change in isar-ref manual
krauss
parents: 33857
diff changeset
   514
    ;
0c348f7997f7 documented size_change in isar-ref manual
krauss
parents: 33857
diff changeset
   515
    orders: ( 'max' | 'min' | 'ms' ) *
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   516
  \end{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   517
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   518
  \begin{description}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   519
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   520
  \item \hyperlink{method.HOL.pat-completeness}{\mbox{\isa{pat{\isaliteral{5F}{\isacharunderscore}}completeness}}} is a specialized method to
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   521
  solve goals regarding the completeness of pattern matching, as
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   522
  required by the \hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}} package (cf.\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   523
  \cite{isabelle-function}).
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   524
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   525
  \item \hyperlink{method.HOL.relation}{\mbox{\isa{relation}}}~\isa{R} introduces a termination
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   526
  proof using the relation \isa{R}.  The resulting proof state will
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   527
  contain goals expressing that \isa{R} is wellfounded, and that the
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   528
  arguments of recursive calls decrease with respect to \isa{R}.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   529
  Usually, this method is used as the initial proof step of manual
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   530
  termination proofs.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   531
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   532
  \item \hyperlink{method.HOL.lexicographic-order}{\mbox{\isa{lexicographic{\isaliteral{5F}{\isacharunderscore}}order}}} attempts a fully
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   533
  automated termination proof by searching for a lexicographic
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   534
  combination of size measures on the arguments of the function. The
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   535
  method accepts the same arguments as the \hyperlink{method.auto}{\mbox{\isa{auto}}} method,
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   536
  which it uses internally to prove local descents.  The same context
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   537
  modifiers as for \hyperlink{method.auto}{\mbox{\isa{auto}}} are accepted, see
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   538
  \secref{sec:clasimp}.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   539
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   540
  In case of failure, extensive information is printed, which can help
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   541
  to analyse the situation (cf.\ \cite{isabelle-function}).
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   542
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   543
  \item \hyperlink{method.HOL.size-change}{\mbox{\isa{size{\isaliteral{5F}{\isacharunderscore}}change}}} also works on termination goals,
33858
0c348f7997f7 documented size_change in isar-ref manual
krauss
parents: 33857
diff changeset
   544
  using a variation of the size-change principle, together with a
0c348f7997f7 documented size_change in isar-ref manual
krauss
parents: 33857
diff changeset
   545
  graph decomposition technique (see \cite{krauss_phd} for details).
0c348f7997f7 documented size_change in isar-ref manual
krauss
parents: 33857
diff changeset
   546
  Three kinds of orders are used internally: \isa{max}, \isa{min},
0c348f7997f7 documented size_change in isar-ref manual
krauss
parents: 33857
diff changeset
   547
  and \isa{ms} (multiset), which is only available when the theory
0c348f7997f7 documented size_change in isar-ref manual
krauss
parents: 33857
diff changeset
   548
  \isa{Multiset} is loaded. When no order kinds are given, they are
0c348f7997f7 documented size_change in isar-ref manual
krauss
parents: 33857
diff changeset
   549
  tried in order. The search for a termination proof uses SAT solving
0c348f7997f7 documented size_change in isar-ref manual
krauss
parents: 33857
diff changeset
   550
  internally.
0c348f7997f7 documented size_change in isar-ref manual
krauss
parents: 33857
diff changeset
   551
0c348f7997f7 documented size_change in isar-ref manual
krauss
parents: 33857
diff changeset
   552
 For local descent proofs, the same context modifiers as for \hyperlink{method.auto}{\mbox{\isa{auto}}} are accepted, see \secref{sec:clasimp}.
0c348f7997f7 documented size_change in isar-ref manual
krauss
parents: 33857
diff changeset
   553
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   554
  \end{description}%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   555
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   556
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   557
%
40171
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   558
\isamarkupsubsection{Functions with explicit partiality%
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   559
}
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   560
\isamarkuptrue%
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   561
%
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   562
\begin{isamarkuptext}%
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   563
\begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   564
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   565
    \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} \\
40171
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   566
  \end{matharray}
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   567
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   568
  \begin{rail}
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   569
    'partial_function' target? '(' mode ')' fixes \\ 'where' thmdecl? prop
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   570
  \end{rail}
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   571
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   572
  \begin{description}
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   573
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   574
  \item \hyperlink{command.HOL.partial-function}{\mbox{\isa{\isacommand{partial{\isaliteral{5F}{\isacharunderscore}}function}}}} defines recursive
40171
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   575
  functions based on fixpoints in complete partial orders. No
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   576
  termination proof is required from the user or constructed
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   577
  internally. Instead, the possibility of non-termination is modelled
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   578
  explicitly in the result type, which contains an explicit bottom
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   579
  element.
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   580
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   581
  Pattern matching and mutual recursion are currently not supported.
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   582
  Thus, the specification consists of a single function described by a
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   583
  single recursive equation.
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   584
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   585
  There are no fixed syntactic restrictions on the body of the
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   586
  function, but the induced functional must be provably monotonic
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   587
  wrt.\ the underlying order.  The monotonicitity proof is performed
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   588
  internally, and the definition is rejected when it fails. The proof
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   589
  can be influenced by declaring hints using the
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   590
  \hyperlink{attribute.HOL.partial-function-mono}{\mbox{\isa{partial{\isaliteral{5F}{\isacharunderscore}}function{\isaliteral{5F}{\isacharunderscore}}mono}}} attribute.
40171
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   591
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   592
  The mandatory \isa{mode} argument specifies the mode of operation
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   593
  of the command, which directly corresponds to a complete partial
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   594
  order on the result type. By default, the following modes are
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   595
  defined: 
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   596
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   597
  \begin{description}
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   598
  \item \isa{option} defines functions that map into the \isa{option} type. Here, the value \isa{None} is used to model a
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   599
  non-terminating computation. Monotonicity requires that if \isa{None} is returned by a recursive call, then the overall result
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   600
  must also be \isa{None}. This is best achieved through the use of
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   601
  the monadic operator \isa{{\isaliteral{22}{\isachardoublequote}}Option{\isaliteral{2E}{\isachardot}}bind{\isaliteral{22}{\isachardoublequote}}}.
40171
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   602
  
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   603
  \item \isa{tailrec} defines functions with an arbitrary result
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   604
  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
40171
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   605
  if \isa{undefined} is returned by a recursive call, then the
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   606
  overall result must also be \isa{undefined}. In practice, this is
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   607
  only satisfied when each recursive call is a tail call, whose result
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   608
  is directly returned. Thus, this mode of operation allows the
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   609
  definition of arbitrary tail-recursive functions.
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   610
  \end{description}
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   611
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   612
  Experienced users may define new modes by instantiating the locale
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   613
  \isa{{\isaliteral{22}{\isachardoublequote}}partial{\isaliteral{5F}{\isacharunderscore}}function{\isaliteral{5F}{\isacharunderscore}}definitions{\isaliteral{22}{\isachardoublequote}}} appropriately.
40171
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   614
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   615
  \item \hyperlink{attribute.HOL.partial-function-mono}{\mbox{\isa{partial{\isaliteral{5F}{\isacharunderscore}}function{\isaliteral{5F}{\isacharunderscore}}mono}}} declares rules for
40171
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   616
  use in the internal monononicity proofs of partial function
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   617
  definitions.
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   618
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   619
  \end{description}%
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   620
\end{isamarkuptext}%
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   621
\isamarkuptrue%
1fa547166a1d basic documentation for command partial_function
krauss
parents: 40170
diff changeset
   622
%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   623
\isamarkupsubsection{Old-style recursive function definitions (TFL)%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   624
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   625
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   626
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   627
\begin{isamarkuptext}%
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   628
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.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   629
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   630
  \begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   631
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   632
    \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}}} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   633
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   634
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   635
  \begin{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   636
    'recdef' ('(' 'permissive' ')')? \\ name term (prop +) hints?
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   637
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   638
    recdeftc thmdecl? tc
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   639
    ;
31913
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   640
    hints: '(' 'hints' ( recdefmod * ) ')'
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   641
    ;
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
   642
    recdefmod: (('recdef_simp' | 'recdef_cong' | 'recdef_wf') (() | 'add' | 'del') ':' thmrefs) | clasimpmod
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   643
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   644
    tc: nameref ('(' nat ')')?
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   645
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   646
  \end{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   647
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   648
  \begin{description}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   649
  
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   650
  \item \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} defines general well-founded
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   651
  recursive functions (using the TFL package), see also
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   652
  \cite{isabelle-HOL}.  The ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}permissive{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}}'' option tells
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   653
  TFL to recover from failed proof attempts, returning unfinished
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   654
  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
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   655
  automated proof process of TFL.  Additional \hyperlink{syntax.clasimpmod}{\mbox{\isa{clasimpmod}}}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   656
  declarations (cf.\ \secref{sec:clasimp}) may be given to tune the
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   657
  context of the Simplifier (cf.\ \secref{sec:simplifier}) and
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   658
  Classical reasoner (cf.\ \secref{sec:classical}).
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   659
  
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   660
  \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
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   661
  proof for leftover termination condition number \isa{i} (default
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   662
  1) as generated by a \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} definition of
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   663
  constant \isa{c}.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   664
  
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   665
  Note that in most cases, \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} is able to finish
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   666
  its internal proofs without manual intervention.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   667
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   668
  \end{description}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   669
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   670
  \medskip Hints for \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} may be also declared
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   671
  globally, using the following attributes.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   672
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   673
  \begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   674
    \indexdef{HOL}{attribute}{recdef\_simp}\hypertarget{attribute.HOL.recdef-simp}{\hyperlink{attribute.HOL.recdef-simp}{\mbox{\isa{recdef{\isaliteral{5F}{\isacharunderscore}}simp}}}} & : & \isa{attribute} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   675
    \indexdef{HOL}{attribute}{recdef\_cong}\hypertarget{attribute.HOL.recdef-cong}{\hyperlink{attribute.HOL.recdef-cong}{\mbox{\isa{recdef{\isaliteral{5F}{\isacharunderscore}}cong}}}} & : & \isa{attribute} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   676
    \indexdef{HOL}{attribute}{recdef\_wf}\hypertarget{attribute.HOL.recdef-wf}{\hyperlink{attribute.HOL.recdef-wf}{\mbox{\isa{recdef{\isaliteral{5F}{\isacharunderscore}}wf}}}} & : & \isa{attribute} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   677
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   678
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   679
  \begin{rail}
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
   680
    ('recdef_simp' | 'recdef_cong' | 'recdef_wf') (() | 'add' | 'del')
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   681
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   682
  \end{rail}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   683
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   684
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   685
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   686
\isamarkupsection{Inductive and coinductive definitions \label{sec:hol-inductive}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   687
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   688
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   689
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   690
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   691
An \textbf{inductive definition} specifies the least predicate (or
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   692
  set) \isa{R} closed under given rules: applying a rule to elements
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   693
  of \isa{R} yields a result within \isa{R}.  For example, a
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   694
  structural operational semantics is an inductive definition of an
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   695
  evaluation relation.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   696
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   697
  Dually, a \textbf{coinductive definition} specifies the greatest
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   698
  predicate~/ set \isa{R} that is consistent with given rules: every
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   699
  element of \isa{R} can be seen as arising by applying a rule to
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   700
  elements of \isa{R}.  An important example is using bisimulation
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   701
  relations to formalise equivalence of processes and infinite data
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   702
  structures.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   703
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   704
  \medskip The HOL package is related to the ZF one, which is
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   705
  described in a separate paper,\footnote{It appeared in CADE
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   706
  \cite{paulson-CADE}; a longer version is distributed with Isabelle.}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   707
  which you should refer to in case of difficulties.  The package is
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   708
  simpler than that of ZF thanks to implicit type-checking in HOL.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   709
  The types of the (co)inductive predicates (or sets) determine the
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   710
  domain of the fixedpoint definition, and the package does not have
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   711
  to use inference rules for type-checking.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   712
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   713
  \begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   714
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   715
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   716
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   717
    \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}}} \\
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   718
    \indexdef{HOL}{attribute}{mono}\hypertarget{attribute.HOL.mono}{\hyperlink{attribute.HOL.mono}{\mbox{\isa{mono}}}} & : & \isa{attribute} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   719
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   720
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   721
  \begin{rail}
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
   722
    ('inductive' | 'inductive_set' | 'coinductive' | 'coinductive_set') target? fixes ('for' fixes)? \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   723
    ('where' clauses)? ('monos' thmrefs)?
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   724
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   725
    clauses: (thmdecl? prop + '|')
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   726
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   727
    'mono' (() | 'add' | 'del')
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   728
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   729
  \end{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   730
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   731
  \begin{description}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   732
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   733
  \item \hyperlink{command.HOL.inductive}{\mbox{\isa{\isacommand{inductive}}}} and \hyperlink{command.HOL.coinductive}{\mbox{\isa{\isacommand{coinductive}}}} define (co)inductive predicates from the
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   734
  introduction rules given in the \hyperlink{keyword.where}{\mbox{\isa{\isakeyword{where}}}} part.  The
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   735
  optional \hyperlink{keyword.for}{\mbox{\isa{\isakeyword{for}}}} part contains a list of parameters of the
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   736
  (co)inductive predicates that remain fixed throughout the
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   737
  definition.  The optional \hyperlink{keyword.monos}{\mbox{\isa{\isakeyword{monos}}}} section contains
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   738
  \emph{monotonicity theorems}, which are required for each operator
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   739
  applied to a recursive set in the introduction rules.  There
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   740
  \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}}},
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   741
  for each premise \isa{{\isaliteral{22}{\isachardoublequote}}M\ R\isaliteral{5C3C5E7375623E}{}\isactrlsub i\ t{\isaliteral{22}{\isachardoublequote}}} in an introduction rule!
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   742
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   743
  \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,
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   744
  allowing the definition of (co)inductive sets.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   745
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   746
  \item \hyperlink{attribute.HOL.mono}{\mbox{\isa{mono}}} declares monotonicity rules.  These
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   747
  rule are involved in the automated monotonicity proof of \hyperlink{command.HOL.inductive}{\mbox{\isa{\isacommand{inductive}}}}.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   748
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   749
  \end{description}%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   750
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   751
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   752
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   753
\isamarkupsubsection{Derived rules%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   754
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   755
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   756
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   757
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   758
Each (co)inductive definition \isa{R} adds definitions to the
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   759
  theory and also proves some theorems:
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   760
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   761
  \begin{description}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   762
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   763
  \item \isa{R{\isaliteral{2E}{\isachardot}}intros} is the list of introduction rules as proven
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   764
  theorems, for the recursive predicates (or sets).  The rules are
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   765
  also available individually, using the names given them in the
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   766
  theory file;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   767
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   768
  \item \isa{R{\isaliteral{2E}{\isachardot}}cases} is the case analysis (or elimination) rule;
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   769
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   770
  \item \isa{R{\isaliteral{2E}{\isachardot}}induct} or \isa{R{\isaliteral{2E}{\isachardot}}coinduct} is the (co)induction
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   771
  rule.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   772
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   773
  \end{description}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   774
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   775
  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
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   776
  defined simultaneously, the list of introduction rules is called
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   777
  \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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   778
  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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   779
  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}}}.%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   780
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   781
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   782
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   783
\isamarkupsubsection{Monotonicity theorems%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   784
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   785
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   786
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   787
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   788
Each theory contains a default set of theorems that are used in
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   789
  monotonicity proofs.  New rules can be added to this set via the
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   790
  \hyperlink{attribute.HOL.mono}{\mbox{\isa{mono}}} attribute.  The HOL theory \isa{Inductive}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   791
  shows how this is done.  In general, the following monotonicity
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   792
  theorems may be added:
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   793
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   794
  \begin{itemize}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   795
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   796
  \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
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   797
  monotonicity of inductive definitions whose introduction rules have
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   798
  premises involving terms such as \isa{{\isaliteral{22}{\isachardoublequote}}M\ R\isaliteral{5C3C5E7375623E}{}\isactrlsub i\ t{\isaliteral{22}{\isachardoublequote}}}.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   799
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   800
  \item Monotonicity theorems for logical operators, which are of the
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   801
  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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   802
  the case of the operator \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6F723E}{\isasymor}}{\isaliteral{22}{\isachardoublequote}}}, the corresponding theorem is
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   803
  \[
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   804
  \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}}}}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   805
  \]
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   806
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   807
  \item De Morgan style equations for reasoning about the ``polarity''
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   808
  of expressions, e.g.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   809
  \[
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   810
  \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6E6F743E}{\isasymnot}}\ {\isaliteral{5C3C6E6F743E}{\isasymnot}}\ P\ {\isaliteral{5C3C6C6F6E676C65667472696768746172726F773E}{\isasymlongleftrightarrow}}\ P{\isaliteral{22}{\isachardoublequote}}} \qquad\qquad
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   811
  \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}}}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   812
  \]
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   813
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   814
  \item Equations for reducing complex operators to more primitive
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   815
  ones whose monotonicity can easily be proved, e.g.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   816
  \[
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   817
  \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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   818
  \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}}}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   819
  \]
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   820
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   821
  \end{itemize}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   822
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   823
  %FIXME: Example of an inductive definition%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   824
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   825
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   826
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   827
\isamarkupsection{Arithmetic proof support%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   828
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   829
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   830
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   831
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   832
\begin{matharray}{rcl}
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
   833
    \indexdef{HOL}{method}{arith}\hypertarget{method.HOL.arith}{\hyperlink{method.HOL.arith}{\mbox{\isa{arith}}}} & : & \isa{method} \\
30863
5dc392a59bb7 Finite_Set: lemma
nipkow
parents: 30172
diff changeset
   834
    \indexdef{HOL}{attribute}{arith}\hypertarget{attribute.HOL.arith}{\hyperlink{attribute.HOL.arith}{\mbox{\isa{arith}}}} & : & \isa{attribute} \\
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   835
    \indexdef{HOL}{attribute}{arith\_split}\hypertarget{attribute.HOL.arith-split}{\hyperlink{attribute.HOL.arith-split}{\mbox{\isa{arith{\isaliteral{5F}{\isacharunderscore}}split}}}} & : & \isa{attribute} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   836
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   837
26902
8db1e960d636 updated generated file;
wenzelm
parents: 26895
diff changeset
   838
  The \hyperlink{method.HOL.arith}{\mbox{\isa{arith}}} method decides linear arithmetic problems
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   839
  (on types \isa{nat}, \isa{int}, \isa{real}).  Any current
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   840
  facts are inserted into the goal before running the procedure.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   841
30863
5dc392a59bb7 Finite_Set: lemma
nipkow
parents: 30172
diff changeset
   842
  The \hyperlink{attribute.HOL.arith}{\mbox{\isa{arith}}} attribute declares facts that are
5dc392a59bb7 Finite_Set: lemma
nipkow
parents: 30172
diff changeset
   843
  always supplied to the arithmetic provers implicitly.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   844
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   845
  The \hyperlink{attribute.HOL.arith-split}{\mbox{\isa{arith{\isaliteral{5F}{\isacharunderscore}}split}}} attribute declares case split
30865
5106e13d400f fixed formal markup;
wenzelm
parents: 30863
diff changeset
   846
  rules to be expanded before \hyperlink{method.HOL.arith}{\mbox{\isa{arith}}} is invoked.
30863
5dc392a59bb7 Finite_Set: lemma
nipkow
parents: 30172
diff changeset
   847
5dc392a59bb7 Finite_Set: lemma
nipkow
parents: 30172
diff changeset
   848
  Note that a simpler (but faster) arithmetic prover is
5dc392a59bb7 Finite_Set: lemma
nipkow
parents: 30172
diff changeset
   849
  already invoked by the Simplifier.%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   850
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   851
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
   852
%
30172
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   853
\isamarkupsection{Intuitionistic proof search%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   854
}
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   855
\isamarkuptrue%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   856
%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   857
\begin{isamarkuptext}%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   858
\begin{matharray}{rcl}
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   859
    \indexdef{HOL}{method}{iprover}\hypertarget{method.HOL.iprover}{\hyperlink{method.HOL.iprover}{\mbox{\isa{iprover}}}} & : & \isa{method} \\
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   860
  \end{matharray}
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   861
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   862
  \begin{rail}
35613
9d3ff36ad4e1 eliminated Args.bang_facts (legacy feature);
wenzelm
parents: 35351
diff changeset
   863
    'iprover' ( rulemod * )
30172
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   864
    ;
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   865
  \end{rail}
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   866
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   867
  The \hyperlink{method.HOL.iprover}{\mbox{\isa{iprover}}} method performs intuitionistic proof
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   868
  search, depending on specifically declared rules from the context,
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   869
  or given as explicit arguments.  Chained facts are inserted into the
35613
9d3ff36ad4e1 eliminated Args.bang_facts (legacy feature);
wenzelm
parents: 35351
diff changeset
   870
  goal before commencing proof search.
9d3ff36ad4e1 eliminated Args.bang_facts (legacy feature);
wenzelm
parents: 35351
diff changeset
   871
30172
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   872
  Rules need to be classified as \hyperlink{attribute.Pure.intro}{\mbox{\isa{intro}}},
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   873
  \hyperlink{attribute.Pure.elim}{\mbox{\isa{elim}}}, or \hyperlink{attribute.Pure.dest}{\mbox{\isa{dest}}}; here the
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   874
  ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{21}{\isacharbang}}{\isaliteral{22}{\isachardoublequote}}}'' indicator refers to ``safe'' rules, which may be
30172
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   875
  applied aggressively (without considering back-tracking later).
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   876
  Rules declared with ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3F}{\isacharquery}}{\isaliteral{22}{\isachardoublequote}}}'' are ignored in proof search (the
30172
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   877
  single-step \hyperlink{method.rule}{\mbox{\isa{rule}}} method still observes these).  An
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   878
  explicit weight annotation may be given as well; otherwise the
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   879
  number of rule premises will be taken into account here.%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   880
\end{isamarkuptext}%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   881
\isamarkuptrue%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   882
%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   883
\isamarkupsection{Coherent Logic%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   884
}
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   885
\isamarkuptrue%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   886
%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   887
\begin{isamarkuptext}%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   888
\begin{matharray}{rcl}
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   889
    \indexdef{HOL}{method}{coherent}\hypertarget{method.HOL.coherent}{\hyperlink{method.HOL.coherent}{\mbox{\isa{coherent}}}} & : & \isa{method} \\
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   890
  \end{matharray}
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   891
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   892
  \begin{rail}
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   893
    'coherent' thmrefs?
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   894
    ;
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   895
  \end{rail}
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   896
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   897
  The \hyperlink{method.HOL.coherent}{\mbox{\isa{coherent}}} method solves problems of
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   898
  \emph{Coherent Logic} \cite{Bezem-Coquand:2005}, which covers
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   899
  applications in confluence theory, lattice theory and projective
40802
3cd23f676c5b updated generated files;
wenzelm
parents: 40711
diff changeset
   900
  geometry.  See \verb|~~/src/HOL/ex/Coherent.thy| for some
30172
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   901
  examples.%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   902
\end{isamarkuptext}%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   903
\isamarkuptrue%
afdf7808cfd0 updated generated files;
wenzelm
parents: 29560
diff changeset
   904
%
31913
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   905
\isamarkupsection{Checking and refuting propositions%
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   906
}
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   907
\isamarkuptrue%
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   908
%
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   909
\begin{isamarkuptext}%
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   910
Identifying incorrect propositions usually involves evaluation of
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   911
  particular assignments and systematic counter example search.  This
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   912
  is supported by the following commands.
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   913
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   914
  \begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   915
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   916
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   917
    \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}}}
31913
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   918
  \end{matharray}
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   919
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   920
  \begin{rail}
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   921
    'value' ( ( '[' name ']' ) ? ) modes? term
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   922
    ;
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   923
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   924
    'quickcheck' ( ( '[' args ']' ) ? ) nat?
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   925
    ;
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   926
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   927
    'quickcheck_params' ( ( '[' args ']' ) ? )
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   928
    ;
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   929
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   930
    modes: '(' (name + ) ')'
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   931
    ;
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   932
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   933
    args: ( name '=' value + ',' )
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   934
    ;
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   935
  \end{rail}
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   936
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   937
  \begin{description}
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   938
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   939
  \item \hyperlink{command.HOL.value}{\mbox{\isa{\isacommand{value}}}}~\isa{t} evaluates and prints a
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   940
    term; optionally \isa{modes} can be specified, which are
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   941
    appended to the current print mode (see also \cite{isabelle-ref}).
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   942
    Internally, the evaluation is performed by registered evaluators,
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   943
    which are invoked sequentially until a result is returned.
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   944
    Alternatively a specific evaluator can be selected using square
37444
2e7e7ff21e25 added simp evaluator
haftmann
parents: 37422
diff changeset
   945
    brackets; typical evaluators use the current set of code equations
2e7e7ff21e25 added simp evaluator
haftmann
parents: 37422
diff changeset
   946
    to normalize and include \isa{simp} for fully symbolic evaluation
2e7e7ff21e25 added simp evaluator
haftmann
parents: 37422
diff changeset
   947
    using the simplifier, \isa{nbe} for \emph{normalization by evaluation}
2e7e7ff21e25 added simp evaluator
haftmann
parents: 37422
diff changeset
   948
    and \emph{code} for code generation in SML.
31913
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   949
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   950
  \item \hyperlink{command.HOL.quickcheck}{\mbox{\isa{\isacommand{quickcheck}}}} tests the current goal for
40937
e2e0ef28d3f8 updated generated file;
wenzelm
parents: 40802
diff changeset
   951
    counter examples using a series of assignments for its
31913
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   952
    free variables; by default the first subgoal is tested, an other
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   953
    can be selected explicitly using an optional goal index.
40937
e2e0ef28d3f8 updated generated file;
wenzelm
parents: 40802
diff changeset
   954
    Assignments can be chosen exhausting the search space upto a given
e2e0ef28d3f8 updated generated file;
wenzelm
parents: 40802
diff changeset
   955
    size or using a fixed number of random assignments in the search space.
e2e0ef28d3f8 updated generated file;
wenzelm
parents: 40802
diff changeset
   956
    By default, quickcheck uses exhaustive testing.
31913
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   957
    A number of configuration options are supported for
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   958
    \hyperlink{command.HOL.quickcheck}{\mbox{\isa{\isacommand{quickcheck}}}}, notably:
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   959
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   960
    \begin{description}
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   961
40937
e2e0ef28d3f8 updated generated file;
wenzelm
parents: 40802
diff changeset
   962
    \item[\isa{tester}] specifies how to explore the search space
e2e0ef28d3f8 updated generated file;
wenzelm
parents: 40802
diff changeset
   963
      (e.g. exhaustive or random).
e2e0ef28d3f8 updated generated file;
wenzelm
parents: 40802
diff changeset
   964
      An unknown configuration option is treated as an argument to tester,
e2e0ef28d3f8 updated generated file;
wenzelm
parents: 40802
diff changeset
   965
      making \isa{{\isaliteral{22}{\isachardoublequote}}tester\ {\isaliteral{3D}{\isacharequal}}{\isaliteral{22}{\isachardoublequote}}} optional.
40254
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   966
    \item[\isa{size}] specifies the maximum size of the search space
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   967
    for assignment values.
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   968
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   969
    \item[\isa{iterations}] sets how many sets of assignments are
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   970
    generated for each particular size.
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   971
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   972
    \item[\isa{no{\isaliteral{5F}{\isacharunderscore}}assms}] specifies whether assumptions in
40254
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   973
    structured proofs should be ignored.
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   974
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   975
    \item[\isa{timeout}] sets the time limit in seconds.
31913
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   976
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   977
    \item[\isa{default{\isaliteral{5F}{\isacharunderscore}}type}] sets the type(s) generally used to
40254
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   978
    instantiate type variables.
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   979
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   980
    \item[\isa{report}] if set quickcheck reports how many tests
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   981
    fulfilled the preconditions.
31913
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   982
40254
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   983
    \item[\isa{quiet}] if not set quickcheck informs about the
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   984
    current size for assignment values.
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   985
6d1ebaa7a4ba proper markup of formal text;
wenzelm
parents: 40171
diff changeset
   986
    \item[\isa{expect}] can be used to check if the user's
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   987
    expectation was met (\isa{no{\isaliteral{5F}{\isacharunderscore}}expectation}, \isa{no{\isaliteral{5F}{\isacharunderscore}}counterexample}, or \isa{counterexample}).
35351
7425aece4ee3 allow general mixfix syntax for type constructors;
wenzelm
parents: 34172
diff changeset
   988
31913
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   989
    \end{description}
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   990
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   991
    These option can be given within square brackets.
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   992
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
   993
  \item \hyperlink{command.HOL.quickcheck-params}{\mbox{\isa{\isacommand{quickcheck{\isaliteral{5F}{\isacharunderscore}}params}}}} changes quickcheck
31913
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   994
    configuration options persitently.
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   995
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   996
  \end{description}%
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   997
\end{isamarkuptext}%
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   998
\isamarkuptrue%
edce86bf8521 updated generated files
haftmann
parents: 31254
diff changeset
   999
%
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1000
\isamarkupsection{Unstructured case analysis and induction \label{sec:hol-induct-tac}%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1001
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1002
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1003
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1004
\begin{isamarkuptext}%
27124
e02d6e655e60 updated generated file;
wenzelm
parents: 27103
diff changeset
  1005
The following tools of Isabelle/HOL support cases analysis and
e02d6e655e60 updated generated file;
wenzelm
parents: 27103
diff changeset
  1006
  induction in unstructured tactic scripts; see also
e02d6e655e60 updated generated file;
wenzelm
parents: 27103
diff changeset
  1007
  \secref{sec:cases-induct} for proper Isar versions of similar ideas.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1008
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1009
  \begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1010
    \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} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1011
    \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} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1012
    \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} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1013
    \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}}} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1014
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1015
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1016
  \begin{rail}
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1017
    'case_tac' goalspec? term rule?
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1018
    ;
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1019
    'induct_tac' goalspec? (insts * 'and') rule?
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1020
    ;
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1021
    'ind_cases' (prop +) ('for' (name +)) ?
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1022
    ;
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1023
    'inductive_cases' (thmdecl? (prop +) + 'and')
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1024
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1025
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1026
    rule: ('rule' ':' thmref)
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1027
    ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1028
  \end{rail}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1029
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1030
  \begin{description}
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1031
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1032
  \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
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1033
  to reason about inductive types.  Rules are selected according to
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1034
  the declarations by the \hyperlink{attribute.cases}{\mbox{\isa{cases}}} and \hyperlink{attribute.induct}{\mbox{\isa{induct}}}
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1035
  attributes, cf.\ \secref{sec:cases-induct}.  The \hyperlink{command.HOL.datatype}{\mbox{\isa{\isacommand{datatype}}}} package already takes care of this.
27124
e02d6e655e60 updated generated file;
wenzelm
parents: 27103
diff changeset
  1036
e02d6e655e60 updated generated file;
wenzelm
parents: 27103
diff changeset
  1037
  These unstructured tactics feature both goal addressing and dynamic
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1038
  instantiation.  Note that named rule cases are \emph{not} provided
27124
e02d6e655e60 updated generated file;
wenzelm
parents: 27103
diff changeset
  1039
  as would be by the proper \hyperlink{method.cases}{\mbox{\isa{cases}}} and \hyperlink{method.induct}{\mbox{\isa{induct}}} proof
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1040
  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
27124
e02d6e655e60 updated generated file;
wenzelm
parents: 27103
diff changeset
  1041
  statements, only the compact object-logic conclusion of the subgoal
e02d6e655e60 updated generated file;
wenzelm
parents: 27103
diff changeset
  1042
  being addressed.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1043
  
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1044
  \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
26861
e6fe036ec21d updated generated file;
wenzelm
parents: 26854
diff changeset
  1045
  forward manner.
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1046
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1047
  While \hyperlink{method.HOL.ind-cases}{\mbox{\isa{ind{\isaliteral{5F}{\isacharunderscore}}cases}}} is a proof method to apply the
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1048
  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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1049
  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
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1050
  be generalized before applying the resulting rule.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1051
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1052
  \end{description}%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1053
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1054
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1055
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1056
\isamarkupsection{Executable code%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1057
}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1058
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1059
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1060
\begin{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1061
Isabelle/Pure provides two generic frameworks to support code
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1062
  generation from executable specifications.  Isabelle/HOL
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1063
  instantiates these mechanisms in a way that is amenable to end-user
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1064
  applications.
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1065
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1066
  \medskip One framework generates code from functional programs
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1067
  (including overloading using type classes) to SML \cite{SML}, OCaml
38813
f50f0802ba99 updated generated files
haftmann
parents: 38462
diff changeset
  1068
  \cite{OCaml}, Haskell \cite{haskell-revised-report} and Scala
f50f0802ba99 updated generated files
haftmann
parents: 38462
diff changeset
  1069
  \cite{scala-overview-tech-report}.
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1070
  Conceptually, code generation is split up in three steps:
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1071
  \emph{selection} of code theorems, \emph{translation} into an
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1072
  abstract executable view and \emph{serialization} to a specific
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1073
  \emph{target language}.  Inductive specifications can be executed
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1074
  using the predicate compiler which operates within HOL.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1075
  See \cite{isabelle-codegen} for an introduction.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1076
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1077
  \begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1078
    \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}}} \\
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1079
    \indexdef{HOL}{attribute}{code}\hypertarget{attribute.HOL.code}{\hyperlink{attribute.HOL.code}{\mbox{\isa{code}}}} & : & \isa{attribute} \\
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1080
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1081
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1082
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1083
    \indexdef{HOL}{attribute}{code\_inline}\hypertarget{attribute.HOL.code-inline}{\hyperlink{attribute.HOL.code-inline}{\mbox{\isa{code{\isaliteral{5F}{\isacharunderscore}}inline}}}} & : & \isa{attribute} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1084
    \indexdef{HOL}{attribute}{code\_post}\hypertarget{attribute.HOL.code-post}{\hyperlink{attribute.HOL.code-post}{\mbox{\isa{code{\isaliteral{5F}{\isacharunderscore}}post}}}} & : & \isa{attribute} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1085
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1086
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1087
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1088
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1089
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1090
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1091
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1092
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1093
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1094
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1095
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1096
    \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}}}
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1097
  \end{matharray}
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1098
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1099
  \begin{rail}
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1100
     'export_code' ( constexpr + ) \\
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1101
       ( ( 'in' target ( 'module_name' string ) ? \\
37820
ffaca9167c16 export_code without file prints to standard output
haftmann
parents: 37749
diff changeset
  1102
        ( 'file' ( string | '-' ) ) ? ( '(' args ')' ) ?) + ) ?
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1103
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1104
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1105
    const: term
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1106
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1107
40711
81bc73585eec globbing constant expressions use more idiomatic underscore rather than star
haftmann
parents: 40709
diff changeset
  1108
    constexpr: ( const | 'name._' | '_' )
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1109
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1110
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1111
    typeconstructor: nameref
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1112
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1113
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1114
    class: nameref
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1115
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1116
38813
f50f0802ba99 updated generated files
haftmann
parents: 38462
diff changeset
  1117
    target: 'SML' | 'OCaml' | 'Haskell' | 'Scala'
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1118
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1119
38462
34d3de1254cd formally document `code abstype` and `code abstract` attributes
haftmann
parents: 37820
diff changeset
  1120
    'code' ( 'del' | 'abstype' | 'abstract' ) ?
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1121
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1122
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1123
    'code_abort' ( const + )
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1124
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1125
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1126
    'code_datatype' ( const + )
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1127
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1128
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1129
    'code_inline' ( 'del' ) ?
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1130
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1131
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1132
    'code_post' ( 'del' ) ?
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1133
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1134
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1135
    'code_thms' ( constexpr + ) ?
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1136
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1137
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1138
    'code_deps' ( constexpr + ) ?
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1139
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1140
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1141
    'code_const' (const + 'and') \\
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1142
      ( ( '(' target ( syntax ? + 'and' ) ')' ) + )
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1143
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1144
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1145
    'code_type' (typeconstructor + 'and') \\
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1146
      ( ( '(' target ( syntax ? + 'and' ) ')' ) + )
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1147
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1148
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1149
    'code_class' (class + 'and') \\
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1150
      ( ( '(' target \\ ( string ? + 'and' ) ')' ) + )
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1151
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1152
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1153
    'code_instance' (( typeconstructor '::' class ) + 'and') \\
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1154
      ( ( '(' target ( '-' ? + 'and' ) ')' ) + )
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1155
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1156
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1157
    'code_reserved' target ( string + )
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1158
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1159
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1160
    'code_monad' const const target
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1161
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1162
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1163
    'code_include' target ( string ( string | '-') )
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1164
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1165
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1166
    'code_modulename' target ( ( string string ) + )
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1167
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1168
40709
b29c70cd5c93 datatype constructor glob for code_reflect
haftmann
parents: 40406
diff changeset
  1169
    'code_reflect' string \\
40711
81bc73585eec globbing constant expressions use more idiomatic underscore rather than star
haftmann
parents: 40709
diff changeset
  1170
      ( 'datatypes' ( string '=' ( '_' | ( string + '|' ) + 'and' ) ) ) ? \\
39608
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1171
      ( 'functions' ( string + ) ) ? ( 'file' string ) ?
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1172
    ;
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1173
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1174
    syntax: string | ( 'infix' | 'infixl' | 'infixr' ) nat string
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1175
    ;
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1176
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1177
  \end{rail}
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1178
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1179
  \begin{description}
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1180
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1181
  \item \hyperlink{command.HOL.export-code}{\mbox{\isa{\isacommand{export{\isaliteral{5F}{\isacharunderscore}}code}}}} generates code for a given list
39608
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1182
  of constants in the specified target language(s).  If no
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1183
  serialization instruction is given, only abstract code is generated
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1184
  internally.
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1185
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1186
  Constants may be specified by giving them literally, referring to
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1187
  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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1188
  available by giving \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}}.
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1189
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1190
  By default, for each involved theory one corresponding name space
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1191
  module is generated.  Alternativly, a module name may be specified
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1192
  after the \hyperlink{keyword.module-name}{\mbox{\isa{\isakeyword{module{\isaliteral{5F}{\isacharunderscore}}name}}}} keyword; then \emph{all} code is
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1193
  placed in this module.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1194
39608
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1195
  For \emph{SML}, \emph{OCaml} and \emph{Scala} the file specification
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1196
  refers to a single file; for \emph{Haskell}, it refers to a whole
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1197
  directory, where code is generated in multiple files reflecting the
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1198
  module hierarchy.  Omitting the file specification denotes standard
37749
c7e15d59c58d updated documentation
haftmann
parents: 37444
diff changeset
  1199
  output.
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1200
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1201
  Serializers take an optional list of arguments in parentheses.  For
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1202
  \emph{SML} and \emph{OCaml}, ``\isa{no{\isaliteral{5F}{\isacharunderscore}}signatures}`` omits
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1203
  explicit module signatures.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1204
  
39608
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1205
  For \emph{Haskell} a module name prefix may be given using the
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1206
  ``\isa{{\isaliteral{22}{\isachardoublequote}}root{\isaliteral{3A}{\isacharcolon}}{\isaliteral{22}{\isachardoublequote}}}'' argument; ``\isa{string{\isaliteral{5F}{\isacharunderscore}}classes}'' adds a
39608
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1207
  ``\verb|deriving (Read, Show)|'' clause to each appropriate
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1208
  datatype declaration.
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1209
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1210
  \item \hyperlink{attribute.HOL.code}{\mbox{\isa{code}}} explicitly selects (or with option
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1211
  ``\isa{{\isaliteral{22}{\isachardoublequote}}del{\isaliteral{22}{\isachardoublequote}}}'' deselects) a code equation for code generation.
38462
34d3de1254cd formally document `code abstype` and `code abstract` attributes
haftmann
parents: 37820
diff changeset
  1212
  Usually packages introducing code equations provide a reasonable
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1213
  default setup for selection.  Variants \isa{{\isaliteral{22}{\isachardoublequote}}code\ abstype{\isaliteral{22}{\isachardoublequote}}} and
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1214
  \isa{{\isaliteral{22}{\isachardoublequote}}code\ abstract{\isaliteral{22}{\isachardoublequote}}} declare abstract datatype certificates or
38462
34d3de1254cd formally document `code abstype` and `code abstract` attributes
haftmann
parents: 37820
diff changeset
  1215
  code equations on abstract datatype representations respectively.
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1216
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1217
  \item \hyperlink{command.HOL.code-abort}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}abort}}}} declares constants which are not
39608
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1218
  required to have a definition by means of code equations; if needed
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1219
  these are implemented by program abort instead.
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1220
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1221
  \item \hyperlink{command.HOL.code-datatype}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}datatype}}}} specifies a constructor set
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1222
  for a logical type.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1223
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1224
  \item \hyperlink{command.HOL.print-codesetup}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}codesetup}}}} gives an overview on
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1225
  selected code equations and code generator datatypes.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1226
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1227
  \item \hyperlink{attribute.HOL.code-inline}{\mbox{\isa{code{\isaliteral{5F}{\isacharunderscore}}inline}}} declares (or with option
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1228
  ``\isa{{\isaliteral{22}{\isachardoublequote}}del{\isaliteral{22}{\isachardoublequote}}}'' removes) inlining theorems which are applied as
39608
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1229
  rewrite rules to any code equation during preprocessing.
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1230
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1231
  \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
39608
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1232
  result of an evaluation.
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1233
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1234
  \item \hyperlink{command.HOL.print-codeproc}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}codeproc}}}} prints the setup of the code
39608
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1235
  generator preprocessor.
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1236
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1237
  \item \hyperlink{command.HOL.code-thms}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}thms}}}} prints a list of theorems
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1238
  representing the corresponding program containing all given
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1239
  constants after preprocessing.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1240
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1241
  \item \hyperlink{command.HOL.code-deps}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}deps}}}} visualizes dependencies of
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1242
  theorems representing the corresponding program containing all given
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1243
  constants after preprocessing.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1244
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1245
  \item \hyperlink{command.HOL.code-const}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}const}}}} associates a list of constants
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1246
  with target-specific serializations; omitting a serialization
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1247
  deletes an existing serialization.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1248
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1249
  \item \hyperlink{command.HOL.code-type}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}type}}}} associates a list of type
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1250
  constructors with target-specific serializations; omitting a
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1251
  serialization deletes an existing serialization.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1252
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1253
  \item \hyperlink{command.HOL.code-class}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}class}}}} associates a list of classes
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1254
  with target-specific class names; omitting a serialization deletes
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1255
  an existing serialization.  This applies only to \emph{Haskell}.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1256
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1257
  \item \hyperlink{command.HOL.code-instance}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}instance}}}} declares a list of type
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1258
  constructor / class instance relations as ``already present'' for a
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1259
  given target.  Omitting a ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{2D}{\isacharminus}}{\isaliteral{22}{\isachardoublequote}}}'' deletes an existing
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1260
  ``already present'' declaration.  This applies only to
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1261
  \emph{Haskell}.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1262
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1263
  \item \hyperlink{command.HOL.code-reserved}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}reserved}}}} declares a list of names as
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1264
  reserved for a given target, preventing it to be shadowed by any
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1265
  generated code.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1266
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1267
  \item \hyperlink{command.HOL.code-monad}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}monad}}}} provides an auxiliary mechanism
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1268
  to generate monadic code for Haskell.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1269
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1270
  \item \hyperlink{command.HOL.code-include}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}include}}}} adds arbitrary named content
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1271
  (``include'') to generated code.  A ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{2D}{\isacharminus}}{\isaliteral{22}{\isachardoublequote}}}'' as last argument
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1272
  will remove an already added ``include''.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1273
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1274
  \item \hyperlink{command.HOL.code-modulename}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}modulename}}}} declares aliasings from one
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1275
  module name onto another.
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1276
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1277
  \item \hyperlink{command.HOL.code-reflect}{\mbox{\isa{\isacommand{code{\isaliteral{5F}{\isacharunderscore}}reflect}}}} without a ``\isa{{\isaliteral{22}{\isachardoublequote}}file{\isaliteral{22}{\isachardoublequote}}}''
39608
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1278
  argument compiles code into the system runtime environment and
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1279
  modifies the code generator setup that future invocations of system
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1280
  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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1281
  entities.  With a ``\isa{{\isaliteral{22}{\isachardoublequote}}file{\isaliteral{22}{\isachardoublequote}}}'' argument, the corresponding code
39608
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1282
  is generated into that specified file without modifying the code
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1283
  generator setup.
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1284
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1285
  \end{description}
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1286
39608
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1287
  The other framework generates code from both functional and
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1288
  relational programs to SML.  See \cite{isabelle-HOL} for further
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1289
  information (this actually covers the new-style theory format as
76bc7e4999f8 formal syntax diagram for code_reflect
haftmann
parents: 38813
diff changeset
  1290
  well).
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1291
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1292
  \begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1293
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1294
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1295
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1296
    \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}}} \\  
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1297
    \indexdef{HOL}{attribute}{code}\hypertarget{attribute.HOL.code}{\hyperlink{attribute.HOL.code}{\mbox{\isa{code}}}} & : & \isa{attribute} \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1298
  \end{matharray}
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1299
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1300
  \begin{rail}
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1301
  ( 'code_module' | 'code_library' ) modespec ? name ? \\
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1302
    ( 'file' name ) ? ( 'imports' ( name + ) ) ? \\
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1303
    'contains' ( ( name '=' term ) + | term + )
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1304
  ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1305
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1306
  modespec: '(' ( name * ) ')'
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1307
  ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1308
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1309
  'consts_code' (codespec +)
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1310
  ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1311
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1312
  codespec: const template attachment ?
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1313
  ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1314
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1315
  'types_code' (tycodespec +)
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1316
  ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1317
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1318
  tycodespec: name template attachment ?
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1319
  ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1320
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1321
  const: term
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1322
  ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1323
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1324
  template: '(' string ')'
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1325
  ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1326
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1327
  attachment: 'attach' modespec ? verblbrace text verbrbrace
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1328
  ;
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1329
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1330
  'code' (name)?
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1331
  ;
37422
6d19e4e6ebf5 tuned internal order
haftmann
parents: 37379
diff changeset
  1332
  \end{rail}%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1333
\end{isamarkuptext}%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1334
\isamarkuptrue%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1335
%
27047
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1336
\isamarkupsection{Definition by specification \label{sec:hol-specification}%
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1337
}
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1338
\isamarkuptrue%
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1339
%
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1340
\begin{isamarkuptext}%
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1341
\begin{matharray}{rcl}
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1342
    \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}}} \\
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1343
    \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}}} \\
27047
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1344
  \end{matharray}
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1345
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1346
  \begin{rail}
40255
9ffbc25e1606 eliminated obsolete \_ escapes in rail environments;
wenzelm
parents: 40254
diff changeset
  1347
  ('specification' | 'ax_specification') '(' (decl +) ')' \\ (thmdecl? prop +)
27047
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1348
  ;
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1349
  decl: ((name ':')? term '(' 'overloaded' ')'?)
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1350
  \end{rail}
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1351
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1352
  \begin{description}
27047
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1353
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1354
  \item \hyperlink{command.HOL.specification}{\mbox{\isa{\isacommand{specification}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}decls\ {\isaliteral{5C3C7068693E}{\isasymphi}}{\isaliteral{22}{\isachardoublequote}}} sets up a
27047
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1355
  goal stating the existence of terms with the properties specified to
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1356
  hold for the constants given in \isa{decls}.  After finishing the
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1357
  proof, the theory will be augmented with definitions for the given
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1358
  constants, as well as with theorems stating the properties for these
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1359
  constants.
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1360
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1361
  \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
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1362
  a goal stating the existence of terms with the properties specified
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1363
  to hold for the constants given in \isa{decls}.  After finishing
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1364
  the proof, the theory will be augmented with axioms expressing the
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1365
  properties given in the first place.
27047
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1366
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1367
  \item \isa{decl} declares a constant to be defined by the
27047
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1368
  specification given.  The definition for the constant \isa{c} is
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1369
  bound to the name \isa{c{\isaliteral{5F}{\isacharunderscore}}def} unless a theorem name is given in
27047
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1370
  the declaration.  Overloaded constants should be declared as such.
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1371
28788
ff9d8a8932e4 updated generated files;
wenzelm
parents: 28687
diff changeset
  1372
  \end{description}
27047
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1373
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1374
  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
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1375
  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
27047
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1376
  user has explicitly proven it to be safe.  A practical issue must be
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1377
  considered, though: After introducing two constants with the same
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1378
  properties using \hyperlink{command.HOL.specification}{\mbox{\isa{\isacommand{specification}}}}, one can prove
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1379
  that the two constants are, in fact, equal.  If this might be a
40406
313a24b66a8d updated generated files;
wenzelm
parents: 40388
diff changeset
  1380
  problem, one should use \hyperlink{command.HOL.ax-specification}{\mbox{\isa{\isacommand{ax{\isaliteral{5F}{\isacharunderscore}}specification}}}}.%
27047
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1381
\end{isamarkuptext}%
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1382
\isamarkuptrue%
2dcdea037385 updated generated file;
wenzelm
parents: 27042
diff changeset
  1383
%
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1384
\isadelimtheory
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1385
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1386
\endisadelimtheory
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1387
%
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1388
\isatagtheory
26840
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
  1389
\isacommand{end}\isamarkupfalse%
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
  1390
%
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
  1391
\endisatagtheory
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
  1392
{\isafoldtheory}%
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
  1393
%
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
  1394
\isadelimtheory
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
  1395
%
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
  1396
\endisadelimtheory
26849
df50bc1249d7 converted HOL specific elements;
wenzelm
parents: 26840
diff changeset
  1397
\isanewline
26840
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
  1398
\end{isabellebody}%
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
  1399
%%% Local Variables:
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
  1400
%%% mode: latex
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
  1401
%%% TeX-master: "root"
ec46381f149d added logic-specific sessions;
wenzelm
parents:
diff changeset
  1402
%%% End: