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