7050
|
1 |
|
|
2 |
%FIXME
|
|
3 |
% - examples (!?)
|
|
4 |
|
7046
|
5 |
|
|
6 |
\chapter{Isar document syntax}
|
|
7 |
|
7134
|
8 |
FIXME shortcut
|
|
9 |
|
7050
|
10 |
FIXME important note: inner versus outer syntax
|
7046
|
11 |
|
|
12 |
\section{Lexical matters}
|
|
13 |
|
|
14 |
\section{Common syntax entities}
|
|
15 |
|
7050
|
16 |
The Isar proof and theory language syntax has been carefully designed with
|
7134
|
17 |
orthogonality in mind. Subsequently, we introduce several basic syntactic
|
|
18 |
entities, such as names, terms, theorem specifications, which have been
|
|
19 |
factored out of the actual Isar language elements described later.
|
|
20 |
|
|
21 |
Some of the basic syntactic entities introduced below act much like tokens
|
|
22 |
rather than nonterminals, in particular for error messages are concerned.
|
|
23 |
E.g.\ syntax elements such as $\CONSTS$ referring to \railqtoken{name} or
|
|
24 |
\railqtoken{type} would really report a missing \railqtoken{name} or
|
|
25 |
\railqtoken{type} rather than any of its constituent primitive tokens
|
|
26 |
(\railtoken{ident}, \railtoken{string} etc.).
|
7046
|
27 |
|
7050
|
28 |
|
|
29 |
\subsection{Names}
|
|
30 |
|
7134
|
31 |
Entity \railqtoken{name} usually refers to any name of types, constants,
|
7050
|
32 |
theorems, etc.\ to be \emph{declared} or \emph{defined} (so qualified
|
7134
|
33 |
identifiers are excluded). Quoted strings provide an escape for
|
|
34 |
non-identifier names or those ruled out by outer syntax keywords (e.g.\
|
|
35 |
\verb|"let"|). Already existing objects are usually referenced by
|
|
36 |
\railqtoken{nameref}.
|
7050
|
37 |
|
7141
|
38 |
\indexoutertoken{name}\indexoutertoken{parname}\indexoutertoken{nameref}
|
7046
|
39 |
\begin{rail}
|
|
40 |
name : ident | symident | string
|
|
41 |
;
|
7141
|
42 |
parname : '(' name ')'
|
|
43 |
;
|
7046
|
44 |
nameref : name | longident
|
|
45 |
;
|
|
46 |
\end{rail}
|
|
47 |
|
7050
|
48 |
|
7046
|
49 |
\subsection{Comments}
|
|
50 |
|
7134
|
51 |
Large chunks of plain \railqtoken{text} are usually given \railtoken{verbatim},
|
|
52 |
i.e.\ enclosed in \verb|{*|\dots\verb|*}|. For convenience, any of the
|
|
53 |
smaller text entities (\railtoken{ident}, \railtoken{string} etc.) are
|
|
54 |
admitted as well. Almost any of the Isar commands may be annotated by a
|
|
55 |
marginal \railnonterm{comment}: \texttt{--} \railqtoken{text}. Note that this
|
|
56 |
kind of comment is actually part of the language, while source level comments
|
|
57 |
\verb|(*|\dots\verb|*)| are already stripped at the lexical level. A few
|
|
58 |
commands such as $\PROOFNAME$ admit additional markup with a ``level of
|
|
59 |
interest'', currently only \texttt{\%} for ``boring, don't read this''.
|
7050
|
60 |
|
|
61 |
\indexoutertoken{text}\indexouternonterm{comment}\indexouternonterm{interest}
|
7046
|
62 |
\begin{rail}
|
7050
|
63 |
text : verbatim | nameref
|
|
64 |
;
|
7134
|
65 |
comment : '--' text
|
7046
|
66 |
;
|
7134
|
67 |
interest : '\%'
|
7046
|
68 |
;
|
|
69 |
\end{rail}
|
|
70 |
|
|
71 |
|
|
72 |
\subsection{Sorts and arities}
|
|
73 |
|
7050
|
74 |
The syntax of sorts and arities is given directly at the outer level. Note
|
|
75 |
that this in contrast to that types and terms (see below). Only few commands
|
|
76 |
ever refer to sorts or arities explicitly.
|
|
77 |
|
|
78 |
\indexouternonterm{sort}\indexouternonterm{arity}\indexouternonterm{simplearity}
|
7135
|
79 |
\indexouternonterm{classdecl}
|
7046
|
80 |
\begin{rail}
|
|
81 |
sort : nameref | lbrace (nameref * ',') rbrace
|
|
82 |
;
|
|
83 |
arity : ( () | '(' (sort + ',') ')' ) sort
|
|
84 |
;
|
7050
|
85 |
simplearity : ( () | '(' (sort + ',') ')' ) nameref
|
|
86 |
;
|
7135
|
87 |
classdecl: name ('<' (nameref ',' +))? comment?
|
7050
|
88 |
\end{rail}
|
|
89 |
|
|
90 |
|
|
91 |
\subsection{Types and terms}
|
|
92 |
|
|
93 |
The actual inner Isabelle syntax, i.e.\ that of types and terms, is far too
|
|
94 |
flexible in order to be modeled explicitly at the outer theory level.
|
|
95 |
Basically, any such entity would have to be quoted at the outer level to turn
|
|
96 |
it into a single token, with the actual parsing deferred to some functions
|
7134
|
97 |
that read and type-check terms etc.\ (note that \railqtoken{prop}s will be
|
|
98 |
handled differently from plain \railqtoken{term}s here). For convenience, the
|
7050
|
99 |
quotes may be omitted for any \emph{atomic} term or type (e.g.\ a single
|
|
100 |
variable).
|
|
101 |
|
|
102 |
\indexoutertoken{type}\indexoutertoken{term}\indexoutertoken{prop}
|
|
103 |
\begin{rail}
|
7134
|
104 |
type : nameref | typefree | typevar
|
7050
|
105 |
;
|
7134
|
106 |
term : nameref | var | textvar | nat
|
7050
|
107 |
;
|
|
108 |
prop : term
|
|
109 |
;
|
|
110 |
\end{rail}
|
|
111 |
|
|
112 |
Type definitions etc.\ usually refer to \railnonterm{typespec} on the
|
|
113 |
left-hand side. This models basic type constructor application at the outer
|
|
114 |
syntax level. Note that only plain postfix notation is available here, but no
|
|
115 |
infixes.
|
|
116 |
|
|
117 |
\indexouternonterm{typespec}
|
|
118 |
\begin{rail}
|
|
119 |
typespec : (() | typefree | '(' ( typefree + ',' ) ')') name
|
|
120 |
;
|
|
121 |
\end{rail}
|
|
122 |
|
|
123 |
|
|
124 |
\subsection{Term patterns}
|
|
125 |
|
|
126 |
Statements like $\SHOWNAME$ involve propositions, some others like $\DEFNAME$
|
|
127 |
plain terms. Any of these usually admit automatic binding of schematic text
|
|
128 |
variables by giving (optional) patterns $\IS{p@1 \dots p@n}$. For
|
7134
|
129 |
\railqtoken{prop}s the $\CONCLNAME$ part refers to the conclusion only, in case
|
7050
|
130 |
actual rules are involved, rather than atomic propositions.
|
|
131 |
|
|
132 |
\indexouternonterm{termpat}\indexouternonterm{proppat}
|
|
133 |
\begin{rail}
|
|
134 |
termpat : '(' (term + 'is' ) ')'
|
|
135 |
;
|
|
136 |
proppat : '(' (() | (prop + 'is' )) (() | 'concl' (prop + 'is' )) ')'
|
7046
|
137 |
;
|
|
138 |
\end{rail}
|
|
139 |
|
|
140 |
|
7050
|
141 |
\subsection{Mixfix annotations}
|
|
142 |
|
7134
|
143 |
Mixfix annotations specify concrete \emph{inner} syntax of Isabelle types and
|
|
144 |
terms. Some commands such as $\TYPES$ admit infixes only, while $\CONSTS$
|
|
145 |
etc.\ support the full range of general mixfixes and binders.
|
7046
|
146 |
|
7050
|
147 |
\indexouternonterm{infix}\indexouternonterm{mixfix}
|
7046
|
148 |
\begin{rail}
|
7050
|
149 |
infix : '(' ('infixl' | 'infixr') (() | string) nat ')'
|
|
150 |
;
|
|
151 |
|
|
152 |
mixfix : infix | string (() | '[' (nat + ',') ']') (() | nat) |
|
|
153 |
'binder' string (() | '[' (nat + ',') ']') nat
|
|
154 |
;
|
7046
|
155 |
\end{rail}
|
|
156 |
|
7050
|
157 |
|
7134
|
158 |
\subsection{Attributes and theorems}\label{sec:syn-att}
|
7050
|
159 |
|
|
160 |
Attributes (and proof methods, see \S\ref{sec:syn-meth}) have their own
|
|
161 |
``semi-inner'' syntax, which does not have to be atomic at the outer level
|
|
162 |
unlike that of types and terms. Instead, the attribute argument
|
|
163 |
specifications may be any sequence of atomic entities (identifiers, strings
|
7134
|
164 |
etc.), or properly bracketed argument lists. Below \railqtoken{atom} refers to
|
7050
|
165 |
any atomic entity (\railtoken{ident}, \railtoken{longident},
|
|
166 |
\railtoken{symident} etc.), including keywords that conform to
|
|
167 |
\railtoken{symident}, but do not coincide with actual command names.
|
|
168 |
|
|
169 |
\indexoutertoken{atom}\indexouternonterm{args}\indexouternonterm{attributes}
|
|
170 |
\begin{rail}
|
7134
|
171 |
atom : nameref | typefree | typevar | var | textvar | nat
|
|
172 |
;
|
|
173 |
arg : atom | '(' args ')' | '[' args ']' | lbrace args rbrace
|
7050
|
174 |
;
|
7134
|
175 |
args : arg *
|
|
176 |
;
|
|
177 |
attributes : '[' (nameref args * ',') ']'
|
7050
|
178 |
;
|
|
179 |
\end{rail}
|
|
180 |
|
7134
|
181 |
Theorem specifications come in three flavors: \railnonterm{thmdecl} usually
|
|
182 |
refers to the result of an assumption or goal statement (e.g.\ $\SHOWNAME$),
|
7050
|
183 |
\railnonterm{thmdef} collects lists of existing theorems (as in $\NOTENAME$),
|
7134
|
184 |
\railnonterm{thmrefs} refers to any list of existing theorems (e.g.\ occurring
|
7050
|
185 |
as proof method arguments). Any of these may include lists of attributes,
|
|
186 |
which are applied to the preceding theorem or list of theorems.
|
|
187 |
|
7135
|
188 |
\indexouternonterm{thmdecl}\indexouternonterm{axmdecl}
|
|
189 |
\indexouternonterm{thmdef}\indexouternonterm{thmrefs}
|
7050
|
190 |
\begin{rail}
|
7134
|
191 |
thmname : name attributes | name | attributes
|
7050
|
192 |
;
|
7135
|
193 |
axmdecl : name attributes? ':'
|
|
194 |
;
|
7134
|
195 |
thmdecl : thmname ':'
|
7050
|
196 |
;
|
7134
|
197 |
thmdef : thmname '='
|
|
198 |
;
|
|
199 |
thmrefs : nameref (() | attributes) +
|
7050
|
200 |
;
|
|
201 |
\end{rail}
|
7046
|
202 |
|
|
203 |
|
7050
|
204 |
\subsection{Proof methods}\label{sec:syn-meth}
|
7046
|
205 |
|
7050
|
206 |
Proof methods are either basic ones, or expressions composed of methods via
|
|
207 |
``\texttt{,}'' (sequential composition), ``\texttt{|}'' (alternatives),
|
|
208 |
``\texttt{?}'' (try), ``\texttt{*}'' (repeat, ${} \ge 0$ times),
|
7134
|
209 |
``\texttt{+}'' (repeat, ${} > 0$ times). In practice, proof methods are very
|
|
210 |
often just a comma separated list of \railqtoken{nameref}~\railnonterm{args}
|
7050
|
211 |
specifications. Thus the syntax is similar to that of attributes, with plain
|
|
212 |
parentheses instead of square brackets (see also \S\ref{sec:syn-att}). Note
|
7134
|
213 |
that parentheses may be dropped for single method specifications without
|
|
214 |
arguments.
|
7046
|
215 |
|
7050
|
216 |
\indexouternonterm{method}
|
|
217 |
\begin{rail}
|
7134
|
218 |
method : (nameref | '(' methods ')') (() | '?' | '*' | '+')
|
|
219 |
;
|
|
220 |
methods : (nameref args | method) + (',' | '|')
|
7050
|
221 |
;
|
|
222 |
\end{rail}
|
7046
|
223 |
|
|
224 |
|
|
225 |
%%% Local Variables:
|
|
226 |
%%% mode: latex
|
|
227 |
%%% TeX-master: "isar-ref"
|
|
228 |
%%% End:
|