| author | haftmann | 
| Thu, 09 Aug 2007 15:52:53 +0200 | |
| changeset 24198 | 4031da6d8ba3 | 
| parent 24033 | 386f025be266 | 
| child 25266 | 37aa898e0523 | 
| 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  | 
||
| 14955 | 66  | 
The Isabelle/Isar outer syntax provides token classes as presented below; most  | 
67  | 
of these coincide with the inner lexical syntax as presented in  | 
|
68  | 
\cite{isabelle-ref}.
 | 
|
| 7134 | 69  | 
|
| 9617 | 70  | 
\indexoutertoken{ident}\indexoutertoken{longident}\indexoutertoken{symident}
 | 
71  | 
\indexoutertoken{nat}\indexoutertoken{var}\indexoutertoken{typefree}
 | 
|
| 18021 | 72  | 
\indexoutertoken{typevar}\indexoutertoken{string}\indexoutertoken{altstring}
 | 
73  | 
\indexoutertoken{verbatim}
 | 
|
| 7315 | 74  | 
\begin{matharray}{rcl}
 | 
| 14955 | 75  | 
ident & = & letter\,quasiletter^* \\  | 
76  | 
longident & = & ident (\verb,.,ident)^+ \\  | 
|
77  | 
symident & = & sym^+ ~|~ \verb,\<,ident\verb,>, \\  | 
|
| 7315 | 78  | 
nat & = & digit^+ \\  | 
| 14212 | 79  | 
var & = & ident ~|~ \verb,?,ident ~|~ \verb,?,ident\verb,.,nat \\  | 
| 7315 | 80  | 
typefree & = & \verb,',ident \\  | 
| 14212 | 81  | 
typevar & = & typefree ~|~ \verb,?,typefree ~|~ \verb,?,typefree\verb,.,nat \\  | 
| 7315 | 82  | 
string & = & \verb,", ~\dots~ \verb,", \\  | 
| 18021 | 83  | 
altstring & = & \backquote ~\dots~ \backquote \\  | 
| 14483 | 84  | 
  verbatim & = & \verb,{*, ~\dots~ \verb,*}, \\[1ex]
 | 
85  | 
||
| 14960 | 86  | 
letter & = & latin ~|~ \verb,\<,latin\verb,>, ~|~ \verb,\<,latin\,latin\verb,>, ~|~ greek ~|~ \\  | 
87  | 
& & \verb,\<^isub>, ~|~ \verb,\<^isup>, \\  | 
|
88  | 
quasiletter & = & letter ~|~ digit ~|~ \verb,_, ~|~ \verb,', \\  | 
|
| 14895 | 89  | 
latin & = & \verb,a, ~|~ \dots ~|~ \verb,z, ~|~ \verb,A, ~|~ \dots ~|~ \verb,Z, \\  | 
| 7315 | 90  | 
digit & = & \verb,0, ~|~ \dots ~|~ \verb,9, \\  | 
91  | 
sym & = & \verb,!, ~|~ \verb,#, ~|~ \verb,$, ~|~ \verb,%, ~|~ \verb,&, ~|~ %$  | 
|
| 20120 | 92  | 
\verb,*, ~|~ \verb,+, ~|~ \verb,-, ~|~ \verb,/, ~|~ \\  | 
| 10160 | 93  | 
  & & \verb,<, ~|~ \verb,=, ~|~ \verb,>, ~|~ \verb,?, ~|~ \texttt{\at} ~|~
 | 
| 17174 | 94  | 
\verb,^, ~|~ \verb,_, ~|~ \verb,|, ~|~ \verb,~, \\  | 
| 14955 | 95  | 
greek & = & \verb,\<alpha>, ~|~ \verb,\<beta>, ~|~ \verb,\<gamma>, ~|~ \verb,\<delta>, ~| \\  | 
96  | 
& & \verb,\<epsilon>, ~|~ \verb,\<zeta>, ~|~ \verb,\<eta>, ~|~ \verb,\<theta>, ~| \\  | 
|
97  | 
& & \verb,\<iota>, ~|~ \verb,\<kappa>, ~|~ \verb,\<mu>, ~|~ \verb,\<nu>, ~| \\  | 
|
98  | 
& & \verb,\<xi>, ~|~ \verb,\<pi>, ~|~ \verb,\<rho>, ~|~ \verb,\<sigma>, ~| \\  | 
|
99  | 
& & \verb,\<tau>, ~|~ \verb,\<upsilon>, ~|~ \verb,\<phi>, ~|~ \verb,\<psi>, ~| \\  | 
|
100  | 
& & \verb,\<omega>, ~|~ \verb,\<Gamma>, ~|~ \verb,\<Delta>, ~|~ \verb,\<Theta>, ~| \\  | 
|
101  | 
& & \verb,\<Lambda>, ~|~ \verb,\<Xi>, ~|~ \verb,\<Pi>, ~|~ \verb,\<Sigma>, ~| \\  | 
|
102  | 
& & \verb,\<Upsilon>, ~|~ \verb,\<Phi>, ~|~ \verb,\<Psi>, ~|~ \verb,\<Omega>, \\  | 
|
| 7315 | 103  | 
\end{matharray}
 | 
104  | 
||
| 13039 | 105  | 
The syntax of $string$ admits any characters, including newlines; ``\verb|"|''  | 
106  | 
(double-quote) and ``\verb|\|'' (backslash) need to be escaped by a backslash.  | 
|
| 18021 | 107  | 
Alternative strings according to $altstring$ are analogous, using single  | 
108  | 
back-quotes instead. The body of $verbatim$ may consist of any text not  | 
|
109  | 
containing ``\verb|*}|''; this allows convenient inclusion of quotes without  | 
|
110  | 
further escapes.  The greek letters do \emph{not} include \verb,\<lambda>,,
 | 
