author | wenzelm |
Sun, 04 Feb 2001 22:28:31 +0100 | |
changeset 11059 | 9ef75bf54a49 |
parent 11017 | 241cbdf4134e |
child 11100 | 34d58b1818f4 |
permissions | -rw-r--r-- |
7046 | 1 |
|
7895 | 2 |
\chapter{Basic Isar Language Elements}\label{ch:pure-syntax} |
7167 | 3 |
|
8515 | 4 |
Subsequently, we introduce the main part of Pure Isar theory and proof |
8547 | 5 |
commands, together with fundamental proof methods and attributes. |
8515 | 6 |
Chapter~\ref{ch:gen-tools} describes further Isar elements provided by generic |
7 |
tools and packages (such as the Simplifier) that are either part of Pure |
|
8 |
Isabelle or pre-installed by most object logics. Chapter~\ref{ch:hol-tools} |
|
9 |
refers to actual object-logic specific 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 |
|
8547 | 20 |
proving. |
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} \\ |
8510 | 30 |
\isarcmd{theory} & : & \isartrans{toplevel}{theory} \\ |
31 |
\isarcmd{context}^* & : & \isartrans{toplevel}{theory} \\ |
|
32 |
\isarcmd{end} & : & \isartrans{theory}{toplevel} \\ |
|
7134 | 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 |
|
8547 | 48 |
last command of any 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 |
8547 | 65 |
the formal beginning of a theory. In actual document preparation the |
7895 | 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} |
|
8547 | 131 |
package to be included in {\LaTeX}, of course.} |
7167 | 132 |
\end{descr} |
7134 | 133 |
|
8684 | 134 |
Any of these markup elements corresponds to a {\LaTeX} command with the name |
135 |
prefixed by \verb,\isamarkup,. For the sectioning commands this is a plain |
|
136 |
macro with a single argument, e.g.\ \verb,\isamarkupchapter{,\dots\verb,}, for |
|
137 |
$\isarkeyword{chapter}$. The $\isarkeyword{text}$ markup results in a |
|
138 |
{\LaTeX} environment \verb,\begin{isamarkuptext}, {\dots} |
|
139 |
\verb,\end{isamarkuptext},, while $\isarkeyword{text_raw}$ causes the text |
|
140 |
to be inserted directly into the {\LaTeX} source. |
|
7895 | 141 |
|
8485 | 142 |
\medskip |
143 |
||
144 |
Additional markup commands are available for proofs (see |
|
7895 | 145 |
\S\ref{sec:markup-prf}). Also note that the $\isarkeyword{header}$ |
8684 | 146 |
declaration (see \S\ref{sec:begin-thy}) admits to insert section markup just |
147 |
preceding the actual theory definition. |
|
7895 | 148 |
|
7134 | 149 |
|
7135 | 150 |
\subsection{Type classes and sorts}\label{sec:classes} |
7134 | 151 |
|
152 |
\indexisarcmd{classes}\indexisarcmd{classrel}\indexisarcmd{defaultsort} |
|
153 |
\begin{matharray}{rcl} |
|
154 |
\isarcmd{classes} & : & \isartrans{theory}{theory} \\ |
|
155 |
\isarcmd{classrel} & : & \isartrans{theory}{theory} \\ |
|
156 |
\isarcmd{defaultsort} & : & \isartrans{theory}{theory} \\ |
|
157 |
\end{matharray} |
|
158 |
||
159 |
\begin{rail} |
|
7167 | 160 |
'classes' (classdecl comment? +) |
7134 | 161 |
; |
162 |
'classrel' nameref '<' nameref comment? |
|
163 |
; |
|
164 |
'defaultsort' sort comment? |
|
165 |
; |
|
166 |
\end{rail} |
|
167 |
||
7167 | 168 |
\begin{descr} |
7335 | 169 |
\item [$\isarkeyword{classes}~c<\vec c$] declares class $c$ to be a subclass |
170 |
of existing classes $\vec c$. Cyclic class structures are ruled out. |
|
7134 | 171 |
\item [$\isarkeyword{classrel}~c@1<c@2$] states a subclass relation between |
172 |
existing classes $c@1$ and $c@2$. This is done axiomatically! The |
|
10223 | 173 |
$\INSTANCE$ command (see \S\ref{sec:axclass}) provides a way to introduce |
174 |
proven class relations. |
|
7134 | 175 |
\item [$\isarkeyword{defaultsort}~s$] makes sort $s$ the new default sort for |
7895 | 176 |
any type variables given without sort constraints. Usually, the default |
8547 | 177 |
sort would be only changed when defining new object-logics. |
7167 | 178 |
\end{descr} |
7134 | 179 |
|
180 |
||
7315 | 181 |
\subsection{Primitive types and type abbreviations}\label{sec:types-pure} |
7134 | 182 |
|
183 |
\indexisarcmd{typedecl}\indexisarcmd{types}\indexisarcmd{nonterminals}\indexisarcmd{arities} |
|
184 |
\begin{matharray}{rcl} |
|
185 |
\isarcmd{types} & : & \isartrans{theory}{theory} \\ |
|
186 |
\isarcmd{typedecl} & : & \isartrans{theory}{theory} \\ |
|
187 |
\isarcmd{nonterminals} & : & \isartrans{theory}{theory} \\ |
|
188 |
\isarcmd{arities} & : & \isartrans{theory}{theory} \\ |
|
189 |
\end{matharray} |
|
190 |
||
191 |
\begin{rail} |
|
192 |
'types' (typespec '=' type infix? comment? +) |
|
193 |
; |
|
194 |
'typedecl' typespec infix? comment? |
|
195 |
; |
|
196 |
'nonterminals' (name +) comment? |
|
197 |
; |
|
198 |
'arities' (nameref '::' arity comment? +) |
|
199 |
; |
|
200 |
\end{rail} |
|
201 |
||
7167 | 202 |
\begin{descr} |
7335 | 203 |
\item [$\TYPES~(\vec\alpha)t = \tau$] introduces \emph{type synonym} |
7134 | 204 |
$(\vec\alpha)t$ for existing type $\tau$. Unlike actual type definitions, |
205 |
as are available in Isabelle/HOL for example, type synonyms are just purely |
|
7895 | 206 |
syntactic abbreviations without any logical significance. Internally, type |
7981 | 207 |
synonyms are fully expanded. |
7134 | 208 |
\item [$\isarkeyword{typedecl}~(\vec\alpha)t$] declares a new type constructor |
7895 | 209 |
$t$, intended as an actual logical type. Note that object-logics such as |
210 |
Isabelle/HOL override $\isarkeyword{typedecl}$ by their own version. |
|
7175 | 211 |
\item [$\isarkeyword{nonterminals}~\vec c$] declares $0$-ary type constructors |
212 |
$\vec c$ to act as purely syntactic types, i.e.\ nonterminal symbols of |
|
213 |
Isabelle's inner syntax of terms or types. |
|
7335 | 214 |
\item [$\isarkeyword{arities}~t::(\vec s)s$] augments Isabelle's order-sorted |
215 |
signature of types by new type constructor arities. This is done |
|
10223 | 216 |
axiomatically! The $\INSTANCE$ command (see \S\ref{sec:axclass}) provides a |
217 |
way to introduce proven type arities. |
|
7167 | 218 |
\end{descr} |
7134 | 219 |
|
220 |
||
7981 | 221 |
\subsection{Constants and simple definitions}\label{sec:consts} |
7134 | 222 |
|
7175 | 223 |
\indexisarcmd{consts}\indexisarcmd{defs}\indexisarcmd{constdefs}\indexoutertoken{constdecl} |
7134 | 224 |
\begin{matharray}{rcl} |
225 |
\isarcmd{consts} & : & \isartrans{theory}{theory} \\ |
|
226 |
\isarcmd{defs} & : & \isartrans{theory}{theory} \\ |
|
227 |
\isarcmd{constdefs} & : & \isartrans{theory}{theory} \\ |
|
228 |
\end{matharray} |
|
229 |
||
230 |
\begin{rail} |
|
231 |
'consts' (constdecl +) |
|
232 |
; |
|
9308 | 233 |
'defs' ('(overloaded)')? (axmdecl prop comment? +) |
7134 | 234 |
; |
235 |
'constdefs' (constdecl prop comment? +) |
|
236 |
; |
|
237 |
||
238 |
constdecl: name '::' type mixfix? comment? |
|
239 |
; |
|
240 |
\end{rail} |
|
241 |
||
7167 | 242 |
\begin{descr} |
7335 | 243 |
\item [$\CONSTS~c::\sigma$] declares constant $c$ to have any instance of type |
244 |
scheme $\sigma$. The optional mixfix annotations may attach concrete syntax |
|
7895 | 245 |
to the constants declared. |
9308 | 246 |
|
7335 | 247 |
\item [$\DEFS~name: eqn$] introduces $eqn$ as a definitional axiom for some |
248 |
existing constant. See \cite[\S6]{isabelle-ref} for more details on the |
|
249 |
form of equations admitted as constant definitions. |
|
9308 | 250 |
|
251 |
The $overloaded$ option declares definitions to be potentially overloaded. |
|
252 |
Unless this option is given, a warning message would be issued for any |
|
253 |
definitional equation with a more special type than that of the |
|
254 |
corresponding constant declaration. |
|
255 |
||
7335 | 256 |
\item [$\isarkeyword{constdefs}~c::\sigma~eqn$] combines declarations and |
8547 | 257 |
definitions of constants, using the canonical name $c_def$ for the |
258 |
definitional axiom. |
|
7167 | 259 |
\end{descr} |
7134 | 260 |
|
261 |
||
7981 | 262 |
\subsection{Syntax and translations}\label{sec:syn-trans} |
7134 | 263 |
|
264 |
\indexisarcmd{syntax}\indexisarcmd{translations} |
|
265 |
\begin{matharray}{rcl} |
|
266 |
\isarcmd{syntax} & : & \isartrans{theory}{theory} \\ |
|
267 |
\isarcmd{translations} & : & \isartrans{theory}{theory} \\ |
|
268 |
\end{matharray} |
|
269 |
||
10640 | 270 |
\railalias{rightleftharpoons}{\isasymrightleftharpoons} |
271 |
\railterm{rightleftharpoons} |
|
272 |
||
273 |
\railalias{rightharpoonup}{\isasymrightharpoonup} |
|
274 |
\railterm{rightharpoonup} |
|
275 |
||
276 |
\railalias{leftharpoondown}{\isasymleftharpoondown} |
|
277 |
\railterm{leftharpoondown} |
|
278 |
||
7134 | 279 |
\begin{rail} |
9727 | 280 |
'syntax' ('(' ( name | 'output' | name 'output' ) ')')? (constdecl +) |
7134 | 281 |
; |
10640 | 282 |
'translations' (transpat ('==' | '=>' | '<=' | rightleftharpoons | rightharpoonup | leftharpoondown) transpat comment? +) |
7134 | 283 |
; |
284 |
transpat: ('(' nameref ')')? string |
|
285 |
; |
|
286 |
\end{rail} |
|
287 |
||
7167 | 288 |
\begin{descr} |
7175 | 289 |
\item [$\isarkeyword{syntax}~(mode)~decls$] is similar to $\CONSTS~decls$, |
290 |
except that the actual logical signature extension is omitted. Thus the |
|
291 |
context free grammar of Isabelle's inner syntax may be augmented in |
|
7335 | 292 |
arbitrary ways, independently of the logic. The $mode$ argument refers to |
8547 | 293 |
the print mode that the grammar rules belong; unless the \texttt{output} |
294 |
flag is given, all productions are added both to the input and output |
|
295 |
grammar. |
|
7175 | 296 |
\item [$\isarkeyword{translations}~rules$] specifies syntactic translation |
10640 | 297 |
rules (i.e.\ \emph{macros}): parse~/ print rules (\texttt{==} or |
298 |
\isasymrightleftharpoons), parse rules (\texttt{=>} or |
|
299 |
\isasymrightharpoonup), or print rules (\texttt{<=} or |
|
300 |
\isasymleftharpoondown). Translation patterns may be prefixed by the |
|
301 |
syntactic category to be used for parsing; the default is \texttt{logic}. |
|
7167 | 302 |
\end{descr} |
7134 | 303 |
|
304 |
||
9605 | 305 |
\subsection{Axioms and theorems}\label{sec:axms-thms} |
7134 | 306 |
|
307 |
\indexisarcmd{axioms}\indexisarcmd{theorems}\indexisarcmd{lemmas} |
|
308 |
\begin{matharray}{rcl} |
|
309 |
\isarcmd{axioms} & : & \isartrans{theory}{theory} \\ |
|
310 |
\isarcmd{theorems} & : & \isartrans{theory}{theory} \\ |
|
311 |
\isarcmd{lemmas} & : & \isartrans{theory}{theory} \\ |
|
312 |
\end{matharray} |
|
313 |
||
314 |
\begin{rail} |
|
7135 | 315 |
'axioms' (axmdecl prop comment? +) |
7134 | 316 |
; |
9199 | 317 |
('theorems' | 'lemmas') (thmdef? thmrefs comment? + 'and') |
7134 | 318 |
; |
319 |
\end{rail} |
|
320 |
||
7167 | 321 |
\begin{descr} |
7335 | 322 |
\item [$\isarkeyword{axioms}~a: \phi$] introduces arbitrary statements as |
7895 | 323 |
axioms of the meta-logic. In fact, axioms are ``axiomatic theorems'', and |
324 |
may be referred later just as any other theorem. |
|
7134 | 325 |
|
326 |
Axioms are usually only introduced when declaring new logical systems. |
|
7175 | 327 |
Everyday work is typically done the hard way, with proper definitions and |
8547 | 328 |
actual proven theorems. |
7335 | 329 |
\item [$\isarkeyword{theorems}~a = \vec b$] stores lists of existing theorems. |
8547 | 330 |
Typical applications would also involve attributes, to declare Simplifier |
331 |
rules, for example. |
|
7134 | 332 |
\item [$\isarkeyword{lemmas}$] is similar to $\isarkeyword{theorems}$, but |
333 |
tags the results as ``lemma''. |
|
7167 | 334 |
\end{descr} |
7134 | 335 |
|
336 |
||
7167 | 337 |
\subsection{Name spaces} |
7134 | 338 |
|
8726 | 339 |
\indexisarcmd{global}\indexisarcmd{local}\indexisarcmd{hide} |
7134 | 340 |
\begin{matharray}{rcl} |
341 |
\isarcmd{global} & : & \isartrans{theory}{theory} \\ |
|
342 |
\isarcmd{local} & : & \isartrans{theory}{theory} \\ |
|
8726 | 343 |
\isarcmd{hide} & : & \isartrans{theory}{theory} \\ |
7134 | 344 |
\end{matharray} |
345 |
||
8726 | 346 |
\begin{rail} |
347 |
'global' comment? |
|
348 |
; |
|
349 |
'local' comment? |
|
350 |
; |
|
351 |
'hide' name (nameref + ) comment? |
|
352 |
; |
|
353 |
\end{rail} |
|
354 |
||
7895 | 355 |
Isabelle organizes any kind of name declarations (of types, constants, |
8547 | 356 |
theorems etc.) by separate hierarchically structured name spaces. Normally |
8726 | 357 |
the user does not have to control the behavior of name spaces by hand, yet the |
358 |
following commands provide some way to do so. |
|
7175 | 359 |
|
7167 | 360 |
\begin{descr} |
361 |
\item [$\isarkeyword{global}$ and $\isarkeyword{local}$] change the current |
|
362 |
name declaration mode. Initially, theories start in $\isarkeyword{local}$ |
|
363 |
mode, causing all names to be automatically qualified by the theory name. |
|
7895 | 364 |
Changing this to $\isarkeyword{global}$ causes all names to be declared |
365 |
without the theory prefix, until $\isarkeyword{local}$ is declared again. |
|
8726 | 366 |
|
367 |
Note that global names are prone to get hidden accidently later, when |
|
368 |
qualified names of the same base name are introduced. |
|
369 |
||
370 |
\item [$\isarkeyword{hide}~space~names$] removes declarations from a given |
|
371 |
name space (which may be $class$, $type$, or $const$). Hidden objects |
|
372 |
remain valid within the logic, but are inaccessible from user input. In |
|
373 |
output, the special qualifier ``$\mathord?\mathord?$'' is prefixed to the |
|
374 |
full internal name. |
|
375 |
||
376 |
Unqualified (global) names may not be hidden deliberately. |
|
7167 | 377 |
\end{descr} |
7134 | 378 |
|
379 |
||
7167 | 380 |
\subsection{Incorporating ML code}\label{sec:ML} |
7134 | 381 |
|
8682 | 382 |
\indexisarcmd{use}\indexisarcmd{ML}\indexisarcmd{ML-command} |
383 |
\indexisarcmd{ML-setup}\indexisarcmd{setup} |
|
9199 | 384 |
\indexisarcmd{method-setup} |
7134 | 385 |
\begin{matharray}{rcl} |
386 |
\isarcmd{use} & : & \isartrans{\cdot}{\cdot} \\ |
|
387 |
\isarcmd{ML} & : & \isartrans{\cdot}{\cdot} \\ |
|
8682 | 388 |
\isarcmd{ML_command} & : & \isartrans{\cdot}{\cdot} \\ |
7895 | 389 |
\isarcmd{ML_setup} & : & \isartrans{theory}{theory} \\ |
7175 | 390 |
\isarcmd{setup} & : & \isartrans{theory}{theory} \\ |
9199 | 391 |
\isarcmd{method_setup} & : & \isartrans{theory}{theory} \\ |
7134 | 392 |
\end{matharray} |
393 |
||
7895 | 394 |
\railalias{MLsetup}{ML\_setup} |
395 |
\railterm{MLsetup} |
|
396 |
||
9199 | 397 |
\railalias{methodsetup}{method\_setup} |
398 |
\railterm{methodsetup} |
|
399 |
||
8682 | 400 |
\railalias{MLcommand}{ML\_command} |
401 |
\railterm{MLcommand} |
|
402 |
||
7134 | 403 |
\begin{rail} |
9273 | 404 |
'use' name comment? |
7134 | 405 |
; |
9273 | 406 |
('ML' | MLcommand | MLsetup | 'setup') text comment? |
7134 | 407 |
; |
9199 | 408 |
methodsetup name '=' text text comment? |
409 |
; |
|
7134 | 410 |
\end{rail} |
411 |
||
7167 | 412 |
\begin{descr} |
7175 | 413 |
\item [$\isarkeyword{use}~file$] reads and executes ML commands from $file$. |
7466 | 414 |
The current theory context (if present) is passed down to the ML session, |
7981 | 415 |
but may not be modified. Furthermore, the file name is checked with the |
7466 | 416 |
$\isarkeyword{files}$ dependency declaration given in the theory header (see |
417 |
also \S\ref{sec:begin-thy}). |
|
418 |
||
8682 | 419 |
\item [$\isarkeyword{ML}~text$ and $\isarkeyword{ML_command}~text$] execute ML |
420 |
commands from $text$. The theory context is passed in the same way as for |
|
10858 | 421 |
$\isarkeyword{use}$, but may not be changed. Note that the output of |
8682 | 422 |
$\isarkeyword{ML_command}$ is less verbose than plain $\isarkeyword{ML}$. |
7895 | 423 |
|
424 |
\item [$\isarkeyword{ML_setup}~text$] executes ML commands from $text$. The |
|
425 |
theory context is passed down to the ML session, and fetched back |
|
426 |
afterwards. Thus $text$ may actually change the theory as a side effect. |
|
427 |
||
7167 | 428 |
\item [$\isarkeyword{setup}~text$] changes the current theory context by |
8379 | 429 |
applying $text$, which refers to an ML expression of type |
430 |
\texttt{(theory~->~theory)~list}. The $\isarkeyword{setup}$ command is the |
|
8547 | 431 |
canonical way to initialize any object-logic specific tools and packages |
432 |
written in ML. |
|
9199 | 433 |
|
434 |
\item [$\isarkeyword{method_setup}~name = text~description$] defines a proof |
|
435 |
method in the current theory. The given $text$ has to be an ML expression |
|
436 |
of type \texttt{Args.src -> Proof.context -> Proof.method}. Parsing |
|
437 |
concrete method syntax from \texttt{Args.src} input can be quite tedious in |
|
438 |
general. The following simple examples are for methods without any explicit |
|
439 |
arguments, or a list of theorems, respectively. |
|
440 |
||
441 |
{\footnotesize |
|
442 |
\begin{verbatim} |
|
9605 | 443 |
Method.no_args (Method.METHOD (fn facts => foobar_tac)) |
444 |
Method.thms_args (fn thms => Method.METHOD (fn facts => foobar_tac)) |
|
10899 | 445 |
Method.ctxt_args (fn ctxt => Method.METHOD (fn facts => foobar_tac)) |
446 |
Method.thms_ctxt_args (fn thms => fn ctxt => Method.METHOD (fn facts => foobar_tac)) |
|
9199 | 447 |
\end{verbatim} |
448 |
} |
|
449 |
||
450 |
Note that mere tactic emulations may ignore the \texttt{facts} parameter |
|
451 |
above. Proper proof methods would do something ``appropriate'' with the list |
|
452 |
of current facts, though. Single-rule methods usually do strict |
|
453 |
forward-chaining (e.g.\ by using \texttt{Method.multi_resolves}), while |
|
454 |
automatic ones just insert the facts using \texttt{Method.insert_tac} before |
|
455 |
applying the main tactic. |
|
7167 | 456 |
\end{descr} |
7134 | 457 |
|
458 |
||
8250 | 459 |
\subsection{Syntax translation functions} |
7134 | 460 |
|
8250 | 461 |
\indexisarcmd{parse-ast-translation}\indexisarcmd{parse-translation} |
462 |
\indexisarcmd{print-translation}\indexisarcmd{typed-print-translation} |
|
463 |
\indexisarcmd{print-ast-translation}\indexisarcmd{token-translation} |
|
464 |
\begin{matharray}{rcl} |
|
465 |
\isarcmd{parse_ast_translation} & : & \isartrans{theory}{theory} \\ |
|
466 |
\isarcmd{parse_translation} & : & \isartrans{theory}{theory} \\ |
|
467 |
\isarcmd{print_translation} & : & \isartrans{theory}{theory} \\ |
|
468 |
\isarcmd{typed_print_translation} & : & \isartrans{theory}{theory} \\ |
|
469 |
\isarcmd{print_ast_translation} & : & \isartrans{theory}{theory} \\ |
|
470 |
\isarcmd{token_translation} & : & \isartrans{theory}{theory} \\ |
|
471 |
\end{matharray} |
|
7134 | 472 |
|
9273 | 473 |
\railalias{parseasttranslation}{parse\_ast\_translation} |
474 |
\railterm{parseasttranslation} |
|
475 |
||
476 |
\railalias{parsetranslation}{parse\_translation} |
|
477 |
\railterm{parsetranslation} |
|
478 |
||
479 |
\railalias{printtranslation}{print\_translation} |
|
480 |
\railterm{printtranslation} |
|
481 |
||
482 |
\railalias{typedprinttranslation}{typed\_print\_translation} |
|
483 |
\railterm{typedprinttranslation} |
|
484 |
||
485 |
\railalias{printasttranslation}{print\_ast\_translation} |
|
486 |
\railterm{printasttranslation} |
|
487 |
||
488 |
\railalias{tokentranslation}{token\_translation} |
|
489 |
\railterm{tokentranslation} |
|
490 |
||
491 |
\begin{rail} |
|
492 |
( parseasttranslation | parsetranslation | printtranslation | typedprinttranslation | |
|
493 |
printasttranslation | tokentranslation ) text comment? |
|
494 |
\end{rail} |
|
495 |
||
8250 | 496 |
Syntax translation functions written in ML admit almost arbitrary |
497 |
manipulations of Isabelle's inner syntax. Any of the above commands have a |
|
498 |
single \railqtoken{text} argument that refers to an ML expression of |
|
8379 | 499 |
appropriate type. |
500 |
||
501 |
\begin{ttbox} |
|
502 |
val parse_ast_translation : (string * (ast list -> ast)) list |
|
503 |
val parse_translation : (string * (term list -> term)) list |
|
504 |
val print_translation : (string * (term list -> term)) list |
|
505 |
val typed_print_translation : |
|
506 |
(string * (bool -> typ -> term list -> term)) list |
|
507 |
val print_ast_translation : (string * (ast list -> ast)) list |
|
508 |
val token_translation : |
|
509 |
(string * string * (string -> string * real)) list |
|
510 |
\end{ttbox} |
|
511 |
See \cite[\S8]{isabelle-ref} for more information on syntax transformations. |
|
7134 | 512 |
|
513 |
||
514 |
\subsection{Oracles} |
|
515 |
||
516 |
\indexisarcmd{oracle} |
|
517 |
\begin{matharray}{rcl} |
|
518 |
\isarcmd{oracle} & : & \isartrans{theory}{theory} \\ |
|
519 |
\end{matharray} |
|
520 |
||
7175 | 521 |
Oracles provide an interface to external reasoning systems, without giving up |
522 |
control completely --- each theorem carries a derivation object recording any |
|
523 |
oracle invocation. See \cite[\S6]{isabelle-ref} for more information. |
|
524 |
||
7134 | 525 |
\begin{rail} |
526 |
'oracle' name '=' text comment? |
|
527 |
; |
|
528 |
\end{rail} |
|
529 |
||
7167 | 530 |
\begin{descr} |
7175 | 531 |
\item [$\isarkeyword{oracle}~name=text$] declares oracle $name$ to be ML |
8379 | 532 |
function $text$, which has to be of type |
533 |
\texttt{Sign.sg~*~Object.T~->~term}. |
|
7167 | 534 |
\end{descr} |
7134 | 535 |
|
536 |
||
537 |
\section{Proof commands} |
|
538 |
||
7987 | 539 |
Proof commands perform transitions of Isar/VM machine configurations, which |
7315 | 540 |
are block-structured, consisting of a stack of nodes with three main |
7335 | 541 |
components: logical proof context, current facts, and open goals. Isar/VM |
8547 | 542 |
transitions are \emph{typed} according to the following three different modes |
543 |
of operation: |
|
7167 | 544 |
\begin{descr} |
545 |
\item [$proof(prove)$] means that a new goal has just been stated that is now |
|
8547 | 546 |
to be \emph{proven}; the next command may refine it by some proof method, |
547 |
and enter a sub-proof to establish the actual result. |
|
10858 | 548 |
\item [$proof(state)$] is like a nested theory mode: the context may be |
7987 | 549 |
augmented by \emph{stating} additional assumptions, intermediate results |
550 |
etc. |
|
7895 | 551 |
\item [$proof(chain)$] is intermediate between $proof(state)$ and |
7987 | 552 |
$proof(prove)$: existing facts (i.e.\ the contents of the special ``$this$'' |
553 |
register) have been just picked up in order to be used when refining the |
|
554 |
goal claimed next. |
|
7167 | 555 |
\end{descr} |
7134 | 556 |
|
7167 | 557 |
|
7895 | 558 |
\subsection{Proof markup commands}\label{sec:markup-prf} |
7167 | 559 |
|
7987 | 560 |
\indexisarcmd{sect}\indexisarcmd{subsect}\indexisarcmd{subsubsect} |
7895 | 561 |
\indexisarcmd{txt}\indexisarcmd{txt-raw} |
7134 | 562 |
\begin{matharray}{rcl} |
8101 | 563 |
\isarcmd{sect} & : & \isartrans{proof}{proof} \\ |
564 |
\isarcmd{subsect} & : & \isartrans{proof}{proof} \\ |
|
565 |
\isarcmd{subsubsect} & : & \isartrans{proof}{proof} \\ |
|
566 |
\isarcmd{txt} & : & \isartrans{proof}{proof} \\ |
|
567 |
\isarcmd{txt_raw} & : & \isartrans{proof}{proof} \\ |
|
7134 | 568 |
\end{matharray} |
569 |
||
7895 | 570 |
These markup commands for proof mode closely correspond to the ones of theory |
8684 | 571 |
mode (see \S\ref{sec:markup-thy}). |
7895 | 572 |
|
573 |
\railalias{txtraw}{txt\_raw} |
|
574 |
\railterm{txtraw} |
|
7175 | 575 |
|
7134 | 576 |
\begin{rail} |
7895 | 577 |
('sect' | 'subsect' | 'subsubsect' | 'txt' | txtraw) text |
7134 | 578 |
; |
579 |
\end{rail} |
|
580 |
||
581 |
||
7315 | 582 |
\subsection{Proof context}\label{sec:proof-context} |
7134 | 583 |
|
7315 | 584 |
\indexisarcmd{fix}\indexisarcmd{assume}\indexisarcmd{presume}\indexisarcmd{def} |
7134 | 585 |
\begin{matharray}{rcl} |
586 |
\isarcmd{fix} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
587 |
\isarcmd{assume} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
588 |
\isarcmd{presume} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
589 |
\isarcmd{def} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
590 |
\end{matharray} |
|
591 |
||
7315 | 592 |
The logical proof context consists of fixed variables and assumptions. The |
593 |
former closely correspond to Skolem constants, or meta-level universal |
|
594 |
quantification as provided by the Isabelle/Pure logical framework. |
|
595 |
Introducing some \emph{arbitrary, but fixed} variable via $\FIX x$ results in |
|
7987 | 596 |
a local value that may be used in the subsequent proof as any other variable |
7895 | 597 |
or constant. Furthermore, any result $\edrv \phi[x]$ exported from the |
7987 | 598 |
context will be universally closed wrt.\ $x$ at the outermost level: $\edrv |
599 |
\All x \phi$ (this is expressed using Isabelle's meta-variables). |
|
7315 | 600 |
|
601 |
Similarly, introducing some assumption $\chi$ has two effects. On the one |
|
602 |
hand, a local theorem is created that may be used as a fact in subsequent |
|
7895 | 603 |
proof steps. On the other hand, any result $\chi \drv \phi$ exported from the |
604 |
context becomes conditional wrt.\ the assumption: $\edrv \chi \Imp \phi$. |
|
605 |
Thus, solving an enclosing goal using such a result would basically introduce |
|
606 |
a new subgoal stemming from the assumption. How this situation is handled |
|
607 |
depends on the actual version of assumption command used: while $\ASSUMENAME$ |
|
608 |
insists on solving the subgoal by unification with some premise of the goal, |
|
609 |
$\PRESUMENAME$ leaves the subgoal unchanged in order to be proved later by the |
|
610 |
user. |
|
7315 | 611 |
|
7319 | 612 |
Local definitions, introduced by $\DEF{}{x \equiv t}$, are achieved by |
7987 | 613 |
combining $\FIX x$ with another version of assumption that causes any |
614 |
hypothetical equation $x \equiv t$ to be eliminated by the reflexivity rule. |
|
615 |
Thus, exporting some result $x \equiv t \drv \phi[x]$ yields $\edrv \phi[t]$. |
|
7175 | 616 |
|
10686 | 617 |
\railalias{equiv}{\isasymequiv} |
618 |
\railterm{equiv} |
|
619 |
||
7134 | 620 |
\begin{rail} |
7431 | 621 |
'fix' (vars + 'and') comment? |
7134 | 622 |
; |
7315 | 623 |
('assume' | 'presume') (assm comment? + 'and') |
7134 | 624 |
; |
10686 | 625 |
'def' thmdecl? \\ name ('==' | equiv) term termpat? comment? |
7134 | 626 |
; |
627 |
||
628 |
var: name ('::' type)? |
|
629 |
; |
|
7458 | 630 |
vars: (name+) ('::' type)? |
7431 | 631 |
; |
7315 | 632 |
assm: thmdecl? (prop proppat? +) |
633 |
; |
|
7134 | 634 |
\end{rail} |
635 |
||
7167 | 636 |
\begin{descr} |
8547 | 637 |
\item [$\FIX{\vec x}$] introduces local \emph{arbitrary, but fixed} variables |
638 |
$\vec x$. |
|
8515 | 639 |
\item [$\ASSUME{a}{\vec\phi}$ and $\PRESUME{a}{\vec\phi}$] introduce local |
640 |
theorems $\vec\phi$ by assumption. Subsequent results applied to an |
|
641 |
enclosing goal (e.g.\ by $\SHOWNAME$) are handled as follows: $\ASSUMENAME$ |
|
642 |
expects to be able to unify with existing premises in the goal, while |
|
643 |
$\PRESUMENAME$ leaves $\vec\phi$ as new subgoals. |
|
7335 | 644 |
|
645 |
Several lists of assumptions may be given (separated by |
|
7895 | 646 |
$\isarkeyword{and}$); the resulting list of current facts consists of all of |
647 |
these concatenated. |
|
7315 | 648 |
\item [$\DEF{a}{x \equiv t}$] introduces a local (non-polymorphic) definition. |
649 |
In results exported from the context, $x$ is replaced by $t$. Basically, |
|
7987 | 650 |
$\DEF{}{x \equiv t}$ abbreviates $\FIX{x}~\ASSUME{}{x \equiv t}$, with the |
7335 | 651 |
resulting hypothetical equation solved by reflexivity. |
7431 | 652 |
|
653 |
The default name for the definitional equation is $x_def$. |
|
7167 | 654 |
\end{descr} |
655 |
||
7895 | 656 |
The special name $prems$\indexisarthm{prems} refers to all assumptions of the |
657 |
current context as a list of theorems. |
|
7315 | 658 |
|
7167 | 659 |
|
660 |
\subsection{Facts and forward chaining} |
|
661 |
||
662 |
\indexisarcmd{note}\indexisarcmd{then}\indexisarcmd{from}\indexisarcmd{with} |
|
663 |
\begin{matharray}{rcl} |
|
664 |
\isarcmd{note} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
665 |
\isarcmd{then} & : & \isartrans{proof(state)}{proof(chain)} \\ |
|
666 |
\isarcmd{from} & : & \isartrans{proof(state)}{proof(chain)} \\ |
|
667 |
\isarcmd{with} & : & \isartrans{proof(state)}{proof(chain)} \\ |
|
668 |
\end{matharray} |
|
669 |
||
7319 | 670 |
New facts are established either by assumption or proof of local statements. |
7335 | 671 |
Any fact will usually be involved in further proofs, either as explicit |
8547 | 672 |
arguments of proof methods, or when forward chaining towards the next goal via |
7335 | 673 |
$\THEN$ (and variants). Note that the special theorem name |
7987 | 674 |
$this$\indexisarthm{this} refers to the most recently established facts. |
7167 | 675 |
\begin{rail} |
9199 | 676 |
'note' (thmdef? thmrefs comment? + 'and') |
7167 | 677 |
; |
678 |
'then' comment? |
|
679 |
; |
|
9199 | 680 |
('from' | 'with') (thmrefs comment? + 'and') |
7167 | 681 |
; |
682 |
\end{rail} |
|
683 |
||
684 |
\begin{descr} |
|
7175 | 685 |
\item [$\NOTE{a}{\vec b}$] recalls existing facts $\vec b$, binding the result |
686 |
as $a$. Note that attributes may be involved as well, both on the left and |
|
687 |
right hand sides. |
|
7167 | 688 |
\item [$\THEN$] indicates forward chaining by the current facts in order to |
7895 | 689 |
establish the goal to be claimed next. The initial proof method invoked to |
690 |
refine that will be offered the facts to do ``anything appropriate'' (cf.\ |
|
691 |
also \S\ref{sec:proof-steps}). For example, method $rule$ (see |
|
8515 | 692 |
\S\ref{sec:pure-meth-att}) would typically do an elimination rather than an |
7895 | 693 |
introduction. Automatic methods usually insert the facts into the goal |
8547 | 694 |
state before operation. This provides a simple scheme to control relevance |
695 |
of facts in automated proof search. |
|
7335 | 696 |
\item [$\FROM{\vec b}$] abbreviates $\NOTE{}{\vec b}~\THEN$; thus $\THEN$ is |
7458 | 697 |
equivalent to $\FROM{this}$. |
10858 | 698 |
\item [$\WITH{\vec b}$] abbreviates $\FROM{\vec b~this}$; thus the forward |
7175 | 699 |
chaining is from earlier facts together with the current ones. |
7167 | 700 |
\end{descr} |
701 |
||
8515 | 702 |
Basic proof methods (such as $rule$, see \S\ref{sec:pure-meth-att}) expect |
7895 | 703 |
multiple facts to be given in their proper order, corresponding to a prefix of |
704 |
the premises of the rule involved. Note that positions may be easily skipped |
|
9695 | 705 |
using something like $\FROM{\Text{\texttt{_}}~a~b}$, for example. This |
8547 | 706 |
involves the trivial rule $\PROP\psi \Imp \PROP\psi$, which happens to be |
707 |
bound in Isabelle/Pure as ``\texttt{_}'' |
|
708 |
(underscore).\indexisarthm{_@\texttt{_}} |
|
7389 | 709 |
|
9238 | 710 |
Forward chaining with an empty list of theorems is the same as not chaining. |
711 |
Thus $\FROM{nothing}$ has no effect apart from entering $prove(chain)$ mode, |
|
712 |
since $nothing$\indexisarthm{nothing} is bound to the empty list of facts. |
|
713 |
||
7167 | 714 |
|
715 |
\subsection{Goal statements} |
|
716 |
||
717 |
\indexisarcmd{theorem}\indexisarcmd{lemma} |
|
718 |
\indexisarcmd{have}\indexisarcmd{show}\indexisarcmd{hence}\indexisarcmd{thus} |
|
719 |
\begin{matharray}{rcl} |
|
720 |
\isarcmd{theorem} & : & \isartrans{theory}{proof(prove)} \\ |
|
721 |
\isarcmd{lemma} & : & \isartrans{theory}{proof(prove)} \\ |
|
7987 | 722 |
\isarcmd{have} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\ |
723 |
\isarcmd{show} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\ |
|
7167 | 724 |
\isarcmd{hence} & : & \isartrans{proof(state)}{proof(prove)} \\ |
725 |
\isarcmd{thus} & : & \isartrans{proof(state)}{proof(prove)} \\ |
|
726 |
\end{matharray} |
|
727 |
||
7175 | 728 |
Proof mode is entered from theory mode by initial goal commands $\THEOREMNAME$ |
7895 | 729 |
and $\LEMMANAME$. New local goals may be claimed within proof mode as well. |
730 |
Four variants are available, indicating whether the result is meant to solve |
|
8547 | 731 |
some pending goal or whether forward chaining is indicated. |
7175 | 732 |
|
7167 | 733 |
\begin{rail} |
734 |
('theorem' | 'lemma') goal |
|
735 |
; |
|
736 |
('have' | 'show' | 'hence' | 'thus') goal |
|
737 |
; |
|
738 |
||
8632 | 739 |
goal: thmdecl? prop proppat? comment? |
7167 | 740 |
; |
741 |
\end{rail} |
|
742 |
||
743 |
\begin{descr} |
|
7335 | 744 |
\item [$\THEOREM{a}{\phi}$] enters proof mode with $\phi$ as main goal, |
8547 | 745 |
eventually resulting in some theorem $\turn \phi$ to be put back into the |
746 |
theory. |
|
7987 | 747 |
\item [$\LEMMA{a}{\phi}$] is similar to $\THEOREMNAME$, but tags the result as |
7167 | 748 |
``lemma''. |
7335 | 749 |
\item [$\HAVE{a}{\phi}$] claims a local goal, eventually resulting in a |
7167 | 750 |
theorem with the current assumption context as hypotheses. |
7335 | 751 |
\item [$\SHOW{a}{\phi}$] is similar to $\HAVE{a}{\phi}$, but solves some |
7895 | 752 |
pending goal with the result \emph{exported} into the corresponding context |
753 |
(cf.\ \S\ref{sec:proof-context}). |
|
754 |
\item [$\HENCENAME$] abbreviates $\THEN~\HAVENAME$, i.e.\ claims a local goal |
|
755 |
to be proven by forward chaining the current facts. Note that $\HENCENAME$ |
|
756 |
is also equivalent to $\FROM{this}~\HAVENAME$. |
|
757 |
\item [$\THUSNAME$] abbreviates $\THEN~\SHOWNAME$. Note that $\THUSNAME$ is |
|
758 |
also equivalent to $\FROM{this}~\SHOWNAME$. |
|
7167 | 759 |
\end{descr} |
760 |
||
10550 | 761 |
Any goal statement causes some term abbreviations (such as $\Var{thesis}$, |
762 |
$\dots$) to be bound automatically, see also \S\ref{sec:term-abbrev}. |
|
763 |
Furthermore, the local context of a (non-atomic) goal is provided via the case |
|
764 |
name $antecedent$\indexisarcase{antecedent}, see also \S\ref{sec:cases}. |
|
765 |
||
766 |
\medskip |
|
767 |
||
768 |
\begin{warn} |
|
769 |
Isabelle/Isar suffers theory-level goal statements to contain \emph{unbound |
|
770 |
schematic variables}, although this does not conform to the aim of |
|
771 |
human-readable proof documents! The main problem with schematic goals is |
|
772 |
that the actual outcome is usually hard to predict, depending on the |
|
773 |
behavior of the actual proof methods applied during the reasoning. Note |
|
774 |
that most semi-automated methods heavily depend on several kinds of implicit |
|
775 |
rule declarations within the current theory context. As this would also |
|
776 |
result in non-compositional checking of sub-proofs, \emph{local goals} are |
|
777 |
not allowed to be schematic at all. |
|
778 |
||
779 |
Nevertheless, schematic goals do have their use in Prolog-style interactive |
|
780 |
synthesis of proven results, usually by stepwise refinement via emulation of |
|
781 |
traditional Isabelle tactic scripts (see also \S\ref{sec:tactic-commands}). |
|
782 |
In any case, users should know what they are doing! |
|
783 |
\end{warn} |
|
8991 | 784 |
|
7167 | 785 |
|
786 |
\subsection{Initial and terminal proof steps}\label{sec:proof-steps} |
|
787 |
||
7175 | 788 |
\indexisarcmd{proof}\indexisarcmd{qed}\indexisarcmd{by} |
789 |
\indexisarcmd{.}\indexisarcmd{..}\indexisarcmd{sorry} |
|
790 |
\begin{matharray}{rcl} |
|
791 |
\isarcmd{proof} & : & \isartrans{proof(prove)}{proof(state)} \\ |
|
792 |
\isarcmd{qed} & : & \isartrans{proof(state)}{proof(state) ~|~ theory} \\ |
|
793 |
\isarcmd{by} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\ |
|
794 |
\isarcmd{.\,.} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\ |
|
795 |
\isarcmd{.} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\ |
|
796 |
\isarcmd{sorry} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\ |
|
797 |
\end{matharray} |
|
798 |
||
8547 | 799 |
Arbitrary goal refinement via tactics is considered harmful. Properly, the |
7335 | 800 |
Isar framework admits proof methods to be invoked in two places only. |
7167 | 801 |
\begin{enumerate} |
7175 | 802 |
\item An \emph{initial} refinement step $\PROOF{m@1}$ reduces a newly stated |
7335 | 803 |
goal to a number of sub-goals that are to be solved later. Facts are passed |
7895 | 804 |
to $m@1$ for forward chaining, if so indicated by $proof(chain)$ mode. |
7167 | 805 |
|
7987 | 806 |
\item A \emph{terminal} conclusion step $\QED{m@2}$ is intended to solve |
807 |
remaining goals. No facts are passed to $m@2$. |
|
7167 | 808 |
\end{enumerate} |
809 |
||
8547 | 810 |
The only other proper way to affect pending goals is by $\SHOWNAME$, which |
811 |
involves an explicit statement of what is to be solved. |
|
7167 | 812 |
|
7175 | 813 |
\medskip |
814 |
||
7167 | 815 |
Also note that initial proof methods should either solve the goal completely, |
7895 | 816 |
or constitute some well-understood reduction to new sub-goals. Arbitrary |
817 |
automatic proof tools that are prone leave a large number of badly structured |
|
818 |
sub-goals are no help in continuing the proof document in any intelligible |
|
7987 | 819 |
way. |
7167 | 820 |
|
7175 | 821 |
\medskip |
822 |
||
8547 | 823 |
Unless given explicitly by the user, the default initial method is ``$rule$'', |
824 |
which applies a single standard elimination or introduction rule according to |
|
825 |
the topmost symbol involved. There is no separate default terminal method. |
|
826 |
Any remaining goals are always solved by assumption in the very last step. |
|
7167 | 827 |
|
828 |
\begin{rail} |
|
829 |
'proof' interest? meth? comment? |
|
830 |
; |
|
831 |
'qed' meth? comment? |
|
832 |
; |
|
833 |
'by' meth meth? comment? |
|
834 |
; |
|
835 |
('.' | '..' | 'sorry') comment? |
|
836 |
; |
|
837 |
||
838 |
meth: method interest? |
|
839 |
; |
|
840 |
\end{rail} |
|
841 |
||
842 |
\begin{descr} |
|
7335 | 843 |
\item [$\PROOF{m@1}$] refines the goal by proof method $m@1$; facts for |
844 |
forward chaining are passed if so indicated by $proof(chain)$ mode. |
|
845 |
\item [$\QED{m@2}$] refines any remaining goals by proof method $m@2$ and |
|
7895 | 846 |
concludes the sub-proof by assumption. If the goal had been $\SHOWNAME$ (or |
847 |
$\THUSNAME$), some pending sub-goal is solved as well by the rule resulting |
|
848 |
from the result \emph{exported} into the enclosing goal context. Thus |
|
849 |
$\QEDNAME$ may fail for two reasons: either $m@2$ fails, or the resulting |
|
850 |
rule does not fit to any pending goal\footnote{This includes any additional |
|
851 |
``strong'' assumptions as introduced by $\ASSUMENAME$.} of the enclosing |
|
852 |
context. Debugging such a situation might involve temporarily changing |
|
853 |
$\SHOWNAME$ into $\HAVENAME$, or weakening the local context by replacing |
|
854 |
some occurrences of $\ASSUMENAME$ by $\PRESUMENAME$. |
|
855 |
\item [$\BYY{m@1}{m@2}$] is a \emph{terminal proof}\index{proof!terminal}; it |
|
7987 | 856 |
abbreviates $\PROOF{m@1}~\QED{m@2}$, with backtracking across both methods, |
857 |
though. Debugging an unsuccessful $\BYY{m@1}{m@2}$ commands might be done |
|
7895 | 858 |
by expanding its definition; in many cases $\PROOF{m@1}$ is already |
7175 | 859 |
sufficient to see what is going wrong. |
7895 | 860 |
\item [``$\DDOT$''] is a \emph{default proof}\index{proof!default}; it |
8515 | 861 |
abbreviates $\BY{rule}$. |
7895 | 862 |
\item [``$\DOT$''] is a \emph{trivial proof}\index{proof!trivial}; it |
8195 | 863 |
abbreviates $\BY{this}$. |
8379 | 864 |
\item [$\SORRY$] is a \emph{fake proof}\index{proof!fake}; provided that the |
865 |
\texttt{quick_and_dirty} flag is enabled, $\SORRY$ pretends to solve the |
|
8515 | 866 |
goal without further ado. Of course, the result would be a fake theorem |
867 |
only, involving some oracle in its internal derivation object (this is |
|
868 |
indicated as ``$[!]$'' in the printed result). The main application of |
|
869 |
$\SORRY$ is to support experimentation and top-down proof development. |
|
870 |
\end{descr} |
|
871 |
||
872 |
||
873 |
\subsection{Fundamental methods and attributes}\label{sec:pure-meth-att} |
|
874 |
||
8547 | 875 |
The following proof methods and attributes refer to basic logical operations |
876 |
of Isar. Further methods and attributes are provided by several generic and |
|
877 |
object-logic specific tools and packages (see chapters \ref{ch:gen-tools} and |
|
878 |
\ref{ch:hol-tools}). |
|
8515 | 879 |
|
880 |
\indexisarmeth{assumption}\indexisarmeth{this}\indexisarmeth{rule}\indexisarmeth{$-$} |
|
9936 | 881 |
\indexisaratt{intro}\indexisaratt{elim}\indexisaratt{dest}\indexisaratt{rule} |
8515 | 882 |
\indexisaratt{OF}\indexisaratt{of} |
883 |
\begin{matharray}{rcl} |
|
884 |
assumption & : & \isarmeth \\ |
|
885 |
this & : & \isarmeth \\ |
|
886 |
rule & : & \isarmeth \\ |
|
887 |
- & : & \isarmeth \\ |
|
888 |
OF & : & \isaratt \\ |
|
889 |
of & : & \isaratt \\ |
|
890 |
intro & : & \isaratt \\ |
|
891 |
elim & : & \isaratt \\ |
|
892 |
dest & : & \isaratt \\ |
|
9936 | 893 |
rule & : & \isaratt \\ |
8515 | 894 |
\end{matharray} |
895 |
||
896 |
\begin{rail} |
|
8547 | 897 |
'rule' thmrefs? |
8515 | 898 |
; |
899 |
'OF' thmrefs |
|
900 |
; |
|
8693 | 901 |
'of' insts ('concl' ':' insts)? |
8515 | 902 |
; |
9936 | 903 |
'rule' 'del' |
904 |
; |
|
8515 | 905 |
\end{rail} |
906 |
||
907 |
\begin{descr} |
|
908 |
\item [$assumption$] solves some goal by a single assumption step. Any facts |
|
909 |
given (${} \le 1$) are guaranteed to participate in the refinement. Recall |
|
910 |
that $\QEDNAME$ (see \S\ref{sec:proof-steps}) already concludes any |
|
911 |
remaining sub-goals by assumption. |
|
912 |
\item [$this$] applies all of the current facts directly as rules. Recall |
|
913 |
that ``$\DOT$'' (dot) abbreviates $\BY{this}$. |
|
8547 | 914 |
\item [$rule~\vec a$] applies some rule given as argument in backward manner; |
8515 | 915 |
facts are used to reduce the rule before applying it to the goal. Thus |
916 |
$rule$ without facts is plain \emph{introduction}, while with facts it |
|
917 |
becomes \emph{elimination}. |
|
918 |
||
8547 | 919 |
When no arguments are given, the $rule$ method tries to pick appropriate |
920 |
rules automatically, as declared in the current context using the $intro$, |
|
921 |
$elim$, $dest$ attributes (see below). This is the default behavior of |
|
922 |
$\PROOFNAME$ and ``$\DDOT$'' (double-dot) steps (see |
|
8515 | 923 |
\S\ref{sec:proof-steps}). |
924 |
\item [``$-$''] does nothing but insert the forward chaining facts as premises |
|
925 |
into the goal. Note that command $\PROOFNAME$ without any method actually |
|
926 |
performs a single reduction step using the $rule$ method; thus a plain |
|
927 |
\emph{do-nothing} proof step would be $\PROOF{-}$ rather than $\PROOFNAME$ |
|
928 |
alone. |
|
8547 | 929 |
\item [$OF~\vec a$] applies some theorem to given rules $\vec a$ (in |
930 |
parallel). This corresponds to the \texttt{MRS} operator in ML |
|
931 |
\cite[\S5]{isabelle-ref}, but note the reversed order. Positions may be |
|
932 |
skipped by including ``$\_$'' (underscore) as argument. |
|
933 |
\item [$of~\vec t$] performs positional instantiation. The terms $\vec t$ are |
|
8515 | 934 |
substituted for any schematic variables occurring in a theorem from left to |
935 |
right; ``\texttt{_}'' (underscore) indicates to skip a position. Arguments |
|
936 |
following a ``$concl\colon$'' specification refer to positions of the |
|
937 |
conclusion of a rule. |
|
938 |
\item [$intro$, $elim$, and $dest$] declare introduction, elimination, and |
|
939 |
destruct rules, respectively. Note that the classical reasoner (see |
|
940 |
\S\ref{sec:classical-basic}) introduces different versions of these |
|
941 |
attributes, and the $rule$ method, too. In object-logics with classical |
|
942 |
reasoning enabled, the latter version should be used all the time to avoid |
|
943 |
confusion! |
|
9936 | 944 |
\item [$rule~del$] undeclares introduction, elimination, or destruct rules. |
7315 | 945 |
\end{descr} |
946 |
||
947 |
||
948 |
\subsection{Term abbreviations}\label{sec:term-abbrev} |
|
949 |
||
950 |
\indexisarcmd{let} |
|
951 |
\begin{matharray}{rcl} |
|
952 |
\isarcmd{let} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
953 |
\isarkeyword{is} & : & syntax \\ |
|
954 |
\end{matharray} |
|
955 |
||
956 |
Abbreviations may be either bound by explicit $\LET{p \equiv t}$ statements, |
|
7987 | 957 |
or by annotating assumptions or goal statements with a list of patterns |
958 |
$\ISS{p@1\;\dots}{p@n}$. In both cases, higher-order matching is invoked to |
|
959 |
bind extra-logical term variables, which may be either named schematic |
|
960 |
variables of the form $\Var{x}$, or nameless dummies ``\texttt{_}'' |
|
961 |
(underscore).\indexisarvar{_@\texttt{_}} Note that in the $\LETNAME$ form the |
|
962 |
patterns occur on the left-hand side, while the $\ISNAME$ patterns are in |
|
963 |
postfix position. |
|
7315 | 964 |
|
8620
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
965 |
Polymorphism of term bindings is handled in Hindley-Milner style, as in ML. |
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
966 |
Type variables referring to local assumptions or open goal statements are |
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
967 |
\emph{fixed}, while those of finished results or bound by $\LETNAME$ may occur |
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
968 |
in \emph{arbitrary} instances later. Even though actual polymorphism should |
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
969 |
be rarely used in practice, this mechanism is essential to achieve proper |
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
970 |
incremental type-inference, as the user proceeds to build up the Isar proof |
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
971 |
text. |
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
972 |
|
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
973 |
\medskip |
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
974 |
|
7319 | 975 |
Term abbreviations are quite different from actual local definitions as |
976 |
introduced via $\DEFNAME$ (see \S\ref{sec:proof-context}). The latter are |
|
7315 | 977 |
visible within the logic as actual equations, while abbreviations disappear |
8620
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
978 |
during the input process just after type checking. Also note that $\DEFNAME$ |
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
979 |
does not support polymorphism. |
7315 | 980 |
|
981 |
\begin{rail} |
|
8664 | 982 |
'let' ((term + 'and') '=' term comment? + 'and') |
7315 | 983 |
; |
984 |
\end{rail} |
|
985 |
||
986 |
The syntax of $\ISNAME$ patterns follows \railnonterm{termpat} or |
|
987 |
\railnonterm{proppat} (see \S\ref{sec:term-pats}). |
|
988 |
||
989 |
\begin{descr} |
|
990 |
\item [$\LET{\vec p = \vec t}$] binds any text variables in patters $\vec p$ |
|
991 |
by simultaneous higher-order matching against terms $\vec t$. |
|
992 |
\item [$\IS{\vec p}$] resembles $\LETNAME$, but matches $\vec p$ against the |
|
993 |
preceding statement. Also note that $\ISNAME$ is not a separate command, |
|
994 |
but part of others (such as $\ASSUMENAME$, $\HAVENAME$ etc.). |
|
995 |
\end{descr} |
|
996 |
||
10160 | 997 |
Some \emph{automatic} term abbreviations\index{term abbreviations} for goals |
7988 | 998 |
and facts are available as well. For any open goal, |
10160 | 999 |
$\Var{thesis}$\indexisarvar{thesis} refers to its object-level statement, |
1000 |
abstracted over any meta-level parameters (if present). Likewise, |
|
1001 |
$\Var{this}$\indexisarvar{this} is bound for fact statements resulting from |
|
1002 |
assumptions or finished goals. In case $\Var{this}$ refers to an object-logic |
|
1003 |
statement that is an application $f(t)$, then $t$ is bound to the special text |
|
1004 |
variable ``$\dots$''\indexisarvar{\dots} (three dots). The canonical |
|
1005 |
application of the latter are calculational proofs (see |
|
1006 |
\S\ref{sec:calculation}). |
|
1007 |
||
1008 |
%FIXME !? |
|
7315 | 1009 |
|
10160 | 1010 |
% A few \emph{automatic} term abbreviations\index{term abbreviations} for goals |
1011 |
% and facts are available as well. For any open goal, |
|
1012 |
% $\Var{thesis_prop}$\indexisarvar{thesis-prop} refers to the full proposition |
|
1013 |
% (which may be a rule), $\Var{thesis_concl}$\indexisarvar{thesis-concl} to its |
|
1014 |
% (atomic) conclusion, and $\Var{thesis}$\indexisarvar{thesis} to its |
|
1015 |
% object-level statement. The latter two abstract over any meta-level |
|
1016 |
% parameters. |
|
1017 |
||
1018 |
% Fact statements resulting from assumptions or finished goals are bound as |
|
1019 |
% $\Var{this_prop}$\indexisarvar{this-prop}, |
|
1020 |
% $\Var{this_concl}$\indexisarvar{this-concl}, and |
|
1021 |
% $\Var{this}$\indexisarvar{this}, similar to $\Var{thesis}$ above. In case |
|
1022 |
% $\Var{this}$ refers to an object-logic statement that is an application |
|
1023 |
% $f(t)$, then $t$ is bound to the special text variable |
|
1024 |
% ``$\dots$''\indexisarvar{\dots} (three dots). The canonical application of |
|
1025 |
% the latter are calculational proofs (see \S\ref{sec:calculation}). |
|
7315 | 1026 |
|
1027 |
||
7134 | 1028 |
\subsection{Block structure} |
1029 |
||
8896 | 1030 |
\indexisarcmd{next}\indexisarcmd{\{}\indexisarcmd{\}} |
7397 | 1031 |
\begin{matharray}{rcl} |
8448 | 1032 |
\NEXT & : & \isartrans{proof(state)}{proof(state)} \\ |
7974 | 1033 |
\BG & : & \isartrans{proof(state)}{proof(state)} \\ |
1034 |
\EN & : & \isartrans{proof(state)}{proof(state)} \\ |
|
7397 | 1035 |
\end{matharray} |
1036 |
||
9030 | 1037 |
\railalias{lbrace}{\ttlbrace} |
1038 |
\railterm{lbrace} |
|
1039 |
||
1040 |
\railalias{rbrace}{\ttrbrace} |
|
1041 |
\railterm{rbrace} |
|
1042 |
||
1043 |
\begin{rail} |
|
1044 |
'next' comment? |
|
1045 |
; |
|
1046 |
lbrace comment? |
|
1047 |
; |
|
1048 |
rbrace comment? |
|
1049 |
; |
|
1050 |
\end{rail} |
|
1051 |
||
7167 | 1052 |
While Isar is inherently block-structured, opening and closing blocks is |
1053 |
mostly handled rather casually, with little explicit user-intervention. Any |
|
1054 |
local goal statement automatically opens \emph{two} blocks, which are closed |
|
1055 |
again when concluding the sub-proof (by $\QEDNAME$ etc.). Sections of |
|
8448 | 1056 |
different context within a sub-proof may be switched via $\NEXT$, which is |
1057 |
just a single block-close followed by block-open again. Thus the effect of |
|
1058 |
$\NEXT$ to reset the local proof context. There is no goal focus involved |
|
1059 |
here! |
|
7167 | 1060 |
|
7175 | 1061 |
For slightly more advanced applications, there are explicit block parentheses |
7895 | 1062 |
as well. These typically achieve a stronger forward style of reasoning. |
7167 | 1063 |
|
1064 |
\begin{descr} |
|
8448 | 1065 |
\item [$\NEXT$] switches to a fresh block within a sub-proof, resetting the |
1066 |
local context to the initial one. |
|
8896 | 1067 |
\item [$\BG$ and $\EN$] explicitly open and close blocks. Any current facts |
1068 |
pass through ``$\BG$'' unchanged, while ``$\EN$'' causes any result to be |
|
7895 | 1069 |
\emph{exported} into the enclosing context. Thus fixed variables are |
1070 |
generalized, assumptions discharged, and local definitions unfolded (cf.\ |
|
1071 |
\S\ref{sec:proof-context}). There is no difference of $\ASSUMENAME$ and |
|
1072 |
$\PRESUMENAME$ in this mode of forward reasoning --- in contrast to plain |
|
1073 |
backward reasoning with the result exported at $\SHOWNAME$ time. |
|
7167 | 1074 |
\end{descr} |
7134 | 1075 |
|
1076 |
||
9605 | 1077 |
\subsection{Emulating tactic scripts}\label{sec:tactic-commands} |
8515 | 1078 |
|
9605 | 1079 |
The Isar provides separate commands to accommodate tactic-style proof scripts |
1080 |
within the same system. While being outside the orthodox Isar proof language, |
|
1081 |
these might come in handy for interactive exploration and debugging, or even |
|
1082 |
actual tactical proof within new-style theories (to benefit from document |
|
1083 |
preparation, for example). See also \S\ref{sec:tactics} for actual tactics, |
|
1084 |
that have been encapsulated as proof methods. Proper proof methods may be |
|
1085 |
used in scripts, too. |
|
8515 | 1086 |
|
9605 | 1087 |
\indexisarcmd{apply}\indexisarcmd{apply-end}\indexisarcmd{done} |
8515 | 1088 |
\indexisarcmd{defer}\indexisarcmd{prefer}\indexisarcmd{back} |
9605 | 1089 |
\indexisarcmd{declare} |
8515 | 1090 |
\begin{matharray}{rcl} |
8533 | 1091 |
\isarcmd{apply}^* & : & \isartrans{proof(prove)}{proof(prove)} \\ |
9605 | 1092 |
\isarcmd{apply_end}^* & : & \isartrans{proof(state)}{proof(state)} \\ |
8946 | 1093 |
\isarcmd{done}^* & : & \isartrans{proof(prove)}{proof(state)} \\ |
8533 | 1094 |
\isarcmd{defer}^* & : & \isartrans{proof}{proof} \\ |
1095 |
\isarcmd{prefer}^* & : & \isartrans{proof}{proof} \\ |
|
1096 |
\isarcmd{back}^* & : & \isartrans{proof}{proof} \\ |
|
9605 | 1097 |
\isarcmd{declare}^* & : & \isartrans{theory}{theory} \\ |
8515 | 1098 |
\end{matharray} |
1099 |
||
1100 |
\railalias{applyend}{apply\_end} |
|
1101 |
\railterm{applyend} |
|
1102 |
||
1103 |
\begin{rail} |
|
9605 | 1104 |
( 'apply' | applyend ) method comment? |
8515 | 1105 |
; |
8946 | 1106 |
'done' comment? |
1107 |
; |
|
8682 | 1108 |
'defer' nat? comment? |
8515 | 1109 |
; |
8682 | 1110 |
'prefer' nat comment? |
8515 | 1111 |
; |
9273 | 1112 |
'back' comment? |
1113 |
; |
|
9605 | 1114 |
'declare' thmrefs comment? |
1115 |
; |
|
8515 | 1116 |
\end{rail} |
1117 |
||
1118 |
\begin{descr} |
|
10223 | 1119 |
\item [$\APPLY{m}$] applies proof method $m$ in initial position, but unlike |
1120 |
$\PROOFNAME$ it retains ``$proof(prove)$'' mode. Thus consecutive method |
|
1121 |
applications may be given just as in tactic scripts. |
|
8515 | 1122 |
|
8881 | 1123 |
Facts are passed to $m$ as indicated by the goal's forward-chain mode, and |
10223 | 1124 |
are \emph{consumed} afterwards. Thus any further $\APPLYNAME$ command would |
1125 |
always work in a purely backward manner. |
|
8946 | 1126 |
|
8515 | 1127 |
\item [$\isarkeyword{apply_end}~(m)$] applies proof method $m$ as if in |
1128 |
terminal position. Basically, this simulates a multi-step tactic script for |
|
1129 |
$\QEDNAME$, but may be given anywhere within the proof body. |
|
1130 |
||
1131 |
No facts are passed to $m$. Furthermore, the static context is that of the |
|
1132 |
enclosing goal (as for actual $\QEDNAME$). Thus the proof method may not |
|
1133 |
refer to any assumptions introduced in the current body, for example. |
|
9605 | 1134 |
|
1135 |
\item [$\isarkeyword{done}$] completes a proof script, provided that the |
|
1136 |
current goal state is already solved completely. Note that actual |
|
1137 |
structured proof commands (e.g.\ ``$\DOT$'' or $\SORRY$) may be used to |
|
1138 |
conclude proof scripts as well. |
|
1139 |
||
8515 | 1140 |
\item [$\isarkeyword{defer}~n$ and $\isarkeyword{prefer}~n$] shuffle the list |
1141 |
of pending goals: $defer$ puts off goal $n$ to the end of the list ($n = 1$ |
|
1142 |
by default), while $prefer$ brings goal $n$ to the top. |
|
9605 | 1143 |
|
8515 | 1144 |
\item [$\isarkeyword{back}$] does back-tracking over the result sequence of |
1145 |
the latest proof command.\footnote{Unlike the ML function \texttt{back} |
|
1146 |
\cite{isabelle-ref}, the Isar command does not search upwards for further |
|
1147 |
branch points.} Basically, any proof command may return multiple results. |
|
9605 | 1148 |
|
1149 |
\item [$\isarkeyword{declare}~thms$] declares theorems to the current theory |
|
1150 |
context. No theorem binding is involved here, unlike |
|
1151 |
$\isarkeyword{theorems}$ or $\isarkeyword{lemmas}$ (cf.\ |
|
1152 |
\S\ref{sec:axms-thms}). So $\isarkeyword{declare}$ only has the effect of |
|
1153 |
applying attributes as included in the theorem specification. |
|
9006 | 1154 |
\end{descr} |
1155 |
||
1156 |
Any proper Isar proof method may be used with tactic script commands such as |
|
10223 | 1157 |
$\APPLYNAME$. A few additional emulations of actual tactics are provided as |
1158 |
well; these would be never used in actual structured proofs, of course. |
|
9006 | 1159 |
|
8515 | 1160 |
|
1161 |
\subsection{Meta-linguistic features} |
|
1162 |
||
1163 |
\indexisarcmd{oops} |
|
1164 |
\begin{matharray}{rcl} |
|
1165 |
\isarcmd{oops} & : & \isartrans{proof}{theory} \\ |
|
1166 |
\end{matharray} |
|
1167 |
||
1168 |
The $\OOPS$ command discontinues the current proof attempt, while considering |
|
1169 |
the partial proof text as properly processed. This is conceptually quite |
|
1170 |
different from ``faking'' actual proofs via $\SORRY$ (see |
|
1171 |
\S\ref{sec:proof-steps}): $\OOPS$ does not observe the proof structure at all, |
|
1172 |
but goes back right to the theory level. Furthermore, $\OOPS$ does not |
|
1173 |
produce any result theorem --- there is no claim to be able to complete the |
|
1174 |
proof anyhow. |
|
1175 |
||
1176 |
A typical application of $\OOPS$ is to explain Isar proofs \emph{within} the |
|
1177 |
system itself, in conjunction with the document preparation tools of Isabelle |
|
1178 |
described in \cite{isabelle-sys}. Thus partial or even wrong proof attempts |
|
1179 |
can be discussed in a logically sound manner. Note that the Isabelle {\LaTeX} |
|
1180 |
macros can be easily adapted to print something like ``$\dots$'' instead of an |
|
1181 |
``$\OOPS$'' keyword. |
|
1182 |
||
8547 | 1183 |
\medskip The $\OOPS$ command is undoable, unlike $\isarkeyword{kill}$ (see |
1184 |
\S\ref{sec:history}). The effect is to get back to the theory \emph{before} |
|
1185 |
the opening of the proof. |
|
8515 | 1186 |
|
1187 |
||
7134 | 1188 |
\section{Other commands} |
1189 |
||
9605 | 1190 |
\subsection{Diagnostics} |
7134 | 1191 |
|
10858 | 1192 |
\indexisarcmd{pr}\indexisarcmd{thm}\indexisarcmd{term} |
1193 |
\indexisarcmd{prop}\indexisarcmd{typ} |
|
7134 | 1194 |
\begin{matharray}{rcl} |
8515 | 1195 |
\isarcmd{pr}^* & : & \isarkeep{\cdot} \\ |
1196 |
\isarcmd{thm}^* & : & \isarkeep{theory~|~proof} \\ |
|
1197 |
\isarcmd{term}^* & : & \isarkeep{theory~|~proof} \\ |
|
1198 |
\isarcmd{prop}^* & : & \isarkeep{theory~|~proof} \\ |
|
1199 |
\isarcmd{typ}^* & : & \isarkeep{theory~|~proof} \\ |
|
7134 | 1200 |
\end{matharray} |
1201 |
||
9605 | 1202 |
These diagnostic commands assist interactive development. Note that $undo$ |
1203 |
does not apply here, the theory or proof configuration is not changed. |
|
7335 | 1204 |
|
7134 | 1205 |
\begin{rail} |
9727 | 1206 |
'pr' modes? nat? (',' nat)? |
7134 | 1207 |
; |
10584 | 1208 |
'thm' modes? thmrefs comment? |
8485 | 1209 |
; |
10584 | 1210 |
'term' modes? term comment? |
7134 | 1211 |
; |
10584 | 1212 |
'prop' modes? prop comment? |
7134 | 1213 |
; |
10584 | 1214 |
'typ' modes? type comment? |
8485 | 1215 |
; |
1216 |
||
1217 |
modes: '(' (name + ) ')' |
|
7134 | 1218 |
; |
1219 |
\end{rail} |
|
1220 |
||
7167 | 1221 |
\begin{descr} |
9727 | 1222 |
\item [$\isarkeyword{pr}~goals, prems$] prints the current proof state (if |
1223 |
present), including the proof context, current facts and goals. The |
|
1224 |
optional limit arguments affect the number of goals and premises to be |
|
1225 |
displayed, which is initially 10 for both. Omitting limit values leaves the |
|
1226 |
current setting unchanged. |
|
8547 | 1227 |
\item [$\isarkeyword{thm}~\vec a$] retrieves theorems from the current theory |
1228 |
or proof context. Note that any attributes included in the theorem |
|
7974 | 1229 |
specifications are applied to a temporary context derived from the current |
8547 | 1230 |
theory or proof; the result is discarded, i.e.\ attributes involved in $\vec |
1231 |
a$ do not have any permanent effect. |
|
9727 | 1232 |
\item [$\isarkeyword{term}~t$ and $\isarkeyword{prop}~\phi$] read, type-check |
1233 |
and print terms or propositions according to the current theory or proof |
|
7895 | 1234 |
context; the inferred type of $t$ is output as well. Note that these |
1235 |
commands are also useful in inspecting the current environment of term |
|
1236 |
abbreviations. |
|
7974 | 1237 |
\item [$\isarkeyword{typ}~\tau$] reads and prints types of the meta-logic |
1238 |
according to the current theory or proof context. |
|
9605 | 1239 |
\end{descr} |
1240 |
||
1241 |
All of the diagnostic commands above admit a list of $modes$ to be specified, |
|
1242 |
which is appended to the current print mode (see also \cite{isabelle-ref}). |
|
1243 |
Thus the output behavior may be modified according particular print mode |
|
1244 |
features. For example, $\isarkeyword{pr}~(latex~xsymbols~symbols)$ would |
|
1245 |
print the current proof state with mathematical symbols and special characters |
|
1246 |
represented in {\LaTeX} source, according to the Isabelle style |
|
1247 |
\cite{isabelle-sys}. |
|
1248 |
||
1249 |
Note that antiquotations (cf.\ \S\ref{sec:antiq}) provide a more systematic |
|
1250 |
way to include formal items into the printed text document. |
|
1251 |
||
1252 |
||
1253 |
\subsection{Inspecting the context} |
|
1254 |
||
1255 |
\indexisarcmd{print-facts}\indexisarcmd{print-binds} |
|
1256 |
\indexisarcmd{print-commands}\indexisarcmd{print-syntax} |
|
1257 |
\indexisarcmd{print-methods}\indexisarcmd{print-attributes} |
|
10858 | 1258 |
\indexisarcmd{thms-containing}\indexisarcmd{thm-deps} |
1259 |
\indexisarcmd{print-theorems} |
|
9605 | 1260 |
\begin{matharray}{rcl} |
1261 |
\isarcmd{print_commands}^* & : & \isarkeep{\cdot} \\ |
|
1262 |
\isarcmd{print_syntax}^* & : & \isarkeep{theory~|~proof} \\ |
|
1263 |
\isarcmd{print_methods}^* & : & \isarkeep{theory~|~proof} \\ |
|
1264 |
\isarcmd{print_attributes}^* & : & \isarkeep{theory~|~proof} \\ |
|
10858 | 1265 |
\isarcmd{print_theorems}^* & : & \isarkeep{theory~|~proof} \\ |
1266 |
\isarcmd{thms_containing}^* & : & \isarkeep{theory~|~proof} \\ |
|
1267 |
\isarcmd{thms_deps}^* & : & \isarkeep{theory~|~proof} \\ |
|
9605 | 1268 |
\isarcmd{print_facts}^* & : & \isarkeep{proof} \\ |
1269 |
\isarcmd{print_binds}^* & : & \isarkeep{proof} \\ |
|
1270 |
\end{matharray} |
|
1271 |
||
10858 | 1272 |
\railalias{thmscontaining}{thms\_containing} |
1273 |
\railterm{thmscontaining} |
|
1274 |
||
1275 |
\railalias{thmdeps}{thm\_deps} |
|
1276 |
\railterm{thmdeps} |
|
1277 |
||
1278 |
\begin{rail} |
|
11017 | 1279 |
thmscontaining (term * ) |
10858 | 1280 |
; |
1281 |
thmdeps thmrefs |
|
1282 |
; |
|
1283 |
\end{rail} |
|
1284 |
||
1285 |
These commands print certain parts of the theory and proof context. Note that |
|
1286 |
there are some further ones available, such as for the set of rules declared |
|
1287 |
for simplifications. |
|
9605 | 1288 |
|
1289 |
\begin{descr} |
|
1290 |
\item [$\isarkeyword{print_commands}$] prints Isabelle's outer theory syntax, |
|
1291 |
including keywords and command. |
|
1292 |
\item [$\isarkeyword{print_syntax}$] prints the inner syntax of types and |
|
1293 |
terms, depending on the current context. The output can be very verbose, |
|
1294 |
including grammar tables and syntax translation rules. See \cite[\S7, |
|
1295 |
\S8]{isabelle-ref} for further information on Isabelle's inner syntax. |
|
10858 | 1296 |
\item [$\isarkeyword{print_methods}$] prints all proof methods available in |
1297 |
the current theory context. |
|
1298 |
\item [$\isarkeyword{print_attributes}$] prints all attributes available in |
|
1299 |
the current theory context. |
|
1300 |
\item [$\isarkeyword{print_theorems}$] prints theorems available in the |
|
1301 |
current theory context. In interactive mode this actually refers to the |
|
1302 |
theorems left by the last transaction; this allows to inspect the result of |
|
1303 |
advanced definitional packages, such as $\isarkeyword{datatype}$. |
|
11017 | 1304 |
\item [$\isarkeyword{thms_containing}~\vec t$] retrieves theorems from the |
1305 |
theory context containing all of the constants occurring in the terms $\vec |
|
1306 |
t$. Note that giving the empty list yields \emph{all} theorems of the |
|
1307 |
current theory. |
|
10858 | 1308 |
\item [$\isarkeyword{thm_deps}~\vec a$] visualizes dependencies of theorems |
1309 |
and lemmas, using Isabelle's graph browser tool (see also |
|
1310 |
\cite{isabelle-sys}). |
|
8379 | 1311 |
\item [$\isarkeyword{print_facts}$] prints any named facts of the current |
1312 |
context, including assumptions and local results. |
|
1313 |
\item [$\isarkeyword{print_binds}$] prints all term abbreviations present in |
|
1314 |
the context. |
|
8485 | 1315 |
\end{descr} |
1316 |
||
1317 |
||
1318 |
\subsection{History commands}\label{sec:history} |
|
1319 |
||
1320 |
\indexisarcmd{undo}\indexisarcmd{redo}\indexisarcmd{kill} |
|
1321 |
\begin{matharray}{rcl} |
|
1322 |
\isarcmd{undo}^{{*}{*}} & : & \isarkeep{\cdot} \\ |
|
1323 |
\isarcmd{redo}^{{*}{*}} & : & \isarkeep{\cdot} \\ |
|
1324 |
\isarcmd{kill}^{{*}{*}} & : & \isarkeep{\cdot} \\ |
|
1325 |
\end{matharray} |
|
1326 |
||
1327 |
The Isabelle/Isar top-level maintains a two-stage history, for theory and |
|
1328 |
proof state transformation. Basically, any command can be undone using |
|
1329 |
$\isarkeyword{undo}$, excluding mere diagnostic elements. Its effect may be |
|
10858 | 1330 |
revoked via $\isarkeyword{redo}$, unless the corresponding |
8485 | 1331 |
$\isarkeyword{undo}$ step has crossed the beginning of a proof or theory. The |
1332 |
$\isarkeyword{kill}$ command aborts the current history node altogether, |
|
1333 |
discontinuing a proof or even the whole theory. This operation is \emph{not} |
|
1334 |
undoable. |
|
1335 |
||
1336 |
\begin{warn} |
|
8547 | 1337 |
History commands should never be used with user interfaces such as |
1338 |
Proof~General \cite{proofgeneral,Aspinall:TACAS:2000}, which takes care of |
|
1339 |
stepping forth and back itself. Interfering by manual $\isarkeyword{undo}$, |
|
8510 | 1340 |
$\isarkeyword{redo}$, or even $\isarkeyword{kill}$ commands would quickly |
1341 |
result in utter confusion. |
|
8485 | 1342 |
\end{warn} |
1343 |
||
8379 | 1344 |
|
7134 | 1345 |
\subsection{System operations} |
1346 |
||
7167 | 1347 |
\indexisarcmd{cd}\indexisarcmd{pwd}\indexisarcmd{use-thy}\indexisarcmd{use-thy-only} |
1348 |
\indexisarcmd{update-thy}\indexisarcmd{update-thy-only} |
|
7134 | 1349 |
\begin{matharray}{rcl} |
8515 | 1350 |
\isarcmd{cd}^* & : & \isarkeep{\cdot} \\ |
1351 |
\isarcmd{pwd}^* & : & \isarkeep{\cdot} \\ |
|
1352 |
\isarcmd{use_thy}^* & : & \isarkeep{\cdot} \\ |
|
1353 |
\isarcmd{use_thy_only}^* & : & \isarkeep{\cdot} \\ |
|
1354 |
\isarcmd{update_thy}^* & : & \isarkeep{\cdot} \\ |
|
1355 |
\isarcmd{update_thy_only}^* & : & \isarkeep{\cdot} \\ |
|
7134 | 1356 |
\end{matharray} |
1357 |
||
7167 | 1358 |
\begin{descr} |
7134 | 1359 |
\item [$\isarkeyword{cd}~name$] changes the current directory of the Isabelle |
1360 |
process. |
|
1361 |
\item [$\isarkeyword{pwd}~$] prints the current working directory. |
|
7175 | 1362 |
\item [$\isarkeyword{use_thy}$, $\isarkeyword{use_thy_only}$, |
7987 | 1363 |
$\isarkeyword{update_thy}$, $\isarkeyword{update_thy_only}$] load some |
7895 | 1364 |
theory given as $name$ argument. These commands are basically the same as |
7987 | 1365 |
the corresponding ML functions\footnote{The ML versions also change the |
1366 |
implicit theory context to that of the theory loaded.} (see also |
|
1367 |
\cite[\S1,\S6]{isabelle-ref}). Note that both the ML and Isar versions may |
|
1368 |
load new- and old-style theories alike. |
|
7167 | 1369 |
\end{descr} |
7134 | 1370 |
|
7987 | 1371 |
These system commands are scarcely used when working with the Proof~General |
1372 |
interface, since loading of theories is done fully transparently. |
|
7134 | 1373 |
|
8379 | 1374 |
|
7046 | 1375 |
%%% Local Variables: |
1376 |
%%% mode: latex |
|
1377 |
%%% TeX-master: "isar-ref" |
|
1378 |
%%% End: |