doc-src/IsarRef/syntax.tex
author wenzelm
Mon, 23 Aug 1999 15:27:27 +0200
changeset 7321 b4dcc32310fb
parent 7319 3907d597cae6
child 7335 abba35b98892
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
     1
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
     2
\chapter{Isar document syntax}
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
     3
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
     4
We give a complete reference of all basic syntactic entities underlying the
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
     5
the Isabelle/Isar document syntax.  This chapter will not introduce any actual
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
     6
theory and proof commands, though (cf.\ chapter~\ref{ch:pure-syntax} and
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
     7
later).
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
     8
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
     9
\medskip
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    10
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    11
In order to get started with writing well-formed Isabelle/Isar documents, the
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    12
most important aspect to be noted is the difference of \emph{inner} versus
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    13
\emph{outer} syntax.  Inner syntax is that of Isabelle types and terms of the
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    14
logic, while outer syntax is that of Isabelle/Isar theories (and proofs).  As
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    15
a general rule, inner syntax entities may occur only as \emph{atomic entities}
7319
wenzelm
parents: 7315
diff changeset
    16
within outer syntax.  Thus, string \texttt{"x + y"} and identifier \texttt{z}
wenzelm
parents: 7315
diff changeset
    17
are legal term specifications, while \texttt{x + y} is not.
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    18
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    19
\begin{warn}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    20
  Note that old-style Isabelle theories used to fake parts of the inner type
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    21
  syntax, with complicated rules when quotes may be omitted.  Despite the
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    22
  minor drawback of requiring quotes more often, Isabelle/Isar is simpler and
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    23
  more robust in that respect.
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    24
\end{warn}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    25
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    26
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    27
\section{Lexical matters}\label{sec:lex-syntax}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    28
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    29
The Isabelle/Isar outer syntax provides token classes as presented below.
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    30
Note that some of these coincide (by full intention) with inner lexical syntax
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    31
as given in \cite{isabelle-ref}.  These different levels of syntax should not
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    32
be confused, though.
7134
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
    33
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    34
\begin{matharray}{rcl}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    35
  ident & = & letter~quasiletter^* \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    36
  longident & = & ident\verb,.,ident~\dots~ident \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    37
  symident & = & sym^+ \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    38
  nat & = & digit^+ \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    39
  var & = & \verb,?,ident ~|~ \verb,?,ident\verb,.,nat \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    40
  textvar & = & \verb,??,ident \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    41
  typefree & = & \verb,',ident \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    42
  typevar & = & \verb,?,typefree ~|~ \verb,?,typefree\verb,.,nat \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    43
  string & = & \verb,", ~\dots~ \verb,", \\
7319
wenzelm
parents: 7315
diff changeset
    44
  verbatim & = & \verb,{*, ~\dots~ \verb,*}, \\
wenzelm
parents: 7315
diff changeset
    45
\end{matharray}
wenzelm
parents: 7315
diff changeset
    46
\begin{matharray}{rcl}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    47
  letter & = & \verb,a, ~|~ \dots ~|~ \verb,z, ~|~ \verb,A, ~|~ \dots ~|~ \verb,Z, \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    48
  digit & = & \verb,0, ~|~ \dots ~|~ \verb,9, \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    49
  quasiletter & = & letter ~|~ digit ~|~ \verb,_, ~|~ \verb,', \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    50
  sym & = & \verb,!, ~|~ \verb,#, ~|~ \verb,$, ~|~ \verb,%, ~|~ \verb,&, ~|~  %$
7319
wenzelm
parents: 7315
diff changeset
    51
   \verb,*, ~|~ \verb,+, ~|~ \verb,-, ~|~ \verb,/, ~|~ \verb,:, ~|~
wenzelm
parents: 7315
diff changeset
    52
   \verb,<, ~|~ \verb,=, ~|~ \verb,>, ~|~ \verb,?, ~|~ \mathtt{\at} ~|~ \\
