doc-src/TutorialI/Documents/document/Documents.tex
author wenzelm
Tue, 08 Jan 2002 17:32:28 +0100
changeset 12670 5c896eccb290
parent 12666 9842befead7a
child 12671 bb6db6c0d4df
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11648
d78a82d112e4 *** empty log message ***
wenzelm
parents:
diff changeset
     1
%
d78a82d112e4 *** empty log message ***
wenzelm
parents:
diff changeset
     2
\begin{isabellebody}%
d78a82d112e4 *** empty log message ***
wenzelm
parents:
diff changeset
     3
\def\isabellecontext{Documents}%
11866
fbd097aec213 updated;
wenzelm
parents: 11648
diff changeset
     4
\isamarkupfalse%
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
     5
%
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
     6
\isamarkupsection{Concrete Syntax \label{sec:concrete-syntax}%
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
     7
}
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
     8
\isamarkuptrue%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
     9
%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    10
\begin{isamarkuptext}%
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    11
Concerning Isabelle's ``inner'' language of simply-typed \isa{{\isasymlambda}}-calculus, the core concept of Isabelle's elaborate
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    12
  infrastructure for concrete syntax is that of general
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    13
  \bfindex{mixfix annotations}.  Associated with any kind of constant
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    14
  declaration, mixfixes affect both the grammar productions for the
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    15
  parser and output templates for the pretty printer.
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    16
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    17
  In full generality, the whole affair of parser and pretty printer
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
    18
  configuration is rather subtle, see also \cite{isabelle-ref}.  Any
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
    19
  syntax specifications given by end-users need to interact properly
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
    20
  with the existing setup of Isabelle/Pure and Isabelle/HOL.  It is
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
    21
  particularly important to get the precedence of new syntactic
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
    22
  constructs right, avoiding ambiguities with existing elements.
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    23
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    24
  \medskip Subsequently we introduce a few simple declaration forms
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    25
  that already cover the most common situations fairly well.%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    26
\end{isamarkuptext}%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    27
\isamarkuptrue%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    28
%
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
    29
\isamarkupsubsection{Infix Annotations%
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    30
}
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    31
\isamarkuptrue%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    32
%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    33
\begin{isamarkuptext}%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    34
Syntax annotations may be included wherever constants are declared
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    35
  directly or indirectly, including \isacommand{consts},
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    36
  \isacommand{constdefs}, or \isacommand{datatype} (for the
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    37
  constructor operations).  Type-constructors may be annotated as
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    38
  well, although this is less frequently encountered in practice
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    39
  (\isa{{\isacharasterisk}} and \isa{{\isacharplus}} types may come to mind).
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    40
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
    41
  Infix declarations\index{infix annotations} provide a useful special
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
    42
  case of mixfixes, where users need not care about the full details
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
    43
  of priorities, nesting, spacing, etc.  The following example of the
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
    44
  exclusive-or operation on boolean values illustrates typical infix
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    45
  declarations arising in practice.%
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    46
\end{isamarkuptext}%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    47
\isamarkuptrue%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    48
\isacommand{constdefs}\isanewline
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    49
\ \ xor\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}bool\ {\isasymRightarrow}\ bool\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isacharbrackleft}{\isacharplus}{\isacharbrackright}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isanewline
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    50
\ \ {\isachardoublequote}A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B\ {\isasymequiv}\ {\isacharparenleft}A\ {\isasymand}\ {\isasymnot}\ B{\isacharparenright}\ {\isasymor}\ {\isacharparenleft}{\isasymnot}\ A\ {\isasymand}\ B{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    51
%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    52
\begin{isamarkuptext}%
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    53
\noindent Now \isa{xor\ A\ B} and \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B} refer to the
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    54
  same expression internally.  Any curried function with at least two
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    55
  arguments may be associated with infix syntax.  For partial
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    56
  applications with less than two operands there is a special notation
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    57
  with \isa{op} prefix: \isa{xor} without arguments is represented
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    58
  as \isa{op\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}}; together with plain prefix application this
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    59
  turns \isa{xor\ A} into \isa{op\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ A}.
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    60
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    61
  \medskip The string \isa{{\isachardoublequote}{\isacharbrackleft}{\isacharplus}{\isacharbrackright}{\isachardoublequote}} in the above annotation
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    62
  refers to the bit of concrete syntax to represent the operator,
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    63
  while the number \isa{{\isadigit{6}}{\isadigit{0}}} determines the precedence of the
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    64
  construct (i.e.\ the syntactic priorities of the arguments and
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    65
  result).
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    66
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    67
  As it happens, Isabelle/HOL already spends many popular combinations
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    68
  of ASCII symbols for its own use, including both \isa{{\isacharplus}} and
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    69
  \isa{{\isacharplus}{\isacharplus}}.  Slightly more awkward combinations like the present
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    70
  \isa{{\isacharbrackleft}{\isacharplus}{\isacharbrackright}} tend to be available for user extensions.  The current
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    71
  arrangement of inner syntax may be inspected via
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    72
  \commdx{print\protect\_syntax}, albeit its output is enormous.
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    73
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    74
  Operator precedence also needs some special considerations.  The
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    75
  admissible range is 0--1000.  Very low or high priorities are
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    76
  basically reserved for the meta-logic.  Syntax of Isabelle/HOL
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    77
  mainly uses the range of 10--100: the equality infix \isa{{\isacharequal}} is
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    78
  centered at 50, logical connectives (like \isa{{\isasymor}} and \isa{{\isasymand}}) are below 50, and algebraic ones (like \isa{{\isacharplus}} and \isa{{\isacharasterisk}}) above 50.  User syntax should strive to coexist with common
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    79
  HOL forms, or use the mostly unused range 100--900.
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    80
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
    81
  The keyword \isakeyword{infixl} specifies an operator that is nested
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
    82
  to the \emph{left}: in iterated applications the more complex
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
    83
  expression appears on the left-hand side: \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C}
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
    84
  stands for \isa{{\isacharparenleft}A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B{\isacharparenright}\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C}.  Similarly,
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    85
  \isakeyword{infixr} specifies to nesting to the \emph{right},
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    86
  reading \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C} as \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ {\isacharparenleft}B\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C{\isacharparenright}}.  In
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    87
  contrast, a \emph{non-oriented} declaration via \isakeyword{infix}
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    88
  would have rendered \isa{A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ B\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}\ C} illegal, but demand
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
    89
  explicit parentheses about the intended grouping.%
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    90
\end{isamarkuptext}%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    91
\isamarkuptrue%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
    92
