| author | nipkow | 
| Fri, 28 Feb 2014 18:09:37 +0100 | |
| changeset 55807 | fd31d0e70eb8 | 
| parent 54936 | 30e2503f1aa2 | 
| child 58620 | 7435b6a3f72e | 
| permissions | -rw-r--r-- | 
| 11647 | 1 | (*<*) | 
| 16417 | 2 | theory Documents imports Main begin | 
| 11647 | 3 | (*>*) | 
| 4 | ||
| 12648 | 5 | section {* Concrete Syntax \label{sec:concrete-syntax} *}
 | 
| 12629 | 6 | |
| 7 | text {*
 | |
| 12766 | 8 | The core concept of Isabelle's framework for concrete syntax is that | 
| 9 |   of \bfindex{mixfix annotations}.  Associated with any kind of
 | |
| 10 | constant declaration, mixfixes affect both the grammar productions | |
| 11 | for the parser and output templates for the pretty printer. | |
| 12629 | 12 | |
| 12743 | 13 | In full generality, parser and pretty printer configuration is a | 
| 50069 | 14 |   subtle affair~\cite{isabelle-isar-ref}.  Your syntax specifications need
 | 
| 12766 | 15 | to interact properly with the existing setup of Isabelle/Pure and | 
| 16 | Isabelle/HOL\@. To avoid creating ambiguities with existing | |
| 17 | elements, it is particularly important to give new syntactic | |
| 12764 | 18 | constructs the right precedence. | 
| 12629 | 19 | |
| 25338 | 20 | Below we introduce a few simple syntax declaration | 
| 12743 | 21 | forms that already cover many common situations fairly well. | 
| 12629 | 22 | *} | 
| 23 | ||
| 24 | ||
| 12648 | 25 | subsection {* Infix Annotations *}
 | 
