author | wenzelm |
Thu, 03 Jan 2002 17:48:02 +0100 | |
changeset 12621 | 48cafea0684b |
parent 12618 | 43a97a2155d0 |
child 12879 | 8e1cae1de136 |
permissions | -rw-r--r-- |
7135 | 1 |
|
7167 | 2 |
\chapter{Generic Tools and Packages}\label{ch:gen-tools} |
3 |
||
12621 | 4 |
\section{Theory specification commands} |
12618 | 5 |
|
6 |
\subsection{Axiomatic type classes}\label{sec:axclass} |
|
7167 | 7 |
|
8904 | 8 |
%FIXME |
9 |
% - qualified names |
|
10 |
% - class intro rules; |
|
11 |
% - class axioms; |
|
12 |
||
8517 | 13 |
\indexisarcmd{axclass}\indexisarcmd{instance}\indexisarmeth{intro-classes} |
7167 | 14 |
\begin{matharray}{rcl} |
8517 | 15 |
\isarcmd{axclass} & : & \isartrans{theory}{theory} \\ |
16 |
\isarcmd{instance} & : & \isartrans{theory}{proof(prove)} \\ |
|
17 |
intro_classes & : & \isarmeth \\ |
|
7167 | 18 |
\end{matharray} |
19 |
||
8517 | 20 |
Axiomatic type classes are provided by Isabelle/Pure as a \emph{definitional} |
21 |
interface to type classes (cf.~\S\ref{sec:classes}). Thus any object logic |
|
8547 | 22 |
may make use of this light-weight mechanism of abstract theories |
8901 | 23 |
\cite{Wenzel:1997:TPHOL}. There is also a tutorial on using axiomatic type |
24 |
classes in isabelle \cite{isabelle-axclass} that is part of the standard |
|
25 |
Isabelle documentation. |
|
8517 | 26 |
|
7167 | 27 |
\begin{rail} |
8517 | 28 |
'axclass' classdecl (axmdecl prop comment? +) |
29 |
; |
|
11100
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11095
diff
changeset
|
30 |
'instance' (nameref ('<' | subseteq) nameref | nameref '::' simplearity) comment? |
7167 | 31 |
; |
32 |
\end{rail} |
|
33 |
||
34 |
\begin{descr} |
|
11100
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11095
diff
changeset
|
35 |
\item [$\AXCLASS~c \subseteq \vec c~axms$] defines an axiomatic type class as |
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11095
diff
changeset
|
36 |
the intersection of existing classes, with additional axioms holding. Class |
10223 | 37 |
axioms may not contain more than one type variable. The class axioms (with |
38 |
implicit sort constraints added) are bound to the given names. Furthermore |
|
39 |
a class introduction rule is generated, which is employed by method |
|
40 |
$intro_classes$ to support instantiation proofs of this class. |
|
41 |
||
11100
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11095
diff
changeset
|
42 |
\item [$\INSTANCE~c@1 \subseteq c@2$ and $\INSTANCE~t :: (\vec s)c$] setup a |
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11095
diff
changeset
|
43 |
goal stating a class relation or type arity. The proof would usually |
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11095
diff
changeset
|
44 |
proceed by $intro_classes$, and then establish the characteristic theorems |
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11095
diff
changeset
|
45 |
of the type classes involved. After finishing the proof, the theory will be |
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11095
diff
changeset
|
46 |
augmented by a type signature declaration corresponding to the resulting |
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11095
diff
changeset
|
47 |
theorem. |
8517 | 48 |
\item [$intro_classes$] repeatedly expands all class introduction rules of |
10858 | 49 |
this theory. Note that this method usually needs not be named explicitly, |
50 |
as it is already included in the default proof step (of $\PROOFNAME$, |
|
51 |
$\BYNAME$, etc.). In particular, instantiation of trivial (syntactic) |
|
52 |
classes may be performed by a single ``$\DDOT$'' proof step. |
|
7167 | 53 |
\end{descr} |
54 |
||
7315 | 55 |
|
12618 | 56 |
\subsection{Locales and local contexts}\label{sec:locale} |
57 |
||
58 |
FIXME |
|
59 |
||
12621 | 60 |
\indexouternonterm{contextelem} |
12618 | 61 |
|
12621 | 62 |
|
63 |
\section{Derived proof schemes} |
|
64 |
||
65 |
\subsection{Generalized elimination}\label{sec:obtain} |
|
66 |
||
67 |
\indexisarcmd{obtain} |
|
68 |
\begin{matharray}{rcl} |
|
69 |
\isarcmd{obtain} & : & \isartrans{proof(state)}{proof(prove)} \\ |
|
70 |
\end{matharray} |
|
71 |
||
72 |
Generalized elimination means that additional elements with certain properties |
|
73 |
may introduced in the current context, by virtue of a locally proven |
|
74 |
``soundness statement''. Technically speaking, the $\OBTAINNAME$ language |
|
75 |
element is like a declaration of $\FIXNAME$ and $\ASSUMENAME$ (see also see |
|
76 |
\S\ref{sec:proof-context}), together with a soundness proof of its additional |
|
77 |
claim. According to the nature of existential reasoning, assumptions get |
|
78 |
eliminated from any result exported from the context later, provided that the |
|
79 |
corresponding parameters do \emph{not} occur in the conclusion. |
|
80 |
||
81 |
\begin{rail} |
|
82 |
'obtain' (vars + 'and') comment? \\ 'where' (props comment? + 'and') |
|
83 |
; |
|
84 |
\end{rail} |
|
12618 | 85 |
|
12621 | 86 |
$\OBTAINNAME$ is defined as a derived Isar command as follows, where $\vec b$ |
87 |
shall refer to (optional) facts indicated for forward chaining. |
|
88 |
\begin{matharray}{l} |
|
89 |
\langle facts~\vec b\rangle \\ |
|
90 |
\OBTAIN{\vec x}{a}{\vec \phi}~~\langle proof\rangle \equiv {} \\[1ex] |
|
91 |
\quad \BG \\ |
|
92 |
\qquad \FIX{thesis} \\ |
|
93 |
\qquad \ASSUME{that~[simp, intro]}{\All{\vec x} \vec\phi \Imp thesis} \\ |
|
94 |
\qquad \FROM{\vec b}~\HAVE{}{thesis}~~\langle proof\rangle \\ |
|
95 |
\quad \EN \\ |
|
96 |
\quad \FIX{\vec x}~\ASSUMENAME^\ast~a\colon~\vec\phi \\ |
|
97 |
\end{matharray} |
|
98 |
||
99 |
Typically, the soundness proof is relatively straight-forward, often just by |
|
100 |
canonical automated tools such as $\BY{simp}$ (see \S\ref{sec:simp}) or |
|
101 |
$\BY{blast}$ (see \S\ref{sec:classical-auto}). Accordingly, the ``$that$'' |
|
102 |
reduction above is declared as simplification and introduction rule. |
|
103 |
||
104 |
\medskip |
|
105 |
||
106 |
In a sense, $\OBTAINNAME$ represents at the level of Isar proofs what would be |
|
107 |
meta-logical existential quantifiers and conjunctions. This concept has a |
|
108 |
broad range of useful applications, ranging from plain elimination (or even |
|
109 |
introduction) of object-level existentials and conjunctions, to elimination |
|
110 |
over results of symbolic evaluation of recursive definitions, for example. |
|
111 |
Also note that $\OBTAINNAME$ without parameters acts much like $\HAVENAME$, |
|
112 |
where the result is treated as an assumption. |
|
113 |
||
114 |
||
115 |
\subsection{Calculational reasoning}\label{sec:calculation} |
|
7315 | 116 |
|
8619 | 117 |
\indexisarcmd{also}\indexisarcmd{finally} |
118 |
\indexisarcmd{moreover}\indexisarcmd{ultimately} |
|
9606 | 119 |
\indexisarcmd{print-trans-rules}\indexisaratt{trans} |
7315 | 120 |
\begin{matharray}{rcl} |
121 |
\isarcmd{also} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
122 |
\isarcmd{finally} & : & \isartrans{proof(state)}{proof(chain)} \\ |
|
8619 | 123 |
\isarcmd{moreover} & : & \isartrans{proof(state)}{proof(state)} \\ |
124 |
\isarcmd{ultimately} & : & \isartrans{proof(state)}{proof(chain)} \\ |
|
10154 | 125 |
\isarcmd{print_trans_rules}^* & : & \isarkeep{theory~|~proof} \\ |
7315 | 126 |
trans & : & \isaratt \\ |
127 |
\end{matharray} |
|
128 |
||
129 |
Calculational proof is forward reasoning with implicit application of |
|
11332 | 130 |
transitivity rules (such those of $=$, $\leq$, $<$). Isabelle/Isar maintains |
7391 | 131 |
an auxiliary register $calculation$\indexisarthm{calculation} for accumulating |
7897 | 132 |
results obtained by transitivity composed with the current result. Command |
133 |
$\ALSO$ updates $calculation$ involving $this$, while $\FINALLY$ exhibits the |
|
134 |
final $calculation$ by forward chaining towards the next goal statement. Both |
|
135 |
commands require valid current facts, i.e.\ may occur only after commands that |
|
136 |
produce theorems such as $\ASSUMENAME$, $\NOTENAME$, or some finished proof of |
|
8619 | 137 |
$\HAVENAME$, $\SHOWNAME$ etc. The $\MOREOVER$ and $\ULTIMATELY$ commands are |
138 |
similar to $\ALSO$ and $\FINALLY$, but only collect further results in |
|
139 |
$calculation$ without applying any rules yet. |
|
7315 | 140 |
|
141 |
Also note that the automatic term abbreviation ``$\dots$'' has its canonical |
|
8619 | 142 |
application with calculational proofs. It refers to the argument\footnote{The |
143 |
argument of a curried infix expression is its right-hand side.} of the |
|
144 |
preceding statement. |
|
7315 | 145 |
|
146 |
Isabelle/Isar calculations are implicitly subject to block structure in the |
|
147 |
sense that new threads of calculational reasoning are commenced for any new |
|
148 |
block (as opened by a local goal, for example). This means that, apart from |
|
149 |
being able to nest calculations, there is no separate \emph{begin-calculation} |
|
150 |
command required. |
|
151 |
||
8619 | 152 |
\medskip |
153 |
||
154 |
The Isar calculation proof commands may be defined as |
|
155 |
follows:\footnote{Internal bookkeeping such as proper handling of |
|
156 |
block-structure has been suppressed.} |
|
157 |
\begin{matharray}{rcl} |
|
158 |
\ALSO@0 & \equiv & \NOTE{calculation}{this} \\ |
|
9606 | 159 |
\ALSO@{n+1} & \equiv & \NOTE{calculation}{trans~[OF~calculation~this]} \\[0.5ex] |
8619 | 160 |
\FINALLY & \equiv & \ALSO~\FROM{calculation} \\ |
161 |
\MOREOVER & \equiv & \NOTE{calculation}{calculation~this} \\ |
|
162 |
\ULTIMATELY & \equiv & \MOREOVER~\FROM{calculation} \\ |
|
163 |
\end{matharray} |
|
164 |
||
7315 | 165 |
\begin{rail} |
166 |
('also' | 'finally') transrules? comment? |
|
167 |
; |
|
8619 | 168 |
('moreover' | 'ultimately') comment? |
169 |
; |
|
8507 | 170 |
'trans' (() | 'add' | 'del') |
7315 | 171 |
; |
172 |
||
173 |
transrules: '(' thmrefs ')' interest? |
|
174 |
; |
|
175 |
\end{rail} |
|
176 |
||
177 |
\begin{descr} |
|
8547 | 178 |
\item [$\ALSO~(\vec a)$] maintains the auxiliary $calculation$ register as |
7315 | 179 |
follows. The first occurrence of $\ALSO$ in some calculational thread |
7905 | 180 |
initializes $calculation$ by $this$. Any subsequent $\ALSO$ on the same |
7335 | 181 |
level of block-structure updates $calculation$ by some transitivity rule |
7458 | 182 |
applied to $calculation$ and $this$ (in that order). Transitivity rules are |
11095 | 183 |
picked from the current context, unless alternative rules are given as |
184 |
explicit arguments. |
|
9614 | 185 |
|
8547 | 186 |
\item [$\FINALLY~(\vec a)$] maintaining $calculation$ in the same way as |
7315 | 187 |
$\ALSO$, and concludes the current calculational thread. The final result |
188 |
is exhibited as fact for forward chaining towards the next goal. Basically, |
|
7987 | 189 |
$\FINALLY$ just abbreviates $\ALSO~\FROM{calculation}$. Note that |
190 |
``$\FINALLY~\SHOW{}{\Var{thesis}}~\DOT$'' and |
|
191 |
``$\FINALLY~\HAVE{}{\phi}~\DOT$'' are typical idioms for concluding |
|
192 |
calculational proofs. |
|
9614 | 193 |
|
8619 | 194 |
\item [$\MOREOVER$ and $\ULTIMATELY$] are analogous to $\ALSO$ and $\FINALLY$, |
195 |
but collect results only, without applying rules. |
|
9614 | 196 |
|
9606 | 197 |
\item [$\isarkeyword{print_trans_rules}$] prints the list of transitivity |
198 |
rules declared in the current context. |
|
9614 | 199 |
|
8547 | 200 |
\item [$trans$] declares theorems as transitivity rules. |
9614 | 201 |
|
7315 | 202 |
\end{descr} |
203 |
||
204 |
||
12621 | 205 |
\section{Specific proof tools} |
8517 | 206 |
|
12618 | 207 |
\subsection{Miscellaneous methods and attributes}\label{sec:misc-meth-att} |
8517 | 208 |
|
9606 | 209 |
\indexisarmeth{unfold}\indexisarmeth{fold}\indexisarmeth{insert} |
8517 | 210 |
\indexisarmeth{erule}\indexisarmeth{drule}\indexisarmeth{frule} |
211 |
\indexisarmeth{fail}\indexisarmeth{succeed} |
|
212 |
\begin{matharray}{rcl} |
|
213 |
unfold & : & \isarmeth \\ |
|
10741 | 214 |
fold & : & \isarmeth \\ |
215 |
insert & : & \isarmeth \\[0.5ex] |
|
8517 | 216 |
erule^* & : & \isarmeth \\ |
217 |
drule^* & : & \isarmeth \\ |
|
218 |
frule^* & : & \isarmeth \\[0.5ex] |
|
219 |
succeed & : & \isarmeth \\ |
|
220 |
fail & : & \isarmeth \\ |
|
221 |
\end{matharray} |
|
7135 | 222 |
|
223 |
\begin{rail} |
|
10741 | 224 |
('fold' | 'unfold' | 'insert') thmrefs |
225 |
; |
|
226 |
('erule' | 'drule' | 'frule') ('('nat')')? thmrefs |
|
7135 | 227 |
; |
228 |
\end{rail} |
|
229 |
||
7167 | 230 |
\begin{descr} |
8547 | 231 |
\item [$unfold~\vec a$ and $fold~\vec a$] expand and fold back again the given |
8517 | 232 |
meta-level definitions throughout all goals; any facts provided are inserted |
233 |
into the goal and subject to rewriting as well. |
|
10741 | 234 |
\item [$insert~\vec a$] inserts theorems as facts into all goals of the proof |
235 |
state. Note that current facts indicated for forward chaining are ignored. |
|
8547 | 236 |
\item [$erule~\vec a$, $drule~\vec a$, and $frule~\vec a$] are similar to the |
237 |
basic $rule$ method (see \S\ref{sec:pure-meth-att}), but apply rules by |
|
8517 | 238 |
elim-resolution, destruct-resolution, and forward-resolution, respectively |
10741 | 239 |
\cite{isabelle-ref}. The optional natural number argument (default $0$) |
240 |
specifies additional assumption steps to be performed. |
|
241 |
||
242 |
Note that these methods are improper ones, mainly serving for |
|
243 |
experimentation and tactic script emulation. Different modes of basic rule |
|
244 |
application are usually expressed in Isar at the proof language level, |
|
245 |
rather than via implicit proof state manipulations. For example, a proper |
|
246 |
single-step elimination would be done using the basic $rule$ method, with |
|
247 |
forward chaining of current facts. |
|
8517 | 248 |
\item [$succeed$] yields a single (unchanged) result; it is the identity of |
249 |
the ``\texttt{,}'' method combinator (cf.\ \S\ref{sec:syn-meth}). |
|
250 |
\item [$fail$] yields an empty result sequence; it is the identity of the |
|
251 |
``\texttt{|}'' method combinator (cf.\ \S\ref{sec:syn-meth}). |
|
7167 | 252 |
\end{descr} |
7135 | 253 |
|
10318 | 254 |
\indexisaratt{tagged}\indexisaratt{untagged} |
9614 | 255 |
\indexisaratt{THEN}\indexisaratt{COMP} |
10318 | 256 |
\indexisaratt{where}\indexisaratt{unfolded}\indexisaratt{folded} |
257 |
\indexisaratt{standard}\indexisaratt{elim-format} |
|
258 |
\indexisaratt{no-vars}\indexisaratt{exported} |
|
8517 | 259 |
\begin{matharray}{rcl} |
9905 | 260 |
tagged & : & \isaratt \\ |
261 |
untagged & : & \isaratt \\[0.5ex] |
|
9614 | 262 |
THEN & : & \isaratt \\ |
8517 | 263 |
COMP & : & \isaratt \\[0.5ex] |
264 |
where & : & \isaratt \\[0.5ex] |
|
9905 | 265 |
unfolded & : & \isaratt \\ |
266 |
folded & : & \isaratt \\[0.5ex] |
|
8517 | 267 |
standard & : & \isaratt \\ |
9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9936
diff
changeset
|
268 |
elim_format & : & \isaratt \\ |
9936 | 269 |
no_vars^* & : & \isaratt \\ |
9905 | 270 |
exported^* & : & \isaratt \\ |
8517 | 271 |
\end{matharray} |
272 |
||
273 |
\begin{rail} |
|
9905 | 274 |
'tagged' (nameref+) |
8517 | 275 |
; |
9905 | 276 |
'untagged' name |
8517 | 277 |
; |
10154 | 278 |
('THEN' | 'COMP') ('[' nat ']')? thmref |
8517 | 279 |
; |
280 |
'where' (name '=' term * 'and') |
|
281 |
; |
|
9905 | 282 |
('unfolded' | 'folded') thmrefs |
8517 | 283 |
; |
284 |
\end{rail} |
|
285 |
||
286 |
\begin{descr} |
|
9905 | 287 |
\item [$tagged~name~args$ and $untagged~name$] add and remove $tags$ of some |
8517 | 288 |
theorem. Tags may be any list of strings that serve as comment for some |
289 |
tools (e.g.\ $\LEMMANAME$ causes the tag ``$lemma$'' to be added to the |
|
290 |
result). The first string is considered the tag name, the rest its |
|
291 |
arguments. Note that untag removes any tags of the same name. |
|
9614 | 292 |
\item [$THEN~n~a$ and $COMP~n~a$] compose rules. $THEN$ resolves with the |
293 |
$n$-th premise of $a$; the $COMP$ version skips the automatic lifting |
|
8547 | 294 |
process that is normally intended (cf.\ \texttt{RS} and \texttt{COMP} in |
295 |
\cite[\S5]{isabelle-ref}). |
|
8517 | 296 |
\item [$where~\vec x = \vec t$] perform named instantiation of schematic |
9606 | 297 |
variables occurring in a theorem. Unlike instantiation tactics such as |
298 |
$rule_tac$ (see \S\ref{sec:tactic-commands}), actual schematic variables |
|
8517 | 299 |
have to be specified (e.g.\ $\Var{x@3}$). |
9905 | 300 |
\item [$unfolded~\vec a$ and $folded~\vec a$] expand and fold back again the |
301 |
given meta-level definitions throughout a rule. |
|
8517 | 302 |
\item [$standard$] puts a theorem into the standard form of object-rules, just |
303 |
as the ML function \texttt{standard} (see \cite[\S5]{isabelle-ref}). |
|
9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9936
diff
changeset
|
304 |
\item [$elim_format$] turns a destruction rule into elimination rule format; |
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9936
diff
changeset
|
305 |
see also the ML function \texttt{make\_elim} (see \cite{isabelle-ref}). |
9232 | 306 |
\item [$no_vars$] replaces schematic variables by free ones; this is mainly |
307 |
for tuning output of pretty printed theorems. |
|
9905 | 308 |
\item [$exported$] lifts a local result out of the current proof context, |
8517 | 309 |
generalizing all fixed variables and discharging all assumptions. Note that |
8547 | 310 |
proper incremental export is already done as part of the basic Isar |
311 |
machinery. This attribute is mainly for experimentation. |
|
8517 | 312 |
\end{descr} |
7135 | 313 |
|
314 |
||
12621 | 315 |
\subsection{Further tactic emulations}\label{sec:tactics} |
9606 | 316 |
|
317 |
The following improper proof methods emulate traditional tactics. These admit |
|
318 |
direct access to the goal state, which is normally considered harmful! In |
|
319 |
particular, this may involve both numbered goal addressing (default 1), and |
|
320 |
dynamic instantiation within the scope of some subgoal. |
|
321 |
||
322 |
\begin{warn} |
|
323 |
Dynamic instantiations are read and type-checked according to a subgoal of |
|
324 |
the current dynamic goal state, rather than the static proof context! In |
|
325 |
particular, locally fixed variables and term abbreviations may not be |
|
326 |
included in the term specifications. Thus schematic variables are left to |
|
327 |
be solved by unification with certain parts of the subgoal involved. |
|
328 |
\end{warn} |
|
329 |
||
330 |
Note that the tactic emulation proof methods in Isabelle/Isar are consistently |
|
331 |
named $foo_tac$. |
|
332 |
||
333 |
\indexisarmeth{rule-tac}\indexisarmeth{erule-tac} |
|
334 |
\indexisarmeth{drule-tac}\indexisarmeth{frule-tac} |
|
335 |
\indexisarmeth{cut-tac}\indexisarmeth{thin-tac} |
|
9642 | 336 |
\indexisarmeth{subgoal-tac}\indexisarmeth{rename-tac} |
9614 | 337 |
\indexisarmeth{rotate-tac}\indexisarmeth{tactic} |
9606 | 338 |
\begin{matharray}{rcl} |
339 |
rule_tac^* & : & \isarmeth \\ |
|
340 |
erule_tac^* & : & \isarmeth \\ |
|
341 |
drule_tac^* & : & \isarmeth \\ |
|
342 |
frule_tac^* & : & \isarmeth \\ |
|
343 |
cut_tac^* & : & \isarmeth \\ |
|
344 |
thin_tac^* & : & \isarmeth \\ |
|
345 |
subgoal_tac^* & : & \isarmeth \\ |
|
9614 | 346 |
rename_tac^* & : & \isarmeth \\ |
347 |
rotate_tac^* & : & \isarmeth \\ |
|
9606 | 348 |
tactic^* & : & \isarmeth \\ |
349 |
\end{matharray} |
|
350 |
||
351 |
\railalias{ruletac}{rule\_tac} |
|
352 |
\railterm{ruletac} |
|
353 |
||
354 |
\railalias{eruletac}{erule\_tac} |
|
355 |
\railterm{eruletac} |
|
356 |
||
357 |
\railalias{druletac}{drule\_tac} |
|
358 |
\railterm{druletac} |
|
359 |
||
360 |
\railalias{fruletac}{frule\_tac} |
|
361 |
\railterm{fruletac} |
|
362 |
||
363 |
\railalias{cuttac}{cut\_tac} |
|
364 |
\railterm{cuttac} |
|
365 |
||
366 |
\railalias{thintac}{thin\_tac} |
|
367 |
\railterm{thintac} |
|
368 |
||
369 |
\railalias{subgoaltac}{subgoal\_tac} |
|
370 |
\railterm{subgoaltac} |
|
371 |
||
9614 | 372 |
\railalias{renametac}{rename\_tac} |
373 |
\railterm{renametac} |
|
374 |
||
375 |
\railalias{rotatetac}{rotate\_tac} |
|
376 |
\railterm{rotatetac} |
|
377 |
||
9606 | 378 |
\begin{rail} |
379 |
( ruletac | eruletac | druletac | fruletac | cuttac | thintac ) goalspec? |
|
380 |
( insts thmref | thmrefs ) |
|
381 |
; |
|
382 |
subgoaltac goalspec? (prop +) |
|
383 |
; |
|
9614 | 384 |
renametac goalspec? (name +) |
385 |
; |
|
386 |
rotatetac goalspec? int? |
|
387 |
; |
|
9606 | 388 |
'tactic' text |
389 |
; |
|
390 |
||
391 |
insts: ((name '=' term) + 'and') 'in' |
|
392 |
; |
|
393 |
\end{rail} |
|
394 |
||
395 |
\begin{descr} |
|
396 |
\item [$rule_tac$ etc.] do resolution of rules with explicit instantiation. |
|
397 |
This works the same way as the ML tactics \texttt{res_inst_tac} etc. (see |
|
398 |
\cite[\S3]{isabelle-ref}). |
|
9614 | 399 |
|
9606 | 400 |
Note that multiple rules may be only given there is no instantiation. Then |
401 |
$rule_tac$ is the same as \texttt{resolve_tac} in ML (see |
|
402 |
\cite[\S3]{isabelle-ref}). |
|
403 |
\item [$cut_tac$] inserts facts into the proof state as assumption of a |
|
404 |
subgoal, see also \texttt{cut_facts_tac} in \cite[\S3]{isabelle-ref}. Note |
|
405 |
that the scope of schmatic variables is spread over the main goal statement. |
|
406 |
Instantiations may be given as well, see also ML tactic |
|
407 |
\texttt{cut_inst_tac} in \cite[\S3]{isabelle-ref}. |
|
408 |
\item [$thin_tac~\phi$] deletes the specified assumption from a subgoal; note |
|
409 |
that $\phi$ may contain schematic variables. See also \texttt{thin_tac} in |
|
410 |
\cite[\S3]{isabelle-ref}. |
|
411 |
\item [$subgoal_tac~\phi$] adds $\phi$ as an assumption to a subgoal. See |
|
412 |
also \texttt{subgoal_tac} and \texttt{subgoals_tac} in |
|
413 |
\cite[\S3]{isabelle-ref}. |
|
9614 | 414 |
\item [$rename_tac~\vec x$] renames parameters of a goal according to the list |
415 |
$\vec x$, which refers to the \emph{suffix} of variables. |
|
416 |
\item [$rotate_tac~n$] rotates the assumptions of a goal by $n$ positions: |
|
417 |
from right to left if $n$ is positive, and from left to right if $n$ is |
|
418 |
negative; the default value is $1$. See also \texttt{rotate_tac} in |
|
419 |
\cite[\S3]{isabelle-ref}. |
|
9606 | 420 |
\item [$tactic~text$] produces a proof method from any ML text of type |
421 |
\texttt{tactic}. Apart from the usual ML environment and the current |
|
422 |
implicit theory context, the ML code may refer to the following locally |
|
423 |
bound values: |
|
424 |
||
425 |
%%FIXME ttbox produces too much trailing space (why?) |
|
426 |
{\footnotesize\begin{verbatim} |
|
427 |
val ctxt : Proof.context |
|
428 |
val facts : thm list |
|
429 |
val thm : string -> thm |
|
430 |
val thms : string -> thm list |
|
431 |
\end{verbatim}} |
|
432 |
Here \texttt{ctxt} refers to the current proof context, \texttt{facts} |
|
433 |
indicates any current facts for forward-chaining, and |
|
434 |
\texttt{thm}~/~\texttt{thms} retrieve named facts (including global |
|
435 |
theorems) from the context. |
|
436 |
\end{descr} |
|
437 |
||
438 |
||
12621 | 439 |
\subsection{The Simplifier}\label{sec:simplifier} |
440 |
||
441 |
\subsubsection{Basic equational reasoning} |
|
7135 | 442 |
|
12621 | 443 |
FIXME |
7315 | 444 |
|
12621 | 445 |
\subsubsection{Simplification methods}\label{sec:simp} |
12618 | 446 |
|
8483 | 447 |
\indexisarmeth{simp}\indexisarmeth{simp-all} |
7315 | 448 |
\begin{matharray}{rcl} |
449 |
simp & : & \isarmeth \\ |
|
8483 | 450 |
simp_all & : & \isarmeth \\ |
7315 | 451 |
\end{matharray} |
452 |
||
8483 | 453 |
\railalias{simpall}{simp\_all} |
454 |
\railterm{simpall} |
|
455 |
||
8704 | 456 |
\railalias{noasm}{no\_asm} |
457 |
\railterm{noasm} |
|
458 |
||
459 |
\railalias{noasmsimp}{no\_asm\_simp} |
|
460 |
\railterm{noasmsimp} |
|
461 |
||
462 |
\railalias{noasmuse}{no\_asm\_use} |
|
463 |
\railterm{noasmuse} |
|
464 |
||
11128 | 465 |
\indexouternonterm{simpmod} |
7315 | 466 |
\begin{rail} |
8706 | 467 |
('simp' | simpall) ('!' ?) opt? (simpmod * ) |
7315 | 468 |
; |
469 |
||
8811 | 470 |
opt: '(' (noasm | noasmsimp | noasmuse) ')' |
8704 | 471 |
; |
9711 | 472 |
simpmod: ('add' | 'del' | 'only' | 'cong' (() | 'add' | 'del') | |
9847 | 473 |
'split' (() | 'add' | 'del')) ':' thmrefs |
7315 | 474 |
; |
475 |
\end{rail} |
|
476 |
||
7321 | 477 |
\begin{descr} |
8547 | 478 |
\item [$simp$] invokes Isabelle's simplifier, after declaring additional rules |
8594 | 479 |
according to the arguments given. Note that the \railtterm{only} modifier |
8547 | 480 |
first removes all other rewrite rules, congruences, and looper tactics |
8594 | 481 |
(including splits), and then behaves like \railtterm{add}. |
9711 | 482 |
|
483 |
\medskip The \railtterm{cong} modifiers add or delete Simplifier congruence |
|
484 |
rules (see also \cite{isabelle-ref}), the default is to add. |
|
485 |
||
486 |
\medskip The \railtterm{split} modifiers add or delete rules for the |
|
487 |
Splitter (see also \cite{isabelle-ref}), the default is to add. This works |
|
488 |
only if the Simplifier method has been properly setup to include the |
|
489 |
Splitter (all major object logics such HOL, HOLCF, FOL, ZF do this already). |
|
8483 | 490 |
\item [$simp_all$] is similar to $simp$, but acts on all goals. |
7321 | 491 |
\end{descr} |
492 |
||
8704 | 493 |
By default, the Simplifier methods are based on \texttt{asm_full_simp_tac} |
8706 | 494 |
internally \cite[\S10]{isabelle-ref}, which means that assumptions are both |
495 |
simplified as well as used in simplifying the conclusion. In structured |
|
496 |
proofs this is usually quite well behaved in practice: just the local premises |
|
497 |
of the actual goal are involved, additional facts may inserted via explicit |
|
498 |
forward-chaining (using $\THEN$, $\FROMNAME$ etc.). The full context of |
|
499 |
assumptions is only included if the ``$!$'' (bang) argument is given, which |
|
500 |
should be used with some care, though. |
|
7321 | 501 |
|
8704 | 502 |
Additional Simplifier options may be specified to tune the behavior even |
9614 | 503 |
further: $(no_asm)$ means assumptions are ignored completely (cf.\ |
8811 | 504 |
\texttt{simp_tac}), $(no_asm_simp)$ means assumptions are used in the |
9614 | 505 |
simplification of the conclusion but are not themselves simplified (cf.\ |
8811 | 506 |
\texttt{asm_simp_tac}), and $(no_asm_use)$ means assumptions are simplified |
507 |
but are not used in the simplification of each other or the conclusion (cf. |
|
8704 | 508 |
\texttt{full_simp_tac}). |
509 |
||
510 |
\medskip |
|
511 |
||
512 |
The Splitter package is usually configured to work as part of the Simplifier. |
|
9711 | 513 |
The effect of repeatedly applying \texttt{split_tac} can be simulated by |
514 |
$(simp~only\colon~split\colon~\vec a)$. There is also a separate $split$ |
|
515 |
method available for single-step case splitting, see \S\ref{sec:basic-eq}. |
|
8483 | 516 |
|
517 |
||
12621 | 518 |
\subsubsection{Declaring rules} |
8483 | 519 |
|
8667 | 520 |
\indexisarcmd{print-simpset} |
8638 | 521 |
\indexisaratt{simp}\indexisaratt{split}\indexisaratt{cong} |
7321 | 522 |
\begin{matharray}{rcl} |
10154 | 523 |
print_simpset^* & : & \isarkeep{theory~|~proof} \\ |
7321 | 524 |
simp & : & \isaratt \\ |
9711 | 525 |
cong & : & \isaratt \\ |
8483 | 526 |
split & : & \isaratt \\ |
7321 | 527 |
\end{matharray} |
528 |
||
529 |
\begin{rail} |
|
9711 | 530 |
('simp' | 'cong' | 'split') (() | 'add' | 'del') |
7321 | 531 |
; |
532 |
\end{rail} |
|
533 |
||
534 |
\begin{descr} |
|
8667 | 535 |
\item [$print_simpset$] prints the collection of rules declared to the |
536 |
Simplifier, which is also known as ``simpset'' internally |
|
537 |
\cite{isabelle-ref}. This is a diagnostic command; $undo$ does not apply. |
|
8547 | 538 |
\item [$simp$] declares simplification rules. |
8638 | 539 |
\item [$cong$] declares congruence rules. |
9711 | 540 |
\item [$split$] declares case split rules. |
7321 | 541 |
\end{descr} |
7319 | 542 |
|
7315 | 543 |
|
12621 | 544 |
\subsubsection{Forward simplification} |
545 |
||
546 |
FIXME thmargs |
|
7315 | 547 |
|
9905 | 548 |
\indexisaratt{simplified} |
7315 | 549 |
\begin{matharray}{rcl} |
9905 | 550 |
simplified & : & \isaratt \\ |
7315 | 551 |
\end{matharray} |
552 |
||
9905 | 553 |
\begin{rail} |
554 |
'simplified' opt? |
|
555 |
; |
|
556 |
||
557 |
opt: '(' (noasm | noasmsimp | noasmuse) ')' |
|
558 |
; |
|
559 |
\end{rail} |
|
7905 | 560 |
|
9905 | 561 |
\begin{descr} |
562 |
\item [$simplified$] causes a theorem to be simplified according to the |
|
563 |
current Simplifier context (there are no separate arguments for declaring |
|
564 |
additional rules). By default the result is fully simplified, including |
|
565 |
assumptions and conclusion. The options $no_asm$ etc.\ restrict the |
|
566 |
Simplifier in the same way as the for the $simp$ method (see |
|
12618 | 567 |
\S\ref{sec:simp}). FIXME args |
9905 | 568 |
|
569 |
The $simplified$ operation should be used only very rarely, usually for |
|
570 |
experimentation only. |
|
571 |
\end{descr} |
|
7315 | 572 |
|
573 |
||
12621 | 574 |
\subsubsection{Basic equational reasoning}\label{sec:basic-eq} |
575 |
||
576 |
FIXME move? |
|
9614 | 577 |
|
9703 | 578 |
\indexisarmeth{subst}\indexisarmeth{hypsubst}\indexisarmeth{split}\indexisaratt{symmetric} |
9614 | 579 |
\begin{matharray}{rcl} |
580 |
subst & : & \isarmeth \\ |
|
581 |
hypsubst^* & : & \isarmeth \\ |
|
9703 | 582 |
split & : & \isarmeth \\ |
9614 | 583 |
symmetric & : & \isaratt \\ |
584 |
\end{matharray} |
|
585 |
||
586 |
\begin{rail} |
|
587 |
'subst' thmref |
|
588 |
; |
|
9799 | 589 |
'split' ('(' 'asm' ')')? thmrefs |
9703 | 590 |
; |
9614 | 591 |
\end{rail} |
592 |
||
593 |
These methods and attributes provide basic facilities for equational reasoning |
|
594 |
that are intended for specialized applications only. Normally, single step |
|
595 |
reasoning would be performed by calculation (see \S\ref{sec:calculation}), |
|
596 |
while the Simplifier is the canonical tool for automated normalization (see |
|
597 |
\S\ref{sec:simplifier}). |
|
598 |
||
599 |
\begin{descr} |
|
600 |
\item [$subst~thm$] performs a single substitution step using rule $thm$, |
|
601 |
which may be either a meta or object equality. |
|
602 |
\item [$hypsubst$] performs substitution using some assumption. |
|
9703 | 603 |
\item [$split~thms$] performs single-step case splitting using rules $thms$. |
9799 | 604 |
By default, splitting is performed in the conclusion of a goal; the $asm$ |
605 |
option indicates to operate on assumptions instead. |
|
606 |
||
9703 | 607 |
Note that the $simp$ method already involves repeated application of split |
608 |
rules as declared in the current context (see \S\ref{sec:simp}). |
|
9614 | 609 |
\item [$symmetric$] applies the symmetry rule of meta or object equality. |
12618 | 610 |
FIXME sym decl |
9614 | 611 |
\end{descr} |
612 |
||
613 |
||
12621 | 614 |
\subsection{The Classical Reasoner}\label{sec:classical} |
7135 | 615 |
|
12621 | 616 |
\subsubsection{Basic methods}\label{sec:classical-basic} |
7321 | 617 |
|
7974 | 618 |
\indexisarmeth{rule}\indexisarmeth{intro} |
619 |
\indexisarmeth{elim}\indexisarmeth{default}\indexisarmeth{contradiction} |
|
7321 | 620 |
\begin{matharray}{rcl} |
621 |
rule & : & \isarmeth \\ |
|
622 |
intro & : & \isarmeth \\ |
|
623 |
elim & : & \isarmeth \\ |
|
624 |
contradiction & : & \isarmeth \\ |
|
625 |
\end{matharray} |
|
626 |
||
627 |
\begin{rail} |
|
8547 | 628 |
('rule' | 'intro' | 'elim') thmrefs? |
7321 | 629 |
; |
630 |
\end{rail} |
|
631 |
||
632 |
\begin{descr} |
|
7466 | 633 |
\item [$rule$] as offered by the classical reasoner is a refinement over the |
8517 | 634 |
primitive one (see \S\ref{sec:pure-meth-att}). In case that no rules are |
7466 | 635 |
provided as arguments, it automatically determines elimination and |
7321 | 636 |
introduction rules from the context (see also \S\ref{sec:classical-mod}). |
8517 | 637 |
This is made the default method for basic proof steps, such as $\PROOFNAME$ |
638 |
and ``$\DDOT$'' (two dots), see also \S\ref{sec:proof-steps} and |
|
639 |
\S\ref{sec:pure-meth-att}. |
|
9614 | 640 |
|
7466 | 641 |
\item [$intro$ and $elim$] repeatedly refine some goal by intro- or |
7905 | 642 |
elim-resolution, after having inserted any facts. Omitting the arguments |
8547 | 643 |
refers to any suitable rules declared in the context, otherwise only the |
644 |
explicitly given ones may be applied. The latter form admits better control |
|
645 |
of what actually happens, thus it is very appropriate as an initial method |
|
646 |
for $\PROOFNAME$ that splits up certain connectives of the goal, before |
|
647 |
entering the actual sub-proof. |
|
9614 | 648 |
|
7466 | 649 |
\item [$contradiction$] solves some goal by contradiction, deriving any result |
650 |
from both $\neg A$ and $A$. Facts, which are guaranteed to participate, may |
|
651 |
appear in either order. |
|
7321 | 652 |
\end{descr} |
653 |
||
654 |
||
12621 | 655 |
\subsubsection{Automated methods}\label{sec:classical-auto} |
7315 | 656 |
|
9799 | 657 |
\indexisarmeth{blast}\indexisarmeth{fast}\indexisarmeth{slow} |
658 |
\indexisarmeth{best}\indexisarmeth{safe}\indexisarmeth{clarify} |
|
7321 | 659 |
\begin{matharray}{rcl} |
9780 | 660 |
blast & : & \isarmeth \\ |
661 |
fast & : & \isarmeth \\ |
|
9799 | 662 |
slow & : & \isarmeth \\ |
9780 | 663 |
best & : & \isarmeth \\ |
664 |
safe & : & \isarmeth \\ |
|
665 |
clarify & : & \isarmeth \\ |
|
7321 | 666 |
\end{matharray} |
667 |
||
11128 | 668 |
\indexouternonterm{clamod} |
7321 | 669 |
\begin{rail} |
7905 | 670 |
'blast' ('!' ?) nat? (clamod * ) |
7321 | 671 |
; |
9799 | 672 |
('fast' | 'slow' | 'best' | 'safe' | 'clarify') ('!' ?) (clamod * ) |
7321 | 673 |
; |
674 |
||
9408 | 675 |
clamod: (('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del') ':' thmrefs |
7321 | 676 |
; |
677 |
\end{rail} |
|
678 |
||
679 |
\begin{descr} |
|
680 |
\item [$blast$] refers to the classical tableau prover (see \texttt{blast_tac} |
|
7335 | 681 |
in \cite[\S11]{isabelle-ref}). The optional argument specifies a |
10858 | 682 |
user-supplied search bound (default 20). |
9799 | 683 |
\item [$fast$, $slow$, $best$, $safe$, and $clarify$] refer to the generic |
684 |
classical reasoner. See \texttt{fast_tac}, \texttt{slow_tac}, |
|
685 |
\texttt{best_tac}, \texttt{safe_tac}, and \texttt{clarify_tac} in |
|
686 |
\cite[\S11]{isabelle-ref} for more information. |
|
7321 | 687 |
\end{descr} |
688 |
||
689 |
Any of above methods support additional modifiers of the context of classical |
|
8517 | 690 |
rules. Their semantics is analogous to the attributes given in |
8547 | 691 |
\S\ref{sec:classical-mod}. Facts provided by forward chaining are |
692 |
inserted\footnote{These methods usually cannot make proper use of actual rules |
|
693 |
inserted that way, though.} into the goal before doing the search. The |
|
694 |
``!''~argument causes the full context of assumptions to be included as well. |
|
695 |
This is slightly less hazardous than for the Simplifier (see |
|
696 |
\S\ref{sec:simp}). |
|
7321 | 697 |
|
7315 | 698 |
|
12621 | 699 |
\subsubsection{Combined automated methods}\label{sec:clasimp} |
7315 | 700 |
|
9799 | 701 |
\indexisarmeth{auto}\indexisarmeth{force}\indexisarmeth{clarsimp} |
702 |
\indexisarmeth{fastsimp}\indexisarmeth{slowsimp}\indexisarmeth{bestsimp} |
|
7321 | 703 |
\begin{matharray}{rcl} |
9606 | 704 |
auto & : & \isarmeth \\ |
7321 | 705 |
force & : & \isarmeth \\ |
9438 | 706 |
clarsimp & : & \isarmeth \\ |
9606 | 707 |
fastsimp & : & \isarmeth \\ |
9799 | 708 |
slowsimp & : & \isarmeth \\ |
709 |
bestsimp & : & \isarmeth \\ |
|
7321 | 710 |
\end{matharray} |
711 |
||
11128 | 712 |
\indexouternonterm{clasimpmod} |
7321 | 713 |
\begin{rail} |
9780 | 714 |
'auto' '!'? (nat nat)? (clasimpmod * ) |
715 |
; |
|
9799 | 716 |
('force' | 'clarsimp' | 'fastsimp' | 'slowsimp' | 'bestsimp') '!'? (clasimpmod * ) |
7321 | 717 |
; |
7315 | 718 |
|
9711 | 719 |
clasimpmod: ('simp' (() | 'add' | 'del' | 'only') | |
10031 | 720 |
('cong' | 'split') (() | 'add' | 'del') | |
721 |
'iff' (((() | 'add') '?'?) | 'del') | |
|
9408 | 722 |
(('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del')) ':' thmrefs |
7321 | 723 |
\end{rail} |
7315 | 724 |
|
7321 | 725 |
\begin{descr} |
9799 | 726 |
\item [$auto$, $force$, $clarsimp$, $fastsimp$, $slowsimp$, and $bestsimp$] |
727 |
provide access to Isabelle's combined simplification and classical reasoning |
|
728 |
tactics. These correspond to \texttt{auto_tac}, \texttt{force_tac}, |
|
729 |
\texttt{clarsimp_tac}, and Classical Reasoner tactics with the Simplifier |
|
730 |
added as wrapper, see \cite[\S11]{isabelle-ref} for more information. The |
|
731 |
modifier arguments correspond to those given in \S\ref{sec:simp} and |
|
9606 | 732 |
\S\ref{sec:classical-auto}. Just note that the ones related to the |
733 |
Simplifier are prefixed by \railtterm{simp} here. |
|
9614 | 734 |
|
7987 | 735 |
Facts provided by forward chaining are inserted into the goal before doing |
736 |
the search. The ``!''~argument causes the full context of assumptions to be |
|
737 |
included as well. |
|
7321 | 738 |
\end{descr} |
739 |
||
7987 | 740 |
|
12621 | 741 |
\subsubsection{Declaring rules}\label{sec:classical-mod} |
7135 | 742 |
|
8667 | 743 |
\indexisarcmd{print-claset} |
7391 | 744 |
\indexisaratt{intro}\indexisaratt{elim}\indexisaratt{dest} |
9936 | 745 |
\indexisaratt{iff}\indexisaratt{rule} |
7321 | 746 |
\begin{matharray}{rcl} |
10154 | 747 |
print_claset^* & : & \isarkeep{theory~|~proof} \\ |
7321 | 748 |
intro & : & \isaratt \\ |
749 |
elim & : & \isaratt \\ |
|
750 |
dest & : & \isaratt \\ |
|
9936 | 751 |
rule & : & \isaratt \\ |
7391 | 752 |
iff & : & \isaratt \\ |
7321 | 753 |
\end{matharray} |
7135 | 754 |
|
7321 | 755 |
\begin{rail} |
9408 | 756 |
('intro' | 'elim' | 'dest') ('!' | () | '?') |
7321 | 757 |
; |
9936 | 758 |
'rule' 'del' |
759 |
; |
|
10031 | 760 |
'iff' (((() | 'add') '?'?) | 'del') |
9936 | 761 |
; |
7321 | 762 |
\end{rail} |
7135 | 763 |
|
7321 | 764 |
\begin{descr} |
8667 | 765 |
\item [$print_claset$] prints the collection of rules declared to the |
766 |
Classical Reasoner, which is also known as ``simpset'' internally |
|
767 |
\cite{isabelle-ref}. This is a diagnostic command; $undo$ does not apply. |
|
8517 | 768 |
\item [$intro$, $elim$, and $dest$] declare introduction, elimination, and |
11332 | 769 |
destruction rules, respectively. By default, rules are considered as |
9408 | 770 |
\emph{unsafe} (i.e.\ not applied blindly without backtracking), while a |
771 |
single ``!'' classifies as \emph{safe}, and ``?'' as \emph{extra} (i.e.\ not |
|
772 |
applied in the search-oriented automated methods, but only in single-step |
|
773 |
methods such as $rule$). |
|
11332 | 774 |
\item [$rule~del$] deletes introduction, elimination, or destruction rules from |
9936 | 775 |
the context. |
11442 | 776 |
\item [$iff$] declares a (possibly conditional) ``safe'' rule to the context in |
777 |
several ways. The rule is declared as a rewrite rule to the Simplifier. |
|
778 |
Furthermore, it is |
|
11332 | 779 |
declared in several ways (depending on its structure) to the Classical |
780 |
Reasoner for aggressive use, which would normally be indicated by ``!''). |
|
781 |
If the rule is an equivalence, the two corresponding implications are |
|
11469 | 782 |
declared as introduction and destruction rules. Otherwise, |
783 |
if the rule is an inequality, the corresponding negation elimination rule |
|
11442 | 784 |
is declared, else the rule itself is declared as an introduction rule. |
10031 | 785 |
|
786 |
The ``?'' version of $iff$ declares ``extra'' Classical Reasoner rules only, |
|
787 |
and omits the Simplifier declaration. Thus the declaration does not have |
|
788 |
any effect on automated proof tools, but only on simple methods such as |
|
12618 | 789 |
$rule$ (see \S\ref{sec:misc-meth-att}). |
7321 | 790 |
\end{descr} |
7135 | 791 |
|
8203
2fcc6017cb72
intro/elim/dest attributes: changed ! / !! flags to ? / ??;
wenzelm
parents:
8195
diff
changeset
|
792 |
|
12621 | 793 |
\subsection{Proof by cases and induction}\label{sec:cases-induct} |
12618 | 794 |
|
12621 | 795 |
\subsubsection{Rule contexts}\label{sec:rule-cases} |
12618 | 796 |
|
797 |
\indexisarcmd{case}\indexisarcmd{print-cases} |
|
798 |
\indexisaratt{case-names}\indexisaratt{params}\indexisaratt{consumes} |
|
799 |
\begin{matharray}{rcl} |
|
800 |
\isarcmd{case} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
801 |
\isarcmd{print_cases}^* & : & \isarkeep{proof} \\ |
|
802 |
case_names & : & \isaratt \\ |
|
803 |
params & : & \isaratt \\ |
|
804 |
consumes & : & \isaratt \\ |
|
805 |
\end{matharray} |
|
806 |
||
807 |
Basically, Isar proof contexts are built up explicitly using commands like |
|
808 |
$\FIXNAME$, $\ASSUMENAME$ etc.\ (see \S\ref{sec:proof-context}). In typical |
|
809 |
verification tasks this can become hard to manage, though. In particular, a |
|
810 |
large number of local contexts may emerge from case analysis or induction over |
|
811 |
inductive sets and types. |
|
812 |
||
813 |
\medskip |
|
814 |
||
815 |
The $\CASENAME$ command provides a shorthand to refer to certain parts of |
|
816 |
logical context symbolically. Proof methods may provide an environment of |
|
817 |
named ``cases'' of the form $c\colon \vec x, \vec \phi$. Then the effect of |
|
818 |
$\CASE{c}$ is exactly the same as $\FIX{\vec x}~\ASSUME{c}{\vec\phi}$. |
|
819 |
||
820 |
FIXME |
|
821 |
||
822 |
It is important to note that $\CASENAME$ does \emph{not} provide any means to |
|
823 |
peek at the current goal state, which is treated as strictly non-observable in |
|
824 |
Isar! Instead, the cases considered here usually emerge in a canonical way |
|
825 |
from certain pieces of specification that appear in the theory somewhere else |
|
826 |
(e.g.\ in an inductive definition, or recursive function). |
|
827 |
||
828 |
FIXME |
|
829 |
||
830 |
\medskip |
|
831 |
||
832 |
Named cases may be exhibited in the current proof context only if both the |
|
833 |
proof method and the rules involved support this. Case names and parameters |
|
834 |
of basic rules may be declared by hand as well, by using appropriate |
|
835 |
attributes. Thus variant versions of rules that have been derived manually |
|
836 |
may be used in advanced case analysis later. |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
837 |
|
12618 | 838 |
\railalias{casenames}{case\_names} |
839 |
\railterm{casenames} |
|
840 |
||
841 |
\begin{rail} |
|
842 |
'case' nameref attributes? |
|
843 |
; |
|
844 |
casenames (name + ) |
|
845 |
; |
|
846 |
'params' ((name * ) + 'and') |
|
847 |
; |
|
848 |
'consumes' nat? |
|
849 |
; |
|
850 |
\end{rail} |
|
851 |
%FIXME bug in rail |
|
852 |
||
853 |
\begin{descr} |
|
854 |
\item [$\CASE{c}$] invokes a named local context $c\colon \vec x, \vec \phi$, |
|
855 |
as provided by an appropriate proof method (such as $cases$ and $induct$, |
|
856 |
see \S\ref{sec:cases-induct-meth}). The command $\CASE{c}$ abbreviates |
|
857 |
$\FIX{\vec x}~\ASSUME{c}{\vec\phi}$. |
|
858 |
\item [$\isarkeyword{print_cases}$] prints all local contexts of the current |
|
859 |
state, using Isar proof language notation. This is a diagnostic command; |
|
860 |
$undo$ does not apply. |
|
861 |
\item [$case_names~\vec c$] declares names for the local contexts of premises |
|
862 |
of some theorem; $\vec c$ refers to the \emph{suffix} of the list of |
|
863 |
premises. |
|
864 |
\item [$params~\vec p@1 \dots \vec p@n$] renames the innermost parameters of |
|
865 |
premises $1, \dots, n$ of some theorem. An empty list of names may be given |
|
866 |
to skip positions, leaving the present parameters unchanged. |
|
867 |
||
868 |
Note that the default usage of case rules does \emph{not} directly expose |
|
869 |
parameters to the proof context (see also \S\ref{sec:cases-induct-meth}). |
|
870 |
\item [$consumes~n$] declares the number of ``major premises'' of a rule, |
|
871 |
i.e.\ the number of facts to be consumed when it is applied by an |
|
872 |
appropriate proof method (cf.\ \S\ref{sec:cases-induct-meth}). The default |
|
873 |
value of $consumes$ is $n = 1$, which is appropriate for the usual kind of |
|
874 |
cases and induction rules for inductive sets (cf.\ |
|
875 |
\S\ref{sec:hol-inductive}). Rules without any $consumes$ declaration given |
|
876 |
are treated as if $consumes~0$ had been specified. |
|
877 |
||
878 |
Note that explicit $consumes$ declarations are only rarely needed; this is |
|
879 |
already taken care of automatically by the higher-level $cases$ and $induct$ |
|
880 |
declarations, see also \S\ref{sec:cases-induct-att}. |
|
881 |
\end{descr} |
|
882 |
||
883 |
||
12621 | 884 |
\subsubsection{Proof methods}\label{sec:cases-induct-meth} |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
885 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
886 |
\indexisarmeth{cases}\indexisarmeth{induct} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
887 |
\begin{matharray}{rcl} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
888 |
cases & : & \isarmeth \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
889 |
induct & : & \isarmeth \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
890 |
\end{matharray} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
891 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
892 |
The $cases$ and $induct$ methods provide a uniform interface to case analysis |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
893 |
and induction over datatypes, inductive sets, and recursive functions. The |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
894 |
corresponding rules may be specified and instantiated in a casual manner. |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
895 |
Furthermore, these methods provide named local contexts that may be invoked |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
896 |
via the $\CASENAME$ proof command within the subsequent proof text (cf.\ |
12618 | 897 |
\S\ref{sec:rule-cases}). This accommodates compact proof texts even when |
898 |
reasoning about large specifications. |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
899 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
900 |
Note that the full spectrum of this generic functionality is currently only |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
901 |
supported by Isabelle/HOL, when used in conjunction with advanced definitional |
12618 | 902 |
packages (see especially \S\ref{sec:hol-datatype} and |
903 |
\S\ref{sec:hol-inductive}). |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
904 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
905 |
\begin{rail} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
906 |
'cases' spec |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
907 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
908 |
'induct' spec |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
909 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
910 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
911 |
spec: open? args rule? params? |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
912 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
913 |
open: '(' 'open' ')' |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
914 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
915 |
args: (insts * 'and') |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
916 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
917 |
rule: ('type' | 'set') ':' nameref | 'rule' ':' thmref |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
918 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
919 |
params: 'of' ':' insts |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
920 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
921 |
\end{rail} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
922 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
923 |
\begin{descr} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
924 |
\item [$cases~insts~R~ps$] applies method $rule$ with an appropriate case |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
925 |
distinction theorem, instantiated to the subjects $insts$. Symbolic case |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
926 |
names are bound according to the rule's local contexts. |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
927 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
928 |
The rule is determined as follows, according to the facts and arguments |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
929 |
passed to the $cases$ method: |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
930 |
\begin{matharray}{llll} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
931 |
\Text{facts} & & \Text{arguments} & \Text{rule} \\\hline |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
932 |
& cases & & \Text{classical case split} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
933 |
& cases & t & \Text{datatype exhaustion (type of $t$)} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
934 |
\edrv a \in A & cases & \dots & \Text{inductive set elimination (of $A$)} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
935 |
\dots & cases & \dots ~ R & \Text{explicit rule $R$} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
936 |
\end{matharray} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
937 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
938 |
Several instantiations may be given, referring to the \emph{suffix} of |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
939 |
premises of the case rule; within each premise, the \emph{prefix} of |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
940 |
variables is instantiated. In most situations, only a single term needs to |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
941 |
be specified; this refers to the first variable of the last premise (it is |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
942 |
usually the same for all cases). |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
943 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
944 |
Additional parameters may be specified as $ps$; these are applied after the |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
945 |
primary instantiation in the same manner as by the $of$ attribute (cf.\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
946 |
\S\ref{sec:pure-meth-att}). This feature is rarely needed in practice; a |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
947 |
typical application would be to specify additional arguments for rules |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
948 |
stemming from parameterized inductive definitions (see also |
12618 | 949 |
\S\ref{sec:hol-inductive}). |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
950 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
951 |
The $open$ option causes the parameters of the new local contexts to be |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
952 |
exposed to the current proof context. Thus local variables stemming from |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
953 |
distant parts of the theory development may be introduced in an implicit |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
954 |
manner, which can be quite confusing to the reader. Furthermore, this |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
955 |
option may cause unwanted hiding of existing local variables, resulting in |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
956 |
less robust proof texts. |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
957 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
958 |
\item [$induct~insts~R~ps$] is analogous to the $cases$ method, but refers to |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
959 |
induction rules, which are determined as follows: |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
960 |
\begin{matharray}{llll} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
961 |
\Text{facts} & & \Text{arguments} & \Text{rule} \\\hline |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
962 |
& induct & P ~ x ~ \dots & \Text{datatype induction (type of $x$)} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
963 |
\edrv x \in A & induct & \dots & \Text{set induction (of $A$)} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
964 |
\dots & induct & \dots ~ R & \Text{explicit rule $R$} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
965 |
\end{matharray} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
966 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
967 |
Several instantiations may be given, each referring to some part of a mutual |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
968 |
inductive definition or datatype --- only related partial induction rules |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
969 |
may be used together, though. Any of the lists of terms $P, x, \dots$ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
970 |
refers to the \emph{suffix} of variables present in the induction rule. |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
971 |
This enables the writer to specify only induction variables, or both |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
972 |
predicates and variables, for example. |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
973 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
974 |
Additional parameters (including the $open$ option) may be given in the same |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
975 |
way as for $cases$, see above. |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
976 |
\end{descr} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
977 |
|
12618 | 978 |
Above methods produce named local contexts (cf.\ \S\ref{sec:rule-cases}), as |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
979 |
determined by the instantiated rule \emph{before} it has been applied to the |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
980 |
internal proof state.\footnote{As a general principle, Isar proof text may |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
981 |
never refer to parts of proof states directly.} Thus proper use of symbolic |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
982 |
cases usually require the rule to be instantiated fully, as far as the |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
983 |
emerging local contexts and subgoals are concerned. In particular, for |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
984 |
induction both the predicates and variables have to be specified. Otherwise |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
985 |
the $\CASENAME$ command would refuse to invoke cases containing schematic |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
986 |
variables. Furthermore the resulting local goal statement is bound to the |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
987 |
term variable $\Var{case}$\indexisarvar{case} --- for each case where it is |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
988 |
fully specified. |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
989 |
|
12618 | 990 |
The $\isarkeyword{print_cases}$ command (\S\ref{sec:rule-cases}) prints all |
991 |
named cases present in the current proof state. |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
992 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
993 |
\medskip |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
994 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
995 |
It is important to note that there is a fundamental difference of the $cases$ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
996 |
and $induct$ methods in handling of non-atomic goal statements: $cases$ just |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
997 |
applies a certain rule in backward fashion, splitting the result into new |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
998 |
goals with the local contexts being augmented in a purely monotonic manner. |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
999 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1000 |
In contrast, $induct$ passes the full goal statement through the ``recursive'' |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1001 |
course involved in the induction. Thus the original statement is basically |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1002 |
replaced by separate copies, corresponding to the induction hypotheses and |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1003 |
conclusion; the original goal context is no longer available. This behavior |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1004 |
allows \emph{strengthened induction predicates} to be expressed concisely as |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1005 |
meta-level rule statements, i.e.\ $\All{\vec x} \vec\phi \Imp \psi$ to |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1006 |
indicate ``variable'' parameters $\vec x$ and ``recursive'' assumptions |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1007 |
$\vec\phi$. Also note that local definitions may be expressed as $\All{\vec |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1008 |
x} n \equiv t[\vec x] \Imp \phi[n]$, with induction over $n$. |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1009 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1010 |
\medskip |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1011 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1012 |
Facts presented to either method are consumed according to the number of |
12618 | 1013 |
``major premises'' of the rule involved (see also \S\ref{sec:cases-induct}), |
1014 |
which is usually $0$ for plain cases and induction rules of datatypes etc.\ |
|
1015 |
and $1$ for rules of inductive sets and the like. The remaining facts are |
|
1016 |
inserted into the goal verbatim before the actual $cases$ or $induct$ rule is |
|
1017 |
applied (thus facts may be even passed through an induction). |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1018 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1019 |
Note that whenever facts are present, the default rule selection scheme would |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1020 |
provide a ``set'' rule only, with the first fact consumed and the rest |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1021 |
inserted into the goal. In order to pass all facts into a ``type'' rule |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1022 |
instead, one would have to specify this explicitly, e.g.\ by appending |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1023 |
``$type: name$'' to the method argument. |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1024 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1025 |
|
12621 | 1026 |
\subsubsection{Declaring rules}\label{sec:cases-induct-att} |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1027 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1028 |
\indexisarcmd{print-induct-rules}\indexisaratt{cases}\indexisaratt{induct} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1029 |
\begin{matharray}{rcl} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1030 |
\isarcmd{print_induct_rules}^* & : & \isarkeep{theory~|~proof} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1031 |
cases & : & \isaratt \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1032 |
induct & : & \isaratt \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1033 |
\end{matharray} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1034 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1035 |
\begin{rail} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1036 |
'cases' spec |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1037 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1038 |
'induct' spec |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1039 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1040 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1041 |
spec: ('type' | 'set') ':' nameref |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1042 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1043 |
\end{rail} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1044 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1045 |
The $cases$ and $induct$ attributes augment the corresponding context of rules |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1046 |
for reasoning about inductive sets and types. The standard rules are already |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1047 |
declared by advanced definitional packages. For special applications, these |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1048 |
may be replaced manually by variant versions. |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1049 |
|
12618 | 1050 |
Refer to the $case_names$ and $ps$ attributes (see \S\ref{sec:rule-cases}) to |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1051 |
adjust names of cases and parameters of a rule. |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1052 |
|
12618 | 1053 |
The $consumes$ declaration (cf.\ \S\ref{sec:rule-cases}) is taken care of |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1054 |
automatically (if none had been given already): $consumes~0$ is specified for |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1055 |
``type'' rules and $consumes~1$ for ``set'' rules. |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1056 |
|
9614 | 1057 |
%%% Local Variables: |
7135 | 1058 |
%%% mode: latex |
1059 |
%%% TeX-master: "isar-ref" |
|
9614 | 1060 |
%%% End: |