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