doc-src/IsarRef/Thy/document/Outer_Syntax.tex
author wenzelm
Mon, 02 Jun 2008 21:19:46 +0200
changeset 27037 33d95687514e
child 27042 8fcf19f2168b
permissions -rw-r--r--
renamed theory "syntax" to "Outer_Syntax";
wenzelm@27037
     1
%
wenzelm@27037
     2
\begin{isabellebody}%
wenzelm@27037
     3
\def\isabellecontext{Outer{\isacharunderscore}Syntax}%
wenzelm@27037
     4
%
wenzelm@27037
     5
\isadelimtheory
wenzelm@27037
     6
\isanewline
wenzelm@27037
     7
\isanewline
wenzelm@27037
     8
%
wenzelm@27037
     9
\endisadelimtheory
wenzelm@27037
    10
%
wenzelm@27037
    11
\isatagtheory
wenzelm@27037
    12
\isacommand{theory}\isamarkupfalse%
wenzelm@27037
    13
\ Outer{\isacharunderscore}Syntax\isanewline
wenzelm@27037
    14
\isakeyword{imports}\ Pure\isanewline
wenzelm@27037
    15
\isakeyword{begin}%
wenzelm@27037
    16
\endisatagtheory
wenzelm@27037
    17
{\isafoldtheory}%
wenzelm@27037
    18
%
wenzelm@27037
    19
\isadelimtheory
wenzelm@27037
    20
%
wenzelm@27037
    21
\endisadelimtheory
wenzelm@27037
    22
%
wenzelm@27037
    23
\isamarkupchapter{Syntax primitives%
wenzelm@27037
    24
}
wenzelm@27037
    25
\isamarkuptrue%
wenzelm@27037
    26
%
wenzelm@27037
    27
\begin{isamarkuptext}%
wenzelm@27037
    28
The rather generic framework of Isabelle/Isar syntax emerges from
wenzelm@27037
    29
  three main syntactic categories: \emph{commands} of the top-level
wenzelm@27037
    30
  Isar engine (covering theory and proof elements), \emph{methods} for
wenzelm@27037
    31
  general goal refinements (analogous to traditional ``tactics''), and
wenzelm@27037
    32
  \emph{attributes} for operations on facts (within a certain
wenzelm@27037
    33
  context).  Subsequently we give a reference of basic syntactic
wenzelm@27037
    34
  entities underlying Isabelle/Isar syntax in a bottom-up manner.
wenzelm@27037
    35
  Concrete theory and proof language elements will be introduced later
wenzelm@27037
    36
  on.
wenzelm@27037
    37
wenzelm@27037
    38
  \medskip In order to get started with writing well-formed
wenzelm@27037
    39
  Isabelle/Isar documents, the most important aspect to be noted is
wenzelm@27037
    40
  the difference of \emph{inner} versus \emph{outer} syntax.  Inner
wenzelm@27037
    41
  syntax is that of Isabelle types and terms of the logic, while outer
wenzelm@27037
    42
  syntax is that of Isabelle/Isar theory sources (specifications and
wenzelm@27037
    43
  proofs).  As a general rule, inner syntax entities may occur only as
wenzelm@27037
    44
  \emph{atomic entities} within outer syntax.  For example, the string
wenzelm@27037
    45
  \verb|"x + y"| and identifier \verb|z| are legal term
wenzelm@27037
    46
  specifications within a theory, while \verb|x + y| without
wenzelm@27037
    47
  quotes is not.
wenzelm@27037
    48
wenzelm@27037
    49
  Printed theory documents usually omit quotes to gain readability
wenzelm@27037
    50
  (this is a matter of {\LaTeX} macro setup, say via \verb|\isabellestyle|, see also \cite{isabelle-sys}).  Experienced
wenzelm@27037
    51
  users of Isabelle/Isar may easily reconstruct the lost technical
wenzelm@27037
    52
  information, while mere readers need not care about quotes at all.
wenzelm@27037
    53
wenzelm@27037
    54
  \medskip Isabelle/Isar input may contain any number of input
wenzelm@27037
    55
  termination characters ``\verb|;|'' (semicolon) to separate
wenzelm@27037
    56
  commands explicitly.  This is particularly useful in interactive
wenzelm@27037
    57
  shell sessions to make clear where the current command is intended
wenzelm@27037
    58
  to end.  Otherwise, the interpreter loop will continue to issue a
wenzelm@27037
    59
  secondary prompt ``\verb|#|'' until an end-of-command is
wenzelm@27037
    60
  clearly recognized from the input syntax, e.g.\ encounter of the
wenzelm@27037
    61
  next command keyword.
wenzelm@27037
    62
wenzelm@27037
    63
  More advanced interfaces such as Proof~General \cite{proofgeneral}
wenzelm@27037
    64
  do not require explicit semicolons, the amount of input text is
wenzelm@27037
    65
  determined automatically by inspecting the present content of the
wenzelm@27037
    66
  Emacs text buffer.  In the printed presentation of Isabelle/Isar
wenzelm@27037
    67
  documents semicolons are omitted altogether for readability.
wenzelm@27037
    68
wenzelm@27037
    69
  \begin{warn}
wenzelm@27037
    70
    Proof~General requires certain syntax classification tables in
wenzelm@27037
    71
    order to achieve properly synchronized interaction with the
wenzelm@27037
    72
    Isabelle/Isar process.  These tables need to be consistent with
wenzelm@27037
    73
    the Isabelle version and particular logic image to be used in a
wenzelm@27037
    74
    running session (common object-logics may well change the outer
wenzelm@27037
    75
    syntax).  The standard setup should work correctly with any of the
wenzelm@27037
    76
    ``official'' logic images derived from Isabelle/HOL (including
wenzelm@27037
    77
    HOLCF etc.).  Users of alternative logics may need to tell
wenzelm@27037
    78
    Proof~General explicitly, e.g.\ by giving an option \verb|-k ZF|
wenzelm@27037
    79
    (in conjunction with \verb|-l ZF|, to specify the default
wenzelm@27037
    80
    logic image).  Note that option \verb|-L| does both
wenzelm@27037
    81
    of this at the same time.
wenzelm@27037
    82
  \end{warn}%
wenzelm@27037
    83
\end{isamarkuptext}%
wenzelm@27037
    84
\isamarkuptrue%
wenzelm@27037
    85
%
wenzelm@27037
    86
\isamarkupsection{Lexical matters \label{sec:lex-syntax}%
wenzelm@27037
    87
}
wenzelm@27037
    88
\isamarkuptrue%
wenzelm@27037
    89
%
wenzelm@27037
    90
\begin{isamarkuptext}%
wenzelm@27037
    91
The Isabelle/Isar outer syntax provides token classes as presented
wenzelm@27037
    92
  below; most of these coincide with the inner lexical syntax as
wenzelm@27037
    93
  presented in \cite{isabelle-ref}.
wenzelm@27037
    94
wenzelm@27037
    95
  \begin{matharray}{rcl}
wenzelm@27037
    96
    \indexdef{}{syntax}{ident}\hypertarget{syntax.ident}{\hyperlink{syntax.ident}{\mbox{\isa{ident}}}} & = & letter\,quasiletter^* \\
wenzelm@27037
    97
    \indexdef{}{syntax}{longident}\hypertarget{syntax.longident}{\hyperlink{syntax.longident}{\mbox{\isa{longident}}}} & = & ident (\verb,.,ident)^+ \\
wenzelm@27037
    98
    \indexdef{}{syntax}{symident}\hypertarget{syntax.symident}{\hyperlink{syntax.symident}{\mbox{\isa{symident}}}} & = & sym^+ ~|~ \verb,\,\verb,<,ident\verb,>, \\
wenzelm@27037
    99
    \indexdef{}{syntax}{nat}\hypertarget{syntax.nat}{\hyperlink{syntax.nat}{\mbox{\isa{nat}}}} & = & digit^+ \\
wenzelm@27037
   100
    \indexdef{}{syntax}{var}\hypertarget{syntax.var}{\hyperlink{syntax.var}{\mbox{\isa{var}}}} & = & ident ~|~ \verb,?,ident ~|~ \verb,?,ident\verb,.,nat \\
wenzelm@27037
   101
    \indexdef{}{syntax}{typefree}\hypertarget{syntax.typefree}{\hyperlink{syntax.typefree}{\mbox{\isa{typefree}}}} & = & \verb,',ident \\
wenzelm@27037
   102
    \indexdef{}{syntax}{typevar}\hypertarget{syntax.typevar}{\hyperlink{syntax.typevar}{\mbox{\isa{typevar}}}} & = & typefree ~|~ \verb,?,typefree ~|~ \verb,?,typefree\verb,.,nat \\
