doc-src/TutorialI/Documents/Documents.thy
author wenzelm
Sun, 06 Jan 2002 13:48:18 +0100
changeset 12648 16d4b8c09086
parent 12645 3af5de958a1a
child 12651 930df4604b36
permissions -rw-r--r--
some more text;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11647
0538cb0f7999 initial setup for chapter on document preparation;
wenzelm
parents:
diff changeset
     1
(*<*)
0538cb0f7999 initial setup for chapter on document preparation;
wenzelm
parents:
diff changeset
     2
theory Documents = Main:
0538cb0f7999 initial setup for chapter on document preparation;
wenzelm
parents:
diff changeset
     3
(*>*)
0538cb0f7999 initial setup for chapter on document preparation;
wenzelm
parents:
diff changeset
     4
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
     5
section {* Concrete Syntax \label{sec:concrete-syntax} *}
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
     6
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
     7
text {*
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
     8
  Concerning Isabelle's ``inner'' language of simply-typed @{text
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
     9
  \<lambda>}-calculus, the core concept of Isabelle's elaborate infrastructure
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
    10
  for concrete syntax is that of general \bfindex{mixfix annotations}.
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
    11
  Associated with any kind of name and type declaration, mixfixes give
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
    12
  rise both to grammar productions for the parser and output templates
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
    13
  for the pretty printer.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    14
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    15
  In full generality, the whole affair of parser and pretty printer
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    16
  configuration is rather subtle.  Any syntax specifications given by
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    17
  end-users need to interact properly with the existing setup of
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    18
  Isabelle/Pure and Isabelle/HOL; see \cite{isabelle-ref} for further
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    19
  details.  It is particularly important to get the precedence of new
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    20
  syntactic constructs right, avoiding ambiguities with existing
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    21
  elements.
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    22
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    23
  \medskip Subsequently we introduce a few simple declaration forms
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    24
  that already cover the most common situations fairly well.
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    25
*}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    26
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    27
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
    28
