wenzelm@18537
|
1 |
%
|
wenzelm@18537
|
2 |
\begin{isabellebody}%
|
wenzelm@18537
|
3 |
\def\isabellecontext{prelim}%
|
wenzelm@18537
|
4 |
%
|
wenzelm@18537
|
5 |
\isadelimtheory
|
wenzelm@18537
|
6 |
\isanewline
|
wenzelm@18537
|
7 |
\isanewline
|
wenzelm@18537
|
8 |
\isanewline
|
wenzelm@18537
|
9 |
%
|
wenzelm@18537
|
10 |
\endisadelimtheory
|
wenzelm@18537
|
11 |
%
|
wenzelm@18537
|
12 |
\isatagtheory
|
wenzelm@18537
|
13 |
\isacommand{theory}\isamarkupfalse%
|
wenzelm@18537
|
14 |
\ prelim\ \isakeyword{imports}\ base\ \isakeyword{begin}%
|
wenzelm@18537
|
15 |
\endisatagtheory
|
wenzelm@18537
|
16 |
{\isafoldtheory}%
|
wenzelm@18537
|
17 |
%
|
wenzelm@18537
|
18 |
\isadelimtheory
|
wenzelm@18537
|
19 |
%
|
wenzelm@18537
|
20 |
\endisadelimtheory
|
wenzelm@18537
|
21 |
%
|
wenzelm@18537
|
22 |
\isamarkupchapter{Preliminaries%
|
wenzelm@18537
|
23 |
}
|
wenzelm@18537
|
24 |
\isamarkuptrue%
|
wenzelm@18537
|
25 |
%
|
wenzelm@20429
|
26 |
\isamarkupsection{Contexts \label{sec:context}%
|
wenzelm@18537
|
27 |
}
|
wenzelm@18537
|
28 |
\isamarkuptrue%
|
wenzelm@18537
|
29 |
%
|
wenzelm@18537
|
30 |
\begin{isamarkuptext}%
|
wenzelm@20451
|
31 |
A logical context represents the background that is required for
|
wenzelm@20451
|
32 |
formulating statements and composing proofs. It acts as a medium to
|
wenzelm@20451
|
33 |
produce formal content, depending on earlier material (declarations,
|
wenzelm@20451
|
34 |
results etc.).
|
wenzelm@18537
|
35 |
|
wenzelm@20451
|
36 |
For example, derivations within the Isabelle/Pure logic can be
|
wenzelm@20451
|
37 |
described as a judgment \isa{{\isasymGamma}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\ {\isasymphi}}, which means that a
|
wenzelm@20429
|
38 |
proposition \isa{{\isasymphi}} is derivable from hypotheses \isa{{\isasymGamma}}
|
wenzelm@20429
|
39 |
within the theory \isa{{\isasymTheta}}. There are logical reasons for
|
wenzelm@20451
|
40 |
keeping \isa{{\isasymTheta}} and \isa{{\isasymGamma}} separate: theories can be
|
wenzelm@20451
|
41 |
liberal about supporting type constructors and schematic
|
wenzelm@20451
|
42 |
polymorphism of constants and axioms, while the inner calculus of
|
wenzelm@20451
|
43 |
\isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymphi}} is strictly limited to Simple Type Theory (with
|
wenzelm@20451
|
44 |
fixed type variables in the assumptions).
|
wenzelm@18537
|
45 |
|
wenzelm@20429
|
46 |
\medskip Contexts and derivations are linked by the following key
|
wenzelm@20429
|
47 |
principles:
|
wenzelm@18537
|
48 |
|
wenzelm@20429
|
49 |
\begin{itemize}
|
wenzelm@18537
|
50 |
|
wenzelm@20429
|
51 |
\item Transfer: monotonicity of derivations admits results to be
|
wenzelm@20451
|
52 |
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}}.
|
wenzelm@18537
|
53 |
|
wenzelm@20429
|
54 |
\item Export: discharge of hypotheses admits results to be exported
|
wenzelm@20451
|
55 |
into a \emph{smaller} context, i.e.\ \isa{{\isasymGamma}{\isacharprime}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\ {\isasymphi}}
|
wenzelm@20451
|
56 |
implies \isa{{\isasymGamma}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\ {\isasymDelta}\ {\isasymLongrightarrow}\ {\isasymphi}} where \isa{{\isasymGamma}{\isacharprime}\ {\isasymsupseteq}\ {\isasymGamma}} and
|
wenzelm@20451
|
57 |
\isa{{\isasymDelta}\ {\isacharequal}\ {\isasymGamma}{\isacharprime}\ {\isacharminus}\ {\isasymGamma}}. Note that \isa{{\isasymTheta}} remains unchanged here,
|
wenzelm@20451
|
58 |
only the \isa{{\isasymGamma}} part is affected.
|
wenzelm@18537
|
59 |
|
wenzelm@20429
|
60 |
\end{itemize}
|
wenzelm@18537
|
61 |
|
wenzelm@20451
|
62 |
\medskip By modeling the main characteristics of the primitive
|
wenzelm@20451
|
63 |
\isa{{\isasymTheta}} and \isa{{\isasymGamma}} above, and abstracting over any
|
wenzelm@20451
|
64 |
particular logical content, we arrive at the fundamental notions of
|
wenzelm@20451
|
65 |
\emph{theory context} and \emph{proof context} in Isabelle/Isar.
|
wenzelm@20451
|
66 |
These implement a certain policy to manage arbitrary \emph{context
|
wenzelm@20451
|
67 |
data}. There is a strongly-typed mechanism to declare new kinds of
|
wenzelm@20429
|
68 |
data at compile time.
|
wenzelm@18537
|
69 |
|
wenzelm@20451
|
70 |
The internal bootstrap process of Isabelle/Pure eventually reaches a
|
wenzelm@20451
|
71 |
stage where certain data slots provide the logical content of \isa{{\isasymTheta}} and \isa{{\isasymGamma}} sketched above, but this does not stop there!
|
wenzelm@20451
|
72 |
Various additional data slots support all kinds of mechanisms that
|
wenzelm@20451
|
73 |
are not necessarily part of the core logic.
|
wenzelm@18537
|
74 |
|
wenzelm@20429
|
75 |
For example, there would be data for canonical introduction and
|
wenzelm@20429
|
76 |
elimination rules for arbitrary operators (depending on the
|
wenzelm@20429
|
77 |
object-logic and application), which enables users to perform
|
wenzelm@20451
|
78 |
standard proof steps implicitly (cf.\ the \isa{rule} method
|
wenzelm@20451
|
79 |
\cite{isabelle-isar-ref}).
|
wenzelm@20429
|
80 |
|
wenzelm@20451
|
81 |
\medskip Thus Isabelle/Isar is able to bring forth more and more
|
wenzelm@20451
|
82 |
concepts successively. In particular, an object-logic like
|
wenzelm@20451
|
83 |
Isabelle/HOL continues the Isabelle/Pure setup by adding specific
|
wenzelm@20451
|
84 |
components for automated reasoning (classical reasoner, tableau
|
wenzelm@20451
|
85 |
prover, structured induction etc.) and derived specification
|
wenzelm@20451
|
86 |
mechanisms (inductive predicates, recursive functions etc.). All of
|
wenzelm@20451
|
87 |
this is ultimately based on the generic data management by theory
|
wenzelm@20451
|
88 |
and proof contexts introduced here.%
|
wenzelm@18537
|
89 |
\end{isamarkuptext}%
|
wenzelm@18537
|
90 |
\isamarkuptrue%
|
wenzelm@18537
|
91 |
%
|
wenzelm@18537
|
92 |
\isamarkupsubsection{Theory context \label{sec:context-theory}%
|
wenzelm@18537
|
93 |
}
|
wenzelm@18537
|
94 |
\isamarkuptrue%
|
wenzelm@18537
|
95 |
%
|
wenzelm@18537
|
96 |
\begin{isamarkuptext}%
|
wenzelm@20447
|
97 |
\glossary{Theory}{FIXME}
|
wenzelm@20447
|
98 |
|
wenzelm@20451
|
99 |
A \emph{theory} is a data container with explicit named and unique
|
wenzelm@20451
|
100 |
identifier. Theories are related by a (nominal) sub-theory
|
wenzelm@20451
|
101 |
relation, which corresponds to the dependency graph of the original
|
wenzelm@20451
|
102 |
construction; each theory is derived from a certain sub-graph of
|
wenzelm@20451
|
103 |
ancestor theories.
|
wenzelm@20451
|
104 |
|
wenzelm@20451
|
105 |
The \isa{merge} operation produces the least upper bound of two
|
wenzelm@20451
|
106 |
theories, which actually degenerates into absorption of one theory
|
wenzelm@20451
|
107 |
into the other (due to the nominal sub-theory relation).
|
wenzelm@18537
|
108 |
|
wenzelm@20429
|
109 |
The \isa{begin} operation starts a new theory by importing
|
wenzelm@20429
|
110 |
several parent theories and entering a special \isa{draft} mode,
|
wenzelm@20429
|
111 |
which is sustained until the final \isa{end} operation. A draft
|
wenzelm@20451
|
112 |
theory acts like a linear type, where updates invalidate earlier
|
wenzelm@20451
|
113 |
versions. An invalidated draft is called ``stale''.
|
wenzelm@20429
|
114 |
|
wenzelm@20447
|
115 |
The \isa{checkpoint} operation produces an intermediate stepping
|
wenzelm@20451
|
116 |
stone that will survive the next update: both the original and the
|
wenzelm@20451
|
117 |
changed theory remain valid and are related by the sub-theory
|
wenzelm@20451
|
118 |
relation. Checkpointing essentially recovers purely functional
|
wenzelm@20451
|
119 |
theory values, at the expense of some extra internal bookkeeping.
|
wenzelm@20429
|
120 |
|
wenzelm@20447
|
121 |
The \isa{copy} operation produces an auxiliary version that has
|
wenzelm@20447
|
122 |
the same data content, but is unrelated to the original: updates of
|
wenzelm@20447
|
123 |
the copy do not affect the original, neither does the sub-theory
|
wenzelm@20447
|
124 |
relation hold.
|
wenzelm@20447
|
125 |
|
wenzelm@20447
|
126 |
\medskip The example in \figref{fig:ex-theory} below shows a theory
|
wenzelm@20451
|
127 |
graph derived from \isa{Pure}, with theory \isa{Length}
|
wenzelm@20451
|
128 |
importing \isa{Nat} and \isa{List}. The body of \isa{Length} consists of a sequence of updates, working mostly on
|
wenzelm@20451
|
129 |
drafts. Intermediate checkpoints may occur as well, due to the
|
wenzelm@20451
|
130 |
history mechanism provided by the Isar top-level, cf.\
|
wenzelm@20451
|
131 |
\secref{sec:isar-toplevel}.
|
wenzelm@20447
|
132 |
|
wenzelm@20447
|
133 |
\begin{figure}[htb]
|
wenzelm@20447
|
134 |
\begin{center}
|
wenzelm@20429
|
135 |
\begin{tabular}{rcccl}
|
wenzelm@20447
|
136 |
& & \isa{Pure} \\
|
wenzelm@20447
|
137 |
& & \isa{{\isasymdown}} \\
|
wenzelm@20447
|
138 |
& & \isa{FOL} \\
|
wenzelm@18537
|
139 |
& $\swarrow$ & & $\searrow$ & \\
|
wenzelm@20447
|
140 |
$Nat$ & & & & \isa{List} \\
|
wenzelm@18537
|
141 |
& $\searrow$ & & $\swarrow$ \\
|
wenzelm@20447
|
142 |
& & \isa{Length} \\
|
wenzelm@18537
|
143 |
& & \multicolumn{3}{l}{~~$\isarkeyword{imports}$} \\
|
wenzelm@18537
|
144 |
& & \multicolumn{3}{l}{~~$\isarkeyword{begin}$} \\
|
wenzelm@18537
|
145 |
& & $\vdots$~~ \\
|
wenzelm@20447
|
146 |
& & \isa{{\isasymbullet}}~~ \\
|
wenzelm@20447
|
147 |
& & $\vdots$~~ \\
|
wenzelm@20447
|
148 |
& & \isa{{\isasymbullet}}~~ \\
|
wenzelm@20447
|
149 |
& & $\vdots$~~ \\
|
wenzelm@18537
|
150 |
& & \multicolumn{3}{l}{~~$\isarkeyword{end}$} \\
|
wenzelm@20429
|
151 |
\end{tabular}
|
wenzelm@20451
|
152 |
\caption{A theory definition depending on ancestors}\label{fig:ex-theory}
|
wenzelm@20447
|
153 |
\end{center}
|
wenzelm@20451
|
154 |
\end{figure}
|
wenzelm@20451
|
155 |
|
wenzelm@20451
|
156 |
\medskip There is a separate notion of \emph{theory reference} for
|
wenzelm@20451
|
157 |
maintaining a live link to an evolving theory context: updates on
|
wenzelm@20451
|
158 |
drafts are propagated automatically. The dynamic stops after an
|
wenzelm@20451
|
159 |
explicit \isa{end} only.
|
wenzelm@20451
|
160 |
|
wenzelm@20451
|
161 |
Derived entities may store a theory reference in order to indicate
|
wenzelm@20451
|
162 |
the context they belong to. This implicitly assumes monotonic
|
wenzelm@20451
|
163 |
reasoning, because the referenced context may become larger without
|
wenzelm@20451
|
164 |
further notice.%
|
wenzelm@18537
|
165 |
\end{isamarkuptext}%
|
wenzelm@18537
|
166 |
\isamarkuptrue%
|
wenzelm@18537
|
167 |
%
|
wenzelm@20430
|
168 |
\isadelimmlref
|
wenzelm@20430
|
169 |
%
|
wenzelm@20430
|
170 |
\endisadelimmlref
|
wenzelm@20430
|
171 |
%
|
wenzelm@20430
|
172 |
\isatagmlref
|
wenzelm@20430
|
173 |
%
|
wenzelm@20430
|
174 |
\begin{isamarkuptext}%
|
wenzelm@20447
|
175 |
\begin{mldecls}
|
wenzelm@20447
|
176 |
\indexmltype{theory}\verb|type theory| \\
|
wenzelm@20447
|
177 |
\indexml{Theory.subthy}\verb|Theory.subthy: theory * theory -> bool| \\
|
wenzelm@20447
|
178 |
\indexml{Theory.merge}\verb|Theory.merge: theory * theory -> theory| \\
|
wenzelm@20447
|
179 |
\indexml{Theory.checkpoint}\verb|Theory.checkpoint: theory -> theory| \\
|
wenzelm@20447
|
180 |
\indexml{Theory.copy}\verb|Theory.copy: theory -> theory| \\[1ex]
|
wenzelm@20447
|
181 |
\indexmltype{theory-ref}\verb|type theory_ref| \\
|
wenzelm@20447
|
182 |
\indexml{Theory.self-ref}\verb|Theory.self_ref: theory -> theory_ref| \\
|
wenzelm@20447
|
183 |
\indexml{Theory.deref}\verb|Theory.deref: theory_ref -> theory| \\
|
wenzelm@20447
|
184 |
\end{mldecls}
|
wenzelm@20447
|
185 |
|
wenzelm@20447
|
186 |
\begin{description}
|
wenzelm@20447
|
187 |
|
wenzelm@20451
|
188 |
\item \verb|theory| represents theory contexts. This is
|
wenzelm@20451
|
189 |
essentially a linear type! Most operations destroy the original
|
wenzelm@20451
|
190 |
version, which then becomes ``stale''.
|
wenzelm@20447
|
191 |
|
wenzelm@20447
|
192 |
\item \verb|Theory.subthy|~\isa{{\isacharparenleft}thy\isactrlsub {\isadigit{1}}{\isacharcomma}\ thy\isactrlsub {\isadigit{2}}{\isacharparenright}}
|
wenzelm@20447
|
193 |
compares theories according to the inherent graph structure of the
|
wenzelm@20447
|
194 |
construction. This sub-theory relation is a nominal approximation
|
wenzelm@20447
|
195 |
of inclusion (\isa{{\isasymsubseteq}}) of the corresponding content.
|
wenzelm@20447
|
196 |
|
wenzelm@20447
|
197 |
\item \verb|Theory.merge|~\isa{{\isacharparenleft}thy\isactrlsub {\isadigit{1}}{\isacharcomma}\ thy\isactrlsub {\isadigit{2}}{\isacharparenright}}
|
wenzelm@20447
|
198 |
absorbs one theory into the other. This fails for unrelated
|
wenzelm@20447
|
199 |
theories!
|
wenzelm@20447
|
200 |
|
wenzelm@20447
|
201 |
\item \verb|Theory.checkpoint|~\isa{thy} produces a safe
|
wenzelm@20447
|
202 |
stepping stone in the linear development of \isa{thy}. The next
|
wenzelm@20447
|
203 |
update will result in two related, valid theories.
|
wenzelm@20447
|
204 |
|
wenzelm@20451
|
205 |
\item \verb|Theory.copy|~\isa{thy} produces a variant of \isa{thy} that holds a copy of the same data. The result is not
|
wenzelm@20451
|
206 |
related to the original; the original is unchanched.
|
wenzelm@20447
|
207 |
|
wenzelm@20451
|
208 |
\item \verb|theory_ref| represents a sliding reference to an
|
wenzelm@20451
|
209 |
always valid theory; updates on the original are propagated
|
wenzelm@20447
|
210 |
automatically.
|
wenzelm@20447
|
211 |
|
wenzelm@20449
|
212 |
\item \verb|Theory.self_ref|~\isa{thy} and \verb|Theory.deref|~\isa{thy{\isacharunderscore}ref} convert between \verb|theory| and \verb|theory_ref|. As the referenced theory
|
wenzelm@20451
|
213 |
evolves monotonically over time, later invocations of \verb|Theory.deref| may refer to a larger context.
|
wenzelm@20447
|
214 |
|
wenzelm@20447
|
215 |
\end{description}%
|
wenzelm@20430
|
216 |
\end{isamarkuptext}%
|
wenzelm@20430
|
217 |
\isamarkuptrue%
|
wenzelm@20430
|
218 |
%
|
wenzelm@20430
|
219 |
\endisatagmlref
|
wenzelm@20430
|
220 |
{\isafoldmlref}%
|
wenzelm@20430
|
221 |
%
|
wenzelm@20430
|
222 |
\isadelimmlref
|
wenzelm@20430
|
223 |
%
|
wenzelm@20430
|
224 |
\endisadelimmlref
|
wenzelm@20430
|
225 |
%
|
wenzelm@18537
|
226 |
\isamarkupsubsection{Proof context \label{sec:context-proof}%
|
wenzelm@18537
|
227 |
}
|
wenzelm@18537
|
228 |
\isamarkuptrue%
|
wenzelm@18537
|
229 |
%
|
wenzelm@18537
|
230 |
\begin{isamarkuptext}%
|
wenzelm@20447
|
231 |
\glossary{Proof context}{The static context of a structured proof,
|
wenzelm@20447
|
232 |
acts like a local ``theory'' of the current portion of Isar proof
|
wenzelm@20447
|
233 |
text, generalizes the idea of local hypotheses \isa{{\isasymGamma}} in
|
wenzelm@20447
|
234 |
judgments \isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymphi}} of natural deduction calculi. There is a
|
wenzelm@20447
|
235 |
generic notion of introducing and discharging hypotheses.
|
wenzelm@20447
|
236 |
Arbritrary auxiliary context data may be adjoined.}
|
wenzelm@20429
|
237 |
|
wenzelm@20447
|
238 |
A proof context is a container for pure data with a back-reference
|
wenzelm@20449
|
239 |
to the theory it belongs to. The \isa{init} operation creates a
|
wenzelm@20451
|
240 |
proof context from a given theory. Modifications to draft theories
|
wenzelm@20451
|
241 |
are propagated to the proof context as usual, but there is also an
|
wenzelm@20451
|
242 |
explicit \isa{transfer} operation to force resynchronization
|
wenzelm@20451
|
243 |
with more substantial updates to the underlying theory. The actual
|
wenzelm@20451
|
244 |
context data does not require any special bookkeeping, thanks to the
|
wenzelm@20451
|
245 |
lack of destructive features.
|
wenzelm@20429
|
246 |
|
wenzelm@20447
|
247 |
Entities derived in a proof context need to record inherent logical
|
wenzelm@20447
|
248 |
requirements explicitly, since there is no separate context
|
wenzelm@20447
|
249 |
identification as for theories. For example, hypotheses used in
|
wenzelm@20451
|
250 |
primitive derivations (cf.\ \secref{sec:thms}) are recorded
|
wenzelm@20447
|
251 |
separately within the sequent \isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymphi}}, just to make double
|
wenzelm@20447
|
252 |
sure. Results could still leak into an alien proof context do to
|
wenzelm@20447
|
253 |
programming errors, but Isabelle/Isar includes some extra validity
|
wenzelm@20447
|
254 |
checks in critical positions, notably at the end of sub-proof.
|
wenzelm@20429
|
255 |
|
wenzelm@20451
|
256 |
Proof contexts may be manipulated arbitrarily, although the common
|
wenzelm@20451
|
257 |
discipline is to follow block structure as a mental model: a given
|
wenzelm@20451
|
258 |
context is extended consecutively, and results are exported back
|
wenzelm@20451
|
259 |
into the original context. Note that the Isar proof states model
|
wenzelm@20451
|
260 |
block-structured reasoning explicitly, using a stack of proof
|
wenzelm@20451
|
261 |
contexts internally, cf.\ \secref{sec:isar-proof-state}.%
|
wenzelm@18537
|
262 |
\end{isamarkuptext}%
|
wenzelm@18537
|
263 |
\isamarkuptrue%
|
wenzelm@18537
|
264 |
%
|
wenzelm@20430
|
265 |
\isadelimmlref
|
wenzelm@20430
|
266 |
%
|
wenzelm@20430
|
267 |
\endisadelimmlref
|
wenzelm@20430
|
268 |
%
|
wenzelm@20430
|
269 |
\isatagmlref
|
wenzelm@20430
|
270 |
%
|
wenzelm@20430
|
271 |
\begin{isamarkuptext}%
|
wenzelm@20449
|
272 |
\begin{mldecls}
|
wenzelm@20449
|
273 |
\indexmltype{Proof.context}\verb|type Proof.context| \\
|
wenzelm@20449
|
274 |
\indexml{ProofContext.init}\verb|ProofContext.init: theory -> Proof.context| \\
|
wenzelm@20449
|
275 |
\indexml{ProofContext.theory-of}\verb|ProofContext.theory_of: Proof.context -> theory| \\
|
wenzelm@20449
|
276 |
\indexml{ProofContext.transfer}\verb|ProofContext.transfer: theory -> Proof.context -> Proof.context| \\
|
wenzelm@20449
|
277 |
\end{mldecls}
|
wenzelm@20449
|
278 |
|
wenzelm@20449
|
279 |
\begin{description}
|
wenzelm@20449
|
280 |
|
wenzelm@20449
|
281 |
\item \verb|Proof.context| represents proof contexts. Elements
|
wenzelm@20449
|
282 |
of this type are essentially pure values, with a sliding reference
|
wenzelm@20449
|
283 |
to the background theory.
|
wenzelm@20449
|
284 |
|
wenzelm@20449
|
285 |
\item \verb|ProofContext.init|~\isa{thy} produces a proof context
|
wenzelm@20449
|
286 |
derived from \isa{thy}, initializing all data.
|
wenzelm@20449
|
287 |
|
wenzelm@20449
|
288 |
\item \verb|ProofContext.theory_of|~\isa{ctxt} selects the
|
wenzelm@20451
|
289 |
background theory from \isa{ctxt}, dereferencing its internal
|
wenzelm@20451
|
290 |
\verb|theory_ref|.
|
wenzelm@20449
|
291 |
|
wenzelm@20449
|
292 |
\item \verb|ProofContext.transfer|~\isa{thy\ ctxt} promotes the
|
wenzelm@20449
|
293 |
background theory of \isa{ctxt} to the super theory \isa{thy}.
|
wenzelm@20449
|
294 |
|
wenzelm@20449
|
295 |
\end{description}%
|
wenzelm@20430
|
296 |
\end{isamarkuptext}%
|
wenzelm@20430
|
297 |
\isamarkuptrue%
|
wenzelm@20430
|
298 |
%
|
wenzelm@20430
|
299 |
\endisatagmlref
|
wenzelm@20430
|
300 |
{\isafoldmlref}%
|
wenzelm@20430
|
301 |
%
|
wenzelm@20430
|
302 |
\isadelimmlref
|
wenzelm@20430
|
303 |
%
|
wenzelm@20430
|
304 |
\endisadelimmlref
|
wenzelm@20430
|
305 |
%
|
wenzelm@20451
|
306 |
\isamarkupsubsection{Generic contexts \label{sec:generic-context}%
|
wenzelm@20429
|
307 |
}
|
wenzelm@20429
|
308 |
\isamarkuptrue%
|
wenzelm@20429
|
309 |
%
|
wenzelm@20430
|
310 |
\begin{isamarkuptext}%
|
wenzelm@20449
|
311 |
A generic context is the disjoint sum of either a theory or proof
|
wenzelm@20451
|
312 |
context. Occasionally, this enables uniform treatment of generic
|
wenzelm@20450
|
313 |
context data, typically extra-logical information. Operations on
|
wenzelm@20449
|
314 |
generic contexts include the usual injections, partial selections,
|
wenzelm@20449
|
315 |
and combinators for lifting operations on either component of the
|
wenzelm@20449
|
316 |
disjoint sum.
|
wenzelm@20449
|
317 |
|
wenzelm@20449
|
318 |
Moreover, there are total operations \isa{theory{\isacharunderscore}of} and \isa{proof{\isacharunderscore}of} to convert a generic context into either kind: a theory
|
wenzelm@20451
|
319 |
can always be selected from the sum, while a proof context might
|
wenzelm@20451
|
320 |
have to be constructed by an ad-hoc \isa{init} operation.%
|
wenzelm@20430
|
321 |
\end{isamarkuptext}%
|
wenzelm@20430
|
322 |
\isamarkuptrue%
|
wenzelm@20430
|
323 |
%
|
wenzelm@20430
|
324 |
\isadelimmlref
|
wenzelm@20430
|
325 |
%
|
wenzelm@20430
|
326 |
\endisadelimmlref
|
wenzelm@20430
|
327 |
%
|
wenzelm@20430
|
328 |
\isatagmlref
|
wenzelm@20430
|
329 |
%
|
wenzelm@20430
|
330 |
\begin{isamarkuptext}%
|
wenzelm@20449
|
331 |
\begin{mldecls}
|
wenzelm@20449
|
332 |
\indexmltype{Context.generic}\verb|type Context.generic| \\
|
wenzelm@20449
|
333 |
\indexml{Context.theory-of}\verb|Context.theory_of: Context.generic -> theory| \\
|
wenzelm@20449
|
334 |
\indexml{Context.proof-of}\verb|Context.proof_of: Context.generic -> Proof.context| \\
|
wenzelm@20449
|
335 |
\end{mldecls}
|
wenzelm@20449
|
336 |
|
wenzelm@20449
|
337 |
\begin{description}
|
wenzelm@20449
|
338 |
|
wenzelm@20451
|
339 |
\item \verb|Context.generic| is the direct sum of \verb|theory| and \verb|Proof.context|, with the datatype
|
wenzelm@20451
|
340 |
constructors \verb|Context.Theory| and \verb|Context.Proof|.
|
wenzelm@20449
|
341 |
|
wenzelm@20449
|
342 |
\item \verb|Context.theory_of|~\isa{context} always produces a
|
wenzelm@20449
|
343 |
theory from the generic \isa{context}, using \verb|ProofContext.theory_of| as required.
|
wenzelm@20449
|
344 |
|
wenzelm@20449
|
345 |
\item \verb|Context.proof_of|~\isa{context} always produces a
|
wenzelm@20451
|
346 |
proof context from the generic \isa{context}, using \verb|ProofContext.init| as required (note that this re-initializes the
|
wenzelm@20451
|
347 |
context data with each invocation).
|
wenzelm@20449
|
348 |
|
wenzelm@20449
|
349 |
\end{description}%
|
wenzelm@20430
|
350 |
\end{isamarkuptext}%
|
wenzelm@20430
|
351 |
\isamarkuptrue%
|
wenzelm@20430
|
352 |
%
|
wenzelm@20430
|
353 |
\endisatagmlref
|
wenzelm@20430
|
354 |
{\isafoldmlref}%
|
wenzelm@20430
|
355 |
%
|
wenzelm@20430
|
356 |
\isadelimmlref
|
wenzelm@20430
|
357 |
%
|
wenzelm@20430
|
358 |
\endisadelimmlref
|
wenzelm@20430
|
359 |
%
|
wenzelm@20447
|
360 |
\isamarkupsubsection{Context data%
|
wenzelm@20447
|
361 |
}
|
wenzelm@20447
|
362 |
\isamarkuptrue%
|
wenzelm@20447
|
363 |
%
|
wenzelm@20447
|
364 |
\begin{isamarkuptext}%
|
wenzelm@20451
|
365 |
The main purpose of theory and proof contexts is to manage arbitrary
|
wenzelm@20451
|
366 |
data. New data types can be declared incrementally at compile time.
|
wenzelm@20451
|
367 |
There are separate declaration mechanisms for any of the three kinds
|
wenzelm@20451
|
368 |
of contexts: theory, proof, generic.
|
wenzelm@20449
|
369 |
|
wenzelm@20449
|
370 |
\paragraph{Theory data} may refer to destructive entities, which are
|
wenzelm@20451
|
371 |
maintained in direct correspondence to the linear evolution of
|
wenzelm@20451
|
372 |
theory values, including explicit copies.\footnote{Most existing
|
wenzelm@20451
|
373 |
instances of destructive theory data are merely historical relics
|
wenzelm@20451
|
374 |
(e.g.\ the destructive theorem storage, and destructive hints for
|
wenzelm@20451
|
375 |
the Simplifier and Classical rules).} A theory data declaration
|
wenzelm@20451
|
376 |
needs to implement the following specification (depending on type
|
wenzelm@20451
|
377 |
\isa{T}):
|
wenzelm@20449
|
378 |
|
wenzelm@20449
|
379 |
\medskip
|
wenzelm@20449
|
380 |
\begin{tabular}{ll}
|
wenzelm@20449
|
381 |
\isa{name{\isacharcolon}\ string} \\
|
wenzelm@20449
|
382 |
\isa{empty{\isacharcolon}\ T} & initial value \\
|
wenzelm@20449
|
383 |
\isa{copy{\isacharcolon}\ T\ {\isasymrightarrow}\ T} & refresh impure data \\
|
wenzelm@20449
|
384 |
\isa{extend{\isacharcolon}\ T\ {\isasymrightarrow}\ T} & re-initialize on import \\
|
wenzelm@20449
|
385 |
\isa{merge{\isacharcolon}\ T\ {\isasymtimes}\ T\ {\isasymrightarrow}\ T} & join on import \\
|
wenzelm@20449
|
386 |
\isa{print{\isacharcolon}\ T\ {\isasymrightarrow}\ unit} & diagnostic output \\
|
wenzelm@20449
|
387 |
\end{tabular}
|
wenzelm@20449
|
388 |
\medskip
|
wenzelm@20449
|
389 |
|
wenzelm@20449
|
390 |
\noindent The \isa{name} acts as a comment for diagnostic
|
wenzelm@20449
|
391 |
messages; \isa{copy} is just the identity for pure data; \isa{extend} is acts like a unitary version of \isa{merge}, both
|
wenzelm@20449
|
392 |
should also include the functionality of \isa{copy} for impure
|
wenzelm@20449
|
393 |
data.
|
wenzelm@20449
|
394 |
|
wenzelm@20451
|
395 |
\paragraph{Proof context data} is purely functional. A declaration
|
wenzelm@20451
|
396 |
needs to implement the following specification:
|
wenzelm@20449
|
397 |
|
wenzelm@20449
|
398 |
\medskip
|
wenzelm@20449
|
399 |
\begin{tabular}{ll}
|
wenzelm@20449
|
400 |
\isa{name{\isacharcolon}\ string} \\
|
wenzelm@20449
|
401 |
\isa{init{\isacharcolon}\ theory\ {\isasymrightarrow}\ T} & produce initial value \\
|
wenzelm@20449
|
402 |
\isa{print{\isacharcolon}\ T\ {\isasymrightarrow}\ unit} & diagnostic output \\
|
wenzelm@20449
|
403 |
\end{tabular}
|
wenzelm@20449
|
404 |
\medskip
|
wenzelm@20449
|
405 |
|
wenzelm@20449
|
406 |
\noindent The \isa{init} operation is supposed to produce a pure
|
wenzelm@20451
|
407 |
value from the given background theory. The remainder is analogous
|
wenzelm@20451
|
408 |
to theory data.
|
wenzelm@20449
|
409 |
|
wenzelm@20451
|
410 |
\paragraph{Generic data} provides a hybrid interface for both theory
|
wenzelm@20451
|
411 |
and proof data. The declaration is essentially the same as for
|
wenzelm@20451
|
412 |
(pure) theory data, without \isa{copy}, though. The \isa{init} operation for proof contexts merely selects the current data
|
wenzelm@20451
|
413 |
value from the background theory.
|
wenzelm@20449
|
414 |
|
wenzelm@20449
|
415 |
\bigskip In any case, a data declaration of type \isa{T} results
|
wenzelm@20449
|
416 |
in the following interface:
|
wenzelm@20449
|
417 |
|
wenzelm@20449
|
418 |
\medskip
|
wenzelm@20449
|
419 |
\begin{tabular}{ll}
|
wenzelm@20449
|
420 |
\isa{init{\isacharcolon}\ theory\ {\isasymrightarrow}\ theory} \\
|
wenzelm@20449
|
421 |
\isa{get{\isacharcolon}\ context\ {\isasymrightarrow}\ T} \\
|
wenzelm@20449
|
422 |
\isa{put{\isacharcolon}\ T\ {\isasymrightarrow}\ context\ {\isasymrightarrow}\ context} \\
|
wenzelm@20449
|
423 |
\isa{map{\isacharcolon}\ {\isacharparenleft}T\ {\isasymrightarrow}\ T{\isacharparenright}\ {\isasymrightarrow}\ context\ {\isasymrightarrow}\ context} \\
|
wenzelm@20449
|
424 |
\isa{print{\isacharcolon}\ context\ {\isasymrightarrow}\ unit}
|
wenzelm@20449
|
425 |
\end{tabular}
|
wenzelm@20449
|
426 |
\medskip
|
wenzelm@20449
|
427 |
|
wenzelm@20449
|
428 |
\noindent Here \isa{init} needs to be applied to the current
|
wenzelm@20449
|
429 |
theory context once, in order to register the initial setup. The
|
wenzelm@20449
|
430 |
other operations provide access for the particular kind of context
|
wenzelm@20449
|
431 |
(theory, proof, or generic context). Note that this is a safe
|
wenzelm@20449
|
432 |
interface: there is no other way to access the corresponding data
|
wenzelm@20451
|
433 |
slot of a context. By keeping these operations private, a component
|
wenzelm@20451
|
434 |
may maintain abstract values authentically, without other components
|
wenzelm@20451
|
435 |
interfering.%
|
wenzelm@20447
|
436 |
\end{isamarkuptext}%
|
wenzelm@20447
|
437 |
\isamarkuptrue%
|
wenzelm@20447
|
438 |
%
|
wenzelm@20450
|
439 |
\isadelimmlref
|
wenzelm@20450
|
440 |
%
|
wenzelm@20450
|
441 |
\endisadelimmlref
|
wenzelm@20450
|
442 |
%
|
wenzelm@20450
|
443 |
\isatagmlref
|
wenzelm@20450
|
444 |
%
|
wenzelm@20450
|
445 |
\begin{isamarkuptext}%
|
wenzelm@20450
|
446 |
\begin{mldecls}
|
wenzelm@20450
|
447 |
\indexmlfunctor{TheoryDataFun}\verb|functor TheoryDataFun| \\
|
wenzelm@20450
|
448 |
\indexmlfunctor{ProofDataFun}\verb|functor ProofDataFun| \\
|
wenzelm@20450
|
449 |
\indexmlfunctor{GenericDataFun}\verb|functor GenericDataFun| \\
|
wenzelm@20450
|
450 |
\end{mldecls}
|
wenzelm@20450
|
451 |
|
wenzelm@20450
|
452 |
\begin{description}
|
wenzelm@20450
|
453 |
|
wenzelm@20450
|
454 |
\item \verb|TheoryDataFun|\isa{{\isacharparenleft}spec{\isacharparenright}} declares data for
|
wenzelm@20450
|
455 |
type \verb|theory| according to the specification provided as
|
wenzelm@20451
|
456 |
argument structure. The resulting structure provides data init and
|
wenzelm@20451
|
457 |
access operations as described above.
|
wenzelm@20450
|
458 |
|
wenzelm@20450
|
459 |
\item \verb|ProofDataFun|\isa{{\isacharparenleft}spec{\isacharparenright}} is analogous for
|
wenzelm@20450
|
460 |
type \verb|Proof.context|.
|
wenzelm@20450
|
461 |
|
wenzelm@20450
|
462 |
\item \verb|GenericDataFun|\isa{{\isacharparenleft}spec{\isacharparenright}} is analogous for
|
wenzelm@20450
|
463 |
type \verb|Context.generic|.
|
wenzelm@20450
|
464 |
|
wenzelm@20450
|
465 |
\end{description}%
|
wenzelm@20450
|
466 |
\end{isamarkuptext}%
|
wenzelm@20450
|
467 |
\isamarkuptrue%
|
wenzelm@20450
|
468 |
%
|
wenzelm@20450
|
469 |
\endisatagmlref
|
wenzelm@20450
|
470 |
{\isafoldmlref}%
|
wenzelm@20450
|
471 |
%
|
wenzelm@20450
|
472 |
\isadelimmlref
|
wenzelm@20450
|
473 |
%
|
wenzelm@20450
|
474 |
\endisadelimmlref
|
wenzelm@20450
|
475 |
%
|
wenzelm@20438
|
476 |
\isamarkupsection{Named entities%
|
wenzelm@20438
|
477 |
}
|
wenzelm@20438
|
478 |
\isamarkuptrue%
|
wenzelm@20438
|
479 |
%
|
wenzelm@20438
|
480 |
\begin{isamarkuptext}%
|
wenzelm@20451
|
481 |
By general convention, each kind of formal entities (logical
|
wenzelm@20451
|
482 |
constant, type, type class, theorem, method etc.) lives in a
|
wenzelm@20451
|
483 |
separate name space. It is usually clear from the syntactic context
|
wenzelm@20451
|
484 |
of a name, which kind of entity it refers to. For example, proof
|
wenzelm@20451
|
485 |
method \isa{foo} vs.\ theorem \isa{foo} vs.\ logical
|
wenzelm@20451
|
486 |
constant \isa{foo} are easily distinguished thanks to the design
|
wenzelm@20451
|
487 |
of the concrete outer syntax. A notable exception are logical
|
wenzelm@20451
|
488 |
identifiers within a term (\secref{sec:terms}): constants, fixed
|
wenzelm@20451
|
489 |
variables, and bound variables all share the same identifier syntax,
|
wenzelm@20451
|
490 |
but are distinguished by their scope.
|
wenzelm@20438
|
491 |
|
wenzelm@20451
|
492 |
Name spaces are organized uniformly, as a collection of qualified
|
wenzelm@20451
|
493 |
names consisting of a sequence of basic name components separated by
|
wenzelm@20451
|
494 |
dots: \isa{Bar{\isachardot}bar{\isachardot}foo}, \isa{Bar{\isachardot}foo}, and \isa{foo}
|
wenzelm@20451
|
495 |
are examples for qualified names.
|
wenzelm@20451
|
496 |
|
wenzelm@20451
|
497 |
Despite the independence of names of different kinds, certain naming
|
wenzelm@20451
|
498 |
conventions may relate them to each other. For example, a constant
|
wenzelm@20451
|
499 |
\isa{foo} could be accompanied with theorems \isa{foo{\isachardot}intro}, \isa{foo{\isachardot}elim}, \isa{foo{\isachardot}simps} etc. The same
|
wenzelm@20451
|
500 |
could happen for a type \isa{foo}, but this is apt to cause
|
wenzelm@20451
|
501 |
clashes in the theorem name space! To avoid this, there is an
|
wenzelm@20451
|
502 |
additional convention to add a suffix that determines the original
|
wenzelm@20451
|
503 |
kind. For example, constant \isa{foo} could associated with
|
wenzelm@20451
|
504 |
theorem \isa{foo{\isachardot}intro}, type \isa{foo} with theorem \isa{foo{\isacharunderscore}type{\isachardot}intro}, and type class \isa{foo} with \isa{foo{\isacharunderscore}class{\isachardot}intro}.
|
wenzelm@20451
|
505 |
|
wenzelm@20451
|
506 |
\medskip Name components are subdivided into \emph{symbols}, which
|
wenzelm@20451
|
507 |
constitute the smallest textual unit in Isabelle --- raw characters
|
wenzelm@20451
|
508 |
are normally not encountered.%
|
wenzelm@20438
|
509 |
\end{isamarkuptext}%
|
wenzelm@20438
|
510 |
\isamarkuptrue%
|
wenzelm@20438
|
511 |
%
|
wenzelm@20438
|
512 |
\isamarkupsubsection{Strings of symbols%
|
wenzelm@20438
|
513 |
}
|
wenzelm@20438
|
514 |
\isamarkuptrue%
|
wenzelm@20438
|
515 |
%
|
wenzelm@20438
|
516 |
\begin{isamarkuptext}%
|
wenzelm@20438
|
517 |
Isabelle strings consist of a sequence of
|
wenzelm@20451
|
518 |
symbols\glossary{Symbol}{The smallest unit of text in Isabelle,
|
wenzelm@20451
|
519 |
subsumes plain ASCII characters as well as an infinite collection of
|
wenzelm@20451
|
520 |
named symbols (for greek, math etc.).}, which are either packed as
|
wenzelm@20451
|
521 |
an actual \isa{string}, or represented as a list. Each symbol
|
wenzelm@20451
|
522 |
is in itself a small string of the following form:
|
wenzelm@20438
|
523 |
|
wenzelm@20451
|
524 |
\begin{enumerate}
|
wenzelm@20438
|
525 |
|
wenzelm@20451
|
526 |
\item either a singleton ASCII character ``\isa{c}'' (with
|
wenzelm@20451
|
527 |
character code 0--127), for example ``\verb,a,'',
|
wenzelm@20438
|
528 |
|
wenzelm@20451
|
529 |
\item or a regular symbol ``\verb,\,\verb,<,\isa{ident}\verb,>,'', for example ``\verb,\,\verb,<alpha>,'',
|
wenzelm@20438
|
530 |
|
wenzelm@20451
|
531 |
\item or a control symbol ``\verb,\,\verb,<^,\isa{ident}\verb,>,'', for example ``\verb,\,\verb,<^bold>,'',
|
wenzelm@20438
|
532 |
|
wenzelm@20451
|
533 |
\item or a raw control symbol ``\verb,\,\verb,<^raw:,\isa{{\isasymdots}}\verb,>,'' where ``\isa{{\isasymdots}}'' refers to any printable ASCII
|
wenzelm@20451
|
534 |
character (excluding ``\verb,.,'' and ``\verb,>,'') or non-ASCII
|
wenzelm@20451
|
535 |
character, for example ``\verb,\,\verb,<^raw:$\sum_{i = 1}^n$>,'',
|
wenzelm@20438
|
536 |
|
wenzelm@20451
|
537 |
\item or a numbered raw control symbol ``\verb,\,\verb,<^raw,\isa{nnn}\verb,>, where \isa{nnn} are digits, for example
|
wenzelm@20451
|
538 |
``\verb,\,\verb,<^raw42>,''.
|
wenzelm@20438
|
539 |
|
wenzelm@20451
|
540 |
\end{enumerate}
|
wenzelm@20438
|
541 |
|
wenzelm@20451
|
542 |
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
|
wenzelm@20451
|
543 |
\isa{digit\ {\isacharequal}\ {\isadigit{0}}{\isachardot}{\isachardot}{\isadigit{9}}}. There are infinitely many regular symbols
|
wenzelm@20451
|
544 |
and control symbols available, but a certain collection of standard
|
wenzelm@20451
|
545 |
symbols is treated specifically. For example,
|
wenzelm@20451
|
546 |
``\verb,\,\verb,<alpha>,'' is classified as a (non-ASCII) letter,
|
wenzelm@20451
|
547 |
which means it may occur within regular Isabelle identifier syntax.
|
wenzelm@20438
|
548 |
|
wenzelm@20451
|
549 |
Output of symbols depends on the print mode
|
wenzelm@20451
|
550 |
(\secref{sec:print-mode}). For example, the standard {\LaTeX} setup
|
wenzelm@20451
|
551 |
of the Isabelle document preparation system would present
|
wenzelm@20451
|
552 |
``\verb,\,\verb,<alpha>,'' as \isa{{\isasymalpha}}, and
|
wenzelm@20451
|
553 |
``\verb,\,\verb,<^bold>,\verb,\,\verb,<alpha>,'' as \isa{\isactrlbold {\isasymalpha}}.
|
wenzelm@20438
|
554 |
|
wenzelm@20451
|
555 |
\medskip It is important to note that the character set underlying
|
wenzelm@20451
|
556 |
Isabelle symbols is plain 7-bit ASCII. Since 8-bit characters are
|
wenzelm@20451
|
557 |
passed through transparently, Isabelle may easily process
|
wenzelm@20451
|
558 |
Unicode/UCS data as well (using UTF-8 encoding). Unicode provides
|
wenzelm@20451
|
559 |
its own collection of mathematical symbols, but there is no built-in
|
wenzelm@20451
|
560 |
link to the ones of Isabelle.%
|
wenzelm@20438
|
561 |
\end{isamarkuptext}%
|
wenzelm@20438
|
562 |
\isamarkuptrue%
|
wenzelm@20438
|
563 |
%
|
wenzelm@20438
|
564 |
\isadelimmlref
|
wenzelm@20438
|
565 |
%
|
wenzelm@20438
|
566 |
\endisadelimmlref
|
wenzelm@20438
|
567 |
%
|
wenzelm@20438
|
568 |
\isatagmlref
|
wenzelm@20438
|
569 |
%
|
wenzelm@20438
|
570 |
\begin{isamarkuptext}%
|
wenzelm@20438
|
571 |
\begin{mldecls}
|
wenzelm@20438
|
572 |
\indexmltype{Symbol.symbol}\verb|type Symbol.symbol| \\
|
wenzelm@20438
|
573 |
\indexml{Symbol.explode}\verb|Symbol.explode: string -> Symbol.symbol list| \\
|
wenzelm@20438
|
574 |
\indexml{Symbol.is-letter}\verb|Symbol.is_letter: Symbol.symbol -> bool| \\
|
wenzelm@20438
|
575 |
\indexml{Symbol.is-digit}\verb|Symbol.is_digit: Symbol.symbol -> bool| \\
|
wenzelm@20438
|
576 |
\indexml{Symbol.is-quasi}\verb|Symbol.is_quasi: Symbol.symbol -> bool| \\
|
wenzelm@20451
|
577 |
\indexml{Symbol.is-blank}\verb|Symbol.is_blank: Symbol.symbol -> bool| \\[1ex]
|
wenzelm@20438
|
578 |
\indexmltype{Symbol.sym}\verb|type Symbol.sym| \\
|
wenzelm@20438
|
579 |
\indexml{Symbol.decode}\verb|Symbol.decode: Symbol.symbol -> Symbol.sym| \\
|
wenzelm@20438
|
580 |
\end{mldecls}
|
wenzelm@20438
|
581 |
|
wenzelm@20438
|
582 |
\begin{description}
|
wenzelm@20438
|
583 |
|
wenzelm@20451
|
584 |
\item \verb|Symbol.symbol| represents Isabelle symbols. This
|
wenzelm@20451
|
585 |
type is an alias for \verb|string|, but emphasizes the
|
wenzelm@20438
|
586 |
specific format encountered here.
|
wenzelm@20438
|
587 |
|
wenzelm@20447
|
588 |
\item \verb|Symbol.explode|~\isa{s} produces a symbol list from
|
wenzelm@20451
|
589 |
the packed form that is encountered in most practical situations.
|
wenzelm@20451
|
590 |
This function supercedes \verb|String.explode| for virtually all
|
wenzelm@20451
|
591 |
purposes of manipulating text in Isabelle! Plain \verb|implode|
|
wenzelm@20451
|
592 |
may still be used for the reverse operation.
|
wenzelm@20438
|
593 |
|
wenzelm@20438
|
594 |
\item \verb|Symbol.is_letter|, \verb|Symbol.is_digit|, \verb|Symbol.is_quasi|, \verb|Symbol.is_blank| classify certain symbols
|
wenzelm@20438
|
595 |
(both ASCII and several named ones) according to fixed syntactic
|
wenzelm@20451
|
596 |
conventions of Isabelle, cf.\ \cite{isabelle-isar-ref}.
|
wenzelm@20438
|
597 |
|
wenzelm@20438
|
598 |
\item \verb|Symbol.sym| is a concrete datatype that represents
|
wenzelm@20451
|
599 |
the different kinds of symbols explicitly with constructors \verb|Symbol.Char|, \verb|Symbol.Sym|, \verb|Symbol.Ctrl|, or \verb|Symbol.Raw|.
|
wenzelm@20438
|
600 |
|
wenzelm@20438
|
601 |
\item \verb|Symbol.decode| converts the string representation of a
|
wenzelm@20451
|
602 |
symbol into the datatype version.
|
wenzelm@20438
|
603 |
|
wenzelm@20438
|
604 |
\end{description}%
|
wenzelm@20438
|
605 |
\end{isamarkuptext}%
|
wenzelm@20438
|
606 |
\isamarkuptrue%
|
wenzelm@20438
|
607 |
%
|
wenzelm@20438
|
608 |
\endisatagmlref
|
wenzelm@20438
|
609 |
{\isafoldmlref}%
|
wenzelm@20438
|
610 |
%
|
wenzelm@20438
|
611 |
\isadelimmlref
|
wenzelm@20438
|
612 |
%
|
wenzelm@20438
|
613 |
\endisadelimmlref
|
wenzelm@20438
|
614 |
%
|
wenzelm@20438
|
615 |
\isamarkupsubsection{Qualified names and name spaces%
|
wenzelm@20438
|
616 |
}
|
wenzelm@20438
|
617 |
\isamarkuptrue%
|
wenzelm@20438
|
618 |
%
|
wenzelm@20438
|
619 |
\begin{isamarkuptext}%
|
wenzelm@20451
|
620 |
A \emph{qualified name} essentially consists of a non-empty list of
|
wenzelm@20451
|
621 |
basic name components. The packad notation uses a dot as separator,
|
wenzelm@20451
|
622 |
as in \isa{A{\isachardot}b}, for example. The very last component is called
|
wenzelm@20451
|
623 |
\emph{base} name, the remaining prefix \emph{qualifier} (which may
|
wenzelm@20451
|
624 |
be empty).
|
wenzelm@20438
|
625 |
|
wenzelm@20451
|
626 |
A \isa{naming} policy tells how to produce fully qualified names
|
wenzelm@20451
|
627 |
from a given specification. The \isa{full} operation applies
|
wenzelm@20451
|
628 |
performs naming of a name; the policy is usually taken from the
|
wenzelm@20451
|
629 |
context. For example, a common policy is to attach an implicit
|
wenzelm@20451
|
630 |
prefix.
|
wenzelm@20438
|
631 |
|
wenzelm@20451
|
632 |
A \isa{name\ space} manages declarations of fully qualified
|
wenzelm@20451
|
633 |
names. There are separate operations to \isa{declare}, \isa{intern}, and \isa{extern} names.
|
wenzelm@20438
|
634 |
|
wenzelm@20451
|
635 |
FIXME%
|
wenzelm@20438
|
636 |
\end{isamarkuptext}%
|
wenzelm@20438
|
637 |
\isamarkuptrue%
|
wenzelm@20438
|
638 |
%
|
wenzelm@20451
|
639 |
\isadelimmlref
|
wenzelm@20451
|
640 |
%
|
wenzelm@20451
|
641 |
\endisadelimmlref
|
wenzelm@20451
|
642 |
%
|
wenzelm@20451
|
643 |
\isatagmlref
|
wenzelm@20451
|
644 |
%
|
wenzelm@20451
|
645 |
\begin{isamarkuptext}%
|
wenzelm@20451
|
646 |
FIXME%
|
wenzelm@20451
|
647 |
\end{isamarkuptext}%
|
wenzelm@20451
|
648 |
\isamarkuptrue%
|
wenzelm@20451
|
649 |
%
|
wenzelm@20451
|
650 |
\endisatagmlref
|
wenzelm@20451
|
651 |
{\isafoldmlref}%
|
wenzelm@20451
|
652 |
%
|
wenzelm@20451
|
653 |
\isadelimmlref
|
wenzelm@20451
|
654 |
%
|
wenzelm@20451
|
655 |
\endisadelimmlref
|
wenzelm@20451
|
656 |
%
|
wenzelm@20438
|
657 |
\isamarkupsection{Structured output%
|
wenzelm@20438
|
658 |
}
|
wenzelm@20438
|
659 |
\isamarkuptrue%
|
wenzelm@20438
|
660 |
%
|
wenzelm@20438
|
661 |
\isamarkupsubsection{Pretty printing%
|
wenzelm@20438
|
662 |
}
|
wenzelm@20438
|
663 |
\isamarkuptrue%
|
wenzelm@20438
|
664 |
%
|
wenzelm@20438
|
665 |
\begin{isamarkuptext}%
|
wenzelm@20438
|
666 |
FIXME%
|
wenzelm@20438
|
667 |
\end{isamarkuptext}%
|
wenzelm@20438
|
668 |
\isamarkuptrue%
|
wenzelm@20438
|
669 |
%
|
wenzelm@20438
|
670 |
\isamarkupsubsection{Output channels%
|
wenzelm@20438
|
671 |
}
|
wenzelm@20438
|
672 |
\isamarkuptrue%
|
wenzelm@20438
|
673 |
%
|
wenzelm@20438
|
674 |
\begin{isamarkuptext}%
|
wenzelm@20438
|
675 |
FIXME%
|
wenzelm@20438
|
676 |
\end{isamarkuptext}%
|
wenzelm@20438
|
677 |
\isamarkuptrue%
|
wenzelm@20438
|
678 |
%
|
wenzelm@20451
|
679 |
\isamarkupsubsection{Print modes \label{sec:print-mode}%
|
wenzelm@20438
|
680 |
}
|
wenzelm@20438
|
681 |
\isamarkuptrue%
|
wenzelm@20438
|
682 |
%
|
wenzelm@20438
|
683 |
\begin{isamarkuptext}%
|
wenzelm@20438
|
684 |
FIXME%
|
wenzelm@20438
|
685 |
\end{isamarkuptext}%
|
wenzelm@20438
|
686 |
\isamarkuptrue%
|
wenzelm@20438
|
687 |
%
|
wenzelm@18537
|
688 |
\isadelimtheory
|
wenzelm@18537
|
689 |
%
|
wenzelm@18537
|
690 |
\endisadelimtheory
|
wenzelm@18537
|
691 |
%
|
wenzelm@18537
|
692 |
\isatagtheory
|
wenzelm@18537
|
693 |
\isacommand{end}\isamarkupfalse%
|
wenzelm@18537
|
694 |
%
|
wenzelm@18537
|
695 |
\endisatagtheory
|
wenzelm@18537
|
696 |
{\isafoldtheory}%
|
wenzelm@18537
|
697 |
%
|
wenzelm@18537
|
698 |
\isadelimtheory
|
wenzelm@18537
|
699 |
%
|
wenzelm@18537
|
700 |
\endisadelimtheory
|
wenzelm@18537
|
701 |
\isanewline
|
wenzelm@18537
|
702 |
\end{isabellebody}%
|
wenzelm@18537
|
703 |
%%% Local Variables:
|
wenzelm@18537
|
704 |
%%% mode: latex
|
wenzelm@18537
|
705 |
%%% TeX-master: "root"
|
wenzelm@18537
|
706 |
%%% End:
|