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