|
111  | 
which is already used differently in the meta-logic.  | 
|
| 7315 | 112  | 
|
| 14955 | 113  | 
Common mathematical symbols such as $\forall$ are represented in Isabelle as  | 
114  | 
\verb,\<forall>,. There are infinitely many legal symbols like this, although  | 
|
115  | 
proper presentation is left to front-end tools such as {\LaTeX} or
 | 
|
116  | 
Proof~General with the X-Symbol package. A list of standard Isabelle symbols  | 
|
117  | 
that work well with these tools is given in \cite[appendix~A]{isabelle-sys}.
 | 
|
118  | 
||
119  | 
Comments take the form \texttt{(*~\dots~*)} and may be nested, although
 | 
|
120  | 
user-interface tools may prevent this.  Note that \texttt{(*~\dots~*)}
 | 
|
121  | 
indicate source comments only, which are stripped after lexical analysis of  | 
|
122  | 
the input. The Isar document syntax also provides formal comments that are  | 
|
123  | 
considered as part of the text (see \S\ref{sec:comments}).
 | 
|
| 12618 | 124  | 
|
125  | 
\begin{warn}
 | 
|
126  | 
Proof~General does not handle nested comments properly; it is also unable to  | 
|
127  | 
  keep \verb,(*,\,/\,\verb,{*, and \verb,*),\,/\,\verb,*}, apart, despite
 | 
|
128  | 
their rather different meaning. These are inherent problems of Emacs  | 
|
| 13039 | 129  | 
legacy. Users should not be overly aggressive about nesting or alternating  | 
130  | 
these delimiters.  | 
|
| 12618 | 131  | 
\end{warn}
 | 
132  | 
||
| 7046 | 133  | 
|
134  | 
\section{Common syntax entities}
 | 
|
135  | 
||
| 7335 | 136  | 
Subsequently, we introduce several basic syntactic entities, such as names,  | 
| 7895 | 137  | 
terms, and theorem specifications, which have been factored out of the actual  | 
138  | 
Isar language elements to be described later.  | 
|
| 7134 | 139  | 
|
| 14895 | 140  | 
Note that some of the basic syntactic entities introduced below (e.g.\  | 
141  | 
\railqtok{name}) act much like tokens rather than plain nonterminals (e.g.\
 | 
|
| 7895 | 142  | 
\railnonterm{sort}), especially for the sake of error messages.  E.g.\ syntax
 | 
| 13048 | 143  | 
elements like $\CONSTS$ referring to \railqtok{name} or \railqtok{type} would
 | 
144  | 
really report a missing name or type rather than any of the constituent  | 
|
145  | 
primitive tokens such as \railtok{ident} or \railtok{string}.
 | 
|
| 7046 | 146  | 
|
| 7050 | 147  | 
|
148  | 
\subsection{Names}
 | 
|
149  | 
||
| 13048 | 150  | 
Entity \railqtok{name} usually refers to any name of types, constants,
 | 
| 7167 | 151  | 
theorems etc.\ that are to be \emph{declared} or \emph{defined} (so qualified
 | 
| 8548 | 152  | 
identifiers are excluded here). Quoted strings provide an escape for  | 
| 14895 | 153  | 
non-identifier names or those ruled out by outer syntax keywords (e.g.\  | 
| 7134 | 154  | 
\verb|"let"|). Already existing objects are usually referenced by  | 
| 13048 | 155  | 
\railqtok{nameref}.
 | 
| 7050 | 156  | 
|
| 7141 | 157  | 
\indexoutertoken{name}\indexoutertoken{parname}\indexoutertoken{nameref}
 | 
| 9617 | 158  | 
\indexoutertoken{int}
 | 
| 7046 | 159  | 
\begin{rail}
 | 
| 8145 | 160  | 
name: ident | symident | string | nat  | 
| 7046 | 161  | 
;  | 
| 7167 | 162  | 
  parname: '(' name ')'
 | 
| 7141 | 163  | 
;  | 
| 7167 | 164  | 
nameref: name | longident  | 
| 7046 | 165  | 
;  | 
| 9617 | 166  | 
int: nat | '-' nat  | 
167  | 
;  | 
|
| 7046 | 168  | 
\end{rail}
 | 
169  | 
||
| 7050 | 170  | 
|
| 7315 | 171  | 
\subsection{Comments}\label{sec:comments}
 | 
| 7046 | 172  | 
|
| 13048 | 173  | 
Large chunks of plain \railqtok{text} are usually given \railtok{verbatim},
 | 
174  | 
i.e.\ enclosed in \verb|{*|~\dots~\verb|*}|.  For convenience, any of the
 | 
|
175  | 
smaller text units conforming to \railqtok{nameref} are admitted as well.  A
 | 
|
176  | 
marginal \railnonterm{comment} is of the form \texttt{--} \railqtok{text}.
 | 
|
177  | 
Any number of these may occur within Isabelle/Isar commands.  | 
|
| 12618 | 178  | 
|
| 12879 | 179  | 
\indexoutertoken{text}\indexouternonterm{comment}
 | 
| 7046 | 180  | 
\begin{rail}
 | 
| 7167 | 181  | 
text: verbatim | nameref  | 
| 7050 | 182  | 
;  | 
| 12879 | 183  | 
comment: '--' text  | 
| 7046 | 184  | 
;  | 
185  | 
\end{rail}
 | 
|
186  | 
||
187  | 
||
| 7335 | 188  | 
\subsection{Type classes, sorts and arities}
 | 
| 7046 | 189  | 
|
| 8896 | 190  | 
Classes are specified by plain names. Sorts have a very simple inner syntax,  | 
191  | 
which is either a single class name $c$ or a list $\{c@1, \dots, c@n\}$
 | 
|
192  | 
referring to the intersection of these classes. The syntax of type arities is  | 
|
193  | 
given directly at the outer level.  | 
|
| 7050 | 194  | 
|
| 
11100
 
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
 
wenzelm 
parents: 
10858 
diff
changeset
 | 
195  | 
\railalias{subseteq}{\isasymsubseteq}
 | 
| 
 
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
 
wenzelm 
parents: 
10858 
diff
changeset
 | 
