| author | paulson | 
| Mon, 12 May 2003 12:36:22 +0200 | |
| changeset 14006 | 13f639890266 | 
| parent 13827 | c690cb885db4 | 
| child 14212 | cd05b503ca2d | 
| permissions | -rw-r--r-- | 
| 7046 | 1  | 
|
| 13048 | 2  | 
\chapter{Syntax primitives}
 | 
| 7046 | 3  | 
|
| 12618 | 4  | 
The rather generic framework of Isabelle/Isar syntax emerges from three main  | 
5  | 
syntactic categories: \emph{commands} of the top-level Isar engine (covering
 | 
|
6  | 
theory and proof elements), \emph{methods} for general goal refinements
 | 
|
7  | 
(analogous to traditional ``tactics''), and \emph{attributes} for operations
 | 
|
8  | 
on facts (within a certain context). Here we give a reference of basic  | 
|
9  | 
syntactic entities underlying Isabelle/Isar syntax in a bottom-up manner.  | 
|
10  | 
Concrete theory and proof language elements will be introduced later on.  | 
|
| 7315 | 11  | 
|
12  | 
\medskip  | 
|
13  | 
||
14  | 
In order to get started with writing well-formed Isabelle/Isar documents, the  | 
|
15  | 
most important aspect to be noted is the difference of \emph{inner} versus
 | 
|
16  | 
\emph{outer} syntax.  Inner syntax is that of Isabelle types and terms of the
 | 
|
| 12618 | 17  | 
logic, while outer syntax is that of Isabelle/Isar theory sources (including  | 
| 7895 | 18  | 
proofs). As a general rule, inner syntax entities may occur only as  | 
19  | 
\emph{atomic entities} within outer syntax.  For example, the string
 | 
|
20  | 
\texttt{"x + y"} and identifier \texttt{z} are legal term specifications
 | 
|
21  | 
within a theory, while \texttt{x + y} is not.
 | 
|
| 7315 | 22  | 
|
23  | 
\begin{warn}
 | 
|
| 12618 | 24  | 
Old-style Isabelle theories used to fake parts of the inner syntax of types,  | 
25  | 
with rather complicated rules when quotes may be omitted. Despite the minor  | 
|
26  | 
drawback of requiring quotes more often, the syntax of Isabelle/Isar is  | 
|
27  | 
somewhat simpler and more robust in that respect.  | 
|
| 7315 | 28  | 
\end{warn}
 | 
29  | 
||
| 12618 | 30  | 
Printed theory documents usually omit quotes to gain readability (this is a  | 
31  | 
matter of {\LaTeX} macro setup, say via \verb,\isabellestyle,, see also
 | 
|
32  | 
\cite{isabelle-sys}).  Experienced users of Isabelle/Isar may easily
 | 
|
33  | 
reconstruct the lost technical information, while mere readers need not care  | 
|
34  | 
about quotes at all.  | 
|
35  | 
||
| 7466 | 36  | 
\medskip  | 
37  | 
||
| 9601 | 38  | 
Isabelle/Isar input may contain any number of input termination characters  | 
| 12618 | 39  | 
``\texttt{;}'' (semicolon) to separate commands explicitly.  This is
 | 
| 9601 | 40  | 
particularly useful in interactive shell sessions to make clear where the  | 
| 12618 | 41  | 
current command is intended to end. Otherwise, the interpreter loop will  | 
42  | 
continue to issue a secondary prompt ``\verb,#,'' until an end-of-command is  | 
|
| 13039 | 43  | 
clearly recognized from the input syntax, e.g.\ encounter of the next command  | 
| 12618 | 44  | 
keyword.  | 
| 9601 | 45  | 
|
46  | 
Advanced interfaces such as Proof~General \cite{proofgeneral} do not require
 | 
|
47  | 
explicit semicolons, the amount of input text is determined automatically by  | 
|
| 12618 | 48  | 
inspecting the present content of the Emacs text buffer. In the printed  | 
49  | 
presentation of Isabelle/Isar documents semicolons are omitted altogether for  | 
|
| 7981 | 50  | 
readability.  | 
| 7466 | 51  | 
|
| 12618 | 52  | 
\begin{warn}
 | 
53  | 
Proof~General requires certain syntax classification tables in order to  | 
|
54  | 
achieve properly synchronized interaction with the Isabelle/Isar process.  | 
|
55  | 
These tables need to be consistent with the Isabelle version and particular  | 
|
56  | 
logic image to be used in a running session (common object-logics may well  | 
|
57  | 
change the outer syntax). The standard setup should work correctly with any  | 
|
58  | 
of the ``official'' logic images derived from Isabelle/HOL (including HOLCF  | 
|
59  | 
etc.). Users of alternative logics may need to tell Proof~General  | 
|
60  | 
explicitly, e.g.\ by giving an option \verb,-k ZF, (in conjunction with  | 
|
61  | 
\verb,-l ZF, to specify the default logic image).  | 
|
62  | 
\end{warn}
 | 
|
| 7315 | 63  | 
|
64  | 
\section{Lexical matters}\label{sec:lex-syntax}
 | 
