author | wenzelm |
Thu, 13 Nov 2008 21:31:25 +0100 | |
changeset 28748 | 69268a097405 |
parent 27050 | cd8d99b9ef09 |
child 28752 | 754f10154d73 |
permissions | -rw-r--r-- |
27037 | 1 |
(* $Id$ *) |
2 |
||
3 |
theory Outer_Syntax |
|
27050 | 4 |
imports Main |
27037 | 5 |
begin |
6 |
||
27040 | 7 |
chapter {* Outer syntax *} |
27037 | 8 |
|
9 |
text {* |
|
10 |
The rather generic framework of Isabelle/Isar syntax emerges from |
|
11 |
three main syntactic categories: \emph{commands} of the top-level |
|
12 |
Isar engine (covering theory and proof elements), \emph{methods} for |
|
13 |
general goal refinements (analogous to traditional ``tactics''), and |
|
14 |
\emph{attributes} for operations on facts (within a certain |
|
15 |
context). Subsequently we give a reference of basic syntactic |
|
16 |
entities underlying Isabelle/Isar syntax in a bottom-up manner. |
|
17 |
Concrete theory and proof language elements will be introduced later |
|
18 |
on. |
|
19 |
||
20 |
\medskip In order to get started with writing well-formed |
|
21 |
Isabelle/Isar documents, the most important aspect to be noted is |
|
22 |
the difference of \emph{inner} versus \emph{outer} syntax. Inner |
|
23 |
syntax is that of Isabelle types and terms of the logic, while outer |
|
24 |
syntax is that of Isabelle/Isar theory sources (specifications and |
|
25 |
proofs). As a general rule, inner syntax entities may occur only as |
|
26 |
\emph{atomic entities} within outer syntax. For example, the string |
|
27 |
@{verbatim "\"x + y\""} and identifier @{verbatim z} are legal term |
|
28 |
specifications within a theory, while @{verbatim "x + y"} without |
|
29 |
quotes is not. |
|
30 |
||
31 |
Printed theory documents usually omit quotes to gain readability |
|
32 |
(this is a matter of {\LaTeX} macro setup, say via @{verbatim |
|
33 |
"\\isabellestyle"}, see also \cite{isabelle-sys}). Experienced |
|
34 |
users of Isabelle/Isar may easily reconstruct the lost technical |
|
35 |
information, while mere readers need not care about quotes at all. |
|
36 |
||
37 |
\medskip Isabelle/Isar input may contain any number of input |
|
38 |
termination characters ``@{verbatim ";"}'' (semicolon) to separate |
|
39 |
commands explicitly. This is particularly useful in interactive |
|
40 |
shell sessions to make clear where the current command is intended |
|
41 |
to end. Otherwise, the interpreter loop will continue to issue a |
|
42 |
secondary prompt ``@{verbatim "#"}'' until an end-of-command is |
|
43 |
clearly recognized from the input syntax, e.g.\ encounter of the |
|
44 |
next command keyword. |
|
45 |
||
46 |
More advanced interfaces such as Proof~General \cite{proofgeneral} |
|
47 |
do not require explicit semicolons, the amount of input text is |
|
48 |
determined automatically by inspecting the present content of the |
|
49 |
Emacs text buffer. In the printed presentation of Isabelle/Isar |
|
50 |
documents semicolons are omitted altogether for readability. |
|
51 |
||
52 |
\begin{warn} |
|
53 |
Proof~General requires certain syntax classification tables in |
|
54 |
order to achieve properly synchronized interaction with the |
|
55 |
Isabelle/Isar process. These tables need to be consistent with |
|
56 |
the Isabelle version and particular logic image to be used in a |
|
57 |
running session (common object-logics may well change the outer |
|
58 |
syntax). The standard setup should work correctly with any of the |
|
59 |
``official'' logic images derived from Isabelle/HOL (including |
|
60 |
HOLCF etc.). Users of alternative logics may need to tell |
|
61 |
Proof~General explicitly, e.g.\ by giving an option @{verbatim "-k ZF"} |
|
62 |
(in conjunction with @{verbatim "-l ZF"}, to specify the default |
|
63 |
logic image). Note that option @{verbatim "-L"} does both |
|
64 |
of this at the same time. |
|
65 |
\end{warn} |
|
66 |
*} |
|
67 |
||
68 |
||
69 |
section {* Lexical matters \label{sec:lex-syntax} *} |
|
70 |
||
71 |
text {* |
|
72 |
The Isabelle/Isar outer syntax provides token classes as presented |
|
73 |
below; most of these coincide with the inner lexical syntax as |
|
74 |
presented in \cite{isabelle-ref}. |
|
75 |
||
76 |
\begin{matharray}{rcl} |
|
77 |
@{syntax_def ident} & = & letter\,quasiletter^* \\ |
|
78 |
@{syntax_def longident} & = & ident (\verb,.,ident)^+ \\ |
|
79 |
@{syntax_def symident} & = & sym^+ ~|~ \verb,\,\verb,<,ident\verb,>, \\ |
|
80 |
@{syntax_def nat} & = & digit^+ \\ |
|
81 |
@{syntax_def var} & = & ident ~|~ \verb,?,ident ~|~ \verb,?,ident\verb,.,nat \\ |
|
82 |
@{syntax_def typefree} & = & \verb,',ident \\ |
|
83 |
@{syntax_def typevar} & = & typefree ~|~ \verb,?,typefree ~|~ \verb,?,typefree\verb,.,nat \\ |
|
84 |
@{syntax_def string} & = & \verb,", ~\dots~ \verb,", \\ |
|
85 |
@{syntax_def altstring} & = & \backquote ~\dots~ \backquote \\ |
|
86 |
@{syntax_def verbatim} & = & \verb,{*, ~\dots~ \verb,*,\verb,}, \\[1ex] |
|
87 |
||
88 |
letter & = & latin ~|~ \verb,\,\verb,<,latin\verb,>, ~|~ \verb,\,\verb,<,latin\,latin\verb,>, ~|~ greek ~|~ \\ |
|
89 |
& & \verb,\<^isub>, ~|~ \verb,\<^isup>, \\ |
|
90 |
quasiletter & = & letter ~|~ digit ~|~ \verb,_, ~|~ \verb,', \\ |
|
91 |
latin & = & \verb,a, ~|~ \dots ~|~ \verb,z, ~|~ \verb,A, ~|~ \dots ~|~ \verb,Z, \\ |
|
92 |
digit & = & \verb,0, ~|~ \dots ~|~ \verb,9, \\ |
|
93 |
sym & = & \verb,!, ~|~ \verb,#, ~|~ \verb,$, ~|~ \verb,%, ~|~ \verb,&, ~|~ |
|
94 |
\verb,*, ~|~ \verb,+, ~|~ \verb,-, ~|~ \verb,/, ~|~ \\ |
|
95 |
& & \verb,<, ~|~ \verb,=, ~|~ \verb,>, ~|~ \verb,?, ~|~ \texttt{\at} ~|~ |
|
96 |
\verb,^, ~|~ \verb,_, ~|~ \verb,|, ~|~ \verb,~, \\ |
|
97 |
greek & = & \verb,\<alpha>, ~|~ \verb,\<beta>, ~|~ \verb,\<gamma>, ~|~ \verb,\<delta>, ~| \\ |
|
98 |
& & \verb,\<epsilon>, ~|~ \verb,\<zeta>, ~|~ \verb,\<eta>, ~|~ \verb,\<theta>, ~| \\ |
|
99 |
& & \verb,\<iota>, ~|~ \verb,\<kappa>, ~|~ \verb,\<mu>, ~|~ \verb,\<nu>, ~| \\ |
|
100 |
& & \verb,\<xi>, ~|~ \verb,\<pi>, ~|~ \verb,\<rho>, ~|~ \verb,\<sigma>, ~|~ \verb,\<tau>, ~| \\ |
|
101 |
& & \verb,\<upsilon>, ~|~ \verb,\<phi>, ~|~ \verb,\<chi>, ~|~ \verb,\<psi>, ~| \\ |
|
102 |
& & \verb,\<omega>, ~|~ \verb,\<Gamma>, ~|~ \verb,\<Delta>, ~|~ \verb,\<Theta>, ~| \\ |
|
103 |
& & \verb,\<Lambda>, ~|~ \verb,\<Xi>, ~|~ \verb,\<Pi>, ~|~ \verb,\<Sigma>, ~| \\ |
|
104 |
& & \verb,\<Upsilon>, ~|~ \verb,\<Phi>, ~|~ \verb,\<Psi>, ~|~ \verb,\<Omega>, \\ |
|
105 |
\end{matharray} |
|
106 |
||
107 |
The syntax of @{syntax string} admits any characters, including |
|
108 |
newlines; ``@{verbatim "\""}'' (double-quote) and ``@{verbatim |
|
109 |
"\\"}'' (backslash) need to be escaped by a backslash; arbitrary |
|
110 |
character codes may be specified as ``@{verbatim "\\"}@{text ddd}'', |
|
111 |
with three decimal digits. Alternative strings according to |
|
112 |
@{syntax altstring} are analogous, using single back-quotes instead. |
|
113 |
The body of @{syntax verbatim} may consist of any text not |
|
114 |
containing ``@{verbatim "*"}@{verbatim "}"}''; this allows |
|
115 |
convenient inclusion of quotes without further escapes. The greek |
|
116 |
letters do \emph{not} include @{verbatim "\<lambda>"}, which is already used |
|
117 |
differently in the meta-logic. |
|
118 |
||
119 |
Common mathematical symbols such as @{text \<forall>} are represented in |
|
120 |
Isabelle as @{verbatim \<forall>}. There are infinitely many Isabelle |
|
121 |
symbols like this, although proper presentation is left to front-end |
|
122 |
tools such as {\LaTeX} or Proof~General with the X-Symbol package. |
|
123 |
A list of standard Isabelle symbols that work well with these tools |
|
124 |
is given in \cite[appendix~A]{isabelle-sys}. |
|
125 |
||
126 |
Source comments take the form @{verbatim "(*"}~@{text |
|
127 |
"\<dots>"}~@{verbatim "*)"} and may be nested, although user-interface |
|
128 |
tools might prevent this. Note that this form indicates source |
|
129 |
comments only, which are stripped after lexical analysis of the |
|
28748
69268a097405
renamed "formal comments" to "document comments";
wenzelm
parents:
27050
diff
changeset
|
130 |
input. The Isar syntax also provides proper \emph{document |
69268a097405
renamed "formal comments" to "document comments";
wenzelm
parents:
27050
diff
changeset
|
131 |
comments} that are considered as part of the text (see |
69268a097405
renamed "formal comments" to "document comments";
wenzelm
parents:
27050
diff
changeset
|
132 |
\secref{sec:comments}). |
27037 | 133 |
*} |
134 |
||
135 |
||
136 |
section {* Common syntax entities *} |
|
137 |
||
138 |
text {* |
|
139 |
We now introduce several basic syntactic entities, such as names, |
|
140 |
terms, and theorem specifications, which are factored out of the |
|
141 |
actual Isar language elements to be described later. |
|
142 |
*} |
|
143 |
||
144 |
||
145 |
subsection {* Names *} |
|
146 |
||
147 |
text {* |
|
148 |
Entity \railqtok{name} usually refers to any name of types, |
|
149 |
constants, theorems etc.\ that are to be \emph{declared} or |
|
150 |
\emph{defined} (so qualified identifiers are excluded here). Quoted |
|
151 |
strings provide an escape for non-identifier names or those ruled |
|
152 |
out by outer syntax keywords (e.g.\ quoted @{verbatim "\"let\""}). |
|
153 |
Already existing objects are usually referenced by |
|
154 |
\railqtok{nameref}. |
|
155 |
||
156 |
\indexoutertoken{name}\indexoutertoken{parname}\indexoutertoken{nameref} |
|
157 |
\indexoutertoken{int} |
|
158 |
\begin{rail} |
|
159 |
name: ident | symident | string | nat |
|
160 |
; |
|
161 |
parname: '(' name ')' |
|
162 |
; |
|
163 |
nameref: name | longident |
|
164 |
; |
|
165 |
int: nat | '-' nat |
|
166 |
; |
|
167 |
\end{rail} |
|
168 |
*} |
|
169 |
||
170 |
||
171 |
subsection {* Comments \label{sec:comments} *} |
|
172 |
||
173 |
text {* |
|
174 |
Large chunks of plain \railqtok{text} are usually given |
|
175 |
\railtok{verbatim}, i.e.\ enclosed in @{verbatim "{"}@{verbatim |
|
176 |
"*"}~@{text "\<dots>"}~@{verbatim "*"}@{verbatim "}"}. For convenience, |
|
177 |
any of the smaller text units conforming to \railqtok{nameref} are |
|
178 |
admitted as well. A marginal \railnonterm{comment} is of the form |
|
179 |
@{verbatim "--"} \railqtok{text}. Any number of these may occur |
|
180 |
within Isabelle/Isar commands. |
|
181 |
||
182 |
\indexoutertoken{text}\indexouternonterm{comment} |
|
183 |
\begin{rail} |
|
184 |
text: verbatim | nameref |
|
185 |
; |
|
186 |
comment: '--' text |
|
187 |
; |
|
188 |
\end{rail} |
|
189 |
*} |
|
190 |
||
191 |
||
192 |
subsection {* Type classes, sorts and arities *} |
|
193 |
||
194 |
text {* |
|
195 |
Classes are specified by plain names. Sorts have a very simple |
|
196 |
inner syntax, which is either a single class name @{text c} or a |
|
197 |
list @{text "{c\<^sub>1, \<dots>, c\<^sub>n}"} referring to the |
|
198 |
intersection of these classes. The syntax of type arities is given |
|
199 |
directly at the outer level. |
|
200 |
||
201 |
\indexouternonterm{sort}\indexouternonterm{arity} |
|
202 |
\indexouternonterm{classdecl} |
|
203 |
\begin{rail} |
|
204 |
classdecl: name (('<' | subseteq) (nameref + ','))? |
|
205 |
; |
|
206 |
sort: nameref |
|
207 |
; |
|
208 |
arity: ('(' (sort + ',') ')')? sort |
|
209 |
; |
|
210 |
\end{rail} |
|
211 |
*} |
|
212 |
||
213 |
||
214 |
subsection {* Types and terms \label{sec:types-terms} *} |
|
215 |
||
216 |
text {* |
|
217 |
The actual inner Isabelle syntax, that of types and terms of the |
|
218 |
logic, is far too sophisticated in order to be modelled explicitly |
|
219 |
at the outer theory level. Basically, any such entity has to be |
|
220 |
quoted to turn it into a single token (the parsing and type-checking |
|
221 |
is performed internally later). For convenience, a slightly more |
|
222 |
liberal convention is adopted: quotes may be omitted for any type or |
|
223 |
term that is already atomic at the outer level. For example, one |
|
224 |
may just write @{verbatim x} instead of quoted @{verbatim "\"x\""}. |
|
225 |
Note that symbolic identifiers (e.g.\ @{verbatim "++"} or @{text |
|
226 |
"\<forall>"} are available as well, provided these have not been superseded |
|
227 |
by commands or other keywords already (such as @{verbatim "="} or |
|
228 |
@{verbatim "+"}). |
|
229 |
||
230 |
\indexoutertoken{type}\indexoutertoken{term}\indexoutertoken{prop} |
|
231 |
\begin{rail} |
|
232 |
type: nameref | typefree | typevar |
|
233 |
; |
|
234 |
term: nameref | var |
|
235 |
; |
|
236 |
prop: term |
|
237 |
; |
|
238 |
\end{rail} |
|
239 |
||
240 |
Positional instantiations are indicated by giving a sequence of |
|
241 |
terms, or the placeholder ``@{text _}'' (underscore), which means to |
|
242 |
skip a position. |
|
243 |
||
244 |
\indexoutertoken{inst}\indexoutertoken{insts} |
|
245 |
\begin{rail} |
|
246 |
inst: underscore | term |
|
247 |
; |
|
248 |
insts: (inst *) |
|
249 |
; |
|
250 |
\end{rail} |
|
251 |
||
252 |
Type declarations and definitions usually refer to |
|
253 |
\railnonterm{typespec} on the left-hand side. This models basic |
|
254 |
type constructor application at the outer syntax level. Note that |
|
255 |
only plain postfix notation is available here, but no infixes. |
|
256 |
||
257 |
\indexouternonterm{typespec} |
|
258 |
\begin{rail} |
|
259 |
typespec: (() | typefree | '(' ( typefree + ',' ) ')') name |
|
260 |
; |
|
261 |
\end{rail} |
|
262 |
*} |
|
263 |
||
264 |
||
265 |
subsection {* Mixfix annotations *} |
|
266 |
||
267 |
text {* |
|
268 |
Mixfix annotations specify concrete \emph{inner} syntax of Isabelle |
|
269 |
types and terms. Some commands such as @{command "types"} (see |
|
270 |
\secref{sec:types-pure}) admit infixes only, while @{command |
|
271 |
"consts"} (see \secref{sec:consts}) and @{command "syntax"} (see |
|
272 |
\secref{sec:syn-trans}) support the full range of general mixfixes |
|
273 |
and binders. |
|
274 |
||
275 |
\indexouternonterm{infix}\indexouternonterm{mixfix}\indexouternonterm{structmixfix} |
|
276 |
\begin{rail} |
|
277 |
infix: '(' ('infix' | 'infixl' | 'infixr') string? nat ')' |
|
278 |
; |
|
279 |
mixfix: infix | '(' string prios? nat? ')' | '(' 'binder' string prios? nat ')' |
|
280 |
; |
|
281 |
structmixfix: mixfix | '(' 'structure' ')' |
|
282 |
; |
|
283 |
||
284 |
prios: '[' (nat + ',') ']' |
|
285 |
; |
|
286 |
\end{rail} |
|
287 |
||
288 |
Here the \railtok{string} specifications refer to the actual mixfix |
|
289 |
template (see also \cite{isabelle-ref}), which may include literal |
|
290 |
text, spacing, blocks, and arguments (denoted by ``@{text _}''); the |
|
291 |
special symbol ``@{verbatim "\<index>"}'' (printed as ``@{text "\<index>"}'') |
|
292 |
represents an index argument that specifies an implicit structure |
|
293 |
reference (see also \secref{sec:locale}). Infix and binder |
|
294 |
declarations provide common abbreviations for particular mixfix |
|
295 |
declarations. So in practice, mixfix templates mostly degenerate to |
|
296 |
literal text for concrete syntax, such as ``@{verbatim "++"}'' for |
|
297 |
an infix symbol, or ``@{verbatim "++"}@{text "\<index>"}'' for an infix of |
|
298 |
an implicit structure. |
|
299 |
*} |
|
300 |
||
301 |
||
302 |
subsection {* Proof methods \label{sec:syn-meth} *} |
|
303 |
||
304 |
text {* |
|
305 |
Proof methods are either basic ones, or expressions composed of |
|
306 |
methods via ``@{verbatim ","}'' (sequential composition), |
|
307 |
``@{verbatim "|"}'' (alternative choices), ``@{verbatim "?"}'' |
|
308 |
(try), ``@{verbatim "+"}'' (repeat at least once), ``@{verbatim |
|
309 |
"["}@{text n}@{verbatim "]"}'' (restriction to first @{text n} |
|
310 |
sub-goals, with default @{text "n = 1"}). In practice, proof |
|
311 |
methods are usually just a comma separated list of |
|
312 |
\railqtok{nameref}~\railnonterm{args} specifications. Note that |
|
313 |
parentheses may be dropped for single method specifications (with no |
|
314 |
arguments). |
|
315 |
||
316 |
\indexouternonterm{method} |
|
317 |
\begin{rail} |
|
318 |
method: (nameref | '(' methods ')') (() | '?' | '+' | '[' nat? ']') |
|
319 |
; |
|
320 |
methods: (nameref args | method) + (',' | '|') |
|
321 |
; |
|
322 |
\end{rail} |
|
323 |
||
324 |
Proper Isar proof methods do \emph{not} admit arbitrary goal |
|
325 |
addressing, but refer either to the first sub-goal or all sub-goals |
|
326 |
uniformly. The goal restriction operator ``@{text "[n]"}'' |
|
327 |
evaluates a method expression within a sandbox consisting of the |
|
328 |
first @{text n} sub-goals (which need to exist). For example, the |
|
329 |
method ``@{text "simp_all[3]"}'' simplifies the first three |
|
330 |
sub-goals, while ``@{text "(rule foo, simp_all)[]"}'' simplifies all |
|
331 |
new goals that emerge from applying rule @{text "foo"} to the |
|
332 |
originally first one. |
|
333 |
||
334 |
Improper methods, notably tactic emulations, offer a separate |
|
335 |
low-level goal addressing scheme as explicit argument to the |
|
336 |
individual tactic being involved. Here ``@{text "[!]"}'' refers to |
|
337 |
all goals, and ``@{text "[n-]"}'' to all goals starting from @{text |
|
338 |
"n"}. |
|
339 |
||
340 |
\indexouternonterm{goalspec} |
|
341 |
\begin{rail} |
|
342 |
goalspec: '[' (nat '-' nat | nat '-' | nat | '!' ) ']' |
|
343 |
; |
|
344 |
\end{rail} |
|
345 |
*} |
|
346 |
||
347 |
||
348 |
subsection {* Attributes and theorems \label{sec:syn-att} *} |
|
349 |
||
350 |
text {* |
|
351 |
Attributes (and proof methods, see \secref{sec:syn-meth}) have their |
|
352 |
own ``semi-inner'' syntax, in the sense that input conforming to |
|
353 |
\railnonterm{args} below is parsed by the attribute a second time. |
|
354 |
The attribute argument specifications may be any sequence of atomic |
|
355 |
entities (identifiers, strings etc.), or properly bracketed argument |
|
356 |
lists. Below \railqtok{atom} refers to any atomic entity, including |
|
357 |
any \railtok{keyword} conforming to \railtok{symident}. |
|
358 |
||
359 |
\indexoutertoken{atom}\indexouternonterm{args}\indexouternonterm{attributes} |
|
360 |
\begin{rail} |
|
361 |
atom: nameref | typefree | typevar | var | nat | keyword |
|
362 |
; |
|
363 |
arg: atom | '(' args ')' | '[' args ']' |
|
364 |
; |
|
365 |
args: arg * |
|
366 |
; |
|
367 |
attributes: '[' (nameref args * ',') ']' |
|
368 |
; |
|
369 |
\end{rail} |
|
370 |
||
371 |
Theorem specifications come in several flavors: |
|
372 |
\railnonterm{axmdecl} and \railnonterm{thmdecl} usually refer to |
|
373 |
axioms, assumptions or results of goal statements, while |
|
374 |
\railnonterm{thmdef} collects lists of existing theorems. Existing |
|
375 |
theorems are given by \railnonterm{thmref} and |
|
376 |
\railnonterm{thmrefs}, the former requires an actual singleton |
|
377 |
result. |
|
378 |
||
379 |
There are three forms of theorem references: |
|
380 |
\begin{enumerate} |
|
381 |
||
382 |
\item named facts @{text "a"}, |
|
383 |
||
384 |
\item selections from named facts @{text "a(i)"} or @{text "a(j - k)"}, |
|
385 |
||
386 |
\item literal fact propositions using @{syntax_ref altstring} syntax |
|
387 |
@{verbatim "`"}@{text "\<phi>"}@{verbatim "`"} (see also method |
|
388 |
@{method_ref fact} in \secref{sec:pure-meth-att}). |
|
389 |
||
390 |
\end{enumerate} |
|
391 |
||
392 |
Any kind of theorem specification may include lists of attributes |
|
393 |
both on the left and right hand sides; attributes are applied to any |
|
394 |
immediately preceding fact. If names are omitted, the theorems are |
|
395 |
not stored within the theorem database of the theory or proof |
|
396 |
context, but any given attributes are applied nonetheless. |
|
397 |
||
398 |
An extra pair of brackets around attributes (like ``@{text |
|
399 |
"[[simproc a]]"}'') abbreviates a theorem reference involving an |
|
400 |
internal dummy fact, which will be ignored later on. So only the |
|
401 |
effect of the attribute on the background context will persist. |
|
402 |
This form of in-place declarations is particularly useful with |
|
403 |
commands like @{command "declare"} and @{command "using"}. |
|
404 |
||
405 |
\indexouternonterm{axmdecl}\indexouternonterm{thmdecl} |
|
406 |
\indexouternonterm{thmdef}\indexouternonterm{thmref} |
|
407 |
\indexouternonterm{thmrefs}\indexouternonterm{selection} |
|
408 |
\begin{rail} |
|
409 |
axmdecl: name attributes? ':' |
|
410 |
; |
|
411 |
thmdecl: thmbind ':' |
|
412 |
; |
|
413 |
thmdef: thmbind '=' |
|
414 |
; |
|
415 |
thmref: (nameref selection? | altstring) attributes? | '[' attributes ']' |
|
416 |
; |
|
417 |
thmrefs: thmref + |
|
418 |
; |
|
419 |
||
420 |
thmbind: name attributes | name | attributes |
|
421 |
; |
|
422 |
selection: '(' ((nat | nat '-' nat?) + ',') ')' |
|
423 |
; |
|
424 |
\end{rail} |
|
425 |
*} |
|
426 |
||
427 |
||
428 |
subsection {* Term patterns and declarations \label{sec:term-decls} *} |
|
429 |
||
430 |
text {* |
|
431 |
Wherever explicit propositions (or term fragments) occur in a proof |
|
432 |
text, casual binding of schematic term variables may be given |
|
433 |
specified via patterns of the form ``@{text "(\<IS> p\<^sub>1 \<dots> |
|
434 |
p\<^sub>n)"}''. This works both for \railqtok{term} and \railqtok{prop}. |
|
435 |
||
436 |
\indexouternonterm{termpat}\indexouternonterm{proppat} |
|
437 |
\begin{rail} |
|
438 |
termpat: '(' ('is' term +) ')' |
|
439 |
; |
|
440 |
proppat: '(' ('is' prop +) ')' |
|
441 |
; |
|
442 |
\end{rail} |
|
443 |
||
444 |
\medskip Declarations of local variables @{text "x :: \<tau>"} and |
|
445 |
logical propositions @{text "a : \<phi>"} represent different views on |
|
446 |
the same principle of introducing a local scope. In practice, one |
|
447 |
may usually omit the typing of \railnonterm{vars} (due to |
|
448 |
type-inference), and the naming of propositions (due to implicit |
|
449 |
references of current facts). In any case, Isar proof elements |
|
450 |
usually admit to introduce multiple such items simultaneously. |
|
451 |
||
452 |
\indexouternonterm{vars}\indexouternonterm{props} |
|
453 |
\begin{rail} |
|
454 |
vars: (name+) ('::' type)? |
|
455 |
; |
|
456 |
props: thmdecl? (prop proppat? +) |
|
457 |
; |
|
458 |
\end{rail} |
|
459 |
||
460 |
The treatment of multiple declarations corresponds to the |
|
461 |
complementary focus of \railnonterm{vars} versus |
|
462 |
\railnonterm{props}. In ``@{text "x\<^sub>1 \<dots> x\<^sub>n :: \<tau>"}'' |
|
463 |
the typing refers to all variables, while in @{text "a: \<phi>\<^sub>1 \<dots> |
|
464 |
\<phi>\<^sub>n"} the naming refers to all propositions collectively. |
|
465 |
Isar language elements that refer to \railnonterm{vars} or |
|
466 |
\railnonterm{props} typically admit separate typings or namings via |
|
467 |
another level of iteration, with explicit @{keyword_ref "and"} |
|
468 |
separators; e.g.\ see @{command "fix"} and @{command "assume"} in |
|
469 |
\secref{sec:proof-context}. |
|
470 |
*} |
|
471 |
||
472 |
end |