wenzelm@27037
   103
    \indexdef{}{syntax}{string}\hypertarget{syntax.string}{\hyperlink{syntax.string}{\mbox{\isa{string}}}} & = & \verb,", ~\dots~ \verb,", \\
wenzelm@27037
   104
    \indexdef{}{syntax}{altstring}\hypertarget{syntax.altstring}{\hyperlink{syntax.altstring}{\mbox{\isa{altstring}}}} & = & \backquote ~\dots~ \backquote \\
wenzelm@27037
   105
    \indexdef{}{syntax}{verbatim}\hypertarget{syntax.verbatim}{\hyperlink{syntax.verbatim}{\mbox{\isa{verbatim}}}} & = & \verb,{*, ~\dots~ \verb,*,\verb,}, \\[1ex]
wenzelm@27037
   106
wenzelm@27037
   107
    letter & = & latin ~|~ \verb,\,\verb,<,latin\verb,>, ~|~ \verb,\,\verb,<,latin\,latin\verb,>, ~|~ greek ~|~ \\
wenzelm@27037
   108
           &   & \verb,\<^isub>, ~|~ \verb,\<^isup>, \\
wenzelm@27037
   109
    quasiletter & = & letter ~|~ digit ~|~ \verb,_, ~|~ \verb,', \\
wenzelm@27037
   110
    latin & = & \verb,a, ~|~ \dots ~|~ \verb,z, ~|~ \verb,A, ~|~ \dots ~|~ \verb,Z, \\
wenzelm@27037
   111
    digit & = & \verb,0, ~|~ \dots ~|~ \verb,9, \\
wenzelm@27037
   112
    sym & = & \verb,!, ~|~ \verb,#, ~|~ \verb,$, ~|~ \verb,%, ~|~ \verb,&, ~|~
wenzelm@27037
   113
     \verb,*, ~|~ \verb,+, ~|~ \verb,-, ~|~ \verb,/, ~|~ \\
wenzelm@27037
   114
    & & \verb,<, ~|~ \verb,=, ~|~ \verb,>, ~|~ \verb,?, ~|~ \texttt{\at} ~|~
wenzelm@27037
   115
    \verb,^, ~|~ \verb,_, ~|~ \verb,|, ~|~ \verb,~, \\
wenzelm@27037
   116
    greek & = & \verb,\<alpha>, ~|~ \verb,\<beta>, ~|~ \verb,\<gamma>, ~|~ \verb,\<delta>, ~| \\
wenzelm@27037
   117
          &   & \verb,\<epsilon>, ~|~ \verb,\<zeta>, ~|~ \verb,\<eta>, ~|~ \verb,\<theta>, ~| \\
wenzelm@27037
   118
          &   & \verb,\<iota>, ~|~ \verb,\<kappa>, ~|~ \verb,\<mu>, ~|~ \verb,\<nu>, ~| \\
wenzelm@27037
   119
          &   & \verb,\<xi>, ~|~ \verb,\<pi>, ~|~ \verb,\<rho>, ~|~ \verb,\<sigma>, ~|~ \verb,\<tau>, ~| \\
wenzelm@27037
   120
          &   & \verb,\<upsilon>, ~|~ \verb,\<phi>, ~|~ \verb,\<chi>, ~|~ \verb,\<psi>, ~| \\
wenzelm@27037
   121
          &   & \verb,\<omega>, ~|~ \verb,\<Gamma>, ~|~ \verb,\<Delta>, ~|~ \verb,\<Theta>, ~| \\
wenzelm@27037
   122
          &   & \verb,\<Lambda>, ~|~ \verb,\<Xi>, ~|~ \verb,\<Pi>, ~|~ \verb,\<Sigma>, ~| \\
wenzelm@27037
   123
          &   & \verb,\<Upsilon>, ~|~ \verb,\<Phi>, ~|~ \verb,\<Psi>, ~|~ \verb,\<Omega>, \\
wenzelm@27037
   124
  \end{matharray}
wenzelm@27037
   125
wenzelm@27037
   126
  The syntax of \hyperlink{syntax.string}{\mbox{\isa{string}}} admits any characters, including
wenzelm@27037
   127
  newlines; ``\verb|"|'' (double-quote) and ``\verb|\|'' (backslash) need to be escaped by a backslash; arbitrary
wenzelm@27037
   128
  character codes may be specified as ``\verb|\|\isa{ddd}'',
wenzelm@27037
   129
  with three decimal digits.  Alternative strings according to
wenzelm@27037
   130
  \hyperlink{syntax.altstring}{\mbox{\isa{altstring}}} are analogous, using single back-quotes instead.
wenzelm@27037
   131
  The body of \hyperlink{syntax.verbatim}{\mbox{\isa{verbatim}}} may consist of any text not
wenzelm@27037
   132
  containing ``\verb|*|\verb|}|''; this allows
wenzelm@27037
   133
  convenient inclusion of quotes without further escapes.  The greek
wenzelm@27037
   134
  letters do \emph{not} include \verb|\<lambda>|, which is already used
wenzelm@27037
   135
  differently in the meta-logic.
wenzelm@27037
   136
wenzelm@27037
   137
  Common mathematical symbols such as \isa{{\isasymforall}} are represented in
wenzelm@27037
   138
  Isabelle as \verb|\<forall>|.  There are infinitely many Isabelle
wenzelm@27037
   139
  symbols like this, although proper presentation is left to front-end
wenzelm@27037
   140
  tools such as {\LaTeX} or Proof~General with the X-Symbol package.
wenzelm@27037
   141
  A list of standard Isabelle symbols that work well with these tools
wenzelm@27037
   142
  is given in \cite[appendix~A]{isabelle-sys}.
wenzelm@27037
   143
  
wenzelm@27037
   144
  Source comments take the form \verb|(*|~\isa{{\isachardoublequote}{\isasymdots}{\isachardoublequote}}~\verb|*)| and may be nested, although user-interface
wenzelm@27037
   145
  tools might prevent this.  Note that this form indicates source
wenzelm@27037
   146
  comments only, which are stripped after lexical analysis of the
wenzelm@27037
   147
  input.  The Isar document syntax also provides formal comments that
wenzelm@27037
   148
  are considered as part of the text (see \secref{sec:comments}).%
wenzelm@27037
   149
\end{isamarkuptext}%
wenzelm@27037
   150
\isamarkuptrue%
wenzelm@27037
   151
%
wenzelm@27037
   152
\isamarkupsection{Common syntax entities%
wenzelm@27037
   153
}
wenzelm@27037
   154
\isamarkuptrue%
wenzelm@27037
   155
%
wenzelm@27037
   156
\begin{isamarkuptext}%
wenzelm@27037
   157
We now introduce several basic syntactic entities, such as names,
wenzelm@27037
   158
  terms, and theorem specifications, which are factored out of the
wenzelm@27037
   159
  actual Isar language elements to be described later.%
wenzelm@27037
   160
\end{isamarkuptext}%
wenzelm@27037
   161
\isamarkuptrue%
wenzelm@27037
   162
%
wenzelm@27037
   163
\isamarkupsubsection{Names%
wenzelm@27037
   164
}
wenzelm@27037
   165
\isamarkuptrue%
wenzelm@27037
   166
%
wenzelm@27037
   167
\begin{isamarkuptext}%
wenzelm@27037
   168
Entity \railqtok{name} usually refers to any name of types,
wenzelm@27037
   169
  constants, theorems etc.\ that are to be \emph{declared} or
wenzelm@27037
   170
  \emph{defined} (so qualified identifiers are excluded here).  Quoted
wenzelm@27037
   171
  strings provide an escape for non-identifier names or those ruled
wenzelm@27037
   172
  out by outer syntax keywords (e.g.\ quoted \verb|"let"|).
wenzelm@27037
   173
  Already existing objects are usually referenced by
wenzelm@27037
   174
  \railqtok{nameref}.
wenzelm@27037
   175
wenzelm@27037
   176
  \indexoutertoken{name}\indexoutertoken{parname}\indexoutertoken{nameref}
wenzelm@27037
   177
  \indexoutertoken{int}
wenzelm@27037
   178
  \begin{rail}
wenzelm@27037
   179
    name: ident | symident | string | nat
wenzelm@27037
   180
    ;
wenzelm@27037
   181
    parname: '(' name ')'
wenzelm@27037
   182
    ;
wenzelm@27037
   183
    nameref: name | longident
wenzelm@27037
   184
    ;
wenzelm@27037
   185
    int: nat | '-' nat
wenzelm@27037
   186
    ;
wenzelm@27037
   187
  \end{rail}%
wenzelm@27037
   188
\end{isamarkuptext}%
wenzelm@27037
   189
\isamarkuptrue%
wenzelm@27037
   190
