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