author | haftmann |
Wed, 08 Feb 2006 09:27:20 +0100 | |
changeset 18976 | 4efb82669880 |
parent 18903 | 45c732782339 |
child 19070 | 99001616e0e2 |
permissions | -rw-r--r-- |
7135 | 1 |
|
13048 | 2 |
\chapter{Generic tools and packages}\label{ch:gen-tools} |
7167 | 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 |
; |
14605
9de4d64eee3b
'instance' and intro_classes now handle general sorts;
wenzelm
parents:
14212
diff
changeset
|
25 |
'instance' (nameref ('<' | subseteq) nameref | nameref '::' arity) |
7167 | 26 |
; |
27 |
\end{rail} |
|
28 |
||
29 |
\begin{descr} |
|
17274
746bb4c56800
axclass: name space prefix is now "c_class" instead of just "c";
wenzelm
parents:
17228
diff
changeset
|
30 |
|
13024 | 31 |
\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
|
32 |
the intersection of existing classes, with additional axioms holding. Class |
10223 | 33 |
axioms may not contain more than one type variable. The class axioms (with |
34 |
implicit sort constraints added) are bound to the given names. Furthermore |
|
17274
746bb4c56800
axclass: name space prefix is now "c_class" instead of just "c";
wenzelm
parents:
17228
diff
changeset
|
35 |
a class introduction rule is generated (being bound as |
746bb4c56800
axclass: name space prefix is now "c_class" instead of just "c";
wenzelm
parents:
17228
diff
changeset
|
36 |
$c_class{\dtt}intro$); this rule is employed by method $intro_classes$ to |
746bb4c56800
axclass: name space prefix is now "c_class" instead of just "c";
wenzelm
parents:
17228
diff
changeset
|
37 |
support instantiation proofs of this class. |
746bb4c56800
axclass: name space prefix is now "c_class" instead of just "c";
wenzelm
parents:
17228
diff
changeset
|
38 |
|
12976 | 39 |
The ``axioms'' are stored as theorems according to the given name |
13039 | 40 |
specifications, adding the class name $c$ as name space prefix; the same |
17274
746bb4c56800
axclass: name space prefix is now "c_class" instead of just "c";
wenzelm
parents:
17228
diff
changeset
|
41 |
facts are also stored collectively as $c_class{\dtt}axioms$. |
14605
9de4d64eee3b
'instance' and intro_classes now handle general sorts;
wenzelm
parents:
14212
diff
changeset
|
42 |
|
9de4d64eee3b
'instance' and intro_classes now handle general sorts;
wenzelm
parents:
14212
diff
changeset
|
43 |
\item [$\INSTANCE~c@1 \subseteq c@2$ and $\INSTANCE~t :: (\vec s)s$] setup a |
11100
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11095
diff
changeset
|
44 |
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
|
45 |
proceed by $intro_classes$, and then establish the characteristic theorems |
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11095
diff
changeset
|
46 |
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
|
47 |
augmented by a type signature declaration corresponding to the resulting |
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11095
diff
changeset
|
48 |
theorem. |
13041 | 49 |
|
8517 | 50 |
\item [$intro_classes$] repeatedly expands all class introduction rules of |
10858 | 51 |
this theory. Note that this method usually needs not be named explicitly, |
13040 | 52 |
as it is already included in the default proof step (of $\PROOFNAME$ etc.). |
53 |
In particular, instantiation of trivial (syntactic) classes may be performed |
|
54 |
by a single ``$\DDOT$'' proof step. |
|
13027 | 55 |
|
7167 | 56 |
\end{descr} |
57 |
||
7315 | 58 |
|
12618 | 59 |
\subsection{Locales and local contexts}\label{sec:locale} |
60 |
||
13040 | 61 |
Locales are named local contexts, consisting of a list of declaration elements |
13041 | 62 |
that are modeled after the Isar proof context commands (cf.\ |
13040 | 63 |
\S\ref{sec:proof-context}). |
12976 | 64 |
|
13048 | 65 |
|
12976 | 66 |
\subsubsection{Localized commands} |
12618 | 67 |
|
12976 | 68 |
Existing locales may be augmented later on by adding new facts. Note that the |
69 |
actual context definition may not be changed! Several theory commands that |
|
70 |
produce facts in some way are available in ``localized'' versions, referring |
|
71 |
to a named locale instead of the global theory context. |
|
12967 | 72 |
|
12976 | 73 |
\indexouternonterm{locale} |
12967 | 74 |
\begin{rail} |
75 |
locale: '(' 'in' name ')' |
|
76 |
; |
|
12976 | 77 |
\end{rail} |
12967 | 78 |
|
12976 | 79 |
Emerging facts of localized commands are stored in two versions, both in the |
80 |
target locale and the theory (after export). The latter view produces a |
|
81 |
qualified binding, using the locale name as a name space prefix. |
|
82 |
||
83 |
For example, ``$\LEMMAS~(\IN~loc)~a = \vec b$'' retrieves facts $\vec b$ from |
|
84 |
the locale context of $loc$ and augments its body by an appropriate |
|
85 |
``$\isarkeyword{notes}$'' element (see below). The exported view of $a$, |
|
86 |
after discharging the locale context, is stored as $loc{.}a$ within the global |
|
13041 | 87 |
theory. A localized goal ``$\LEMMANAME~(\IN~loc)~a:~\phi$'' works similarly, |
88 |
only that the fact emerges through the subsequent proof, which may refer to |
|
89 |
the full infrastructure of the locale context (covering local parameters with |
|
90 |
typing and concrete syntax, assumptions, definitions etc.). Most notably, |
|
13411 | 91 |
fact declarations of the locale are active during the proof as well (e.g.\ |
13041 | 92 |
local $simp$ rules). |
12976 | 93 |
|
13411 | 94 |
As a general principle, results exported from a locale context acquire |
95 |
additional premises according to the specification. Usually this is only a |
|
96 |
single predicate according to the standard ``closed'' view of locale |
|
97 |
specifications. |
|
98 |
||
12976 | 99 |
|
100 |
\subsubsection{Locale specifications} |
|
101 |
||
102 |
\indexisarcmd{locale}\indexisarcmd{print-locale}\indexisarcmd{print-locales} |
|
103 |
\begin{matharray}{rcl} |
|
104 |
\isarcmd{locale} & : & \isarkeep{theory} \\ |
|
105 |
\isarcmd{print_locale}^* & : & \isarkeep{theory~|~proof} \\ |
|
106 |
\isarcmd{print_locales}^* & : & \isarkeep{theory~|~proof} \\ |
|
107 |
\end{matharray} |
|
108 |
||
109 |
\indexouternonterm{contextexpr}\indexouternonterm{contextelem} |
|
18903 | 110 |
\indexisarelem{fixes}\indexisarelem{constrains}\indexisarelem{assumes} |
111 |
\indexisarelem{defines}\indexisarelem{notes}\indexisarelem{includes} |
|
12976 | 112 |
|
113 |
\begin{rail} |
|
13411 | 114 |
'locale' ('(open)')? name ('=' localeexpr)? |
12976 | 115 |
; |
18903 | 116 |
'print\_locale' '!'? localeexpr |
12976 | 117 |
; |
118 |
localeexpr: ((contextexpr '+' (contextelem+)) | contextexpr | (contextelem+)) |
|
119 |
; |
|
120 |
||
121 |
contextexpr: nameref | '(' contextexpr ')' | |
|
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
16010
diff
changeset
|
122 |
(contextexpr (name mixfix? +)) | (contextexpr + '+') |
12976 | 123 |
; |
16168
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
124 |
contextelem: fixes | constrains | assumes | defines | notes | includes |
12976 | 125 |
; |
18854 | 126 |
fixes: 'fixes' ((name ('::' type)? structmixfix? | vars) + 'and') |
12976 | 127 |
; |
16168
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
128 |
constrains: 'constrains' (name '::' type + 'and') |
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
129 |
; |
12976 | 130 |
assumes: 'assumes' (thmdecl? props + 'and') |
131 |
; |
|
132 |
defines: 'defines' (thmdecl? prop proppat? + 'and') |
|
133 |
; |
|
134 |
notes: 'notes' (thmdef? thmrefs + 'and') |
|
135 |
; |
|
136 |
includes: 'includes' contextexpr |
|
137 |
; |
|
12967 | 138 |
\end{rail} |
12618 | 139 |
|
12976 | 140 |
\begin{descr} |
13411 | 141 |
|
142 |
\item [$\LOCALE~loc~=~import~+~body$] defines a new locale $loc$ as a context |
|
12976 | 143 |
consisting of a certain view of existing locales ($import$) plus some |
144 |
additional elements ($body$). Both $import$ and $body$ are optional; the |
|
13024 | 145 |
degenerate form $\LOCALE~loc$ defines an empty locale, which may still be |
146 |
useful to collect declarations of facts later on. Type-inference on locale |
|
12976 | 147 |
expressions automatically takes care of the most general typing that the |
148 |
combined context elements may acquire. |
|
13041 | 149 |
|
12976 | 150 |
The $import$ consists of a structured context expression, consisting of |
151 |
references to existing locales, renamed contexts, or merged contexts. |
|
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
16010
diff
changeset
|
152 |
Renaming uses positional notation: $c~\vec x$ means that (a prefix of) the |
12976 | 153 |
fixed parameters of context $c$ are named according to $\vec x$; a |
16102
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
16010
diff
changeset
|
154 |
``\texttt{_}'' (underscore) \indexisarthm{_@\texttt{_}} means to skip that |
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
16010
diff
changeset
|
155 |
position. Renaming by default deletes existing syntax. Optionally, |
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
16010
diff
changeset
|
156 |
new syntax may by specified with a mixfix annotation. Note that the |
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
16010
diff
changeset
|
157 |
special syntax declared with ``$(structure)$'' (see below) is |
c5f6726d9bb1
Locale expressions: rename with optional mixfix syntax.
ballarin
parents:
16010
diff
changeset
|
158 |
neither deleted nor can it be changed. |
13041 | 159 |
Merging proceeds from left-to-right, suppressing any duplicates stemming |
160 |
from different paths through the import hierarchy. |
|
161 |
||
12976 | 162 |
The $body$ consists of basic context elements, further context expressions |
163 |
may be included as well. |
|
164 |
||
165 |
\begin{descr} |
|
13041 | 166 |
|
12976 | 167 |
\item [$\FIXES{~x::\tau~(mx)}$] declares a local parameter of type $\tau$ |
168 |
and mixfix annotation $mx$ (both are optional). The special syntax |
|
13027 | 169 |
declaration ``$(structure)$'' means that $x$ may be referenced |
170 |
implicitly in this context. |
|
13041 | 171 |
|
16168
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
172 |
\item [$\CONSTRAINS{~x::\tau}$] introduces a type constraint $\tau$ |
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
173 |
on the local parameter $x$. |
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
174 |
|
12976 | 175 |
\item [$\ASSUMES{a}{\vec\phi}$] introduces local premises, similar to |
176 |
$\ASSUMENAME$ within a proof (cf.\ \S\ref{sec:proof-context}). |
|
13041 | 177 |
|
12976 | 178 |
\item [$\DEFINES{a}{x \equiv t}$] defines a previously declared parameter. |
13041 | 179 |
This is close to $\DEFNAME$ within a proof (cf.\ |
12976 | 180 |
\S\ref{sec:proof-context}), but $\DEFINESNAME$ takes an equational |
13041 | 181 |
proposition instead of variable-term pair. The left-hand side of the |
182 |
equation may have additional arguments, e.g.\ ``$\DEFINES{}{f~\vec x |
|
183 |
\equiv t}$''. |
|
184 |
||
12976 | 185 |
\item [$\NOTES{a}{\vec b}$] reconsiders facts within a local context. Most |
186 |
notably, this may include arbitrary declarations in any attribute |
|
187 |
specifications included here, e.g.\ a local $simp$ rule. |
|
13041 | 188 |
|
12976 | 189 |
\item [$\INCLUDES{c}$] copies the specified context in a statically scoped |
15763
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
190 |
manner. Only available in the long goal format of \S\ref{sec:goals}. |
13041 | 191 |
|
12976 | 192 |
In contrast, the initial $import$ specification of a locale expression |
193 |
maintains a dynamic relation to the locales being referenced (benefiting |
|
194 |
from any later fact declarations in the obvious manner). |
|
195 |
\end{descr} |
|
13411 | 196 |
|
13041 | 197 |
Note that ``$\IS{p}$'' patterns given in the syntax of $\ASSUMESNAME$ and |
13411 | 198 |
$\DEFINESNAME$ above are illegal in locale definitions. In the long goal |
199 |
format of \S\ref{sec:goals}, term bindings may be included as expected, |
|
200 |
though. |
|
201 |
||
202 |
\medskip By default, locale specifications are ``closed up'' by turning the |
|
203 |
given text into a predicate definition $loc_axioms$ and deriving the |
|
204 |
original assumptions as local lemmas (modulo local definitions). The |
|
205 |
predicate statement covers only the newly specified assumptions, omitting |
|
206 |
the content of included locale expressions. The full cumulative view is |
|
207 |
only provided on export, involving another predicate $loc$ that refers to |
|
208 |
the complete specification text. |
|
209 |
||
210 |
In any case, the predicate arguments are those locale parameters that |
|
211 |
actually occur in the respective piece of text. Also note that these |
|
212 |
predicates operate at the meta-level in theory, but the locale packages |
|
213 |
attempts to internalize statements according to the object-logic setup |
|
214 |
(e.g.\ replacing $\Forall$ by $\forall$, and $\Imp$ by $\imp$ in HOL; see |
|
215 |
also \S\ref{sec:object-logic}). Separate introduction rules |
|
216 |
$loc_axioms.intro$ and $loc.intro$ are declared as well. |
|
217 |
||
218 |
The $(open)$ option of a locale specification prevents both the current |
|
219 |
$loc_axioms$ and cumulative $loc$ predicate constructions. Predicates are |
|
220 |
also omitted for empty specification texts. |
|
12976 | 221 |
|
222 |
\item [$\isarkeyword{print_locale}~import~+~body$] prints the specified locale |
|
223 |
expression in a flattened form. The notable special case |
|
224 |
$\isarkeyword{print_locale}~loc$ just prints the contents of the named |
|
225 |
locale, but keep in mind that type-inference will normalize type variables |
|
17228 | 226 |
according to the usual alphabetical order. The command omits |
227 |
$\isarkeyword{notes}$ elements by default. Use |
|
228 |
$\isarkeyword{print_locale}!$ to get them included. |
|
13041 | 229 |
|
12976 | 230 |
\item [$\isarkeyword{print_locales}$] prints the names of all locales of the |
231 |
current theory. |
|
232 |
||
233 |
\end{descr} |
|
234 |
||
12621 | 235 |
|
15763
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
236 |
\subsubsection{Interpretation of locales} |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
237 |
|
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
238 |
Locale expressions (more precisely, \emph{context expressions}) may be |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
239 |
instantiated, and the instantiated facts added to the current context. |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
240 |
This requires a proof of the instantiated specification and is called |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
241 |
\emph{locale interpretation}. Interpretation is possible in theories |
17043 | 242 |
and locales |
243 |
(command $\isarcmd{interpretation}$) and also in proof contexts |
|
15763
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
244 |
($\isarcmd{interpret}$). |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
245 |
|
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
246 |
\indexisarcmd{interpretation}\indexisarcmd{interpret} |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
247 |
\indexisarcmd{print-interps} |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
248 |
\begin{matharray}{rcl} |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
249 |
\isarcmd{interpretation} & : & \isartrans{theory}{proof(prove)} \\ |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
250 |
\isarcmd{interpret} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\ |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
251 |
\isarcmd{print_interps}^* & : & \isarkeep{theory~|~proof} \\ |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
252 |
\end{matharray} |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
253 |
|
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
254 |
\indexouternonterm{interp} |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
255 |
|
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
256 |
\railalias{printinterps}{print\_interps} |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
257 |
\railterm{printinterps} |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
258 |
|
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
259 |
\begin{rail} |
17043 | 260 |
'interpretation' (interp | name ('<' | subseteq) contextexp) |
15763
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
261 |
; |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
262 |
'interpret' interp |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
263 |
; |
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17043
diff
changeset
|
264 |
printinterps '!'? name |
15763
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
265 |
; |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
266 |
interp: thmdecl? contextexpr ('[' (inst+) ']')? |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
267 |
; |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
268 |
\end{rail} |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
269 |
|
17043 | 270 |
|
15763
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
271 |
\begin{descr} |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
272 |
|
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
273 |
\item [$\isarcmd{interpretation}~expr~insts$] |
17043 | 274 |
|
275 |
The first form of $\isarcmd{interpretation}$ interprets $expr$ |
|
276 |
in the theory. The instantiation is given as a list of |
|
277 |
terms $insts$ and is positional. |
|
15763
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
278 |
All parameters must receive an instantiation term --- with the |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
279 |
exception of defined parameters. These are, if omitted, derived |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
280 |
from the defining equation and other instantiations. Use ``\_'' to |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
281 |
omit an instantiation term. Free variables are automatically |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
282 |
generalized. |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
283 |
|
17043 | 284 |
The command generates proof obligations for the instantiated |
285 |
specifications (assumes and defines elements). Once these are |
|
286 |
discharged by the user, instantiated facts are added to the theory in |
|
287 |
a post-processing phase. |
|
15763
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
288 |
|
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
289 |
The command is aware of interpretations already active in the |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
290 |
theory. No proof obligations are generated for those, neither is |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
291 |
post-processing applied to their facts. This avoids duplication of |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
292 |
interpreted facts, in particular. Note that, in the case of a |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
293 |
locale with import, parts of the interpretation may already be |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
294 |
active. The command will only generate proof obligations and add |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
295 |
facts for new parts. |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
296 |
|
17043 | 297 |
The context expression may be preceded by a name and/or attributes. |
298 |
These take effect in the post-processing of facts. The name is used |
|
299 |
to prefix fact names, for example to avoid accidental hiding of |
|
300 |
other facts. Attributes are applied after attributes of the |
|
301 |
interpreted facts. |
|
302 |
||
15763
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
303 |
Adding facts to locales has the |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
304 |
effect of adding interpreted facts to the theory for all active |
17043 | 305 |
interpretations also. That is, interpretations dynamically |
306 |
participate in any facts added to locales. |
|
307 |
||
308 |
\item [$\isarcmd{interpretation}~name~\subseteq~expr$] |
|
309 |
||
310 |
This form of the command interprets $expr$ in the locale $name$. It |
|
311 |
requires a proof that the specification of $name$ implies the |
|
312 |
specification of $expr$. As in the localized version of the theorem |
|
313 |
command, the proof is in the context of $name$. After the proof |
|
314 |
obligation has been dischared, the facts of $expr$ |
|
315 |
become part of locale $name$ as \emph{derived} context elements and |
|
316 |
are available when the context $name$ is subsequently entered. |
|
317 |
Note that, like import, this is dynamic: facts added to a locale |
|
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17043
diff
changeset
|
318 |
part of $expr$ after interpretation become also available in |
17043 | 319 |
$name$. Like facts |
320 |
of renamed context elements, facts obtained by interpretation may be |
|
321 |
accessed by prefixing with the parameter renaming (where the parameters |
|
322 |
are separated by `\_'). |
|
323 |
||
324 |
Unlike interpretation in theories, instantiation is confined to the |
|
325 |
renaming of parameters, which may be specified as part of the context |
|
326 |
expression $expr$. Using defined parameters in $name$ one may |
|
327 |
achieve an effect similar to instantiation, though. |
|
328 |
||
329 |
Only specification fragments of $expr$ that are not already part of |
|
330 |
$name$ (be it imported, derived or a derived fragment of the import) |
|
331 |
are considered by interpretation. This enables circular |
|
332 |
interpretations. |
|
333 |
||
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17043
diff
changeset
|
334 |
If interpretations of $name$ exist in the current theory, the |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17043
diff
changeset
|
335 |
command adds interpretations for $expr$ as well, with the same |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17043
diff
changeset
|
336 |
prefix and attributes, although only for fragments of $expr$ that |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17043
diff
changeset
|
337 |
are not interpreted in the theory already. |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17043
diff
changeset
|
338 |
|
15763
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
339 |
\item [$\isarcmd{interpret}~expr~insts$] |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
340 |
interprets $expr$ in the proof context and is otherwise similar to |
17043 | 341 |
interpretation in theories. Free variables in instantiations are not |
15763
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
342 |
generalized, however. |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
343 |
|
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
344 |
\item [$\isarcmd{print_interps}~loc$] |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
345 |
prints the interpretations of a particular locale $loc$ that are |
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17043
diff
changeset
|
346 |
active in the current context, either theory or proof context. The |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17043
diff
changeset
|
347 |
exclamation point argument causes triggers printing of |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17043
diff
changeset
|
348 |
\emph{witness} theorems justifying interpretations. These are |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17043
diff
changeset
|
349 |
normally omitted from the output. |
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17043
diff
changeset
|
350 |
|
15763
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
351 |
|
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
352 |
\end{descr} |
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
353 |
|
15837 | 354 |
\begin{warn} |
355 |
Since attributes are applied to interpreted theorems, interpretation |
|
356 |
may modify the current simpset and claset. Take this into |
|
357 |
account when choosing attributes for local theorems. |
|
358 |
\end{warn} |
|
359 |
||
16168
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
360 |
\begin{warn} |
17043 | 361 |
An interpretation in a theory may subsume previous interpretations. |
362 |
This happens if the same specification fragment is interpreted twice |
|
363 |
and the instantiation of the second interpretation is more general |
|
364 |
than the interpretation of the first. A warning |
|
16168
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
365 |
is issued, since it is likely that these could have been generalized |
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
366 |
in the first place. The locale package does not attempt to remove |
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
367 |
subsumed interpretations. This situation is normally harmless, but |
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
368 |
note that $blast$ gets confused by the presence of multiple axclass |
17139
165c97f9bb63
Printing of interpretations: option to show witness theorems;
ballarin
parents:
17043
diff
changeset
|
369 |
instances of a rule. |
16168
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
370 |
\end{warn} |
adb83939177f
Locales: new element constrains, parameter renaming with syntax,
ballarin
parents:
16102
diff
changeset
|
371 |
|
15763
b901a127ac73
Interpretation supports statically scoped attributes; documentation.
ballarin
parents:
14605
diff
changeset
|
372 |
|
12621 | 373 |
\section{Derived proof schemes} |
374 |
||
375 |
\subsection{Generalized elimination}\label{sec:obtain} |
|
376 |
||
17864 | 377 |
\indexisarcmd{obtain}\indexisarcmd{guess} |
12621 | 378 |
\begin{matharray}{rcl} |
379 |
\isarcmd{obtain} & : & \isartrans{proof(state)}{proof(prove)} \\ |
|
17864 | 380 |
\isarcmd{guess}^* & : & \isartrans{proof(state)}{proof(prove)} \\ |
12621 | 381 |
\end{matharray} |
382 |
||
383 |
Generalized elimination means that additional elements with certain properties |
|
13041 | 384 |
may be introduced in the current context, by virtue of a locally proven |
12621 | 385 |
``soundness statement''. Technically speaking, the $\OBTAINNAME$ language |
386 |
element is like a declaration of $\FIXNAME$ and $\ASSUMENAME$ (see also see |
|
387 |
\S\ref{sec:proof-context}), together with a soundness proof of its additional |
|
388 |
claim. According to the nature of existential reasoning, assumptions get |
|
389 |
eliminated from any result exported from the context later, provided that the |
|
390 |
corresponding parameters do \emph{not} occur in the conclusion. |
|
391 |
||
392 |
\begin{rail} |
|
18903 | 393 |
'obtain' parname? (vars + 'and') 'where' (props + 'and') |
12621 | 394 |
; |
17864 | 395 |
'guess' (vars + 'and') |
396 |
; |
|
12621 | 397 |
\end{rail} |
12618 | 398 |
|
12621 | 399 |
$\OBTAINNAME$ is defined as a derived Isar command as follows, where $\vec b$ |
400 |
shall refer to (optional) facts indicated for forward chaining. |
|
401 |
\begin{matharray}{l} |
|
402 |
\langle facts~\vec b\rangle \\ |
|
403 |
\OBTAIN{\vec x}{a}{\vec \phi}~~\langle proof\rangle \equiv {} \\[1ex] |
|
13041 | 404 |
\quad \HAVE{}{\All{thesis} (\All{\vec x} \vec\phi \Imp thesis) \Imp thesis} \\ |
405 |
\quad \PROOF{succeed} \\ |
|
12621 | 406 |
\qquad \FIX{thesis} \\ |
13041 | 407 |
\qquad \ASSUME{that~[intro?]}{\All{\vec x} \vec\phi \Imp thesis} \\ |
13042 | 408 |
\qquad \THUS{}{thesis} \\ |
409 |
\quad\qquad \APPLY{-} \\ |
|
13041 | 410 |
\quad\qquad \USING{\vec b}~~\langle proof\rangle \\ |
411 |
\quad \QED{} \\ |
|
12621 | 412 |
\quad \FIX{\vec x}~\ASSUMENAME^\ast~a\colon~\vec\phi \\ |
413 |
\end{matharray} |
|
414 |
||
415 |
Typically, the soundness proof is relatively straight-forward, often just by |
|
13048 | 416 |
canonical automated tools such as ``$\BY{simp}$'' or ``$\BY{blast}$''. |
417 |
Accordingly, the ``$that$'' reduction above is declared as simplification and |
|
418 |
introduction rule. |
|
12621 | 419 |
|
420 |
In a sense, $\OBTAINNAME$ represents at the level of Isar proofs what would be |
|
421 |
meta-logical existential quantifiers and conjunctions. This concept has a |
|
13041 | 422 |
broad range of useful applications, ranging from plain elimination (or |
17864 | 423 |
introduction) of object-level existential and conjunctions, to elimination |
12621 | 424 |
over results of symbolic evaluation of recursive definitions, for example. |
425 |
Also note that $\OBTAINNAME$ without parameters acts much like $\HAVENAME$, |
|
13041 | 426 |
where the result is treated as a genuine assumption. |
12621 | 427 |
|
18903 | 428 |
An alternative name to be used instead of ``$that$'' above may be |
429 |
given in parentheses. |
|
430 |
||
17864 | 431 |
\medskip |
432 |
||
433 |
The improper variant $\isarkeyword{guess}$ is similar to $\OBTAINNAME$, but |
|
434 |
derives the obtained statement from the course of reasoning! The proof starts |
|
435 |
with a fixed goal $thesis$. The subsequent proof may refine this to anything |
|
436 |
of the form like $\All{\vec x} \vec\phi \Imp thesis$, but must not introduce |
|
437 |
new subgoals. The final goal state is then used as reduction rule for the |
|
438 |
obtain scheme described above. Obtained parameters $\vec x$ are marked as |
|
439 |
internal by default, which prevents the proof context from being polluted by |
|
440 |
ad-hoc variables. The variable names and type constraints given as arguments |
|
441 |
for $\isarkeyword{guess}$ specify a prefix of obtained parameters explicitly |
|
442 |
in the text. |
|
443 |
||
444 |
It is important to note that the facts introduced by $\OBTAINNAME$ and |
|
445 |
$\isarkeyword{guess}$ may not be polymorphic: any type-variables occurring |
|
446 |
here are fixed in the present context! |
|
447 |
||
12621 | 448 |
|
449 |
\subsection{Calculational reasoning}\label{sec:calculation} |
|
7315 | 450 |
|
8619 | 451 |
\indexisarcmd{also}\indexisarcmd{finally} |
452 |
\indexisarcmd{moreover}\indexisarcmd{ultimately} |
|
12976 | 453 |
\indexisarcmd{print-trans-rules} |
454 |
\indexisaratt{trans}\indexisaratt{sym}\indexisaratt{symmetric} |
|
7315 | 455 |
\begin{matharray}{rcl} |
456 |
\isarcmd{also} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
457 |
\isarcmd{finally} & : & \isartrans{proof(state)}{proof(chain)} \\ |
|
8619 | 458 |
\isarcmd{moreover} & : & \isartrans{proof(state)}{proof(state)} \\ |
459 |
\isarcmd{ultimately} & : & \isartrans{proof(state)}{proof(chain)} \\ |
|
10154 | 460 |
\isarcmd{print_trans_rules}^* & : & \isarkeep{theory~|~proof} \\ |
7315 | 461 |
trans & : & \isaratt \\ |
12976 | 462 |
sym & : & \isaratt \\ |
463 |
symmetric & : & \isaratt \\ |
|
7315 | 464 |
\end{matharray} |
465 |
||
466 |
Calculational proof is forward reasoning with implicit application of |
|
11332 | 467 |
transitivity rules (such those of $=$, $\leq$, $<$). Isabelle/Isar maintains |
7391 | 468 |
an auxiliary register $calculation$\indexisarthm{calculation} for accumulating |
7897 | 469 |
results obtained by transitivity composed with the current result. Command |
470 |
$\ALSO$ updates $calculation$ involving $this$, while $\FINALLY$ exhibits the |
|
471 |
final $calculation$ by forward chaining towards the next goal statement. Both |
|
472 |
commands require valid current facts, i.e.\ may occur only after commands that |
|
473 |
produce theorems such as $\ASSUMENAME$, $\NOTENAME$, or some finished proof of |
|
8619 | 474 |
$\HAVENAME$, $\SHOWNAME$ etc. The $\MOREOVER$ and $\ULTIMATELY$ commands are |
475 |
similar to $\ALSO$ and $\FINALLY$, but only collect further results in |
|
476 |
$calculation$ without applying any rules yet. |
|
7315 | 477 |
|
13041 | 478 |
Also note that the implicit term abbreviation ``$\dots$'' has its canonical |
479 |
application with calculational proofs. It refers to the argument of the |
|
480 |
preceding statement. (The argument of a curried infix expression happens to be |
|
481 |
its right-hand side.) |
|
7315 | 482 |
|
483 |
Isabelle/Isar calculations are implicitly subject to block structure in the |
|
484 |
sense that new threads of calculational reasoning are commenced for any new |
|
485 |
block (as opened by a local goal, for example). This means that, apart from |
|
486 |
being able to nest calculations, there is no separate \emph{begin-calculation} |
|
487 |
command required. |
|
488 |
||
8619 | 489 |
\medskip |
490 |
||
13041 | 491 |
The Isar calculation proof commands may be defined as follows:\footnote{We |
492 |
suppress internal bookkeeping such as proper handling of block-structure.} |
|
8619 | 493 |
\begin{matharray}{rcl} |
494 |
\ALSO@0 & \equiv & \NOTE{calculation}{this} \\ |
|
9606 | 495 |
\ALSO@{n+1} & \equiv & \NOTE{calculation}{trans~[OF~calculation~this]} \\[0.5ex] |
8619 | 496 |
\FINALLY & \equiv & \ALSO~\FROM{calculation} \\ |
497 |
\MOREOVER & \equiv & \NOTE{calculation}{calculation~this} \\ |
|
498 |
\ULTIMATELY & \equiv & \MOREOVER~\FROM{calculation} \\ |
|
499 |
\end{matharray} |
|
500 |
||
7315 | 501 |
\begin{rail} |
13024 | 502 |
('also' | 'finally') ('(' thmrefs ')')? |
8619 | 503 |
; |
8507 | 504 |
'trans' (() | 'add' | 'del') |
7315 | 505 |
; |
506 |
\end{rail} |
|
507 |
||
508 |
\begin{descr} |
|
13041 | 509 |
|
8547 | 510 |
\item [$\ALSO~(\vec a)$] maintains the auxiliary $calculation$ register as |
7315 | 511 |
follows. The first occurrence of $\ALSO$ in some calculational thread |
7905 | 512 |
initializes $calculation$ by $this$. Any subsequent $\ALSO$ on the same |
7335 | 513 |
level of block-structure updates $calculation$ by some transitivity rule |
7458 | 514 |
applied to $calculation$ and $this$ (in that order). Transitivity rules are |
11095 | 515 |
picked from the current context, unless alternative rules are given as |
516 |
explicit arguments. |
|
9614 | 517 |
|
8547 | 518 |
\item [$\FINALLY~(\vec a)$] maintaining $calculation$ in the same way as |
7315 | 519 |
$\ALSO$, and concludes the current calculational thread. The final result |
520 |
is exhibited as fact for forward chaining towards the next goal. Basically, |
|
7987 | 521 |
$\FINALLY$ just abbreviates $\ALSO~\FROM{calculation}$. Note that |
522 |
``$\FINALLY~\SHOW{}{\Var{thesis}}~\DOT$'' and |
|
523 |
``$\FINALLY~\HAVE{}{\phi}~\DOT$'' are typical idioms for concluding |
|
524 |
calculational proofs. |
|
9614 | 525 |
|
8619 | 526 |
\item [$\MOREOVER$ and $\ULTIMATELY$] are analogous to $\ALSO$ and $\FINALLY$, |
527 |
but collect results only, without applying rules. |
|
13041 | 528 |
|
13024 | 529 |
\item [$\isarkeyword{print_trans_rules}$] prints the list of transitivity |
530 |
rules (for calculational commands $\ALSO$ and $\FINALLY$) and symmetry rules |
|
531 |
(for the $symmetric$ operation and single step elimination patters) of the |
|
532 |
current context. |
|
13041 | 533 |
|
8547 | 534 |
\item [$trans$] declares theorems as transitivity rules. |
13041 | 535 |
|
13024 | 536 |
\item [$sym$] declares symmetry rules. |
13041 | 537 |
|
12976 | 538 |
\item [$symmetric$] resolves a theorem with some rule declared as $sym$ in the |
539 |
current context. For example, ``$\ASSUME{[symmetric]}{x = y}$'' produces a |
|
540 |
swapped fact derived from that assumption. |
|
13041 | 541 |
|
13024 | 542 |
In structured proof texts it is often more appropriate to use an explicit |
543 |
single-step elimination proof, such as ``$\ASSUME{}{x = y}~\HENCE{}{y = |
|
13041 | 544 |
x}~\DDOT$''. The very same rules known to $symmetric$ are declared as |
545 |
$elim?$ as well. |
|
13027 | 546 |
|
7315 | 547 |
\end{descr} |
548 |
||
549 |
||
13041 | 550 |
\section{Proof tools} |
8517 | 551 |
|
12618 | 552 |
\subsection{Miscellaneous methods and attributes}\label{sec:misc-meth-att} |
8517 | 553 |
|
9606 | 554 |
\indexisarmeth{unfold}\indexisarmeth{fold}\indexisarmeth{insert} |
8517 | 555 |
\indexisarmeth{erule}\indexisarmeth{drule}\indexisarmeth{frule} |
556 |
\indexisarmeth{fail}\indexisarmeth{succeed} |
|
557 |
\begin{matharray}{rcl} |
|
558 |
unfold & : & \isarmeth \\ |
|
10741 | 559 |
fold & : & \isarmeth \\ |
560 |
insert & : & \isarmeth \\[0.5ex] |
|
8517 | 561 |
erule^* & : & \isarmeth \\ |
562 |
drule^* & : & \isarmeth \\ |
|
13024 | 563 |
frule^* & : & \isarmeth \\ |
8517 | 564 |
succeed & : & \isarmeth \\ |
565 |
fail & : & \isarmeth \\ |
|
566 |
\end{matharray} |
|
7135 | 567 |
|
568 |
\begin{rail} |
|
10741 | 569 |
('fold' | 'unfold' | 'insert') thmrefs |
570 |
; |
|
571 |
('erule' | 'drule' | 'frule') ('('nat')')? thmrefs |
|
7135 | 572 |
; |
573 |
\end{rail} |
|
574 |
||
7167 | 575 |
\begin{descr} |
13041 | 576 |
|
13024 | 577 |
\item [$unfold~\vec a$ and $fold~\vec a$] expand (or fold back again) the |
578 |
given meta-level definitions throughout all goals; any chained facts |
|
579 |
provided are inserted into the goal and subject to rewriting as well. |
|
13041 | 580 |
|
10741 | 581 |
\item [$insert~\vec a$] inserts theorems as facts into all goals of the proof |
582 |
state. Note that current facts indicated for forward chaining are ignored. |
|
13024 | 583 |
|
8547 | 584 |
\item [$erule~\vec a$, $drule~\vec a$, and $frule~\vec a$] are similar to the |
585 |
basic $rule$ method (see \S\ref{sec:pure-meth-att}), but apply rules by |
|
8517 | 586 |
elim-resolution, destruct-resolution, and forward-resolution, respectively |
10741 | 587 |
\cite{isabelle-ref}. The optional natural number argument (default $0$) |
13041 | 588 |
specifies additional assumption steps to be performed here. |
589 |
||
10741 | 590 |
Note that these methods are improper ones, mainly serving for |
591 |
experimentation and tactic script emulation. Different modes of basic rule |
|
592 |
application are usually expressed in Isar at the proof language level, |
|
593 |
rather than via implicit proof state manipulations. For example, a proper |
|
13041 | 594 |
single-step elimination would be done using the plain $rule$ method, with |
10741 | 595 |
forward chaining of current facts. |
13024 | 596 |
|
8517 | 597 |
\item [$succeed$] yields a single (unchanged) result; it is the identity of |
598 |
the ``\texttt{,}'' method combinator (cf.\ \S\ref{sec:syn-meth}). |
|
13024 | 599 |
|
8517 | 600 |
\item [$fail$] yields an empty result sequence; it is the identity of the |
601 |
``\texttt{|}'' method combinator (cf.\ \S\ref{sec:syn-meth}). |
|
13024 | 602 |
|
7167 | 603 |
\end{descr} |
7135 | 604 |
|
10318 | 605 |
\indexisaratt{tagged}\indexisaratt{untagged} |
9614 | 606 |
\indexisaratt{THEN}\indexisaratt{COMP} |
14175
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
607 |
\indexisaratt{unfolded}\indexisaratt{folded} |
13027 | 608 |
\indexisaratt{standard}\indexisarattof{Pure}{elim-format} |
13024 | 609 |
\indexisaratt{no-vars} |
8517 | 610 |
\begin{matharray}{rcl} |
9905 | 611 |
tagged & : & \isaratt \\ |
612 |
untagged & : & \isaratt \\[0.5ex] |
|
9614 | 613 |
THEN & : & \isaratt \\ |
8517 | 614 |
COMP & : & \isaratt \\[0.5ex] |
9905 | 615 |
unfolded & : & \isaratt \\ |
616 |
folded & : & \isaratt \\[0.5ex] |
|
9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9936
diff
changeset
|
617 |
elim_format & : & \isaratt \\ |
13041 | 618 |
standard^* & : & \isaratt \\ |
9936 | 619 |
no_vars^* & : & \isaratt \\ |
8517 | 620 |
\end{matharray} |
621 |
||
622 |
\begin{rail} |
|
9905 | 623 |
'tagged' (nameref+) |
8517 | 624 |
; |
9905 | 625 |
'untagged' name |
8517 | 626 |
; |
10154 | 627 |
('THEN' | 'COMP') ('[' nat ']')? thmref |
8517 | 628 |
; |
9905 | 629 |
('unfolded' | 'folded') thmrefs |
8517 | 630 |
; |
631 |
\end{rail} |
|
632 |
||
633 |
\begin{descr} |
|
13041 | 634 |
|
9905 | 635 |
\item [$tagged~name~args$ and $untagged~name$] add and remove $tags$ of some |
8517 | 636 |
theorem. Tags may be any list of strings that serve as comment for some |
637 |
tools (e.g.\ $\LEMMANAME$ causes the tag ``$lemma$'' to be added to the |
|
638 |
result). The first string is considered the tag name, the rest its |
|
639 |
arguments. Note that untag removes any tags of the same name. |
|
13041 | 640 |
|
641 |
\item [$THEN~a$ and $COMP~a$] compose rules by resolution. $THEN$ resolves |
|
642 |
with the first premise of $a$ (an alternative position may be also |
|
643 |
specified); the $COMP$ version skips the automatic lifting process that is |
|
644 |
normally intended (cf.\ \texttt{RS} and \texttt{COMP} in |
|
8547 | 645 |
\cite[\S5]{isabelle-ref}). |
13041 | 646 |
|
9905 | 647 |
\item [$unfolded~\vec a$ and $folded~\vec a$] expand and fold back again the |
648 |
given meta-level definitions throughout a rule. |
|
13041 | 649 |
|
13027 | 650 |
\item [$elim_format$] turns a destruction rule into elimination rule format, |
651 |
by resolving with the rule $\PROP A \Imp (\PROP A \Imp \PROP B) \Imp \PROP |
|
652 |
B$. |
|
13048 | 653 |
|
654 |
Note that the Classical Reasoner (\S\ref{sec:classical}) provides its own |
|
655 |
version of this operation. |
|
13041 | 656 |
|
657 |
\item [$standard$] puts a theorem into the standard form of object-rules at |
|
658 |
the outermost theory level. Note that this operation violates the local |
|
659 |
proof context (including active locales). |
|
660 |
||
9232 | 661 |
\item [$no_vars$] replaces schematic variables by free ones; this is mainly |
662 |
for tuning output of pretty printed theorems. |
|
13027 | 663 |
|
8517 | 664 |
\end{descr} |
7135 | 665 |
|
666 |
||
12621 | 667 |
\subsection{Further tactic emulations}\label{sec:tactics} |
9606 | 668 |
|
669 |
The following improper proof methods emulate traditional tactics. These admit |
|
670 |
direct access to the goal state, which is normally considered harmful! In |
|
671 |
particular, this may involve both numbered goal addressing (default 1), and |
|
672 |
dynamic instantiation within the scope of some subgoal. |
|
673 |
||
674 |
\begin{warn} |
|
14175
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
675 |
Dynamic instantiations refer to universally quantified parameters of |
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
676 |
a subgoal (the dynamic context) rather than fixed variables and term |
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
677 |
abbreviations of a (static) Isar context. |
9606 | 678 |
\end{warn} |
679 |
||
14175
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
680 |
Tactic emulation methods, unlike their ML counterparts, admit |
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
681 |
simultaneous instantiation from both dynamic and static contexts. If |
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
682 |
names occur in both contexts goal parameters hide locally fixed |
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
683 |
variables. Likewise, schematic variables refer to term abbreviations, |
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
684 |
if present in the static context. Otherwise the schematic variable is |
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
685 |
interpreted as a schematic variable and left to be solved by unification |
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
686 |
with certain parts of the subgoal. |
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
687 |
|
9606 | 688 |
Note that the tactic emulation proof methods in Isabelle/Isar are consistently |
14175
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
689 |
named $foo_tac$. Note also that variable names occurring on left hand sides |
14212 | 690 |
of instantiations must be preceded by a question mark if they coincide with |
691 |
a keyword or contain dots. |
|
14175
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13622
diff
changeset
|
692 |
This is consistent with the attribute $where$ (see \S\ref{sec:pure-meth-att}). |
9606 | 693 |
|
694 |
\indexisarmeth{rule-tac}\indexisarmeth{erule-tac} |
|
695 |
\indexisarmeth{drule-tac}\indexisarmeth{frule-tac} |
|
696 |
\indexisarmeth{cut-tac}\indexisarmeth{thin-tac} |
|
9642 | 697 |
\indexisarmeth{subgoal-tac}\indexisarmeth{rename-tac} |
9614 | 698 |
\indexisarmeth{rotate-tac}\indexisarmeth{tactic} |
9606 | 699 |
\begin{matharray}{rcl} |
700 |
rule_tac^* & : & \isarmeth \\ |
|
701 |
erule_tac^* & : & \isarmeth \\ |
|
702 |
drule_tac^* & : & \isarmeth \\ |
|
703 |
frule_tac^* & : & \isarmeth \\ |
|
704 |
cut_tac^* & : & \isarmeth \\ |
|
705 |
thin_tac^* & : & \isarmeth \\ |
|
706 |
subgoal_tac^* & : & \isarmeth \\ |
|
9614 | 707 |
rename_tac^* & : & \isarmeth \\ |
708 |
rotate_tac^* & : & \isarmeth \\ |
|
9606 | 709 |
tactic^* & : & \isarmeth \\ |
710 |
\end{matharray} |
|
711 |
||
712 |
\railalias{ruletac}{rule\_tac} |
|
713 |
\railterm{ruletac} |
|
714 |
||
715 |
\railalias{eruletac}{erule\_tac} |
|
716 |
\railterm{eruletac} |
|
717 |
||
718 |
\railalias{druletac}{drule\_tac} |
|
719 |
\railterm{druletac} |
|
720 |
||
721 |
\railalias{fruletac}{frule\_tac} |
|
722 |
\railterm{fruletac} |
|
723 |
||
724 |
\railalias{cuttac}{cut\_tac} |
|
725 |
\railterm{cuttac} |
|
726 |
||
727 |
\railalias{thintac}{thin\_tac} |
|
728 |
\railterm{thintac} |
|
729 |
||
730 |
\railalias{subgoaltac}{subgoal\_tac} |
|
731 |
\railterm{subgoaltac} |
|
732 |
||
9614 | 733 |
\railalias{renametac}{rename\_tac} |
734 |
\railterm{renametac} |
|
735 |
||
736 |
\railalias{rotatetac}{rotate\_tac} |
|
737 |
\railterm{rotatetac} |
|
738 |
||
9606 | 739 |
\begin{rail} |
740 |
( ruletac | eruletac | druletac | fruletac | cuttac | thintac ) goalspec? |
|
741 |
( insts thmref | thmrefs ) |
|
742 |
; |
|
743 |
subgoaltac goalspec? (prop +) |
|
744 |
; |
|
9614 | 745 |
renametac goalspec? (name +) |
746 |
; |
|
747 |
rotatetac goalspec? int? |
|
748 |
; |
|
9606 | 749 |
'tactic' text |
750 |
; |
|
751 |
||
752 |
insts: ((name '=' term) + 'and') 'in' |
|
753 |
; |
|
754 |
\end{rail} |
|
755 |
||
756 |
\begin{descr} |
|
13041 | 757 |
|
9606 | 758 |
\item [$rule_tac$ etc.] do resolution of rules with explicit instantiation. |
759 |
This works the same way as the ML tactics \texttt{res_inst_tac} etc. (see |
|
760 |
\cite[\S3]{isabelle-ref}). |
|
13041 | 761 |
|
762 |
Multiple rules may be only given if there is no instantiation; then |
|
9606 | 763 |
$rule_tac$ is the same as \texttt{resolve_tac} in ML (see |
764 |
\cite[\S3]{isabelle-ref}). |
|
13041 | 765 |
|
9606 | 766 |
\item [$cut_tac$] inserts facts into the proof state as assumption of a |
767 |
subgoal, see also \texttt{cut_facts_tac} in \cite[\S3]{isabelle-ref}. Note |
|
13027 | 768 |
that the scope of schematic variables is spread over the main goal |
769 |
statement. Instantiations may be given as well, see also ML tactic |
|
9606 | 770 |
\texttt{cut_inst_tac} in \cite[\S3]{isabelle-ref}. |
13041 | 771 |
|
9606 | 772 |
\item [$thin_tac~\phi$] deletes the specified assumption from a subgoal; note |
773 |
that $\phi$ may contain schematic variables. See also \texttt{thin_tac} in |
|
774 |
\cite[\S3]{isabelle-ref}. |
|
13041 | 775 |
|
9606 | 776 |
\item [$subgoal_tac~\phi$] adds $\phi$ as an assumption to a subgoal. See |
777 |
also \texttt{subgoal_tac} and \texttt{subgoals_tac} in |
|
778 |
\cite[\S3]{isabelle-ref}. |
|
13041 | 779 |
|
9614 | 780 |
\item [$rename_tac~\vec x$] renames parameters of a goal according to the list |
781 |
$\vec x$, which refers to the \emph{suffix} of variables. |
|
13041 | 782 |
|
9614 | 783 |
\item [$rotate_tac~n$] rotates the assumptions of a goal by $n$ positions: |
784 |
from right to left if $n$ is positive, and from left to right if $n$ is |
|
785 |
negative; the default value is $1$. See also \texttt{rotate_tac} in |
|
786 |
\cite[\S3]{isabelle-ref}. |
|
13041 | 787 |
|
9606 | 788 |
\item [$tactic~text$] produces a proof method from any ML text of type |
789 |
\texttt{tactic}. Apart from the usual ML environment and the current |
|
790 |
implicit theory context, the ML code may refer to the following locally |
|
791 |
bound values: |
|
792 |
||
793 |
{\footnotesize\begin{verbatim} |
|
794 |
val ctxt : Proof.context |
|
795 |
val facts : thm list |
|
796 |
val thm : string -> thm |
|
797 |
val thms : string -> thm list |
|
798 |
\end{verbatim}} |
|
799 |
Here \texttt{ctxt} refers to the current proof context, \texttt{facts} |
|
800 |
indicates any current facts for forward-chaining, and |
|
801 |
\texttt{thm}~/~\texttt{thms} retrieve named facts (including global |
|
802 |
theorems) from the context. |
|
803 |
\end{descr} |
|
804 |
||
805 |
||
12621 | 806 |
\subsection{The Simplifier}\label{sec:simplifier} |
807 |
||
13048 | 808 |
\subsubsection{Simplification methods} |
12618 | 809 |
|
8483 | 810 |
\indexisarmeth{simp}\indexisarmeth{simp-all} |
7315 | 811 |
\begin{matharray}{rcl} |
812 |
simp & : & \isarmeth \\ |
|
8483 | 813 |
simp_all & : & \isarmeth \\ |
7315 | 814 |
\end{matharray} |
815 |
||
8483 | 816 |
\railalias{simpall}{simp\_all} |
817 |
\railterm{simpall} |
|
818 |
||
8704 | 819 |
\railalias{noasm}{no\_asm} |
820 |
\railterm{noasm} |
|
821 |
||
822 |
\railalias{noasmsimp}{no\_asm\_simp} |
|
823 |
\railterm{noasmsimp} |
|
824 |
||
825 |
\railalias{noasmuse}{no\_asm\_use} |
|
826 |
\railterm{noasmuse} |
|
827 |
||
13617 | 828 |
\railalias{asmlr}{asm\_lr} |
829 |
\railterm{asmlr} |
|
830 |
||
11128 | 831 |
\indexouternonterm{simpmod} |
7315 | 832 |
\begin{rail} |
13027 | 833 |
('simp' | simpall) ('!' ?) opt? (simpmod *) |
7315 | 834 |
; |
835 |
||
13617 | 836 |
opt: '(' (noasm | noasmsimp | noasmuse | asmlr) ')' |
8704 | 837 |
; |
9711 | 838 |
simpmod: ('add' | 'del' | 'only' | 'cong' (() | 'add' | 'del') | |
9847 | 839 |
'split' (() | 'add' | 'del')) ':' thmrefs |
7315 | 840 |
; |
841 |
\end{rail} |
|
842 |
||
7321 | 843 |
\begin{descr} |
13015 | 844 |
|
8547 | 845 |
\item [$simp$] invokes Isabelle's simplifier, after declaring additional rules |
8594 | 846 |
according to the arguments given. Note that the \railtterm{only} modifier |
8547 | 847 |
first removes all other rewrite rules, congruences, and looper tactics |
8594 | 848 |
(including splits), and then behaves like \railtterm{add}. |
13041 | 849 |
|
9711 | 850 |
\medskip The \railtterm{cong} modifiers add or delete Simplifier congruence |
851 |
rules (see also \cite{isabelle-ref}), the default is to add. |
|
13041 | 852 |
|
9711 | 853 |
\medskip The \railtterm{split} modifiers add or delete rules for the |
854 |
Splitter (see also \cite{isabelle-ref}), the default is to add. This works |
|
855 |
only if the Simplifier method has been properly setup to include the |
|
856 |
Splitter (all major object logics such HOL, HOLCF, FOL, ZF do this already). |
|
13041 | 857 |
|
13015 | 858 |
\item [$simp_all$] is similar to $simp$, but acts on all goals (backwards from |
859 |
the last to the first one). |
|
860 |
||
7321 | 861 |
\end{descr} |
862 |
||
13015 | 863 |
By default the Simplifier methods take local assumptions fully into account, |
864 |
using equational assumptions in the subsequent normalization process, or |
|
13024 | 865 |
simplifying assumptions themselves (cf.\ \texttt{asm_full_simp_tac} in |
13015 | 866 |
\cite[\S10]{isabelle-ref}). In structured proofs this is usually quite well |
867 |
behaved in practice: just the local premises of the actual goal are involved, |
|
13041 | 868 |
additional facts may be inserted via explicit forward-chaining (using $\THEN$, |
13015 | 869 |
$\FROMNAME$ etc.). The full context of assumptions is only included if the |
870 |
``$!$'' (bang) argument is given, which should be used with some care, though. |
|
7321 | 871 |
|
13015 | 872 |
Additional Simplifier options may be specified to tune the behavior further |
13041 | 873 |
(mostly for unstructured scripts with many accidental local facts): |
874 |
``$(no_asm)$'' means assumptions are ignored completely (cf.\ |
|
875 |
\texttt{simp_tac}), ``$(no_asm_simp)$'' means assumptions are used in the |
|
876 |
simplification of the conclusion but are not themselves simplified (cf.\ |
|
877 |
\texttt{asm_simp_tac}), and ``$(no_asm_use)$'' means assumptions are |
|
878 |
simplified but are not used in the simplification of each other or the |
|
879 |
conclusion (cf.\ \texttt{full_simp_tac}). |
|
13617 | 880 |
For compatibility reasons, there is also an option ``$(asm_lr)$'', |
881 |
which means that an assumption is only used for simplifying assumptions |
|
882 |
which are to the right of it (cf.\ \texttt{asm_lr_simp_tac}). |
|
8704 | 883 |
|
884 |
\medskip |
|
885 |
||
886 |
The Splitter package is usually configured to work as part of the Simplifier. |
|
9711 | 887 |
The effect of repeatedly applying \texttt{split_tac} can be simulated by |
13041 | 888 |
``$(simp~only\colon~split\colon~\vec a)$''. There is also a separate $split$ |
889 |
method available for single-step case splitting. |
|
8483 | 890 |
|
891 |
||
12621 | 892 |
\subsubsection{Declaring rules} |
8483 | 893 |
|
8667 | 894 |
\indexisarcmd{print-simpset} |
8638 | 895 |
\indexisaratt{simp}\indexisaratt{split}\indexisaratt{cong} |
7321 | 896 |
\begin{matharray}{rcl} |
13024 | 897 |
\isarcmd{print_simpset}^* & : & \isarkeep{theory~|~proof} \\ |
7321 | 898 |
simp & : & \isaratt \\ |
9711 | 899 |
cong & : & \isaratt \\ |
8483 | 900 |
split & : & \isaratt \\ |
7321 | 901 |
\end{matharray} |
902 |
||
903 |
\begin{rail} |
|
9711 | 904 |
('simp' | 'cong' | 'split') (() | 'add' | 'del') |
7321 | 905 |
; |
906 |
\end{rail} |
|
907 |
||
908 |
\begin{descr} |
|
13024 | 909 |
|
910 |
\item [$\isarcmd{print_simpset}$] prints the collection of rules declared to |
|
911 |
the Simplifier, which is also known as ``simpset'' internally |
|
8667 | 912 |
\cite{isabelle-ref}. This is a diagnostic command; $undo$ does not apply. |
13024 | 913 |
|
8547 | 914 |
\item [$simp$] declares simplification rules. |
13024 | 915 |
|
8638 | 916 |
\item [$cong$] declares congruence rules. |
13024 | 917 |
|
9711 | 918 |
\item [$split$] declares case split rules. |
13024 | 919 |
|
7321 | 920 |
\end{descr} |
7319 | 921 |
|
7315 | 922 |
|
12621 | 923 |
\subsubsection{Forward simplification} |
924 |
||
9905 | 925 |
\indexisaratt{simplified} |
7315 | 926 |
\begin{matharray}{rcl} |
9905 | 927 |
simplified & : & \isaratt \\ |
7315 | 928 |
\end{matharray} |
929 |
||
9905 | 930 |
\begin{rail} |
13015 | 931 |
'simplified' opt? thmrefs? |
9905 | 932 |
; |
933 |
||
934 |
opt: '(' (noasm | noasmsimp | noasmuse) ')' |
|
935 |
; |
|
936 |
\end{rail} |
|
7905 | 937 |
|
9905 | 938 |
\begin{descr} |
13048 | 939 |
|
13015 | 940 |
\item [$simplified~\vec a$] causes a theorem to be simplified, either by |
941 |
exactly the specified rules $\vec a$, or the implicit Simplifier context if |
|
942 |
no arguments are given. The result is fully simplified by default, |
|
943 |
including assumptions and conclusion; the options $no_asm$ etc.\ tune the |
|
13048 | 944 |
Simplifier in the same way as the for the $simp$ method. |
13041 | 945 |
|
13015 | 946 |
Note that forward simplification restricts the simplifier to its most basic |
947 |
operation of term rewriting; solver and looper tactics \cite{isabelle-ref} |
|
948 |
are \emph{not} involved here. The $simplified$ attribute should be only |
|
949 |
rarely required under normal circumstances. |
|
950 |
||
9905 | 951 |
\end{descr} |
7315 | 952 |
|
953 |
||
13048 | 954 |
\subsubsection{Low-level equational reasoning} |
9614 | 955 |
|
12976 | 956 |
\indexisarmeth{subst}\indexisarmeth{hypsubst}\indexisarmeth{split} |
9614 | 957 |
\begin{matharray}{rcl} |
13015 | 958 |
subst^* & : & \isarmeth \\ |
9614 | 959 |
hypsubst^* & : & \isarmeth \\ |
13015 | 960 |
split^* & : & \isarmeth \\ |
9614 | 961 |
\end{matharray} |
962 |
||
963 |
\begin{rail} |
|
15995 | 964 |
'subst' ('(' 'asm' ')')? ('(' (nat+) ')')? thmref |
9614 | 965 |
; |
9799 | 966 |
'split' ('(' 'asm' ')')? thmrefs |
9703 | 967 |
; |
9614 | 968 |
\end{rail} |
969 |
||
13015 | 970 |
These methods provide low-level facilities for equational reasoning that are |
971 |
intended for specialized applications only. Normally, single step |
|
972 |
calculations would be performed in a structured text (see also |
|
973 |
\S\ref{sec:calculation}), while the Simplifier methods provide the canonical |
|
974 |
way for automated normalization (see \S\ref{sec:simplifier}). |
|
9614 | 975 |
|
976 |
\begin{descr} |
|
13041 | 977 |
|
15995 | 978 |
\item [$subst~eq$] performs a single substitution step using rule $eq$, which |
13041 | 979 |
may be either a meta or object equality. |
980 |
||
15995 | 981 |
\item [$subst~(asm)~eq$] substitutes in an assumption. |
982 |
||
983 |
\item [$subst~(i \dots j)~eq$] performs several substitutions in the |
|
984 |
conclusion. The numbers $i$ to $j$ indicate the positions to substitute at. |
|
985 |
Positions are ordered from the top of the term tree moving down from left to |
|
986 |
right. For example, in $(a+b)+(c+d)$ there are three positions where |
|
987 |
commutativity of $+$ is applicable: 1 refers to the whole term, 2 to $a+b$ |
|
988 |
and 3 to $c+d$. If the positions in the list $(i \dots j)$ are |
|
989 |
non-overlapping (e.g. $(2~3)$ in $(a+b)+(c+d)$) you may assume all |
|
990 |
substitutions are performed simultaneously. Otherwise the behaviour of |
|
991 |
$subst$ is not specified. |
|
992 |
||
993 |
\item [$subst~(asm)~(i \dots j)~eq$] performs the substitutions in the |
|
16010 | 994 |
assumptions. Positions $1 \dots i@1$ refer |
995 |
to assumption 1, positions $i@1+1 \dots i@2$ to assumption 2, and so on. |
|
15995 | 996 |
|
13041 | 997 |
\item [$hypsubst$] performs substitution using some assumption; this only |
998 |
works for equations of the form $x = t$ where $x$ is a free or bound |
|
999 |
variable. |
|
1000 |
||
1001 |
\item [$split~\vec a$] performs single-step case splitting using rules $thms$. |
|
9799 | 1002 |
By default, splitting is performed in the conclusion of a goal; the $asm$ |
1003 |
option indicates to operate on assumptions instead. |
|
13048 | 1004 |
|
9703 | 1005 |
Note that the $simp$ method already involves repeated application of split |
13048 | 1006 |
rules as declared in the current context. |
9614 | 1007 |
\end{descr} |
1008 |
||
1009 |
||
12621 | 1010 |
\subsection{The Classical Reasoner}\label{sec:classical} |
7135 | 1011 |
|
13048 | 1012 |
\subsubsection{Basic methods} |
7321 | 1013 |
|
13024 | 1014 |
\indexisarmeth{rule}\indexisarmeth{default}\indexisarmeth{contradiction} |
1015 |
\indexisarmeth{intro}\indexisarmeth{elim} |
|
7321 | 1016 |
\begin{matharray}{rcl} |
1017 |
rule & : & \isarmeth \\ |
|
13024 | 1018 |
contradiction & : & \isarmeth \\ |
7321 | 1019 |
intro & : & \isarmeth \\ |
1020 |
elim & : & \isarmeth \\ |
|
1021 |
\end{matharray} |
|
1022 |
||
1023 |
\begin{rail} |
|
8547 | 1024 |
('rule' | 'intro' | 'elim') thmrefs? |
7321 | 1025 |
; |
1026 |
\end{rail} |
|
1027 |
||
1028 |
\begin{descr} |
|
13041 | 1029 |
|
7466 | 1030 |
\item [$rule$] as offered by the classical reasoner is a refinement over the |
13024 | 1031 |
primitive one (see \S\ref{sec:pure-meth-att}). Both versions essentially |
1032 |
work the same, but the classical version observes the classical rule context |
|
13041 | 1033 |
in addition to that of Isabelle/Pure. |
1034 |
||
1035 |
Common object logics (HOL, ZF, etc.) declare a rich collection of classical |
|
1036 |
rules (even if these would qualify as intuitionistic ones), but only few |
|
1037 |
declarations to the rule context of Isabelle/Pure |
|
1038 |
(\S\ref{sec:pure-meth-att}). |
|
1039 |
||
13024 | 1040 |
\item [$contradiction$] solves some goal by contradiction, deriving any result |
13041 | 1041 |
from both $\neg A$ and $A$. Chained facts, which are guaranteed to |
1042 |
participate, may appear in either order. |
|
9614 | 1043 |
|
7466 | 1044 |
\item [$intro$ and $elim$] repeatedly refine some goal by intro- or |
13041 | 1045 |
elim-resolution, after having inserted any chained facts. Exactly the rules |
1046 |
given as arguments are taken into account; this allows fine-tuned |
|
1047 |
decomposition of a proof problem, in contrast to common automated tools. |
|
1048 |
||
7321 | 1049 |
\end{descr} |
1050 |
||
1051 |
||
13048 | 1052 |
\subsubsection{Automated methods} |
7315 | 1053 |
|
9799 | 1054 |
\indexisarmeth{blast}\indexisarmeth{fast}\indexisarmeth{slow} |
1055 |
\indexisarmeth{best}\indexisarmeth{safe}\indexisarmeth{clarify} |
|
7321 | 1056 |
\begin{matharray}{rcl} |
9780 | 1057 |
blast & : & \isarmeth \\ |
1058 |
fast & : & \isarmeth \\ |
|
9799 | 1059 |
slow & : & \isarmeth \\ |
9780 | 1060 |
best & : & \isarmeth \\ |
1061 |
safe & : & \isarmeth \\ |
|
1062 |
clarify & : & \isarmeth \\ |
|
7321 | 1063 |
\end{matharray} |
1064 |
||
11128 | 1065 |
\indexouternonterm{clamod} |
7321 | 1066 |
\begin{rail} |
13027 | 1067 |
'blast' ('!' ?) nat? (clamod *) |
7321 | 1068 |
; |
13027 | 1069 |
('fast' | 'slow' | 'best' | 'safe' | 'clarify') ('!' ?) (clamod *) |
7321 | 1070 |
; |
1071 |
||
9408 | 1072 |
clamod: (('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del') ':' thmrefs |
7321 | 1073 |
; |
1074 |
\end{rail} |
|
1075 |
||
1076 |
\begin{descr} |
|
1077 |
\item [$blast$] refers to the classical tableau prover (see \texttt{blast_tac} |
|
7335 | 1078 |
in \cite[\S11]{isabelle-ref}). The optional argument specifies a |
10858 | 1079 |
user-supplied search bound (default 20). |
9799 | 1080 |
\item [$fast$, $slow$, $best$, $safe$, and $clarify$] refer to the generic |
1081 |
classical reasoner. See \texttt{fast_tac}, \texttt{slow_tac}, |
|
1082 |
\texttt{best_tac}, \texttt{safe_tac}, and \texttt{clarify_tac} in |
|
1083 |
\cite[\S11]{isabelle-ref} for more information. |
|
7321 | 1084 |
\end{descr} |
1085 |
||
13041 | 1086 |
Any of the above methods support additional modifiers of the context of |
1087 |
classical rules. Their semantics is analogous to the attributes given before. |
|
1088 |
Facts provided by forward chaining are inserted into the goal before |
|
1089 |
commencing proof search. The ``!''~argument causes the full context of |
|
1090 |
assumptions to be included as well. |
|
7321 | 1091 |
|
7315 | 1092 |
|
12621 | 1093 |
\subsubsection{Combined automated methods}\label{sec:clasimp} |
7315 | 1094 |
|
9799 | 1095 |
\indexisarmeth{auto}\indexisarmeth{force}\indexisarmeth{clarsimp} |
1096 |
\indexisarmeth{fastsimp}\indexisarmeth{slowsimp}\indexisarmeth{bestsimp} |
|
7321 | 1097 |
\begin{matharray}{rcl} |
9606 | 1098 |
auto & : & \isarmeth \\ |
7321 | 1099 |
force & : & \isarmeth \\ |
9438 | 1100 |
clarsimp & : & \isarmeth \\ |
9606 | 1101 |
fastsimp & : & \isarmeth \\ |
9799 | 1102 |
slowsimp & : & \isarmeth \\ |
1103 |
bestsimp & : & \isarmeth \\ |
|
7321 | 1104 |
\end{matharray} |
1105 |
||
11128 | 1106 |
\indexouternonterm{clasimpmod} |
7321 | 1107 |
\begin{rail} |
13027 | 1108 |
'auto' '!'? (nat nat)? (clasimpmod *) |
9780 | 1109 |
; |
13027 | 1110 |
('force' | 'clarsimp' | 'fastsimp' | 'slowsimp' | 'bestsimp') '!'? (clasimpmod *) |
7321 | 1111 |
; |
7315 | 1112 |
|
9711 | 1113 |
clasimpmod: ('simp' (() | 'add' | 'del' | 'only') | |
10031 | 1114 |
('cong' | 'split') (() | 'add' | 'del') | |
1115 |
'iff' (((() | 'add') '?'?) | 'del') | |
|
9408 | 1116 |
(('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del')) ':' thmrefs |
7321 | 1117 |
\end{rail} |
7315 | 1118 |
|
7321 | 1119 |
\begin{descr} |
9799 | 1120 |
\item [$auto$, $force$, $clarsimp$, $fastsimp$, $slowsimp$, and $bestsimp$] |
1121 |
provide access to Isabelle's combined simplification and classical reasoning |
|
1122 |
tactics. These correspond to \texttt{auto_tac}, \texttt{force_tac}, |
|
1123 |
\texttt{clarsimp_tac}, and Classical Reasoner tactics with the Simplifier |
|
1124 |
added as wrapper, see \cite[\S11]{isabelle-ref} for more information. The |
|
13048 | 1125 |
modifier arguments correspond to those given in \S\ref{sec:simplifier} and |
1126 |
\S\ref{sec:classical}. Just note that the ones related to the Simplifier |
|
1127 |
are prefixed by \railtterm{simp} here. |
|
9614 | 1128 |
|
7987 | 1129 |
Facts provided by forward chaining are inserted into the goal before doing |
1130 |
the search. The ``!''~argument causes the full context of assumptions to be |
|
1131 |
included as well. |
|
7321 | 1132 |
\end{descr} |
1133 |
||
7987 | 1134 |
|
13048 | 1135 |
\subsubsection{Declaring rules} |
7135 | 1136 |
|
8667 | 1137 |
\indexisarcmd{print-claset} |
7391 | 1138 |
\indexisaratt{intro}\indexisaratt{elim}\indexisaratt{dest} |
9936 | 1139 |
\indexisaratt{iff}\indexisaratt{rule} |
7321 | 1140 |
\begin{matharray}{rcl} |
13024 | 1141 |
\isarcmd{print_claset}^* & : & \isarkeep{theory~|~proof} \\ |
7321 | 1142 |
intro & : & \isaratt \\ |
1143 |
elim & : & \isaratt \\ |
|
1144 |
dest & : & \isaratt \\ |
|
9936 | 1145 |
rule & : & \isaratt \\ |
7391 | 1146 |
iff & : & \isaratt \\ |
7321 | 1147 |
\end{matharray} |
7135 | 1148 |
|
7321 | 1149 |
\begin{rail} |
18854 | 1150 |
('intro' | 'elim' | 'dest') ('!' | () | '?') nat? |
7321 | 1151 |
; |
9936 | 1152 |
'rule' 'del' |
1153 |
; |
|
10031 | 1154 |
'iff' (((() | 'add') '?'?) | 'del') |
9936 | 1155 |
; |
7321 | 1156 |
\end{rail} |
7135 | 1157 |
|
7321 | 1158 |
\begin{descr} |
13024 | 1159 |
|
1160 |
\item [$\isarcmd{print_claset}$] prints the collection of rules declared to |
|
1161 |
the Classical Reasoner, which is also known as ``simpset'' internally |
|
8667 | 1162 |
\cite{isabelle-ref}. This is a diagnostic command; $undo$ does not apply. |
18854 | 1163 |
|
8517 | 1164 |
\item [$intro$, $elim$, and $dest$] declare introduction, elimination, and |
11332 | 1165 |
destruction rules, respectively. By default, rules are considered as |
9408 | 1166 |
\emph{unsafe} (i.e.\ not applied blindly without backtracking), while a |
13041 | 1167 |
single ``!'' classifies as \emph{safe}. Rule declarations marked by ``?'' |
18854 | 1168 |
coincide with those of Isabelle/Pure, cf.\ \S\ref{sec:pure-meth-att} (i.e.\ |
1169 |
are only applied in single steps of the $rule$ method). The optional |
|
1170 |
natural number specifies an explicit weight argument, which is ignored by |
|
1171 |
automated tools, but determines the search order of single rule steps. |
|
13024 | 1172 |
|
11332 | 1173 |
\item [$rule~del$] deletes introduction, elimination, or destruction rules from |
9936 | 1174 |
the context. |
13041 | 1175 |
|
1176 |
\item [$iff$] declares logical equivalences to the Simplifier and the |
|
13024 | 1177 |
Classical reasoner at the same time. Non-conditional rules result in a |
1178 |
``safe'' introduction and elimination pair; conditional ones are considered |
|
1179 |
``unsafe''. Rules with negative conclusion are automatically inverted |
|
13041 | 1180 |
(using $\neg$ elimination internally). |
1181 |
||
1182 |
The ``?'' version of $iff$ declares rules to the Isabelle/Pure context only, |
|
1183 |
and omits the Simplifier declaration. |
|
1184 |
||
7321 | 1185 |
\end{descr} |
7135 | 1186 |
|
8203
2fcc6017cb72
intro/elim/dest attributes: changed ! / !! flags to ? / ??;
wenzelm
parents:
8195
diff
changeset
|
1187 |
|
13048 | 1188 |
\subsubsection{Classical operations} |
13027 | 1189 |
|
18530 | 1190 |
\indexisaratt{swapped} |
13027 | 1191 |
|
1192 |
\begin{matharray}{rcl} |
|
1193 |
swapped & : & \isaratt \\ |
|
1194 |
\end{matharray} |
|
1195 |
||
1196 |
\begin{descr} |
|
13041 | 1197 |
|
13027 | 1198 |
\item [$swapped$] turns an introduction rule into an elimination, by resolving |
1199 |
with the classical swap principle $(\neg B \Imp A) \Imp (\neg A \Imp B)$. |
|
1200 |
||
1201 |
\end{descr} |
|
1202 |
||
1203 |
||
12621 | 1204 |
\subsection{Proof by cases and induction}\label{sec:cases-induct} |
12618 | 1205 |
|
13048 | 1206 |
\subsubsection{Rule contexts} |
12618 | 1207 |
|
1208 |
\indexisarcmd{case}\indexisarcmd{print-cases} |
|
18232 | 1209 |
\indexisaratt{case-names}\indexisaratt{case-conclusion} |
1210 |
\indexisaratt{params}\indexisaratt{consumes} |
|
12618 | 1211 |
\begin{matharray}{rcl} |
1212 |
\isarcmd{case} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
1213 |
\isarcmd{print_cases}^* & : & \isarkeep{proof} \\ |
|
1214 |
case_names & : & \isaratt \\ |
|
18232 | 1215 |
case_conclusion & : & \isaratt \\ |
12618 | 1216 |
params & : & \isaratt \\ |
1217 |
consumes & : & \isaratt \\ |
|
1218 |
\end{matharray} |
|
1219 |
||
18232 | 1220 |
The puristic way to build up Isar proof contexts is by explicit language |
1221 |
elements like $\FIXNAME$, $\ASSUMENAME$, $\LET$ (see |
|
1222 |
\S\ref{sec:proof-context}). This is adequate for plain natural deduction, but |
|
1223 |
easily becomes unwieldy in concrete verification tasks, which typically |
|
1224 |
involve big induction rules with several cases. |
|
1225 |
||
1226 |
The $\CASENAME$ command provides a shorthand to refer to a local context |
|
1227 |
symbolically: certain proof methods provide an environment of named ``cases'' |
|
1228 |
of the form $c\colon \vec x, \vec \phi$; the effect of ``$\CASE{c}$'' is then |
|
1229 |
equivalent to ``$\FIX{\vec x}~\ASSUME{c}{\vec\phi}$''. Term bindings may be |
|
1230 |
covered as well, notably $\Var{case}$ for the main conclusion. |
|
1231 |
||
1232 |
By default, the ``terminology'' $\vec x$ of a case value is marked as hidden, |
|
1233 |
i.e.\ there is no way to refer to such parameters in the subsequent proof |
|
1234 |
text. After all, original rule parameters stem from somewhere outside of the |
|
1235 |
current proof text. By using the explicit form ``$\CASE{(c~\vec y)}$'' |
|
1236 |
instead, the proof author is able to chose local names that fit nicely into |
|
1237 |
the current context. |
|
12618 | 1238 |
|
1239 |
\medskip |
|
1240 |
||
18232 | 1241 |
It is important to note that proper use of $\CASENAME$ does not provide means |
1242 |
to peek at the current goal state, which is not directly observable in Isar! |
|
1243 |
Nonetheless, goal refinement commands do provide named cases $goal@i$ for each |
|
1244 |
subgoal $i = 1, \dots, n$ of the resulting goal state. Using this feature |
|
1245 |
requires great care, because some bits of the internal tactical machinery |
|
1246 |
intrude the proof text. In particular, parameter names stemming from the |
|
1247 |
left-over of automated reasoning tools are usually quite unpredictable. |
|
12618 | 1248 |
|
18232 | 1249 |
Under normal circumstances, the text of cases emerge from standard elimination |
1250 |
or induction rules, which in turn are derived from previous theory |
|
13041 | 1251 |
specifications in a canonical way (say from $\isarkeyword{inductive}$ |
1252 |
definitions). |
|
13027 | 1253 |
|
18232 | 1254 |
\medskip Proper cases are only available if both the proof method and the |
1255 |
rules involved support this. By using appropriate attributes, case names, |
|
1256 |
conclusions, and parameters may be also declared by hand. Thus variant |
|
1257 |
versions of rules that have been derived manually become reasy to use in |
|
1258 |
advanced case analysis later. |
|
12618 | 1259 |
|
1260 |
\begin{rail} |
|
13041 | 1261 |
'case' (caseref | '(' caseref ((name | underscore) +) ')') |
12618 | 1262 |
; |
13024 | 1263 |
caseref: nameref attributes? |
1264 |
; |
|
1265 |
||
18232 | 1266 |
'case\_names' (name +) |
1267 |
; |
|
1268 |
'case\_conclusion' name (name *) |
|
12618 | 1269 |
; |
13027 | 1270 |
'params' ((name *) + 'and') |
12618 | 1271 |
; |
1272 |
'consumes' nat? |
|
1273 |
; |
|
1274 |
\end{rail} |
|
1275 |
||
1276 |
\begin{descr} |
|
18232 | 1277 |
|
13041 | 1278 |
\item [$\CASE{(c~\vec x)}$] invokes a named local context $c\colon \vec x, |
1279 |
\vec \phi$, as provided by an appropriate proof method (such as $cases$ and |
|
18232 | 1280 |
$induct$). The command ``$\CASE{(c~\vec x)}$'' abbreviates ``$\FIX{\vec |
1281 |
x}~\ASSUME{c}{\vec\phi}$''. |
|
13041 | 1282 |
|
12618 | 1283 |
\item [$\isarkeyword{print_cases}$] prints all local contexts of the current |
1284 |
state, using Isar proof language notation. This is a diagnostic command; |
|
1285 |
$undo$ does not apply. |
|
18232 | 1286 |
|
12618 | 1287 |
\item [$case_names~\vec c$] declares names for the local contexts of premises |
18232 | 1288 |
of a theorem; $\vec c$ refers to the \emph{suffix} of the list of premises. |
1289 |
||
1290 |
\item [$case_conclusion~c~\vec d$] declares names for the conclusions of a |
|
1291 |
named premise $c$; here $\vec d$ refers to the prefix of arguments of a |
|
1292 |
logical formula built by nesting a binary connective (e.g.\ $\lor$). |
|
1293 |
||
1294 |
Note that proof methods such as $induct$ and $coinduct$ already provide a |
|
1295 |
default name for the conclusion as a whole. The need to name subformulas |
|
1296 |
only arises with cases that split into several sub-cases, as in common |
|
1297 |
co-induction rules. |
|
13041 | 1298 |
|
12618 | 1299 |
\item [$params~\vec p@1 \dots \vec p@n$] renames the innermost parameters of |
1300 |
premises $1, \dots, n$ of some theorem. An empty list of names may be given |
|
1301 |
to skip positions, leaving the present parameters unchanged. |
|
18232 | 1302 |
|
12618 | 1303 |
Note that the default usage of case rules does \emph{not} directly expose |
18232 | 1304 |
parameters to the proof context. |
1305 |
||
12618 | 1306 |
\item [$consumes~n$] declares the number of ``major premises'' of a rule, |
1307 |
i.e.\ the number of facts to be consumed when it is applied by an |
|
18232 | 1308 |
appropriate proof method. The default value of $consumes$ is $n = 1$, which |
1309 |
is appropriate for the usual kind of cases and induction rules for inductive |
|
1310 |
sets (cf.\ \S\ref{sec:hol-inductive}). Rules without any $consumes$ |
|
1311 |
declaration given are treated as if $consumes~0$ had been specified. |
|
1312 |
||
12618 | 1313 |
Note that explicit $consumes$ declarations are only rarely needed; this is |
18232 | 1314 |
already taken care of automatically by the higher-level $cases$, $induct$, |
1315 |
and $coinduct$ declarations. |
|
13027 | 1316 |
|
12618 | 1317 |
\end{descr} |
1318 |
||
1319 |
||
18232 | 1320 |
\subsubsection{Proof methods} |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1321 |
|
18232 | 1322 |
\indexisarmeth{cases}\indexisarmeth{induct}\indexisarmeth{coinduct} |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1323 |
\begin{matharray}{rcl} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1324 |
cases & : & \isarmeth \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1325 |
induct & : & \isarmeth \\ |
18232 | 1326 |
coinduct & : & \isarmeth \\ |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1327 |
\end{matharray} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1328 |
|
18232 | 1329 |
The $cases$, $induct$, and $coinduct$ methods provide a uniform interface to |
1330 |
common proof techniques over datatypes, inductive sets, recursive functions |
|
1331 |
etc. The corresponding rules may be specified and instantiated in a casual |
|
1332 |
manner. Furthermore, these methods provide named local contexts that may be |
|
1333 |
invoked via the $\CASENAME$ proof command within the subsequent proof text. |
|
1334 |
This accommodates compact proof texts even when reasoning about large |
|
13048 | 1335 |
specifications. |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1336 |
|
18232 | 1337 |
The $induct$ method also provides some additional infrastructure in order to |
1338 |
be applicable to structure statements (either using explicit meta-level |
|
1339 |
connectives, or including facts and parameters separately). This avoids |
|
1340 |
cumbersome encoding of ``strengthened'' inductive statements within the |
|
1341 |
object-logic. |
|
1342 |
||
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1343 |
\begin{rail} |
18232 | 1344 |
'cases' open? (insts * 'and') rule? |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1345 |
; |
18232 | 1346 |
'induct' open? (definsts * 'and') \\ fixing? taking? rule? |
1347 |
; |
|
1348 |
'coinduct' open? insts taking rule? |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1349 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1350 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1351 |
open: '(' 'open' ')' |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1352 |
; |
18505 | 1353 |
rule: ('type' | 'set') ':' (nameref +) | 'rule' ':' (thmref +) |
18232 | 1354 |
; |
1355 |
definst: name ('==' | equiv) term | inst |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1356 |
; |
18232 | 1357 |
definsts: ( definst *) |
1358 |
; |
|
1359 |
fixing: 'fixing' ':' ((term *) 'and' +) |
|
1360 |
; |
|
1361 |
taking: 'taking' ':' insts |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1362 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1363 |
\end{rail} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1364 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1365 |
\begin{descr} |
13041 | 1366 |
|
1367 |
\item [$cases~insts~R$] applies method $rule$ with an appropriate case |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1368 |
distinction theorem, instantiated to the subjects $insts$. Symbolic case |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1369 |
names are bound according to the rule's local contexts. |
13041 | 1370 |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1371 |
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
|
1372 |
passed to the $cases$ method: |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1373 |
\begin{matharray}{llll} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1374 |
\Text{facts} & & \Text{arguments} & \Text{rule} \\\hline |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1375 |
& cases & & \Text{classical case split} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1376 |
& cases & t & \Text{datatype exhaustion (type of $t$)} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1377 |
\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
|
1378 |
\dots & cases & \dots ~ R & \Text{explicit rule $R$} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1379 |
\end{matharray} |
13041 | 1380 |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1381 |
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
|
1382 |
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
|
1383 |
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
|
1384 |
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
|
1385 |
usually the same for all cases). |
13041 | 1386 |
|
1387 |
The ``$(open)$'' option causes the parameters of the new local contexts to |
|
1388 |
be exposed to the current proof context. Thus local variables stemming from |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1389 |
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
|
1390 |
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
|
1391 |
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
|
1392 |
less robust proof texts. |
13041 | 1393 |
|
1394 |
\item [$induct~insts~R$] is analogous to the $cases$ method, but refers to |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1395 |
induction rules, which are determined as follows: |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1396 |
\begin{matharray}{llll} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1397 |
\Text{facts} & & \Text{arguments} & \Text{rule} \\\hline |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1398 |
& induct & P ~ x ~ \dots & \Text{datatype induction (type of $x$)} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1399 |
\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
|
1400 |
\dots & induct & \dots ~ R & \Text{explicit rule $R$} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1401 |
\end{matharray} |
18505 | 1402 |
|
1403 |
Several instantiations may be given, each referring to some part of |
|
1404 |
a mutual inductive definition or datatype --- only related partial |
|
1405 |
induction rules may be used together, though. Any of the lists of |
|
1406 |
terms $P, x, \dots$ refers to the \emph{suffix} of variables present |
|
1407 |
in the induction rule. This enables the writer to specify only |
|
1408 |
induction variables, or both predicates and variables, for example. |
|
18232 | 1409 |
|
1410 |
Instantiations may be definitional: equations $x \equiv t$ introduce local |
|
1411 |
definitions, which are inserted into the claim and discharged after applying |
|
1412 |
the induction rule. Equalities reappear in the inductive cases, but have |
|
1413 |
been transformed according to the induction principle being involved here. |
|
1414 |
In order to achieve practically useful induction hypotheses, some variables |
|
1415 |
occurring in $t$ need to be fixed (see below). |
|
1416 |
||
1417 |
The optional ``$fixing\colon \vec x$'' specification generalizes variables |
|
1418 |
$\vec x$ of the original goal before applying induction. Thus induction |
|
1419 |
hypotheses may become sufficiently general to get the proof through. |
|
1420 |
Together with definitional instantiations, one may effectively perform |
|
1421 |
induction over expressions of a certain structure. |
|
1422 |
||
1423 |
The optional ``$taking\colon \vec t$'' specification provides additional |
|
1424 |
instantiations of a prefix of pending variables in the rule. Such schematic |
|
1425 |
induction rules rarely occur in practice, though. |
|
1426 |
||
1427 |
The ``$(open)$'' option works the same way as for $cases$. |
|
1428 |
||
1429 |
\item [$coinduct~inst~R$] is analogous to the $induct$ method, but refers to |
|
1430 |
coinduction rules, which are determined as follows: |
|
1431 |
\begin{matharray}{llll} |
|
1432 |
\Text{goal} & & \Text{arguments} & \Text{rule} \\\hline |
|
1433 |
& coinduct & x ~ \dots & \Text{type coinduction (type of $x$)} \\ |
|
1434 |
x \in A & coinduct & \dots & \Text{set coinduction (of $A$)} \\ |
|
1435 |
\dots & coinduct & \dots ~ R & \Text{explicit rule $R$} \\ |
|
1436 |
\end{matharray} |
|
1437 |
||
1438 |
Coinduction is the dual of induction. Induction essentially eliminates $x |
|
1439 |
\in A$ towards a generic result $P ~ x$, while coinduction introduces $x \in |
|
1440 |
A$ starting with $x \in B$, for a suitable ``bisimulation'' $B$. The cases |
|
1441 |
of a coinduct rule are typically named after the sets being covered, while |
|
1442 |
the conclusions consist of several alternatives being named after the |
|
1443 |
individual destructor patterns. |
|
1444 |
||
1445 |
The given instantiation refers to the \emph{prefix} of variables occurring |
|
1446 |
in the rule's conclusion. An additional ``$taking: \vec t$'' specification |
|
1447 |
may be required in order to specify the bisimulation to be used in the |
|
1448 |
coinduction step. |
|
13041 | 1449 |
|
1450 |
The ``$(open)$'' option works the same way as for $cases$. |
|
13027 | 1451 |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1452 |
\end{descr} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1453 |
|
13048 | 1454 |
Above methods produce named local contexts, as determined by the instantiated |
18232 | 1455 |
rule as given in the text. Beyond that, the $induct$ and $coinduct$ methods |
1456 |
guess further instantiations from the goal specification itself. Any |
|
1457 |
persisting unresolved schematic variables of the resulting rule will render |
|
1458 |
the the corresponding case invalid. The term binding |
|
1459 |
$\Var{case}$\indexisarvar{case} for the conclusion will be provided with each |
|
1460 |
case, provided that term is fully specified. |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1461 |
|
13048 | 1462 |
The $\isarkeyword{print_cases}$ command prints all named cases present in the |
1463 |
current proof state. |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1464 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1465 |
\medskip |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1466 |
|
18232 | 1467 |
Despite the additional infrastructure, both $cases$ and $coinduct$ merely |
1468 |
apply a certain rule, after instantiation, while conforming due to the usual |
|
1469 |
way of monotonic natural deduction: the context of a structured statement |
|
1470 |
$\All{\vec x} \vec\phi \Imp \dots$ reappears unchanged after the case split. |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1471 |
|
18232 | 1472 |
The $induct$ method is significantly different in this respect: the meta-level |
1473 |
structure is passed through the ``recursive'' course involved in the |
|
1474 |
induction. Thus the original statement is basically replaced by separate |
|
1475 |
copies, corresponding to the induction hypotheses and conclusion; the original |
|
1476 |
goal context is no longer available. Thus local assumptions, fixed parameters |
|
1477 |
and definitions effectively participate in the inductive rephrasing of the |
|
1478 |
original statement. |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1479 |
|
13425
119ae829ad9b
support for split assumptions in cases (hyps vs. prems);
wenzelm
parents:
13411
diff
changeset
|
1480 |
In induction proofs, local assumptions introduced by cases are split into two |
119ae829ad9b
support for split assumptions in cases (hyps vs. prems);
wenzelm
parents:
13411
diff
changeset
|
1481 |
different kinds: $hyps$ stemming from the rule and $prems$ from the goal |
119ae829ad9b
support for split assumptions in cases (hyps vs. prems);
wenzelm
parents:
13411
diff
changeset
|
1482 |
statement. This is reflected in the extracted cases accordingly, so invoking |
119ae829ad9b
support for split assumptions in cases (hyps vs. prems);
wenzelm
parents:
13411
diff
changeset
|
1483 |
``$\isarcmd{case}~c$'' will provide separate facts $c\mathord.hyps$ and |
119ae829ad9b
support for split assumptions in cases (hyps vs. prems);
wenzelm
parents:
13411
diff
changeset
|
1484 |
$c\mathord.prems$, as well as fact $c$ to hold the all-inclusive list. |
119ae829ad9b
support for split assumptions in cases (hyps vs. prems);
wenzelm
parents:
13411
diff
changeset
|
1485 |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1486 |
\medskip |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1487 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1488 |
Facts presented to either method are consumed according to the number of |
18232 | 1489 |
``major premises'' of the rule involved, which is usually $0$ for plain cases |
1490 |
and induction rules of datatypes etc.\ and $1$ for rules of inductive sets and |
|
1491 |
the like. The remaining facts are inserted into the goal verbatim before the |
|
1492 |
actual $cases$, $induct$, or $coinduct$ rule is applied. |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1493 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1494 |
|
18232 | 1495 |
\subsubsection{Declaring rules} |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1496 |
|
18232 | 1497 |
\indexisarcmd{print-induct-rules}\indexisaratt{cases}\indexisaratt{induct}\indexisaratt{coinduct} |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1498 |
\begin{matharray}{rcl} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1499 |
\isarcmd{print_induct_rules}^* & : & \isarkeep{theory~|~proof} \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1500 |
cases & : & \isaratt \\ |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1501 |
induct & : & \isaratt \\ |
18232 | 1502 |
coinduct & : & \isaratt \\ |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1503 |
\end{matharray} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1504 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1505 |
\begin{rail} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1506 |
'cases' spec |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1507 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1508 |
'induct' spec |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1509 |
; |
18232 | 1510 |
'coinduct' spec |
1511 |
; |
|
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1512 |
|
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1513 |
spec: ('type' | 'set') ':' nameref |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1514 |
; |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1515 |
\end{rail} |
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1516 |
|
13024 | 1517 |
\begin{descr} |
13041 | 1518 |
|
13024 | 1519 |
\item [$\isarkeyword{print_induct_rules}$] prints cases and induct rules for |
1520 |
sets and types of the current context. |
|
13048 | 1521 |
|
18232 | 1522 |
\item [$cases$, $induct$, and $coinduct$] (as attributes) augment the |
1523 |
corresponding context of rules for reasoning about (co)inductive sets and |
|
1524 |
types, using the corresponding methods of the same name. Certain |
|
1525 |
definitional packages of object-logics usually declare emerging cases and |
|
1526 |
induction rules as expected, so users rarely need to intervene. |
|
1527 |
||
1528 |
Manual rule declarations usually refer to the $case_names$ and $params$ |
|
1529 |
attributes to adjust names of cases and parameters of a rule; the $consumes$ |
|
1530 |
declaration is taken care of automatically: $consumes~0$ is specified for |
|
1531 |
``type'' rules and $consumes~1$ for ``set'' rules. |
|
13041 | 1532 |
|
13024 | 1533 |
\end{descr} |
11691
fc9bd420162c
induct/cases made generic, removed simplified/stripped options;
wenzelm
parents:
11469
diff
changeset
|
1534 |
|
9614 | 1535 |
%%% Local Variables: |
7135 | 1536 |
%%% mode: latex |
1537 |
%%% TeX-master: "isar-ref" |
|
9614 | 1538 |
%%% End: |