196  | 
\railterm{subseteq}
 | 
| 
 
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
 
wenzelm 
parents: 
10858 
diff
changeset
 | 
197  | 
|
| 
14605
 
9de4d64eee3b
'instance' and intro_classes now handle general sorts;
 
wenzelm 
parents: 
14483 
diff
changeset
 | 
198  | 
\indexouternonterm{sort}\indexouternonterm{arity}
 | 
| 7135 | 199  | 
\indexouternonterm{classdecl}
 | 
| 7046 | 200  | 
\begin{rail}
 | 
| 
11100
 
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
 
wenzelm 
parents: 
10858 
diff
changeset
 | 
201  | 
  classdecl: name (('<' | subseteq) (nameref + ','))?
 | 
| 7046 | 202  | 
;  | 
| 8896 | 203  | 
sort: nameref  | 
| 7046 | 204  | 
;  | 
| 7167 | 205  | 
  arity: ('(' (sort + ',') ')')? sort
 | 
| 7050 | 206  | 
;  | 
207  | 
\end{rail}
 | 
|
208  | 
||
209  | 
||
| 7167 | 210  | 
\subsection{Types and terms}\label{sec:types-terms}
 | 
| 7050 | 211  | 
|
| 7167 | 212  | 
The actual inner Isabelle syntax, that of types and terms of the logic, is far  | 
| 7895 | 213  | 
too sophisticated in order to be modelled explicitly at the outer theory  | 
| 8548 | 214  | 
level. Basically, any such entity has to be quoted to turn it into a single  | 
215  | 
token (the parsing and type-checking is performed internally later). For  | 
|
216  | 
convenience, a slightly more liberal convention is adopted: quotes may be  | 
|
| 13039 | 217  | 
omitted for any type or term that is already atomic at the outer level. For  | 
218  | 
example, one may just write \texttt{x} instead of \texttt{"x"}.  Note that
 | 
|
| 8548 | 219  | 
symbolic identifiers (e.g.\ \texttt{++} or $\forall$) are available as well,
 | 
| 12618 | 220  | 
provided these have not been superseded by commands or other keywords already  | 
221  | 
(e.g.\ \texttt{=} or \texttt{+}).
 | 
|
| 7050 | 222  | 
|
223  | 
\indexoutertoken{type}\indexoutertoken{term}\indexoutertoken{prop}
 | 
|
224  | 
\begin{rail}
 | 
|
| 7167 | 225  | 
type: nameref | typefree | typevar  | 
| 7050 | 226  | 
;  | 
| 8593 | 227  | 
term: nameref | var  | 
| 7050 | 228  | 
;  | 
| 7167 | 229  | 
prop: term  | 
| 7050 | 230  | 
;  | 
231  | 
\end{rail}
 | 
|
232  | 
||
| 8690 | 233  | 
Positional instantiations are indicated by giving a sequence of terms, or the  | 
234  | 
placeholder ``$\_$'' (underscore), which means to skip a position.  | 
|
235  | 
||
236  | 
\indexoutertoken{inst}\indexoutertoken{insts}
 | 
|
237  | 
\begin{rail}
 | 
|
238  | 
inst: underscore | term  | 
|
239  | 
;  | 
|
240  | 
insts: (inst *)  | 
|
241  | 
;  | 
|
242  | 
\end{rail}
 | 
|
243  | 
||
| 7167 | 244  | 
Type declarations and definitions usually refer to \railnonterm{typespec} on
 | 
245  | 
the left-hand side. This models basic type constructor application at the  | 
|
246  | 
outer syntax level. Note that only plain postfix notation is available here,  | 
|
247  | 
but no infixes.  | 
|
| 7050 | 248  | 
|
249  | 
\indexouternonterm{typespec}
 | 
|
250  | 
\begin{rail}
 | 
|
| 7167 | 251  | 
  typespec: (() | typefree | '(' ( typefree + ',' ) ')') name
 | 
| 7050 | 252  | 
;  | 
253  | 
\end{rail}
 | 
|
254  | 
||
255  | 
||
256  | 
\subsection{Mixfix annotations}
 | 
|
257  | 
||
| 7134 | 258  | 
Mixfix annotations specify concrete \emph{inner} syntax of Isabelle types and
 | 
| 12618 | 259  | 
terms.  Some commands such as $\TYPES$ (see \S\ref{sec:types-pure}) admit
 | 
260  | 
infixes only, while $\CONSTS$ (see \S\ref{sec:consts}) and
 | 
|
261  | 
$\isarkeyword{syntax}$ (see \S\ref{sec:syn-trans}) support the full range of
 | 
|
262  | 
general mixfixes and binders.  | 
|
| 7046 | 263  | 
|
| 12976 | 264  | 
\indexouternonterm{infix}\indexouternonterm{mixfix}\indexouternonterm{structmixfix}
 | 
| 7046 | 265  | 
\begin{rail}
 | 
| 11651 | 266  | 
  infix: '(' ('infix' | 'infixl' | 'infixr') string? nat ')'
 | 
| 7167 | 267  | 
;  | 
| 7175 | 268  | 
  mixfix: infix | '(' string prios? nat? ')' | '(' 'binder' string prios? nat ')'
 | 
| 7050 | 269  | 
;  | 
| 12976 | 270  | 
  structmixfix: mixfix | '(' 'structure' ')'
 | 
271  | 
;  | 
|
| 7050 | 272  | 
|
| 7175 | 273  | 
prios: '[' (nat + ',') ']'  | 
| 7050 | 274  | 
;  | 
| 7046 | 275  | 
\end{rail}
 | 
276  | 
||
| 13048 | 277  | 
Here the \railtok{string} specifications refer to the actual mixfix template
 | 
| 12618 | 278  | 
(see also \cite{isabelle-ref}), which may include literal text, spacing,
 | 
279  | 
blocks, and arguments (denoted by ``$_$''); the special symbol \verb,\<index>,  | 
|
280  | 
(printed as ``\i'') represents an index argument that specifies an implicit  | 
|
281  | 
structure reference (see also \S\ref{sec:locale}).  Infix and binder
 | 