%
wenzelm@27037
   191
\isamarkupsubsection{Comments \label{sec:comments}%
wenzelm@27037
   192
}
wenzelm@27037
   193
\isamarkuptrue%
wenzelm@27037
   194
%
wenzelm@27037
   195
\begin{isamarkuptext}%
wenzelm@27037
   196
Large chunks of plain \railqtok{text} are usually given
wenzelm@27037
   197
  \railtok{verbatim}, i.e.\ enclosed in \verb|{|\verb|*|~\isa{{\isachardoublequote}{\isasymdots}{\isachardoublequote}}~\verb|*|\verb|}|.  For convenience,
wenzelm@27037
   198
  any of the smaller text units conforming to \railqtok{nameref} are
wenzelm@27037
   199
  admitted as well.  A marginal \railnonterm{comment} is of the form
wenzelm@27037
   200
  \verb|--| \railqtok{text}.  Any number of these may occur
wenzelm@27037
   201
  within Isabelle/Isar commands.
wenzelm@27037
   202
wenzelm@27037
   203
  \indexoutertoken{text}\indexouternonterm{comment}
wenzelm@27037
   204
  \begin{rail}
wenzelm@27037
   205
    text: verbatim | nameref
wenzelm@27037
   206
    ;
wenzelm@27037
   207
    comment: '--' text
wenzelm@27037
   208
    ;
wenzelm@27037
   209
  \end{rail}%
wenzelm@27037
   210
\end{isamarkuptext}%
wenzelm@27037
   211
\isamarkuptrue%
wenzelm@27037
   212
%
wenzelm@27037
   213
\isamarkupsubsection{Type classes, sorts and arities%
wenzelm@27037
   214
}
wenzelm@27037
   215
\isamarkuptrue%
wenzelm@27037
   216
%
wenzelm@27037
   217
\begin{isamarkuptext}%
wenzelm@27037
   218
Classes are specified by plain names.  Sorts have a very simple
wenzelm@27037
   219
  inner syntax, which is either a single class name \isa{c} or a
wenzelm@27037
   220
  list \isa{{\isachardoublequote}{\isacharbraceleft}c\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ c\isactrlsub n{\isacharbraceright}{\isachardoublequote}} referring to the
wenzelm@27037
   221
  intersection of these classes.  The syntax of type arities is given
wenzelm@27037
   222
  directly at the outer level.
wenzelm@27037
   223
wenzelm@27037
   224
  \indexouternonterm{sort}\indexouternonterm{arity}
wenzelm@27037
   225
  \indexouternonterm{classdecl}
wenzelm@27037
   226
  \begin{rail}
wenzelm@27037
   227
    classdecl: name (('<' | subseteq) (nameref + ','))?
wenzelm@27037
   228
    ;
wenzelm@27037
   229
    sort: nameref
wenzelm@27037
   230
    ;
wenzelm@27037
   231
    arity: ('(' (sort + ',') ')')? sort
wenzelm@27037
   232
    ;
wenzelm@27037
   233
  \end{rail}%
wenzelm@27037
   234
\end{isamarkuptext}%
wenzelm@27037
   235
\isamarkuptrue%
wenzelm@27037
   236
%
wenzelm@27037
   237
\isamarkupsubsection{Types and terms \label{sec:types-terms}%
wenzelm@27037
   238
}
wenzelm@27037
   239
\isamarkuptrue%
wenzelm@27037
   240
%
wenzelm@27037
   241
\begin{isamarkuptext}%
wenzelm@27037
   242
The actual inner Isabelle syntax, that of types and terms of the
wenzelm@27037
   243
  logic, is far too sophisticated in order to be modelled explicitly
wenzelm@27037
   244
  at the outer theory level.  Basically, any such entity has to be
wenzelm@27037
   245
  quoted to turn it into a single token (the parsing and type-checking
wenzelm@27037
   246
  is performed internally later).  For convenience, a slightly more
wenzelm@27037
   247
  liberal convention is adopted: quotes may be omitted for any type or
wenzelm@27037
   248
  term that is already atomic at the outer level.  For example, one
wenzelm@27037
   249
  may just write \verb|x| instead of quoted \verb|"x"|.
