author | wenzelm |
Sun, 08 Nov 2009 21:00:05 +0100 | |
changeset 33524 | a08e6c1cbc04 |
parent 33174 | 1f2051f41335 |
child 35001 | 31f8d9eaceff |
permissions | -rw-r--r-- |
30296 | 1 |
% |
2 |
\begin{isabellebody}% |
|
3 |
\def\isabellecontext{Prelim}% |
|
4 |
% |
|
5 |
\isadelimtheory |
|
6 |
% |
|
7 |
\endisadelimtheory |
|
8 |
% |
|
9 |
\isatagtheory |
|
10 |
\isacommand{theory}\isamarkupfalse% |
|
11 |
\ Prelim\isanewline |
|
12 |
\isakeyword{imports}\ Base\isanewline |
|
13 |
\isakeyword{begin}% |
|
14 |
\endisatagtheory |
|
15 |
{\isafoldtheory}% |
|
16 |
% |
|
17 |
\isadelimtheory |
|
18 |
% |
|
19 |
\endisadelimtheory |
|
20 |
% |
|
21 |
\isamarkupchapter{Preliminaries% |
|
22 |
} |
|
23 |
\isamarkuptrue% |
|
24 |
% |
|
25 |
\isamarkupsection{Contexts \label{sec:context}% |
|
26 |
} |
|
27 |
\isamarkuptrue% |
|
28 |
% |
|
29 |
\begin{isamarkuptext}% |
|
30 |
A logical context represents the background that is required for |
|
31 |
formulating statements and composing proofs. It acts as a medium to |
|
32 |
produce formal content, depending on earlier material (declarations, |
|
33 |
results etc.). |
|
34 |
||
35 |
For example, derivations within the Isabelle/Pure logic can be |
|
36 |
described as a judgment \isa{{\isasymGamma}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\ {\isasymphi}}, which means that a |
|
37 |
proposition \isa{{\isasymphi}} is derivable from hypotheses \isa{{\isasymGamma}} |
|
38 |
within the theory \isa{{\isasymTheta}}. There are logical reasons for |
|
39 |
keeping \isa{{\isasymTheta}} and \isa{{\isasymGamma}} separate: theories can be |
|
40 |
liberal about supporting type constructors and schematic |
|
41 |
polymorphism of constants and axioms, while the inner calculus of |
|
42 |
\isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymphi}} is strictly limited to Simple Type Theory (with |
|
43 |
fixed type variables in the assumptions). |
|
44 |
||
45 |
\medskip Contexts and derivations are linked by the following key |
|
46 |
principles: |
|
47 |
||
48 |
\begin{itemize} |
|
49 |
||
50 |
\item Transfer: monotonicity of derivations admits results to be |
|
51 |
transferred into a \emph{larger} context, i.e.\ \isa{{\isasymGamma}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\ {\isasymphi}} implies \isa{{\isasymGamma}{\isacharprime}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\isactrlsub {\isacharprime}\ {\isasymphi}} for contexts \isa{{\isasymTheta}{\isacharprime}\ {\isasymsupseteq}\ {\isasymTheta}} and \isa{{\isasymGamma}{\isacharprime}\ {\isasymsupseteq}\ {\isasymGamma}}. |
|
52 |
||
53 |
\item Export: discharge of hypotheses admits results to be exported |
|
54 |
into a \emph{smaller} context, i.e.\ \isa{{\isasymGamma}{\isacharprime}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\ {\isasymphi}} |
|
55 |
implies \isa{{\isasymGamma}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\ {\isasymDelta}\ {\isasymLongrightarrow}\ {\isasymphi}} where \isa{{\isasymGamma}{\isacharprime}\ {\isasymsupseteq}\ {\isasymGamma}} and |
|
56 |
\isa{{\isasymDelta}\ {\isacharequal}\ {\isasymGamma}{\isacharprime}\ {\isacharminus}\ {\isasymGamma}}. Note that \isa{{\isasymTheta}} remains unchanged here, |
|
57 |
only the \isa{{\isasymGamma}} part is affected. |
|
58 |
||
59 |
\end{itemize} |
|
60 |
||
61 |
\medskip By modeling the main characteristics of the primitive |
|
62 |
\isa{{\isasymTheta}} and \isa{{\isasymGamma}} above, and abstracting over any |
|
63 |
particular logical content, we arrive at the fundamental notions of |
|
64 |
\emph{theory context} and \emph{proof context} in Isabelle/Isar. |
|
65 |
These implement a certain policy to manage arbitrary \emph{context |
|
66 |
data}. There is a strongly-typed mechanism to declare new kinds of |
|
67 |
data at compile time. |
|
68 |
||
69 |
The internal bootstrap process of Isabelle/Pure eventually reaches a |
|
70 |
stage where certain data slots provide the logical content of \isa{{\isasymTheta}} and \isa{{\isasymGamma}} sketched above, but this does not stop there! |
|
71 |
Various additional data slots support all kinds of mechanisms that |
|
72 |
are not necessarily part of the core logic. |
|
73 |
||
74 |
For example, there would be data for canonical introduction and |
|
75 |
elimination rules for arbitrary operators (depending on the |
|
76 |
object-logic and application), which enables users to perform |
|
77 |
standard proof steps implicitly (cf.\ the \isa{rule} method |
|
78 |
\cite{isabelle-isar-ref}). |
|
79 |
||
80 |
\medskip Thus Isabelle/Isar is able to bring forth more and more |
|
81 |
concepts successively. In particular, an object-logic like |
|
82 |
Isabelle/HOL continues the Isabelle/Pure setup by adding specific |
|
83 |
components for automated reasoning (classical reasoner, tableau |
|
84 |
prover, structured induction etc.) and derived specification |
|
85 |
mechanisms (inductive predicates, recursive functions etc.). All of |
|
86 |
this is ultimately based on the generic data management by theory |
|
87 |
and proof contexts introduced here.% |
|
88 |
\end{isamarkuptext}% |
|
89 |
\isamarkuptrue% |
|
90 |
% |
|
91 |
\isamarkupsubsection{Theory context \label{sec:context-theory}% |
|
92 |
} |
|
93 |
\isamarkuptrue% |
|
94 |
% |
|
95 |
\begin{isamarkuptext}% |
|
96 |
A \emph{theory} is a data container with explicit name and unique |
|
97 |
identifier. Theories are related by a (nominal) sub-theory |
|
98 |
relation, which corresponds to the dependency graph of the original |
|
99 |
construction; each theory is derived from a certain sub-graph of |
|
100 |
ancestor theories. |
|
101 |
||
102 |
The \isa{merge} operation produces the least upper bound of two |
|
103 |
theories, which actually degenerates into absorption of one theory |
|
104 |
into the other (due to the nominal sub-theory relation). |
|
105 |
||
106 |
The \isa{begin} operation starts a new theory by importing |
|
107 |
several parent theories and entering a special \isa{draft} mode, |
|
108 |
which is sustained until the final \isa{end} operation. A draft |
|
109 |
theory acts like a linear type, where updates invalidate earlier |
|
110 |
versions. An invalidated draft is called ``stale''. |
|
111 |
||
112 |
The \isa{checkpoint} operation produces an intermediate stepping |
|
113 |
stone that will survive the next update: both the original and the |
|
114 |
changed theory remain valid and are related by the sub-theory |
|
115 |
relation. Checkpointing essentially recovers purely functional |
|
116 |
theory values, at the expense of some extra internal bookkeeping. |
|
117 |
||
118 |
The \isa{copy} operation produces an auxiliary version that has |
|
119 |
the same data content, but is unrelated to the original: updates of |
|
120 |
the copy do not affect the original, neither does the sub-theory |
|
121 |
relation hold. |
|
122 |
||
123 |
\medskip The example in \figref{fig:ex-theory} below shows a theory |
|
124 |
graph derived from \isa{Pure}, with theory \isa{Length} |
|
125 |
importing \isa{Nat} and \isa{List}. The body of \isa{Length} consists of a sequence of updates, working mostly on |
|
126 |
drafts. Intermediate checkpoints may occur as well, due to the |
|
127 |
history mechanism provided by the Isar top-level, cf.\ |
|
128 |
\secref{sec:isar-toplevel}. |
|
129 |
||
130 |
\begin{figure}[htb] |
|
131 |
\begin{center} |
|
132 |
\begin{tabular}{rcccl} |
|
133 |
& & \isa{Pure} \\ |
|
134 |
& & \isa{{\isasymdown}} \\ |
|
135 |
& & \isa{FOL} \\ |
|
136 |
& $\swarrow$ & & $\searrow$ & \\ |
|
137 |
\isa{Nat} & & & & \isa{List} \\ |
|
138 |
& $\searrow$ & & $\swarrow$ \\ |
|
139 |
& & \isa{Length} \\ |
|
140 |
& & \multicolumn{3}{l}{~~\hyperlink{keyword.imports}{\mbox{\isa{\isakeyword{imports}}}}} \\ |
|
141 |
& & \multicolumn{3}{l}{~~\hyperlink{keyword.begin}{\mbox{\isa{\isakeyword{begin}}}}} \\ |
|
142 |
& & $\vdots$~~ \\ |
|
143 |
& & \isa{{\isasymbullet}}~~ \\ |
|
144 |
& & $\vdots$~~ \\ |
|
145 |
& & \isa{{\isasymbullet}}~~ \\ |
|
146 |
& & $\vdots$~~ \\ |
|
147 |
& & \multicolumn{3}{l}{~~\hyperlink{command.end}{\mbox{\isa{\isacommand{end}}}}} \\ |
|
148 |
\end{tabular} |
|
149 |
\caption{A theory definition depending on ancestors}\label{fig:ex-theory} |
|
150 |
\end{center} |
|
151 |
\end{figure} |
|
152 |
||
153 |
\medskip There is a separate notion of \emph{theory reference} for |
|
154 |
maintaining a live link to an evolving theory context: updates on |
|
155 |
drafts are propagated automatically. Dynamic updating stops after |
|
156 |
an explicit \isa{end} only. |
|
157 |
||
158 |
Derived entities may store a theory reference in order to indicate |
|
159 |
the context they belong to. This implicitly assumes monotonic |
|
160 |
reasoning, because the referenced context may become larger without |
|
161 |
further notice.% |
|
162 |
\end{isamarkuptext}% |
|
163 |
\isamarkuptrue% |
|
164 |
% |
|
165 |
\isadelimmlref |
|
166 |
% |
|
167 |
\endisadelimmlref |
|
168 |
% |
|
169 |
\isatagmlref |
|
170 |
% |
|
171 |
\begin{isamarkuptext}% |
|
172 |
\begin{mldecls} |
|
173 |
\indexdef{}{ML type}{theory}\verb|type theory| \\ |
|
174 |
\indexdef{}{ML}{Theory.subthy}\verb|Theory.subthy: theory * theory -> bool| \\ |
|
175 |
\indexdef{}{ML}{Theory.merge}\verb|Theory.merge: theory * theory -> theory| \\ |
|
176 |
\indexdef{}{ML}{Theory.checkpoint}\verb|Theory.checkpoint: theory -> theory| \\ |
|
177 |
\indexdef{}{ML}{Theory.copy}\verb|Theory.copy: theory -> theory| \\ |
|
178 |
\end{mldecls} |
|
179 |
\begin{mldecls} |
|
180 |
\indexdef{}{ML type}{theory\_ref}\verb|type theory_ref| \\ |
|
181 |
\indexdef{}{ML}{Theory.deref}\verb|Theory.deref: theory_ref -> theory| \\ |
|
182 |
\indexdef{}{ML}{Theory.check\_thy}\verb|Theory.check_thy: theory -> theory_ref| \\ |
|
183 |
\end{mldecls} |
|
184 |
||
185 |
\begin{description} |
|
186 |
||
187 |
\item \verb|theory| represents theory contexts. This is |
|
188 |
essentially a linear type! Most operations destroy the original |
|
189 |
version, which then becomes ``stale''. |
|
190 |
||
191 |
\item \verb|Theory.subthy|~\isa{{\isacharparenleft}thy\isactrlsub {\isadigit{1}}{\isacharcomma}\ thy\isactrlsub {\isadigit{2}}{\isacharparenright}} |
|
192 |
compares theories according to the inherent graph structure of the |
|
193 |
construction. This sub-theory relation is a nominal approximation |
|
194 |
of inclusion (\isa{{\isasymsubseteq}}) of the corresponding content. |
|
195 |
||
196 |
\item \verb|Theory.merge|~\isa{{\isacharparenleft}thy\isactrlsub {\isadigit{1}}{\isacharcomma}\ thy\isactrlsub {\isadigit{2}}{\isacharparenright}} |
|
197 |
absorbs one theory into the other. This fails for unrelated |
|
198 |
theories! |
|
199 |
||
200 |
\item \verb|Theory.checkpoint|~\isa{thy} produces a safe |
|
201 |
stepping stone in the linear development of \isa{thy}. The next |
|
202 |
update will result in two related, valid theories. |
|
203 |
||
33524
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
204 |
\item \verb|Theory.copy|~\isa{thy} produces a variant of \isa{thy} with the same data. The result is not related to the |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
205 |
original; the original is unchanged. |
30296 | 206 |
|
207 |
\item \verb|theory_ref| represents a sliding reference to an |
|
208 |
always valid theory; updates on the original are propagated |
|
209 |
automatically. |
|
210 |
||
211 |
\item \verb|Theory.deref|~\isa{thy{\isacharunderscore}ref} turns a \verb|theory_ref| into an \verb|theory| value. As the referenced |
|
212 |
theory evolves monotonically over time, later invocations of \verb|Theory.deref| may refer to a larger context. |
|
213 |
||
214 |
\item \verb|Theory.check_thy|~\isa{thy} produces a \verb|theory_ref| from a valid \verb|theory| value. |
|
215 |
||
216 |
\end{description}% |
|
217 |
\end{isamarkuptext}% |
|
218 |
\isamarkuptrue% |
|
219 |
% |
|
220 |
\endisatagmlref |
|
221 |
{\isafoldmlref}% |
|
222 |
% |
|
223 |
\isadelimmlref |
|
224 |
% |
|
225 |
\endisadelimmlref |
|
226 |
% |
|
227 |
\isamarkupsubsection{Proof context \label{sec:context-proof}% |
|
228 |
} |
|
229 |
\isamarkuptrue% |
|
230 |
% |
|
231 |
\begin{isamarkuptext}% |
|
232 |
A proof context is a container for pure data with a back-reference |
|
233 |
to the theory it belongs to. The \isa{init} operation creates a |
|
234 |
proof context from a given theory. Modifications to draft theories |
|
235 |
are propagated to the proof context as usual, but there is also an |
|
236 |
explicit \isa{transfer} operation to force resynchronization |
|
237 |
with more substantial updates to the underlying theory. The actual |
|
238 |
context data does not require any special bookkeeping, thanks to the |
|
239 |
lack of destructive features. |
|
240 |
||
241 |
Entities derived in a proof context need to record inherent logical |
|
242 |
requirements explicitly, since there is no separate context |
|
243 |
identification as for theories. For example, hypotheses used in |
|
244 |
primitive derivations (cf.\ \secref{sec:thms}) are recorded |
|
245 |
separately within the sequent \isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymphi}}, just to make double |
|
246 |
sure. Results could still leak into an alien proof context due to |
|
247 |
programming errors, but Isabelle/Isar includes some extra validity |
|
248 |
checks in critical positions, notably at the end of a sub-proof. |
|
249 |
||
250 |
Proof contexts may be manipulated arbitrarily, although the common |
|
251 |
discipline is to follow block structure as a mental model: a given |
|
252 |
context is extended consecutively, and results are exported back |
|
253 |
into the original context. Note that the Isar proof states model |
|
254 |
block-structured reasoning explicitly, using a stack of proof |
|
255 |
contexts internally.% |
|
256 |
\end{isamarkuptext}% |
|
257 |
\isamarkuptrue% |
|
258 |
% |
|
259 |
\isadelimmlref |
|
260 |
% |
|
261 |
\endisadelimmlref |
|
262 |
% |
|
263 |
\isatagmlref |
|
264 |
% |
|
265 |
\begin{isamarkuptext}% |
|
266 |
\begin{mldecls} |
|
267 |
\indexdef{}{ML type}{Proof.context}\verb|type Proof.context| \\ |
|
268 |
\indexdef{}{ML}{ProofContext.init}\verb|ProofContext.init: theory -> Proof.context| \\ |
|
269 |
\indexdef{}{ML}{ProofContext.theory\_of}\verb|ProofContext.theory_of: Proof.context -> theory| \\ |
|
270 |
\indexdef{}{ML}{ProofContext.transfer}\verb|ProofContext.transfer: theory -> Proof.context -> Proof.context| \\ |
|
271 |
\end{mldecls} |
|
272 |
||
273 |
\begin{description} |
|
274 |
||
275 |
\item \verb|Proof.context| represents proof contexts. Elements |
|
276 |
of this type are essentially pure values, with a sliding reference |
|
277 |
to the background theory. |
|
278 |
||
279 |
\item \verb|ProofContext.init|~\isa{thy} produces a proof context |
|
280 |
derived from \isa{thy}, initializing all data. |
|
281 |
||
282 |
\item \verb|ProofContext.theory_of|~\isa{ctxt} selects the |
|
283 |
background theory from \isa{ctxt}, dereferencing its internal |
|
284 |
\verb|theory_ref|. |
|
285 |
||
286 |
\item \verb|ProofContext.transfer|~\isa{thy\ ctxt} promotes the |
|
287 |
background theory of \isa{ctxt} to the super theory \isa{thy}. |
|
288 |
||
289 |
\end{description}% |
|
290 |
\end{isamarkuptext}% |
|
291 |
\isamarkuptrue% |
|
292 |
% |
|
293 |
\endisatagmlref |
|
294 |
{\isafoldmlref}% |
|
295 |
% |
|
296 |
\isadelimmlref |
|
297 |
% |
|
298 |
\endisadelimmlref |
|
299 |
% |
|
300 |
\isamarkupsubsection{Generic contexts \label{sec:generic-context}% |
|
301 |
} |
|
302 |
\isamarkuptrue% |
|
303 |
% |
|
304 |
\begin{isamarkuptext}% |
|
305 |
A generic context is the disjoint sum of either a theory or proof |
|
306 |
context. Occasionally, this enables uniform treatment of generic |
|
307 |
context data, typically extra-logical information. Operations on |
|
308 |
generic contexts include the usual injections, partial selections, |
|
309 |
and combinators for lifting operations on either component of the |
|
310 |
disjoint sum. |
|
311 |
||
312 |
Moreover, there are total operations \isa{theory{\isacharunderscore}of} and \isa{proof{\isacharunderscore}of} to convert a generic context into either kind: a theory |
|
313 |
can always be selected from the sum, while a proof context might |
|
314 |
have to be constructed by an ad-hoc \isa{init} operation.% |
|
315 |
\end{isamarkuptext}% |
|
316 |
\isamarkuptrue% |
|
317 |
% |
|
318 |
\isadelimmlref |
|
319 |
% |
|
320 |
\endisadelimmlref |
|
321 |
% |
|
322 |
\isatagmlref |
|
323 |
% |
|
324 |
\begin{isamarkuptext}% |
|
325 |
\begin{mldecls} |
|
326 |
\indexdef{}{ML type}{Context.generic}\verb|type Context.generic| \\ |
|
327 |
\indexdef{}{ML}{Context.theory\_of}\verb|Context.theory_of: Context.generic -> theory| \\ |
|
328 |
\indexdef{}{ML}{Context.proof\_of}\verb|Context.proof_of: Context.generic -> Proof.context| \\ |
|
329 |
\end{mldecls} |
|
330 |
||
331 |
\begin{description} |
|
332 |
||
333 |
\item \verb|Context.generic| is the direct sum of \verb|theory| and \verb|Proof.context|, with the datatype |
|
334 |
constructors \verb|Context.Theory| and \verb|Context.Proof|. |
|
335 |
||
336 |
\item \verb|Context.theory_of|~\isa{context} always produces a |
|
337 |
theory from the generic \isa{context}, using \verb|ProofContext.theory_of| as required. |
|
338 |
||
339 |
\item \verb|Context.proof_of|~\isa{context} always produces a |
|
340 |
proof context from the generic \isa{context}, using \verb|ProofContext.init| as required (note that this re-initializes the |
|
341 |
context data with each invocation). |
|
342 |
||
343 |
\end{description}% |
|
344 |
\end{isamarkuptext}% |
|
345 |
\isamarkuptrue% |
|
346 |
% |
|
347 |
\endisatagmlref |
|
348 |
{\isafoldmlref}% |
|
349 |
% |
|
350 |
\isadelimmlref |
|
351 |
% |
|
352 |
\endisadelimmlref |
|
353 |
% |
|
354 |
\isamarkupsubsection{Context data \label{sec:context-data}% |
|
355 |
} |
|
356 |
\isamarkuptrue% |
|
357 |
% |
|
358 |
\begin{isamarkuptext}% |
|
33524
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
359 |
The main purpose of theory and proof contexts is to manage |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
360 |
arbitrary (pure) data. New data types can be declared incrementally |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
361 |
at compile time. There are separate declaration mechanisms for any |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
362 |
of the three kinds of contexts: theory, proof, generic. |
30296 | 363 |
|
33524
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
364 |
\paragraph{Theory data} declarations need to implement the following |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
365 |
SML signature: |
30296 | 366 |
|
367 |
\medskip |
|
368 |
\begin{tabular}{ll} |
|
369 |
\isa{{\isasymtype}\ T} & representing type \\ |
|
370 |
\isa{{\isasymval}\ empty{\isacharcolon}\ T} & empty default value \\ |
|
371 |
\isa{{\isasymval}\ extend{\isacharcolon}\ T\ {\isasymrightarrow}\ T} & re-initialize on import \\ |
|
372 |
\isa{{\isasymval}\ merge{\isacharcolon}\ T\ {\isasymtimes}\ T\ {\isasymrightarrow}\ T} & join on import \\ |
|
373 |
\end{tabular} |
|
374 |
\medskip |
|
375 |
||
376 |
\noindent The \isa{empty} value acts as initial default for |
|
33524
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
377 |
\emph{any} theory that does not declare actual data content; \isa{extend} is acts like a unitary version of \isa{merge}. |
30296 | 378 |
|
33524
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
379 |
\paragraph{Proof context data} declarations need to implement the |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
380 |
following SML signature: |
30296 | 381 |
|
382 |
\medskip |
|
383 |
\begin{tabular}{ll} |
|
384 |
\isa{{\isasymtype}\ T} & representing type \\ |
|
385 |
\isa{{\isasymval}\ init{\isacharcolon}\ theory\ {\isasymrightarrow}\ T} & produce initial value \\ |
|
386 |
\end{tabular} |
|
387 |
\medskip |
|
388 |
||
389 |
\noindent The \isa{init} operation is supposed to produce a pure |
|
390 |
value from the given background theory. |
|
391 |
||
392 |
\paragraph{Generic data} provides a hybrid interface for both theory |
|
33524
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
393 |
and proof data. The \isa{init} operation for proof contexts is |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
394 |
predefined to select the current data value from the background |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
395 |
theory. |
30296 | 396 |
|
397 |
\bigskip A data declaration of type \isa{T} results in the |
|
398 |
following interface: |
|
399 |
||
400 |
\medskip |
|
401 |
\begin{tabular}{ll} |
|
402 |
\isa{get{\isacharcolon}\ context\ {\isasymrightarrow}\ T} \\ |
|
403 |
\isa{put{\isacharcolon}\ T\ {\isasymrightarrow}\ context\ {\isasymrightarrow}\ context} \\ |
|
404 |
\isa{map{\isacharcolon}\ {\isacharparenleft}T\ {\isasymrightarrow}\ T{\isacharparenright}\ {\isasymrightarrow}\ context\ {\isasymrightarrow}\ context} \\ |
|
405 |
\end{tabular} |
|
406 |
\medskip |
|
407 |
||
33524
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
408 |
\noindent These other operations provide access for the particular |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
409 |
kind of context (theory, proof, or generic context). Note that this |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
410 |
is a safe interface: there is no other way to access the |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
411 |
corresponding data slot of a context. By keeping these operations |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
412 |
private, a component may maintain abstract values authentically, |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
413 |
without other components interfering.% |
30296 | 414 |
\end{isamarkuptext}% |
415 |
\isamarkuptrue% |
|
416 |
% |
|
417 |
\isadelimmlref |
|
418 |
% |
|
419 |
\endisadelimmlref |
|
420 |
% |
|
421 |
\isatagmlref |
|
422 |
% |
|
423 |
\begin{isamarkuptext}% |
|
424 |
\begin{mldecls} |
|
33524
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
425 |
\indexdef{}{ML functor}{Theory\_Data}\verb|functor Theory_Data| \\ |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
426 |
\indexdef{}{ML functor}{Proof\_Data}\verb|functor Proof_Data| \\ |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
427 |
\indexdef{}{ML functor}{Generic\_Data}\verb|functor Generic_Data| \\ |
30296 | 428 |
\end{mldecls} |
429 |
||
430 |
\begin{description} |
|
431 |
||
33524
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
432 |
\item \verb|Theory_Data|\isa{{\isacharparenleft}spec{\isacharparenright}} declares data for |
30296 | 433 |
type \verb|theory| according to the specification provided as |
434 |
argument structure. The resulting structure provides data init and |
|
435 |
access operations as described above. |
|
436 |
||
33524
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
437 |
\item \verb|Proof_Data|\isa{{\isacharparenleft}spec{\isacharparenright}} is analogous to |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
438 |
\verb|Theory_Data| for type \verb|Proof.context|. |
30296 | 439 |
|
33524
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
440 |
\item \verb|Generic_Data|\isa{{\isacharparenleft}spec{\isacharparenright}} is analogous to |
a08e6c1cbc04
updated functor Theory_Data, Proof_Data, Generic_Data;
wenzelm
parents:
33174
diff
changeset
|
441 |
\verb|Theory_Data| for type \verb|Context.generic|. |
30296 | 442 |
|
443 |
\end{description}% |
|
444 |
\end{isamarkuptext}% |
|
445 |
\isamarkuptrue% |
|
446 |
% |
|
447 |
\endisatagmlref |
|
448 |
{\isafoldmlref}% |
|
449 |
% |
|
450 |
\isadelimmlref |
|
451 |
% |
|
452 |
\endisadelimmlref |
|
453 |
% |
|
454 |
\isamarkupsection{Names \label{sec:names}% |
|
455 |
} |
|
456 |
\isamarkuptrue% |
|
457 |
% |
|
458 |
\begin{isamarkuptext}% |
|
459 |
In principle, a name is just a string, but there are various |
|
460 |
convention for encoding additional structure. For example, ``\isa{Foo{\isachardot}bar{\isachardot}baz}'' is considered as a qualified name consisting of |
|
461 |
three basic name components. The individual constituents of a name |
|
462 |
may have further substructure, e.g.\ the string |
|
463 |
``\verb,\,\verb,<alpha>,'' encodes as a single symbol.% |
|
464 |
\end{isamarkuptext}% |
|
465 |
\isamarkuptrue% |
|
466 |
% |
|
467 |
\isamarkupsubsection{Strings of symbols% |
|
468 |
} |
|
469 |
\isamarkuptrue% |
|
470 |
% |
|
471 |
\begin{isamarkuptext}% |
|
472 |
A \emph{symbol} constitutes the smallest textual unit in Isabelle |
|
473 |
--- raw characters are normally not encountered at all. Isabelle |
|
474 |
strings consist of a sequence of symbols, represented as a packed |
|
475 |
string or a list of strings. Each symbol is in itself a small |
|
476 |
string, which has either one of the following forms: |
|
477 |
||
478 |
\begin{enumerate} |
|
479 |
||
480 |
\item a single ASCII character ``\isa{c}'', for example |
|
481 |
``\verb,a,'', |
|
482 |
||
483 |
\item a regular symbol ``\verb,\,\verb,<,\isa{ident}\verb,>,'', |
|
484 |
for example ``\verb,\,\verb,<alpha>,'', |
|
485 |
||
486 |
\item a control symbol ``\verb,\,\verb,<^,\isa{ident}\verb,>,'', |
|
487 |
for example ``\verb,\,\verb,<^bold>,'', |
|
488 |
||
489 |
\item a raw symbol ``\verb,\,\verb,<^raw:,\isa{text}\verb,>,'' |
|
490 |
where \isa{text} constists of printable characters excluding |
|
491 |
``\verb,.,'' and ``\verb,>,'', for example |
|
492 |
``\verb,\,\verb,<^raw:$\sum_{i = 1}^n$>,'', |
|
493 |
||
494 |
\item a numbered raw control symbol ``\verb,\,\verb,<^raw,\isa{n}\verb,>, where \isa{n} consists of digits, for example |
|
495 |
``\verb,\,\verb,<^raw42>,''. |
|
496 |
||
497 |
\end{enumerate} |
|
498 |
||
499 |
\noindent The \isa{ident} syntax for symbol names is \isa{letter\ {\isacharparenleft}letter\ {\isacharbar}\ digit{\isacharparenright}\isactrlsup {\isacharasterisk}}, where \isa{letter\ {\isacharequal}\ A{\isachardot}{\isachardot}Za{\isachardot}{\isachardot}z} and \isa{digit\ {\isacharequal}\ {\isadigit{0}}{\isachardot}{\isachardot}{\isadigit{9}}}. There are infinitely many |
|
500 |
regular symbols and control symbols, but a fixed collection of |
|
501 |
standard symbols is treated specifically. For example, |
|
502 |
``\verb,\,\verb,<alpha>,'' is classified as a letter, which means it |
|
503 |
may occur within regular Isabelle identifiers. |
|
504 |
||
505 |
Since the character set underlying Isabelle symbols is 7-bit ASCII |
|
506 |
and 8-bit characters are passed through transparently, Isabelle may |
|
507 |
also process Unicode/UCS data in UTF-8 encoding. Unicode provides |
|
508 |
its own collection of mathematical symbols, but there is no built-in |
|
509 |
link to the standard collection of Isabelle. |
|
510 |
||
511 |
\medskip Output of Isabelle symbols depends on the print mode |
|
512 |
(\secref{print-mode}). For example, the standard {\LaTeX} setup of |
|
513 |
the Isabelle document preparation system would present |
|
514 |
``\verb,\,\verb,<alpha>,'' as \isa{{\isasymalpha}}, and |
|
515 |
``\verb,\,\verb,<^bold>,\verb,\,\verb,<alpha>,'' as \isa{\isactrlbold {\isasymalpha}}.% |
|
516 |
\end{isamarkuptext}% |
|
517 |
\isamarkuptrue% |
|
518 |
% |
|
519 |
\isadelimmlref |
|
520 |
% |
|
521 |
\endisadelimmlref |
|
522 |
% |
|
523 |
\isatagmlref |
|
524 |
% |
|
525 |
\begin{isamarkuptext}% |
|
526 |
\begin{mldecls} |
|
527 |
\indexdef{}{ML type}{Symbol.symbol}\verb|type Symbol.symbol| \\ |
|
528 |
\indexdef{}{ML}{Symbol.explode}\verb|Symbol.explode: string -> Symbol.symbol list| \\ |
|
529 |
\indexdef{}{ML}{Symbol.is\_letter}\verb|Symbol.is_letter: Symbol.symbol -> bool| \\ |
|
530 |
\indexdef{}{ML}{Symbol.is\_digit}\verb|Symbol.is_digit: Symbol.symbol -> bool| \\ |
|
531 |
\indexdef{}{ML}{Symbol.is\_quasi}\verb|Symbol.is_quasi: Symbol.symbol -> bool| \\ |
|
532 |
\indexdef{}{ML}{Symbol.is\_blank}\verb|Symbol.is_blank: Symbol.symbol -> bool| \\ |
|
533 |
\end{mldecls} |
|
534 |
\begin{mldecls} |
|
535 |
\indexdef{}{ML type}{Symbol.sym}\verb|type Symbol.sym| \\ |
|
536 |
\indexdef{}{ML}{Symbol.decode}\verb|Symbol.decode: Symbol.symbol -> Symbol.sym| \\ |
|
537 |
\end{mldecls} |
|
538 |
||
539 |
\begin{description} |
|
540 |
||
541 |
\item \verb|Symbol.symbol| represents individual Isabelle |
|
542 |
symbols; this is an alias for \verb|string|. |
|
543 |
||
544 |
\item \verb|Symbol.explode|~\isa{str} produces a symbol list |
|
545 |
from the packed form. This function supercedes \verb|String.explode| for virtually all purposes of manipulating text in |
|
546 |
Isabelle! |
|
547 |
||
548 |
\item \verb|Symbol.is_letter|, \verb|Symbol.is_digit|, \verb|Symbol.is_quasi|, \verb|Symbol.is_blank| classify standard |
|
549 |
symbols according to fixed syntactic conventions of Isabelle, cf.\ |
|
550 |
\cite{isabelle-isar-ref}. |
|
551 |
||
552 |
\item \verb|Symbol.sym| is a concrete datatype that represents |
|
553 |
the different kinds of symbols explicitly, with constructors \verb|Symbol.Char|, \verb|Symbol.Sym|, \verb|Symbol.Ctrl|, \verb|Symbol.Raw|. |
|
554 |
||
555 |
\item \verb|Symbol.decode| converts the string representation of a |
|
556 |
symbol into the datatype version. |
|
557 |
||
558 |
\end{description}% |
|
559 |
\end{isamarkuptext}% |
|
560 |
\isamarkuptrue% |
|
561 |
% |
|
562 |
\endisatagmlref |
|
563 |
{\isafoldmlref}% |
|
564 |
% |
|
565 |
\isadelimmlref |
|
566 |
% |
|
567 |
\endisadelimmlref |
|
568 |
% |
|
569 |
\isamarkupsubsection{Basic names \label{sec:basic-names}% |
|
570 |
} |
|
571 |
\isamarkuptrue% |
|
572 |
% |
|
573 |
\begin{isamarkuptext}% |
|
574 |
A \emph{basic name} essentially consists of a single Isabelle |
|
575 |
identifier. There are conventions to mark separate classes of basic |
|
576 |
names, by attaching a suffix of underscores: one underscore means |
|
577 |
\emph{internal name}, two underscores means \emph{Skolem name}, |
|
578 |
three underscores means \emph{internal Skolem name}. |
|
579 |
||
580 |
For example, the basic name \isa{foo} has the internal version |
|
581 |
\isa{foo{\isacharunderscore}}, with Skolem versions \isa{foo{\isacharunderscore}{\isacharunderscore}} and \isa{foo{\isacharunderscore}{\isacharunderscore}{\isacharunderscore}}, respectively. |
|
582 |
||
583 |
These special versions provide copies of the basic name space, apart |
|
584 |
from anything that normally appears in the user text. For example, |
|
585 |
system generated variables in Isar proof contexts are usually marked |
|
586 |
as internal, which prevents mysterious name references like \isa{xaa} to appear in the text. |
|
587 |
||
588 |
\medskip Manipulating binding scopes often requires on-the-fly |
|
589 |
renamings. A \emph{name context} contains a collection of already |
|
590 |
used names. The \isa{declare} operation adds names to the |
|
591 |
context. |
|
592 |
||
593 |
The \isa{invents} operation derives a number of fresh names from |
|
594 |
a given starting point. For example, the first three names derived |
|
595 |
from \isa{a} are \isa{a}, \isa{b}, \isa{c}. |
|
596 |
||
597 |
The \isa{variants} operation produces fresh names by |
|
598 |
incrementing tentative names as base-26 numbers (with digits \isa{a{\isachardot}{\isachardot}z}) until all clashes are resolved. For example, name \isa{foo} results in variants \isa{fooa}, \isa{foob}, \isa{fooc}, \dots, \isa{fooaa}, \isa{fooab} etc.; each renaming |
|
599 |
step picks the next unused variant from this sequence.% |
|
600 |
\end{isamarkuptext}% |
|
601 |
\isamarkuptrue% |
|
602 |
% |
|
603 |
\isadelimmlref |
|
604 |
% |
|
605 |
\endisadelimmlref |
|
606 |
% |
|
607 |
\isatagmlref |
|
608 |
% |
|
609 |
\begin{isamarkuptext}% |
|
610 |
\begin{mldecls} |
|
611 |
\indexdef{}{ML}{Name.internal}\verb|Name.internal: string -> string| \\ |
|
612 |
\indexdef{}{ML}{Name.skolem}\verb|Name.skolem: string -> string| \\ |
|
613 |
\end{mldecls} |
|
614 |
\begin{mldecls} |
|
615 |
\indexdef{}{ML type}{Name.context}\verb|type Name.context| \\ |
|
616 |
\indexdef{}{ML}{Name.context}\verb|Name.context: Name.context| \\ |
|
617 |
\indexdef{}{ML}{Name.declare}\verb|Name.declare: string -> Name.context -> Name.context| \\ |
|
618 |
\indexdef{}{ML}{Name.invents}\verb|Name.invents: Name.context -> string -> int -> string list| \\ |
|
619 |
\indexdef{}{ML}{Name.variants}\verb|Name.variants: string list -> Name.context -> string list * Name.context| \\ |
|
620 |
\end{mldecls} |
|
621 |
||
622 |
\begin{description} |
|
623 |
||
624 |
\item \verb|Name.internal|~\isa{name} produces an internal name |
|
625 |
by adding one underscore. |
|
626 |
||
627 |
\item \verb|Name.skolem|~\isa{name} produces a Skolem name by |
|
628 |
adding two underscores. |
|
629 |
||
630 |
\item \verb|Name.context| represents the context of already used |
|
631 |
names; the initial value is \verb|Name.context|. |
|
632 |
||
633 |
\item \verb|Name.declare|~\isa{name} enters a used name into the |
|
634 |
context. |
|
635 |
||
636 |
\item \verb|Name.invents|~\isa{context\ name\ n} produces \isa{n} fresh names derived from \isa{name}. |
|
637 |
||
638 |
\item \verb|Name.variants|~\isa{names\ context} produces fresh |
|
639 |
variants of \isa{names}; the result is entered into the context. |
|
640 |
||
641 |
\end{description}% |
|
642 |
\end{isamarkuptext}% |
|
643 |
\isamarkuptrue% |
|
644 |
% |
|
645 |
\endisatagmlref |
|
646 |
{\isafoldmlref}% |
|
647 |
% |
|
648 |
\isadelimmlref |
|
649 |
% |
|
650 |
\endisadelimmlref |
|
651 |
% |
|
652 |
\isamarkupsubsection{Indexed names% |
|
653 |
} |
|
654 |
\isamarkuptrue% |
|
655 |
% |
|
656 |
\begin{isamarkuptext}% |
|
657 |
An \emph{indexed name} (or \isa{indexname}) is a pair of a basic |
|
658 |
name and a natural number. This representation allows efficient |
|
659 |
renaming by incrementing the second component only. The canonical |
|
660 |
way to rename two collections of indexnames apart from each other is |
|
661 |
this: determine the maximum index \isa{maxidx} of the first |
|
662 |
collection, then increment all indexes of the second collection by |
|
663 |
\isa{maxidx\ {\isacharplus}\ {\isadigit{1}}}; the maximum index of an empty collection is |
|
664 |
\isa{{\isacharminus}{\isadigit{1}}}. |
|
665 |
||
666 |
Occasionally, basic names and indexed names are injected into the |
|
667 |
same pair type: the (improper) indexname \isa{{\isacharparenleft}x{\isacharcomma}\ {\isacharminus}{\isadigit{1}}{\isacharparenright}} is used |
|
668 |
to encode basic names. |
|
669 |
||
670 |
\medskip Isabelle syntax observes the following rules for |
|
671 |
representing an indexname \isa{{\isacharparenleft}x{\isacharcomma}\ i{\isacharparenright}} as a packed string: |
|
672 |
||
673 |
\begin{itemize} |
|
674 |
||
675 |
\item \isa{{\isacharquery}x} if \isa{x} does not end with a digit and \isa{i\ {\isacharequal}\ {\isadigit{0}}}, |
|
676 |
||
677 |
\item \isa{{\isacharquery}xi} if \isa{x} does not end with a digit, |
|
678 |
||
679 |
\item \isa{{\isacharquery}x{\isachardot}i} otherwise. |
|
680 |
||
681 |
\end{itemize} |
|
682 |
||
683 |
Indexnames may acquire large index numbers over time. Results are |
|
684 |
normalized towards \isa{{\isadigit{0}}} at certain checkpoints, notably at |
|
685 |
the end of a proof. This works by producing variants of the |
|
686 |
corresponding basic name components. For example, the collection |
|
687 |
\isa{{\isacharquery}x{\isadigit{1}}{\isacharcomma}\ {\isacharquery}x{\isadigit{7}}{\isacharcomma}\ {\isacharquery}x{\isadigit{4}}{\isadigit{2}}} becomes \isa{{\isacharquery}x{\isacharcomma}\ {\isacharquery}xa{\isacharcomma}\ {\isacharquery}xb}.% |
|
688 |
\end{isamarkuptext}% |
|
689 |
\isamarkuptrue% |
|
690 |
% |
|
691 |
\isadelimmlref |
|
692 |
% |
|
693 |
\endisadelimmlref |
|
694 |
% |
|
695 |
\isatagmlref |
|
696 |
% |
|
697 |
\begin{isamarkuptext}% |
|
698 |
\begin{mldecls} |
|
699 |
\indexdef{}{ML type}{indexname}\verb|type indexname| \\ |
|
700 |
\end{mldecls} |
|
701 |
||
702 |
\begin{description} |
|
703 |
||
704 |
\item \verb|indexname| represents indexed names. This is an |
|
705 |
abbreviation for \verb|string * int|. The second component is |
|
706 |
usually non-negative, except for situations where \isa{{\isacharparenleft}x{\isacharcomma}\ {\isacharminus}{\isadigit{1}}{\isacharparenright}} |
|
707 |
is used to embed basic names into this type. |
|
708 |
||
709 |
\end{description}% |
|
710 |
\end{isamarkuptext}% |
|
711 |
\isamarkuptrue% |
|
712 |
% |
|
713 |
\endisatagmlref |
|
714 |
{\isafoldmlref}% |
|
715 |
% |
|
716 |
\isadelimmlref |
|
717 |
% |
|
718 |
\endisadelimmlref |
|
719 |
% |
|
720 |
\isamarkupsubsection{Qualified names and name spaces% |
|
721 |
} |
|
722 |
\isamarkuptrue% |
|
723 |
% |
|
724 |
\begin{isamarkuptext}% |
|
725 |
A \emph{qualified name} consists of a non-empty sequence of basic |
|
726 |
name components. The packed representation uses a dot as separator, |
|
727 |
as in ``\isa{A{\isachardot}b{\isachardot}c}''. The last component is called \emph{base} |
|
728 |
name, the remaining prefix \emph{qualifier} (which may be empty). |
|
729 |
The idea of qualified names is to encode nested structures by |
|
730 |
recording the access paths as qualifiers. For example, an item |
|
731 |
named ``\isa{A{\isachardot}b{\isachardot}c}'' may be understood as a local entity \isa{c}, within a local structure \isa{b}, within a global |
|
732 |
structure \isa{A}. Typically, name space hierarchies consist of |
|
733 |
1--2 levels of qualification, but this need not be always so. |
|
734 |
||
735 |
The empty name is commonly used as an indication of unnamed |
|
736 |
entities, whenever this makes any sense. The basic operations on |
|
737 |
qualified names are smart enough to pass through such improper names |
|
738 |
unchanged. |
|
739 |
||
740 |
\medskip A \isa{naming} policy tells how to turn a name |
|
741 |
specification into a fully qualified internal name (by the \isa{full} operation), and how fully qualified names may be accessed |
|
742 |
externally. For example, the default naming policy is to prefix an |
|
743 |
implicit path: \isa{full\ x} produces \isa{path{\isachardot}x}, and the |
|
744 |
standard accesses for \isa{path{\isachardot}x} include both \isa{x} and |
|
745 |
\isa{path{\isachardot}x}. Normally, the naming is implicit in the theory or |
|
746 |
proof context; there are separate versions of the corresponding. |
|
747 |
||
748 |
\medskip A \isa{name\ space} manages a collection of fully |
|
749 |
internalized names, together with a mapping between external names |
|
750 |
and internal names (in both directions). The corresponding \isa{intern} and \isa{extern} operations are mostly used for |
|
751 |
parsing and printing only! The \isa{declare} operation augments |
|
752 |
a name space according to the accesses determined by the naming |
|
753 |
policy. |
|
754 |
||
755 |
\medskip As a general principle, there is a separate name space for |
|
756 |
each kind of formal entity, e.g.\ logical constant, type |
|
757 |
constructor, type class, theorem. It is usually clear from the |
|
758 |
occurrence in concrete syntax (or from the scope) which kind of |
|
759 |
entity a name refers to. For example, the very same name \isa{c} may be used uniformly for a constant, type constructor, and |
|
760 |
type class. |
|
761 |
||
762 |
There are common schemes to name theorems systematically, according |
|
763 |
to the name of the main logical entity involved, e.g.\ \isa{c{\isachardot}intro} for a canonical theorem related to constant \isa{c}. |
|
764 |
This technique of mapping names from one space into another requires |
|
765 |
some care in order to avoid conflicts. In particular, theorem names |
|
766 |
derived from a type constructor or type class are better suffixed in |
|
767 |
addition to the usual qualification, e.g.\ \isa{c{\isacharunderscore}type{\isachardot}intro} |
|
768 |
and \isa{c{\isacharunderscore}class{\isachardot}intro} for theorems related to type \isa{c} |
|
769 |
and class \isa{c}, respectively.% |
|
770 |
\end{isamarkuptext}% |
|
771 |
\isamarkuptrue% |
|
772 |
% |
|
773 |
\isadelimmlref |
|
774 |
% |
|
775 |
\endisadelimmlref |
|
776 |
% |
|
777 |
\isatagmlref |
|
778 |
% |
|
779 |
\begin{isamarkuptext}% |
|
780 |
\begin{mldecls} |
|
30365 | 781 |
\indexdef{}{ML}{Long\_Name.base\_name}\verb|Long_Name.base_name: string -> string| \\ |
782 |
\indexdef{}{ML}{Long\_Name.qualifier}\verb|Long_Name.qualifier: string -> string| \\ |
|
783 |
\indexdef{}{ML}{Long\_Name.append}\verb|Long_Name.append: string -> string -> string| \\ |
|
784 |
\indexdef{}{ML}{Long\_Name.implode}\verb|Long_Name.implode: string list -> string| \\ |
|
785 |
\indexdef{}{ML}{Long\_Name.explode}\verb|Long_Name.explode: string -> string list| \\ |
|
30296 | 786 |
\end{mldecls} |
787 |
\begin{mldecls} |
|
33174 | 788 |
\indexdef{}{ML type}{Name\_Space.naming}\verb|type Name_Space.naming| \\ |
789 |
\indexdef{}{ML}{Name\_Space.default\_naming}\verb|Name_Space.default_naming: Name_Space.naming| \\ |
|
790 |
\indexdef{}{ML}{Name\_Space.add\_path}\verb|Name_Space.add_path: string -> Name_Space.naming -> Name_Space.naming| \\ |
|
791 |
\indexdef{}{ML}{Name\_Space.full\_name}\verb|Name_Space.full_name: Name_Space.naming -> binding -> string| \\ |
|
30296 | 792 |
\end{mldecls} |
793 |
\begin{mldecls} |
|
33174 | 794 |
\indexdef{}{ML type}{Name\_Space.T}\verb|type Name_Space.T| \\ |
795 |
\indexdef{}{ML}{Name\_Space.empty}\verb|Name_Space.empty: string -> Name_Space.T| \\ |
|
796 |
\indexdef{}{ML}{Name\_Space.merge}\verb|Name_Space.merge: Name_Space.T * Name_Space.T -> Name_Space.T| \\ |
|
797 |
\indexdef{}{ML}{Name\_Space.declare}\verb|Name_Space.declare: bool -> Name_Space.naming -> binding -> Name_Space.T ->|\isasep\isanewline% |
|
798 |
\verb| string * Name_Space.T| \\ |
|
799 |
\indexdef{}{ML}{Name\_Space.intern}\verb|Name_Space.intern: Name_Space.T -> string -> string| \\ |
|
800 |
\indexdef{}{ML}{Name\_Space.extern}\verb|Name_Space.extern: Name_Space.T -> string -> string| \\ |
|
30296 | 801 |
\end{mldecls} |
802 |
||
803 |
\begin{description} |
|
804 |
||
30365 | 805 |
\item \verb|Long_Name.base_name|~\isa{name} returns the base name of a |
30296 | 806 |
qualified name. |
807 |
||
30365 | 808 |
\item \verb|Long_Name.qualifier|~\isa{name} returns the qualifier |
30296 | 809 |
of a qualified name. |
810 |
||
30365 | 811 |
\item \verb|Long_Name.append|~\isa{name\isactrlisub {\isadigit{1}}\ name\isactrlisub {\isadigit{2}}} |
30296 | 812 |
appends two qualified names. |
813 |
||
30365 | 814 |
\item \verb|Long_Name.implode|~\isa{names} and \verb|Long_Name.explode|~\isa{name} convert between the packed string |
30296 | 815 |
representation and the explicit list form of qualified names. |
816 |
||
33174 | 817 |
\item \verb|Name_Space.naming| represents the abstract concept of |
30296 | 818 |
a naming policy. |
819 |
||
33174 | 820 |
\item \verb|Name_Space.default_naming| is the default naming policy. |
30296 | 821 |
In a theory context, this is usually augmented by a path prefix |
822 |
consisting of the theory name. |
|
823 |
||
33174 | 824 |
\item \verb|Name_Space.add_path|~\isa{path\ naming} augments the |
30296 | 825 |
naming policy by extending its path component. |
826 |
||
33174 | 827 |
\item \verb|Name_Space.full_name|~\isa{naming\ binding} turns a |
30296 | 828 |
name binding (usually a basic name) into the fully qualified |
829 |
internal name, according to the given naming policy. |
|
830 |
||
33174 | 831 |
\item \verb|Name_Space.T| represents name spaces. |
30296 | 832 |
|
33174 | 833 |
\item \verb|Name_Space.empty|~\isa{kind} and \verb|Name_Space.merge|~\isa{{\isacharparenleft}space\isactrlisub {\isadigit{1}}{\isacharcomma}\ space\isactrlisub {\isadigit{2}}{\isacharparenright}} are the canonical operations for |
834 |
maintaining name spaces according to theory data management |
|
835 |
(\secref{sec:context-data}); \isa{kind} is a formal comment |
|
836 |
to characterize the purpose of a name space. |
|
30296 | 837 |
|
33174 | 838 |
\item \verb|Name_Space.declare|~\isa{strict\ naming\ bindings\ space} enters a name binding as fully qualified internal name into |
839 |
the name space, with external accesses determined by the naming |
|
840 |
policy. |
|
841 |
||
842 |
\item \verb|Name_Space.intern|~\isa{space\ name} internalizes a |
|
30296 | 843 |
(partially qualified) external name. |
844 |
||
845 |
This operation is mostly for parsing! Note that fully qualified |
|
33174 | 846 |
names stemming from declarations are produced via \verb|Name_Space.full_name| and \verb|Name_Space.declare| |
30296 | 847 |
(or their derivatives for \verb|theory| and |
848 |
\verb|Proof.context|). |
|
849 |
||
33174 | 850 |
\item \verb|Name_Space.extern|~\isa{space\ name} externalizes a |
30296 | 851 |
(fully qualified) internal name. |
852 |
||
853 |
This operation is mostly for printing! User code should not rely on |
|
854 |
the precise result too much. |
|
855 |
||
856 |
\end{description}% |
|
857 |
\end{isamarkuptext}% |
|
858 |
\isamarkuptrue% |
|
859 |
% |
|
860 |
\endisatagmlref |
|
861 |
{\isafoldmlref}% |
|
862 |
% |
|
863 |
\isadelimmlref |
|
864 |
% |
|
865 |
\endisadelimmlref |
|
866 |
% |
|
867 |
\isadelimtheory |
|
868 |
% |
|
869 |
\endisadelimtheory |
|
870 |
% |
|
871 |
\isatagtheory |
|
872 |
\isacommand{end}\isamarkupfalse% |
|
873 |
% |
|
874 |
\endisatagtheory |
|
875 |
{\isafoldtheory}% |
|
876 |
% |
|
877 |
\isadelimtheory |
|
878 |
% |
|
879 |
\endisadelimtheory |
|
880 |
\isanewline |
|
881 |
\end{isabellebody}% |
|
882 |
%%% Local Variables: |
|
883 |
%%% mode: latex |
|
884 |
%%% TeX-master: "root" |
|
885 |
%%% End: |