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