wenzelm@27037
   250
  Note that symbolic identifiers (e.g.\ \verb|++| or \isa{{\isachardoublequote}{\isasymforall}{\isachardoublequote}} are available as well, provided these have not been superseded
wenzelm@27037
   251
  by commands or other keywords already (such as \verb|=| or
wenzelm@27037
   252
  \verb|+|).
wenzelm@27037
   253
wenzelm@27037
   254
  \indexoutertoken{type}\indexoutertoken{term}\indexoutertoken{prop}
wenzelm@27037
   255
  \begin{rail}
wenzelm@27037
   256
    type: nameref | typefree | typevar
wenzelm@27037
   257
    ;
wenzelm@27037
   258
    term: nameref | var
wenzelm@27037
   259
    ;
wenzelm@27037
   260
    prop: term
wenzelm@27037
   261
    ;
wenzelm@27037
   262
  \end{rail}
wenzelm@27037
   263
wenzelm@27037
   264
  Positional instantiations are indicated by giving a sequence of
wenzelm@27037
   265
  terms, or the placeholder ``\isa{{\isacharunderscore}}'' (underscore), which means to
wenzelm@27037
   266
  skip a position.
wenzelm@27037
   267
wenzelm@27037
   268
  \indexoutertoken{inst}\indexoutertoken{insts}
wenzelm@27037
   269
  \begin{rail}
wenzelm@27037
   270
    inst: underscore | term
wenzelm@27037
   271
    ;
wenzelm@27037
   272
    insts: (inst *)
wenzelm@27037
   273
    ;
wenzelm@27037
   274
  \end{rail}
wenzelm@27037
   275
wenzelm@27037
   276
  Type declarations and definitions usually refer to
wenzelm@27037
   277
  \railnonterm{typespec} on the left-hand side.  This models basic
wenzelm@27037
   278
  type constructor application at the outer syntax level.  Note that
wenzelm@27037
   279
  only plain postfix notation is available here, but no infixes.
wenzelm@27037
   280
wenzelm@27037
   281
  \indexouternonterm{typespec}
wenzelm@27037
   282
  \begin{rail}
wenzelm@27037
   283
    typespec: (() | typefree | '(' ( typefree + ',' ) ')') name
wenzelm@27037
   284
    ;
wenzelm@27037
   285
  \end{rail}%
wenzelm@27037
   286
\end{isamarkuptext}%
wenzelm@27037
   287
\isamarkuptrue%
wenzelm@27037
   288
%
wenzelm@27037
   289
\isamarkupsubsection{Mixfix annotations%
wenzelm@27037
   290
}
wenzelm@27037
   291
\isamarkuptrue%
wenzelm@27037
   292
%
wenzelm@27037
   293
\begin{isamarkuptext}%
wenzelm@27037
   294
Mixfix annotations specify concrete \emph{inner} syntax of Isabelle
wenzelm@27037
   295
  types and terms.  Some commands such as \hyperlink{command.types}{\mbox{\isa{\isacommand{types}}}} (see
wenzelm@27037
   296
  \secref{sec:types-pure}) admit infixes only, while \hyperlink{command.consts}{\mbox{\isa{\isacommand{consts}}}} (see \secref{sec:consts}) and \hyperlink{command.syntax}{\mbox{\isa{\isacommand{syntax}}}} (see
wenzelm@27037
   297
  \secref{sec:syn-trans}) support the full range of general mixfixes
wenzelm@27037
   298
  and binders.
wenzelm@27037
   299
wenzelm@27037
   300
  \indexouternonterm{infix}\indexouternonterm{mixfix}\indexouternonterm{structmixfix}
wenzelm@27037
   301
  \begin{rail}
wenzelm@27037
   302
    infix: '(' ('infix' | 'infixl' | 'infixr') string? nat ')'
wenzelm@27037
   303
    ;
wenzelm@27037
   304
    mixfix: infix | '(' string prios? nat? ')' | '(' 'binder' string prios? nat ')'
wenzelm@27037
   305
    ;
wenzelm@27037
   306
    structmixfix: mixfix | '(' 'structure' ')'
wenzelm@27037
   307
    ;
wenzelm@27037
   308
wenzelm@27037
   309
    prios: '[' (nat + ',') ']'
wenzelm@27037
   310
    ;
wenzelm@27037
   311
  \end{rail}
wenzelm@27037
   312
wenzelm@27037
   313
  Here the \railtok{string} specifications refer to the actual mixfix
wenzelm@27037
   314
  template (see also \cite{isabelle-ref}), which may include literal
wenzelm@27037
   315
  text, spacing, blocks, and arguments (denoted by ``\isa{{\isacharunderscore}}''); the
wenzelm@27037
   316
  special symbol ``\verb|\<index>|'' (printed as ``\isa{{\isachardoublequote}{\isasymindex}{\isachardoublequote}}'')
wenzelm@27037
   317
  represents an index argument that specifies an implicit structure
wenzelm@27037
   318
  reference (see also \secref{sec:locale}).  Infix and binder
wenzelm@27037
   319
  declarations provide common abbreviations for particular mixfix
wenzelm@27037
   320
  declarations.  So in practice, mixfix templates mostly degenerate to
wenzelm@27037
   321
  literal text for concrete syntax, such as ``\verb|++|'' for
wenzelm@27037
   322
  an infix symbol, or ``\verb|++|\isa{{\isachardoublequote}{\isasymindex}{\isachardoublequote}}'' for an infix of
wenzelm@27037
   323
  an implicit structure.%
wenzelm@27037
   324
\end{isamarkuptext}%
wenzelm@27037
   325
\isamarkuptrue%
wenzelm@27037
   326
%
wenzelm@27037
   327
\isamarkupsubsection{Proof methods \label{sec:syn-meth}%
wenzelm@27037
   328
}
wenzelm@27037
   329
\isamarkuptrue%
wenzelm@27037
   330
%
wenzelm@27037
   331
\begin{isamarkuptext}%
wenzelm@27037
   332
Proof methods are either basic ones, or expressions composed of
wenzelm@27037
   333
  methods via ``\verb|,|'' (sequential composition),
wenzelm@27037
   334
  ``\verb||\verb,|,\verb||'' (alternative choices), ``\verb|?|'' 
wenzelm@27037
   335
  (try), ``\verb|+|'' (repeat at least once), ``\verb|[|\isa{n}\verb|]|'' (restriction to first \isa{n}
wenzelm@27037
   336
  sub-goals, with default \isa{{\isachardoublequote}n\ {\isacharequal}\ {\isadigit{1}}{\isachardoublequote}}).  In practice, proof
wenzelm@27037
   337
  methods are usually just a comma separated list of
wenzelm@27037
   338
  \railqtok{nameref}~\railnonterm{args} specifications.  Note that
wenzelm@27037
   339
  parentheses may be dropped for single method specifications (with no
wenzelm@27037
   340
  arguments).
wenzelm@27037
   341
wenzelm@27037
   342
  \indexouternonterm{method}
wenzelm@27037
   343
  \begin{rail}
wenzelm@27037
   344
    method: (nameref | '(' methods ')') (() | '?' | '+' | '[' nat? ']')
wenzelm@27037
   345
    ;
wenzelm@27037
   346
    methods: (nameref args | method) + (',' | '|')
wenzelm@27037
   347
    ;
wenzelm@27037
   348
  \end{rail}
wenzelm@27037
   349
wenzelm@27037
   350
  Proper Isar proof methods do \emph{not} admit arbitrary goal
wenzelm@27037
   351
  addressing, but refer either to the first sub-goal or all sub-goals
wenzelm@27037
   352
  uniformly.  The goal restriction operator ``\isa{{\isachardoublequote}{\isacharbrackleft}n{\isacharbrackright}{\isachardoublequote}}''
wenzelm@27037
   353
  evaluates a method expression within a sandbox consisting of the
wenzelm@27037
   354
  first \isa{n} sub-goals (which need to exist).  For example, the
wenzelm@27037
   355
  method ``\isa{{\isachardoublequote}simp{\isacharunderscore}all{\isacharbrackleft}{\isadigit{3}}{\isacharbrackright}{\isachardoublequote}}'' simplifies the first three
wenzelm@27037
   356
  sub-goals, while ``\isa{{\isachardoublequote}{\isacharparenleft}rule\ foo{\isacharcomma}\ simp{\isacharunderscore}all{\isacharparenright}{\isacharbrackleft}{\isacharbrackright}{\isachardoublequote}}'' simplifies all
wenzelm@27037
   357
  new goals that emerge from applying rule \isa{{\isachardoublequote}foo{\isachardoublequote}} to the
wenzelm@27037
   358
  originally first one.
wenzelm@27037
   359
wenzelm@27037
   360
  Improper methods, notably tactic emulations, offer a separate
wenzelm@27037
   361
  low-level goal addressing scheme as explicit argument to the
wenzelm@27037
   362
  individual tactic being involved.  Here ``\isa{{\isachardoublequote}{\isacharbrackleft}{\isacharbang}{\isacharbrackright}{\isachardoublequote}}'' refers to
wenzelm@27037
   363
  all goals, and ``\isa{{\isachardoublequote}{\isacharbrackleft}n{\isacharminus}{\isacharbrackright}{\isachardoublequote}}'' to all goals starting from \isa{{\isachardoublequote}n{\isachardoublequote}}.
wenzelm@27037
   364
wenzelm@27037
   365
  \indexouternonterm{goalspec}
wenzelm@27037
   366
  \begin{rail}
wenzelm@27037
   367
    goalspec: '[' (nat '-' nat | nat '-' | nat | '!' ) ']'
wenzelm@27037
   368
    ;
wenzelm@27037
   369
  \end{rail}%
wenzelm@27037
   370
\end{isamarkuptext}%
wenzelm@27037
   371
\isamarkuptrue%
wenzelm@27037
   372
%
wenzelm@27037
   373
\isamarkupsubsection{Attributes and theorems \label{sec:syn-att}%
wenzelm@27037
   374
}
wenzelm@27037
   375
\isamarkuptrue%
wenzelm@27037
   376
%
wenzelm@27037
   377
\begin{isamarkuptext}%
wenzelm@27037
   378
Attributes (and proof methods, see \secref{sec:syn-meth}) have their
wenzelm@27037
   379
  own ``semi-inner'' syntax, in the sense that input conforming to
wenzelm@27037
   380
  \railnonterm{args} below is parsed by the attribute a second time.
wenzelm@27037
   381
  The attribute argument specifications may be any sequence of atomic
wenzelm@27037
   382
  entities (identifiers, strings etc.), or properly bracketed argument
wenzelm@27037
   383
  lists.  Below \railqtok{atom} refers to any atomic entity, including
wenzelm@27037
   384
  any \railtok{keyword} conforming to \railtok{symident}.
wenzelm@27037
   385
wenzelm@27037
   386
  \indexoutertoken{atom}\indexouternonterm{args}\indexouternonterm{attributes}
wenzelm@27037
   387
  \begin{rail}
wenzelm@27037
   388
    atom: nameref | typefree | typevar | var | nat | keyword
wenzelm@27037
   389
    ;
wenzelm@27037
   390
    arg: atom | '(' args ')' | '[' args ']'
wenzelm@27037
   391
    ;
wenzelm@27037
   392
    args: arg *
wenzelm@27037
   393
    ;
wenzelm@27037
   394
    attributes: '[' (nameref args * ',') ']'
wenzelm@27037
   395
    ;
wenzelm@27037
   396
  \end{rail}
wenzelm@27037
   397
wenzelm@27037
   398
  Theorem specifications come in several flavors:
wenzelm@27037
   399
  \railnonterm{axmdecl} and \railnonterm{thmdecl} usually refer to
wenzelm@27037
   400
  axioms, assumptions or results of goal statements, while
wenzelm@27037
   401
  \railnonterm{thmdef} collects lists of existing theorems.  Existing
wenzelm@27037
   402
  theorems are given by \railnonterm{thmref} and
wenzelm@27037
   403
  \railnonterm{thmrefs}, the former requires an actual singleton
wenzelm@27037
   404
  result.
wenzelm@27037
   405
wenzelm@27037
   406
  There are three forms of theorem references:
wenzelm@27037
   407
  \begin{enumerate}
wenzelm@27037
   408
  
wenzelm@27037
   409
  \item named facts \isa{{\isachardoublequote}a{\isachardoublequote}},
wenzelm@27037
   410
wenzelm@27037
   411
  \item selections from named facts \isa{{\isachardoublequote}a{\isacharparenleft}i{\isacharparenright}{\isachardoublequote}} or \isa{{\isachardoublequote}a{\isacharparenleft}j\ {\isacharminus}\ k{\isacharparenright}{\isachardoublequote}},
wenzelm@27037
   412
wenzelm@27037
   413
  \item literal fact propositions using \indexref{}{syntax}{altstring}\hyperlink{syntax.altstring}{\mbox{\isa{altstring}}} syntax
wenzelm@27037
   414
  \verb|`|\isa{{\isachardoublequote}{\isasymphi}{\isachardoublequote}}\verb|`| (see also method
wenzelm@27037
   415
  \indexref{}{method}{fact}\hyperlink{method.fact}{\mbox{\isa{fact}}} in \secref{sec:pure-meth-att}).
wenzelm@27037
   416
wenzelm@27037
   417
  \end{enumerate}
wenzelm@27037
   418
wenzelm@27037
   419
  Any kind of theorem specification may include lists of attributes
wenzelm@27037
   420
  both on the left and right hand sides; attributes are applied to any
wenzelm@27037
   421
  immediately preceding fact.  If names are omitted, the theorems are
wenzelm@27037
   422
  not stored within the theorem database of the theory or proof
wenzelm@27037
   423
  context, but any given attributes are applied nonetheless.
wenzelm@27037
   424
wenzelm@27037
   425
  An extra pair of brackets around attributes (like ``\isa{{\isachardoublequote}{\isacharbrackleft}{\isacharbrackleft}simproc\ a{\isacharbrackright}{\isacharbrackright}{\isachardoublequote}}'') abbreviates a theorem reference involving an
wenzelm@27037
   426
  internal dummy fact, which will be ignored later on.  So only the
wenzelm@27037
   427
  effect of the attribute on the background context will persist.
wenzelm@27037
   428
  This form of in-place declarations is particularly useful with
wenzelm@27037
   429
  commands like \hyperlink{command.declare}{\mbox{\isa{\isacommand{declare}}}} and \hyperlink{command.using}{\mbox{\isa{\isacommand{using}}}}.
wenzelm@27037
   430
wenzelm@27037
   431
  \indexouternonterm{axmdecl}\indexouternonterm{thmdecl}
wenzelm@27037
   432
  \indexouternonterm{thmdef}\indexouternonterm{thmref}
wenzelm@27037
   433
  \indexouternonterm{thmrefs}\indexouternonterm{selection}
wenzelm@27037
   434
  \begin{rail}
wenzelm@27037
   435
    axmdecl: name attributes? ':'
wenzelm@27037
   436
    ;
wenzelm@27037
   437
    thmdecl: thmbind ':'
wenzelm@27037
   438
    ;
wenzelm@27037
   439
    thmdef: thmbind '='
wenzelm@27037
   440
    ;
wenzelm@27037
   441
    thmref: (nameref selection? | altstring) attributes? | '[' attributes ']'
wenzelm@27037
   442
    ;
wenzelm@27037
   443
    thmrefs: thmref +
wenzelm@27037
   444
    ;
wenzelm@27037
   445
wenzelm@27037
   446
    thmbind: name attributes | name | attributes
wenzelm@27037
   447
    ;
wenzelm@27037
   448
    selection: '(' ((nat | nat '-' nat?) + ',') ')'
wenzelm@27037
   449
    ;
wenzelm@27037
   450
  \end{rail}%
wenzelm@27037
   451
\end{isamarkuptext}%
wenzelm@27037
   452
\isamarkuptrue%
wenzelm@27037
   453
%
wenzelm@27037
   454
\isamarkupsubsection{Term patterns and declarations \label{sec:term-decls}%
wenzelm@27037
   455
}
wenzelm@27037
   456
\isamarkuptrue%
wenzelm@27037
   457
%
wenzelm@27037
   458
\begin{isamarkuptext}%
wenzelm@27037
   459
Wherever explicit propositions (or term fragments) occur in a proof
wenzelm@27037
   460
  text, casual binding of schematic term variables may be given
wenzelm@27037
   461
  specified via patterns of the form ``\isa{{\isachardoublequote}{\isacharparenleft}{\isasymIS}\ p\isactrlsub {\isadigit{1}}\ {\isasymdots}\ p\isactrlsub n{\isacharparenright}{\isachardoublequote}}''.  This works both for \railqtok{term} and \railqtok{prop}.
wenzelm@27037
   462
wenzelm@27037
   463
  \indexouternonterm{termpat}\indexouternonterm{proppat}
wenzelm@27037
   464
  \begin{rail}
wenzelm@27037
   465
    termpat: '(' ('is' term +) ')'
wenzelm@27037
   466
    ;
wenzelm@27037
   467
    proppat: '(' ('is' prop +) ')'
wenzelm@27037
   468
    ;
wenzelm@27037
   469
  \end{rail}
wenzelm@27037
   470
wenzelm@27037
   471
  \medskip Declarations of local variables \isa{{\isachardoublequote}x\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}{\isachardoublequote}} and
