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