author | blanchet |
Mon, 08 Nov 2010 02:33:48 +0100 | |
changeset 40419 | 718b44dbd74d |
parent 40388 | cb9fd7dd641c |
child 40406 | 313a24b66a8d |
permissions | -rw-r--r-- |
26840 | 1 |
% |
2 |
\begin{isabellebody}% |
|
3 |
\def\isabellecontext{HOL{\isacharunderscore}Specific}% |
|
4 |
% |
|
5 |
\isadelimtheory |
|
6 |
% |
|
7 |
\endisadelimtheory |
|
8 |
% |
|
9 |
\isatagtheory |
|
10 |
\isacommand{theory}\isamarkupfalse% |
|
11 |
\ HOL{\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} |
|
35744 | 31 |
\indexdef{HOL}{command}{typedef}\hypertarget{command.HOL.typedef}{\hyperlink{command.HOL.typedef}{\mbox{\isa{\isacommand{typedef}}}}} & : & \isa{{\isachardoublequote}local{\isacharunderscore}theory\ {\isasymrightarrow}\ proof{\isacharparenleft}prove{\isacharparenright}{\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} |
26849 | 47 |
|
35744 | 48 |
\item \hyperlink{command.HOL.typedef}{\mbox{\isa{\isacommand{typedef}}}}~\isa{{\isachardoublequote}{\isacharparenleft}{\isasymalpha}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlsub n{\isacharparenright}\ t\ {\isacharequal}\ A{\isachardoublequote}} |
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. |
|
26849 | 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 |
|
62 |
base name is given in parentheses, or the ``\isa{{\isachardoublequote}{\isacharparenleft}open{\isacharparenright}{\isachardoublequote}}'' |
|
63 |
declaration is used to suppress a separate constant definition |
|
64 |
altogether. The injection from type to set is called \isa{Rep{\isacharunderscore}t}, |
|
65 |
its inverse \isa{Abs{\isacharunderscore}t} --- this may be changed via an explicit |
|
66 |
\hyperlink{keyword.HOL.morphisms}{\mbox{\isa{\isakeyword{morphisms}}}} declaration. |
|
26849 | 67 |
|
68 |
Theorems \isa{Rep{\isacharunderscore}t}, \isa{Rep{\isacharunderscore}t{\isacharunderscore}inverse}, and \isa{Abs{\isacharunderscore}t{\isacharunderscore}inverse} provide the most basic characterization as a |
|
69 |
corresponding injection/surjection pair (in both directions). Rules |
|
70 |
\isa{Rep{\isacharunderscore}t{\isacharunderscore}inject} and \isa{Abs{\isacharunderscore}t{\isacharunderscore}inject} provide a slightly |
|
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}}} |
26895 | 73 |
declarations). Rules \isa{Rep{\isacharunderscore}t{\isacharunderscore}cases}/\isa{Rep{\isacharunderscore}t{\isacharunderscore}induct}, and |
74 |
\isa{Abs{\isacharunderscore}t{\isacharunderscore}cases}/\isa{Abs{\isacharunderscore}t{\isacharunderscore}induct} provide alternative views |
|
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. |
26849 | 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} |
|
28788 | 92 |
\hyperlink{attribute.HOL.split-format}{\mbox{\isa{split{\isacharunderscore}format}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\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} |
26849 | 101 |
|
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
|
102 |
\item \hyperlink{attribute.HOL.split-format}{\mbox{\isa{split{\isacharunderscore}format}}}\ \isa{{\isachardoublequote}{\isacharparenleft}complete{\isacharparenright}{\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 |
|
140 |
fixed & \isa{{\isachardoublequote}{\isasymlparr}x\ {\isacharequal}\ a{\isacharcomma}\ y\ {\isacharequal}\ b{\isasymrparr}{\isachardoublequote}} & \isa{{\isachardoublequote}{\isasymlparr}x\ {\isacharcolon}{\isacharcolon}\ A{\isacharcomma}\ y\ {\isacharcolon}{\isacharcolon}\ B{\isasymrparr}{\isachardoublequote}} \\ |
|
141 |
schematic & \isa{{\isachardoublequote}{\isasymlparr}x\ {\isacharequal}\ a{\isacharcomma}\ y\ {\isacharequal}\ b{\isacharcomma}\ {\isasymdots}\ {\isacharequal}\ m{\isasymrparr}{\isachardoublequote}} & |
|
142 |
\isa{{\isachardoublequote}{\isasymlparr}x\ {\isacharcolon}{\isacharcolon}\ A{\isacharcomma}\ y\ {\isacharcolon}{\isacharcolon}\ B{\isacharcomma}\ {\isasymdots}\ {\isacharcolon}{\isacharcolon}\ M{\isasymrparr}{\isachardoublequote}} \\ |
|
143 |
\end{tabular} |
|
144 |
\end{center} |
|
145 |
||
146 |
\noindent The ASCII representation of \isa{{\isachardoublequote}{\isasymlparr}x\ {\isacharequal}\ a{\isasymrparr}{\isachardoublequote}} is \isa{{\isachardoublequote}{\isacharparenleft}{\isacharbar}\ x\ {\isacharequal}\ a\ {\isacharbar}{\isacharparenright}{\isachardoublequote}}. |
|
147 |
||
148 |
A fixed record \isa{{\isachardoublequote}{\isasymlparr}x\ {\isacharequal}\ a{\isacharcomma}\ y\ {\isacharequal}\ b{\isasymrparr}{\isachardoublequote}} has field \isa{x} of value |
|
149 |
\isa{a} and field \isa{y} of value \isa{b}. The corresponding |
|
150 |
type is \isa{{\isachardoublequote}{\isasymlparr}x\ {\isacharcolon}{\isacharcolon}\ A{\isacharcomma}\ y\ {\isacharcolon}{\isacharcolon}\ B{\isasymrparr}{\isachardoublequote}}, assuming that \isa{{\isachardoublequote}a\ {\isacharcolon}{\isacharcolon}\ A{\isachardoublequote}} |
|
151 |
and \isa{{\isachardoublequote}b\ {\isacharcolon}{\isacharcolon}\ B{\isachardoublequote}}. |
|
152 |
||
153 |
A record scheme like \isa{{\isachardoublequote}{\isasymlparr}x\ {\isacharequal}\ a{\isacharcomma}\ y\ {\isacharequal}\ b{\isacharcomma}\ {\isasymdots}\ {\isacharequal}\ m{\isasymrparr}{\isachardoublequote}} contains fields |
|
154 |
\isa{x} and \isa{y} as before, but also possibly further fields |
|
155 |
as indicated by the ``\isa{{\isachardoublequote}{\isasymdots}{\isachardoublequote}}'' notation (which is actually part |
|
156 |
of the syntax). The improper field ``\isa{{\isachardoublequote}{\isasymdots}{\isachardoublequote}}'' of a record |
|
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 |
|
26852 | 161 |
previous scheme may get instantiated to \isa{{\isachardoublequote}{\isasymlparr}x\ {\isacharequal}\ a{\isacharcomma}\ y\ {\isacharequal}\ b{\isacharcomma}\ z\ {\isacharequal}\ c{\isacharcomma}\ {\isasymdots}\ {\isacharequal}\ m{\isacharprime}{\isasymrparr}{\isachardoublequote}}, where \isa{m{\isacharprime}} refers to a different more part. |
26849 | 162 |
Fixed records are special instances of record schemes, where |
163 |
``\isa{{\isachardoublequote}{\isasymdots}{\isachardoublequote}}'' is properly terminated by the \isa{{\isachardoublequote}{\isacharparenleft}{\isacharparenright}\ {\isacharcolon}{\isacharcolon}\ unit{\isachardoublequote}} |
|
164 |
element. In fact, \isa{{\isachardoublequote}{\isasymlparr}x\ {\isacharequal}\ a{\isacharcomma}\ y\ {\isacharequal}\ b{\isasymrparr}{\isachardoublequote}} is just an abbreviation |
|
165 |
for \isa{{\isachardoublequote}{\isasymlparr}x\ {\isacharequal}\ a{\isacharcomma}\ y\ {\isacharequal}\ b{\isacharcomma}\ {\isasymdots}\ {\isacharequal}\ {\isacharparenleft}{\isacharparenright}{\isasymrparr}{\isachardoublequote}}. |
|
166 |
||
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} |
|
28788 | 198 |
\indexdef{HOL}{command}{record}\hypertarget{command.HOL.record}{\hyperlink{command.HOL.record}{\mbox{\isa{\isacommand{record}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\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 |
|
28788 | 208 |
\item \hyperlink{command.HOL.record}{\mbox{\isa{\isacommand{record}}}}~\isa{{\isachardoublequote}{\isacharparenleft}{\isasymalpha}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlsub m{\isacharparenright}\ t\ {\isacharequal}\ {\isasymtau}\ {\isacharplus}\ c\isactrlsub {\isadigit{1}}\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}\isactrlsub {\isadigit{1}}\ {\isasymdots}\ c\isactrlsub n\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}\isactrlsub n{\isachardoublequote}} defines extensible record type \isa{{\isachardoublequote}{\isacharparenleft}{\isasymalpha}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlsub m{\isacharparenright}\ t{\isachardoublequote}}, |
26849 | 209 |
derived from the optional parent record \isa{{\isachardoublequote}{\isasymtau}{\isachardoublequote}} by adding new |
210 |
field components \isa{{\isachardoublequote}c\isactrlsub i\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}\isactrlsub i{\isachardoublequote}} etc. |
|
211 |
||
212 |
The type variables of \isa{{\isachardoublequote}{\isasymtau}{\isachardoublequote}} and \isa{{\isachardoublequote}{\isasymsigma}\isactrlsub i{\isachardoublequote}} need to be |
|
213 |
covered by the (distinct) parameters \isa{{\isachardoublequote}{\isasymalpha}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlsub m{\isachardoublequote}}. Type constructor \isa{t} has to be new, while \isa{{\isasymtau}} needs to specify an instance of an existing record type. At |
|
214 |
least one new field \isa{{\isachardoublequote}c\isactrlsub i{\isachardoublequote}} has to be specified. |
|
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 |
||
219 |
The parent record specification \isa{{\isasymtau}} is optional; if omitted |
|
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 |
||
225 |
For convenience, \isa{{\isachardoublequote}{\isacharparenleft}{\isasymalpha}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlsub m{\isacharparenright}\ t{\isachardoublequote}} is made a |
|
226 |
type abbreviation for the fixed record type \isa{{\isachardoublequote}{\isasymlparr}c\isactrlsub {\isadigit{1}}\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ c\isactrlsub n\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}\isactrlsub n{\isasymrparr}{\isachardoublequote}}, likewise is \isa{{\isachardoublequote}{\isacharparenleft}{\isasymalpha}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlsub m{\isacharcomma}\ {\isasymzeta}{\isacharparenright}\ t{\isacharunderscore}scheme{\isachardoublequote}} made an abbreviation for |
|
227 |
\isa{{\isachardoublequote}{\isasymlparr}c\isactrlsub {\isadigit{1}}\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ c\isactrlsub n\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}\isactrlsub n{\isacharcomma}\ {\isasymdots}\ {\isacharcolon}{\isacharcolon}\ {\isasymzeta}{\isasymrparr}{\isachardoublequote}}. |
|
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 |
|
242 |
presentation below, we assume for now that \isa{{\isachardoublequote}{\isacharparenleft}{\isasymalpha}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlsub m{\isacharparenright}\ t{\isachardoublequote}} is a root record with fields \isa{{\isachardoublequote}c\isactrlsub {\isadigit{1}}\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ c\isactrlsub n\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}\isactrlsub n{\isachardoublequote}}. |
|
243 |
||
244 |
\medskip \textbf{Selectors} and \textbf{updates} are available for |
|
245 |
any field (including ``\isa{more}''): |
|
246 |
||
247 |
\begin{matharray}{lll} |
|
26852 | 248 |
\isa{{\isachardoublequote}c\isactrlsub i{\isachardoublequote}} & \isa{{\isachardoublequote}{\isacharcolon}{\isacharcolon}{\isachardoublequote}} & \isa{{\isachardoublequote}{\isasymlparr}\isactrlvec c\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymsigma}{\isacharcomma}\ {\isasymdots}\ {\isacharcolon}{\isacharcolon}\ {\isasymzeta}{\isasymrparr}\ {\isasymRightarrow}\ {\isasymsigma}\isactrlsub i{\isachardoublequote}} \\ |
249 |
\isa{{\isachardoublequote}c\isactrlsub i{\isacharunderscore}update{\isachardoublequote}} & \isa{{\isachardoublequote}{\isacharcolon}{\isacharcolon}{\isachardoublequote}} & \isa{{\isachardoublequote}{\isasymsigma}\isactrlsub i\ {\isasymRightarrow}\ {\isasymlparr}\isactrlvec c\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymsigma}{\isacharcomma}\ {\isasymdots}\ {\isacharcolon}{\isacharcolon}\ {\isasymzeta}{\isasymrparr}\ {\isasymRightarrow}\ {\isasymlparr}\isactrlvec c\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymsigma}{\isacharcomma}\ {\isasymdots}\ {\isacharcolon}{\isacharcolon}\ {\isasymzeta}{\isasymrparr}{\isachardoublequote}} \\ |
|
26849 | 250 |
\end{matharray} |
251 |
||
252 |
There is special syntax for application of updates: \isa{{\isachardoublequote}r{\isasymlparr}x\ {\isacharcolon}{\isacharequal}\ a{\isasymrparr}{\isachardoublequote}} abbreviates term \isa{{\isachardoublequote}x{\isacharunderscore}update\ a\ r{\isachardoublequote}}. Further notation for |
|
253 |
repeated updates is also available: \isa{{\isachardoublequote}r{\isasymlparr}x\ {\isacharcolon}{\isacharequal}\ a{\isasymrparr}{\isasymlparr}y\ {\isacharcolon}{\isacharequal}\ b{\isasymrparr}{\isasymlparr}z\ {\isacharcolon}{\isacharequal}\ c{\isasymrparr}{\isachardoublequote}} may be written \isa{{\isachardoublequote}r{\isasymlparr}x\ {\isacharcolon}{\isacharequal}\ a{\isacharcomma}\ y\ {\isacharcolon}{\isacharequal}\ b{\isacharcomma}\ z\ {\isacharcolon}{\isacharequal}\ c{\isasymrparr}{\isachardoublequote}}. Note that |
|
254 |
because of postfix notation the order of fields shown here is |
|
255 |
reverse than in the actual term. Since repeated updates are just |
|
256 |
function applications, fields may be freely permuted in \isa{{\isachardoublequote}{\isasymlparr}x\ {\isacharcolon}{\isacharequal}\ a{\isacharcomma}\ y\ {\isacharcolon}{\isacharequal}\ b{\isacharcomma}\ z\ {\isacharcolon}{\isacharequal}\ c{\isasymrparr}{\isachardoublequote}}, as far as logical equality is concerned. |
|
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} |
|
26852 | 264 |
\isa{{\isachardoublequote}t{\isachardot}make{\isachardoublequote}} & \isa{{\isachardoublequote}{\isacharcolon}{\isacharcolon}{\isachardoublequote}} & \isa{{\isachardoublequote}{\isasymsigma}\isactrlsub {\isadigit{1}}\ {\isasymRightarrow}\ {\isasymdots}\ {\isasymsigma}\isactrlsub n\ {\isasymRightarrow}\ {\isasymlparr}\isactrlvec c\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymsigma}{\isasymrparr}{\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. |
|
273 |
Assuming that \isa{{\isachardoublequote}{\isacharparenleft}{\isasymalpha}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlsub m{\isacharparenright}\ t{\isachardoublequote}} has ancestor |
|
274 |
fields \isa{{\isachardoublequote}b\isactrlsub {\isadigit{1}}\ {\isacharcolon}{\isacharcolon}\ {\isasymrho}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ b\isactrlsub k\ {\isacharcolon}{\isacharcolon}\ {\isasymrho}\isactrlsub k{\isachardoublequote}}, |
|
275 |
the above record operations will get the following types: |
|
276 |
||
26852 | 277 |
\medskip |
278 |
\begin{tabular}{lll} |
|
279 |
\isa{{\isachardoublequote}c\isactrlsub i{\isachardoublequote}} & \isa{{\isachardoublequote}{\isacharcolon}{\isacharcolon}{\isachardoublequote}} & \isa{{\isachardoublequote}{\isasymlparr}\isactrlvec b\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymrho}{\isacharcomma}\ \isactrlvec c\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymsigma}{\isacharcomma}\ {\isasymdots}\ {\isacharcolon}{\isacharcolon}\ {\isasymzeta}{\isasymrparr}\ {\isasymRightarrow}\ {\isasymsigma}\isactrlsub i{\isachardoublequote}} \\ |
|
280 |
\isa{{\isachardoublequote}c\isactrlsub i{\isacharunderscore}update{\isachardoublequote}} & \isa{{\isachardoublequote}{\isacharcolon}{\isacharcolon}{\isachardoublequote}} & \isa{{\isachardoublequote}{\isasymsigma}\isactrlsub i\ {\isasymRightarrow}\ {\isasymlparr}\isactrlvec b\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymrho}{\isacharcomma}\ \isactrlvec c\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymsigma}{\isacharcomma}\ {\isasymdots}\ {\isacharcolon}{\isacharcolon}\ {\isasymzeta}{\isasymrparr}\ {\isasymRightarrow}\ {\isasymlparr}\isactrlvec b\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymrho}{\isacharcomma}\ \isactrlvec c\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymsigma}{\isacharcomma}\ {\isasymdots}\ {\isacharcolon}{\isacharcolon}\ {\isasymzeta}{\isasymrparr}{\isachardoublequote}} \\ |
|
281 |
\isa{{\isachardoublequote}t{\isachardot}make{\isachardoublequote}} & \isa{{\isachardoublequote}{\isacharcolon}{\isacharcolon}{\isachardoublequote}} & \isa{{\isachardoublequote}{\isasymrho}\isactrlsub {\isadigit{1}}\ {\isasymRightarrow}\ {\isasymdots}\ {\isasymrho}\isactrlsub k\ {\isasymRightarrow}\ {\isasymsigma}\isactrlsub {\isadigit{1}}\ {\isasymRightarrow}\ {\isasymdots}\ {\isasymsigma}\isactrlsub n\ {\isasymRightarrow}\ {\isasymlparr}\isactrlvec b\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymrho}{\isacharcomma}\ \isactrlvec c\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymsigma}{\isasymrparr}{\isachardoublequote}} \\ |
|
282 |
\end{tabular} |
|
283 |
\medskip |
|
26849 | 284 |
|
26852 | 285 |
\noindent Some further operations address the extension aspect of a |
26849 | 286 |
derived record scheme specifically: \isa{{\isachardoublequote}t{\isachardot}fields{\isachardoublequote}} produces a |
287 |
record fragment consisting of exactly the new fields introduced here |
|
288 |
(the result may serve as a more part elsewhere); \isa{{\isachardoublequote}t{\isachardot}extend{\isachardoublequote}} |
|
289 |
takes a fixed record and adds a given more part; \isa{{\isachardoublequote}t{\isachardot}truncate{\isachardoublequote}} restricts a record scheme to a fixed record. |
|
290 |
||
26852 | 291 |
\medskip |
292 |
\begin{tabular}{lll} |
|
293 |
\isa{{\isachardoublequote}t{\isachardot}fields{\isachardoublequote}} & \isa{{\isachardoublequote}{\isacharcolon}{\isacharcolon}{\isachardoublequote}} & \isa{{\isachardoublequote}{\isasymsigma}\isactrlsub {\isadigit{1}}\ {\isasymRightarrow}\ {\isasymdots}\ {\isasymsigma}\isactrlsub n\ {\isasymRightarrow}\ {\isasymlparr}\isactrlvec c\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymsigma}{\isasymrparr}{\isachardoublequote}} \\ |
|
294 |
\isa{{\isachardoublequote}t{\isachardot}extend{\isachardoublequote}} & \isa{{\isachardoublequote}{\isacharcolon}{\isacharcolon}{\isachardoublequote}} & \isa{{\isachardoublequote}{\isasymlparr}\isactrlvec b\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymrho}{\isacharcomma}\ \isactrlvec c\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymsigma}{\isasymrparr}\ {\isasymRightarrow}\ {\isasymzeta}\ {\isasymRightarrow}\ {\isasymlparr}\isactrlvec b\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymrho}{\isacharcomma}\ \isactrlvec c\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymsigma}{\isacharcomma}\ {\isasymdots}\ {\isacharcolon}{\isacharcolon}\ {\isasymzeta}{\isasymrparr}{\isachardoublequote}} \\ |
|
295 |
\isa{{\isachardoublequote}t{\isachardot}truncate{\isachardoublequote}} & \isa{{\isachardoublequote}{\isacharcolon}{\isacharcolon}{\isachardoublequote}} & \isa{{\isachardoublequote}{\isasymlparr}\isactrlvec b\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymrho}{\isacharcomma}\ \isactrlvec c\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymsigma}{\isacharcomma}\ {\isasymdots}\ {\isacharcolon}{\isacharcolon}\ {\isasymzeta}{\isasymrparr}\ {\isasymRightarrow}\ {\isasymlparr}\isactrlvec b\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymrho}{\isacharcomma}\ \isactrlvec c\ {\isacharcolon}{\isacharcolon}\ \isactrlvec {\isasymsigma}{\isasymrparr}{\isachardoublequote}} \\ |
|
296 |
\end{tabular} |
|
297 |
\medskip |
|
26849 | 298 |
|
299 |
\noindent Note that \isa{{\isachardoublequote}t{\isachardot}make{\isachardoublequote}} and \isa{{\isachardoublequote}t{\isachardot}fields{\isachardoublequote}} coincide |
|
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} |
|
315 |
||
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 |
26849 | 320 |
are available as \isa{{\isachardoublequote}t{\isachardot}simps{\isachardoublequote}}, too. |
321 |
||
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 |
||
326 |
\item Inject equations of a form analogous to \isa{{\isachardoublequote}{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}x{\isacharprime}{\isacharcomma}\ y{\isacharprime}{\isacharparenright}\ {\isasymequiv}\ x\ {\isacharequal}\ x{\isacharprime}\ {\isasymand}\ y\ {\isacharequal}\ y{\isacharprime}{\isachardoublequote}} are declared to the Simplifier and Classical |
|
26902 | 327 |
Reasoner as \hyperlink{attribute.iff}{\mbox{\isa{iff}}} rules. These rules are available as |
26849 | 328 |
\isa{{\isachardoublequote}t{\isachardot}iffs{\isachardoublequote}}. |
329 |
||
330 |
\item The introduction rule for record equality analogous to \isa{{\isachardoublequote}x\ r\ {\isacharequal}\ x\ r{\isacharprime}\ {\isasymLongrightarrow}\ y\ r\ {\isacharequal}\ y\ r{\isacharprime}\ {\isasymdots}\ {\isasymLongrightarrow}\ r\ {\isacharequal}\ r{\isacharprime}{\isachardoublequote}} is declared to the Simplifier, |
|
26902 | 331 |
and as the basic rule context as ``\hyperlink{attribute.intro}{\mbox{\isa{intro}}}\isa{{\isachardoublequote}{\isacharquery}{\isachardoublequote}}''. |
26849 | 332 |
The rule is called \isa{{\isachardoublequote}t{\isachardot}equality{\isachardoublequote}}. |
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. |
|
338 |
||
339 |
The generic proof methods are sufficiently smart to pick the most |
|
340 |
sensible rule according to the type of the indicated record |
|
341 |
expression: users just need to apply something like ``\isa{{\isachardoublequote}{\isacharparenleft}cases\ r{\isacharparenright}{\isachardoublequote}}'' to a certain proof problem. |
|
342 |
||
343 |
\item The derived record operations \isa{{\isachardoublequote}t{\isachardot}make{\isachardoublequote}}, \isa{{\isachardoublequote}t{\isachardot}fields{\isachardoublequote}}, \isa{{\isachardoublequote}t{\isachardot}extend{\isachardoublequote}}, \isa{{\isachardoublequote}t{\isachardot}truncate{\isachardoublequote}} are \emph{not} |
|
344 |
treated automatically, but usually need to be expanded by hand, |
|
345 |
using the collective fact \isa{{\isachardoublequote}t{\isachardot}defs{\isachardoublequote}}. |
|
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} |
|
28788 | 357 |
\indexdef{HOL}{command}{datatype}\hypertarget{command.HOL.datatype}{\hyperlink{command.HOL.datatype}{\mbox{\isa{\isacommand{datatype}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
358 |
\indexdef{HOL}{command}{rep\_datatype}\hypertarget{command.HOL.rep-datatype}{\hyperlink{command.HOL.rep-datatype}{\mbox{\isa{\isacommand{rep{\isacharunderscore}datatype}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ proof{\isacharparenleft}prove{\isacharparenright}{\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 |
||
28788 | 377 |
\item \hyperlink{command.HOL.rep-datatype}{\mbox{\isa{\isacommand{rep{\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 |
|
26907 | 390 |
emulations of ML tactics \hyperlink{method.HOL.case-tac}{\mbox{\isa{case{\isacharunderscore}tac}}} and \hyperlink{method.HOL.induct-tac}{\mbox{\isa{induct{\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 |
% |
|
396 |
\isamarkupsection{Recursive functions \label{sec:recursion}% |
|
397 |
} |
|
398 |
\isamarkuptrue% |
|
399 |
% |
|
400 |
\begin{isamarkuptext}% |
|
401 |
\begin{matharray}{rcl} |
|
28788 | 402 |
\indexdef{HOL}{command}{primrec}\hypertarget{command.HOL.primrec}{\hyperlink{command.HOL.primrec}{\mbox{\isa{\isacommand{primrec}}}}} & : & \isa{{\isachardoublequote}local{\isacharunderscore}theory\ {\isasymrightarrow}\ local{\isacharunderscore}theory{\isachardoublequote}} \\ |
403 |
\indexdef{HOL}{command}{fun}\hypertarget{command.HOL.fun}{\hyperlink{command.HOL.fun}{\mbox{\isa{\isacommand{fun}}}}} & : & \isa{{\isachardoublequote}local{\isacharunderscore}theory\ {\isasymrightarrow}\ local{\isacharunderscore}theory{\isachardoublequote}} \\ |
|
404 |
\indexdef{HOL}{command}{function}\hypertarget{command.HOL.function}{\hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}}} & : & \isa{{\isachardoublequote}local{\isacharunderscore}theory\ {\isasymrightarrow}\ proof{\isacharparenleft}prove{\isacharparenright}{\isachardoublequote}} \\ |
|
405 |
\indexdef{HOL}{command}{termination}\hypertarget{command.HOL.termination}{\hyperlink{command.HOL.termination}{\mbox{\isa{\isacommand{termination}}}}} & : & \isa{{\isachardoublequote}local{\isacharunderscore}theory\ {\isasymrightarrow}\ proof{\isacharparenleft}prove{\isacharparenright}{\isachardoublequote}} \\ |
|
26849 | 406 |
\end{matharray} |
407 |
||
408 |
\begin{rail} |
|
409 |
'primrec' target? fixes 'where' equations |
|
410 |
; |
|
40170 | 411 |
('fun' | 'function') target? functionopts? fixes \\ 'where' equations |
26849 | 412 |
; |
40170 | 413 |
equations: (thmdecl? prop + '|') |
26849 | 414 |
; |
26987 | 415 |
functionopts: '(' (('sequential' | 'domintros' | 'tailrec' | 'default' term) + ',') ')' |
26849 | 416 |
; |
417 |
'termination' ( term )? |
|
418 |
\end{rail} |
|
419 |
||
28788 | 420 |
\begin{description} |
26849 | 421 |
|
28788 | 422 |
\item \hyperlink{command.HOL.primrec}{\mbox{\isa{\isacommand{primrec}}}} defines primitive recursive |
26849 | 423 |
functions over datatypes, see also \cite{isabelle-HOL}. |
424 |
||
28788 | 425 |
\item \hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}} defines functions by general |
26849 | 426 |
wellfounded recursion. A detailed description with examples can be |
427 |
found in \cite{isabelle-function}. The function is specified by a |
|
428 |
set of (possibly conditional) recursive equations with arbitrary |
|
429 |
pattern matching. The command generates proof obligations for the |
|
430 |
completeness and the compatibility of patterns. |
|
431 |
||
432 |
The defined function is considered partial, and the resulting |
|
433 |
simplification rules (named \isa{{\isachardoublequote}f{\isachardot}psimps{\isachardoublequote}}) and induction rule |
|
434 |
(named \isa{{\isachardoublequote}f{\isachardot}pinduct{\isachardoublequote}}) are guarded by a generated domain |
|
26902 | 435 |
predicate \isa{{\isachardoublequote}f{\isacharunderscore}dom{\isachardoublequote}}. The \hyperlink{command.HOL.termination}{\mbox{\isa{\isacommand{termination}}}} |
26849 | 436 |
command can then be used to establish that the function is total. |
437 |
||
28788 | 438 |
\item \hyperlink{command.HOL.fun}{\mbox{\isa{\isacommand{fun}}}} is a shorthand notation for ``\hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}}~\isa{{\isachardoublequote}{\isacharparenleft}sequential{\isacharparenright}{\isachardoublequote}}, followed by automated |
439 |
proof attempts regarding pattern matching and termination. See |
|
440 |
\cite{isabelle-function} for further details. |
|
26849 | 441 |
|
28788 | 442 |
\item \hyperlink{command.HOL.termination}{\mbox{\isa{\isacommand{termination}}}}~\isa{f} commences a |
26849 | 443 |
termination proof for the previously defined function \isa{f}. If |
444 |
this is omitted, the command refers to the most recent function |
|
445 |
definition. After the proof is closed, the recursive equations and |
|
446 |
the induction principle is established. |
|
447 |
||
28788 | 448 |
\end{description} |
26849 | 449 |
|
27452 | 450 |
Recursive definitions introduced by the \hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}} |
451 |
command accommodate |
|
26849 | 452 |
reasoning by induction (cf.\ \secref{sec:cases-induct}): rule \isa{{\isachardoublequote}c{\isachardot}induct{\isachardoublequote}} (where \isa{c} is the name of the function definition) |
453 |
refers to a specific induction rule, with parameters named according |
|
33857 | 454 |
to the user-specified equations. Cases are numbered (starting from 1). |
455 |
||
456 |
For \hyperlink{command.HOL.primrec}{\mbox{\isa{\isacommand{primrec}}}}, the induction principle coincides |
|
27452 | 457 |
with structural recursion on the datatype the recursion is carried |
458 |
out. |
|
26849 | 459 |
|
460 |
The equations provided by these packages may be referred later as |
|
461 |
theorem list \isa{{\isachardoublequote}f{\isachardot}simps{\isachardoublequote}}, where \isa{f} is the (collective) |
|
462 |
name of the functions defined. Individual equations may be named |
|
463 |
explicitly as well. |
|
464 |
||
26902 | 465 |
The \hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}} command accepts the following |
26849 | 466 |
options. |
467 |
||
28788 | 468 |
\begin{description} |
26849 | 469 |
|
28788 | 470 |
\item \isa{sequential} enables a preprocessor which disambiguates |
471 |
overlapping patterns by making them mutually disjoint. Earlier |
|
472 |
equations take precedence over later ones. This allows to give the |
|
473 |
specification in a format very similar to functional programming. |
|
474 |
Note that the resulting simplification and induction rules |
|
475 |
correspond to the transformed specification, not the one given |
|
26849 | 476 |
originally. This usually means that each equation given by the user |
36139 | 477 |
may result in several theorems. Also note that this automatic |
26849 | 478 |
transformation only works for ML-style datatype patterns. |
479 |
||
28788 | 480 |
\item \isa{domintros} enables the automated generation of |
26849 | 481 |
introduction rules for the domain predicate. While mostly not |
482 |
needed, they can be helpful in some proofs about partial functions. |
|
483 |
||
28788 | 484 |
\item \isa{tailrec} generates the unconstrained recursive |
26849 | 485 |
equations even without a termination proof, provided that the |
486 |
function is tail-recursive. This currently only works |
|
487 |
||
28788 | 488 |
\item \isa{{\isachardoublequote}default\ d{\isachardoublequote}} allows to specify a default value for a |
26849 | 489 |
(partial) function, which will ensure that \isa{{\isachardoublequote}f\ x\ {\isacharequal}\ d\ x{\isachardoublequote}} |
490 |
whenever \isa{{\isachardoublequote}x\ {\isasymnotin}\ f{\isacharunderscore}dom{\isachardoublequote}}. |
|
491 |
||
28788 | 492 |
\end{description}% |
26849 | 493 |
\end{isamarkuptext}% |
494 |
\isamarkuptrue% |
|
495 |
% |
|
496 |
\isamarkupsubsection{Proof methods related to recursive definitions% |
|
497 |
} |
|
498 |
\isamarkuptrue% |
|
499 |
% |
|
500 |
\begin{isamarkuptext}% |
|
501 |
\begin{matharray}{rcl} |
|
28788 | 502 |
\indexdef{HOL}{method}{pat\_completeness}\hypertarget{method.HOL.pat-completeness}{\hyperlink{method.HOL.pat-completeness}{\mbox{\isa{pat{\isacharunderscore}completeness}}}} & : & \isa{method} \\ |
503 |
\indexdef{HOL}{method}{relation}\hypertarget{method.HOL.relation}{\hyperlink{method.HOL.relation}{\mbox{\isa{relation}}}} & : & \isa{method} \\ |
|
504 |
\indexdef{HOL}{method}{lexicographic\_order}\hypertarget{method.HOL.lexicographic-order}{\hyperlink{method.HOL.lexicographic-order}{\mbox{\isa{lexicographic{\isacharunderscore}order}}}} & : & \isa{method} \\ |
|
33858 | 505 |
\indexdef{HOL}{method}{size\_change}\hypertarget{method.HOL.size-change}{\hyperlink{method.HOL.size-change}{\mbox{\isa{size{\isacharunderscore}change}}}} & : & \isa{method} \\ |
26849 | 506 |
\end{matharray} |
507 |
||
508 |
\begin{rail} |
|
509 |
'relation' term |
|
510 |
; |
|
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
511 |
'lexicographic_order' ( clasimpmod * ) |
26849 | 512 |
; |
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
513 |
'size_change' ( orders ( clasimpmod * ) ) |
33858 | 514 |
; |
515 |
orders: ( 'max' | 'min' | 'ms' ) * |
|
26849 | 516 |
\end{rail} |
517 |
||
28788 | 518 |
\begin{description} |
26849 | 519 |
|
28788 | 520 |
\item \hyperlink{method.HOL.pat-completeness}{\mbox{\isa{pat{\isacharunderscore}completeness}}} is a specialized method to |
26849 | 521 |
solve goals regarding the completeness of pattern matching, as |
26902 | 522 |
required by the \hyperlink{command.HOL.function}{\mbox{\isa{\isacommand{function}}}} package (cf.\ |
26849 | 523 |
\cite{isabelle-function}). |
524 |
||
28788 | 525 |
\item \hyperlink{method.HOL.relation}{\mbox{\isa{relation}}}~\isa{R} introduces a termination |
26849 | 526 |
proof using the relation \isa{R}. The resulting proof state will |
527 |
contain goals expressing that \isa{R} is wellfounded, and that the |
|
528 |
arguments of recursive calls decrease with respect to \isa{R}. |
|
529 |
Usually, this method is used as the initial proof step of manual |
|
530 |
termination proofs. |
|
531 |
||
28788 | 532 |
\item \hyperlink{method.HOL.lexicographic-order}{\mbox{\isa{lexicographic{\isacharunderscore}order}}} attempts a fully |
26849 | 533 |
automated termination proof by searching for a lexicographic |
534 |
combination of size measures on the arguments of the function. The |
|
26902 | 535 |
method accepts the same arguments as the \hyperlink{method.auto}{\mbox{\isa{auto}}} method, |
26849 | 536 |
which it uses internally to prove local descents. The same context |
26902 | 537 |
modifiers as for \hyperlink{method.auto}{\mbox{\isa{auto}}} are accepted, see |
26849 | 538 |
\secref{sec:clasimp}. |
539 |
||
540 |
In case of failure, extensive information is printed, which can help |
|
541 |
to analyse the situation (cf.\ \cite{isabelle-function}). |
|
542 |
||
33858 | 543 |
\item \hyperlink{method.HOL.size-change}{\mbox{\isa{size{\isacharunderscore}change}}} also works on termination goals, |
544 |
using a variation of the size-change principle, together with a |
|
545 |
graph decomposition technique (see \cite{krauss_phd} for details). |
|
546 |
Three kinds of orders are used internally: \isa{max}, \isa{min}, |
|
547 |
and \isa{ms} (multiset), which is only available when the theory |
|
548 |
\isa{Multiset} is loaded. When no order kinds are given, they are |
|
549 |
tried in order. The search for a termination proof uses SAT solving |
|
550 |
internally. |
|
551 |
||
552 |
For local descent proofs, the same context modifiers as for \hyperlink{method.auto}{\mbox{\isa{auto}}} are accepted, see \secref{sec:clasimp}. |
|
553 |
||
28788 | 554 |
\end{description}% |
26849 | 555 |
\end{isamarkuptext}% |
556 |
\isamarkuptrue% |
|
557 |
% |
|
40171 | 558 |
\isamarkupsubsection{Functions with explicit partiality% |
559 |
} |
|
560 |
\isamarkuptrue% |
|
561 |
% |
|
562 |
\begin{isamarkuptext}% |
|
563 |
\begin{matharray}{rcl} |
|
564 |
\indexdef{HOL}{command}{partial\_function}\hypertarget{command.HOL.partial-function}{\hyperlink{command.HOL.partial-function}{\mbox{\isa{\isacommand{partial{\isacharunderscore}function}}}}} & : & \isa{{\isachardoublequote}local{\isacharunderscore}theory\ {\isasymrightarrow}\ local{\isacharunderscore}theory{\isachardoublequote}} \\ |
|
565 |
\indexdef{HOL}{attribute}{partial\_function\_mono}\hypertarget{attribute.HOL.partial-function-mono}{\hyperlink{attribute.HOL.partial-function-mono}{\mbox{\isa{partial{\isacharunderscore}function{\isacharunderscore}mono}}}} & : & \isa{attribute} \\ |
|
566 |
\end{matharray} |
|
567 |
||
568 |
\begin{rail} |
|
569 |
'partial_function' target? '(' mode ')' fixes \\ 'where' thmdecl? prop |
|
570 |
\end{rail} |
|
571 |
||
572 |
\begin{description} |
|
573 |
||
574 |
\item \hyperlink{command.HOL.partial-function}{\mbox{\isa{\isacommand{partial{\isacharunderscore}function}}}} defines recursive |
|
575 |
functions based on fixpoints in complete partial orders. No |
|
576 |
termination proof is required from the user or constructed |
|
577 |
internally. Instead, the possibility of non-termination is modelled |
|
578 |
explicitly in the result type, which contains an explicit bottom |
|
579 |
element. |
|
580 |
||
581 |
Pattern matching and mutual recursion are currently not supported. |
|
582 |
Thus, the specification consists of a single function described by a |
|
583 |
single recursive equation. |
|
584 |
||
585 |
There are no fixed syntactic restrictions on the body of the |
|
586 |
function, but the induced functional must be provably monotonic |
|
587 |
wrt.\ the underlying order. The monotonicitity proof is performed |
|
588 |
internally, and the definition is rejected when it fails. The proof |
|
589 |
can be influenced by declaring hints using the |
|
590 |
\hyperlink{attribute.HOL.partial-function-mono}{\mbox{\isa{partial{\isacharunderscore}function{\isacharunderscore}mono}}} attribute. |
|
591 |
||
592 |
The mandatory \isa{mode} argument specifies the mode of operation |
|
593 |
of the command, which directly corresponds to a complete partial |
|
594 |
order on the result type. By default, the following modes are |
|
595 |
defined: |
|
596 |
||
597 |
\begin{description} |
|
598 |
\item \isa{option} defines functions that map into the \isa{option} type. Here, the value \isa{None} is used to model a |
|
599 |
non-terminating computation. Monotonicity requires that if \isa{None} is returned by a recursive call, then the overall result |
|
600 |
must also be \isa{None}. This is best achieved through the use of |
|
601 |
the monadic operator \isa{{\isachardoublequote}Option{\isachardot}bind{\isachardoublequote}}. |
|
602 |
||
603 |
\item \isa{tailrec} defines functions with an arbitrary result |
|
604 |
type and uses the slightly degenerated partial order where \isa{{\isachardoublequote}undefined{\isachardoublequote}} is the bottom element. Now, monotonicity requires that |
|
605 |
if \isa{undefined} is returned by a recursive call, then the |
|
606 |
overall result must also be \isa{undefined}. In practice, this is |
|
607 |
only satisfied when each recursive call is a tail call, whose result |
|
608 |
is directly returned. Thus, this mode of operation allows the |
|
609 |
definition of arbitrary tail-recursive functions. |
|
610 |
\end{description} |
|
611 |
||
612 |
Experienced users may define new modes by instantiating the locale |
|
613 |
\isa{{\isachardoublequote}partial{\isacharunderscore}function{\isacharunderscore}definitions{\isachardoublequote}} appropriately. |
|
614 |
||
615 |
\item \hyperlink{attribute.HOL.partial-function-mono}{\mbox{\isa{partial{\isacharunderscore}function{\isacharunderscore}mono}}} declares rules for |
|
616 |
use in the internal monononicity proofs of partial function |
|
617 |
definitions. |
|
618 |
||
619 |
\end{description}% |
|
620 |
\end{isamarkuptext}% |
|
621 |
\isamarkuptrue% |
|
622 |
% |
|
26849 | 623 |
\isamarkupsubsection{Old-style recursive function definitions (TFL)% |
624 |
} |
|
625 |
\isamarkuptrue% |
|
626 |
% |
|
627 |
\begin{isamarkuptext}% |
|
26907 | 628 |
The old TFL commands \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} and \hyperlink{command.HOL.recdef-tc}{\mbox{\isa{\isacommand{recdef{\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 | 629 |
|
630 |
\begin{matharray}{rcl} |
|
28788 | 631 |
\indexdef{HOL}{command}{recdef}\hypertarget{command.HOL.recdef}{\hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isacharparenright}{\isachardoublequote}} \\ |
632 |
\indexdef{HOL}{command}{recdef\_tc}\hypertarget{command.HOL.recdef-tc}{\hyperlink{command.HOL.recdef-tc}{\mbox{\isa{\isacommand{recdef{\isacharunderscore}tc}}}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ proof{\isacharparenleft}prove{\isacharparenright}{\isachardoublequote}} \\ |
|
26849 | 633 |
\end{matharray} |
634 |
||
635 |
\begin{rail} |
|
636 |
'recdef' ('(' 'permissive' ')')? \\ name term (prop +) hints? |
|
637 |
; |
|
638 |
recdeftc thmdecl? tc |
|
639 |
; |
|
31913 | 640 |
hints: '(' 'hints' ( recdefmod * ) ')' |
26849 | 641 |
; |
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
642 |
recdefmod: (('recdef_simp' | 'recdef_cong' | 'recdef_wf') (() | 'add' | 'del') ':' thmrefs) | clasimpmod |
26849 | 643 |
; |
644 |
tc: nameref ('(' nat ')')? |
|
645 |
; |
|
646 |
\end{rail} |
|
647 |
||
28788 | 648 |
\begin{description} |
26849 | 649 |
|
28788 | 650 |
\item \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} defines general well-founded |
26849 | 651 |
recursive functions (using the TFL package), see also |
652 |
\cite{isabelle-HOL}. The ``\isa{{\isachardoublequote}{\isacharparenleft}permissive{\isacharparenright}{\isachardoublequote}}'' option tells |
|
653 |
TFL to recover from failed proof attempts, returning unfinished |
|
654 |
results. The \isa{recdef{\isacharunderscore}simp}, \isa{recdef{\isacharunderscore}cong}, and \isa{recdef{\isacharunderscore}wf} hints refer to auxiliary rules to be used in the internal |
|
26902 | 655 |
automated proof process of TFL. Additional \hyperlink{syntax.clasimpmod}{\mbox{\isa{clasimpmod}}} |
26849 | 656 |
declarations (cf.\ \secref{sec:clasimp}) may be given to tune the |
657 |
context of the Simplifier (cf.\ \secref{sec:simplifier}) and |
|
658 |
Classical reasoner (cf.\ \secref{sec:classical}). |
|
659 |
||
28788 | 660 |
\item \hyperlink{command.HOL.recdef-tc}{\mbox{\isa{\isacommand{recdef{\isacharunderscore}tc}}}}~\isa{{\isachardoublequote}c\ {\isacharparenleft}i{\isacharparenright}{\isachardoublequote}} recommences the |
26849 | 661 |
proof for leftover termination condition number \isa{i} (default |
26902 | 662 |
1) as generated by a \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} definition of |
26849 | 663 |
constant \isa{c}. |
664 |
||
26902 | 665 |
Note that in most cases, \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} is able to finish |
26849 | 666 |
its internal proofs without manual intervention. |
667 |
||
28788 | 668 |
\end{description} |
26849 | 669 |
|
26902 | 670 |
\medskip Hints for \hyperlink{command.HOL.recdef}{\mbox{\isa{\isacommand{recdef}}}} may be also declared |
26849 | 671 |
globally, using the following attributes. |
672 |
||
673 |
\begin{matharray}{rcl} |
|
28788 | 674 |
\indexdef{HOL}{attribute}{recdef\_simp}\hypertarget{attribute.HOL.recdef-simp}{\hyperlink{attribute.HOL.recdef-simp}{\mbox{\isa{recdef{\isacharunderscore}simp}}}} & : & \isa{attribute} \\ |
675 |
\indexdef{HOL}{attribute}{recdef\_cong}\hypertarget{attribute.HOL.recdef-cong}{\hyperlink{attribute.HOL.recdef-cong}{\mbox{\isa{recdef{\isacharunderscore}cong}}}} & : & \isa{attribute} \\ |
|
676 |
\indexdef{HOL}{attribute}{recdef\_wf}\hypertarget{attribute.HOL.recdef-wf}{\hyperlink{attribute.HOL.recdef-wf}{\mbox{\isa{recdef{\isacharunderscore}wf}}}} & : & \isa{attribute} \\ |
|
26849 | 677 |
\end{matharray} |
678 |
||
679 |
\begin{rail} |
|
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
680 |
('recdef_simp' | 'recdef_cong' | 'recdef_wf') (() | 'add' | 'del') |
26849 | 681 |
; |
682 |
\end{rail}% |
|
683 |
\end{isamarkuptext}% |
|
684 |
\isamarkuptrue% |
|
685 |
% |
|
686 |
\isamarkupsection{Inductive and coinductive definitions \label{sec:hol-inductive}% |
|
687 |
} |
|
688 |
\isamarkuptrue% |
|
689 |
% |
|
690 |
\begin{isamarkuptext}% |
|
691 |
An \textbf{inductive definition} specifies the least predicate (or |
|
692 |
set) \isa{R} closed under given rules: applying a rule to elements |
|
693 |
of \isa{R} yields a result within \isa{R}. For example, a |
|
694 |
structural operational semantics is an inductive definition of an |
|
695 |
evaluation relation. |
|
696 |
||
697 |
Dually, a \textbf{coinductive definition} specifies the greatest |
|
698 |
predicate~/ set \isa{R} that is consistent with given rules: every |
|
699 |
element of \isa{R} can be seen as arising by applying a rule to |
|
700 |
elements of \isa{R}. An important example is using bisimulation |
|
701 |
relations to formalise equivalence of processes and infinite data |
|
702 |
structures. |
|
703 |
||
704 |
\medskip The HOL package is related to the ZF one, which is |
|
705 |
described in a separate paper,\footnote{It appeared in CADE |
|
706 |
\cite{paulson-CADE}; a longer version is distributed with Isabelle.} |
|
707 |
which you should refer to in case of difficulties. The package is |
|
708 |
simpler than that of ZF thanks to implicit type-checking in HOL. |
|
709 |
The types of the (co)inductive predicates (or sets) determine the |
|
710 |
domain of the fixedpoint definition, and the package does not have |
|
711 |
to use inference rules for type-checking. |
|
712 |
||
713 |
\begin{matharray}{rcl} |
|
28788 | 714 |
\indexdef{HOL}{command}{inductive}\hypertarget{command.HOL.inductive}{\hyperlink{command.HOL.inductive}{\mbox{\isa{\isacommand{inductive}}}}} & : & \isa{{\isachardoublequote}local{\isacharunderscore}theory\ {\isasymrightarrow}\ local{\isacharunderscore}theory{\isachardoublequote}} \\ |
715 |
\indexdef{HOL}{command}{inductive\_set}\hypertarget{command.HOL.inductive-set}{\hyperlink{command.HOL.inductive-set}{\mbox{\isa{\isacommand{inductive{\isacharunderscore}set}}}}} & : & \isa{{\isachardoublequote}local{\isacharunderscore}theory\ {\isasymrightarrow}\ local{\isacharunderscore}theory{\isachardoublequote}} \\ |
|
716 |
\indexdef{HOL}{command}{coinductive}\hypertarget{command.HOL.coinductive}{\hyperlink{command.HOL.coinductive}{\mbox{\isa{\isacommand{coinductive}}}}} & : & \isa{{\isachardoublequote}local{\isacharunderscore}theory\ {\isasymrightarrow}\ local{\isacharunderscore}theory{\isachardoublequote}} \\ |
|
717 |
\indexdef{HOL}{command}{coinductive\_set}\hypertarget{command.HOL.coinductive-set}{\hyperlink{command.HOL.coinductive-set}{\mbox{\isa{\isacommand{coinductive{\isacharunderscore}set}}}}} & : & \isa{{\isachardoublequote}local{\isacharunderscore}theory\ {\isasymrightarrow}\ local{\isacharunderscore}theory{\isachardoublequote}} \\ |
|
718 |
\indexdef{HOL}{attribute}{mono}\hypertarget{attribute.HOL.mono}{\hyperlink{attribute.HOL.mono}{\mbox{\isa{mono}}}} & : & \isa{attribute} \\ |
|
26849 | 719 |
\end{matharray} |
720 |
||
721 |
\begin{rail} |
|
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
722 |
('inductive' | 'inductive_set' | 'coinductive' | 'coinductive_set') target? fixes ('for' fixes)? \\ |
26849 | 723 |
('where' clauses)? ('monos' thmrefs)? |
724 |
; |
|
725 |
clauses: (thmdecl? prop + '|') |
|
726 |
; |
|
727 |
'mono' (() | 'add' | 'del') |
|
728 |
; |
|
729 |
\end{rail} |
|
730 |
||
28788 | 731 |
\begin{description} |
26849 | 732 |
|
28788 | 733 |
\item \hyperlink{command.HOL.inductive}{\mbox{\isa{\isacommand{inductive}}}} and \hyperlink{command.HOL.coinductive}{\mbox{\isa{\isacommand{coinductive}}}} define (co)inductive predicates from the |
26902 | 734 |
introduction rules given in the \hyperlink{keyword.where}{\mbox{\isa{\isakeyword{where}}}} part. The |
735 |
optional \hyperlink{keyword.for}{\mbox{\isa{\isakeyword{for}}}} part contains a list of parameters of the |
|
26849 | 736 |
(co)inductive predicates that remain fixed throughout the |
26902 | 737 |
definition. The optional \hyperlink{keyword.monos}{\mbox{\isa{\isakeyword{monos}}}} section contains |
26849 | 738 |
\emph{monotonicity theorems}, which are required for each operator |
739 |
applied to a recursive set in the introduction rules. There |
|
740 |
\emph{must} be a theorem of the form \isa{{\isachardoublequote}A\ {\isasymle}\ B\ {\isasymLongrightarrow}\ M\ A\ {\isasymle}\ M\ B{\isachardoublequote}}, |
|
741 |
for each premise \isa{{\isachardoublequote}M\ R\isactrlsub i\ t{\isachardoublequote}} in an introduction rule! |
|
742 |
||
28788 | 743 |
\item \hyperlink{command.HOL.inductive-set}{\mbox{\isa{\isacommand{inductive{\isacharunderscore}set}}}} and \hyperlink{command.HOL.coinductive-set}{\mbox{\isa{\isacommand{coinductive{\isacharunderscore}set}}}} are wrappers for to the previous commands, |
26849 | 744 |
allowing the definition of (co)inductive sets. |
745 |
||
28788 | 746 |
\item \hyperlink{attribute.HOL.mono}{\mbox{\isa{mono}}} declares monotonicity rules. These |
26902 | 747 |
rule are involved in the automated monotonicity proof of \hyperlink{command.HOL.inductive}{\mbox{\isa{\isacommand{inductive}}}}. |
26849 | 748 |
|
28788 | 749 |
\end{description}% |
26849 | 750 |
\end{isamarkuptext}% |
751 |
\isamarkuptrue% |
|
752 |
% |
|
753 |
\isamarkupsubsection{Derived rules% |
|
754 |
} |
|
755 |
\isamarkuptrue% |
|
756 |
% |
|
757 |
\begin{isamarkuptext}% |
|
758 |
Each (co)inductive definition \isa{R} adds definitions to the |
|
759 |
theory and also proves some theorems: |
|
760 |
||
761 |
\begin{description} |
|
762 |
||
28788 | 763 |
\item \isa{R{\isachardot}intros} is the list of introduction rules as proven |
26849 | 764 |
theorems, for the recursive predicates (or sets). The rules are |
765 |
also available individually, using the names given them in the |
|
766 |
theory file; |
|
767 |
||
28788 | 768 |
\item \isa{R{\isachardot}cases} is the case analysis (or elimination) rule; |
26849 | 769 |
|
28788 | 770 |
\item \isa{R{\isachardot}induct} or \isa{R{\isachardot}coinduct} is the (co)induction |
26849 | 771 |
rule. |
772 |
||
773 |
\end{description} |
|
774 |
||
775 |
When several predicates \isa{{\isachardoublequote}R\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ R\isactrlsub n{\isachardoublequote}} are |
|
776 |
defined simultaneously, the list of introduction rules is called |
|
777 |
\isa{{\isachardoublequote}R\isactrlsub {\isadigit{1}}{\isacharunderscore}{\isasymdots}{\isacharunderscore}R\isactrlsub n{\isachardot}intros{\isachardoublequote}}, the case analysis rules are |
|
778 |
called \isa{{\isachardoublequote}R\isactrlsub {\isadigit{1}}{\isachardot}cases{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ R\isactrlsub n{\isachardot}cases{\isachardoublequote}}, and the list |
|
779 |
of mutual induction rules is called \isa{{\isachardoublequote}R\isactrlsub {\isadigit{1}}{\isacharunderscore}{\isasymdots}{\isacharunderscore}R\isactrlsub n{\isachardot}inducts{\isachardoublequote}}.% |
|
780 |
\end{isamarkuptext}% |
|
781 |
\isamarkuptrue% |
|
782 |
% |
|
783 |
\isamarkupsubsection{Monotonicity theorems% |
|
784 |
} |
|
785 |
\isamarkuptrue% |
|
786 |
% |
|
787 |
\begin{isamarkuptext}% |
|
788 |
Each theory contains a default set of theorems that are used in |
|
789 |
monotonicity proofs. New rules can be added to this set via the |
|
26902 | 790 |
\hyperlink{attribute.HOL.mono}{\mbox{\isa{mono}}} attribute. The HOL theory \isa{Inductive} |
26849 | 791 |
shows how this is done. In general, the following monotonicity |
792 |
theorems may be added: |
|
793 |
||
794 |
\begin{itemize} |
|
795 |
||
796 |
\item Theorems of the form \isa{{\isachardoublequote}A\ {\isasymle}\ B\ {\isasymLongrightarrow}\ M\ A\ {\isasymle}\ M\ B{\isachardoublequote}}, for proving |
|
797 |
monotonicity of inductive definitions whose introduction rules have |
|
798 |
premises involving terms such as \isa{{\isachardoublequote}M\ R\isactrlsub i\ t{\isachardoublequote}}. |
|
799 |
||
800 |
\item Monotonicity theorems for logical operators, which are of the |
|
801 |
general form \isa{{\isachardoublequote}{\isacharparenleft}{\isasymdots}\ {\isasymlongrightarrow}\ {\isasymdots}{\isacharparenright}\ {\isasymLongrightarrow}\ {\isasymdots}\ {\isacharparenleft}{\isasymdots}\ {\isasymlongrightarrow}\ {\isasymdots}{\isacharparenright}\ {\isasymLongrightarrow}\ {\isasymdots}\ {\isasymlongrightarrow}\ {\isasymdots}{\isachardoublequote}}. For example, in |
|
802 |
the case of the operator \isa{{\isachardoublequote}{\isasymor}{\isachardoublequote}}, the corresponding theorem is |
|
803 |
\[ |
|
804 |
\infer{\isa{{\isachardoublequote}P\isactrlsub {\isadigit{1}}\ {\isasymor}\ P\isactrlsub {\isadigit{2}}\ {\isasymlongrightarrow}\ Q\isactrlsub {\isadigit{1}}\ {\isasymor}\ Q\isactrlsub {\isadigit{2}}{\isachardoublequote}}}{\isa{{\isachardoublequote}P\isactrlsub {\isadigit{1}}\ {\isasymlongrightarrow}\ Q\isactrlsub {\isadigit{1}}{\isachardoublequote}} & \isa{{\isachardoublequote}P\isactrlsub {\isadigit{2}}\ {\isasymlongrightarrow}\ Q\isactrlsub {\isadigit{2}}{\isachardoublequote}}} |
|
805 |
\] |
|
806 |
||
807 |
\item De Morgan style equations for reasoning about the ``polarity'' |
|
808 |
of expressions, e.g. |
|
809 |
\[ |
|
810 |
\isa{{\isachardoublequote}{\isasymnot}\ {\isasymnot}\ P\ {\isasymlongleftrightarrow}\ P{\isachardoublequote}} \qquad\qquad |
|
811 |
\isa{{\isachardoublequote}{\isasymnot}\ {\isacharparenleft}P\ {\isasymand}\ Q{\isacharparenright}\ {\isasymlongleftrightarrow}\ {\isasymnot}\ P\ {\isasymor}\ {\isasymnot}\ Q{\isachardoublequote}} |
|
812 |
\] |
|
813 |
||
814 |
\item Equations for reducing complex operators to more primitive |
|
815 |
ones whose monotonicity can easily be proved, e.g. |
|
816 |
\[ |
|
817 |
\isa{{\isachardoublequote}{\isacharparenleft}P\ {\isasymlongrightarrow}\ Q{\isacharparenright}\ {\isasymlongleftrightarrow}\ {\isasymnot}\ P\ {\isasymor}\ Q{\isachardoublequote}} \qquad\qquad |
|
818 |
\isa{{\isachardoublequote}Ball\ A\ P\ {\isasymequiv}\ {\isasymforall}x{\isachardot}\ x\ {\isasymin}\ A\ {\isasymlongrightarrow}\ P\ x{\isachardoublequote}} |
|
819 |
\] |
|
820 |
||
821 |
\end{itemize} |
|
822 |
||
823 |
%FIXME: Example of an inductive definition% |
|
824 |
\end{isamarkuptext}% |
|
825 |
\isamarkuptrue% |
|
826 |
% |
|
827 |
\isamarkupsection{Arithmetic proof support% |
|
828 |
} |
|
829 |
\isamarkuptrue% |
|
830 |
% |
|
831 |
\begin{isamarkuptext}% |
|
832 |
\begin{matharray}{rcl} |
|
28788 | 833 |
\indexdef{HOL}{method}{arith}\hypertarget{method.HOL.arith}{\hyperlink{method.HOL.arith}{\mbox{\isa{arith}}}} & : & \isa{method} \\ |
30863 | 834 |
\indexdef{HOL}{attribute}{arith}\hypertarget{attribute.HOL.arith}{\hyperlink{attribute.HOL.arith}{\mbox{\isa{arith}}}} & : & \isa{attribute} \\ |
28788 | 835 |
\indexdef{HOL}{attribute}{arith\_split}\hypertarget{attribute.HOL.arith-split}{\hyperlink{attribute.HOL.arith-split}{\mbox{\isa{arith{\isacharunderscore}split}}}} & : & \isa{attribute} \\ |
26849 | 836 |
\end{matharray} |
837 |
||
26902 | 838 |
The \hyperlink{method.HOL.arith}{\mbox{\isa{arith}}} method decides linear arithmetic problems |
26849 | 839 |
(on types \isa{nat}, \isa{int}, \isa{real}). Any current |
840 |
facts are inserted into the goal before running the procedure. |
|
841 |
||
30863 | 842 |
The \hyperlink{attribute.HOL.arith}{\mbox{\isa{arith}}} attribute declares facts that are |
843 |
always supplied to the arithmetic provers implicitly. |
|
26849 | 844 |
|
30863 | 845 |
The \hyperlink{attribute.HOL.arith-split}{\mbox{\isa{arith{\isacharunderscore}split}}} attribute declares case split |
30865 | 846 |
rules to be expanded before \hyperlink{method.HOL.arith}{\mbox{\isa{arith}}} is invoked. |
30863 | 847 |
|
848 |
Note that a simpler (but faster) arithmetic prover is |
|
849 |
already invoked by the Simplifier.% |
|
26849 | 850 |
\end{isamarkuptext}% |
851 |
\isamarkuptrue% |
|
852 |
% |
|
30172 | 853 |
\isamarkupsection{Intuitionistic proof search% |
854 |
} |
|
855 |
\isamarkuptrue% |
|
856 |
% |
|
857 |
\begin{isamarkuptext}% |
|
858 |
\begin{matharray}{rcl} |
|
859 |
\indexdef{HOL}{method}{iprover}\hypertarget{method.HOL.iprover}{\hyperlink{method.HOL.iprover}{\mbox{\isa{iprover}}}} & : & \isa{method} \\ |
|
860 |
\end{matharray} |
|
861 |
||
862 |
\begin{rail} |
|
35613 | 863 |
'iprover' ( rulemod * ) |
30172 | 864 |
; |
865 |
\end{rail} |
|
866 |
||
867 |
The \hyperlink{method.HOL.iprover}{\mbox{\isa{iprover}}} method performs intuitionistic proof |
|
868 |
search, depending on specifically declared rules from the context, |
|
869 |
or given as explicit arguments. Chained facts are inserted into the |
|
35613 | 870 |
goal before commencing proof search. |
871 |
||
30172 | 872 |
Rules need to be classified as \hyperlink{attribute.Pure.intro}{\mbox{\isa{intro}}}, |
873 |
\hyperlink{attribute.Pure.elim}{\mbox{\isa{elim}}}, or \hyperlink{attribute.Pure.dest}{\mbox{\isa{dest}}}; here the |
|
874 |
``\isa{{\isachardoublequote}{\isacharbang}{\isachardoublequote}}'' indicator refers to ``safe'' rules, which may be |
|
875 |
applied aggressively (without considering back-tracking later). |
|
876 |
Rules declared with ``\isa{{\isachardoublequote}{\isacharquery}{\isachardoublequote}}'' are ignored in proof search (the |
|
877 |
single-step \hyperlink{method.rule}{\mbox{\isa{rule}}} method still observes these). An |
|
878 |
explicit weight annotation may be given as well; otherwise the |
|
879 |
number of rule premises will be taken into account here.% |
|
880 |
\end{isamarkuptext}% |
|
881 |
\isamarkuptrue% |
|
882 |
% |
|
883 |
\isamarkupsection{Coherent Logic% |
|
884 |
} |
|
885 |
\isamarkuptrue% |
|
886 |
% |
|
887 |
\begin{isamarkuptext}% |
|
888 |
\begin{matharray}{rcl} |
|
889 |
\indexdef{HOL}{method}{coherent}\hypertarget{method.HOL.coherent}{\hyperlink{method.HOL.coherent}{\mbox{\isa{coherent}}}} & : & \isa{method} \\ |
|
890 |
\end{matharray} |
|
891 |
||
892 |
\begin{rail} |
|
893 |
'coherent' thmrefs? |
|
894 |
; |
|
895 |
\end{rail} |
|
896 |
||
897 |
The \hyperlink{method.HOL.coherent}{\mbox{\isa{coherent}}} method solves problems of |
|
898 |
\emph{Coherent Logic} \cite{Bezem-Coquand:2005}, which covers |
|
899 |
applications in confluence theory, lattice theory and projective |
|
900 |
geometry. See \hyperlink{file.~~/src/HOL/ex/Coherent.thy}{\mbox{\isa{\isatt{{\isachartilde}{\isachartilde}{\isacharslash}src{\isacharslash}HOL{\isacharslash}ex{\isacharslash}Coherent{\isachardot}thy}}}} for some |
|
901 |
examples.% |
|
902 |
\end{isamarkuptext}% |
|
903 |
\isamarkuptrue% |
|
904 |
% |
|
31913 | 905 |
\isamarkupsection{Checking and refuting propositions% |
906 |
} |
|
907 |
\isamarkuptrue% |
|
908 |
% |
|
909 |
\begin{isamarkuptext}% |
|
910 |
Identifying incorrect propositions usually involves evaluation of |
|
911 |
particular assignments and systematic counter example search. This |
|
912 |
is supported by the following commands. |
|
913 |
||
914 |
\begin{matharray}{rcl} |
|
915 |
\indexdef{HOL}{command}{value}\hypertarget{command.HOL.value}{\hyperlink{command.HOL.value}{\mbox{\isa{\isacommand{value}}}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isa{{\isachardoublequote}context\ {\isasymrightarrow}{\isachardoublequote}} \\ |
|
916 |
\indexdef{HOL}{command}{quickcheck}\hypertarget{command.HOL.quickcheck}{\hyperlink{command.HOL.quickcheck}{\mbox{\isa{\isacommand{quickcheck}}}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isa{{\isachardoublequote}proof\ {\isasymrightarrow}{\isachardoublequote}} \\ |
|
917 |
\indexdef{HOL}{command}{quickcheck\_params}\hypertarget{command.HOL.quickcheck-params}{\hyperlink{command.HOL.quickcheck-params}{\mbox{\isa{\isacommand{quickcheck{\isacharunderscore}params}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} |
|
918 |
\end{matharray} |
|
919 |
||
920 |
\begin{rail} |
|
921 |
'value' ( ( '[' name ']' ) ? ) modes? term |
|
922 |
; |
|
923 |
||
924 |
'quickcheck' ( ( '[' args ']' ) ? ) nat? |
|
925 |
; |
|
926 |
||
927 |
'quickcheck_params' ( ( '[' args ']' ) ? ) |
|
928 |
; |
|
929 |
||
930 |
modes: '(' (name + ) ')' |
|
931 |
; |
|
932 |
||
933 |
args: ( name '=' value + ',' ) |
|
934 |
; |
|
935 |
\end{rail} |
|
936 |
||
937 |
\begin{description} |
|
938 |
||
939 |
\item \hyperlink{command.HOL.value}{\mbox{\isa{\isacommand{value}}}}~\isa{t} evaluates and prints a |
|
940 |
term; optionally \isa{modes} can be specified, which are |
|
941 |
appended to the current print mode (see also \cite{isabelle-ref}). |
|
942 |
Internally, the evaluation is performed by registered evaluators, |
|
943 |
which are invoked sequentially until a result is returned. |
|
944 |
Alternatively a specific evaluator can be selected using square |
|
37444 | 945 |
brackets; typical evaluators use the current set of code equations |
946 |
to normalize and include \isa{simp} for fully symbolic evaluation |
|
947 |
using the simplifier, \isa{nbe} for \emph{normalization by evaluation} |
|
948 |
and \emph{code} for code generation in SML. |
|
31913 | 949 |
|
950 |
\item \hyperlink{command.HOL.quickcheck}{\mbox{\isa{\isacommand{quickcheck}}}} tests the current goal for |
|
951 |
counter examples using a series of arbitrary assignments for its |
|
952 |
free variables; by default the first subgoal is tested, an other |
|
953 |
can be selected explicitly using an optional goal index. |
|
954 |
A number of configuration options are supported for |
|
955 |
\hyperlink{command.HOL.quickcheck}{\mbox{\isa{\isacommand{quickcheck}}}}, notably: |
|
956 |
||
957 |
\begin{description} |
|
958 |
||
40254 | 959 |
\item[\isa{size}] specifies the maximum size of the search space |
960 |
for assignment values. |
|
961 |
||
962 |
\item[\isa{iterations}] sets how many sets of assignments are |
|
963 |
generated for each particular size. |
|
964 |
||
965 |
\item[\isa{no{\isacharunderscore}assms}] specifies whether assumptions in |
|
966 |
structured proofs should be ignored. |
|
967 |
||
968 |
\item[\isa{timeout}] sets the time limit in seconds. |
|
31913 | 969 |
|
40254 | 970 |
\item[\isa{default{\isacharunderscore}type}] sets the type(s) generally used to |
971 |
instantiate type variables. |
|
972 |
||
973 |
\item[\isa{report}] if set quickcheck reports how many tests |
|
974 |
fulfilled the preconditions. |
|
31913 | 975 |
|
40254 | 976 |
\item[\isa{quiet}] if not set quickcheck informs about the |
977 |
current size for assignment values. |
|
978 |
||
979 |
\item[\isa{expect}] can be used to check if the user's |
|
980 |
expectation was met (\isa{no{\isacharunderscore}expectation}, \isa{no{\isacharunderscore}counterexample}, or \isa{counterexample}). |
|
35351
7425aece4ee3
allow general mixfix syntax for type constructors;
wenzelm
parents:
34172
diff
changeset
|
981 |
|
31913 | 982 |
\end{description} |
983 |
||
984 |
These option can be given within square brackets. |
|
985 |
||
986 |
\item \hyperlink{command.HOL.quickcheck-params}{\mbox{\isa{\isacommand{quickcheck{\isacharunderscore}params}}}} changes quickcheck |
|
987 |
configuration options persitently. |
|
988 |
||
989 |
\end{description}% |
|
990 |
\end{isamarkuptext}% |
|
991 |
\isamarkuptrue% |
|
992 |
% |
|
28788 | 993 |
\isamarkupsection{Unstructured case analysis and induction \label{sec:hol-induct-tac}% |
26849 | 994 |
} |
995 |
\isamarkuptrue% |
|
996 |
% |
|
997 |
\begin{isamarkuptext}% |
|
27124 | 998 |
The following tools of Isabelle/HOL support cases analysis and |
999 |
induction in unstructured tactic scripts; see also |
|
1000 |
\secref{sec:cases-induct} for proper Isar versions of similar ideas. |
|
26849 | 1001 |
|
1002 |
\begin{matharray}{rcl} |
|
28788 | 1003 |
\indexdef{HOL}{method}{case\_tac}\hypertarget{method.HOL.case-tac}{\hyperlink{method.HOL.case-tac}{\mbox{\isa{case{\isacharunderscore}tac}}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isa{method} \\ |
1004 |
\indexdef{HOL}{method}{induct\_tac}\hypertarget{method.HOL.induct-tac}{\hyperlink{method.HOL.induct-tac}{\mbox{\isa{induct{\isacharunderscore}tac}}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isa{method} \\ |
|
1005 |
\indexdef{HOL}{method}{ind\_cases}\hypertarget{method.HOL.ind-cases}{\hyperlink{method.HOL.ind-cases}{\mbox{\isa{ind{\isacharunderscore}cases}}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isa{method} \\ |
|
1006 |
\indexdef{HOL}{command}{inductive\_cases}\hypertarget{command.HOL.inductive-cases}{\hyperlink{command.HOL.inductive-cases}{\mbox{\isa{\isacommand{inductive{\isacharunderscore}cases}}}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isa{{\isachardoublequote}local{\isacharunderscore}theory\ {\isasymrightarrow}\ local{\isacharunderscore}theory{\isachardoublequote}} \\ |
|
26849 | 1007 |
\end{matharray} |
1008 |
||
1009 |
\begin{rail} |
|
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1010 |
'case_tac' goalspec? term rule? |
26849 | 1011 |
; |
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1012 |
'induct_tac' goalspec? (insts * 'and') rule? |
26849 | 1013 |
; |
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1014 |
'ind_cases' (prop +) ('for' (name +)) ? |
26849 | 1015 |
; |
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1016 |
'inductive_cases' (thmdecl? (prop +) + 'and') |
26849 | 1017 |
; |
1018 |
||
1019 |
rule: ('rule' ':' thmref) |
|
1020 |
; |
|
1021 |
\end{rail} |
|
1022 |
||
28788 | 1023 |
\begin{description} |
26849 | 1024 |
|
28788 | 1025 |
\item \hyperlink{method.HOL.case-tac}{\mbox{\isa{case{\isacharunderscore}tac}}} and \hyperlink{method.HOL.induct-tac}{\mbox{\isa{induct{\isacharunderscore}tac}}} admit |
1026 |
to reason about inductive types. Rules are selected according to |
|
1027 |
the declarations by the \hyperlink{attribute.cases}{\mbox{\isa{cases}}} and \hyperlink{attribute.induct}{\mbox{\isa{induct}}} |
|
1028 |
attributes, cf.\ \secref{sec:cases-induct}. The \hyperlink{command.HOL.datatype}{\mbox{\isa{\isacommand{datatype}}}} package already takes care of this. |
|
27124 | 1029 |
|
1030 |
These unstructured tactics feature both goal addressing and dynamic |
|
26849 | 1031 |
instantiation. Note that named rule cases are \emph{not} provided |
27124 | 1032 |
as would be by the proper \hyperlink{method.cases}{\mbox{\isa{cases}}} and \hyperlink{method.induct}{\mbox{\isa{induct}}} proof |
1033 |
methods (see \secref{sec:cases-induct}). Unlike the \hyperlink{method.induct}{\mbox{\isa{induct}}} method, \hyperlink{method.induct-tac}{\mbox{\isa{induct{\isacharunderscore}tac}}} does not handle structured rule |
|
1034 |
statements, only the compact object-logic conclusion of the subgoal |
|
1035 |
being addressed. |
|
26849 | 1036 |
|
28788 | 1037 |
\item \hyperlink{method.HOL.ind-cases}{\mbox{\isa{ind{\isacharunderscore}cases}}} and \hyperlink{command.HOL.inductive-cases}{\mbox{\isa{\isacommand{inductive{\isacharunderscore}cases}}}} provide an interface to the internal \verb|mk_cases| operation. Rules are simplified in an unrestricted |
26861 | 1038 |
forward manner. |
26849 | 1039 |
|
26907 | 1040 |
While \hyperlink{method.HOL.ind-cases}{\mbox{\isa{ind{\isacharunderscore}cases}}} is a proof method to apply the |
1041 |
result immediately as elimination rules, \hyperlink{command.HOL.inductive-cases}{\mbox{\isa{\isacommand{inductive{\isacharunderscore}cases}}}} provides case split theorems at the theory level |
|
1042 |
for later use. The \hyperlink{keyword.for}{\mbox{\isa{\isakeyword{for}}}} argument of the \hyperlink{method.HOL.ind-cases}{\mbox{\isa{ind{\isacharunderscore}cases}}} method allows to specify a list of variables that should |
|
26849 | 1043 |
be generalized before applying the resulting rule. |
1044 |
||
28788 | 1045 |
\end{description}% |
26849 | 1046 |
\end{isamarkuptext}% |
1047 |
\isamarkuptrue% |
|
1048 |
% |
|
1049 |
\isamarkupsection{Executable code% |
|
1050 |
} |
|
1051 |
\isamarkuptrue% |
|
1052 |
% |
|
1053 |
\begin{isamarkuptext}% |
|
1054 |
Isabelle/Pure provides two generic frameworks to support code |
|
1055 |
generation from executable specifications. Isabelle/HOL |
|
1056 |
instantiates these mechanisms in a way that is amenable to end-user |
|
1057 |
applications. |
|
1058 |
||
37422 | 1059 |
\medskip One framework generates code from functional programs |
1060 |
(including overloading using type classes) to SML \cite{SML}, OCaml |
|
38813 | 1061 |
\cite{OCaml}, Haskell \cite{haskell-revised-report} and Scala |
1062 |
\cite{scala-overview-tech-report}. |
|
37422 | 1063 |
Conceptually, code generation is split up in three steps: |
1064 |
\emph{selection} of code theorems, \emph{translation} into an |
|
1065 |
abstract executable view and \emph{serialization} to a specific |
|
1066 |
\emph{target language}. Inductive specifications can be executed |
|
1067 |
using the predicate compiler which operates within HOL. |
|
1068 |
See \cite{isabelle-codegen} for an introduction. |
|
1069 |
||
1070 |
\begin{matharray}{rcl} |
|
1071 |
\indexdef{HOL}{command}{export\_code}\hypertarget{command.HOL.export-code}{\hyperlink{command.HOL.export-code}{\mbox{\isa{\isacommand{export{\isacharunderscore}code}}}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isa{{\isachardoublequote}context\ {\isasymrightarrow}{\isachardoublequote}} \\ |
|
1072 |
\indexdef{HOL}{attribute}{code}\hypertarget{attribute.HOL.code}{\hyperlink{attribute.HOL.code}{\mbox{\isa{code}}}} & : & \isa{attribute} \\ |
|
1073 |
\indexdef{HOL}{command}{code\_abort}\hypertarget{command.HOL.code-abort}{\hyperlink{command.HOL.code-abort}{\mbox{\isa{\isacommand{code{\isacharunderscore}abort}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
|
1074 |
\indexdef{HOL}{command}{code\_datatype}\hypertarget{command.HOL.code-datatype}{\hyperlink{command.HOL.code-datatype}{\mbox{\isa{\isacommand{code{\isacharunderscore}datatype}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
|
1075 |
\indexdef{HOL}{command}{print\_codesetup}\hypertarget{command.HOL.print-codesetup}{\hyperlink{command.HOL.print-codesetup}{\mbox{\isa{\isacommand{print{\isacharunderscore}codesetup}}}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isa{{\isachardoublequote}context\ {\isasymrightarrow}{\isachardoublequote}} \\ |
|
1076 |
\indexdef{HOL}{attribute}{code\_inline}\hypertarget{attribute.HOL.code-inline}{\hyperlink{attribute.HOL.code-inline}{\mbox{\isa{code{\isacharunderscore}inline}}}} & : & \isa{attribute} \\ |
|
1077 |
\indexdef{HOL}{attribute}{code\_post}\hypertarget{attribute.HOL.code-post}{\hyperlink{attribute.HOL.code-post}{\mbox{\isa{code{\isacharunderscore}post}}}} & : & \isa{attribute} \\ |
|
1078 |
\indexdef{HOL}{command}{print\_codeproc}\hypertarget{command.HOL.print-codeproc}{\hyperlink{command.HOL.print-codeproc}{\mbox{\isa{\isacommand{print{\isacharunderscore}codeproc}}}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isa{{\isachardoublequote}context\ {\isasymrightarrow}{\isachardoublequote}} \\ |
|
1079 |
\indexdef{HOL}{command}{code\_thms}\hypertarget{command.HOL.code-thms}{\hyperlink{command.HOL.code-thms}{\mbox{\isa{\isacommand{code{\isacharunderscore}thms}}}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isa{{\isachardoublequote}context\ {\isasymrightarrow}{\isachardoublequote}} \\ |
|
1080 |
\indexdef{HOL}{command}{code\_deps}\hypertarget{command.HOL.code-deps}{\hyperlink{command.HOL.code-deps}{\mbox{\isa{\isacommand{code{\isacharunderscore}deps}}}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isa{{\isachardoublequote}context\ {\isasymrightarrow}{\isachardoublequote}} \\ |
|
1081 |
\indexdef{HOL}{command}{code\_const}\hypertarget{command.HOL.code-const}{\hyperlink{command.HOL.code-const}{\mbox{\isa{\isacommand{code{\isacharunderscore}const}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
|
1082 |
\indexdef{HOL}{command}{code\_type}\hypertarget{command.HOL.code-type}{\hyperlink{command.HOL.code-type}{\mbox{\isa{\isacommand{code{\isacharunderscore}type}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
|
1083 |
\indexdef{HOL}{command}{code\_class}\hypertarget{command.HOL.code-class}{\hyperlink{command.HOL.code-class}{\mbox{\isa{\isacommand{code{\isacharunderscore}class}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
|
1084 |
\indexdef{HOL}{command}{code\_instance}\hypertarget{command.HOL.code-instance}{\hyperlink{command.HOL.code-instance}{\mbox{\isa{\isacommand{code{\isacharunderscore}instance}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
|
1085 |
\indexdef{HOL}{command}{code\_reserved}\hypertarget{command.HOL.code-reserved}{\hyperlink{command.HOL.code-reserved}{\mbox{\isa{\isacommand{code{\isacharunderscore}reserved}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
|
1086 |
\indexdef{HOL}{command}{code\_monad}\hypertarget{command.HOL.code-monad}{\hyperlink{command.HOL.code-monad}{\mbox{\isa{\isacommand{code{\isacharunderscore}monad}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
|
1087 |
\indexdef{HOL}{command}{code\_include}\hypertarget{command.HOL.code-include}{\hyperlink{command.HOL.code-include}{\mbox{\isa{\isacommand{code{\isacharunderscore}include}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
|
1088 |
\indexdef{HOL}{command}{code\_modulename}\hypertarget{command.HOL.code-modulename}{\hyperlink{command.HOL.code-modulename}{\mbox{\isa{\isacommand{code{\isacharunderscore}modulename}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
|
39608 | 1089 |
\indexdef{HOL}{command}{code\_reflect}\hypertarget{command.HOL.code-reflect}{\hyperlink{command.HOL.code-reflect}{\mbox{\isa{\isacommand{code{\isacharunderscore}reflect}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} |
37422 | 1090 |
\end{matharray} |
1091 |
||
1092 |
\begin{rail} |
|
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1093 |
'export_code' ( constexpr + ) \\ |
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1094 |
( ( 'in' target ( 'module_name' string ) ? \\ |
37820
ffaca9167c16
export_code without file prints to standard output
haftmann
parents:
37749
diff
changeset
|
1095 |
( 'file' ( string | '-' ) ) ? ( '(' args ')' ) ?) + ) ? |
37422 | 1096 |
; |
1097 |
||
1098 |
const: term |
|
1099 |
; |
|
1100 |
||
1101 |
constexpr: ( const | 'name.*' | '*' ) |
|
1102 |
; |
|
1103 |
||
1104 |
typeconstructor: nameref |
|
1105 |
; |
|
1106 |
||
1107 |
class: nameref |
|
1108 |
; |
|
1109 |
||
38813 | 1110 |
target: 'SML' | 'OCaml' | 'Haskell' | 'Scala' |
37422 | 1111 |
; |
1112 |
||
38462
34d3de1254cd
formally document `code abstype` and `code abstract` attributes
haftmann
parents:
37820
diff
changeset
|
1113 |
'code' ( 'del' | 'abstype' | 'abstract' ) ? |
37422 | 1114 |
; |
1115 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1116 |
'code_abort' ( const + ) |
37422 | 1117 |
; |
1118 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1119 |
'code_datatype' ( const + ) |
37422 | 1120 |
; |
1121 |
||
1122 |
'code_inline' ( 'del' ) ? |
|
1123 |
; |
|
1124 |
||
1125 |
'code_post' ( 'del' ) ? |
|
1126 |
; |
|
1127 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1128 |
'code_thms' ( constexpr + ) ? |
37422 | 1129 |
; |
1130 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1131 |
'code_deps' ( constexpr + ) ? |
37422 | 1132 |
; |
1133 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1134 |
'code_const' (const + 'and') \\ |
37422 | 1135 |
( ( '(' target ( syntax ? + 'and' ) ')' ) + ) |
1136 |
; |
|
1137 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1138 |
'code_type' (typeconstructor + 'and') \\ |
37422 | 1139 |
( ( '(' target ( syntax ? + 'and' ) ')' ) + ) |
1140 |
; |
|
1141 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1142 |
'code_class' (class + 'and') \\ |
37422 | 1143 |
( ( '(' target \\ ( string ? + 'and' ) ')' ) + ) |
1144 |
; |
|
1145 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1146 |
'code_instance' (( typeconstructor '::' class ) + 'and') \\ |
37422 | 1147 |
( ( '(' target ( '-' ? + 'and' ) ')' ) + ) |
1148 |
; |
|
1149 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1150 |
'code_reserved' target ( string + ) |
37422 | 1151 |
; |
1152 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1153 |
'code_monad' const const target |
37422 | 1154 |
; |
1155 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1156 |
'code_include' target ( string ( string | '-') ) |
37422 | 1157 |
; |
1158 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1159 |
'code_modulename' target ( ( string string ) + ) |
37422 | 1160 |
; |
1161 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1162 |
'code_reflect' string ( 'datatypes' ( string '=' ( string + '|' ) + 'and' ) ) ? \\ |
39608 | 1163 |
( 'functions' ( string + ) ) ? ( 'file' string ) ? |
1164 |
; |
|
1165 |
||
37422 | 1166 |
syntax: string | ( 'infix' | 'infixl' | 'infixr' ) nat string |
1167 |
; |
|
1168 |
||
1169 |
\end{rail} |
|
1170 |
||
1171 |
\begin{description} |
|
1172 |
||
1173 |
\item \hyperlink{command.HOL.export-code}{\mbox{\isa{\isacommand{export{\isacharunderscore}code}}}} generates code for a given list |
|
39608 | 1174 |
of constants in the specified target language(s). If no |
1175 |
serialization instruction is given, only abstract code is generated |
|
1176 |
internally. |
|
37422 | 1177 |
|
1178 |
Constants may be specified by giving them literally, referring to |
|
1179 |
all executable contants within a certain theory by giving \isa{{\isachardoublequote}name{\isachardot}{\isacharasterisk}{\isachardoublequote}}, or referring to \emph{all} executable constants currently |
|
1180 |
available by giving \isa{{\isachardoublequote}{\isacharasterisk}{\isachardoublequote}}. |
|
1181 |
||
1182 |
By default, for each involved theory one corresponding name space |
|
1183 |
module is generated. Alternativly, a module name may be specified |
|
1184 |
after the \hyperlink{keyword.module-name}{\mbox{\isa{\isakeyword{module{\isacharunderscore}name}}}} keyword; then \emph{all} code is |
|
1185 |
placed in this module. |
|
1186 |
||
39608 | 1187 |
For \emph{SML}, \emph{OCaml} and \emph{Scala} the file specification |
1188 |
refers to a single file; for \emph{Haskell}, it refers to a whole |
|
1189 |
directory, where code is generated in multiple files reflecting the |
|
1190 |
module hierarchy. Omitting the file specification denotes standard |
|
37749 | 1191 |
output. |
37422 | 1192 |
|
1193 |
Serializers take an optional list of arguments in parentheses. For |
|
1194 |
\emph{SML} and \emph{OCaml}, ``\isa{no{\isacharunderscore}signatures}`` omits |
|
1195 |
explicit module signatures. |
|
1196 |
||
39608 | 1197 |
For \emph{Haskell} a module name prefix may be given using the |
1198 |
``\isa{{\isachardoublequote}root{\isacharcolon}{\isachardoublequote}}'' argument; ``\isa{string{\isacharunderscore}classes}'' adds a |
|
1199 |
``\verb|deriving (Read, Show)|'' clause to each appropriate |
|
1200 |
datatype declaration. |
|
37422 | 1201 |
|
1202 |
\item \hyperlink{attribute.HOL.code}{\mbox{\isa{code}}} explicitly selects (or with option |
|
38462
34d3de1254cd
formally document `code abstype` and `code abstract` attributes
haftmann
parents:
37820
diff
changeset
|
1203 |
``\isa{{\isachardoublequote}del{\isachardoublequote}}'' deselects) a code equation for code generation. |
34d3de1254cd
formally document `code abstype` and `code abstract` attributes
haftmann
parents:
37820
diff
changeset
|
1204 |
Usually packages introducing code equations provide a reasonable |
34d3de1254cd
formally document `code abstype` and `code abstract` attributes
haftmann
parents:
37820
diff
changeset
|
1205 |
default setup for selection. Variants \isa{{\isachardoublequote}code\ abstype{\isachardoublequote}} and |
34d3de1254cd
formally document `code abstype` and `code abstract` attributes
haftmann
parents:
37820
diff
changeset
|
1206 |
\isa{{\isachardoublequote}code\ abstract{\isachardoublequote}} declare abstract datatype certificates or |
34d3de1254cd
formally document `code abstype` and `code abstract` attributes
haftmann
parents:
37820
diff
changeset
|
1207 |
code equations on abstract datatype representations respectively. |
37422 | 1208 |
|
1209 |
\item \hyperlink{command.HOL.code-abort}{\mbox{\isa{\isacommand{code{\isacharunderscore}abort}}}} declares constants which are not |
|
39608 | 1210 |
required to have a definition by means of code equations; if needed |
1211 |
these are implemented by program abort instead. |
|
37422 | 1212 |
|
1213 |
\item \hyperlink{command.HOL.code-datatype}{\mbox{\isa{\isacommand{code{\isacharunderscore}datatype}}}} specifies a constructor set |
|
1214 |
for a logical type. |
|
1215 |
||
1216 |
\item \hyperlink{command.HOL.print-codesetup}{\mbox{\isa{\isacommand{print{\isacharunderscore}codesetup}}}} gives an overview on |
|
1217 |
selected code equations and code generator datatypes. |
|
1218 |
||
39608 | 1219 |
\item \hyperlink{attribute.HOL.code-inline}{\mbox{\isa{code{\isacharunderscore}inline}}} declares (or with option |
1220 |
``\isa{{\isachardoublequote}del{\isachardoublequote}}'' removes) inlining theorems which are applied as |
|
1221 |
rewrite rules to any code equation during preprocessing. |
|
37422 | 1222 |
|
39608 | 1223 |
\item \hyperlink{attribute.HOL.code-post}{\mbox{\isa{code{\isacharunderscore}post}}} declares (or with option ``\isa{{\isachardoublequote}del{\isachardoublequote}}'' removes) theorems which are applied as rewrite rules to any |
1224 |
result of an evaluation. |
|
37422 | 1225 |
|
39608 | 1226 |
\item \hyperlink{command.HOL.print-codeproc}{\mbox{\isa{\isacommand{print{\isacharunderscore}codeproc}}}} prints the setup of the code |
1227 |
generator preprocessor. |
|
37422 | 1228 |
|
1229 |
\item \hyperlink{command.HOL.code-thms}{\mbox{\isa{\isacommand{code{\isacharunderscore}thms}}}} prints a list of theorems |
|
1230 |
representing the corresponding program containing all given |
|
1231 |
constants after preprocessing. |
|
1232 |
||
1233 |
\item \hyperlink{command.HOL.code-deps}{\mbox{\isa{\isacommand{code{\isacharunderscore}deps}}}} visualizes dependencies of |
|
1234 |
theorems representing the corresponding program containing all given |
|
1235 |
constants after preprocessing. |
|
1236 |
||
1237 |
\item \hyperlink{command.HOL.code-const}{\mbox{\isa{\isacommand{code{\isacharunderscore}const}}}} associates a list of constants |
|
1238 |
with target-specific serializations; omitting a serialization |
|
1239 |
deletes an existing serialization. |
|
1240 |
||
1241 |
\item \hyperlink{command.HOL.code-type}{\mbox{\isa{\isacommand{code{\isacharunderscore}type}}}} associates a list of type |
|
1242 |
constructors with target-specific serializations; omitting a |
|
1243 |
serialization deletes an existing serialization. |
|
1244 |
||
1245 |
\item \hyperlink{command.HOL.code-class}{\mbox{\isa{\isacommand{code{\isacharunderscore}class}}}} associates a list of classes |
|
1246 |
with target-specific class names; omitting a serialization deletes |
|
1247 |
an existing serialization. This applies only to \emph{Haskell}. |
|
1248 |
||
1249 |
\item \hyperlink{command.HOL.code-instance}{\mbox{\isa{\isacommand{code{\isacharunderscore}instance}}}} declares a list of type |
|
1250 |
constructor / class instance relations as ``already present'' for a |
|
1251 |
given target. Omitting a ``\isa{{\isachardoublequote}{\isacharminus}{\isachardoublequote}}'' deletes an existing |
|
1252 |
``already present'' declaration. This applies only to |
|
1253 |
\emph{Haskell}. |
|
1254 |
||
1255 |
\item \hyperlink{command.HOL.code-reserved}{\mbox{\isa{\isacommand{code{\isacharunderscore}reserved}}}} declares a list of names as |
|
1256 |
reserved for a given target, preventing it to be shadowed by any |
|
1257 |
generated code. |
|
1258 |
||
1259 |
\item \hyperlink{command.HOL.code-monad}{\mbox{\isa{\isacommand{code{\isacharunderscore}monad}}}} provides an auxiliary mechanism |
|
1260 |
to generate monadic code for Haskell. |
|
1261 |
||
1262 |
\item \hyperlink{command.HOL.code-include}{\mbox{\isa{\isacommand{code{\isacharunderscore}include}}}} adds arbitrary named content |
|
1263 |
(``include'') to generated code. A ``\isa{{\isachardoublequote}{\isacharminus}{\isachardoublequote}}'' as last argument |
|
1264 |
will remove an already added ``include''. |
|
1265 |
||
1266 |
\item \hyperlink{command.HOL.code-modulename}{\mbox{\isa{\isacommand{code{\isacharunderscore}modulename}}}} declares aliasings from one |
|
1267 |
module name onto another. |
|
1268 |
||
39608 | 1269 |
\item \hyperlink{command.HOL.code-reflect}{\mbox{\isa{\isacommand{code{\isacharunderscore}reflect}}}} without a ``\isa{{\isachardoublequote}file{\isachardoublequote}}'' |
1270 |
argument compiles code into the system runtime environment and |
|
1271 |
modifies the code generator setup that future invocations of system |
|
1272 |
runtime code generation referring to one of the ``\isa{{\isachardoublequote}datatypes{\isachardoublequote}}'' or ``\isa{{\isachardoublequote}functions{\isachardoublequote}}'' entities use these precompiled |
|
1273 |
entities. With a ``\isa{{\isachardoublequote}file{\isachardoublequote}}'' argument, the corresponding code |
|
1274 |
is generated into that specified file without modifying the code |
|
1275 |
generator setup. |
|
1276 |
||
37422 | 1277 |
\end{description} |
1278 |
||
39608 | 1279 |
The other framework generates code from both functional and |
1280 |
relational programs to SML. See \cite{isabelle-HOL} for further |
|
1281 |
information (this actually covers the new-style theory format as |
|
1282 |
well). |
|
26849 | 1283 |
|
1284 |
\begin{matharray}{rcl} |
|
28788 | 1285 |
\indexdef{HOL}{command}{code\_module}\hypertarget{command.HOL.code-module}{\hyperlink{command.HOL.code-module}{\mbox{\isa{\isacommand{code{\isacharunderscore}module}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
1286 |
\indexdef{HOL}{command}{code\_library}\hypertarget{command.HOL.code-library}{\hyperlink{command.HOL.code-library}{\mbox{\isa{\isacommand{code{\isacharunderscore}library}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
|
1287 |
\indexdef{HOL}{command}{consts\_code}\hypertarget{command.HOL.consts-code}{\hyperlink{command.HOL.consts-code}{\mbox{\isa{\isacommand{consts{\isacharunderscore}code}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
|
1288 |
\indexdef{HOL}{command}{types\_code}\hypertarget{command.HOL.types-code}{\hyperlink{command.HOL.types-code}{\mbox{\isa{\isacommand{types{\isacharunderscore}code}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ theory{\isachardoublequote}} \\ |
|
1289 |
\indexdef{HOL}{attribute}{code}\hypertarget{attribute.HOL.code}{\hyperlink{attribute.HOL.code}{\mbox{\isa{code}}}} & : & \isa{attribute} \\ |
|
26849 | 1290 |
\end{matharray} |
1291 |
||
1292 |
\begin{rail} |
|
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1293 |
( 'code_module' | 'code_library' ) modespec ? name ? \\ |
26849 | 1294 |
( 'file' name ) ? ( 'imports' ( name + ) ) ? \\ |
1295 |
'contains' ( ( name '=' term ) + | term + ) |
|
1296 |
; |
|
1297 |
||
1298 |
modespec: '(' ( name * ) ')' |
|
1299 |
; |
|
1300 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1301 |
'consts_code' (codespec +) |
26849 | 1302 |
; |
1303 |
||
1304 |
codespec: const template attachment ? |
|
1305 |
; |
|
1306 |
||
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1307 |
'types_code' (tycodespec +) |
26849 | 1308 |
; |
1309 |
||
1310 |
tycodespec: name template attachment ? |
|
1311 |
; |
|
1312 |
||
1313 |
const: term |
|
1314 |
; |
|
1315 |
||
1316 |
template: '(' string ')' |
|
1317 |
; |
|
1318 |
||
1319 |
attachment: 'attach' modespec ? verblbrace text verbrbrace |
|
1320 |
; |
|
1321 |
||
1322 |
'code' (name)? |
|
1323 |
; |
|
37422 | 1324 |
\end{rail}% |
26849 | 1325 |
\end{isamarkuptext}% |
1326 |
\isamarkuptrue% |
|
1327 |
% |
|
27047 | 1328 |
\isamarkupsection{Definition by specification \label{sec:hol-specification}% |
1329 |
} |
|
1330 |
\isamarkuptrue% |
|
1331 |
% |
|
1332 |
\begin{isamarkuptext}% |
|
1333 |
\begin{matharray}{rcl} |
|
28788 | 1334 |
\indexdef{HOL}{command}{specification}\hypertarget{command.HOL.specification}{\hyperlink{command.HOL.specification}{\mbox{\isa{\isacommand{specification}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ proof{\isacharparenleft}prove{\isacharparenright}{\isachardoublequote}} \\ |
1335 |
\indexdef{HOL}{command}{ax\_specification}\hypertarget{command.HOL.ax-specification}{\hyperlink{command.HOL.ax-specification}{\mbox{\isa{\isacommand{ax{\isacharunderscore}specification}}}}} & : & \isa{{\isachardoublequote}theory\ {\isasymrightarrow}\ proof{\isacharparenleft}prove{\isacharparenright}{\isachardoublequote}} \\ |
|
27047 | 1336 |
\end{matharray} |
1337 |
||
1338 |
\begin{rail} |
|
40255
9ffbc25e1606
eliminated obsolete \_ escapes in rail environments;
wenzelm
parents:
40254
diff
changeset
|
1339 |
('specification' | 'ax_specification') '(' (decl +) ')' \\ (thmdecl? prop +) |
27047 | 1340 |
; |
1341 |
decl: ((name ':')? term '(' 'overloaded' ')'?) |
|
1342 |
\end{rail} |
|
1343 |
||
28788 | 1344 |
\begin{description} |
27047 | 1345 |
|
28788 | 1346 |
\item \hyperlink{command.HOL.specification}{\mbox{\isa{\isacommand{specification}}}}~\isa{{\isachardoublequote}decls\ {\isasymphi}{\isachardoublequote}} sets up a |
27047 | 1347 |
goal stating the existence of terms with the properties specified to |
1348 |
hold for the constants given in \isa{decls}. After finishing the |
|
1349 |
proof, the theory will be augmented with definitions for the given |
|
1350 |
constants, as well as with theorems stating the properties for these |
|
1351 |
constants. |
|
1352 |
||
28788 | 1353 |
\item \hyperlink{command.HOL.ax-specification}{\mbox{\isa{\isacommand{ax{\isacharunderscore}specification}}}}~\isa{{\isachardoublequote}decls\ {\isasymphi}{\isachardoublequote}} sets up |
1354 |
a goal stating the existence of terms with the properties specified |
|
1355 |
to hold for the constants given in \isa{decls}. After finishing |
|
1356 |
the proof, the theory will be augmented with axioms expressing the |
|
1357 |
properties given in the first place. |
|
27047 | 1358 |
|
28788 | 1359 |
\item \isa{decl} declares a constant to be defined by the |
27047 | 1360 |
specification given. The definition for the constant \isa{c} is |
1361 |
bound to the name \isa{c{\isacharunderscore}def} unless a theorem name is given in |
|
1362 |
the declaration. Overloaded constants should be declared as such. |
|
1363 |
||
28788 | 1364 |
\end{description} |
27047 | 1365 |
|
1366 |
Whether to use \hyperlink{command.HOL.specification}{\mbox{\isa{\isacommand{specification}}}} or \hyperlink{command.HOL.ax-specification}{\mbox{\isa{\isacommand{ax{\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 |
|
1367 |
construction cannot introduce inconsistencies, whereas \hyperlink{command.HOL.ax-specification}{\mbox{\isa{\isacommand{ax{\isacharunderscore}specification}}}} does introduce axioms, but only after the |
|
1368 |
user has explicitly proven it to be safe. A practical issue must be |
|
1369 |
considered, though: After introducing two constants with the same |
|
1370 |
properties using \hyperlink{command.HOL.specification}{\mbox{\isa{\isacommand{specification}}}}, one can prove |
|
1371 |
that the two constants are, in fact, equal. If this might be a |
|
1372 |
problem, one should use \hyperlink{command.HOL.ax-specification}{\mbox{\isa{\isacommand{ax{\isacharunderscore}specification}}}}.% |
|
1373 |
\end{isamarkuptext}% |
|
1374 |
\isamarkuptrue% |
|
1375 |
% |
|
26849 | 1376 |
\isadelimtheory |
1377 |
% |
|
1378 |
\endisadelimtheory |
|
1379 |
% |
|
1380 |
\isatagtheory |
|
26840 | 1381 |
\isacommand{end}\isamarkupfalse% |
1382 |
% |
|
1383 |
\endisatagtheory |
|
1384 |
{\isafoldtheory}% |
|
1385 |
% |
|
1386 |
\isadelimtheory |
|
1387 |
% |
|
1388 |
\endisadelimtheory |
|
26849 | 1389 |
\isanewline |
26840 | 1390 |
\end{isabellebody}% |
1391 |
%%% Local Variables: |
|
1392 |
%%% mode: latex |
|
1393 |
%%% TeX-master: "root" |
|
1394 |
%%% End: |