wenzelm@27037
   472
  logical propositions \isa{{\isachardoublequote}a\ {\isacharcolon}\ {\isasymphi}{\isachardoublequote}} represent different views on
wenzelm@27037
   473
  the same principle of introducing a local scope.  In practice, one
wenzelm@27037
   474
  may usually omit the typing of \railnonterm{vars} (due to
wenzelm@27037
   475
  type-inference), and the naming of propositions (due to implicit
wenzelm@27037
   476
  references of current facts).  In any case, Isar proof elements
wenzelm@27037
   477
  usually admit to introduce multiple such items simultaneously.
wenzelm@27037
   478
wenzelm@27037
   479
  \indexouternonterm{vars}\indexouternonterm{props}
wenzelm@27037
   480
  \begin{rail}
wenzelm@27037
   481
    vars: (name+) ('::' type)?
wenzelm@27037
   482
    ;
wenzelm@27037
   483
    props: thmdecl? (prop proppat? +)
wenzelm@27037
   484
    ;
wenzelm@27037
   485
  \end{rail}
wenzelm@27037
   486
wenzelm@27037
   487
  The treatment of multiple declarations corresponds to the
wenzelm@27037
   488
  complementary focus of \railnonterm{vars} versus
wenzelm@27037
   489
  \railnonterm{props}.  In ``\isa{{\isachardoublequote}x\isactrlsub {\isadigit{1}}\ {\isasymdots}\ x\isactrlsub n\ {\isacharcolon}{\isacharcolon}\ {\isasymtau}{\isachardoublequote}}''
wenzelm@27037
   490
  the typing refers to all variables, while in \isa{{\isachardoublequote}a{\isacharcolon}\ {\isasymphi}\isactrlsub {\isadigit{1}}\ {\isasymdots}\ {\isasymphi}\isactrlsub n{\isachardoublequote}} the naming refers to all propositions collectively.
wenzelm@27037
   491
  Isar language elements that refer to \railnonterm{vars} or
wenzelm@27037
   492
  \railnonterm{props} typically admit separate typings or namings via
wenzelm@27037
   493
  another level of iteration, with explicit \indexref{}{keyword}{and}\hyperlink{keyword.and}{\mbox{\isa{\isakeyword{and}}}}
wenzelm@27037
   494
  separators; e.g.\ see \hyperlink{command.fix}{\mbox{\isa{\isacommand{fix}}}} and \hyperlink{command.assume}{\mbox{\isa{\isacommand{assume}}}} in
wenzelm@27037
   495
  \secref{sec:proof-context}.%
wenzelm@27037
   496
\end{isamarkuptext}%
wenzelm@27037
   497
\isamarkuptrue%
wenzelm@27037
   498
%
wenzelm@27037
   499
\isamarkupsubsection{Antiquotations \label{sec:antiq}%
wenzelm@27037
   500
}
wenzelm@27037
   501
\isamarkuptrue%
wenzelm@27037
   502
%
wenzelm@27037
   503
\begin{isamarkuptext}%
wenzelm@27037
   504
\begin{matharray}{rcl}
wenzelm@27037
   505
    \indexdef{}{antiquotation}{theory}\hypertarget{antiquotation.theory}{\hyperlink{antiquotation.theory}{\mbox{\isa{theory}}}} & : & \isarantiq \\
wenzelm@27037
   506
    \indexdef{}{antiquotation}{thm}\hypertarget{antiquotation.thm}{\hyperlink{antiquotation.thm}{\mbox{\isa{thm}}}} & : & \isarantiq \\
wenzelm@27037
   507
    \indexdef{}{antiquotation}{prop}\hypertarget{antiquotation.prop}{\hyperlink{antiquotation.prop}{\mbox{\isa{prop}}}} & : & \isarantiq \\
wenzelm@27037
   508
    \indexdef{}{antiquotation}{term}\hypertarget{antiquotation.term}{\hyperlink{antiquotation.term}{\mbox{\isa{term}}}} & : & \isarantiq \\
wenzelm@27037
   509
    \indexdef{}{antiquotation}{const}\hypertarget{antiquotation.const}{\hyperlink{antiquotation.const}{\mbox{\isa{const}}}} & : & \isarantiq \\
wenzelm@27037
   510
    \indexdef{}{antiquotation}{abbrev}\hypertarget{antiquotation.abbrev}{\hyperlink{antiquotation.abbrev}{\mbox{\isa{abbrev}}}} & : & \isarantiq \\
