author | paulson |
Tue, 10 Feb 2004 12:17:04 +0100 | |
changeset 14379 | ea10a8c3e9cf |
parent 14353 | 79f9fbef9106 |
child 14486 | 74c053a25513 |
permissions | -rw-r--r-- |
11648 | 1 |
% |
2 |
\begin{isabellebody}% |
|
3 |
\def\isabellecontext{Documents}% |
|
11866 | 4 |
\isamarkupfalse% |
12627 | 5 |
% |
12647 | 6 |
\isamarkupsection{Concrete Syntax \label{sec:concrete-syntax}% |
12627 | 7 |
} |
8 |
\isamarkuptrue% |
|
9 |
% |
|
10 |
\begin{isamarkuptext}% |
|
12767 | 11 |
The core concept of Isabelle's framework for concrete syntax is that |
12 |
of \bfindex{mixfix annotations}. Associated with any kind of |
|
13 |
constant declaration, mixfixes affect both the grammar productions |
|
14 |
for the parser and output templates for the pretty printer. |
|
12627 | 15 |
|
12743 | 16 |
In full generality, parser and pretty printer configuration is a |
12767 | 17 |
subtle affair \cite{isabelle-ref}. Your syntax specifications need |
18 |
to interact properly with the existing setup of Isabelle/Pure and |
|
19 |
Isabelle/HOL\@. To avoid creating ambiguities with existing |
|
20 |
elements, it is particularly important to give new syntactic |
|
12764 | 21 |
constructs the right precedence. |
12627 | 22 |
|
12671 | 23 |
\medskip Subsequently we introduce a few simple syntax declaration |
12743 | 24 |
forms that already cover many common situations fairly well.% |
12627 | 25 |
\end{isamarkuptext}% |
26 |
\isamarkuptrue% |
|
27 |
% |
|
12647 | 28 |
\isamarkupsubsection{Infix Annotations% |
12627 | 29 |
} |
30 |
\isamarkuptrue% |
|
31 |
% |
|
32 |
\begin{isamarkuptext}% |
|
12764 | 33 |
Syntax annotations may be included wherever constants are declared, |
12767 | 34 |
such as \isacommand{consts} and \isacommand{constdefs} --- and also |
35 |
\isacommand{datatype}, which declares constructor operations. |
|
36 |
Type-constructors may be annotated as well, although this is less |
|
37 |
frequently encountered in practice (the infix type \isa{{\isasymtimes}} comes |
|
38 |
to mind). |
|
12627 | 39 |
|
12644 | 40 |
Infix declarations\index{infix annotations} provide a useful special |
12767 | 41 |
case of mixfixes. The following example of the exclusive-or |
42 |
operation on boolean values illustrates typical infix declarations.% |
|
12627 | 43 |
\end{isamarkuptext}% |
44 |
\isamarkuptrue% |
|
45 |
\isacommand{constdefs}\isanewline |
|
46 |
\ \ xor\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}bool\ {\isasymRightarrow}\ bool\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isacharbrackleft}{\isacharplus}{\isacharbrackright}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isanewline |
|
47 |
\ \ {\isachardoublequote}A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B\ {\isasymequiv}\ {\isacharparenleft}A\ {\isasymand}\ {\isasymnot}\ B{\isacharparenright}\ {\isasymor}\ {\isacharparenleft}{\isasymnot}\ A\ {\isasymand}\ B{\isacharparenright}{\isachardoublequote}\isamarkupfalse% |
|
48 |
% |
|
49 |
\begin{isamarkuptext}% |
|
12652 | 50 |
\noindent Now \isa{xor\ A\ B} and \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B} refer to the |
51 |
same expression internally. Any curried function with at least two |
|
12767 | 52 |
arguments may be given infix syntax. For partial applications with |
53 |
fewer than two operands, there is a notation using the prefix~\isa{op}. For instance, \isa{xor} without arguments is represented as |
|
54 |
\isa{op\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}}; together with ordinary function application, this |
|
12652 | 55 |
turns \isa{xor\ A} into \isa{op\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ A}. |
12627 | 56 |
|
12747 | 57 |
\medskip The keyword \isakeyword{infixl} seen above specifies an |
58 |
infix operator that is nested to the \emph{left}: in iterated |
|
59 |
applications the more complex expression appears on the left-hand |
|
12767 | 60 |
side, and \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C} stands for \isa{{\isacharparenleft}A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B{\isacharparenright}\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C}. Similarly, \isakeyword{infixr} means nesting to the |
61 |
\emph{right}, reading \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C} as \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ {\isacharparenleft}B\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C{\isacharparenright}}. A \emph{non-oriented} declaration via \isakeyword{infix} |
|
62 |
would render \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C} illegal, but demand explicit |
|
63 |
parentheses to indicate the intended grouping. |
|
12743 | 64 |
|
12747 | 65 |
The string \isa{{\isachardoublequote}{\isacharbrackleft}{\isacharplus}{\isacharbrackright}{\isachardoublequote}} in our annotation refers to the |
66 |
concrete syntax to represent the operator (a literal token), while |
|
12764 | 67 |
the number \isa{{\isadigit{6}}{\isadigit{0}}} determines the precedence of the construct: |
12767 | 68 |
the syntactic priorities of the arguments and result. Isabelle/HOL |
69 |
already uses up many popular combinations of ASCII symbols for its |
|
70 |
own use, including both \isa{{\isacharplus}} and \isa{{\isacharplus}{\isacharplus}}. Longer |
|
71 |
character combinations are more likely to be still available for |
|
72 |
user extensions, such as our~\isa{{\isacharbrackleft}{\isacharplus}{\isacharbrackright}}. |
|
12627 | 73 |
|
12767 | 74 |
Operator precedences have a range of 0--1000. Very low or high |
75 |
priorities are reserved for the meta-logic. HOL syntax mainly uses |
|
76 |
the range of 10--100: the equality infix \isa{{\isacharequal}} is centered at |
|
77 |
50; logical connectives (like \isa{{\isasymor}} and \isa{{\isasymand}}) are |
|
78 |
below 50; algebraic ones (like \isa{{\isacharplus}} and \isa{{\isacharasterisk}}) are |
|
79 |
above 50. User syntax should strive to coexist with common HOL |
|
80 |
forms, or use the mostly unused range 100--900.% |
|
12627 | 81 |
\end{isamarkuptext}% |
82 |
\isamarkuptrue% |
|
12635 | 83 |
% |
12658 | 84 |
\isamarkupsubsection{Mathematical Symbols \label{sec:syntax-symbols}% |
12635 | 85 |
} |
12627 | 86 |
\isamarkuptrue% |
12635 | 87 |
% |
88 |
\begin{isamarkuptext}% |
|
12767 | 89 |
Concrete syntax based on ASCII characters has inherent limitations. |
90 |
Mathematical notation demands a larger repertoire of glyphs. |
|
91 |
Several standards of extended character sets have been proposed over |
|
92 |
decades, but none has become universally available so far. Isabelle |
|
93 |
has its own notion of \bfindex{symbols} as the smallest entities of |
|
94 |
source text, without referring to internal encodings. There are |
|
95 |
three kinds of such ``generalized characters'': |
|
12635 | 96 |
|
97 |
\begin{enumerate} |
|
98 |
||
12652 | 99 |
\item 7-bit ASCII characters |
12635 | 100 |
|
12652 | 101 |
\item named symbols: \verb,\,\verb,<,$ident$\verb,>, |
12635 | 102 |
|
12652 | 103 |
\item named control symbols: \verb,\,\verb,<^,$ident$\verb,>, |
12635 | 104 |
|
105 |
\end{enumerate} |
|
106 |
||
107 |
Here $ident$ may be any identifier according to the usual Isabelle |
|
108 |
conventions. This results in an infinite store of symbols, whose |
|
12767 | 109 |
interpretation is left to further front-end tools. For example, the |
110 |
user-interface of Proof~General + X-Symbol and the Isabelle document |
|
111 |
processor (see \S\ref{sec:document-preparation}) display the |
|
112 |
\verb,\,\verb,<forall>, symbol as~\isa{{\isasymforall}}. |
|
12635 | 113 |
|
114 |
A list of standard Isabelle symbols is given in |
|
12767 | 115 |
\cite[appendix~A]{isabelle-sys}. You may introduce your own |
12635 | 116 |
interpretation of further symbols by configuring the appropriate |
12652 | 117 |
front-end tool accordingly, e.g.\ by defining certain {\LaTeX} |
118 |
macros (see also \S\ref{sec:doc-prep-symbols}). There are also a |
|
119 |
few predefined control symbols, such as \verb,\,\verb,<^sub>, and |
|
12635 | 120 |
\verb,\,\verb,<^sup>, for sub- and superscript of the subsequent |
12764 | 121 |
printable symbol, respectively. For example, \verb,A\<^sup>\<star>, is |
12671 | 122 |
output as \isa{A\isactrlsup {\isasymstar}}. |
12635 | 123 |
|
12767 | 124 |
\medskip Replacing our definition of \isa{xor} by the following |
13439 | 125 |
specifies an Isabelle symbol for the new operator:% |
12635 | 126 |
\end{isamarkuptext}% |
127 |
\isamarkuptrue% |
|
128 |
\isamarkupfalse% |
|
129 |
\isamarkupfalse% |
|
130 |
\isacommand{constdefs}\isanewline |
|
131 |
\ \ xor\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}bool\ {\isasymRightarrow}\ bool\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymoplus}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isanewline |
|
13791 | 132 |
\ \ {\isachardoublequote}A\ {\isasymoplus}\ B\ {\isasymequiv}\ {\isacharparenleft}A\ {\isasymand}\ {\isasymnot}\ B{\isacharparenright}\ {\isasymor}\ {\isacharparenleft}{\isasymnot}\ A\ {\isasymand}\ B{\isacharparenright}{\isachardoublequote}\isamarkupfalse% |
12635 | 133 |
\isamarkupfalse% |
134 |
% |
|
135 |
\begin{isamarkuptext}% |
|
12652 | 136 |
\noindent The X-Symbol package within Proof~General provides several |
137 |
input methods to enter \isa{{\isasymoplus}} in the text. If all fails one may |
|
12767 | 138 |
just type a named entity \verb,\,\verb,<oplus>, by hand; the |
139 |
corresponding symbol will be displayed after further input. |
|
12635 | 140 |
|
12767 | 141 |
\medskip More flexible is to provide alternative syntax forms |
142 |
through the \bfindex{print mode} concept~\cite{isabelle-ref}. By |
|
143 |
convention, the mode of ``$xsymbols$'' is enabled whenever |
|
144 |
Proof~General's X-Symbol mode or {\LaTeX} output is active. Now |
|
145 |
consider the following hybrid declaration of \isa{xor}:% |
|
12635 | 146 |
\end{isamarkuptext}% |
12627 | 147 |
\isamarkuptrue% |
148 |
\isamarkupfalse% |
|
149 |
\isamarkupfalse% |
|
12635 | 150 |
\isacommand{constdefs}\isanewline |
151 |
\ \ xor\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}bool\ {\isasymRightarrow}\ bool\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isacharbrackleft}{\isacharplus}{\isacharbrackright}{\isasymignore}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isanewline |
|
152 |
\ \ {\isachardoublequote}A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}{\isasymignore}\ B\ {\isasymequiv}\ {\isacharparenleft}A\ {\isasymand}\ {\isasymnot}\ B{\isacharparenright}\ {\isasymor}\ {\isacharparenleft}{\isasymnot}\ A\ {\isasymand}\ B{\isacharparenright}{\isachardoublequote}\isanewline |
|
153 |
\isanewline |
|
12627 | 154 |
\isamarkupfalse% |
12635 | 155 |
\isacommand{syntax}\ {\isacharparenleft}xsymbols{\isacharparenright}\isanewline |
13791 | 156 |
\ \ xor\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}bool\ {\isasymRightarrow}\ bool\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymoplus}{\isasymignore}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isamarkupfalse% |
12627 | 157 |
\isamarkupfalse% |
12635 | 158 |
% |
159 |
\begin{isamarkuptext}% |
|
12652 | 160 |
The \commdx{syntax} command introduced here acts like |
12743 | 161 |
\isakeyword{consts}, but without declaring a logical constant. The |
12747 | 162 |
print mode specification of \isakeyword{syntax}, here \isa{{\isacharparenleft}xsymbols{\isacharparenright}}, is optional. Also note that its type merely serves |
163 |
for syntactic purposes, and is \emph{not} checked for consistency |
|
164 |
with the real constant. |
|
12635 | 165 |
|
12672 | 166 |
\medskip We may now write \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B} or \isa{A\ {\isasymoplus}\ B} in |
12767 | 167 |
input, while output uses the nicer syntax of $xsymbols$ whenever |
12672 | 168 |
that print mode is active. Such an arrangement is particularly |
12767 | 169 |
useful for interactive development, where users may type ASCII text |
170 |
and see mathematical symbols displayed during proofs.% |
|
12635 | 171 |
\end{isamarkuptext}% |
12627 | 172 |
\isamarkuptrue% |
12635 | 173 |
% |
12647 | 174 |
\isamarkupsubsection{Prefix Annotations% |
12635 | 175 |
} |
12627 | 176 |
\isamarkuptrue% |
12635 | 177 |
% |
178 |
\begin{isamarkuptext}% |
|
12767 | 179 |
Prefix syntax annotations\index{prefix annotation} are another form |
180 |
of mixfixes \cite{isabelle-ref}, without any template arguments or |
|
181 |
priorities --- just some literal syntax. The following example |
|
182 |
associates common symbols with the constructors of a datatype.% |
|
12635 | 183 |
\end{isamarkuptext}% |
12627 | 184 |
\isamarkuptrue% |
12635 | 185 |
\isacommand{datatype}\ currency\ {\isacharequal}\isanewline |
186 |
\ \ \ \ Euro\ nat\ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isasymeuro}{\isachardoublequote}{\isacharparenright}\isanewline |
|
187 |
\ \ {\isacharbar}\ Pounds\ nat\ \ {\isacharparenleft}{\isachardoublequote}{\isasympounds}{\isachardoublequote}{\isacharparenright}\isanewline |
|
188 |
\ \ {\isacharbar}\ Yen\ nat\ \ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isasymyen}{\isachardoublequote}{\isacharparenright}\isanewline |
|
189 |
\ \ {\isacharbar}\ Dollar\ nat\ \ {\isacharparenleft}{\isachardoublequote}{\isachardollar}{\isachardoublequote}{\isacharparenright}\isamarkupfalse% |
|
190 |
% |
|
191 |
\begin{isamarkuptext}% |
|
12652 | 192 |
\noindent Here the mixfix annotations on the rightmost column happen |
193 |
to consist of a single Isabelle symbol each: \verb,\,\verb,<euro>,, |
|
194 |
\verb,\,\verb,<pounds>,, \verb,\,\verb,<yen>,, and \verb,$,. Recall |
|
12747 | 195 |
that a constructor like \isa{Euro} actually is a function \isa{nat\ {\isasymRightarrow}\ currency}. The expression \isa{Euro\ {\isadigit{1}}{\isadigit{0}}} will be |
12652 | 196 |
printed as \isa{{\isasymeuro}\ {\isadigit{1}}{\isadigit{0}}}; only the head of the application is |
12743 | 197 |
subject to our concrete syntax. This rather simple form already |
198 |
achieves conformance with notational standards of the European |
|
199 |
Commission. |
|
12635 | 200 |
|
12767 | 201 |
Prefix syntax works the same way for \isakeyword{consts} or |
12764 | 202 |
\isakeyword{constdefs}.% |
12649 | 203 |
\end{isamarkuptext}% |
204 |
\isamarkuptrue% |
|
205 |
% |
|
206 |
\isamarkupsubsection{Syntax Translations \label{sec:syntax-translations}% |
|
12635 | 207 |
} |
12627 | 208 |
\isamarkuptrue% |
12635 | 209 |
% |
210 |
\begin{isamarkuptext}% |
|
12767 | 211 |
Mixfix syntax annotations merely decorate particular constant |
212 |
application forms with concrete syntax, for instance replacing \ |
|
213 |
\isa{xor\ A\ B} by \isa{A\ {\isasymoplus}\ B}. Occasionally, the |
|
214 |
relationship between some piece of notation and its internal form is |
|
215 |
more complicated. Here we need \bfindex{syntax translations}. |
|
12635 | 216 |
|
12764 | 217 |
Using the \isakeyword{syntax}\index{syntax (command)}, command we |
218 |
introduce uninterpreted notational elements. Then |
|
219 |
\commdx{translations} relate input forms to complex logical |
|
12767 | 220 |
expressions. This provides a simple mechanism for syntactic macros; |
221 |
even heavier transformations may be written in ML |
|
12671 | 222 |
\cite{isabelle-ref}. |
12649 | 223 |
|
12764 | 224 |
\medskip A typical use of syntax translations is to introduce |
12767 | 225 |
relational notation for membership in a set of pair, replacing \ |
226 |
\isa{{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isasymin}\ sim} by \isa{x\ {\isasymapprox}\ y}.% |
|
12635 | 227 |
\end{isamarkuptext}% |
12627 | 228 |
\isamarkuptrue% |
12649 | 229 |
\isacommand{consts}\isanewline |
230 |
\ \ sim\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}{\isacharprime}a\ {\isasymtimes}\ {\isacharprime}a{\isacharparenright}\ set{\isachardoublequote}\isanewline |
|
231 |
\isanewline |
|
232 |
\isamarkupfalse% |
|
233 |
\isacommand{syntax}\isanewline |
|
234 |
\ \ {\isachardoublequote}{\isacharunderscore}sim{\isachardoublequote}\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infix}\ {\isachardoublequote}{\isasymapprox}{\isachardoublequote}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\isanewline |
|
235 |
\isamarkupfalse% |
|
236 |
\isacommand{translations}\isanewline |
|
237 |
\ \ {\isachardoublequote}x\ {\isasymapprox}\ y{\isachardoublequote}\ {\isasymrightleftharpoons}\ {\isachardoublequote}{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isasymin}\ sim{\isachardoublequote}\isamarkupfalse% |
|
12635 | 238 |
% |
239 |
\begin{isamarkuptext}% |
|
12649 | 240 |
\noindent Here the name of the dummy constant \isa{{\isacharunderscore}sim} does |
12767 | 241 |
not matter, as long as it is not used elsewhere. Prefixing an |
242 |
underscore is a common convention. The \isakeyword{translations} |
|
12649 | 243 |
declaration already uses concrete syntax on the left-hand side; |
244 |
internally we relate a raw application \isa{{\isacharunderscore}sim\ x\ y} with |
|
245 |
\isa{{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isasymin}\ sim}. |
|
12635 | 246 |
|
12652 | 247 |
\medskip Another common application of syntax translations is to |
12649 | 248 |
provide variant versions of fundamental relational expressions, such |
249 |
as \isa{{\isasymnoteq}} for negated equalities. The following declaration |
|
250 |
stems from Isabelle/HOL itself:% |
|
251 |
\end{isamarkuptext}% |
|
252 |
\isamarkuptrue% |
|
253 |
\isacommand{syntax}\ {\isachardoublequote}{\isacharunderscore}not{\isacharunderscore}equal{\isachardoublequote}\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymnoteq}{\isasymignore}{\isachardoublequote}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\isanewline |
|
254 |
\isamarkupfalse% |
|
255 |
\isacommand{translations}\ {\isachardoublequote}x\ {\isasymnoteq}{\isasymignore}\ y{\isachardoublequote}\ {\isasymrightleftharpoons}\ {\isachardoublequote}{\isasymnot}\ {\isacharparenleft}x\ {\isacharequal}\ y{\isacharparenright}{\isachardoublequote}\isamarkupfalse% |
|
256 |
% |
|
257 |
\begin{isamarkuptext}% |
|
258 |
\noindent Normally one would introduce derived concepts like this |
|
12652 | 259 |
within the logic, using \isakeyword{consts} + \isakeyword{defs} |
260 |
instead of \isakeyword{syntax} + \isakeyword{translations}. The |
|
12649 | 261 |
present formulation has the virtue that expressions are immediately |
12666 | 262 |
replaced by the ``definition'' upon parsing; the effect is reversed |
263 |
upon printing. |
|
12649 | 264 |
|
12767 | 265 |
This sort of translation is appropriate when the defined concept is |
266 |
a trivial variation on an existing one. On the other hand, syntax |
|
267 |
translations do not scale up well to large hierarchies of concepts. |
|
268 |
Translations do not replace definitions!% |
|
12635 | 269 |
\end{isamarkuptext}% |
12627 | 270 |
\isamarkuptrue% |
12635 | 271 |
% |
12652 | 272 |
\isamarkupsection{Document Preparation \label{sec:document-preparation}% |
12635 | 273 |
} |
274 |
\isamarkuptrue% |
|
275 |
% |
|
12644 | 276 |
\begin{isamarkuptext}% |
12652 | 277 |
Isabelle/Isar is centered around the concept of \bfindex{formal |
12767 | 278 |
proof documents}\index{documents|bold}. The outcome of a formal |
279 |
development effort is meant to be a human-readable record, presented |
|
280 |
as browsable PDF file or printed on paper. The overall document |
|
281 |
structure follows traditional mathematical articles, with sections, |
|
282 |
intermediate explanations, definitions, theorems and proofs. |
|
12644 | 283 |
|
284 |
\medskip The Isabelle document preparation system essentially acts |
|
12671 | 285 |
as a front-end to {\LaTeX}. After checking specifications and |
286 |
proofs formally, the theory sources are turned into typesetting |
|
12767 | 287 |
instructions in a schematic manner. This lets you write authentic |
288 |
reports on theory developments with little effort: many technical |
|
289 |
consistency checks are handled by the system. |
|
12745 | 290 |
|
291 |
Here is an example to illustrate the idea of Isabelle document |
|
12747 | 292 |
preparation.% |
293 |
\end{isamarkuptext}% |
|
294 |
\isamarkuptrue% |
|
295 |
% |
|
296 |
\begin{quotation} |
|
297 |
% |
|
298 |
\begin{isamarkuptext}% |
|
299 |
The following datatype definition of \isa{{\isacharprime}a\ bintree} models |
|
300 |
binary trees with nodes being decorated by elements of type \isa{{\isacharprime}a}.% |
|
12745 | 301 |
\end{isamarkuptext}% |
302 |
\isamarkuptrue% |
|
303 |
\isacommand{datatype}\ {\isacharprime}a\ bintree\ {\isacharequal}\isanewline |
|
12747 | 304 |
\ \ \ \ \ Leaf\ {\isacharbar}\ Branch\ {\isacharprime}a\ \ {\isachardoublequote}{\isacharprime}a\ bintree{\isachardoublequote}\ \ {\isachardoublequote}{\isacharprime}a\ bintree{\isachardoublequote}\isamarkupfalse% |
12745 | 305 |
% |
306 |
\begin{isamarkuptext}% |
|
307 |
\noindent The datatype induction rule generated here is of the form |
|
308 |
\begin{isabelle}% |
|
12749 | 309 |
\ {\isasymlbrakk}P\ Leaf{\isacharsemicolon}\isanewline |
14379 | 310 |
\isaindent{\ \ }{\isasymAnd}a\ bintree{\isadigit{1}}\ bintree{\isadigit{2}}{\isachardot}\isanewline |
311 |
\isaindent{\ \ \ \ \ }{\isasymlbrakk}P\ bintree{\isadigit{1}}{\isacharsemicolon}\ P\ bintree{\isadigit{2}}{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ {\isacharparenleft}Branch\ a\ bintree{\isadigit{1}}\ bintree{\isadigit{2}}{\isacharparenright}{\isasymrbrakk}\isanewline |
|
12749 | 312 |
\isaindent{\ }{\isasymLongrightarrow}\ P\ bintree% |
12747 | 313 |
\end{isabelle}% |
314 |
\end{isamarkuptext}% |
|
315 |
\isamarkuptrue% |
|
316 |
% |
|
317 |
\end{quotation} |
|
318 |
% |
|
319 |
\begin{isamarkuptext}% |
|
12767 | 320 |
\noindent The above document output has been produced as follows: |
12745 | 321 |
|
322 |
\begin{ttbox} |
|
323 |
text {\ttlbrace}* |
|
324 |
The following datatype definition of {\at}{\ttlbrace}text "'a bintree"{\ttrbrace} |
|
325 |
models binary trees with nodes being decorated by elements |
|
326 |
of type {\at}{\ttlbrace}typ 'a{\ttrbrace}. |
|
327 |
*{\ttrbrace} |
|
328 |
||
329 |
datatype 'a bintree = |
|
330 |
Leaf | Branch 'a "'a bintree" "'a bintree" |
|
12767 | 331 |
\end{ttbox} |
332 |
\begin{ttbox} |
|
12745 | 333 |
text {\ttlbrace}* |
334 |
{\ttback}noindent The datatype induction rule generated here is |
|
335 |
of the form {\at}{\ttlbrace}thm [display] bintree.induct [no_vars]{\ttrbrace} |
|
336 |
*{\ttrbrace} |
|
12767 | 337 |
\end{ttbox}\vspace{-\medskipamount} |
12745 | 338 |
|
12747 | 339 |
\noindent Here we have augmented the theory by formal comments |
12767 | 340 |
(using \isakeyword{text} blocks), the informal parts may again refer |
341 |
to formal entities by means of ``antiquotations'' (such as |
|
12745 | 342 |
\texttt{\at}\verb,{text "'a bintree"}, or |
12747 | 343 |
\texttt{\at}\verb,{typ 'a},), see also \S\ref{sec:doc-prep-text}.% |
12644 | 344 |
\end{isamarkuptext}% |
12635 | 345 |
\isamarkuptrue% |
346 |
% |
|
12647 | 347 |
\isamarkupsubsection{Isabelle Sessions% |
12635 | 348 |
} |
349 |
\isamarkuptrue% |
|
350 |
% |
|
351 |
\begin{isamarkuptext}% |
|
12652 | 352 |
In contrast to the highly interactive mode of Isabelle/Isar theory |
353 |
development, the document preparation stage essentially works in |
|
12671 | 354 |
batch-mode. An Isabelle \bfindex{session} consists of a collection |
12767 | 355 |
of source files that may contribute to an output document. Each |
356 |
session is derived from a single parent, usually an object-logic |
|
357 |
image like \texttt{HOL}. This results in an overall tree structure, |
|
358 |
which is reflected by the output location in the file system |
|
359 |
(usually rooted at \verb,~/isabelle/browser_info,). |
|
12644 | 360 |
|
12684 | 361 |
\medskip The easiest way to manage Isabelle sessions is via |
12686 | 362 |
\texttt{isatool mkdir} (generates an initial session source setup) |
363 |
and \texttt{isatool make} (run sessions controlled by |
|
12684 | 364 |
\texttt{IsaMakefile}). For example, a new session |
365 |
\texttt{MySession} derived from \texttt{HOL} may be produced as |
|
366 |
follows: |
|
367 |
||
368 |
\begin{verbatim} |
|
369 |
isatool mkdir HOL MySession |
|
370 |
isatool make |
|
371 |
\end{verbatim} |
|
372 |
||
12686 | 373 |
The \texttt{isatool make} job also informs about the file-system |
374 |
location of the ultimate results. The above dry run should be able |
|
375 |
to produce some \texttt{document.pdf} (with dummy title, empty table |
|
12743 | 376 |
of contents etc.). Any failure at this stage usually indicates |
12686 | 377 |
technical problems of the {\LaTeX} installation.\footnote{Especially |
12767 | 378 |
make sure that \texttt{pdflatex} is present; if in doubt one may |
12686 | 379 |
fall back on DVI output by changing \texttt{usedir} options in |
380 |
\texttt{IsaMakefile} \cite{isabelle-sys}.} |
|
12684 | 381 |
|
382 |
\medskip The detailed arrangement of the session sources is as |
|
12747 | 383 |
follows. |
12644 | 384 |
|
385 |
\begin{itemize} |
|
386 |
||
12671 | 387 |
\item Directory \texttt{MySession} holds the required theory files |
388 |
$T@1$\texttt{.thy}, \dots, $T@n$\texttt{.thy}. |
|
12644 | 389 |
|
390 |
\item File \texttt{MySession/ROOT.ML} holds appropriate ML commands |
|
391 |
for loading all wanted theories, usually just |
|
12666 | 392 |
``\texttt{use_thy"$T@i$";}'' for any $T@i$ in leaf position of the |
12671 | 393 |
dependency graph. |
12644 | 394 |
|
395 |
\item Directory \texttt{MySession/document} contains everything |
|
12652 | 396 |
required for the {\LaTeX} stage; only \texttt{root.tex} needs to be |
397 |
provided initially. |
|
12644 | 398 |
|
12652 | 399 |
The latter file holds appropriate {\LaTeX} code to commence a |
400 |
document (\verb,\documentclass, etc.), and to include the generated |
|
12743 | 401 |
files $T@i$\texttt{.tex} for each theory. Isabelle will generate a |
402 |
file \texttt{session.tex} holding {\LaTeX} commands to include all |
|
12747 | 403 |
generated theory output files in topologically sorted order, so |
404 |
\verb,\input{session}, in the body of \texttt{root.tex} does the job |
|
405 |
in most situations. |
|
12652 | 406 |
|
12682 | 407 |
\item \texttt{IsaMakefile} holds appropriate dependencies and |
408 |
invocations of Isabelle tools to control the batch job. In fact, |
|
12747 | 409 |
several sessions may be managed by the same \texttt{IsaMakefile}. |
12764 | 410 |
See the \emph{Isabelle System Manual} \cite{isabelle-sys} |
411 |
for further details, especially on |
|
12652 | 412 |
\texttt{isatool usedir} and \texttt{isatool make}. |
12644 | 413 |
|
414 |
\end{itemize} |
|
415 |
||
12686 | 416 |
One may now start to populate the directory \texttt{MySession}, and |
12767 | 417 |
the file \texttt{MySession/ROOT.ML} accordingly. The file |
418 |
\texttt{MySession/document/root.tex} should also be adapted at some |
|
12686 | 419 |
point; the default version is mostly self-explanatory. Note that |
420 |
\verb,\isabellestyle, enables fine-tuning of the general appearance |
|
421 |
of characters and mathematical symbols (see also |
|
422 |
\S\ref{sec:doc-prep-symbols}). |
|
12652 | 423 |
|
12686 | 424 |
Especially observe the included {\LaTeX} packages \texttt{isabelle} |
425 |
(mandatory), \texttt{isabellesym} (required for mathematical |
|
12743 | 426 |
symbols), and the final \texttt{pdfsetup} (provides sane defaults |
12764 | 427 |
for \texttt{hyperref}, including URL markup). All three are |
12743 | 428 |
distributed with Isabelle. Further packages may be required in |
12764 | 429 |
particular applications, say for unusual mathematical symbols. |
12644 | 430 |
|
12747 | 431 |
\medskip Any additional files for the {\LaTeX} stage go into the |
432 |
\texttt{MySession/document} directory as well. In particular, |
|
12767 | 433 |
adding a file named \texttt{root.bib} causes an automatic run of |
434 |
\texttt{bibtex} to process a bibliographic database; see also |
|
435 |
\texttt{isatool document} \cite{isabelle-sys}. |
|
12644 | 436 |
|
12652 | 437 |
\medskip Any failure of the document preparation phase in an |
12671 | 438 |
Isabelle batch session leaves the generated sources in their target |
12767 | 439 |
location, identified by the accompanying error message. This lets |
440 |
you trace {\LaTeX} problems with the generated files at hand.% |
|
12644 | 441 |
\end{isamarkuptext}% |
442 |
\isamarkuptrue% |
|
443 |
% |
|
12647 | 444 |
\isamarkupsubsection{Structure Markup% |
12644 | 445 |
} |
446 |
\isamarkuptrue% |
|
447 |
% |
|
448 |
\begin{isamarkuptext}% |
|
12652 | 449 |
The large-scale structure of Isabelle documents follows existing |
450 |
{\LaTeX} conventions, with chapters, sections, subsubsections etc. |
|
451 |
The Isar language includes separate \bfindex{markup commands}, which |
|
12682 | 452 |
do not affect the formal meaning of a theory (or proof), but result |
12666 | 453 |
in corresponding {\LaTeX} elements. |
12644 | 454 |
|
12666 | 455 |
There are separate markup commands depending on the textual context: |
456 |
in header position (just before \isakeyword{theory}), within the |
|
457 |
theory body, or within a proof. The header needs to be treated |
|
458 |
specially here, since ordinary theory and proof commands may only |
|
459 |
occur \emph{after} the initial \isakeyword{theory} specification. |
|
12644 | 460 |
|
12666 | 461 |
\medskip |
12644 | 462 |
|
463 |
\begin{tabular}{llll} |
|
464 |
header & theory & proof & default meaning \\\hline |
|
465 |
& \commdx{chapter} & & \verb,\chapter, \\ |
|
466 |
\commdx{header} & \commdx{section} & \commdx{sect} & \verb,\section, \\ |
|
467 |
& \commdx{subsection} & \commdx{subsect} & \verb,\subsection, \\ |
|
468 |
& \commdx{subsubsection} & \commdx{subsubsect} & \verb,\subsubsection, \\ |
|
469 |
\end{tabular} |
|
470 |
||
471 |
\medskip |
|
472 |
||
473 |
From the Isabelle perspective, each markup command takes a single |
|
12747 | 474 |
$text$ argument (delimited by \verb,",~\isa{{\isasymdots}}~\verb,", or |
475 |
\verb,{,\verb,*,~\isa{{\isasymdots}}~\verb,*,\verb,},). After stripping any |
|
12644 | 476 |
surrounding white space, the argument is passed to a {\LaTeX} macro |
12767 | 477 |
\verb,\isamarkupXYZ, for command \isakeyword{XYZ}. These macros are |
478 |
defined in \verb,isabelle.sty, according to the meaning given in the |
|
479 |
rightmost column above. |
|
12644 | 480 |
|
481 |
\medskip The following source fragment illustrates structure markup |
|
12652 | 482 |
of a theory. Note that {\LaTeX} labels may be included inside of |
483 |
section headings as well. |
|
12644 | 484 |
|
485 |
\begin{ttbox} |
|
486 |
header {\ttlbrace}* Some properties of Foo Bar elements *{\ttrbrace} |
|
487 |
||
488 |
theory Foo_Bar = Main: |
|
489 |
||
490 |
subsection {\ttlbrace}* Basic definitions *{\ttrbrace} |
|
491 |
||
492 |
consts |
|
493 |
foo :: \dots |
|
494 |
bar :: \dots |
|
12647 | 495 |
|
12644 | 496 |
defs \dots |
12647 | 497 |
|
12644 | 498 |
subsection {\ttlbrace}* Derived rules *{\ttrbrace} |
499 |
||
500 |
lemma fooI: \dots |
|
501 |
lemma fooE: \dots |
|
502 |
||
12647 | 503 |
subsection {\ttlbrace}* Main theorem {\ttback}label{\ttlbrace}sec:main-theorem{\ttrbrace} *{\ttrbrace} |
12644 | 504 |
|
505 |
theorem main: \dots |
|
506 |
||
507 |
end |
|
12767 | 508 |
\end{ttbox}\vspace{-\medskipamount} |
12644 | 509 |
|
12767 | 510 |
You may occasionally want to change the meaning of markup commands, |
511 |
say via \verb,\renewcommand, in \texttt{root.tex}. For example, |
|
512 |
\verb,\isamarkupheader, is a good candidate for some tuning. We |
|
513 |
could move it up in the hierarchy to become \verb,\chapter,. |
|
12644 | 514 |
|
515 |
\begin{verbatim} |
|
516 |
\renewcommand{\isamarkupheader}[1]{\chapter{#1}} |
|
517 |
\end{verbatim} |
|
518 |
||
12767 | 519 |
\noindent Now we must change the document class given in |
520 |
\texttt{root.tex} to something that supports chapters. A suitable |
|
521 |
command is \verb,\documentclass{report},. |
|
12644 | 522 |
|
12647 | 523 |
\medskip The {\LaTeX} macro \verb,\isabellecontext, is maintained to |
524 |
hold the name of the current theory context. This is particularly |
|
12652 | 525 |
useful for document headings: |
12644 | 526 |
|
527 |
\begin{verbatim} |
|
12652 | 528 |
\renewcommand{\isamarkupheader}[1] |
12644 | 529 |
{\chapter{#1}\markright{THEORY~\isabellecontext}} |
530 |
\end{verbatim} |
|
531 |
||
532 |
\noindent Make sure to include something like |
|
12647 | 533 |
\verb,\pagestyle{headings}, in \texttt{root.tex}; the document |
12764 | 534 |
should have more than two pages to show the effect.% |
12644 | 535 |
\end{isamarkuptext}% |
536 |
\isamarkuptrue% |
|
537 |
% |
|
12745 | 538 |
\isamarkupsubsection{Formal Comments and Antiquotations \label{sec:doc-prep-text}% |
12644 | 539 |
} |
540 |
\isamarkuptrue% |
|
541 |
% |
|
542 |
\begin{isamarkuptext}% |
|
12745 | 543 |
Isabelle \bfindex{source comments}, which are of the form |
12747 | 544 |
\verb,(,\verb,*,~\isa{{\isasymdots}}~\verb,*,\verb,),, essentially act like |
545 |
white space and do not really contribute to the content. They |
|
546 |
mainly serve technical purposes to mark certain oddities in the raw |
|
547 |
input text. In contrast, \bfindex{formal comments} are portions of |
|
548 |
text that are associated with formal Isabelle/Isar commands |
|
12682 | 549 |
(\bfindex{marginal comments}), or as standalone paragraphs within a |
12666 | 550 |
theory or proof context (\bfindex{text blocks}). |
12658 | 551 |
|
552 |
\medskip Marginal comments are part of each command's concrete |
|
12671 | 553 |
syntax \cite{isabelle-ref}; the common form is ``\verb,--,~$text$'' |
12747 | 554 |
where $text$ is delimited by \verb,",\isa{{\isasymdots}}\verb,", or |
555 |
\verb,{,\verb,*,~\isa{{\isasymdots}}~\verb,*,\verb,}, as before. Multiple |
|
12671 | 556 |
marginal comments may be given at the same time. Here is a simple |
557 |
example:% |
|
12666 | 558 |
\end{isamarkuptext}% |
559 |
\isamarkuptrue% |
|
560 |
\isacommand{lemma}\ {\isachardoublequote}A\ {\isacharminus}{\isacharminus}{\isachargreater}\ A{\isachardoublequote}\isanewline |
|
561 |
\ \ % |
|
562 |
\isamarkupcmt{a triviality of propositional logic% |
|
563 |
} |
|
564 |
\isanewline |
|
565 |
\ \ % |
|
566 |
\isamarkupcmt{(should not really bother)% |
|
567 |
} |
|
568 |
\isanewline |
|
569 |
\ \ \isamarkupfalse% |
|
570 |
\isacommand{by}\ {\isacharparenleft}rule\ impI{\isacharparenright}\ % |
|
571 |
\isamarkupcmt{implicit assumption step involved here% |
|
572 |
} |
|
573 |
\isamarkupfalse% |
|
574 |
% |
|
575 |
\begin{isamarkuptext}% |
|
576 |
\noindent The above output has been produced as follows: |
|
12658 | 577 |
|
578 |
\begin{verbatim} |
|
579 |
lemma "A --> A" |
|
580 |
-- "a triviality of propositional logic" |
|
581 |
-- "(should not really bother)" |
|
582 |
by (rule impI) -- "implicit assumption step involved here" |
|
583 |
\end{verbatim} |
|
584 |
||
12671 | 585 |
From the {\LaTeX} viewpoint, ``\verb,--,'' acts like a markup |
586 |
command, associated with the macro \verb,\isamarkupcmt, (taking a |
|
587 |
single argument). |
|
12658 | 588 |
|
12666 | 589 |
\medskip Text blocks are introduced by the commands \bfindex{text} |
590 |
and \bfindex{txt}, for theory and proof contexts, respectively. |
|
591 |
Each takes again a single $text$ argument, which is interpreted as a |
|
592 |
free-form paragraph in {\LaTeX} (surrounded by some additional |
|
12671 | 593 |
vertical space). This behavior may be changed by redefining the |
594 |
{\LaTeX} environments of \verb,isamarkuptext, or |
|
595 |
\verb,isamarkuptxt,, respectively (via \verb,\renewenvironment,) The |
|
596 |
text style of the body is determined by \verb,\isastyletext, and |
|
597 |
\verb,\isastyletxt,; the default setup uses a smaller font within |
|
12747 | 598 |
proofs. This may be changed as follows: |
599 |
||
600 |
\begin{verbatim} |
|
601 |
\renewcommand{\isastyletxt}{\isastyletext} |
|
602 |
\end{verbatim} |
|
12658 | 603 |
|
12767 | 604 |
\medskip The $text$ part of Isabelle markup commands essentially |
605 |
inserts \emph{quoted material} into a formal text, mainly for |
|
606 |
instruction of the reader. An \bfindex{antiquotation} is again a |
|
607 |
formal object embedded into such an informal portion. The |
|
608 |
interpretation of antiquotations is limited to some well-formedness |
|
609 |
checks, with the result being pretty printed to the resulting |
|
610 |
document. Quoted text blocks together with antiquotations provide |
|
611 |
an attractive means of referring to formal entities, with good |
|
612 |
confidence in getting the technical details right (especially syntax |
|
613 |
and types). |
|
12658 | 614 |
|
12666 | 615 |
The general syntax of antiquotations is as follows: |
12658 | 616 |
\texttt{{\at}{\ttlbrace}$name$ $arguments${\ttrbrace}}, or |
617 |
\texttt{{\at}{\ttlbrace}$name$ [$options$] $arguments${\ttrbrace}} |
|
12666 | 618 |
for a comma-separated list of options consisting of a $name$ or |
12767 | 619 |
\texttt{$name$=$value$} each. The syntax of $arguments$ depends on |
620 |
the kind of antiquotation, it generally follows the same conventions |
|
621 |
for types, terms, or theorems as in the formal part of a theory. |
|
12649 | 622 |
|
12767 | 623 |
\medskip This sentence demonstrates quotations and antiquotations: |
624 |
\isa{{\isasymlambda}x\ y{\isachardot}\ x} is a well-typed term. |
|
12658 | 625 |
|
12764 | 626 |
\medskip\noindent The output above was produced as follows: |
12658 | 627 |
\begin{ttbox} |
628 |
text {\ttlbrace}* |
|
12764 | 629 |
This sentence demonstrates quotations and antiquotations: |
12658 | 630 |
{\at}{\ttlbrace}term "%x y. x"{\ttrbrace} is a well-typed term. |
631 |
*{\ttrbrace} |
|
12767 | 632 |
\end{ttbox}\vspace{-\medskipamount} |
12658 | 633 |
|
12764 | 634 |
The notational change from the ASCII character~\verb,%, to the |
12767 | 635 |
symbol~\isa{{\isasymlambda}} reveals that Isabelle printed this term, after |
636 |
parsing and type-checking. Document preparation enables symbolic |
|
637 |
output by default. |
|
12658 | 638 |
|
12764 | 639 |
\medskip The next example includes an option to modify Isabelle's |
640 |
\verb,show_types, flag. The antiquotation |
|
12767 | 641 |
\texttt{{\at}}\verb,{term [show_types] "%x y. x"}, produces the |
642 |
output \isa{{\isasymlambda}{\isacharparenleft}x{\isasymColon}{\isacharprime}a{\isacharparenright}\ y{\isasymColon}{\isacharprime}b{\isachardot}\ x}. Type inference has figured |
|
643 |
out the most general typings in the present theory context. Terms |
|
644 |
may acquire different typings due to constraints imposed by their |
|
645 |
environment; within a proof, for example, variables are given the |
|
646 |
same types as they have in the main goal statement. |
|
12658 | 647 |
|
12764 | 648 |
\medskip Several further kinds of antiquotations and options are |
12666 | 649 |
available \cite{isabelle-sys}. Here are a few commonly used |
12671 | 650 |
combinations: |
12658 | 651 |
|
652 |
\medskip |
|
653 |
||
654 |
\begin{tabular}{ll} |
|
655 |
\texttt{\at}\verb,{typ,~$\tau$\verb,}, & print type $\tau$ \\ |
|
656 |
\texttt{\at}\verb,{term,~$t$\verb,}, & print term $t$ \\ |
|
657 |
\texttt{\at}\verb,{prop,~$\phi$\verb,}, & print proposition $\phi$ \\ |
|
12666 | 658 |
\texttt{\at}\verb,{prop [display],~$\phi$\verb,}, & print large proposition $\phi$ (with linebreaks) \\ |
12658 | 659 |
\texttt{\at}\verb,{prop [source],~$\phi$\verb,}, & check proposition $\phi$, print its input \\ |
660 |
\texttt{\at}\verb,{thm,~$a$\verb,}, & print fact $a$ \\ |
|
661 |
\texttt{\at}\verb,{thm,~$a$~\verb,[no_vars]}, & print fact $a$, fixing schematic variables \\ |
|
12747 | 662 |
\texttt{\at}\verb,{thm [source],~$a$\verb,}, & check availability of fact $a$, print its name \\ |
12658 | 663 |
\texttt{\at}\verb,{text,~$s$\verb,}, & print uninterpreted text $s$ \\ |
664 |
\end{tabular} |
|
665 |
||
666 |
\medskip |
|
667 |
||
12666 | 668 |
Note that \attrdx{no_vars} given above is \emph{not} an |
669 |
antiquotation option, but an attribute of the theorem argument given |
|
670 |
here. This might be useful with a diagnostic command like |
|
671 |
\isakeyword{thm}, too. |
|
12658 | 672 |
|
12666 | 673 |
\medskip The \texttt{\at}\verb,{text, $s$\verb,}, antiquotation is |
12658 | 674 |
particularly interesting. Embedding uninterpreted text within an |
12666 | 675 |
informal body might appear useless at first sight. Here the key |
676 |
virtue is that the string $s$ is processed as Isabelle output, |
|
677 |
interpreting Isabelle symbols appropriately. |
|
12658 | 678 |
|
12666 | 679 |
For example, \texttt{\at}\verb,{text "\<forall>\<exists>"}, produces \isa{{\isasymforall}{\isasymexists}}, according to the standard interpretation of these symbol |
680 |
(cf.\ \S\ref{sec:doc-prep-symbols}). Thus we achieve consistent |
|
12658 | 681 |
mathematical notation in both the formal and informal parts of the |
12767 | 682 |
document very easily, independently of the term language of |
683 |
Isabelle. Manual {\LaTeX} code would leave more control over the |
|
684 |
typesetting, but is also slightly more tedious.% |
|
12644 | 685 |
\end{isamarkuptext}% |
686 |
\isamarkuptrue% |
|
687 |
% |
|
12674 | 688 |
\isamarkupsubsection{Interpretation of Symbols \label{sec:doc-prep-symbols}% |
12644 | 689 |
} |
690 |
\isamarkuptrue% |
|
691 |
% |
|
692 |
\begin{isamarkuptext}% |
|
12666 | 693 |
As has been pointed out before (\S\ref{sec:syntax-symbols}), |
12671 | 694 |
Isabelle symbols are the smallest syntactic entities --- a |
12682 | 695 |
straightforward generalization of ASCII characters. While Isabelle |
12666 | 696 |
does not impose any interpretation of the infinite collection of |
12764 | 697 |
named symbols, {\LaTeX} documents use canonical glyphs for certain |
12671 | 698 |
standard symbols \cite[appendix~A]{isabelle-sys}. |
12658 | 699 |
|
12767 | 700 |
The {\LaTeX} code produced from Isabelle text follows a simple |
701 |
scheme. You can tune the final appearance by redefining certain |
|
702 |
macros, say in \texttt{root.tex} of the document. |
|
12671 | 703 |
|
704 |
\begin{enumerate} |
|
12658 | 705 |
|
12671 | 706 |
\item 7-bit ASCII characters: letters \texttt{A\dots Z} and |
12747 | 707 |
\texttt{a\dots z} are output directly, digits are passed as an |
12671 | 708 |
argument to the \verb,\isadigit, macro, other characters are |
709 |
replaced by specifically named macros of the form |
|
12666 | 710 |
\verb,\isacharXYZ,. |
12658 | 711 |
|
12767 | 712 |
\item Named symbols: \verb,\,\verb,<XYZ>, is turned into |
713 |
\verb,{\isasymXYZ},; note the additional braces. |
|
12658 | 714 |
|
12767 | 715 |
\item Named control symbols: \verb,\,\verb,<^XYZ>, is turned into |
716 |
\verb,\isactrlXYZ,; subsequent symbols may act as arguments if the |
|
717 |
control macro is defined accordingly. |
|
12671 | 718 |
|
12666 | 719 |
\end{enumerate} |
720 |
||
12764 | 721 |
You may occasionally wish to give new {\LaTeX} interpretations of |
722 |
named symbols. This merely requires an appropriate definition of |
|
12767 | 723 |
\verb,\isasymXYZ,, for \verb,\,\verb,<XYZ>, (see |
12747 | 724 |
\texttt{isabelle.sty} for working examples). Control symbols are |
725 |
slightly more difficult to get right, though. |
|
12666 | 726 |
|
727 |
\medskip The \verb,\isabellestyle, macro provides a high-level |
|
728 |
interface to tune the general appearance of individual symbols. For |
|
12671 | 729 |
example, \verb,\isabellestyle{it}, uses the italics text style to |
730 |
mimic the general appearance of the {\LaTeX} math mode; double |
|
12743 | 731 |
quotes are not printed at all. The resulting quality of typesetting |
732 |
is quite good, so this should be the default style for work that |
|
733 |
gets distributed to a broader audience.% |
|
12644 | 734 |
\end{isamarkuptext}% |
735 |
\isamarkuptrue% |
|
736 |
% |
|
12652 | 737 |
\isamarkupsubsection{Suppressing Output \label{sec:doc-prep-suppress}% |
12644 | 738 |
} |
739 |
\isamarkuptrue% |
|
740 |
% |
|
741 |
\begin{isamarkuptext}% |
|
12749 | 742 |
By default, Isabelle's document system generates a {\LaTeX} file for |
743 |
each theory that gets loaded while running the session. The |
|
744 |
generated \texttt{session.tex} will include all of these in order of |
|
745 |
appearance, which in turn gets included by the standard |
|
12743 | 746 |
\texttt{root.tex}. Certainly one may change the order or suppress |
12747 | 747 |
unwanted theories by ignoring \texttt{session.tex} and load |
748 |
individual files directly in \texttt{root.tex}. On the other hand, |
|
749 |
such an arrangement requires additional maintenance whenever the |
|
750 |
collection of theories changes. |
|
12647 | 751 |
|
752 |
Alternatively, one may tune the theory loading process in |
|
12652 | 753 |
\texttt{ROOT.ML} itself: traversal of the theory dependency graph |
12671 | 754 |
may be fine-tuned by adding \verb,use_thy, invocations, although |
755 |
topological sorting still has to be observed. Moreover, the ML |
|
756 |
operator \verb,no_document, temporarily disables document generation |
|
12767 | 757 |
while executing a theory loader command. Its usage is like this: |
12647 | 758 |
|
759 |
\begin{verbatim} |
|
12666 | 760 |
no_document use_thy "T"; |
12647 | 761 |
\end{verbatim} |
12644 | 762 |
|
12767 | 763 |
\medskip Theory output may be suppressed more selectively. Research |
764 |
articles and slides usually do not include the formal content in |
|
765 |
full. Delimiting \bfindex{ignored material} by the special source |
|
766 |
comments \verb,(,\verb,*,\verb,<,\verb,*,\verb,), and |
|
767 |
\verb,(,\verb,*,\verb,>,\verb,*,\verb,), tells the document |
|
768 |
preparation system to suppress these parts; the formal checking of |
|
12771 | 769 |
the theory is unchanged, of course. |
12647 | 770 |
|
12767 | 771 |
In this example, we hide a theory's \isakeyword{theory} and |
772 |
\isakeyword{end} brackets: |
|
12647 | 773 |
|
774 |
\medskip |
|
775 |
||
776 |
\begin{tabular}{l} |
|
777 |
\verb,(,\verb,*,\verb,<,\verb,*,\verb,), \\ |
|
12666 | 778 |
\texttt{theory T = Main:} \\ |
12647 | 779 |
\verb,(,\verb,*,\verb,>,\verb,*,\verb,), \\ |
780 |
~~$\vdots$ \\ |
|
781 |
\verb,(,\verb,*,\verb,<,\verb,*,\verb,), \\ |
|
782 |
\texttt{end} \\ |
|
783 |
\verb,(,\verb,*,\verb,>,\verb,*,\verb,), \\ |
|
784 |
\end{tabular} |
|
785 |
||
786 |
\medskip |
|
787 |
||
12764 | 788 |
Text may be suppressed in a fine-grained manner. We may even hide |
12747 | 789 |
vital parts of a proof, pretending that things have been simpler |
12767 | 790 |
than they really were. For example, this ``fully automatic'' proof |
791 |
is actually a fake:% |
|
12649 | 792 |
\end{isamarkuptext}% |
793 |
\isamarkuptrue% |
|
794 |
\isacommand{lemma}\ {\isachardoublequote}x\ {\isasymnoteq}\ {\isacharparenleft}{\isadigit{0}}{\isacharcolon}{\isacharcolon}int{\isacharparenright}\ {\isasymLongrightarrow}\ {\isadigit{0}}\ {\isacharless}\ x\ {\isacharasterisk}\ x{\isachardoublequote}\isanewline |
|
795 |
\ \ \isamarkupfalse% |
|
796 |
\isacommand{by}\ {\isacharparenleft}auto{\isacharparenright}\isamarkupfalse% |
|
797 |
% |
|
798 |
\begin{isamarkuptext}% |
|
799 |
\noindent Here the real source of the proof has been as follows: |
|
800 |
||
801 |
\begin{verbatim} |
|
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
13791
diff
changeset
|
802 |
by (auto(*<*)simp add: zero_less_mult_iff(*>*)) |
12658 | 803 |
\end{verbatim} |
804 |
%(* |
|
12649 | 805 |
|
12767 | 806 |
\medskip Suppressing portions of printed text demands care. You |
807 |
should not misrepresent the underlying theory development. It is |
|
808 |
easy to invalidate the visible text by hiding references to |
|
809 |
questionable axioms. |
|
12652 | 810 |
|
12747 | 811 |
Authentic reports of Isabelle/Isar theories, say as part of a |
12767 | 812 |
library, should suppress nothing. Other users may need the full |
813 |
information for their own derivative work. If a particular |
|
814 |
formalization appears inadequate for general public coverage, it is |
|
815 |
often more appropriate to think of a better way in the first place. |
|
12671 | 816 |
|
817 |
\medskip Some technical subtleties of the |
|
12666 | 818 |
\verb,(,\verb,*,\verb,<,\verb,*,\verb,),~\verb,(,\verb,*,\verb,>,\verb,*,\verb,), |
12764 | 819 |
elements need to be kept in mind, too --- the system performs few |
12671 | 820 |
sanity checks here. Arguments of markup commands and formal |
12649 | 821 |
comments must not be hidden, otherwise presentation fails. Open and |
12751 | 822 |
close parentheses need to be inserted carefully; it is easy to hide |
823 |
the wrong parts, especially after rearranging the theory text.% |
|
12635 | 824 |
\end{isamarkuptext}% |
12627 | 825 |
\isamarkuptrue% |
11866 | 826 |
\isamarkupfalse% |
11648 | 827 |
\end{isabellebody}% |
828 |
%%% Local Variables: |
|
829 |
%%% mode: latex |
|
830 |
%%% TeX-master: "root" |
|
831 |
%%% End: |