src/Doc/Tutorial/Documents/Documents.thy
changeset 67406 23307fd33906
parent 67398 5eb932e604a2
child 67443 3abf6a722518
equal deleted inserted replaced
67405:e9ab4ad7bd15 67406:23307fd33906
     1 (*<*)
     1 (*<*)
     2 theory Documents imports Main begin
     2 theory Documents imports Main begin
     3 (*>*)
     3 (*>*)
     4 
     4 
     5 section {* Concrete Syntax \label{sec:concrete-syntax} *}
     5 section \<open>Concrete Syntax \label{sec:concrete-syntax}\<close>
     6 
     6 
     7 text {*
     7 text \<open>
     8   The core concept of Isabelle's framework for concrete syntax is that
     8   The core concept of Isabelle's framework for concrete syntax is that
     9   of \bfindex{mixfix annotations}.  Associated with any kind of
     9   of \bfindex{mixfix annotations}.  Associated with any kind of
    10   constant declaration, mixfixes affect both the grammar productions
    10   constant declaration, mixfixes affect both the grammar productions
    11   for the parser and output templates for the pretty printer.
    11   for the parser and output templates for the pretty printer.
    12 
    12 
    17   elements, it is particularly important to give new syntactic
    17   elements, it is particularly important to give new syntactic
    18   constructs the right precedence.
    18   constructs the right precedence.
    19 
    19 
    20   Below we introduce a few simple syntax declaration
    20   Below we introduce a few simple syntax declaration
    21   forms that already cover many common situations fairly well.
    21   forms that already cover many common situations fairly well.
    22 *}
    22 \<close>
    23 
    23 
    24 
    24 
    25 subsection {* Infix Annotations *}
    25 subsection \<open>Infix Annotations\<close>
    26 
    26 
    27 text {*
    27 text \<open>
    28   Syntax annotations may be included wherever constants are declared,
    28   Syntax annotations may be included wherever constants are declared,
    29   such as \isacommand{definition} and \isacommand{primrec} --- and also
    29   such as \isacommand{definition} and \isacommand{primrec} --- and also
    30   \isacommand{datatype}, which declares constructor operations.
    30   \isacommand{datatype}, which declares constructor operations.
    31   Type-constructors may be annotated as well, although this is less
    31   Type-constructors may be annotated as well, although this is less
    32   frequently encountered in practice (the infix type @{text "\<times>"} comes
    32   frequently encountered in practice (the infix type @{text "\<times>"} comes
    33   to mind).
    33   to mind).
    34 
    34 
    35   Infix declarations\index{infix annotations} provide a useful special
    35   Infix declarations\index{infix annotations} provide a useful special
    36   case of mixfixes.  The following example of the exclusive-or
    36   case of mixfixes.  The following example of the exclusive-or
    37   operation on boolean values illustrates typical infix declarations.
    37   operation on boolean values illustrates typical infix declarations.
    38 *}
    38 \<close>
    39 
    39 
    40 definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "[+]" 60)
    40 definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "[+]" 60)
    41 where "A [+] B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
    41 where "A [+] B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
    42 
    42 
    43 text {*
    43 text \<open>
    44   \noindent Now @{text "xor A B"} and @{text "A [+] B"} refer to the
    44   \noindent Now @{text "xor A B"} and @{text "A [+] B"} refer to the
    45   same expression internally.  Any curried function with at least two
    45   same expression internally.  Any curried function with at least two
    46   arguments may be given infix syntax.  For partial applications with
    46   arguments may be given infix syntax.  For partial applications with
    47   fewer than two operands, the operator is enclosed in parentheses.
    47   fewer than two operands, the operator is enclosed in parentheses.
    48   For instance, @{text xor} without arguments is represented as
    48   For instance, @{text xor} without arguments is represented as
    73   the range of 10--100: the equality infix @{text "="} is centered at
    73   the range of 10--100: the equality infix @{text "="} is centered at
    74   50; logical connectives (like @{text "\<or>"} and @{text "\<and>"}) are
    74   50; logical connectives (like @{text "\<or>"} and @{text "\<and>"}) are
    75   below 50; algebraic ones (like @{text "+"} and @{text "*"}) are
    75   below 50; algebraic ones (like @{text "+"} and @{text "*"}) are
    76   above 50.  User syntax should strive to coexist with common HOL
    76   above 50.  User syntax should strive to coexist with common HOL
    77   forms, or use the mostly unused range 100--900.
    77   forms, or use the mostly unused range 100--900.
    78 *}
    78 \<close>
    79 
    79 
    80 
    80 
    81 subsection {* Mathematical Symbols \label{sec:syntax-symbols} *}
    81 subsection \<open>Mathematical Symbols \label{sec:syntax-symbols}\<close>
    82 
    82 
    83 text {*
    83 text \<open>
    84   Concrete syntax based on ASCII characters has inherent limitations.
    84   Concrete syntax based on ASCII characters has inherent limitations.
    85   Mathematical notation demands a larger repertoire of glyphs.
    85   Mathematical notation demands a larger repertoire of glyphs.
    86   Several standards of extended character sets have been proposed over
    86   Several standards of extended character sets have been proposed over
    87   decades, but none has become universally available so far.  Isabelle
    87   decades, but none has become universally available so far.  Isabelle
    88   has its own notion of \bfindex{symbols} as the smallest entities of
    88   has its own notion of \bfindex{symbols} as the smallest entities of
   131   \noindent is recognized as the term @{term "\<forall>\<alpha>\<^sub>1. \<alpha>\<^sub>1 = \<Pi>\<^sub>\<A>"} 
   131   \noindent is recognized as the term @{term "\<forall>\<alpha>\<^sub>1. \<alpha>\<^sub>1 = \<Pi>\<^sub>\<A>"} 
   132   by Isabelle.
   132   by Isabelle.
   133 
   133 
   134   Replacing our previous definition of @{text xor} by the
   134   Replacing our previous definition of @{text xor} by the
   135   following specifies an Isabelle symbol for the new operator:
   135   following specifies an Isabelle symbol for the new operator:
   136 *}
   136 \<close>
   137 
   137 
   138 (*<*)
   138 (*<*)
   139 hide_const xor
   139 hide_const xor
   140 setup {* Sign.add_path "version1" *}
   140 setup \<open>Sign.add_path "version1"\<close>
   141 (*>*)
   141 (*>*)
   142 definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "\<oplus>" 60)
   142 definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "\<oplus>" 60)
   143 where "A \<oplus> B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
   143 where "A \<oplus> B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
   144 (*<*)
   144 (*<*)
   145 setup {* Sign.local_path *}
   145 setup \<open>Sign.local_path\<close>
   146 (*>*)
   146 (*>*)
   147 
   147 
   148 text {*
   148 text \<open>
   149   It is possible to provide alternative syntax forms
   149   It is possible to provide alternative syntax forms
   150   through the \bfindex{print mode} concept~@{cite "isabelle-isar-ref"}.  By
   150   through the \bfindex{print mode} concept~@{cite "isabelle-isar-ref"}.  By
   151   convention, the mode of ``$xsymbols$'' is enabled whenever
   151   convention, the mode of ``$xsymbols$'' is enabled whenever
   152   Proof~General's X-Symbol mode or {\LaTeX} output is active.  Now
   152   Proof~General's X-Symbol mode or {\LaTeX} output is active.  Now
   153   consider the following hybrid declaration of @{text xor}:
   153   consider the following hybrid declaration of @{text xor}:
   154 *}
   154 \<close>
   155 
   155 
   156 (*<*)
   156 (*<*)
   157 hide_const xor
   157 hide_const xor
   158 setup {* Sign.add_path "version2" *}
   158 setup \<open>Sign.add_path "version2"\<close>
   159 (*>*)
   159 (*>*)
   160 definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "[+]\<ignore>" 60)
   160 definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "[+]\<ignore>" 60)
   161 where "A [+]\<ignore> B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
   161 where "A [+]\<ignore> B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
   162 
   162 
   163 notation (xsymbols) xor (infixl "\<oplus>\<ignore>" 60)
   163 notation (xsymbols) xor (infixl "\<oplus>\<ignore>" 60)
   164 (*<*)
   164 (*<*)
   165 setup {* Sign.local_path *}
   165 setup \<open>Sign.local_path\<close>
   166 (*>*)
   166 (*>*)
   167 
   167 
   168 text {*\noindent
   168 text \<open>\noindent
   169 The \commdx{notation} command associates a mixfix
   169 The \commdx{notation} command associates a mixfix
   170 annotation with a known constant.  The print mode specification,
   170 annotation with a known constant.  The print mode specification,
   171 here @{text "(xsymbols)"}, is optional.
   171 here @{text "(xsymbols)"}, is optional.
   172 
   172 
   173 We may now write @{text "A [+] B"} or @{text "A \<oplus> B"} in input, while
   173 We may now write @{text "A [+] B"} or @{text "A \<oplus> B"} in input, while
   174 output uses the nicer syntax of $xsymbols$ whenever that print mode is
   174 output uses the nicer syntax of $xsymbols$ whenever that print mode is
   175 active.  Such an arrangement is particularly useful for interactive
   175 active.  Such an arrangement is particularly useful for interactive
   176 development, where users may type ASCII text and see mathematical
   176 development, where users may type ASCII text and see mathematical
   177 symbols displayed during proofs.  *}
   177 symbols displayed during proofs.\<close>
   178 
   178 
   179 
   179 
   180 subsection {* Prefix Annotations *}
   180 subsection \<open>Prefix Annotations\<close>
   181 
   181 
   182 text {*
   182 text \<open>
   183   Prefix syntax annotations\index{prefix annotation} are another form
   183   Prefix syntax annotations\index{prefix annotation} are another form
   184   of mixfixes @{cite "isabelle-isar-ref"}, without any template arguments or
   184   of mixfixes @{cite "isabelle-isar-ref"}, without any template arguments or
   185   priorities --- just some literal syntax.  The following example
   185   priorities --- just some literal syntax.  The following example
   186   associates common symbols with the constructors of a datatype.
   186   associates common symbols with the constructors of a datatype.
   187 *}
   187 \<close>
   188 
   188 
   189 datatype currency =
   189 datatype currency =
   190     Euro nat    ("\<euro>")
   190     Euro nat    ("\<euro>")
   191   | Pounds nat  ("\<pounds>")
   191   | Pounds nat  ("\<pounds>")
   192   | Yen nat     ("\<yen>")
   192   | Yen nat     ("\<yen>")
   193   | Dollar nat  ("$")
   193   | Dollar nat  ("$")
   194 
   194 
   195 text {*
   195 text \<open>
   196   \noindent Here the mixfix annotations on the rightmost column happen
   196   \noindent Here the mixfix annotations on the rightmost column happen
   197   to consist of a single Isabelle symbol each: \verb,\,\verb,<euro>,,
   197   to consist of a single Isabelle symbol each: \verb,\,\verb,<euro>,,
   198   \verb,\,\verb,<pounds>,, \verb,\,\verb,<yen>,, and \verb,$,.  Recall
   198   \verb,\,\verb,<pounds>,, \verb,\,\verb,<yen>,, and \verb,$,.  Recall
   199   that a constructor like @{text Euro} actually is a function @{typ
   199   that a constructor like @{text Euro} actually is a function @{typ
   200   "nat \<Rightarrow> currency"}.  The expression @{text "Euro 10"} will be
   200   "nat \<Rightarrow> currency"}.  The expression @{text "Euro 10"} will be
   202   subject to our concrete syntax.  This rather simple form already
   202   subject to our concrete syntax.  This rather simple form already
   203   achieves conformance with notational standards of the European
   203   achieves conformance with notational standards of the European
   204   Commission.
   204   Commission.
   205 
   205 
   206   Prefix syntax works the same way for other commands that introduce new constants, e.g. \isakeyword{primrec}.
   206   Prefix syntax works the same way for other commands that introduce new constants, e.g. \isakeyword{primrec}.
   207 *}
   207 \<close>
   208 
   208 
   209 
   209 
   210 subsection {* Abbreviations \label{sec:abbreviations} *}
   210 subsection \<open>Abbreviations \label{sec:abbreviations}\<close>
   211 
   211 
   212 text{* Mixfix syntax annotations merely decorate particular constant
   212 text\<open>Mixfix syntax annotations merely decorate particular constant
   213 application forms with concrete syntax, for instance replacing
   213 application forms with concrete syntax, for instance replacing
   214 @{text "xor A B"} by @{text "A \<oplus> B"}.  Occasionally, the relationship
   214 @{text "xor A B"} by @{text "A \<oplus> B"}.  Occasionally, the relationship
   215 between some piece of notation and its internal form is more
   215 between some piece of notation and its internal form is more
   216 complicated.  Here we need \emph{abbreviations}.
   216 complicated.  Here we need \emph{abbreviations}.
   217 
   217 
   221 simple mechanism for syntactic macros.
   221 simple mechanism for syntactic macros.
   222 
   222 
   223 A typical use of abbreviations is to introduce relational notation for
   223 A typical use of abbreviations is to introduce relational notation for
   224 membership in a set of pairs, replacing @{text "(x, y) \<in> sim"} by
   224 membership in a set of pairs, replacing @{text "(x, y) \<in> sim"} by
   225 @{text "x \<approx> y"}. We assume that a constant @{text sim } of type
   225 @{text "x \<approx> y"}. We assume that a constant @{text sim } of type
   226 @{typ"('a \<times> 'a) set"} has been introduced at this point. *}
   226 @{typ"('a \<times> 'a) set"} has been introduced at this point.\<close>
   227 (*<*)consts sim :: "('a \<times> 'a) set"(*>*)
   227 (*<*)consts sim :: "('a \<times> 'a) set"(*>*)
   228 abbreviation sim2 :: "'a \<Rightarrow> 'a \<Rightarrow> bool"   (infix "\<approx>" 50)
   228 abbreviation sim2 :: "'a \<Rightarrow> 'a \<Rightarrow> bool"   (infix "\<approx>" 50)
   229 where "x \<approx> y  \<equiv>  (x, y) \<in> sim"
   229 where "x \<approx> y  \<equiv>  (x, y) \<in> sim"
   230 
   230 
   231 text {* \noindent The given meta-equality is used as a rewrite rule
   231 text \<open>\noindent The given meta-equality is used as a rewrite rule
   232 after parsing (replacing \mbox{@{prop"x \<approx> y"}} by @{text"(x,y) \<in>
   232 after parsing (replacing \mbox{@{prop"x \<approx> y"}} by @{text"(x,y) \<in>
   233 sim"}) and before printing (turning @{text"(x,y) \<in> sim"} back into
   233 sim"}) and before printing (turning @{text"(x,y) \<in> sim"} back into
   234 \mbox{@{prop"x \<approx> y"}}). The name of the dummy constant @{text "sim2"}
   234 \mbox{@{prop"x \<approx> y"}}). The name of the dummy constant @{text "sim2"}
   235 does not matter, as long as it is unique.
   235 does not matter, as long as it is unique.
   236 
   236 
   237 Another common application of abbreviations is to
   237 Another common application of abbreviations is to
   238 provide variant versions of fundamental relational expressions, such
   238 provide variant versions of fundamental relational expressions, such
   239 as @{text \<noteq>} for negated equalities.  The following declaration
   239 as @{text \<noteq>} for negated equalities.  The following declaration
   240 stems from Isabelle/HOL itself:
   240 stems from Isabelle/HOL itself:
   241 *}
   241 \<close>
   242 
   242 
   243 abbreviation not_equal :: "'a \<Rightarrow> 'a \<Rightarrow> bool"    (infixl "~=\<ignore>" 50)
   243 abbreviation not_equal :: "'a \<Rightarrow> 'a \<Rightarrow> bool"    (infixl "~=\<ignore>" 50)
   244 where "x ~=\<ignore> y  \<equiv>  \<not> (x = y)"
   244 where "x ~=\<ignore> y  \<equiv>  \<not> (x = y)"
   245 
   245 
   246 notation (xsymbols) not_equal (infix "\<noteq>\<ignore>" 50)
   246 notation (xsymbols) not_equal (infix "\<noteq>\<ignore>" 50)
   247 
   247 
   248 text {* \noindent The notation @{text \<noteq>} is introduced separately to restrict it
   248 text \<open>\noindent The notation @{text \<noteq>} is introduced separately to restrict it
   249 to the \emph{xsymbols} mode.
   249 to the \emph{xsymbols} mode.
   250 
   250 
   251 Abbreviations are appropriate when the defined concept is a
   251 Abbreviations are appropriate when the defined concept is a
   252 simple variation on an existing one.  But because of the automatic
   252 simple variation on an existing one.  But because of the automatic
   253 folding and unfolding of abbreviations, they do not scale up well to
   253 folding and unfolding of abbreviations, they do not scale up well to
   255 definitions.
   255 definitions.
   256 
   256 
   257 Abbreviations are a simplified form of the general concept of
   257 Abbreviations are a simplified form of the general concept of
   258 \emph{syntax translations}; even heavier transformations may be
   258 \emph{syntax translations}; even heavier transformations may be
   259 written in ML @{cite "isabelle-isar-ref"}.
   259 written in ML @{cite "isabelle-isar-ref"}.
   260 *}
   260 \<close>
   261 
   261 
   262 
   262 
   263 section {* Document Preparation \label{sec:document-preparation} *}
   263 section \<open>Document Preparation \label{sec:document-preparation}\<close>
   264 
   264 
   265 text {*
   265 text \<open>
   266   Isabelle/Isar is centered around the concept of \bfindex{formal
   266   Isabelle/Isar is centered around the concept of \bfindex{formal
   267   proof documents}\index{documents|bold}.  The outcome of a formal
   267   proof documents}\index{documents|bold}.  The outcome of a formal
   268   development effort is meant to be a human-readable record, presented
   268   development effort is meant to be a human-readable record, presented
   269   as browsable PDF file or printed on paper.  The overall document
   269   as browsable PDF file or printed on paper.  The overall document
   270   structure follows traditional mathematical articles, with sections,
   270   structure follows traditional mathematical articles, with sections,
   277   reports on theory developments with little effort: many technical
   277   reports on theory developments with little effort: many technical
   278   consistency checks are handled by the system.
   278   consistency checks are handled by the system.
   279 
   279 
   280   Here is an example to illustrate the idea of Isabelle document
   280   Here is an example to illustrate the idea of Isabelle document
   281   preparation.
   281   preparation.
   282 *}
   282 \<close>
   283 
   283 
   284 text_raw {* \begin{quotation} *}
   284 text_raw \<open>\begin{quotation}\<close>
   285 
   285 
   286 text {*
   286 text \<open>
   287   The following datatype definition of @{text "'a bintree"} models
   287   The following datatype definition of @{text "'a bintree"} models
   288   binary trees with nodes being decorated by elements of type @{typ
   288   binary trees with nodes being decorated by elements of type @{typ
   289   'a}.
   289   'a}.
   290 *}
   290 \<close>
   291 
   291 
   292 datatype 'a bintree =
   292 datatype 'a bintree =
   293      Leaf | Branch 'a  "'a bintree"  "'a bintree"
   293      Leaf | Branch 'a  "'a bintree"  "'a bintree"
   294 
   294 
   295 text {*
   295 text \<open>
   296   \noindent The datatype induction rule generated here is of the form
   296   \noindent The datatype induction rule generated here is of the form
   297   @{thm [indent = 1, display] bintree.induct [no_vars]}
   297   @{thm [indent = 1, display] bintree.induct [no_vars]}
   298 *}
   298 \<close>
   299 
   299 
   300 text_raw {* \end{quotation} *}
   300 text_raw \<open>\end{quotation}\<close>
   301 
   301 
   302 text {*
   302 text \<open>
   303   \noindent The above document output has been produced as follows:
   303   \noindent The above document output has been produced as follows:
   304 
   304 
   305   \begin{ttbox}
   305   \begin{ttbox}
   306   text {\ttlbrace}*
   306   text {\ttlbrace}*
   307     The following datatype definition of {\at}{\ttlbrace}text "'a bintree"{\ttrbrace}
   307     The following datatype definition of {\at}{\ttlbrace}text "'a bintree"{\ttrbrace}
   322   \noindent Here we have augmented the theory by formal comments
   322   \noindent Here we have augmented the theory by formal comments
   323   (using \isakeyword{text} blocks), the informal parts may again refer
   323   (using \isakeyword{text} blocks), the informal parts may again refer
   324   to formal entities by means of ``antiquotations'' (such as
   324   to formal entities by means of ``antiquotations'' (such as
   325   \texttt{\at}\verb,{text "'a bintree"}, or
   325   \texttt{\at}\verb,{text "'a bintree"}, or
   326   \texttt{\at}\verb,{typ 'a},), see also \S\ref{sec:doc-prep-text}.
   326   \texttt{\at}\verb,{typ 'a},), see also \S\ref{sec:doc-prep-text}.
   327 *}
   327 \<close>
   328 
   328 
   329 
   329 
   330 subsection {* Isabelle Sessions *}
   330 subsection \<open>Isabelle Sessions\<close>
   331 
   331 
   332 text {*
   332 text \<open>
   333   In contrast to the highly interactive mode of Isabelle/Isar theory
   333   In contrast to the highly interactive mode of Isabelle/Isar theory
   334   development, the document preparation stage essentially works in
   334   development, the document preparation stage essentially works in
   335   batch-mode.  An Isabelle \bfindex{session} consists of a collection
   335   batch-mode.  An Isabelle \bfindex{session} consists of a collection
   336   of source files that may contribute to an output document.  Each
   336   of source files that may contribute to an output document.  Each
   337   session is derived from a single parent, usually an object-logic
   337   session is derived from a single parent, usually an object-logic
   410 
   410 
   411   \medskip Any failure of the document preparation phase in an
   411   \medskip Any failure of the document preparation phase in an
   412   Isabelle batch session leaves the generated sources in their target
   412   Isabelle batch session leaves the generated sources in their target
   413   location, identified by the accompanying error message.  This lets
   413   location, identified by the accompanying error message.  This lets
   414   you trace {\LaTeX} problems with the generated files at hand.
   414   you trace {\LaTeX} problems with the generated files at hand.
   415 *}
   415 \<close>
   416 
   416 
   417 
   417 
   418 subsection {* Structure Markup *}
   418 subsection \<open>Structure Markup\<close>
   419 
   419 
   420 text {*
   420 text \<open>
   421   The large-scale structure of Isabelle documents follows existing
   421   The large-scale structure of Isabelle documents follows existing
   422   {\LaTeX} conventions, with chapters, sections, subsubsections etc.
   422   {\LaTeX} conventions, with chapters, sections, subsubsections etc.
   423   The Isar language includes separate \bfindex{markup commands}, which
   423   The Isar language includes separate \bfindex{markup commands}, which
   424   do not affect the formal meaning of a theory (or proof), but result
   424   do not affect the formal meaning of a theory (or proof), but result
   425   in corresponding {\LaTeX} elements.
   425   in corresponding {\LaTeX} elements.
   458 
   458 
   459   theorem main: \dots
   459   theorem main: \dots
   460 
   460 
   461   end
   461   end
   462   \end{ttbox}
   462   \end{ttbox}
   463 *}
   463 \<close>
   464 
   464 
   465 
   465 
   466 subsection {* Formal Comments and Antiquotations \label{sec:doc-prep-text} *}
   466 subsection \<open>Formal Comments and Antiquotations \label{sec:doc-prep-text}\<close>
   467 
   467 
   468 text {*
   468 text \<open>
   469   Isabelle \bfindex{source comments}, which are of the form
   469   Isabelle \bfindex{source comments}, which are of the form
   470   \verb,(,\verb,*,~@{text \<dots>}~\verb,*,\verb,),, essentially act like
   470   \verb,(,\verb,*,~@{text \<dots>}~\verb,*,\verb,),, essentially act like
   471   white space and do not really contribute to the content.  They
   471   white space and do not really contribute to the content.  They
   472   mainly serve technical purposes to mark certain oddities in the raw
   472   mainly serve technical purposes to mark certain oddities in the raw
   473   input text.  In contrast, \bfindex{formal comments} are portions of
   473   input text.  In contrast, \bfindex{formal comments} are portions of
   479   syntax @{cite "isabelle-isar-ref"}; the common form is ``\verb,--,~$text$''
   479   syntax @{cite "isabelle-isar-ref"}; the common form is ``\verb,--,~$text$''
   480   where $text$ is delimited by \verb,",@{text \<dots>}\verb,", or
   480   where $text$ is delimited by \verb,",@{text \<dots>}\verb,", or
   481   \verb,{,\verb,*,~@{text \<dots>}~\verb,*,\verb,}, as before.  Multiple
   481   \verb,{,\verb,*,~@{text \<dots>}~\verb,*,\verb,}, as before.  Multiple
   482   marginal comments may be given at the same time.  Here is a simple
   482   marginal comments may be given at the same time.  Here is a simple
   483   example:
   483   example:
   484 *}
   484 \<close>
   485 
   485 
   486 lemma "A --> A"
   486 lemma "A --> A"
   487   -- "a triviality of propositional logic"
   487   \<comment> "a triviality of propositional logic"
   488   -- "(should not really bother)"
   488   \<comment> "(should not really bother)"
   489   by (rule impI) -- "implicit assumption step involved here"
   489   by (rule impI) \<comment> "implicit assumption step involved here"
   490 
   490 
   491 text {*
   491 text \<open>
   492   \noindent The above output has been produced as follows:
   492   \noindent The above output has been produced as follows:
   493 
   493 
   494 \begin{verbatim}
   494 \begin{verbatim}
   495   lemma "A --> A"
   495   lemma "A --> A"
   496     -- "a triviality of propositional logic"
   496     -- "a triviality of propositional logic"
   591   (cf.\ \S\ref{sec:doc-prep-symbols}).  Thus we achieve consistent
   591   (cf.\ \S\ref{sec:doc-prep-symbols}).  Thus we achieve consistent
   592   mathematical notation in both the formal and informal parts of the
   592   mathematical notation in both the formal and informal parts of the
   593   document very easily, independently of the term language of
   593   document very easily, independently of the term language of
   594   Isabelle.  Manual {\LaTeX} code would leave more control over the
   594   Isabelle.  Manual {\LaTeX} code would leave more control over the
   595   typesetting, but is also slightly more tedious.
   595   typesetting, but is also slightly more tedious.
   596 *}
   596 \<close>
   597 
   597 
   598 
   598 
   599 subsection {* Interpretation of Symbols \label{sec:doc-prep-symbols} *}
   599 subsection \<open>Interpretation of Symbols \label{sec:doc-prep-symbols}\<close>
   600 
   600 
   601 text {*
   601 text \<open>
   602   As has been pointed out before (\S\ref{sec:syntax-symbols}),
   602   As has been pointed out before (\S\ref{sec:syntax-symbols}),
   603   Isabelle symbols are the smallest syntactic entities --- a
   603   Isabelle symbols are the smallest syntactic entities --- a
   604   straightforward generalization of ASCII characters.  While Isabelle
   604   straightforward generalization of ASCII characters.  While Isabelle
   605   does not impose any interpretation of the infinite collection of
   605   does not impose any interpretation of the infinite collection of
   606   named symbols, {\LaTeX} documents use canonical glyphs for certain
   606   named symbols, {\LaTeX} documents use canonical glyphs for certain
   638   example, \verb,\isabellestyle{it}, uses the italics text style to
   638   example, \verb,\isabellestyle{it}, uses the italics text style to
   639   mimic the general appearance of the {\LaTeX} math mode; double
   639   mimic the general appearance of the {\LaTeX} math mode; double
   640   quotes are not printed at all.  The resulting quality of typesetting
   640   quotes are not printed at all.  The resulting quality of typesetting
   641   is quite good, so this should be the default style for work that
   641   is quite good, so this should be the default style for work that
   642   gets distributed to a broader audience.
   642   gets distributed to a broader audience.
   643 *}
   643 \<close>
   644 
   644 
   645 
   645 
   646 subsection {* Suppressing Output \label{sec:doc-prep-suppress} *}
   646 subsection \<open>Suppressing Output \label{sec:doc-prep-suppress}\<close>
   647 
   647 
   648 text {*
   648 text \<open>
   649   By default, Isabelle's document system generates a {\LaTeX} file for
   649   By default, Isabelle's document system generates a {\LaTeX} file for
   650   each theory that gets loaded while running the session.  The
   650   each theory that gets loaded while running the session.  The
   651   generated \texttt{session.tex} will include all of these in order of
   651   generated \texttt{session.tex} will include all of these in order of
   652   appearance, which in turn gets included by the standard
   652   appearance, which in turn gets included by the standard
   653   \texttt{root.tex}.  Certainly one may change the order or suppress
   653   \texttt{root.tex}.  Certainly one may change the order or suppress
   681   using the predefined tags ``\emph{theory}'' (for theory begin and
   681   using the predefined tags ``\emph{theory}'' (for theory begin and
   682   end), ``\emph{proof}'' (for proof commands), and ``\emph{ML}'' (for
   682   end), ``\emph{proof}'' (for proof commands), and ``\emph{ML}'' (for
   683   commands involving ML code).  Users may add their own tags using the
   683   commands involving ML code).  Users may add their own tags using the
   684   \verb,%,\emph{tag} notation right after a command name.  In the
   684   \verb,%,\emph{tag} notation right after a command name.  In the
   685   subsequent example we hide a particularly irrelevant proof:
   685   subsequent example we hide a particularly irrelevant proof:
   686 *}
   686 \<close>
   687 
   687 
   688 lemma "x = x" by %invisible (simp)
   688 lemma "x = x" by %invisible (simp)
   689 
   689 
   690 text {*
   690 text \<open>
   691   The original source has been ``\verb,lemma "x = x" by %invisible (simp),''.
   691   The original source has been ``\verb,lemma "x = x" by %invisible (simp),''.
   692   Tags observe the structure of proofs; adjacent commands with the
   692   Tags observe the structure of proofs; adjacent commands with the
   693   same tag are joined into a single region.  The Isabelle document
   693   same tag are joined into a single region.  The Isabelle document
   694   preparation system allows the user to specify how to interpret a
   694   preparation system allows the user to specify how to interpret a
   695   tagged region, in order to keep, drop, or fold the corresponding
   695   tagged region, in order to keep, drop, or fold the corresponding
   703   \verb,(,\verb,*,\verb,>,\verb,*,\verb,),.  These parts are stripped
   703   \verb,(,\verb,*,\verb,>,\verb,*,\verb,),.  These parts are stripped
   704   before the type-setting phase, without affecting the formal checking
   704   before the type-setting phase, without affecting the formal checking
   705   of the theory, of course.  For example, we may hide parts of a proof
   705   of the theory, of course.  For example, we may hide parts of a proof
   706   that seem unfit for general public inspection.  The following
   706   that seem unfit for general public inspection.  The following
   707   ``fully automatic'' proof is actually a fake:
   707   ``fully automatic'' proof is actually a fake:
   708 *}
   708 \<close>
   709 
   709 
   710 lemma "x \<noteq> (0::int) \<Longrightarrow> 0 < x * x"
   710 lemma "x \<noteq> (0::int) \<Longrightarrow> 0 < x * x"
   711   by (auto(*<*)simp add: zero_less_mult_iff(*>*))
   711   by (auto(*<*)simp add: zero_less_mult_iff(*>*))
   712 
   712 
   713 text {*
   713 text \<open>
   714   \noindent The real source of the proof has been as follows:
   714   \noindent The real source of the proof has been as follows:
   715 
   715 
   716 \begin{verbatim}
   716 \begin{verbatim}
   717   by (auto(*<*)simp add: zero_less_mult_iff(*>*))
   717   by (auto(*<*)simp add: zero_less_mult_iff(*>*))
   718 \end{verbatim}
   718 \end{verbatim}
   720 
   720 
   721   \medskip Suppressing portions of printed text demands care.  You
   721   \medskip Suppressing portions of printed text demands care.  You
   722   should not misrepresent the underlying theory development.  It is
   722   should not misrepresent the underlying theory development.  It is
   723   easy to invalidate the visible text by hiding references to
   723   easy to invalidate the visible text by hiding references to
   724   questionable axioms, for example.
   724   questionable axioms, for example.
   725 *}
   725 \<close>
   726 
   726 
   727 (*<*)
   727 (*<*)
   728 end
   728 end
   729 (*>*)
   729 (*>*)