|
282  | 
declarations provide common abbreviations for particular mixfix declarations.  | 
|
283  | 
So in practice, mixfix templates mostly degenerate to literal text for  | 
|
284  | 
concrete syntax, such as ``\verb,++,'' for an infix symbol, or ``\verb,++,\i''  | 
|
285  | 
for an infix of an implicit structure.  | 
|
286  | 
||
287  | 
||
288  | 
||
289  | 
\subsection{Proof methods}\label{sec:syn-meth}
 | 
|
290  | 
||
| 19182 | 291  | 
Proof methods are either basic ones, or expressions composed of  | 
292  | 
methods via ``\texttt{,}'' (sequential composition), ``\texttt{|}''
 | 
|
293  | 
(alternative choices), ``\texttt{?}'' (try), ``\texttt{+}'' (repeat at
 | 
|
| 19220 | 294  | 
least once), ``\texttt{[$n$]}'' (restriction to first $n$ sub-goals,
 | 
295  | 
default $n = 1$). In practice, proof methods are usually just a comma  | 
|
296  | 
separated list of \railqtok{nameref}~\railnonterm{args}
 | 
|
297  | 
specifications. Note that parentheses may be dropped for single  | 
|
298  | 
method specifications (with no arguments).  | 
|
| 12618 | 299  | 
|
300  | 
\indexouternonterm{method}
 | 
|
301  | 
\begin{rail}
 | 
|
| 19220 | 302  | 
  method: (nameref | '(' methods ')') (() | '?' | '+' | '[' nat? ']')
 | 
| 12618 | 303  | 
;  | 
304  | 
  methods: (nameref args | method) + (',' | '|')
 | 
|
305  | 
;  | 
|
306  | 
\end{rail}
 | 
|
307  | 
||
| 19220 | 308  | 
Proper Isar proof methods do \emph{not} admit arbitrary goal
 | 
309  | 
addressing, but refer either to the first sub-goal or all sub-goals  | 
|
310  | 
uniformly.  The goal restriction operator ``\texttt{[$n$]}'' evaluates
 | 
|
311  | 
a method expression within a sandbox consisting of the first $n$  | 
|
312  | 
sub-goals (which need to exist). For example,  | 
|
313  | 
$simp_all\mbox{\tt[}3\mbox{\tt]}$ simplifies the first three
 | 
|
314  | 
sub-goals, while $(rule~foo, simp_all)\mbox{\tt[]}$ simplifies all new
 | 
|
315  | 
goals that emerge from applying rule $foo$ to the originally first  | 
|
316  | 
one.  | 
|
317  | 
||
318  | 
Improper methods, notably tactic emulations, offer a separate  | 
|
319  | 
low-level goal addressing scheme as explicit argument to the  | 
|
320  | 
individual tactic being involved. Here $[!]$ refers to all goals, and  | 
|
321  | 
$[n-]$ to all goals starting from $n$,  | 
|
| 12618 | 322  | 
|
323  | 
\indexouternonterm{goalspec}
 | 
|
324  | 
\begin{rail}
 | 
|
325  | 
goalspec: '[' (nat '-' nat | nat '-' | nat | '!' ) ']'  | 
|
326  | 
;  | 
|
327  | 
\end{rail}
 | 
|
328  | 
||
| 7050 | 329  | 
|
| 7134 | 330  | 
\subsection{Attributes and theorems}\label{sec:syn-att}
 | 
| 7050 | 331  | 
|
332  | 
Attributes (and proof methods, see \S\ref{sec:syn-meth}) have their own
 | 
|
| 7335 | 333  | 
``semi-inner'' syntax, in the sense that input conforming to  | 
334  | 
\railnonterm{args} below is parsed by the attribute a second time.  The
 | 
|
335  | 
attribute argument specifications may be any sequence of atomic entities  | 
|
336  | 
(identifiers, strings etc.), or properly bracketed argument lists. Below  | 
|
| 13048 | 337  | 
\railqtok{atom} refers to any atomic entity, including any \railtok{keyword}
 | 
338  | 
conforming to \railtok{symident}.
 | 
|
| 7050 | 339  | 
|
340  | 
\indexoutertoken{atom}\indexouternonterm{args}\indexouternonterm{attributes}
 | 
|
341  | 
\begin{rail}
 | 
|
| 7466 | 342  | 
atom: nameref | typefree | typevar | var | nat | keyword  | 
| 7134 | 343  | 
;  | 
| 8896 | 344  | 
  arg: atom | '(' args ')' | '[' args ']'
 | 
| 7050 | 345  | 
;  | 
| 7167 | 346  | 
args: arg *  | 
| 7134 | 347  | 
;  | 
| 7167 | 348  | 
attributes: '[' (nameref args * ',') ']'  | 
| 7050 | 349  | 
;  | 
350  | 
\end{rail}
 | 
|
351  | 
||
| 24016 | 352  | 
Theorem specifications come in several flavors: \railnonterm{axmdecl}
 | 
353  | 
and \railnonterm{thmdecl} usually refer to axioms, assumptions or
 | 
|
354  | 
results of goal statements, while \railnonterm{thmdef} collects lists
 | 
|
355  | 
of existing theorems. Existing theorems are given by  | 
|
356  | 
\railnonterm{thmref} and \railnonterm{thmrefs}, the former requires an
 | 
|
357  | 
actual singleton result. There are three forms of theorem references:  | 
|
358  | 
(1) named facts $a$, (2) selections from named facts $a(i, j - k)$, or  | 
|
359  | 
(3) literal fact propositions using $altstring$ syntax  | 
|
| 18021 | 360  | 
$\backquote\phi\backquote$, (see also method $fact$ in  | 
361  | 
\S\ref{sec:pure-meth-att}).
 | 
