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