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