|
362  | 
||
| 24016 | 363  | 
Any kind of theorem specification may include lists of attributes both  | 
364  | 
on the left and right hand sides; attributes are applied to any  | 
|
365  | 
immediately preceding fact. If names are omitted, the theorems are  | 
|
366  | 
not stored within the theorem database of the theory or proof context,  | 
|
367  | 
but any given attributes are applied nonetheless.  | 
|
368  | 
||
| 24033 | 369  | 
An extra pair of brackets around attribute declarations --- such as  | 
370  | 
``$[[simproc~a]]$'' --- abbreviates a theorem reference involving an  | 
|
371  | 
internal dummy fact, which will be ignored later on. So only the  | 
|
| 24016 | 372  | 
effect of the attribute on the background context will persist. This  | 
373  | 
form of in-place declarations is particularly useful with commands  | 
|
374  | 
like $\DECLARE$ and $\USINGNAME$.  | 
|
| 7050 | 375  | 
|
| 15687 | 376  | 
\indexouternonterm{axmdecl}\indexouternonterm{thmdecl}
 | 
377  | 
\indexouternonterm{thmdef}\indexouternonterm{thmref}
 | 
|
378  | 
\indexouternonterm{thmrefs}\indexouternonterm{selection}
 | 
|
| 7050 | 379  | 
\begin{rail}
 | 
| 7167 | 380  | 
axmdecl: name attributes? ':'  | 
| 7050 | 381  | 
;  | 
| 9200 | 382  | 
thmdecl: thmbind ':'  | 
| 7135 | 383  | 
;  | 
| 9200 | 384  | 
thmdef: thmbind '='  | 
| 7050 | 385  | 
;  | 
| 24016 | 386  | 
thmref: (nameref selection? | altstring) attributes? | '[' attributes ']'  | 
| 7175 | 387  | 
;  | 
388  | 
thmrefs: thmref +  | 
|
| 7134 | 389  | 
;  | 
| 7167 | 390  | 
|
| 9200 | 391  | 
thmbind: name attributes | name | attributes  | 
| 7050 | 392  | 
;  | 
| 15687 | 393  | 
  selection: '(' ((nat | nat '-' nat?) + ',') ')'
 | 
394  | 
;  | 
|
| 7050 | 395  | 
\end{rail}
 | 
| 7046 | 396  | 
|
397  | 
||
| 12618 | 398  | 
\subsection{Term patterns and declarations}\label{sec:term-decls}
 | 
| 7046 | 399  | 
|
| 12618 | 400  | 
Wherever explicit propositions (or term fragments) occur in a proof text,  | 
401  | 
casual binding of schematic term variables may be given specified via patterns  | 
|
| 13039 | 402  | 
of the form ``$\ISS{p@1\;\dots}{p@n}$''.  There are separate versions
 | 
| 13048 | 403  | 
available for \railqtok{term}s and \railqtok{prop}s.  The latter provides a
 | 
404  | 
$\CONCLNAME$ part with patterns referring the (atomic) conclusion of a rule.  | 
|
| 7046 | 405  | 
|
| 12618 | 406  | 
\indexouternonterm{termpat}\indexouternonterm{proppat}
 | 
| 7050 | 407  | 
\begin{rail}
 | 
| 12618 | 408  | 
  termpat: '(' ('is' term +) ')'
 | 
| 7134 | 409  | 
;  | 
| 19586 | 410  | 
  proppat: '(' ('is' prop +) ')'
 | 
| 7050 | 411  | 
;  | 
412  | 
\end{rail}
 | 
|
| 7046 | 413  | 
|
| 12618 | 414  | 
Declarations of local variables $x :: \tau$ and logical propositions $a :  | 
415  | 
\phi$ represent different views on the same principle of introducing a local  | 
|
416  | 
scope. In practice, one may usually omit the typing of $vars$ (due to  | 
|
| 13039 | 417  | 
type-inference), and the naming of propositions (due to implicit references of  | 
418  | 
current facts). In any case, Isar proof elements usually admit to introduce  | 
|
| 12618 | 419  | 
multiple such items simultaneously.  | 
| 8532 | 420  | 
|
| 12618 | 421  | 
\indexouternonterm{vars}\indexouternonterm{props}
 | 
| 8532 | 422  | 
\begin{rail}
 | 
| 12618 | 423  | 
  vars: (name+) ('::' type)?
 | 
424  | 
;  | 
|
425  | 
props: thmdecl? (prop proppat? +)  | 
|
| 8532 | 426  | 
;  | 
427  | 
\end{rail}
 | 
|
428  | 
||
| 12618 | 429  | 
The treatment of multiple declarations corresponds to the complementary focus  | 
430  | 
of $vars$ versus $props$: in ``$x@1~\dots~x@n :: \tau$'' the typing refers to  | 
|
431  | 
all variables, while in $a\colon \phi@1~\dots~\phi@n$ the naming refers to all  | 
|
432  | 
propositions collectively. Isar language elements that refer to $vars$ or  | 
|
433  | 
$props$ typically admit separate typings or namings via another level of  | 
|
434  | 
iteration, with explicit $\AND$ separators; e.g.\ see $\FIXNAME$ and  | 
|
435  | 
$\ASSUMENAME$ in \S\ref{sec:proof-context}.
 | 
|
436  | 
||
| 7046 | 437  | 
|
| 9200 | 438  | 
\subsection{Antiquotations}\label{sec:antiq}
 | 
439  | 
||
| 17053 | 440  | 
\begin{matharray}{rcl}
 | 