%
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
    93
\isamarkupsubsection{Mathematical Symbols \label{sec:syntax-symbols}%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
    94
}
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
    95
\isamarkuptrue%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
    96
%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
    97
\begin{isamarkuptext}%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
    98
Concrete syntax based on plain ASCII characters has its inherent
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
    99
  limitations.  Rich mathematical notation demands a larger repertoire
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   100
  of symbols.  Several standards of extended character sets have been
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   101
  proposed over decades, but none has become universally available so
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   102
  far.  Isabelle supports a generic notion of \bfindex{symbols} as the
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   103
  smallest entities of source text, without referring to internal
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   104
  encodings.  There are three kinds of such ``generalized
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   105
  characters'':
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   106
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   107
  \begin{enumerate}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   108
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   109
  \item 7-bit ASCII characters
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   110
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   111
  \item named symbols: \verb,\,\verb,<,$ident$\verb,>,
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   112
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   113
  \item named control symbols: \verb,\,\verb,<^,$ident$\verb,>,
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   114
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   115
  \end{enumerate}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   116
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   117
  Here $ident$ may be any identifier according to the usual Isabelle
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   118
  conventions.  This results in an infinite store of symbols, whose
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   119
  interpretation is left to further front-end tools.  For example,
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   120
  both by the user-interface of Proof~General + X-Symbol and the
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   121
  Isabelle document processor (see \S\ref{sec:document-preparation})
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   122
  display the \verb,\,\verb,<forall>, symbol really as \isa{{\isasymforall}}.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   123
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   124
  A list of standard Isabelle symbols is given in
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   125
  \cite[appendix~A]{isabelle-sys}.  Users may introduce their own
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   126
  interpretation of further symbols by configuring the appropriate
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   127
  front-end tool accordingly, e.g.\ by defining certain {\LaTeX}
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   128
  macros (see also \S\ref{sec:doc-prep-symbols}).  There are also a
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   129
  few predefined control symbols, such as \verb,\,\verb,<^sub>, and
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   130
  \verb,\,\verb,<^sup>, for sub- and superscript of the subsequent
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   131
  (printable) symbol, respectively.  For example, \verb,A\<^sup>\<star>, is
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   132
  shown as \isa{A\isactrlsup {\isasymstar}}.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   133
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   134
  \medskip The following version of our \isa{xor} definition uses a
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   135
  standard Isabelle symbol to achieve typographically pleasing output.%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   136
\end{isamarkuptext}%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   137
\isamarkuptrue%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   138
\isamarkupfalse%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   139
\isamarkupfalse%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   140
\isacommand{constdefs}\isanewline
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   141
\ \ xor\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}bool\ {\isasymRightarrow}\ bool\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymoplus}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isanewline
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   142
\ \ {\isachardoublequote}A\ {\isasymoplus}\ B\ {\isasymequiv}\ {\isacharparenleft}A\ {\isasymand}\ {\isasymnot}\ B{\isacharparenright}\ {\isasymor}\ {\isacharparenleft}{\isasymnot}\ A\ {\isasymand}\ B{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   143
\isamarkupfalse%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   144
%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   145
\begin{isamarkuptext}%
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   146
\noindent The X-Symbol package within Proof~General provides several
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   147
  input methods to enter \isa{{\isasymoplus}} in the text.  If all fails one may
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   148
  just type \verb,\,\verb,<oplus>, by hand; the display will be
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   149
  adapted immediately after continuing input.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   150
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   151
  \medskip A slightly more refined scheme is to provide alternative
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   152
  syntax via the \bfindex{print mode} concept of Isabelle (see also
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   153
  \cite{isabelle-ref}).  By convention, the mode of ``$xsymbols$'' is
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   154
  enabled whenever Proof~General's X-Symbol mode (or {\LaTeX} output)
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   155
  is active.  Consider the following hybrid declaration of \isa{xor}.%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   156
\end{isamarkuptext}%
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
   157
\isamarkuptrue%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
   158
\isamarkupfalse%
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
   159
\isamarkupfalse%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   160
\isacommand{constdefs}\isanewline
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   161
\ \ xor\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}bool\ {\isasymRightarrow}\ bool\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isacharbrackleft}{\isacharplus}{\isacharbrackright}{\isasymignore}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isanewline
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   162
\ \ {\isachardoublequote}A\ {\isacharbrackleft}{\isacharplus}{\isacharbrackright}{\isasymignore}\ B\ {\isasymequiv}\ {\isacharparenleft}A\ {\isasymand}\ {\isasymnot}\ B{\isacharparenright}\ {\isasymor}\ {\isacharparenleft}{\isasymnot}\ A\ {\isasymand}\ B{\isacharparenright}{\isachardoublequote}\isanewline
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   163
\isanewline
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
   164
\isamarkupfalse%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   165
\isacommand{syntax}\ {\isacharparenleft}xsymbols{\isacharparenright}\isanewline
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   166
\ \ xor\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}bool\ {\isasymRightarrow}\ bool\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymoplus}{\isasymignore}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isamarkupfalse%
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
   167
\isamarkupfalse%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   168
%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   169
\begin{isamarkuptext}%
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   170
The \commdx{syntax} command introduced here acts like
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   171
  \isakeyword{consts}, but without declaring a logical constant; an
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   172
  optional print mode specification may be given, too.  Note that the
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   173
  type declaration given here merely serves for syntactic purposes,
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   174
  and is not checked for consistency with the real constant.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   175
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   176
  \medskip We may now write either \isa{{\isacharbrackleft}{\isacharplus}{\isacharbrackright}} or \isa{{\isasymoplus}} in
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   177
  input, while output uses the nicer syntax of $xsymbols$, provided
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   178
  that print mode is presently active.  Such an arrangement is
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   179
  particularly useful for interactive development, where users may
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   180
  type plain ASCII text, but gain improved visual feedback from the
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   181
  system (say in current goal output).
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   182
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   183
  \begin{warn}
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   184
  Alternative syntax declarations are apt to result in varying
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   185
  occurrences of concrete syntax in the input sources.  Isabelle
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   186
  provides no systematic way to convert alternative syntax expressions
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   187
  back and forth; print modes only affect situations where formal
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   188
  entities are pretty printed by the Isabelle process (e.g.\ output of
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   189
  terms and types), but not the original theory text.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   190
  \end{warn}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   191
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   192
  \medskip The following variant makes the alternative \isa{{\isasymoplus}}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   193
  notation only available for output.  Thus we may enforce input
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   194
  sources to refer to plain ASCII only, but effectively disable
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   195
  cut-and-paste from output as well.%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   196
