doc-src/TutorialI/Documents/Documents.thy
changeset 12653 a55c066624eb
parent 12651 930df4604b36
child 12659 2aa05eb15bd2
equal deleted inserted replaced
12652:2d136f05e164 12653:a55c066624eb
     1 (*<*)
     1 (*<*)
     2 theory Documents = Main:
     2 theory Documents = Main:
     3 (*>*)
     3 (*>*)
     4 
     4 
       
     5 (* FIXME exercises? *)
       
     6 
     5 section {* Concrete Syntax \label{sec:concrete-syntax} *}
     7 section {* Concrete Syntax \label{sec:concrete-syntax} *}
     6 
     8 
     7 text {*
     9 text {*
     8   Concerning Isabelle's ``inner'' language of simply-typed @{text
    10   Concerning Isabelle's ``inner'' language of simply-typed @{text
     9   \<lambda>}-calculus, the core concept of Isabelle's elaborate infrastructure
    11   \<lambda>}-calculus, the core concept of Isabelle's elaborate
    10   for concrete syntax is that of general \bfindex{mixfix annotations}.
    12   infrastructure for concrete syntax is that of general
    11   Associated with any kind of name and type declaration, mixfixes give
    13   \bfindex{mixfix annotations}.  Associated with any kind of constant
    12   rise both to grammar productions for the parser and output templates
    14   declaration, mixfixes affect both the grammar productions for the
    13   for the pretty printer.
    15   parser and output templates for the pretty printer.
    14 
    16 
    15   In full generality, the whole affair of parser and pretty printer
    17   In full generality, the whole affair of parser and pretty printer
    16   configuration is rather subtle.  Any syntax specifications given by
    18   configuration is rather subtle, see \cite{isabelle-ref} for further
    17   end-users need to interact properly with the existing setup of
    19   details.  Any syntax specifications given by end-users need to
    18   Isabelle/Pure and Isabelle/HOL; see \cite{isabelle-ref} for further
    20   interact properly with the existing setup of Isabelle/Pure and
    19   details.  It is particularly important to get the precedence of new
    21   Isabelle/HOL.  It is particularly important to get the precedence of
    20   syntactic constructs right, avoiding ambiguities with existing
    22   new syntactic constructs right, avoiding ambiguities with existing
    21   elements.
    23   elements.
    22 
    24 
    23   \medskip Subsequently we introduce a few simple declaration forms
    25   \medskip Subsequently we introduce a few simple declaration forms
    24   that already cover the most common situations fairly well.
    26   that already cover the most common situations fairly well.
    25 *}
    27 *}
    37 
    39 
    38   Infix declarations\index{infix annotations} provide a useful special
    40   Infix declarations\index{infix annotations} provide a useful special
    39   case of mixfixes, where users need not care about the full details
    41   case of mixfixes, where users need not care about the full details
    40   of priorities, nesting, spacing, etc.  The subsequent example of the
    42   of priorities, nesting, spacing, etc.  The subsequent example of the
    41   exclusive-or operation on boolean values illustrates typical infix
    43   exclusive-or operation on boolean values illustrates typical infix
    42   declarations.
    44   declarations arising in practice.
    43 *}
    45 *}
    44 
    46 
    45 constdefs
    47 constdefs
    46   xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "[+]" 60)
    48   xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "[+]" 60)
    47   "A [+] B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
    49   "A [+] B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
    48 
    50 
    49 text {*
    51 text {*
    50   Any curried function with at least two arguments may be associated
    52   \noindent Now @{text "xor A B"} and @{text "A [+] B"} refer to the
    51   with infix syntax: @{text "xor A B"} and @{text "A [+] B"} refer to
    53   same expression internally.  Any curried function with at least two
    52   the same expression internally.  In partial applications with less
    54   arguments may be associated with infix syntax.  For partial
    53   than two operands there is a special notation with \isa{op} prefix:
    55   applications with less than two operands there is a special notation
    54   @{text xor} without arguments is represented as @{text "op [+]"};
    56   with \isa{op} prefix: @{text xor} without arguments is represented
    55   combined with plain prefix application this turns @{text "xor A"}
    57   as @{text "op [+]"}; together with plain prefix application this
    56   into @{text "op [+] A"}.
    58   turns @{text "xor A"} into @{text "op [+] A"}.
    57 
    59 
    58   \medskip The string @{text [source] "[+]"} in the above declaration
    60   \medskip The string @{text [source] "[+]"} in the above annotation
    59   refers to the bit of concrete syntax to represent the operator,
    61   refers to the bit of concrete syntax to represent the operator,
    60   while the number @{text 60} determines the precedence of the whole
    62   while the number @{text 60} determines the precedence of the
    61   construct.
    63   construct (i.e.\ the syntactic priorities of the arguments and
       
    64   result).
    62 
    65 
    63   As it happens, Isabelle/HOL already spends many popular combinations
    66   As it happens, Isabelle/HOL already spends many popular combinations
    64   of ASCII symbols for its own use, including both @{text "+"} and
    67   of ASCII symbols for its own use, including both @{text "+"} and
    65   @{text "++"}.  Slightly more awkward combinations like the present
    68   @{text "++"}.  Slightly more awkward combinations like the present
    66   @{text "[+]"} tend to be available for user extensions.  The current
    69   @{text "[+]"} tend to be available for user extensions.  The current
    78 
    81 
    79   \medskip The keyword \isakeyword{infixl} specifies an operator that
    82   \medskip The keyword \isakeyword{infixl} specifies an operator that
    80   is nested to the \emph{left}: in iterated applications the more
    83   is nested to the \emph{left}: in iterated applications the more
    81   complex expression appears on the left-hand side: @{term "A [+] B
    84   complex expression appears on the left-hand side: @{term "A [+] B
    82   [+] C"} stands for @{text "(A [+] B) [+] C"}.  Similarly,
    85   [+] C"} stands for @{text "(A [+] B) [+] C"}.  Similarly,
    83   \isakeyword{infixr} refers to nesting to the \emph{right}, reading
    86   \isakeyword{infixr} specifies to nesting to the \emph{right},
    84   @{term "A [+] B [+] C"} as @{text "A [+] (B [+] C)"}.  In contrast,
    87   reading @{term "A [+] B [+] C"} as @{text "A [+] (B [+] C)"}.  In
    85   a \emph{non-oriented} declaration via \isakeyword{infix} would
    88   contrast, a \emph{non-oriented} declaration via \isakeyword{infix}
    86   always demand explicit parentheses.
    89   would have rendered @{term "A [+] B [+] C"} illegal, but demand
    87 
    90   explicit parentheses about the intended grouping.
    88   Many binary operations observe the associative law, so the exact
       
    89   grouping does not matter.  Nevertheless, formal statements need be
       
    90   given in a particular format, associativity needs to be treated
       
    91   explicitly within the logic.  Exclusive-or is happens to be
       
    92   associative, as shown below.
       
    93 *}
       
    94 
       
    95 lemma xor_assoc: "(A [+] B) [+] C = A [+] (B [+] C)"
       
    96   by (auto simp add: xor_def)
       
    97 
       
    98 text {*
       
    99   Such rules may be used in simplification to regroup nested
       
   100   expressions as required.  Note that the system would actually print
       
   101   the above statement as @{term "A [+] B [+] C = A [+] (B [+] C)"}
       
   102   (due to nesting to the left).  We have preferred to give the fully
       
   103   parenthesized form in the text for clarity.  Only in rare situations
       
   104   one may consider to force parentheses by use of non-oriented infix
       
   105   syntax; equality would probably be a typical candidate.
       
   106 *}
    91 *}
   107 
    92 
   108 
    93 
   109 subsection {* Mathematical Symbols *}
    94 subsection {* Mathematical Symbols *}
   110 
    95 
   111 text {*
    96 text {*
   112   Concrete syntax based on plain ASCII characters has its inherent
    97   Concrete syntax based on plain ASCII characters has its inherent
   113   limitations.  Rich mathematical notation demands a larger repertoire
    98   limitations.  Rich mathematical notation demands a larger repertoire
   114   of symbols.  Several standards of extended character sets have been
    99   of symbols.  Several standards of extended character sets have been
   115   proposed over decades, but none has become universally available so
   100   proposed over decades, but none has become universally available so
   116   far, not even Unicode\index{Unicode}.
   101   far, not even Unicode\index{Unicode}.  Isabelle supports a generic
   117 
   102   notion of \bfindex{symbols} as the smallest entities of source text,
   118   Isabelle supports a generic notion of \bfindex{symbols} as the
   103   without referring to internal encodings.
   119   smallest entities of source text, without referring to internal
   104 
   120   encodings.  Such ``generalized characters'' may be of one of the
   105   There are three kinds of such ``generalized characters'' available:
   121   following three kinds:
       
   122 
   106 
   123   \begin{enumerate}
   107   \begin{enumerate}
   124 
   108 
   125   \item Traditional 7-bit ASCII characters.
   109   \item 7-bit ASCII characters
   126 
   110 
   127   \item Named symbols: \verb,\,\verb,<,$ident$\verb,>, (or
   111   \item named symbols: \verb,\,\verb,<,$ident$\verb,>,
   128   \verb,\\,\verb,<,$ident$\verb,>,).
   112 
   129 
   113   \item named control symbols: \verb,\,\verb,<^,$ident$\verb,>,
   130   \item Named control symbols: \verb,\,\verb,<^,$ident$\verb,>, (or
       
   131   \verb,\\,\verb,<^,$ident$\verb,>,).
       
   132 
   114 
   133   \end{enumerate}
   115   \end{enumerate}
   134 
   116 
   135   Here $ident$ may be any identifier according to the usual Isabelle
   117   Here $ident$ may be any identifier according to the usual Isabelle
   136   conventions.  This results in an infinite store of symbols, whose
   118   conventions.  This results in an infinite store of symbols, whose
   137   interpretation is left to further front-end tools.  For example, the
   119   interpretation is left to further front-end tools.  For example,
   138   \verb,\,\verb,<forall>, symbol of Isabelle is really displayed as
   120   both by the user-interface of Proof~General + X-Symbol and the
   139   $\forall$ --- both by the user-interface of Proof~General + X-Symbol
   121   Isabelle document processor (see \S\ref{sec:document-preparation})
   140   and the Isabelle document processor (see \S\ref{sec:document-prep}).
   122   display the \verb,\,\verb,<forall>, symbol really as ``$\forall$''.
   141 
   123 
   142   A list of standard Isabelle symbols is given in
   124   A list of standard Isabelle symbols is given in
   143   \cite[appendix~A]{isabelle-sys}.  Users may introduce their own
   125   \cite[appendix~A]{isabelle-sys}.  Users may introduce their own
   144   interpretation of further symbols by configuring the appropriate
   126   interpretation of further symbols by configuring the appropriate
   145   front-end tool accordingly, e.g.\ defining appropriate {\LaTeX}
   127   front-end tool accordingly, e.g.\ by defining certain {\LaTeX}
   146   macros for document preparation.  There are also a few predefined
   128   macros (see also \S\ref{sec:doc-prep-symbols}).  There are also a
   147   control symbols, such as \verb,\,\verb,<^sub>, and
   129   few predefined control symbols, such as \verb,\,\verb,<^sub>, and
   148   \verb,\,\verb,<^sup>, for sub- and superscript of the subsequent
   130   \verb,\,\verb,<^sup>, for sub- and superscript of the subsequent
   149   (printable) symbol, respectively.
   131   (printable) symbol, respectively.  For example, \verb,A\<^sup>\<star>, is
       
   132   shown as ``@{text "A\<^sup>\<star>"}''.
   150 
   133 
   151   \medskip The following version of our @{text xor} definition uses a
   134   \medskip The following version of our @{text xor} definition uses a
   152   standard Isabelle symbol to achieve typographically pleasing output.
   135   standard Isabelle symbol to achieve typographically pleasing output.
   153 *}
   136 *}
   154 
   137 
   162 (*<*)
   145 (*<*)
   163 local
   146 local
   164 (*>*)
   147 (*>*)
   165 
   148 
   166 text {*
   149 text {*
   167   The X-Symbol package within Proof~General provides several input
   150   \noindent The X-Symbol package within Proof~General provides several
   168   methods to enter @{text \<oplus>} in the text.  If all fails one may just
   151   input methods to enter @{text \<oplus>} in the text.  If all fails one may
   169   type \verb,\,\verb,<oplus>, by hand; the display is adapted
   152   just type \verb,\,\verb,<oplus>, by hand; the display will be
   170   immediately after continuing further input.
   153   adapted immediately after continuing input.
   171 
   154 
   172   \medskip A slightly more refined scheme is to provide alternative
   155   \medskip A slightly more refined scheme is to provide alternative
   173   syntax via the \bfindex{print mode} concept of Isabelle (see also
   156   syntax via the \bfindex{print mode} concept of Isabelle (see also
   174   \cite{isabelle-ref}).  By convention, the mode ``$xsymbols$'' is
   157   \cite{isabelle-ref}).  By convention, the mode of ``$xsymbols$'' is
   175   enabled whenever X-Symbol is active.  Consider the following hybrid
   158   enabled whenever Proof~General's X-Symbol mode (or {\LaTeX} output)
   176   declaration of @{text xor}.
   159   is active.  Consider the following hybrid declaration of @{text
       
   160   xor}.
   177 *}
   161 *}
   178 
   162 
   179 (*<*)
   163 (*<*)
   180 hide const xor
   164 hide const xor
   181 ML_setup {* Context.>> (Theory.add_path "2") *}
   165 ML_setup {* Context.>> (Theory.add_path "2") *}
   189 (*<*)
   173 (*<*)
   190 local
   174 local
   191 (*>*)
   175 (*>*)
   192 
   176 
   193 text {*
   177 text {*
   194   Here the \commdx{syntax} command acts like \isakeyword{consts}, but
   178   The \commdx{syntax} command introduced here acts like
   195   without declaring a logical constant, and with an optional print
   179   \isakeyword{consts}, but without declaring a logical constant; an
   196   mode specification.  Note that the type declaration given here
   180   optional print mode specification may be given, too.  Note that the
   197   merely serves for syntactic purposes, and is not checked for
   181   type declaration given here merely serves for syntactic purposes,
   198   consistency with the real constant.
   182   and is not checked for consistency with the real constant.
   199 
   183 
   200   \medskip Now we may write either @{text "[+]"} or @{text "\<oplus>"} in
   184   \medskip We may now write either @{text "[+]"} or @{text "\<oplus>"} in
   201   input, while output uses the nicer syntax of $xsymbols$, provided
   185   input, while output uses the nicer syntax of $xsymbols$, provided
   202   that print mode is presently active.  This scheme is particularly
   186   that print mode is presently active.  Such an arrangement is
   203   useful for interactive development, with the user typing plain ASCII
   187   particularly useful for interactive development, where users may
   204   text, but gaining improved visual feedback from the system (say in
   188   type plain ASCII text, but gain improved visual feedback from the
   205   current goal output).
   189   system (say in current goal output).
   206 
   190 
   207   \begin{warn}
   191   \begin{warn}
   208   Using alternative syntax declarations easily results in varying
   192   Alternative syntax declarations are apt to result in varying
   209   versions of input sources.  Isabelle provides no systematic way to
   193   occurrences of concrete syntax in the input sources.  Isabelle
   210   convert alternative expressions back and forth.  Print modes only
   194   provides no systematic way to convert alternative syntax expressions
   211   affect situations where formal entities are pretty printed by the
   195   back and forth; print modes only affect situations where formal
   212   Isabelle process (e.g.\ output of terms and types), but not the
   196   entities are pretty printed by the Isabelle process (e.g.\ output of
   213   original theory text.
   197   terms and types), but not the original theory text.
   214   \end{warn}
   198   \end{warn}
   215 
   199 
   216   \medskip The following variant makes the alternative @{text \<oplus>}
   200   \medskip The following variant makes the alternative @{text \<oplus>}
   217   notation only available for output.  Thus we may enforce input
   201   notation only available for output.  Thus we may enforce input
   218   sources to refer to plain ASCII only.
   202   sources to refer to plain ASCII only, but effectively disable
       
   203   cut-and-paste from output as well.
   219 *}
   204 *}
   220 
   205 
   221 syntax (xsymbols output)
   206 syntax (xsymbols output)
   222   xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "\<oplus>\<ignore>" 60)
   207   xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "\<oplus>\<ignore>" 60)
   223 
   208 
   224 
   209 
   225 subsection {* Prefix Annotations *}
   210 subsection {* Prefix Annotations *}
   226 
   211 
   227 text {*
   212 text {*
   228   Prefix syntax annotations\index{prefix annotation} are just a very
   213   Prefix syntax annotations\index{prefix annotation} are just another
   229   degenerate of the general mixfix form \cite{isabelle-ref}, without
   214   degenerate form of general mixfixes \cite{isabelle-ref}, without any
   230   any template arguments or priorities --- just some piece of literal
   215   template arguments or priorities --- just some bits of literal
   231   syntax.
   216   syntax.  The following example illustrates this idea idea by
   232 
   217   associating common symbols with the constructors of a datatype.
   233   The following example illustrates this idea idea by associating
       
   234   common symbols with the constructors of a currency datatype.
       
   235 *}
   218 *}
   236 
   219 
   237 datatype currency =
   220 datatype currency =
   238     Euro nat    ("\<euro>")
   221     Euro nat    ("\<euro>")
   239   | Pounds nat  ("\<pounds>")
   222   | Pounds nat  ("\<pounds>")
   240   | Yen nat     ("\<yen>")
   223   | Yen nat     ("\<yen>")
   241   | Dollar nat  ("$")
   224   | Dollar nat  ("$")
   242 
   225 
   243 text {*
   226 text {*
   244   \noindent Here the degenerate mixfix annotations on the rightmost
   227   \noindent Here the mixfix annotations on the rightmost column happen
   245   column happen to consist of a single Isabelle symbol each:
   228   to consist of a single Isabelle symbol each: \verb,\,\verb,<euro>,,
   246   \verb,\,\verb,<euro>,, \verb,\,\verb,<pounds>,,
   229   \verb,\,\verb,<pounds>,, \verb,\,\verb,<yen>,, and \verb,$,.  Recall
   247   \verb,\,\verb,<yen>,, and \verb,$,.
   230   that a constructor like @{text Euro} actually is a function @{typ
   248 
   231   "nat \<Rightarrow> currency"}.  An expression like @{text "Euro 10"} will be
   249   Recall that a constructor like @{text Euro} actually is a function
   232   printed as @{term "\<euro> 10"}; only the head of the application is
   250   @{typ "nat \<Rightarrow> currency"}.  An expression like @{text "Euro 10"} will
       
   251   be printed as @{term "\<euro> 10"}; only the head of the application is
       
   252   subject to our concrete syntax.  This simple form already achieves
   233   subject to our concrete syntax.  This simple form already achieves
   253   conformance with notational standards of the European Commission.
   234   conformance with notational standards of the European Commission.
   254 
   235 
   255   \medskip Certainly, the same idea of prefix syntax also works for
   236   \medskip Certainly, the same idea of prefix syntax also works for
   256   \isakeyword{consts}, \isakeyword{constdefs} etc.  The slightly
   237   \isakeyword{consts}, \isakeyword{constdefs} etc.  The slightly
   262 syntax
   243 syntax
   263   currency :: type    ("\<currency>")
   244   currency :: type    ("\<currency>")
   264 
   245 
   265 text {*
   246 text {*
   266   \noindent Here @{typ type} refers to the builtin syntactic category
   247   \noindent Here @{typ type} refers to the builtin syntactic category
   267   of Isabelle types.  We could now write down funny things like @{text
   248   of Isabelle types.  We may now write down funny things like @{text
   268   "\<euro> :: nat \<Rightarrow> \<currency>"}, for example.
   249   "\<euro> :: nat \<Rightarrow> \<currency>"}, for example.
   269 *}
   250 *}
   270 
   251 
   271 
   252 
   272 subsection {* Syntax Translations \label{sec:syntax-translations} *}
   253 subsection {* Syntax Translations \label{sec:syntax-translations} *}
   273 
   254 
   274 text{*
   255 text{*
   275   Mixfix syntax annotations work well for those situations, where a
   256   Mixfix syntax annotations work well for those situations where a
   276   constant application forms needs to be decorated by concrete syntax.
   257   particular constant application forms need to be decorated by
   277   Just reconsider @{text "xor A B"} versus @{text "A \<oplus> B"} covered
   258   concrete syntax; just reconsider @{text "xor A B"} versus @{text "A
   278   before.  Occasionally, the relationship between some piece of
   259   \<oplus> B"} covered before.  Occasionally, the relationship between some
   279   notation and its internal form is slightly more involved.
   260   piece of notation and its internal form is slightly more involved.
   280 
       
   281   Here the concept of \bfindex{syntax translations} enters the scene.
   261   Here the concept of \bfindex{syntax translations} enters the scene.
       
   262 
   282   Using the raw \isakeyword{syntax}\index{syntax (command)} command we
   263   Using the raw \isakeyword{syntax}\index{syntax (command)} command we
   283   introduce uninterpreted notational elements, while
   264   may introduce uninterpreted notational elements, while
   284   \commdx{translations} relates the input forms with certain logical
   265   \commdx{translations} relates the input forms with more complex
   285   expressions.  This essentially provides a simple mechanism for for
   266   logical expressions.  This essentially provides a simple mechanism
   286   syntactic macros; even heavier transformations may be programmed in
   267   for for syntactic macros; even heavier transformations may be
   287   ML \cite{isabelle-ref}.
   268   programmed in ML \cite{isabelle-ref}.
   288 
   269 
   289   \medskip A typical example of syntax translations is to decorate an
   270   \medskip A typical example of syntax translations is to decorate
   290   relational expression (i.e.\ set membership of tuples) with nice
   271   relational expressions (set membership of tuples) with nice symbolic
   291   symbolic notation, such as @{text "(x, y) \<in> sim"} versus @{text "x \<approx>
   272   notation, such as @{text "(x, y) \<in> sim"} versus @{text "x \<approx> y"}.
   292   y"}.
       
   293 *}
   273 *}
   294 
   274 
   295 consts
   275 consts
   296   sim :: "('a \<times> 'a) set"
   276   sim :: "('a \<times> 'a) set"
   297 
   277 
   300 translations
   280 translations
   301   "x \<approx> y" \<rightleftharpoons> "(x, y) \<in> sim"
   281   "x \<approx> y" \<rightleftharpoons> "(x, y) \<in> sim"
   302 
   282 
   303 text {*
   283 text {*
   304   \noindent Here the name of the dummy constant @{text "_sim"} does
   284   \noindent Here the name of the dummy constant @{text "_sim"} does
   305   not really matter, as long as it is not used otherwise.  Prefixing
   285   not really matter, as long as it is not used elsewhere.  Prefixing
   306   an underscore is a common convention.  The \isakeyword{translations}
   286   an underscore is a common convention.  The \isakeyword{translations}
   307   declaration already uses concrete syntax on the left-hand side;
   287   declaration already uses concrete syntax on the left-hand side;
   308   internally we relate a raw application @{text "_sim x y"} with
   288   internally we relate a raw application @{text "_sim x y"} with
   309   @{text "(x, y) \<in> sim"}.
   289   @{text "(x, y) \<in> sim"}.
   310 
   290 
   311   \medskip Another useful application of syntax translations is to
   291   \medskip Another common application of syntax translations is to
   312   provide variant versions of fundamental relational expressions, such
   292   provide variant versions of fundamental relational expressions, such
   313   as @{text \<noteq>} for negated equalities.  The following declaration
   293   as @{text \<noteq>} for negated equalities.  The following declaration
   314   stems from Isabelle/HOL itself:
   294   stems from Isabelle/HOL itself:
   315 *}
   295 *}
   316 
   296 
   317 syntax "_not_equal" :: "'a \<Rightarrow> 'a \<Rightarrow> bool"    (infixl "\<noteq>\<ignore>" 50)
   297 syntax "_not_equal" :: "'a \<Rightarrow> 'a \<Rightarrow> bool"    (infixl "\<noteq>\<ignore>" 50)
   318 translations "x \<noteq>\<ignore> y" \<rightleftharpoons> "\<not> (x = y)"
   298 translations "x \<noteq>\<ignore> y" \<rightleftharpoons> "\<not> (x = y)"
   319 
   299 
   320 text {*
   300 text {*
   321   \noindent Normally one would introduce derived concepts like this
   301   \noindent Normally one would introduce derived concepts like this
   322   within the logic, using \isakeyword{consts} and \isakeyword{defs}
   302   within the logic, using \isakeyword{consts} + \isakeyword{defs}
   323   instead of \isakeyword{syntax} and \isakeyword{translations}.  The
   303   instead of \isakeyword{syntax} + \isakeyword{translations}.  The
   324   present formulation has the virtue that expressions are immediately
   304   present formulation has the virtue that expressions are immediately
   325   replaced by its ``definition'' upon parsing; the effect is reversed
   305   replaced by its ``definition'' upon parsing; the effect is reversed
   326   upon printing.  Internally, @{text"\<noteq>"} never appears.
   306   upon printing.  Internally, @{text"\<noteq>"} never appears.
   327 
   307 
   328   Simulating definitions via translations is adequate for very basic
   308   Simulating definitions via translations is adequate for very basic
   329   variations of fundamental logical concepts, when the new
   309   logical concepts, where a new representation is a trivial variation
   330   representation is a trivial variation on an existing one.  On the
   310   on an existing one.  On the other hand, syntax translations do not
   331   other hand, syntax translations do not scale up well to large
   311   scale up well to large hierarchies of concepts built on each other.
   332   hierarchies of concepts built on each other.
   312 *}
   333 *}
   313 
   334 
   314 
   335 
   315 section {* Document Preparation \label{sec:document-preparation} *}
   336 section {* Document Preparation \label{sec:document-prep} *}
   316 
   337 
   317 text {*
   338 text {*
   318   Isabelle/Isar is centered around the concept of \bfindex{formal
   339   Isabelle/Isar is centered around a certain notion of \bfindex{formal
   319   proof documents}\index{documents|bold}.  Ultimately the result of
   340   proof documents}\index{documents|bold}: ultimately the result of the
   320   the user's theory development efforts is meant to be a
   341   user's theory development efforts is a human-readable record --- as
   321   human-readable record, presented as a browsable PDF file or printed
   342   a browsable PDF file or printed on paper.  The overall document
   322   on paper.  The overall document structure follows traditional
   343   structure follows traditional mathematical articles, with
   323   mathematical articles, with sectioning, intermediate explanations,
   344   sectioning, explanations, definitions, theorem statements, and
   324   definitions, theorem statements and proofs.
   345   proofs.
       
   346 
   325 
   347   The Isar proof language \cite{Wenzel-PhD}, which is not covered in
   326   The Isar proof language \cite{Wenzel-PhD}, which is not covered in
   348   this book, admits to write formal proof texts that are acceptable
   327   this book, admits to write formal proof texts that are acceptable
   349   both to the machine and human readers at the same time.  Thus
   328   both to the machine and human readers at the same time.  Thus
   350   marginal comments and explanations may be kept at a minimum.
   329   marginal comments and explanations may be kept at a minimum.  Even
   351   Nevertheless, Isabelle document output is still useful without
   330   without proper coverage of human-readable proofs, Isabelle document
   352   actual Isar proof texts; formal specifications usually deserve their
   331   is very useful to produce formally derived texts (elaborating on the
   353   own coverage in the text, while unstructured proof scripts may be
   332   specifications etc.).  Unstructured proof scripts given here may be
   354   just ignore by readers (or intentionally suppressed from the text).
   333   just ignored by readers, or intentionally suppressed from the text
       
   334   by the writer (see also \S\ref{sec:doc-prep-suppress}).
   355 
   335 
   356   \medskip The Isabelle document preparation system essentially acts
   336   \medskip The Isabelle document preparation system essentially acts
   357   like a formal front-end for {\LaTeX}.  After checking definitions
   337   like a formal front-end to {\LaTeX}.  After checking specifications
   358   and proofs the theory sources are turned into typesetting
   338   and proofs, the theory sources are turned into typesetting
   359   instructions, so the final document is known to observe quite strong
   339   instructions in a well-defined manner.  This enables users to write
   360   ``soundness'' properties.  This enables users to write authentic
   340   authentic reports on formal theory developments with little
   361   reports on formal theory developments with little additional effort,
   341   additional effort, the most tedious consistency checks are handled
   362   the most tedious consistency checks are handled by the system.
   342   by the system.
   363 *}
   343 *}
   364 
   344 
   365 
   345 
   366 subsection {* Isabelle Sessions *}
   346 subsection {* Isabelle Sessions *}
   367 
   347 
   368 text {*
   348 text {*
   369   In contrast to the highly interactive mode of the formal parts of
   349   In contrast to the highly interactive mode of Isabelle/Isar theory
   370   Isabelle/Isar theory development, the document preparation stage
   350   development, the document preparation stage essentially works in
   371   essentially works in batch-mode.  This revolves around the concept
   351   batch-mode.  An Isabelle \bfindex{session} essentially consists of a
   372   of a \bfindex{session}, which essentially consists of a collection
   352   collection of theory source files that contribute to a single output
   373   of theory source files that contribute to a single output document.
   353   document eventually.  Session is derived from a single parent each
   374   Each session is derived from a parent one (usually an object-logic
   354   (usually an object-logic image like \texttt{HOL}), resulting in an
   375   image such as \texttt{HOL}); this results in an overall tree
   355   overall tree structure that is reflected in the output location
   376   structure of Isabelle sessions.
   356   within the file system (usually rooted at
   377 
   357   \verb,~/isabelle/browser_info,).
   378   The canonical arrangement of source files of a session called
   358 
   379   \texttt{MySession} is as follows:
   359   Here is the canonical arrangement of sources of a session called
       
   360   \texttt{MySession}:
   380 
   361 
   381   \begin{itemize}
   362   \begin{itemize}
   382 
   363 
   383   \item Directory \texttt{MySession} contains the required theory
   364   \item Directory \texttt{MySession} contains the required theory
   384   files, say $A@1$\texttt{.thy}, \dots, $A@n$\texttt{.thy}.
   365   files ($A@1$\texttt{.thy}, \dots, $A@n$\texttt{.thy}).
   385 
   366 
   386   \item File \texttt{MySession/ROOT.ML} holds appropriate ML commands
   367   \item File \texttt{MySession/ROOT.ML} holds appropriate ML commands
   387   for loading all wanted theories, usually just
   368   for loading all wanted theories, usually just
   388   \texttt{use_thy~"$A@i$"} for any $A@i$ in leaf position of the
   369   ``\texttt{use_thy~"$A@i$";}'' for any $A@i$ in leaf position of the
   389   theory dependency graph.
   370   theory dependency graph.
   390 
   371 
   391   \item Directory \texttt{MySession/document} contains everything
   372   \item Directory \texttt{MySession/document} contains everything
   392   required for the {\LaTeX} stage, but only \texttt{root.tex} needs to
   373   required for the {\LaTeX} stage; only \texttt{root.tex} needs to be
   393   be provided initially.  The latter file holds appropriate {\LaTeX}
   374   provided initially.
   394   code to commence a document (\verb,\documentclass, etc.), and to
   375 
   395   include the generated files $A@i$\texttt{.tex} for each theory.  The
   376   The latter file holds appropriate {\LaTeX} code to commence a
   396   generated file \texttt{session.tex} holds {\LaTeX} commands to
   377   document (\verb,\documentclass, etc.), and to include the generated
   397   include \emph{all} theory output files in topologically sorted
   378   files $A@i$\texttt{.tex} for each theory.  The generated
   398   order.
   379   \texttt{session.tex} will hold {\LaTeX} commands to include all
   399 
   380   theory output files in topologically sorted order, so
   400   \item In addition an \texttt{IsaMakefile} outside of directory
   381   \verb,\input{session}, in \texttt{root.tex} will do it in most
       
   382   situations.
       
   383 
       
   384   \item In addition, \texttt{IsaMakefile} outside of the directory
   401   \texttt{MySession} holds appropriate dependencies and invocations of
   385   \texttt{MySession} holds appropriate dependencies and invocations of
   402   Isabelle tools to control the batch job.  The details are covered in
   386   Isabelle tools to control the batch job.  In fact, several sessions
   403   \cite{isabelle-sys}; \texttt{isatool usedir} is the most important
   387   may be controlled by the same \texttt{IsaMakefile}.  See also
   404   entry point.
   388   \cite{isabelle-sys} for further details, especially on
       
   389   \texttt{isatool usedir} and \texttt{isatool make}.
   405 
   390 
   406   \end{itemize}
   391   \end{itemize}
   407 
   392 
   408   With everything put in its proper place, \texttt{isatool make}
   393   With everything put in its proper place, \texttt{isatool make}
   409   should be sufficient to process the Isabelle session completely,
   394   should be sufficient to process the Isabelle session completely,
   410   with the generated document appearing in its proper place (within
   395   with the generated document appearing in its proper place.
   411   \verb,~/isabelle/browser_info,).
   396 
   412 
   397   \medskip In practice, users may want to have \texttt{isatool mkdir}
   413   In practice, users may want to have \texttt{isatool mkdir} generate
   398   generate an initial working setup without further ado.  For example,
   414   an initial working setup without further ado.  For example, an empty
   399   an empty session \texttt{MySession} derived from \texttt{HOL} may be
   415   session \texttt{MySession} derived from \texttt{HOL} may be produced
   400   produced as follows:
   416   as follows:
       
   417 
   401 
   418 \begin{verbatim}
   402 \begin{verbatim}
   419   isatool mkdir HOL MySession
   403   isatool mkdir HOL MySession
   420   isatool make
   404   isatool make
   421 \end{verbatim}
   405 \end{verbatim}
   422 
   406 
   423   This runs the session with sensible default options, including
   407   This processes the session with sensible default options, including
   424   verbose mode to tell the user where the result will appear.  The
   408   verbose mode to tell the user where the ultimate results will
   425   above dry run should produce should produce a single page of output
   409   appear.  The above dry run should produce should already be able to
   426   (with a dummy title, empty table of contents etc.).  Any failure at
   410   produce a single page of output (with a dummy title, empty table of
   427   that stage is likely to indicate some technical problems with your
   411   contents etc.).  Any failure at that stage is likely to indicate
   428   {\LaTeX} installation.\footnote{Especially make sure that
   412   technical problems with the user's {\LaTeX}
   429   \texttt{pdflatex} is present.}
   413   installation.\footnote{Especially make sure that \texttt{pdflatex}
   430 
   414   is present; if all fails one may fall back on DVI output by changing
   431   \medskip Users may now start to populate the directory
   415   \texttt{usedir} options \cite{isabelle-sys}.}
       
   416 
       
   417   \medskip One may now start to populate the directory
   432   \texttt{MySession}, and the file \texttt{MySession/ROOT.ML}
   418   \texttt{MySession}, and the file \texttt{MySession/ROOT.ML}
   433   accordingly.  \texttt{MySession/document/root.tex} should be also
   419   accordingly.  \texttt{MySession/document/root.tex} should be also
   434   adapted at some point; the generated version is mostly
   420   adapted at some point; the default version is mostly
   435   self-explanatory.  The default versions includes the
   421   self-explanatory.
   436   \texttt{isabelle} (mandatory) and \texttt{isabellesym} (required for
   422 
   437   mathematical symbols); further packages may required, e.g.\ for
   423   Especially note the standard inclusion of {\LaTeX} packages
   438   unusual Isabelle symbols.
   424   \texttt{isabelle} (mandatory), and \texttt{isabellesym} (required
   439 
   425   for mathematical symbols), and the final \texttt{pdfsetup} (provides
   440   Realistic applications may demand additional files in
   426   handsome defaults for \texttt{hyperref}, including URL markup).
   441   \texttt{MySession/document} for the {\LaTeX} stage, such as
   427   Further {\LaTeX} packages further packages may required in
   442   \texttt{root.bib} for the bibliographic database.\footnote{Using
   428   particular applications, e.g.\ for unusual Isabelle symbols.
   443   that particular name of \texttt{root.bib}, the Isabelle document
   429 
   444   processor (actually \texttt{isatool document} \cite{isabelle-sys})
   430   \medskip Further auxiliary files for the {\LaTeX} stage should be
   445   will be smart enough to invoke \texttt{bibtex} accordingly.}
   431   included in the \texttt{MySession/document} directory, e.g.\
   446 
   432   additional {\TeX} sources or graphics.  In particular, adding
   447   \medskip Failure of the document preparation phase in an Isabelle
   433   \texttt{root.bib} here (with that specific name) causes an automatic
   448   batch session leaves the generated sources in there target location
   434   run of \texttt{bibtex} to process a bibliographic database; see for
   449   (as pointed out by the accompanied error message).  In case of
   435   further commodities \texttt{isatool document} covered in
   450   {\LaTeX} errors, users may trace error messages at the file position
   436   \cite{isabelle-sys}.
   451   of the generated text.
   437 
       
   438   \medskip Any failure of the document preparation phase in an
       
   439   Isabelle batch session leaves the generated sources in there target
       
   440   location (as pointed out by the accompanied error message).  In case
       
   441   of {\LaTeX} errors, users may trace error messages at the file
       
   442   position of the generated text.
   452 *}
   443 *}
   453 
   444 
   454 
   445 
   455 subsection {* Structure Markup *}
   446 subsection {* Structure Markup *}
   456 
   447 
   457 subsubsection {* Sections *}
   448 text {*
   458 
   449   The large-scale structure of Isabelle documents follows existing
   459 text {*
   450   {\LaTeX} conventions, with chapters, sections, subsubsections etc.
   460   The large-scale structure of Isabelle documents closely follows
   451   The Isar language includes separate \bfindex{markup commands}, which
   461   {\LaTeX} convention, with chapters, sections, subsubsections etc.
   452   do not effect the formal content of a theory (or proof), but result
   462   The formal Isar language includes separate structure \bfindex{markup
   453   in corresponding {\LaTeX} elements issued to the output.
   463   commands}, which do not effect the formal content of a theory (or
   454 
   464   proof), but results in corresponding {\LaTeX} elements issued to the
   455   There are separate markup commands for different formal contexts: in
   465   output.
   456   header position (just before a \isakeyword{theory} command), within
   466 
   457   the theory body, or within a proof.  Note that the header needs to
   467   There are different markup commands for different formal contexts:
   458   be treated specially, since ordinary theory and proof commands may
   468   in header position (just before a \isakeyword{theory} command),
   459   only occur \emph{after} the initial \isakeyword{theory}
   469   within the theory body, or within a proof.  Note that the header
       
   470   needs to be treated specially, since ordinary theory and proof
       
   471   commands may only occur \emph{after} the initial \isakeyword{theory}
       
   472   specification.
   460   specification.
   473 
   461 
   474   \smallskip
   462   \smallskip
   475 
   463 
   476   \begin{tabular}{llll}
   464   \begin{tabular}{llll}
   483 
   471 
   484   \medskip
   472   \medskip
   485 
   473 
   486   From the Isabelle perspective, each markup command takes a single
   474   From the Isabelle perspective, each markup command takes a single
   487   text argument (delimited by \verb,",\dots\verb,", or
   475   text argument (delimited by \verb,",\dots\verb,", or
   488   \verb,{,\verb,*,~\dots~\verb,*,\verb,},).  After stripping
   476   \verb,{,\verb,*,~\dots~\verb,*,\verb,},).  After stripping any
   489   surrounding white space, the argument is passed to a {\LaTeX} macro
   477   surrounding white space, the argument is passed to a {\LaTeX} macro
   490   \verb,\isamarkupXXX, for any command \isakeyword{XXX}.  The latter
   478   \verb,\isamarkupXYZ, for any command \isakeyword{XYZ}.  These macros
   491   are defined in \verb,isabelle.sty, according to the rightmost column
   479   are defined in \verb,isabelle.sty, according to the meaning given in
   492   above.
   480   the rightmost column above.
   493 
   481 
   494   \medskip The following source fragment illustrates structure markup
   482   \medskip The following source fragment illustrates structure markup
   495   of a theory.  Note that {\LaTeX} labels may well be included inside
   483   of a theory.  Note that {\LaTeX} labels may be included inside of
   496   of section headings as well.
   484   section headings as well.
   497 
   485 
   498   \begin{ttbox}
   486   \begin{ttbox}
   499   header {\ttlbrace}* Some properties of Foo Bar elements *{\ttrbrace}
   487   header {\ttlbrace}* Some properties of Foo Bar elements *{\ttrbrace}
   500 
   488 
   501   theory Foo_Bar = Main:
   489   theory Foo_Bar = Main:
   518   theorem main: \dots
   506   theorem main: \dots
   519 
   507 
   520   end
   508   end
   521   \end{ttbox}
   509   \end{ttbox}
   522 
   510 
   523   Users may occasionally want to change the meaning of some markup
   511   Users may occasionally want to change the meaning of markup
   524   commands, typically via appropriate use of \verb,\renewcommand, in
   512   commands, say via \verb,\renewcommand, in \texttt{root.tex}.  The
   525   \texttt{root.tex}.  The \verb,\isamarkupheader, is a good candidate
   513   \verb,\isamarkupheader, is a good candidate for some adaption, e.g.\
   526   for some adaption, e.g.\ moving it up in the hierarchy to become
   514   moving it up in the hierarchy to become \verb,\chapter,.
   527   \verb,\chapter,.
       
   528 
   515 
   529 \begin{verbatim}
   516 \begin{verbatim}
   530   \renewcommand{\isamarkupheader}[1]{\chapter{#1}}
   517   \renewcommand{\isamarkupheader}[1]{\chapter{#1}}
   531 \end{verbatim}
   518 \end{verbatim}
   532 
   519 
   533   Certainly, this requires to change the default
   520   \noindent Certainly, this requires to change the default
   534   \verb,\documentclass{article}, in \texttt{root.tex} to something
   521   \verb,\documentclass{article}, in \texttt{root.tex} to something
   535   that supports the notion of chapters in the first place, e.g.\
   522   that supports the notion of chapters in the first place, e.g.\
   536   \verb,\documentclass{report},.
   523   \verb,\documentclass{report},.
   537 
   524 
   538   \medskip The {\LaTeX} macro \verb,\isabellecontext, is maintained to
   525   \medskip The {\LaTeX} macro \verb,\isabellecontext, is maintained to
   539   hold the name of the current theory context.  This is particularly
   526   hold the name of the current theory context.  This is particularly
   540   useful for document headings or footings, e.g.\ like this:
   527   useful for document headings:
   541 
   528 
   542 \begin{verbatim}
   529 \begin{verbatim}
   543   \renewcommand{\isamarkupheader}[1]%
   530   \renewcommand{\isamarkupheader}[1]
   544   {\chapter{#1}\markright{THEORY~\isabellecontext}}
   531   {\chapter{#1}\markright{THEORY~\isabellecontext}}
   545 \end{verbatim}
   532 \end{verbatim}
   546 
   533 
   547   \noindent Make sure to include something like
   534   \noindent Make sure to include something like
   548   \verb,\pagestyle{headings}, in \texttt{root.tex}; the document
   535   \verb,\pagestyle{headings}, in \texttt{root.tex}; the document
   558   FIXME
   545   FIXME
   559 
   546 
   560 *}
   547 *}
   561 
   548 
   562 
   549 
   563 subsection {* Symbols and Characters *}
   550 subsection {* Symbols and Characters \label{sec:doc-prep-symbols} *}
   564 
   551 
   565 text {*
   552 text {*
   566   FIXME \verb,\isabellestyle,
   553   FIXME \verb,\isabellestyle,
   567 *}
   554 *}
   568 
   555 
   569 
   556 
   570 subsection {* Suppressing Output *}
   557 subsection {* Suppressing Output \label{sec:doc-prep-suppress} *}
   571 
   558 
   572 text {*
   559 text {*
   573   By default Isabelle's document system generates a {\LaTeX} source
   560   By default Isabelle's document system generates a {\LaTeX} source
   574   file for each theory that happens to get loaded during the session.
   561   file for each theory that happens to get loaded during the session.
   575   The generated \texttt{session.tex} file will include all of these in
   562   The generated \texttt{session.tex} will include all of these in
   576   order of appearance, which in turn gets included by the standard
   563   order of appearance, which in turn gets included by the standard
   577   \texttt{root.tex} file.  Certainly one may change the order of
   564   \texttt{root.tex}.  Certainly one may change the order of appearance
   578   appearance or suppress unwanted theories by ignoring
   565   or suppress unwanted theories by ignoring \texttt{session.tex} and
   579   \texttt{session.tex} and include individual files in
   566   include individual files in \texttt{root.tex} by hand.  On the other
   580   \texttt{root.tex} by hand.  On the other hand, such an arrangement
   567   hand, such an arrangement requires additional maintenance chores
   581   requires additional efforts for maintenance.
   568   whenever the collection of theories changes.
   582 
   569 
   583   Alternatively, one may tune the theory loading process in
   570   Alternatively, one may tune the theory loading process in
   584   \texttt{ROOT.ML}: traversal of the theory dependency graph may be
   571   \texttt{ROOT.ML} itself: traversal of the theory dependency graph
   585   fine-tuned by adding further \verb,use_thy, invocations, although
   572   may be fine-tuned by adding further \verb,use_thy, invocations,
   586   topological sorting needs to be preserved.  Moreover, the ML
   573   although topological sorting still has to be observed.  Moreover,
   587   operator \verb,no_document, temporarily disables document generation
   574   the ML operator \verb,no_document, temporarily disables document
   588   while executing a theory loader command; the usage is like this:
   575   generation while executing a theory loader command; its usage is
       
   576   like this:
   589 
   577 
   590 \begin{verbatim}
   578 \begin{verbatim}
   591   no_document use_thy "Aux";
   579   no_document use_thy "A";
   592 \end{verbatim}
   580 \end{verbatim}
   593 
   581 
   594   Theory output may be also suppressed \emph{partially} as well.
   582   \medskip Theory output may be also suppressed in smaller portions as
   595   Typical applications include research papers or slides based on
   583   well.  For example, research papers or slides usually do not include
   596   formal developments --- these usually do not show the full formal
   584   the formal content in full.  In order to delimit \bfindex{ignored
   597   content.  The special source comments
   585   material} special source comments
   598   \verb,(,\verb,*,\verb,<,\verb,*,\verb,), and
   586   \verb,(,\verb,*,\verb,<,\verb,*,\verb,), and
   599   \verb,(,\verb,*,\verb,>,\verb,*,\verb,), are interpreted by the
   587   \verb,(,\verb,*,\verb,>,\verb,*,\verb,), may be included in the
   600   document generator as open and close parenthesis for
   588   text.  Only the document preparation system is affected, the formal
   601   \bfindex{ignored material}.  Any text inside of (potentially nested)
   589   checking the theory is performed as before.
   602   \verb,(,\verb,*,\verb,<,\verb,*,\verb,),~\dots~\verb,(,\verb,*,\verb,>,\verb,*,\verb,),
       
   603   parentheses is just ignored from the output --- after correct formal
       
   604   checking.
       
   605 
   590 
   606   In the following example we suppress the slightly formalistic
   591   In the following example we suppress the slightly formalistic
   607   \isakeyword{theory} and \isakeyword{end} part of a theory text.
   592   \isakeyword{theory} + \isakeyword{end} surroundings a theory.
   608 
   593 
   609   \medskip
   594   \medskip
   610 
   595 
   611   \begin{tabular}{l}
   596   \begin{tabular}{l}
   612   \verb,(,\verb,*,\verb,<,\verb,*,\verb,), \\
   597   \verb,(,\verb,*,\verb,<,\verb,*,\verb,), \\
   618   \verb,(,\verb,*,\verb,>,\verb,*,\verb,), \\
   603   \verb,(,\verb,*,\verb,>,\verb,*,\verb,), \\
   619   \end{tabular}
   604   \end{tabular}
   620 
   605 
   621   \medskip
   606   \medskip
   622 
   607 
   623   Text may be suppressed at a very fine grain; thus we may even drop
   608   Text may be suppressed in a fine grained manner.  For example, we
   624   vital parts of the formal text, preventing that things have been
   609   may even drop vital parts of a formal proof, pretending that things
   625   simpler than in reality.  For example, the following ``fully
   610   have been simpler than in reality.  For example, the following
   626   automatic'' proof is actually a fake:
   611   ``fully automatic'' proof is actually a fake:
   627 *}
   612 *}
   628 
   613 
   629 lemma "x \<noteq> (0::int) \<Longrightarrow> 0 < x * x"
   614 lemma "x \<noteq> (0::int) \<Longrightarrow> 0 < x * x"
   630   by (auto(*<*)simp add: int_less_le(*>*))
   615   by (auto(*<*)simp add: int_less_le(*>*))
   631 
   616 
   634 
   619 
   635 \begin{verbatim}
   620 \begin{verbatim}
   636   by (auto(*<*)simp add: int_less_le(*>*))
   621   by (auto(*<*)simp add: int_less_le(*>*))
   637 \end{verbatim} %(*
   622 \end{verbatim} %(*
   638 
   623 
   639   \medskip Ignoring portions of printed text generally demands some
   624   \medskip Ignoring portions of printed does demand some care by the
   640   care by the user.  First of all, the writer is responsible not to
   625   user.  First of all, the writer is responsible not to obfuscate the
   641   obfuscate the underlying formal development in an unduly manner.  It
   626   underlying formal development in an unduly manner.  It is fairly
   642   is fairly easy to scramble the remaining visible text by referring
   627   easy to invalidate the remaining visible text, e.g.\ by referencing
   643   to questionable formal items (strange definitions, arbitrary axioms
   628   questionable formal items (strange definitions, arbitrary axioms
   644   etc.) that have been hidden from sight.
   629   etc.) that have been hidden from sight beforehand.
   645 
   630 
   646   Some minor technical subtleties of the
   631   Some minor technical subtleties of the
   647   \verb,(,\verb,*,\verb,<,\verb,*,\verb,),~\verb,(,\verb,*,\verb,>,\verb,*,\verb,),
   632   \verb,(,\verb,*,\verb,<,\verb,*,\verb,),-\verb,(,\verb,*,\verb,>,\verb,*,\verb,),
   648   elements need to be observed as well, as the system performs little
   633   elements need to be kept in mind as well, since the system performs
   649   sanity checks here.  Arguments of markup commands and formal
   634   little sanity checks here.  Arguments of markup commands and formal
   650   comments must not be hidden, otherwise presentation fails.  Open and
   635   comments must not be hidden, otherwise presentation fails.  Open and
   651   close parentheses need to be inserted carefully; it is fairly easy
   636   close parentheses need to be inserted carefully; it is fairly easy
   652   to hide just the wrong parts, especially after rearranging the
   637   to hide the wrong parts, especially after rearranging the sources.
   653   sources.
       
   654 
   638 
   655   \medskip Authentic reports of formal theories, say as part of a
   639   \medskip Authentic reports of formal theories, say as part of a
   656   library, should usually refrain from suppressing parts of the text
   640   library, usually should refrain from suppressing parts of the text
   657   at all.  Other users may need the full information for their own
   641   at all.  Other users may need the full information for their own
   658   derivative work.  If a particular formalization works out as too
   642   derivative work.  If a particular formalization appears inadequate
   659   ugly for general public coverage, it is often better to think of a
   643   for general public coverage, it is often more appropriate to think
   660   better way in the first place.
   644   of a better way in the first place.
   661 *}
   645 *}
   662 
   646 
   663 (*<*)
   647 (*<*)
   664 end
   648 end
   665 (*>*)
   649 (*>*)