author | wenzelm |
Sun, 22 May 2005 16:53:11 +0200 | |
changeset 16032 | bbc85a9748fc |
parent 16017 | cb983795bcdf |
child 16074 | 9e569163ba8c |
permissions | -rw-r--r-- |
7046 | 1 |
|
13048 | 2 |
\chapter{Basic language elements}\label{ch:pure-syntax} |
7167 | 3 |
|
13039 | 4 |
Subsequently, we introduce the main part of Pure theory and proof commands, |
5 |
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 |
|
12879 | 8 |
Isabelle or pre-installed in most object logics. Chapter~\ref{ch:logics} |
12621 | 9 |
refers to object-logic specific elements (mainly for HOL and ZF). |
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 |
|
12618 | 16 |
are subsequently marked by ``$^*$'', are often helpful when developing proof |
13039 | 17 |
documents, while their use is discouraged for the final human-readable |
18 |
outcome. Typical examples are diagnostic commands that print terms or |
|
19 |
theorems according to the current context; other commands emulate old-style |
|
20 |
tactical theorem proving. |
|
7167 | 21 |
|
7134 | 22 |
|
12621 | 23 |
\section{Theory commands} |
7134 | 24 |
|
7167 | 25 |
\subsection{Defining theories}\label{sec:begin-thy} |
7134 | 26 |
|
12621 | 27 |
\indexisarcmd{header}\indexisarcmd{theory}\indexisarcmd{context}\indexisarcmd{end} |
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 |
|
12621 | 41 |
The first ``real'' command of any theory has to be $\THEORY$, which starts a |
42 |
new theory based on the merge of existing ones. Just preceding $\THEORY$, |
|
43 |
there may be an optional $\isarkeyword{header}$ declaration, which is relevant |
|
44 |
to document preparation only; it acts very much like a special pre-theory |
|
45 |
markup command (cf.\ \S\ref{sec:markup-thy} and \S\ref{sec:markup-thy}). The |
|
13039 | 46 |
$\END$ command concludes a theory development; it has to be the very last |
47 |
command of any theory file loaded in batch-mode. The theory context may be |
|
12621 | 48 |
also changed interactively by $\CONTEXT$ without creating a new theory. |
7134 | 49 |
|
50 |
\begin{rail} |
|
7895 | 51 |
'header' text |
52 |
; |
|
7134 | 53 |
'theory' name '=' (name + '+') filespecs? ':' |
54 |
; |
|
55 |
'context' name |
|
56 |
; |
|
57 |
||
7167 | 58 |
filespecs: 'files' ((name | parname) +); |
7134 | 59 |
\end{rail} |
60 |
||
7167 | 61 |
\begin{descr} |
7895 | 62 |
\item [$\isarkeyword{header}~text$] provides plain text markup just preceding |
8547 | 63 |
the formal beginning of a theory. In actual document preparation the |
7895 | 64 |
corresponding {\LaTeX} macro \verb,\isamarkupheader, may be redefined to |
65 |
produce chapter or section headings. See also \S\ref{sec:markup-thy} and |
|
66 |
\S\ref{sec:markup-prf} for further markup commands. |
|
67 |
||
12621 | 68 |
\item [$\THEORY~A = B@1 + \cdots + B@n\colon$] starts a new theory $A$ based |
69 |
on the merge of existing theories $B@1, \dots, B@n$. |
|
70 |
||
71 |
Due to inclusion of several ancestors, the overall theory structure emerging |
|
72 |
in an Isabelle session forms a directed acyclic graph (DAG). Isabelle's |
|
73 |
theory loader ensures that the sources contributing to the development graph |
|
74 |
are always up-to-date. Changed files are automatically reloaded when |
|
75 |
processing theory headers interactively; batch-mode explicitly distinguishes |
|
76 |
\verb,update_thy, from \verb,use_thy,, see also \cite{isabelle-ref}. |
|
77 |
||
78 |
The optional $\isarkeyword{files}$ specification declares additional |
|
79 |
dependencies on ML files. Files will be loaded immediately, unless the name |
|
80 |
is put in parentheses, which merely documents the dependency to be resolved |
|
81 |
later in the text (typically via explicit $\isarcmd{use}$ in the body text, |
|
82 |
see \S\ref{sec:ML}). In reminiscence of the old-style theory system of |
|
83 |
Isabelle, \texttt{$A$.thy} may be also accompanied by an additional file |
|
84 |
\texttt{$A$.ML} consisting of ML code that is executed in the context of the |
|
85 |
\emph{finished} theory $A$. That file should not be included in the |
|
86 |
$\isarkeyword{files}$ dependency declaration, though. |
|
7134 | 87 |
|
7895 | 88 |
\item [$\CONTEXT~B$] enters an existing theory context, basically in read-only |
7981 | 89 |
mode, so only a limited set of commands may be performed without destroying |
90 |
the theory. Just as for $\THEORY$, the theory loader ensures that $B$ is |
|
91 |
loaded and up-to-date. |
|
7175 | 92 |
|
12621 | 93 |
This command is occasionally useful for quick interactive experiments; |
94 |
normally one should always commence a new context via $\THEORY$. |
|
95 |
||
7167 | 96 |
\item [$\END$] concludes the current theory definition or context switch. |
12621 | 97 |
Note that this command cannot be undone, but the whole theory definition has |
98 |
to be retracted. |
|
99 |
||
7167 | 100 |
\end{descr} |
7134 | 101 |
|
102 |
||
12621 | 103 |
\subsection{Markup commands}\label{sec:markup-thy} |
7134 | 104 |
|
7895 | 105 |
\indexisarcmd{chapter}\indexisarcmd{section}\indexisarcmd{subsection} |
106 |
\indexisarcmd{subsubsection}\indexisarcmd{text}\indexisarcmd{text-raw} |
|
7134 | 107 |
\begin{matharray}{rcl} |
108 |
\isarcmd{chapter} & : & \isartrans{theory}{theory} \\ |
|
7167 | 109 |
\isarcmd{section} & : & \isartrans{theory}{theory} \\ |
7134 | 110 |
\isarcmd{subsection} & : & \isartrans{theory}{theory} \\ |
111 |
\isarcmd{subsubsection} & : & \isartrans{theory}{theory} \\ |
|
112 |
\isarcmd{text} & : & \isartrans{theory}{theory} \\ |
|
7895 | 113 |
\isarcmd{text_raw} & : & \isartrans{theory}{theory} \\ |
7134 | 114 |
\end{matharray} |
115 |
||
7895 | 116 |
Apart from formal comments (see \S\ref{sec:comments}), markup commands provide |
7981 | 117 |
a structured way to insert text into the document generated from a theory (see |
7895 | 118 |
\cite{isabelle-sys} for more information on Isabelle's document preparation |
119 |
tools). |
|
7134 | 120 |
|
7895 | 121 |
\railalias{textraw}{text\_raw} |
122 |
\railterm{textraw} |
|
7134 | 123 |
|
124 |
\begin{rail} |
|
7895 | 125 |
('chapter' | 'section' | 'subsection' | 'subsubsection' | 'text' | textraw) text |
7134 | 126 |
; |
127 |
\end{rail} |
|
128 |
||
7167 | 129 |
\begin{descr} |
7335 | 130 |
\item [$\isarkeyword{chapter}$, $\isarkeyword{section}$, |
131 |
$\isarkeyword{subsection}$, and $\isarkeyword{subsubsection}$] mark chapter |
|
132 |
and section headings. |
|
7895 | 133 |
\item [$\TEXT$] specifies paragraphs of plain text, including references to |
12618 | 134 |
formal entities (see also \S\ref{sec:antiq} on ``antiquotations''). |
7895 | 135 |
\item [$\isarkeyword{text_raw}$] inserts {\LaTeX} source into the output, |
136 |
without additional markup. Thus the full range of document manipulations |
|
12618 | 137 |
becomes available. |
7167 | 138 |
\end{descr} |
7134 | 139 |
|
8684 | 140 |
Any of these markup elements corresponds to a {\LaTeX} command with the name |
141 |
prefixed by \verb,\isamarkup,. For the sectioning commands this is a plain |
|
142 |
macro with a single argument, e.g.\ \verb,\isamarkupchapter{,\dots\verb,}, for |
|
143 |
$\isarkeyword{chapter}$. The $\isarkeyword{text}$ markup results in a |
|
144 |
{\LaTeX} environment \verb,\begin{isamarkuptext}, {\dots} |
|
145 |
\verb,\end{isamarkuptext},, while $\isarkeyword{text_raw}$ causes the text |
|
146 |
to be inserted directly into the {\LaTeX} source. |
|
7895 | 147 |
|
8485 | 148 |
\medskip |
149 |
||
150 |
Additional markup commands are available for proofs (see |
|
7895 | 151 |
\S\ref{sec:markup-prf}). Also note that the $\isarkeyword{header}$ |
8684 | 152 |
declaration (see \S\ref{sec:begin-thy}) admits to insert section markup just |
153 |
preceding the actual theory definition. |
|
7895 | 154 |
|
7134 | 155 |
|
7135 | 156 |
\subsection{Type classes and sorts}\label{sec:classes} |
7134 | 157 |
|
158 |
\indexisarcmd{classes}\indexisarcmd{classrel}\indexisarcmd{defaultsort} |
|
12621 | 159 |
\begin{matharray}{rcll} |
7134 | 160 |
\isarcmd{classes} & : & \isartrans{theory}{theory} \\ |
12621 | 161 |
\isarcmd{classrel} & : & \isartrans{theory}{theory} & (axiomatic!) \\ |
7134 | 162 |
\isarcmd{defaultsort} & : & \isartrans{theory}{theory} \\ |
163 |
\end{matharray} |
|
164 |
||
165 |
\begin{rail} |
|
12879 | 166 |
'classes' (classdecl +) |
7134 | 167 |
; |
14817 | 168 |
'classrel' (nameref ('<' | subseteq) nameref + 'and') |
7134 | 169 |
; |
12879 | 170 |
'defaultsort' sort |
7134 | 171 |
; |
172 |
\end{rail} |
|
173 |
||
7167 | 174 |
\begin{descr} |
11100
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11017
diff
changeset
|
175 |
\item [$\isarkeyword{classes}~c \subseteq \vec c$] declares class $c$ to be a |
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11017
diff
changeset
|
176 |
subclass of existing classes $\vec c$. Cyclic class structures are ruled |
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11017
diff
changeset
|
177 |
out. |
14817 | 178 |
\item [$\isarkeyword{classrel}~c@1 \subseteq c@2$] states subclass relations |
11100
34d58b1818f4
\<subseteq> syntax for classes/classrel/axclass/instance;
wenzelm
parents:
11017
diff
changeset
|
179 |
between existing classes $c@1$ and $c@2$. This is done axiomatically! The |
10223 | 180 |
$\INSTANCE$ command (see \S\ref{sec:axclass}) provides a way to introduce |
181 |
proven class relations. |
|
7134 | 182 |
\item [$\isarkeyword{defaultsort}~s$] makes sort $s$ the new default sort for |
7895 | 183 |
any type variables given without sort constraints. Usually, the default |
12621 | 184 |
sort would be only changed when defining a new object-logic. |
7167 | 185 |
\end{descr} |
7134 | 186 |
|
187 |
||
7315 | 188 |
\subsection{Primitive types and type abbreviations}\label{sec:types-pure} |
7134 | 189 |
|
190 |
\indexisarcmd{typedecl}\indexisarcmd{types}\indexisarcmd{nonterminals}\indexisarcmd{arities} |
|
12621 | 191 |
\begin{matharray}{rcll} |
7134 | 192 |
\isarcmd{types} & : & \isartrans{theory}{theory} \\ |
193 |
\isarcmd{typedecl} & : & \isartrans{theory}{theory} \\ |
|
194 |
\isarcmd{nonterminals} & : & \isartrans{theory}{theory} \\ |
|
12621 | 195 |
\isarcmd{arities} & : & \isartrans{theory}{theory} & (axiomatic!) \\ |
7134 | 196 |
\end{matharray} |
197 |
||
198 |
\begin{rail} |
|
12879 | 199 |
'types' (typespec '=' type infix? +) |
7134 | 200 |
; |
12879 | 201 |
'typedecl' typespec infix? |
7134 | 202 |
; |
12879 | 203 |
'nonterminals' (name +) |
7134 | 204 |
; |
12879 | 205 |
'arities' (nameref '::' arity +) |
7134 | 206 |
; |
207 |
\end{rail} |
|
208 |
||
7167 | 209 |
\begin{descr} |
13039 | 210 |
|
7335 | 211 |
\item [$\TYPES~(\vec\alpha)t = \tau$] introduces \emph{type synonym} |
7134 | 212 |
$(\vec\alpha)t$ for existing type $\tau$. Unlike actual type definitions, |
213 |
as are available in Isabelle/HOL for example, type synonyms are just purely |
|
7895 | 214 |
syntactic abbreviations without any logical significance. Internally, type |
7981 | 215 |
synonyms are fully expanded. |
13039 | 216 |
|
7134 | 217 |
\item [$\isarkeyword{typedecl}~(\vec\alpha)t$] declares a new type constructor |
13039 | 218 |
$t$, intended as an actual logical type. Note that the Isabelle/HOL |
219 |
object-logic overrides $\isarkeyword{typedecl}$ by its own version |
|
220 |
(\S\ref{sec:hol-typedef}). |
|
221 |
||
7175 | 222 |
\item [$\isarkeyword{nonterminals}~\vec c$] declares $0$-ary type constructors |
223 |
$\vec c$ to act as purely syntactic types, i.e.\ nonterminal symbols of |
|
224 |
Isabelle's inner syntax of terms or types. |
|
13039 | 225 |
|
7335 | 226 |
\item [$\isarkeyword{arities}~t::(\vec s)s$] augments Isabelle's order-sorted |
227 |
signature of types by new type constructor arities. This is done |
|
10223 | 228 |
axiomatically! The $\INSTANCE$ command (see \S\ref{sec:axclass}) provides a |
229 |
way to introduce proven type arities. |
|
13039 | 230 |
|
7167 | 231 |
\end{descr} |
7134 | 232 |
|
233 |
||
7981 | 234 |
\subsection{Constants and simple definitions}\label{sec:consts} |
7134 | 235 |
|
7175 | 236 |
\indexisarcmd{consts}\indexisarcmd{defs}\indexisarcmd{constdefs}\indexoutertoken{constdecl} |
7134 | 237 |
\begin{matharray}{rcl} |
238 |
\isarcmd{consts} & : & \isartrans{theory}{theory} \\ |
|
239 |
\isarcmd{defs} & : & \isartrans{theory}{theory} \\ |
|
240 |
\isarcmd{constdefs} & : & \isartrans{theory}{theory} \\ |
|
241 |
\end{matharray} |
|
242 |
||
243 |
\begin{rail} |
|
14642 | 244 |
'consts' ((name '::' type mixfix?) +) |
245 |
; |
|
246 |
'defs' ('(' 'overloaded' ')')? (axmdecl prop +) |
|
7134 | 247 |
; |
14642 | 248 |
\end{rail} |
249 |
||
250 |
\begin{rail} |
|
251 |
'constdefs' structs? (constdecl? constdef +) |
|
7134 | 252 |
; |
253 |
||
14642 | 254 |
structs: '(' 'structure' (vars + 'and') ')' |
255 |
; |
|
256 |
constdecl: (name '::' type) mixfix | (name '::' type) | name 'where' | mixfix |
|
257 |
; |
|
258 |
constdef: thmdecl? prop |
|
7134 | 259 |
; |
260 |
\end{rail} |
|
261 |
||
7167 | 262 |
\begin{descr} |
7335 | 263 |
\item [$\CONSTS~c::\sigma$] declares constant $c$ to have any instance of type |
264 |
scheme $\sigma$. The optional mixfix annotations may attach concrete syntax |
|
7895 | 265 |
to the constants declared. |
9308 | 266 |
|
7335 | 267 |
\item [$\DEFS~name: eqn$] introduces $eqn$ as a definitional axiom for some |
268 |
existing constant. See \cite[\S6]{isabelle-ref} for more details on the |
|
269 |
form of equations admitted as constant definitions. |
|
9308 | 270 |
|
14642 | 271 |
The $(overloaded)$ option declares definitions to be potentially overloaded. |
9308 | 272 |
Unless this option is given, a warning message would be issued for any |
273 |
definitional equation with a more special type than that of the |
|
274 |
corresponding constant declaration. |
|
12621 | 275 |
|
14642 | 276 |
\item [$\CONSTDEFS$] provides a streamlined combination of constants |
277 |
declarations and definitions: type-inference takes care of the most general |
|
278 |
typing of the given specification (the optional type constraint may refer to |
|
279 |
type-inference dummies ``$_$'' as usual). The resulting type declaration |
|
280 |
needs to agree with that of the specification; overloading is \emph{not} |
|
281 |
supported here! |
|
282 |
||
283 |
The constant name may be omitted altogether, if neither type nor syntax |
|
284 |
declarations are given. The canonical name of the definitional axiom for |
|
285 |
constant $c$ will be $c_def$, unless specified otherwise. Also note that |
|
286 |
the given list of specifications is processed in a strictly sequential |
|
287 |
manner, with type-checking being performed independently. |
|
288 |
||
289 |
An optional initial context of $(structure)$ declarations admits use of |
|
290 |
indexed syntax, using the special symbol \verb,\<index>, (printed as |
|
291 |
``\i''). The latter concept is particularly useful with locales (see also |
|
292 |
\S\ref{sec:locale}). |
|
7167 | 293 |
\end{descr} |
7134 | 294 |
|
295 |
||
7981 | 296 |
\subsection{Syntax and translations}\label{sec:syn-trans} |
7134 | 297 |
|
15744
daa84ebbdf94
Pure: command 'no_syntax' removes grammar declarations;
wenzelm
parents:
15686
diff
changeset
|
298 |
\indexisarcmd{syntax}\indexisarcmd{no-syntax}\indexisarcmd{translations} |
7134 | 299 |
\begin{matharray}{rcl} |
300 |
\isarcmd{syntax} & : & \isartrans{theory}{theory} \\ |
|
15744
daa84ebbdf94
Pure: command 'no_syntax' removes grammar declarations;
wenzelm
parents:
15686
diff
changeset
|
301 |
\isarcmd{no_syntax} & : & \isartrans{theory}{theory} \\ |
7134 | 302 |
\isarcmd{translations} & : & \isartrans{theory}{theory} \\ |
303 |
\end{matharray} |
|
304 |
||
10640 | 305 |
\railalias{rightleftharpoons}{\isasymrightleftharpoons} |
306 |
\railterm{rightleftharpoons} |
|
307 |
||
308 |
\railalias{rightharpoonup}{\isasymrightharpoonup} |
|
309 |
\railterm{rightharpoonup} |
|
310 |
||
311 |
\railalias{leftharpoondown}{\isasymleftharpoondown} |
|
312 |
\railterm{leftharpoondown} |
|
313 |
||
15744
daa84ebbdf94
Pure: command 'no_syntax' removes grammar declarations;
wenzelm
parents:
15686
diff
changeset
|
314 |
\railalias{nosyntax}{no\_syntax} |
daa84ebbdf94
Pure: command 'no_syntax' removes grammar declarations;
wenzelm
parents:
15686
diff
changeset
|
315 |
\railterm{nosyntax} |
daa84ebbdf94
Pure: command 'no_syntax' removes grammar declarations;
wenzelm
parents:
15686
diff
changeset
|
316 |
|
7134 | 317 |
\begin{rail} |
15744
daa84ebbdf94
Pure: command 'no_syntax' removes grammar declarations;
wenzelm
parents:
15686
diff
changeset
|
318 |
('syntax' | nosyntax) mode? (constdecl +) |
7134 | 319 |
; |
12879 | 320 |
'translations' (transpat ('==' | '=>' | '<=' | rightleftharpoons | rightharpoonup | leftharpoondown) transpat +) |
7134 | 321 |
; |
15744
daa84ebbdf94
Pure: command 'no_syntax' removes grammar declarations;
wenzelm
parents:
15686
diff
changeset
|
322 |
|
daa84ebbdf94
Pure: command 'no_syntax' removes grammar declarations;
wenzelm
parents:
15686
diff
changeset
|
323 |
mode: ('(' ( name | 'output' | name 'output' ) ')') |
daa84ebbdf94
Pure: command 'no_syntax' removes grammar declarations;
wenzelm
parents:
15686
diff
changeset
|
324 |
; |
7134 | 325 |
transpat: ('(' nameref ')')? string |
326 |
; |
|
327 |
\end{rail} |
|
328 |
||
7167 | 329 |
\begin{descr} |
13024 | 330 |
|
7175 | 331 |
\item [$\isarkeyword{syntax}~(mode)~decls$] is similar to $\CONSTS~decls$, |
332 |
except that the actual logical signature extension is omitted. Thus the |
|
333 |
context free grammar of Isabelle's inner syntax may be augmented in |
|
7335 | 334 |
arbitrary ways, independently of the logic. The $mode$ argument refers to |
13024 | 335 |
the print mode that the grammar rules belong; unless the |
336 |
$\isarkeyword{output}$ indicator is given, all productions are added both to |
|
337 |
the input and output grammar. |
|
338 |
||
15744
daa84ebbdf94
Pure: command 'no_syntax' removes grammar declarations;
wenzelm
parents:
15686
diff
changeset
|
339 |
\item [$\isarkeyword{no_syntax}~(mode)~decls$] removes grammar declarations |
daa84ebbdf94
Pure: command 'no_syntax' removes grammar declarations;
wenzelm
parents:
15686
diff
changeset
|
340 |
(and translations) resulting from $decls$, which are interpreted in the same |
daa84ebbdf94
Pure: command 'no_syntax' removes grammar declarations;
wenzelm
parents:
15686
diff
changeset
|
341 |
manner as for $\isarkeyword{syntax}$ above. |
daa84ebbdf94
Pure: command 'no_syntax' removes grammar declarations;
wenzelm
parents:
15686
diff
changeset
|
342 |
|
7175 | 343 |
\item [$\isarkeyword{translations}~rules$] specifies syntactic translation |
13024 | 344 |
rules (i.e.\ macros): parse~/ print rules (\isasymrightleftharpoons), parse |
345 |
rules (\isasymrightharpoonup), or print rules (\isasymleftharpoondown). |
|
346 |
Translation patterns may be prefixed by the syntactic category to be used |
|
347 |
for parsing; the default is $logic$. |
|
7167 | 348 |
\end{descr} |
7134 | 349 |
|
350 |
||
9605 | 351 |
\subsection{Axioms and theorems}\label{sec:axms-thms} |
7134 | 352 |
|
12618 | 353 |
\indexisarcmd{axioms}\indexisarcmd{lemmas}\indexisarcmd{theorems} |
12621 | 354 |
\begin{matharray}{rcll} |
355 |
\isarcmd{axioms} & : & \isartrans{theory}{theory} & (axiomatic!) \\ |
|
12618 | 356 |
\isarcmd{lemmas} & : & \isartrans{theory}{theory} \\ |
7134 | 357 |
\isarcmd{theorems} & : & \isartrans{theory}{theory} \\ |
358 |
\end{matharray} |
|
359 |
||
360 |
\begin{rail} |
|
12879 | 361 |
'axioms' (axmdecl prop +) |
7134 | 362 |
; |
12976 | 363 |
('lemmas' | 'theorems') locale? (thmdef? thmrefs + 'and') |
7134 | 364 |
; |
365 |
\end{rail} |
|
366 |
||
7167 | 367 |
\begin{descr} |
12976 | 368 |
|
7335 | 369 |
\item [$\isarkeyword{axioms}~a: \phi$] introduces arbitrary statements as |
7895 | 370 |
axioms of the meta-logic. In fact, axioms are ``axiomatic theorems'', and |
371 |
may be referred later just as any other theorem. |
|
7134 | 372 |
|
373 |
Axioms are usually only introduced when declaring new logical systems. |
|
7175 | 374 |
Everyday work is typically done the hard way, with proper definitions and |
13039 | 375 |
proven theorems. |
12976 | 376 |
|
13024 | 377 |
\item [$\isarkeyword{lemmas}~a = \vec b$] retrieves and stores existing facts |
12976 | 378 |
in the theory context, or the specified locale (see also |
379 |
\S\ref{sec:locale}). Typical applications would also involve attributes, to |
|
380 |
declare Simplifier rules, for example. |
|
381 |
||
12618 | 382 |
\item [$\isarkeyword{theorems}$] is essentially the same as |
383 |
$\isarkeyword{lemmas}$, but marks the result as a different kind of facts. |
|
12976 | 384 |
|
7167 | 385 |
\end{descr} |
7134 | 386 |
|
387 |
||
7167 | 388 |
\subsection{Name spaces} |
7134 | 389 |
|
8726 | 390 |
\indexisarcmd{global}\indexisarcmd{local}\indexisarcmd{hide} |
7134 | 391 |
\begin{matharray}{rcl} |
392 |
\isarcmd{global} & : & \isartrans{theory}{theory} \\ |
|
393 |
\isarcmd{local} & : & \isartrans{theory}{theory} \\ |
|
8726 | 394 |
\isarcmd{hide} & : & \isartrans{theory}{theory} \\ |
7134 | 395 |
\end{matharray} |
396 |
||
8726 | 397 |
\begin{rail} |
12879 | 398 |
'hide' name (nameref + ) |
8726 | 399 |
; |
400 |
\end{rail} |
|
401 |
||
7895 | 402 |
Isabelle organizes any kind of name declarations (of types, constants, |
8547 | 403 |
theorems etc.) by separate hierarchically structured name spaces. Normally |
8726 | 404 |
the user does not have to control the behavior of name spaces by hand, yet the |
405 |
following commands provide some way to do so. |
|
7175 | 406 |
|
7167 | 407 |
\begin{descr} |
408 |
\item [$\isarkeyword{global}$ and $\isarkeyword{local}$] change the current |
|
409 |
name declaration mode. Initially, theories start in $\isarkeyword{local}$ |
|
410 |
mode, causing all names to be automatically qualified by the theory name. |
|
7895 | 411 |
Changing this to $\isarkeyword{global}$ causes all names to be declared |
412 |
without the theory prefix, until $\isarkeyword{local}$ is declared again. |
|
8726 | 413 |
|
414 |
Note that global names are prone to get hidden accidently later, when |
|
415 |
qualified names of the same base name are introduced. |
|
416 |
||
417 |
\item [$\isarkeyword{hide}~space~names$] removes declarations from a given |
|
418 |
name space (which may be $class$, $type$, or $const$). Hidden objects |
|
419 |
remain valid within the logic, but are inaccessible from user input. In |
|
420 |
output, the special qualifier ``$\mathord?\mathord?$'' is prefixed to the |
|
12621 | 421 |
full internal name. Unqualified (global) names may not be hidden. |
7167 | 422 |
\end{descr} |
7134 | 423 |
|
424 |
||
7167 | 425 |
\subsection{Incorporating ML code}\label{sec:ML} |
7134 | 426 |
|
8682 | 427 |
\indexisarcmd{use}\indexisarcmd{ML}\indexisarcmd{ML-command} |
428 |
\indexisarcmd{ML-setup}\indexisarcmd{setup} |
|
9199 | 429 |
\indexisarcmd{method-setup} |
7134 | 430 |
\begin{matharray}{rcl} |
431 |
\isarcmd{use} & : & \isartrans{\cdot}{\cdot} \\ |
|
432 |
\isarcmd{ML} & : & \isartrans{\cdot}{\cdot} \\ |
|
8682 | 433 |
\isarcmd{ML_command} & : & \isartrans{\cdot}{\cdot} \\ |
7895 | 434 |
\isarcmd{ML_setup} & : & \isartrans{theory}{theory} \\ |
7175 | 435 |
\isarcmd{setup} & : & \isartrans{theory}{theory} \\ |
9199 | 436 |
\isarcmd{method_setup} & : & \isartrans{theory}{theory} \\ |
7134 | 437 |
\end{matharray} |
438 |
||
7895 | 439 |
\railalias{MLsetup}{ML\_setup} |
440 |
\railterm{MLsetup} |
|
441 |
||
9199 | 442 |
\railalias{methodsetup}{method\_setup} |
443 |
\railterm{methodsetup} |
|
444 |
||
8682 | 445 |
\railalias{MLcommand}{ML\_command} |
446 |
\railterm{MLcommand} |
|
447 |
||
7134 | 448 |
\begin{rail} |
12879 | 449 |
'use' name |
7134 | 450 |
; |
12879 | 451 |
('ML' | MLcommand | MLsetup | 'setup') text |
7134 | 452 |
; |
12879 | 453 |
methodsetup name '=' text text |
9199 | 454 |
; |
7134 | 455 |
\end{rail} |
456 |
||
7167 | 457 |
\begin{descr} |
7175 | 458 |
\item [$\isarkeyword{use}~file$] reads and executes ML commands from $file$. |
7466 | 459 |
The current theory context (if present) is passed down to the ML session, |
7981 | 460 |
but may not be modified. Furthermore, the file name is checked with the |
7466 | 461 |
$\isarkeyword{files}$ dependency declaration given in the theory header (see |
462 |
also \S\ref{sec:begin-thy}). |
|
463 |
||
8682 | 464 |
\item [$\isarkeyword{ML}~text$ and $\isarkeyword{ML_command}~text$] execute ML |
465 |
commands from $text$. The theory context is passed in the same way as for |
|
10858 | 466 |
$\isarkeyword{use}$, but may not be changed. Note that the output of |
8682 | 467 |
$\isarkeyword{ML_command}$ is less verbose than plain $\isarkeyword{ML}$. |
7895 | 468 |
|
469 |
\item [$\isarkeyword{ML_setup}~text$] executes ML commands from $text$. The |
|
470 |
theory context is passed down to the ML session, and fetched back |
|
471 |
afterwards. Thus $text$ may actually change the theory as a side effect. |
|
472 |
||
7167 | 473 |
\item [$\isarkeyword{setup}~text$] changes the current theory context by |
8379 | 474 |
applying $text$, which refers to an ML expression of type |
475 |
\texttt{(theory~->~theory)~list}. The $\isarkeyword{setup}$ command is the |
|
8547 | 476 |
canonical way to initialize any object-logic specific tools and packages |
477 |
written in ML. |
|
9199 | 478 |
|
479 |
\item [$\isarkeyword{method_setup}~name = text~description$] defines a proof |
|
480 |
method in the current theory. The given $text$ has to be an ML expression |
|
481 |
of type \texttt{Args.src -> Proof.context -> Proof.method}. Parsing |
|
482 |
concrete method syntax from \texttt{Args.src} input can be quite tedious in |
|
483 |
general. The following simple examples are for methods without any explicit |
|
484 |
arguments, or a list of theorems, respectively. |
|
485 |
||
486 |
{\footnotesize |
|
487 |
\begin{verbatim} |
|
9605 | 488 |
Method.no_args (Method.METHOD (fn facts => foobar_tac)) |
489 |
Method.thms_args (fn thms => Method.METHOD (fn facts => foobar_tac)) |
|
10899 | 490 |
Method.ctxt_args (fn ctxt => Method.METHOD (fn facts => foobar_tac)) |
12618 | 491 |
Method.thms_ctxt_args (fn thms => fn ctxt => |
492 |
Method.METHOD (fn facts => foobar_tac)) |
|
9199 | 493 |
\end{verbatim} |
494 |
} |
|
495 |
||
496 |
Note that mere tactic emulations may ignore the \texttt{facts} parameter |
|
13039 | 497 |
above. Proper proof methods would do something appropriate with the list of |
498 |
current facts, though. Single-rule methods usually do strict forward-chaining |
|
499 |
(e.g.\ by using \texttt{Method.multi_resolves}), while automatic ones just |
|
500 |
insert the facts using \texttt{Method.insert_tac} before applying the main |
|
501 |
tactic. |
|
7167 | 502 |
\end{descr} |
7134 | 503 |
|
504 |
||
8250 | 505 |
\subsection{Syntax translation functions} |
7134 | 506 |
|
8250 | 507 |
\indexisarcmd{parse-ast-translation}\indexisarcmd{parse-translation} |
508 |
\indexisarcmd{print-translation}\indexisarcmd{typed-print-translation} |
|
509 |
\indexisarcmd{print-ast-translation}\indexisarcmd{token-translation} |
|
510 |
\begin{matharray}{rcl} |
|
511 |
\isarcmd{parse_ast_translation} & : & \isartrans{theory}{theory} \\ |
|
512 |
\isarcmd{parse_translation} & : & \isartrans{theory}{theory} \\ |
|
513 |
\isarcmd{print_translation} & : & \isartrans{theory}{theory} \\ |
|
514 |
\isarcmd{typed_print_translation} & : & \isartrans{theory}{theory} \\ |
|
515 |
\isarcmd{print_ast_translation} & : & \isartrans{theory}{theory} \\ |
|
516 |
\isarcmd{token_translation} & : & \isartrans{theory}{theory} \\ |
|
517 |
\end{matharray} |
|
7134 | 518 |
|
9273 | 519 |
\railalias{parseasttranslation}{parse\_ast\_translation} |
520 |
\railterm{parseasttranslation} |
|
521 |
||
522 |
\railalias{parsetranslation}{parse\_translation} |
|
523 |
\railterm{parsetranslation} |
|
524 |
||
525 |
\railalias{printtranslation}{print\_translation} |
|
526 |
\railterm{printtranslation} |
|
527 |
||
528 |
\railalias{typedprinttranslation}{typed\_print\_translation} |
|
529 |
\railterm{typedprinttranslation} |
|
530 |
||
531 |
\railalias{printasttranslation}{print\_ast\_translation} |
|
532 |
\railterm{printasttranslation} |
|
533 |
||
534 |
\railalias{tokentranslation}{token\_translation} |
|
535 |
\railterm{tokentranslation} |
|
536 |
||
537 |
\begin{rail} |
|
538 |
( parseasttranslation | parsetranslation | printtranslation | typedprinttranslation | |
|
14642 | 539 |
printasttranslation ) ('(' 'advanced' ')')? text; |
540 |
||
541 |
tokentranslation text |
|
9273 | 542 |
\end{rail} |
543 |
||
8250 | 544 |
Syntax translation functions written in ML admit almost arbitrary |
545 |
manipulations of Isabelle's inner syntax. Any of the above commands have a |
|
13048 | 546 |
single \railqtok{text} argument that refers to an ML expression of appropriate |
14642 | 547 |
type, which are as follows by default: |
8379 | 548 |
|
549 |
\begin{ttbox} |
|
550 |
val parse_ast_translation : (string * (ast list -> ast)) list |
|
551 |
val parse_translation : (string * (term list -> term)) list |
|
552 |
val print_translation : (string * (term list -> term)) list |
|
553 |
val typed_print_translation : |
|
554 |
(string * (bool -> typ -> term list -> term)) list |
|
555 |
val print_ast_translation : (string * (ast list -> ast)) list |
|
556 |
val token_translation : |
|
557 |
(string * string * (string -> string * real)) list |
|
558 |
\end{ttbox} |
|
14642 | 559 |
|
560 |
In case that the $(advanced)$ option is given, the corresponding translation |
|
561 |
functions may depend on the signature of the current theory context. This |
|
562 |
allows to implement advanced syntax mechanisms, as translations functions may |
|
563 |
refer to specific theory declarations and auxiliary data. |
|
564 |
||
565 |
See also \cite[\S8]{isabelle-ref} for more information on the general concept |
|
566 |
of syntax transformations in Isabelle. |
|
567 |
||
568 |
\begin{ttbox} |
|
569 |
val parse_ast_translation: |
|
570 |
(string * (Sign.sg -> ast list -> ast)) list |
|
571 |
val parse_translation: |
|
572 |
(string * (Sign.sg -> term list -> term)) list |
|
573 |
val print_translation: |
|
574 |
(string * (Sign.sg -> term list -> term)) list |
|
575 |
val typed_print_translation: |
|
576 |
(string * (Sign.sg -> bool -> typ -> term list -> term)) list |
|
577 |
val print_ast_translation: |
|
578 |
(string * (Sign.sg -> ast list -> ast)) list |
|
579 |
\end{ttbox} |
|
7134 | 580 |
|
581 |
||
582 |
\subsection{Oracles} |
|
583 |
||
584 |
\indexisarcmd{oracle} |
|
585 |
\begin{matharray}{rcl} |
|
586 |
\isarcmd{oracle} & : & \isartrans{theory}{theory} \\ |
|
587 |
\end{matharray} |
|
588 |
||
7175 | 589 |
Oracles provide an interface to external reasoning systems, without giving up |
590 |
control completely --- each theorem carries a derivation object recording any |
|
591 |
oracle invocation. See \cite[\S6]{isabelle-ref} for more information. |
|
592 |
||
7134 | 593 |
\begin{rail} |
12879 | 594 |
'oracle' name '=' text |
7134 | 595 |
; |
596 |
\end{rail} |
|
597 |
||
7167 | 598 |
\begin{descr} |
7175 | 599 |
\item [$\isarkeyword{oracle}~name=text$] declares oracle $name$ to be ML |
8379 | 600 |
function $text$, which has to be of type |
601 |
\texttt{Sign.sg~*~Object.T~->~term}. |
|
7167 | 602 |
\end{descr} |
7134 | 603 |
|
604 |
||
605 |
\section{Proof commands} |
|
606 |
||
7987 | 607 |
Proof commands perform transitions of Isar/VM machine configurations, which |
7315 | 608 |
are block-structured, consisting of a stack of nodes with three main |
7335 | 609 |
components: logical proof context, current facts, and open goals. Isar/VM |
8547 | 610 |
transitions are \emph{typed} according to the following three different modes |
611 |
of operation: |
|
7167 | 612 |
\begin{descr} |
613 |
\item [$proof(prove)$] means that a new goal has just been stated that is now |
|
8547 | 614 |
to be \emph{proven}; the next command may refine it by some proof method, |
615 |
and enter a sub-proof to establish the actual result. |
|
10858 | 616 |
\item [$proof(state)$] is like a nested theory mode: the context may be |
7987 | 617 |
augmented by \emph{stating} additional assumptions, intermediate results |
618 |
etc. |
|
7895 | 619 |
\item [$proof(chain)$] is intermediate between $proof(state)$ and |
7987 | 620 |
$proof(prove)$: existing facts (i.e.\ the contents of the special ``$this$'' |
621 |
register) have been just picked up in order to be used when refining the |
|
622 |
goal claimed next. |
|
7167 | 623 |
\end{descr} |
7134 | 624 |
|
12621 | 625 |
The proof mode indicator may be read as a verb telling the writer what kind of |
626 |
operation may be performed next. The corresponding typings of proof commands |
|
627 |
restricts the shape of well-formed proof texts to particular command |
|
628 |
sequences. So dynamic arrangements of commands eventually turn out as static |
|
13039 | 629 |
texts of a certain structure. Appendix~\ref{ap:refcard} gives a simplified |
630 |
grammar of the overall (extensible) language emerging that way. |
|
7167 | 631 |
|
12621 | 632 |
|
633 |
\subsection{Markup commands}\label{sec:markup-prf} |
|
7167 | 634 |
|
7987 | 635 |
\indexisarcmd{sect}\indexisarcmd{subsect}\indexisarcmd{subsubsect} |
7895 | 636 |
\indexisarcmd{txt}\indexisarcmd{txt-raw} |
7134 | 637 |
\begin{matharray}{rcl} |
8101 | 638 |
\isarcmd{sect} & : & \isartrans{proof}{proof} \\ |
639 |
\isarcmd{subsect} & : & \isartrans{proof}{proof} \\ |
|
640 |
\isarcmd{subsubsect} & : & \isartrans{proof}{proof} \\ |
|
641 |
\isarcmd{txt} & : & \isartrans{proof}{proof} \\ |
|
642 |
\isarcmd{txt_raw} & : & \isartrans{proof}{proof} \\ |
|
7134 | 643 |
\end{matharray} |
644 |
||
7895 | 645 |
These markup commands for proof mode closely correspond to the ones of theory |
8684 | 646 |
mode (see \S\ref{sec:markup-thy}). |
7895 | 647 |
|
648 |
\railalias{txtraw}{txt\_raw} |
|
649 |
\railterm{txtraw} |
|
7175 | 650 |
|
7134 | 651 |
\begin{rail} |
7895 | 652 |
('sect' | 'subsect' | 'subsubsect' | 'txt' | txtraw) text |
7134 | 653 |
; |
654 |
\end{rail} |
|
655 |
||
656 |
||
12621 | 657 |
\subsection{Context elements}\label{sec:proof-context} |
7134 | 658 |
|
7315 | 659 |
\indexisarcmd{fix}\indexisarcmd{assume}\indexisarcmd{presume}\indexisarcmd{def} |
7134 | 660 |
\begin{matharray}{rcl} |
661 |
\isarcmd{fix} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
662 |
\isarcmd{assume} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
663 |
\isarcmd{presume} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
664 |
\isarcmd{def} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
665 |
\end{matharray} |
|
666 |
||
7315 | 667 |
The logical proof context consists of fixed variables and assumptions. The |
668 |
former closely correspond to Skolem constants, or meta-level universal |
|
669 |
quantification as provided by the Isabelle/Pure logical framework. |
|
13039 | 670 |
Introducing some \emph{arbitrary, but fixed} variable via ``$\FIX x$'' results |
671 |
in a local value that may be used in the subsequent proof as any other |
|
672 |
variable or constant. Furthermore, any result $\edrv \phi[x]$ exported from |
|
673 |
the context will be universally closed wrt.\ $x$ at the outermost level: |
|
674 |
$\edrv \All x \phi$ (this is expressed using Isabelle's meta-variables). |
|
7315 | 675 |
|
676 |
Similarly, introducing some assumption $\chi$ has two effects. On the one |
|
677 |
hand, a local theorem is created that may be used as a fact in subsequent |
|
7895 | 678 |
proof steps. On the other hand, any result $\chi \drv \phi$ exported from the |
679 |
context becomes conditional wrt.\ the assumption: $\edrv \chi \Imp \phi$. |
|
680 |
Thus, solving an enclosing goal using such a result would basically introduce |
|
681 |
a new subgoal stemming from the assumption. How this situation is handled |
|
682 |
depends on the actual version of assumption command used: while $\ASSUMENAME$ |
|
683 |
insists on solving the subgoal by unification with some premise of the goal, |
|
684 |
$\PRESUMENAME$ leaves the subgoal unchanged in order to be proved later by the |
|
685 |
user. |
|
7315 | 686 |
|
13039 | 687 |
Local definitions, introduced by ``$\DEF{}{x \equiv t}$'', are achieved by |
688 |
combining ``$\FIX x$'' with another version of assumption that causes any |
|
7987 | 689 |
hypothetical equation $x \equiv t$ to be eliminated by the reflexivity rule. |
690 |
Thus, exporting some result $x \equiv t \drv \phi[x]$ yields $\edrv \phi[t]$. |
|
7175 | 691 |
|
10686 | 692 |
\railalias{equiv}{\isasymequiv} |
693 |
\railterm{equiv} |
|
694 |
||
7134 | 695 |
\begin{rail} |
12879 | 696 |
'fix' (vars + 'and') |
7134 | 697 |
; |
12879 | 698 |
('assume' | 'presume') (props + 'and') |
7134 | 699 |
; |
12879 | 700 |
'def' thmdecl? \\ name ('==' | equiv) term termpat? |
7134 | 701 |
; |
702 |
\end{rail} |
|
703 |
||
7167 | 704 |
\begin{descr} |
13039 | 705 |
|
8547 | 706 |
\item [$\FIX{\vec x}$] introduces local \emph{arbitrary, but fixed} variables |
707 |
$\vec x$. |
|
13039 | 708 |
|
8515 | 709 |
\item [$\ASSUME{a}{\vec\phi}$ and $\PRESUME{a}{\vec\phi}$] introduce local |
710 |
theorems $\vec\phi$ by assumption. Subsequent results applied to an |
|
711 |
enclosing goal (e.g.\ by $\SHOWNAME$) are handled as follows: $\ASSUMENAME$ |
|
712 |
expects to be able to unify with existing premises in the goal, while |
|
713 |
$\PRESUMENAME$ leaves $\vec\phi$ as new subgoals. |
|
7335 | 714 |
|
715 |
Several lists of assumptions may be given (separated by |
|
7895 | 716 |
$\isarkeyword{and}$); the resulting list of current facts consists of all of |
717 |
these concatenated. |
|
13039 | 718 |
|
7315 | 719 |
\item [$\DEF{a}{x \equiv t}$] introduces a local (non-polymorphic) definition. |
720 |
In results exported from the context, $x$ is replaced by $t$. Basically, |
|
13039 | 721 |
``$\DEF{}{x \equiv t}$'' abbreviates ``$\FIX{x}~\ASSUME{}{x \equiv t}$'', |
722 |
with the resulting hypothetical equation solved by reflexivity. |
|
7431 | 723 |
|
724 |
The default name for the definitional equation is $x_def$. |
|
13039 | 725 |
|
7167 | 726 |
\end{descr} |
727 |
||
7895 | 728 |
The special name $prems$\indexisarthm{prems} refers to all assumptions of the |
729 |
current context as a list of theorems. |
|
7315 | 730 |
|
7167 | 731 |
|
732 |
\subsection{Facts and forward chaining} |
|
733 |
||
734 |
\indexisarcmd{note}\indexisarcmd{then}\indexisarcmd{from}\indexisarcmd{with} |
|
12966 | 735 |
\indexisarcmd{using} |
7167 | 736 |
\begin{matharray}{rcl} |
737 |
\isarcmd{note} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
738 |
\isarcmd{then} & : & \isartrans{proof(state)}{proof(chain)} \\ |
|
739 |
\isarcmd{from} & : & \isartrans{proof(state)}{proof(chain)} \\ |
|
740 |
\isarcmd{with} & : & \isartrans{proof(state)}{proof(chain)} \\ |
|
12966 | 741 |
\isarcmd{using} & : & \isartrans{proof(prove)}{proof(prove)} \\ |
7167 | 742 |
\end{matharray} |
743 |
||
7319 | 744 |
New facts are established either by assumption or proof of local statements. |
7335 | 745 |
Any fact will usually be involved in further proofs, either as explicit |
8547 | 746 |
arguments of proof methods, or when forward chaining towards the next goal via |
12966 | 747 |
$\THEN$ (and variants); $\FROMNAME$ and $\WITHNAME$ are composite forms |
13039 | 748 |
involving $\NOTENAME$. The $\USINGNAME$ elements augments the collection of |
749 |
used facts \emph{after} a goal has been stated. Note that the special theorem |
|
750 |
name $this$\indexisarthm{this} refers to the most recently established facts, |
|
751 |
but only \emph{before} issuing a follow-up claim. |
|
12966 | 752 |
|
7167 | 753 |
\begin{rail} |
12879 | 754 |
'note' (thmdef? thmrefs + 'and') |
7167 | 755 |
; |
12966 | 756 |
('from' | 'with' | 'using') (thmrefs + 'and') |
7167 | 757 |
; |
758 |
\end{rail} |
|
759 |
||
760 |
\begin{descr} |
|
13039 | 761 |
|
7175 | 762 |
\item [$\NOTE{a}{\vec b}$] recalls existing facts $\vec b$, binding the result |
763 |
as $a$. Note that attributes may be involved as well, both on the left and |
|
764 |
right hand sides. |
|
13039 | 765 |
|
7167 | 766 |
\item [$\THEN$] indicates forward chaining by the current facts in order to |
7895 | 767 |
establish the goal to be claimed next. The initial proof method invoked to |
13039 | 768 |
refine that will be offered the facts to do ``anything appropriate'' (see |
7895 | 769 |
also \S\ref{sec:proof-steps}). For example, method $rule$ (see |
8515 | 770 |
\S\ref{sec:pure-meth-att}) would typically do an elimination rather than an |
7895 | 771 |
introduction. Automatic methods usually insert the facts into the goal |
8547 | 772 |
state before operation. This provides a simple scheme to control relevance |
773 |
of facts in automated proof search. |
|
13039 | 774 |
|
775 |
\item [$\FROM{\vec b}$] abbreviates ``$\NOTE{}{\vec b}~\THEN$''; thus $\THEN$ |
|
776 |
is equivalent to ``$\FROM{this}$''. |
|
777 |
||
778 |
\item [$\WITH{\vec b}$] abbreviates ``$\FROM{\vec b~\AND~this}$''; thus the |
|
779 |
forward chaining is from earlier facts together with the current ones. |
|
780 |
||
12966 | 781 |
\item [$\USING{\vec b}$] augments the facts being currently indicated for use |
13039 | 782 |
by a subsequent refinement step (such as $\APPLYNAME$ or $\PROOFNAME$). |
783 |
||
7167 | 784 |
\end{descr} |
785 |
||
13039 | 786 |
Forward chaining with an empty list of theorems is the same as not chaining at |
787 |
all. Thus ``$\FROM{nothing}$'' has no effect apart from entering |
|
788 |
$prove(chain)$ mode, since $nothing$\indexisarthm{nothing} is bound to the |
|
789 |
empty list of theorems. |
|
9238 | 790 |
|
12966 | 791 |
Basic proof methods (such as $rule$) expect multiple facts to be given in |
792 |
their proper order, corresponding to a prefix of the premises of the rule |
|
793 |
involved. Note that positions may be easily skipped using something like |
|
794 |
$\FROM{\Text{\texttt{_}}~a~b}$, for example. This involves the trivial rule |
|
795 |
$\PROP\psi \Imp \PROP\psi$, which happens to be bound in Isabelle/Pure as |
|
796 |
``\texttt{_}'' (underscore).\indexisarthm{_@\texttt{_}} |
|
797 |
||
798 |
Automated methods (such as $simp$ or $auto$) just insert any given facts |
|
799 |
before their usual operation. Depending on the kind of procedure involved, |
|
800 |
the order of facts is less significant here. |
|
801 |
||
7167 | 802 |
|
12976 | 803 |
\subsection{Goal statements}\label{sec:goals} |
7167 | 804 |
|
12618 | 805 |
\indexisarcmd{lemma}\indexisarcmd{theorem}\indexisarcmd{corollary} |
7167 | 806 |
\indexisarcmd{have}\indexisarcmd{show}\indexisarcmd{hence}\indexisarcmd{thus} |
807 |
\begin{matharray}{rcl} |
|
12618 | 808 |
\isarcmd{lemma} & : & \isartrans{theory}{proof(prove)} \\ |
7167 | 809 |
\isarcmd{theorem} & : & \isartrans{theory}{proof(prove)} \\ |
12618 | 810 |
\isarcmd{corollary} & : & \isartrans{theory}{proof(prove)} \\ |
7987 | 811 |
\isarcmd{have} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\ |
812 |
\isarcmd{show} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\ |
|
7167 | 813 |
\isarcmd{hence} & : & \isartrans{proof(state)}{proof(prove)} \\ |
814 |
\isarcmd{thus} & : & \isartrans{proof(state)}{proof(prove)} \\ |
|
815 |
\end{matharray} |
|
816 |
||
12621 | 817 |
From a theory context, proof mode is entered by an initial goal command such |
13039 | 818 |
as $\LEMMANAME$, $\THEOREMNAME$, or $\COROLLARYNAME$. Within a proof, new |
819 |
claims may be introduced locally as well; four variants are available here to |
|
12621 | 820 |
indicate whether forward chaining of facts should be performed initially (via |
13039 | 821 |
$\THEN$), and whether the final result is meant to solve some pending goal. |
12618 | 822 |
|
823 |
Goals may consist of multiple statements, resulting in a list of facts |
|
824 |
eventually. A pending multi-goal is internally represented as a meta-level |
|
13039 | 825 |
conjunction (printed as \verb,&&,), which is usually split into the |
826 |
corresponding number of sub-goals prior to an initial method application, via |
|
12618 | 827 |
$\PROOFNAME$ (\S\ref{sec:proof-steps}) or $\APPLYNAME$ |
13039 | 828 |
(\S\ref{sec:tactic-commands}). The $induct$ method covered in |
829 |
\S\ref{sec:cases-induct-meth} acts on multiple claims simultaneously. |
|
12966 | 830 |
|
13016 | 831 |
Claims at the theory level may be either in short or long form. A short goal |
832 |
merely consists of several simultaneous propositions (often just one). A long |
|
833 |
goal includes an explicit context specification for the subsequent |
|
834 |
conclusions, involving local parameters; here the role of each part of the |
|
835 |
statement is explicitly marked by separate keywords (see also |
|
12966 | 836 |
\S\ref{sec:locale}). |
12618 | 837 |
|
7167 | 838 |
\begin{rail} |
13016 | 839 |
('lemma' | 'theorem' | 'corollary') locale? (goal | longgoal) |
7167 | 840 |
; |
13016 | 841 |
('have' | 'show' | 'hence' | 'thus') goal |
7167 | 842 |
; |
12966 | 843 |
|
13016 | 844 |
goal: (props + 'and') |
12621 | 845 |
; |
13016 | 846 |
longgoal: thmdecl? (contextelem *) 'shows' goal |
12621 | 847 |
; |
7167 | 848 |
\end{rail} |
849 |
||
850 |
\begin{descr} |
|
13039 | 851 |
|
12618 | 852 |
\item [$\LEMMA{a}{\vec\phi}$] enters proof mode with $\vec\phi$ as main goal, |
853 |
eventually resulting in some fact $\turn \vec\phi$ to be put back into the |
|
13039 | 854 |
theory context, or into the specified locale (cf.\ \S\ref{sec:locale}). An |
855 |
additional \railnonterm{context} specification may build up an initial proof |
|
856 |
context for the subsequent claim; this includes local definitions and syntax |
|
857 |
as well, see the definition of $contextelem$ in \S\ref{sec:locale}. |
|
12618 | 858 |
|
859 |
\item [$\THEOREM{a}{\vec\phi}$ and $\COROLLARY{a}{\vec\phi}$] are essentially |
|
860 |
the same as $\LEMMA{a}{\vec\phi}$, but the facts are internally marked as |
|
861 |
being of a different kind. This discrimination acts like a formal comment. |
|
862 |
||
863 |
\item [$\HAVE{a}{\vec\phi}$] claims a local goal, eventually resulting in a |
|
864 |
fact within the current logical context. This operation is completely |
|
865 |
independent of any pending sub-goals of an enclosing goal statements, so |
|
866 |
$\HAVENAME$ may be freely used for experimental exploration of potential |
|
867 |
results within a proof body. |
|
868 |
||
869 |
\item [$\SHOW{a}{\vec\phi}$] is like $\HAVE{a}{\vec\phi}$ plus a second stage |
|
870 |
to refine some pending sub-goal for each one of the finished result, after |
|
871 |
having been exported into the corresponding context (at the head of the |
|
13039 | 872 |
sub-proof of this $\SHOWNAME$ command). |
12618 | 873 |
|
874 |
To accommodate interactive debugging, resulting rules are printed before |
|
875 |
being applied internally. Even more, interactive execution of $\SHOWNAME$ |
|
13039 | 876 |
predicts potential failure and displays the resulting error as a warning |
877 |
beforehand. Watch out for the following message: |
|
12618 | 878 |
|
879 |
\begin{ttbox} |
|
880 |
Problem! Local statement will fail to solve any pending goal |
|
881 |
\end{ttbox} |
|
13039 | 882 |
|
883 |
\item [$\HENCENAME$] abbreviates ``$\THEN~\HAVENAME$'', i.e.\ claims a local |
|
884 |
goal to be proven by forward chaining the current facts. Note that |
|
885 |
$\HENCENAME$ is also equivalent to ``$\FROM{this}~\HAVENAME$''. |
|
886 |
||
887 |
\item [$\THUSNAME$] abbreviates ``$\THEN~\SHOWNAME$''. Note that $\THUSNAME$ |
|
888 |
is also equivalent to ``$\FROM{this}~\SHOWNAME$''. |
|
12618 | 889 |
|
7167 | 890 |
\end{descr} |
891 |
||
13039 | 892 |
Any goal statement causes some term abbreviations (such as $\Var{thesis}$) to |
893 |
be bound automatically, see also \S\ref{sec:term-abbrev}. Furthermore, the |
|
894 |
local context of a (non-atomic) goal is provided via the |
|
13048 | 895 |
$rule_context$\indexisarcase{rule-context} case. |
10550 | 896 |
|
897 |
\medskip |
|
898 |
||
899 |
\begin{warn} |
|
900 |
Isabelle/Isar suffers theory-level goal statements to contain \emph{unbound |
|
901 |
schematic variables}, although this does not conform to the aim of |
|
902 |
human-readable proof documents! The main problem with schematic goals is |
|
903 |
that the actual outcome is usually hard to predict, depending on the |
|
13039 | 904 |
behavior of the proof methods applied during the course of reasoning. Note |
10550 | 905 |
that most semi-automated methods heavily depend on several kinds of implicit |
906 |
rule declarations within the current theory context. As this would also |
|
907 |
result in non-compositional checking of sub-proofs, \emph{local goals} are |
|
12618 | 908 |
not allowed to be schematic at all. Nevertheless, schematic goals do have |
909 |
their use in Prolog-style interactive synthesis of proven results, usually |
|
910 |
by stepwise refinement via emulation of traditional Isabelle tactic scripts |
|
911 |
(see also \S\ref{sec:tactic-commands}). In any case, users should know what |
|
912 |
they are doing. |
|
10550 | 913 |
\end{warn} |
8991 | 914 |
|
7167 | 915 |
|
916 |
\subsection{Initial and terminal proof steps}\label{sec:proof-steps} |
|
917 |
||
7175 | 918 |
\indexisarcmd{proof}\indexisarcmd{qed}\indexisarcmd{by} |
919 |
\indexisarcmd{.}\indexisarcmd{..}\indexisarcmd{sorry} |
|
920 |
\begin{matharray}{rcl} |
|
921 |
\isarcmd{proof} & : & \isartrans{proof(prove)}{proof(state)} \\ |
|
922 |
\isarcmd{qed} & : & \isartrans{proof(state)}{proof(state) ~|~ theory} \\ |
|
923 |
\isarcmd{by} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\ |
|
924 |
\isarcmd{.\,.} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\ |
|
925 |
\isarcmd{.} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\ |
|
926 |
\isarcmd{sorry} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\ |
|
927 |
\end{matharray} |
|
928 |
||
8547 | 929 |
Arbitrary goal refinement via tactics is considered harmful. Properly, the |
7335 | 930 |
Isar framework admits proof methods to be invoked in two places only. |
7167 | 931 |
\begin{enumerate} |
7175 | 932 |
\item An \emph{initial} refinement step $\PROOF{m@1}$ reduces a newly stated |
7335 | 933 |
goal to a number of sub-goals that are to be solved later. Facts are passed |
7895 | 934 |
to $m@1$ for forward chaining, if so indicated by $proof(chain)$ mode. |
7167 | 935 |
|
7987 | 936 |
\item A \emph{terminal} conclusion step $\QED{m@2}$ is intended to solve |
937 |
remaining goals. No facts are passed to $m@2$. |
|
7167 | 938 |
\end{enumerate} |
939 |
||
13039 | 940 |
The only other (proper) way to affect pending goals in a proof body is by |
12621 | 941 |
$\SHOWNAME$, which involves an explicit statement of what is to be solved |
942 |
eventually. Thus we avoid the fundamental problem of unstructured tactic |
|
943 |
scripts that consist of numerous consecutive goal transformations, with |
|
944 |
invisible effects. |
|
7167 | 945 |
|
7175 | 946 |
\medskip |
947 |
||
12621 | 948 |
As a general rule of thumb for good proof style, initial proof methods should |
949 |
either solve the goal completely, or constitute some well-understood reduction |
|
950 |
to new sub-goals. Arbitrary automatic proof tools that are prone leave a |
|
951 |
large number of badly structured sub-goals are no help in continuing the proof |
|
13039 | 952 |
document in an intelligible manner. |
7175 | 953 |
|
8547 | 954 |
Unless given explicitly by the user, the default initial method is ``$rule$'', |
955 |
which applies a single standard elimination or introduction rule according to |
|
956 |
the topmost symbol involved. There is no separate default terminal method. |
|
957 |
Any remaining goals are always solved by assumption in the very last step. |
|
7167 | 958 |
|
959 |
\begin{rail} |
|
12879 | 960 |
'proof' method? |
7167 | 961 |
; |
12879 | 962 |
'qed' method? |
7167 | 963 |
; |
12879 | 964 |
'by' method method? |
7167 | 965 |
; |
12879 | 966 |
('.' | '..' | 'sorry') |
7167 | 967 |
; |
968 |
\end{rail} |
|
969 |
||
970 |
\begin{descr} |
|
13039 | 971 |
|
7335 | 972 |
\item [$\PROOF{m@1}$] refines the goal by proof method $m@1$; facts for |
973 |
forward chaining are passed if so indicated by $proof(chain)$ mode. |
|
13039 | 974 |
|
7335 | 975 |
\item [$\QED{m@2}$] refines any remaining goals by proof method $m@2$ and |
7895 | 976 |
concludes the sub-proof by assumption. If the goal had been $\SHOWNAME$ (or |
977 |
$\THUSNAME$), some pending sub-goal is solved as well by the rule resulting |
|
978 |
from the result \emph{exported} into the enclosing goal context. Thus |
|
979 |
$\QEDNAME$ may fail for two reasons: either $m@2$ fails, or the resulting |
|
980 |
rule does not fit to any pending goal\footnote{This includes any additional |
|
981 |
``strong'' assumptions as introduced by $\ASSUMENAME$.} of the enclosing |
|
982 |
context. Debugging such a situation might involve temporarily changing |
|
983 |
$\SHOWNAME$ into $\HAVENAME$, or weakening the local context by replacing |
|
13039 | 984 |
occurrences of $\ASSUMENAME$ by $\PRESUMENAME$. |
985 |
||
7895 | 986 |
\item [$\BYY{m@1}{m@2}$] is a \emph{terminal proof}\index{proof!terminal}; it |
13039 | 987 |
abbreviates $\PROOF{m@1}~\QED{m@2}$, but with backtracking across both |
988 |
methods. Debugging an unsuccessful $\BYY{m@1}{m@2}$ commands might be done |
|
989 |
by expanding its definition; in many cases $\PROOF{m@1}$ (or even |
|
990 |
$\APPLY{m@1}$) is already sufficient to see the problem. |
|
991 |
||
7895 | 992 |
\item [``$\DDOT$''] is a \emph{default proof}\index{proof!default}; it |
8515 | 993 |
abbreviates $\BY{rule}$. |
13039 | 994 |
|
7895 | 995 |
\item [``$\DOT$''] is a \emph{trivial proof}\index{proof!trivial}; it |
8195 | 996 |
abbreviates $\BY{this}$. |
13039 | 997 |
|
12618 | 998 |
\item [$\SORRY$] is a \emph{fake proof}\index{proof!fake} pretending to solve |
999 |
the pending claim without further ado. This only works in interactive |
|
13039 | 1000 |
development, or if the \texttt{quick_and_dirty} flag is enabled. Facts |
1001 |
emerging from fake proofs are not the real thing. Internally, each theorem |
|
1002 |
container is tainted by an oracle invocation, which is indicated as |
|
1003 |
``$[!]$'' in the printed result. |
|
12618 | 1004 |
|
1005 |
The most important application of $\SORRY$ is to support experimentation and |
|
13039 | 1006 |
top-down proof development. |
8515 | 1007 |
\end{descr} |
1008 |
||
1009 |
||
1010 |
\subsection{Fundamental methods and attributes}\label{sec:pure-meth-att} |
|
1011 |
||
8547 | 1012 |
The following proof methods and attributes refer to basic logical operations |
1013 |
of Isar. Further methods and attributes are provided by several generic and |
|
1014 |
object-logic specific tools and packages (see chapters \ref{ch:gen-tools} and |
|
12621 | 1015 |
\ref{ch:logics}). |
8515 | 1016 |
|
13024 | 1017 |
\indexisarmeth{$-$}\indexisarmeth{assumption} |
1018 |
\indexisarmeth{this}\indexisarmeth{rule}\indexisarmeth{rules} |
|
12621 | 1019 |
\indexisarattof{Pure}{intro}\indexisarattof{Pure}{elim} |
1020 |
\indexisarattof{Pure}{dest}\indexisarattof{Pure}{rule} |
|
14175
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13827
diff
changeset
|
1021 |
\indexisaratt{OF}\indexisaratt{of}\indexisaratt{where} |
8515 | 1022 |
\begin{matharray}{rcl} |
13024 | 1023 |
- & : & \isarmeth \\ |
8515 | 1024 |
assumption & : & \isarmeth \\ |
1025 |
this & : & \isarmeth \\ |
|
1026 |
rule & : & \isarmeth \\ |
|
13024 | 1027 |
rules & : & \isarmeth \\[0.5ex] |
8515 | 1028 |
intro & : & \isaratt \\ |
1029 |
elim & : & \isaratt \\ |
|
1030 |
dest & : & \isaratt \\ |
|
13024 | 1031 |
rule & : & \isaratt \\[0.5ex] |
1032 |
OF & : & \isaratt \\ |
|
1033 |
of & : & \isaratt \\ |
|
14175
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13827
diff
changeset
|
1034 |
where & : & \isaratt \\ |
8515 | 1035 |
\end{matharray} |
1036 |
||
1037 |
\begin{rail} |
|
8547 | 1038 |
'rule' thmrefs? |
8515 | 1039 |
; |
13024 | 1040 |
'rules' ('!' ?) (rulemod *) |
1041 |
; |
|
1042 |
rulemod: ('intro' | 'elim' | 'dest') ((('!' | () | '?') nat?) | 'del') ':' thmrefs |
|
1043 |
; |
|
1044 |
('intro' | 'elim' | 'dest') ('!' | () | '?') nat? |
|
1045 |
; |
|
1046 |
'rule' 'del' |
|
1047 |
; |
|
8515 | 1048 |
'OF' thmrefs |
1049 |
; |
|
8693 | 1050 |
'of' insts ('concl' ':' insts)? |
8515 | 1051 |
; |
15686 | 1052 |
'where' ((name | var | typefree | typevar) '=' (type | term) * 'and') |
14175
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13827
diff
changeset
|
1053 |
; |
8515 | 1054 |
\end{rail} |
1055 |
||
1056 |
\begin{descr} |
|
13024 | 1057 |
|
1058 |
\item [``$-$''] does nothing but insert the forward chaining facts as premises |
|
1059 |
into the goal. Note that command $\PROOFNAME$ without any method actually |
|
1060 |
performs a single reduction step using the $rule$ method; thus a plain |
|
13039 | 1061 |
\emph{do-nothing} proof step would be ``$\PROOF{-}$'' rather than |
1062 |
$\PROOFNAME$ alone. |
|
13024 | 1063 |
|
13039 | 1064 |
\item [$assumption$] solves some goal by a single assumption step. All given |
1065 |
facts are guaranteed to participate in the refinement; this means there may |
|
1066 |
be only $0$ or $1$ in the first place. Recall that $\QEDNAME$ (see |
|
1067 |
\S\ref{sec:proof-steps}) already concludes any remaining sub-goals by |
|
1068 |
assumption, so structured proofs usually need not quote the $assumption$ |
|
1069 |
method at all. |
|
13024 | 1070 |
|
8515 | 1071 |
\item [$this$] applies all of the current facts directly as rules. Recall |
13039 | 1072 |
that ``$\DOT$'' (dot) abbreviates ``$\BY{this}$''. |
13024 | 1073 |
|
8547 | 1074 |
\item [$rule~\vec a$] applies some rule given as argument in backward manner; |
8515 | 1075 |
facts are used to reduce the rule before applying it to the goal. Thus |
13039 | 1076 |
$rule$ without facts is plain introduction, while with facts it becomes |
1077 |
elimination. |
|
8515 | 1078 |
|
8547 | 1079 |
When no arguments are given, the $rule$ method tries to pick appropriate |
1080 |
rules automatically, as declared in the current context using the $intro$, |
|
1081 |
$elim$, $dest$ attributes (see below). This is the default behavior of |
|
1082 |
$\PROOFNAME$ and ``$\DDOT$'' (double-dot) steps (see |
|
8515 | 1083 |
\S\ref{sec:proof-steps}). |
13024 | 1084 |
|
1085 |
\item [$rules$] performs intuitionistic proof search, depending on |
|
1086 |
specifically declared rules from the context, or given as explicit |
|
1087 |
arguments. Chained facts are inserted into the goal before commencing proof |
|
13039 | 1088 |
search; ``$rules!$'' means to include the current $prems$ as well. |
13024 | 1089 |
|
1090 |
Rules need to be classified as $intro$, $elim$, or $dest$; here the ``$!$'' |
|
1091 |
indicator refers to ``safe'' rules, which may be applied aggressively |
|
1092 |
(without considering back-tracking later). Rules declared with ``$?$'' are |
|
1093 |
ignored in proof search (the single-step $rule$ method still observes |
|
1094 |
these). An explicit weight annotation may be given as well; otherwise the |
|
13039 | 1095 |
number of rule premises will be taken into account here. |
1096 |
||
13024 | 1097 |
\item [$intro$, $elim$, and $dest$] declare introduction, elimination, and |
1098 |
destruct rules, to be used with the $rule$ and $rules$ methods. Note that |
|
13039 | 1099 |
the latter will ignore rules declared with ``$?$'', while ``$!$'' are used |
13024 | 1100 |
most aggressively. |
1101 |
||
13048 | 1102 |
The classical reasoner (see \S\ref{sec:classical}) introduces its own |
13024 | 1103 |
variants of these attributes; use qualified names to access the present |
1104 |
versions of Isabelle/Pure, i.e.\ $Pure{\dtt}intro$ or $CPure{\dtt}intro$. |
|
1105 |
||
1106 |
\item [$rule~del$] undeclares introduction, elimination, or destruct rules. |
|
1107 |
||
8547 | 1108 |
\item [$OF~\vec a$] applies some theorem to given rules $\vec a$ (in |
1109 |
parallel). This corresponds to the \texttt{MRS} operator in ML |
|
1110 |
\cite[\S5]{isabelle-ref}, but note the reversed order. Positions may be |
|
13039 | 1111 |
effectively skipped by including ``$\_$'' (underscore) as argument. |
13024 | 1112 |
|
15686 | 1113 |
\item [$of~\vec t$] performs positional instantiation of term variables. The |
1114 |
terms $\vec t$ are substituted for any schematic variables occurring in a |
|
1115 |
theorem from left to right; ``\texttt{_}'' (underscore) indicates to skip a |
|
1116 |
position. Arguments following a ``$concl\colon$'' specification refer to |
|
1117 |
positions of the conclusion of a rule. |
|
13024 | 1118 |
|
15686 | 1119 |
\item [$where~\vec x = \vec t$] performs named instantiation of schematic type |
1120 |
and term variables occurring in a theorem. Schematic variables have to be |
|
1121 |
specified on the left-hand side (e.g.\ $?x1\!.\!3$). The question mark may |
|
1122 |
be omitted if the variable name is a plain identifier without index. As |
|
1123 |
type instantiations are inferred from term instantiations, explicit type |
|
1124 |
instantiations are seldom necessary. |
|
14175
dbd16ebaf907
Method rule_tac understands Isar contexts: documentation.
ballarin
parents:
13827
diff
changeset
|
1125 |
|
7315 | 1126 |
\end{descr} |
1127 |
||
1128 |
||
1129 |
\subsection{Term abbreviations}\label{sec:term-abbrev} |
|
1130 |
||
1131 |
\indexisarcmd{let} |
|
1132 |
\begin{matharray}{rcl} |
|
1133 |
\isarcmd{let} & : & \isartrans{proof(state)}{proof(state)} \\ |
|
1134 |
\isarkeyword{is} & : & syntax \\ |
|
1135 |
\end{matharray} |
|
1136 |
||
1137 |
Abbreviations may be either bound by explicit $\LET{p \equiv t}$ statements, |
|
7987 | 1138 |
or by annotating assumptions or goal statements with a list of patterns |
13039 | 1139 |
``$\ISS{p@1\;\dots}{p@n}$''. In both cases, higher-order matching is invoked |
1140 |
to bind extra-logical term variables, which may be either named schematic |
|
7987 | 1141 |
variables of the form $\Var{x}$, or nameless dummies ``\texttt{_}'' |
1142 |
(underscore).\indexisarvar{_@\texttt{_}} Note that in the $\LETNAME$ form the |
|
1143 |
patterns occur on the left-hand side, while the $\ISNAME$ patterns are in |
|
1144 |
postfix position. |
|
7315 | 1145 |
|
12621 | 1146 |
Polymorphism of term bindings is handled in Hindley-Milner style, similar to |
1147 |
ML. Type variables referring to local assumptions or open goal statements are |
|
8620
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
1148 |
\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
|
1149 |
in \emph{arbitrary} instances later. Even though actual polymorphism should |
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
1150 |
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
|
1151 |
incremental type-inference, as the user proceeds to build up the Isar proof |
13039 | 1152 |
text from left to right. |
8620
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
1153 |
|
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
1154 |
\medskip |
3786d47f5570
support Hindley-Milner polymorphisms in results and bindings;
wenzelm
parents:
8547
diff
changeset
|
1155 |
|
13039 | 1156 |
Term abbreviations are quite different from local definitions as introduced |
1157 |
via $\DEFNAME$ (see \S\ref{sec:proof-context}). The latter are visible within |
|
1158 |
the logic as actual equations, while abbreviations disappear during the input |
|
1159 |
process just after type checking. Also note that $\DEFNAME$ does not support |
|
1160 |
polymorphism. |
|
7315 | 1161 |
|
1162 |
\begin{rail} |
|
12879 | 1163 |
'let' ((term + 'and') '=' term + 'and') |
7315 | 1164 |
; |
1165 |
\end{rail} |
|
1166 |
||
1167 |
The syntax of $\ISNAME$ patterns follows \railnonterm{termpat} or |
|
12618 | 1168 |
\railnonterm{proppat} (see \S\ref{sec:term-decls}). |
7315 | 1169 |
|
1170 |
\begin{descr} |
|
1171 |
\item [$\LET{\vec p = \vec t}$] binds any text variables in patters $\vec p$ |
|
1172 |
by simultaneous higher-order matching against terms $\vec t$. |
|
1173 |
\item [$\IS{\vec p}$] resembles $\LETNAME$, but matches $\vec p$ against the |
|
1174 |
preceding statement. Also note that $\ISNAME$ is not a separate command, |
|
1175 |
but part of others (such as $\ASSUMENAME$, $\HAVENAME$ etc.). |
|
1176 |
\end{descr} |
|
1177 |
||
10160 | 1178 |
Some \emph{automatic} term abbreviations\index{term abbreviations} for goals |
7988 | 1179 |
and facts are available as well. For any open goal, |
10160 | 1180 |
$\Var{thesis}$\indexisarvar{thesis} refers to its object-level statement, |
1181 |
abstracted over any meta-level parameters (if present). Likewise, |
|
1182 |
$\Var{this}$\indexisarvar{this} is bound for fact statements resulting from |
|
1183 |
assumptions or finished goals. In case $\Var{this}$ refers to an object-logic |
|
1184 |
statement that is an application $f(t)$, then $t$ is bound to the special text |
|
1185 |
variable ``$\dots$''\indexisarvar{\dots} (three dots). The canonical |
|
1186 |
application of the latter are calculational proofs (see |
|
1187 |
\S\ref{sec:calculation}). |
|
1188 |
||
7315 | 1189 |
|
7134 | 1190 |
\subsection{Block structure} |
1191 |
||
8896 | 1192 |
\indexisarcmd{next}\indexisarcmd{\{}\indexisarcmd{\}} |
7397 | 1193 |
\begin{matharray}{rcl} |
8448 | 1194 |
\NEXT & : & \isartrans{proof(state)}{proof(state)} \\ |
7974 | 1195 |
\BG & : & \isartrans{proof(state)}{proof(state)} \\ |
1196 |
\EN & : & \isartrans{proof(state)}{proof(state)} \\ |
|
7397 | 1197 |
\end{matharray} |
1198 |
||
7167 | 1199 |
While Isar is inherently block-structured, opening and closing blocks is |
1200 |
mostly handled rather casually, with little explicit user-intervention. Any |
|
1201 |
local goal statement automatically opens \emph{two} blocks, which are closed |
|
1202 |
again when concluding the sub-proof (by $\QEDNAME$ etc.). Sections of |
|
8448 | 1203 |
different context within a sub-proof may be switched via $\NEXT$, which is |
13039 | 1204 |
just a single block-close followed by block-open again. The effect of $\NEXT$ |
1205 |
is to reset the local proof context; there is no goal focus involved here! |
|
7167 | 1206 |
|
7175 | 1207 |
For slightly more advanced applications, there are explicit block parentheses |
7895 | 1208 |
as well. These typically achieve a stronger forward style of reasoning. |
7167 | 1209 |
|
1210 |
\begin{descr} |
|
8448 | 1211 |
\item [$\NEXT$] switches to a fresh block within a sub-proof, resetting the |
1212 |
local context to the initial one. |
|
8896 | 1213 |
\item [$\BG$ and $\EN$] explicitly open and close blocks. Any current facts |
1214 |
pass through ``$\BG$'' unchanged, while ``$\EN$'' causes any result to be |
|
7895 | 1215 |
\emph{exported} into the enclosing context. Thus fixed variables are |
1216 |
generalized, assumptions discharged, and local definitions unfolded (cf.\ |
|
1217 |
\S\ref{sec:proof-context}). There is no difference of $\ASSUMENAME$ and |
|
1218 |
$\PRESUMENAME$ in this mode of forward reasoning --- in contrast to plain |
|
1219 |
backward reasoning with the result exported at $\SHOWNAME$ time. |
|
7167 | 1220 |
\end{descr} |
7134 | 1221 |
|
1222 |
||
9605 | 1223 |
\subsection{Emulating tactic scripts}\label{sec:tactic-commands} |
8515 | 1224 |
|
9605 | 1225 |
The Isar provides separate commands to accommodate tactic-style proof scripts |
1226 |
within the same system. While being outside the orthodox Isar proof language, |
|
1227 |
these might come in handy for interactive exploration and debugging, or even |
|
1228 |
actual tactical proof within new-style theories (to benefit from document |
|
1229 |
preparation, for example). See also \S\ref{sec:tactics} for actual tactics, |
|
1230 |
that have been encapsulated as proof methods. Proper proof methods may be |
|
1231 |
used in scripts, too. |
|
8515 | 1232 |
|
9605 | 1233 |
\indexisarcmd{apply}\indexisarcmd{apply-end}\indexisarcmd{done} |
8515 | 1234 |
\indexisarcmd{defer}\indexisarcmd{prefer}\indexisarcmd{back} |
9605 | 1235 |
\indexisarcmd{declare} |
8515 | 1236 |
\begin{matharray}{rcl} |
8533 | 1237 |
\isarcmd{apply}^* & : & \isartrans{proof(prove)}{proof(prove)} \\ |
9605 | 1238 |
\isarcmd{apply_end}^* & : & \isartrans{proof(state)}{proof(state)} \\ |
8946 | 1239 |
\isarcmd{done}^* & : & \isartrans{proof(prove)}{proof(state)} \\ |
8533 | 1240 |
\isarcmd{defer}^* & : & \isartrans{proof}{proof} \\ |
1241 |
\isarcmd{prefer}^* & : & \isartrans{proof}{proof} \\ |
|
1242 |
\isarcmd{back}^* & : & \isartrans{proof}{proof} \\ |
|
9605 | 1243 |
\isarcmd{declare}^* & : & \isartrans{theory}{theory} \\ |
8515 | 1244 |
\end{matharray} |
1245 |
||
1246 |
\railalias{applyend}{apply\_end} |
|
1247 |
\railterm{applyend} |
|
1248 |
||
1249 |
\begin{rail} |
|
12879 | 1250 |
( 'apply' | applyend ) method |
8515 | 1251 |
; |
12879 | 1252 |
'defer' nat? |
8515 | 1253 |
; |
12879 | 1254 |
'prefer' nat |
8515 | 1255 |
; |
12976 | 1256 |
'declare' locale? (thmrefs + 'and') |
9605 | 1257 |
; |
8515 | 1258 |
\end{rail} |
1259 |
||
1260 |
\begin{descr} |
|
13042 | 1261 |
|
10223 | 1262 |
\item [$\APPLY{m}$] applies proof method $m$ in initial position, but unlike |
1263 |
$\PROOFNAME$ it retains ``$proof(prove)$'' mode. Thus consecutive method |
|
1264 |
applications may be given just as in tactic scripts. |
|
8515 | 1265 |
|
8881 | 1266 |
Facts are passed to $m$ as indicated by the goal's forward-chain mode, and |
10223 | 1267 |
are \emph{consumed} afterwards. Thus any further $\APPLYNAME$ command would |
1268 |
always work in a purely backward manner. |
|
8946 | 1269 |
|
8515 | 1270 |
\item [$\isarkeyword{apply_end}~(m)$] applies proof method $m$ as if in |
1271 |
terminal position. Basically, this simulates a multi-step tactic script for |
|
1272 |
$\QEDNAME$, but may be given anywhere within the proof body. |
|
1273 |
||
1274 |
No facts are passed to $m$. Furthermore, the static context is that of the |
|
1275 |
enclosing goal (as for actual $\QEDNAME$). Thus the proof method may not |
|
1276 |
refer to any assumptions introduced in the current body, for example. |
|
13039 | 1277 |
|
9605 | 1278 |
\item [$\isarkeyword{done}$] completes a proof script, provided that the |
13039 | 1279 |
current goal state is solved completely. Note that actual structured proof |
1280 |
commands (e.g.\ ``$\DOT$'' or $\SORRY$) may be used to conclude proof |
|
1281 |
scripts as well. |
|
9605 | 1282 |
|
8515 | 1283 |
\item [$\isarkeyword{defer}~n$ and $\isarkeyword{prefer}~n$] shuffle the list |
1284 |
of pending goals: $defer$ puts off goal $n$ to the end of the list ($n = 1$ |
|
1285 |
by default), while $prefer$ brings goal $n$ to the top. |
|
13039 | 1286 |
|
8515 | 1287 |
\item [$\isarkeyword{back}$] does back-tracking over the result sequence of |
13039 | 1288 |
the latest proof command. Basically, any proof command may return multiple |
1289 |
results. |
|
9605 | 1290 |
|
1291 |
\item [$\isarkeyword{declare}~thms$] declares theorems to the current theory |
|
12976 | 1292 |
context (or the specified locale, see also \S\ref{sec:locale}). No theorem |
1293 |
binding is involved here, unlike $\isarkeyword{theorems}$ or |
|
1294 |
$\isarkeyword{lemmas}$ (cf.\ \S\ref{sec:axms-thms}), so |
|
1295 |
$\isarkeyword{declare}$ only has the effect of applying attributes as |
|
1296 |
included in the theorem specification. |
|
13042 | 1297 |
|
9006 | 1298 |
\end{descr} |
1299 |
||
1300 |
Any proper Isar proof method may be used with tactic script commands such as |
|
10223 | 1301 |
$\APPLYNAME$. A few additional emulations of actual tactics are provided as |
1302 |
well; these would be never used in actual structured proofs, of course. |
|
9006 | 1303 |
|
8515 | 1304 |
|
1305 |
\subsection{Meta-linguistic features} |
|
1306 |
||
1307 |
\indexisarcmd{oops} |
|
1308 |
\begin{matharray}{rcl} |
|
1309 |
\isarcmd{oops} & : & \isartrans{proof}{theory} \\ |
|
1310 |
\end{matharray} |
|
1311 |
||
1312 |
The $\OOPS$ command discontinues the current proof attempt, while considering |
|
1313 |
the partial proof text as properly processed. This is conceptually quite |
|
1314 |
different from ``faking'' actual proofs via $\SORRY$ (see |
|
1315 |
\S\ref{sec:proof-steps}): $\OOPS$ does not observe the proof structure at all, |
|
1316 |
but goes back right to the theory level. Furthermore, $\OOPS$ does not |
|
13039 | 1317 |
produce any result theorem --- there is no intended claim to be able to |
1318 |
complete the proof anyhow. |
|
8515 | 1319 |
|
1320 |
A typical application of $\OOPS$ is to explain Isar proofs \emph{within} the |
|
1321 |
system itself, in conjunction with the document preparation tools of Isabelle |
|
1322 |
described in \cite{isabelle-sys}. Thus partial or even wrong proof attempts |
|
1323 |
can be discussed in a logically sound manner. Note that the Isabelle {\LaTeX} |
|
1324 |
macros can be easily adapted to print something like ``$\dots$'' instead of an |
|
1325 |
``$\OOPS$'' keyword. |
|
1326 |
||
12618 | 1327 |
\medskip The $\OOPS$ command is undo-able, unlike $\isarkeyword{kill}$ (see |
13039 | 1328 |
\S\ref{sec:history}). The effect is to get back to the theory just before the |
1329 |
opening of the proof. |
|
8515 | 1330 |
|
1331 |
||
7134 | 1332 |
\section{Other commands} |
1333 |
||
9605 | 1334 |
\subsection{Diagnostics} |
7134 | 1335 |
|
10858 | 1336 |
\indexisarcmd{pr}\indexisarcmd{thm}\indexisarcmd{term} |
1337 |
\indexisarcmd{prop}\indexisarcmd{typ} |
|
7134 | 1338 |
\begin{matharray}{rcl} |
8515 | 1339 |
\isarcmd{pr}^* & : & \isarkeep{\cdot} \\ |
1340 |
\isarcmd{thm}^* & : & \isarkeep{theory~|~proof} \\ |
|
1341 |
\isarcmd{term}^* & : & \isarkeep{theory~|~proof} \\ |
|
1342 |
\isarcmd{prop}^* & : & \isarkeep{theory~|~proof} \\ |
|
1343 |
\isarcmd{typ}^* & : & \isarkeep{theory~|~proof} \\ |
|
13827
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1344 |
\isarcmd{prf}^* & : & \isarkeep{theory~|~proof} \\ |
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1345 |
\isarcmd{full_prf}^* & : & \isarkeep{theory~|~proof} \\ |
7134 | 1346 |
\end{matharray} |
1347 |
||
9605 | 1348 |
These diagnostic commands assist interactive development. Note that $undo$ |
1349 |
does not apply here, the theory or proof configuration is not changed. |
|
7335 | 1350 |
|
7134 | 1351 |
\begin{rail} |
9727 | 1352 |
'pr' modes? nat? (',' nat)? |
7134 | 1353 |
; |
12879 | 1354 |
'thm' modes? thmrefs |
8485 | 1355 |
; |
12879 | 1356 |
'term' modes? term |
7134 | 1357 |
; |
12879 | 1358 |
'prop' modes? prop |
7134 | 1359 |
; |
12879 | 1360 |
'typ' modes? type |
8485 | 1361 |
; |
13827
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1362 |
'prf' modes? thmrefs? |
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1363 |
; |
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1364 |
'full\_prf' modes? thmrefs? |
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1365 |
; |
8485 | 1366 |
|
1367 |
modes: '(' (name + ) ')' |
|
7134 | 1368 |
; |
1369 |
\end{rail} |
|
1370 |
||
7167 | 1371 |
\begin{descr} |
9727 | 1372 |
\item [$\isarkeyword{pr}~goals, prems$] prints the current proof state (if |
1373 |
present), including the proof context, current facts and goals. The |
|
1374 |
optional limit arguments affect the number of goals and premises to be |
|
1375 |
displayed, which is initially 10 for both. Omitting limit values leaves the |
|
1376 |
current setting unchanged. |
|
8547 | 1377 |
\item [$\isarkeyword{thm}~\vec a$] retrieves theorems from the current theory |
1378 |
or proof context. Note that any attributes included in the theorem |
|
7974 | 1379 |
specifications are applied to a temporary context derived from the current |
8547 | 1380 |
theory or proof; the result is discarded, i.e.\ attributes involved in $\vec |
1381 |
a$ do not have any permanent effect. |
|
9727 | 1382 |
\item [$\isarkeyword{term}~t$ and $\isarkeyword{prop}~\phi$] read, type-check |
1383 |
and print terms or propositions according to the current theory or proof |
|
7895 | 1384 |
context; the inferred type of $t$ is output as well. Note that these |
1385 |
commands are also useful in inspecting the current environment of term |
|
1386 |
abbreviations. |
|
7974 | 1387 |
\item [$\isarkeyword{typ}~\tau$] reads and prints types of the meta-logic |
1388 |
according to the current theory or proof context. |
|
13827
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1389 |
\item [$\isarkeyword{prf}$] displays the (compact) proof term of the current |
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1390 |
proof state (if present), or of the given theorems. Note that this |
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1391 |
requires proof terms to be switched on for the current object logic |
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1392 |
(see the ``Proof terms'' section of the Isabelle reference manual |
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1393 |
for information on how to do this). |
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1394 |
\item [$\isarkeyword{full_prf}$] is like $\isarkeyword{prf}$, but displays |
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1395 |
the full proof term, i.e.\ also displays information omitted in |
c690cb885db4
Documented prf / full_prf commands and antiquotations.
berghofe
parents:
13542
diff
changeset
|
1396 |
the compact proof term, which is denoted by ``$_$'' placeholders there. |
9605 | 1397 |
\end{descr} |
1398 |
||
1399 |
All of the diagnostic commands above admit a list of $modes$ to be specified, |
|
1400 |
which is appended to the current print mode (see also \cite{isabelle-ref}). |
|
1401 |
Thus the output behavior may be modified according particular print mode |
|
1402 |
features. For example, $\isarkeyword{pr}~(latex~xsymbols~symbols)$ would |
|
1403 |
print the current proof state with mathematical symbols and special characters |
|
1404 |
represented in {\LaTeX} source, according to the Isabelle style |
|
1405 |
\cite{isabelle-sys}. |
|
1406 |
||
1407 |
Note that antiquotations (cf.\ \S\ref{sec:antiq}) provide a more systematic |
|
1408 |
way to include formal items into the printed text document. |
|
1409 |
||
1410 |
||
1411 |
\subsection{Inspecting the context} |
|
1412 |
||
1413 |
\indexisarcmd{print-facts}\indexisarcmd{print-binds} |
|
1414 |
\indexisarcmd{print-commands}\indexisarcmd{print-syntax} |
|
1415 |
\indexisarcmd{print-methods}\indexisarcmd{print-attributes} |
|
10858 | 1416 |
\indexisarcmd{thms-containing}\indexisarcmd{thm-deps} |
1417 |
\indexisarcmd{print-theorems} |
|
9605 | 1418 |
\begin{matharray}{rcl} |
1419 |
\isarcmd{print_commands}^* & : & \isarkeep{\cdot} \\ |
|
1420 |
\isarcmd{print_syntax}^* & : & \isarkeep{theory~|~proof} \\ |
|
1421 |
\isarcmd{print_methods}^* & : & \isarkeep{theory~|~proof} \\ |
|
1422 |
\isarcmd{print_attributes}^* & : & \isarkeep{theory~|~proof} \\ |
|
10858 | 1423 |
\isarcmd{print_theorems}^* & : & \isarkeep{theory~|~proof} \\ |
1424 |
\isarcmd{thms_containing}^* & : & \isarkeep{theory~|~proof} \\ |
|
1425 |
\isarcmd{thms_deps}^* & : & \isarkeep{theory~|~proof} \\ |
|
9605 | 1426 |
\isarcmd{print_facts}^* & : & \isarkeep{proof} \\ |
1427 |
\isarcmd{print_binds}^* & : & \isarkeep{proof} \\ |
|
1428 |
\end{matharray} |
|
1429 |
||
10858 | 1430 |
\railalias{thmscontaining}{thms\_containing} |
1431 |
\railterm{thmscontaining} |
|
1432 |
||
1433 |
\railalias{thmdeps}{thm\_deps} |
|
1434 |
\railterm{thmdeps} |
|
1435 |
||
1436 |
\begin{rail} |
|
16017 | 1437 |
thmscontaining (('(' nat ')')?) (criterion *) |
15996
3699351b8939
documented new thms_containing ('rewrites' still missing)
kleing
parents:
15744
diff
changeset
|
1438 |
; |
16017 | 1439 |
criterion: ('-'?) ('name' ':' nameref | 'intro' | 'elim' | 'dest' | |
1440 |
'rewrite' ':' term | term) |
|
10858 | 1441 |
; |
1442 |
thmdeps thmrefs |
|
1443 |
; |
|
1444 |
\end{rail} |
|
1445 |
||
1446 |
These commands print certain parts of the theory and proof context. Note that |
|
1447 |
there are some further ones available, such as for the set of rules declared |
|
1448 |
for simplifications. |
|
9605 | 1449 |
|
1450 |
\begin{descr} |
|
13039 | 1451 |
|
9605 | 1452 |
\item [$\isarkeyword{print_commands}$] prints Isabelle's outer theory syntax, |
1453 |
including keywords and command. |
|
13039 | 1454 |
|
9605 | 1455 |
\item [$\isarkeyword{print_syntax}$] prints the inner syntax of types and |
1456 |
terms, depending on the current context. The output can be very verbose, |
|
1457 |
including grammar tables and syntax translation rules. See \cite[\S7, |
|
1458 |
\S8]{isabelle-ref} for further information on Isabelle's inner syntax. |
|
13039 | 1459 |
|
10858 | 1460 |
\item [$\isarkeyword{print_methods}$] prints all proof methods available in |
1461 |
the current theory context. |
|
13039 | 1462 |
|
10858 | 1463 |
\item [$\isarkeyword{print_attributes}$] prints all attributes available in |
1464 |
the current theory context. |
|
13039 | 1465 |
|
10858 | 1466 |
\item [$\isarkeyword{print_theorems}$] prints theorems available in the |
13039 | 1467 |
current theory context. |
1468 |
||
1469 |
In interactive mode this actually refers to the theorems left by the last |
|
1470 |
transaction; this allows to inspect the result of advanced definitional |
|
1471 |
packages, such as $\isarkeyword{datatype}$. |
|
1472 |
||
15996
3699351b8939
documented new thms_containing ('rewrites' still missing)
kleing
parents:
15744
diff
changeset
|
1473 |
\item [$\isarkeyword{thms_containing}~\vec c$] retrieves facts from the theory |
16017 | 1474 |
or proof context matching all of the search criteria $\vec c$. A criterion |
1475 |
$name: s$ selects all theorems that contain $s$ in their fully qualified |
|
1476 |
name. The criteria $intro$, $elim$, and $dest$ select theorems that match |
|
1477 |
the current goal as introduction, elimination or destruction rules, |
|
1478 |
respectively. A criterion $rewrite: t$ selects all rewrite rules whose |
|
1479 |
left-hand side matches the given term. A criterion term $t$ selects all |
|
1480 |
theorems that contain the pattern $t$ -- as usual patterns may contain |
|
1481 |
occurrences of the dummy ``$\_$'', schematic variables, and type |
|
1482 |
constraints. |
|
1483 |
||
1484 |
Criteria can be preceded by ``$-$'' to select theorems that do \emph{not} |
|
1485 |
match. Note that giving the empty list of criteria yields \emph{all} |
|
1486 |
currently known facts. An optional limit for the number of printed facts |
|
1487 |
may be given; the default is 40. |
|
13039 | 1488 |
|
12618 | 1489 |
\item [$\isarkeyword{thm_deps}~\vec a$] visualizes dependencies of facts, |
1490 |
using Isabelle's graph browser tool (see also \cite{isabelle-sys}). |
|
13039 | 1491 |
|
8379 | 1492 |
\item [$\isarkeyword{print_facts}$] prints any named facts of the current |
1493 |
context, including assumptions and local results. |
|
13039 | 1494 |
|
8379 | 1495 |
\item [$\isarkeyword{print_binds}$] prints all term abbreviations present in |
1496 |
the context. |
|
13039 | 1497 |
|
8485 | 1498 |
\end{descr} |
1499 |
||
1500 |
||
1501 |
\subsection{History commands}\label{sec:history} |
|
1502 |
||
1503 |
\indexisarcmd{undo}\indexisarcmd{redo}\indexisarcmd{kill} |
|
1504 |
\begin{matharray}{rcl} |
|
1505 |
\isarcmd{undo}^{{*}{*}} & : & \isarkeep{\cdot} \\ |
|
1506 |
\isarcmd{redo}^{{*}{*}} & : & \isarkeep{\cdot} \\ |
|
1507 |
\isarcmd{kill}^{{*}{*}} & : & \isarkeep{\cdot} \\ |
|
1508 |
\end{matharray} |
|
1509 |
||
1510 |
The Isabelle/Isar top-level maintains a two-stage history, for theory and |
|
1511 |
proof state transformation. Basically, any command can be undone using |
|
1512 |
$\isarkeyword{undo}$, excluding mere diagnostic elements. Its effect may be |
|
10858 | 1513 |
revoked via $\isarkeyword{redo}$, unless the corresponding |
8485 | 1514 |
$\isarkeyword{undo}$ step has crossed the beginning of a proof or theory. The |
1515 |
$\isarkeyword{kill}$ command aborts the current history node altogether, |
|
1516 |
discontinuing a proof or even the whole theory. This operation is \emph{not} |
|
12618 | 1517 |
undo-able. |
8485 | 1518 |
|
1519 |
\begin{warn} |
|
8547 | 1520 |
History commands should never be used with user interfaces such as |
1521 |
Proof~General \cite{proofgeneral,Aspinall:TACAS:2000}, which takes care of |
|
1522 |
stepping forth and back itself. Interfering by manual $\isarkeyword{undo}$, |
|
8510 | 1523 |
$\isarkeyword{redo}$, or even $\isarkeyword{kill}$ commands would quickly |
1524 |
result in utter confusion. |
|
8485 | 1525 |
\end{warn} |
1526 |
||
8379 | 1527 |
|
7134 | 1528 |
\subsection{System operations} |
1529 |
||
7167 | 1530 |
\indexisarcmd{cd}\indexisarcmd{pwd}\indexisarcmd{use-thy}\indexisarcmd{use-thy-only} |
14934 | 1531 |
\indexisarcmd{update-thy}\indexisarcmd{update-thy-only}\indexisarcmd{display-drafts} |
1532 |
\indexisarcmd{print-drafts} |
|
7134 | 1533 |
\begin{matharray}{rcl} |
8515 | 1534 |
\isarcmd{cd}^* & : & \isarkeep{\cdot} \\ |
1535 |
\isarcmd{pwd}^* & : & \isarkeep{\cdot} \\ |
|
1536 |
\isarcmd{use_thy}^* & : & \isarkeep{\cdot} \\ |
|
1537 |
\isarcmd{use_thy_only}^* & : & \isarkeep{\cdot} \\ |
|
1538 |
\isarcmd{update_thy}^* & : & \isarkeep{\cdot} \\ |
|
1539 |
\isarcmd{update_thy_only}^* & : & \isarkeep{\cdot} \\ |
|
14934 | 1540 |
\isarcmd{display_drafts}^* & : & \isarkeep{\cdot} \\ |
1541 |
\isarcmd{print_drafts}^* & : & \isarkeep{\cdot} \\ |
|
7134 | 1542 |
\end{matharray} |
1543 |
||
14955 | 1544 |
\railalias{usethy}{use\_thy} |
1545 |
\railterm{usethy} |
|
1546 |
\railalias{usethyonly}{use\_thy\_only} |
|
1547 |
\railterm{usethyonly} |
|
1548 |
\railalias{updatethy}{update\_thy} |
|
1549 |
\railterm{updatethy} |
|
1550 |
\railalias{updatethyonly}{update\_thy\_only} |
|
1551 |
\railterm{updatethyonly} |
|
1552 |
\railalias{displaydrafts}{display\_drafts} |
|
1553 |
\railterm{displaydrafts} |
|
1554 |
\railalias{printdrafts}{print\_drafts} |
|
1555 |
\railterm{printdrafts} |
|
1556 |
||
1557 |
\begin{rail} |
|
1558 |
('cd' | usethy | usethyonly | updatethy | updatethyonly) name |
|
1559 |
; |
|
1560 |
(displaydrafts | printdrafts) (name +) |
|
1561 |
; |
|
1562 |
\end{rail} |
|
1563 |
||
7167 | 1564 |
\begin{descr} |
14955 | 1565 |
\item [$\isarkeyword{cd}~path$] changes the current directory of the Isabelle |
7134 | 1566 |
process. |
1567 |
\item [$\isarkeyword{pwd}~$] prints the current working directory. |
|
7175 | 1568 |
\item [$\isarkeyword{use_thy}$, $\isarkeyword{use_thy_only}$, |
7987 | 1569 |
$\isarkeyword{update_thy}$, $\isarkeyword{update_thy_only}$] load some |
7895 | 1570 |
theory given as $name$ argument. These commands are basically the same as |
7987 | 1571 |
the corresponding ML functions\footnote{The ML versions also change the |
1572 |
implicit theory context to that of the theory loaded.} (see also |
|
1573 |
\cite[\S1,\S6]{isabelle-ref}). Note that both the ML and Isar versions may |
|
1574 |
load new- and old-style theories alike. |
|
14955 | 1575 |
\item [$\isarkeyword{display_drafts}~paths$ and |
1576 |
$\isarkeyword{print_drafts}~paths$] perform simple output of a given list of |
|
1577 |
raw source files. Only those symbols that do not require additional |
|
1578 |
{\LaTeX} packages are displayed properly, everything else is left verbatim. |
|
7167 | 1579 |
\end{descr} |
7134 | 1580 |
|
7987 | 1581 |
These system commands are scarcely used when working with the Proof~General |
13039 | 1582 |
interface, since loading of theories is done transparently. |
8379 | 1583 |
|
7046 | 1584 |
%%% Local Variables: |
1585 |
%%% mode: latex |
|
1586 |
%%% TeX-master: "isar-ref" |
|
1587 |
%%% End: |