\end{isamarkuptext}%
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
   197
\isamarkuptrue%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   198
\isacommand{syntax}\ {\isacharparenleft}xsymbols\ \isakeyword{output}{\isacharparenright}\isanewline
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   199
\ \ xor\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}bool\ {\isasymRightarrow}\ bool\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymoplus}{\isasymignore}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isamarkupfalse%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   200
%
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   201
\isamarkupsubsection{Prefix Annotations%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   202
}
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
   203
\isamarkuptrue%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   204
%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   205
\begin{isamarkuptext}%
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   206
Prefix syntax annotations\index{prefix annotation} are just another
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   207
  degenerate form of general mixfixes \cite{isabelle-ref}, without any
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   208
  template arguments or priorities --- just some bits of literal
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   209
  syntax.  The following example illustrates this idea idea by
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   210
  associating common symbols with the constructors of a datatype.%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   211
\end{isamarkuptext}%
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
   212
\isamarkuptrue%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   213
\isacommand{datatype}\ currency\ {\isacharequal}\isanewline
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   214
\ \ \ \ Euro\ nat\ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isasymeuro}{\isachardoublequote}{\isacharparenright}\isanewline
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   215
\ \ {\isacharbar}\ Pounds\ nat\ \ {\isacharparenleft}{\isachardoublequote}{\isasympounds}{\isachardoublequote}{\isacharparenright}\isanewline
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   216
\ \ {\isacharbar}\ Yen\ nat\ \ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isasymyen}{\isachardoublequote}{\isacharparenright}\isanewline
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   217
\ \ {\isacharbar}\ Dollar\ nat\ \ {\isacharparenleft}{\isachardoublequote}{\isachardollar}{\isachardoublequote}{\isacharparenright}\isamarkupfalse%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   218
%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   219
\begin{isamarkuptext}%
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   220
\noindent Here the mixfix annotations on the rightmost column happen
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   221
  to consist of a single Isabelle symbol each: \verb,\,\verb,<euro>,,
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   222
  \verb,\,\verb,<pounds>,, \verb,\,\verb,<yen>,, and \verb,$,.  Recall
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   223
  that a constructor like \isa{Euro} actually is a function \isa{nat\ {\isasymRightarrow}\ currency}.  An expression like \isa{Euro\ {\isadigit{1}}{\isadigit{0}}} will be
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   224
  printed as \isa{{\isasymeuro}\ {\isadigit{1}}{\isadigit{0}}}; only the head of the application is
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   225
  subject to our concrete syntax.  This simple form already achieves
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   226
  conformance with notational standards of the European Commission.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   227
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   228
  Prefix syntax also works for plain \isakeyword{consts} or
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   229
  \isakeyword{constdefs}, of course.%
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   230
\end{isamarkuptext}%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   231
\isamarkuptrue%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   232
%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   233
\isamarkupsubsection{Syntax Translations \label{sec:syntax-translations}%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   234
}
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
   235
\isamarkuptrue%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   236
%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   237
\begin{isamarkuptext}%
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   238
Mixfix syntax annotations work well for those situations where a
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   239
  particular constant application forms need to be decorated by
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   240
  concrete syntax; just reconsider \isa{xor\ A\ B} versus \isa{A\ {\isasymoplus}\ B} covered before.  Occasionally, the relationship between some
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   241
  piece of notation and its internal form is slightly more involved.
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   242
  Here the concept of \bfindex{syntax translations} enters the scene.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   243
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   244
  Using the raw \isakeyword{syntax}\index{syntax (command)} command we
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   245
  may introduce uninterpreted notational elements, while
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   246
  \commdx{translations} relates the input forms with more complex
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   247
  logical expressions.  This essentially provides a simple mechanism
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   248
  for for syntactic macros; even heavier transformations may be
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   249
  written in ML \cite{isabelle-ref}.
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   250
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   251
  \medskip A typical example of syntax translations is to decorate
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   252
  relational expressions with nice symbolic notation, such as \isa{{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isasymin}\ sim} versus \isa{x\ {\isasymapprox}\ y}.%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   253
\end{isamarkuptext}%
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
   254
\isamarkuptrue%
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   255
\isacommand{consts}\isanewline
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   256
\ \ sim\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}{\isacharprime}a\ {\isasymtimes}\ {\isacharprime}a{\isacharparenright}\ set{\isachardoublequote}\isanewline
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   257
\isanewline
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   258
\isamarkupfalse%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   259
\isacommand{syntax}\isanewline
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   260
\ \ {\isachardoublequote}{\isacharunderscore}sim{\isachardoublequote}\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infix}\ {\isachardoublequote}{\isasymapprox}{\isachardoublequote}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\isanewline
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   261
\isamarkupfalse%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   262
\isacommand{translations}\isanewline
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   263
\ \ {\isachardoublequote}x\ {\isasymapprox}\ y{\isachardoublequote}\ {\isasymrightleftharpoons}\ {\isachardoublequote}{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isasymin}\ sim{\isachardoublequote}\isamarkupfalse%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   264
%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   265
\begin{isamarkuptext}%
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   266
\noindent Here the name of the dummy constant \isa{{\isacharunderscore}sim} does
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   267
  not really matter, as long as it is not used elsewhere.  Prefixing
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   268
  an underscore is a common convention.  The \isakeyword{translations}
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   269
  declaration already uses concrete syntax on the left-hand side;
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   270
  internally we relate a raw application \isa{{\isacharunderscore}sim\ x\ y} with
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   271
  \isa{{\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isasymin}\ sim}.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   272
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   273
  \medskip Another common application of syntax translations is to
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   274
  provide variant versions of fundamental relational expressions, such
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   275
  as \isa{{\isasymnoteq}} for negated equalities.  The following declaration
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   276
  stems from Isabelle/HOL itself:%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   277
