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