34 \begin{descr} |
29 \begin{descr} |
35 \item [$\AXCLASS~c \subseteq \vec c~axms$] defines an axiomatic type class as |
30 \item [$\AXCLASS~c \subseteq \vec c~axms$] defines an axiomatic type class as |
36 the intersection of existing classes, with additional axioms holding. Class |
31 the intersection of existing classes, with additional axioms holding. Class |
37 axioms may not contain more than one type variable. The class axioms (with |
32 axioms may not contain more than one type variable. The class axioms (with |
38 implicit sort constraints added) are bound to the given names. Furthermore |
33 implicit sort constraints added) are bound to the given names. Furthermore |
39 a class introduction rule is generated, which is employed by method |
34 a class introduction rule is generated (being bound as $c{.}intro$); this |
40 $intro_classes$ to support instantiation proofs of this class. |
35 rule is employed by method $intro_classes$ to support instantiation proofs |
|
36 of this class. |
|
37 |
|
38 The ``axioms'' are stored as theorems according to the given name |
|
39 specifications, adding the class name $c$ as name space prefix; these facts |
|
40 are stored collectively as $c.axioms$, too. |
41 |
41 |
42 \item [$\INSTANCE~c@1 \subseteq c@2$ and $\INSTANCE~t :: (\vec s)c$] setup a |
42 \item [$\INSTANCE~c@1 \subseteq c@2$ and $\INSTANCE~t :: (\vec s)c$] setup a |
43 goal stating a class relation or type arity. The proof would usually |
43 goal stating a class relation or type arity. The proof would usually |
44 proceed by $intro_classes$, and then establish the characteristic theorems |
44 proceed by $intro_classes$, and then establish the characteristic theorems |
45 of the type classes involved. After finishing the proof, the theory will be |
45 of the type classes involved. After finishing the proof, the theory will be |
46 augmented by a type signature declaration corresponding to the resulting |
46 augmented by a type signature declaration corresponding to the resulting |
47 theorem. |
47 theorem. |
|
48 |
48 \item [$intro_classes$] repeatedly expands all class introduction rules of |
49 \item [$intro_classes$] repeatedly expands all class introduction rules of |
49 this theory. Note that this method usually needs not be named explicitly, |
50 this theory. Note that this method usually needs not be named explicitly, |
50 as it is already included in the default proof step (of $\PROOFNAME$, |
51 as it is already included in the default proof step (of $\PROOFNAME$, |
51 $\BYNAME$, etc.). In particular, instantiation of trivial (syntactic) |
52 $\BYNAME$, etc.). In particular, instantiation of trivial (syntactic) |
52 classes may be performed by a single ``$\DDOT$'' proof step. |
53 classes may be performed by a single ``$\DDOT$'' proof step. |
53 \end{descr} |
54 \end{descr} |
54 |
55 |
55 |
56 |
56 \subsection{Locales and local contexts}\label{sec:locale} |
57 \subsection{Locales and local contexts}\label{sec:locale} |
57 |
58 |
58 FIXME |
59 Locales are named local contexts, consisting of a declaration elements that |
59 |
60 are modeled after the Isar proof context (cf.\ \S\ref{sec:proof-context}). |
60 \indexouternonterm{locale}\indexouternonterm{contextelem} |
61 |
61 |
62 \subsubsection{Localized commands} |
|
63 |
|
64 Existing locales may be augmented later on by adding new facts. Note that the |
|
65 actual context definition may not be changed! Several theory commands that |
|
66 produce facts in some way are available in ``localized'' versions, referring |
|
67 to a named locale instead of the global theory context. |
|
68 |
|
69 \indexouternonterm{locale} |
62 \begin{rail} |
70 \begin{rail} |
63 locale: '(' 'in' name ')' |
71 locale: '(' 'in' name ')' |
64 ; |
72 ; |
65 |
73 \end{rail} |
66 contextelem: FIXME |
74 |
67 ; |
75 Emerging facts of localized commands are stored in two versions, both in the |
68 \end{rail} |
76 target locale and the theory (after export). The latter view produces a |
|
77 qualified binding, using the locale name as a name space prefix. |
|
78 |
|
79 For example, ``$\LEMMAS~(\IN~loc)~a = \vec b$'' retrieves facts $\vec b$ from |
|
80 the locale context of $loc$ and augments its body by an appropriate |
|
81 ``$\isarkeyword{notes}$'' element (see below). The exported view of $a$, |
|
82 after discharging the locale context, is stored as $loc{.}a$ within the global |
|
83 theory. A localized goal ``$\LEMMANAME~(\IN~loc)~a:~\phi$'' work similarly, |
|
84 only that the fact emerges through the subsequent proof, |
|
85 which may refer to the full infrastructure of the locale context (including |
|
86 local parameters with typing and concrete syntax, assumptions, definitions |
|
87 etc.). Most notably, fact declarations of the locale are active during the |
|
88 proof, too (e.g.\ local $simp$ rules). |
|
89 |
|
90 |
|
91 \subsubsection{Locale specifications} |
|
92 |
|
93 \indexisarcmd{locale}\indexisarcmd{print-locale}\indexisarcmd{print-locales} |
|
94 \begin{matharray}{rcl} |
|
95 \isarcmd{locale} & : & \isarkeep{theory} \\ |
|
96 \isarcmd{print_locale}^* & : & \isarkeep{theory~|~proof} \\ |
|
97 \isarcmd{print_locales}^* & : & \isarkeep{theory~|~proof} \\ |
|
98 \end{matharray} |
|
99 |
|
100 \indexouternonterm{contextexpr}\indexouternonterm{contextelem} |
|
101 |
|
102 \railalias{printlocale}{print\_locale} |
|
103 \railterm{printlocale} |
|
104 |
|
105 \begin{rail} |
|
106 'locale' name ('=' localeexpr)? |
|
107 ; |
|
108 printlocale localeexpr |
|
109 ; |
|
110 localeexpr: ((contextexpr '+' (contextelem+)) | contextexpr | (contextelem+)) |
|
111 ; |
|
112 |
|
113 contextexpr: nameref | '(' contextexpr ')' | |
|
114 (contextexpr (name+)) | (contextexpr + '+') |
|
115 ; |
|
116 contextelem: fixes | assumes | defines | notes | includes |
|
117 ; |
|
118 fixes: 'fixes' (name ('::' type)? structmixfix? + 'and') |
|
119 ; |
|
120 assumes: 'assumes' (thmdecl? props + 'and') |
|
121 ; |
|
122 defines: 'defines' (thmdecl? prop proppat? + 'and') |
|
123 ; |
|
124 notes: 'notes' (thmdef? thmrefs + 'and') |
|
125 ; |
|
126 includes: 'includes' contextexpr |
|
127 ; |
|
128 \end{rail} |
|
129 |
|
130 \begin{descr} |
|
131 |
|
132 \item [$\LOCALE~loc~=~import~+~body$] defines new locale $loc$ as a context |
|
133 consisting of a certain view of existing locales ($import$) plus some |
|
134 additional elements ($body$). Both $import$ and $body$ are optional; the |
|
135 trivial $\LOCALE~loc$ defines an empty locale, which may still be useful to |
|
136 collect declarations of facts later on. Type-inference on locale |
|
137 expressions automatically takes care of the most general typing that the |
|
138 combined context elements may acquire. |
|
139 |
|
140 The $import$ consists of a structured context expression, consisting of |
|
141 references to existing locales, renamed contexts, or merged contexts. |
|
142 Renaming uses positional notation: $c~\vec x$ means that (a prefix) the |
|
143 fixed parameters of context $c$ are named according to $\vec x$; a |
|
144 ``\texttt{_}'' (underscore).\indexisarthm{_@\texttt{_}} means to skip that |
|
145 position. Also note that concrete syntax only works with the original name. |
|
146 Merging proceeds from left-to-right, suppressing any duplicates emerging |
|
147 from different paths through an import hierarchy. |
|
148 |
|
149 The $body$ consists of basic context elements, further context expressions |
|
150 may be included as well. |
|
151 |
|
152 \begin{descr} |
|
153 |
|
154 \item [$\FIXES{~x::\tau~(mx)}$] declares a local parameter of type $\tau$ |
|
155 and mixfix annotation $mx$ (both are optional). The special syntax |
|
156 declaration $(structure)$ means that $x$ may be referenced |
|
157 implicitly in this context. %see also FIXME |
|
158 |
|
159 \item [$\ASSUMES{a}{\vec\phi}$] introduces local premises, similar to |
|
160 $\ASSUMENAME$ within a proof (cf.\ \S\ref{sec:proof-context}). |
|
161 |
|
162 \item [$\DEFINES{a}{x \equiv t}$] defines a previously declared parameter. |
|
163 This is close to $\DEFNAME$ within a proof (cf.\ |
|
164 \S\ref{sec:proof-context}), but $\DEFINESNAME$ takes an equational |
|
165 proposition instead of variable-term. The left-hand side of the equation |
|
166 may have additional arguments, e.g.\ $\DEFINES{}{f~\vec x \equiv t}$. |
|
167 |
|
168 \item [$\NOTES{a}{\vec b}$] reconsiders facts within a local context. Most |
|
169 notably, this may include arbitrary declarations in any attribute |
|
170 specifications included here, e.g.\ a local $simp$ rule. |
|
171 |
|
172 \item [$\INCLUDES{c}$] copies the specified context in a statically scoped |
|
173 manner. |
|
174 |
|
175 In contrast, the initial $import$ specification of a locale expression |
|
176 maintains a dynamic relation to the locales being referenced (benefiting |
|
177 from any later fact declarations in the obvious manner). |
|
178 \end{descr} |
|
179 |
|
180 Note that $\IS{p}$ patterns given in the syntax of $\ASSUMESNAME$ and |
|
181 $\DEFINESNAME$ above is actually illegal in locale definitions. In the long |
|
182 goal format of \S\ref{sec:goals}, term bindings may be included as expected. |
|
183 |
|
184 \item [$\isarkeyword{print_locale}~import~+~body$] prints the specified locale |
|
185 expression in a flattened form. The notable special case |
|
186 $\isarkeyword{print_locale}~loc$ just prints the contents of the named |
|
187 locale, but keep in mind that type-inference will normalize type variables |
|
188 according to the usual alphabetical order. |
|
189 |
|
190 \item [$\isarkeyword{print_locales}$] prints the names of all locales of the |
|
191 current theory. |
|
192 |
|
193 \end{descr} |
69 |
194 |
70 |
195 |
71 \section{Derived proof schemes} |
196 \section{Derived proof schemes} |
72 |
197 |
73 \subsection{Generalized elimination}\label{sec:obtain} |
198 \subsection{Generalized elimination}\label{sec:obtain} |
122 |
247 |
123 \subsection{Calculational reasoning}\label{sec:calculation} |
248 \subsection{Calculational reasoning}\label{sec:calculation} |
124 |
249 |
125 \indexisarcmd{also}\indexisarcmd{finally} |
250 \indexisarcmd{also}\indexisarcmd{finally} |
126 \indexisarcmd{moreover}\indexisarcmd{ultimately} |
251 \indexisarcmd{moreover}\indexisarcmd{ultimately} |
127 \indexisarcmd{print-trans-rules}\indexisaratt{trans} |
252 \indexisarcmd{print-trans-rules} |
|
253 \indexisaratt{trans}\indexisaratt{sym}\indexisaratt{symmetric} |
128 \begin{matharray}{rcl} |
254 \begin{matharray}{rcl} |
129 \isarcmd{also} & : & \isartrans{proof(state)}{proof(state)} \\ |
255 \isarcmd{also} & : & \isartrans{proof(state)}{proof(state)} \\ |
130 \isarcmd{finally} & : & \isartrans{proof(state)}{proof(chain)} \\ |
256 \isarcmd{finally} & : & \isartrans{proof(state)}{proof(chain)} \\ |
131 \isarcmd{moreover} & : & \isartrans{proof(state)}{proof(state)} \\ |
257 \isarcmd{moreover} & : & \isartrans{proof(state)}{proof(state)} \\ |
132 \isarcmd{ultimately} & : & \isartrans{proof(state)}{proof(chain)} \\ |
258 \isarcmd{ultimately} & : & \isartrans{proof(state)}{proof(chain)} \\ |
133 \isarcmd{print_trans_rules}^* & : & \isarkeep{theory~|~proof} \\ |
259 \isarcmd{print_trans_rules}^* & : & \isarkeep{theory~|~proof} \\ |
134 trans & : & \isaratt \\ |
260 trans & : & \isaratt \\ |
|
261 sym & : & \isaratt \\ |
|
262 symmetric & : & \isaratt \\ |
135 \end{matharray} |
263 \end{matharray} |
136 |
264 |
137 Calculational proof is forward reasoning with implicit application of |
265 Calculational proof is forward reasoning with implicit application of |
138 transitivity rules (such those of $=$, $\leq$, $<$). Isabelle/Isar maintains |
266 transitivity rules (such those of $=$, $\leq$, $<$). Isabelle/Isar maintains |
139 an auxiliary register $calculation$\indexisarthm{calculation} for accumulating |
267 an auxiliary register $calculation$\indexisarthm{calculation} for accumulating |