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