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