| 12629 | 26 | |
| 27 | text {*
 | |
| 12764 | 28 | Syntax annotations may be included wherever constants are declared, | 
| 27015 | 29 |   such as \isacommand{definition} and \isacommand{primrec} --- and also
 | 
| 12766 | 30 |   \isacommand{datatype}, which declares constructor operations.
 | 
| 31 | Type-constructors may be annotated as well, although this is less | |
| 32 |   frequently encountered in practice (the infix type @{text "\<times>"} comes
 | |
| 33 | to mind). | |
| 12629 | 34 | |
| 12645 | 35 |   Infix declarations\index{infix annotations} provide a useful special
 | 
| 12766 | 36 | case of mixfixes. The following example of the exclusive-or | 
| 37 | operation on boolean values illustrates typical infix declarations. | |
| 12629 | 38 | *} | 
| 39 | ||
| 27015 | 40 | definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool" (infixl "[+]" 60) | 
| 41 | where "A [+] B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)" | |
| 12629 | 42 | |
| 43 | text {*
 | |
| 12653 | 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 | |
| 12766 | 46 | arguments may be given infix syntax. For partial applications with | 
| 47 |   fewer than two operands, there is a notation using the prefix~@{text
 | |
| 48 |   op}.  For instance, @{text xor} without arguments is represented as
 | |
| 49 |   @{text "op [+]"}; together with ordinary function application, this
 | |
| 12653 | 50 |   turns @{text "xor A"} into @{text "op [+] A"}.
 | 
| 12629 | 51 | |
| 25338 | 52 |   The keyword \isakeyword{infixl} seen above specifies an
 | 
| 12746 | 53 |   infix operator that is nested to the \emph{left}: in iterated
 | 
| 54 | applications the more complex expression appears on the left-hand | |
| 12766 | 55 |   side, and @{term "A [+] B [+] C"} stands for @{text "(A [+] B) [+]
 | 
| 56 |   C"}.  Similarly, \isakeyword{infixr} means nesting to the
 | |
| 12746 | 57 |   \emph{right}, reading @{term "A [+] B [+] C"} as @{text "A [+] (B
 | 
| 12766 | 58 |   [+] C)"}.  A \emph{non-oriented} declaration via \isakeyword{infix}
 | 
| 59 |   would render @{term "A [+] B [+] C"} illegal, but demand explicit
 | |
| 60 | parentheses to indicate the intended grouping. | |
| 12743 | 61 | |
| 12746 | 62 |   The string @{text [source] "[+]"} in our annotation refers to the
 | 
| 63 | concrete syntax to represent the operator (a literal token), while | |
| 12764 | 64 |   the number @{text 60} determines the precedence of the construct:
 | 
| 12766 | 65 | the syntactic priorities of the arguments and result. Isabelle/HOL | 
| 66 | already uses up many popular combinations of ASCII symbols for its | |
| 67 |   own use, including both @{text "+"} and @{text "++"}.  Longer
 | |
| 68 | character combinations are more likely to be still available for | |
| 69 |   user extensions, such as our~@{text "[+]"}.
 | |
| 12629 | 70 | |
| 12766 | 71 | Operator precedences have a range of 0--1000. Very low or high | 
| 72 | priorities are reserved for the meta-logic. HOL syntax mainly uses | |
| 73 |   the range of 10--100: the equality infix @{text "="} is centered at
 | |
| 74 |   50; logical connectives (like @{text "\<or>"} and @{text "\<and>"}) are
 | |
| 75 |   below 50; algebraic ones (like @{text "+"} and @{text "*"}) are
 | |
| 76 | above 50. User syntax should strive to coexist with common HOL | |
| 77 | forms, or use the mostly unused range 100--900. | |
| 12629 | 78 | *} | 
| 79 | ||
| 12635 | 80 | |
| 12659 | 81 | subsection {* Mathematical Symbols \label{sec:syntax-symbols} *}
 | 
| 12629 | 82 | |
| 83 | text {*
 | |
| 12766 | 84 | Concrete syntax based on ASCII characters has inherent limitations. | 
| 85 | Mathematical notation demands a larger repertoire of glyphs. | |
| 86 | Several standards of extended character sets have been proposed over | |
| 87 | decades, but none has become universally available so far. Isabelle | |
| 88 |   has its own notion of \bfindex{symbols} as the smallest entities of
 | |
| 89 | source text, without referring to internal encodings. There are | |
| 90 | three kinds of such ``generalized characters'': | |
| 12635 | 91 | |
| 92 |   \begin{enumerate}
 | |
| 93 | ||
| 12653 | 94 | \item 7-bit ASCII characters | 
| 12635 | 95 | |
| 12653 | 96 | \item named symbols: \verb,\,\verb,<,$ident$\verb,>, | 
| 12629 | 97 | |
| 12653 | 98 | \item named control symbols: \verb,\,\verb,<^,$ident$\verb,>, | 
| 12635 | 99 | |
| 100 |   \end{enumerate}
 | |
| 101 | ||
| 14486 | 102 | Here $ident$ is any sequence of letters. | 
| 103 | This results in an infinite store of symbols, whose | |
| 12766 | 104 | interpretation is left to further front-end tools. For example, the | 
| 105 | user-interface of Proof~General + X-Symbol and the Isabelle document | |
| 106 |   processor (see \S\ref{sec:document-preparation}) display the
 | |
| 107 |   \verb,\,\verb,<forall>, symbol as~@{text \<forall>}.
 | |
| 12635 | 108 | |
| 109 | A list of standard Isabelle symbols is given in | |
| 28838 
d5db6dfcb34a
moved table of standard Isabelle symbols to isar-ref manual;
 wenzelm parents: 
28504diff
changeset | 110 |   \cite{isabelle-isar-ref}.  You may introduce your own
 | 
| 12635 | 111 | interpretation of further symbols by configuring the appropriate | 
| 12653 | 112 |   front-end tool accordingly, e.g.\ by defining certain {\LaTeX}
 | 
| 113 |   macros (see also \S\ref{sec:doc-prep-symbols}).  There are also a
 | |
| 114 | few predefined control symbols, such as \verb,\,\verb,<^sub>, and | |
| 12635 | 115 | \verb,\,\verb,<^sup>, for sub- and superscript of the subsequent | 
| 12764 | 116 | printable symbol, respectively. For example, \verb,A\<^sup>\<star>, is | 
| 12670 | 117 |   output as @{text "A\<^sup>\<star>"}.
 | 
| 12635 | 118 | |
| 17183 | 119 | A number of symbols are considered letters by the Isabelle lexer and | 
| 120 | can be used as part of identifiers. These are the greek letters | |
| 121 |   @{text "\<alpha>"} (\verb+\+\verb+<alpha>+), @{text "\<beta>"}
 | |
| 122 |   (\verb+\+\verb+<beta>+), etc. (excluding @{text "\<lambda>"}),
 | |
| 123 |   special letters like @{text "\<A>"} (\verb+\+\verb+<A>+) and @{text
 | |
| 52919 | 124 | "\<AA>"} (\verb+\+\verb+<AA>+). Moreover the control symbol | 
| 125 | \verb+\+\verb+<^sub>+ may be used to subscript a single letter or digit | |
| 126 | in the trailing part of an identifier. This means that the input | |
| 14486 | 127 | |
| 128 | \medskip | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52919diff
changeset | 129 |   {\small\noindent \verb,\,\verb,<forall>\,\verb,<alpha>\<^sub>1.,~\verb,\,\verb,<alpha>\<^sub>1 = \,\verb,<Pi>\<^sub>\<A>,}
 | 
| 14486 | 130 | |
| 131 | \medskip | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52919diff
changeset | 132 |   \noindent is recognized as the term @{term "\<forall>\<alpha>\<^sub>1. \<alpha>\<^sub>1 = \<Pi>\<^sub>\<A>"} 
 | 
| 52919 | 133 | by Isabelle. | 
| 14486 | 134 | |
| 25338 | 135 |   Replacing our previous definition of @{text xor} by the
 | 
| 17183 | 136 | following specifies an Isabelle symbol for the new operator: | 
| 12629 | 137 | *} | 
| 138 | ||
| 139 | (*<*) | |
| 36176 
3fe7e97ccca8
replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
 wenzelm parents: 
30649diff
changeset | 140 | hide_const xor | 
| 26698 | 141 | setup {* Sign.add_path "version1" *}
 | 
| 12629 | 142 | (*>*) | 
| 27015 | 143 | definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool" (infixl "\<oplus>" 60) | 
| 144 | where "A \<oplus> B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)" | |
| 12635 | 145 | (*<*) | 
| 38765 | 146 | setup {* Sign.local_path *}
 | 
| 12635 | 147 | (*>*) | 
| 12629 | 148 | |
| 12635 | 149 | text {*
 | 
| 47822 
34b44d28fc4b
some updates concerning current Proof General 4.x, which lacks X-Symbol mode of 3.x;
 wenzelm parents: 
45106diff
changeset | 150 | \noindent Proof~General provides several input methods to enter | 
| 
34b44d28fc4b
some updates concerning current Proof General 4.x, which lacks X-Symbol mode of 3.x;
 wenzelm parents: 
45106diff
changeset | 151 |   @{text \<oplus>} in the text.  If all fails one may just type a named
 | 
| 
34b44d28fc4b
some updates concerning current Proof General 4.x, which lacks X-Symbol mode of 3.x;
 wenzelm parents: 
45106diff
changeset | 152 | entity \verb,\,\verb,<oplus>, by hand; the corresponding symbol will | 
| 
34b44d28fc4b
some updates concerning current Proof General 4.x, which lacks X-Symbol mode of 3.x;
 wenzelm parents: 
45106diff
changeset | 153 | be displayed after further input. | 
| 12635 | 154 | |
| 25338 | 155 | More flexible is to provide alternative syntax forms | 
| 50069 | 156 |   through the \bfindex{print mode} concept~\cite{isabelle-isar-ref}.  By
 | 
| 12766 | 157 | convention, the mode of ``$xsymbols$'' is enabled whenever | 
| 158 |   Proof~General's X-Symbol mode or {\LaTeX} output is active.  Now
 | |
| 159 |   consider the following hybrid declaration of @{text xor}:
 | |
| 12635 | 160 | *} | 
| 161 | ||
| 162 | (*<*) | |
| 36176 
3fe7e97ccca8
replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
 wenzelm parents: 
30649diff
changeset | 163 | hide_const xor | 
| 26698 | 164 | setup {* Sign.add_path "version2" *}
 | 
| 12635 | 165 | (*>*) | 
| 27015 | 166 | definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool" (infixl "[+]\<ignore>" 60) | 
| 167 | where "A [+]\<ignore> B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)" | |
| 12635 | 168 | |
| 25338 | 169 | notation (xsymbols) xor (infixl "\<oplus>\<ignore>" 60) | 
| 12629 | 170 | (*<*) | 
| 38765 | 171 | setup {* Sign.local_path *}
 | 
| 12629 | 172 | (*>*) | 
| 173 | ||
| 27015 | 174 | text {*\noindent
 | 
| 175 | The \commdx{notation} command associates a mixfix
 | |
| 176 | annotation with a known constant. The print mode specification, | |
| 177 | here @{text "(xsymbols)"}, is optional.
 | |
| 12635 | 178 | |
| 25338 | 179 | We may now write @{text "A [+] B"} or @{text "A \<oplus> B"} in input, while
 | 
| 180 | output uses the nicer syntax of $xsymbols$ whenever that print mode is | |
| 181 | active. Such an arrangement is particularly useful for interactive | |
| 182 | development, where users may type ASCII text and see mathematical | |
| 183 | symbols displayed during proofs. *} | |
| 12635 | 184 | |
| 12629 | 185 | |
| 12648 | 186 | subsection {* Prefix Annotations *}
 | 
| 12629 | 187 | |
| 188 | text {*
 | |
| 12766 | 189 |   Prefix syntax annotations\index{prefix annotation} are another form
 | 
| 50069 | 190 |   of mixfixes \cite{isabelle-isar-ref}, without any template arguments or
 | 
| 12766 | 191 | priorities --- just some literal syntax. The following example | 
| 192 | associates common symbols with the constructors of a datatype. | |
| 12629 | 193 | *} | 
| 194 | ||
| 195 | datatype currency = | |
| 196 |     Euro nat    ("\<euro>")
 | |
| 197 |   | Pounds nat  ("\<pounds>")
 | |
| 198 |   | Yen nat     ("\<yen>")
 | |
| 199 |   | Dollar nat  ("$")
 | |
| 200 | ||
| 201 | text {*
 | |
| 12653 | 202 | \noindent Here the mixfix annotations on the rightmost column happen | 
| 203 | to consist of a single Isabelle symbol each: \verb,\,\verb,<euro>,, | |
| 204 | \verb,\,\verb,<pounds>,, \verb,\,\verb,<yen>,, and \verb,$,. Recall | |
| 205 |   that a constructor like @{text Euro} actually is a function @{typ
 | |
| 12746 | 206 |   "nat \<Rightarrow> currency"}.  The expression @{text "Euro 10"} will be
 | 
| 12653 | 207 |   printed as @{term "\<euro> 10"}; only the head of the application is
 | 
| 12743 | 208 | subject to our concrete syntax. This rather simple form already | 
| 209 | achieves conformance with notational standards of the European | |
| 210 | Commission. | |
| 12629 | 211 | |
| 27015 | 212 |   Prefix syntax works the same way for other commands that introduce new constants, e.g. \isakeyword{primrec}.
 | 
| 12651 | 213 | *} | 
| 214 | ||
| 215 | ||
| 25338 | 216 | subsection {* Abbreviations \label{sec:abbreviations} *}
 | 
| 12651 | 217 | |
| 25338 | 218 | text{* Mixfix syntax annotations merely decorate particular constant
 | 
| 219 | application forms with concrete syntax, for instance replacing | |
| 220 | @{text "xor A B"} by @{text "A \<oplus> B"}.  Occasionally, the relationship
 | |
| 221 | between some piece of notation and its internal form is more | |
| 222 | complicated.  Here we need \emph{abbreviations}.
 | |
| 223 | ||
| 224 | Command \commdx{abbreviation} introduces an uninterpreted notational
 | |
| 225 | constant as an abbreviation for a complex term. Abbreviations are | |
| 226 | unfolded upon parsing and re-introduced upon printing. This provides a | |
| 227 | simple mechanism for syntactic macros. | |
| 12651 | 228 | |
| 25338 | 229 | A typical use of abbreviations is to introduce relational notation for | 
| 230 | membership in a set of pairs, replacing @{text "(x, y) \<in> sim"} by
 | |
| 27015 | 231 | @{text "x \<approx> y"}. We assume that a constant @{text sim } of type
 | 
| 232 | @{typ"('a \<times> 'a) set"} has been introduced at this point. *}
 | |
| 233 | (*<*)consts sim :: "('a \<times> 'a) set"(*>*)
 | |
| 25338 | 234 | abbreviation sim2 :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<approx>" 50) | 
| 235 | where "x \<approx> y \<equiv> (x, y) \<in> sim" | |
| 12651 | 236 | |
| 25338 | 237 | text {* \noindent The given meta-equality is used as a rewrite rule
 | 
| 238 | after parsing (replacing \mbox{@{prop"x \<approx> y"}} by @{text"(x,y) \<in>
 | |
| 239 | sim"}) and before printing (turning @{text"(x,y) \<in> sim"} back into
 | |
| 240 | \mbox{@{prop"x \<approx> y"}}). The name of the dummy constant @{text "sim2"}
 | |
| 241 | does not matter, as long as it is unique. | |
| 242 | ||
| 243 | Another common application of abbreviations is to | |
| 244 | provide variant versions of fundamental relational expressions, such | |
| 245 | as @{text \<noteq>} for negated equalities.  The following declaration
 | |
| 246 | stems from Isabelle/HOL itself: | |
| 12635 | 247 | *} | 
| 248 | ||
| 25338 | 249 | abbreviation not_equal :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "~=\<ignore>" 50) | 
| 250 | where "x ~=\<ignore> y \<equiv> \<not> (x = y)" | |
| 12629 | 251 | |
| 25338 | 252 | notation (xsymbols) not_equal (infix "\<noteq>\<ignore>" 50) | 
| 253 | ||
| 254 | text {* \noindent The notation @{text \<noteq>} is introduced separately to restrict it
 | |
| 255 | to the \emph{xsymbols} mode.
 | |
| 12651 | 256 | |
| 27015 | 257 | Abbreviations are appropriate when the defined concept is a | 
| 25338 | 258 | simple variation on an existing one. But because of the automatic | 
| 259 | folding and unfolding of abbreviations, they do not scale up well to | |
| 260 | large hierarchies of concepts. Abbreviations do not replace | |
| 261 | definitions. | |
| 12629 | 262 | |
| 25338 | 263 | Abbreviations are a simplified form of the general concept of | 
| 264 | \emph{syntax translations}; even heavier transformations may be
 | |
| 50069 | 265 | written in ML \cite{isabelle-isar-ref}.
 | 
| 12629 | 266 | *} | 
| 267 | ||
| 268 | ||
| 12653 | 269 | section {* Document Preparation \label{sec:document-preparation} *}
 | 
| 12629 | 270 | |
| 12645 | 271 | text {*
 | 
| 12653 | 272 |   Isabelle/Isar is centered around the concept of \bfindex{formal
 | 
| 12766 | 273 |   proof documents}\index{documents|bold}.  The outcome of a formal
 | 
| 274 | development effort is meant to be a human-readable record, presented | |
| 275 | as browsable PDF file or printed on paper. The overall document | |
| 276 | structure follows traditional mathematical articles, with sections, | |
| 277 | intermediate explanations, definitions, theorems and proofs. | |
| 12629 | 278 | |
| 12645 | 279 | \medskip The Isabelle document preparation system essentially acts | 
| 12670 | 280 |   as a front-end to {\LaTeX}.  After checking specifications and
 | 
| 281 | proofs formally, the theory sources are turned into typesetting | |
| 12766 | 282 | instructions in a schematic manner. This lets you write authentic | 
| 283 | reports on theory developments with little effort: many technical | |
| 284 | consistency checks are handled by the system. | |
| 12744 | 285 | |
| 286 | Here is an example to illustrate the idea of Isabelle document | |
| 287 | preparation. | |
| 12746 | 288 | *} | 
| 12744 | 289 | |
| 12746 | 290 | text_raw {* \begin{quotation} *}
 | 
| 291 | ||
| 292 | text {*
 | |
| 293 |   The following datatype definition of @{text "'a bintree"} models
 | |
| 294 |   binary trees with nodes being decorated by elements of type @{typ
 | |
| 295 | 'a}. | |
| 12744 | 296 | *} | 
| 297 | ||
| 298 | datatype 'a bintree = | |
| 12746 | 299 | Leaf | Branch 'a "'a bintree" "'a bintree" | 
| 12744 | 300 | |
| 301 | text {*
 | |
| 302 | \noindent The datatype induction rule generated here is of the form | |
| 12746 | 303 |   @{thm [indent = 1, display] bintree.induct [no_vars]}
 | 
| 304 | *} | |
| 12744 | 305 | |
| 12746 | 306 | text_raw {* \end{quotation} *}
 | 
| 307 | ||
| 308 | text {*
 | |
| 12766 | 309 | \noindent The above document output has been produced as follows: | 
| 12744 | 310 | |
| 311 |   \begin{ttbox}
 | |
| 312 |   text {\ttlbrace}*
 | |
| 313 |     The following datatype definition of {\at}{\ttlbrace}text "'a bintree"{\ttrbrace}
 | |
| 314 | models binary trees with nodes being decorated by elements | |
| 315 |     of type {\at}{\ttlbrace}typ 'a{\ttrbrace}.
 | |
| 316 |   *{\ttrbrace}
 | |
| 317 | ||
| 318 | datatype 'a bintree = | |
| 319 | Leaf | Branch 'a "'a bintree" "'a bintree" | |
| 12766 | 320 |   \end{ttbox}
 | 
| 321 |   \begin{ttbox}
 | |
| 12744 | 322 |   text {\ttlbrace}*
 | 
| 323 |     {\ttback}noindent The datatype induction rule generated here is
 | |
| 324 |     of the form {\at}{\ttlbrace}thm [display] bintree.induct [no_vars]{\ttrbrace}
 | |
| 325 |   *{\ttrbrace}
 | |
| 12766 | 326 |   \end{ttbox}\vspace{-\medskipamount}
 | 
| 12744 | 327 | |
| 12746 | 328 | \noindent Here we have augmented the theory by formal comments | 
| 12766 | 329 |   (using \isakeyword{text} blocks), the informal parts may again refer
 | 
| 330 | to formal entities by means of ``antiquotations'' (such as | |
| 12744 | 331 |   \texttt{\at}\verb,{text "'a bintree"}, or
 | 
| 12746 | 332 |   \texttt{\at}\verb,{typ 'a},), see also \S\ref{sec:doc-prep-text}.
 | 
| 12645 | 333 | *} | 
| 334 | ||
| 335 | ||
| 12648 | 336 | subsection {* Isabelle Sessions *}
 | 
| 12629 | 337 | |
| 338 | text {*
 | |
| 12653 | 339 | In contrast to the highly interactive mode of Isabelle/Isar theory | 
| 340 | development, the document preparation stage essentially works in | |
| 12670 | 341 |   batch-mode.  An Isabelle \bfindex{session} consists of a collection
 | 
| 12766 | 342 | of source files that may contribute to an output document. Each | 
| 343 | session is derived from a single parent, usually an object-logic | |
| 344 |   image like \texttt{HOL}.  This results in an overall tree structure,
 | |
| 345 | which is reflected by the output location in the file system | |
| 54936 | 346 | (the root directory is determined by the Isabelle settings variable | 
| 347 | \verb,ISABELLE_BROWSER_INFO,). | |
| 12645 | 348 | |
| 12683 | 349 | \medskip The easiest way to manage Isabelle sessions is via | 
| 51057 | 350 |   \texttt{isabelle mkroot} (to generate an initial session source
 | 
| 351 |   setup) and \texttt{isabelle build} (to run sessions as specified in
 | |
| 352 |   the corresponding \texttt{ROOT} file).  These Isabelle tools are
 | |
| 353 |   described in further detail in the \emph{Isabelle System Manual}
 | |
| 354 |   \cite{isabelle-sys}.
 | |
| 355 | ||
| 356 |   For example, a new session \texttt{MySession} (with document
 | |
| 357 | preparation) may be produced as follows: | |
| 12683 | 358 | |
| 359 | \begin{verbatim}
 | |
| 51057 | 360 | isabelle mkroot -d MySession | 
| 361 | isabelle build -D MySession | |
| 12683 | 362 | \end{verbatim}
 | 
| 363 | ||
| 51057 | 364 |   The \texttt{isabelle build} job also informs about the file-system
 | 
| 12685 | 365 | location of the ultimate results. The above dry run should be able | 
| 366 |   to produce some \texttt{document.pdf} (with dummy title, empty table
 | |
| 12743 | 367 | of contents etc.). Any failure at this stage usually indicates | 
| 17183 | 368 |   technical problems of the {\LaTeX} installation.
 | 
| 12683 | 369 | |
| 370 | \medskip The detailed arrangement of the session sources is as | |
| 12746 | 371 | follows. | 
| 12645 | 372 | |
| 373 |   \begin{itemize}
 | |
| 374 | ||
| 12670 | 375 |   \item Directory \texttt{MySession} holds the required theory files
 | 
| 376 |   $T@1$\texttt{.thy}, \dots, $T@n$\texttt{.thy}.
 | |
| 12645 | 377 | |
| 51057 | 378 |   \item File \texttt{MySession/ROOT} specifies the session options and
 | 
| 379 | content, with declarations for all wanted theories; it is sufficient | |
| 380 | to specify the terminal nodes of the theory dependency graph. | |
| 12645 | 381 | |
| 382 |   \item Directory \texttt{MySession/document} contains everything
 | |
| 12653 | 383 |   required for the {\LaTeX} stage; only \texttt{root.tex} needs to be
 | 
| 384 | provided initially. | |
| 12645 | 385 | |
| 12653 | 386 |   The latter file holds appropriate {\LaTeX} code to commence a
 | 
| 387 | document (\verb,\documentclass, etc.), and to include the generated | |
| 12743 | 388 |   files $T@i$\texttt{.tex} for each theory.  Isabelle will generate a
 | 
| 389 |   file \texttt{session.tex} holding {\LaTeX} commands to include all
 | |
| 12746 | 390 | generated theory output files in topologically sorted order, so | 
| 391 |   \verb,\input{session}, in the body of \texttt{root.tex} does the job
 | |
| 392 | in most situations. | |
| 12653 | 393 | |
| 12645 | 394 |   \end{itemize}
 | 
| 395 | ||
| 51057 | 396 |   One may now start to populate the directory \texttt{MySession} and
 | 
| 397 |   its \texttt{ROOT} file accordingly.  The file
 | |
| 12766 | 398 |   \texttt{MySession/document/root.tex} should also be adapted at some
 | 
| 12685 | 399 | point; the default version is mostly self-explanatory. Note that | 
| 400 | \verb,\isabellestyle, enables fine-tuning of the general appearance | |
| 401 | of characters and mathematical symbols (see also | |
| 402 |   \S\ref{sec:doc-prep-symbols}).
 | |
| 12653 | 403 | |
| 12685 | 404 |   Especially observe the included {\LaTeX} packages \texttt{isabelle}
 | 
| 405 |   (mandatory), \texttt{isabellesym} (required for mathematical
 | |
| 12743 | 406 |   symbols), and the final \texttt{pdfsetup} (provides sane defaults
 | 
| 12764 | 407 |   for \texttt{hyperref}, including URL markup).  All three are
 | 
| 12743 | 408 | distributed with Isabelle. Further packages may be required in | 
| 12764 | 409 | particular applications, say for unusual mathematical symbols. | 
| 12645 | 410 | |
| 12746 | 411 |   \medskip Any additional files for the {\LaTeX} stage go into the
 | 
| 412 |   \texttt{MySession/document} directory as well.  In particular,
 | |
| 12766 | 413 |   adding a file named \texttt{root.bib} causes an automatic run of
 | 
| 414 |   \texttt{bibtex} to process a bibliographic database; see also
 | |
| 28504 
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
 wenzelm parents: 
27027diff
changeset | 415 |   \texttt{isabelle document} \cite{isabelle-sys}.
 | 
| 12645 | 416 | |
| 12653 | 417 | \medskip Any failure of the document preparation phase in an | 
| 12670 | 418 | Isabelle batch session leaves the generated sources in their target | 
| 12766 | 419 | location, identified by the accompanying error message. This lets | 
| 420 |   you trace {\LaTeX} problems with the generated files at hand.
 | |
| 12645 | 421 | *} | 
| 422 | ||
| 423 | ||
| 12648 | 424 | subsection {* Structure Markup *}
 | 
| 12645 | 425 | |
| 12653 | 426 | text {*
 | 
| 427 | The large-scale structure of Isabelle documents follows existing | |
| 428 |   {\LaTeX} conventions, with chapters, sections, subsubsections etc.
 | |
| 429 |   The Isar language includes separate \bfindex{markup commands}, which
 | |
| 12681 | 430 | do not affect the formal meaning of a theory (or proof), but result | 
| 12665 | 431 |   in corresponding {\LaTeX} elements.
 | 
| 12645 | 432 | |
| 12665 | 433 | There are separate markup commands depending on the textual context: | 
| 434 |   in header position (just before \isakeyword{theory}), within the
 | |
| 435 | theory body, or within a proof. The header needs to be treated | |
| 436 | specially here, since ordinary theory and proof commands may only | |
| 437 |   occur \emph{after} the initial \isakeyword{theory} specification.
 | |
| 12645 | 438 | |
| 12665 | 439 | \medskip | 
| 12645 | 440 | |
| 441 |   \begin{tabular}{llll}
 | |
| 442 | header & theory & proof & default meaning \\\hline | |
| 443 |     & \commdx{chapter} & & \verb,\chapter, \\
 | |
| 444 |   \commdx{header} & \commdx{section} & \commdx{sect} & \verb,\section, \\
 | |
| 445 |     & \commdx{subsection} & \commdx{subsect} & \verb,\subsection, \\
 | |
| 446 |     & \commdx{subsubsection} & \commdx{subsubsect} & \verb,\subsubsection, \\
 | |
| 447 |   \end{tabular}
 | |
| 448 | ||
| 449 | \medskip | |
| 450 | ||
| 451 | From the Isabelle perspective, each markup command takes a single | |
| 12746 | 452 |   $text$ argument (delimited by \verb,",~@{text \<dots>}~\verb,", or
 | 
| 453 |   \verb,{,\verb,*,~@{text \<dots>}~\verb,*,\verb,},).  After stripping any
 | |
| 12645 | 454 |   surrounding white space, the argument is passed to a {\LaTeX} macro
 | 
| 12766 | 455 |   \verb,\isamarkupXYZ, for command \isakeyword{XYZ}.  These macros are
 | 
| 456 | defined in \verb,isabelle.sty, according to the meaning given in the | |
| 457 | rightmost column above. | |
| 12645 | 458 | |
| 459 | \medskip The following source fragment illustrates structure markup | |
| 12653 | 460 |   of a theory.  Note that {\LaTeX} labels may be included inside of
 | 
| 461 | section headings as well. | |
| 12645 | 462 | |
| 463 |   \begin{ttbox}
 | |
| 464 |   header {\ttlbrace}* Some properties of Foo Bar elements *{\ttrbrace}
 | |
| 465 | ||
| 15136 | 466 | theory Foo_Bar | 
| 15141 | 467 | imports Main | 
| 15136 | 468 | begin | 
| 12645 | 469 | |
| 470 |   subsection {\ttlbrace}* Basic definitions *{\ttrbrace}
 | |
| 471 | ||
| 27027 | 472 | definition foo :: \dots | 
| 12648 | 473 | |
| 27027 | 474 | definition bar :: \dots | 
| 12648 | 475 | |
| 12645 | 476 |   subsection {\ttlbrace}* Derived rules *{\ttrbrace}
 | 
| 477 | ||
| 478 | lemma fooI: \dots | |
| 479 | lemma fooE: \dots | |
| 480 | ||
| 12648 | 481 |   subsection {\ttlbrace}* Main theorem {\ttback}label{\ttlbrace}sec:main-theorem{\ttrbrace} *{\ttrbrace}
 | 
| 12645 | 482 | |
| 483 | theorem main: \dots | |
| 484 | ||
| 485 | end | |
| 12766 | 486 |   \end{ttbox}\vspace{-\medskipamount}
 | 
| 12645 | 487 | |
| 12766 | 488 | You may occasionally want to change the meaning of markup commands, | 
| 489 |   say via \verb,\renewcommand, in \texttt{root.tex}.  For example,
 | |
| 490 | \verb,\isamarkupheader, is a good candidate for some tuning. We | |
| 491 | could move it up in the hierarchy to become \verb,\chapter,. | |
| 12645 | 492 | |
| 493 | \begin{verbatim}
 | |
| 494 |   \renewcommand{\isamarkupheader}[1]{\chapter{#1}}
 | |
| 495 | \end{verbatim}
 | |
| 496 | ||
| 12766 | 497 | \noindent Now we must change the document class given in | 
| 498 |   \texttt{root.tex} to something that supports chapters.  A suitable
 | |
| 499 |   command is \verb,\documentclass{report},.
 | |
| 12645 | 500 | |
| 12648 | 501 |   \medskip The {\LaTeX} macro \verb,\isabellecontext, is maintained to
 | 
| 502 | hold the name of the current theory context. This is particularly | |
| 12653 | 503 | useful for document headings: | 
| 12645 | 504 | |
| 505 | \begin{verbatim}
 | |
| 12653 | 506 |   \renewcommand{\isamarkupheader}[1]
 | 
| 12645 | 507 |   {\chapter{#1}\markright{THEORY~\isabellecontext}}
 | 
| 508 | \end{verbatim}
 | |
| 509 | ||
| 510 | \noindent Make sure to include something like | |
| 12648 | 511 |   \verb,\pagestyle{headings}, in \texttt{root.tex}; the document
 | 
| 12764 | 512 | should have more than two pages to show the effect. | 
| 12645 | 513 | *} | 
| 514 | ||
| 515 | ||
| 12744 | 516 | subsection {* Formal Comments and Antiquotations \label{sec:doc-prep-text} *}
 | 
| 12645 | 517 | |
| 518 | text {*
 | |
| 12744 | 519 |   Isabelle \bfindex{source comments}, which are of the form
 | 
| 12746 | 520 |   \verb,(,\verb,*,~@{text \<dots>}~\verb,*,\verb,),, essentially act like
 | 
| 521 | white space and do not really contribute to the content. They | |
| 522 | mainly serve technical purposes to mark certain oddities in the raw | |
| 523 |   input text.  In contrast, \bfindex{formal comments} are portions of
 | |
| 524 | text that are associated with formal Isabelle/Isar commands | |
| 12681 | 525 |   (\bfindex{marginal comments}), or as standalone paragraphs within a
 | 
| 12665 | 526 |   theory or proof context (\bfindex{text blocks}).
 | 
| 12659 | 527 | |
| 528 | \medskip Marginal comments are part of each command's concrete | |
| 50069 | 529 |   syntax \cite{isabelle-isar-ref}; the common form is ``\verb,--,~$text$''
 | 
| 12746 | 530 |   where $text$ is delimited by \verb,",@{text \<dots>}\verb,", or
 | 
| 531 |   \verb,{,\verb,*,~@{text \<dots>}~\verb,*,\verb,}, as before.  Multiple
 | |
| 12670 | 532 | marginal comments may be given at the same time. Here is a simple | 
| 533 | example: | |
| 12665 | 534 | *} | 
| 535 | ||
| 536 | lemma "A --> A" | |
| 537 | -- "a triviality of propositional logic" | |
| 538 | -- "(should not really bother)" | |
| 539 | by (rule impI) -- "implicit assumption step involved here" | |
| 540 | ||
| 541 | text {*
 | |
| 542 | \noindent The above output has been produced as follows: | |
| 12659 | 543 | |
| 544 | \begin{verbatim}
 | |
| 545 | lemma "A --> A" | |
| 546 | -- "a triviality of propositional logic" | |
| 547 | -- "(should not really bother)" | |
| 548 | by (rule impI) -- "implicit assumption step involved here" | |
| 549 | \end{verbatim}
 | |
| 550 | ||
| 12670 | 551 |   From the {\LaTeX} viewpoint, ``\verb,--,'' acts like a markup
 | 
| 552 | command, associated with the macro \verb,\isamarkupcmt, (taking a | |
| 553 | single argument). | |
| 12659 | 554 | |
| 12665 | 555 |   \medskip Text blocks are introduced by the commands \bfindex{text}
 | 
| 556 |   and \bfindex{txt}, for theory and proof contexts, respectively.
 | |
| 557 | Each takes again a single $text$ argument, which is interpreted as a | |
| 558 |   free-form paragraph in {\LaTeX} (surrounded by some additional
 | |
| 12670 | 559 | vertical space). This behavior may be changed by redefining the | 
| 560 |   {\LaTeX} environments of \verb,isamarkuptext, or
 | |
| 561 | \verb,isamarkuptxt,, respectively (via \verb,\renewenvironment,) The | |
| 562 | text style of the body is determined by \verb,\isastyletext, and | |
| 563 | \verb,\isastyletxt,; the default setup uses a smaller font within | |
| 12746 | 564 | proofs. This may be changed as follows: | 
| 565 | ||
| 566 | \begin{verbatim}
 | |
| 567 |   \renewcommand{\isastyletxt}{\isastyletext}
 | |
| 568 | \end{verbatim}
 | |
| 12659 | 569 | |
| 12766 | 570 | \medskip The $text$ part of Isabelle markup commands essentially | 
| 571 |   inserts \emph{quoted material} into a formal text, mainly for
 | |
| 572 |   instruction of the reader.  An \bfindex{antiquotation} is again a
 | |
| 573 | formal object embedded into such an informal portion. The | |
| 574 | interpretation of antiquotations is limited to some well-formedness | |
| 575 | checks, with the result being pretty printed to the resulting | |
| 576 | document. Quoted text blocks together with antiquotations provide | |
| 577 | an attractive means of referring to formal entities, with good | |
| 578 | confidence in getting the technical details right (especially syntax | |
| 579 | and types). | |
| 12659 | 580 | |
| 12665 | 581 | The general syntax of antiquotations is as follows: | 
| 12659 | 582 |   \texttt{{\at}{\ttlbrace}$name$ $arguments${\ttrbrace}}, or
 | 
| 583 |   \texttt{{\at}{\ttlbrace}$name$ [$options$] $arguments${\ttrbrace}}
 | |
| 12665 | 584 | for a comma-separated list of options consisting of a $name$ or | 
| 12766 | 585 |   \texttt{$name$=$value$} each.  The syntax of $arguments$ depends on
 | 
| 586 | the kind of antiquotation, it generally follows the same conventions | |
| 587 | for types, terms, or theorems as in the formal part of a theory. | |
| 12645 | 588 | |
| 12766 | 589 | \medskip This sentence demonstrates quotations and antiquotations: | 
| 590 |   @{term "%x y. x"} is a well-typed term.
 | |
| 12659 | 591 | |
| 12764 | 592 | \medskip\noindent The output above was produced as follows: | 
| 12659 | 593 |   \begin{ttbox}
 | 
| 594 | text {\ttlbrace}*
 | |
| 12764 | 595 | This sentence demonstrates quotations and antiquotations: | 
| 12659 | 596 |   {\at}{\ttlbrace}term "%x y. x"{\ttrbrace} is a well-typed term.
 | 
| 597 | *{\ttrbrace}
 | |
| 12766 | 598 |   \end{ttbox}\vspace{-\medskipamount}
 | 
| 12659 | 599 | |
| 12764 | 600 | The notational change from the ASCII character~\verb,%, to the | 
| 12766 | 601 |   symbol~@{text \<lambda>} reveals that Isabelle printed this term, after
 | 
| 602 | parsing and type-checking. Document preparation enables symbolic | |
| 603 | output by default. | |
| 12659 | 604 | |
| 16523 | 605 | \medskip The next example includes an option to show the type of all | 
| 606 | variables. The antiquotation | |
| 12766 | 607 |   \texttt{{\at}}\verb,{term [show_types] "%x y. x"}, produces the
 | 
| 608 |   output @{term [show_types] "%x y. x"}.  Type inference has figured
 | |
| 609 | out the most general typings in the present theory context. Terms | |
| 610 | may acquire different typings due to constraints imposed by their | |
| 611 | environment; within a proof, for example, variables are given the | |
| 612 | same types as they have in the main goal statement. | |
| 12659 | 613 | |
| 12764 | 614 | \medskip Several further kinds of antiquotations and options are | 
| 30649 
57753e0ec1d4
1. New cancellation simprocs for common factors in inequations
 nipkow parents: 
28914diff
changeset | 615 |   available \cite{isabelle-isar-ref}.  Here are a few commonly used
 | 
| 12670 | 616 | combinations: | 
| 12659 | 617 | |
| 618 | \medskip | |
| 12651 | 619 | |
| 12659 | 620 |   \begin{tabular}{ll}
 | 
| 621 |   \texttt{\at}\verb,{typ,~$\tau$\verb,}, & print type $\tau$ \\
 | |
| 25338 | 622 |   \texttt{\at}\verb,{const,~$c$\verb,}, & check existence of $c$ and print it \\
 | 
| 12659 | 623 |   \texttt{\at}\verb,{term,~$t$\verb,}, & print term $t$ \\
 | 
| 624 |   \texttt{\at}\verb,{prop,~$\phi$\verb,}, & print proposition $\phi$ \\
 | |
| 12665 | 625 |   \texttt{\at}\verb,{prop [display],~$\phi$\verb,}, & print large proposition $\phi$ (with linebreaks) \\
 | 
| 12659 | 626 |   \texttt{\at}\verb,{prop [source],~$\phi$\verb,}, & check proposition $\phi$, print its input \\
 | 
| 627 |   \texttt{\at}\verb,{thm,~$a$\verb,}, & print fact $a$ \\
 | |
| 628 |   \texttt{\at}\verb,{thm,~$a$~\verb,[no_vars]}, & print fact $a$, fixing schematic variables \\
 | |
| 12746 | 629 |   \texttt{\at}\verb,{thm [source],~$a$\verb,}, & check availability of fact $a$, print its name \\
 | 
| 12659 | 630 |   \texttt{\at}\verb,{text,~$s$\verb,}, & print uninterpreted text $s$ \\
 | 
| 631 |   \end{tabular}
 | |
| 632 | ||
| 633 | \medskip | |
| 634 | ||
| 12665 | 635 |   Note that \attrdx{no_vars} given above is \emph{not} an
 | 
| 636 | antiquotation option, but an attribute of the theorem argument given | |
| 637 | here. This might be useful with a diagnostic command like | |
| 638 |   \isakeyword{thm}, too.
 | |
| 12659 | 639 | |
| 12665 | 640 |   \medskip The \texttt{\at}\verb,{text, $s$\verb,}, antiquotation is
 | 
| 12659 | 641 | particularly interesting. Embedding uninterpreted text within an | 
| 12665 | 642 | informal body might appear useless at first sight. Here the key | 
| 643 | virtue is that the string $s$ is processed as Isabelle output, | |
| 644 | interpreting Isabelle symbols appropriately. | |
| 12659 | 645 | |
| 12665 | 646 |   For example, \texttt{\at}\verb,{text "\<forall>\<exists>"}, produces @{text
 | 
| 647 | "\<forall>\<exists>"}, according to the standard interpretation of these symbol | |
| 648 |   (cf.\ \S\ref{sec:doc-prep-symbols}).  Thus we achieve consistent
 | |
| 12659 | 649 | mathematical notation in both the formal and informal parts of the | 
| 12766 | 650 | document very easily, independently of the term language of | 
| 651 |   Isabelle.  Manual {\LaTeX} code would leave more control over the
 | |
| 652 | typesetting, but is also slightly more tedious. | |
| 12645 | 653 | *} | 
| 654 | ||
| 655 | ||
| 12674 | 656 | subsection {* Interpretation of Symbols \label{sec:doc-prep-symbols} *}
 | 
| 12645 | 657 | |
| 658 | text {*
 | |
| 12665 | 659 |   As has been pointed out before (\S\ref{sec:syntax-symbols}),
 | 
| 12670 | 660 | Isabelle symbols are the smallest syntactic entities --- a | 
| 12681 | 661 | straightforward generalization of ASCII characters. While Isabelle | 
| 12665 | 662 | does not impose any interpretation of the infinite collection of | 
| 12764 | 663 |   named symbols, {\LaTeX} documents use canonical glyphs for certain
 | 
| 28838 
d5db6dfcb34a
moved table of standard Isabelle symbols to isar-ref manual;
 wenzelm parents: 
28504diff
changeset | 664 |   standard symbols \cite{isabelle-isar-ref}.
 | 
| 12659 | 665 | |
| 12766 | 666 |   The {\LaTeX} code produced from Isabelle text follows a simple
 | 
| 667 | scheme. You can tune the final appearance by redefining certain | |
| 668 |   macros, say in \texttt{root.tex} of the document.
 | |
| 12670 | 669 | |
| 670 |   \begin{enumerate}
 | |
| 12659 | 671 | |
| 12670 | 672 |   \item 7-bit ASCII characters: letters \texttt{A\dots Z} and
 | 
| 12746 | 673 |   \texttt{a\dots z} are output directly, digits are passed as an
 | 
| 12670 | 674 | argument to the \verb,\isadigit, macro, other characters are | 
| 675 | replaced by specifically named macros of the form | |
| 12665 | 676 | \verb,\isacharXYZ,. | 
| 12659 | 677 | |
| 12766 | 678 | \item Named symbols: \verb,\,\verb,<XYZ>, is turned into | 
| 679 |   \verb,{\isasymXYZ},; note the additional braces.
 | |
| 12659 | 680 | |
| 12766 | 681 | \item Named control symbols: \verb,\,\verb,<^XYZ>, is turned into | 
| 682 | \verb,\isactrlXYZ,; subsequent symbols may act as arguments if the | |
| 683 | control macro is defined accordingly. | |
| 12670 | 684 | |
| 12659 | 685 |   \end{enumerate}
 | 
| 12665 | 686 | |
| 12764 | 687 |   You may occasionally wish to give new {\LaTeX} interpretations of
 | 
| 688 | named symbols. This merely requires an appropriate definition of | |
| 12766 | 689 | \verb,\isasymXYZ,, for \verb,\,\verb,<XYZ>, (see | 
| 12746 | 690 |   \texttt{isabelle.sty} for working examples).  Control symbols are
 | 
| 691 | slightly more difficult to get right, though. | |
| 12665 | 692 | |
| 693 | \medskip The \verb,\isabellestyle, macro provides a high-level | |
| 694 | interface to tune the general appearance of individual symbols. For | |
| 12670 | 695 |   example, \verb,\isabellestyle{it}, uses the italics text style to
 | 
| 696 |   mimic the general appearance of the {\LaTeX} math mode; double
 | |
| 12743 | 697 | quotes are not printed at all. The resulting quality of typesetting | 
| 698 | is quite good, so this should be the default style for work that | |
| 699 | gets distributed to a broader audience. | |
| 12645 | 700 | *} | 
| 701 | ||
| 702 | ||
| 12653 | 703 | subsection {* Suppressing Output \label{sec:doc-prep-suppress} *}
 | 
| 12645 | 704 | |
| 705 | text {*
 | |
| 12748 | 706 |   By default, Isabelle's document system generates a {\LaTeX} file for
 | 
| 707 | each theory that gets loaded while running the session. The | |
| 708 |   generated \texttt{session.tex} will include all of these in order of
 | |
| 709 | appearance, which in turn gets included by the standard | |
| 12743 | 710 |   \texttt{root.tex}.  Certainly one may change the order or suppress
 | 
| 12746 | 711 |   unwanted theories by ignoring \texttt{session.tex} and load
 | 
| 712 |   individual files directly in \texttt{root.tex}.  On the other hand,
 | |
| 713 | such an arrangement requires additional maintenance whenever the | |
| 714 | collection of theories changes. | |
| 12648 | 715 | |
| 716 | Alternatively, one may tune the theory loading process in | |
| 51057 | 717 |   \texttt{ROOT} itself: some sequential order of \textbf{theories}
 | 
| 718 | sections may enforce a certain traversal of the dependency graph, | |
| 719 | although this could degrade parallel processing. The nodes of each | |
| 720 | sub-graph that is specified here are presented in some topological | |
| 721 | order of their formal dependencies. | |
| 722 | ||
| 723 | Moreover, the system build option \verb,document=false, allows to | |
| 724 | disable document generation for some theories. Its usage in the | |
| 725 |   session \texttt{ROOT} is like this:
 | |
| 12648 | 726 | |
| 727 | \begin{verbatim}
 | |
| 51057 | 728 | theories [document = false] T | 
| 12648 | 729 | \end{verbatim}
 | 
| 12645 | 730 | |
| 17183 | 731 | \medskip Theory output may be suppressed more selectively, either | 
| 732 |   via \bfindex{tagged command regions} or \bfindex{ignored material}.
 | |
| 12648 | 733 | |
| 17183 | 734 | Tagged command regions works by annotating commands with named tags, | 
| 735 |   which correspond to certain {\LaTeX} markup that tells how to treat
 | |
| 736 | particular parts of a document when doing the actual type-setting. | |
| 737 | By default, certain Isabelle/Isar commands are implicitly marked up | |
| 738 |   using the predefined tags ``\emph{theory}'' (for theory begin and
 | |
| 739 |   end), ``\emph{proof}'' (for proof commands), and ``\emph{ML}'' (for
 | |
| 740 | commands involving ML code). Users may add their own tags using the | |
| 741 |   \verb,%,\emph{tag} notation right after a command name.  In the
 | |
| 742 | subsequent example we hide a particularly irrelevant proof: | |
| 743 | *} | |
| 12648 | 744 | |
| 17183 | 745 | lemma "x = x" by %invisible (simp) | 
| 12648 | 746 | |
| 17183 | 747 | text {*
 | 
| 748 | The original source has been ``\verb,lemma "x = x" by %invisible (simp),''. | |
| 749 | Tags observe the structure of proofs; adjacent commands with the | |
| 750 | same tag are joined into a single region. The Isabelle document | |
| 751 | preparation system allows the user to specify how to interpret a | |
| 752 | tagged region, in order to keep, drop, or fold the corresponding | |
| 753 |   parts of the document.  See the \emph{Isabelle System Manual}
 | |
| 754 |   \cite{isabelle-sys} for further details, especially on
 | |
| 51057 | 755 |   \texttt{isabelle build} and \texttt{isabelle document}.
 | 
| 12648 | 756 | |
| 17183 | 757 | Ignored material is specified by delimiting the original formal | 
| 758 | source with special source comments | |
| 759 | \verb,(,\verb,*,\verb,<,\verb,*,\verb,), and | |
| 760 | \verb,(,\verb,*,\verb,>,\verb,*,\verb,),. These parts are stripped | |
| 761 | before the type-setting phase, without affecting the formal checking | |
| 762 | of the theory, of course. For example, we may hide parts of a proof | |
| 763 | that seem unfit for general public inspection. The following | |
| 764 | ``fully automatic'' proof is actually a fake: | |
| 12651 | 765 | *} | 
| 766 | ||
| 767 | lemma "x \<noteq> (0::int) \<Longrightarrow> 0 < x * x" | |
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
13439diff
changeset | 768 | by (auto(*<*)simp add: zero_less_mult_iff(*>*)) | 
| 12651 | 769 | |
| 770 | text {*
 | |
| 17183 | 771 | \noindent The real source of the proof has been as follows: | 
| 12651 | 772 | |
| 773 | \begin{verbatim}
 | |
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
13439diff
changeset | 774 | by (auto(*<*)simp add: zero_less_mult_iff(*>*)) | 
| 12659 | 775 | \end{verbatim}
 | 
| 776 | %(* | |
| 12651 | 777 | |
| 12766 | 778 | \medskip Suppressing portions of printed text demands care. You | 
| 779 | should not misrepresent the underlying theory development. It is | |
| 780 | easy to invalidate the visible text by hiding references to | |
| 17183 | 781 | questionable axioms, for example. | 
| 12629 | 782 | *} | 
| 783 | ||
| 11647 | 784 | (*<*) | 
| 785 | end | |
| 786 | (*>*) |