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