| 21343 | 441  | 
theory & : & \isarantiq \\  | 
| 17053 | 442  | 
thm & : & \isarantiq \\  | 
443  | 
prop & : & \isarantiq \\  | 
|
444  | 
term & : & \isarantiq \\  | 
|
445  | 
const & : & \isarantiq \\  | 
|
| 21717 | 446  | 
abbrev & : & \isarantiq \\  | 
| 17053 | 447  | 
typeof & : & \isarantiq \\  | 
448  | 
typ & : & \isarantiq \\  | 
|
449  | 
thm_style & : & \isarantiq \\  | 
|
450  | 
term_style & : & \isarantiq \\  | 
|
451  | 
text & : & \isarantiq \\  | 
|
452  | 
goals & : & \isarantiq \\  | 
|
453  | 
subgoals & : & \isarantiq \\  | 
|
454  | 
prf & : & \isarantiq \\  | 
|
455  | 
full_prf & : & \isarantiq \\  | 
|
456  | 
ML & : & \isarantiq \\  | 
|
| 17867 | 457  | 
ML_type & : & \isarantiq \\  | 
458  | 
ML_struct & : & \isarantiq \\  | 
|
| 10336 | 459  | 
\end{matharray}
 | 
460  | 
||
| 9200 | 461  | 
The text body of formal comments (see also \S\ref{sec:comments}) may contain
 | 
462  | 
antiquotations of logical entities, such as theorems, terms and types, which  | 
|
463  | 
are to be presented in the final output produced by the Isabelle document  | 
|
464  | 
preparation system (see also \S\ref{sec:document-prep}).
 | 
|
465  | 
||
| 9601 | 466  | 
Thus embedding of  | 
| 13039 | 467  | 
``\texttt{{\at}{\ttlbrace}term~[show_types]~"f(x)~=~a~+~x"{\ttrbrace}}''
 | 
468  | 
within a text block would cause  | 
|
| 9200 | 469  | 
\isa{(f{\isasymColon}'a~{\isasymRightarrow}~'a)~(x{\isasymColon}'a)~=~(a{\isasymColon}'a)~+~x}
 | 
| 10160 | 470  | 
to appear in the final {\LaTeX} document.  Also note that theorem
 | 
471  | 
antiquotations may involve attributes as well. For example,  | 
|
472  | 
\texttt{{\at}{\ttlbrace}thm~sym~[no_vars]{\ttrbrace}} would print the
 | 
|
473  | 
statement where all schematic variables have been replaced by fixed ones,  | 
|
| 12618 | 474  | 
which are easier to read.  | 
| 9200 | 475  | 
|
| 21343 | 476  | 
\indexisarant{theory}\indexisarant{thm}\indexisarant{prop}\indexisarant{term}\indexisarant{const}
 | 
| 21717 | 477  | 
\indexisarant{abbrev}\indexisarant{typeof}\indexisarant{typ}\indexisarant{thm-style}
 | 
| 16018 | 478  | 
\indexisarant{term-style}\indexisarant{text}\indexisarant{goals}
 | 
| 17053 | 479  | 
\indexisarant{subgoals}\indexisarant{prf}\indexisarant{full-prf}\indexisarant{ML}
 | 
| 17867 | 480  | 
\indexisarant{ML-type}\indexisarant{ML-struct}
 | 
| 16018 | 481  | 
|
| 9200 | 482  | 
\begin{rail}
 | 
483  | 
atsign lbrace antiquotation rbrace  | 
|
484  | 
;  | 
|
485  | 
||
486  | 
antiquotation:  | 
|
| 21343 | 487  | 
'theory' options name |  | 
| 9200 | 488  | 
'thm' options thmrefs |  | 
489  | 
'prop' options prop |  | 
|
490  | 
'term' options term |  | 
|
| 15960 | 491  | 
'const' options term |  | 
| 21717 | 492  | 
'abbrev' options term |  | 
| 15960 | 493  | 
'typeof' options term |  | 
| 9728 | 494  | 
'typ' options type |  | 
| 17053 | 495  | 
'thm\_style' options name thmref |  | 
496  | 
'term\_style' options name term |  | 
|
| 
10319
 
02463775cafb
added antiquotation "goals" and option "goals_limit";
 
wenzelm 
parents: 
10160 
diff
changeset
 | 
497  | 
'text' options name |  | 
| 10355 | 498  | 
'goals' options |  | 
| 
13827
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
499  | 
'subgoals' options |  | 
| 
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
500  | 
'prf' options thmrefs |  | 
| 17053 | 501  | 
'full\_prf' options thmrefs |  | 
| 17867 | 502  | 
'ML' options name |  | 
503  | 
'ML\_type' options name |  | 
|
504  | 
'ML\_struct' options name  | 
|
| 9200 | 505  | 
;  | 
506  | 
options: '[' (option * ',') ']'  | 
|
507  | 
;  | 
|
508  | 
option: name | name '=' name  | 
|
509  | 
;  | 
|
510  | 
\end{rail}
 | 
|
511  | 
||
512  | 
Note that the syntax of antiquotations may \emph{not} include source comments
 | 
|
513  | 
\texttt{(*~\dots~*)} or verbatim text \verb|{*|~\dots~\verb|*}|.
 | 
|
514  | 
||
| 
10319
 
02463775cafb
added antiquotation "goals" and option "goals_limit";
 
wenzelm 
parents: 
10160 
diff
changeset
 | 
515  | 
\begin{descr}
 | 
| 21343 | 516  | 
|
517  | 
\item [$\at\{theory~A\}$] prints the name $A$, which is guaranteed to
 | 
|
| 21358 | 518  | 
refer to a valid ancestor theory in the current context.  | 
| 14895 | 519  | 
|
| 10336 | 520  | 
\item [$\at\{thm~\vec a\}$] prints theorems $\vec a$. Note that attribute
 | 
521  | 
  specifications may be included as well (see also \S\ref{sec:syn-att}); the
 | 
|
| 12618 | 522  | 
  $no_vars$ operation (see \S\ref{sec:misc-meth-att}) would be particularly
 | 
| 10336 | 523  | 
useful to suppress printing of schematic variables.  | 
| 13039 | 524  | 
|
| 10336 | 525  | 
\item [$\at\{prop~\phi\}$] prints a well-typed proposition $\phi$.
 | 
| 13039 | 526  | 
|
| 10336 | 527  | 
\item [$\at\{term~t\}$] prints a well-typed term $t$.
 | 
