7046
|
1 |
|
7895
|
2 |
\chapter{Basic Isar Language Elements}\label{ch:pure-syntax}
|
7167
|
3 |
|
7315
|
4 |
Subsequently, we introduce the main part of the basic Isar theory and proof
|
|
5 |
commands as provided by Isabelle/Pure. Chapter~\ref{ch:gen-tools} describes
|
7895
|
6 |
further Isar elements provided by generic tools and packages (such as the
|
|
7 |
Simplifier) that are either part of Pure Isabelle or pre-loaded by most object
|
|
8 |
logics. Chapter~\ref{ch:hol-tools} refers to actual object-logic specific
|
|
9 |
elements of Isabelle/HOL.
|
7046
|
10 |
|
7167
|
11 |
\medskip
|
|
12 |
|
|
13 |
Isar commands may be either \emph{proper} document constructors, or
|
7466
|
14 |
\emph{improper commands}. Some proof methods and attributes introduced later
|
|
15 |
are classified as improper as well. Improper Isar language elements, which
|
|
16 |
are subsequently marked by $^*$, are often helpful when developing proof
|
7981
|
17 |
documents, while their use is discouraged for the final outcome. Typical
|
|
18 |
examples are diagnostic commands that print terms or theorems according to the
|
|
19 |
current context; other commands even emulate old-style tactical theorem
|
|
20 |
proving, which facilitates porting of legacy proof scripts.
|
7167
|
21 |
|
7134
|
22 |
|
|
23 |
\section{Theory commands}
|
|
24 |
|
7167
|
25 |
\subsection{Defining theories}\label{sec:begin-thy}
|
7134
|
26 |
|
7895
|
27 |
\indexisarcmd{header}\indexisarcmd{theory}\indexisarcmd{end}\indexisarcmd{context}
|
7134
|
28 |
\begin{matharray}{rcl}
|
7895
|
29 |
\isarcmd{header} & : & \isarkeep{toplevel} \\
|
7134
|
30 |
\isarcmd{theory} & : & \isartrans{\cdot}{theory} \\
|
|
31 |
\isarcmd{context}^* & : & \isartrans{\cdot}{theory} \\
|
|
32 |
\isarcmd{end} & : & \isartrans{theory}{\cdot} \\
|
|
33 |
\end{matharray}
|
|
34 |
|
|
35 |
Isabelle/Isar ``new-style'' theories are either defined via theory files or
|
7981
|
36 |
interactively. Both theory-level specifications and proofs are handled
|
7335
|
37 |
uniformly --- occasionally definitional mechanisms even require some explicit
|
|
38 |
proof as well. In contrast, ``old-style'' Isabelle theories support batch
|
|
39 |
processing only, with the proof scripts collected in separate ML files.
|
7134
|
40 |
|
7895
|
41 |
The first actual command of any theory has to be $\THEORY$, starting a new
|
|
42 |
theory based on the merge of existing ones. Just preceding $\THEORY$, there
|
|
43 |
may be an optional $\isarkeyword{header}$ declaration, which is relevant to
|
|
44 |
document preparation only; it acts very much like a special pre-theory markup
|
|
45 |
command (cf.\ \S\ref{sec:markup-thy} and \S\ref{sec:markup-thy}). The theory
|
|
46 |
context may be also changed by $\CONTEXT$ without creating a new theory. In
|
|
47 |
both cases, $\END$ concludes the theory development; it has to be the very
|
|
48 |
last command in a theory file.
|
7134
|
49 |
|
|
50 |
\begin{rail}
|
7895
|
51 |
'header' text
|
|
52 |
;
|
7134
|
53 |
'theory' name '=' (name + '+') filespecs? ':'
|
|
54 |
;
|
|
55 |
'context' name
|
|
56 |
;
|
|
57 |
'end'
|
|
58 |
;;
|
|
59 |
|
7167
|
60 |
filespecs: 'files' ((name | parname) +);
|
7134
|
61 |
\end{rail}
|
|
62 |
|
7167
|
63 |
\begin{descr}
|
7895
|
64 |
\item [$\isarkeyword{header}~text$] provides plain text markup just preceding
|
|
65 |
the formal begin of a theory. In actual document preparation the
|
|
66 |
corresponding {\LaTeX} macro \verb,\isamarkupheader, may be redefined to
|
|
67 |
produce chapter or section headings. See also \S\ref{sec:markup-thy} and
|
|
68 |
\S\ref{sec:markup-prf} for further markup commands.
|
|
69 |
|
7981
|
70 |
\item [$\THEORY~A = B@1 + \cdots + B@n\colon$] commences a new theory $A$
|
|
71 |
based on existing ones $B@1 + \cdots + B@n$. Isabelle's theory loader
|
|
72 |
system ensures that any of the base theories are properly loaded (and fully
|
|
73 |
up-to-date when $\THEORY$ is executed interactively). The optional
|
|
74 |
$\isarkeyword{files}$ specification declares additional dependencies on ML
|
|
75 |
files. Unless put in parentheses, any file will be loaded immediately via
|
|
76 |
$\isarcmd{use}$ (see also \S\ref{sec:ML}). The optional ML file
|
|
77 |
\texttt{$A$.ML} that may be associated with any theory should \emph{not} be
|
|
78 |
included in $\isarkeyword{files}$, though.
|
7134
|
79 |
|
7895
|
80 |
\item [$\CONTEXT~B$] enters an existing theory context, basically in read-only
|
7981
|
81 |
mode, so only a limited set of commands may be performed without destroying
|
|
82 |
the theory. Just as for $\THEORY$, the theory loader ensures that $B$ is
|
|
83 |
loaded and up-to-date.
|
7175
|
84 |
|
7167
|
85 |
\item [$\END$] concludes the current theory definition or context switch.
|
7981
|
86 |
Note that this command cannot be undone, but the whole theory definition has
|
|
87 |
to be retracted.
|
7167
|
88 |
\end{descr}
|
7134
|
89 |
|
|
90 |
|
7895
|
91 |
\subsection{Theory markup commands}\label{sec:markup-thy}
|
7134
|
92 |
|
7895
|
93 |
\indexisarcmd{chapter}\indexisarcmd{section}\indexisarcmd{subsection}
|
|
94 |
\indexisarcmd{subsubsection}\indexisarcmd{text}\indexisarcmd{text-raw}
|
7134
|
95 |
\begin{matharray}{rcl}
|
|
96 |
\isarcmd{chapter} & : & \isartrans{theory}{theory} \\
|
7167
|
97 |
\isarcmd{section} & : & \isartrans{theory}{theory} \\
|
7134
|
98 |
\isarcmd{subsection} & : & \isartrans{theory}{theory} \\
|
|
99 |
\isarcmd{subsubsection} & : & \isartrans{theory}{theory} \\
|
|
100 |
\isarcmd{text} & : & \isartrans{theory}{theory} \\
|
7895
|
101 |
\isarcmd{text_raw} & : & \isartrans{theory}{theory} \\
|
7134
|
102 |
\end{matharray}
|
|
103 |
|
7895
|
104 |
Apart from formal comments (see \S\ref{sec:comments}), markup commands provide
|
7981
|
105 |
a structured way to insert text into the document generated from a theory (see
|
7895
|
106 |
\cite{isabelle-sys} for more information on Isabelle's document preparation
|
|
107 |
tools).
|
7134
|
108 |
|
7895
|
109 |
\railalias{textraw}{text\_raw}
|
|
110 |
\railterm{textraw}
|
7134
|
111 |
|
|
112 |
\begin{rail}
|
7895
|
113 |
('chapter' | 'section' | 'subsection' | 'subsubsection' | 'text' | textraw) text
|
7134
|
114 |
;
|
|
115 |
\end{rail}
|
|
116 |
|
7167
|
117 |
\begin{descr}
|
7335
|
118 |
\item [$\isarkeyword{chapter}$, $\isarkeyword{section}$,
|
|
119 |
$\isarkeyword{subsection}$, and $\isarkeyword{subsubsection}$] mark chapter
|
|
120 |
and section headings.
|
7895
|
121 |
\item [$\TEXT$] specifies paragraphs of plain text, including references to
|
|
122 |
formal entities.\footnote{The latter feature is not yet supported.
|
|
123 |
Nevertheless, any source text of the form
|
|
124 |
``\texttt{\at\ttlbrace$\dots$\ttrbrace}'' should be considered as reserved
|
|
125 |
for future use.}
|
|
126 |
\item [$\isarkeyword{text_raw}$] inserts {\LaTeX} source into the output,
|
|
127 |
without additional markup. Thus the full range of document manipulations
|
|
128 |
becomes available. A typical application would be to emit
|
|
129 |
\verb,\begin{comment}, and \verb,\end{comment}, commands to exclude certain
|
|
130 |
parts from the final document.\footnote{This requires the \texttt{comment}
|
7981
|
131 |
package to be included in {\LaTeX}.}
|
7167
|
132 |
\end{descr}
|
7134
|
133 |
|
7895
|
134 |
Any markup command (except $\isarkeyword{text_raw}$) corresponds to a {\LaTeX}
|
7981
|
135 |
macro with the name prefixed by \verb,\isamarkup, (e.g.\
|
7895
|
136 |
\verb,\isamarkupchapter, for $\isarkeyword{chapter}$). The \railqtoken{text}
|
7981
|
137 |
argument is passed to that macro unchanged, i.e.\ further {\LaTeX} commands
|
|
138 |
may be included here as well.
|
7895
|
139 |
|
7981
|
140 |
\medskip Additional markup commands are available for proofs (see
|
7895
|
141 |
\S\ref{sec:markup-prf}). Also note that the $\isarkeyword{header}$
|
|
142 |
declaration (see \S\ref{sec:begin-thy}) admits to insert document markup
|
|
143 |
elements just preceding the actual theory definition.
|
|
144 |
|
7134
|
145 |
|
7135
|
146 |
\subsection{Type classes and sorts}\label{sec:classes}
|
7134
|
147 |
|
|
148 |
\indexisarcmd{classes}\indexisarcmd{classrel}\indexisarcmd{defaultsort}
|
|
149 |
\begin{matharray}{rcl}
|
|
150 |
\isarcmd{classes} & : & \isartrans{theory}{theory} \\
|
|
151 |
\isarcmd{classrel} & : & \isartrans{theory}{theory} \\
|
|
152 |
\isarcmd{defaultsort} & : & \isartrans{theory}{theory} \\
|
|
153 |
\end{matharray}
|
|
154 |
|
|
155 |
\begin{rail}
|
7167
|
156 |
'classes' (classdecl comment? +)
|
7134
|
157 |
;
|
|
158 |
'classrel' nameref '<' nameref comment?
|
|
159 |
;
|
|
160 |
'defaultsort' sort comment?
|
|
161 |
;
|
|
162 |
\end{rail}
|
|
163 |
|
7167
|
164 |
\begin{descr}
|
7335
|
165 |
\item [$\isarkeyword{classes}~c<\vec c$] declares class $c$ to be a subclass
|
|
166 |
of existing classes $\vec c$. Cyclic class structures are ruled out.
|
7134
|
167 |
\item [$\isarkeyword{classrel}~c@1<c@2$] states a subclass relation between
|
|
168 |
existing classes $c@1$ and $c@2$. This is done axiomatically! The
|
7895
|
169 |
$\isarkeyword{instance}$ command (see \S\ref{sec:axclass}) provides a way to
|
7175
|
170 |
introduce proven class relations.
|
7134
|
171 |
\item [$\isarkeyword{defaultsort}~s$] makes sort $s$ the new default sort for
|
7895
|
172 |
any type variables given without sort constraints. Usually, the default
|
7134
|
173 |
sort would be only changed when defining new logics.
|
7167
|
174 |
\end{descr}
|
7134
|
175 |
|
|
176 |
|
7315
|
177 |
\subsection{Primitive types and type abbreviations}\label{sec:types-pure}
|
7134
|
178 |
|
|
179 |
\indexisarcmd{typedecl}\indexisarcmd{types}\indexisarcmd{nonterminals}\indexisarcmd{arities}
|
|
180 |
\begin{matharray}{rcl}
|
|
181 |
\isarcmd{types} & : & \isartrans{theory}{theory} \\
|
|
182 |
\isarcmd{typedecl} & : & \isartrans{theory}{theory} \\
|
|
183 |
\isarcmd{nonterminals} & : & \isartrans{theory}{theory} \\
|
|
184 |
\isarcmd{arities} & : & \isartrans{theory}{theory} \\
|
|
185 |
\end{matharray}
|
|
186 |
|
|
187 |
\begin{rail}
|
|
188 |
'types' (typespec '=' type infix? comment? +)
|
|
189 |
;
|
|
190 |
'typedecl' typespec infix? comment?
|
|
191 |
;
|
|
192 |
'nonterminals' (name +) comment?
|
|
193 |
;
|
|
194 |
'arities' (nameref '::' arity comment? +)
|
|
195 |
;
|
|
196 |
\end{rail}
|
|
197 |
|
7167
|
198 |
\begin{descr}
|
7335
|
199 |
\item [$\TYPES~(\vec\alpha)t = \tau$] introduces \emph{type synonym}
|
7134
|
200 |
$(\vec\alpha)t$ for existing type $\tau$. Unlike actual type definitions,
|
|
201 |
as are available in Isabelle/HOL for example, type synonyms are just purely
|
7895
|
202 |
syntactic abbreviations without any logical significance. Internally, type
|
7981
|
203 |
synonyms are fully expanded.
|
7134
|
204 |
\item [$\isarkeyword{typedecl}~(\vec\alpha)t$] declares a new type constructor
|
7895
|
205 |
$t$, intended as an actual logical type. Note that object-logics such as
|
|
206 |
Isabelle/HOL override $\isarkeyword{typedecl}$ by their own version.
|
7175
|
207 |
\item [$\isarkeyword{nonterminals}~\vec c$] declares $0$-ary type constructors
|
|
208 |
$\vec c$ to act as purely syntactic types, i.e.\ nonterminal symbols of
|
|
209 |
Isabelle's inner syntax of terms or types.
|
7335
|
210 |
\item [$\isarkeyword{arities}~t::(\vec s)s$] augments Isabelle's order-sorted
|
|
211 |
signature of types by new type constructor arities. This is done
|
|
212 |
axiomatically! The $\isarkeyword{instance}$ command (see
|
7895
|
213 |
\S\ref{sec:axclass}) provides a way to introduce proven type arities.
|
7167
|
214 |
\end{descr}
|
7134
|
215 |
|
|
216 |
|
7981
|
217 |
\subsection{Constants and simple definitions}\label{sec:consts}
|
7134
|
218 |
|
7175
|
219 |
\indexisarcmd{consts}\indexisarcmd{defs}\indexisarcmd{constdefs}\indexoutertoken{constdecl}
|
7134
|
220 |
\begin{matharray}{rcl}
|
|
221 |
\isarcmd{consts} & : & \isartrans{theory}{theory} \\
|
|
222 |
\isarcmd{defs} & : & \isartrans{theory}{theory} \\
|
|
223 |
\isarcmd{constdefs} & : & \isartrans{theory}{theory} \\
|
|
224 |
\end{matharray}
|
|
225 |
|
|
226 |
\begin{rail}
|
|
227 |
'consts' (constdecl +)
|
|
228 |
;
|
7608
|
229 |
'defs' (axmdecl prop comment? +)
|
7134
|
230 |
;
|
|
231 |
'constdefs' (constdecl prop comment? +)
|
|
232 |
;
|
|
233 |
|
|
234 |
constdecl: name '::' type mixfix? comment?
|
|
235 |
;
|
|
236 |
\end{rail}
|
|
237 |
|
7167
|
238 |
\begin{descr}
|
7335
|
239 |
\item [$\CONSTS~c::\sigma$] declares constant $c$ to have any instance of type
|
|
240 |
scheme $\sigma$. The optional mixfix annotations may attach concrete syntax
|
7895
|
241 |
to the constants declared.
|
7335
|
242 |
\item [$\DEFS~name: eqn$] introduces $eqn$ as a definitional axiom for some
|
|
243 |
existing constant. See \cite[\S6]{isabelle-ref} for more details on the
|
|
244 |
form of equations admitted as constant definitions.
|
|
245 |
\item [$\isarkeyword{constdefs}~c::\sigma~eqn$] combines declarations and
|
|
246 |
definitions of constants, using canonical name $c_def$ for the definitional
|
|
247 |
axiom.
|
7167
|
248 |
\end{descr}
|
7134
|
249 |
|
|
250 |
|
7981
|
251 |
\subsection{Syntax and translations}\label{sec:syn-trans}
|
7134
|
252 |
|
|
253 |
\indexisarcmd{syntax}\indexisarcmd{translations}
|
|
254 |
\begin{matharray}{rcl}
|
|
255 |
\isarcmd{syntax} & : & \isartrans{theory}{theory} \\
|
|
256 |
\isarcmd{translations} & : & \isartrans{theory}{theory} \\
|
|
257 |
\end{matharray}
|
|
258 |
|
|
259 |
\begin{rail}
|
|
260 |
'syntax' ('(' name 'output'? ')')? (constdecl +)
|
|
261 |
;
|
|
262 |
'translations' (transpat ('==' | '=>' | '<=') transpat comment? +)
|
|
263 |
;
|
|
264 |
transpat: ('(' nameref ')')? string
|
|
265 |
;
|
|
266 |
\end{rail}
|
|
267 |
|
7167
|
268 |
\begin{descr}
|
7175
|
269 |
\item [$\isarkeyword{syntax}~(mode)~decls$] is similar to $\CONSTS~decls$,
|
|
270 |
except that the actual logical signature extension is omitted. Thus the
|
|
271 |
context free grammar of Isabelle's inner syntax may be augmented in
|
7335
|
272 |
arbitrary ways, independently of the logic. The $mode$ argument refers to
|
|
273 |
the print mode that the grammar rules belong; unless there is the
|
|
274 |
\texttt{output} flag given, all productions are added both to the input and
|
|
275 |
output grammar.
|
7175
|
276 |
\item [$\isarkeyword{translations}~rules$] specifies syntactic translation
|
7981
|
277 |
rules (i.e.\ \emph{macros}): parse~/ print rules (\texttt{==}), parse rules
|
7895
|
278 |
(\texttt{=>}), or print rules (\texttt{<=}). Translation patterns may be
|
|
279 |
prefixed by the syntactic category to be used for parsing; the default is
|
7134
|
280 |
\texttt{logic}.
|
7167
|
281 |
\end{descr}
|
7134
|
282 |
|
|
283 |
|
|
284 |
\subsection{Axioms and theorems}
|
|
285 |
|
|
286 |
\indexisarcmd{axioms}\indexisarcmd{theorems}\indexisarcmd{lemmas}
|
|
287 |
\begin{matharray}{rcl}
|
|
288 |
\isarcmd{axioms} & : & \isartrans{theory}{theory} \\
|
|
289 |
\isarcmd{theorems} & : & \isartrans{theory}{theory} \\
|
|
290 |
\isarcmd{lemmas} & : & \isartrans{theory}{theory} \\
|
|
291 |
\end{matharray}
|
|
292 |
|
|
293 |
\begin{rail}
|
7135
|
294 |
'axioms' (axmdecl prop comment? +)
|
7134
|
295 |
;
|
|
296 |
('theorems' | 'lemmas') thmdef? thmrefs
|
|
297 |
;
|
|
298 |
\end{rail}
|
|
299 |
|
7167
|
300 |
\begin{descr}
|
7335
|
301 |
\item [$\isarkeyword{axioms}~a: \phi$] introduces arbitrary statements as
|
7895
|
302 |
axioms of the meta-logic. In fact, axioms are ``axiomatic theorems'', and
|
|
303 |
may be referred later just as any other theorem.
|
7134
|
304 |
|
|
305 |
Axioms are usually only introduced when declaring new logical systems.
|
7175
|
306 |
Everyday work is typically done the hard way, with proper definitions and
|
7134
|
307 |
actual theorems.
|
7335
|
308 |
\item [$\isarkeyword{theorems}~a = \vec b$] stores lists of existing theorems.
|
7981
|
309 |
Typical applications would also involve attributes, to augment the
|
7335
|
310 |
Simplifier context, for example.
|
7134
|
311 |
\item [$\isarkeyword{lemmas}$] is similar to $\isarkeyword{theorems}$, but
|
|
312 |
tags the results as ``lemma''.
|
7167
|
313 |
\end{descr}
|
7134
|
314 |
|
|
315 |
|
7167
|
316 |
\subsection{Name spaces}
|
7134
|
317 |
|
7167
|
318 |
\indexisarcmd{global}\indexisarcmd{local}
|
7134
|
319 |
\begin{matharray}{rcl}
|
|
320 |
\isarcmd{global} & : & \isartrans{theory}{theory} \\
|
|
321 |
\isarcmd{local} & : & \isartrans{theory}{theory} \\
|
|
322 |
\end{matharray}
|
|
323 |
|
7895
|
324 |
Isabelle organizes any kind of name declarations (of types, constants,
|
|
325 |
theorems etc.) by hierarchically structured name spaces. Normally the user
|
|
326 |
never has to control the behavior of name space entry by hand, yet the
|
|
327 |
following commands provide some way to do so.
|
7175
|
328 |
|
7167
|
329 |
\begin{descr}
|
|
330 |
\item [$\isarkeyword{global}$ and $\isarkeyword{local}$] change the current
|
|
331 |
name declaration mode. Initially, theories start in $\isarkeyword{local}$
|
|
332 |
mode, causing all names to be automatically qualified by the theory name.
|
7895
|
333 |
Changing this to $\isarkeyword{global}$ causes all names to be declared
|
|
334 |
without the theory prefix, until $\isarkeyword{local}$ is declared again.
|
7167
|
335 |
\end{descr}
|
7134
|
336 |
|
|
337 |
|
7167
|
338 |
\subsection{Incorporating ML code}\label{sec:ML}
|
7134
|
339 |
|
7895
|
340 |
\indexisarcmd{use}\indexisarcmd{ML}\indexisarcmd{ML-setup}\indexisarcmd{setup}
|
7134
|
341 |
\begin{matharray}{rcl}
|
|
342 |
\isarcmd{use} & : & \isartrans{\cdot}{\cdot} \\
|
|
343 |
\isarcmd{ML} & : & \isartrans{\cdot}{\cdot} \\
|
7895
|
344 |
\isarcmd{ML_setup} & : & \isartrans{theory}{theory} \\
|
7175
|
345 |
\isarcmd{setup} & : & \isartrans{theory}{theory} \\
|
7134
|
346 |
\end{matharray}
|
|
347 |
|
7895
|
348 |
\railalias{MLsetup}{ML\_setup}
|
|
349 |
\railterm{MLsetup}
|
|
350 |
|
7134
|
351 |
\begin{rail}
|
|
352 |
'use' name
|
|
353 |
;
|
7895
|
354 |
('ML' | MLsetup | 'setup') text
|
7134
|
355 |
;
|
|
356 |
\end{rail}
|
|
357 |
|
7167
|
358 |
\begin{descr}
|
7175
|
359 |
\item [$\isarkeyword{use}~file$] reads and executes ML commands from $file$.
|
7466
|
360 |
The current theory context (if present) is passed down to the ML session,
|
7981
|
361 |
but may not be modified. Furthermore, the file name is checked with the
|
7466
|
362 |
$\isarkeyword{files}$ dependency declaration given in the theory header (see
|
|
363 |
also \S\ref{sec:begin-thy}).
|
|
364 |
|
7895
|
365 |
\item [$\isarkeyword{ML}~text$] executes ML commands from $text$. The theory
|
|
366 |
context is passed in the same way as for $\isarkeyword{use}$.
|
|
367 |
|
|
368 |
\item [$\isarkeyword{ML_setup}~text$] executes ML commands from $text$. The
|
|
369 |
theory context is passed down to the ML session, and fetched back
|
|
370 |
afterwards. Thus $text$ may actually change the theory as a side effect.
|
|
371 |
|
7167
|
372 |
\item [$\isarkeyword{setup}~text$] changes the current theory context by
|
8379
|
373 |
applying $text$, which refers to an ML expression of type
|
|
374 |
\texttt{(theory~->~theory)~list}. The $\isarkeyword{setup}$ command is the
|
|
375 |
canonical way to initialize object-logic specific tools and packages written
|
|
376 |
in ML.
|
7167
|
377 |
\end{descr}
|
7134
|
378 |
|
|
379 |
|
8250
|
380 |
\subsection{Syntax translation functions}
|
7134
|
381 |
|
8250
|
382 |
\indexisarcmd{parse-ast-translation}\indexisarcmd{parse-translation}
|
|
383 |
\indexisarcmd{print-translation}\indexisarcmd{typed-print-translation}
|
|
384 |
\indexisarcmd{print-ast-translation}\indexisarcmd{token-translation}
|
|
385 |
\begin{matharray}{rcl}
|
|
386 |
\isarcmd{parse_ast_translation} & : & \isartrans{theory}{theory} \\
|
|
387 |
\isarcmd{parse_translation} & : & \isartrans{theory}{theory} \\
|
|
388 |
\isarcmd{print_translation} & : & \isartrans{theory}{theory} \\
|
|
389 |
\isarcmd{typed_print_translation} & : & \isartrans{theory}{theory} \\
|
|
390 |
\isarcmd{print_ast_translation} & : & \isartrans{theory}{theory} \\
|
|
391 |
\isarcmd{token_translation} & : & \isartrans{theory}{theory} \\
|
|
392 |
\end{matharray}
|
7134
|
393 |
|
8250
|
394 |
Syntax translation functions written in ML admit almost arbitrary
|
|
395 |
manipulations of Isabelle's inner syntax. Any of the above commands have a
|
|
396 |
single \railqtoken{text} argument that refers to an ML expression of
|
8379
|
397 |
appropriate type.
|
|
398 |
|
|
399 |
\begin{ttbox}
|
|
400 |
val parse_ast_translation : (string * (ast list -> ast)) list
|
|
401 |
val parse_translation : (string * (term list -> term)) list
|
|
402 |
val print_translation : (string * (term list -> term)) list
|
|
403 |
val typed_print_translation :
|
|
404 |
(string * (bool -> typ -> term list -> term)) list
|
|
405 |
val print_ast_translation : (string * (ast list -> ast)) list
|
|
406 |
val token_translation :
|
|
407 |
(string * string * (string -> string * real)) list
|
|
408 |
\end{ttbox}
|
|
409 |
See \cite[\S8]{isabelle-ref} for more information on syntax transformations.
|
7134
|
410 |
|
|
411 |
|
|
412 |
\subsection{Oracles}
|
|
413 |
|
|
414 |
\indexisarcmd{oracle}
|
|
415 |
\begin{matharray}{rcl}
|
|
416 |
\isarcmd{oracle} & : & \isartrans{theory}{theory} \\
|
|
417 |
\end{matharray}
|
|
418 |
|
7175
|
419 |
Oracles provide an interface to external reasoning systems, without giving up
|
|
420 |
control completely --- each theorem carries a derivation object recording any
|
|
421 |
oracle invocation. See \cite[\S6]{isabelle-ref} for more information.
|
|
422 |
|
7134
|
423 |
\begin{rail}
|
|
424 |
'oracle' name '=' text comment?
|
|
425 |
;
|
|
426 |
\end{rail}
|
|
427 |
|
7167
|
428 |
\begin{descr}
|
7175
|
429 |
\item [$\isarkeyword{oracle}~name=text$] declares oracle $name$ to be ML
|
8379
|
430 |
function $text$, which has to be of type
|
|
431 |
\texttt{Sign.sg~*~Object.T~->~term}.
|
7167
|
432 |
\end{descr}
|
7134
|
433 |
|
|
434 |
|
|
435 |
\section{Proof commands}
|
|
436 |
|
7987
|
437 |
Proof commands perform transitions of Isar/VM machine configurations, which
|
7315
|
438 |
are block-structured, consisting of a stack of nodes with three main
|
7335
|
439 |
components: logical proof context, current facts, and open goals. Isar/VM
|
|
440 |
transitions are \emph{typed} according to the following three three different
|
|
441 |
modes of operation:
|
7167
|
442 |
\begin{descr}
|
|
443 |
\item [$proof(prove)$] means that a new goal has just been stated that is now
|
|
444 |
to be \emph{proven}; the next command may refine it by some proof method
|
7895
|
445 |
(read: tactic), and enter a sub-proof to establish the actual result.
|
7167
|
446 |
\item [$proof(state)$] is like an internal theory mode: the context may be
|
7987
|
447 |
augmented by \emph{stating} additional assumptions, intermediate results
|
|
448 |
etc.
|
7895
|
449 |
\item [$proof(chain)$] is intermediate between $proof(state)$ and
|
7987
|
450 |
$proof(prove)$: existing facts (i.e.\ the contents of the special ``$this$''
|
|
451 |
register) have been just picked up in order to be used when refining the
|
|
452 |
goal claimed next.
|
7167
|
453 |
\end{descr}
|
7134
|
454 |
|
7167
|
455 |
|
7895
|
456 |
\subsection{Proof markup commands}\label{sec:markup-prf}
|
7167
|
457 |
|
7987
|
458 |
\indexisarcmd{sect}\indexisarcmd{subsect}\indexisarcmd{subsubsect}
|
7895
|
459 |
\indexisarcmd{txt}\indexisarcmd{txt-raw}
|
7134
|
460 |
\begin{matharray}{rcl}
|
8101
|
461 |
\isarcmd{sect} & : & \isartrans{proof}{proof} \\
|
|
462 |
\isarcmd{subsect} & : & \isartrans{proof}{proof} \\
|
|
463 |
\isarcmd{subsubsect} & : & \isartrans{proof}{proof} \\
|
|
464 |
\isarcmd{txt} & : & \isartrans{proof}{proof} \\
|
|
465 |
\isarcmd{txt_raw} & : & \isartrans{proof}{proof} \\
|
7134
|
466 |
\end{matharray}
|
|
467 |
|
7895
|
468 |
These markup commands for proof mode closely correspond to the ones of theory
|
|
469 |
mode (see \S\ref{sec:markup-thy}). Note that $\isarkeyword{txt_raw}$ is
|
|
470 |
special in the same way as $\isarkeyword{text_raw}$.
|
|
471 |
|
|
472 |
\railalias{txtraw}{txt\_raw}
|
|
473 |
\railterm{txtraw}
|
7175
|
474 |
|
7134
|
475 |
\begin{rail}
|
7895
|
476 |
('sect' | 'subsect' | 'subsubsect' | 'txt' | txtraw) text
|
7134
|
477 |
;
|
|
478 |
\end{rail}
|
|
479 |
|
|
480 |
|
7315
|
481 |
\subsection{Proof context}\label{sec:proof-context}
|
7134
|
482 |
|
7315
|
483 |
\indexisarcmd{fix}\indexisarcmd{assume}\indexisarcmd{presume}\indexisarcmd{def}
|
8379
|
484 |
\indexisarcmd{case}
|
7134
|
485 |
\begin{matharray}{rcl}
|
|
486 |
\isarcmd{fix} & : & \isartrans{proof(state)}{proof(state)} \\
|
|
487 |
\isarcmd{assume} & : & \isartrans{proof(state)}{proof(state)} \\
|
|
488 |
\isarcmd{presume} & : & \isartrans{proof(state)}{proof(state)} \\
|
|
489 |
\isarcmd{def} & : & \isartrans{proof(state)}{proof(state)} \\
|
8379
|
490 |
\isarcmd{case} & : & \isartrans{proof(state)}{proof(state)} \\
|
7134
|
491 |
\end{matharray}
|
|
492 |
|
7315
|
493 |
The logical proof context consists of fixed variables and assumptions. The
|
|
494 |
former closely correspond to Skolem constants, or meta-level universal
|
|
495 |
quantification as provided by the Isabelle/Pure logical framework.
|
|
496 |
Introducing some \emph{arbitrary, but fixed} variable via $\FIX x$ results in
|
7987
|
497 |
a local value that may be used in the subsequent proof as any other variable
|
7895
|
498 |
or constant. Furthermore, any result $\edrv \phi[x]$ exported from the
|
7987
|
499 |
context will be universally closed wrt.\ $x$ at the outermost level: $\edrv
|
|
500 |
\All x \phi$ (this is expressed using Isabelle's meta-variables).
|
7315
|
501 |
|
|
502 |
Similarly, introducing some assumption $\chi$ has two effects. On the one
|
|
503 |
hand, a local theorem is created that may be used as a fact in subsequent
|
7895
|
504 |
proof steps. On the other hand, any result $\chi \drv \phi$ exported from the
|
|
505 |
context becomes conditional wrt.\ the assumption: $\edrv \chi \Imp \phi$.
|
|
506 |
Thus, solving an enclosing goal using such a result would basically introduce
|
|
507 |
a new subgoal stemming from the assumption. How this situation is handled
|
|
508 |
depends on the actual version of assumption command used: while $\ASSUMENAME$
|
|
509 |
insists on solving the subgoal by unification with some premise of the goal,
|
|
510 |
$\PRESUMENAME$ leaves the subgoal unchanged in order to be proved later by the
|
|
511 |
user.
|
7315
|
512 |
|
7319
|
513 |
Local definitions, introduced by $\DEF{}{x \equiv t}$, are achieved by
|
7987
|
514 |
combining $\FIX x$ with another version of assumption that causes any
|
|
515 |
hypothetical equation $x \equiv t$ to be eliminated by the reflexivity rule.
|
|
516 |
Thus, exporting some result $x \equiv t \drv \phi[x]$ yields $\edrv \phi[t]$.
|
7175
|
517 |
|
8379
|
518 |
\medskip Basically, Isar proof contexts have to be built up explicitly using
|
|
519 |
any of the above commands. In typical verification tasks this can become hard
|
|
520 |
to manage, though, with a large number of local contexts emerging from case
|
|
521 |
analysis or induction, for example. The $\CASENAME$ command provides a
|
|
522 |
shorthand to refer to certain parts of logical context symbolically. Proof
|
|
523 |
methods may provide an environment of named ``cases'' of the form $c\colon
|
|
524 |
\vec x, \vec \chi$. Then the effect of $\CASE{c}$ is exactly the same as
|
|
525 |
$\FIX{\vec x}~\ASSUME{c}{\vec\chi}$.
|
|
526 |
|
|
527 |
It is important to note that $\CASENAME$ does \emph{not} provide means to peek
|
|
528 |
at the current goal state, which is considered strictly non-observable in
|
|
529 |
Isar. Instead, the cases considered here typically emerge in a canonical way
|
|
530 |
from certain pieces of specification that appears in the theory somewhere,
|
8448
|
531 |
such as an inductive definition, or recursive function. See
|
|
532 |
\S\ref{sec:induct-method} for more details of how this works in HOL.
|
8379
|
533 |
|
7134
|
534 |
\begin{rail}
|
7431
|
535 |
'fix' (vars + 'and') comment?
|
7134
|
536 |
;
|
7315
|
537 |
('assume' | 'presume') (assm comment? + 'and')
|
7134
|
538 |
;
|
7175
|
539 |
'def' thmdecl? \\ var '==' term termpat? comment?
|
7134
|
540 |
;
|
8448
|
541 |
'case' name attributes?
|
8379
|
542 |
;
|
7134
|
543 |
|
|
544 |
var: name ('::' type)?
|
|
545 |
;
|
7458
|
546 |
vars: (name+) ('::' type)?
|
7431
|
547 |
;
|
7315
|
548 |
assm: thmdecl? (prop proppat? +)
|
|
549 |
;
|
7134
|
550 |
\end{rail}
|
|
551 |
|
7167
|
552 |
\begin{descr}
|
7315
|
553 |
\item [$\FIX{x}$] introduces a local \emph{arbitrary, but fixed} variable $x$.
|
|
554 |
\item [$\ASSUME{a}{\Phi}$ and $\PRESUME{a}{\Phi}$] introduce local theorems
|
7335
|
555 |
$\Phi$ by assumption. Subsequent results applied to an enclosing goal
|
7895
|
556 |
(e.g.\ by $\SHOWNAME$) are handled as follows: $\ASSUMENAME$ expects to be
|
7335
|
557 |
able to unify with existing premises in the goal, while $\PRESUMENAME$
|
|
558 |
leaves $\Phi$ as new subgoals.
|
|
559 |
|
|
560 |
Several lists of assumptions may be given (separated by
|
7895
|
561 |
$\isarkeyword{and}$); the resulting list of current facts consists of all of
|
|
562 |
these concatenated.
|
7315
|
563 |
\item [$\DEF{a}{x \equiv t}$] introduces a local (non-polymorphic) definition.
|
|
564 |
In results exported from the context, $x$ is replaced by $t$. Basically,
|
7987
|
565 |
$\DEF{}{x \equiv t}$ abbreviates $\FIX{x}~\ASSUME{}{x \equiv t}$, with the
|
7335
|
566 |
resulting hypothetical equation solved by reflexivity.
|
7431
|
567 |
|
|
568 |
The default name for the definitional equation is $x_def$.
|
8379
|
569 |
\item [$\CASE{c}$] invokes local context $c\colon \vec x, \vec \chi$, as
|
|
570 |
provided by an appropriate proof method. This abbreviates $\FIX{\vec
|
|
571 |
x}~\ASSUME{c}{\vec\chi}$.
|
7167
|
572 |
\end{descr}
|
|
573 |
|
7895
|
574 |
The special name $prems$\indexisarthm{prems} refers to all assumptions of the
|
|
575 |
current context as a list of theorems.
|
7315
|
576 |
|
7167
|
577 |
|
|
578 |
\subsection{Facts and forward chaining}
|
|
579 |
|
|
580 |
\indexisarcmd{note}\indexisarcmd{then}\indexisarcmd{from}\indexisarcmd{with}
|
|
581 |
\begin{matharray}{rcl}
|
|
582 |
\isarcmd{note} & : & \isartrans{proof(state)}{proof(state)} \\
|
|
583 |
\isarcmd{then} & : & \isartrans{proof(state)}{proof(chain)} \\
|
|
584 |
\isarcmd{from} & : & \isartrans{proof(state)}{proof(chain)} \\
|
|
585 |
\isarcmd{with} & : & \isartrans{proof(state)}{proof(chain)} \\
|
|
586 |
\end{matharray}
|
|
587 |
|
7319
|
588 |
New facts are established either by assumption or proof of local statements.
|
7335
|
589 |
Any fact will usually be involved in further proofs, either as explicit
|
|
590 |
arguments of proof methods or when forward chaining towards the next goal via
|
|
591 |
$\THEN$ (and variants). Note that the special theorem name
|
7987
|
592 |
$this$\indexisarthm{this} refers to the most recently established facts.
|
7167
|
593 |
\begin{rail}
|
|
594 |
'note' thmdef? thmrefs comment?
|
|
595 |
;
|
|
596 |
'then' comment?
|
|
597 |
;
|
|
598 |
('from' | 'with') thmrefs comment?
|
|
599 |
;
|
|
600 |
\end{rail}
|
|
601 |
|
|
602 |
\begin{descr}
|
7175
|
603 |
\item [$\NOTE{a}{\vec b}$] recalls existing facts $\vec b$, binding the result
|
|
604 |
as $a$. Note that attributes may be involved as well, both on the left and
|
|
605 |
right hand sides.
|
7167
|
606 |
\item [$\THEN$] indicates forward chaining by the current facts in order to
|
7895
|
607 |
establish the goal to be claimed next. The initial proof method invoked to
|
|
608 |
refine that will be offered the facts to do ``anything appropriate'' (cf.\
|
|
609 |
also \S\ref{sec:proof-steps}). For example, method $rule$ (see
|
|
610 |
\S\ref{sec:pure-meth}) would typically do an elimination rather than an
|
|
611 |
introduction. Automatic methods usually insert the facts into the goal
|
|
612 |
state before operation.
|
7335
|
613 |
\item [$\FROM{\vec b}$] abbreviates $\NOTE{}{\vec b}~\THEN$; thus $\THEN$ is
|
7458
|
614 |
equivalent to $\FROM{this}$.
|
7175
|
615 |
\item [$\WITH{\vec b}$] abbreviates $\FROM{\vec b~facts}$; thus the forward
|
|
616 |
chaining is from earlier facts together with the current ones.
|
7167
|
617 |
\end{descr}
|
|
618 |
|
7389
|
619 |
Basic proof methods (such as $rule$, see \S\ref{sec:pure-meth}) expect
|
7895
|
620 |
multiple facts to be given in their proper order, corresponding to a prefix of
|
|
621 |
the premises of the rule involved. Note that positions may be easily skipped
|
7458
|
622 |
using a form like $\FROM{\text{\texttt{_}}~a~b}$, for example. This involves
|
7895
|
623 |
the trivial rule $\PROP\psi \Imp \PROP\psi$, which is bound in Isabelle/Pure
|
|
624 |
as ``\texttt{_}'' (underscore).\indexisarthm{_@\texttt{_}}
|
7389
|
625 |
|
7167
|
626 |
|
|
627 |
\subsection{Goal statements}
|
|
628 |
|
|
629 |
\indexisarcmd{theorem}\indexisarcmd{lemma}
|
|
630 |
\indexisarcmd{have}\indexisarcmd{show}\indexisarcmd{hence}\indexisarcmd{thus}
|
|
631 |
\begin{matharray}{rcl}
|
|
632 |
\isarcmd{theorem} & : & \isartrans{theory}{proof(prove)} \\
|
|
633 |
\isarcmd{lemma} & : & \isartrans{theory}{proof(prove)} \\
|
7987
|
634 |
\isarcmd{have} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
|
|
635 |
\isarcmd{show} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
|
7167
|
636 |
\isarcmd{hence} & : & \isartrans{proof(state)}{proof(prove)} \\
|
|
637 |
\isarcmd{thus} & : & \isartrans{proof(state)}{proof(prove)} \\
|
|
638 |
\end{matharray}
|
|
639 |
|
7175
|
640 |
Proof mode is entered from theory mode by initial goal commands $\THEOREMNAME$
|
7895
|
641 |
and $\LEMMANAME$. New local goals may be claimed within proof mode as well.
|
|
642 |
Four variants are available, indicating whether the result is meant to solve
|
7987
|
643 |
some pending goal or whether forward chaining is employed.
|
7175
|
644 |
|
7167
|
645 |
\begin{rail}
|
|
646 |
('theorem' | 'lemma') goal
|
|
647 |
;
|
|
648 |
('have' | 'show' | 'hence' | 'thus') goal
|
|
649 |
;
|
|
650 |
|
|
651 |
goal: thmdecl? proppat comment?
|
|
652 |
;
|
|
653 |
\end{rail}
|
|
654 |
|
|
655 |
\begin{descr}
|
7335
|
656 |
\item [$\THEOREM{a}{\phi}$] enters proof mode with $\phi$ as main goal,
|
7895
|
657 |
eventually resulting in some theorem $\turn \phi$ put back into the theory.
|
7987
|
658 |
\item [$\LEMMA{a}{\phi}$] is similar to $\THEOREMNAME$, but tags the result as
|
7167
|
659 |
``lemma''.
|
7335
|
660 |
\item [$\HAVE{a}{\phi}$] claims a local goal, eventually resulting in a
|
7167
|
661 |
theorem with the current assumption context as hypotheses.
|
7335
|
662 |
\item [$\SHOW{a}{\phi}$] is similar to $\HAVE{a}{\phi}$, but solves some
|
7895
|
663 |
pending goal with the result \emph{exported} into the corresponding context
|
|
664 |
(cf.\ \S\ref{sec:proof-context}).
|
|
665 |
\item [$\HENCENAME$] abbreviates $\THEN~\HAVENAME$, i.e.\ claims a local goal
|
|
666 |
to be proven by forward chaining the current facts. Note that $\HENCENAME$
|
|
667 |
is also equivalent to $\FROM{this}~\HAVENAME$.
|
|
668 |
\item [$\THUSNAME$] abbreviates $\THEN~\SHOWNAME$. Note that $\THUSNAME$ is
|
|
669 |
also equivalent to $\FROM{this}~\SHOWNAME$.
|
7167
|
670 |
\end{descr}
|
|
671 |
|
|
672 |
|
|
673 |
\subsection{Initial and terminal proof steps}\label{sec:proof-steps}
|
|
674 |
|
7175
|
675 |
\indexisarcmd{proof}\indexisarcmd{qed}\indexisarcmd{by}
|
|
676 |
\indexisarcmd{.}\indexisarcmd{..}\indexisarcmd{sorry}
|
|
677 |
\begin{matharray}{rcl}
|
|
678 |
\isarcmd{proof} & : & \isartrans{proof(prove)}{proof(state)} \\
|
|
679 |
\isarcmd{qed} & : & \isartrans{proof(state)}{proof(state) ~|~ theory} \\
|
|
680 |
\isarcmd{by} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
|
|
681 |
\isarcmd{.\,.} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
|
|
682 |
\isarcmd{.} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
|
|
683 |
\isarcmd{sorry} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
|
|
684 |
\end{matharray}
|
|
685 |
|
7335
|
686 |
Arbitrary goal refinement via tactics is considered harmful. Consequently the
|
|
687 |
Isar framework admits proof methods to be invoked in two places only.
|
7167
|
688 |
\begin{enumerate}
|
7175
|
689 |
\item An \emph{initial} refinement step $\PROOF{m@1}$ reduces a newly stated
|
7335
|
690 |
goal to a number of sub-goals that are to be solved later. Facts are passed
|
7895
|
691 |
to $m@1$ for forward chaining, if so indicated by $proof(chain)$ mode.
|
7167
|
692 |
|
7987
|
693 |
\item A \emph{terminal} conclusion step $\QED{m@2}$ is intended to solve
|
|
694 |
remaining goals. No facts are passed to $m@2$.
|
7167
|
695 |
\end{enumerate}
|
|
696 |
|
7335
|
697 |
The only other proper way to affect pending goals is by $\SHOWNAME$ (or
|
|
698 |
$\THUSNAME$), which involves an explicit statement of what is to be solved.
|
7167
|
699 |
|
7175
|
700 |
\medskip
|
|
701 |
|
7167
|
702 |
Also note that initial proof methods should either solve the goal completely,
|
7895
|
703 |
or constitute some well-understood reduction to new sub-goals. Arbitrary
|
|
704 |
automatic proof tools that are prone leave a large number of badly structured
|
|
705 |
sub-goals are no help in continuing the proof document in any intelligible
|
7987
|
706 |
way.
|
|
707 |
%FIXME
|
|
708 |
%A more appropriate technique would be to $\SHOWNAME$ some non-trivial
|
|
709 |
%reduction as an explicit rule, which is solved completely by some automated
|
|
710 |
%method, and then applied to some pending goal.
|
7167
|
711 |
|
7175
|
712 |
\medskip
|
|
713 |
|
|
714 |
Unless given explicitly by the user, the default initial method is
|
|
715 |
``$default$'', which is usually set up to apply a single standard elimination
|
7458
|
716 |
or introduction rule according to the topmost symbol involved. There is no
|
7987
|
717 |
separate default terminal method. In any case, any goals left after that are
|
|
718 |
solved by assumption as the very last step.
|
7167
|
719 |
|
|
720 |
\begin{rail}
|
|
721 |
'proof' interest? meth? comment?
|
|
722 |
;
|
|
723 |
'qed' meth? comment?
|
|
724 |
;
|
|
725 |
'by' meth meth? comment?
|
|
726 |
;
|
|
727 |
('.' | '..' | 'sorry') comment?
|
|
728 |
;
|
|
729 |
|
|
730 |
meth: method interest?
|
|
731 |
;
|
|
732 |
\end{rail}
|
|
733 |
|
|
734 |
\begin{descr}
|
7335
|
735 |
\item [$\PROOF{m@1}$] refines the goal by proof method $m@1$; facts for
|
|
736 |
forward chaining are passed if so indicated by $proof(chain)$ mode.
|
|
737 |
\item [$\QED{m@2}$] refines any remaining goals by proof method $m@2$ and
|
7895
|
738 |
concludes the sub-proof by assumption. If the goal had been $\SHOWNAME$ (or
|
|
739 |
$\THUSNAME$), some pending sub-goal is solved as well by the rule resulting
|
|
740 |
from the result \emph{exported} into the enclosing goal context. Thus
|
|
741 |
$\QEDNAME$ may fail for two reasons: either $m@2$ fails, or the resulting
|
|
742 |
rule does not fit to any pending goal\footnote{This includes any additional
|
|
743 |
``strong'' assumptions as introduced by $\ASSUMENAME$.} of the enclosing
|
|
744 |
context. Debugging such a situation might involve temporarily changing
|
|
745 |
$\SHOWNAME$ into $\HAVENAME$, or weakening the local context by replacing
|
|
746 |
some occurrences of $\ASSUMENAME$ by $\PRESUMENAME$.
|
|
747 |
\item [$\BYY{m@1}{m@2}$] is a \emph{terminal proof}\index{proof!terminal}; it
|
7987
|
748 |
abbreviates $\PROOF{m@1}~\QED{m@2}$, with backtracking across both methods,
|
|
749 |
though. Debugging an unsuccessful $\BYY{m@1}{m@2}$ commands might be done
|
7895
|
750 |
by expanding its definition; in many cases $\PROOF{m@1}$ is already
|
7175
|
751 |
sufficient to see what is going wrong.
|
7895
|
752 |
\item [``$\DDOT$''] is a \emph{default proof}\index{proof!default}; it
|
|
753 |
abbreviates $\BY{default}$.
|
|
754 |
\item [``$\DOT$''] is a \emph{trivial proof}\index{proof!trivial}; it
|
8195
|
755 |
abbreviates $\BY{this}$.
|
8379
|
756 |
\item [$\SORRY$] is a \emph{fake proof}\index{proof!fake}; provided that the
|
|
757 |
\texttt{quick_and_dirty} flag is enabled, $\SORRY$ pretends to solve the
|
|
758 |
goal without further ado. Of course, the result is a fake theorem only,
|
|
759 |
involving some oracle in its internal derivation object (this is indicated
|
|
760 |
as ``$[!]$'' in the printed result). The main application of $\SORRY$ is to
|
|
761 |
support experimentation and top-down proof development.
|
7315
|
762 |
\end{descr}
|
|
763 |
|
|
764 |
|
|
765 |
\subsection{Term abbreviations}\label{sec:term-abbrev}
|
|
766 |
|
|
767 |
\indexisarcmd{let}
|
|
768 |
\begin{matharray}{rcl}
|
|
769 |
\isarcmd{let} & : & \isartrans{proof(state)}{proof(state)} \\
|
|
770 |
\isarkeyword{is} & : & syntax \\
|
|
771 |
\end{matharray}
|
|
772 |
|
|
773 |
Abbreviations may be either bound by explicit $\LET{p \equiv t}$ statements,
|
7987
|
774 |
or by annotating assumptions or goal statements with a list of patterns
|
|
775 |
$\ISS{p@1\;\dots}{p@n}$. In both cases, higher-order matching is invoked to
|
|
776 |
bind extra-logical term variables, which may be either named schematic
|
|
777 |
variables of the form $\Var{x}$, or nameless dummies ``\texttt{_}''
|
|
778 |
(underscore).\indexisarvar{_@\texttt{_}} Note that in the $\LETNAME$ form the
|
|
779 |
patterns occur on the left-hand side, while the $\ISNAME$ patterns are in
|
|
780 |
postfix position.
|
7315
|
781 |
|
7319
|
782 |
Term abbreviations are quite different from actual local definitions as
|
|
783 |
introduced via $\DEFNAME$ (see \S\ref{sec:proof-context}). The latter are
|
7315
|
784 |
visible within the logic as actual equations, while abbreviations disappear
|
|
785 |
during the input process just after type checking.
|
|
786 |
|
|
787 |
\begin{rail}
|
|
788 |
'let' ((term + 'as') '=' term comment? + 'and')
|
|
789 |
;
|
|
790 |
\end{rail}
|
|
791 |
|
|
792 |
The syntax of $\ISNAME$ patterns follows \railnonterm{termpat} or
|
|
793 |
\railnonterm{proppat} (see \S\ref{sec:term-pats}).
|
|
794 |
|
|
795 |
\begin{descr}
|
|
796 |
\item [$\LET{\vec p = \vec t}$] binds any text variables in patters $\vec p$
|
|
797 |
by simultaneous higher-order matching against terms $\vec t$.
|
|
798 |
\item [$\IS{\vec p}$] resembles $\LETNAME$, but matches $\vec p$ against the
|
|
799 |
preceding statement. Also note that $\ISNAME$ is not a separate command,
|
|
800 |
but part of others (such as $\ASSUMENAME$, $\HAVENAME$ etc.).
|
|
801 |
\end{descr}
|
|
802 |
|
7988
|
803 |
A few \emph{automatic} term abbreviations\index{term abbreviations} for goals
|
|
804 |
and facts are available as well. For any open goal,
|
7466
|
805 |
$\Var{thesis_prop}$\indexisarvar{thesis-prop} refers to the full proposition
|
|
806 |
(which may be a rule), $\Var{thesis_concl}$\indexisarvar{thesis-concl} to its
|
|
807 |
(atomic) conclusion, and $\Var{thesis}$\indexisarvar{thesis} to its
|
7335
|
808 |
object-logical statement. The latter two abstract over any meta-level
|
7987
|
809 |
parameters.
|
7315
|
810 |
|
7466
|
811 |
Fact statements resulting from assumptions or finished goals are bound as
|
|
812 |
$\Var{this_prop}$\indexisarvar{this-prop},
|
|
813 |
$\Var{this_concl}$\indexisarvar{this-concl}, and
|
|
814 |
$\Var{this}$\indexisarvar{this}, similar to $\Var{thesis}$ above. In case
|
|
815 |
$\Var{this}$ refers to an object-logic statement that is an application
|
7895
|
816 |
$f(t)$, then $t$ is bound to the special text variable
|
7466
|
817 |
``$\dots$''\indexisarvar{\dots} (three dots). The canonical application of
|
7987
|
818 |
the latter are calculational proofs (see \S\ref{sec:calculation}).
|
7315
|
819 |
|
|
820 |
|
7134
|
821 |
\subsection{Block structure}
|
|
822 |
|
7397
|
823 |
\indexisarcmd{next}\indexisarcmd{\{\{}\indexisarcmd{\}\}}
|
|
824 |
\begin{matharray}{rcl}
|
8448
|
825 |
\NEXT & : & \isartrans{proof(state)}{proof(state)} \\
|
7974
|
826 |
\BG & : & \isartrans{proof(state)}{proof(state)} \\
|
|
827 |
\EN & : & \isartrans{proof(state)}{proof(state)} \\
|
7397
|
828 |
\end{matharray}
|
|
829 |
|
7167
|
830 |
While Isar is inherently block-structured, opening and closing blocks is
|
|
831 |
mostly handled rather casually, with little explicit user-intervention. Any
|
|
832 |
local goal statement automatically opens \emph{two} blocks, which are closed
|
|
833 |
again when concluding the sub-proof (by $\QEDNAME$ etc.). Sections of
|
8448
|
834 |
different context within a sub-proof may be switched via $\NEXT$, which is
|
|
835 |
just a single block-close followed by block-open again. Thus the effect of
|
|
836 |
$\NEXT$ to reset the local proof context. There is no goal focus involved
|
|
837 |
here!
|
7167
|
838 |
|
7175
|
839 |
For slightly more advanced applications, there are explicit block parentheses
|
7895
|
840 |
as well. These typically achieve a stronger forward style of reasoning.
|
7167
|
841 |
|
|
842 |
\begin{descr}
|
8448
|
843 |
\item [$\NEXT$] switches to a fresh block within a sub-proof, resetting the
|
|
844 |
local context to the initial one.
|
7167
|
845 |
\item [$\isarkeyword{\{\{}$ and $\isarkeyword{\}\}}$] explicitly open and
|
7895
|
846 |
close blocks. Any current facts pass through ``$\isarkeyword{\{\{}$''
|
|
847 |
unchanged, while ``$\isarkeyword{\}\}}$'' causes any result to be
|
|
848 |
\emph{exported} into the enclosing context. Thus fixed variables are
|
|
849 |
generalized, assumptions discharged, and local definitions unfolded (cf.\
|
|
850 |
\S\ref{sec:proof-context}). There is no difference of $\ASSUMENAME$ and
|
|
851 |
$\PRESUMENAME$ in this mode of forward reasoning --- in contrast to plain
|
|
852 |
backward reasoning with the result exported at $\SHOWNAME$ time.
|
7167
|
853 |
\end{descr}
|
7134
|
854 |
|
|
855 |
|
|
856 |
\section{Other commands}
|
|
857 |
|
8448
|
858 |
\subsection{Diagnostics}\label{sec:diag}
|
7134
|
859 |
|
7974
|
860 |
\indexisarcmd{thm}\indexisarcmd{term}\indexisarcmd{prop}\indexisarcmd{typ}
|
8379
|
861 |
\indexisarcmd{print-facts}\indexisarcmd{print-binds}\indexisarcmd{print-cases}
|
7134
|
862 |
\begin{matharray}{rcl}
|
7974
|
863 |
\isarcmd{thm} & : & \isarkeep{theory~|~proof} \\
|
7134
|
864 |
\isarcmd{term} & : & \isarkeep{theory~|~proof} \\
|
|
865 |
\isarcmd{prop} & : & \isarkeep{theory~|~proof} \\
|
7974
|
866 |
\isarcmd{typ} & : & \isarkeep{theory~|~proof} \\
|
8379
|
867 |
\isarcmd{print_facts} & : & \isarkeep{proof} \\
|
|
868 |
\isarcmd{print_binds} & : & \isarkeep{proof} \\
|
|
869 |
\isarcmd{print_cases} & : & \isarkeep{proof} \\
|
7134
|
870 |
\end{matharray}
|
|
871 |
|
7335
|
872 |
These commands are not part of the actual Isabelle/Isar syntax, but assist
|
|
873 |
interactive development. Also note that $undo$ does not apply here, since the
|
|
874 |
theory or proof configuration is not changed.
|
|
875 |
|
7134
|
876 |
\begin{rail}
|
7974
|
877 |
'thm' thmrefs
|
7134
|
878 |
;
|
|
879 |
'term' term
|
|
880 |
;
|
|
881 |
'prop' prop
|
|
882 |
;
|
7974
|
883 |
'typ' type
|
7134
|
884 |
;
|
|
885 |
\end{rail}
|
|
886 |
|
7167
|
887 |
\begin{descr}
|
7974
|
888 |
\item [$\isarkeyword{thm}~thms$] retrieves lists of theorems from the current
|
|
889 |
theory or proof context. Note that any attributes included in the theorem
|
|
890 |
specifications are applied to a temporary context derived from the current
|
|
891 |
theory or proof; the result is discarded, i.e.\ attributes involved in
|
|
892 |
$thms$ do not have any permanent effect.
|
7987
|
893 |
\item [$\isarkeyword{term}~t$, $\isarkeyword{prop}~\phi$] read, type-check and
|
|
894 |
print terms or propositions according to the current theory or proof
|
7895
|
895 |
context; the inferred type of $t$ is output as well. Note that these
|
|
896 |
commands are also useful in inspecting the current environment of term
|
|
897 |
abbreviations.
|
7974
|
898 |
\item [$\isarkeyword{typ}~\tau$] reads and prints types of the meta-logic
|
|
899 |
according to the current theory or proof context.
|
8379
|
900 |
\item [$\isarkeyword{print_facts}$] prints any named facts of the current
|
|
901 |
context, including assumptions and local results.
|
|
902 |
\item [$\isarkeyword{print_binds}$] prints all term abbreviations present in
|
|
903 |
the context.
|
|
904 |
\item [$\isarkeyword{print_cases}$] prints all local contexts (also known as
|
|
905 |
``cases'') of the current goal context.
|
7167
|
906 |
\end{descr}
|
7134
|
907 |
|
|
908 |
|
8379
|
909 |
\subsection{Meta-linguistic features}
|
|
910 |
|
|
911 |
\indexisarcmd{oops}
|
|
912 |
\begin{matharray}{rcl}
|
|
913 |
\isarcmd{oops}^* & : & \isartrans{proof}{theory} \\
|
|
914 |
\end{matharray}
|
|
915 |
|
|
916 |
The $\OOPS$ command discontinues the current proof attempt, while considering
|
|
917 |
the partial proof text as properly processed. This is conceptually quite
|
|
918 |
different from ``faking'' actual proofs via $\SORRY$ (see
|
|
919 |
\S\ref{sec:proof-steps}): $\OOPS$ does not observe the proof structure at all,
|
|
920 |
but goes back right to the theory level. Furthermore, $\OOPS$ does not
|
|
921 |
produce any result theorem --- there is no claim to be able to complete the
|
|
922 |
proof anyhow.
|
|
923 |
|
|
924 |
A typical application of $\OOPS$ is to explain Isar proofs \emph{within} the
|
|
925 |
system itself, in conjunction with the document preparation tools of Isabelle
|
|
926 |
described in \cite{isabelle-sys}. Thus partial or even wrong proof attempts
|
|
927 |
can be discussed in a logically sound manner. Note that the Isabelle {\LaTeX}
|
|
928 |
macros can be easily adapted to print something like ``$\dots$'' instead of an
|
|
929 |
``$\OOPS$'' keyword.
|
|
930 |
|
|
931 |
|
7134
|
932 |
\subsection{System operations}
|
|
933 |
|
7167
|
934 |
\indexisarcmd{cd}\indexisarcmd{pwd}\indexisarcmd{use-thy}\indexisarcmd{use-thy-only}
|
|
935 |
\indexisarcmd{update-thy}\indexisarcmd{update-thy-only}
|
7134
|
936 |
\begin{matharray}{rcl}
|
|
937 |
\isarcmd{cd} & : & \isarkeep{\cdot} \\
|
|
938 |
\isarcmd{pwd} & : & \isarkeep{\cdot} \\
|
|
939 |
\isarcmd{use_thy} & : & \isarkeep{\cdot} \\
|
|
940 |
\isarcmd{use_thy_only} & : & \isarkeep{\cdot} \\
|
|
941 |
\isarcmd{update_thy} & : & \isarkeep{\cdot} \\
|
|
942 |
\isarcmd{update_thy_only} & : & \isarkeep{\cdot} \\
|
|
943 |
\end{matharray}
|
|
944 |
|
7167
|
945 |
\begin{descr}
|
7134
|
946 |
\item [$\isarkeyword{cd}~name$] changes the current directory of the Isabelle
|
|
947 |
process.
|
|
948 |
\item [$\isarkeyword{pwd}~$] prints the current working directory.
|
7175
|
949 |
\item [$\isarkeyword{use_thy}$, $\isarkeyword{use_thy_only}$,
|
7987
|
950 |
$\isarkeyword{update_thy}$, $\isarkeyword{update_thy_only}$] load some
|
7895
|
951 |
theory given as $name$ argument. These commands are basically the same as
|
7987
|
952 |
the corresponding ML functions\footnote{The ML versions also change the
|
|
953 |
implicit theory context to that of the theory loaded.} (see also
|
|
954 |
\cite[\S1,\S6]{isabelle-ref}). Note that both the ML and Isar versions may
|
|
955 |
load new- and old-style theories alike.
|
7167
|
956 |
\end{descr}
|
7134
|
957 |
|
7987
|
958 |
These system commands are scarcely used when working with the Proof~General
|
|
959 |
interface, since loading of theories is done fully transparently.
|
7134
|
960 |
|
8379
|
961 |
|
|
962 |
\subsection{Emulating tactic scripts}
|
|
963 |
|
|
964 |
The following elements emulate unstructured tactic scripts to some extent.
|
|
965 |
While these are anathema for writing proper Isar proof documents, they might
|
|
966 |
come in handy for interactive exploration and debugging.
|
|
967 |
|
|
968 |
\indexisarcmd{apply}\indexisarcmd{apply-end}\indexisarcmd{back}\indexisarmeth{tactic}
|
|
969 |
\begin{matharray}{rcl}
|
|
970 |
\isarcmd{apply} & : & \isartrans{proof(prove)}{proof(prove)} \\
|
|
971 |
\isarcmd{apply_end}^* & : & \isartrans{proof(state)}{proof(state)} \\
|
|
972 |
tactic & : & \isarmeth \\
|
|
973 |
\isarcmd{back}^* & : & \isartrans{proof}{proof} \\
|
|
974 |
\end{matharray}
|
|
975 |
|
|
976 |
\railalias{applyend}{apply\_end}
|
|
977 |
\railterm{applyend}
|
|
978 |
|
|
979 |
\begin{rail}
|
|
980 |
'apply' method
|
|
981 |
;
|
|
982 |
applyend method
|
|
983 |
;
|
|
984 |
'tactic' text
|
|
985 |
;
|
|
986 |
'back'
|
|
987 |
;
|
|
988 |
\end{rail}
|
|
989 |
|
|
990 |
\begin{descr}
|
|
991 |
\item [$\isarkeyword{apply}~(m)$] applies proof method $m$ in an initial
|
|
992 |
position, but retains ``$prove$'' mode (unlike $\PROOFNAME$). Thus
|
|
993 |
consecutive method applications may be given just as in tactic scripts. In
|
|
994 |
order to complete the proof properly, any of the actual structured proof
|
|
995 |
commands (e.g.\ ``$\DOT$'') has to be given eventually.
|
|
996 |
|
|
997 |
Facts are passed to $m$ as indicated by the goal's forward-chain mode.
|
|
998 |
Common use of $\isarkeyword{apply}$ would be in a purely backward manner,
|
|
999 |
though.
|
|
1000 |
\item [$\isarkeyword{apply_end}~(m)$] applies proof method $m$ as if in
|
|
1001 |
terminal position. Basically, this simulates a multi-step tactic script for
|
|
1002 |
$\QEDNAME$, but may be given anywhere within the proof body.
|
|
1003 |
|
|
1004 |
No facts are passed to $m$. Furthermore, the static context is that of the
|
|
1005 |
enclosing goal (as for actual $\QEDNAME$). Thus the proof method may not
|
|
1006 |
refer to any assumptions introduced in the current body, for example.
|
|
1007 |
\item [$tactic~text$] produces a proof method from any ML text of type
|
|
1008 |
\texttt{tactic}. Apart from the usual ML environment, and the current
|
|
1009 |
implicit theory context, the ML code may refer to the following locally
|
|
1010 |
bound values:
|
|
1011 |
\begin{ttbox}
|
|
1012 |
val ctxt : Proof.context
|
|
1013 |
val facts : thm list
|
|
1014 |
val thm : string -> thm
|
|
1015 |
val thms : string -> thm list
|
|
1016 |
\end{ttbox}
|
|
1017 |
Here \texttt{ctxt} refers to the current proof context, \texttt{facts}
|
|
1018 |
indicates any current facts for forward-chaining, and
|
|
1019 |
\texttt{thm}~/~\texttt{thms} retrieve named facts (including global
|
|
1020 |
theorems) from the context.
|
|
1021 |
\item [$\isarkeyword{back}$] does back-tracking over the result sequence of
|
|
1022 |
the latest proof command.\footnote{Unlike the ML function \texttt{back}
|
|
1023 |
\cite{isabelle-ref}, the Isar command does not search upwards for further
|
|
1024 |
branch points.} Basically, any proof command may return multiple results.
|
|
1025 |
\end{descr}
|
|
1026 |
|
|
1027 |
|
7046
|
1028 |
%%% Local Variables:
|
|
1029 |
%%% mode: latex
|
|
1030 |
%%% TeX-master: "isar-ref"
|
|
1031 |
%%% End:
|