wenzelm@27037
   511
    \indexdef{}{antiquotation}{typeof}\hypertarget{antiquotation.typeof}{\hyperlink{antiquotation.typeof}{\mbox{\isa{typeof}}}} & : & \isarantiq \\
wenzelm@27037
   512
    \indexdef{}{antiquotation}{typ}\hypertarget{antiquotation.typ}{\hyperlink{antiquotation.typ}{\mbox{\isa{typ}}}} & : & \isarantiq \\
wenzelm@27037
   513
    \indexdef{}{antiquotation}{thm\_style}\hypertarget{antiquotation.thm-style}{\hyperlink{antiquotation.thm-style}{\mbox{\isa{thm{\isacharunderscore}style}}}} & : & \isarantiq \\
wenzelm@27037
   514
    \indexdef{}{antiquotation}{term\_style}\hypertarget{antiquotation.term-style}{\hyperlink{antiquotation.term-style}{\mbox{\isa{term{\isacharunderscore}style}}}} & : & \isarantiq \\
wenzelm@27037
   515
    \indexdef{}{antiquotation}{text}\hypertarget{antiquotation.text}{\hyperlink{antiquotation.text}{\mbox{\isa{text}}}} & : & \isarantiq \\
wenzelm@27037
   516
    \indexdef{}{antiquotation}{goals}\hypertarget{antiquotation.goals}{\hyperlink{antiquotation.goals}{\mbox{\isa{goals}}}} & : & \isarantiq \\
wenzelm@27037
   517
    \indexdef{}{antiquotation}{subgoals}\hypertarget{antiquotation.subgoals}{\hyperlink{antiquotation.subgoals}{\mbox{\isa{subgoals}}}} & : & \isarantiq \\
wenzelm@27037
   518
    \indexdef{}{antiquotation}{prf}\hypertarget{antiquotation.prf}{\hyperlink{antiquotation.prf}{\mbox{\isa{prf}}}} & : & \isarantiq \\
wenzelm@27037
   519
    \indexdef{}{antiquotation}{full\_prf}\hypertarget{antiquotation.full-prf}{\hyperlink{antiquotation.full-prf}{\mbox{\isa{full{\isacharunderscore}prf}}}} & : & \isarantiq \\
wenzelm@27037
   520
    \indexdef{}{antiquotation}{ML}\hypertarget{antiquotation.ML}{\hyperlink{antiquotation.ML}{\mbox{\isa{ML}}}} & : & \isarantiq \\
wenzelm@27037
   521
    \indexdef{}{antiquotation}{ML\_type}\hypertarget{antiquotation.ML-type}{\hyperlink{antiquotation.ML-type}{\mbox{\isa{ML{\isacharunderscore}type}}}} & : & \isarantiq \\
wenzelm@27037
   522
    \indexdef{}{antiquotation}{ML\_struct}\hypertarget{antiquotation.ML-struct}{\hyperlink{antiquotation.ML-struct}{\mbox{\isa{ML{\isacharunderscore}struct}}}} & : & \isarantiq \\
wenzelm@27037
   523
  \end{matharray}
wenzelm@27037
   524
wenzelm@27037
   525
  The text body of formal comments (see also \secref{sec:comments})
wenzelm@27037
   526
  may contain antiquotations of logical entities, such as theorems,
wenzelm@27037
   527
  terms and types, which are to be presented in the final output
wenzelm@27037
   528
  produced by the Isabelle document preparation system (see also
wenzelm@27037
   529
  \secref{sec:document-prep}).
wenzelm@27037
   530
wenzelm@27037
   531
  Thus embedding of ``\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}term\ {\isacharbrackleft}show{\isacharunderscore}types{\isacharbrackright}\ {\isachardoublequote}f\ x\ {\isacharequal}\ a\ {\isacharplus}\ x{\isachardoublequote}{\isacharbraceright}{\isachardoublequote}}''
wenzelm@27037
   532
  within a text block would cause
wenzelm@27037
   533
  \isa{{\isacharparenleft}f{\isasymColon}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isacharparenright}\ {\isacharparenleft}x{\isasymColon}{\isacharprime}a{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}a{\isasymColon}{\isacharprime}a{\isacharparenright}\ {\isacharplus}\ x} to appear in the final {\LaTeX} document.  Also note that theorem
wenzelm@27037
   534
  antiquotations may involve attributes as well.  For example,
wenzelm@27037
   535
  \isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}thm\ sym\ {\isacharbrackleft}no{\isacharunderscore}vars{\isacharbrackright}{\isacharbraceright}{\isachardoublequote}} would print the theorem's
wenzelm@27037
   536
  statement where all schematic variables have been replaced by fixed
wenzelm@27037
   537
  ones, which are easier to read.
wenzelm@27037
   538
wenzelm@27037
   539
  \begin{rail}
wenzelm@27037
   540
    atsign lbrace antiquotation rbrace
wenzelm@27037
   541
    ;
wenzelm@27037
   542
wenzelm@27037
   543
    antiquotation:
wenzelm@27037
   544
      'theory' options name |
wenzelm@27037
   545
      'thm' options thmrefs |
wenzelm@27037
   546
      'prop' options prop |
wenzelm@27037
   547
      'term' options term |
wenzelm@27037
   548
      'const' options term |
wenzelm@27037
   549
      'abbrev' options term |
wenzelm@27037
   550
      'typeof' options term |
wenzelm@27037
   551
      'typ' options type |
wenzelm@27037
   552
      'thm\_style' options name thmref |
wenzelm@27037
   553
      'term\_style' options name term |
wenzelm@27037
   554
      'text' options name |
wenzelm@27037
   555
      'goals' options |
wenzelm@27037
   556
      'subgoals' options |
wenzelm@27037
   557
      'prf' options thmrefs |
wenzelm@27037
   558
      'full\_prf' options thmrefs |
wenzelm@27037
   559
      'ML' options name |
wenzelm@27037
   560
      'ML\_type' options name |
wenzelm@27037
   561
      'ML\_struct' options name
wenzelm@27037
   562
    ;
wenzelm@27037
   563
    options: '[' (option * ',') ']'
wenzelm@27037
   564
    ;
wenzelm@27037
   565
    option: name | name '=' name
wenzelm@27037
   566
    ;
wenzelm@27037
   567
  \end{rail}
wenzelm@27037
   568
wenzelm@27037
   569
  Note that the syntax of antiquotations may \emph{not} include source
wenzelm@27037
   570
  comments \verb|(*|~\isa{{\isachardoublequote}{\isasymdots}{\isachardoublequote}}~\verb|*)| or verbatim
wenzelm@27037
   571
  text \verb|{|\verb|*|~\isa{{\isachardoublequote}{\isasymdots}{\isachardoublequote}}~\verb|*|\verb|}|.
wenzelm@27037
   572
wenzelm@27037
   573
  \begin{descr}
wenzelm@27037
   574
  
wenzelm@27037
   575
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}theory\ A{\isacharbraceright}{\isachardoublequote}}] prints the name \isa{{\isachardoublequote}A{\isachardoublequote}}, which is
wenzelm@27037
   576
  guaranteed to refer to a valid ancestor theory in the current
wenzelm@27037
   577
  context.
wenzelm@27037
   578
wenzelm@27037
   579
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}thm\ a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n{\isacharbraceright}{\isachardoublequote}}] prints theorems
wenzelm@27037
   580
  \isa{{\isachardoublequote}a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n{\isachardoublequote}}.  Note that attribute specifications
wenzelm@27037
   581
  may be included as well (see also \secref{sec:syn-att}); the
wenzelm@27037
   582
  \indexref{}{attribute}{no\_vars}\hyperlink{attribute.no-vars}{\mbox{\isa{no{\isacharunderscore}vars}}} rule (see \secref{sec:misc-meth-att}) would
wenzelm@27037
   583
  be particularly useful to suppress printing of schematic variables.
wenzelm@27037
   584
wenzelm@27037
   585
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}prop\ {\isasymphi}{\isacharbraceright}{\isachardoublequote}}] prints a well-typed proposition \isa{{\isachardoublequote}{\isasymphi}{\isachardoublequote}}.
wenzelm@27037
   586
wenzelm@27037
   587
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}term\ t{\isacharbraceright}{\isachardoublequote}}] prints a well-typed term \isa{{\isachardoublequote}t{\isachardoublequote}}.
wenzelm@27037
   588
wenzelm@27037
   589
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}const\ c{\isacharbraceright}{\isachardoublequote}}] prints a logical or syntactic constant
wenzelm@27037
   590
  \isa{{\isachardoublequote}c{\isachardoublequote}}.
wenzelm@27037
   591
  
