doc-src/TutorialI/Documents/document/Documents.tex
changeset 12743 46e3ef8dd9ea
parent 12686 2b0aa746e4b8
child 12745 d7b4d8c9bf86
equal deleted inserted replaced
12742:83cd2140977d 12743:46e3ef8dd9ea
     6 \isamarkupsection{Concrete Syntax \label{sec:concrete-syntax}%
     6 \isamarkupsection{Concrete Syntax \label{sec:concrete-syntax}%
     7 }
     7 }
     8 \isamarkuptrue%
     8 \isamarkuptrue%
     9 %
     9 %
    10 \begin{isamarkuptext}%
    10 \begin{isamarkuptext}%
    11 Concerning Isabelle's ``inner'' language of simply-typed \isa{{\isasymlambda}}-calculus, the core concept of Isabelle's elaborate
    11 The core concept of Isabelle's elaborate infrastructure for concrete
    12   infrastructure for concrete syntax is that of general
    12   syntax is that of general \bfindex{mixfix annotations}.  Associated
    13   \bfindex{mixfix annotations}.  Associated with any kind of constant
    13   with any kind of constant declaration, mixfixes affect both the
    14   declaration, mixfixes affect both the grammar productions for the
    14   grammar productions for the parser and output templates for the
    15   parser and output templates for the pretty printer.
    15   pretty printer.
    16 
    16 
    17   In full generality, the whole affair of parser and pretty printer
    17   In full generality, parser and pretty printer configuration is a
    18   configuration is rather subtle, see also \cite{isabelle-ref}.
    18   rather subtle affair, see \cite{isabelle-ref} for details.  Syntax
    19   Syntax specifications given by end-users need to interact properly
    19   specifications given by end-users need to interact properly with the
    20   with the existing setup of Isabelle/Pure and Isabelle/HOL.  It is
    20   existing setup of Isabelle/Pure and Isabelle/HOL.  It is
    21   particularly important to get the precedence of new syntactic
    21   particularly important to get the precedence of new syntactic
    22   constructs right, avoiding ambiguities with existing elements.
    22   constructs right, avoiding ambiguities with existing elements.
    23 
    23 
    24   \medskip Subsequently we introduce a few simple syntax declaration
    24   \medskip Subsequently we introduce a few simple syntax declaration
    25   forms that already cover most common situations fairly well.%
    25   forms that already cover many common situations fairly well.%
    26 \end{isamarkuptext}%
    26 \end{isamarkuptext}%
    27 \isamarkuptrue%
    27 \isamarkuptrue%
    28 %
    28 %
    29 \isamarkupsubsection{Infix Annotations%
    29 \isamarkupsubsection{Infix Annotations%
    30 }
    30 }
    33 \begin{isamarkuptext}%
    33 \begin{isamarkuptext}%
    34 Syntax annotations may be included wherever constants are declared
    34 Syntax annotations may be included wherever constants are declared
    35   directly or indirectly, including \isacommand{consts},
    35   directly or indirectly, including \isacommand{consts},
    36   \isacommand{constdefs}, or \isacommand{datatype} (for the
    36   \isacommand{constdefs}, or \isacommand{datatype} (for the
    37   constructor operations).  Type-constructors may be annotated as
    37   constructor operations).  Type-constructors may be annotated as
    38   well, although this is less frequently encountered in practice
    38   well, although this is less frequently encountered in practice (the
    39   (\isa{{\isacharasterisk}} and \isa{{\isacharplus}} types may come to mind).
    39   infix type \isa{{\isasymtimes}} comes to mind).
    40 
    40 
    41   Infix declarations\index{infix annotations} provide a useful special
    41   Infix declarations\index{infix annotations} provide a useful special
    42   case of mixfixes, where users need not care about the full details
    42   case of mixfixes, where users need not care about the full details
    43   of priorities, nesting, spacing, etc.  The following example of the
    43   of priorities, nesting, spacing, etc.  The following example of the
    44   exclusive-or operation on boolean values illustrates typical infix
    44   exclusive-or operation on boolean values illustrates typical infix
    56   applications with less than two operands there is a special notation
    56   applications with less than two operands there is a special notation
    57   with \isa{op} prefix: \isa{xor} without arguments is represented
    57   with \isa{op} prefix: \isa{xor} without arguments is represented
    58   as \isa{op\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}}; together with plain prefix application this
    58   as \isa{op\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}}; together with plain prefix application this
    59   turns \isa{xor\ A} into \isa{op\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ A}.
    59   turns \isa{xor\ A} into \isa{op\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ A}.
    60 
    60 
    61   \medskip The string \isa{{\isachardoublequote}{\isacharbrackleft}{\isacharplus}{\isacharbrackright}{\isachardoublequote}} in the above annotation
    61   \medskip The keyword \isakeyword{infixl} specifies an infix operator
    62   refers to the bit of concrete syntax to represent the operator,
    62   that is nested to the \emph{left}: in iterated applications the more
       
    63   complex expression appears on the left-hand side: \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,
       
    64   \isakeyword{infixr} specifies to nesting to the \emph{right},
       
    65   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
       
    66   contrast, a \emph{non-oriented} declaration via \isakeyword{infix}
       
    67   would render \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C} illegal, but demand explicit
       
    68   parentheses to indicate the intended grouping.
       
    69 
       
    70   The string \isa{{\isachardoublequote}{\isacharbrackleft}{\isacharplus}{\isacharbrackright}{\isachardoublequote}} in the above annotation refers to
       
    71   the concrete syntax to represent the operator (a literal token),
    63   while the number \isa{{\isadigit{6}}{\isadigit{0}}} determines the precedence of the
    72   while the number \isa{{\isadigit{6}}{\isadigit{0}}} determines the precedence of the
    64   construct (i.e.\ the syntactic priorities of the arguments and
    73   construct (i.e.\ the syntactic priorities of the arguments and
    65   result).
    74   result).  As it happens, Isabelle/HOL already uses up many popular
    66 
    75   combinations of ASCII symbols for its own use, including both \isa{{\isacharplus}} and \isa{{\isacharplus}{\isacharplus}}.  Slightly more awkward combinations like the
    67   As it happens, Isabelle/HOL already spends many popular combinations
    76   present \isa{{\isacharbrackleft}{\isacharplus}{\isacharbrackright}} tend to be available for user extensions.
    68   of ASCII symbols for its own use, including both \isa{{\isacharplus}} and
       
    69   \isa{{\isacharplus}{\isacharplus}}.  Slightly more awkward combinations like the present
       
    70   \isa{{\isacharbrackleft}{\isacharplus}{\isacharbrackright}} tend to be available for user extensions.  The current
       
    71   arrangement of inner syntax may be inspected via
       
    72   \commdx{print\protect\_syntax}, albeit its output is enormous.
       
    73 
    77 
    74   Operator precedence also needs some special considerations.  The
    78   Operator precedence also needs some special considerations.  The
    75   admissible range is 0--1000.  Very low or high priorities are
    79   admissible range is 0--1000.  Very low or high priorities are
    76   basically reserved for the meta-logic.  Syntax of Isabelle/HOL
    80   basically reserved for the meta-logic.  Syntax of Isabelle/HOL
    77   mainly uses the range of 10--100: the equality infix \isa{{\isacharequal}} is
    81   mainly uses the range of 10--100: the equality infix \isa{{\isacharequal}} is
    78   centered at 50, logical connectives (like \isa{{\isasymor}} and \isa{{\isasymand}}) are below 50, and algebraic ones (like \isa{{\isacharplus}} and \isa{{\isacharasterisk}}) above 50.  User syntax should strive to coexist with common
    82   centered at 50, logical connectives (like \isa{{\isasymor}} and \isa{{\isasymand}}) are below 50, and algebraic ones (like \isa{{\isacharplus}} and \isa{{\isacharasterisk}}) above 50.  User syntax should strive to coexist with common
    79   HOL forms, or use the mostly unused range 100--900.
    83   HOL forms, or use the mostly unused range 100--900.%
    80 
       
    81   The keyword \isakeyword{infixl} specifies an infix operator that is
       
    82   nested to the \emph{left}: in iterated applications the more complex
       
    83   expression appears on the left-hand side: \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C}
       
    84   stands for \isa{{\isacharparenleft}A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B{\isacharparenright}\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C}.  Similarly,
       
    85   \isakeyword{infixr} specifies to nesting to the \emph{right},
       
    86   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
       
    87   contrast, a \emph{non-oriented} declaration via \isakeyword{infix}
       
    88   would render \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C} illegal, but demand explicit
       
    89   parentheses to indicate the intended grouping.%
       
    90 \end{isamarkuptext}%
    84 \end{isamarkuptext}%
    91 \isamarkuptrue%
    85 \isamarkuptrue%
    92 %
    86 %
    93 \isamarkupsubsection{Mathematical Symbols \label{sec:syntax-symbols}%
    87 \isamarkupsubsection{Mathematical Symbols \label{sec:syntax-symbols}%
    94 }
    88 }
   117   Here $ident$ may be any identifier according to the usual Isabelle
   111   Here $ident$ may be any identifier according to the usual Isabelle
   118   conventions.  This results in an infinite store of symbols, whose
   112   conventions.  This results in an infinite store of symbols, whose
   119   interpretation is left to further front-end tools.  For example,
   113   interpretation is left to further front-end tools.  For example,
   120   both the user-interface of Proof~General + X-Symbol and the Isabelle
   114   both the user-interface of Proof~General + X-Symbol and the Isabelle
   121   document processor (see \S\ref{sec:document-preparation}) display
   115   document processor (see \S\ref{sec:document-preparation}) display
   122   the \verb,\,\verb,<forall>, symbol really as \isa{{\isasymforall}}.
   116   the \verb,\,\verb,<forall>, symbol as \isa{{\isasymforall}}.
   123 
   117 
   124   A list of standard Isabelle symbols is given in
   118   A list of standard Isabelle symbols is given in
   125   \cite[appendix~A]{isabelle-sys}.  Users may introduce their own
   119   \cite[appendix~A]{isabelle-sys}.  Users may introduce their own
   126   interpretation of further symbols by configuring the appropriate
   120   interpretation of further symbols by configuring the appropriate
   127   front-end tool accordingly, e.g.\ by defining certain {\LaTeX}
   121   front-end tool accordingly, e.g.\ by defining certain {\LaTeX}
   167 \ \ xor\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}bool\ {\isasymRightarrow}\ bool\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymoplus}{\isasymignore}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isamarkupfalse%
   161 \ \ xor\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}bool\ {\isasymRightarrow}\ bool\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymoplus}{\isasymignore}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isamarkupfalse%
   168 \isamarkupfalse%
   162 \isamarkupfalse%
   169 %
   163 %
   170 \begin{isamarkuptext}%
   164 \begin{isamarkuptext}%
   171 The \commdx{syntax} command introduced here acts like
   165 The \commdx{syntax} command introduced here acts like
   172   \isakeyword{consts}, but without declaring a logical constant; an
   166   \isakeyword{consts}, but without declaring a logical constant.  The
   173   optional print mode specification may be given, too.  Note that the
   167   print mode specification (here \isa{{\isacharparenleft}xsymbols{\isacharparenright}}) limits the
   174   type declaration given above merely serves for syntactic purposes,
   168   effect of the syntax annotation concerning output; that alternative
   175   and is not checked for consistency with the real constant.
   169   production available for input invariably.  Also note that the type
       
   170   declaration in \isakeyword{syntax} merely serves for syntactic
       
   171   purposes, and is \emph{not} checked for consistency with the real
       
   172   constant.
   176 
   173 
   177   \medskip We may now write \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B} or \isa{A\ {\isasymoplus}\ B} in
   174   \medskip We may now write \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B} or \isa{A\ {\isasymoplus}\ B} in
   178   input, while output uses the nicer syntax of $xsymbols$, provided
   175   input, while output uses the nicer syntax of $xsymbols$, provided
   179   that print mode is active.  Such an arrangement is particularly
   176   that print mode is active.  Such an arrangement is particularly
   180   useful for interactive development, where users may type plain ASCII
   177   useful for interactive development, where users may type plain ASCII
   181   text, but gain improved visual feedback from the system.
   178   text, but gain improved visual feedback from the system.%
   182 
   179 \end{isamarkuptext}%
   183   \begin{warn}
   180 \isamarkuptrue%
   184   Alternative syntax declarations are apt to result in varying
       
   185   occurrences of concrete syntax in the input sources.  Isabelle
       
   186   provides no systematic way to convert alternative syntax expressions
       
   187   back and forth; print modes only affect situations where formal
       
   188   entities are pretty printed by the Isabelle process (e.g.\ output of
       
   189   terms and types), but not the original theory text.
       
   190   \end{warn}
       
   191 
       
   192   \medskip The following variant makes the alternative \isa{{\isasymoplus}}
       
   193   notation only available for output.  Thus we may enforce input
       
   194   sources to refer to plain ASCII only, but effectively disable
       
   195   cut-and-paste from output at the same time.%
       
   196 \end{isamarkuptext}%
       
   197 \isamarkuptrue%
       
   198 \isacommand{syntax}\ {\isacharparenleft}xsymbols\ \isakeyword{output}{\isacharparenright}\isanewline
       
   199 \ \ xor\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}bool\ {\isasymRightarrow}\ bool\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymoplus}{\isasymignore}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isamarkupfalse%
       
   200 %
   181 %
   201 \isamarkupsubsection{Prefix Annotations%
   182 \isamarkupsubsection{Prefix Annotations%
   202 }
   183 }
   203 \isamarkuptrue%
   184 \isamarkuptrue%
   204 %
   185 %
   205 \begin{isamarkuptext}%
   186 \begin{isamarkuptext}%
   206 Prefix syntax annotations\index{prefix annotation} are just another
   187 Prefix syntax annotations\index{prefix annotation} are another
   207   degenerate form of mixfixes \cite{isabelle-ref}, without any
   188   degenerate form of mixfixes \cite{isabelle-ref}, without any
   208   template arguments or priorities --- just some bits of literal
   189   template arguments or priorities --- just some bits of literal
   209   syntax.  The following example illustrates this idea idea by
   190   syntax.  The following example illustrates this idea idea by
   210   associating common symbols with the constructors of a datatype.%
   191   associating common symbols with the constructors of a datatype.%
   211 \end{isamarkuptext}%
   192 \end{isamarkuptext}%
   220 \noindent Here the mixfix annotations on the rightmost column happen
   201 \noindent Here the mixfix annotations on the rightmost column happen
   221   to consist of a single Isabelle symbol each: \verb,\,\verb,<euro>,,
   202   to consist of a single Isabelle symbol each: \verb,\,\verb,<euro>,,
   222   \verb,\,\verb,<pounds>,, \verb,\,\verb,<yen>,, and \verb,$,.  Recall
   203   \verb,\,\verb,<pounds>,, \verb,\,\verb,<yen>,, and \verb,$,.  Recall
   223   that a constructor like \isa{Euro} actually is a function \isa{nat\ {\isasymRightarrow}\ currency}.  An expression like \isa{Euro\ {\isadigit{1}}{\isadigit{0}}} will be
   204   that a constructor like \isa{Euro} actually is a function \isa{nat\ {\isasymRightarrow}\ currency}.  An expression like \isa{Euro\ {\isadigit{1}}{\isadigit{0}}} will be
   224   printed as \isa{{\isasymeuro}\ {\isadigit{1}}{\isadigit{0}}}; only the head of the application is
   205   printed as \isa{{\isasymeuro}\ {\isadigit{1}}{\isadigit{0}}}; only the head of the application is
   225   subject to our concrete syntax.  This simple form already achieves
   206   subject to our concrete syntax.  This rather simple form already
   226   conformance with notational standards of the European Commission.
   207   achieves conformance with notational standards of the European
       
   208   Commission.
   227 
   209 
   228   Prefix syntax also works for plain \isakeyword{consts} or
   210   Prefix syntax also works for plain \isakeyword{consts} or
   229   \isakeyword{constdefs}, of course.%
   211   \isakeyword{constdefs}, of course.%
   230 \end{isamarkuptext}%
   212 \end{isamarkuptext}%
   231 \isamarkuptrue%
   213 \isamarkuptrue%
   235 \isamarkuptrue%
   217 \isamarkuptrue%
   236 %
   218 %
   237 \begin{isamarkuptext}%
   219 \begin{isamarkuptext}%
   238 Mixfix syntax annotations work well in those situations where
   220 Mixfix syntax annotations work well in those situations where
   239   particular constant application forms need to be decorated by
   221   particular constant application forms need to be decorated by
   240   concrete syntax; just reconsider \isa{xor\ A\ B} versus \isa{A\ {\isasymoplus}\ B} covered before.  Occasionally the relationship between some
   222   concrete syntax; e.g.\ \isa{xor\ A\ B} versus \isa{A\ {\isasymoplus}\ B}
   241   piece of notation and its internal form is slightly more involved.
   223   covered before.  Occasionally the relationship between some piece of
   242   Here the concept of \bfindex{syntax translations} enters the scene.
   224   notation and its internal form is slightly more involved.  Here the
       
   225   concept of \bfindex{syntax translations} enters the scene.
   243 
   226 
   244   Using the raw \isakeyword{syntax}\index{syntax (command)} command we
   227   Using the raw \isakeyword{syntax}\index{syntax (command)} command we
   245   may introduce uninterpreted notational elements, while
   228   may introduce uninterpreted notational elements, while
   246   \commdx{translations} relates input forms with more complex logical
   229   \commdx{translations} relate input forms with more complex logical
   247   expressions.  This essentially provides a simple mechanism for
   230   expressions.  This essentially provides a simple mechanism for
   248   syntactic macros; even heavier transformations may be written in ML
   231   syntactic macros; even heavier transformations may be written in ML
   249   \cite{isabelle-ref}.
   232   \cite{isabelle-ref}.
   250 
   233 
   251   \medskip A typical example of syntax translations is to decorate
   234   \medskip A typical example of syntax translations is to decorate
   252   relational expressions (i.e.\ set-membership of tuples) with
   235   relational expressions (i.e.\ set-membership of tuples) with nice
   253   handsome symbolic notation, such as \isa{{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isasymin}\ sim} versus
   236   symbolic notation, such as \isa{{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isasymin}\ sim} versus \isa{x\ {\isasymapprox}\ y}.%
   254   \isa{x\ {\isasymapprox}\ y}.%
       
   255 \end{isamarkuptext}%
   237 \end{isamarkuptext}%
   256 \isamarkuptrue%
   238 \isamarkuptrue%
   257 \isacommand{consts}\isanewline
   239 \isacommand{consts}\isanewline
   258 \ \ sim\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}{\isacharprime}a\ {\isasymtimes}\ {\isacharprime}a{\isacharparenright}\ set{\isachardoublequote}\isanewline
   240 \ \ sim\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}{\isacharprime}a\ {\isasymtimes}\ {\isacharprime}a{\isacharparenright}\ set{\isachardoublequote}\isanewline
   259 \isanewline
   241 \isanewline
   308   presented as browsable PDF file or printed on paper.  The overall
   290   presented as browsable PDF file or printed on paper.  The overall
   309   document structure follows traditional mathematical articles, with
   291   document structure follows traditional mathematical articles, with
   310   sections, intermediate explanations, definitions, theorems and
   292   sections, intermediate explanations, definitions, theorems and
   311   proofs.
   293   proofs.
   312 
   294 
   313   The Isar proof language \cite{Wenzel-PhD}, which is not covered in
       
   314   this book, admits to write formal proof texts that are acceptable
       
   315   both to the machine and human readers at the same time.  Thus
       
   316   marginal comments and explanations may be kept at a minimum.  Even
       
   317   without proper coverage of human-readable proofs, Isabelle document
       
   318   preparation is very useful to produce formally derived texts.
       
   319   Unstructured proof scripts given here may be just ignored by
       
   320   readers, or intentionally suppressed from the text by the writer
       
   321   (see also \S\ref{sec:doc-prep-suppress}).
       
   322 
       
   323   \medskip The Isabelle document preparation system essentially acts
   295   \medskip The Isabelle document preparation system essentially acts
   324   as a front-end to {\LaTeX}.  After checking specifications and
   296   as a front-end to {\LaTeX}.  After checking specifications and
   325   proofs formally, the theory sources are turned into typesetting
   297   proofs formally, the theory sources are turned into typesetting
   326   instructions in a schematic manner.  This enables users to write
   298   instructions in a schematic manner.  This enables users to write
   327   authentic reports on theory developments with little effort, where
   299   authentic reports on theory developments with little effort, where
   335 %
   307 %
   336 \begin{isamarkuptext}%
   308 \begin{isamarkuptext}%
   337 In contrast to the highly interactive mode of Isabelle/Isar theory
   309 In contrast to the highly interactive mode of Isabelle/Isar theory
   338   development, the document preparation stage essentially works in
   310   development, the document preparation stage essentially works in
   339   batch-mode.  An Isabelle \bfindex{session} consists of a collection
   311   batch-mode.  An Isabelle \bfindex{session} consists of a collection
   340   of theory source files that may contribute to an output document
   312   of source files that may contribute to an output document
   341   eventually.  Each session is derived from a single parent, usually
   313   eventually.  Each session is derived from a single parent, usually
   342   an object-logic image like \texttt{HOL}.  This results in an overall
   314   an object-logic image like \texttt{HOL}.  This results in an overall
   343   tree structure, which is reflected by the output location in the
   315   tree structure, which is reflected by the output location in the
   344   file system (usually rooted at \verb,~/isabelle/browser_info,).
   316   file system (usually rooted at \verb,~/isabelle/browser_info,).
   345 
   317 
   356 \end{verbatim}
   328 \end{verbatim}
   357 
   329 
   358   The \texttt{isatool make} job also informs about the file-system
   330   The \texttt{isatool make} job also informs about the file-system
   359   location of the ultimate results.  The above dry run should be able
   331   location of the ultimate results.  The above dry run should be able
   360   to produce some \texttt{document.pdf} (with dummy title, empty table
   332   to produce some \texttt{document.pdf} (with dummy title, empty table
   361   of contents etc.).  Any failure at that stage usually indicates
   333   of contents etc.).  Any failure at this stage usually indicates
   362   technical problems of the {\LaTeX} installation.\footnote{Especially
   334   technical problems of the {\LaTeX} installation.\footnote{Especially
   363   make sure that \texttt{pdflatex} is present; if all fails one may
   335   make sure that \texttt{pdflatex} is present; if all fails one may
   364   fall back on DVI output by changing \texttt{usedir} options in
   336   fall back on DVI output by changing \texttt{usedir} options in
   365   \texttt{IsaMakefile} \cite{isabelle-sys}.}
   337   \texttt{IsaMakefile} \cite{isabelle-sys}.}
   366 
   338 
   367   \medskip The detailed arrangement of the session sources is as
   339   \medskip The detailed arrangement of the session sources is as
   368   follows:
   340   follows; advanced
   369 
   341 
   370   \begin{itemize}
   342   \begin{itemize}
   371 
   343 
   372   \item Directory \texttt{MySession} holds the required theory files
   344   \item Directory \texttt{MySession} holds the required theory files
   373   $T@1$\texttt{.thy}, \dots, $T@n$\texttt{.thy}.
   345   $T@1$\texttt{.thy}, \dots, $T@n$\texttt{.thy}.
   381   required for the {\LaTeX} stage; only \texttt{root.tex} needs to be
   353   required for the {\LaTeX} stage; only \texttt{root.tex} needs to be
   382   provided initially.
   354   provided initially.
   383 
   355 
   384   The latter file holds appropriate {\LaTeX} code to commence a
   356   The latter file holds appropriate {\LaTeX} code to commence a
   385   document (\verb,\documentclass, etc.), and to include the generated
   357   document (\verb,\documentclass, etc.), and to include the generated
   386   files $T@i$\texttt{.tex} for each theory.  The generated
   358   files $T@i$\texttt{.tex} for each theory.  Isabelle will generate a
   387   \texttt{session.tex} will contain {\LaTeX} commands to include all
   359   file \texttt{session.tex} holding {\LaTeX} commands to include all
   388   generated files in topologically sorted order, so
   360   generated theory output files in topologically sorted order.  So
   389   \verb,\input{session}, in \texttt{root.tex} does the job in most
   361   \verb,\input{session}, in \texttt{root.tex} does the job in most
   390   situations.
   362   situations.
   391 
   363 
   392   \item \texttt{IsaMakefile} holds appropriate dependencies and
   364   \item \texttt{IsaMakefile} holds appropriate dependencies and
   393   invocations of Isabelle tools to control the batch job.  In fact,
   365   invocations of Isabelle tools to control the batch job.  In fact,
   405   of characters and mathematical symbols (see also
   377   of characters and mathematical symbols (see also
   406   \S\ref{sec:doc-prep-symbols}).
   378   \S\ref{sec:doc-prep-symbols}).
   407 
   379 
   408   Especially observe the included {\LaTeX} packages \texttt{isabelle}
   380   Especially observe the included {\LaTeX} packages \texttt{isabelle}
   409   (mandatory), \texttt{isabellesym} (required for mathematical
   381   (mandatory), \texttt{isabellesym} (required for mathematical
   410   symbols), and the final \texttt{pdfsetup} (provides handsome
   382   symbols), and the final \texttt{pdfsetup} (provides sane defaults
   411   defaults for \texttt{hyperref}, including URL markup) --- all three
   383   for \texttt{hyperref}, including URL markup) --- all three are
   412   are distributed with Isabelle. Further packages may be required in
   384   distributed with Isabelle. Further packages may be required in
   413   particular applications, e.g.\ for unusual mathematical symbols.
   385   particular applications, e.g.\ for unusual mathematical symbols.
   414 
   386 
   415   \medskip Additional files for the {\LaTeX} stage may be put into the
   387   \medskip Additional files for the {\LaTeX} stage may be put into the
   416   \texttt{MySession/document} directory, too.  In particular, adding
   388   \texttt{MySession/document} directory, too.  In particular, adding
   417   \texttt{root.bib} here (with that specific name) causes an automatic
   389   \texttt{root.bib} here (with that specific name) causes an automatic
   499 
   471 
   500 \begin{verbatim}
   472 \begin{verbatim}
   501   \renewcommand{\isamarkupheader}[1]{\chapter{#1}}
   473   \renewcommand{\isamarkupheader}[1]{\chapter{#1}}
   502 \end{verbatim}
   474 \end{verbatim}
   503 
   475 
   504   \noindent Certainly, this requires to change the default
   476   \noindent That particular modification requires to change the
   505   \verb,\documentclass{article}, in \texttt{root.tex} to something
   477   default \verb,\documentclass{article}, in \texttt{root.tex} to
   506   that supports the notion of chapters in the first place, e.g.\
   478   something that supports the notion of chapters in the first place,
   507   \verb,\documentclass{report},.
   479   such as \verb,\documentclass{report},.
   508 
   480 
   509   \medskip The {\LaTeX} macro \verb,\isabellecontext, is maintained to
   481   \medskip The {\LaTeX} macro \verb,\isabellecontext, is maintained to
   510   hold the name of the current theory context.  This is particularly
   482   hold the name of the current theory context.  This is particularly
   511   useful for document headings:
   483   useful for document headings:
   512 
   484 
   588   formal text, mainly for instruction of the reader.  An
   560   formal text, mainly for instruction of the reader.  An
   589   \bfindex{antiquotation} is again a formal object embedded into such
   561   \bfindex{antiquotation} is again a formal object embedded into such
   590   an informal portion.  The interpretation of antiquotations is
   562   an informal portion.  The interpretation of antiquotations is
   591   limited to some well-formedness checks, with the result being pretty
   563   limited to some well-formedness checks, with the result being pretty
   592   printed to the resulting document.  So quoted text blocks together
   564   printed to the resulting document.  So quoted text blocks together
   593   with antiquotations provide very handsome means to reference formal
   565   with antiquotations provide very useful means to reference formal
   594   entities with good confidence in getting the technical details right
   566   entities with good confidence in getting the technical details right
   595   (especially syntax and types).
   567   (especially syntax and types).
   596 
   568 
   597   The general syntax of antiquotations is as follows:
   569   The general syntax of antiquotations is as follows:
   598   \texttt{{\at}{\ttlbrace}$name$ $arguments${\ttrbrace}}, or
   570   \texttt{{\at}{\ttlbrace}$name$ $arguments${\ttrbrace}}, or
   638   \texttt{\at}\verb,{prop,~$\phi$\verb,}, & print proposition $\phi$ \\
   610   \texttt{\at}\verb,{prop,~$\phi$\verb,}, & print proposition $\phi$ \\
   639   \texttt{\at}\verb,{prop [display],~$\phi$\verb,}, & print large proposition $\phi$ (with linebreaks) \\
   611   \texttt{\at}\verb,{prop [display],~$\phi$\verb,}, & print large proposition $\phi$ (with linebreaks) \\
   640   \texttt{\at}\verb,{prop [source],~$\phi$\verb,}, & check proposition $\phi$, print its input \\
   612   \texttt{\at}\verb,{prop [source],~$\phi$\verb,}, & check proposition $\phi$, print its input \\
   641   \texttt{\at}\verb,{thm,~$a$\verb,}, & print fact $a$ \\
   613   \texttt{\at}\verb,{thm,~$a$\verb,}, & print fact $a$ \\
   642   \texttt{\at}\verb,{thm,~$a$~\verb,[no_vars]}, & print fact $a$, fixing schematic variables \\
   614   \texttt{\at}\verb,{thm,~$a$~\verb,[no_vars]}, & print fact $a$, fixing schematic variables \\
   643   \texttt{\at}\verb,{thm [source],~$a$\verb,}, & check validity of fact $a$, print its name \\
   615   \texttt{\at}\verb,{thm [source],~$a$\verb,}, & check availability of fact, print name $a$ \\
   644   \texttt{\at}\verb,{text,~$s$\verb,}, & print uninterpreted text $s$ \\
   616   \texttt{\at}\verb,{text,~$s$\verb,}, & print uninterpreted text $s$ \\
   645   \end{tabular}
   617   \end{tabular}
   646 
   618 
   647   \medskip
   619   \medskip
   648 
   620 
   706 
   678 
   707   \medskip The \verb,\isabellestyle, macro provides a high-level
   679   \medskip The \verb,\isabellestyle, macro provides a high-level
   708   interface to tune the general appearance of individual symbols.  For
   680   interface to tune the general appearance of individual symbols.  For
   709   example, \verb,\isabellestyle{it}, uses the italics text style to
   681   example, \verb,\isabellestyle{it}, uses the italics text style to
   710   mimic the general appearance of the {\LaTeX} math mode; double
   682   mimic the general appearance of the {\LaTeX} math mode; double
   711   quotes are not printed at all.  The resulting quality of
   683   quotes are not printed at all.  The resulting quality of typesetting
   712   typesetting is quite good, so this should usually be the default
   684   is quite good, so this should be the default style for work that
   713   style for real production work that gets distributed to a broader
   685   gets distributed to a broader audience.%
   714   audience.%
       
   715 \end{isamarkuptext}%
   686 \end{isamarkuptext}%
   716 \isamarkuptrue%
   687 \isamarkuptrue%
   717 %
   688 %
   718 \isamarkupsubsection{Suppressing Output \label{sec:doc-prep-suppress}%
   689 \isamarkupsubsection{Suppressing Output \label{sec:doc-prep-suppress}%
   719 }
   690 }
   720 \isamarkuptrue%
   691 \isamarkuptrue%
   721 %
   692 %
   722 \begin{isamarkuptext}%
   693 \begin{isamarkuptext}%
   723 By default, Isabelle's document system generates a {\LaTeX} source
   694 By default, Isabelle's document system generates a {\LaTeX} source
   724   file for each theory that happens to get loaded while running the
   695   file for each theory that gets loaded while running the session.
   725   session.  The generated \texttt{session.tex} will include all of
   696   The generated \texttt{session.tex} will include all of these in
   726   these in order of appearance, which in turn gets included by the
   697   order of appearance, which in turn gets included by the standard
   727   standard \texttt{root.tex}.  Certainly one may change the order or
   698   \texttt{root.tex}.  Certainly one may change the order or suppress
   728   suppress unwanted theories by ignoring \texttt{session.tex} and
   699   unwanted theories by ignoring \texttt{session.tex} and include
   729   include individual files in \texttt{root.tex} by hand.  On the other
   700   individual files in \texttt{root.tex} by hand.  On the other hand,
   730   hand, such an arrangement requires additional maintenance chores
   701   such an arrangement requires additional maintenance chores whenever
   731   whenever the collection of theories changes.
   702   the collection of theories changes.
   732 
   703 
   733   Alternatively, one may tune the theory loading process in
   704   Alternatively, one may tune the theory loading process in
   734   \texttt{ROOT.ML} itself: traversal of the theory dependency graph
   705   \texttt{ROOT.ML} itself: traversal of the theory dependency graph
   735   may be fine-tuned by adding \verb,use_thy, invocations, although
   706   may be fine-tuned by adding \verb,use_thy, invocations, although
   736   topological sorting still has to be observed.  Moreover, the ML
   707   topological sorting still has to be observed.  Moreover, the ML
   791   is fairly easy to invalidate the remaining visible text, e.g.\ by
   762   is fairly easy to invalidate the remaining visible text, e.g.\ by
   792   referencing questionable formal items (strange definitions,
   763   referencing questionable formal items (strange definitions,
   793   arbitrary axioms etc.) that have been hidden from sight beforehand.
   764   arbitrary axioms etc.) that have been hidden from sight beforehand.
   794 
   765 
   795   Authentic reports of formal theories, say as part of a library,
   766   Authentic reports of formal theories, say as part of a library,
   796   usually should refrain from suppressing parts of the text at all.
   767   should refrain from suppressing parts of the text at all.  Other
   797   Other users may need the full information for their own derivative
   768   users may need the full information for their own derivative work.
   798   work.  If a particular formalization appears inadequate for general
   769   If a particular formalization appears inadequate for general public
   799   public coverage, it is often more appropriate to think of a better
   770   coverage, it is often more appropriate to think of a better way in
   800   way in the first place.
   771   the first place.
   801 
   772 
   802   \medskip Some technical subtleties of the
   773   \medskip Some technical subtleties of the
   803   \verb,(,\verb,*,\verb,<,\verb,*,\verb,),~\verb,(,\verb,*,\verb,>,\verb,*,\verb,),
   774   \verb,(,\verb,*,\verb,<,\verb,*,\verb,),~\verb,(,\verb,*,\verb,>,\verb,*,\verb,),
   804   elements need to be kept in mind, too --- the system performs little
   775   elements need to be kept in mind, too --- the system performs little
   805   sanity checks here.  Arguments of markup commands and formal
   776   sanity checks here.  Arguments of markup commands and formal