|
65  | 
||
66  | 
The Isabelle/Isar outer syntax provides token classes as presented below.  | 
|
| 7895 | 67  | 
Note that some of these coincide (by full intention) with the inner lexical  | 
| 12618 | 68  | 
syntax as presented in \cite{isabelle-ref}.
 | 
| 7134 | 69  | 
|
| 9617 | 70  | 
\indexoutertoken{ident}\indexoutertoken{longident}\indexoutertoken{symident}
 | 
71  | 
\indexoutertoken{nat}\indexoutertoken{var}\indexoutertoken{typefree}
 | 
|
72  | 
\indexoutertoken{typevar}\indexoutertoken{string}\indexoutertoken{verbatim}
 | 
|
| 7315 | 73  | 
\begin{matharray}{rcl}
 | 
74  | 
ident & = & letter~quasiletter^* \\  | 
|
75  | 
longident & = & ident\verb,.,ident~\dots~ident \\  | 
|
| 8548 | 76  | 
symident & = & sym^+ ~|~ symbol \\  | 
| 7315 | 77  | 
nat & = & digit^+ \\  | 
78  | 
var & = & \verb,?,ident ~|~ \verb,?,ident\verb,.,nat \\  | 
|
79  | 
typefree & = & \verb,',ident \\  | 
|
80  | 
typevar & = & \verb,?,typefree ~|~ \verb,?,typefree\verb,.,nat \\  | 
|
81  | 
string & = & \verb,", ~\dots~ \verb,", \\  | 
|
| 7319 | 82  | 
  verbatim & = & \verb,{*, ~\dots~ \verb,*}, \\
 | 
83  | 
\end{matharray}
 | 
|
84  | 
\begin{matharray}{rcl}
 | 
|
| 7315 | 85  | 
letter & = & \verb,a, ~|~ \dots ~|~ \verb,z, ~|~ \verb,A, ~|~ \dots ~|~ \verb,Z, \\  | 
86  | 
digit & = & \verb,0, ~|~ \dots ~|~ \verb,9, \\  | 
|
87  | 
quasiletter & = & letter ~|~ digit ~|~ \verb,_, ~|~ \verb,', \\  | 
|
88  | 
sym & = & \verb,!, ~|~ \verb,#, ~|~ \verb,$, ~|~ \verb,%, ~|~ \verb,&, ~|~ %$  | 
|
| 10160 | 89  | 
\verb,*, ~|~ \verb,+, ~|~ \verb,-, ~|~ \verb,/, ~|~ \verb,:, ~|~ \\  | 
90  | 
  & & \verb,<, ~|~ \verb,=, ~|~ \verb,>, ~|~ \verb,?, ~|~ \texttt{\at} ~|~
 | 