\end{isamarkuptext}%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   278
\isamarkuptrue%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   279
\isacommand{syntax}\ {\isachardoublequote}{\isacharunderscore}not{\isacharunderscore}equal{\isachardoublequote}\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymnoteq}{\isasymignore}{\isachardoublequote}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\isanewline
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   280
\isamarkupfalse%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   281
\isacommand{translations}\ {\isachardoublequote}x\ {\isasymnoteq}{\isasymignore}\ y{\isachardoublequote}\ {\isasymrightleftharpoons}\ {\isachardoublequote}{\isasymnot}\ {\isacharparenleft}x\ {\isacharequal}\ y{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   282
%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   283
\begin{isamarkuptext}%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   284
\noindent Normally one would introduce derived concepts like this
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   285
  within the logic, using \isakeyword{consts} + \isakeyword{defs}
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   286
  instead of \isakeyword{syntax} + \isakeyword{translations}.  The
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   287
  present formulation has the virtue that expressions are immediately
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   288
  replaced by the ``definition'' upon parsing; the effect is reversed
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   289
  upon printing.
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   290
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   291
  Simulating definitions via translations is adequate for very basic
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   292
  principles, where a new representation is a trivial variation on an
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   293
  existing one.  On the other hand, syntax translations do not scale
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   294
  up well to large hierarchies of concepts built on each other.%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   295
\end{isamarkuptext}%
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
   296
\isamarkuptrue%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   297
%
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   298
\isamarkupsection{Document Preparation \label{sec:document-preparation}%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   299
}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   300
\isamarkuptrue%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   301
%
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   302
\begin{isamarkuptext}%
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   303
Isabelle/Isar is centered around the concept of \bfindex{formal
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   304
  proof documents}\index{documents|bold}.  The ultimate result of a
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   305
  formal development effort is meant to be a human-readable record,
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   306
  presented as browsable PDF file or printed on paper.  The overall
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   307
  document structure follows traditional mathematical articles, with
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   308
  sections, intermediate explanations, definitions, theorems and
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   309
  proofs.
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   310
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   311
  The Isar proof language \cite{Wenzel-PhD}, which is not covered in
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   312
  this book, admits to write formal proof texts that are acceptable
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   313
  both to the machine and human readers at the same time.  Thus
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   314
  marginal comments and explanations may be kept at a minimum.  Even
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   315
  without proper coverage of human-readable proofs, Isabelle document
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   316
  is very useful to produce formally derived texts.  Unstructured
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   317
  proof scripts given here may be just ignored by readers, or
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   318
  intentionally suppressed from the text by the writer (see also
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   319
  \S\ref{sec:doc-prep-suppress}).
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   320
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   321
  \medskip The Isabelle document preparation system essentially acts
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   322
  like a formal front-end to {\LaTeX}.  After checking specifications
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   323
  and proofs, the theory sources are turned into typesetting
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   324
  instructions in a well-defined manner.  This enables users to write
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   325
  authentic reports on formal developments with little effort, most
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   326
  tedious consistency checks are handled by the system.%
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   327
\end{isamarkuptext}%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   328
\isamarkuptrue%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   329
%
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   330
\isamarkupsubsection{Isabelle Sessions%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   331
}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   332
\isamarkuptrue%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   333
%
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   334
\begin{isamarkuptext}%
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   335
In contrast to the highly interactive mode of Isabelle/Isar theory
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   336
  development, the document preparation stage essentially works in
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   337
  batch-mode.  An Isabelle \bfindex{session} essentially consists of a
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   338
  collection of theory source files that contribute to a single output
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   339
  document eventually.  Session is derived from a single parent each
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   340
  (usually an object-logic image like \texttt{HOL}), resulting in an
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   341
  overall tree structure that is reflected in the output location
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   342
  within the file system (usually rooted at
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   343
  \verb,~/isabelle/browser_info,).
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   344
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   345
  Here is the canonical arrangement of sources of a session called
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   346
  \texttt{MySession}:
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   347
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   348
  \begin{itemize}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   349
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   350
  \item Directory \texttt{MySession} contains the required theory
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   351
  files $T@1$\texttt{.thy}, \dots, $T@n$\texttt{.thy}.
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   352
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   353
  \item File \texttt{MySession/ROOT.ML} holds appropriate ML commands
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   354
  for loading all wanted theories, usually just
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   355
  ``\texttt{use_thy"$T@i$";}'' for any $T@i$ in leaf position of the
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   356
  theory dependency graph.
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   357
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   358
  \item Directory \texttt{MySession/document} contains everything
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   359
  required for the {\LaTeX} stage; only \texttt{root.tex} needs to be
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   360
  provided initially.
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   361
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   362
  The latter file holds appropriate {\LaTeX} code to commence a
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   363
  document (\verb,\documentclass, etc.), and to include the generated
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   364
  files $T@i$\texttt{.tex} for each theory.  The generated
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   365
  \texttt{session.tex} will hold {\LaTeX} commands to include all
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   366
  theory output files in topologically sorted order, so
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   367
  \verb,\input{session}, in \texttt{root.tex} will do it in most
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   368
  situations.
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   369
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   370
  \item \texttt{IsaMakefile} outside of the directory
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   371
  \texttt{MySession} holds appropriate dependencies and invocations of
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   372
  Isabelle tools to control the batch job.  In fact, several sessions
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   373
  may be controlled by the same \texttt{IsaMakefile}.  See also
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   374
  \cite{isabelle-sys} for further details, especially on
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   375
  \texttt{isatool usedir} and \texttt{isatool make}.
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   376
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   377
  \end{itemize}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   378
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   379
  With everything put in its proper place, \texttt{isatool make}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   380
  should be sufficient to process the Isabelle session completely,
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   381
  with the generated document appearing in its proper place.
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   382
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   383
  \medskip In reality, users may want to have \texttt{isatool mkdir}
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   384
  generate an initial working setup without further ado.  For example,
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   385
  an empty session \texttt{MySession} derived from \texttt{HOL} may be
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   386
  produced as follows:
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   387
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   388
\begin{verbatim}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   389
  isatool mkdir HOL MySession
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   390
  isatool make
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   391
\end{verbatim}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   392
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   393
  This processes the session with sensible default options, including
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   394
  verbose mode to tell the user where the ultimate results will
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   395
  appear.  The above dry run should produce should already be able to
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   396
  produce a single page of output (with a dummy title, empty table of
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   397
  contents etc.).  Any failure at that stage is likely to indicate
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   398
  technical problems with the user's {\LaTeX}
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   399
  installation.\footnote{Especially make sure that \texttt{pdflatex}
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   400
  is present; if all fails one may fall back on DVI output by changing
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   401
  \texttt{usedir} options \cite{isabelle-sys}.}
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   402
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   403
  \medskip One may now start to populate the directory
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   404
  \texttt{MySession}, and the file \texttt{MySession/ROOT.ML}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   405
  accordingly.  \texttt{MySession/document/root.tex} should be also
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   406
  adapted at some point; the default version is mostly
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   407
  self-explanatory.  Note that the \verb,\isabellestyle, enables
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   408
  fine-tuning of the general appearance of characters and mathematical
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   409
  symbols (see also \S\ref{sec:doc-prep-symbols}).
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   410
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   411
  Especially note the standard inclusion of {\LaTeX} packages
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   412
  \texttt{isabelle} (mandatory), and \texttt{isabellesym} (required
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   413
  for mathematical symbols), and the final \texttt{pdfsetup} (provides
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   414
  handsome defaults for \texttt{hyperref}, including URL markup).
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   415
  Further {\LaTeX} packages further packages may required in
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   416
  particular applications, e.g.\ for unusual Isabelle symbols.
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   417
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   418
  \medskip Further auxiliary files for the {\LaTeX} stage should be
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   419
  included in the \texttt{MySession/document} directory, e.g.\
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   420
  additional {\TeX} sources or graphics.  In particular, adding
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   421
  \texttt{root.bib} here (with that specific name) causes an automatic
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   422
  run of \texttt{bibtex} to process a bibliographic database; see for
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   423
  further commodities \texttt{isatool document} covered in
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   424
  \cite{isabelle-sys}.
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   425
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   426
  \medskip Any failure of the document preparation phase in an
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   427
  Isabelle batch session leaves the generated sources in there target
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   428
  location (as pointed out by the accompanied error message).  In case
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   429
  of {\LaTeX} errors, users may trace error messages at the file
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   430
  position of the generated text.%
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   431
\end{isamarkuptext}%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   432
\isamarkuptrue%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   433
%
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   434
\isamarkupsubsection{Structure Markup%
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   435
}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   436
\isamarkuptrue%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   437
%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   438
\begin{isamarkuptext}%
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   439
The large-scale structure of Isabelle documents follows existing
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   440
  {\LaTeX} conventions, with chapters, sections, subsubsections etc.
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   441
  The Isar language includes separate \bfindex{markup commands}, which
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   442
  do not effect the formal content of a theory (or proof), but result
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   443
  in corresponding {\LaTeX} elements.
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   444
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   445
  There are separate markup commands depending on the textual context:
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   446
  in header position (just before \isakeyword{theory}), within the
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   447
  theory body, or within a proof.  The header needs to be treated
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   448
  specially here, since ordinary theory and proof commands may only
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   449
  occur \emph{after} the initial \isakeyword{theory} specification.
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   450
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   451
  \medskip
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   452
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   453
  \begin{tabular}{llll}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   454
  header & theory & proof & default meaning \\\hline
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   455
    & \commdx{chapter} & & \verb,\chapter, \\
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   456
  \commdx{header} & \commdx{section} & \commdx{sect} & \verb,\section, \\
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   457
    & \commdx{subsection} & \commdx{subsect} & \verb,\subsection, \\
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   458
    & \commdx{subsubsection} & \commdx{subsubsect} & \verb,\subsubsection, \\
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   459
  \end{tabular}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   460
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   461
  \medskip
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   462
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   463
  From the Isabelle perspective, each markup command takes a single
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   464
  $text$ argument (delimited by \verb,",\dots\verb,", or
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   465
  \verb,{,\verb,*,~\dots~\verb,*,\verb,},).  After stripping any
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   466
  surrounding white space, the argument is passed to a {\LaTeX} macro
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   467
  \verb,\isamarkupXYZ, for any command \isakeyword{XYZ}.  These macros
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   468
  are defined in \verb,isabelle.sty, according to the meaning given in
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   469
  the rightmost column above.
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   470
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   471
  \medskip The following source fragment illustrates structure markup
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   472
  of a theory.  Note that {\LaTeX} labels may be included inside of
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   473
  section headings as well.
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   474
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   475
  \begin{ttbox}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   476
  header {\ttlbrace}* Some properties of Foo Bar elements *{\ttrbrace}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   477
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   478
  theory Foo_Bar = Main:
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   479
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   480
  subsection {\ttlbrace}* Basic definitions *{\ttrbrace}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   481
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   482
  consts
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   483
    foo :: \dots
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   484
    bar :: \dots
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   485
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   486
  defs \dots
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   487
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   488
  subsection {\ttlbrace}* Derived rules *{\ttrbrace}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   489
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   490
  lemma fooI: \dots
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   491
  lemma fooE: \dots
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   492
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   493
  subsection {\ttlbrace}* Main theorem {\ttback}label{\ttlbrace}sec:main-theorem{\ttrbrace} *{\ttrbrace}
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   494
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   495
  theorem main: \dots
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   496
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   497
  end
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   498
  \end{ttbox}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   499
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   500
  Users may occasionally want to change the meaning of markup
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   501
  commands, say via \verb,\renewcommand, in \texttt{root.tex};
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   502
  \verb,\isamarkupheader, is a good candidate for some adaption, e.g.\
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   503
  moving it up in the hierarchy to become \verb,\chapter,.
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   504
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   505
\begin{verbatim}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   506
  \renewcommand{\isamarkupheader}[1]{\chapter{#1}}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   507
\end{verbatim}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   508
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   509
  \noindent Certainly, this requires to change the default
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   510
  \verb,\documentclass{article}, in \texttt{root.tex} to something
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   511
  that supports the notion of chapters in the first place, e.g.\
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   512
  \verb,\documentclass{report},.
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   513
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   514
  \medskip The {\LaTeX} macro \verb,\isabellecontext, is maintained to
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   515
  hold the name of the current theory context.  This is particularly
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   516
  useful for document headings:
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   517
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   518
\begin{verbatim}
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   519
  \renewcommand{\isamarkupheader}[1]
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   520
  {\chapter{#1}\markright{THEORY~\isabellecontext}}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   521
\end{verbatim}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   522
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   523
  \noindent Make sure to include something like
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   524
  \verb,\pagestyle{headings}, in \texttt{root.tex}; the document
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   525
  should have more than 2 pages to show the effect.%
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   526
\end{isamarkuptext}%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   527
\isamarkuptrue%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   528
%
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   529
\isamarkupsubsection{Formal Comments and Antiquotations%
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   530
}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   531
\isamarkuptrue%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   532
%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   533
\begin{isamarkuptext}%
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   534
Isabelle source comments, which are of the form
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   535
  \verb,(,\verb,*,~\dots~\verb,*,\verb,),, essentially act like white
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   536
  space and do not really contribute to the content.  They mainly
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   537
  serve technical purposes to mark certain oddities in the raw input
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   538
  text.  In contrast, \bfindex{formal comments} are portions of text
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   539
  that are associated with formal Isabelle/Isar commands
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   540
  (\bfindex{marginal comments}), or as stanalone paragraphs within a
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   541
  theory or proof context (\bfindex{text blocks}).
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   542
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   543
  \medskip Marginal comments are part of each command's concrete
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   544
  syntax \cite{isabelle-ref}; the common form is ``\verb,--,~text''
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   545
  where $text$ is delimited by \verb,",\dots\verb,", or
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   546
  \verb,{,\verb,*,~\dots~\verb,*,\verb,}, as usual.  Multiple marginal
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   547
  comments may be given at the same time.  Here is a simple example:%
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   548
\end{isamarkuptext}%
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   549
\isamarkuptrue%
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   550
\isacommand{lemma}\ {\isachardoublequote}A\ {\isacharminus}{\isacharminus}{\isachargreater}\ A{\isachardoublequote}\isanewline
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   551
\ \ %
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   552
\isamarkupcmt{a triviality of propositional logic%
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   553
}
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   554
\isanewline
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   555
\ \ %
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   556
\isamarkupcmt{(should not really bother)%
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   557
}
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   558
\isanewline
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   559
\ \ \isamarkupfalse%
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   560
\isacommand{by}\ {\isacharparenleft}rule\ impI{\isacharparenright}\ %
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   561
\isamarkupcmt{implicit assumption step involved here%
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   562
}
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   563
\isamarkupfalse%
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   564
%
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   565
\begin{isamarkuptext}%
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   566
\noindent The above output has been produced as follows:
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   567
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   568
\begin{verbatim}
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   569
  lemma "A --> A"
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   570
    -- "a triviality of propositional logic"
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   571
    -- "(should not really bother)"
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   572
    by (rule impI) -- "implicit assumption step involved here"
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   573
\end{verbatim}
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   574
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   575
  From the {\LaTeX} view, ``\verb,--,'' acts like a markup command,
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   576
  the corresponding macro is \verb,\isamarkupcmt, (with a single
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   577
  argument).
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   578
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   579
  \medskip Text blocks are introduced by the commands \bfindex{text}
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   580
  and \bfindex{txt}, for theory and proof contexts, respectively.
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   581
  Each takes again a single $text$ argument, which is interpreted as a
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   582
  free-form paragraph in {\LaTeX} (surrounded by some additional
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   583
  vertical space).  The exact behavior may be changed by redefining
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   584
  the {\LaTeX} environments of \verb,isamarkuptext, or
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   585
  \verb,isamarkuptxt,, respectively.  The text style of the body is
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   586
  determined by the \verb,\isastyletext, and \verb,\isastyletxt,
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   587
  macros; the default uses a smaller font within proofs.
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   588
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   589
  \medskip The $text$ part of each of the various markup commands
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   590
  considered so far essentially inserts quoted material within a
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   591
  formal text, mainly for instruction of the reader (arbitrary
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   592
  {\LaTeX} macros may be also included).  An \bfindex{antiquotation}
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   593
  is again a formal object that has been embedded into such an
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   594
  informal portion.  The interpretation of antiquotations is limited
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   595
  to some well-formedness checks, with the result being pretty printed
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   596
  to the resulting document.  So quoted text blocks together with
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   597
  antiquotations provide very handsome means to reference formal
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   598
  entities with good confidence in technical details (especially
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   599
  syntax and types).
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   600
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   601
  The general syntax of antiquotations is as follows:
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   602
  \texttt{{\at}{\ttlbrace}$name$ $arguments${\ttrbrace}}, or
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   603
  \texttt{{\at}{\ttlbrace}$name$ [$options$] $arguments${\ttrbrace}}
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   604
  for a comma-separated list of options consisting of a $name$ or
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   605
  \texttt{$name$=$value$} pair \cite{isabelle-isar-ref}.  The syntax
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   606
  of $arguments$ depends on the kind of antiquotation, it generally
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   607
  follows the same conventions for types, terms, or theorems as in the
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   608
  formal part of a theory.
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   609
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   610
  \medskip Here is an example of the quotation-antiquotation
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   611
  technique: \isa{{\isasymlambda}x\ y{\isachardot}\ x} is a well-typed term.
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   612
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   613
  \medskip\noindent The above output has been produced as follows:
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   614
  \begin{ttbox}
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   615
text {\ttlbrace}*
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   616
  Here is an example of the quotation-antiquotation technique:
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   617
  {\at}{\ttlbrace}term "%x y. x"{\ttrbrace} is a well-typed term.
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   618
*{\ttrbrace}
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   619
  \end{ttbox}
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   620
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   621
  From the notational change of the ASCII character \verb,%, to the
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   622
  symbol \isa{{\isasymlambda}} we see that the term really got printed by the
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   623
  system (after parsing and type-checking), document preparation
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   624
  enables symbolic output by default.
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   625
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   626
  \medskip The next example includes an option to modify the
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   627
  \verb,show_types, flag of Isabelle:
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   628
  \texttt{{\at}}\verb,{term [show_types] "%x y. x"}, produces \isa{{\isasymlambda}{\isacharparenleft}x{\isasymColon}{\isacharprime}a{\isacharparenright}\ y{\isasymColon}{\isacharprime}b{\isachardot}\ x}.  Here type-inference has figured out the
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   629
  most general typings in the present (theory) context.  Note that
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   630
  term fragments may acquire a different typings due to constraints
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   631
  imposed by previous text (within a proof), say by the main goal
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   632
  statement given before hand.
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   633
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   634
  \medskip Several further kinds of antiquotations (and options) are
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   635
  available \cite{isabelle-sys}.  Here are a few commonly used
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   636
  combinations are as follows:
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   637
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   638
  \medskip
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   639
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   640
  \begin{tabular}{ll}
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   641
  \texttt{\at}\verb,{typ,~$\tau$\verb,}, & print type $\tau$ \\
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   642
  \texttt{\at}\verb,{term,~$t$\verb,}, & print term $t$ \\
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   643
  \texttt{\at}\verb,{prop,~$\phi$\verb,}, & print proposition $\phi$ \\
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   644
  \texttt{\at}\verb,{prop [display],~$\phi$\verb,}, & print large proposition $\phi$ (with linebreaks) \\
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   645
  \texttt{\at}\verb,{prop [source],~$\phi$\verb,}, & check proposition $\phi$, print its input \\
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   646
  \texttt{\at}\verb,{thm,~$a$\verb,}, & print fact $a$ \\
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   647
  \texttt{\at}\verb,{thm,~$a$~\verb,[no_vars]}, & print fact $a$, fixing schematic variables \\
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   648
  \texttt{\at}\verb,{thm [source],~$a$\verb,}, & check validity of fact $a$, print its name \\
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   649
  \texttt{\at}\verb,{text,~$s$\verb,}, & print uninterpreted text $s$ \\
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   650
  \end{tabular}
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   651
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   652
  \medskip
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   653
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   654
  Note that \attrdx{no_vars} given above is \emph{not} an
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   655
  antiquotation option, but an attribute of the theorem argument given
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   656
  here.  This might be useful with a diagnostic command like
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   657
  \isakeyword{thm}, too.
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   658
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   659
  \medskip The \texttt{\at}\verb,{text, $s$\verb,}, antiquotation is
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   660
  particularly interesting.  Embedding uninterpreted text within an
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   661
  informal body might appear useless at first sight.  Here the key
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   662
  virtue is that the string $s$ is processed as Isabelle output,
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   663
  interpreting Isabelle symbols appropriately.
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   664
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   665
  For example, \texttt{\at}\verb,{text "\<forall>\<exists>"}, produces \isa{{\isasymforall}{\isasymexists}}, according to the standard interpretation of these symbol
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   666
  (cf.\ \S\ref{sec:doc-prep-symbols}).  Thus we achieve consistent
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   667
  mathematical notation in both the formal and informal parts of the
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   668
  document very easily.  Manual {\LaTeX} code would leave more control
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   669
  over the type-setting, but is also slightly more tedious.%
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   670
\end{isamarkuptext}%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   671
\isamarkuptrue%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   672
%
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   673
\isamarkupsubsection{Interpretation of symbols \label{sec:doc-prep-symbols}%
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   674
}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   675
\isamarkuptrue%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   676
%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   677
\begin{isamarkuptext}%
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   678
As has been pointed out before (\S\ref{sec:syntax-symbols}),
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   679
  Isabelle symbols are the the smallest syntactic entities, a
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   680
  straight-forward generalization of ASCII characters.  While Isabelle
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   681
  does not impose any interpretation of the infinite collection of
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   682
  symbols, the {\LaTeX} document output produces the canonical output
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   683
  for certain standard symbols \cite[appendix~A]{isabelle-sys}.
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   684
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   685
  The {\LaTeX} code produced from Isabelle text follows a relatively
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   686
  simple scheme (see below).  Users may wish to tune the final
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   687
  appearance by redefining certain macros, say in \texttt{root.tex} of
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   688
  the document.
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   689
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   690
  \begin{enumerate} \item 7-bit ASCII characters: letters
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   691
  \texttt{A\dots Z} and \texttt{a\dots z} are output verbatim, digits
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   692
  are passed as an argument to the \verb,\isadigit, macro, other
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   693
  characters are replaced by specifically named macros of the form
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   694
  \verb,\isacharXYZ,.
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   695
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   696
  \item Named symbols: \verb,\,\verb,<,$XYZ$\verb,>, become
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   697
  \verb,{\isasym,$XYZ$\verb,}, each (note the additional braces).  See
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   698
  \cite[appendix~A]{isabelle-sys} and \texttt{isabellesym.sty} for the
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   699
  collection of predefined standard symbols.
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   700
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   701
  \item Named control symbols: \verb,\,\verb,<^,$XYZ$\verb,>, become
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   702
  \verb,\isactrl,$XYZ$; subsequent symbols may act as arguments, if
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   703
  the corresponding macro is defined accordingly.
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   704
  \end{enumerate}
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   705
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   706
  Users may occasionally wish to invent new named symbols; this merely
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   707
  requires an appropriate definition of \verb,\,\verb,<,$XYZ$\verb,>,
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   708
  as far as {\LaTeX} output is concerned.  Control symbols are
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   709
  slightly more difficult to get right, though.
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   710
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   711
  \medskip The \verb,\isabellestyle, macro provides a high-level
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   712
  interface to tune the general appearance of individual symbols.  For
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   713
  example, \verb,\isabellestyle{it}, uses italics fonts to mimic the
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   714
  general appearance of the {\LaTeX} math mode; double quotes are not
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   715
  printed at all.  The resulting quality of type-setting is quite
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   716
  good, so this should probably be the default style for real
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   717
  production work that gets distributed to a broader audience.%
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   718
\end{isamarkuptext}%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   719
\isamarkuptrue%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   720
%
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   721
\isamarkupsubsection{Suppressing Output \label{sec:doc-prep-suppress}%
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   722
}
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   723
\isamarkuptrue%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   724
%
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   725
\begin{isamarkuptext}%
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   726
By default Isabelle's document system generates a {\LaTeX} source
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   727
  file for each theory that happens to get loaded during the session.
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   728
  The generated \texttt{session.tex} will include all of these in
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   729
  order of appearance, which in turn gets included by the standard
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   730
  \texttt{root.tex}.  Certainly one may change the order of appearance
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   731
  or suppress unwanted theories by ignoring \texttt{session.tex} and
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   732
  include individual files in \texttt{root.tex} by hand.  On the other
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   733
  hand, such an arrangement requires additional maintenance chores
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   734
  whenever the collection of theories changes.
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   735
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   736
  Alternatively, one may tune the theory loading process in
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   737
  \texttt{ROOT.ML} itself: traversal of the theory dependency graph
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   738
  may be fine-tuned by adding further \verb,use_thy, invocations,
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   739
  although topological sorting still has to be observed.  Moreover,
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   740
  the ML operator \verb,no_document, temporarily disables document
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   741
  generation while executing a theory loader command; its usage is
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   742
  like this:
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   743
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   744
\begin{verbatim}
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   745
  no_document use_thy "T";
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   746
\end{verbatim}
12644
a107eeffd557 updated;
wenzelm
parents: 12642
diff changeset
   747
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   748
  \medskip Theory output may be also suppressed in smaller portions as
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   749
  well.  For example, research papers or slides usually do not include
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   750
  the formal content in full.  In order to delimit \bfindex{ignored
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   751
  material} special source comments
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   752
  \verb,(,\verb,*,\verb,<,\verb,*,\verb,), and
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   753
  \verb,(,\verb,*,\verb,>,\verb,*,\verb,), may be included in the
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   754
  text.  Only the document preparation system is affected, the formal
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   755
  checking the theory is performed as before.
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   756
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   757
  In the following example we suppress the slightly formalistic
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   758
  \isakeyword{theory} + \isakeyword{end} surroundings a theory.
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   759
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   760
  \medskip
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   761
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   762
  \begin{tabular}{l}
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   763
  \verb,(,\verb,*,\verb,<,\verb,*,\verb,), \\
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   764
  \texttt{theory T = Main:} \\
12647
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   765
  \verb,(,\verb,*,\verb,>,\verb,*,\verb,), \\
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   766
  ~~$\vdots$ \\
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   767
  \verb,(,\verb,*,\verb,<,\verb,*,\verb,), \\
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   768
  \texttt{end} \\
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   769
  \verb,(,\verb,*,\verb,>,\verb,*,\verb,), \\
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   770
  \end{tabular}
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   771
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   772
  \medskip
001d10bbc61b updated;
wenzelm
parents: 12644
diff changeset
   773
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   774
  Text may be suppressed in a fine grained manner.  For example, we
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   775
  may even drop vital parts of a formal proof, pretending that things
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   776
  have been simpler than in reality.  For example, the following
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   777
  ``fully automatic'' proof is actually a fake:%
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   778
\end{isamarkuptext}%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   779
\isamarkuptrue%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   780
\isacommand{lemma}\ {\isachardoublequote}x\ {\isasymnoteq}\ {\isacharparenleft}{\isadigit{0}}{\isacharcolon}{\isacharcolon}int{\isacharparenright}\ {\isasymLongrightarrow}\ {\isadigit{0}}\ {\isacharless}\ x\ {\isacharasterisk}\ x{\isachardoublequote}\isanewline
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   781
\ \ \isamarkupfalse%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   782
\isacommand{by}\ {\isacharparenleft}auto{\isacharparenright}\isamarkupfalse%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   783
%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   784
\begin{isamarkuptext}%
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   785
\noindent Here the real source of the proof has been as follows:
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   786
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   787
\begin{verbatim}
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   788
  by (auto(*<*)simp add: int_less_le(*>*))
12658
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   789
\end{verbatim}
3939e7dea202 updated;
wenzelm
parents: 12652
diff changeset
   790
%(*
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   791
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   792
  \medskip Ignoring portions of printed does demand some care by the
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   793
  user.  First of all, the writer is responsible not to obfuscate the
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   794
  underlying formal development in an unduly manner.  It is fairly
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   795
  easy to invalidate the remaining visible text, e.g.\ by referencing
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   796
  questionable formal items (strange definitions, arbitrary axioms
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   797
  etc.) that have been hidden from sight beforehand.
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   798
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   799
  Some minor technical subtleties of the
12666
9842befead7a updated;
wenzelm
parents: 12658
diff changeset
   800
  \verb,(,\verb,*,\verb,<,\verb,*,\verb,),~\verb,(,\verb,*,\verb,>,\verb,*,\verb,),
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   801
  elements need to be kept in mind as well, since the system performs
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   802
  little sanity checks here.  Arguments of markup commands and formal
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   803
  comments must not be hidden, otherwise presentation fails.  Open and
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   804
  close parentheses need to be inserted carefully; it is fairly easy
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   805
  to hide the wrong parts, especially after rearranging the sources.
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   806
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   807
  \medskip Authentic reports of formal theories, say as part of a
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   808
  library, usually should refrain from suppressing parts of the text
12649
6e17f2ae9e16 updated;
wenzelm
parents: 12647
diff changeset
   809
  at all.  Other users may need the full information for their own
12652
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   810
  derivative work.  If a particular formalization appears inadequate
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   811
  for general public coverage, it is often more appropriate to think
2d136f05e164 updated;
wenzelm
parents: 12649
diff changeset
   812
  of a better way in the first place.%
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12627
diff changeset
   813
\end{isamarkuptext}%
12627
08eee994bf99 updated;
wenzelm
parents: 11866
diff changeset
   814
\isamarkuptrue%
11866
fbd097aec213 updated;
wenzelm
parents: 11648
diff changeset
   815
\isamarkupfalse%
11648
d78a82d112e4 *** empty log message ***
wenzelm
parents:
diff changeset
   816
\end{isabellebody}%
d78a82d112e4 *** empty log message ***
wenzelm
parents:
diff changeset
   817
%%% Local Variables:
d78a82d112e4 *** empty log message ***
wenzelm
parents:
diff changeset
   818
%%% mode: latex
d78a82d112e4 *** empty log message ***
wenzelm
parents:
diff changeset
   819
%%% TeX-master: "root"
d78a82d112e4 *** empty log message ***
wenzelm
parents:
diff changeset
   820
%%% End: