18537
|
1 |
|
|
2 |
(* $Id$ *)
|
|
3 |
|
|
4 |
theory prelim imports base begin
|
|
5 |
|
|
6 |
chapter {* Preliminaries *}
|
|
7 |
|
20429
|
8 |
section {* Contexts \label{sec:context} *}
|
18537
|
9 |
|
20429
|
10 |
text {*
|
|
11 |
A logical context represents the background that is taken for
|
|
12 |
granted when formulating statements and composing proofs. It acts
|
|
13 |
as a medium to produce formal content, depending on earlier material
|
|
14 |
(declarations, results etc.).
|
18537
|
15 |
|
20429
|
16 |
In particular, derivations within the primitive Pure logic can be
|
|
17 |
described as a judgment @{text "\<Gamma> \<turnstile>\<^sub>\<Theta> \<phi>"}, meaning that a
|
|
18 |
proposition @{text "\<phi>"} is derivable from hypotheses @{text "\<Gamma>"}
|
|
19 |
within the theory @{text "\<Theta>"}. There are logical reasons for
|
|
20 |
keeping @{text "\<Theta>"} and @{text "\<Gamma>"} separate: theories support type
|
|
21 |
constructors and schematic polymorphism of constants and axioms,
|
|
22 |
while the inner calculus of @{text "\<Gamma> \<turnstile> \<phi>"} is limited to Simple
|
|
23 |
Type Theory (with fixed type variables in the assumptions).
|
18537
|
24 |
|
20429
|
25 |
\medskip Contexts and derivations are linked by the following key
|
|
26 |
principles:
|
|
27 |
|
|
28 |
\begin{itemize}
|
|
29 |
|
|
30 |
\item Transfer: monotonicity of derivations admits results to be
|
|
31 |
transferred into a larger context, i.e.\ @{text "\<Gamma> \<turnstile>\<^sub>\<Theta> \<phi>"}
|
|
32 |
implies @{text "\<Gamma>' \<turnstile>\<^sub>\<Theta>\<^sub>' \<phi>"} for contexts @{text "\<Theta>' \<supseteq>
|
|
33 |
\<Theta>"} and @{text "\<Gamma>' \<supseteq> \<Gamma>"}.
|
18537
|
34 |
|
20429
|
35 |
\item Export: discharge of hypotheses admits results to be exported
|
|
36 |
into a smaller context, i.e.\ @{text "\<Gamma>' \<turnstile>\<^sub>\<Theta> \<phi>"} implies
|
|
37 |
@{text "\<Gamma> \<turnstile>\<^sub>\<Theta> \<Delta> \<Longrightarrow> \<phi>"} where @{text "\<Gamma>' \<supseteq> \<Gamma>"} and @{text "\<Delta> =
|
|
38 |
\<Gamma>' - \<Gamma>"}. Note that @{text "\<Theta>"} remains unchanged here, only the
|
|
39 |
@{text "\<Gamma>"} part is affected.
|
|
40 |
|
|
41 |
\end{itemize}
|
18537
|
42 |
|
20429
|
43 |
\medskip Isabelle/Isar provides two different notions of abstract
|
|
44 |
containers called \emph{theory context} and \emph{proof context},
|
|
45 |
respectively. These model the main characteristics of the primitive
|
|
46 |
@{text "\<Theta>"} and @{text "\<Gamma>"} above, without subscribing to any
|
|
47 |
particular kind of content yet. Instead, contexts merely impose a
|
|
48 |
certain policy of managing arbitrary \emph{context data}. The
|
|
49 |
system provides strongly typed mechanisms to declare new kinds of
|
|
50 |
data at compile time.
|
18537
|
51 |
|
20429
|
52 |
Thus the internal bootstrap process of Isabelle/Pure eventually
|
|
53 |
reaches a stage where certain data slots provide the logical content
|
|
54 |
of @{text "\<Theta>"} and @{text "\<Gamma>"} sketched above, but this does not
|
|
55 |
stop there! Various additional data slots support all kinds of
|
|
56 |
mechanisms that are not necessarily part of the core logic.
|
18537
|
57 |
|
20429
|
58 |
For example, there would be data for canonical introduction and
|
|
59 |
elimination rules for arbitrary operators (depending on the
|
|
60 |
object-logic and application), which enables users to perform
|
|
61 |
standard proof steps implicitly (cf.\ the @{text "rule"} method).
|
18537
|
62 |
|
20429
|
63 |
Isabelle is able to bring forth more and more concepts successively.
|
|
64 |
In particular, an object-logic like Isabelle/HOL continues the
|
|
65 |
Isabelle/Pure setup by adding specific components for automated
|
|
66 |
reasoning (classical reasoner, tableau prover, structured induction
|
|
67 |
etc.) and derived specification mechanisms (inductive predicates,
|
|
68 |
recursive functions etc.). All of this is based on the generic data
|
|
69 |
management by theory and proof contexts.
|
18537
|
70 |
*}
|
|
71 |
|
|
72 |
|
|
73 |
subsection {* Theory context \label{sec:context-theory} *}
|
|
74 |
|
20429
|
75 |
text {*
|
20447
|
76 |
\glossary{Theory}{FIXME}
|
|
77 |
|
20429
|
78 |
Each theory is explicitly named and holds a unique identifier.
|
|
79 |
There is a separate \emph{theory reference} for pointing backwards
|
|
80 |
to the enclosing theory context of derived entities. Theories are
|
|
81 |
related by a (nominal) sub-theory relation, which corresponds to the
|
|
82 |
canonical dependency graph: each theory is derived from a certain
|
|
83 |
sub-graph of ancestor theories. The @{text "merge"} of two theories
|
|
84 |
refers to the least upper bound, which actually degenerates into
|
|
85 |
absorption of one theory into the other, due to the nominal
|
|
86 |
sub-theory relation this.
|
18537
|
87 |
|
20429
|
88 |
The @{text "begin"} operation starts a new theory by importing
|
|
89 |
several parent theories and entering a special @{text "draft"} mode,
|
|
90 |
which is sustained until the final @{text "end"} operation. A draft
|
|
91 |
mode theory acts like a linear type, where updates invalidate
|
|
92 |
earlier drafts, but theory reference values will be propagated
|
|
93 |
automatically. Thus derived entities that ``belong'' to a draft
|
|
94 |
might be transferred spontaneously to a larger context. An
|
20447
|
95 |
invalidated draft is called ``stale''.
|
20429
|
96 |
|
20447
|
97 |
The @{text "checkpoint"} operation produces an intermediate stepping
|
|
98 |
stone that will survive the next update unscathed: both the original
|
|
99 |
and the changed theory remain valid and are related by the
|
|
100 |
sub-theory relation. Checkpointing essentially recovers purely
|
|
101 |
functional theory values, at the expense of some extra internal
|
|
102 |
bookeeping.
|
|
103 |
|
|
104 |
The @{text "copy"} operation produces an auxiliary version that has
|
|
105 |
the same data content, but is unrelated to the original: updates of
|
|
106 |
the copy do not affect the original, neither does the sub-theory
|
|
107 |
relation hold.
|
20429
|
108 |
|
20447
|
109 |
\medskip The example in \figref{fig:ex-theory} below shows a theory
|
|
110 |
graph derived from @{text "Pure"}. Theory @{text "Length"} imports
|
|
111 |
@{text "Nat"} and @{text "List"}. The theory body consists of a
|
|
112 |
sequence of updates, working mostly on drafts. Intermediate
|
|
113 |
checkpoints may occur as well, due to the history mechanism provided
|
|
114 |
by the Isar toplevel, cf.\ \secref{sec:isar-toplevel}.
|
|
115 |
|
|
116 |
\begin{figure}[htb]
|
|
117 |
\begin{center}
|
20429
|
118 |
\begin{tabular}{rcccl}
|
20447
|
119 |
& & @{text "Pure"} \\
|
|
120 |
& & @{text "\<down>"} \\
|
|
121 |
& & @{text "FOL"} \\
|
18537
|
122 |
& $\swarrow$ & & $\searrow$ & \\
|
20447
|
123 |
$Nat$ & & & & @{text "List"} \\
|
18537
|
124 |
& $\searrow$ & & $\swarrow$ \\
|
20447
|
125 |
& & @{text "Length"} \\
|
18537
|
126 |
& & \multicolumn{3}{l}{~~$\isarkeyword{imports}$} \\
|
|
127 |
& & \multicolumn{3}{l}{~~$\isarkeyword{begin}$} \\
|
|
128 |
& & $\vdots$~~ \\
|
20447
|
129 |
& & @{text "\<bullet>"}~~ \\
|
|
130 |
& & $\vdots$~~ \\
|
|
131 |
& & @{text "\<bullet>"}~~ \\
|
|
132 |
& & $\vdots$~~ \\
|
18537
|
133 |
& & \multicolumn{3}{l}{~~$\isarkeyword{end}$} \\
|
20429
|
134 |
\end{tabular}
|
20447
|
135 |
\caption{Theory definition depending on ancestors}\label{fig:ex-theory}
|
|
136 |
\end{center}
|
|
137 |
\end{figure}
|
18537
|
138 |
*}
|
|
139 |
|
20430
|
140 |
text %mlref {*
|
20447
|
141 |
\begin{mldecls}
|
|
142 |
@{index_ML_type theory} \\
|
|
143 |
@{index_ML Theory.subthy: "theory * theory -> bool"} \\
|
|
144 |
@{index_ML Theory.merge: "theory * theory -> theory"} \\
|
|
145 |
@{index_ML Theory.checkpoint: "theory -> theory"} \\
|
|
146 |
@{index_ML Theory.copy: "theory -> theory"} \\[1ex]
|
|
147 |
@{index_ML_type theory_ref} \\
|
|
148 |
@{index_ML Theory.self_ref: "theory -> theory_ref"} \\
|
|
149 |
@{index_ML Theory.deref: "theory_ref -> theory"} \\
|
|
150 |
\end{mldecls}
|
|
151 |
|
|
152 |
\begin{description}
|
|
153 |
|
|
154 |
\item @{ML_type theory} represents theory contexts. This is a
|
|
155 |
linear type! Most operations destroy the old version, which then
|
|
156 |
becomes ``stale''.
|
|
157 |
|
|
158 |
\item @{ML "Theory.subthy"}~@{text "(thy\<^sub>1, thy\<^sub>2)"}
|
|
159 |
compares theories according to the inherent graph structure of the
|
|
160 |
construction. This sub-theory relation is a nominal approximation
|
|
161 |
of inclusion (@{text "\<subseteq>"}) of the corresponding content.
|
|
162 |
|
|
163 |
\item @{ML "Theory.merge"}~@{text "(thy\<^sub>1, thy\<^sub>2)"}
|
|
164 |
absorbs one theory into the other. This fails for unrelated
|
|
165 |
theories!
|
|
166 |
|
|
167 |
\item @{ML "Theory.checkpoint"}~@{text "thy"} produces a safe
|
|
168 |
stepping stone in the linear development of @{text "thy"}. The next
|
|
169 |
update will result in two related, valid theories.
|
|
170 |
|
|
171 |
\item @{ML "Theory.copy"}~@{text "thy"} produces a variant of @{text
|
|
172 |
"thy"} that holds a copy of the same data. The copy is not related
|
|
173 |
to the original, which is not touched at all.
|
|
174 |
|
|
175 |
\item @{ML_type theory_ref} represents a sliding reference to a
|
|
176 |
valid theory --- updates on the original are propagated
|
|
177 |
automatically.
|
|
178 |
|
20449
|
179 |
\item @{ML "Theory.self_ref"}~@{text "thy"} and @{ML
|
|
180 |
"Theory.deref"}~@{text "thy_ref"} convert between @{ML_type
|
|
181 |
"theory"} and @{ML_type "theory_ref"}. As the referenced theory
|
|
182 |
evolves monotonically over time, later invocations of @{ML
|
|
183 |
"Theory.deref"} may refer to larger contexts.
|
20447
|
184 |
|
|
185 |
\end{description}
|
20430
|
186 |
*}
|
|
187 |
|
18537
|
188 |
|
|
189 |
subsection {* Proof context \label{sec:context-proof} *}
|
|
190 |
|
|
191 |
text {*
|
20447
|
192 |
\glossary{Proof context}{The static context of a structured proof,
|
|
193 |
acts like a local ``theory'' of the current portion of Isar proof
|
|
194 |
text, generalizes the idea of local hypotheses @{text "\<Gamma>"} in
|
|
195 |
judgments @{text "\<Gamma> \<turnstile> \<phi>"} of natural deduction calculi. There is a
|
|
196 |
generic notion of introducing and discharging hypotheses.
|
|
197 |
Arbritrary auxiliary context data may be adjoined.}
|
20429
|
198 |
|
20447
|
199 |
A proof context is a container for pure data with a back-reference
|
20449
|
200 |
to the theory it belongs to. The @{text "init"} operation creates a
|
|
201 |
proof context derived from a given theory. Modifications to draft
|
|
202 |
theories are propagated to the proof context as usual, but there is
|
|
203 |
also an explicit @{text "transfer"} operation to force
|
|
204 |
resynchronization with more substantial updates to the underlying
|
|
205 |
theory. The actual context data does not require any special
|
|
206 |
bookkeeping, thanks to the lack of destructive features.
|
20429
|
207 |
|
20447
|
208 |
Entities derived in a proof context need to record inherent logical
|
|
209 |
requirements explicitly, since there is no separate context
|
|
210 |
identification as for theories. For example, hypotheses used in
|
|
211 |
primitive derivations (cf.\ \secref{sec:thm}) are recorded
|
|
212 |
separately within the sequent @{text "\<Gamma> \<turnstile> \<phi>"}, just to make double
|
|
213 |
sure. Results could still leak into an alien proof context do to
|
|
214 |
programming errors, but Isabelle/Isar includes some extra validity
|
|
215 |
checks in critical positions, notably at the end of sub-proof.
|
20429
|
216 |
|
20447
|
217 |
Proof contexts may be produced in arbitrary ways, although the
|
|
218 |
common discipline is to follow block structure as a mental model: a
|
|
219 |
given context is extended consecutively, and results are exported
|
|
220 |
back into the original context. Note that the Isar proof states
|
|
221 |
model block-structured reasoning explicitly, using a stack of proof
|
|
222 |
contexts, cf.\ \secref{isar-proof-state}.
|
18537
|
223 |
*}
|
|
224 |
|
20449
|
225 |
text %mlref {*
|
|
226 |
\begin{mldecls}
|
|
227 |
@{index_ML_type Proof.context} \\
|
|
228 |
@{index_ML ProofContext.init: "theory -> Proof.context"} \\
|
|
229 |
@{index_ML ProofContext.theory_of: "Proof.context -> theory"} \\
|
|
230 |
@{index_ML ProofContext.transfer: "theory -> Proof.context -> Proof.context"} \\
|
|
231 |
\end{mldecls}
|
|
232 |
|
|
233 |
\begin{description}
|
|
234 |
|
|
235 |
\item @{ML_type Proof.context} represents proof contexts. Elements
|
|
236 |
of this type are essentially pure values, with a sliding reference
|
|
237 |
to the background theory.
|
|
238 |
|
|
239 |
\item @{ML ProofContext.init}~@{text "thy"} produces a proof context
|
|
240 |
derived from @{text "thy"}, initializing all data.
|
|
241 |
|
|
242 |
\item @{ML ProofContext.theory_of}~@{text "ctxt"} selects the
|
|
243 |
background theory from @{text "ctxt"}.
|
|
244 |
|
|
245 |
\item @{ML ProofContext.transfer}~@{text "thy ctxt"} promotes the
|
|
246 |
background theory of @{text "ctxt"} to the super theory @{text
|
|
247 |
"thy"}.
|
|
248 |
|
|
249 |
\end{description}
|
|
250 |
*}
|
|
251 |
|
20430
|
252 |
|
20429
|
253 |
|
|
254 |
subsection {* Generic contexts *}
|
|
255 |
|
20449
|
256 |
text {*
|
|
257 |
A generic context is the disjoint sum of either a theory or proof
|
|
258 |
context. Occasionally, this simplifies uniform treatment of generic
|
|
259 |
context data, typically extralogical information. Operations on
|
|
260 |
generic contexts include the usual injections, partial selections,
|
|
261 |
and combinators for lifting operations on either component of the
|
|
262 |
disjoint sum.
|
|
263 |
|
|
264 |
Moreover, there are total operations @{text "theory_of"} and @{text
|
|
265 |
"proof_of"} to convert a generic context into either kind: a theory
|
|
266 |
can always be selected, while a proof context may have to be
|
|
267 |
constructed by an ad-hoc @{text "init"} operation.
|
|
268 |
*}
|
20430
|
269 |
|
20449
|
270 |
text %mlref {*
|
|
271 |
\begin{mldecls}
|
|
272 |
@{index_ML_type Context.generic} \\
|
|
273 |
@{index_ML Context.theory_of: "Context.generic -> theory"} \\
|
|
274 |
@{index_ML Context.proof_of: "Context.generic -> Proof.context"} \\
|
|
275 |
\end{mldecls}
|
|
276 |
|
|
277 |
\begin{description}
|
20430
|
278 |
|
20449
|
279 |
\item @{ML_type Context.generic} is the direct sum of @{ML_type
|
|
280 |
"theory"} and @{ML_type "Proof.context"}, with datatype constructors
|
|
281 |
@{ML "Context.Theory"} and @{ML "Context.Proof"}.
|
|
282 |
|
|
283 |
\item @{ML Context.theory_of}~@{text "context"} always produces a
|
|
284 |
theory from the generic @{text "context"}, using @{ML
|
|
285 |
"ProofContext.theory_of"} as required.
|
|
286 |
|
|
287 |
\item @{ML Context.proof_of}~@{text "context"} always produces a
|
|
288 |
proof context from the generic @{text "context"}, using @{ML
|
|
289 |
"ProofContext.init"} as required. Note that this re-initializes the
|
|
290 |
context data with each invocation.
|
|
291 |
|
|
292 |
\end{description}
|
|
293 |
*}
|
20437
|
294 |
|
20447
|
295 |
subsection {* Context data *}
|
|
296 |
|
|
297 |
text {*
|
20449
|
298 |
Both theory and proof contexts manage arbitrary data, which is the
|
|
299 |
main purpose of contexts in the first place. Data can be declared
|
|
300 |
incrementally at compile --- Isabelle/Pure and major object-logics
|
|
301 |
are bootstrapped that way.
|
|
302 |
|
|
303 |
\paragraph{Theory data} may refer to destructive entities, which are
|
|
304 |
maintained in correspondence to the linear evolution of theory
|
|
305 |
values, or explicit copies.\footnote{Most existing instances of
|
|
306 |
destructive theory data are merely historical relics (e.g.\ the
|
|
307 |
destructive theorem storage, and destructive hints for the
|
|
308 |
Simplifier and Classical rules).} A theory data declaration needs to
|
|
309 |
provide the following information:
|
|
310 |
|
|
311 |
\medskip
|
|
312 |
\begin{tabular}{ll}
|
|
313 |
@{text "name: string"} \\
|
|
314 |
@{text "T"} & the ML type \\
|
|
315 |
@{text "empty: T"} & initial value \\
|
|
316 |
@{text "copy: T \<rightarrow> T"} & refresh impure data \\
|
|
317 |
@{text "extend: T \<rightarrow> T"} & re-initialize on import \\
|
|
318 |
@{text "merge: T \<times> T \<rightarrow> T"} & join on import \\
|
|
319 |
@{text "print: T \<rightarrow> unit"} & diagnostic output \\
|
|
320 |
\end{tabular}
|
|
321 |
\medskip
|
|
322 |
|
|
323 |
\noindent The @{text "name"} acts as a comment for diagnostic
|
|
324 |
messages; @{text "copy"} is just the identity for pure data; @{text
|
|
325 |
"extend"} is acts like a unitary version of @{text "merge"}, both
|
|
326 |
should also include the functionality of @{text "copy"} for impure
|
|
327 |
data.
|
|
328 |
|
|
329 |
\paragraph{Proof context data} is purely functional. It is declared
|
|
330 |
by providing the following information:
|
|
331 |
|
|
332 |
\medskip
|
|
333 |
\begin{tabular}{ll}
|
|
334 |
@{text "name: string"} \\
|
|
335 |
@{text "T"} & the ML type \\
|
|
336 |
@{text "init: theory \<rightarrow> T"} & produce initial value \\
|
|
337 |
@{text "print: T \<rightarrow> unit"} & diagnostic output \\
|
|
338 |
\end{tabular}
|
|
339 |
\medskip
|
|
340 |
|
|
341 |
\noindent The @{text "init"} operation is supposed to produce a pure
|
|
342 |
value from the given background theory. The rest is analogous to
|
|
343 |
(pure) theory data.
|
|
344 |
|
|
345 |
\paragraph{Generic data} provides a hybrid interface for both kinds.
|
|
346 |
The declaration is essentially the same as for pure theory data,
|
|
347 |
without @{text "copy"} (it is always the identity). The @{text
|
|
348 |
"init"} operation for proof contexts selects the current data value
|
|
349 |
from the background theory.
|
|
350 |
|
|
351 |
\bigskip In any case, a data declaration of type @{text "T"} results
|
|
352 |
in the following interface:
|
|
353 |
|
|
354 |
\medskip
|
|
355 |
\begin{tabular}{ll}
|
|
356 |
@{text "init: theory \<rightarrow> theory"} \\
|
|
357 |
@{text "get: context \<rightarrow> T"} \\
|
|
358 |
@{text "put: T \<rightarrow> context \<rightarrow> context"} \\
|
|
359 |
@{text "map: (T \<rightarrow> T) \<rightarrow> context \<rightarrow> context"} \\
|
|
360 |
@{text "print: context \<rightarrow> unit"}
|
|
361 |
\end{tabular}
|
|
362 |
\medskip
|
|
363 |
|
|
364 |
\noindent Here @{text "init"} needs to be applied to the current
|
|
365 |
theory context once, in order to register the initial setup. The
|
|
366 |
other operations provide access for the particular kind of context
|
|
367 |
(theory, proof, or generic context). Note that this is a safe
|
|
368 |
interface: there is no other way to access the corresponding data
|
|
369 |
slot within a context. By keeping these operations private, a
|
|
370 |
component may maintain abstract values authentically, without other
|
|
371 |
components interfering.
|
20447
|
372 |
*}
|
|
373 |
|
|
374 |
|
20437
|
375 |
section {* Named entities *}
|
|
376 |
|
|
377 |
text {* Named entities of different kinds (logical constant, type,
|
|
378 |
type class, theorem, method etc.) live in separate name spaces. It is
|
|
379 |
usually clear from the occurrence of a name which kind of entity it
|
|
380 |
refers to. For example, proof method @{text "foo"} vs.\ theorem
|
|
381 |
@{text "foo"} vs.\ logical constant @{text "foo"} are easily
|
|
382 |
distinguished by means of the syntactic context. A notable exception
|
|
383 |
are logical identifiers within a term (\secref{sec:terms}): constants,
|
|
384 |
fixed variables, and bound variables all share the same identifier
|
|
385 |
syntax, but are distinguished by their scope.
|
|
386 |
|
|
387 |
Each name space is organized as a collection of \emph{qualified
|
|
388 |
names}, which consist of a sequence of basic name components separated
|
|
389 |
by dots: @{text "Bar.bar.foo"}, @{text "Bar.foo"}, and @{text "foo"}
|
|
390 |
are examples for valid qualified names. Name components are
|
|
391 |
subdivided into \emph{symbols}, which constitute the smallest textual
|
|
392 |
unit in Isabelle --- raw characters are normally not encountered
|
|
393 |
directly. *}
|
|
394 |
|
|
395 |
|
|
396 |
subsection {* Strings of symbols *}
|
|
397 |
|
|
398 |
text {* Isabelle strings consist of a sequence of
|
|
399 |
symbols\glossary{Symbol}{The smalles unit of text in Isabelle,
|
|
400 |
subsumes plain ASCII characters as well as an infinite collection of
|
|
401 |
named symbols (for greek, math etc.).}, which are either packed as an
|
|
402 |
actual @{text "string"}, or represented as a list. Each symbol is in
|
|
403 |
itself a small string of the following form:
|
|
404 |
|
|
405 |
\begin{enumerate}
|
|
406 |
|
|
407 |
\item either a singleton ASCII character ``@{text "c"}'' (with
|
|
408 |
character code 0--127), for example ``\verb,a,'',
|
|
409 |
|
|
410 |
\item or a regular symbol ``\verb,\,\verb,<,@{text "ident"}\verb,>,'',
|
|
411 |
for example ``\verb,\,\verb,<alpha>,'',
|
|
412 |
|
|
413 |
\item or a control symbol ``\verb,\,\verb,<^,@{text
|
|
414 |
"ident"}\verb,>,'', for example ``\verb,\,\verb,<^bold>,'',
|
|
415 |
|
|
416 |
\item or a raw control symbol ``\verb,\,\verb,<^raw:,@{text
|
|
417 |
"\<dots>"}\verb,>,'' where ``@{text "\<dots>"}'' refers to any
|
|
418 |
printable ASCII character (excluding ``\verb,.,'' and ``\verb,>,'') or
|
|
419 |
non-ASCII character, for example ``\verb,\,\verb,<^raw:$\sum_{i = 1}^n$>,'',
|
|
420 |
|
|
421 |
\item or a numbered raw control symbol ``\verb,\,\verb,<^raw,@{text
|
|
422 |
"nnn"}\verb,>, where @{text "nnn"} are digits, for example
|
|
423 |
``\verb,\,\verb,<^raw42>,''.
|
|
424 |
|
|
425 |
\end{enumerate}
|
|
426 |
|
|
427 |
The @{text "ident"} syntax for symbol names is @{text "letter (letter
|
|
428 |
| digit)\<^sup>*"}, where @{text "letter = A..Za..Z"} and @{text
|
|
429 |
"digit = 0..9"}. There are infinitely many regular symbols and
|
|
430 |
control symbols available, but a certain collection of standard
|
|
431 |
symbols is treated specifically. For example,
|
|
432 |
``\verb,\,\verb,<alpha>,'' is classified as a (non-ASCII) letter,
|
|
433 |
which means it may occur within regular Isabelle identifier syntax.
|
|
434 |
|
|
435 |
Output of symbols depends on the print mode (\secref{sec:print-mode}).
|
|
436 |
For example, the standard {\LaTeX} setup of the Isabelle document
|
|
437 |
preparation system would present ``\verb,\,\verb,<alpha>,'' as @{text
|
|
438 |
"\<alpha>"}, and ``\verb,\,\verb,<^bold>,\verb,\,\verb,<alpha>,'' as @{text
|
|
439 |
"\<^bold>\<alpha>"}.
|
|
440 |
|
|
441 |
\medskip It is important to note that the character set underlying
|
|
442 |
Isabelle symbols is plain 7-bit ASCII. Since 8-bit characters are
|
|
443 |
passed through transparently, Isabelle may easily process actual
|
|
444 |
Unicode/UCS data (using the well-known UTF-8 encoding, for example).
|
|
445 |
Unicode provides its own collection of mathematical symbols, but there
|
|
446 |
is presently no link to Isabelle's named ones; both kinds of symbols
|
|
447 |
coexist independently. *}
|
|
448 |
|
|
449 |
text %mlref {*
|
|
450 |
\begin{mldecls}
|
|
451 |
@{index_ML_type "Symbol.symbol"} \\
|
|
452 |
@{index_ML Symbol.explode: "string -> Symbol.symbol list"} \\
|
|
453 |
@{index_ML Symbol.is_letter: "Symbol.symbol -> bool"} \\
|
|
454 |
@{index_ML Symbol.is_digit: "Symbol.symbol -> bool"} \\
|
|
455 |
@{index_ML Symbol.is_quasi: "Symbol.symbol -> bool"} \\
|
|
456 |
@{index_ML Symbol.is_blank: "Symbol.symbol -> bool"} \\
|
|
457 |
@{index_ML_type "Symbol.sym"} \\
|
|
458 |
@{index_ML Symbol.decode: "Symbol.symbol -> Symbol.sym"} \\
|
|
459 |
\end{mldecls}
|
|
460 |
|
|
461 |
\begin{description}
|
|
462 |
|
|
463 |
\item @{ML_type "Symbol.symbol"} represents Isabelle symbols; this type
|
|
464 |
is merely an alias for @{ML_type "string"}, but emphasizes the
|
|
465 |
specific format encountered here.
|
|
466 |
|
20447
|
467 |
\item @{ML "Symbol.explode"}~@{text "s"} produces a symbol list from
|
|
468 |
the packed form usually encountered as user input. This function
|
|
469 |
replaces @{ML "String.explode"} for virtually all purposes of
|
|
470 |
manipulating text in Isabelle! Plain @{ML "implode"} may be used
|
|
471 |
for the reverse operation.
|
20437
|
472 |
|
|
473 |
\item @{ML "Symbol.is_letter"}, @{ML "Symbol.is_digit"}, @{ML
|
|
474 |
"Symbol.is_quasi"}, @{ML "Symbol.is_blank"} classify certain symbols
|
|
475 |
(both ASCII and several named ones) according to fixed syntactic
|
|
476 |
convections of Isabelle, e.g.\ see \cite{isabelle-isar-ref}.
|
|
477 |
|
|
478 |
\item @{ML_type "Symbol.sym"} is a concrete datatype that represents
|
|
479 |
the different kinds of symbols explicitly as @{ML "Symbol.Char"},
|
|
480 |
@{ML "Symbol.Sym"}, @{ML "Symbol.Ctrl"}, or @{ML "Symbol.Raw"}.
|
|
481 |
|
|
482 |
\item @{ML "Symbol.decode"} converts the string representation of a
|
|
483 |
symbol into the explicit datatype version.
|
|
484 |
|
|
485 |
\end{description}
|
|
486 |
*}
|
|
487 |
|
|
488 |
|
|
489 |
subsection {* Qualified names and name spaces *}
|
|
490 |
|
|
491 |
text %FIXME {* Qualified names are constructed according to implicit naming
|
|
492 |
principles of the present context.
|
|
493 |
|
|
494 |
|
|
495 |
The last component is called \emph{base name}; the remaining prefix of
|
|
496 |
qualification may be empty.
|
|
497 |
|
|
498 |
Some practical conventions help to organize named entities more
|
|
499 |
systematically:
|
|
500 |
|
|
501 |
\begin{itemize}
|
|
502 |
|
|
503 |
\item Names are qualified first by the theory name, second by an
|
|
504 |
optional ``structure''. For example, a constant @{text "c"} declared
|
|
505 |
as part of a certain structure @{text "b"} (say a type definition) in
|
|
506 |
theory @{text "A"} will be named @{text "A.b.c"} internally.
|
|
507 |
|
|
508 |
\item
|
|
509 |
|
|
510 |
\item
|
|
511 |
|
|
512 |
\item
|
|
513 |
|
|
514 |
\item
|
|
515 |
|
|
516 |
\end{itemize}
|
|
517 |
|
|
518 |
Names of different kinds of entities are basically independent, but
|
|
519 |
some practical naming conventions relate them to each other. For
|
|
520 |
example, a constant @{text "foo"} may be accompanied with theorems
|
|
521 |
@{text "foo.intro"}, @{text "foo.elim"}, @{text "foo.simps"} etc. The
|
|
522 |
same may happen for a type @{text "foo"}, which is then apt to cause
|
|
523 |
clashes in the theorem name space! To avoid this, we occasionally
|
|
524 |
follow an additional convention of suffixes that determine the
|
|
525 |
original kind of entity that a name has been derived. For example,
|
|
526 |
constant @{text "foo"} is associated with theorem @{text "foo.intro"},
|
|
527 |
type @{text "foo"} with theorem @{text "foo_type.intro"}, and type
|
|
528 |
class @{text "foo"} with @{text "foo_class.intro"}.
|
|
529 |
|
|
530 |
*}
|
|
531 |
|
|
532 |
|
|
533 |
section {* Structured output *}
|
|
534 |
|
|
535 |
subsection {* Pretty printing *}
|
|
536 |
|
|
537 |
text FIXME
|
|
538 |
|
|
539 |
subsection {* Output channels *}
|
|
540 |
|
|
541 |
text FIXME
|
|
542 |
|
|
543 |
subsection {* Print modes *}
|
|
544 |
|
|
545 |
text FIXME
|
|
546 |
|
|
547 |
|
18537
|
548 |
end
|