|
91  | 
\verb,^, ~|~ \verb,_, ~|~ \verb,`, ~|~ \verb,|, ~|~ \verb,~, \\  | 
|
| 12618 | 92  | 
  symbol & = & {\forall} ~|~ {\exists} ~|~ {\land} ~|~ {\lor} ~|~ \dots
 | 
| 7315 | 93  | 
\end{matharray}
 | 
94  | 
||
| 13039 | 95  | 
The syntax of $string$ admits any characters, including newlines; ``\verb|"|''  | 
96  | 
(double-quote) and ``\verb|\|'' (backslash) need to be escaped by a backslash.  | 
|
97  | 
Note that ML-style control characters are \emph{not} supported.  The body of
 | 
|
98  | 
$verbatim$ may consist of any text not containing ``\verb|*}|''; this allows  | 
|
99  | 
convenient inclusion of quotes without further escapes.  | 
|
| 7315 | 100  | 
|
| 12618 | 101  | 
Comments take the form \texttt{(*~\dots~*)} and may in principle be nested,
 | 
102  | 
just as in ML.  Note that these are \emph{source} comments only, which are
 | 
|
103  | 
stripped after lexical analysis of the input. The Isar document syntax also  | 
|
| 12879 | 104  | 
provides \emph{formal comments} that are considered as part of the text (see
 | 
| 12618 | 105  | 
\S\ref{sec:comments}).
 | 
106  | 
||
107  | 
\begin{warn}
 | 
|
108  | 
Proof~General does not handle nested comments properly; it is also unable to  | 
|
109  | 
  keep \verb,(*,\,/\,\verb,{*, and \verb,*),\,/\,\verb,*}, apart, despite
 | 
|
110  | 
their rather different meaning. These are inherent problems of Emacs  | 
|
| 13039 | 111  | 
legacy. Users should not be overly aggressive about nesting or alternating  | 
112  | 
these delimiters.  | 
|
| 12618 | 113  | 
\end{warn}
 | 
114  | 
||
115  | 
\medskip  | 
|
| 7315 | 116  | 
|
| 10160 | 117  | 
Mathematical symbols such as ``$\forall$'' are represented in plain ASCII as  | 
| 12618 | 118  | 
``\verb,\<forall>,''. Concerning Isabelle itself, any sequence of the form  | 
119  | 
\verb,\<,$ident$\verb,>, (or \verb,\\<,$ident$\verb,>,) is a legal symbol.  | 
|
120  | 
Display of appropriate glyphs is a matter of front-end tools, say the  | 
|
121  | 
user-interface of Proof~General plus the X-Symbol package, or the {\LaTeX}
 | 
|
122  | 
macro setup of document output. A list of predefined Isabelle symbols is  | 
|
| 12637 | 123  | 
given in \cite[appendix~A]{isabelle-sys}.
 | 
| 10160 | 124  | 
|
| 7046 | 125  | 
|
126  | 
\section{Common syntax entities}
 | 
|
127  | 
||
| 7335 | 128  | 
Subsequently, we introduce several basic syntactic entities, such as names,  | 
| 7895 | 129  | 
terms, and theorem specifications, which have been factored out of the actual  | 
130  | 
Isar language elements to be described later.  | 
|
| 7134 | 131  | 
|
| 7981 | 132  | 
Note that some of the basic syntactic entities introduced below (e.g.\  | 
| 13048 | 133  | 
\railqtok{name}) act much like tokens rather than plain nonterminals (e.g.\ 
 | 
| 7895 | 134  | 
\railnonterm{sort}), especially for the sake of error messages.  E.g.\ syntax
 | 
| 13048 | 135  | 
elements like $\CONSTS$ referring to \railqtok{name} or \railqtok{type} would
 | 
136  | 
really report a missing name or type rather than any of the constituent  | 
|
137  | 
primitive tokens such as \railtok{ident} or \railtok{string}.
 | 
|
| 7046 | 138  | 
|
| 7050 | 139  | 
|
140  | 
\subsection{Names}
 | 
|
141  | 
||
| 13048 | 142  | 
Entity \railqtok{name} usually refers to any name of types, constants,
 | 
| 7167 | 143  | 
theorems etc.\ that are to be \emph{declared} or \emph{defined} (so qualified
 | 
| 8548 | 144  | 
identifiers are excluded here). Quoted strings provide an escape for  | 
| 7134 | 145  | 
non-identifier names or those ruled out by outer syntax keywords (e.g.\  | 
146  | 
\verb|"let"|). Already existing objects are usually referenced by  | 
|
| 13048 | 147  | 
\railqtok{nameref}.
 | 
| 7050 | 148  | 
|
| 7141 | 149  | 
\indexoutertoken{name}\indexoutertoken{parname}\indexoutertoken{nameref}
 | 
| 9617 | 150  | 
\indexoutertoken{int}
 | 
| 7046 | 151  | 
\begin{rail}
 | 
| 8145 | 152  | 
name: ident | symident | string | nat  | 
| 7046 | 153  | 
;  | 
| 7167 | 154  | 
  parname: '(' name ')'
 | 
| 7141 | 155  | 
;  | 
| 7167 | 156  | 
nameref: name | longident  | 
| 7046 | 157  | 
;  | 
| 9617 | 158  | 
int: nat | '-' nat  | 
159  | 
;  | 
|
| 7046 | 160  | 
\end{rail}
 | 
161  | 
||
| 7050 | 162  | 
|
| 7315 | 163  | 
\subsection{Comments}\label{sec:comments}
 | 
| 7046 | 164  | 
|
| 13048 | 165  | 
Large chunks of plain \railqtok{text} are usually given \railtok{verbatim},
 | 
166  | 
i.e.\ enclosed in \verb|{*|~\dots~\verb|*}|.  For convenience, any of the
 | 
|
167  | 
smaller text units conforming to \railqtok{nameref} are admitted as well.  A
 | 
|
168  | 
marginal \railnonterm{comment} is of the form \texttt{--} \railqtok{text}.
 | 
|
169  | 
Any number of these may occur within Isabelle/Isar commands.  | 
|
| 12618 | 170  | 
|
| 12879 | 171  | 
\indexoutertoken{text}\indexouternonterm{comment}
 | 
| 7046 | 172  | 
\begin{rail}
 | 
| 7167 | 173  | 
text: verbatim | nameref  | 
| 7050 | 174  | 
;  | 
| 12879 | 175  | 
comment: '--' text  | 
| 7046 | 176  | 
;  | 
177  | 
\end{rail}
 | 
|
178  | 
||
179  | 
||
| 7335 | 180  | 
\subsection{Type classes, sorts and arities}
 | 
| 7046 | 181  | 
|
| 8896 | 182  | 
Classes are specified by plain names. Sorts have a very simple inner syntax,  | 
183  | 
which is either a single class name $c$ or a list $\{c@1, \dots, c@n\}$
 | 
|
184  | 
referring to the intersection of these classes. The syntax of type arities is  | 
|
185  | 
given directly at the outer level.  | 
|
| 7050 | 186  | 
|
| 
11100
 
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
 
wenzelm 
parents: 
10858 
diff
changeset
 | 
187  | 
\railalias{subseteq}{\isasymsubseteq}
 | 
| 
 
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
 
wenzelm 
parents: 
10858 
diff
changeset
 | 
188  | 
\railterm{subseteq}
 | 
| 
 
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
 
wenzelm 
parents: 
10858 
diff
changeset
 | 
189  | 
|
| 7050 | 190  | 
\indexouternonterm{sort}\indexouternonterm{arity}\indexouternonterm{simplearity}
 | 
| 7135 | 191  | 
\indexouternonterm{classdecl}
 | 
| 7046 | 192  | 
\begin{rail}
 | 
| 
11100
 
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
 
wenzelm 
parents: 
10858 
diff
changeset
 | 
193  | 
  classdecl: name (('<' | subseteq) (nameref + ','))?
 | 
| 7046 | 194  | 
;  | 
| 8896 | 195  | 
sort: nameref  | 
| 7046 | 196  | 
;  | 
| 7167 | 197  | 
  arity: ('(' (sort + ',') ')')? sort
 | 
| 7050 | 198  | 
;  | 
| 7167 | 199  | 
  simplearity: ('(' (sort + ',') ')')? nameref
 | 
200  | 
;  | 
|
| 7050 | 201  | 
\end{rail}
 | 
202  | 
||
203  | 
||
| 7167 | 204  | 
\subsection{Types and terms}\label{sec:types-terms}
 | 
| 7050 | 205  | 
|
| 7167 | 206  | 
The actual inner Isabelle syntax, that of types and terms of the logic, is far  | 
| 7895 | 207  | 
too sophisticated in order to be modelled explicitly at the outer theory  | 
| 8548 | 208  | 
level. Basically, any such entity has to be quoted to turn it into a single  | 
209  | 
token (the parsing and type-checking is performed internally later). For  | 
|
210  | 
convenience, a slightly more liberal convention is adopted: quotes may be  | 
|
| 13039 | 211  | 
omitted for any type or term that is already atomic at the outer level. For  | 
212  | 
example, one may just write \texttt{x} instead of \texttt{"x"}.  Note that
 | 
|
| 8548 | 213  | 
symbolic identifiers (e.g.\ \texttt{++} or $\forall$) are available as well,
 | 
| 12618 | 214  | 
provided these have not been superseded by commands or other keywords already  | 
215  | 
(e.g.\ \texttt{=} or \texttt{+}).
 | 
|
| 7050 | 216  | 
|
217  | 
\indexoutertoken{type}\indexoutertoken{term}\indexoutertoken{prop}
 | 
|
218  | 
\begin{rail}
 | 
|
| 7167 | 219  | 
type: nameref | typefree | typevar  | 
| 7050 | 220  | 
;  | 
| 8593 | 221  | 
term: nameref | var  | 
| 7050 | 222  | 
;  | 
| 7167 | 223  | 
prop: term  | 
| 7050 | 224  | 
;  | 
225  | 
\end{rail}
 | 
|
226  | 
||
| 8690 | 227  | 
Positional instantiations are indicated by giving a sequence of terms, or the  | 
228  | 
placeholder ``$\_$'' (underscore), which means to skip a position.  | 
|
229  | 
||
230  | 
\indexoutertoken{inst}\indexoutertoken{insts}
 | 
|
231  | 
\begin{rail}
 | 
|
232  | 
inst: underscore | term  | 
|
233  | 
;  | 
|
234  | 
insts: (inst *)  | 
|
235  | 
;  | 
|
236  | 
\end{rail}
 | 
|
237  | 
||
| 7167 | 238  | 
Type declarations and definitions usually refer to \railnonterm{typespec} on
 | 
239  | 
the left-hand side. This models basic type constructor application at the  | 
|
240  | 
outer syntax level. Note that only plain postfix notation is available here,  | 
|
241  | 
but no infixes.  | 
|
| 7050 | 242  | 
|
243  | 
\indexouternonterm{typespec}
 | 
|
244  | 
\begin{rail}
 | 
|
| 7167 | 245  | 
  typespec: (() | typefree | '(' ( typefree + ',' ) ')') name
 | 
| 7050 | 246  | 
;  | 
247  | 
\end{rail}
 | 
|
248  | 
||
249  | 
||
250  | 
\subsection{Mixfix annotations}
 | 
|
251  | 
||
| 7134 | 252  | 
Mixfix annotations specify concrete \emph{inner} syntax of Isabelle types and
 | 
| 12618 | 253  | 
terms.  Some commands such as $\TYPES$ (see \S\ref{sec:types-pure}) admit
 | 
254  | 
infixes only, while $\CONSTS$ (see \S\ref{sec:consts}) and
 | 
|
255  | 
$\isarkeyword{syntax}$ (see \S\ref{sec:syn-trans}) support the full range of
 | 
|
256  | 
general mixfixes and binders.  | 
|
| 7046 | 257  | 
|
| 12976 | 258  | 
\indexouternonterm{infix}\indexouternonterm{mixfix}\indexouternonterm{structmixfix}
 | 
| 7046 | 259  | 
\begin{rail}
 | 
| 11651 | 260  | 
  infix: '(' ('infix' | 'infixl' | 'infixr') string? nat ')'
 | 
| 7167 | 261  | 
;  | 
| 7175 | 262  | 
  mixfix: infix | '(' string prios? nat? ')' | '(' 'binder' string prios? nat ')'
 | 
| 7050 | 263  | 
;  | 
| 12976 | 264  | 
  structmixfix: mixfix | '(' 'structure' ')'
 | 
265  | 
;  | 
|
| 7050 | 266  | 
|
| 7175 | 267  | 
prios: '[' (nat + ',') ']'  | 
| 7050 | 268  | 
;  | 
| 7046 | 269  | 
\end{rail}
 | 
270  | 
||
| 13048 | 271  | 
Here the \railtok{string} specifications refer to the actual mixfix template
 | 
| 12618 | 272  | 
(see also \cite{isabelle-ref}), which may include literal text, spacing,
 | 
273  | 
blocks, and arguments (denoted by ``$_$''); the special symbol \verb,\<index>,  | 
|
274  | 
(printed as ``\i'') represents an index argument that specifies an implicit  | 
|
275  | 
structure reference (see also \S\ref{sec:locale}).  Infix and binder
 | 
|
276  | 
declarations provide common abbreviations for particular mixfix declarations.  | 
|
277  | 
So in practice, mixfix templates mostly degenerate to literal text for  | 
|
278  | 
concrete syntax, such as ``\verb,++,'' for an infix symbol, or ``\verb,++,\i''  | 
|
279  | 
for an infix of an implicit structure.  | 
|
280  | 
||
281  | 
||
282  | 
||
283  | 
\subsection{Proof methods}\label{sec:syn-meth}
 | 
|
284  | 
||
285  | 
Proof methods are either basic ones, or expressions composed of methods via  | 
|
286  | 
``\texttt{,}'' (sequential composition), ``\texttt{|}'' (alternative choices),
 | 
|
287  | 
``\texttt{?}'' (try), ``\texttt{+}'' (repeat at least once).  In practice,
 | 
|
288  | 
proof methods are usually just a comma separated list of  | 
|
| 13048 | 289  | 
\railqtok{nameref}~\railnonterm{args} specifications.  Note that parentheses
 | 
| 12618 | 290  | 
may be dropped for single method specifications (with no arguments).  | 
291  | 
||
292  | 
\indexouternonterm{method}
 | 
|
293  | 
\begin{rail}
 | 
|
294  | 
  method: (nameref | '(' methods ')') (() | '?' | '+')
 | 
|
295  | 
;  | 
|
296  | 
  methods: (nameref args | method) + (',' | '|')
 | 
|
297  | 
;  | 
|
298  | 
\end{rail}
 | 
|
299  | 
||
300  | 
Proper use of Isar proof methods does \emph{not} involve goal addressing.
 | 
|
301  | 
Nevertheless, specifying goal ranges may occasionally come in handy in  | 
|
302  | 
emulating tactic scripts. Note that $[n-]$ refers to all goals, starting from  | 
|
303  | 
$n$. All goals may be specified by $[!]$, which is the same as $[1-]$.  | 
|
304  | 
||
305  | 
\indexouternonterm{goalspec}
 | 
|
306  | 
\begin{rail}
 | 
|
307  | 
goalspec: '[' (nat '-' nat | nat '-' | nat | '!' ) ']'  | 
|
308  | 
;  | 
|
309  | 
\end{rail}
 | 
|
310  | 
||
| 7050 | 311  | 
|
| 7134 | 312  | 
\subsection{Attributes and theorems}\label{sec:syn-att}
 | 
| 7050 | 313  | 
|
314  | 
Attributes (and proof methods, see \S\ref{sec:syn-meth}) have their own
 | 
|
| 7335 | 315  | 
``semi-inner'' syntax, in the sense that input conforming to  | 
316  | 
\railnonterm{args} below is parsed by the attribute a second time.  The
 | 
|
317  | 
attribute argument specifications may be any sequence of atomic entities  | 
|
318  | 
(identifiers, strings etc.), or properly bracketed argument lists. Below  | 
|
| 13048 | 319  | 
\railqtok{atom} refers to any atomic entity, including any \railtok{keyword}
 | 
320  | 
conforming to \railtok{symident}.
 | 
|
| 7050 | 321  | 
|
322  | 
\indexoutertoken{atom}\indexouternonterm{args}\indexouternonterm{attributes}
 | 
|
323  | 
\begin{rail}
 | 
|
| 7466 | 324  | 
atom: nameref | typefree | typevar | var | nat | keyword  | 
| 7134 | 325  | 
;  | 
| 8896 | 326  | 
  arg: atom | '(' args ')' | '[' args ']'
 | 
| 7050 | 327  | 
;  | 
| 7167 | 328  | 
args: arg *  | 
| 7134 | 329  | 
;  | 
| 7167 | 330  | 
attributes: '[' (nameref args * ',') ']'  | 
| 7050 | 331  | 
;  | 
332  | 
\end{rail}
 | 
|
333  | 
||
| 7895 | 334  | 
Theorem specifications come in several flavors: \railnonterm{axmdecl} and
 | 
| 7175 | 335  | 
\railnonterm{thmdecl} usually refer to axioms, assumptions or results of goal
 | 
| 7981 | 336  | 
statements, while \railnonterm{thmdef} collects lists of existing theorems.
 | 
337  | 
Existing theorems are given by \railnonterm{thmref} and \railnonterm{thmrefs},
 | 
|
338  | 
the former requires an actual singleton result. Any of these theorem  | 
|
| 7175 | 339  | 
specifications may include lists of attributes both on the left and right hand  | 
| 13039 | 340  | 
sides; attributes are applied to any immediately preceding fact. If names are  | 
341  | 
omitted, the theorems are not stored within the theorem database of the theory  | 
|
342  | 
or proof context; any given attributes are still applied, though.  | 
|
| 7050 | 343  | 
|
| 7135 | 344  | 
\indexouternonterm{thmdecl}\indexouternonterm{axmdecl}
 | 
345  | 
\indexouternonterm{thmdef}\indexouternonterm{thmrefs}
 | 
|
| 7050 | 346  | 
\begin{rail}
 | 
| 7167 | 347  | 
axmdecl: name attributes? ':'  | 
| 7050 | 348  | 
;  | 
| 9200 | 349  | 
thmdecl: thmbind ':'  | 
| 7135 | 350  | 
;  | 
| 9200 | 351  | 
thmdef: thmbind '='  | 
| 7050 | 352  | 
;  | 
| 7175 | 353  | 
thmref: nameref attributes?  | 
354  | 
;  | 
|
355  | 
thmrefs: thmref +  | 
|
| 7134 | 356  | 
;  | 
| 7167 | 357  | 
|
| 9200 | 358  | 
thmbind: name attributes | name | attributes  | 
| 7050 | 359  | 
;  | 
360  | 
\end{rail}
 | 
|
| 7046 | 361  | 
|
362  | 
||
| 12618 | 363  | 
\subsection{Term patterns and declarations}\label{sec:term-decls}
 | 
| 7046 | 364  | 
|
| 12618 | 365  | 
Wherever explicit propositions (or term fragments) occur in a proof text,  | 
366  | 
casual binding of schematic term variables may be given specified via patterns  | 
|
| 13039 | 367  | 
of the form ``$\ISS{p@1\;\dots}{p@n}$''.  There are separate versions
 | 
| 13048 | 368  | 
available for \railqtok{term}s and \railqtok{prop}s.  The latter provides a
 | 
369  | 
$\CONCLNAME$ part with patterns referring the (atomic) conclusion of a rule.  | 
|
| 7046 | 370  | 
|
| 12618 | 371  | 
\indexouternonterm{termpat}\indexouternonterm{proppat}
 | 
| 7050 | 372  | 
\begin{rail}
 | 
| 12618 | 373  | 
  termpat: '(' ('is' term +) ')'
 | 
| 7134 | 374  | 
;  | 
| 12618 | 375  | 
  proppat: '(' (('is' prop +) | 'concl' ('is' prop +) | ('is' prop +) 'concl' ('is' prop +)) ')'
 | 
| 7050 | 376  | 
;  | 
377  | 
\end{rail}
 | 
|
| 7046 | 378  | 
|
| 12618 | 379  | 
Declarations of local variables $x :: \tau$ and logical propositions $a :  | 
380  | 
\phi$ represent different views on the same principle of introducing a local  | 
|
381  | 
scope. In practice, one may usually omit the typing of $vars$ (due to  | 
|
| 13039 | 382  | 
type-inference), and the naming of propositions (due to implicit references of  | 
383  | 
current facts). In any case, Isar proof elements usually admit to introduce  | 
|
| 12618 | 384  | 
multiple such items simultaneously.  | 
| 8532 | 385  | 
|
| 12618 | 386  | 
\indexouternonterm{vars}\indexouternonterm{props}
 | 
| 8532 | 387  | 
\begin{rail}
 | 
| 12618 | 388  | 
  vars: (name+) ('::' type)?
 | 
389  | 
;  | 
|
390  | 
props: thmdecl? (prop proppat? +)  | 
|
| 8532 | 391  | 
;  | 
392  | 
\end{rail}
 | 
|
393  | 
||
| 12618 | 394  | 
The treatment of multiple declarations corresponds to the complementary focus  | 
395  | 
of $vars$ versus $props$: in ``$x@1~\dots~x@n :: \tau$'' the typing refers to  | 
|
396  | 
all variables, while in $a\colon \phi@1~\dots~\phi@n$ the naming refers to all  | 
|
397  | 
propositions collectively. Isar language elements that refer to $vars$ or  | 
|
398  | 
$props$ typically admit separate typings or namings via another level of  | 
|
399  | 
iteration, with explicit $\AND$ separators; e.g.\ see $\FIXNAME$ and  | 
|
400  | 
$\ASSUMENAME$ in \S\ref{sec:proof-context}.
 | 
|
401  | 
||
| 7046 | 402  | 
|
| 9200 | 403  | 
\subsection{Antiquotations}\label{sec:antiq}
 | 
404  | 
||
| 10336 | 405  | 
\begin{matharray}{rcl}
 | 
406  | 
thm & : & \isarantiq \\  | 
|
407  | 
prop & : & \isarantiq \\  | 
|
408  | 
term & : & \isarantiq \\  | 
|
409  | 
typ & : & \isarantiq \\  | 
|
410  | 
text & : & \isarantiq \\  | 
|
411  | 
goals & : & \isarantiq \\  | 
|
| 10351 | 412  | 
subgoals & : & \isarantiq \\  | 
| 
13827
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
413  | 
prf & : & \isarantiq \\  | 
| 
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
414  | 
full_prf & : & \isarantiq \\  | 
| 10336 | 415  | 
\end{matharray}
 | 
416  | 
||
| 9200 | 417  | 
The text body of formal comments (see also \S\ref{sec:comments}) may contain
 | 
418  | 
antiquotations of logical entities, such as theorems, terms and types, which  | 
|
419  | 
are to be presented in the final output produced by the Isabelle document  | 
|
420  | 
preparation system (see also \S\ref{sec:document-prep}).
 | 
|
421  | 
||
| 9601 | 422  | 
Thus embedding of  | 
| 13039 | 423  | 
``\texttt{{\at}{\ttlbrace}term~[show_types]~"f(x)~=~a~+~x"{\ttrbrace}}''
 | 
424  | 
within a text block would cause  | 
|
| 9200 | 425  | 
\isa{(f{\isasymColon}'a~{\isasymRightarrow}~'a)~(x{\isasymColon}'a)~=~(a{\isasymColon}'a)~+~x}
 | 
| 10160 | 426  | 
to appear in the final {\LaTeX} document.  Also note that theorem
 | 
427  | 
antiquotations may involve attributes as well. For example,  | 
|
428  | 
\texttt{{\at}{\ttlbrace}thm~sym~[no_vars]{\ttrbrace}} would print the
 | 
|
429  | 
statement where all schematic variables have been replaced by fixed ones,  | 
|
| 12618 | 430  | 
which are easier to read.  | 
| 9200 | 431  | 
|
| 9728 | 432  | 
\indexisarant{thm}\indexisarant{prop}\indexisarant{term}
 | 
| 10355 | 433  | 
\indexisarant{typ}\indexisarant{text}\indexisarant{goals}\indexisarant{subgoals}
 | 
| 9200 | 434  | 
\begin{rail}
 | 
435  | 
atsign lbrace antiquotation rbrace  | 
|
436  | 
;  | 
|
437  | 
||
438  | 
antiquotation:  | 
|
439  | 
'thm' options thmrefs |  | 
|
440  | 
'prop' options prop |  | 
|
441  | 
'term' options term |  | 
|
| 9728 | 442  | 
'typ' options type |  | 
| 
10319
 
02463775cafb
added antiquotation "goals" and option "goals_limit";
 
wenzelm 
parents: 
10160 
diff
changeset
 | 
443  | 
'text' options name |  | 
| 10355 | 444  | 
'goals' options |  | 
| 
13827
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
445  | 
'subgoals' options |  | 
| 
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
446  | 
'prf' options thmrefs |  | 
| 
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
447  | 
'full\_prf' options thmrefs  | 
| 9200 | 448  | 
;  | 
449  | 
options: '[' (option * ',') ']'  | 
|
450  | 
;  | 
|
451  | 
option: name | name '=' name  | 
|
452  | 
;  | 
|
453  | 
\end{rail}
 | 
|
454  | 
||
455  | 
Note that the syntax of antiquotations may \emph{not} include source comments
 | 
|
456  | 
\texttt{(*~\dots~*)} or verbatim text \verb|{*|~\dots~\verb|*}|.
 | 
|
457  | 
||
| 
10319
 
02463775cafb
added antiquotation "goals" and option "goals_limit";
 
wenzelm 
parents: 
10160 
diff
changeset
 | 
458  | 
\begin{descr}
 | 
| 13039 | 459  | 
|
| 10336 | 460  | 
\item [$\at\{thm~\vec a\}$] prints theorems $\vec a$. Note that attribute
 | 
461  | 
  specifications may be included as well (see also \S\ref{sec:syn-att}); the
 | 
|
| 12618 | 462  | 
  $no_vars$ operation (see \S\ref{sec:misc-meth-att}) would be particularly
 | 
| 10336 | 463  | 
useful to suppress printing of schematic variables.  | 
| 13039 | 464  | 
|
| 10336 | 465  | 
\item [$\at\{prop~\phi\}$] prints a well-typed proposition $\phi$.
 | 
| 13039 | 466  | 
|
| 10336 | 467  | 
\item [$\at\{term~t\}$] prints a well-typed term $t$.
 | 
| 13039 | 468  | 
|
| 10336 | 469  | 
\item [$\at\{typ~\tau\}$] prints a well-formed type $\tau$.
 | 
| 13039 | 470  | 
|
| 10336 | 471  | 
\item [$\at\{text~s\}$] prints uninterpreted source text $s$.  This is
 | 
472  | 
particularly useful to print portions of text according to the Isabelle  | 
|
473  | 
  {\LaTeX} output style, without demanding well-formedness (e.g.\ small pieces
 | 
|
| 13039 | 474  | 
of terms that should not be parsed or type-checked yet).  | 
475  | 
||
| 10336 | 476  | 
\item [$\at\{goals\}$] prints the current \emph{dynamic} goal state.  This is
 | 
| 13039 | 477  | 
mainly for support of tactic-emulation scripts within Isar --- presentation  | 
478  | 
of goal states does not conform to actual human-readable proof documents.  | 
|
| 
10319
 
02463775cafb
added antiquotation "goals" and option "goals_limit";
 
wenzelm 
parents: 
10160 
diff
changeset
 | 
479  | 
Please do not include goal states into document output unless you really  | 
| 
 
02463775cafb
added antiquotation "goals" and option "goals_limit";
 
wenzelm 
parents: 
10160 
diff
changeset
 | 
480  | 
know what you are doing!  | 
| 13039 | 481  | 
|
| 10355 | 482  | 
\item [$\at\{subgoals\}$] behaves almost like $goals$, except that it does not
 | 
483  | 
print the main goal.  | 
|
| 13039 | 484  | 
|
| 
13827
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
485  | 
\item [$\at\{prf~\vec a\}$] prints the (compact) proof terms corresponding to
 | 
| 
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
486  | 
the theorems $\vec a$. Note that this  | 
| 
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
487  | 
requires proof terms to be switched on for the current object logic  | 
| 
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
488  | 
(see the ``Proof terms'' section of the Isabelle reference manual  | 
| 
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
489  | 
for information on how to do this).  | 
| 
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
490  | 
|
| 
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
491  | 
\item [$\at\{full_prf~\vec a\}$] is like $\at\{prf~\vec a\}$, but displays
 | 
| 
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
492  | 
the full proof terms, i.e.\ also displays information omitted in  | 
| 
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
493  | 
the compact proof term, which is denoted by ``$_$'' placeholders there.  | 
| 
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
494  | 
|
| 
10319
 
02463775cafb
added antiquotation "goals" and option "goals_limit";
 
wenzelm 
parents: 
10160 
diff
changeset
 | 
495  | 
\end{descr}
 | 
| 
 
02463775cafb
added antiquotation "goals" and option "goals_limit";
 
wenzelm 
parents: 
10160 
diff
changeset
 | 
496  | 
|
| 9200 | 497  | 
\medskip  | 
498  | 
||
| 10336 | 499  | 
The following options are available to tune the output. Note that most of  | 
| 9233 | 500  | 
these coincide with ML flags of the same names (see also \cite{isabelle-ref}).
 | 
| 9200 | 501  | 
\begin{descr}
 | 
| 9233 | 502  | 
\item[$show_types = bool$ and $show_sorts = bool$] control printing of  | 
| 9234 | 503  | 
explicit type and sort constraints.  | 
| 9233 | 504  | 
\item[$long_names = bool$] forces names of types and constants etc.\ to be  | 
505  | 
printed in their fully qualified internal form.  | 
|
506  | 
\item[$eta_contract = bool$] prints terms in $\eta$-contracted form.  | 
|
| 9200 | 507  | 
\item[$display = bool$] indicates if the text is to be output as multi-line  | 
508  | 
``display material'', rather than a small piece of text without line breaks  | 
|
509  | 
(which is the default).  | 
|
510  | 
\item[$quotes = bool$] indicates if the output should be enclosed in double  | 
|
511  | 
quotes.  | 
|
| 9233 | 512  | 
\item[$mode = name$] adds $name$ to the print mode to be used for presentation  | 
513  | 
  (see also \cite{isabelle-ref}).  Note that the standard setup for {\LaTeX}
 | 
|
514  | 
output is already present by default, including the modes ``$latex$'',  | 
|
515  | 
``$xsymbols$'', ``$symbols$''.  | 
|
| 9728 | 516  | 
\item[$margin = nat$ and $indent = nat$] change the margin or indentation for  | 
517  | 
pretty printing of display material.  | 
|
| 9752 | 518  | 
\item[$source = bool$] prints the source text of the antiquotation arguments,  | 
519  | 
rather than the actual value. Note that this does not affect  | 
|
520  | 
well-formedness checks of $thm$, $term$, etc. (only the $text$ antiquotation  | 
|
521  | 
admits arbitrary output).  | 
|
| 
10319
 
02463775cafb
added antiquotation "goals" and option "goals_limit";
 
wenzelm 
parents: 
10160 
diff
changeset
 | 
522  | 
\item[$goals_limit = nat$] determines the maximum number of goals to be  | 
| 
 
02463775cafb
added antiquotation "goals" and option "goals_limit";
 
wenzelm 
parents: 
10160 
diff
changeset
 | 
523  | 
printed.  | 
| 9200 | 524  | 
\end{descr}
 | 
525  | 
||
526  | 
For boolean flags, ``$name = true$'' may be abbreviated as ``$name$''. All of  | 
|
527  | 
the above flags are disabled by default, unless changed from ML.  | 
|
528  | 
||
| 10336 | 529  | 
\medskip Note that antiquotations do not only spare the author from tedious  | 
| 13039 | 530  | 
typing of logical entities, but also achieve some degree of  | 
531  | 
consistency-checking of informal explanations with formal developments:  | 
|
532  | 
well-formedness of terms and types with respect to the current theory or proof  | 
|
533  | 
context is ensured here.  | 
|
| 9200 | 534  | 
|
| 7046 | 535  | 
%%% Local Variables:  | 
536  | 
%%% mode: latex  | 
|
537  | 
%%% TeX-master: "isar-ref"  | 
|
538  | 
%%% End:  |