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