wenzelm
parents: 7315
diff changeset
    53
  & & \verb,^, ~|~ \verb,_, ~|~ \verb,`, ~|~ \verb,|, ~|~ \verb,~, \\
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    54
\end{matharray}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    55
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    56
The syntax of \texttt{string} admits any characters, including newlines;
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    57
\verb|"| and \verb|\| have to be escaped by a backslash, though.  Note that
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    58
ML-style control character notation is not supported.  The body of
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    59
\texttt{verbatim} may consist of any text not containing \verb|*}|.
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    60
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    61
Comments take the form \texttt{(*~\dots~*)} and may be nested, just as in ML.
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    62
Note that these are \emph{source} comments only, which are stripped after
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    63
lexical analysis of the input.  The Isar document syntax also provides several
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    64
elements of \emph{formal comments} that are actually part of the text (see
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    65
\S\ref{sec:comments}, \S\ref{sec:formal-cmt-thy}, \S\ref{sec:formal-cmt-prf}).
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
    66
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
    67
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
    68
\section{Common syntax entities}
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
    69
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
    70
The Isar proof and theory language syntax has been carefully designed with
7134
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
    71
orthogonality in mind.  Subsequently, we introduce several basic syntactic
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
    72
entities, such as names, terms, theorem specifications, which have been
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
    73
factored out of the actual Isar language elements described later.
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
    74
7167
wenzelm
parents: 7141
diff changeset
    75
Note that some of the basic syntactic entities introduced below act much like
wenzelm
parents: 7141
diff changeset
    76
tokens rather than nonterminals, in particular for the sake of error messages.
7134
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
    77
E.g.\ syntax elements such as $\CONSTS$ referring to \railqtoken{name} or
7167
wenzelm
parents: 7141
diff changeset
    78
\railqtoken{type} would really report a missing name or type rather than any
wenzelm
parents: 7141
diff changeset
    79
of the constituent primitive tokens such as \railtoken{ident} or
wenzelm
parents: 7141
diff changeset
    80
\railtoken{string}.
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
    81
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
    82
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
    83
\subsection{Names}
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
    84
7134
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
    85
Entity \railqtoken{name} usually refers to any name of types, constants,
7167
wenzelm
parents: 7141
diff changeset
    86
theorems etc.\ that are to be \emph{declared} or \emph{defined} (so qualified
7134
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
    87
identifiers are excluded).  Quoted strings provide an escape for
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
    88
non-identifier names or those ruled out by outer syntax keywords (e.g.\ 
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
    89
\verb|"let"|).  Already existing objects are usually referenced by
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
    90
\railqtoken{nameref}.
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
    91
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    92
\indexoutertoken{name}\indexoutertoken{parname}\indexoutertoken{nameref}
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
    93
\begin{rail}
7167
wenzelm
parents: 7141
diff changeset
    94
  name: ident | symident | string
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
    95
  ;
7167
wenzelm
parents: 7141
diff changeset
    96
  parname: '(' name ')'
7141
a67dde8820c0 even more stuff;
wenzelm
parents: 7135
diff changeset
    97
  ;
7167
wenzelm
parents: 7141
diff changeset
    98
  nameref: name | longident
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
    99
  ;
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   100
\end{rail}
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   101
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   102
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   103
\subsection{Comments}\label{sec:comments}
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   104
7167
wenzelm
parents: 7141
diff changeset
   105
Large chunks of plain \railqtoken{text} are usually given
wenzelm
parents: 7141
diff changeset
   106
\railtoken{verbatim}, i.e.\ enclosed in \verb|{*|\dots\verb|*}|.  For
7175
wenzelm
parents: 7167
diff changeset
   107
convenience, any of the smaller text units conforming to \railqtoken{nameref}
wenzelm
parents: 7167
diff changeset
   108
are admitted as well.  Almost any of the Isar commands may be annotated by
wenzelm
parents: 7167
diff changeset
   109
some marginal \railnonterm{comment} of the form \texttt{--} \railqtoken{text}.
7167
wenzelm
parents: 7141
diff changeset
   110
Note that this kind of comment is actually part of the language, while source
wenzelm
parents: 7141
diff changeset
   111
level comments \verb|(*|\dots\verb|*)| are already stripped at the lexical
wenzelm
parents: 7141
diff changeset
   112
level.  A few commands such as $\PROOFNAME$ admit additional markup with a
wenzelm
parents: 7141
diff changeset
   113
``level of interest'': \texttt{\%} followed by an optional number $n$ (default
wenzelm
parents: 7141
diff changeset
   114
$n = 1$) indicates that the respective part of the document becomes $n$ levels
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   115
more obscure; \texttt{\%\%} means that interest drops by $\infty$ ---
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   116
\emph{abandon every hope, who enter here}.
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   117
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   118
\indexoutertoken{text}\indexouternonterm{comment}\indexouternonterm{interest}
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   119
\begin{rail}
7167
wenzelm
parents: 7141
diff changeset
   120
  text: verbatim | nameref
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   121
  ;
7167
wenzelm
parents: 7141
diff changeset
   122
  comment: '--' text
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   123
  ;
7167
wenzelm
parents: 7141
diff changeset
   124
  interest: percent nat? | ppercent
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   125
  ;
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   126
\end{rail}
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   127
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   128
7175
wenzelm
parents: 7167
diff changeset
   129
\subsection{Type classes, Sorts and arities}
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   130
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   131
The syntax of sorts and arities is given directly at the outer level.  Note
7167
wenzelm
parents: 7141
diff changeset
   132
that this is in contrast to that types and terms (see \ref{sec:types-terms}).
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   133
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   134
\indexouternonterm{sort}\indexouternonterm{arity}\indexouternonterm{simplearity}
7135
wenzelm
parents: 7134
diff changeset
   135
\indexouternonterm{classdecl}
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   136
\begin{rail}
7321
wenzelm
parents: 7319
diff changeset
   137
  classdecl: name ('<' (nameref + ','))?
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   138
  ;
7167
wenzelm
parents: 7141
diff changeset
   139
  sort: nameref | lbrace (nameref * ',') rbrace
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   140
  ;
7167
wenzelm
parents: 7141
diff changeset
   141
  arity: ('(' (sort + ',') ')')? sort
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   142
  ;
7167
wenzelm
parents: 7141
diff changeset
   143
  simplearity: ('(' (sort + ',') ')')? nameref
wenzelm
parents: 7141
diff changeset
   144
  ;
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   145
\end{rail}
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   146
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   147
7167
wenzelm
parents: 7141
diff changeset
   148
\subsection{Types and terms}\label{sec:types-terms}
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   149
7167
wenzelm
parents: 7141
diff changeset
   150
The actual inner Isabelle syntax, that of types and terms of the logic, is far
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   151
too flexible in order to be modelled explicitly at the outer theory level.
7167
wenzelm
parents: 7141
diff changeset
   152
Basically, any such entity has to be quoted at the outer level to turn it into
7175
wenzelm
parents: 7167
diff changeset
   153
a single token (the parsing and type-checking is performed later).  For
wenzelm
parents: 7167
diff changeset
   154
convenience, a slightly more liberal convention is adopted: quotes may be
wenzelm
parents: 7167
diff changeset
   155
omitted for any type or term that is already \emph{atomic at the outer level}.
wenzelm
parents: 7167
diff changeset
   156
E.g.\ one may write just \texttt{x} instead of \texttt{"x"}.
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   157
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   158
\indexoutertoken{type}\indexoutertoken{term}\indexoutertoken{prop}
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   159
\begin{rail}
7167
wenzelm
parents: 7141
diff changeset
   160
  type: nameref | typefree | typevar
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   161
  ;
7167
wenzelm
parents: 7141
diff changeset
   162
  term: nameref | var | textvar | nat
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   163
  ;
7167
wenzelm
parents: 7141
diff changeset
   164
  prop: term
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   165
  ;
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   166
\end{rail}
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   167
7167
wenzelm
parents: 7141
diff changeset
   168
Type declarations and definitions usually refer to \railnonterm{typespec} on
wenzelm
parents: 7141
diff changeset
   169
the left-hand side.  This models basic type constructor application at the
wenzelm
parents: 7141
diff changeset
   170
outer syntax level.  Note that only plain postfix notation is available here,
wenzelm
parents: 7141
diff changeset
   171
but no infixes.
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   172
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   173
\indexouternonterm{typespec}
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   174
\begin{rail}
7167
wenzelm
parents: 7141
diff changeset
   175
  typespec: (() | typefree | '(' ( typefree + ',' ) ')') name
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   176
  ;
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   177
\end{rail}
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   178
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   179
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   180
\subsection{Term patterns}\label{sec:term-pats}
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   181
7167
wenzelm
parents: 7141
diff changeset
   182
Assumptions and goal statements usually admit automatic binding of schematic
wenzelm
parents: 7141
diff changeset
   183
text variables by giving (optional) patterns of the form $\IS{p@1 \dots p@n}$.
wenzelm
parents: 7141
diff changeset
   184
There are separate versions available for \railqtoken{term}s and
wenzelm
parents: 7141
diff changeset
   185
\railqtoken{prop}s.  The latter provides a $\CONCLNAME$ part with patterns
wenzelm
parents: 7141
diff changeset
   186
referring the (atomic) conclusion of a rule.
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   187
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   188
\indexouternonterm{termpat}\indexouternonterm{proppat}
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   189
\begin{rail}
7167
wenzelm
parents: 7141
diff changeset
   190
  termpat: '(' ('is' term +) ')'
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   191
  ;
7167
wenzelm
parents: 7141
diff changeset
   192
  proppat: '(' (('is' prop +) | 'concl' ('is' prop +) | ('is' prop +) 'concl' ('is' prop +)) ')'
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   193
  ;
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   194
\end{rail}
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   195
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   196
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   197
\subsection{Mixfix annotations}
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   198
7134
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
   199
Mixfix annotations specify concrete \emph{inner} syntax of Isabelle types and
7167
wenzelm
parents: 7141
diff changeset
   200
terms.  Some commands such as $\TYPES$ admit infixes only, while $\CONSTS$ and
wenzelm
parents: 7141
diff changeset
   201
$\isarkeyword{syntax}$ support the full range of general mixfixes and binders.
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   202
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   203
\indexouternonterm{infix}\indexouternonterm{mixfix}
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   204
\begin{rail}
7167
wenzelm
parents: 7141
diff changeset
   205
  infix: '(' ('infixl' | 'infixr') string? nat ')'
wenzelm
parents: 7141
diff changeset
   206
  ;
7175
wenzelm
parents: 7167
diff changeset
   207
  mixfix: infix | '(' string prios? nat? ')' | '(' 'binder' string prios? nat ')'
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   208
  ;
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   209
7175
wenzelm
parents: 7167
diff changeset
   210
  prios: '[' (nat + ',') ']'
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   211
  ;
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   212
\end{rail}
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   213
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   214
7134
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
   215
\subsection{Attributes and theorems}\label{sec:syn-att}
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   216
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   217
Attributes (and proof methods, see \S\ref{sec:syn-meth}) have their own
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   218
``semi-inner'' syntax, in the sense that input conforming \railnonterm{args}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   219
below are parsed by the attribute a second time.  The attribute argument
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   220
specifications may be any sequence of atomic entities (identifiers, strings
7167
wenzelm
parents: 7141
diff changeset
   221
etc.), or properly bracketed argument lists.  Below \railqtoken{atom} refers
7175
wenzelm
parents: 7167
diff changeset
   222
to any atomic entity, including \railtoken{keyword}s conforming to
wenzelm
parents: 7167
diff changeset
   223
\railtoken{symident}.
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   224
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   225
\indexoutertoken{atom}\indexouternonterm{args}\indexouternonterm{attributes}
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   226
\begin{rail}
7167
wenzelm
parents: 7141
diff changeset
   227
  atom: nameref | typefree | typevar | var | textvar | nat | keyword
7134
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
   228
  ;
7167
wenzelm
parents: 7141
diff changeset
   229
  arg: atom | '(' args ')' | '[' args ']' | lbrace args rbrace
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   230
  ;
7167
wenzelm
parents: 7141
diff changeset
   231
  args: arg *
7134
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
   232
  ;
7167
wenzelm
parents: 7141
diff changeset
   233
  attributes: '[' (nameref args * ',') ']'
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   234
  ;
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   235
\end{rail}
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   236
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   237
Theorem specifications come in several flavours: \railnonterm{axmdecl} and
7175
wenzelm
parents: 7167
diff changeset
   238
\railnonterm{thmdecl} usually refer to axioms, assumptions or results of goal
wenzelm
parents: 7167
diff changeset
   239
statements, \railnonterm{thmdef} collects lists of existing theorems.
wenzelm
parents: 7167
diff changeset
   240
Existing theorems are given by \railnonterm{thmref} and \railnonterm{thmrefs}
wenzelm
parents: 7167
diff changeset
   241
(the former requires an actual singleton result).  Any of these theorem
wenzelm
parents: 7167
diff changeset
   242
specifications may include lists of attributes both on the left and right hand
wenzelm
parents: 7167
diff changeset
   243
sides; attributes are applied to the any immediately preceding theorem.
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   244
7135
wenzelm
parents: 7134
diff changeset
   245
\indexouternonterm{thmdecl}\indexouternonterm{axmdecl}
wenzelm
parents: 7134
diff changeset
   246
\indexouternonterm{thmdef}\indexouternonterm{thmrefs}
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   247
\begin{rail}
7167
wenzelm
parents: 7141
diff changeset
   248
  axmdecl: name attributes? ':'
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   249
  ;
7167
wenzelm
parents: 7141
diff changeset
   250
  thmdecl: thmname ':'
7135
wenzelm
parents: 7134
diff changeset
   251
  ;
7167
wenzelm
parents: 7141
diff changeset
   252
  thmdef: thmname '='
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   253
  ;
7175
wenzelm
parents: 7167
diff changeset
   254
  thmref: nameref attributes?
wenzelm
parents: 7167
diff changeset
   255
  ;
wenzelm
parents: 7167
diff changeset
   256
  thmrefs: thmref +
7134
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
   257
  ;
7167
wenzelm
parents: 7141
diff changeset
   258
wenzelm
parents: 7141
diff changeset
   259
  thmname: name attributes | name | attributes
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   260
  ;
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   261
\end{rail}
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   262
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   263
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   264
\subsection{Proof methods}\label{sec:syn-meth}
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   265
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   266
Proof methods are either basic ones, or expressions composed of methods via
7175
wenzelm
parents: 7167
diff changeset
   267
``\texttt{,}'' (sequential composition), ``\texttt{|}'' (alternative choices),
7167
wenzelm
parents: 7141
diff changeset
   268
``\texttt{?}'' (try), ``\texttt{*}'' (repeat ${} \ge 0$ times), ``\texttt{+}''
wenzelm
parents: 7141
diff changeset
   269
(repeat ${} > 0$ times).  In practice, proof methods are usually just a comma
7175
wenzelm
parents: 7167
diff changeset
   270
separated list of (\railqtoken{nameref}~\railnonterm{args}) specifications.
7167
wenzelm
parents: 7141
diff changeset
   271
Thus the syntax is similar to that of attributes, with plain parentheses
wenzelm
parents: 7141
diff changeset
   272
instead of square brackets (see also \S\ref{sec:syn-att}).  Note that
wenzelm
parents: 7141
diff changeset
   273
parentheses may be dropped for single method specifications without arguments.
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   274
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   275
\indexouternonterm{method}
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   276
\begin{rail}
7167
wenzelm
parents: 7141
diff changeset
   277
  method: (nameref | '(' methods ')') (() | '?' | '*' | '+')
7134
320b412e5800 more stuff;
wenzelm
parents: 7050
diff changeset
   278
  ;
7167
wenzelm
parents: 7141
diff changeset
   279
  methods: (nameref args | method) + (',' | '|')
7050
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   280
  ;
c70d3402fef5 checkpoint;
wenzelm
parents: 7046
diff changeset
   281
\end{rail}
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   282
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   283
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   284
%%% Local Variables: 
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   285
%%% mode: latex
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   286
%%% TeX-master: "isar-ref"
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   287
%%% End: