18537
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
|
3 |
\def\isabellecontext{prelim}%
|
|
4 |
%
|
|
5 |
\isadelimtheory
|
|
6 |
\isanewline
|
|
7 |
\isanewline
|
|
8 |
\isanewline
|
|
9 |
%
|
|
10 |
\endisadelimtheory
|
|
11 |
%
|
|
12 |
\isatagtheory
|
|
13 |
\isacommand{theory}\isamarkupfalse%
|
|
14 |
\ prelim\ \isakeyword{imports}\ base\ \isakeyword{begin}%
|
|
15 |
\endisatagtheory
|
|
16 |
{\isafoldtheory}%
|
|
17 |
%
|
|
18 |
\isadelimtheory
|
|
19 |
%
|
|
20 |
\endisadelimtheory
|
|
21 |
%
|
|
22 |
\isamarkupchapter{Preliminaries%
|
|
23 |
}
|
|
24 |
\isamarkuptrue%
|
|
25 |
%
|
|
26 |
\isamarkupsection{Named entities%
|
|
27 |
}
|
|
28 |
\isamarkuptrue%
|
|
29 |
%
|
|
30 |
\begin{isamarkuptext}%
|
|
31 |
Named entities of different kinds (logical constant, type,
|
|
32 |
type class, theorem, method etc.) live in separate name spaces. It is
|
|
33 |
usually clear from the occurrence of a name which kind of entity it
|
|
34 |
refers to. For example, proof method \isa{foo} vs.\ theorem
|
|
35 |
\isa{foo} vs.\ logical constant \isa{foo} are easily
|
|
36 |
distinguished by means of the syntactic context. A notable exception
|
|
37 |
are logical identifiers within a term (\secref{sec:terms}): constants,
|
|
38 |
fixed variables, and bound variables all share the same identifier
|
|
39 |
syntax, but are distinguished by their scope.
|
|
40 |
|
|
41 |
Each name space is organized as a collection of \emph{qualified
|
|
42 |
names}, which consist of a sequence of basic name components separated
|
|
43 |
by dots: \isa{Bar{\isachardot}bar{\isachardot}foo}, \isa{Bar{\isachardot}foo}, and \isa{foo}
|
|
44 |
are examples for valid qualified names. Name components are
|
|
45 |
subdivided into \emph{symbols}, which constitute the smallest textual
|
|
46 |
unit in Isabelle --- raw characters are normally not encountered
|
|
47 |
directly.%
|
|
48 |
\end{isamarkuptext}%
|
|
49 |
\isamarkuptrue%
|
|
50 |
%
|
|
51 |
\isamarkupsubsection{Strings of symbols%
|
|
52 |
}
|
|
53 |
\isamarkuptrue%
|
|
54 |
%
|
|
55 |
\begin{isamarkuptext}%
|
|
56 |
Isabelle strings consist of a sequence of
|
|
57 |
symbols\glossary{Symbol}{The smalles unit of text in Isabelle,
|
|
58 |
subsumes plain ASCII characters as well as an infinite collection of
|
|
59 |
named symbols (for greek, math etc.).}, which are either packed as an
|
|
60 |
actual \isa{string}, or represented as a list. Each symbol is in
|
|
61 |
itself a small string of the following form:
|
|
62 |
|
|
63 |
\begin{enumerate}
|
|
64 |
|
|
65 |
\item either a singleton ASCII character ``\isa{c}'' (with
|
|
66 |
character code 0--127), for example ``\verb,a,'',
|
|
67 |
|
|
68 |
\item or a regular symbol ``\verb,\,\verb,<,\isa{ident}\verb,>,'',
|
|
69 |
for example ``\verb,\,\verb,<alpha>,'',
|
|
70 |
|
|
71 |
\item or a control symbol ``\verb,\,\verb,<^,\isa{ident}\verb,>,'', for example ``\verb,\,\verb,<^bold>,'',
|
|
72 |
|
|
73 |
\item or a raw control symbol ``\verb,\,\verb,<^raw:,\isa{{\isasymdots}}\verb,>,'' where ``\isa{{\isasymdots}}'' refers to any printable ASCII
|
|
74 |
character (excluding ``\verb,>,'') or non-ASCII character, for example
|
|
75 |
``\verb,\,\verb,<^raw:$\sum_{i = 1}^n$>,'',
|
|
76 |
|
|
77 |
\item or a numbered raw control symbol ``\verb,\,\verb,<^raw,\isa{nnn}\verb,>, where \isa{nnn} are digits, for example
|
|
78 |
``\verb,\,\verb,<^raw42>,''.
|
|
79 |
|
|
80 |
\end{enumerate}
|
|
81 |
|
|
82 |
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 regular symbols and
|
|
83 |
control symbols available, but a certain collection of standard
|
|
84 |
symbols is treated specifically. For example,
|
|
85 |
``\verb,\,\verb,<alpha>,'' is classified as a (non-ASCII) letter,
|
|
86 |
which means it may occur within regular Isabelle identifier syntax.
|
|
87 |
|
|
88 |
Output of symbols depends on the print mode (\secref{sec:print-mode}).
|
|
89 |
For example, the standard {\LaTeX} setup of the Isabelle document
|
|
90 |
preparation system would present ``\verb,\,\verb,<alpha>,'' as \isa{{\isasymalpha}}, and ``\verb,\,\verb,<^bold>,\verb,\,\verb,<alpha>,'' as \isa{\isactrlbold {\isasymalpha}}.
|
|
91 |
|
|
92 |
\medskip It is important to note that the character set underlying
|
|
93 |
Isabelle symbols is plain 7-bit ASCII. Since 8-bit characters are
|
|
94 |
passed through transparently, Isabelle may easily process actual
|
|
95 |
Unicode/UCS data (using the well-known UTF-8 encoding, for example).
|
|
96 |
Unicode provides its own collection of mathematical symbols, but there
|
|
97 |
is presently no link to Isabelle's named ones; both kinds of symbols
|
|
98 |
coexist independently.%
|
|
99 |
\end{isamarkuptext}%
|
|
100 |
\isamarkuptrue%
|
|
101 |
%
|
|
102 |
\isadelimmlref
|
|
103 |
%
|
|
104 |
\endisadelimmlref
|
|
105 |
%
|
|
106 |
\isatagmlref
|
|
107 |
%
|
|
108 |
\begin{isamarkuptext}%
|
|
109 |
\begin{mldecls}
|
|
110 |
\indexmltype{Symbol.symbol}\verb|type Symbol.symbol| \\
|
|
111 |
\indexml{Symbol.explode}\verb|Symbol.explode: string -> Symbol.symbol list| \\
|
|
112 |
\indexml{Symbol.is-letter}\verb|Symbol.is_letter: Symbol.symbol -> bool| \\
|
|
113 |
\indexml{Symbol.is-digit}\verb|Symbol.is_digit: Symbol.symbol -> bool| \\
|
|
114 |
\indexml{Symbol.is-quasi}\verb|Symbol.is_quasi: Symbol.symbol -> bool| \\
|
|
115 |
\indexml{Symbol.is-blank}\verb|Symbol.is_blank: Symbol.symbol -> bool| \\
|
|
116 |
\indexmltype{Symbol.sym}\verb|type Symbol.sym| \\
|
|
117 |
\indexml{Symbol.decode}\verb|Symbol.decode: Symbol.symbol -> Symbol.sym| \\
|
|
118 |
\end{mldecls}
|
|
119 |
|
|
120 |
\begin{description}
|
|
121 |
|
|
122 |
\item \verb|Symbol.symbol| represents Isabelle symbols; this type
|
|
123 |
is merely an alias for \verb|string|, but emphasizes the
|
|
124 |
specific format encountered here.
|
|
125 |
|
|
126 |
\item \verb|Symbol.explode|~\isa{s} produces an actual symbol
|
|
127 |
list from the packed form usually encountered as user input. This
|
|
128 |
function replaces \verb|String.explode| for virtually all purposes
|
|
129 |
of manipulating text in Isabelle! Plain \isa{implode} may be
|
|
130 |
used for the reverse operation.
|
|
131 |
|
|
132 |
\item \verb|Symbol.is_letter|, \verb|Symbol.is_digit|, \verb|Symbol.is_quasi|, \verb|Symbol.is_blank| classify certain symbols
|
|
133 |
(both ASCII and several named ones) according to fixed syntactic
|
|
134 |
convections of Isabelle, e.g.\ see \cite{isabelle-isar-ref}.
|
|
135 |
|
|
136 |
\item \verb|Symbol.sym| is a concrete datatype that represents
|
|
137 |
the different kinds of symbols explicitly as \verb|Symbol.Char|,
|
|
138 |
\verb|Symbol.Sym|, \verb|Symbol.Ctrl|, or \verb|Symbol.Raw|.
|
|
139 |
|
|
140 |
\item \verb|Symbol.decode| converts the string representation of a
|
|
141 |
symbol into the explicit datatype version.
|
|
142 |
|
|
143 |
\end{description}%
|
|
144 |
\end{isamarkuptext}%
|
|
145 |
\isamarkuptrue%
|
|
146 |
%
|
|
147 |
\endisatagmlref
|
|
148 |
{\isafoldmlref}%
|
|
149 |
%
|
|
150 |
\isadelimmlref
|
|
151 |
%
|
|
152 |
\endisadelimmlref
|
|
153 |
%
|
|
154 |
\isamarkupsubsection{Qualified names and name spaces%
|
|
155 |
}
|
|
156 |
\isamarkuptrue%
|
|
157 |
%
|
|
158 |
\isadelimFIXME
|
|
159 |
%
|
|
160 |
\endisadelimFIXME
|
|
161 |
%
|
|
162 |
\isatagFIXME
|
|
163 |
%
|
|
164 |
\begin{isamarkuptext}%
|
|
165 |
Qualified names are constructed according to implicit naming
|
|
166 |
principles of the present context.
|
|
167 |
|
|
168 |
|
|
169 |
The last component is called \emph{base name}; the remaining prefix of
|
|
170 |
qualification may be empty.
|
|
171 |
|
|
172 |
Some practical conventions help to organize named entities more
|
|
173 |
systematically:
|
|
174 |
|
|
175 |
\begin{itemize}
|
|
176 |
|
|
177 |
\item Names are qualified first by the theory name, second by an
|
|
178 |
optional ``structure''. For example, a constant \isa{c} declared
|
|
179 |
as part of a certain structure \isa{b} (say a type definition) in
|
|
180 |
theory \isa{A} will be named \isa{A{\isachardot}b{\isachardot}c} internally.
|
|
181 |
|
|
182 |
\item
|
|
183 |
|
|
184 |
\item
|
|
185 |
|
|
186 |
\item
|
|
187 |
|
|
188 |
\item
|
|
189 |
|
|
190 |
\end{itemize}
|
|
191 |
|
|
192 |
Names of different kinds of entities are basically independent, but
|
|
193 |
some practical naming conventions relate them to each other. For
|
|
194 |
example, a constant \isa{foo} may be accompanied with theorems
|
|
195 |
\isa{foo{\isachardot}intro}, \isa{foo{\isachardot}elim}, \isa{foo{\isachardot}simps} etc. The
|
|
196 |
same may happen for a type \isa{foo}, which is then apt to cause
|
|
197 |
clashes in the theorem name space! To avoid this, we occasionally
|
|
198 |
follow an additional convention of suffixes that determine the
|
|
199 |
original kind of entity that a name has been derived. For example,
|
|
200 |
constant \isa{foo} is associated with theorem \isa{foo{\isachardot}intro},
|
|
201 |
type \isa{foo} with theorem \isa{foo{\isacharunderscore}type{\isachardot}intro}, and type
|
|
202 |
class \isa{foo} with \isa{foo{\isacharunderscore}class{\isachardot}intro}.%
|
|
203 |
\end{isamarkuptext}%
|
|
204 |
\isamarkuptrue%
|
|
205 |
%
|
|
206 |
\endisatagFIXME
|
|
207 |
{\isafoldFIXME}%
|
|
208 |
%
|
|
209 |
\isadelimFIXME
|
|
210 |
%
|
|
211 |
\endisadelimFIXME
|
|
212 |
%
|
|
213 |
\isamarkupsection{Structured output%
|
|
214 |
}
|
|
215 |
\isamarkuptrue%
|
|
216 |
%
|
|
217 |
\isamarkupsubsection{Pretty printing%
|
|
218 |
}
|
|
219 |
\isamarkuptrue%
|
|
220 |
%
|
|
221 |
\begin{isamarkuptext}%
|
|
222 |
FIXME%
|
|
223 |
\end{isamarkuptext}%
|
|
224 |
\isamarkuptrue%
|
|
225 |
%
|
|
226 |
\isamarkupsubsection{Output channels%
|
|
227 |
}
|
|
228 |
\isamarkuptrue%
|
|
229 |
%
|
|
230 |
\begin{isamarkuptext}%
|
|
231 |
FIXME%
|
|
232 |
\end{isamarkuptext}%
|
|
233 |
\isamarkuptrue%
|
|
234 |
%
|
|
235 |
\isamarkupsubsection{Print modes%
|
|
236 |
}
|
|
237 |
\isamarkuptrue%
|
|
238 |
%
|
|
239 |
\begin{isamarkuptext}%
|
|
240 |
FIXME%
|
|
241 |
\end{isamarkuptext}%
|
|
242 |
\isamarkuptrue%
|
|
243 |
%
|
|
244 |
\isamarkupsection{Context \label{sec:context}%
|
|
245 |
}
|
|
246 |
\isamarkuptrue%
|
|
247 |
%
|
|
248 |
\isadelimFIXME
|
|
249 |
%
|
|
250 |
\endisadelimFIXME
|
|
251 |
%
|
|
252 |
\isatagFIXME
|
|
253 |
%
|
|
254 |
\begin{isamarkuptext}%
|
|
255 |
What is a context anyway? A highly advanced
|
|
256 |
technological and cultural achievement, which took humanity several
|
|
257 |
thousands of years to be develop, is writing with pen-and-paper. Here
|
|
258 |
the paper is the context, or medium. It accommodates a certain range
|
|
259 |
of different kinds of pens, but also has some inherent limitations.
|
|
260 |
For example, carved inscriptions are better done on solid material
|
|
261 |
like wood or stone.
|
|
262 |
|
|
263 |
Isabelle/Isar distinguishes two key notions of context: \emph{theory
|
18554
|
264 |
context} and \emph{proof context}. To motivate this fundamental
|
|
265 |
division consider the very idea of logical reasoning which is about
|
|
266 |
judgments $\Gamma \Drv{\Theta} \phi$, where $\Theta$ is the background
|
|
267 |
theory with declarations of operators and axioms stating their
|
|
268 |
properties, and $\Gamma$ a collection of hypotheses emerging
|
|
269 |
temporarily during proof. For example, the rule of
|
|
270 |
implication-introduction \[ \infer{\Gamma \Drv{\Theta} A \Imp
|
|
271 |
B}{\Gamma, A \Drv{\Theta} B} \] can be read as ``to show $A \Imp B$ we
|
|
272 |
may assume $A$ as hypothesis and need to show $B$''. It is
|
|
273 |
characteristic that $\Theta$ is unchanged and $\Gamma$ is only
|
|
274 |
modified according to some general patterns of ``assuming'' and
|
|
275 |
``discharging'' hypotheses. This admits the following abbreviated
|
|
276 |
notation, where the fixed $\Theta$ and locally changed $\Gamma$ are
|
|
277 |
left implicit: \[ \infer{A \Imp B}{\infer*{B}{[A]}} \]
|
18537
|
278 |
|
|
279 |
In some logical traditions (e.g.\ Type Theory) there is a tendency to
|
|
280 |
unify all kinds of declarations within a single notion of context.
|
|
281 |
This is theoretically very nice, but also more demanding, because
|
|
282 |
everything is internalized into the logical calculus itself.
|
|
283 |
Isabelle/Pure is a very simple logic, but achieves many practically
|
|
284 |
useful concepts by differentiating various basic elements.
|
|
285 |
|
|
286 |
Take polymorphism, for example. Instead of embarking on the
|
|
287 |
adventurous enterprise of full higher-order logic with full
|
|
288 |
type-quantification and polymorphic entities, Isabelle/Pure merely
|
|
289 |
takes a stripped-down version of Church's Simple Type Theory
|
|
290 |
\cite{church40}. Then after the tradition of Gordon's HOL
|
|
291 |
\cite{mgordon-hol} it is fairly easy to introduce syntactic notions of
|
|
292 |
type variables and type-constructors, and require every theory
|
|
293 |
$\Theta$ being closed by type instantiation. Whenever we wish to
|
|
294 |
reason with a polymorphic constant or axiom scheme at a particular
|
|
295 |
type, we may assume that it has been referenced initially at that very
|
|
296 |
instance (due to the Deduction Theorem). Thus we achieve the
|
|
297 |
following \emph{admissible
|
|
298 |
rule}\glossary{Admissible rule}{FIXME} of schematic type-instantiation:
|
|
299 |
|
|
300 |
\[
|
|
301 |
\infer{\phi(\tau)}{\infer*{\phi(\alpha)}{[\alpha]}}
|
|
302 |
\]
|
|
303 |
|
|
304 |
Using this approach, the structured Isar proof language offers
|
|
305 |
schematic polymorphism within nested sub-proofs -- similar to that of
|
|
306 |
polymorphic let-bindings according to Hindley-Milner.\
|
|
307 |
\cite{milner78}. All of this is achieved without disintegrating the
|
|
308 |
rather simplistic logical core. On the other hand, the succinct rule
|
|
309 |
presented above already involves rather delicate interaction of the
|
|
310 |
theory and proof context (with side-conditions not mentioned here),
|
|
311 |
and unwinding an admissible rule involves induction over derivations.
|
|
312 |
All of this diversity needs to be accomodated by the system
|
|
313 |
architecture and actual implementation.
|
|
314 |
|
|
315 |
\medskip Despite these important observations, Isabelle/Isar is not just a
|
|
316 |
logical calculus, there are further extra-logical aspects to be considered.
|
|
317 |
Practical experience over the years suggests two context data structures which
|
|
318 |
are used in rather dissimilar manners, even though there is a considerable
|
|
319 |
overlap of underlying ideas.
|
|
320 |
|
|
321 |
From the system's perspective the mode of use of theory vs.\ proof context is
|
|
322 |
the key distinction. The actual content is merely a generic slot for
|
|
323 |
\emph{theory data} and \emph{proof data}, respectively. There are generic
|
|
324 |
interfaces to declare data entries at any time. Even the core logic of
|
|
325 |
Isabelle/Pure registers its very own notion of theory context data (types,
|
|
326 |
constants, axioms etc.) like any other Isabelle tool out there. Likewise, the
|
|
327 |
essentials of Isar proof contexts are one proof data slot among many others,
|
|
328 |
notably those of derived Isar concepts (e.g.\ calculational reasoning rules).
|
|
329 |
|
|
330 |
In that respect, a theory is more like a stone tablet to carve long-lasting
|
|
331 |
inscriptions -- but take care not to break it! While a proof context is like
|
|
332 |
a block of paper to scribble and dispose quickly. More recently Isabelle has
|
|
333 |
started to cultivate the paper-based craftsmanship a bit further, by
|
|
334 |
maintaining small collections of paper booklets, better known as locales.
|
|
335 |
|
|
336 |
Thus we achive ``thick'' augmented versions of {\boldmath$\Theta$} and
|
|
337 |
{\boldmath$\Gamma$} to support realistic structured reasoning within a
|
|
338 |
practically usable system.%
|
|
339 |
\end{isamarkuptext}%
|
|
340 |
\isamarkuptrue%
|
|
341 |
%
|
|
342 |
\endisatagFIXME
|
|
343 |
{\isafoldFIXME}%
|
|
344 |
%
|
|
345 |
\isadelimFIXME
|
|
346 |
%
|
|
347 |
\endisadelimFIXME
|
|
348 |
%
|
|
349 |
\isamarkupsubsection{Theory context \label{sec:context-theory}%
|
|
350 |
}
|
|
351 |
\isamarkuptrue%
|
|
352 |
%
|
|
353 |
\isadelimFIXME
|
|
354 |
%
|
|
355 |
\endisadelimFIXME
|
|
356 |
%
|
|
357 |
\isatagFIXME
|
|
358 |
%
|
|
359 |
\begin{isamarkuptext}%
|
|
360 |
A theory context consists of management information plus the
|
|
361 |
actual data, which may be declared by other software modules later on.
|
|
362 |
The management part is surprisingly complex, we illustrate it by the
|
|
363 |
following typical situation of incremental theory development.
|
|
364 |
|
|
365 |
\begin{tabular}{rcccl}
|
|
366 |
& & $Pure$ \\
|
|
367 |
& & $\downarrow$ \\
|
|
368 |
& & $FOL$ \\
|
|
369 |
& $\swarrow$ & & $\searrow$ & \\
|
|
370 |
$Nat$ & & & & $List$ \\
|
|
371 |
& $\searrow$ & & $\swarrow$ \\
|
|
372 |
& & $Length$ \\
|
|
373 |
& & \multicolumn{3}{l}{~~$\isarkeyword{imports}$} \\
|
|
374 |
& & \multicolumn{3}{l}{~~$\isarkeyword{begin}$} \\
|
|
375 |
& & $\vdots$~~ \\
|
|
376 |
& & $\bullet$~~ \\
|
|
377 |
& & $\vdots$~~ \\
|
|
378 |
& & $\bullet$~~ \\
|
|
379 |
& & $\vdots$~~ \\
|
|
380 |
& & \multicolumn{3}{l}{~~$\isarkeyword{end}$} \\
|
|
381 |
\end{tabular}
|
|
382 |
|
|
383 |
\begin{itemize}
|
|
384 |
\item \emph{name}, \emph{parents} and \emph{ancestors}
|
|
385 |
\item \emph{identity}
|
|
386 |
\item \emph{intermediate versions}
|
|
387 |
\end{itemize}
|
|
388 |
|
|
389 |
\begin{description}
|
|
390 |
\item [draft]
|
|
391 |
\item [intermediate]
|
|
392 |
\item [finished]
|
|
393 |
\end{description}
|
|
394 |
|
|
395 |
\emph{theory reference}%
|
|
396 |
\end{isamarkuptext}%
|
|
397 |
\isamarkuptrue%
|
|
398 |
%
|
|
399 |
\endisatagFIXME
|
|
400 |
{\isafoldFIXME}%
|
|
401 |
%
|
|
402 |
\isadelimFIXME
|
|
403 |
%
|
|
404 |
\endisadelimFIXME
|
|
405 |
%
|
|
406 |
\isamarkupsubsection{Proof context \label{sec:context-proof}%
|
|
407 |
}
|
|
408 |
\isamarkuptrue%
|
|
409 |
%
|
|
410 |
\begin{isamarkuptext}%
|
|
411 |
FIXME
|
|
412 |
|
|
413 |
\glossary{Proof context}{The static context of a structured proof,
|
|
414 |
acts like a local ``theory'' of the current portion of Isar proof
|
|
415 |
text, generalizes the idea of local hypotheses \isa{{\isasymGamma}} in
|
|
416 |
judgments \isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymphi}} of natural deduction calculi. There is a
|
|
417 |
generic notion of introducing and discharging hypotheses. Arbritrary
|
|
418 |
auxiliary context data may be adjoined.}%
|
|
419 |
\end{isamarkuptext}%
|
|
420 |
\isamarkuptrue%
|
|
421 |
%
|
|
422 |
\isadelimtheory
|
|
423 |
%
|
|
424 |
\endisadelimtheory
|
|
425 |
%
|
|
426 |
\isatagtheory
|
|
427 |
\isacommand{end}\isamarkupfalse%
|
|
428 |
%
|
|
429 |
\endisatagtheory
|
|
430 |
{\isafoldtheory}%
|
|
431 |
%
|
|
432 |
\isadelimtheory
|
|
433 |
%
|
|
434 |
\endisadelimtheory
|
|
435 |
\isanewline
|
|
436 |
\end{isabellebody}%
|
|
437 |
%%% Local Variables:
|
|
438 |
%%% mode: latex
|
|
439 |
%%% TeX-master: "root"
|
|
440 |
%%% End:
|