author | wenzelm |
Mon, 12 Oct 2015 22:03:24 +0200 | |
changeset 61421 | e0825405d398 |
parent 61252 | c165f0472d57 |
child 61439 | 2bf52eec4e8a |
permissions | -rw-r--r-- |
27037 | 1 |
theory Outer_Syntax |
42651 | 2 |
imports Base Main |
27037 | 3 |
begin |
4 |
||
58618 | 5 |
chapter \<open>Outer syntax --- the theory language \label{ch:outer-syntax}\<close> |
27037 | 6 |
|
58618 | 7 |
text \<open> |
27037 | 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 |
||
61421 | 18 |
\<^medskip> |
19 |
In order to get started with writing well-formed |
|
27037 | 20 |
Isabelle/Isar documents, the most important aspect to be noted is |
21 |
the difference of \emph{inner} versus \emph{outer} syntax. Inner |
|
22 |
syntax is that of Isabelle types and terms of the logic, while outer |
|
23 |
syntax is that of Isabelle/Isar theory sources (specifications and |
|
24 |
proofs). As a general rule, inner syntax entities may occur only as |
|
25 |
\emph{atomic entities} within outer syntax. For example, the string |
|
58724 | 26 |
@{verbatim \<open>"x + y"\<close>} and identifier @{verbatim z} are legal term |
27037 | 27 |
specifications within a theory, while @{verbatim "x + y"} without |
28 |
quotes is not. |
|
29 |
||
30 |
Printed theory documents usually omit quotes to gain readability |
|
31 |
(this is a matter of {\LaTeX} macro setup, say via @{verbatim |
|
60270 | 32 |
"\\isabellestyle"}, see also @{cite "isabelle-system"}). Experienced |
27037 | 33 |
users of Isabelle/Isar may easily reconstruct the lost technical |
34 |
information, while mere readers need not care about quotes at all. |
|
58618 | 35 |
\<close> |
27037 | 36 |
|
37 |
||
58618 | 38 |
section \<open>Commands\<close> |
50213 | 39 |
|
58618 | 40 |
text \<open> |
50213 | 41 |
\begin{matharray}{rcl} |
42 |
@{command_def "print_commands"}@{text "\<^sup>*"} & : & @{text "any \<rightarrow>"} \\ |
|
43 |
@{command_def "help"}@{text "\<^sup>*"} & : & @{text "any \<rightarrow>"} \\ |
|
44 |
\end{matharray} |
|
45 |
||
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
46 |
@{rail \<open> |
50213 | 47 |
@@{command help} (@{syntax name} * ) |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
48 |
\<close>} |
50213 | 49 |
|
50 |
\begin{description} |
|
51 |
||
52 |
\item @{command "print_commands"} prints all outer syntax keywords |
|
53 |
and commands. |
|
54 |
||
55 |
\item @{command "help"}~@{text "pats"} retrieves outer syntax |
|
56 |
commands according to the specified name patterns. |
|
57 |
||
58 |
\end{description} |
|
58618 | 59 |
\<close> |
50213 | 60 |
|
61 |
||
58618 | 62 |
subsubsection \<open>Examples\<close> |
50213 | 63 |
|
58618 | 64 |
text \<open>Some common diagnostic commands are retrieved like this |
65 |
(according to usual naming conventions):\<close> |
|
50213 | 66 |
|
67 |
help "print" |
|
68 |
help "find" |
|
69 |
||
70 |
||
58618 | 71 |
section \<open>Lexical matters \label{sec:outer-lex}\<close> |
27037 | 72 |
|
58618 | 73 |
text \<open>The outer lexical syntax consists of three main categories of |
28776 | 74 |
syntax tokens: |
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
75 |
|
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
76 |
\begin{enumerate} |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
77 |
|
61421 | 78 |
\<^enum> \emph{major keywords} --- the command names that are available |
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
79 |
in the present logic session; |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
80 |
|
61421 | 81 |
\<^enum> \emph{minor keywords} --- additional literal tokens required |
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
82 |
by the syntax of commands; |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
83 |
|
61421 | 84 |
\<^enum> \emph{named tokens} --- various categories of identifiers etc. |
27037 | 85 |
|
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
86 |
\end{enumerate} |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
87 |
|
28776 | 88 |
Major keywords and minor keywords are guaranteed to be disjoint. |
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
89 |
This helps user-interfaces to determine the overall structure of a |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
90 |
theory text, without knowing the full details of command syntax. |
28776 | 91 |
Internally, there is some additional information about the kind of |
92 |
major keywords, which approximates the command type (theory command, |
|
93 |
proof command etc.). |
|
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
94 |
|
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
95 |
Keywords override named tokens. For example, the presence of a |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
96 |
command called @{verbatim term} inhibits the identifier @{verbatim |
58724 | 97 |
term}, but the string @{verbatim \<open>"term"\<close>} can be used instead. |
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
98 |
By convention, the outer syntax always allows quoted strings in |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
99 |
addition to identifiers, wherever a named entity is expected. |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
100 |
|
28776 | 101 |
When tokenizing a given input sequence, the lexer repeatedly takes |
102 |
the longest prefix of the input that forms a valid token. Spaces, |
|
103 |
tabs, newlines and formfeeds between tokens serve as explicit |
|
104 |
separators. |
|
105 |
||
61421 | 106 |
\<^medskip> |
107 |
The categories for named tokens are defined once and for all as follows. |
|
27037 | 108 |
|
28776 | 109 |
\begin{center} |
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
110 |
\begin{supertabular}{rcl} |
53059 | 111 |
@{syntax_def ident} & = & @{text "letter (subscript\<^sup>? quasiletter)\<^sup>*"} \\ |
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
112 |
@{syntax_def longident} & = & @{text "ident("}@{verbatim "."}@{text "ident)\<^sup>+"} \\ |
58724 | 113 |
@{syntax_def symident} & = & @{text "sym\<^sup>+ | "}@{verbatim \<open>\\<close>}@{verbatim "<"}@{text ident}@{verbatim ">"} \\ |
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
114 |
@{syntax_def nat} & = & @{text "digit\<^sup>+"} \\ |
40290
47f572aff50a
support for floating-point tokens in outer syntax (coinciding with inner syntax version);
wenzelm
parents:
35841
diff
changeset
|
115 |
@{syntax_def float} & = & @{syntax_ref nat}@{verbatim "."}@{syntax_ref nat}@{text " | "}@{verbatim "-"}@{syntax_ref nat}@{verbatim "."}@{syntax_ref nat} \\ |
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
116 |
@{syntax_def var} & = & @{verbatim "?"}@{text "ident | "}@{verbatim "?"}@{text ident}@{verbatim "."}@{text nat} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
117 |
@{syntax_def typefree} & = & @{verbatim "'"}@{text ident} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
118 |
@{syntax_def typevar} & = & @{verbatim "?"}@{text "typefree | "}@{verbatim "?"}@{text typefree}@{verbatim "."}@{text nat} \\ |
58724 | 119 |
@{syntax_def string} & = & @{verbatim \<open>"\<close>} @{text "\<dots>"} @{verbatim \<open>"\<close>} \\ |
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
120 |
@{syntax_def altstring} & = & @{verbatim "`"} @{text "\<dots>"} @{verbatim "`"} \\ |
55033 | 121 |
@{syntax_def cartouche} & = & @{verbatim "\<open>"} @{text "\<dots>"} @{verbatim "\<close>"} \\ |
58725 | 122 |
@{syntax_def verbatim} & = & @{verbatim "{*"} @{text "\<dots>"} @{verbatim "*}"} \\[1ex] |
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
123 |
|
58724 | 124 |
@{text letter} & = & @{text "latin | "}@{verbatim \<open>\\<close>}@{verbatim "<"}@{text latin}@{verbatim ">"}@{text " | "}@{verbatim \<open>\\<close>}@{verbatim "<"}@{text "latin latin"}@{verbatim ">"}@{text " | greek |"} \\ |
53059 | 125 |
@{text subscript} & = & @{verbatim "\<^sub>"} \\ |
28775
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
126 |
@{text quasiletter} & = & @{text "letter | digit | "}@{verbatim "_"}@{text " | "}@{verbatim "'"} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
127 |
@{text latin} & = & @{verbatim a}@{text " | \<dots> | "}@{verbatim z}@{text " | "}@{verbatim A}@{text " | \<dots> | "}@{verbatim Z} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
128 |
@{text digit} & = & @{verbatim "0"}@{text " | \<dots> | "}@{verbatim "9"} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
129 |
@{text sym} & = & @{verbatim "!"}@{text " | "}@{verbatim "#"}@{text " | "}@{verbatim "$"}@{text " | "}@{verbatim "%"}@{text " | "}@{verbatim "&"}@{text " | "}@{verbatim "*"}@{text " | "}@{verbatim "+"}@{text " | "}@{verbatim "-"}@{text " | "}@{verbatim "/"}@{text " |"} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
130 |
& & @{verbatim "<"}@{text " | "}@{verbatim "="}@{text " | "}@{verbatim ">"}@{text " | "}@{verbatim "?"}@{text " | "}@{verbatim "@"}@{text " | "}@{verbatim "^"}@{text " | "}@{verbatim "_"}@{text " | "}@{verbatim "|"}@{text " | "}@{verbatim "~"} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
131 |
@{text greek} & = & @{verbatim "\<alpha>"}@{text " | "}@{verbatim "\<beta>"}@{text " | "}@{verbatim "\<gamma>"}@{text " | "}@{verbatim "\<delta>"}@{text " |"} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
132 |
& & @{verbatim "\<epsilon>"}@{text " | "}@{verbatim "\<zeta>"}@{text " | "}@{verbatim "\<eta>"}@{text " | "}@{verbatim "\<theta>"}@{text " |"} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
133 |
& & @{verbatim "\<iota>"}@{text " | "}@{verbatim "\<kappa>"}@{text " | "}@{verbatim "\<mu>"}@{text " | "}@{verbatim "\<nu>"}@{text " |"} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
134 |
& & @{verbatim "\<xi>"}@{text " | "}@{verbatim "\<pi>"}@{text " | "}@{verbatim "\<rho>"}@{text " | "}@{verbatim "\<sigma>"}@{text " | "}@{verbatim "\<tau>"}@{text " |"} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
135 |
& & @{verbatim "\<upsilon>"}@{text " | "}@{verbatim "\<phi>"}@{text " | "}@{verbatim "\<chi>"}@{text " | "}@{verbatim "\<psi>"}@{text " |"} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
136 |
& & @{verbatim "\<omega>"}@{text " | "}@{verbatim "\<Gamma>"}@{text " | "}@{verbatim "\<Delta>"}@{text " | "}@{verbatim "\<Theta>"}@{text " |"} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
137 |
& & @{verbatim "\<Lambda>"}@{text " | "}@{verbatim "\<Xi>"}@{text " | "}@{verbatim "\<Pi>"}@{text " | "}@{verbatim "\<Sigma>"}@{text " |"} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
138 |
& & @{verbatim "\<Upsilon>"}@{text " | "}@{verbatim "\<Phi>"}@{text " | "}@{verbatim "\<Psi>"}@{text " | "}@{verbatim "\<Omega>"} \\ |
d25fe9601dbd
tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents:
28774
diff
changeset
|
139 |
\end{supertabular} |
28776 | 140 |
\end{center} |
27037 | 141 |
|
28778 | 142 |
A @{syntax_ref var} or @{syntax_ref typevar} describes an unknown, |
143 |
which is internally a pair of base name and index (ML type @{ML_type |
|
144 |
indexname}). These components are either separated by a dot as in |
|
145 |
@{text "?x.1"} or @{text "?x7.3"} or run together as in @{text |
|
146 |
"?x1"}. The latter form is possible if the base name does not end |
|
147 |
with digits. If the index is 0, it may be dropped altogether: |
|
148 |
@{text "?x"} and @{text "?x0"} and @{text "?x.0"} all refer to the |
|
149 |
same unknown, with basename @{text "x"} and index 0. |
|
150 |
||
151 |
The syntax of @{syntax_ref string} admits any characters, including |
|
58724 | 152 |
newlines; ``@{verbatim \<open>"\<close>}'' (double-quote) and ``@{verbatim \<open>\\<close>}'' |
153 |
(backslash) need to be escaped by a backslash; arbitrary |
|
154 |
character codes may be specified as ``@{verbatim \<open>\\<close>}@{text ddd}'', |
|
27037 | 155 |
with three decimal digits. Alternative strings according to |
28778 | 156 |
@{syntax_ref altstring} are analogous, using single back-quotes |
157 |
instead. |
|
158 |
||
58725 | 159 |
The body of @{syntax_ref verbatim} may consist of any text not containing |
160 |
``@{verbatim "*}"}''; this allows to include quotes without further |
|
161 |
escapes, but there is no way to escape ``@{verbatim "*}"}''. Cartouches |
|
162 |
do not have this limitation. |
|
28778 | 163 |
|
55033 | 164 |
A @{syntax_ref cartouche} consists of arbitrary text, with properly |
165 |
balanced blocks of ``@{verbatim "\<open>"}~@{text "\<dots>"}~@{verbatim |
|
166 |
"\<close>"}''. Note that the rendering of cartouche delimiters is |
|
167 |
usually like this: ``@{text "\<open> \<dots> \<close>"}''. |
|
168 |
||
28778 | 169 |
Source comments take the form @{verbatim "(*"}~@{text |
170 |
"\<dots>"}~@{verbatim "*)"} and may be nested, although the user-interface |
|
171 |
might prevent this. Note that this form indicates source comments |
|
172 |
only, which are stripped after lexical analysis of the input. The |
|
173 |
Isar syntax also provides proper \emph{document comments} that are |
|
174 |
considered as part of the text (see \secref{sec:comments}). |
|
27037 | 175 |
|
176 |
Common mathematical symbols such as @{text \<forall>} are represented in |
|
177 |
Isabelle as @{verbatim \<forall>}. There are infinitely many Isabelle |
|
178 |
symbols like this, although proper presentation is left to front-end |
|
58842 | 179 |
tools such as {\LaTeX} or Isabelle/jEdit. A list of |
47822
34b44d28fc4b
some updates concerning current Proof General 4.x, which lacks X-Symbol mode of 3.x;
wenzelm
parents:
47114
diff
changeset
|
180 |
predefined Isabelle symbols that work well with these tools is given |
34b44d28fc4b
some updates concerning current Proof General 4.x, which lacks X-Symbol mode of 3.x;
wenzelm
parents:
47114
diff
changeset
|
181 |
in \appref{app:symbols}. Note that @{verbatim "\<lambda>"} does not belong |
34b44d28fc4b
some updates concerning current Proof General 4.x, which lacks X-Symbol mode of 3.x;
wenzelm
parents:
47114
diff
changeset
|
182 |
to the @{text letter} category, since it is already used differently |
58618 | 183 |
in the Pure term language.\<close> |
27037 | 184 |
|
185 |
||
58618 | 186 |
section \<open>Common syntax entities\<close> |
27037 | 187 |
|
58618 | 188 |
text \<open> |
27037 | 189 |
We now introduce several basic syntactic entities, such as names, |
190 |
terms, and theorem specifications, which are factored out of the |
|
191 |
actual Isar language elements to be described later. |
|
58618 | 192 |
\<close> |
27037 | 193 |
|
194 |
||
58618 | 195 |
subsection \<open>Names\<close> |
27037 | 196 |
|
58618 | 197 |
text \<open>Entity @{syntax name} usually refers to any name of types, |
27037 | 198 |
constants, theorems etc.\ that are to be \emph{declared} or |
199 |
\emph{defined} (so qualified identifiers are excluded here). Quoted |
|
200 |
strings provide an escape for non-identifier names or those ruled |
|
58724 | 201 |
out by outer syntax keywords (e.g.\ quoted @{verbatim \<open>"let"\<close>}). |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
202 |
Already existing objects are usually referenced by @{syntax |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
203 |
nameref}. |
27037 | 204 |
|
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
205 |
@{rail \<open> |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
206 |
@{syntax_def name}: @{syntax ident} | @{syntax symident} | |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
207 |
@{syntax string} | @{syntax nat} |
27037 | 208 |
; |
60131 | 209 |
@{syntax_def par_name}: '(' @{syntax name} ')' |
27037 | 210 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
211 |
@{syntax_def nameref}: @{syntax name} | @{syntax longident} |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
212 |
\<close>} |
58618 | 213 |
\<close> |
40296 | 214 |
|
215 |
||
58618 | 216 |
subsection \<open>Numbers\<close> |
40296 | 217 |
|
58618 | 218 |
text \<open>The outer lexical syntax (\secref{sec:outer-lex}) admits |
40296 | 219 |
natural numbers and floating point numbers. These are combined as |
220 |
@{syntax int} and @{syntax real} as follows. |
|
221 |
||
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
222 |
@{rail \<open> |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
223 |
@{syntax_def int}: @{syntax nat} | '-' @{syntax nat} |
27037 | 224 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
225 |
@{syntax_def real}: @{syntax float} | @{syntax int} |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
226 |
\<close>} |
40296 | 227 |
|
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
228 |
Note that there is an overlap with the category @{syntax name}, |
40296 | 229 |
which also includes @{syntax nat}. |
58618 | 230 |
\<close> |
27037 | 231 |
|
232 |
||
58618 | 233 |
subsection \<open>Comments \label{sec:comments}\<close> |
27037 | 234 |
|
58725 | 235 |
text \<open>Large chunks of plain @{syntax text} are usually given @{syntax |
236 |
verbatim}, i.e.\ enclosed in @{verbatim "{*"}~@{text "\<dots>"}~@{verbatim "*}"}, |
|
237 |
or as @{syntax cartouche} @{text "\<open>\<dots>\<close>"}. For convenience, any of the |
|
238 |
smaller text units conforming to @{syntax nameref} are admitted as well. A |
|
239 |
marginal @{syntax comment} is of the form @{verbatim "--"}~@{syntax text}. |
|
240 |
Any number of these may occur within Isabelle/Isar commands. |
|
27037 | 241 |
|
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
242 |
@{rail \<open> |
56499
7e0178c84994
allow text cartouches in regular outer syntax categories "text" and "altstring";
wenzelm
parents:
56451
diff
changeset
|
243 |
@{syntax_def text}: @{syntax verbatim} | @{syntax cartouche} | @{syntax nameref} |
27037 | 244 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
245 |
@{syntax_def comment}: '--' @{syntax text} |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
246 |
\<close>} |
58618 | 247 |
\<close> |
27037 | 248 |
|
249 |
||
58618 | 250 |
subsection \<open>Type classes, sorts and arities\<close> |
27037 | 251 |
|
58618 | 252 |
text \<open> |
27037 | 253 |
Classes are specified by plain names. Sorts have a very simple |
254 |
inner syntax, which is either a single class name @{text c} or a |
|
255 |
list @{text "{c\<^sub>1, \<dots>, c\<^sub>n}"} referring to the |
|
256 |
intersection of these classes. The syntax of type arities is given |
|
257 |
directly at the outer level. |
|
258 |
||
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
259 |
@{rail \<open> |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
260 |
@{syntax_def classdecl}: @{syntax name} (('<' | '\<subseteq>') (@{syntax nameref} + ','))? |
27037 | 261 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
262 |
@{syntax_def sort}: @{syntax nameref} |
27037 | 263 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
264 |
@{syntax_def arity}: ('(' (@{syntax sort} + ',') ')')? @{syntax sort} |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
265 |
\<close>} |
58618 | 266 |
\<close> |
27037 | 267 |
|
268 |
||
58618 | 269 |
subsection \<open>Types and terms \label{sec:types-terms}\<close> |
27037 | 270 |
|
58618 | 271 |
text \<open> |
27037 | 272 |
The actual inner Isabelle syntax, that of types and terms of the |
273 |
logic, is far too sophisticated in order to be modelled explicitly |
|
274 |
at the outer theory level. Basically, any such entity has to be |
|
275 |
quoted to turn it into a single token (the parsing and type-checking |
|
276 |
is performed internally later). For convenience, a slightly more |
|
277 |
liberal convention is adopted: quotes may be omitted for any type or |
|
278 |
term that is already atomic at the outer level. For example, one |
|
58724 | 279 |
may just write @{verbatim x} instead of quoted @{verbatim \<open>"x"\<close>}. |
27037 | 280 |
Note that symbolic identifiers (e.g.\ @{verbatim "++"} or @{text |
281 |
"\<forall>"} are available as well, provided these have not been superseded |
|
282 |
by commands or other keywords already (such as @{verbatim "="} or |
|
283 |
@{verbatim "+"}). |
|
284 |
||
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
285 |
@{rail \<open> |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
286 |
@{syntax_def type}: @{syntax nameref} | @{syntax typefree} | |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
287 |
@{syntax typevar} |
27037 | 288 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
289 |
@{syntax_def term}: @{syntax nameref} | @{syntax var} |
27037 | 290 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
291 |
@{syntax_def prop}: @{syntax term} |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
292 |
\<close>} |
27037 | 293 |
|
59853 | 294 |
Positional instantiations are specified as a sequence of terms, or the |
295 |
placeholder ``@{text _}'' (underscore), which means to skip a position. |
|
27037 | 296 |
|
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
297 |
@{rail \<open> |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
298 |
@{syntax_def inst}: '_' | @{syntax term} |
27037 | 299 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
300 |
@{syntax_def insts}: (@{syntax inst} *) |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
301 |
\<close>} |
27037 | 302 |
|
59853 | 303 |
Named instantiations are specified as pairs of assignments @{text "v = |
304 |
t"}, which refer to schematic variables in some theorem that is |
|
305 |
instantiated. Both type and terms instantiations are admitted, and |
|
306 |
distinguished by the usual syntax of variable names. |
|
307 |
||
308 |
@{rail \<open> |
|
309 |
@{syntax_def named_inst}: variable '=' (type | term) |
|
310 |
; |
|
311 |
@{syntax_def named_insts}: (named_inst @'and' +) |
|
312 |
; |
|
313 |
variable: @{syntax name} | @{syntax var} | @{syntax typefree} | @{syntax typevar} |
|
314 |
\<close>} |
|
315 |
||
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
316 |
Type declarations and definitions usually refer to @{syntax |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
317 |
typespec} on the left-hand side. This models basic type constructor |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
318 |
application at the outer syntax level. Note that only plain postfix |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
319 |
notation is available here, but no infixes. |
27037 | 320 |
|
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
321 |
@{rail \<open> |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
322 |
@{syntax_def typespec}: |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
323 |
(() | @{syntax typefree} | '(' ( @{syntax typefree} + ',' ) ')') @{syntax name} |
27037 | 324 |
; |
42705 | 325 |
@{syntax_def typespec_sorts}: |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
326 |
(() | (@{syntax typefree} ('::' @{syntax sort})?) | |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
327 |
'(' ( (@{syntax typefree} ('::' @{syntax sort})?) + ',' ) ')') @{syntax name} |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
328 |
\<close>} |
58618 | 329 |
\<close> |
27037 | 330 |
|
331 |
||
58618 | 332 |
subsection \<open>Term patterns and declarations \label{sec:term-decls}\<close> |
28754
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
333 |
|
58618 | 334 |
text \<open>Wherever explicit propositions (or term fragments) occur in a |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
335 |
proof text, casual binding of schematic term variables may be given |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
336 |
specified via patterns of the form ``@{text "(\<IS> p\<^sub>1 \<dots> p\<^sub>n)"}''. |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
337 |
This works both for @{syntax term} and @{syntax prop}. |
28754
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
338 |
|
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
339 |
@{rail \<open> |
42705 | 340 |
@{syntax_def term_pat}: '(' (@'is' @{syntax term} +) ')' |
28754
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
341 |
; |
42705 | 342 |
@{syntax_def prop_pat}: '(' (@'is' @{syntax prop} +) ')' |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
343 |
\<close>} |
28754
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
344 |
|
61421 | 345 |
\<^medskip> |
346 |
Declarations of local variables @{text "x :: \<tau>"} and |
|
28754
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
347 |
logical propositions @{text "a : \<phi>"} represent different views on |
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
348 |
the same principle of introducing a local scope. In practice, one |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
349 |
may usually omit the typing of @{syntax vars} (due to |
28754
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
350 |
type-inference), and the naming of propositions (due to implicit |
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
351 |
references of current facts). In any case, Isar proof elements |
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
352 |
usually admit to introduce multiple such items simultaneously. |
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
353 |
|
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
354 |
@{rail \<open> |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
355 |
@{syntax_def vars}: (@{syntax name} +) ('::' @{syntax type})? |
28754
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
356 |
; |
42705 | 357 |
@{syntax_def props}: @{syntax thmdecl}? (@{syntax prop} @{syntax prop_pat}? +) |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
358 |
\<close>} |
28754
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
359 |
|
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
360 |
The treatment of multiple declarations corresponds to the |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
361 |
complementary focus of @{syntax vars} versus @{syntax props}. In |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
362 |
``@{text "x\<^sub>1 \<dots> x\<^sub>n :: \<tau>"}'' the typing refers to all variables, while |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
363 |
in @{text "a: \<phi>\<^sub>1 \<dots> \<phi>\<^sub>n"} the naming refers to all propositions |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
364 |
collectively. Isar language elements that refer to @{syntax vars} |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
365 |
or @{syntax props} typically admit separate typings or namings via |
28754
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
366 |
another level of iteration, with explicit @{keyword_ref "and"} |
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
367 |
separators; e.g.\ see @{command "fix"} and @{command "assume"} in |
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
368 |
\secref{sec:proof-context}. |
59785 | 369 |
|
370 |
@{rail \<open> |
|
371 |
@{syntax_def "fixes"}: |
|
372 |
((@{syntax name} ('::' @{syntax type})? @{syntax mixfix}? | @{syntax vars}) + @'and') |
|
373 |
; |
|
374 |
@{syntax_def "for_fixes"}: (@'for' @{syntax "fixes"})? |
|
375 |
\<close>} |
|
376 |
||
377 |
The category @{syntax "fixes"} is a richer variant of @{syntax vars}: it |
|
378 |
admits specification of mixfix syntax for the entities that are introduced |
|
379 |
into the context. An optional suffix ``@{keyword "for"}~@{text "fixes"}'' |
|
380 |
is admitted in many situations to indicate a so-called ``eigen-context'' |
|
381 |
of a formal element: the result will be exported and thus generalized over |
|
382 |
the given variables.\<close> |
|
28754
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
383 |
|
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
384 |
|
58618 | 385 |
subsection \<open>Attributes and theorems \label{sec:syn-att}\<close> |
27037 | 386 |
|
58618 | 387 |
text \<open>Attributes have their own ``semi-inner'' syntax, in the sense |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
388 |
that input conforming to @{syntax args} below is parsed by the |
28754
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
389 |
attribute a second time. The attribute argument specifications may |
6f2e67a3dfaa
moved section "Proof method expressions" to proof chapter;
wenzelm
parents:
28753
diff
changeset
|
390 |
be any sequence of atomic entities (identifiers, strings etc.), or |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
391 |
properly bracketed argument lists. Below @{syntax atom} refers to |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
392 |
any atomic entity, including any @{syntax keyword} conforming to |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
393 |
@{syntax symident}. |
27037 | 394 |
|
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
395 |
@{rail \<open> |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
396 |
@{syntax_def atom}: @{syntax nameref} | @{syntax typefree} | |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
397 |
@{syntax typevar} | @{syntax var} | @{syntax nat} | @{syntax float} | |
55045
99056d23e05b
cartouche within nested args (attributes, methods, etc.);
wenzelm
parents:
55033
diff
changeset
|
398 |
@{syntax keyword} | @{syntax cartouche} |
27037 | 399 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
400 |
arg: @{syntax atom} | '(' @{syntax args} ')' | '[' @{syntax args} ']' |
27037 | 401 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
402 |
@{syntax_def args}: arg * |
27037 | 403 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
404 |
@{syntax_def attributes}: '[' (@{syntax nameref} @{syntax args} * ',') ']' |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
405 |
\<close>} |
27037 | 406 |
|
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
407 |
Theorem specifications come in several flavors: @{syntax axmdecl} |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
408 |
and @{syntax thmdecl} usually refer to axioms, assumptions or |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
409 |
results of goal statements, while @{syntax thmdef} collects lists of |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
410 |
existing theorems. Existing theorems are given by @{syntax thmref} |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
411 |
and @{syntax thmrefs}, the former requires an actual singleton |
27037 | 412 |
result. |
413 |
||
414 |
There are three forms of theorem references: |
|
415 |
\begin{enumerate} |
|
60674 | 416 |
|
61421 | 417 |
\<^enum> named facts @{text "a"}, |
27037 | 418 |
|
61421 | 419 |
\<^enum> selections from named facts @{text "a(i)"} or @{text "a(j - k)"}, |
27037 | 420 |
|
61421 | 421 |
\<^enum> literal fact propositions using token syntax @{syntax_ref altstring} |
56499
7e0178c84994
allow text cartouches in regular outer syntax categories "text" and "altstring";
wenzelm
parents:
56451
diff
changeset
|
422 |
@{verbatim "`"}@{text "\<phi>"}@{verbatim "`"} or @{syntax_ref cartouche} |
7e0178c84994
allow text cartouches in regular outer syntax categories "text" and "altstring";
wenzelm
parents:
56451
diff
changeset
|
423 |
@{text "\<open>\<phi>\<close>"} (see also method @{method_ref fact}). |
27037 | 424 |
|
425 |
\end{enumerate} |
|
426 |
||
427 |
Any kind of theorem specification may include lists of attributes |
|
428 |
both on the left and right hand sides; attributes are applied to any |
|
429 |
immediately preceding fact. If names are omitted, the theorems are |
|
430 |
not stored within the theorem database of the theory or proof |
|
431 |
context, but any given attributes are applied nonetheless. |
|
432 |
||
433 |
An extra pair of brackets around attributes (like ``@{text |
|
434 |
"[[simproc a]]"}'') abbreviates a theorem reference involving an |
|
435 |
internal dummy fact, which will be ignored later on. So only the |
|
436 |
effect of the attribute on the background context will persist. |
|
437 |
This form of in-place declarations is particularly useful with |
|
438 |
commands like @{command "declare"} and @{command "using"}. |
|
439 |
||
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
440 |
@{rail \<open> |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
441 |
@{syntax_def axmdecl}: @{syntax name} @{syntax attributes}? ':' |
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
442 |
; |
60631 | 443 |
@{syntax_def thmbind}: |
444 |
@{syntax name} @{syntax attributes} | @{syntax name} | @{syntax attributes} |
|
445 |
; |
|
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
446 |
@{syntax_def thmdecl}: thmbind ':' |
27037 | 447 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
448 |
@{syntax_def thmdef}: thmbind '=' |
27037 | 449 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
450 |
@{syntax_def thmref}: |
56499
7e0178c84994
allow text cartouches in regular outer syntax categories "text" and "altstring";
wenzelm
parents:
56451
diff
changeset
|
451 |
(@{syntax nameref} selection? | @{syntax altstring} | @{syntax cartouche}) |
7e0178c84994
allow text cartouches in regular outer syntax categories "text" and "altstring";
wenzelm
parents:
56451
diff
changeset
|
452 |
@{syntax attributes}? | |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
453 |
'[' @{syntax attributes} ']' |
27037 | 454 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
455 |
@{syntax_def thmrefs}: @{syntax thmref} + |
27037 | 456 |
; |
42596
6c621a9d612a
modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents:
40296
diff
changeset
|
457 |
selection: '(' ((@{syntax nat} | @{syntax nat} '-' @{syntax nat}?) + ',') ')' |
55112
b1a5d603fd12
prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents:
55045
diff
changeset
|
458 |
\<close>} |
58618 | 459 |
\<close> |
27037 | 460 |
|
60674 | 461 |
|
462 |
section \<open>Diagnostic commands\<close> |
|
463 |
||
464 |
text \<open> |
|
465 |
\begin{matharray}{rcl} |
|
466 |
@{command_def "print_theory"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
|
61252 | 467 |
@{command_def "print_definitions"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
60674 | 468 |
@{command_def "print_methods"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
469 |
@{command_def "print_attributes"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
|
470 |
@{command_def "print_theorems"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
|
471 |
@{command_def "find_theorems"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
|
472 |
@{command_def "find_consts"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
|
473 |
@{command_def "thm_deps"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
|
474 |
@{command_def "unused_thms"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
|
475 |
@{command_def "print_facts"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
|
476 |
@{command_def "print_term_bindings"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
|
477 |
\end{matharray} |
|
478 |
||
479 |
@{rail \<open> |
|
480 |
(@@{command print_theory} | |
|
61252 | 481 |
@@{command print_definitions} | |
60674 | 482 |
@@{command print_methods} | |
483 |
@@{command print_attributes} | |
|
484 |
@@{command print_theorems} | |
|
485 |
@@{command print_facts}) ('!'?) |
|
486 |
; |
|
487 |
@@{command find_theorems} ('(' @{syntax nat}? 'with_dups'? ')')? \<newline> (thm_criterion*) |
|
488 |
; |
|
489 |
thm_criterion: ('-'?) ('name' ':' @{syntax nameref} | 'intro' | 'elim' | 'dest' | |
|
490 |
'solves' | 'simp' ':' @{syntax term} | @{syntax term}) |
|
491 |
; |
|
492 |
@@{command find_consts} (const_criterion*) |
|
493 |
; |
|
494 |
const_criterion: ('-'?) |
|
495 |
('name' ':' @{syntax nameref} | 'strict' ':' @{syntax type} | @{syntax type}) |
|
496 |
; |
|
497 |
@@{command thm_deps} @{syntax thmrefs} |
|
498 |
; |
|
499 |
@@{command unused_thms} ((@{syntax name} +) '-' (@{syntax name} * ))? |
|
500 |
\<close>} |
|
501 |
||
502 |
These commands print certain parts of the theory and proof context. |
|
503 |
Note that there are some further ones available, such as for the set |
|
504 |
of rules declared for simplifications. |
|
505 |
||
506 |
\begin{description} |
|
507 |
||
508 |
\item @{command "print_theory"} prints the main logical content of the |
|
509 |
background theory; the ``@{text "!"}'' option indicates extra verbosity. |
|
510 |
||
61252 | 511 |
\item @{command "print_definitions"} prints dependencies of definitional |
512 |
specifications within the background theory, which may be constants |
|
513 |
\secref{sec:consts} or types (\secref{sec:types-pure}, |
|
514 |
\secref{sec:hol-typedef}); the ``@{text "!"}'' option indicates extra |
|
515 |
verbosity. |
|
516 |
||
60674 | 517 |
\item @{command "print_methods"} prints all proof methods available in the |
518 |
current theory context; the ``@{text "!"}'' option indicates extra |
|
519 |
verbosity. |
|
520 |
||
521 |
\item @{command "print_attributes"} prints all attributes available in the |
|
522 |
current theory context; the ``@{text "!"}'' option indicates extra |
|
523 |
verbosity. |
|
524 |
||
525 |
\item @{command "print_theorems"} prints theorems of the background theory |
|
526 |
resulting from the last command; the ``@{text "!"}'' option indicates |
|
527 |
extra verbosity. |
|
528 |
||
529 |
\item @{command "print_facts"} prints all local facts of the current |
|
530 |
context, both named and unnamed ones; the ``@{text "!"}'' option indicates |
|
531 |
extra verbosity. |
|
532 |
||
533 |
\item @{command "print_term_bindings"} prints all term bindings that |
|
534 |
are present in the context. |
|
535 |
||
536 |
\item @{command "find_theorems"}~@{text criteria} retrieves facts |
|
537 |
from the theory or proof context matching all of given search |
|
538 |
criteria. The criterion @{text "name: p"} selects all theorems |
|
539 |
whose fully qualified name matches pattern @{text p}, which may |
|
540 |
contain ``@{text "*"}'' wildcards. The criteria @{text intro}, |
|
541 |
@{text elim}, and @{text dest} select theorems that match the |
|
542 |
current goal as introduction, elimination or destruction rules, |
|
543 |
respectively. The criterion @{text "solves"} returns all rules |
|
544 |
that would directly solve the current goal. The criterion |
|
545 |
@{text "simp: t"} selects all rewrite rules whose left-hand side |
|
546 |
matches the given term. The criterion term @{text t} selects all |
|
547 |
theorems that contain the pattern @{text t} -- as usual, patterns |
|
548 |
may contain occurrences of the dummy ``@{text _}'', schematic |
|
549 |
variables, and type constraints. |
|
550 |
||
551 |
Criteria can be preceded by ``@{text "-"}'' to select theorems that |
|
552 |
do \emph{not} match. Note that giving the empty list of criteria |
|
553 |
yields \emph{all} currently known facts. An optional limit for the |
|
554 |
number of printed facts may be given; the default is 40. By |
|
555 |
default, duplicates are removed from the search result. Use |
|
556 |
@{text with_dups} to display duplicates. |
|
557 |
||
558 |
\item @{command "find_consts"}~@{text criteria} prints all constants |
|
559 |
whose type meets all of the given criteria. The criterion @{text |
|
560 |
"strict: ty"} is met by any type that matches the type pattern |
|
561 |
@{text ty}. Patterns may contain both the dummy type ``@{text _}'' |
|
562 |
and sort constraints. The criterion @{text ty} is similar, but it |
|
563 |
also matches against subtypes. The criterion @{text "name: p"} and |
|
564 |
the prefix ``@{text "-"}'' function as described for @{command |
|
565 |
"find_theorems"}. |
|
566 |
||
567 |
\item @{command "thm_deps"}~@{text "a\<^sub>1 \<dots> a\<^sub>n"} |
|
568 |
visualizes dependencies of facts, using Isabelle's graph browser |
|
569 |
tool (see also @{cite "isabelle-system"}). |
|
570 |
||
571 |
\item @{command "unused_thms"}~@{text "A\<^sub>1 \<dots> A\<^sub>m - B\<^sub>1 \<dots> B\<^sub>n"} |
|
572 |
displays all theorems that are proved in theories @{text "B\<^sub>1 \<dots> B\<^sub>n"} |
|
573 |
or their parents but not in @{text "A\<^sub>1 \<dots> A\<^sub>m"} or their parents and |
|
574 |
that are never used. |
|
575 |
If @{text n} is @{text 0}, the end of the range of theories |
|
576 |
defaults to the current theory. If no range is specified, |
|
577 |
only the unused theorems in the current theory are displayed. |
|
578 |
||
579 |
\end{description} |
|
580 |
\<close> |
|
581 |
||
27037 | 582 |
end |