wenzelm@27037
   592
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}abbrev\ c\ x\isactrlsub {\isadigit{1}}\ {\isasymdots}\ x\isactrlsub n{\isacharbraceright}{\isachardoublequote}}] prints a constant
wenzelm@27037
   593
  abbreviation \isa{{\isachardoublequote}c\ x\isactrlsub {\isadigit{1}}\ {\isasymdots}\ x\isactrlsub n\ {\isasymequiv}\ rhs{\isachardoublequote}} as defined in
wenzelm@27037
   594
  the current context.
wenzelm@27037
   595
wenzelm@27037
   596
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}typeof\ t{\isacharbraceright}{\isachardoublequote}}] prints the type of a well-typed term
wenzelm@27037
   597
  \isa{{\isachardoublequote}t{\isachardoublequote}}.
wenzelm@27037
   598
wenzelm@27037
   599
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}typ\ {\isasymtau}{\isacharbraceright}{\isachardoublequote}}] prints a well-formed type \isa{{\isachardoublequote}{\isasymtau}{\isachardoublequote}}.
wenzelm@27037
   600
  
wenzelm@27037
   601
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}thm{\isacharunderscore}style\ s\ a{\isacharbraceright}{\isachardoublequote}}] prints theorem \isa{a},
wenzelm@27037
   602
  previously applying a style \isa{s} to it (see below).
wenzelm@27037
   603
  
wenzelm@27037
   604
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}term{\isacharunderscore}style\ s\ t{\isacharbraceright}{\isachardoublequote}}] prints a well-typed term \isa{t} after applying a style \isa{s} to it (see below).
wenzelm@27037
   605
wenzelm@27037
   606
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}text\ s{\isacharbraceright}{\isachardoublequote}}] prints uninterpreted source text \isa{s}.  This is particularly useful to print portions of text according
wenzelm@27037
   607
  to the Isabelle {\LaTeX} output style, without demanding
wenzelm@27037
   608
  well-formedness (e.g.\ small pieces of terms that should not be
wenzelm@27037
   609
  parsed or type-checked yet).
wenzelm@27037
   610
wenzelm@27037
   611
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}goals{\isacharbraceright}{\isachardoublequote}}] prints the current \emph{dynamic} goal
wenzelm@27037
   612
  state.  This is mainly for support of tactic-emulation scripts
wenzelm@27037
   613
  within Isar --- presentation of goal states does not conform to
wenzelm@27037
   614
  actual human-readable proof documents.
wenzelm@27037
   615
wenzelm@27037
   616
  Please do not include goal states into document output unless you
wenzelm@27037
   617
  really know what you are doing!
wenzelm@27037
   618
  
wenzelm@27037
   619
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}subgoals{\isacharbraceright}{\isachardoublequote}}] is similar to \isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}goals{\isacharbraceright}{\isachardoublequote}}, but
wenzelm@27037
   620
  does not print the main goal.
wenzelm@27037
   621
  
wenzelm@27037
   622
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}prf\ a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n{\isacharbraceright}{\isachardoublequote}}] prints the (compact)
wenzelm@27037
   623
  proof terms corresponding to the theorems \isa{{\isachardoublequote}a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n{\isachardoublequote}}. Note that this requires proof terms to be switched on
wenzelm@27037
   624
  for the current object logic (see the ``Proof terms'' section of the
wenzelm@27037
   625
  Isabelle reference manual for information on how to do this).
wenzelm@27037
   626
  
wenzelm@27037
   627
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}full{\isacharunderscore}prf\ a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n{\isacharbraceright}{\isachardoublequote}}] is like \isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}prf\ a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n{\isacharbraceright}{\isachardoublequote}}, but displays the full proof terms,
wenzelm@27037
   628
  i.e.\ also displays information omitted in the compact proof term,
wenzelm@27037
   629
  which is denoted by ``\isa{{\isacharunderscore}}'' placeholders there.
wenzelm@27037
   630
  
wenzelm@27037
   631
  \item [\isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}ML\ s{\isacharbraceright}{\isachardoublequote}}, \isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}ML{\isacharunderscore}type\ s{\isacharbraceright}{\isachardoublequote}}, and \isa{{\isachardoublequote}{\isacharat}{\isacharbraceleft}ML{\isacharunderscore}struct\ s{\isacharbraceright}{\isachardoublequote}}] check text \isa{s} as ML value, type, and
wenzelm@27037
   632
  structure, respectively.  The source is displayed verbatim.
wenzelm@27037
   633
wenzelm@27037
   634
  \end{descr}
wenzelm@27037
   635
wenzelm@27037
   636
  \medskip The following standard styles for use with \isa{thm{\isacharunderscore}style} and \isa{term{\isacharunderscore}style} are available:
wenzelm@27037
   637
wenzelm@27037
   638
  \begin{descr}
wenzelm@27037
   639
  
wenzelm@27037
   640
  \item [\isa{lhs}] extracts the first argument of any application
wenzelm@27037
   641
  form with at least two arguments -- typically meta-level or
wenzelm@27037
   642
  object-level equality, or any other binary relation.
wenzelm@27037
   643
  
wenzelm@27037
   644
  \item [\isa{rhs}] is like \isa{lhs}, but extracts the second
wenzelm@27037
   645
  argument.
wenzelm@27037
   646
  
wenzelm@27037
   647
  \item [\isa{{\isachardoublequote}concl{\isachardoublequote}}] extracts the conclusion \isa{C} from a rule
wenzelm@27037
   648
  in Horn-clause normal form \isa{{\isachardoublequote}A\isactrlsub {\isadigit{1}}\ {\isasymLongrightarrow}\ {\isasymdots}\ A\isactrlsub n\ {\isasymLongrightarrow}\ C{\isachardoublequote}}.
wenzelm@27037
   649
  
wenzelm@27037
   650
  \item [\isa{{\isachardoublequote}prem{\isadigit{1}}{\isachardoublequote}}, \dots, \isa{{\isachardoublequote}prem{\isadigit{9}}{\isachardoublequote}}] extract premise
wenzelm@27037
   651
  number \isa{{\isachardoublequote}{\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isadigit{9}}{\isachardoublequote}}, respectively, from from a rule in
wenzelm@27037
   652
  Horn-clause normal form \isa{{\isachardoublequote}A\isactrlsub {\isadigit{1}}\ {\isasymLongrightarrow}\ {\isasymdots}\ A\isactrlsub n\ {\isasymLongrightarrow}\ C{\isachardoublequote}}
wenzelm@27037
   653
wenzelm@27037
   654
  \end{descr}
wenzelm@27037
   655
wenzelm@27037
   656
  \medskip
wenzelm@27037
   657
  The following options are available to tune the output.  Note that most of
wenzelm@27037
   658
  these coincide with ML flags of the same names (see also \cite{isabelle-ref}).
wenzelm@27037
   659
wenzelm@27037
   660
  \begin{descr}
wenzelm@27037
   661
wenzelm@27037
   662
  \item[\isa{{\isachardoublequote}show{\isacharunderscore}types\ {\isacharequal}\ bool{\isachardoublequote}} and \isa{{\isachardoublequote}show{\isacharunderscore}sorts\ {\isacharequal}\ bool{\isachardoublequote}}]
wenzelm@27037
   663
  control printing of explicit type and sort constraints.
wenzelm@27037
   664
wenzelm@27037
   665
  \item[\isa{{\isachardoublequote}show{\isacharunderscore}structs\ {\isacharequal}\ bool{\isachardoublequote}}] controls printing of implicit
wenzelm@27037
   666
  structures.
wenzelm@27037
   667
wenzelm@27037
   668
  \item[\isa{{\isachardoublequote}long{\isacharunderscore}names\ {\isacharequal}\ bool{\isachardoublequote}}] forces names of types and
wenzelm@27037
   669
  constants etc.\ to be printed in their fully qualified internal
wenzelm@27037
   670
  form.
wenzelm@27037
   671
wenzelm@27037
   672
  \item[\isa{{\isachardoublequote}short{\isacharunderscore}names\ {\isacharequal}\ bool{\isachardoublequote}}] forces names of types and
wenzelm@27037
   673
  constants etc.\ to be printed unqualified.  Note that internalizing
wenzelm@27037
   674
  the output again in the current context may well yield a different
wenzelm@27037
   675
  result.
wenzelm@27037
   676
wenzelm@27037
   677
  \item[\isa{{\isachardoublequote}unique{\isacharunderscore}names\ {\isacharequal}\ bool{\isachardoublequote}}] determines whether the printed
wenzelm@27037
   678
  version of qualified names should be made sufficiently long to avoid
wenzelm@27037
   679
  overlap with names declared further back.  Set to \isa{false} for
wenzelm@27037
   680
  more concise output.
wenzelm@27037
   681
