author | wenzelm |
Thu, 13 Nov 2008 22:44:40 +0100 | |
changeset 28787 | 8ea7403147c5 |
parent 28768 | a056077b65a1 |
child 29560 | fa6c5d62adf5 |
permissions | -rw-r--r-- |
26869 | 1 |
(* $Id$ *) |
2 |
||
3 |
theory Spec |
|
4 |
imports Main |
|
5 |
begin |
|
6 |
||
27046 | 7 |
chapter {* Theory specifications *} |
26869 | 8 |
|
26870 | 9 |
section {* Defining theories \label{sec:begin-thy} *} |
10 |
||
11 |
text {* |
|
12 |
\begin{matharray}{rcl} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
13 |
@{command_def "theory"} & : & @{text "toplevel \<rightarrow> theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
14 |
@{command_def (global) "end"} & : & @{text "theory \<rightarrow> toplevel"} \\ |
26870 | 15 |
\end{matharray} |
16 |
||
28745 | 17 |
Isabelle/Isar theories are defined via theory files, which may |
18 |
contain both specifications and proofs; occasionally definitional |
|
19 |
mechanisms also require some explicit proof. The theory body may be |
|
20 |
sub-structured by means of \emph{local theory targets}, such as |
|
21 |
@{command "locale"} and @{command "class"}. |
|
26870 | 22 |
|
28745 | 23 |
The first proper command of a theory is @{command "theory"}, which |
24 |
indicates imports of previous theories and optional dependencies on |
|
25 |
other source files (usually in ML). Just preceding the initial |
|
26 |
@{command "theory"} command there may be an optional @{command |
|
27 |
"header"} declaration, which is only relevant to document |
|
28 |
preparation: see also the other section markup commands in |
|
29 |
\secref{sec:markup}. |
|
30 |
||
31 |
A theory is concluded by a final @{command (global) "end"} command, |
|
32 |
one that does not belong to a local theory target. No further |
|
33 |
commands may follow such a global @{command (global) "end"}, |
|
34 |
although some user-interfaces might pretend that trailing input is |
|
35 |
admissible. |
|
26870 | 36 |
|
37 |
\begin{rail} |
|
38 |
'theory' name 'imports' (name +) uses? 'begin' |
|
39 |
; |
|
40 |
||
41 |
uses: 'uses' ((name | parname) +); |
|
42 |
\end{rail} |
|
43 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
44 |
\begin{description} |
26870 | 45 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
46 |
\item @{command "theory"}~@{text "A \<IMPORTS> B\<^sub>1 \<dots> B\<^sub>n \<BEGIN>"} |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
47 |
starts a new theory @{text A} based on the merge of existing |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
48 |
theories @{text "B\<^sub>1 \<dots> B\<^sub>n"}. |
26870 | 49 |
|
28745 | 50 |
Due to the possibility to import more than one ancestor, the |
51 |
resulting theory structure of an Isabelle session forms a directed |
|
52 |
acyclic graph (DAG). Isabelle's theory loader ensures that the |
|
53 |
sources contributing to the development graph are always up-to-date: |
|
54 |
changed files are automatically reloaded whenever a theory header |
|
55 |
specification is processed. |
|
26870 | 56 |
|
57 |
The optional @{keyword_def "uses"} specification declares additional |
|
58 |
dependencies on extra files (usually ML sources). Files will be |
|
28745 | 59 |
loaded immediately (as ML), unless the name is parenthesized. The |
60 |
latter case records a dependency that needs to be resolved later in |
|
61 |
the text, usually via explicit @{command_ref "use"} for ML files; |
|
62 |
other file formats require specific load commands defined by the |
|
63 |
corresponding tools or packages. |
|
26870 | 64 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
65 |
\item @{command (global) "end"} concludes the current theory |
28745 | 66 |
definition. Note that local theory targets involve a local |
67 |
@{command (local) "end"}, which is clear from the nesting. |
|
27040 | 68 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
69 |
\end{description} |
27040 | 70 |
*} |
71 |
||
72 |
||
73 |
section {* Local theory targets \label{sec:target} *} |
|
74 |
||
75 |
text {* |
|
76 |
A local theory target is a context managed separately within the |
|
77 |
enclosing theory. Contexts may introduce parameters (fixed |
|
78 |
variables) and assumptions (hypotheses). Definitions and theorems |
|
79 |
depending on the context may be added incrementally later on. Named |
|
80 |
contexts refer to locales (cf.\ \secref{sec:locale}) or type classes |
|
81 |
(cf.\ \secref{sec:class}); the name ``@{text "-"}'' signifies the |
|
82 |
global theory context. |
|
83 |
||
84 |
\begin{matharray}{rcll} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
85 |
@{command_def "context"} & : & @{text "theory \<rightarrow> local_theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
86 |
@{command_def (local) "end"} & : & @{text "local_theory \<rightarrow> theory"} \\ |
27040 | 87 |
\end{matharray} |
88 |
||
89 |
\indexouternonterm{target} |
|
90 |
\begin{rail} |
|
91 |
'context' name 'begin' |
|
92 |
; |
|
93 |
||
94 |
target: '(' 'in' name ')' |
|
95 |
; |
|
96 |
\end{rail} |
|
97 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
98 |
\begin{description} |
27040 | 99 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
100 |
\item @{command "context"}~@{text "c \<BEGIN>"} recommences an |
27040 | 101 |
existing locale or class context @{text c}. Note that locale and |
27051 | 102 |
class definitions allow to include the @{keyword "begin"} keyword as |
103 |
well, in order to continue the local theory immediately after the |
|
104 |
initial specification. |
|
27040 | 105 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
106 |
\item @{command (local) "end"} concludes the current local theory |
27040 | 107 |
and continues the enclosing global theory. Note that a global |
108 |
@{command (global) "end"} has a different meaning: it concludes the |
|
109 |
theory itself (\secref{sec:begin-thy}). |
|
110 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
111 |
\item @{text "(\<IN> c)"} given after any local theory command |
27040 | 112 |
specifies an immediate target, e.g.\ ``@{command |
113 |
"definition"}~@{text "(\<IN> c) \<dots>"}'' or ``@{command |
|
114 |
"theorem"}~@{text "(\<IN> c) \<dots>"}''. This works both in a local or |
|
115 |
global theory context; the current target context will be suspended |
|
116 |
for this command only. Note that ``@{text "(\<IN> -)"}'' will |
|
117 |
always produce a global result independently of the current target |
|
118 |
context. |
|
119 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
120 |
\end{description} |
27040 | 121 |
|
122 |
The exact meaning of results produced within a local theory context |
|
123 |
depends on the underlying target infrastructure (locale, type class |
|
124 |
etc.). The general idea is as follows, considering a context named |
|
125 |
@{text c} with parameter @{text x} and assumption @{text "A[x]"}. |
|
126 |
||
127 |
Definitions are exported by introducing a global version with |
|
128 |
additional arguments; a syntactic abbreviation links the long form |
|
129 |
with the abstract version of the target context. For example, |
|
130 |
@{text "a \<equiv> t[x]"} becomes @{text "c.a ?x \<equiv> t[?x]"} at the theory |
|
131 |
level (for arbitrary @{text "?x"}), together with a local |
|
132 |
abbreviation @{text "c \<equiv> c.a x"} in the target context (for the |
|
133 |
fixed parameter @{text x}). |
|
134 |
||
135 |
Theorems are exported by discharging the assumptions and |
|
136 |
generalizing the parameters of the context. For example, @{text "a: |
|
137 |
B[x]"} becomes @{text "c.a: A[?x] \<Longrightarrow> B[?x]"}, again for arbitrary |
|
138 |
@{text "?x"}. |
|
139 |
*} |
|
140 |
||
141 |
||
142 |
section {* Basic specification elements *} |
|
143 |
||
144 |
text {* |
|
145 |
\begin{matharray}{rcll} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
146 |
@{command_def "axiomatization"} & : & @{text "theory \<rightarrow> theory"} & (axiomatic!)\\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
147 |
@{command_def "definition"} & : & @{text "local_theory \<rightarrow> local_theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
148 |
@{attribute_def "defn"} & : & @{text attribute} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
149 |
@{command_def "abbreviation"} & : & @{text "local_theory \<rightarrow> local_theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
150 |
@{command_def "print_abbrevs"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow> "} \\ |
27040 | 151 |
\end{matharray} |
152 |
||
153 |
These specification mechanisms provide a slightly more abstract view |
|
154 |
than the underlying primitives of @{command "consts"}, @{command |
|
155 |
"defs"} (see \secref{sec:consts}), and @{command "axioms"} (see |
|
156 |
\secref{sec:axms-thms}). In particular, type-inference is commonly |
|
157 |
available, and result names need not be given. |
|
158 |
||
159 |
\begin{rail} |
|
160 |
'axiomatization' target? fixes? ('where' specs)? |
|
161 |
; |
|
162 |
'definition' target? (decl 'where')? thmdecl? prop |
|
163 |
; |
|
164 |
'abbreviation' target? mode? (decl 'where')? prop |
|
165 |
; |
|
166 |
||
167 |
fixes: ((name ('::' type)? mixfix? | vars) + 'and') |
|
168 |
; |
|
169 |
specs: (thmdecl? props + 'and') |
|
170 |
; |
|
171 |
decl: name ('::' type)? mixfix? |
|
172 |
; |
|
173 |
\end{rail} |
|
174 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
175 |
\begin{description} |
27040 | 176 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
177 |
\item @{command "axiomatization"}~@{text "c\<^sub>1 \<dots> c\<^sub>m \<WHERE> \<phi>\<^sub>1 \<dots> \<phi>\<^sub>n"} |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
178 |
introduces several constants simultaneously and states axiomatic |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
179 |
properties for these. The constants are marked as being specified |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
180 |
once and for all, which prevents additional specifications being |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
181 |
issued later on. |
27040 | 182 |
|
183 |
Note that axiomatic specifications are only appropriate when |
|
28114 | 184 |
declaring a new logical system; axiomatic specifications are |
185 |
restricted to global theory contexts. Normal applications should |
|
186 |
only use definitional mechanisms! |
|
27040 | 187 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
188 |
\item @{command "definition"}~@{text "c \<WHERE> eq"} produces an |
27040 | 189 |
internal definition @{text "c \<equiv> t"} according to the specification |
190 |
given as @{text eq}, which is then turned into a proven fact. The |
|
191 |
given proposition may deviate from internal meta-level equality |
|
192 |
according to the rewrite rules declared as @{attribute defn} by the |
|
193 |
object-logic. This usually covers object-level equality @{text "x = |
|
194 |
y"} and equivalence @{text "A \<leftrightarrow> B"}. End-users normally need not |
|
195 |
change the @{attribute defn} setup. |
|
196 |
||
197 |
Definitions may be presented with explicit arguments on the LHS, as |
|
198 |
well as additional conditions, e.g.\ @{text "f x y = t"} instead of |
|
199 |
@{text "f \<equiv> \<lambda>x y. t"} and @{text "y \<noteq> 0 \<Longrightarrow> g x y = u"} instead of an |
|
200 |
unrestricted @{text "g \<equiv> \<lambda>x y. u"}. |
|
201 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
202 |
\item @{command "abbreviation"}~@{text "c \<WHERE> eq"} introduces a |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
203 |
syntactic constant which is associated with a certain term according |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
204 |
to the meta-level equality @{text eq}. |
27040 | 205 |
|
206 |
Abbreviations participate in the usual type-inference process, but |
|
207 |
are expanded before the logic ever sees them. Pretty printing of |
|
208 |
terms involves higher-order rewriting with rules stemming from |
|
209 |
reverted abbreviations. This needs some care to avoid overlapping |
|
210 |
or looping syntactic replacements! |
|
211 |
||
212 |
The optional @{text mode} specification restricts output to a |
|
213 |
particular print mode; using ``@{text input}'' here achieves the |
|
214 |
effect of one-way abbreviations. The mode may also include an |
|
215 |
``@{keyword "output"}'' qualifier that affects the concrete syntax |
|
216 |
declared for abbreviations, cf.\ @{command "syntax"} in |
|
217 |
\secref{sec:syn-trans}. |
|
218 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
219 |
\item @{command "print_abbrevs"} prints all constant abbreviations |
27040 | 220 |
of the current context. |
221 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
222 |
\end{description} |
27040 | 223 |
*} |
224 |
||
225 |
||
226 |
section {* Generic declarations *} |
|
227 |
||
228 |
text {* |
|
229 |
Arbitrary operations on the background context may be wrapped-up as |
|
230 |
generic declaration elements. Since the underlying concept of local |
|
231 |
theories may be subject to later re-interpretation, there is an |
|
232 |
additional dependency on a morphism that tells the difference of the |
|
233 |
original declaration context wrt.\ the application context |
|
234 |
encountered later on. A fact declaration is an important special |
|
235 |
case: it consists of a theorem which is applied to the context by |
|
236 |
means of an attribute. |
|
237 |
||
238 |
\begin{matharray}{rcl} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
239 |
@{command_def "declaration"} & : & @{text "local_theory \<rightarrow> local_theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
240 |
@{command_def "declare"} & : & @{text "local_theory \<rightarrow> local_theory"} \\ |
27040 | 241 |
\end{matharray} |
242 |
||
243 |
\begin{rail} |
|
244 |
'declaration' target? text |
|
245 |
; |
|
246 |
'declare' target? (thmrefs + 'and') |
|
247 |
; |
|
248 |
\end{rail} |
|
249 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
250 |
\begin{description} |
27040 | 251 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
252 |
\item @{command "declaration"}~@{text d} adds the declaration |
27040 | 253 |
function @{text d} of ML type @{ML_type declaration}, to the current |
254 |
local theory under construction. In later application contexts, the |
|
255 |
function is transformed according to the morphisms being involved in |
|
256 |
the interpretation hierarchy. |
|
257 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
258 |
\item @{command "declare"}~@{text thms} declares theorems to the |
27040 | 259 |
current local theory context. No theorem binding is involved here, |
260 |
unlike @{command "theorems"} or @{command "lemmas"} (cf.\ |
|
261 |
\secref{sec:axms-thms}), so @{command "declare"} only has the effect |
|
262 |
of applying attributes as included in the theorem specification. |
|
263 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
264 |
\end{description} |
27040 | 265 |
*} |
266 |
||
267 |
||
268 |
section {* Locales \label{sec:locale} *} |
|
269 |
||
270 |
text {* |
|
271 |
Locales are named local contexts, consisting of a list of |
|
272 |
declaration elements that are modeled after the Isar proof context |
|
273 |
commands (cf.\ \secref{sec:proof-context}). |
|
274 |
*} |
|
275 |
||
276 |
||
277 |
subsection {* Locale specifications *} |
|
278 |
||
279 |
text {* |
|
280 |
\begin{matharray}{rcl} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
281 |
@{command_def "locale"} & : & @{text "theory \<rightarrow> local_theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
282 |
@{command_def "print_locale"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
283 |
@{command_def "print_locales"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
284 |
@{method_def intro_locales} & : & @{text method} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
285 |
@{method_def unfold_locales} & : & @{text method} \\ |
27040 | 286 |
\end{matharray} |
287 |
||
288 |
\indexouternonterm{contextexpr}\indexouternonterm{contextelem} |
|
289 |
\indexisarelem{fixes}\indexisarelem{constrains}\indexisarelem{assumes} |
|
28787 | 290 |
\indexisarelem{defines}\indexisarelem{notes} |
27040 | 291 |
\begin{rail} |
27681 | 292 |
'locale' name ('=' localeexpr)? 'begin'? |
27040 | 293 |
; |
294 |
'print\_locale' '!'? localeexpr |
|
295 |
; |
|
296 |
localeexpr: ((contextexpr '+' (contextelem+)) | contextexpr | (contextelem+)) |
|
297 |
; |
|
298 |
||
299 |
contextexpr: nameref | '(' contextexpr ')' | |
|
300 |
(contextexpr (name mixfix? +)) | (contextexpr + '+') |
|
301 |
; |
|
302 |
contextelem: fixes | constrains | assumes | defines | notes |
|
303 |
; |
|
304 |
fixes: 'fixes' ((name ('::' type)? structmixfix? | vars) + 'and') |
|
305 |
; |
|
306 |
constrains: 'constrains' (name '::' type + 'and') |
|
307 |
; |
|
308 |
assumes: 'assumes' (thmdecl? props + 'and') |
|
309 |
; |
|
310 |
defines: 'defines' (thmdecl? prop proppat? + 'and') |
|
311 |
; |
|
312 |
notes: 'notes' (thmdef? thmrefs + 'and') |
|
313 |
; |
|
314 |
\end{rail} |
|
315 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
316 |
\begin{description} |
27040 | 317 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
318 |
\item @{command "locale"}~@{text "loc = import + body"} defines a |
27040 | 319 |
new locale @{text loc} as a context consisting of a certain view of |
320 |
existing locales (@{text import}) plus some additional elements |
|
321 |
(@{text body}). Both @{text import} and @{text body} are optional; |
|
322 |
the degenerate form @{command "locale"}~@{text loc} defines an empty |
|
323 |
locale, which may still be useful to collect declarations of facts |
|
324 |
later on. Type-inference on locale expressions automatically takes |
|
325 |
care of the most general typing that the combined context elements |
|
326 |
may acquire. |
|
327 |
||
328 |
The @{text import} consists of a structured context expression, |
|
329 |
consisting of references to existing locales, renamed contexts, or |
|
330 |
merged contexts. Renaming uses positional notation: @{text "c |
|
331 |
x\<^sub>1 \<dots> x\<^sub>n"} means that (a prefix of) the fixed |
|
332 |
parameters of context @{text c} are named @{text "x\<^sub>1, \<dots>, |
|
333 |
x\<^sub>n"}; a ``@{text _}'' (underscore) means to skip that |
|
334 |
position. Renaming by default deletes concrete syntax, but new |
|
335 |
syntax may by specified with a mixfix annotation. An exeption of |
|
336 |
this rule is the special syntax declared with ``@{text |
|
337 |
"(\<STRUCTURE>)"}'' (see below), which is neither deleted nor can it |
|
338 |
be changed. Merging proceeds from left-to-right, suppressing any |
|
339 |
duplicates stemming from different paths through the import |
|
340 |
hierarchy. |
|
341 |
||
342 |
The @{text body} consists of basic context elements, further context |
|
343 |
expressions may be included as well. |
|
344 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
345 |
\begin{description} |
27040 | 346 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
347 |
\item @{element "fixes"}~@{text "x :: \<tau> (mx)"} declares a local |
27040 | 348 |
parameter of type @{text \<tau>} and mixfix annotation @{text mx} (both |
349 |
are optional). The special syntax declaration ``@{text |
|
350 |
"(\<STRUCTURE>)"}'' means that @{text x} may be referenced |
|
351 |
implicitly in this context. |
|
352 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
353 |
\item @{element "constrains"}~@{text "x :: \<tau>"} introduces a type |
27040 | 354 |
constraint @{text \<tau>} on the local parameter @{text x}. |
355 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
356 |
\item @{element "assumes"}~@{text "a: \<phi>\<^sub>1 \<dots> \<phi>\<^sub>n"} |
27040 | 357 |
introduces local premises, similar to @{command "assume"} within a |
358 |
proof (cf.\ \secref{sec:proof-context}). |
|
359 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
360 |
\item @{element "defines"}~@{text "a: x \<equiv> t"} defines a previously |
27040 | 361 |
declared parameter. This is similar to @{command "def"} within a |
362 |
proof (cf.\ \secref{sec:proof-context}), but @{element "defines"} |
|
363 |
takes an equational proposition instead of variable-term pair. The |
|
364 |
left-hand side of the equation may have additional arguments, e.g.\ |
|
365 |
``@{element "defines"}~@{text "f x\<^sub>1 \<dots> x\<^sub>n \<equiv> t"}''. |
|
366 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
367 |
\item @{element "notes"}~@{text "a = b\<^sub>1 \<dots> b\<^sub>n"} |
27040 | 368 |
reconsiders facts within a local context. Most notably, this may |
369 |
include arbitrary declarations in any attribute specifications |
|
370 |
included here, e.g.\ a local @{attribute simp} rule. |
|
371 |
||
28787 | 372 |
The initial @{text import} specification of a locale expression |
373 |
maintains a dynamic relation to the locales being referenced |
|
374 |
(benefiting from any later fact declarations in the obvious manner). |
|
27040 | 375 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
376 |
\end{description} |
27040 | 377 |
|
378 |
Note that ``@{text "(\<IS> p\<^sub>1 \<dots> p\<^sub>n)"}'' patterns given |
|
379 |
in the syntax of @{element "assumes"} and @{element "defines"} above |
|
380 |
are illegal in locale definitions. In the long goal format of |
|
381 |
\secref{sec:goals}, term bindings may be included as expected, |
|
382 |
though. |
|
383 |
||
384 |
\medskip By default, locale specifications are ``closed up'' by |
|
385 |
turning the given text into a predicate definition @{text |
|
386 |
loc_axioms} and deriving the original assumptions as local lemmas |
|
387 |
(modulo local definitions). The predicate statement covers only the |
|
388 |
newly specified assumptions, omitting the content of included locale |
|
389 |
expressions. The full cumulative view is only provided on export, |
|
390 |
involving another predicate @{text loc} that refers to the complete |
|
391 |
specification text. |
|
392 |
||
393 |
In any case, the predicate arguments are those locale parameters |
|
394 |
that actually occur in the respective piece of text. Also note that |
|
395 |
these predicates operate at the meta-level in theory, but the locale |
|
396 |
packages attempts to internalize statements according to the |
|
397 |
object-logic setup (e.g.\ replacing @{text \<And>} by @{text \<forall>}, and |
|
398 |
@{text "\<Longrightarrow>"} by @{text "\<longrightarrow>"} in HOL; see also |
|
399 |
\secref{sec:object-logic}). Separate introduction rules @{text |
|
400 |
loc_axioms.intro} and @{text loc.intro} are provided as well. |
|
401 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
402 |
\item @{command "print_locale"}~@{text "import + body"} prints the |
27040 | 403 |
specified locale expression in a flattened form. The notable |
404 |
special case @{command "print_locale"}~@{text loc} just prints the |
|
405 |
contents of the named locale, but keep in mind that type-inference |
|
406 |
will normalize type variables according to the usual alphabetical |
|
407 |
order. The command omits @{element "notes"} elements by default. |
|
408 |
Use @{command "print_locale"}@{text "!"} to get them included. |
|
409 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
410 |
\item @{command "print_locales"} prints the names of all locales |
27040 | 411 |
of the current theory. |
412 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
413 |
\item @{method intro_locales} and @{method unfold_locales} |
27040 | 414 |
repeatedly expand all introduction rules of locale predicates of the |
415 |
theory. While @{method intro_locales} only applies the @{text |
|
416 |
loc.intro} introduction rules and therefore does not decend to |
|
417 |
assumptions, @{method unfold_locales} is more aggressive and applies |
|
418 |
@{text loc_axioms.intro} as well. Both methods are aware of locale |
|
28787 | 419 |
specifications entailed by the context, both from target statements, |
420 |
and from interpretations (see below). New goals that are entailed |
|
421 |
by the current context are discharged automatically. |
|
27040 | 422 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
423 |
\end{description} |
27040 | 424 |
*} |
425 |
||
426 |
||
427 |
subsection {* Interpretation of locales *} |
|
428 |
||
429 |
text {* |
|
430 |
Locale expressions (more precisely, \emph{context expressions}) may |
|
431 |
be instantiated, and the instantiated facts added to the current |
|
432 |
context. This requires a proof of the instantiated specification |
|
433 |
and is called \emph{locale interpretation}. Interpretation is |
|
434 |
possible in theories and locales (command @{command |
|
435 |
"interpretation"}) and also within a proof body (command @{command |
|
436 |
"interpret"}). |
|
437 |
||
438 |
\begin{matharray}{rcl} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
439 |
@{command_def "interpretation"} & : & @{text "theory \<rightarrow> proof(prove)"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
440 |
@{command_def "interpret"} & : & @{text "proof(state) | proof(chain \<rightarrow> proof(prove)"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
441 |
@{command_def "print_interps"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
27040 | 442 |
\end{matharray} |
443 |
||
444 |
\indexouternonterm{interp} |
|
445 |
\begin{rail} |
|
446 |
'interpretation' (interp | name ('<' | subseteq) contextexpr) |
|
447 |
; |
|
448 |
'interpret' interp |
|
449 |
; |
|
450 |
'print\_interps' '!'? name |
|
451 |
; |
|
452 |
instantiation: ('[' (inst+) ']')? |
|
453 |
; |
|
28085
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
27681
diff
changeset
|
454 |
interp: (name ':')? \\ (contextexpr instantiation | |
27040 | 455 |
name instantiation 'where' (thmdecl? prop + 'and')) |
456 |
; |
|
457 |
\end{rail} |
|
458 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
459 |
\begin{description} |
27040 | 460 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
461 |
\item @{command "interpretation"}~@{text "expr insts \<WHERE> eqns"} |
27040 | 462 |
|
463 |
The first form of @{command "interpretation"} interprets @{text |
|
464 |
expr} in the theory. The instantiation is given as a list of terms |
|
465 |
@{text insts} and is positional. All parameters must receive an |
|
466 |
instantiation term --- with the exception of defined parameters. |
|
467 |
These are, if omitted, derived from the defining equation and other |
|
468 |
instantiations. Use ``@{text _}'' to omit an instantiation term. |
|
469 |
||
470 |
The command generates proof obligations for the instantiated |
|
471 |
specifications (assumes and defines elements). Once these are |
|
472 |
discharged by the user, instantiated facts are added to the theory |
|
473 |
in a post-processing phase. |
|
474 |
||
475 |
Additional equations, which are unfolded in facts during |
|
476 |
post-processing, may be given after the keyword @{keyword "where"}. |
|
477 |
This is useful for interpreting concepts introduced through |
|
478 |
definition specification elements. The equations must be proved. |
|
479 |
Note that if equations are present, the context expression is |
|
480 |
restricted to a locale name. |
|
481 |
||
482 |
The command is aware of interpretations already active in the |
|
28085
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
27681
diff
changeset
|
483 |
theory, but does not simplify the goal automatically. In order to |
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
27681
diff
changeset
|
484 |
simplify the proof obligations use methods @{method intro_locales} |
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
27681
diff
changeset
|
485 |
or @{method unfold_locales}. Post-processing is not applied to |
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
27681
diff
changeset
|
486 |
facts of interpretations that are already active. This avoids |
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
27681
diff
changeset
|
487 |
duplication of interpreted facts, in particular. Note that, in the |
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
27681
diff
changeset
|
488 |
case of a locale with import, parts of the interpretation may |
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
27681
diff
changeset
|
489 |
already be active. The command will only process facts for new |
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
27681
diff
changeset
|
490 |
parts. |
27040 | 491 |
|
28085
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
27681
diff
changeset
|
492 |
The context expression may be preceded by a name, which takes effect |
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
27681
diff
changeset
|
493 |
in the post-processing of facts. It is used to prefix fact names, |
914183e229e9
Interpretation commands no longer accept interpretation attributes.
ballarin
parents:
27681
diff
changeset
|
494 |
for example to avoid accidental hiding of other facts. |
27040 | 495 |
|
496 |
Adding facts to locales has the effect of adding interpreted facts |
|
497 |
to the theory for all active interpretations also. That is, |
|
498 |
interpretations dynamically participate in any facts added to |
|
499 |
locales. |
|
500 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
501 |
\item @{command "interpretation"}~@{text "name \<subseteq> expr"} |
27040 | 502 |
|
503 |
This form of the command interprets @{text expr} in the locale |
|
504 |
@{text name}. It requires a proof that the specification of @{text |
|
505 |
name} implies the specification of @{text expr}. As in the |
|
506 |
localized version of the theorem command, the proof is in the |
|
507 |
context of @{text name}. After the proof obligation has been |
|
508 |
dischared, the facts of @{text expr} become part of locale @{text |
|
509 |
name} as \emph{derived} context elements and are available when the |
|
510 |
context @{text name} is subsequently entered. Note that, like |
|
511 |
import, this is dynamic: facts added to a locale part of @{text |
|
512 |
expr} after interpretation become also available in @{text name}. |
|
513 |
Like facts of renamed context elements, facts obtained by |
|
514 |
interpretation may be accessed by prefixing with the parameter |
|
515 |
renaming (where the parameters are separated by ``@{text _}''). |
|
516 |
||
517 |
Unlike interpretation in theories, instantiation is confined to the |
|
518 |
renaming of parameters, which may be specified as part of the |
|
519 |
context expression @{text expr}. Using defined parameters in @{text |
|
520 |
name} one may achieve an effect similar to instantiation, though. |
|
521 |
||
522 |
Only specification fragments of @{text expr} that are not already |
|
523 |
part of @{text name} (be it imported, derived or a derived fragment |
|
524 |
of the import) are considered by interpretation. This enables |
|
525 |
circular interpretations. |
|
526 |
||
527 |
If interpretations of @{text name} exist in the current theory, the |
|
528 |
command adds interpretations for @{text expr} as well, with the same |
|
529 |
prefix and attributes, although only for fragments of @{text expr} |
|
530 |
that are not interpreted in the theory already. |
|
531 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
532 |
\item @{command "interpret"}~@{text "expr insts \<WHERE> eqns"} |
27040 | 533 |
interprets @{text expr} in the proof context and is otherwise |
534 |
similar to interpretation in theories. |
|
535 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
536 |
\item @{command "print_interps"}~@{text loc} prints the |
27040 | 537 |
interpretations of a particular locale @{text loc} that are active |
538 |
in the current context, either theory or proof context. The |
|
539 |
exclamation point argument triggers printing of \emph{witness} |
|
540 |
theorems justifying interpretations. These are normally omitted |
|
541 |
from the output. |
|
542 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
543 |
\end{description} |
27040 | 544 |
|
545 |
\begin{warn} |
|
546 |
Since attributes are applied to interpreted theorems, |
|
547 |
interpretation may modify the context of common proof tools, e.g.\ |
|
548 |
the Simplifier or Classical Reasoner. Since the behavior of such |
|
549 |
automated reasoning tools is \emph{not} stable under |
|
550 |
interpretation morphisms, manual declarations might have to be |
|
551 |
issued. |
|
552 |
\end{warn} |
|
553 |
||
554 |
\begin{warn} |
|
555 |
An interpretation in a theory may subsume previous |
|
556 |
interpretations. This happens if the same specification fragment |
|
557 |
is interpreted twice and the instantiation of the second |
|
558 |
interpretation is more general than the interpretation of the |
|
559 |
first. A warning is issued, since it is likely that these could |
|
560 |
have been generalized in the first place. The locale package does |
|
561 |
not attempt to remove subsumed interpretations. |
|
562 |
\end{warn} |
|
563 |
*} |
|
564 |
||
565 |
||
566 |
section {* Classes \label{sec:class} *} |
|
567 |
||
568 |
text {* |
|
569 |
A class is a particular locale with \emph{exactly one} type variable |
|
570 |
@{text \<alpha>}. Beyond the underlying locale, a corresponding type class |
|
571 |
is established which is interpreted logically as axiomatic type |
|
572 |
class \cite{Wenzel:1997:TPHOL} whose logical content are the |
|
573 |
assumptions of the locale. Thus, classes provide the full |
|
574 |
generality of locales combined with the commodity of type classes |
|
575 |
(notably type-inference). See \cite{isabelle-classes} for a short |
|
576 |
tutorial. |
|
577 |
||
578 |
\begin{matharray}{rcl} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
579 |
@{command_def "class"} & : & @{text "theory \<rightarrow> local_theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
580 |
@{command_def "instantiation"} & : & @{text "theory \<rightarrow> local_theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
581 |
@{command_def "instance"} & : & @{text "local_theory \<rightarrow> local_theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
582 |
@{command_def "subclass"} & : & @{text "local_theory \<rightarrow> local_theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
583 |
@{command_def "print_classes"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
584 |
@{method_def intro_classes} & : & @{text method} \\ |
27040 | 585 |
\end{matharray} |
586 |
||
587 |
\begin{rail} |
|
588 |
'class' name '=' ((superclassexpr '+' (contextelem+)) | superclassexpr | (contextelem+)) \\ |
|
589 |
'begin'? |
|
590 |
; |
|
591 |
'instantiation' (nameref + 'and') '::' arity 'begin' |
|
592 |
; |
|
593 |
'instance' |
|
594 |
; |
|
595 |
'subclass' target? nameref |
|
596 |
; |
|
597 |
'print\_classes' |
|
598 |
; |
|
599 |
||
600 |
superclassexpr: nameref | (nameref '+' superclassexpr) |
|
601 |
; |
|
602 |
\end{rail} |
|
603 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
604 |
\begin{description} |
27040 | 605 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
606 |
\item @{command "class"}~@{text "c = superclasses + body"} defines |
27040 | 607 |
a new class @{text c}, inheriting from @{text superclasses}. This |
608 |
introduces a locale @{text c} with import of all locales @{text |
|
609 |
superclasses}. |
|
610 |
||
611 |
Any @{element "fixes"} in @{text body} are lifted to the global |
|
612 |
theory level (\emph{class operations} @{text "f\<^sub>1, \<dots>, |
|
613 |
f\<^sub>n"} of class @{text c}), mapping the local type parameter |
|
614 |
@{text \<alpha>} to a schematic type variable @{text "?\<alpha> :: c"}. |
|
615 |
||
616 |
Likewise, @{element "assumes"} in @{text body} are also lifted, |
|
617 |
mapping each local parameter @{text "f :: \<tau>[\<alpha>]"} to its |
|
618 |
corresponding global constant @{text "f :: \<tau>[?\<alpha> :: c]"}. The |
|
619 |
corresponding introduction rule is provided as @{text |
|
620 |
c_class_axioms.intro}. This rule should be rarely needed directly |
|
621 |
--- the @{method intro_classes} method takes care of the details of |
|
622 |
class membership proofs. |
|
623 |
||
28768
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
624 |
\item @{command "instantiation"}~@{text "t :: (s\<^sub>1, \<dots>, s\<^sub>n)s |
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
625 |
\<BEGIN>"} opens a theory target (cf.\ \secref{sec:target}) which |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
626 |
allows to specify class operations @{text "f\<^sub>1, \<dots>, f\<^sub>n"} corresponding |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
627 |
to sort @{text s} at the particular type instance @{text "(\<alpha>\<^sub>1 :: s\<^sub>1, |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
628 |
\<dots>, \<alpha>\<^sub>n :: s\<^sub>n) t"}. A plain @{command "instance"} command in the |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
629 |
target body poses a goal stating these type arities. The target is |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
630 |
concluded by an @{command_ref (local) "end"} command. |
27040 | 631 |
|
632 |
Note that a list of simultaneous type constructors may be given; |
|
633 |
this corresponds nicely to mutual recursive type definitions, e.g.\ |
|
634 |
in Isabelle/HOL. |
|
635 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
636 |
\item @{command "instance"} in an instantiation target body sets |
27040 | 637 |
up a goal stating the type arities claimed at the opening @{command |
638 |
"instantiation"}. The proof would usually proceed by @{method |
|
639 |
intro_classes}, and then establish the characteristic theorems of |
|
640 |
the type classes involved. After finishing the proof, the |
|
641 |
background theory will be augmented by the proven type arities. |
|
642 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
643 |
\item @{command "subclass"}~@{text c} in a class context for class |
27040 | 644 |
@{text d} sets up a goal stating that class @{text c} is logically |
645 |
contained in class @{text d}. After finishing the proof, class |
|
646 |
@{text d} is proven to be subclass @{text c} and the locale @{text |
|
647 |
c} is interpreted into @{text d} simultaneously. |
|
648 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
649 |
\item @{command "print_classes"} prints all classes in the current |
27040 | 650 |
theory. |
651 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
652 |
\item @{method intro_classes} repeatedly expands all class |
27040 | 653 |
introduction rules of this theory. Note that this method usually |
654 |
needs not be named explicitly, as it is already included in the |
|
655 |
default proof step (e.g.\ of @{command "proof"}). In particular, |
|
656 |
instantiation of trivial (syntactic) classes may be performed by a |
|
657 |
single ``@{command ".."}'' proof step. |
|
26870 | 658 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
659 |
\end{description} |
26870 | 660 |
*} |
661 |
||
27040 | 662 |
|
663 |
subsection {* The class target *} |
|
664 |
||
665 |
text {* |
|
666 |
%FIXME check |
|
667 |
||
668 |
A named context may refer to a locale (cf.\ \secref{sec:target}). |
|
669 |
If this locale is also a class @{text c}, apart from the common |
|
670 |
locale target behaviour the following happens. |
|
671 |
||
672 |
\begin{itemize} |
|
673 |
||
674 |
\item Local constant declarations @{text "g[\<alpha>]"} referring to the |
|
675 |
local type parameter @{text \<alpha>} and local parameters @{text "f[\<alpha>]"} |
|
676 |
are accompanied by theory-level constants @{text "g[?\<alpha> :: c]"} |
|
677 |
referring to theory-level class operations @{text "f[?\<alpha> :: c]"}. |
|
678 |
||
679 |
\item Local theorem bindings are lifted as are assumptions. |
|
680 |
||
681 |
\item Local syntax refers to local operations @{text "g[\<alpha>]"} and |
|
682 |
global operations @{text "g[?\<alpha> :: c]"} uniformly. Type inference |
|
683 |
resolves ambiguities. In rare cases, manual type annotations are |
|
684 |
needed. |
|
685 |
||
686 |
\end{itemize} |
|
687 |
*} |
|
688 |
||
689 |
||
27053 | 690 |
subsection {* Old-style axiomatic type classes \label{sec:axclass} *} |
27040 | 691 |
|
692 |
text {* |
|
693 |
\begin{matharray}{rcl} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
694 |
@{command_def "axclass"} & : & @{text "theory \<rightarrow> theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
695 |
@{command_def "instance"} & : & @{text "theory \<rightarrow> proof(prove)"} \\ |
27040 | 696 |
\end{matharray} |
697 |
||
698 |
Axiomatic type classes are Isabelle/Pure's primitive |
|
699 |
\emph{definitional} interface to type classes. For practical |
|
700 |
applications, you should consider using classes |
|
701 |
(cf.~\secref{sec:classes}) which provide high level interface. |
|
702 |
||
703 |
\begin{rail} |
|
704 |
'axclass' classdecl (axmdecl prop +) |
|
705 |
; |
|
706 |
'instance' (nameref ('<' | subseteq) nameref | nameref '::' arity) |
|
707 |
; |
|
708 |
\end{rail} |
|
709 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
710 |
\begin{description} |
27040 | 711 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
712 |
\item @{command "axclass"}~@{text "c \<subseteq> c\<^sub>1, \<dots>, c\<^sub>n axms"} defines an |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
713 |
axiomatic type class as the intersection of existing classes, with |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
714 |
additional axioms holding. Class axioms may not contain more than |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
715 |
one type variable. The class axioms (with implicit sort constraints |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
716 |
added) are bound to the given names. Furthermore a class |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
717 |
introduction rule is generated (being bound as @{text |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
718 |
c_class.intro}); this rule is employed by method @{method |
27040 | 719 |
intro_classes} to support instantiation proofs of this class. |
720 |
||
28767 | 721 |
The ``class axioms'' (which are derived from the internal class |
722 |
definition) are stored as theorems according to the given name |
|
723 |
specifications; the name space prefix @{text "c_class"} is added |
|
724 |
here. The full collection of these facts is also stored as @{text |
|
27040 | 725 |
c_class.axioms}. |
726 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
727 |
\item @{command "instance"}~@{text "c\<^sub>1 \<subseteq> c\<^sub>2"} and @{command |
28768
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
728 |
"instance"}~@{text "t :: (s\<^sub>1, \<dots>, s\<^sub>n)s"} setup a goal stating a class |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
729 |
relation or type arity. The proof would usually proceed by @{method |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
730 |
intro_classes}, and then establish the characteristic theorems of |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
731 |
the type classes involved. After finishing the proof, the theory |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
732 |
will be augmented by a type signature declaration corresponding to |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
733 |
the resulting theorem. |
27040 | 734 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
735 |
\end{description} |
27040 | 736 |
*} |
737 |
||
738 |
||
739 |
section {* Unrestricted overloading *} |
|
740 |
||
741 |
text {* |
|
742 |
Isabelle/Pure's definitional schemes support certain forms of |
|
743 |
overloading (see \secref{sec:consts}). At most occassions |
|
744 |
overloading will be used in a Haskell-like fashion together with |
|
745 |
type classes by means of @{command "instantiation"} (see |
|
746 |
\secref{sec:class}). Sometimes low-level overloading is desirable. |
|
747 |
The @{command "overloading"} target provides a convenient view for |
|
748 |
end-users. |
|
749 |
||
750 |
\begin{matharray}{rcl} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
751 |
@{command_def "overloading"} & : & @{text "theory \<rightarrow> local_theory"} \\ |
27040 | 752 |
\end{matharray} |
753 |
||
754 |
\begin{rail} |
|
755 |
'overloading' \\ |
|
756 |
( string ( '==' | equiv ) term ( '(' 'unchecked' ')' )? + ) 'begin' |
|
757 |
\end{rail} |
|
758 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
759 |
\begin{description} |
27040 | 760 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
761 |
\item @{command "overloading"}~@{text "x\<^sub>1 \<equiv> c\<^sub>1 :: \<tau>\<^sub>1 \<AND> \<dots> x\<^sub>n \<equiv> c\<^sub>n :: \<tau>\<^sub>n \<BEGIN>"} |
27040 | 762 |
opens a theory target (cf.\ \secref{sec:target}) which allows to |
763 |
specify constants with overloaded definitions. These are identified |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
764 |
by an explicitly given mapping from variable names @{text "x\<^sub>i"} to |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
765 |
constants @{text "c\<^sub>i"} at particular type instances. The |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
766 |
definitions themselves are established using common specification |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
767 |
tools, using the names @{text "x\<^sub>i"} as reference to the |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
768 |
corresponding constants. The target is concluded by @{command |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
769 |
(local) "end"}. |
27040 | 770 |
|
771 |
A @{text "(unchecked)"} option disables global dependency checks for |
|
772 |
the corresponding definition, which is occasionally useful for |
|
773 |
exotic overloading. It is at the discretion of the user to avoid |
|
774 |
malformed theory specifications! |
|
775 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
776 |
\end{description} |
27040 | 777 |
*} |
778 |
||
779 |
||
780 |
section {* Incorporating ML code \label{sec:ML} *} |
|
781 |
||
782 |
text {* |
|
783 |
\begin{matharray}{rcl} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
784 |
@{command_def "use"} & : & @{text "local_theory \<rightarrow> local_theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
785 |
@{command_def "ML"} & : & @{text "local_theory \<rightarrow> local_theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
786 |
@{command_def "ML_prf"} & : & @{text "proof \<rightarrow> proof"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
787 |
@{command_def "ML_val"} & : & @{text "any \<rightarrow>"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
788 |
@{command_def "ML_command"} & : & @{text "any \<rightarrow>"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
789 |
@{command_def "setup"} & : & @{text "theory \<rightarrow> theory"} \\ |
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
790 |
\end{matharray} |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
791 |
|
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
792 |
\begin{mldecls} |
28758 | 793 |
@{index_ML bind_thms: "string * thm list -> unit"} \\ |
794 |
@{index_ML bind_thm: "string * thm -> unit"} \\ |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
795 |
\end{mldecls} |
27040 | 796 |
|
797 |
\begin{rail} |
|
798 |
'use' name |
|
799 |
; |
|
28757 | 800 |
('ML' | 'ML\_prf' | 'ML\_val' | 'ML\_command' | 'setup') text |
27040 | 801 |
; |
802 |
\end{rail} |
|
803 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
804 |
\begin{description} |
27040 | 805 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
806 |
\item @{command "use"}~@{text "file"} reads and executes ML |
27040 | 807 |
commands from @{text "file"}. The current theory context is passed |
28757 | 808 |
down to the ML toplevel and may be modified, using @{ML [source=false] |
27040 | 809 |
"Context.>>"} or derived ML commands. The file name is checked with |
810 |
the @{keyword_ref "uses"} dependency declaration given in the theory |
|
811 |
header (see also \secref{sec:begin-thy}). |
|
28281 | 812 |
|
813 |
Top-level ML bindings are stored within the (global or local) theory |
|
814 |
context. |
|
27040 | 815 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
816 |
\item @{command "ML"}~@{text "text"} is similar to @{command "use"}, |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
817 |
but executes ML commands directly from the given @{text "text"}. |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
818 |
Top-level ML bindings are stored within the (global or local) theory |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
819 |
context. |
28281 | 820 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
821 |
\item @{command "ML_prf"} is analogous to @{command "ML"} but works |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
822 |
within a proof context. |
28281 | 823 |
|
824 |
Top-level ML bindings are stored within the proof context in a |
|
825 |
purely sequential fashion, disregarding the nested proof structure. |
|
826 |
ML bindings introduced by @{command "ML_prf"} are discarded at the |
|
827 |
end of the proof. |
|
27040 | 828 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
829 |
\item @{command "ML_val"} and @{command "ML_command"} are diagnostic |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
830 |
versions of @{command "ML"}, which means that the context may not be |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
831 |
updated. @{command "ML_val"} echos the bindings produced at the ML |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
832 |
toplevel, but @{command "ML_command"} is silent. |
27040 | 833 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
834 |
\item @{command "setup"}~@{text "text"} changes the current theory |
27040 | 835 |
context by applying @{text "text"}, which refers to an ML expression |
28757 | 836 |
of type @{ML_type [source=false] "theory -> theory"}. This enables |
837 |
to initialize any object-logic specific tools and packages written |
|
838 |
in ML, for example. |
|
28758 | 839 |
|
840 |
\item @{ML bind_thms}~@{text "(name, thms)"} stores a list of |
|
841 |
theorems produced in ML both in the theory context and the ML |
|
842 |
toplevel, associating it with the provided name. Theorems are put |
|
843 |
into a global ``standard'' format before being stored. |
|
844 |
||
845 |
\item @{ML bind_thm} is similar to @{ML bind_thms} but refers to a |
|
846 |
singleton theorem. |
|
27040 | 847 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
848 |
\end{description} |
27040 | 849 |
*} |
850 |
||
851 |
||
852 |
section {* Primitive specification elements *} |
|
853 |
||
854 |
subsection {* Type classes and sorts \label{sec:classes} *} |
|
855 |
||
856 |
text {* |
|
857 |
\begin{matharray}{rcll} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
858 |
@{command_def "classes"} & : & @{text "theory \<rightarrow> theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
859 |
@{command_def "classrel"} & : & @{text "theory \<rightarrow> theory"} & (axiomatic!) \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
860 |
@{command_def "defaultsort"} & : & @{text "theory \<rightarrow> theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
861 |
@{command_def "class_deps"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
27040 | 862 |
\end{matharray} |
863 |
||
864 |
\begin{rail} |
|
865 |
'classes' (classdecl +) |
|
866 |
; |
|
867 |
'classrel' (nameref ('<' | subseteq) nameref + 'and') |
|
868 |
; |
|
869 |
'defaultsort' sort |
|
870 |
; |
|
871 |
\end{rail} |
|
872 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
873 |
\begin{description} |
27040 | 874 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
875 |
\item @{command "classes"}~@{text "c \<subseteq> c\<^sub>1, \<dots>, c\<^sub>n"} declares class |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
876 |
@{text c} to be a subclass of existing classes @{text "c\<^sub>1, \<dots>, c\<^sub>n"}. |
28767 | 877 |
Isabelle implicitly maintains the transitive closure of the class |
878 |
hierarchy. Cyclic class structures are not permitted. |
|
27040 | 879 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
880 |
\item @{command "classrel"}~@{text "c\<^sub>1 \<subseteq> c\<^sub>2"} states subclass |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
881 |
relations between existing classes @{text "c\<^sub>1"} and @{text "c\<^sub>2"}. |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
882 |
This is done axiomatically! The @{command_ref "instance"} command |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
883 |
(see \secref{sec:axclass}) provides a way to introduce proven class |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
884 |
relations. |
27040 | 885 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
886 |
\item @{command "defaultsort"}~@{text s} makes sort @{text s} the |
28767 | 887 |
new default sort for any type variable that is given explicitly in |
888 |
the text, but lacks a sort constraint (wrt.\ the current context). |
|
889 |
Type variables generated by type inference are not affected. |
|
890 |
||
891 |
Usually the default sort is only changed when defining a new |
|
892 |
object-logic. For example, the default sort in Isabelle/HOL is |
|
893 |
@{text type}, the class of all HOL types. %FIXME sort antiq? |
|
894 |
||
895 |
When merging theories, the default sorts of the parents are |
|
896 |
logically intersected, i.e.\ the representations as lists of classes |
|
897 |
are joined. |
|
27040 | 898 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
899 |
\item @{command "class_deps"} visualizes the subclass relation, |
27040 | 900 |
using Isabelle's graph browser tool (see also \cite{isabelle-sys}). |
901 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
902 |
\end{description} |
27040 | 903 |
*} |
904 |
||
905 |
||
906 |
subsection {* Types and type abbreviations \label{sec:types-pure} *} |
|
907 |
||
908 |
text {* |
|
909 |
\begin{matharray}{rcll} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
910 |
@{command_def "types"} & : & @{text "theory \<rightarrow> theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
911 |
@{command_def "typedecl"} & : & @{text "theory \<rightarrow> theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
912 |
@{command_def "arities"} & : & @{text "theory \<rightarrow> theory"} & (axiomatic!) \\ |
27040 | 913 |
\end{matharray} |
914 |
||
915 |
\begin{rail} |
|
916 |
'types' (typespec '=' type infix? +) |
|
917 |
; |
|
918 |
'typedecl' typespec infix? |
|
919 |
; |
|
920 |
'arities' (nameref '::' arity +) |
|
921 |
; |
|
922 |
\end{rail} |
|
923 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
924 |
\begin{description} |
27040 | 925 |
|
28767 | 926 |
\item @{command "types"}~@{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n) t = \<tau>"} introduces a |
927 |
\emph{type synonym} @{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n) t"} for the existing type |
|
928 |
@{text "\<tau>"}. Unlike actual type definitions, as are available in |
|
929 |
Isabelle/HOL for example, type synonyms are merely syntactic |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
930 |
abbreviations without any logical significance. Internally, type |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
931 |
synonyms are fully expanded. |
27040 | 932 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
933 |
\item @{command "typedecl"}~@{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n) t"} declares a new |
28767 | 934 |
type constructor @{text t}. If the object-logic defines a base sort |
935 |
@{text s}, then the constructor is declared to operate on that, via |
|
936 |
the axiomatic specification @{command arities}~@{text "t :: (s, \<dots>, |
|
28768
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
937 |
s)s"}. |
27040 | 938 |
|
28768
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
939 |
\item @{command "arities"}~@{text "t :: (s\<^sub>1, \<dots>, s\<^sub>n)s"} augments |
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
940 |
Isabelle's order-sorted signature of types by new type constructor |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
941 |
arities. This is done axiomatically! The @{command_ref "instance"} |
28768
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
942 |
command (see \secref{sec:axclass}) provides a way to introduce |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
943 |
proven type arities. |
27040 | 944 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
945 |
\end{description} |
27040 | 946 |
*} |
947 |
||
948 |
||
28768
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
949 |
subsection {* Co-regularity of type classes and arities *} |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
950 |
|
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
951 |
text {* The class relation together with the collection of |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
952 |
type-constructor arities must obey the principle of |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
953 |
\emph{co-regularity} as defined below. |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
954 |
|
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
955 |
\medskip For the subsequent formulation of co-regularity we assume |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
956 |
that the class relation is closed by transitivity and reflexivity. |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
957 |
Moreover the collection of arities @{text "t :: (\<^vec>s)c"} is |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
958 |
completed such that @{text "t :: (\<^vec>s)c"} and @{text "c \<subseteq> c'"} |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
959 |
implies @{text "t :: (\<^vec>s)c'"} for all such declarations. |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
960 |
|
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
961 |
Treating sorts as finite sets of classes (meaning the intersection), |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
962 |
the class relation @{text "c\<^sub>1 \<subseteq> c\<^sub>2"} is extended to sorts as |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
963 |
follows: |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
964 |
\[ |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
965 |
@{text "s\<^sub>1 \<subseteq> s\<^sub>2 \<equiv> \<forall>c\<^sub>2 \<in> s\<^sub>2. \<exists>c\<^sub>1 \<in> s\<^sub>1. c\<^sub>1 \<subseteq> c\<^sub>2"} |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
966 |
\] |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
967 |
|
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
968 |
This relation on sorts is further extended to tuples of sorts (of |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
969 |
the same length) in the component-wise way. |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
970 |
|
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
971 |
\smallskip Co-regularity of the class relation together with the |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
972 |
arities relation means: |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
973 |
\[ |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
974 |
@{text "t :: (\<^vec>s\<^sub>1)c\<^sub>1 \<Longrightarrow> t :: (\<^vec>s\<^sub>2)c\<^sub>2 \<Longrightarrow> c\<^sub>1 \<subseteq> c\<^sub>2 \<Longrightarrow> \<^vec>s\<^sub>1 \<subseteq> \<^vec>s\<^sub>2"} |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
975 |
\] |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
976 |
\noindent for all such arities. In other words, whenever the result |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
977 |
classes of some type-constructor arities are related, then the |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
978 |
argument sorts need to be related in the same way. |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
979 |
|
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
980 |
\medskip Co-regularity is a very fundamental property of the |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
981 |
order-sorted algebra of types. For example, it entails principle |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
982 |
types and most general unifiers, e.g.\ see \cite{nipkow-prehofer}. |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
983 |
*} |
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
984 |
|
a056077b65a1
added section "Co-regularity of type classes and arities" (variant from old ref manual);
wenzelm
parents:
28767
diff
changeset
|
985 |
|
27040 | 986 |
subsection {* Constants and definitions \label{sec:consts} *} |
987 |
||
988 |
text {* |
|
989 |
Definitions essentially express abbreviations within the logic. The |
|
990 |
simplest form of a definition is @{text "c :: \<sigma> \<equiv> t"}, where @{text |
|
991 |
c} is a newly declared constant. Isabelle also allows derived forms |
|
992 |
where the arguments of @{text c} appear on the left, abbreviating a |
|
993 |
prefix of @{text \<lambda>}-abstractions, e.g.\ @{text "c \<equiv> \<lambda>x y. t"} may be |
|
994 |
written more conveniently as @{text "c x y \<equiv> t"}. Moreover, |
|
995 |
definitions may be weakened by adding arbitrary pre-conditions: |
|
996 |
@{text "A \<Longrightarrow> c x y \<equiv> t"}. |
|
997 |
||
998 |
\medskip The built-in well-formedness conditions for definitional |
|
999 |
specifications are: |
|
1000 |
||
1001 |
\begin{itemize} |
|
1002 |
||
1003 |
\item Arguments (on the left-hand side) must be distinct variables. |
|
1004 |
||
1005 |
\item All variables on the right-hand side must also appear on the |
|
1006 |
left-hand side. |
|
1007 |
||
1008 |
\item All type variables on the right-hand side must also appear on |
|
1009 |
the left-hand side; this prohibits @{text "0 :: nat \<equiv> length ([] :: |
|
1010 |
\<alpha> list)"} for example. |
|
1011 |
||
1012 |
\item The definition must not be recursive. Most object-logics |
|
1013 |
provide definitional principles that can be used to express |
|
1014 |
recursion safely. |
|
1015 |
||
1016 |
\end{itemize} |
|
1017 |
||
1018 |
Overloading means that a constant being declared as @{text "c :: \<alpha> |
|
1019 |
decl"} may be defined separately on type instances @{text "c :: |
|
1020 |
(\<beta>\<^sub>1, \<dots>, \<beta>\<^sub>n) t decl"} for each type constructor @{text |
|
1021 |
t}. The right-hand side may mention overloaded constants |
|
1022 |
recursively at type instances corresponding to the immediate |
|
1023 |
argument types @{text "\<beta>\<^sub>1, \<dots>, \<beta>\<^sub>n"}. Incomplete |
|
1024 |
specification patterns impose global constraints on all occurrences, |
|
1025 |
e.g.\ @{text "d :: \<alpha> \<times> \<alpha>"} on the left-hand side means that all |
|
1026 |
corresponding occurrences on some right-hand side need to be an |
|
1027 |
instance of this, general @{text "d :: \<alpha> \<times> \<beta>"} will be disallowed. |
|
1028 |
||
1029 |
\begin{matharray}{rcl} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
1030 |
@{command_def "consts"} & : & @{text "theory \<rightarrow> theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
1031 |
@{command_def "defs"} & : & @{text "theory \<rightarrow> theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
1032 |
@{command_def "constdefs"} & : & @{text "theory \<rightarrow> theory"} \\ |
27040 | 1033 |
\end{matharray} |
1034 |
||
1035 |
\begin{rail} |
|
1036 |
'consts' ((name '::' type mixfix?) +) |
|
1037 |
; |
|
1038 |
'defs' ('(' 'unchecked'? 'overloaded'? ')')? \\ (axmdecl prop +) |
|
1039 |
; |
|
1040 |
\end{rail} |
|
1041 |
||
1042 |
\begin{rail} |
|
1043 |
'constdefs' structs? (constdecl? constdef +) |
|
1044 |
; |
|
1045 |
||
1046 |
structs: '(' 'structure' (vars + 'and') ')' |
|
1047 |
; |
|
1048 |
constdecl: ((name '::' type mixfix | name '::' type | name mixfix) 'where'?) | name 'where' |
|
1049 |
; |
|
1050 |
constdef: thmdecl? prop |
|
1051 |
; |
|
1052 |
\end{rail} |
|
1053 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1054 |
\begin{description} |
27040 | 1055 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1056 |
\item @{command "consts"}~@{text "c :: \<sigma>"} declares constant @{text |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1057 |
c} to have any instance of type scheme @{text \<sigma>}. The optional |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1058 |
mixfix annotations may attach concrete syntax to the constants |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1059 |
declared. |
27040 | 1060 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1061 |
\item @{command "defs"}~@{text "name: eqn"} introduces @{text eqn} |
27040 | 1062 |
as a definitional axiom for some existing constant. |
1063 |
||
1064 |
The @{text "(unchecked)"} option disables global dependency checks |
|
1065 |
for this definition, which is occasionally useful for exotic |
|
1066 |
overloading. It is at the discretion of the user to avoid malformed |
|
1067 |
theory specifications! |
|
1068 |
||
1069 |
The @{text "(overloaded)"} option declares definitions to be |
|
1070 |
potentially overloaded. Unless this option is given, a warning |
|
1071 |
message would be issued for any definitional equation with a more |
|
1072 |
special type than that of the corresponding constant declaration. |
|
1073 |
||
28767 | 1074 |
\item @{command "constdefs"} combines constant declarations and |
1075 |
definitions, with type-inference taking care of the most general |
|
1076 |
typing of the given specification (the optional type constraint may |
|
1077 |
refer to type-inference dummies ``@{text _}'' as usual). The |
|
1078 |
resulting type declaration needs to agree with that of the |
|
1079 |
specification; overloading is \emph{not} supported here! |
|
27040 | 1080 |
|
1081 |
The constant name may be omitted altogether, if neither type nor |
|
1082 |
syntax declarations are given. The canonical name of the |
|
1083 |
definitional axiom for constant @{text c} will be @{text c_def}, |
|
1084 |
unless specified otherwise. Also note that the given list of |
|
1085 |
specifications is processed in a strictly sequential manner, with |
|
1086 |
type-checking being performed independently. |
|
1087 |
||
1088 |
An optional initial context of @{text "(structure)"} declarations |
|
1089 |
admits use of indexed syntax, using the special symbol @{verbatim |
|
1090 |
"\<index>"} (printed as ``@{text "\<index>"}''). The latter concept is |
|
28767 | 1091 |
particularly useful with locales (see also \secref{sec:locale}). |
27040 | 1092 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1093 |
\end{description} |
27040 | 1094 |
*} |
1095 |
||
1096 |
||
1097 |
section {* Axioms and theorems \label{sec:axms-thms} *} |
|
1098 |
||
1099 |
text {* |
|
1100 |
\begin{matharray}{rcll} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
1101 |
@{command_def "axioms"} & : & @{text "theory \<rightarrow> theory"} & (axiomatic!) \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
1102 |
@{command_def "lemmas"} & : & @{text "local_theory \<rightarrow> local_theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
1103 |
@{command_def "theorems"} & : & @{text "local_theory \<rightarrow> local_theory"} \\ |
27040 | 1104 |
\end{matharray} |
1105 |
||
1106 |
\begin{rail} |
|
1107 |
'axioms' (axmdecl prop +) |
|
1108 |
; |
|
1109 |
('lemmas' | 'theorems') target? (thmdef? thmrefs + 'and') |
|
1110 |
; |
|
1111 |
\end{rail} |
|
1112 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1113 |
\begin{description} |
27040 | 1114 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1115 |
\item @{command "axioms"}~@{text "a: \<phi>"} introduces arbitrary |
27040 | 1116 |
statements as axioms of the meta-logic. In fact, axioms are |
1117 |
``axiomatic theorems'', and may be referred later just as any other |
|
1118 |
theorem. |
|
1119 |
||
1120 |
Axioms are usually only introduced when declaring new logical |
|
1121 |
systems. Everyday work is typically done the hard way, with proper |
|
1122 |
definitions and proven theorems. |
|
1123 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1124 |
\item @{command "lemmas"}~@{text "a = b\<^sub>1 \<dots> b\<^sub>n"} retrieves and stores |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1125 |
existing facts in the theory context, or the specified target |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1126 |
context (see also \secref{sec:target}). Typical applications would |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1127 |
also involve attributes, to declare Simplifier rules, for example. |
27040 | 1128 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1129 |
\item @{command "theorems"} is essentially the same as @{command |
27040 | 1130 |
"lemmas"}, but marks the result as a different kind of facts. |
1131 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1132 |
\end{description} |
27040 | 1133 |
*} |
1134 |
||
1135 |
||
1136 |
section {* Oracles *} |
|
1137 |
||
28756 | 1138 |
text {* Oracles allow Isabelle to take advantage of external reasoners |
1139 |
such as arithmetic decision procedures, model checkers, fast |
|
1140 |
tautology checkers or computer algebra systems. Invoked as an |
|
1141 |
oracle, an external reasoner can create arbitrary Isabelle theorems. |
|
1142 |
||
1143 |
It is the responsibility of the user to ensure that the external |
|
1144 |
reasoner is as trustworthy as the application requires. Another |
|
1145 |
typical source of errors is the linkup between Isabelle and the |
|
1146 |
external tool, not just its concrete implementation, but also the |
|
1147 |
required translation between two different logical environments. |
|
1148 |
||
1149 |
Isabelle merely guarantees well-formedness of the propositions being |
|
1150 |
asserted, and records within the internal derivation object how |
|
1151 |
presumed theorems depend on unproven suppositions. |
|
1152 |
||
27040 | 1153 |
\begin{matharray}{rcl} |
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
1154 |
@{command_def "oracle"} & : & @{text "theory \<rightarrow> theory"} \\ |
27040 | 1155 |
\end{matharray} |
1156 |
||
1157 |
\begin{rail} |
|
28290 | 1158 |
'oracle' name '=' text |
27040 | 1159 |
; |
1160 |
\end{rail} |
|
1161 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1162 |
\begin{description} |
27040 | 1163 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1164 |
\item @{command "oracle"}~@{text "name = text"} turns the given ML |
28290 | 1165 |
expression @{text "text"} of type @{ML_text "'a -> cterm"} into an |
1166 |
ML function of type @{ML_text "'a -> thm"}, which is bound to the |
|
28756 | 1167 |
global identifier @{ML_text name}. This acts like an infinitary |
1168 |
specification of axioms! Invoking the oracle only works within the |
|
1169 |
scope of the resulting theory. |
|
27040 | 1170 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1171 |
\end{description} |
28756 | 1172 |
|
1173 |
See @{"file" "~~/src/FOL/ex/IffOracle.thy"} for a worked example of |
|
1174 |
defining a new primitive rule as oracle, and turning it into a proof |
|
1175 |
method. |
|
27040 | 1176 |
*} |
1177 |
||
1178 |
||
1179 |
section {* Name spaces *} |
|
1180 |
||
1181 |
text {* |
|
1182 |
\begin{matharray}{rcl} |
|
28761
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
1183 |
@{command_def "global"} & : & @{text "theory \<rightarrow> theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
1184 |
@{command_def "local"} & : & @{text "theory \<rightarrow> theory"} \\ |
9ec4482c9201
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm
parents:
28760
diff
changeset
|
1185 |
@{command_def "hide"} & : & @{text "theory \<rightarrow> theory"} \\ |
27040 | 1186 |
\end{matharray} |
1187 |
||
1188 |
\begin{rail} |
|
1189 |
'hide' ('(open)')? name (nameref + ) |
|
1190 |
; |
|
1191 |
\end{rail} |
|
1192 |
||
1193 |
Isabelle organizes any kind of name declarations (of types, |
|
1194 |
constants, theorems etc.) by separate hierarchically structured name |
|
1195 |
spaces. Normally the user does not have to control the behavior of |
|
1196 |
name spaces by hand, yet the following commands provide some way to |
|
1197 |
do so. |
|
1198 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1199 |
\begin{description} |
27040 | 1200 |
|
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1201 |
\item @{command "global"} and @{command "local"} change the current |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1202 |
name declaration mode. Initially, theories start in @{command |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1203 |
"local"} mode, causing all names to be automatically qualified by |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1204 |
the theory name. Changing this to @{command "global"} causes all |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1205 |
names to be declared without the theory prefix, until @{command |
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1206 |
"local"} is declared again. |
27040 | 1207 |
|
1208 |
Note that global names are prone to get hidden accidently later, |
|
1209 |
when qualified names of the same base name are introduced. |
|
1210 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1211 |
\item @{command "hide"}~@{text "space names"} fully removes |
27040 | 1212 |
declarations from a given name space (which may be @{text "class"}, |
1213 |
@{text "type"}, @{text "const"}, or @{text "fact"}); with the @{text |
|
1214 |
"(open)"} option, only the base name is hidden. Global |
|
1215 |
(unqualified) names may never be hidden. |
|
1216 |
||
1217 |
Note that hiding name space accesses has no impact on logical |
|
28756 | 1218 |
declarations --- they remain valid internally. Entities that are no |
27040 | 1219 |
longer accessible to the user are printed with the special qualifier |
1220 |
``@{text "??"}'' prefixed to the full internal name. |
|
1221 |
||
28760
cbc435f7b16b
unified use of declaration environment with IsarImplementation;
wenzelm
parents:
28758
diff
changeset
|
1222 |
\end{description} |
27040 | 1223 |
*} |
1224 |
||
26869 | 1225 |
end |