subsection {* Infix Annotations *}
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    29
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    30
text {*
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    31
  Syntax annotations may be included wherever constants are declared
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    32
  directly or indirectly, including \isacommand{consts},
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    33
  \isacommand{constdefs}, or \isacommand{datatype} (for the
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    34
  constructor operations).  Type-constructors may be annotated as
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    35
  well, although this is less frequently encountered in practice
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    36
  (@{text "*"} and @{text "+"} types may come to mind).
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    37
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
    38
  Infix declarations\index{infix annotations} provide a useful special
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
    39
  case of mixfixes, where users need not care about the full details
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
    40
  of priorities, nesting, spacing, etc.  The subsequent example of the
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
    41
  exclusive-or operation on boolean values illustrates typical infix
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
    42
  declarations.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    43
*}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    44
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    45
constdefs
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    46
  xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "[+]" 60)
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    47
  "A [+] B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    48
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    49
text {*
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    50
  Any curried function with at least two arguments may be associated
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    51
  with infix syntax: @{text "xor A B"} and @{text "A [+] B"} refer to
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    52
  the same expression internally.  In partial applications with less
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    53
  than two operands there is a special notation with \isa{op} prefix:
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    54
  @{text xor} without arguments is represented as @{text "op [+]"};
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    55
  combined with plain prefix application this turns @{text "xor A"}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    56
  into @{text "op [+] A"}.
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    57
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    58
  \medskip The string @{text [source] "[+]"} in the above declaration
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    59
  refers to the bit of concrete syntax to represent the operator,
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    60
  while the number @{text 60} determines the precedence of the whole
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    61
  construct.
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    62
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    63
  As it happens, Isabelle/HOL already spends many popular combinations
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    64
  of ASCII symbols for its own use, including both @{text "+"} and
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    65
  @{text "++"}.  Slightly more awkward combinations like the present
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    66
  @{text "[+]"} tend to be available for user extensions.  The current
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    67
  arrangement of inner syntax may be inspected via
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    68
  \commdx{print\protect\_syntax}, albeit its output is enormous.
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    69
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    70
  Operator precedence also needs some special considerations.  The
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    71
  admissible range is 0--1000.  Very low or high priorities are
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    72
  basically reserved for the meta-logic.  Syntax of Isabelle/HOL
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    73
  mainly uses the range of 10--100: the equality infix @{text "="} is
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    74
  centered at 50, logical connectives (like @{text "\<or>"} and @{text
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    75
  "\<and>"}) are below 50, and algebraic ones (like @{text "+"} and @{text
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    76
  "*"}) above 50.  User syntax should strive to coexist with common
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    77
  HOL forms, or use the mostly unused range 100--900.
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    78
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    79
  \medskip The keyword \isakeyword{infixl} specifies an operator that
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    80
  is nested to the \emph{left}: in iterated applications the more
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    81
  complex expression appears on the left-hand side: @{term "A [+] B
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    82
  [+] C"} stands for @{text "(A [+] B) [+] C"}.  Similarly,
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
    83
  \isakeyword{infixr} refers to nesting to the \emph{right}, reading
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
    84
  @{term "A [+] B [+] C"} as @{text "A [+] (B [+] C)"}.  In contrast,
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
    85
  a \emph{non-oriented} declaration via \isakeyword{infix} would
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
    86
  always demand explicit parentheses.
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
    87
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    88
  Many binary operations observe the associative law, so the exact
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    89
  grouping does not matter.  Nevertheless, formal statements need be
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    90
  given in a particular format, associativity needs to be treated
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    91
  explicitly within the logic.  Exclusive-or is happens to be
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    92
  associative, as shown below.
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    93
*}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    94
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    95
lemma xor_assoc: "(A [+] B) [+] C = A [+] (B [+] C)"
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    96
  by (auto simp add: xor_def)
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    97
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    98
text {*
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    99
  Such rules may be used in simplification to regroup nested
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   100
  expressions as required.  Note that the system would actually print
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   101
  the above statement as @{term "A [+] B [+] C = A [+] (B [+] C)"}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   102
  (due to nesting to the left).  We have preferred to give the fully
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   103
  parenthesized form in the text for clarity.  Only in rare situations
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   104
  one may consider to force parentheses by use of non-oriented infix
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   105
  syntax; equality would probably be a typical candidate.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   106
*}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   107
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   108
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   109
subsection {* Mathematical Symbols \label{sec:thy-present-symbols} *}
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   110
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   111
text {*
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   112
  Concrete syntax based on plain ASCII characters has its inherent
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   113
  limitations.  Rich mathematical notation demands a larger repertoire
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   114
  of symbols.  Several standards of extended character sets have been
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   115
  proposed over decades, but none has become universally available so
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   116
  far, not even Unicode\index{Unicode}.
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   117
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   118
  Isabelle supports a generic notion of \bfindex{symbols} as the
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   119
  smallest entities of source text, without referring to internal
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   120
  encodings.  Such ``generalized characters'' may be of one of the
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   121
  following three kinds:
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   122
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   123
  \begin{enumerate}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   124
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   125
  \item Traditional 7-bit ASCII characters.
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   126
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   127
  \item Named symbols: \verb,\,\verb,<,$ident$\verb,>, (or
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   128
  \verb,\\,\verb,<,$ident$\verb,>,).
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   129
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   130
  \item Named control symbols: \verb,\,\verb,<^,$ident$\verb,>, (or
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   131
  \verb,\\,\verb,<^,$ident$\verb,>,).
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   132
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   133
  \end{enumerate}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   134
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   135
  Here $ident$ may be any identifier according to the usual Isabelle
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   136
  conventions.  This results in an infinite store of symbols, whose
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   137
  interpretation is left to further front-end tools.  For example, the
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   138
  \verb,\,\verb,<forall>, symbol of Isabelle is really displayed as
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   139
  $\forall$ --- both by the user-interface of Proof~General + X-Symbol
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   140
  and the Isabelle document processor (see \S\ref{FIXME}).
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   141
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   142
  A list of standard Isabelle symbols is given in
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   143
  \cite[appendix~A]{isabelle-sys}.  Users may introduce their own
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   144
  interpretation of further symbols by configuring the appropriate
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   145
  front-end tool accordingly, e.g.\ defining appropriate {\LaTeX}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   146
  macros for document preparation.  There are also a few predefined
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   147
  control symbols, such as \verb,\,\verb,<^sub>, and
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   148
  \verb,\,\verb,<^sup>, for sub- and superscript of the subsequent
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   149
  (printable) symbol, respectively.
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   150
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   151
  \medskip The following version of our @{text xor} definition uses a
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   152
  standard Isabelle symbol to achieve typographically pleasing output.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   153
*}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   154
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   155
(*<*)
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   156
hide const xor
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   157
ML_setup {* Context.>> (Theory.add_path "1") *}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   158
(*>*)
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   159
constdefs
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   160
  xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "\<oplus>" 60)
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   161
  "A \<oplus> B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   162