wenzelm@27037
   682
  \item[\isa{{\isachardoublequote}eta{\isacharunderscore}contract\ {\isacharequal}\ bool{\isachardoublequote}}] prints terms in \isa{{\isasymeta}}-contracted form.
wenzelm@27037
   683
wenzelm@27037
   684
  \item[\isa{{\isachardoublequote}display\ {\isacharequal}\ bool{\isachardoublequote}}] indicates if the text is to be
wenzelm@27037
   685
  output as multi-line ``display material'', rather than a small piece
wenzelm@27037
   686
  of text without line breaks (which is the default).
wenzelm@27037
   687
wenzelm@27037
   688
  \item[\isa{{\isachardoublequote}break\ {\isacharequal}\ bool{\isachardoublequote}}] controls line breaks in non-display
wenzelm@27037
   689
  material.
wenzelm@27037
   690
wenzelm@27037
   691
  \item[\isa{{\isachardoublequote}quotes\ {\isacharequal}\ bool{\isachardoublequote}}] indicates if the output should be
wenzelm@27037
   692
  enclosed in double quotes.
wenzelm@27037
   693
wenzelm@27037
   694
  \item[\isa{{\isachardoublequote}mode\ {\isacharequal}\ name{\isachardoublequote}}] adds \isa{name} to the print mode to
wenzelm@27037
   695
  be used for presentation (see also \cite{isabelle-ref}).  Note that
wenzelm@27037
   696
  the standard setup for {\LaTeX} output is already present by
wenzelm@27037
   697
  default, including the modes \isa{latex} and \isa{xsymbols}.
wenzelm@27037
   698
wenzelm@27037
   699
  \item[\isa{{\isachardoublequote}margin\ {\isacharequal}\ nat{\isachardoublequote}} and \isa{{\isachardoublequote}indent\ {\isacharequal}\ nat{\isachardoublequote}}] change the
wenzelm@27037
   700
  margin or indentation for pretty printing of display material.
wenzelm@27037
   701
wenzelm@27037
   702
  \item[\isa{{\isachardoublequote}source\ {\isacharequal}\ bool{\isachardoublequote}}] prints the source text of the
wenzelm@27037
   703
  antiquotation arguments, rather than the actual value.  Note that
wenzelm@27037
   704
  this does not affect well-formedness checks of \hyperlink{antiquotation.thm}{\mbox{\isa{thm}}}, \hyperlink{antiquotation.term}{\mbox{\isa{term}}}, etc. (only the \hyperlink{antiquotation.text}{\mbox{\isa{text}}} antiquotation admits arbitrary output).
wenzelm@27037
   705
wenzelm@27037
   706
  \item[\isa{{\isachardoublequote}goals{\isacharunderscore}limit\ {\isacharequal}\ nat{\isachardoublequote}}] determines the maximum number of
wenzelm@27037
   707
  goals to be printed.
wenzelm@27037
   708
wenzelm@27037
   709
  \item[\isa{{\isachardoublequote}locale\ {\isacharequal}\ name{\isachardoublequote}}] specifies an alternative locale
wenzelm@27037
   710
  context used for evaluating and printing the subsequent argument.
wenzelm@27037
   711
wenzelm@27037
   712
  \end{descr}
wenzelm@27037
   713
wenzelm@27037
   714
  For boolean flags, ``\isa{{\isachardoublequote}name\ {\isacharequal}\ true{\isachardoublequote}}'' may be abbreviated as
wenzelm@27037
   715
  ``\isa{name}''.  All of the above flags are disabled by default,
wenzelm@27037
   716
  unless changed from ML.
wenzelm@27037
   717
wenzelm@27037
   718
  \medskip Note that antiquotations do not only spare the author from
wenzelm@27037
   719
  tedious typing of logical entities, but also achieve some degree of
wenzelm@27037
   720
  consistency-checking of informal explanations with formal
wenzelm@27037
   721
  developments: well-formedness of terms and types with respect to the
wenzelm@27037
   722
  current theory or proof context is ensured here.%
wenzelm@27037
   723
\end{isamarkuptext}%
wenzelm@27037
   724
\isamarkuptrue%
wenzelm@27037
   725
%
wenzelm@27037
   726
\isamarkupsubsection{Tagged commands \label{sec:tags}%
wenzelm@27037
   727
}
wenzelm@27037
   728
\isamarkuptrue%
wenzelm@27037
   729
%
wenzelm@27037
   730
\begin{isamarkuptext}%
wenzelm@27037
   731
Each Isabelle/Isar command may be decorated by presentation tags:
wenzelm@27037
   732
wenzelm@27037
   733
  \indexouternonterm{tags}
wenzelm@27037
   734
  \begin{rail}
wenzelm@27037
   735
    tags: ( tag * )
wenzelm@27037
   736
    ;
wenzelm@27037
   737
    tag: '\%' (ident | string)
wenzelm@27037
   738
  \end{rail}
wenzelm@27037
   739
wenzelm@27037
   740
  The tags \isa{{\isachardoublequote}theory{\isachardoublequote}}, \isa{{\isachardoublequote}proof{\isachardoublequote}}, \isa{{\isachardoublequote}ML{\isachardoublequote}} are already
wenzelm@27037
   741
  pre-declared for certain classes of commands:
wenzelm@27037
   742
wenzelm@27037
   743
 \medskip
wenzelm@27037
   744
wenzelm@27037
   745
  \begin{tabular}{ll}
wenzelm@27037
   746
    \isa{{\isachardoublequote}theory{\isachardoublequote}} & theory begin/end \\
wenzelm@27037
   747
    \isa{{\isachardoublequote}proof{\isachardoublequote}} & all proof commands \\
wenzelm@27037
   748
    \isa{{\isachardoublequote}ML{\isachardoublequote}} & all commands involving ML code \\
wenzelm@27037
   749
  \end{tabular}
wenzelm@27037
   750
wenzelm@27037
   751
  \medskip The Isabelle document preparation system (see also
wenzelm@27037
   752
  \cite{isabelle-sys}) allows tagged command regions to be presented
wenzelm@27037
   753
  specifically, e.g.\ to fold proof texts, or drop parts of the text
wenzelm@27037
   754
  completely.
wenzelm@27037
   755
wenzelm@27037
   756
  For example ``\hyperlink{command.by}{\mbox{\isa{\isacommand{by}}}}~\isa{{\isachardoublequote}{\isacharpercent}invisible\ auto{\isachardoublequote}}'' would
wenzelm@27037
   757
  cause that piece of proof to be treated as \isa{invisible} instead
wenzelm@27037
   758
  of \isa{{\isachardoublequote}proof{\isachardoublequote}} (the default), which may be either show or hidden
wenzelm@27037
   759
  depending on the document setup.  In contrast, ``\hyperlink{command.by}{\mbox{\isa{\isacommand{by}}}}~\isa{{\isachardoublequote}{\isacharpercent}visible\ auto{\isachardoublequote}}'' would force this text to be shown
wenzelm@27037
   760
  invariably.
wenzelm@27037
   761
wenzelm@27037
   762
  Explicit tag specifications within a proof apply to all subsequent
wenzelm@27037
   763
  commands of the same level of nesting.  For example, ``\hyperlink{command.proof}{\mbox{\isa{\isacommand{proof}}}}~\isa{{\isachardoublequote}{\isacharpercent}visible\ {\isasymdots}{\isachardoublequote}}~\hyperlink{command.qed}{\mbox{\isa{\isacommand{qed}}}}'' would force the
wenzelm@27037
   764
  whole sub-proof to be typeset as \isa{visible} (unless some of its
wenzelm@27037
   765
  parts are tagged differently).%
wenzelm@27037
   766
\end{isamarkuptext}%
wenzelm@27037
   767
\isamarkuptrue%
wenzelm@27037
   768
%
wenzelm@27037
   769
\isadelimtheory
wenzelm@27037
   770
%
wenzelm@27037
   771
\endisadelimtheory
wenzelm@27037
   772
%
wenzelm@27037
   773
\isatagtheory
wenzelm@27037
   774
\isacommand{end}\isamarkupfalse%
wenzelm@27037
   775
%
wenzelm@27037
   776
\endisatagtheory
wenzelm@27037
   777
{\isafoldtheory}%
wenzelm@27037
   778
%
wenzelm@27037
   779
\isadelimtheory
wenzelm@27037
   780
%
wenzelm@27037
   781
\endisadelimtheory
wenzelm@27037
   782
\isanewline
wenzelm@27037
   783
\end{isabellebody}%
wenzelm@27037
   784
%%% Local Variables:
wenzelm@27037
   785
%%% mode: latex
wenzelm@27037
   786
%%% TeX-master: "root"
wenzelm@27037
   787
%%% End: