2 theory Documents = Main:
5 section {* Concrete Syntax \label{sec:concrete-syntax} *}
8 Concerning Isabelle's ``inner'' language of simply-typed @{text
9 \<lambda>}-calculus, the core concept of Isabelle's elaborate
10 infrastructure for concrete syntax is that of general
11 \bfindex{mixfix annotations}. Associated with any kind of constant
12 declaration, mixfixes affect both the grammar productions for the
13 parser and output templates for the pretty printer.
15 In full generality, the whole affair of parser and pretty printer
16 configuration is rather subtle, see also \cite{isabelle-ref}.
17 Syntax specifications given by end-users need to interact properly
18 with the existing setup of Isabelle/Pure and Isabelle/HOL. It is
19 particularly important to get the precedence of new syntactic
20 constructs right, avoiding ambiguities with existing elements.
22 \medskip Subsequently we introduce a few simple syntax declaration
23 forms that already cover most common situations fairly well.
27 subsection {* Infix Annotations *}
30 Syntax annotations may be included wherever constants are declared
31 directly or indirectly, including \isacommand{consts},
32 \isacommand{constdefs}, or \isacommand{datatype} (for the
33 constructor operations). Type-constructors may be annotated as
34 well, although this is less frequently encountered in practice
35 (@{text "*"} and @{text "+"} types may come to mind).
37 Infix declarations\index{infix annotations} provide a useful special
38 case of mixfixes, where users need not care about the full details
39 of priorities, nesting, spacing, etc. The following example of the
40 exclusive-or operation on boolean values illustrates typical infix
41 declarations arising in practice.
45 xor :: "bool \<Rightarrow> bool \<Rightarrow> bool" (infixl "[+]" 60)
46 "A [+] B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
49 \noindent Now @{text "xor A B"} and @{text "A [+] B"} refer to the
50 same expression internally. Any curried function with at least two
51 arguments may be associated with infix syntax. For partial
52 applications with less than two operands there is a special notation
53 with \isa{op} prefix: @{text xor} without arguments is represented
54 as @{text "op [+]"}; together with plain prefix application this
55 turns @{text "xor A"} into @{text "op [+] A"}.
57 \medskip The string @{text [source] "[+]"} in the above annotation
58 refers to the bit of concrete syntax to represent the operator,
59 while the number @{text 60} determines the precedence of the
60 construct (i.e.\ the syntactic priorities of the arguments and
63 As it happens, Isabelle/HOL already spends many popular combinations
64 of ASCII symbols for its own use, including both @{text "+"} and
65 @{text "++"}. Slightly more awkward combinations like the present
66 @{text "[+]"} tend to be available for user extensions. The current
67 arrangement of inner syntax may be inspected via
68 \commdx{print\protect\_syntax}, albeit its output is enormous.
70 Operator precedence also needs some special considerations. The
71 admissible range is 0--1000. Very low or high priorities are
72 basically reserved for the meta-logic. Syntax of Isabelle/HOL
73 mainly uses the range of 10--100: the equality infix @{text "="} is
74 centered at 50, logical connectives (like @{text "\<or>"} and @{text
75 "\<and>"}) are below 50, and algebraic ones (like @{text "+"} and @{text
76 "*"}) above 50. User syntax should strive to coexist with common
77 HOL forms, or use the mostly unused range 100--900.
79 The keyword \isakeyword{infixl} specifies an infix operator that is
80 nested to the \emph{left}: in iterated applications the more complex
81 expression appears on the left-hand side: @{term "A [+] B [+] C"}
82 stands for @{text "(A [+] B) [+] C"}. Similarly,
83 \isakeyword{infixr} specifies to nesting to the \emph{right},
84 reading @{term "A [+] B [+] C"} as @{text "A [+] (B [+] C)"}. In
85 contrast, a \emph{non-oriented} declaration via \isakeyword{infix}
86 would render @{term "A [+] B [+] C"} illegal, but demand explicit
87 parentheses to indicate the intended grouping.
91 subsection {* Mathematical Symbols \label{sec:syntax-symbols} *}
94 Concrete syntax based on plain ASCII characters has its inherent
95 limitations. Rich mathematical notation demands a larger repertoire
96 of glyphs. Several standards of extended character sets have been
97 proposed over decades, but none has become universally available so
98 far. Isabelle supports a generic notion of \bfindex{symbols} as the
99 smallest entities of source text, without referring to internal
100 encodings. There are three kinds of such ``generalized
105 \item 7-bit ASCII characters
107 \item named symbols: \verb,\,\verb,<,$ident$\verb,>,
109 \item named control symbols: \verb,\,\verb,<^,$ident$\verb,>,
113 Here $ident$ may be any identifier according to the usual Isabelle
114 conventions. This results in an infinite store of symbols, whose
115 interpretation is left to further front-end tools. For example,
116 both the user-interface of Proof~General + X-Symbol and the Isabelle
117 document processor (see \S\ref{sec:document-preparation}) display
118 the \verb,\,\verb,<forall>, symbol really as @{text \<forall>}.
120 A list of standard Isabelle symbols is given in
121 \cite[appendix~A]{isabelle-sys}. Users may introduce their own
122 interpretation of further symbols by configuring the appropriate
123 front-end tool accordingly, e.g.\ by defining certain {\LaTeX}
124 macros (see also \S\ref{sec:doc-prep-symbols}). There are also a
125 few predefined control symbols, such as \verb,\,\verb,<^sub>, and
126 \verb,\,\verb,<^sup>, for sub- and superscript of the subsequent
127 (printable) symbol, respectively. For example, \verb,A\<^sup>\<star>, is
128 output as @{text "A\<^sup>\<star>"}.
130 \medskip The following version of our @{text xor} definition uses a
131 standard Isabelle symbol to achieve typographically more pleasing
137 ML_setup {* Context.>> (Theory.add_path "version1") *}
140 xor :: "bool \<Rightarrow> bool \<Rightarrow> bool" (infixl "\<oplus>" 60)
141 "A \<oplus> B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
147 \noindent The X-Symbol package within Proof~General provides several
148 input methods to enter @{text \<oplus>} in the text. If all fails one may
149 just type a named entity \verb,\,\verb,<oplus>, by hand; the display
150 will be adapted immediately after continuing input.
152 \medskip A slightly more refined scheme is to provide alternative
153 syntax via the \bfindex{print mode} concept of Isabelle (see also
154 \cite{isabelle-ref}). By convention, the mode of ``$xsymbols$'' is
155 enabled whenever Proof~General's X-Symbol mode (or {\LaTeX} output)
156 is active. Now consider the following hybrid declaration of @{text
162 ML_setup {* Context.>> (Theory.add_path "version2") *}
165 xor :: "bool \<Rightarrow> bool \<Rightarrow> bool" (infixl "[+]\<ignore>" 60)
166 "A [+]\<ignore> B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
169 xor :: "bool \<Rightarrow> bool \<Rightarrow> bool" (infixl "\<oplus>\<ignore>" 60)
175 The \commdx{syntax} command introduced here acts like
176 \isakeyword{consts}, but without declaring a logical constant; an
177 optional print mode specification may be given, too. Note that the
178 type declaration given above merely serves for syntactic purposes,
179 and is not checked for consistency with the real constant.
181 \medskip We may now write @{text "A [+] B"} or @{text "A \<oplus> B"} in
182 input, while output uses the nicer syntax of $xsymbols$, provided
183 that print mode is active. Such an arrangement is particularly
184 useful for interactive development, where users may type plain ASCII
185 text, but gain improved visual feedback from the system.
188 Alternative syntax declarations are apt to result in varying
189 occurrences of concrete syntax in the input sources. Isabelle
190 provides no systematic way to convert alternative syntax expressions
191 back and forth; print modes only affect situations where formal
192 entities are pretty printed by the Isabelle process (e.g.\ output of
193 terms and types), but not the original theory text.
196 \medskip The following variant makes the alternative @{text \<oplus>}
197 notation only available for output. Thus we may enforce input
198 sources to refer to plain ASCII only, but effectively disable
199 cut-and-paste from output at the same time.
202 syntax (xsymbols output)
203 xor :: "bool \<Rightarrow> bool \<Rightarrow> bool" (infixl "\<oplus>\<ignore>" 60)
206 subsection {* Prefix Annotations *}
209 Prefix syntax annotations\index{prefix annotation} are just another
210 degenerate form of mixfixes \cite{isabelle-ref}, without any
211 template arguments or priorities --- just some bits of literal
212 syntax. The following example illustrates this idea idea by
213 associating common symbols with the constructors of a datatype.
218 | Pounds nat ("\<pounds>")
223 \noindent Here the mixfix annotations on the rightmost column happen
224 to consist of a single Isabelle symbol each: \verb,\,\verb,<euro>,,
225 \verb,\,\verb,<pounds>,, \verb,\,\verb,<yen>,, and \verb,$,. Recall
226 that a constructor like @{text Euro} actually is a function @{typ
227 "nat \<Rightarrow> currency"}. An expression like @{text "Euro 10"} will be
228 printed as @{term "\<euro> 10"}; only the head of the application is
229 subject to our concrete syntax. This simple form already achieves
230 conformance with notational standards of the European Commission.
232 Prefix syntax also works for plain \isakeyword{consts} or
233 \isakeyword{constdefs}, of course.
237 subsection {* Syntax Translations \label{sec:syntax-translations} *}
240 Mixfix syntax annotations work well in those situations where
241 particular constant application forms need to be decorated by
242 concrete syntax; just reconsider @{text "xor A B"} versus @{text "A
243 \<oplus> B"} covered before. Occasionally the relationship between some
244 piece of notation and its internal form is slightly more involved.
245 Here the concept of \bfindex{syntax translations} enters the scene.
247 Using the raw \isakeyword{syntax}\index{syntax (command)} command we
248 may introduce uninterpreted notational elements, while
249 \commdx{translations} relates input forms with more complex logical
250 expressions. This essentially provides a simple mechanism for
251 syntactic macros; even heavier transformations may be written in ML
254 \medskip A typical example of syntax translations is to decorate
255 relational expressions (i.e.\ set-membership of tuples) with
256 handsome symbolic notation, such as @{text "(x, y) \<in> sim"} versus
257 @{text "x \<approx> y"}.
261 sim :: "('a \<times> 'a) set"
264 "_sim" :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<approx>" 50)
266 "x \<approx> y" \<rightleftharpoons> "(x, y) \<in> sim"
269 \noindent Here the name of the dummy constant @{text "_sim"} does
270 not really matter, as long as it is not used elsewhere. Prefixing
271 an underscore is a common convention. The \isakeyword{translations}
272 declaration already uses concrete syntax on the left-hand side;
273 internally we relate a raw application @{text "_sim x y"} with
274 @{text "(x, y) \<in> sim"}.
276 \medskip Another common application of syntax translations is to
277 provide variant versions of fundamental relational expressions, such
278 as @{text \<noteq>} for negated equalities. The following declaration
279 stems from Isabelle/HOL itself:
282 syntax "_not_equal" :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "\<noteq>\<ignore>" 50)
283 translations "x \<noteq>\<ignore> y" \<rightleftharpoons> "\<not> (x = y)"
286 \noindent Normally one would introduce derived concepts like this
287 within the logic, using \isakeyword{consts} + \isakeyword{defs}
288 instead of \isakeyword{syntax} + \isakeyword{translations}. The
289 present formulation has the virtue that expressions are immediately
290 replaced by the ``definition'' upon parsing; the effect is reversed
293 Simulating definitions via translations is adequate for very basic
294 principles, where a new representation is a trivial variation on an
295 existing one. On the other hand, syntax translations do not scale
296 up well to large hierarchies of concepts built on each other.
300 section {* Document Preparation \label{sec:document-preparation} *}
303 Isabelle/Isar is centered around the concept of \bfindex{formal
304 proof documents}\index{documents|bold}. The ultimate result of a
305 formal development effort is meant to be a human-readable record,
306 presented as browsable PDF file or printed on paper. The overall
307 document structure follows traditional mathematical articles, with
308 sections, intermediate explanations, definitions, theorems and
311 The Isar proof language \cite{Wenzel-PhD}, which is not covered in
312 this book, admits to write formal proof texts that are acceptable
313 both to the machine and human readers at the same time. Thus
314 marginal comments and explanations may be kept at a minimum. Even
315 without proper coverage of human-readable proofs, Isabelle document
316 preparation is very useful to produce formally derived texts.
317 Unstructured proof scripts given here may be just ignored by
318 readers, or intentionally suppressed from the text by the writer
319 (see also \S\ref{sec:doc-prep-suppress}).
321 \medskip The Isabelle document preparation system essentially acts
322 as a front-end to {\LaTeX}. After checking specifications and
323 proofs formally, the theory sources are turned into typesetting
324 instructions in a schematic manner. This enables users to write
325 authentic reports on theory developments with little effort, where
326 most consistency checks are handled by the system.
330 subsection {* Isabelle Sessions *}
333 In contrast to the highly interactive mode of Isabelle/Isar theory
334 development, the document preparation stage essentially works in
335 batch-mode. An Isabelle \bfindex{session} consists of a collection
336 of theory source files that contribute to an output document
337 eventually. Each session is derived from a single parent, usually
338 an object-logic image like \texttt{HOL}. This results in an overall
339 tree structure, which is reflected by the output location in the
340 file system (usually rooted at \verb,~/isabelle/browser_info,).
342 \medskip Here is the canonical arrangement of sources of a session
343 called \texttt{MySession}:
347 \item Directory \texttt{MySession} holds the required theory files
348 $T@1$\texttt{.thy}, \dots, $T@n$\texttt{.thy}.
350 \item File \texttt{MySession/ROOT.ML} holds appropriate ML commands
351 for loading all wanted theories, usually just
352 ``\texttt{use_thy"$T@i$";}'' for any $T@i$ in leaf position of the
355 \item Directory \texttt{MySession/document} contains everything
356 required for the {\LaTeX} stage; only \texttt{root.tex} needs to be
359 The latter file holds appropriate {\LaTeX} code to commence a
360 document (\verb,\documentclass, etc.), and to include the generated
361 files $T@i$\texttt{.tex} for each theory. The generated
362 \texttt{session.tex} will contain {\LaTeX} commands to include all
363 generated files in topologically sorted order, so
364 \verb,\input{session}, in \texttt{root.tex} does the job in most
367 \item \texttt{IsaMakefile} holds appropriate dependencies and
368 invocations of Isabelle tools to control the batch job. In fact,
369 several sessions may be controlled by the same \texttt{IsaMakefile}.
370 See also \cite{isabelle-sys} for further details, especially on
371 \texttt{isatool usedir} and \texttt{isatool make}.
375 With everything put in its proper place, \texttt{isatool make}
376 should be sufficient to process the Isabelle session completely,
377 with the generated document appearing in its proper place.
379 \medskip In reality, users may want to have \texttt{isatool mkdir}
380 generate an initial working setup without further ado. For example,
381 a new session \texttt{MySession} derived from \texttt{HOL} may be
385 isatool mkdir HOL MySession
389 This processes the session with sensible default options, including
390 verbose mode to tell the user where the ultimate results will
391 appear. The above dry run should already be able to produce a
392 single page of output (with a dummy title, empty table of contents
393 etc.). Any failure at that stage is likely to indicate technical
394 problems with the user's {\LaTeX} installation.\footnote{Especially
395 make sure that \texttt{pdflatex} is present; if all fails one may
396 fall back on DVI output by changing \texttt{usedir} options in
397 \texttt{IsaMakefile} \cite{isabelle-sys}.}
399 \medskip One may now start to populate the directory
400 \texttt{MySession}, and the file \texttt{MySession/ROOT.ML}
401 accordingly. \texttt{MySession/document/root.tex} should also be
402 adapted at some point; the default version is mostly
403 self-explanatory. Note that \verb,\isabellestyle, enables
404 fine-tuning of the general appearance of characters and mathematical
405 symbols (see also \S\ref{sec:doc-prep-symbols}).
407 Especially observe inclusion of the {\LaTeX} packages
408 \texttt{isabelle} (mandatory), and \texttt{isabellesym} (required
409 for mathematical symbols), and the final \texttt{pdfsetup} (provides
410 handsome defaults for \texttt{hyperref}, including URL markup).
411 Further packages may be required in particular applications, e.g.\
412 for unusual Isabelle symbols.
414 \medskip Additional files for the {\LaTeX} stage may be included in
415 the directory \texttt{MySession/document}, too, such as {\TeX}
416 sources or graphics). In particular, adding \texttt{root.bib} here
417 (with that specific name) causes an automatic run of \texttt{bibtex}
418 to process a bibliographic database; see also \texttt{isatool
419 document} covered in \cite{isabelle-sys}.
421 \medskip Any failure of the document preparation phase in an
422 Isabelle batch session leaves the generated sources in their target
423 location (as pointed out by the accompanied error message). This
424 enables users to trace {\LaTeX} at the file positions of the
429 subsection {* Structure Markup *}
432 The large-scale structure of Isabelle documents follows existing
433 {\LaTeX} conventions, with chapters, sections, subsubsections etc.
434 The Isar language includes separate \bfindex{markup commands}, which
435 do not affect the formal meaning of a theory (or proof), but result
436 in corresponding {\LaTeX} elements.
438 There are separate markup commands depending on the textual context:
439 in header position (just before \isakeyword{theory}), within the
440 theory body, or within a proof. The header needs to be treated
441 specially here, since ordinary theory and proof commands may only
442 occur \emph{after} the initial \isakeyword{theory} specification.
446 \begin{tabular}{llll}
447 header & theory & proof & default meaning \\\hline
448 & \commdx{chapter} & & \verb,\chapter, \\
449 \commdx{header} & \commdx{section} & \commdx{sect} & \verb,\section, \\
450 & \commdx{subsection} & \commdx{subsect} & \verb,\subsection, \\
451 & \commdx{subsubsection} & \commdx{subsubsect} & \verb,\subsubsection, \\
456 From the Isabelle perspective, each markup command takes a single
457 $text$ argument (delimited by \verb,",\dots\verb,", or
458 \verb,{,\verb,*,~\dots~\verb,*,\verb,},). After stripping any
459 surrounding white space, the argument is passed to a {\LaTeX} macro
460 \verb,\isamarkupXYZ, for any command \isakeyword{XYZ}. These macros
461 are defined in \verb,isabelle.sty, according to the meaning given in
462 the rightmost column above.
464 \medskip The following source fragment illustrates structure markup
465 of a theory. Note that {\LaTeX} labels may be included inside of
466 section headings as well.
469 header {\ttlbrace}* Some properties of Foo Bar elements *{\ttrbrace}
471 theory Foo_Bar = Main:
473 subsection {\ttlbrace}* Basic definitions *{\ttrbrace}
481 subsection {\ttlbrace}* Derived rules *{\ttrbrace}
486 subsection {\ttlbrace}* Main theorem {\ttback}label{\ttlbrace}sec:main-theorem{\ttrbrace} *{\ttrbrace}
493 Users may occasionally want to change the meaning of markup
494 commands, say via \verb,\renewcommand, in \texttt{root.tex};
495 \verb,\isamarkupheader, is a good candidate for some tuning, e.g.\
496 moving it up in the hierarchy to become \verb,\chapter,.
499 \renewcommand{\isamarkupheader}[1]{\chapter{#1}}
502 \noindent Certainly, this requires to change the default
503 \verb,\documentclass{article}, in \texttt{root.tex} to something
504 that supports the notion of chapters in the first place, e.g.\
505 \verb,\documentclass{report},.
507 \medskip The {\LaTeX} macro \verb,\isabellecontext, is maintained to
508 hold the name of the current theory context. This is particularly
509 useful for document headings:
512 \renewcommand{\isamarkupheader}[1]
513 {\chapter{#1}\markright{THEORY~\isabellecontext}}
516 \noindent Make sure to include something like
517 \verb,\pagestyle{headings}, in \texttt{root.tex}; the document
518 should have more than 2 pages to show the effect.
522 subsection {* Formal Comments and Antiquotations *}
525 Isabelle source comments, which are of the form
526 \verb,(,\verb,*,~\dots~\verb,*,\verb,),, essentially act like white
527 space and do not really contribute to the content. They mainly
528 serve technical purposes to mark certain oddities in the raw input
529 text. In contrast, \bfindex{formal comments} are portions of text
530 that are associated with formal Isabelle/Isar commands
531 (\bfindex{marginal comments}), or as standalone paragraphs within a
532 theory or proof context (\bfindex{text blocks}).
534 \medskip Marginal comments are part of each command's concrete
535 syntax \cite{isabelle-ref}; the common form is ``\verb,--,~$text$''
536 where $text$ is delimited by \verb,",\dots\verb,", or
537 \verb,{,\verb,*,~\dots~\verb,*,\verb,}, as before. Multiple
538 marginal comments may be given at the same time. Here is a simple
543 -- "a triviality of propositional logic"
544 -- "(should not really bother)"
545 by (rule impI) -- "implicit assumption step involved here"
548 \noindent The above output has been produced as follows:
552 -- "a triviality of propositional logic"
553 -- "(should not really bother)"
554 by (rule impI) -- "implicit assumption step involved here"
557 From the {\LaTeX} viewpoint, ``\verb,--,'' acts like a markup
558 command, associated with the macro \verb,\isamarkupcmt, (taking a
561 \medskip Text blocks are introduced by the commands \bfindex{text}
562 and \bfindex{txt}, for theory and proof contexts, respectively.
563 Each takes again a single $text$ argument, which is interpreted as a
564 free-form paragraph in {\LaTeX} (surrounded by some additional
565 vertical space). This behavior may be changed by redefining the
566 {\LaTeX} environments of \verb,isamarkuptext, or
567 \verb,isamarkuptxt,, respectively (via \verb,\renewenvironment,) The
568 text style of the body is determined by \verb,\isastyletext, and
569 \verb,\isastyletxt,; the default setup uses a smaller font within
572 \medskip The $text$ part of each of the various markup commands
573 considered so far essentially inserts \emph{quoted material} into a
574 formal text, mainly for instruction of the reader. An
575 \bfindex{antiquotation} is again a formal object embedded into such
576 an informal portion. The interpretation of antiquotations is
577 limited to some well-formedness checks, with the result being pretty
578 printed to the resulting document. So quoted text blocks together
579 with antiquotations provide very handsome means to reference formal
580 entities with good confidence in getting the technical details right
581 (especially syntax and types).
583 The general syntax of antiquotations is as follows:
584 \texttt{{\at}{\ttlbrace}$name$ $arguments${\ttrbrace}}, or
585 \texttt{{\at}{\ttlbrace}$name$ [$options$] $arguments${\ttrbrace}}
586 for a comma-separated list of options consisting of a $name$ or
587 \texttt{$name$=$value$}. The syntax of $arguments$ depends on the
588 kind of antiquotation, it generally follows the same conventions for
589 types, terms, or theorems as in the formal part of a theory.
591 \medskip Here is an example of the quotation-antiquotation
592 technique: @{term "%x y. x"} is a well-typed term.
594 \medskip\noindent The above output has been produced as follows:
597 Here is an example of the quotation-antiquotation technique:
598 {\at}{\ttlbrace}term "%x y. x"{\ttrbrace} is a well-typed term.
602 From the notational change of the ASCII character \verb,%, to the
603 symbol @{text \<lambda>} we see that the term really got printed by the
604 system (after parsing and type-checking) --- document preparation
605 enables symbolic output by default.
607 \medskip The next example includes an option to modify the
608 \verb,show_types, flag of Isabelle:
609 \texttt{{\at}}\verb,{term [show_types] "%x y. x"}, produces @{term
610 [show_types] "%x y. x"}. Type-inference has figured out the most
611 general typings in the present (theory) context. Note that term
612 fragments may acquire different typings due to constraints imposed
613 by previous text (say within a proof), e.g.\ due to the main goal
614 statement given beforehand.
616 \medskip Several further kinds of antiquotations (and options) are
617 available \cite{isabelle-sys}. Here are a few commonly used
623 \texttt{\at}\verb,{typ,~$\tau$\verb,}, & print type $\tau$ \\
624 \texttt{\at}\verb,{term,~$t$\verb,}, & print term $t$ \\
625 \texttt{\at}\verb,{prop,~$\phi$\verb,}, & print proposition $\phi$ \\
626 \texttt{\at}\verb,{prop [display],~$\phi$\verb,}, & print large proposition $\phi$ (with linebreaks) \\
627 \texttt{\at}\verb,{prop [source],~$\phi$\verb,}, & check proposition $\phi$, print its input \\
628 \texttt{\at}\verb,{thm,~$a$\verb,}, & print fact $a$ \\
629 \texttt{\at}\verb,{thm,~$a$~\verb,[no_vars]}, & print fact $a$, fixing schematic variables \\
630 \texttt{\at}\verb,{thm [source],~$a$\verb,}, & check validity of fact $a$, print its name \\
631 \texttt{\at}\verb,{text,~$s$\verb,}, & print uninterpreted text $s$ \\
636 Note that \attrdx{no_vars} given above is \emph{not} an
637 antiquotation option, but an attribute of the theorem argument given
638 here. This might be useful with a diagnostic command like
639 \isakeyword{thm}, too.
641 \medskip The \texttt{\at}\verb,{text, $s$\verb,}, antiquotation is
642 particularly interesting. Embedding uninterpreted text within an
643 informal body might appear useless at first sight. Here the key
644 virtue is that the string $s$ is processed as Isabelle output,
645 interpreting Isabelle symbols appropriately.
647 For example, \texttt{\at}\verb,{text "\<forall>\<exists>"}, produces @{text
648 "\<forall>\<exists>"}, according to the standard interpretation of these symbol
649 (cf.\ \S\ref{sec:doc-prep-symbols}). Thus we achieve consistent
650 mathematical notation in both the formal and informal parts of the
651 document very easily. Manual {\LaTeX} code would leave more control
652 over the typesetting, but is also slightly more tedious.
656 subsection {* Interpretation of Symbols \label{sec:doc-prep-symbols} *}
659 As has been pointed out before (\S\ref{sec:syntax-symbols}),
660 Isabelle symbols are the smallest syntactic entities --- a
661 straightforward generalization of ASCII characters. While Isabelle
662 does not impose any interpretation of the infinite collection of
663 named symbols, {\LaTeX} documents show canonical glyphs for certain
664 standard symbols \cite[appendix~A]{isabelle-sys}.
666 The {\LaTeX} code produced from Isabelle text follows a relatively
667 simple scheme. Users may wish to tune the final appearance by
668 redefining certain macros, say in \texttt{root.tex} of the document.
672 \item 7-bit ASCII characters: letters \texttt{A\dots Z} and
673 \texttt{a\dots z} are output verbatim, digits are passed as an
674 argument to the \verb,\isadigit, macro, other characters are
675 replaced by specifically named macros of the form
678 \item Named symbols: \verb,\,\verb,<,$XYZ$\verb,>, become
679 \verb,{\isasym,$XYZ$\verb,}, each (note the additional braces).
681 \item Named control symbols: \verb,{\isasym,$XYZ$\verb,}, become
682 \verb,\isactrl,$XYZ$ each; subsequent symbols may act as arguments
683 if the corresponding macro is defined accordingly.
687 Users may occasionally wish to give new {\LaTeX} interpretations of
688 named symbols; this merely requires an appropriate definition of
689 \verb,\,\verb,<,$XYZ$\verb,>, (see \texttt{isabelle.sty} for working
690 examples). Control symbols are slightly more difficult to get
693 \medskip The \verb,\isabellestyle, macro provides a high-level
694 interface to tune the general appearance of individual symbols. For
695 example, \verb,\isabellestyle{it}, uses the italics text style to
696 mimic the general appearance of the {\LaTeX} math mode; double
697 quotes are not printed at all. The resulting quality of
698 typesetting is quite good, so this should usually be the default
699 style for real production work that gets distributed to a broader
704 subsection {* Suppressing Output \label{sec:doc-prep-suppress} *}
707 By default, Isabelle's document system generates a {\LaTeX} source
708 file for each theory that happens to get loaded while running the
709 session. The generated \texttt{session.tex} will include all of
710 these in order of appearance, which in turn gets included by the
711 standard \texttt{root.tex}. Certainly one may change the order or
712 suppress unwanted theories by ignoring \texttt{session.tex} and
713 include individual files in \texttt{root.tex} by hand. On the other
714 hand, such an arrangement requires additional maintenance chores
715 whenever the collection of theories changes.
717 Alternatively, one may tune the theory loading process in
718 \texttt{ROOT.ML} itself: traversal of the theory dependency graph
719 may be fine-tuned by adding \verb,use_thy, invocations, although
720 topological sorting still has to be observed. Moreover, the ML
721 operator \verb,no_document, temporarily disables document generation
722 while executing a theory loader command; its usage is like this:
725 no_document use_thy "T";
728 \medskip Theory output may also be suppressed in smaller portions.
729 For example, research articles, or slides usually do not include the
730 formal content in full. In order to delimit \bfindex{ignored
731 material} special source comments
732 \verb,(,\verb,*,\verb,<,\verb,*,\verb,), and
733 \verb,(,\verb,*,\verb,>,\verb,*,\verb,), may be included in the
734 text. Only the document preparation system is affected, the formal
735 checking the theory is performed unchanged.
737 In the following example we suppress the slightly formalistic
738 \isakeyword{theory} + \isakeyword{end} surroundings a theory.
743 \verb,(,\verb,*,\verb,<,\verb,*,\verb,), \\
744 \texttt{theory T = Main:} \\
745 \verb,(,\verb,*,\verb,>,\verb,*,\verb,), \\
747 \verb,(,\verb,*,\verb,<,\verb,*,\verb,), \\
749 \verb,(,\verb,*,\verb,>,\verb,*,\verb,), \\
754 Text may be suppressed in a fine-grained manner. We may even drop
755 vital parts of a formal proof, pretending that things have been
756 simpler than in reality. For example, the following ``fully
757 automatic'' proof is actually a fake:
760 lemma "x \<noteq> (0::int) \<Longrightarrow> 0 < x * x"
761 by (auto(*<*)simp add: int_less_le(*>*))
764 \noindent Here the real source of the proof has been as follows:
767 by (auto(*<*)simp add: int_less_le(*>*))
771 \medskip Ignoring portions of printed text does demand some care by
772 the writer. First of all, the writer is responsible not to
773 obfuscate the underlying formal development in an unduly manner. It
774 is fairly easy to invalidate the remaining visible text, e.g.\ by
775 referencing questionable formal items (strange definitions,
776 arbitrary axioms etc.) that have been hidden from sight beforehand.
778 Authentic reports of formal theories, say as part of a library,
779 usually should refrain from suppressing parts of the text at all.
780 Other users may need the full information for their own derivative
781 work. If a particular formalization appears inadequate for general
782 public coverage, it is often more appropriate to think of a better
783 way in the first place.
785 \medskip Some technical subtleties of the
786 \verb,(,\verb,*,\verb,<,\verb,*,\verb,),~\verb,(,\verb,*,\verb,>,\verb,*,\verb,),
787 elements need to be kept in mind, too --- the system performs little
788 sanity checks here. Arguments of markup commands and formal
789 comments must not be hidden, otherwise presentation fails. Open and
790 close parentheses need to be inserted carefully; it is fairly easy
791 to hide the wrong parts, especially after rearranging the sources.