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