author | wenzelm |
Thu, 01 Dec 2005 22:03:06 +0100 | |
changeset 18327 | 1ee4523c831f |
parent 17659 | b1019337c857 |
child 19988 | 05f940b9ef15 |
permissions | -rw-r--r-- |
12621 | 1 |
|
13048 | 2 |
\chapter{Object-logic specific elements}\label{ch:logics} |
12621 | 3 |
|
4 |
\section{General logic setup}\label{sec:object-logic} |
|
5 |
||
6 |
\indexisarcmd{judgment} |
|
7 |
\indexisarmeth{atomize}\indexisaratt{atomize} |
|
8 |
\indexisaratt{rule-format}\indexisaratt{rulify} |
|
9 |
||
10 |
\begin{matharray}{rcl} |
|
11 |
\isarcmd{judgment} & : & \isartrans{theory}{theory} \\ |
|
12 |
atomize & : & \isarmeth \\ |
|
13 |
atomize & : & \isaratt \\ |
|
14 |
rule_format & : & \isaratt \\ |
|
15 |
rulify & : & \isaratt \\ |
|
16 |
\end{matharray} |
|
17 |
||
18 |
The very starting point for any Isabelle object-logic is a ``truth judgment'' |
|
19 |
that links object-level statements to the meta-logic (with its minimal |
|
20 |
language of $prop$ that covers universal quantification $\Forall$ and |
|
13041 | 21 |
implication $\Imp$). |
22 |
||
23 |
Common object-logics are sufficiently expressive to internalize rule |
|
24 |
statements over $\Forall$ and $\Imp$ within their own language. This is |
|
25 |
useful in certain situations where a rule needs to be viewed as an atomic |
|
26 |
statement from the meta-level perspective, e.g.\ $\All x x \in A \Imp P(x)$ |
|
27 |
versus $\forall x \in A. P(x)$. |
|
12621 | 28 |
|
29 |
From the following language elements, only the $atomize$ method and |
|
30 |
$rule_format$ attribute are occasionally required by end-users, the rest is |
|
31 |
for those who need to setup their own object-logic. In the latter case |
|
32 |
existing formulations of Isabelle/FOL or Isabelle/HOL may be taken as |
|
33 |
realistic examples. |
|
34 |
||
35 |
Generic tools may refer to the information provided by object-logic |
|
13041 | 36 |
declarations internally. |
37 |
||
38 |
\railalias{ruleformat}{rule\_format} |
|
39 |
\railterm{ruleformat} |
|
12621 | 40 |
|
41 |
\begin{rail} |
|
42 |
'judgment' constdecl |
|
43 |
; |
|
13041 | 44 |
'atomize' ('(' 'full' ')')? |
13014 | 45 |
; |
46 |
ruleformat ('(' 'noasm' ')')? |
|
12621 | 47 |
; |
48 |
\end{rail} |
|
49 |
||
50 |
\begin{descr} |
|
13041 | 51 |
|
52 |
\item [$\isarkeyword{judgment}~c::\sigma~~(mx)$] declares constant $c$ as the |
|
12621 | 53 |
truth judgment of the current object-logic. Its type $\sigma$ should |
54 |
specify a coercion of the category of object-level propositions to $prop$ of |
|
13041 | 55 |
the Pure meta-logic; the mixfix annotation $(mx)$ would typically just link |
12621 | 56 |
the object language (internally of syntactic category $logic$) with that of |
57 |
$prop$. Only one $\isarkeyword{judgment}$ declaration may be given in any |
|
58 |
theory development. |
|
13041 | 59 |
|
12621 | 60 |
\item [$atomize$] (as a method) rewrites any non-atomic premises of a |
61 |
sub-goal, using the meta-level equations declared via $atomize$ (as an |
|
62 |
attribute) beforehand. As a result, heavily nested goals become amenable to |
|
63 |
fundamental operations such as resolution (cf.\ the $rule$ method) and |
|
13014 | 64 |
proof-by-assumption (cf.\ $assumption$). Giving the ``$(full)$'' option |
13041 | 65 |
here means to turn the whole subgoal into an object-statement (if possible), |
13014 | 66 |
including the outermost parameters and assumptions as well. |
67 |
||
12621 | 68 |
A typical collection of $atomize$ rules for a particular object-logic would |
69 |
provide an internalization for each of the connectives of $\Forall$, $\Imp$, |
|
70 |
and $\equiv$. Meta-level conjunction expressed in the manner of minimal |
|
71 |
higher-order logic as $\All{\PROP\,C} (A \Imp B \Imp \PROP\,C) \Imp PROP\,C$ |
|
72 |
should be covered as well (this is particularly important for locales, see |
|
73 |
\S\ref{sec:locale}). |
|
13014 | 74 |
|
12621 | 75 |
\item [$rule_format$] rewrites a theorem by the equalities declared as |
76 |
$rulify$ rules in the current object-logic. By default, the result is fully |
|
77 |
normalized, including assumptions and conclusions at any depth. The |
|
78 |
$no_asm$ option restricts the transformation to the conclusion of a rule. |
|
13014 | 79 |
|
12621 | 80 |
In common object-logics (HOL, FOL, ZF), the effect of $rule_format$ is to |
81 |
replace (bounded) universal quantification ($\forall$) and implication |
|
82 |
($\imp$) by the corresponding rule statements over $\Forall$ and $\Imp$. |
|
83 |
||
84 |
\end{descr} |
|
85 |
||
86 |
||
87 |
\section{HOL} |
|
88 |
||
13039 | 89 |
\subsection{Primitive types}\label{sec:hol-typedef} |
12621 | 90 |
|
91 |
\indexisarcmdof{HOL}{typedecl}\indexisarcmdof{HOL}{typedef} |
|
92 |
\begin{matharray}{rcl} |
|
93 |
\isarcmd{typedecl} & : & \isartrans{theory}{theory} \\ |
|
94 |
\isarcmd{typedef} & : & \isartrans{theory}{proof(prove)} \\ |
|
95 |
\end{matharray} |
|
96 |
||
97 |
\begin{rail} |
|
12879 | 98 |
'typedecl' typespec infix? |
12621 | 99 |
; |
13443 | 100 |
'typedef' altname? abstype '=' repset |
13016 | 101 |
; |
102 |
||
13444 | 103 |
altname: '(' (name | 'open' | 'open' name) ')' |
13443 | 104 |
; |
13016 | 105 |
abstype: typespec infix? |
106 |
; |
|
107 |
repset: term ('morphisms' name name)? |
|
12621 | 108 |
; |
109 |
\end{rail} |
|
110 |
||
111 |
\begin{descr} |
|
13014 | 112 |
|
12621 | 113 |
\item [$\isarkeyword{typedecl}~(\vec\alpha)t$] is similar to the original |
114 |
$\isarkeyword{typedecl}$ of Isabelle/Pure (see \S\ref{sec:types-pure}), but |
|
13041 | 115 |
also declares type arity $t :: (type, \dots, type) type$, making $t$ an |
12621 | 116 |
actual HOL type constructor. |
13014 | 117 |
|
12621 | 118 |
\item [$\isarkeyword{typedef}~(\vec\alpha)t = A$] sets up a goal stating |
119 |
non-emptiness of the set $A$. After finishing the proof, the theory will be |
|
13014 | 120 |
augmented by a Gordon/HOL-style type definition, which establishes a |
121 |
bijection between the representing set $A$ and the new type $t$. |
|
122 |
||
123 |
Technically, $\isarkeyword{typedef}$ defines both a type $t$ and a set (term |
|
13016 | 124 |
constant) of the same name (an alternative base name may be given in |
125 |
parentheses). The injection from type to set is called $Rep_t$, its inverse |
|
126 |
$Abs_t$ (this may be changed via an explicit $\isarkeyword{morphisms}$ |
|
127 |
declaration). |
|
128 |
||
13041 | 129 |
Theorems $Rep_t$, $Rep_t_inverse$, and $Abs_t_inverse$ provide the most |
130 |
basic characterization as a corresponding injection/surjection pair (in both |
|
13016 | 131 |
directions). Rules $Rep_t_inject$ and $Abs_t_inject$ provide a slightly |
13041 | 132 |
more convenient view on the injectivity part, suitable for automated proof |
133 |
tools (e.g.\ in $simp$ or $iff$ declarations). Rules |
|
134 |
$Rep_t_cases/Rep_t_induct$, and $Abs_t_cases/Abs_t_induct$ provide |
|
135 |
alternative views on surjectivity; these are already declared as set or type |
|
136 |
rules for the generic $cases$ and $induct$ methods. |
|
13443 | 137 |
|
138 |
An alternative name may be specified in parentheses; the default is to use |
|
139 |
$t$ as indicated before. The $open$ declaration suppresses a separate |
|
140 |
constant definition for the representing set. |
|
12621 | 141 |
\end{descr} |
142 |
||
13041 | 143 |
Note that raw type declarations are rarely used in practice; the main |
144 |
application is with experimental (or even axiomatic!) theory fragments. |
|
145 |
Instead of primitive HOL type definitions, user-level theories usually refer |
|
146 |
to higher-level packages such as $\isarkeyword{record}$ (see |
|
147 |
\S\ref{sec:hol-record}) or $\isarkeyword{datatype}$ (see |
|
148 |
\S\ref{sec:hol-datatype}). |
|
12621 | 149 |
|
13014 | 150 |
|
151 |
\subsection{Adhoc tuples} |
|
12621 | 152 |
|
153 |
\indexisarattof{HOL}{split-format} |
|
154 |
\begin{matharray}{rcl} |
|
155 |
split_format^* & : & \isaratt \\ |
|
156 |
\end{matharray} |
|
157 |
||
158 |
\railalias{splitformat}{split\_format} |
|
159 |
\railterm{splitformat} |
|
160 |
||
161 |
\begin{rail} |
|
13027 | 162 |
splitformat (((name *) + 'and') | ('(' 'complete' ')')) |
12621 | 163 |
; |
164 |
\end{rail} |
|
165 |
||
166 |
\begin{descr} |
|
13041 | 167 |
|
12621 | 168 |
\item [$split_format~\vec p@1 \dots \vec p@n$] puts expressions of low-level |
169 |
tuple types into canonical form as specified by the arguments given; $\vec |
|
13049 | 170 |
p@i$ refers to occurrences in premise $i$ of the rule. The ``$(complete)$'' |
13041 | 171 |
option causes \emph{all} arguments in function applications to be |
172 |
represented canonically according to their tuple type structure. |
|
13014 | 173 |
|
12621 | 174 |
Note that these operations tend to invent funny names for new local |
175 |
parameters to be introduced. |
|
176 |
||
177 |
\end{descr} |
|
178 |
||
179 |
||
13039 | 180 |
\subsection{Records}\label{sec:hol-record} |
13014 | 181 |
|
13041 | 182 |
In principle, records merely generalize the concept of tuples, where |
183 |
components may be addressed by labels instead of just position. The logical |
|
13014 | 184 |
infrastructure of records in Isabelle/HOL is slightly more advanced, though, |
185 |
supporting truly extensible record schemes. This admits operations that are |
|
186 |
polymorphic with respect to record extension, yielding ``object-oriented'' |
|
187 |
effects like (single) inheritance. See also \cite{NaraschewskiW-TPHOLs98} for |
|
188 |
more details on object-oriented verification and record subtyping in HOL. |
|
189 |
||
190 |
||
13039 | 191 |
\subsubsection{Basic concepts} |
13014 | 192 |
|
193 |
Isabelle/HOL supports both \emph{fixed} and \emph{schematic} records at the |
|
194 |
level of terms and types. The notation is as follows: |
|
195 |
||
196 |
\begin{center} |
|
197 |
\begin{tabular}{l|l|l} |
|
198 |
& record terms & record types \\ \hline |
|
199 |
fixed & $\record{x = a\fs y = b}$ & $\record{x \ty A\fs y \ty B}$ \\ |
|
200 |
schematic & $\record{x = a\fs y = b\fs \more = m}$ & |
|
201 |
$\record{x \ty A\fs y \ty B\fs \more \ty M}$ \\ |
|
202 |
\end{tabular} |
|
203 |
\end{center} |
|
204 |
||
205 |
\noindent The ASCII representation of $\record{x = a}$ is \texttt{(| x = a |)}. |
|
206 |
||
207 |
A fixed record $\record{x = a\fs y = b}$ has field $x$ of value $a$ and field |
|
208 |
$y$ of value $b$. The corresponding type is $\record{x \ty A\fs y \ty B}$, |
|
209 |
assuming that $a \ty A$ and $b \ty B$. |
|
12621 | 210 |
|
13014 | 211 |
A record scheme like $\record{x = a\fs y = b\fs \more = m}$ contains fields |
212 |
$x$ and $y$ as before, but also possibly further fields as indicated by the |
|
213 |
``$\more$'' notation (which is actually part of the syntax). The improper |
|
214 |
field ``$\more$'' of a record scheme is called the \emph{more part}. |
|
215 |
Logically it is just a free variable, which is occasionally referred to as |
|
13041 | 216 |
``row variable'' in the literature. The more part of a record scheme may be |
217 |
instantiated by zero or more further components. For example, the previous |
|
13014 | 218 |
scheme may get instantiated to $\record{x = a\fs y = b\fs z = c\fs \more = |
219 |
m'}$, where $m'$ refers to a different more part. Fixed records are special |
|
220 |
instances of record schemes, where ``$\more$'' is properly terminated by the |
|
221 |
$() :: unit$ element. Actually, $\record{x = a\fs y = b}$ is just an |
|
222 |
abbreviation for $\record{x = a\fs y = b\fs \more = ()}$. |
|
223 |
||
224 |
\medskip |
|
12621 | 225 |
|
13014 | 226 |
Two key observations make extensible records in a simply typed language like |
227 |
HOL feasible: |
|
228 |
\begin{enumerate} |
|
229 |
\item the more part is internalized, as a free term or type variable, |
|
230 |
\item field names are externalized, they cannot be accessed within the logic |
|
231 |
as first-class values. |
|
232 |
\end{enumerate} |
|
233 |
||
234 |
\medskip |
|
235 |
||
236 |
In Isabelle/HOL record types have to be defined explicitly, fixing their field |
|
13042 | 237 |
names and types, and their (optional) parent record. Afterwards, records may |
238 |
be formed using above syntax, while obeying the canonical order of fields as |
|
239 |
given by their declaration. The record package provides several standard |
|
240 |
operations like selectors and updates. The common setup for various generic |
|
241 |
proof tools enable succinct reasoning patterns. See also the Isabelle/HOL |
|
242 |
tutorial \cite{isabelle-hol-book} for further instructions on using records in |
|
13014 | 243 |
practice. |
244 |
||
245 |
||
13042 | 246 |
\subsubsection{Record specifications} |
12621 | 247 |
|
248 |
\indexisarcmdof{HOL}{record} |
|
249 |
\begin{matharray}{rcl} |
|
250 |
\isarcmd{record} & : & \isartrans{theory}{theory} \\ |
|
251 |
\end{matharray} |
|
252 |
||
253 |
\begin{rail} |
|
254 |
'record' typespec '=' (type '+')? (constdecl +) |
|
255 |
; |
|
256 |
\end{rail} |
|
257 |
||
258 |
\begin{descr} |
|
259 |
\item [$\isarkeyword{record}~(\vec\alpha)t = \tau + \vec c :: \vec\sigma$] |
|
260 |
defines extensible record type $(\vec\alpha)t$, derived from the optional |
|
261 |
parent record $\tau$ by adding new field components $\vec c :: \vec\sigma$. |
|
13014 | 262 |
|
263 |
The type variables of $\tau$ and $\vec\sigma$ need to be covered by the |
|
264 |
(distinct) parameters $\vec\alpha$. Type constructor $t$ has to be new, |
|
265 |
while $\tau$ needs to specify an instance of an existing record type. At |
|
266 |
least one new field $\vec c$ has to be specified. Basically, field names |
|
267 |
need to belong to a unique record. This is not a real restriction in |
|
268 |
practice, since fields are qualified by the record name internally. |
|
269 |
||
270 |
The parent record specification $\tau$ is optional; if omitted $t$ becomes a |
|
271 |
root record. The hierarchy of all records declared within a theory context |
|
272 |
forms a forest structure, i.e.\ a set of trees starting with a root record |
|
273 |
each. There is no way to merge multiple parent records! |
|
274 |
||
275 |
For convenience, $(\vec\alpha) \, t$ is made a type abbreviation for the |
|
276 |
fixed record type $\record{\vec c \ty \vec\sigma}$, likewise is |
|
277 |
$(\vec\alpha, \zeta) \, t_scheme$ made an abbreviation for $\record{\vec c |
|
278 |
\ty \vec\sigma\fs \more \ty \zeta}$. |
|
279 |
||
12621 | 280 |
\end{descr} |
281 |
||
13042 | 282 |
\subsubsection{Record operations} |
13014 | 283 |
|
284 |
Any record definition of the form presented above produces certain standard |
|
285 |
operations. Selectors and updates are provided for any field, including the |
|
286 |
improper one ``$more$''. There are also cumulative record constructor |
|
287 |
functions. To simplify the presentation below, we assume for now that |
|
288 |
$(\vec\alpha) \, t$ is a root record with fields $\vec c \ty \vec\sigma$. |
|
289 |
||
290 |
\medskip \textbf{Selectors} and \textbf{updates} are available for any field |
|
291 |
(including ``$more$''): |
|
292 |
\begin{matharray}{lll} |
|
293 |
c@i & \ty & \record{\vec c \ty \vec \sigma, \more \ty \zeta} \To \sigma@i \\ |
|
294 |
c@i_update & \ty & \sigma@i \To \record{\vec c \ty \vec\sigma, \more \ty \zeta} \To |
|
295 |
\record{\vec c \ty \vec\sigma, \more \ty \zeta} |
|
296 |
\end{matharray} |
|
297 |
||
298 |
There is special syntax for application of updates: $r \, \record{x \asn a}$ |
|
299 |
abbreviates term $x_update \, a \, r$. Further notation for repeated updates |
|
300 |
is also available: $r \, \record{x \asn a} \, \record{y \asn b} \, \record{z |
|
301 |
\asn c}$ may be written $r \, \record{x \asn a\fs y \asn b\fs z \asn c}$. |
|
302 |
Note that because of postfix notation the order of fields shown here is |
|
303 |
reverse than in the actual term. Since repeated updates are just function |
|
304 |
applications, fields may be freely permuted in $\record{x \asn a\fs y \asn |
|
305 |
b\fs z \asn c}$, as far as logical equality is concerned. Thus |
|
13041 | 306 |
commutativity of independent updates can be proven within the logic for any |
307 |
two fields, but not as a general theorem. |
|
13014 | 308 |
|
309 |
\medskip The \textbf{make} operation provides a cumulative record constructor |
|
13041 | 310 |
function: |
13014 | 311 |
\begin{matharray}{lll} |
312 |
t{\dtt}make & \ty & \vec\sigma \To \record{\vec c \ty \vec \sigma} \\ |
|
313 |
\end{matharray} |
|
314 |
||
315 |
\medskip We now reconsider the case of non-root records, which are derived of |
|
316 |
some parent. In general, the latter may depend on another parent as well, |
|
317 |
resulting in a list of \emph{ancestor records}. Appending the lists of fields |
|
318 |
of all ancestors results in a certain field prefix. The record package |
|
319 |
automatically takes care of this by lifting operations over this context of |
|
320 |
ancestor fields. Assuming that $(\vec\alpha) \, t$ has ancestor fields $\vec |
|
321 |
b \ty \vec\rho$, the above record operations will get the following types: |
|
322 |
\begin{matharray}{lll} |
|
323 |
c@i & \ty & \record{\vec b \ty \vec\rho, \vec c \ty \vec\sigma, \more \ty |
|
324 |
\zeta} \To \sigma@i \\ |
|
325 |
c@i_update & \ty & \sigma@i \To |
|
326 |
\record{\vec b \ty \vec\rho, \vec c \ty \vec\sigma, \more \ty \zeta} \To |
|
327 |
\record{\vec b \ty \vec\rho, \vec c \ty \vec\sigma, \more \ty \zeta} \\ |
|
328 |
t{\dtt}make & \ty & \vec\rho \To \vec\sigma \To |
|
329 |
\record{\vec b \ty \vec\rho, \vec c \ty \vec \sigma} \\ |
|
330 |
\end{matharray} |
|
331 |
\noindent |
|
332 |
||
333 |
\medskip Some further operations address the extension aspect of a derived |
|
334 |
record scheme specifically: $fields$ produces a record fragment consisting of |
|
335 |
exactly the new fields introduced here (the result may serve as a more part |
|
336 |
elsewhere); $extend$ takes a fixed record and adds a given more part; |
|
337 |
$truncate$ restricts a record scheme to a fixed record. |
|
338 |
||
339 |
\begin{matharray}{lll} |
|
340 |
t{\dtt}fields & \ty & \vec\sigma \To \record{\vec c \ty \vec \sigma} \\ |
|
341 |
t{\dtt}extend & \ty & \record{\vec d \ty \vec \rho, \vec c \ty \vec\sigma} \To |
|
342 |
\zeta \To \record{\vec d \ty \vec \rho, \vec c \ty \vec\sigma, \more \ty \zeta} \\ |
|
343 |
t{\dtt}truncate & \ty & \record{\vec d \ty \vec \rho, \vec c \ty \vec\sigma, \more \ty \zeta} \To |
|
344 |
\record{\vec d \ty \vec \rho, \vec c \ty \vec\sigma} \\ |
|
345 |
\end{matharray} |
|
346 |
||
13041 | 347 |
\noindent Note that $t{\dtt}make$ and $t{\dtt}fields$ actually coincide for root records. |
13014 | 348 |
|
349 |
||
13042 | 350 |
\subsubsection{Derived rules and proof tools} |
13014 | 351 |
|
352 |
The record package proves several results internally, declaring these facts to |
|
353 |
appropriate proof tools. This enables users to reason about record structures |
|
13041 | 354 |
quite conveniently. Assume that $t$ is a record type as specified above. |
13014 | 355 |
|
356 |
\begin{enumerate} |
|
13041 | 357 |
|
13014 | 358 |
\item Standard conversions for selectors or updates applied to record |
359 |
constructor terms are made part of the default Simplifier context; thus |
|
360 |
proofs by reduction of basic operations merely require the $simp$ method |
|
13041 | 361 |
without further arguments. These rules are available as $t{\dtt}simps$, |
362 |
too. |
|
363 |
||
13014 | 364 |
\item Selectors applied to updated records are automatically reduced by an |
13041 | 365 |
internal simplification procedure, which is also part of the standard |
366 |
Simplifier setup. |
|
13014 | 367 |
|
368 |
\item Inject equations of a form analogous to $((x, y) = (x', y')) \equiv x=x' |
|
369 |
\conj y=y'$ are declared to the Simplifier and Classical Reasoner as $iff$ |
|
370 |
rules. These rules are available as $t{\dtt}iffs$. |
|
371 |
||
372 |
\item The introduction rule for record equality analogous to $x~r = x~r' \Imp |
|
373 |
y~r = y~r' \Imp \dots \Imp r = r'$ is declared to the Simplifier, and as the |
|
374 |
basic rule context as ``$intro?$''. The rule is called $t{\dtt}equality$. |
|
375 |
||
376 |
\item Representations of arbitrary record expressions as canonical constructor |
|
377 |
terms are provided both in $cases$ and $induct$ format (cf.\ the generic |
|
378 |
proof methods of the same name, \S\ref{sec:cases-induct}). Several |
|
379 |
variations are available, for fixed records, record schemes, more parts etc. |
|
13041 | 380 |
|
13014 | 381 |
The generic proof methods are sufficiently smart to pick the most sensible |
382 |
rule according to the type of the indicated record expression: users just |
|
13041 | 383 |
need to apply something like ``$(cases~r)$'' to a certain proof problem. |
13014 | 384 |
|
385 |
\item The derived record operations $t{\dtt}make$, $t{\dtt}fields$, |
|
386 |
$t{\dtt}extend$, $t{\dtt}truncate$ are \emph{not} treated automatically, but |
|
387 |
usually need to be expanded by hand, using the collective fact |
|
388 |
$t{\dtt}defs$. |
|
389 |
||
390 |
\end{enumerate} |
|
391 |
||
12621 | 392 |
|
393 |
\subsection{Datatypes}\label{sec:hol-datatype} |
|
394 |
||
395 |
\indexisarcmdof{HOL}{datatype}\indexisarcmdof{HOL}{rep-datatype} |
|
396 |
\begin{matharray}{rcl} |
|
397 |
\isarcmd{datatype} & : & \isartrans{theory}{theory} \\ |
|
398 |
\isarcmd{rep_datatype} & : & \isartrans{theory}{theory} \\ |
|
399 |
\end{matharray} |
|
400 |
||
401 |
\railalias{repdatatype}{rep\_datatype} |
|
402 |
\railterm{repdatatype} |
|
403 |
||
404 |
\begin{rail} |
|
405 |
'datatype' (dtspec + 'and') |
|
406 |
; |
|
13024 | 407 |
repdatatype (name *) dtrules |
12621 | 408 |
; |
409 |
||
410 |
dtspec: parname? typespec infix? '=' (cons + '|') |
|
411 |
; |
|
13024 | 412 |
cons: name (type *) mixfix? |
12621 | 413 |
; |
414 |
dtrules: 'distinct' thmrefs 'inject' thmrefs 'induction' thmrefs |
|
415 |
\end{rail} |
|
416 |
||
417 |
\begin{descr} |
|
418 |
\item [$\isarkeyword{datatype}$] defines inductive datatypes in HOL. |
|
419 |
\item [$\isarkeyword{rep_datatype}$] represents existing types as inductive |
|
420 |
ones, generating the standard infrastructure of derived concepts (primitive |
|
421 |
recursion etc.). |
|
422 |
\end{descr} |
|
423 |
||
424 |
The induction and exhaustion theorems generated provide case names according |
|
425 |
to the constructors involved, while parameters are named after the types (see |
|
426 |
also \S\ref{sec:cases-induct}). |
|
427 |
||
13014 | 428 |
See \cite{isabelle-HOL} for more details on datatypes, but beware of the |
429 |
old-style theory syntax being used there! Apart from proper proof methods for |
|
430 |
case-analysis and induction, there are also emulations of ML tactics |
|
12621 | 431 |
\texttt{case_tac} and \texttt{induct_tac} available, see |
13042 | 432 |
\S\ref{sec:hol-induct-tac}; these admit to refer directly to the internal |
433 |
structure of subgoals (including internally bound parameters). |
|
12621 | 434 |
|
435 |
||
436 |
\subsection{Recursive functions}\label{sec:recursion} |
|
437 |
||
438 |
\indexisarcmdof{HOL}{primrec}\indexisarcmdof{HOL}{recdef}\indexisarcmdof{HOL}{recdef-tc} |
|
439 |
\begin{matharray}{rcl} |
|
440 |
\isarcmd{primrec} & : & \isartrans{theory}{theory} \\ |
|
441 |
\isarcmd{recdef} & : & \isartrans{theory}{theory} \\ |
|
442 |
\isarcmd{recdef_tc}^* & : & \isartrans{theory}{proof(prove)} \\ |
|
443 |
\end{matharray} |
|
444 |
||
445 |
\railalias{recdefsimp}{recdef\_simp} |
|
446 |
\railterm{recdefsimp} |
|
447 |
||
448 |
\railalias{recdefcong}{recdef\_cong} |
|
449 |
\railterm{recdefcong} |
|
450 |
||
451 |
\railalias{recdefwf}{recdef\_wf} |
|
452 |
\railterm{recdefwf} |
|
453 |
||
454 |
\railalias{recdeftc}{recdef\_tc} |
|
455 |
\railterm{recdeftc} |
|
456 |
||
457 |
\begin{rail} |
|
13024 | 458 |
'primrec' parname? (equation +) |
12621 | 459 |
; |
13024 | 460 |
'recdef' ('(' 'permissive' ')')? \\ name term (prop +) hints? |
12621 | 461 |
; |
12879 | 462 |
recdeftc thmdecl? tc |
12621 | 463 |
; |
464 |
||
12879 | 465 |
equation: thmdecl? prop |
12621 | 466 |
; |
13024 | 467 |
hints: '(' 'hints' (recdefmod *) ')' |
12621 | 468 |
; |
469 |
recdefmod: ((recdefsimp | recdefcong | recdefwf) (() | 'add' | 'del') ':' thmrefs) | clasimpmod |
|
470 |
; |
|
471 |
tc: nameref ('(' nat ')')? |
|
472 |
; |
|
473 |
\end{rail} |
|
474 |
||
475 |
\begin{descr} |
|
13024 | 476 |
|
12621 | 477 |
\item [$\isarkeyword{primrec}$] defines primitive recursive functions over |
13024 | 478 |
datatypes, see also \cite{isabelle-HOL}. |
479 |
||
12621 | 480 |
\item [$\isarkeyword{recdef}$] defines general well-founded recursive |
13024 | 481 |
functions (using the TFL package), see also \cite{isabelle-HOL}. The |
13041 | 482 |
``$(permissive)$'' option tells TFL to recover from failed proof attempts, |
12621 | 483 |
returning unfinished results. The $recdef_simp$, $recdef_cong$, and |
484 |
$recdef_wf$ hints refer to auxiliary rules to be used in the internal |
|
13024 | 485 |
automated proof process of TFL. Additional $clasimpmod$ declarations (cf.\ |
12621 | 486 |
\S\ref{sec:clasimp}) may be given to tune the context of the Simplifier |
13024 | 487 |
(cf.\ \S\ref{sec:simplifier}) and Classical reasoner (cf.\ |
12621 | 488 |
\S\ref{sec:classical}). |
13024 | 489 |
|
12621 | 490 |
\item [$\isarkeyword{recdef_tc}~c~(i)$] recommences the proof for leftover |
491 |
termination condition number $i$ (default $1$) as generated by a |
|
492 |
$\isarkeyword{recdef}$ definition of constant $c$. |
|
13024 | 493 |
|
12621 | 494 |
Note that in most cases, $\isarkeyword{recdef}$ is able to finish its |
495 |
internal proofs without manual intervention. |
|
13024 | 496 |
|
12621 | 497 |
\end{descr} |
498 |
||
13014 | 499 |
Both kinds of recursive definitions accommodate reasoning by induction (cf.\ |
12621 | 500 |
\S\ref{sec:cases-induct}): rule $c\mathord{.}induct$ (where $c$ is the name of |
501 |
the function definition) refers to a specific induction rule, with parameters |
|
502 |
named according to the user-specified equations. Case names of |
|
503 |
$\isarkeyword{primrec}$ are that of the datatypes involved, while those of |
|
504 |
$\isarkeyword{recdef}$ are numbered (starting from $1$). |
|
505 |
||
506 |
The equations provided by these packages may be referred later as theorem list |
|
13041 | 507 |
$f{\dtt}simps$, where $f$ is the (collective) name of the functions defined. |
508 |
Individual equations may be named explicitly as well; note that for |
|
12621 | 509 |
$\isarkeyword{recdef}$ each specification given by the user may result in |
510 |
several theorems. |
|
511 |
||
512 |
\medskip Hints for $\isarkeyword{recdef}$ may be also declared globally, using |
|
513 |
the following attributes. |
|
514 |
||
515 |
\indexisarattof{HOL}{recdef-simp}\indexisarattof{HOL}{recdef-cong}\indexisarattof{HOL}{recdef-wf} |
|
516 |
\begin{matharray}{rcl} |
|
517 |
recdef_simp & : & \isaratt \\ |
|
518 |
recdef_cong & : & \isaratt \\ |
|
519 |
recdef_wf & : & \isaratt \\ |
|
520 |
\end{matharray} |
|
521 |
||
522 |
\railalias{recdefsimp}{recdef\_simp} |
|
523 |
\railterm{recdefsimp} |
|
524 |
||
525 |
\railalias{recdefcong}{recdef\_cong} |
|
526 |
\railterm{recdefcong} |
|
527 |
||
528 |
\railalias{recdefwf}{recdef\_wf} |
|
529 |
\railterm{recdefwf} |
|
530 |
||
531 |
\begin{rail} |
|
532 |
(recdefsimp | recdefcong | recdefwf) (() | 'add' | 'del') |
|
533 |
; |
|
534 |
\end{rail} |
|
535 |
||
14119 | 536 |
\subsection{Definition by specification}\label{sec:hol-specification} |
537 |
||
538 |
\indexisarcmdof{HOL}{specification} |
|
539 |
\begin{matharray}{rcl} |
|
540 |
\isarcmd{specification} & : & \isartrans{theory}{proof(prove)} \\ |
|
14619
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
541 |
\isarcmd{ax_specification} & : & \isartrans{theory}{proof(prove)} \\ |
14119 | 542 |
\end{matharray} |
543 |
||
544 |
\begin{rail} |
|
14619
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
545 |
('specification' | 'ax\_specification') '(' (decl +) ')' \\ (thmdecl? prop +) |
14119 | 546 |
; |
14642 | 547 |
decl: ((name ':')? term '(' 'overloaded' ')'?) |
14119 | 548 |
\end{rail} |
549 |
||
550 |
\begin{descr} |
|
14165
67b4c4cdb270
New specification syntax added (the specification may be split over
skalberg
parents:
14119
diff
changeset
|
551 |
\item [$\isarkeyword{specification}~decls~\phi$] sets up a goal stating |
67b4c4cdb270
New specification syntax added (the specification may be split over
skalberg
parents:
14119
diff
changeset
|
552 |
the existence of terms with the properties specified to hold for the |
67b4c4cdb270
New specification syntax added (the specification may be split over
skalberg
parents:
14119
diff
changeset
|
553 |
constants given in $\mathit{decls}$. After finishing the proof, the |
67b4c4cdb270
New specification syntax added (the specification may be split over
skalberg
parents:
14119
diff
changeset
|
554 |
theory will be augmented with definitions for the given constants, |
67b4c4cdb270
New specification syntax added (the specification may be split over
skalberg
parents:
14119
diff
changeset
|
555 |
as well as with theorems stating the properties for these constants. |
14619
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
556 |
\item [$\isarkeyword{ax_specification}~decls~\phi$] sets up a goal stating |
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
557 |
the existence of terms with the properties specified to hold for the |
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
558 |
constants given in $\mathit{decls}$. After finishing the proof, the |
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
559 |
theory will be augmented with axioms expressing the properties given |
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
560 |
in the first place. |
14119 | 561 |
\item[$decl$] declares a constant to be defined by the specification |
562 |
given. The definition for the constant $c$ is bound to the name |
|
563 |
$c$\_def unless a theorem name is given in the declaration. |
|
564 |
Overloaded constants should be declared as such. |
|
565 |
\end{descr} |
|
12621 | 566 |
|
14619
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
567 |
Whether to use $\isarkeyword{specification}$ or $\isarkeyword{ax_specification}$ |
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
568 |
is to some extent a matter of style. $\isarkeyword{specification}$ introduces no new axioms, |
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
569 |
and so by construction cannot introduce inconsistencies, whereas $\isarkeyword{ax_specification}$ |
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
570 |
does introduce axioms, but only after the user has explicitly proven it to be |
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
571 |
safe. A practical issue must be considered, though: After introducing two constants |
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
572 |
with the same properties using $\isarkeyword{specification}$, one can prove |
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
573 |
that the two constants are, in fact, equal. If this might be a problem, |
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
574 |
one should use $\isarkeyword{ax_specification}$. |
8876ad83b1fb
Added documentation for ax_specification, as well as a small comparison of
skalberg
parents:
14165
diff
changeset
|
575 |
|
12621 | 576 |
\subsection{(Co)Inductive sets}\label{sec:hol-inductive} |
577 |
||
578 |
\indexisarcmdof{HOL}{inductive}\indexisarcmdof{HOL}{coinductive}\indexisarattof{HOL}{mono} |
|
579 |
\begin{matharray}{rcl} |
|
580 |
\isarcmd{inductive} & : & \isartrans{theory}{theory} \\ |
|
581 |
\isarcmd{coinductive} & : & \isartrans{theory}{theory} \\ |
|
582 |
mono & : & \isaratt \\ |
|
583 |
\end{matharray} |
|
584 |
||
585 |
\begin{rail} |
|
586 |
('inductive' | 'coinductive') sets intros monos? |
|
587 |
; |
|
588 |
'mono' (() | 'add' | 'del') |
|
589 |
; |
|
590 |
||
12879 | 591 |
sets: (term +) |
12621 | 592 |
; |
12879 | 593 |
intros: 'intros' (thmdecl? prop +) |
12621 | 594 |
; |
12879 | 595 |
monos: 'monos' thmrefs |
12621 | 596 |
; |
597 |
\end{rail} |
|
598 |
||
599 |
\begin{descr} |
|
600 |
\item [$\isarkeyword{inductive}$ and $\isarkeyword{coinductive}$] define |
|
601 |
(co)inductive sets from the given introduction rules. |
|
602 |
\item [$mono$] declares monotonicity rules. These rule are involved in the |
|
603 |
automated monotonicity proof of $\isarkeyword{inductive}$. |
|
604 |
\end{descr} |
|
605 |
||
13024 | 606 |
See \cite{isabelle-HOL} for further information on inductive definitions in |
607 |
HOL, but note that this covers the old-style theory format. |
|
12621 | 608 |
|
609 |
||
610 |
\subsection{Arithmetic proof support} |
|
611 |
||
612 |
\indexisarmethof{HOL}{arith}\indexisarattof{HOL}{arith-split} |
|
613 |
\begin{matharray}{rcl} |
|
614 |
arith & : & \isarmeth \\ |
|
615 |
arith_split & : & \isaratt \\ |
|
616 |
\end{matharray} |
|
617 |
||
618 |
\begin{rail} |
|
619 |
'arith' '!'? |
|
620 |
; |
|
621 |
\end{rail} |
|
622 |
||
623 |
The $arith$ method decides linear arithmetic problems (on types $nat$, $int$, |
|
624 |
$real$). Any current facts are inserted into the goal before running the |
|
625 |
procedure. The ``!''~argument causes the full context of assumptions to be |
|
626 |
included. The $arith_split$ attribute declares case split rules to be |
|
627 |
expanded before the arithmetic procedure is invoked. |
|
628 |
||
629 |
Note that a simpler (but faster) version of arithmetic reasoning is already |
|
630 |
performed by the Simplifier. |
|
631 |
||
632 |
||
13024 | 633 |
\subsection{Cases and induction: emulating tactic scripts}\label{sec:hol-induct-tac} |
12621 | 634 |
|
635 |
The following important tactical tools of Isabelle/HOL have been ported to |
|
636 |
Isar. These should be never used in proper proof texts! |
|
637 |
||
638 |
\indexisarmethof{HOL}{case-tac}\indexisarmethof{HOL}{induct-tac} |
|
639 |
\indexisarmethof{HOL}{ind-cases}\indexisarcmdof{HOL}{inductive-cases} |
|
640 |
\begin{matharray}{rcl} |
|
641 |
case_tac^* & : & \isarmeth \\ |
|
642 |
induct_tac^* & : & \isarmeth \\ |
|
643 |
ind_cases^* & : & \isarmeth \\ |
|
644 |
\isarcmd{inductive_cases} & : & \isartrans{theory}{theory} \\ |
|
645 |
\end{matharray} |
|
646 |
||
647 |
\railalias{casetac}{case\_tac} |
|
648 |
\railterm{casetac} |
|
649 |
||
650 |
\railalias{inducttac}{induct\_tac} |
|
651 |
\railterm{inducttac} |
|
652 |
||
653 |
\railalias{indcases}{ind\_cases} |
|
654 |
\railterm{indcases} |
|
655 |
||
656 |
\railalias{inductivecases}{inductive\_cases} |
|
657 |
\railterm{inductivecases} |
|
658 |
||
659 |
\begin{rail} |
|
660 |
casetac goalspec? term rule? |
|
661 |
; |
|
662 |
inducttac goalspec? (insts * 'and') rule? |
|
663 |
; |
|
664 |
indcases (prop +) |
|
665 |
; |
|
13014 | 666 |
inductivecases (thmdecl? (prop +) + 'and') |
12621 | 667 |
; |
668 |
||
669 |
rule: ('rule' ':' thmref) |
|
670 |
; |
|
671 |
\end{rail} |
|
672 |
||
673 |
\begin{descr} |
|
674 |
\item [$case_tac$ and $induct_tac$] admit to reason about inductive datatypes |
|
675 |
only (unless an alternative rule is given explicitly). Furthermore, |
|
676 |
$case_tac$ does a classical case split on booleans; $induct_tac$ allows only |
|
677 |
variables to be given as instantiation. These tactic emulations feature |
|
678 |
both goal addressing and dynamic instantiation. Note that named rule cases |
|
679 |
are \emph{not} provided as would be by the proper $induct$ and $cases$ proof |
|
680 |
methods (see \S\ref{sec:cases-induct}). |
|
13041 | 681 |
|
12621 | 682 |
\item [$ind_cases$ and $\isarkeyword{inductive_cases}$] provide an interface |
13041 | 683 |
to the internal \texttt{mk_cases} operation. Rules are simplified in an |
684 |
unrestricted forward manner. |
|
13014 | 685 |
|
12621 | 686 |
While $ind_cases$ is a proof method to apply the result immediately as |
687 |
elimination rules, $\isarkeyword{inductive_cases}$ provides case split |
|
688 |
theorems at the theory level for later use, |
|
689 |
\end{descr} |
|
690 |
||
691 |
||
13039 | 692 |
\subsection{Executable code} |
13027 | 693 |
|
694 |
Isabelle/Pure provides a generic infrastructure to support code generation |
|
695 |
from executable specifications, both functional and relational programs. |
|
696 |
Isabelle/HOL instantiates these mechanisms in a way that is amenable to |
|
697 |
end-user applications. See \cite{isabelle-HOL} for further information (this |
|
13041 | 698 |
actually covers the new-style theory format as well). |
13027 | 699 |
|
17659 | 700 |
\indexisarcmd{code-module}\indexisarcmd{code-library}\indexisarcmd{consts-code}\indexisarcmd{types-code} |
13027 | 701 |
\indexisaratt{code} |
702 |
||
703 |
\begin{matharray}{rcl} |
|
17659 | 704 |
\isarcmd{code_module} & : & \isartrans{theory}{theory} \\ |
705 |
\isarcmd{code_library} & : & \isartrans{theory}{theory} \\ |
|
13027 | 706 |
\isarcmd{consts_code} & : & \isartrans{theory}{theory} \\ |
707 |
\isarcmd{types_code} & : & \isartrans{theory}{theory} \\ |
|
708 |
code & : & \isaratt \\ |
|
709 |
\end{matharray} |
|
710 |
||
17659 | 711 |
\railalias{verblbrace}{\texttt{\ttlbrace*}} |
712 |
\railalias{verbrbrace}{\texttt{*\ttrbrace}} |
|
713 |
\railterm{verblbrace} |
|
714 |
\railterm{verbrbrace} |
|
715 |
||
716 |
\railalias{codemodule}{code\_module} |
|
717 |
\railterm{codemodule} |
|
718 |
||
719 |
\railalias{codelibrary}{code\_library} |
|
720 |
\railterm{codelibrary} |
|
13027 | 721 |
|
722 |
\railalias{constscode}{consts\_code} |
|
723 |
\railterm{constscode} |
|
724 |
||
725 |
\railalias{typescode}{types\_code} |
|
726 |
\railterm{typescode} |
|
727 |
||
728 |
\begin{rail} |
|
17659 | 729 |
( codemodule | codelibrary ) modespec ? name ? \\ |
730 |
( 'file' name ) ? ( 'imports' ( name + ) ) ? \\ |
|
731 |
'contains' ( ( name '=' term ) + | term + ); |
|
732 |
||
733 |
modespec : '(' ( name * ) ')'; |
|
734 |
||
735 |
constscode (codespec +); |
|
736 |
||
737 |
codespec : name ( '::' type) ? template attachment ?; |
|
13027 | 738 |
|
17659 | 739 |
typescode (tycodespec +); |
740 |
||
741 |
tycodespec : name template attachment ?; |
|
742 |
||
743 |
template: '(' string ')'; |
|
744 |
||
745 |
attachment: 'attach' modespec ? verblbrace text verbrbrace; |
|
746 |
||
747 |
'code' (name)?; |
|
13027 | 748 |
\end{rail} |
749 |
||
750 |
||
12621 | 751 |
\section{HOLCF} |
752 |
||
753 |
\subsection{Mixfix syntax for continuous operations} |
|
754 |
||
14682
a5072752114c
HOLCF: discontinued special version of 'constdefs';
wenzelm
parents:
14642
diff
changeset
|
755 |
\indexisarcmdof{HOLCF}{consts} |
12621 | 756 |
|
757 |
\begin{matharray}{rcl} |
|
758 |
\isarcmd{consts} & : & \isartrans{theory}{theory} \\ |
|
759 |
\end{matharray} |
|
760 |
||
14165
67b4c4cdb270
New specification syntax added (the specification may be split over
skalberg
parents:
14119
diff
changeset
|
761 |
HOLCF provides a separate type for continuous functions $\alpha \to |
12621 | 762 |
\beta$, with an explicit application operator $f \cdot x$. Isabelle mixfix |
763 |
syntax normally refers directly to the pure meta-level function type $\alpha |
|
764 |
\To \beta$, with application $f\,x$. |
|
765 |
||
14682
a5072752114c
HOLCF: discontinued special version of 'constdefs';
wenzelm
parents:
14642
diff
changeset
|
766 |
The HOLCF variant of $\CONSTS$ modifies that of Pure Isabelle (cf.\ |
a5072752114c
HOLCF: discontinued special version of 'constdefs';
wenzelm
parents:
14642
diff
changeset
|
767 |
\S\ref{sec:consts}) such that declarations involving continuous function types |
a5072752114c
HOLCF: discontinued special version of 'constdefs';
wenzelm
parents:
14642
diff
changeset
|
768 |
are treated specifically. Any given syntax template is transformed |
a5072752114c
HOLCF: discontinued special version of 'constdefs';
wenzelm
parents:
14642
diff
changeset
|
769 |
internally, generating translation rules for the abstract and concrete |
a5072752114c
HOLCF: discontinued special version of 'constdefs';
wenzelm
parents:
14642
diff
changeset
|
770 |
representation of continuous application. Note that mixing of HOLCF and Pure |
14642 | 771 |
application is \emph{not} supported! |
12621 | 772 |
|
773 |
\subsection{Recursive domains} |
|
774 |
||
775 |
\indexisarcmdof{HOLCF}{domain} |
|
776 |
\begin{matharray}{rcl} |
|
777 |
\isarcmd{domain} & : & \isartrans{theory}{theory} \\ |
|
778 |
\end{matharray} |
|
779 |
||
780 |
\begin{rail} |
|
781 |
'domain' parname? (dmspec + 'and') |
|
782 |
; |
|
783 |
||
784 |
dmspec: typespec '=' (cons + '|') |
|
785 |
; |
|
13024 | 786 |
cons: name (type *) mixfix? |
12621 | 787 |
; |
788 |
dtrules: 'distinct' thmrefs 'inject' thmrefs 'induction' thmrefs |
|
789 |
\end{rail} |
|
790 |
||
13041 | 791 |
Recursive domains in HOLCF are analogous to datatypes in classical HOL (cf.\ |
792 |
\S\ref{sec:hol-datatype}). Mutual recursion is supported, but no nesting nor |
|
12621 | 793 |
arbitrary branching. Domain constructors may be strict (default) or lazy, the |
13041 | 794 |
latter admits to introduce infinitary objects in the typical LCF manner (e.g.\ |
13014 | 795 |
lazy lists). See also \cite{MuellerNvOS99} for a general discussion of HOLCF |
796 |
domains. |
|
12621 | 797 |
|
798 |
||
799 |
\section{ZF} |
|
800 |
||
801 |
\subsection{Type checking} |
|
802 |
||
13024 | 803 |
The ZF logic is essentially untyped, so the concept of ``type checking'' is |
804 |
performed as logical reasoning about set-membership statements. A special |
|
805 |
method assists users in this task; a version of this is already declared as a |
|
13041 | 806 |
``solver'' in the standard Simplifier setup. |
13024 | 807 |
|
808 |
\indexisarcmd{print-tcset}\indexisaratt{typecheck}\indexisaratt{TC} |
|
809 |
||
810 |
\begin{matharray}{rcl} |
|
811 |
\isarcmd{print_tcset}^* & : & \isarkeep{theory~|~proof} \\ |
|
812 |
typecheck & : & \isarmeth \\ |
|
813 |
TC & : & \isaratt \\ |
|
814 |
\end{matharray} |
|
815 |
||
816 |
\begin{rail} |
|
817 |
'TC' (() | 'add' | 'del') |
|
818 |
; |
|
819 |
\end{rail} |
|
820 |
||
821 |
\begin{descr} |
|
822 |
||
823 |
\item [$\isarcmd{print_tcset}$] prints the collection of typechecking rules of |
|
824 |
the current context. |
|
825 |
||
826 |
Note that the component built into the Simplifier only knows about those |
|
827 |
rules being declared globally in the theory! |
|
828 |
||
829 |
\item [$typecheck$] attempts to solve any pending type-checking problems in |
|
830 |
subgoals. |
|
831 |
||
832 |
\item [$TC$] adds or deletes type-checking rules from the context. |
|
833 |
||
834 |
\end{descr} |
|
835 |
||
836 |
||
837 |
\subsection{(Co)Inductive sets and datatypes} |
|
838 |
||
839 |
\subsubsection{Set definitions} |
|
840 |
||
841 |
In ZF everything is a set. The generic inductive package also provides a |
|
842 |
specific view for ``datatype'' specifications. Coinductive definitions are |
|
13041 | 843 |
available in both cases, too. |
13024 | 844 |
|
845 |
\indexisarcmdof{ZF}{inductive}\indexisarcmdof{ZF}{coinductive} |
|
846 |
\indexisarcmdof{ZF}{datatype}\indexisarcmdof{ZF}{codatatype} |
|
847 |
\begin{matharray}{rcl} |
|
848 |
\isarcmd{inductive} & : & \isartrans{theory}{theory} \\ |
|
849 |
\isarcmd{coinductive} & : & \isartrans{theory}{theory} \\ |
|
850 |
\isarcmd{datatype} & : & \isartrans{theory}{theory} \\ |
|
851 |
\isarcmd{codatatype} & : & \isartrans{theory}{theory} \\ |
|
852 |
\end{matharray} |
|
853 |
||
854 |
\railalias{CONDEFS}{con\_defs} |
|
855 |
\railterm{CONDEFS} |
|
856 |
||
857 |
\railalias{TYPEINTROS}{type\_intros} |
|
858 |
\railterm{TYPEINTROS} |
|
859 |
||
860 |
\railalias{TYPEELIMS}{type\_elims} |
|
861 |
\railterm{TYPEELIMS} |
|
862 |
||
863 |
\begin{rail} |
|
864 |
('inductive' | 'coinductive') domains intros hints |
|
865 |
; |
|
12621 | 866 |
|
13024 | 867 |
domains: 'domains' (term + '+') ('<=' | subseteq) term |
868 |
; |
|
869 |
intros: 'intros' (thmdecl? prop +) |
|
870 |
; |
|
871 |
hints: monos? condefs? typeintros? typeelims? |
|
872 |
; |
|
873 |
monos: ('monos' thmrefs)? |
|
874 |
; |
|
875 |
condefs: (CONDEFS thmrefs)? |
|
876 |
; |
|
877 |
typeintros: (TYPEINTROS thmrefs)? |
|
878 |
; |
|
879 |
typeelims: (TYPEELIMS thmrefs)? |
|
880 |
; |
|
881 |
\end{rail} |
|
882 |
||
883 |
In the following diagram $monos$, $typeintros$, and $typeelims$ are the same |
|
884 |
as above. |
|
885 |
||
886 |
\begin{rail} |
|
887 |
('datatype' | 'codatatype') domain? (dtspec + 'and') hints |
|
888 |
; |
|
889 |
||
890 |
domain: ('<=' | subseteq) term |
|
891 |
; |
|
892 |
dtspec: term '=' (con + '|') |
|
893 |
; |
|
894 |
con: name ('(' (term ',' +) ')')? |
|
895 |
; |
|
896 |
hints: monos? typeintros? typeelims? |
|
897 |
; |
|
898 |
\end{rail} |
|
899 |
||
900 |
See \cite{isabelle-ZF} for further information on inductive definitions in |
|
901 |
HOL, but note that this covers the old-style theory format. |
|
12621 | 902 |
|
13024 | 903 |
|
904 |
\subsubsection{Primitive recursive functions} |
|
905 |
||
906 |
\indexisarcmdof{ZF}{primrec} |
|
907 |
\begin{matharray}{rcl} |
|
908 |
\isarcmd{primrec} & : & \isartrans{theory}{theory} \\ |
|
909 |
\end{matharray} |
|
910 |
||
911 |
\begin{rail} |
|
912 |
'primrec' (thmdecl? prop +) |
|
913 |
; |
|
914 |
\end{rail} |
|
915 |
||
916 |
||
13042 | 917 |
\subsubsection{Cases and induction: emulating tactic scripts} |
13024 | 918 |
|
919 |
The following important tactical tools of Isabelle/ZF have been ported to |
|
920 |
Isar. These should be never used in proper proof texts! |
|
921 |
||
922 |
\indexisarmethof{ZF}{case-tac}\indexisarmethof{ZF}{induct-tac} |
|
923 |
\indexisarmethof{ZF}{ind-cases}\indexisarcmdof{ZF}{inductive-cases} |
|
924 |
\begin{matharray}{rcl} |
|
925 |
case_tac^* & : & \isarmeth \\ |
|
926 |
induct_tac^* & : & \isarmeth \\ |
|
927 |
ind_cases^* & : & \isarmeth \\ |
|
928 |
\isarcmd{inductive_cases} & : & \isartrans{theory}{theory} \\ |
|
929 |
\end{matharray} |
|
930 |
||
931 |
\begin{rail} |
|
932 |
(casetac | inducttac) goalspec? name |
|
933 |
; |
|
934 |
indcases (prop +) |
|
935 |
; |
|
936 |
inductivecases (thmdecl? (prop +) + 'and') |
|
937 |
; |
|
938 |
\end{rail} |
|
12621 | 939 |
|
13014 | 940 |
%%% Local Variables: |
12621 | 941 |
%%% mode: latex |
942 |
%%% TeX-master: "isar-ref" |
|
13014 | 943 |
%%% End: |