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