| 13039 | 528  | 
|
| 15960 | 529  | 
\item [$\at\{const~c\}$] prints a well-defined constant $c$.
 | 
| 21717 | 530  | 
|
531  | 
\item [$\at\{abbrev~c\,\vec x\}$] prints a constant abbreviation
 | 
|
532  | 
$c\,\vec x \equiv rhs$ as defined in the current context.  | 
|
| 15960 | 533  | 
|
534  | 
\item [$\at\{typeof~t\}$] prints the type of a well-typed term $t$.
 | 
|
535  | 
||
| 10336 | 536  | 
\item [$\at\{typ~\tau\}$] prints a well-formed type $\tau$.
 | 
| 16256 | 537  | 
|
538  | 
\item [$\at\{thm_style~s~a\}$] prints theorem $a$, previously applying a style
 | 
|
539  | 
$s$ to it (see below).  | 
|
540  | 
||
541  | 
\item [$\at\{term_style~s~t\}$] prints a well-typed term $t$ after applying a
 | 
|
542  | 
style $s$ to it (see below).  | 
|
| 15960 | 543  | 
|
| 10336 | 544  | 
\item [$\at\{text~s\}$] prints uninterpreted source text $s$.  This is
 | 
545  | 
particularly useful to print portions of text according to the Isabelle  | 
|
546  | 
  {\LaTeX} output style, without demanding well-formedness (e.g.\ small pieces
 | 
|
| 13039 | 547  | 
of terms that should not be parsed or type-checked yet).  | 
| 14895 | 548  | 
|
| 10336 | 549  | 
\item [$\at\{goals\}$] prints the current \emph{dynamic} goal state.  This is
 | 
| 13039 | 550  | 
mainly for support of tactic-emulation scripts within Isar --- presentation  | 
551  | 
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
 | 
552  | 
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
 | 
553  | 
know what you are doing!  | 
| 16256 | 554  | 
|
555  | 
\item [$\at\{subgoals\}$] is similar to $goals$, but does not print the main
 | 
|
556  | 
goal.  | 
|
557  | 
||
| 
13827
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
558  | 
\item [$\at\{prf~\vec a\}$] prints the (compact) proof terms corresponding to
 | 
| 16256 | 559  | 
the theorems $\vec a$. Note that this requires proof terms to be switched on  | 
560  | 
for the current object logic (see the ``Proof terms'' section of the  | 
|
561  | 
Isabelle reference manual for information on how to do this).  | 
|
562  | 
||
563  | 
\item [$\at\{full_prf~\vec a\}$] is like $\at\{prf~\vec a\}$, but displays the
 | 
|
564  | 
full proof terms, i.e.\ also displays information omitted in the compact  | 
|
565  | 
proof term, which is denoted by ``$_$'' placeholders there.  | 
|
| 17053 | 566  | 
|
| 17867 | 567  | 
\item [$\at\{ML~s\}$, $\at\{ML_type~s\}$, and $\at\{ML_struct~s\}$] check text
 | 
568  | 
$s$ as ML value, type, and structure, respectively. If successful, the  | 
|
569  | 
source is displayed verbatim.  | 
|
| 
13827
 
c690cb885db4
Documented prf / full_prf commands and antiquotations.
 
berghofe 
parents: 
13048 
diff
changeset
 | 
570  | 
|
| 
10319
 
02463775cafb
added antiquotation "goals" and option "goals_limit";
 
wenzelm 
parents: 
10160 
diff
changeset
 | 
571  | 
\end{descr}
 | 
| 
 
02463775cafb
added antiquotation "goals" and option "goals_limit";
 
wenzelm 
parents: 
10160 
diff
changeset
 | 
572  | 
|
| 16256 | 573  | 
\medskip  | 
574  | 
||
575  | 
The following standard styles for use with $thm_style$ and $term_style$ are  | 
|
576  | 
available:  | 
|
| 15960 | 577  | 
|
578  | 
\begin{descr}
 | 
|
| 16018 | 579  | 
|
580  | 
\item [$lhs$] extracts the first argument of any application form with at  | 
|
| 16256 | 581  | 
least two arguments -- typically meta-level or object-level equality, or any  | 
582  | 
other binary relation.  | 
|
583  | 
||
584  | 
\item [$rhs$] is like $lhs$, but extracts the second argument.  | 
|
| 16018 | 585  | 
|
| 16256 | 586  | 
\item [$concl$] extracts the conclusion $C$ from a nested meta-level  | 
587  | 
implication $A@1 \Imp \cdots A@n \Imp C$.  | 
|
| 16018 | 588  | 
|
| 16256 | 589  | 
\item [$prem1$, \dots, $prem9$] extract premise number $1$, \dots, $9$,  | 
590  | 
respectively, from a nested meta-level implication $A@1 \Imp \cdots A@n \Imp  | 
|
591  | 
C$.  | 
|
| 15960 | 592  | 
|
593  | 
\end{descr}
 | 
|
594  | 
||
| 9200 | 595  | 
\medskip  | 
596  | 
||
| 10336 | 597  | 
The following options are available to tune the output. Note that most of  | 
| 9233 | 598  | 
these coincide with ML flags of the same names (see also \cite{isabelle-ref}).
 | 
| 9200 | 599  | 
\begin{descr}
 | 
| 9233 | 600  | 
\item[$show_types = bool$ and $show_sorts = bool$] control printing of  | 
| 9234 | 601  | 
explicit type and sort constraints.  | 
| 14707 | 602  | 
\item[$show_structs = bool$] controls printing of implicit structures.  | 
| 9233 | 603  | 
\item[$long_names = bool$] forces names of types and constants etc.\ to be  | 
604  | 
printed in their fully qualified internal form.  | 
|
| 
16120
 
6a449deff8d9
antiquotations: added options short_names, unique_names;
 
wenzelm 
parents: 
16068 
diff
changeset
 | 
605  | 
\item[$short_names = bool$] forces names of types and constants etc.\ to be  | 
| 
 
6a449deff8d9
antiquotations: added options short_names, unique_names;
 