(*<*)
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   163
local
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   164
(*>*)
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   165
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   166
text {*
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   167
  The X-Symbol package within Proof~General provides several input
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   168
  methods to enter @{text \<oplus>} in the text.  If all fails one may just
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   169
  type \verb,\,\verb,<oplus>, by hand; the display is adapted
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   170
  immediately after continuing further input.
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   171
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   172
  \medskip A slightly more refined scheme is to provide alternative
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   173
  syntax via the \bfindex{print mode} concept of Isabelle (see also
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   174
  \cite{isabelle-ref}).  By convention, the mode ``$xsymbols$'' is
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   175
  enabled whenever X-Symbol is active.  Consider the following hybrid
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   176
  declaration of @{text xor}.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   177
*}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   178
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   179
(*<*)
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   180
hide const xor
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   181
ML_setup {* Context.>> (Theory.add_path "2") *}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   182
(*>*)
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   183
constdefs
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   184
  xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "[+]\<ignore>" 60)
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   185
  "A [+]\<ignore> B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   186
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   187
syntax (xsymbols)
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   188
  xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "\<oplus>\<ignore>" 60)
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   189
(*<*)
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   190
local
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   191
(*>*)
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   192
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   193
text {*
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   194
  Here the \commdx{syntax} command acts like \isakeyword{consts}, but
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   195
  without declaring a logical constant, and with an optional print
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   196
  mode specification.  Note that the type declaration given here
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   197
  merely serves for syntactic purposes, and is not checked for
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   198
  consistency with the real constant.
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   199
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   200
  \medskip Now we may write either @{text "[+]"} or @{text "\<oplus>"} in
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   201
  input, while output uses the nicer syntax of $xsymbols$, provided
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   202
  that print mode is presently active.  This scheme is particularly
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   203
  useful for interactive development, with the user typing plain ASCII
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   204
  text, but gaining improved visual feedback from the system (say in
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   205
  current goal output).
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   206
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   207
  \begin{warn}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   208
  Using alternative syntax declarations easily results in varying
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   209
  versions of input sources.  Isabelle provides no systematic way to
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   210
  convert alternative expressions back and forth.  Print modes only
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   211
  affect situations where formal entities are pretty printed by the
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   212
  Isabelle process (e.g.\ output of terms and types), but not the
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   213
  original theory text.
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   214
  \end{warn}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   215
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   216
  \medskip The following variant makes the alternative @{text \<oplus>}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   217
  notation only available for output.  Thus we may enforce input
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   218
  sources to refer to plain ASCII only.
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   219
*}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   220
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   221
syntax (xsymbols output)
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   222
  xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "\<oplus>\<ignore>" 60)
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   223
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   224
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   225
subsection {* Prefix Annotations *}
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   226
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   227
text {*
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   228
  Prefix syntax annotations\index{prefix annotation} are just a very
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   229
  degenerate of the general mixfix form \cite{isabelle-ref}, without
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   230
  any template arguments or priorities --- just some piece of literal
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   231
  syntax.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   232
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   233
  The following example illustrates this idea idea by associating
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   234
  common symbols with the constructors of a currency datatype.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   235
*}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   236
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   237
datatype currency =
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   238
    Euro nat    ("\<euro>")
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   239
  | Pounds nat  ("\<pounds>")
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   240
  | Yen nat     ("\<yen>")
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   241
  | Dollar nat  ("$")
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   242
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   243
text {*
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   244
  Here the degenerate mixfix annotations on the rightmost column
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   245
  happen to consist of a single Isabelle symbol each:
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   246
  \verb,\,\verb,<euro>,, \verb,\,\verb,<pounds>,,
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   247
  \verb,\,\verb,<yen>,, \verb,$,.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   248
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   249
  Recall that a constructor like @{text Euro} actually is a function
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   250
  @{typ "nat \<Rightarrow> currency"}.  An expression like @{text "Euro 10"} will
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   251
  be printed as @{term "\<euro> 10"}.  Only the head of the application is
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   252
  subject to our concrete syntax; this simple form already achieves
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   253
  conformance with notational standards of the European Commission.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   254
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   255
  \medskip Certainly, the same idea of prefix syntax also works for
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   256
  \isakeyword{consts}, \isakeyword{constdefs} etc.  For example, we
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   257
  might introduce a (slightly unrealistic) function to calculate an
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   258
  abstract currency value, by cases on the datatype constructors and
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   259
  fixed exchange rates.  The funny symbol used here is that of
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   260
  \verb,\<currency>,.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   261
*}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   262
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   263
consts
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   264
  currency :: "currency \<Rightarrow> nat"    ("\<currency>")
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   265
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   266
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   267
subsection {* Syntax Translations \label{sec:def-translations} *}
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   268
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   269
text{*
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   270
  FIXME
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   271
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   272
\index{syntax translations|(}%
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   273
\index{translations@\isacommand {translations} (command)|(}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   274
Isabelle offers an additional definitional facility,
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   275
\textbf{syntax translations}.
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   276
They resemble macros: upon parsing, the defined concept is immediately
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   277
replaced by its definition.  This effect is reversed upon printing.  For example,
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   278
the symbol @{text"\<noteq>"} is defined via a syntax translation:
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   279
*}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   280
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   281
translations "x \<noteq> y" \<rightleftharpoons> "\<not>(x = y)"
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   282
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   283
text{*\index{$IsaEqTrans@\isasymrightleftharpoons}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   284
\noindent
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   285
Internally, @{text"\<noteq>"} never appears.
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   286
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   287
In addition to @{text"\<rightleftharpoons>"} there are
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   288
@{text"\<rightharpoonup>"}\index{$IsaEqTrans1@\isasymrightharpoonup}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   289
and @{text"\<leftharpoondown>"}\index{$IsaEqTrans2@\isasymleftharpoondown}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   290
for uni-directional translations, which only affect
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   291
parsing or printing.  This tutorial will not cover the details of
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   292
translations.  We have mentioned the concept merely because it
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   293
crops up occasionally; a number of HOL's built-in constructs are defined
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   294
via translations.  Translations are preferable to definitions when the new
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   295
concept is a trivial variation on an existing one.  For example, we
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   296
don't need to derive new theorems about @{text"\<noteq>"}, since existing theorems
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   297
about @{text"="} still apply.%
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   298
\index{syntax translations|)}%
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   299
\index{translations@\isacommand {translations} (command)|)}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   300
*}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   301
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   302
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   303
section {* Document Preparation *}
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   304
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   305
text {*
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   306
  Isabelle/Isar is centered around a certain notion of \bfindex{formal
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   307
  proof documents}\index{documents|bold}: ultimately the result of the
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   308
  user's theory development efforts is a human-readable record --- as
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   309
  a browsable PDF file or printed on paper.  The overall document
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   310
  structure follows traditional mathematical articles, with
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   311
  sectioning, explanations, definitions, theorem statements, and
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   312
  proofs.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   313
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   314
  The Isar proof language \cite{Wenzel-PhD}, which is not covered in
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   315
  this book, admits to write formal proof texts that are acceptable
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   316
  both to the machine and human readers at the same time.  Thus
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   317
  marginal comments and explanations may be kept at a minimum.
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   318
  Nevertheless, Isabelle document output is still useful without
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   319
  actual Isar proof texts; formal specifications usually deserve their
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   320
  own coverage in the text, while unstructured proof scripts may be
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   321
  just ignore by readers (or intentionally suppressed from the text).
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   322
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   323
  \medskip The Isabelle document preparation system essentially acts
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   324
  like a formal front-end for {\LaTeX}.  After checking definitions
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   325
  and proofs the theory sources are turned into typesetting
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   326
  instructions, so the final document is known to observe quite strong
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   327
  ``soundness'' properties.  This enables users to write authentic
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   328
  reports on formal theory developments with little additional effort,
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   329
  the most tedious consistency checks are handled by the system.
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   330
*}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   331
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   332
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   333
subsection {* Isabelle Sessions *}
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   334
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   335
text {*
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   336
  In contrast to the highly interactive mode of the formal parts of
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   337
  Isabelle/Isar theory development, the document preparation stage
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   338
  essentially works in batch-mode.  This revolves around the concept
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   339
  of a \bfindex{session}, which essentially consists of a collection
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   340
  of theory source files that contribute to a single output document.
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   341
  Each session is derived from a parent one (usually an object-logic
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   342
  image such as \texttt{HOL}); this results in an overall tree
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   343
  structure of Isabelle sessions.
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   344
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   345
  The canonical arrangement of source files of a session called
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   346
  \texttt{MySession} is as follows:
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   347
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   348
  \begin{itemize}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   349
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   350
  \item Directory \texttt{MySession} contains the required theory
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   351
  files, say $A@1$\texttt{.thy}, \dots, $A@n$\texttt{.thy}.
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   352
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   353
  \item File \texttt{MySession/ROOT.ML} holds appropriate ML commands
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   354
  for loading all wanted theories, usually just
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   355
  \texttt{use_thy~"$A@i$"} for any $A@i$ in leaf position of the
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   356
  theory dependency graph.
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   357
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   358
  \item Directory \texttt{MySession/document} contains everything
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   359
  required for the {\LaTeX} stage, but only \texttt{root.tex} needs to
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   360
  be provided initially.  The latter file holds appropriate {\LaTeX}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   361
  code to commence a document (\verb,\documentclass, etc.), and to
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   362
  include the generated files $A@i$\texttt{.tex} for each theory.  The
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   363
  generated file \texttt{session.tex} holds {\LaTeX} commands to
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   364
  include \emph{all} theory output files in topologically sorted
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   365
  order.
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   366
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   367
  \item In addition an \texttt{IsaMakefile} outside of directory
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   368
  \texttt{MySession} holds appropriate dependencies and invocations of
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   369
  Isabelle tools to control the batch job.  The details are covered in
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   370
  \cite{isabelle-sys}; \texttt{isatool usedir} is the most important
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   371
  entry point.
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   372
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   373
  \end{itemize}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   374
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   375
  With everything put in its proper place, \texttt{isatool make}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   376
  should be sufficient to process the Isabelle session completely,
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   377
  with the generated document appearing in its proper place (within
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   378
  \verb,~/isabelle/browser_info,).
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   379
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   380
  In practice, users may want to have \texttt{isatool mkdir} generate
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   381
  an initial working setup without further ado.  For example, an empty
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   382
  session \texttt{MySession} derived from \texttt{HOL} may be produced
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   383
  as follows:
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   384
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   385
\begin{verbatim}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   386
  isatool mkdir HOL MySession
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   387
  isatool make
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   388
\end{verbatim}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   389
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   390
  This runs the session with sensible default options, including
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   391
  verbose mode to tell the user where the result will appear.  The
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   392
  above dry run should produce should produce a single page of output
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   393
  (with a dummy title, empty table of contents etc.).  Any failure at
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   394
  that stage is likely to indicate some technical problems with your
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   395
  {\LaTeX} installation.\footnote{Especially make sure that
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   396
  \texttt{pdflatex} is present.}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   397
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   398
  \medskip Users may now start to populate the directory
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   399
  \texttt{MySession}, and the file \texttt{MySession/ROOT.ML}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   400
  accordingly.  \texttt{MySession/document/root.tex} should be also
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   401
  adapted at some point; the generated version is mostly
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   402
  self-explanatory.  The default versions includes the
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   403
  \texttt{isabelle} (mandatory) and \texttt{isabellesym} (required for
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   404
  mathematical symbols); further packages may required, e.g.\ for
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   405
  unusual Isabelle symbols.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   406
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   407
  Realistic applications may demand additional files in
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   408
  \texttt{MySession/document} for the {\LaTeX} stage, such as
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   409
  \texttt{root.bib} for the bibliographic database.\footnote{Using
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   410
  that particular name of \texttt{root.bib}, the Isabelle document
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   411
  processor (actually \texttt{isatool document} \cite{isabelle-sys})
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   412
  will be smart enough to invoke \texttt{bibtex} accordingly.}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   413
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   414
  \medskip Failure of the document preparation phase in an Isabelle
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   415
  batch session leaves the generated sources in there target location
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   416
  (as pointed out by the accompanied error message).  In case of
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   417
  {\LaTeX} errors, users may trace error messages at the file position
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   418
  of the generated text.
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   419
*}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   420
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   421
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   422
subsection {* Structure Markup *}
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   423
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   424
subsubsection {* Sections *}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   425
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   426
text {*
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   427
  FIXME \verb,\label, within sections;
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   428
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   429
  The large-scale structure of Isabelle documents closely follows
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   430
  {\LaTeX} convention, with chapters, sections, subsubsections etc.
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   431
  The formal Isar language includes separate structure \bfindex{markup
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   432
  commands}, which do not effect the formal content of a theory (or
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   433
  proof), but results in corresponding {\LaTeX} elements issued to the
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   434
  output.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   435
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   436
  There are different markup commands for different formal contexts:
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   437
  in header position (just before a \isakeyword{theory} command),
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   438
  within the theory body, or within a proof.  Note that the header
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   439
  needs to be treated specially, since ordinary theory and proof
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   440
  commands may only occur \emph{after} the initial \isakeyword{theory}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   441
  specification.
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   442
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   443
  \smallskip
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   444
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   445
  \begin{tabular}{llll}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   446
  header & theory & proof & default meaning \\\hline
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   447
    & \commdx{chapter} & & \verb,\chapter, \\
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   448
  \commdx{header} & \commdx{section} & \commdx{sect} & \verb,\section, \\
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   449
    & \commdx{subsection} & \commdx{subsect} & \verb,\subsection, \\
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   450
    & \commdx{subsubsection} & \commdx{subsubsect} & \verb,\subsubsection, \\
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   451
  \end{tabular}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   452
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   453
  \medskip
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   454
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   455
  From the Isabelle perspective, each markup command takes a single
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   456
  text argument (delimited by \verb,",\dots\verb,", or
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   457
  \verb,{,\verb,*,~\dots~\verb,*,\verb,},).  After stripping
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   458
  surrounding white space, the argument is passed to a {\LaTeX} macro
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   459
  \verb,\isamarkupXXX, for any command \isakeyword{XXX}.  The latter
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   460
  are defined in \verb,isabelle.sty, according to the rightmost column
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   461
  above.
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   462
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   463
  \medskip The following source fragment illustrates structure markup
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   464
  of a theory.  Note that {\LaTeX} labels may well be included inside
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   465
  of section headings as well.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   466
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   467
  \begin{ttbox}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   468
  header {\ttlbrace}* Some properties of Foo Bar elements *{\ttrbrace}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   469
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   470
  theory Foo_Bar = Main:
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   471
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   472
  subsection {\ttlbrace}* Basic definitions *{\ttrbrace}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   473
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   474
  consts
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   475
    foo :: \dots
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   476
    bar :: \dots
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   477
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   478
  defs \dots
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   479
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   480
  subsection {\ttlbrace}* Derived rules *{\ttrbrace}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   481
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   482
  lemma fooI: \dots
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   483
  lemma fooE: \dots
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   484
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   485
  subsection {\ttlbrace}* Main theorem {\ttback}label{\ttlbrace}sec:main-theorem{\ttrbrace} *{\ttrbrace}
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   486
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   487
  theorem main: \dots
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   488
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   489
  end
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   490
  \end{ttbox}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   491
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   492
  Users may occasionally want to change the meaning of some markup
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   493
  commands, typically via appropriate use of \verb,\renewcommand, in
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   494
  \texttt{root.tex}.  The \verb,\isamarkupheader, is a good candidate
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   495
  for some adaption, e.g.\ moving it up in the hierarchy to become
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   496
  \verb,\chapter,.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   497
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   498
\begin{verbatim}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   499
  \renewcommand{\isamarkupheader}[1]{\chapter{#1}}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   500
\end{verbatim}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   501
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   502
  Certainly, this requires to change the default
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   503
  \verb,\documentclass{article}, in \texttt{root.tex} to something
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   504
  that supports the notion of chapters in the first place, e.g.\
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   505
  \verb,\documentclass{report},.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   506
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   507
  \medskip The {\LaTeX} macro \verb,\isabellecontext, is maintained to
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   508
  hold the name of the current theory context.  This is particularly
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   509
  useful for document headings or footings, e.g.\ like this:
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   510
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   511
\begin{verbatim}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   512
  \renewcommand{\isamarkupheader}[1]%
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   513
  {\chapter{#1}\markright{THEORY~\isabellecontext}}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   514
\end{verbatim}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   515
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   516
  \noindent Make sure to include something like
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   517
  \verb,\pagestyle{headings}, in \texttt{root.tex}; the document
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   518
  should have more than 2 pages to show the effect.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   519
*}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   520
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   521
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   522
subsection {* Formal Comments and Antiquotations *}
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   523
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   524
text {*
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   525
  Comments of the form \verb,(,\verb,*,~\dots~\verb,*,\verb,),
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   526
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   527
*}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   528
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   529
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   530
subsection {* Symbols and Characters *}
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   531
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   532
text {*
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   533
  FIXME \verb,\isabellestyle,
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   534
*}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   535
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   536
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   537
subsection {* Suppressing Output *}
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   538
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   539
text {*
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   540
  By default Isabelle's document system generates a {\LaTeX} source
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   541
  file for each theory that happens to get loaded during the session.
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   542
  The generated \texttt{session.tex} file will include all of these in
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   543
  order of appearance, which in turn gets included by the standard
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   544
  \texttt{root.tex} file.  Certainly one may change the order of
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   545
  appearance or suppress unwanted theories by ignoring
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   546
  \texttt{session.tex} and include individual files in
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   547
  \texttt{root.tex} by hand.  On the other hand, such an arrangement
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   548
  requires additional efforts for maintenance.
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   549
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   550
  Alternatively, one may tune the theory loading process in
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   551
  \texttt{ROOT.ML}: traversal of the theory dependency graph may be
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   552
  fine-tuned by adding further \verb,use_thy, invocations, although
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   553
  topological sorting needs to be preserved.  Moreover, the ML
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   554
  operator \verb,no_document, temporarily disables document generation
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   555
  while executing a theory loader command; the usage is like this:
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   556
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   557
\begin{verbatim}
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   558
  no_document use_thy "Aux";
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   559
\end{verbatim}
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   560
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   561
  Theory output may be also suppressed \emph{partially} as well.
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   562
  Typical applications include research papers or slides based on
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   563
  formal developments --- these usually do not show the full formal
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   564
  content.  The special source comments
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   565
  \verb,(,\verb,*,\verb,<,\verb,*,\verb,), and
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   566
  \verb,(,\verb,*,\verb,>,\verb,*,\verb,), are interpreted by the
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   567
  document generator as open and close parenthesis for
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   568
  \bfindex{ignored material}.  Any text inside of (potentially nested)
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   569
  \verb,(,\verb,*,\verb,<,\verb,*,\verb,),~\dots~\verb,(,\verb,*,\verb,>,\verb,*,\verb,),
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   570
  parentheses is just ignored from the output --- after correct formal
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   571
  checking.
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   572
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   573
  In the following example we suppress the slightly formalistic
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   574
  \isakeyword{theory} and \isakeyword{end} part of a theory text.
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   575
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   576
  \medskip
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   577
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   578
  \begin{tabular}{l}
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   579
  \verb,(,\verb,*,\verb,<,\verb,*,\verb,), \\
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   580
  \texttt{theory A = Main:} \\
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   581
  \verb,(,\verb,*,\verb,>,\verb,*,\verb,), \\
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   582
  ~~$\vdots$ \\
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   583
  \verb,(,\verb,*,\verb,<,\verb,*,\verb,), \\
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   584
  \texttt{end} \\
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   585
  \verb,(,\verb,*,\verb,>,\verb,*,\verb,), \\
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   586
  \end{tabular}
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   587
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   588
  \medskip
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   589
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   590
  Ignoring portions of printed text like this demands some special
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   591
  care. FIXME
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   592
*}
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   593
11647
0538cb0f7999 initial setup for chapter on document preparation;
wenzelm
parents:
diff changeset
   594
(*<*)
0538cb0f7999 initial setup for chapter on document preparation;
wenzelm
parents:
diff changeset
   595
end
0538cb0f7999 initial setup for chapter on document preparation;
wenzelm
parents:
diff changeset
   596
(*>*)