author | wenzelm |
Fri, 28 Sep 2001 20:08:05 +0200 | |
changeset 11635 | fd242f857508 |
parent 11634 | cddf6441a14a |
child 11662 | 744399c9dd6a |
permissions | -rw-r--r-- |
7046 | 1 |
|
7167 | 2 |
\chapter{Isabelle/HOL Tools and Packages}\label{ch:hol-tools} |
7135 | 3 |
|
10240 | 4 |
\section{Miscellaneous attributes}\label{sec:rule-format} |
7990 | 5 |
|
11039 | 6 |
\indexisaratt{rule-format}\indexisaratt{split-format} |
7990 | 7 |
\begin{matharray}{rcl} |
9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9935
diff
changeset
|
8 |
rule_format & : & \isaratt \\ |
11051 | 9 |
split_format^* & : & \isaratt \\ |
7990 | 10 |
\end{matharray} |
11 |
||
9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9935
diff
changeset
|
12 |
\railalias{ruleformat}{rule\_format} |
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9935
diff
changeset
|
13 |
\railterm{ruleformat} |
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9935
diff
changeset
|
14 |
|
11039 | 15 |
\railalias{splitformat}{split\_format} |
16 |
\railterm{splitformat} |
|
17 |
\railterm{complete} |
|
18 |
||
9905 | 19 |
\begin{rail} |
9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9935
diff
changeset
|
20 |
ruleformat ('(' noasm ')')? |
9905 | 21 |
; |
11039 | 22 |
splitformat (((name * ) + 'and') | ('(' complete ')')) |
23 |
; |
|
9905 | 24 |
\end{rail} |
25 |
||
7990 | 26 |
\begin{descr} |
9848 | 27 |
|
9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9935
diff
changeset
|
28 |
\item [$rule_format$] causes a theorem to be put into standard object-rule |
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9935
diff
changeset
|
29 |
form, replacing implication and (bounded) universal quantification of HOL by |
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9935
diff
changeset
|
30 |
the corresponding meta-logical connectives. By default, the result is fully |
9905 | 31 |
normalized, including assumptions and conclusions at any depth. The |
32 |
$no_asm$ option restricts the transformation to the conclusion of a rule. |
|
11039 | 33 |
|
34 |
\item [$split_format~\vec p@1 \dots \vec p@n$] puts tuple objects into |
|
35 |
canonical form as specified by the arguments given; $\vec p@i$ refers to |
|
11051 | 36 |
occurrences in premise $i$ of the rule. The $split_format~(complete)$ form |
37 |
causes \emph{all} arguments in function applications to be represented |
|
38 |
canonically according to their tuple type structure. |
|
11039 | 39 |
|
11051 | 40 |
Note that these operations tend to invent funny names for new local |
41 |
parameters to be introduced. |
|
11039 | 42 |
|
7990 | 43 |
\end{descr} |
44 |
||
45 |
||
7135 | 46 |
\section{Primitive types} |
47 |
||
7141 | 48 |
\indexisarcmd{typedecl}\indexisarcmd{typedef} |
49 |
\begin{matharray}{rcl} |
|
50 |
\isarcmd{typedecl} & : & \isartrans{theory}{theory} \\ |
|
51 |
\isarcmd{typedef} & : & \isartrans{theory}{proof(prove)} \\ |
|
52 |
\end{matharray} |
|
53 |
||
54 |
\begin{rail} |
|
55 |
'typedecl' typespec infix? comment? |
|
56 |
; |
|
57 |
'typedef' parname? typespec infix? \\ '=' term comment? |
|
58 |
; |
|
59 |
\end{rail} |
|
60 |
||
7167 | 61 |
\begin{descr} |
7141 | 62 |
\item [$\isarkeyword{typedecl}~(\vec\alpha)t$] is similar to the original |
63 |
$\isarkeyword{typedecl}$ of Isabelle/Pure (see \S\ref{sec:types-pure}), but |
|
64 |
also declares type arity $t :: (term, \dots, term) term$, making $t$ an |
|
65 |
actual HOL type constructor. |
|
66 |
\item [$\isarkeyword{typedef}~(\vec\alpha)t = A$] sets up a goal stating |
|
67 |
non-emptiness of the set $A$. After finishing the proof, the theory will be |
|
7175 | 68 |
augmented by a Gordon/HOL-style type definition. See \cite{isabelle-HOL} |
7335 | 69 |
for more information. Note that user-level theories usually do not directly |
70 |
refer to the HOL $\isarkeyword{typedef}$ primitive, but use more advanced |
|
71 |
packages such as $\isarkeyword{record}$ (see \S\ref{sec:record}) and |
|
7175 | 72 |
$\isarkeyword{datatype}$ (see \S\ref{sec:datatype}). |
7167 | 73 |
\end{descr} |
7141 | 74 |
|
75 |
||
76 |
\section{Records}\label{sec:record} |
|
77 |
||
78 |
\indexisarcmd{record} |
|
79 |
\begin{matharray}{rcl} |
|
80 |
\isarcmd{record} & : & \isartrans{theory}{theory} \\ |
|
81 |
\end{matharray} |
|
82 |
||
83 |
\begin{rail} |
|
84 |
'record' typespec '=' (type '+')? (field +) |
|
85 |
; |
|
7135 | 86 |
|
7141 | 87 |
field: name '::' type comment? |
88 |
; |
|
89 |
\end{rail} |
|
90 |
||
7167 | 91 |
\begin{descr} |
7141 | 92 |
\item [$\isarkeyword{record}~(\vec\alpha)t = \tau + \vec c :: \vec\sigma$] |
93 |
defines extensible record type $(\vec\alpha)t$, derived from the optional |
|
94 |
parent record $\tau$ by adding new field components $\vec c :: \vec\sigma$. |
|
11498 | 95 |
See \cite{isabelle-HOL,NaraschewskiW-TPHOLs98} for more information on |
7335 | 96 |
simply-typed extensible records. |
7167 | 97 |
\end{descr} |
7141 | 98 |
|
99 |
||
100 |
\section{Datatypes}\label{sec:datatype} |
|
101 |
||
7167 | 102 |
\indexisarcmd{datatype}\indexisarcmd{rep-datatype} |
7141 | 103 |
\begin{matharray}{rcl} |
104 |
\isarcmd{datatype} & : & \isartrans{theory}{theory} \\ |
|
105 |
\isarcmd{rep_datatype} & : & \isartrans{theory}{theory} \\ |
|
106 |
\end{matharray} |
|
107 |
||
108 |
\railalias{repdatatype}{rep\_datatype} |
|
109 |
\railterm{repdatatype} |
|
110 |
||
111 |
\begin{rail} |
|
9848 | 112 |
'datatype' (dtspec + 'and') |
7141 | 113 |
; |
9848 | 114 |
repdatatype (name * ) dtrules |
7141 | 115 |
; |
116 |
||
9848 | 117 |
dtspec: parname? typespec infix? '=' (cons + '|') |
7141 | 118 |
; |
9848 | 119 |
cons: name (type * ) mixfix? comment? |
120 |
; |
|
121 |
dtrules: 'distinct' thmrefs 'inject' thmrefs 'induction' thmrefs |
|
7141 | 122 |
\end{rail} |
123 |
||
7167 | 124 |
\begin{descr} |
7319 | 125 |
\item [$\isarkeyword{datatype}$] defines inductive datatypes in HOL. |
126 |
\item [$\isarkeyword{rep_datatype}$] represents existing types as inductive |
|
127 |
ones, generating the standard infrastructure of derived concepts (primitive |
|
128 |
recursion etc.). |
|
7167 | 129 |
\end{descr} |
7141 | 130 |
|
8449 | 131 |
The induction and exhaustion theorems generated provide case names according |
132 |
to the constructors involved, while parameters are named after the types (see |
|
133 |
also \S\ref{sec:induct-method}). |
|
134 |
||
7319 | 135 |
See \cite{isabelle-HOL} for more details on datatypes. Note that the theory |
7335 | 136 |
syntax above has been slightly simplified over the old version, usually |
8531 | 137 |
requiring more quotes and less parentheses. Apart from proper proof methods |
138 |
for case-analysis and induction, there are also emulations of ML tactics |
|
8945 | 139 |
\texttt{case_tac} and \texttt{induct_tac} available, see |
8665 | 140 |
\S\ref{sec:induct_tac}. |
7319 | 141 |
|
7135 | 142 |
|
143 |
\section{Recursive functions} |
|
144 |
||
10771 | 145 |
\indexisarcmd{primrec}\indexisarcmd{recdef}\indexisarcmd{recdef-tc} |
7141 | 146 |
\begin{matharray}{rcl} |
147 |
\isarcmd{primrec} & : & \isartrans{theory}{theory} \\ |
|
148 |
\isarcmd{recdef} & : & \isartrans{theory}{theory} \\ |
|
10771 | 149 |
\isarcmd{recdef_tc}^* & : & \isartrans{theory}{proof(prove)} \\ |
7141 | 150 |
%FIXME |
151 |
% \isarcmd{defer_recdef} & : & \isartrans{theory}{theory} \\ |
|
152 |
\end{matharray} |
|
153 |
||
9949 | 154 |
\railalias{recdefsimp}{recdef\_simp} |
155 |
\railterm{recdefsimp} |
|
156 |
||
157 |
\railalias{recdefcong}{recdef\_cong} |
|
158 |
\railterm{recdefcong} |
|
159 |
||
160 |
\railalias{recdefwf}{recdef\_wf} |
|
161 |
\railterm{recdefwf} |
|
162 |
||
10771 | 163 |
\railalias{recdeftc}{recdef\_tc} |
164 |
\railterm{recdeftc} |
|
165 |
||
7141 | 166 |
\begin{rail} |
8657 | 167 |
'primrec' parname? (equation + ) |
168 |
; |
|
11634 | 169 |
'recdef' ('(' 'permissive' ')')? \\ name term (eqn + ) hints? |
9848 | 170 |
; |
10771 | 171 |
recdeftc thmdecl? tc comment? |
172 |
; |
|
8657 | 173 |
|
9848 | 174 |
equation: thmdecl? eqn |
175 |
; |
|
176 |
eqn: prop comment? |
|
8657 | 177 |
; |
9848 | 178 |
hints: '(' 'hints' (recdefmod * ) ')' |
179 |
; |
|
9949 | 180 |
recdefmod: ((recdefsimp | recdefcong | recdefwf) (() | 'add' | 'del') ':' thmrefs) | clasimpmod |
7141 | 181 |
; |
10771 | 182 |
tc: nameref ('(' nat ')')? |
183 |
; |
|
7141 | 184 |
\end{rail} |
185 |
||
7167 | 186 |
\begin{descr} |
7319 | 187 |
\item [$\isarkeyword{primrec}$] defines primitive recursive functions over |
9848 | 188 |
datatypes, see also \cite{isabelle-HOL}. |
7319 | 189 |
\item [$\isarkeyword{recdef}$] defines general well-founded recursive |
9848 | 190 |
functions (using the TFL package), see also \cite{isabelle-HOL}. The |
11634 | 191 |
$(permissive)$ option tells TFL to recover from failed proof attempts, |
192 |
returning unfinished results. The $recdef_simp$, $recdef_cong$, and |
|
193 |
$recdef_wf$ hints refer to auxiliary rules to be used in the internal |
|
194 |
automated proof process of TFL. Additional $clasimpmod$ declarations (cf.\ |
|
195 |
\S\ref{sec:clasimp}) may be given to tune the context of the Simplifier |
|
196 |
(cf.\ \S\ref{sec:simplifier}) and Classical reasoner (cf.\ |
|
197 |
\S\ref{sec:classical}). |
|
10771 | 198 |
\item [$\isarkeyword{recdef_tc}~c~(i)$] recommences the proof for leftover |
199 |
termination condition number $i$ (default $1$) as generated by a |
|
200 |
$\isarkeyword{recdef}$ definition of constant $c$. |
|
201 |
||
202 |
Note that in most cases, $\isarkeyword{recdef}$ is able to finish its |
|
203 |
internal proofs without manual intervention. |
|
7167 | 204 |
\end{descr} |
7141 | 205 |
|
9848 | 206 |
Both kinds of recursive definitions accommodate reasoning by induction (cf.\ |
8449 | 207 |
\S\ref{sec:induct-method}): rule $c\mathord{.}induct$ (where $c$ is the name |
208 |
of the function definition) refers to a specific induction rule, with |
|
209 |
parameters named according to the user-specified equations. Case names of |
|
210 |
$\isarkeyword{primrec}$ are that of the datatypes involved, while those of |
|
211 |
$\isarkeyword{recdef}$ are numbered (starting from $1$). |
|
212 |
||
8657 | 213 |
The equations provided by these packages may be referred later as theorem list |
214 |
$f\mathord.simps$, where $f$ is the (collective) name of the functions |
|
215 |
defined. Individual equations may be named explicitly as well; note that for |
|
216 |
$\isarkeyword{recdef}$ each specification given by the user may result in |
|
217 |
several theorems. |
|
218 |
||
9935 | 219 |
\medskip Hints for $\isarkeyword{recdef}$ may be also declared globally, using |
220 |
the following attributes. |
|
221 |
||
222 |
\indexisaratt{recdef-simp}\indexisaratt{recdef-cong}\indexisaratt{recdef-wf} |
|
223 |
\begin{matharray}{rcl} |
|
224 |
recdef_simp & : & \isaratt \\ |
|
225 |
recdef_cong & : & \isaratt \\ |
|
226 |
recdef_wf & : & \isaratt \\ |
|
227 |
\end{matharray} |
|
228 |
||
229 |
\railalias{recdefsimp}{recdef\_simp} |
|
230 |
\railterm{recdefsimp} |
|
231 |
||
232 |
\railalias{recdefcong}{recdef\_cong} |
|
233 |
\railterm{recdefcong} |
|
234 |
||
235 |
\railalias{recdefwf}{recdef\_wf} |
|
236 |
\railterm{recdefwf} |
|
237 |
||
238 |
\begin{rail} |
|
239 |
(recdefsimp | recdefcong | recdefwf) (() | 'add' | 'del') |
|
240 |
; |
|
241 |
\end{rail} |
|
242 |
||
7141 | 243 |
|
10549
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
244 |
\section{(Co)Inductive sets}\label{sec:inductive} |
7135 | 245 |
|
9602 | 246 |
\indexisarcmd{inductive}\indexisarcmd{coinductive}\indexisaratt{mono} |
7141 | 247 |
\begin{matharray}{rcl} |
248 |
\isarcmd{inductive} & : & \isartrans{theory}{theory} \\ |
|
9848 | 249 |
\isarcmd{coinductive} & : & \isartrans{theory}{theory} \\ |
7990 | 250 |
mono & : & \isaratt \\ |
7141 | 251 |
\end{matharray} |
252 |
||
253 |
\railalias{condefs}{con\_defs} |
|
9602 | 254 |
\railterm{condefs} |
7141 | 255 |
|
256 |
\begin{rail} |
|
9848 | 257 |
('inductive' | 'coinductive') sets intros monos? |
7141 | 258 |
; |
7990 | 259 |
'mono' (() | 'add' | 'del') |
260 |
; |
|
9848 | 261 |
|
262 |
sets: (term comment? +) |
|
263 |
; |
|
11634 | 264 |
intros: 'intros' (thmdecl? prop comment? +) |
9848 | 265 |
; |
266 |
monos: 'monos' thmrefs comment? |
|
267 |
; |
|
7141 | 268 |
\end{rail} |
269 |
||
7167 | 270 |
\begin{descr} |
7319 | 271 |
\item [$\isarkeyword{inductive}$ and $\isarkeyword{coinductive}$] define |
272 |
(co)inductive sets from the given introduction rules. |
|
8547 | 273 |
\item [$mono$] declares monotonicity rules. These rule are involved in the |
274 |
automated monotonicity proof of $\isarkeyword{inductive}$. |
|
7167 | 275 |
\end{descr} |
7141 | 276 |
|
8449 | 277 |
See \cite{isabelle-HOL} for further information on inductive definitions in |
278 |
HOL. |
|
7319 | 279 |
|
7141 | 280 |
|
8449 | 281 |
\section{Proof by cases and induction}\label{sec:induct-method} |
282 |
||
8666 | 283 |
\subsection{Proof methods}\label{sec:induct-method-proper} |
7141 | 284 |
|
8449 | 285 |
\indexisarmeth{cases}\indexisarmeth{induct} |
7319 | 286 |
\begin{matharray}{rcl} |
8449 | 287 |
cases & : & \isarmeth \\ |
7319 | 288 |
induct & : & \isarmeth \\ |
289 |
\end{matharray} |
|
290 |
||
8449 | 291 |
The $cases$ and $induct$ methods provide a uniform interface to case analysis |
292 |
and induction over datatypes, inductive sets, and recursive functions. The |
|
293 |
corresponding rules may be specified and instantiated in a casual manner. |
|
294 |
Furthermore, these methods provide named local contexts that may be invoked |
|
295 |
via the $\CASENAME$ proof command within the subsequent proof text (cf.\ |
|
8484 | 296 |
\S\ref{sec:cases}). This accommodates compact proof texts even when reasoning |
297 |
about large specifications. |
|
7319 | 298 |
|
299 |
\begin{rail} |
|
10802
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
300 |
'cases' ('(' 'simplified' ')')? spec |
9848 | 301 |
; |
10802
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
302 |
'induct' ('(' 'stripped' ')')? spec |
7319 | 303 |
; |
304 |
||
10802
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
305 |
spec: open? args rule? params? |
9848 | 306 |
; |
307 |
open: '(' 'open' ')' |
|
308 |
; |
|
309 |
args: (insts * 'and') |
|
310 |
; |
|
8449 | 311 |
rule: ('type' | 'set') ':' nameref | 'rule' ':' thmref |
7319 | 312 |
; |
10802
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
313 |
params: 'of' ':' insts |
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
314 |
; |
7319 | 315 |
\end{rail} |
316 |
||
317 |
\begin{descr} |
|
10802
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
318 |
\item [$cases~insts~R~ps$] applies method $rule$ with an appropriate case |
9602 | 319 |
distinction theorem, instantiated to the subjects $insts$. Symbolic case |
320 |
names are bound according to the rule's local contexts. |
|
8449 | 321 |
|
322 |
The rule is determined as follows, according to the facts and arguments |
|
323 |
passed to the $cases$ method: |
|
324 |
\begin{matharray}{llll} |
|
9695 | 325 |
\Text{facts} & & \Text{arguments} & \Text{rule} \\\hline |
326 |
& cases & & \Text{classical case split} \\ |
|
327 |
& cases & t & \Text{datatype exhaustion (type of $t$)} \\ |
|
328 |
\edrv a \in A & cases & \dots & \Text{inductive set elimination (of $A$)} \\ |
|
329 |
\dots & cases & \dots ~ R & \Text{explicit rule $R$} \\ |
|
8449 | 330 |
\end{matharray} |
9602 | 331 |
|
332 |
Several instantiations may be given, referring to the \emph{suffix} of |
|
333 |
premises of the case rule; within each premise, the \emph{prefix} of |
|
334 |
variables is instantiated. In most situations, only a single term needs to |
|
335 |
be specified; this refers to the first variable of the last premise (it is |
|
336 |
usually the same for all cases). |
|
10802
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
337 |
|
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
338 |
Additional parameters may be specified as $ps$; these are applied after the |
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
339 |
primary instantiation in the same manner as by the $of$ attribute (cf.\ |
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
340 |
\S\ref{sec:pure-meth-att}). This feature is rarely needed in practice; a |
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
341 |
typical application would be to specify additional arguments for rules |
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
342 |
stemming from parameterized inductive definitions (see also |
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
343 |
\S\ref{sec:inductive}). |
8449 | 344 |
|
345 |
The $simplified$ option causes ``obvious cases'' of the rule to be solved |
|
346 |
beforehand, while the others are left unscathed. |
|
347 |
||
9616
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
348 |
The $open$ option causes the parameters of the new local contexts to be |
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
349 |
exposed to the current proof context. Thus local variables stemming from |
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
350 |
distant parts of the theory development may be introduced in an implicit |
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
351 |
manner, which can be quite confusing to the reader. Furthermore, this |
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
352 |
option may cause unwanted hiding of existing local variables, resulting in |
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
353 |
less robust proof texts. |
10802
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
354 |
|
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
355 |
\item [$induct~insts~R~ps$] is analogous to the $cases$ method, but refers to |
8449 | 356 |
induction rules, which are determined as follows: |
357 |
\begin{matharray}{llll} |
|
9695 | 358 |
\Text{facts} & & \Text{arguments} & \Text{rule} \\\hline |
359 |
& induct & P ~ x ~ \dots & \Text{datatype induction (type of $x$)} \\ |
|
360 |
\edrv x \in A & induct & \dots & \Text{set induction (of $A$)} \\ |
|
361 |
\dots & induct & \dots ~ R & \Text{explicit rule $R$} \\ |
|
8449 | 362 |
\end{matharray} |
363 |
||
364 |
Several instantiations may be given, each referring to some part of a mutual |
|
365 |
inductive definition or datatype --- only related partial induction rules |
|
366 |
may be used together, though. Any of the lists of terms $P, x, \dots$ |
|
367 |
refers to the \emph{suffix} of variables present in the induction rule. |
|
368 |
This enables the writer to specify only induction variables, or both |
|
369 |
predicates and variables, for example. |
|
7507 | 370 |
|
10802
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
371 |
Additional parameters may be given in the same way as for $cases$. |
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
372 |
|
8449 | 373 |
The $stripped$ option causes implications and (bounded) universal |
374 |
quantifiers to be removed from each new subgoal emerging from the |
|
10456 | 375 |
application of the induction rule. This accommodates special applications |
376 |
of ``strengthened induction predicates''. This option is rarely needed, the |
|
377 |
$induct$ method already handles proper rules appropriately by default. |
|
9307 | 378 |
|
9616
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
379 |
The $open$ option has the same effect as for the $cases$ method, see above. |
7319 | 380 |
\end{descr} |
7141 | 381 |
|
8484 | 382 |
Above methods produce named local contexts (cf.\ \S\ref{sec:cases}), as |
383 |
determined by the instantiated rule \emph{before} it has been applied to the |
|
384 |
internal proof state.\footnote{As a general principle, Isar proof text may |
|
8449 | 385 |
never refer to parts of proof states directly.} Thus proper use of symbolic |
386 |
cases usually require the rule to be instantiated fully, as far as the |
|
387 |
emerging local contexts and subgoals are concerned. In particular, for |
|
388 |
induction both the predicates and variables have to be specified. Otherwise |
|
8547 | 389 |
the $\CASENAME$ command would refuse to invoke cases containing schematic |
10802
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
390 |
variables. Furthermore the resulting local goal statement is bound to the |
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
391 |
term variable $\Var{case}$\indexisarvar{case} --- for each case where it is |
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
392 |
fully specified. |
8449 | 393 |
|
9602 | 394 |
The $\isarkeyword{print_cases}$ command (\S\ref{sec:cases}) prints all named |
8547 | 395 |
cases present in the current proof state. |
8449 | 396 |
|
10456 | 397 |
\medskip |
398 |
||
399 |
It is important to note that there is a fundamental difference of the $cases$ |
|
400 |
and $induct$ methods in handling of non-atomic goal statements: $cases$ just |
|
401 |
applies a certain rule in backward fashion, splitting the result into new |
|
402 |
goals with the local contexts being augmented in a purely monotonic manner. |
|
403 |
||
404 |
In contrast, $induct$ passes the full goal statement through the ``recursive'' |
|
405 |
course involved in the induction. Thus the original statement is basically |
|
406 |
replaced by separate copies, corresponding to the induction hypotheses and |
|
407 |
conclusion; the original goal context is no longer available. This behavior |
|
408 |
allows \emph{strengthened induction predicates} to be expressed concisely as |
|
409 |
meta-level rule statements, i.e.\ $\All{\vec x} \vec\phi \Imp \psi$ to |
|
410 |
indicate ``variable'' parameters $\vec x$ and ``recursive'' assumptions |
|
411 |
$\vec\phi$. Also note that local definitions may be expressed as $\All{\vec |
|
412 |
x} n \equiv t[\vec x] \Imp \phi[n]$, with induction over $n$. |
|
413 |
||
10549
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
414 |
\medskip |
8449 | 415 |
|
10549
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
416 |
Facts presented to either method are consumed according to the number of |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
417 |
``major premises'' of the rule involved (see also \S\ref{sec:induct-att} and |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
418 |
\S\ref{sec:cases}), which is usually $0$ for plain cases and induction rules |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
419 |
of datatypes etc.\ and $1$ for rules of inductive sets and the like. The |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
420 |
remaining facts are inserted into the goal verbatim before the actual $cases$ |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
421 |
or $induct$ rule is applied (thus facts may be even passed through an |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
422 |
induction). |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
423 |
|
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
424 |
Note that whenever facts are present, the default rule selection scheme would |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
425 |
provide a ``set'' rule only, with the first fact consumed and the rest |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
426 |
inserted into the goal. In order to pass all facts into a ``type'' rule |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
427 |
instead, one would have to specify this explicitly, e.g.\ by appending |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
428 |
``$type: name$'' to the method argument. |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
429 |
|
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
430 |
|
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
431 |
\subsection{Declaring rules}\label{sec:induct-att} |
8449 | 432 |
|
433 |
\indexisaratt{cases}\indexisaratt{induct} |
|
434 |
\begin{matharray}{rcl} |
|
435 |
cases & : & \isaratt \\ |
|
436 |
induct & : & \isaratt \\ |
|
437 |
\end{matharray} |
|
438 |
||
439 |
\begin{rail} |
|
440 |
'cases' spec |
|
441 |
; |
|
442 |
'induct' spec |
|
443 |
; |
|
444 |
||
445 |
spec: ('type' | 'set') ':' nameref |
|
446 |
; |
|
447 |
\end{rail} |
|
448 |
||
449 |
The $cases$ and $induct$ attributes augment the corresponding context of rules |
|
450 |
for reasoning about inductive sets and types. The standard rules are already |
|
451 |
declared by HOL definitional packages. For special applications, these may be |
|
452 |
replaced manually by variant versions. |
|
453 |
||
10802
7fa042e28c43
'cases' / 'induct' method: ?case binding, 'of:' spec;
wenzelm
parents:
10771
diff
changeset
|
454 |
Refer to the $case_names$ and $ps$ attributes (see \S\ref{sec:cases}) to |
8484 | 455 |
adjust names of cases and parameters of a rule. |
456 |
||
10549
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
457 |
The $consumes$ declaration (cf.\ \S\ref{sec:cases}) is taken care of |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
458 |
automatically (if none had been given already): $consumes~0$ is specified for |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
459 |
``type'' rules and $consumes~1$ for ``set'' rules. |
5e19ae8d9582
cases/induct: tuned handling of facts ('consumes');
wenzelm
parents:
10456
diff
changeset
|
460 |
|
7046 | 461 |
|
8665 | 462 |
\subsection{Emulating tactic scripts}\label{sec:induct_tac} |
463 |
||
464 |
\indexisarmeth{case-tac}\indexisarmeth{induct-tac} |
|
9616
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
465 |
\indexisarmeth{ind-cases}\indexisarcmd{inductive-cases} |
8665 | 466 |
\begin{matharray}{rcl} |
9616
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
467 |
case_tac^* & : & \isarmeth \\ |
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
468 |
induct_tac^* & : & \isarmeth \\ |
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
469 |
ind_cases^* & : & \isarmeth \\ |
9602 | 470 |
\isarcmd{inductive_cases} & : & \isartrans{theory}{theory} \\ |
8665 | 471 |
\end{matharray} |
472 |
||
473 |
\railalias{casetac}{case\_tac} |
|
474 |
\railterm{casetac} |
|
9602 | 475 |
|
8665 | 476 |
\railalias{inducttac}{induct\_tac} |
477 |
\railterm{inducttac} |
|
478 |
||
9616
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
479 |
\railalias{indcases}{ind\_cases} |
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
480 |
\railterm{indcases} |
9602 | 481 |
|
9616
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
482 |
\railalias{inductivecases}{inductive\_cases} |
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
483 |
\railterm{inductivecases} |
9602 | 484 |
|
8665 | 485 |
\begin{rail} |
8666 | 486 |
casetac goalspec? term rule? |
8665 | 487 |
; |
8692 | 488 |
inducttac goalspec? (insts * 'and') rule? |
8666 | 489 |
; |
9616
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
490 |
indcases (prop +) |
9602 | 491 |
; |
9616
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
492 |
inductivecases thmdecl? (prop +) comment? |
9602 | 493 |
; |
8666 | 494 |
|
495 |
rule: ('rule' ':' thmref) |
|
8665 | 496 |
; |
497 |
\end{rail} |
|
498 |
||
9602 | 499 |
\begin{descr} |
500 |
\item [$case_tac$ and $induct_tac$] admit to reason about inductive datatypes |
|
501 |
only (unless an alternative rule is given explicitly). Furthermore, |
|
502 |
$case_tac$ does a classical case split on booleans; $induct_tac$ allows only |
|
503 |
variables to be given as instantiation. These tactic emulations feature |
|
504 |
both goal addressing and dynamic instantiation. Note that named local |
|
505 |
contexts (see \S\ref{sec:cases}) are \emph{not} provided as would be by the |
|
506 |
proper $induct$ and $cases$ proof methods (see |
|
507 |
\S\ref{sec:induct-method-proper}). |
|
508 |
||
9616
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
509 |
\item [$ind_cases$ and $\isarkeyword{inductive_cases}$] provide an interface |
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
510 |
to the \texttt{mk_cases} operation. Rules are simplified in an unrestricted |
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
511 |
forward manner, unlike the proper $cases$ method (see |
9602 | 512 |
\S\ref{sec:induct-method-proper}) which requires simplified cases to be |
513 |
solved completely. |
|
514 |
||
9616
b80ea2b32f8e
cases/induct method: 'opaque' by default; added 'open' option;
wenzelm
parents:
9602
diff
changeset
|
515 |
While $ind_cases$ is a proof method to apply the result immediately as |
9602 | 516 |
elimination rules, $\isarkeyword{inductive_cases}$ provides case split |
517 |
theorems at the theory level for later use, |
|
518 |
\end{descr} |
|
8665 | 519 |
|
520 |
||
7390 | 521 |
\section{Arithmetic} |
522 |
||
9642 | 523 |
\indexisarmeth{arith}\indexisaratt{arith-split} |
7390 | 524 |
\begin{matharray}{rcl} |
525 |
arith & : & \isarmeth \\ |
|
9602 | 526 |
arith_split & : & \isaratt \\ |
7390 | 527 |
\end{matharray} |
528 |
||
8506 | 529 |
\begin{rail} |
530 |
'arith' '!'? |
|
531 |
; |
|
532 |
\end{rail} |
|
533 |
||
7390 | 534 |
The $arith$ method decides linear arithmetic problems (on types $nat$, $int$, |
8506 | 535 |
$real$). Any current facts are inserted into the goal before running the |
536 |
procedure. The ``!''~argument causes the full context of assumptions to be |
|
9602 | 537 |
included. The $arith_split$ attribute declares case split rules to be |
538 |
expanded before the arithmetic procedure is invoked. |
|
8506 | 539 |
|
540 |
Note that a simpler (but faster) version of arithmetic reasoning is already |
|
541 |
performed by the Simplifier. |
|
7390 | 542 |
|
543 |
||
7046 | 544 |
%%% Local Variables: |
545 |
%%% mode: latex |
|
546 |
%%% TeX-master: "isar-ref" |
|
547 |
%%% End: |