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