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