wenzelm 
parents: 
16068 
diff
changeset
 | 
606  | 
printed unqualified. Note that internalizing the output again in the  | 
| 
 
6a449deff8d9
antiquotations: added options short_names, unique_names;
 
wenzelm 
parents: 
16068 
diff
changeset
 | 
607  | 
current context may well yield a different result.  | 
| 
 
6a449deff8d9
antiquotations: added options short_names, unique_names;
 
wenzelm 
parents: 
16068 
diff
changeset
 | 
608  | 
\item[$unique_names = bool$] determines whether the printed version of  | 
| 
 
6a449deff8d9
antiquotations: added options short_names, unique_names;
 
wenzelm 
parents: 
16068 
diff
changeset
 | 
609  | 
qualified names should be made sufficiently long to avoid overlap with names  | 
| 
 
6a449deff8d9
antiquotations: added options short_names, unique_names;
 
wenzelm 
parents: 
16068 
diff
changeset
 | 
610  | 
declared further back. Set to $false$ for more concise output.  | 
| 9233 | 611  | 
\item[$eta_contract = bool$] prints terms in $\eta$-contracted form.  | 
| 9200 | 612  | 
\item[$display = bool$] indicates if the text is to be output as multi-line  | 
613  | 
``display material'', rather than a small piece of text without line breaks  | 
|
614  | 
(which is the default).  | 
|
| 14689 | 615  | 
\item[$breaks = bool$] controls line breaks in non-display material.  | 
| 9200 | 616  | 
\item[$quotes = bool$] indicates if the output should be enclosed in double  | 
617  | 
quotes.  | 
|
| 9233 | 618  | 
\item[$mode = name$] adds $name$ to the print mode to be used for presentation  | 
619  | 
  (see also \cite{isabelle-ref}).  Note that the standard setup for {\LaTeX}
 | 
|
620  | 
output is already present by default, including the modes ``$latex$'',  | 
|
621  | 
``$xsymbols$'', ``$symbols$''.  | 
|
| 9728 | 622  | 
\item[$margin = nat$ and $indent = nat$] change the margin or indentation for  | 
623  | 
pretty printing of display material.  | 
|
| 9752 | 624  | 
\item[$source = bool$] prints the source text of the antiquotation arguments,  | 
625  | 
rather than the actual value. Note that this does not affect  | 
|
626  | 
well-formedness checks of $thm$, $term$, etc. (only the $text$ antiquotation  | 
|
627  | 
admits arbitrary output).  | 
|
| 
10319
 
02463775cafb
added antiquotation "goals" and option "goals_limit";
 
wenzelm 
parents: 
10160 
diff
changeset
 | 
628  | 
\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
 | 
629  | 
printed.  | 
| 14895 | 630  | 
\item[$locale = name$] specifies an alternative context used for evaluating  | 
| 14919 | 631  | 
and printing the subsequent argument.  | 
| 9200 | 632  | 
\end{descr}
 | 
633  | 
||
634  | 
For boolean flags, ``$name = true$'' may be abbreviated as ``$name$''. All of  | 
|
635  | 
the above flags are disabled by default, unless changed from ML.  | 
|
636  | 
||
| 10336 | 637  | 
\medskip Note that antiquotations do not only spare the author from tedious  | 
| 13039 | 638  | 
typing of logical entities, but also achieve some degree of  | 
639  | 
consistency-checking of informal explanations with formal developments:  | 
|
640  | 
well-formedness of terms and types with respect to the current theory or proof  | 
|
641  | 
context is ensured here.  | 
|
| 9200 | 642  | 
|
| 17053 | 643  | 
|
644  | 
\subsection{Tagged commands}\label{sec:tags}
 | 
|
645  | 
||
646  | 
Each Isabelle/Isar command may be decorated by presentation tags:  | 
|
647  | 
||
648  | 
\indexouternonterm{tags}
 | 
|
649  | 
\begin{rail}
 | 
|
650  | 
tags: ( tag * )  | 
|
651  | 
;  | 
|
652  | 
tag: '\%' (ident | string)  | 
|
653  | 
\end{rail}
 | 
|
654  | 
||
655  | 
The tags $theory$, $proof$, $ML$ are already pre-declared for certain classes  | 
|
656  | 
of commands:  | 
|
657  | 
||
658  | 
\medskip  | 
|
659  | 
||
660  | 
\begin{tabular}{ll}
 | 
|
661  | 
$theory$ & theory begin and end \\  | 
|
662  | 
$proof$ & all proof commands \\  | 
|
663  | 
$ML$ & all commands involving ML code \\  | 
|
664  | 
\end{tabular}
 | 
|
665  | 
||
666  | 
\medskip The Isabelle document preparation system (see also  | 
|
667  | 
\cite{isabelle-sys}) allows tagged command regions to be presented
 | 
|
668  | 
specifically, e.g.\ to fold proof texts, or drop parts of the text completely.  | 
|
669  | 
||
670  | 
For example ``$\BYNAME~\%invisible~(auto)$'' would cause that piece of proof  | 
|
671  | 
to be treated as $invisible$ instead of $proof$ (the default), which may be  | 
|
672  | 
either show or hidden depending on the document setup. In contrast,  | 
|
673  | 
``$\BYNAME~\%visible~(auto)$'' would force this text to be shown invariably.  | 
|
674  | 
||
675  | 
Explicit tag specifications within a proof apply to all subsequent commands of  | 
|
676  | 
the same level of nesting. For example,  | 
|
677  | 
``$\PROOFNAME~\%visible~\dots\QEDNAME$'' would force the whole sub-proof to be  | 
|
678  | 
typeset as $visible$ (unless some of its parts are tagged differently).  | 
|
679  | 
||
| 14895 | 680  | 
%%% Local Variables:  | 
| 7046 | 681  | 
%%% mode: latex  | 
682  | 
%%% TeX-master: "isar-ref"  | 
|
| 14895 | 683  | 
%%% End:  |