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