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