| author | wenzelm |
| Wed, 15 Mar 2000 18:36:53 +0100 | |
| changeset 8467 | 58dbeea60bb8 |
| parent 8136 | 8c65f3ca13f2 |
| child 8969 | 23c6e0ca0086 |
| permissions | -rw-r--r-- |
| 104 | 1 |
%% $Id$ |
2 |
\chapter{Theorems and Forward Proof}
|
|
3 |
\index{theorems|(}
|
|
| 326 | 4 |
|
| 3108 | 5 |
Theorems, which represent the axioms, theorems and rules of |
6 |
object-logics, have type \mltydx{thm}. This chapter begins by
|
|
7 |
describing operations that print theorems and that join them in |
|
8 |
forward proof. Most theorem operations are intended for advanced |
|
9 |
applications, such as programming new proof procedures. Many of these |
|
10 |
operations refer to signatures, certified terms and certified types, |
|
11 |
which have the \ML{} types {\tt Sign.sg}, {\tt cterm} and {\tt ctyp}
|
|
12 |
and are discussed in Chapter~\ref{theories}. Beginning users should
|
|
13 |
ignore such complexities --- and skip all but the first section of |
|
14 |
this chapter. |
|
| 104 | 15 |
|
16 |
The theorem operations do not print error messages. Instead, they raise |
|
| 326 | 17 |
exception~\xdx{THM}\@. Use \ttindex{print_exn} to display
|
| 104 | 18 |
exceptions nicely: |
19 |
\begin{ttbox}
|
|
20 |
allI RS mp handle e => print_exn e; |
|
21 |
{\out Exception THM raised:}
|
|
22 |
{\out RSN: no unifiers -- premise 1}
|
|
23 |
{\out (!!x. ?P(x)) ==> ALL x. ?P(x)}
|
|
24 |
{\out [| ?P --> ?Q; ?P |] ==> ?Q}
|
|
25 |
{\out}
|
|
26 |
{\out uncaught exception THM}
|
|
27 |
\end{ttbox}
|
|
28 |
||
29 |
||
30 |
\section{Basic operations on theorems}
|
|
31 |
\subsection{Pretty-printing a theorem}
|
|
| 326 | 32 |
\index{theorems!printing of}
|
| 104 | 33 |
\begin{ttbox}
|
| 326 | 34 |
prth : thm -> thm |
35 |
prths : thm list -> thm list |
|
| 4276 | 36 |
prthq : thm Seq.seq -> thm Seq.seq |
| 326 | 37 |
print_thm : thm -> unit |
38 |
print_goals : int -> thm -> unit |
|
39 |
string_of_thm : thm -> string |
|
| 104 | 40 |
\end{ttbox}
|
| 326 | 41 |
The first three commands are for interactive use. They are identity |
42 |
functions that display, then return, their argument. The \ML{} identifier
|
|
43 |
{\tt it} will refer to the value just displayed.
|
|
44 |
||
45 |
The others are for use in programs. Functions with result type {\tt unit}
|
|
46 |
are convenient for imperative programming. |
|
47 |
||
48 |
\begin{ttdescription}
|
|
| 104 | 49 |
\item[\ttindexbold{prth} {\it thm}]
|
50 |
prints {\it thm\/} at the terminal.
|
|
51 |
||
52 |
\item[\ttindexbold{prths} {\it thms}]
|
|
53 |
prints {\it thms}, a list of theorems.
|
|
54 |
||
55 |
\item[\ttindexbold{prthq} {\it thmq}]
|
|
56 |
prints {\it thmq}, a sequence of theorems. It is useful for inspecting
|
|
57 |
the output of a tactic. |
|
58 |
||
59 |
\item[\ttindexbold{print_thm} {\it thm}]
|
|
60 |
prints {\it thm\/} at the terminal.
|
|
61 |
||
62 |
\item[\ttindexbold{print_goals} {\it limit\/} {\it thm}]
|
|
63 |
prints {\it thm\/} in goal style, with the premises as subgoals. It prints
|
|
64 |
at most {\it limit\/} subgoals. The subgoal module calls {\tt print_goals}
|
|
65 |
to display proof states. |
|
66 |
||
67 |
\item[\ttindexbold{string_of_thm} {\it thm}]
|
|
68 |
converts {\it thm\/} to a string.
|
|
| 326 | 69 |
\end{ttdescription}
|
| 104 | 70 |
|
71 |
||
| 326 | 72 |
\subsection{Forward proof: joining rules by resolution}
|
73 |
\index{theorems!joining by resolution}
|
|
74 |
\index{resolution}\index{forward proof}
|
|
| 104 | 75 |
\begin{ttbox}
|
| 8136 | 76 |
RSN : thm * (int * thm) -> thm \hfill\textbf{infix}
|
77 |
RS : thm * thm -> thm \hfill\textbf{infix}
|
|
78 |
MRS : thm list * thm -> thm \hfill\textbf{infix}
|
|
79 |
RLN : thm list * (int * thm list) -> thm list \hfill\textbf{infix}
|
|
80 |
RL : thm list * thm list -> thm list \hfill\textbf{infix}
|
|
81 |
MRL : thm list list * thm list -> thm list \hfill\textbf{infix}
|
|
| 104 | 82 |
\end{ttbox}
|
| 326 | 83 |
Joining rules together is a simple way of deriving new rules. These |
| 876 | 84 |
functions are especially useful with destruction rules. To store |
85 |
the result in the theorem database, use \ttindex{bind_thm}
|
|
86 |
(\S\ref{ExtractingAndStoringTheProvedTheorem}).
|
|
| 326 | 87 |
\begin{ttdescription}
|
| 104 | 88 |
\item[\tt$thm@1$ RSN $(i,thm@2)$] \indexbold{*RSN}
|
| 326 | 89 |
resolves the conclusion of $thm@1$ with the $i$th premise of~$thm@2$. |
90 |
Unless there is precisely one resolvent it raises exception |
|
91 |
\xdx{THM}; in that case, use {\tt RLN}.
|
|
| 104 | 92 |
|
93 |
\item[\tt$thm@1$ RS $thm@2$] \indexbold{*RS}
|
|
94 |
abbreviates \hbox{\tt$thm@1$ RSN $(1,thm@2)$}. Thus, it resolves the
|
|
95 |
conclusion of $thm@1$ with the first premise of~$thm@2$. |
|
96 |
||
97 |
\item[\tt {$[thm@1,\ldots,thm@n]$} MRS $thm$] \indexbold{*MRS}
|
|
| 332 | 98 |
uses {\tt RSN} to resolve $thm@i$ against premise~$i$ of $thm$, for
|
| 104 | 99 |
$i=n$, \ldots,~1. This applies $thm@n$, \ldots, $thm@1$ to the first $n$ |
100 |
premises of $thm$. Because the theorems are used from right to left, it |
|
101 |
does not matter if the $thm@i$ create new premises. {\tt MRS} is useful
|
|
102 |
for expressing proof trees. |
|
103 |
||
| 151 | 104 |
\item[\tt$thms@1$ RLN $(i,thms@2)$] \indexbold{*RLN}
|
| 326 | 105 |
joins lists of theorems. For every $thm@1$ in $thms@1$ and $thm@2$ in |
106 |
$thms@2$, it resolves the conclusion of $thm@1$ with the $i$th premise |
|
107 |
of~$thm@2$, accumulating the results. |
|
| 104 | 108 |
|
| 151 | 109 |
\item[\tt$thms@1$ RL $thms@2$] \indexbold{*RL}
|
110 |
abbreviates \hbox{\tt$thms@1$ RLN $(1,thms@2)$}.
|
|
| 104 | 111 |
|
112 |
\item[\tt {$[thms@1,\ldots,thms@n]$} MRL $thms$] \indexbold{*MRL}
|
|
113 |
is analogous to {\tt MRS}, but combines theorem lists rather than theorems.
|
|
114 |
It too is useful for expressing proof trees. |
|
| 326 | 115 |
\end{ttdescription}
|
| 104 | 116 |
|
117 |
||
118 |
\subsection{Expanding definitions in theorems}
|
|
| 326 | 119 |
\index{meta-rewriting!in theorems}
|
| 104 | 120 |
\begin{ttbox}
|
121 |
rewrite_rule : thm list -> thm -> thm |
|
122 |
rewrite_goals_rule : thm list -> thm -> thm |
|
123 |
\end{ttbox}
|
|
| 326 | 124 |
\begin{ttdescription}
|
| 104 | 125 |
\item[\ttindexbold{rewrite_rule} {\it defs} {\it thm}]
|
126 |
unfolds the {\it defs} throughout the theorem~{\it thm}.
|
|
127 |
||
128 |
\item[\ttindexbold{rewrite_goals_rule} {\it defs} {\it thm}]
|
|
| 8136 | 129 |
unfolds the {\it defs} in the premises of~{\it thm}, but it leaves the
|
130 |
conclusion unchanged. This rule is the basis for \ttindex{rewrite_goals_tac},
|
|
131 |
but it serves little purpose in forward proof. |
|
| 326 | 132 |
\end{ttdescription}
|
| 104 | 133 |
|
134 |
||
| 4383 | 135 |
\subsection{Instantiating unknowns in a theorem} \label{sec:instantiate}
|
| 326 | 136 |
\index{instantiation}
|
| 8136 | 137 |
\begin{alltt}\footnotesize
|
| 4383 | 138 |
read_instantiate : (string*string) list -> thm -> thm |
139 |
read_instantiate_sg : Sign.sg -> (string*string) list -> thm -> thm |
|
140 |
cterm_instantiate : (cterm*cterm) list -> thm -> thm |
|
141 |
instantiate' : ctyp option list -> cterm option list -> thm -> thm |
|
| 8136 | 142 |
\end{alltt}
|
| 104 | 143 |
These meta-rules instantiate type and term unknowns in a theorem. They are |
144 |
occasionally useful. They can prevent difficulties with higher-order |
|
145 |
unification, and define specialized versions of rules. |
|
| 326 | 146 |
\begin{ttdescription}
|
| 104 | 147 |
\item[\ttindexbold{read_instantiate} {\it insts} {\it thm}]
|
148 |
processes the instantiations {\it insts} and instantiates the rule~{\it
|
|
149 |
thm}. The processing of instantiations is described |
|
| 326 | 150 |
in \S\ref{res_inst_tac}, under {\tt res_inst_tac}.
|
| 104 | 151 |
|
152 |
Use {\tt res_inst_tac}, not {\tt read_instantiate}, to instantiate a rule
|
|
153 |
and refine a particular subgoal. The tactic allows instantiation by the |
|
154 |
subgoal's parameters, and reads the instantiations using the signature |
|
| 326 | 155 |
associated with the proof state. |
156 |
||
157 |
Use {\tt read_instantiate_sg} below if {\it insts\/} appears to be treated
|
|
158 |
incorrectly. |
|
| 104 | 159 |
|
| 326 | 160 |
\item[\ttindexbold{read_instantiate_sg} {\it sg} {\it insts} {\it thm}]
|
|
4597
a0bdee64194c
Fixed a lot of overfull and underfull lines (hboxes)
paulson
parents:
4383
diff
changeset
|
161 |
is like \texttt{read_instantiate {\it insts}~{\it thm}}, but it reads
|
| 326 | 162 |
the instantiations under signature~{\it sg}. This is necessary to
|
163 |
instantiate a rule from a general theory, such as first-order logic, |
|
164 |
using the notation of some specialized theory. Use the function {\tt
|
|
165 |
sign_of} to get a theory's signature. |
|
| 104 | 166 |
|
167 |
\item[\ttindexbold{cterm_instantiate} {\it ctpairs} {\it thm}]
|
|
168 |
is similar to {\tt read_instantiate}, but the instantiations are provided
|
|
169 |
as pairs of certified terms, not as strings to be read. |
|
| 4317 | 170 |
|
171 |
\item[\ttindexbold{instantiate'} {\it ctyps} {\it cterms} {\it thm}]
|
|
172 |
instantiates {\it thm} according to the positional arguments {\it
|
|
173 |
ctyps} and {\it cterms}. Counting from left to right, schematic
|
|
174 |
variables $?x$ are either replaced by $t$ for any argument |
|
175 |
\texttt{Some\(\;t\)}, or left unchanged in case of \texttt{None} or
|
|
176 |
if the end of the argument list is encountered. Types are |
|
177 |
instantiated before terms. |
|
178 |
||
| 326 | 179 |
\end{ttdescription}
|
| 104 | 180 |
|
181 |
||
|
866
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents:
332
diff
changeset
|
182 |
\subsection{Miscellaneous forward rules}\label{MiscellaneousForwardRules}
|
| 326 | 183 |
\index{theorems!standardizing}
|
| 104 | 184 |
\begin{ttbox}
|
| 332 | 185 |
standard : thm -> thm |
186 |
zero_var_indexes : thm -> thm |
|
187 |
make_elim : thm -> thm |
|
| 104 | 188 |
rule_by_tactic : tactic -> thm -> thm |
| 4607 | 189 |
rotate_prems : int -> thm -> thm |
| 104 | 190 |
\end{ttbox}
|
| 326 | 191 |
\begin{ttdescription}
|
| 3108 | 192 |
\item[\ttindexbold{standard} $thm$] puts $thm$ into the standard form
|
193 |
of object-rules. It discharges all meta-assumptions, replaces free |
|
194 |
variables by schematic variables, renames schematic variables to |
|
195 |
have subscript zero, also strips outer (meta) quantifiers and |
|
196 |
removes dangling sort hypotheses. |
|
| 104 | 197 |
|
198 |
\item[\ttindexbold{zero_var_indexes} $thm$]
|
|
199 |
makes all schematic variables have subscript zero, renaming them to avoid |
|
200 |
clashes. |
|
201 |
||
202 |
\item[\ttindexbold{make_elim} $thm$]
|
|
203 |
\index{rules!converting destruction to elimination}
|
|
| 8136 | 204 |
converts $thm$, which should be a destruction rule of the form |
205 |
$\List{P@1;\ldots;P@m}\Imp
|
|
| 104 | 206 |
Q$, to the elimination rule $\List{P@1; \ldots; P@m; Q\Imp R}\Imp R$. This
|
207 |
is the basis for destruct-resolution: {\tt dresolve_tac}, etc.
|
|
208 |
||
209 |
\item[\ttindexbold{rule_by_tactic} {\it tac} {\it thm}]
|
|
210 |
applies {\it tac\/} to the {\it thm}, freezing its variables first, then
|
|
211 |
yields the proof state returned by the tactic. In typical usage, the |
|
212 |
{\it thm\/} represents an instance of a rule with several premises, some
|
|
213 |
with contradictory assumptions (because of the instantiation). The |
|
214 |
tactic proves those subgoals and does whatever else it can, and returns |
|
215 |
whatever is left. |
|
| 4607 | 216 |
|
217 |
\item[\ttindexbold{rotate_prems} $k$ $thm$] rotates the premises of $thm$ to
|
|
218 |
the left by~$k$ positions. It requires $0\leq k\leq n$, where $n$ is the |
|
219 |
number of premises; the rotation has no effect if $k$ is at either extreme. |
|
220 |
Used with \texttt{eresolve_tac}\index{*eresolve_tac!on other than first
|
|
221 |
premise}, it gives the effect of applying the tactic to some other premise |
|
222 |
of $thm$ than the first. |
|
| 326 | 223 |
\end{ttdescription}
|
| 104 | 224 |
|
225 |
||
226 |
\subsection{Taking a theorem apart}
|
|
| 326 | 227 |
\index{theorems!taking apart}
|
| 104 | 228 |
\index{flex-flex constraints}
|
229 |
\begin{ttbox}
|
|
| 4317 | 230 |
cprop_of : thm -> cterm |
| 104 | 231 |
concl_of : thm -> term |
232 |
prems_of : thm -> term list |
|
| 4317 | 233 |
cprems_of : thm -> cterm list |
| 104 | 234 |
nprems_of : thm -> int |
| 4383 | 235 |
tpairs_of : thm -> (term*term) list |
| 4317 | 236 |
sign_of_thm : thm -> Sign.sg |
|
866
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents:
332
diff
changeset
|
237 |
theory_of_thm : thm -> theory |
| 8136 | 238 |
dest_state : thm * int -> (term*term) list * term list * term * term |
239 |
rep_thm : thm -> \{sign_ref: Sign.sg_ref, der: deriv, maxidx: int,
|
|
240 |
shyps: sort list, hyps: term list, prop: term\} |
|
241 |
crep_thm : thm -> \{sign_ref: Sign.sg_ref, der: deriv, maxidx: int,
|
|
242 |
shyps: sort list, hyps: cterm list, prop:{\ts}cterm\}
|
|
| 104 | 243 |
\end{ttbox}
|
| 326 | 244 |
\begin{ttdescription}
|
| 4317 | 245 |
\item[\ttindexbold{cprop_of} $thm$] returns the statement of $thm$ as
|
246 |
a certified term. |
|
247 |
||
248 |
\item[\ttindexbold{concl_of} $thm$] returns the conclusion of $thm$ as
|
|
249 |
a term. |
|
250 |
||
251 |
\item[\ttindexbold{prems_of} $thm$] returns the premises of $thm$ as a
|
|
252 |
list of terms. |
|
253 |
||
254 |
\item[\ttindexbold{cprems_of} $thm$] returns the premises of $thm$ as
|
|
255 |
a list of certified terms. |
|
| 104 | 256 |
|
257 |
\item[\ttindexbold{nprems_of} $thm$]
|
|
| 286 | 258 |
returns the number of premises in $thm$, and is equivalent to {\tt
|
| 4317 | 259 |
length~(prems_of~$thm$)}. |
| 104 | 260 |
|
| 4317 | 261 |
\item[\ttindexbold{tpairs_of} $thm$] returns the flex-flex constraints
|
262 |
of $thm$. |
|
263 |
||
264 |
\item[\ttindexbold{sign_of_thm} $thm$] returns the signature
|
|
265 |
associated with $thm$. |
|
266 |
||
267 |
\item[\ttindexbold{theory_of_thm} $thm$] returns the theory associated
|
|
268 |
with $thm$. Note that this does a lookup in Isabelle's global |
|
269 |
database of loaded theories. |
|
|
866
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents:
332
diff
changeset
|
270 |
|
| 104 | 271 |
\item[\ttindexbold{dest_state} $(thm,i)$]
|
272 |
decomposes $thm$ as a tuple containing a list of flex-flex constraints, a |
|
273 |
list of the subgoals~1 to~$i-1$, subgoal~$i$, and the rest of the theorem |
|
274 |
(this will be an implication if there are more than $i$ subgoals). |
|
275 |
||
| 4317 | 276 |
\item[\ttindexbold{rep_thm} $thm$] decomposes $thm$ as a record
|
277 |
containing the statement of~$thm$ ({\tt prop}), its list of
|
|
278 |
meta-assumptions ({\tt hyps}), its derivation ({\tt der}), a bound
|
|
279 |
on the maximum subscript of its unknowns ({\tt maxidx}), and a
|
|
280 |
reference to its signature ({\tt sign_ref}). The {\tt shyps} field
|
|
281 |
is discussed below. |
|
282 |
||
283 |
\item[\ttindexbold{crep_thm} $thm$] like \texttt{rep_thm}, but returns
|
|
284 |
the hypotheses and statement as certified terms. |
|
285 |
||
|
2040
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
286 |
\end{ttdescription}
|
|
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
287 |
|
|
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
288 |
|
| 5777 | 289 |
\subsection{*Sort hypotheses} \label{sec:sort-hyps}
|
|
2040
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
290 |
\index{sort hypotheses}
|
|
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
291 |
\begin{ttbox}
|
| 7644 | 292 |
strip_shyps : thm -> thm |
293 |
strip_shyps_warning : thm -> thm |
|
|
2040
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
294 |
\end{ttbox}
|
|
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
295 |
|
|
2044
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
paulson
parents:
2040
diff
changeset
|
296 |
Isabelle's type variables are decorated with sorts, constraining them to |
|
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
paulson
parents:
2040
diff
changeset
|
297 |
certain ranges of types. This has little impact when sorts only serve for |
|
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
paulson
parents:
2040
diff
changeset
|
298 |
syntactic classification of types --- for example, FOL distinguishes between |
|
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
paulson
parents:
2040
diff
changeset
|
299 |
terms and other types. But when type classes are introduced through axioms, |
|
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
paulson
parents:
2040
diff
changeset
|
300 |
this may result in some sorts becoming {\em empty\/}: where one cannot exhibit
|
| 4317 | 301 |
a type belonging to it because certain sets of axioms are unsatisfiable. |
|
2044
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
paulson
parents:
2040
diff
changeset
|
302 |
|
| 3108 | 303 |
If a theorem contains a type variable that is constrained by an empty |
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3135
diff
changeset
|
304 |
sort, then that theorem has no instances. It is basically an instance |
| 3108 | 305 |
of {\em ex falso quodlibet}. But what if it is used to prove another
|
306 |
theorem that no longer involves that sort? The latter theorem holds |
|
307 |
only if under an additional non-emptiness assumption. |
|
|
2040
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
308 |
|
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3135
diff
changeset
|
309 |
Therefore, Isabelle's theorems carry around sort hypotheses. The {\tt
|
|
2044
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
paulson
parents:
2040
diff
changeset
|
310 |
shyps} field is a list of sorts occurring in type variables in the current |
|
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
paulson
parents:
2040
diff
changeset
|
311 |
{\tt prop} and {\tt hyps} fields. It may also includes sorts used in the
|
|
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
paulson
parents:
2040
diff
changeset
|
312 |
theorem's proof that no longer appear in the {\tt prop} or {\tt hyps}
|
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3135
diff
changeset
|
313 |
fields --- so-called {\em dangling\/} sort constraints. These are the
|
|
2044
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
paulson
parents:
2040
diff
changeset
|
314 |
critical ones, asserting non-emptiness of the corresponding sorts. |
|
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
paulson
parents:
2040
diff
changeset
|
315 |
|
| 7644 | 316 |
Isabelle automatically removes extraneous sorts from the {\tt shyps} field at
|
317 |
the end of a proof, provided that non-emptiness can be established by looking |
|
318 |
at the theorem's signature: from the {\tt classes} and {\tt arities}
|
|
319 |
information. This operation is performed by \texttt{strip_shyps} and
|
|
320 |
\texttt{strip_shyps_warning}.
|
|
321 |
||
322 |
\begin{ttdescription}
|
|
323 |
||
324 |
\item[\ttindexbold{strip_shyps} $thm$] removes any extraneous sort hypotheses
|
|
325 |
that can be witnessed from the type signature. |
|
326 |
||
327 |
\item[\ttindexbold{strip_shyps_warning}] is like \texttt{strip_shyps}, but
|
|
328 |
issues a warning message of any pending sort hypotheses that do not have a |
|
329 |
(syntactic) witness. |
|
330 |
||
331 |
\end{ttdescription}
|
|
|
2040
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
332 |
|
| 104 | 333 |
|
334 |
\subsection{Tracing flags for unification}
|
|
| 326 | 335 |
\index{tracing!of unification}
|
| 104 | 336 |
\begin{ttbox}
|
| 8136 | 337 |
Unify.trace_simp : bool ref \hfill\textbf{initially false}
|
338 |
Unify.trace_types : bool ref \hfill\textbf{initially false}
|
|
339 |
Unify.trace_bound : int ref \hfill\textbf{initially 10}
|
|
340 |
Unify.search_bound : int ref \hfill\textbf{initially 20}
|
|
| 104 | 341 |
\end{ttbox}
|
342 |
Tracing the search may be useful when higher-order unification behaves |
|
343 |
unexpectedly. Letting {\tt res_inst_tac} circumvent the problem is easier,
|
|
344 |
though. |
|
| 326 | 345 |
\begin{ttdescription}
|
| 4317 | 346 |
\item[set Unify.trace_simp;] |
| 104 | 347 |
causes tracing of the simplification phase. |
348 |
||
| 4317 | 349 |
\item[set Unify.trace_types;] |
| 104 | 350 |
generates warnings of incompleteness, when unification is not considering |
351 |
all possible instantiations of type unknowns. |
|
352 |
||
| 326 | 353 |
\item[Unify.trace_bound := $n$;] |
| 104 | 354 |
causes unification to print tracing information once it reaches depth~$n$. |
355 |
Use $n=0$ for full tracing. At the default value of~10, tracing |
|
356 |
information is almost never printed. |
|
357 |
||
| 8136 | 358 |
\item[Unify.search_bound := $n$;] prevents unification from |
359 |
searching past the depth~$n$. Because of this bound, higher-order |
|
| 4317 | 360 |
unification cannot return an infinite sequence, though it can return |
| 8136 | 361 |
an exponentially long one. The search rarely approaches the default value |
| 4317 | 362 |
of~20. If the search is cut off, unification prints a warning |
363 |
\texttt{Unification bound exceeded}.
|
|
| 326 | 364 |
\end{ttdescription}
|
| 104 | 365 |
|
366 |
||
| 4317 | 367 |
\section{*Primitive meta-level inference rules}
|
| 104 | 368 |
\index{meta-rules|(}
|
| 4317 | 369 |
These implement the meta-logic in the style of the {\sc lcf} system,
|
370 |
as functions from theorems to theorems. They are, rarely, useful for |
|
371 |
deriving results in the pure theory. Mainly, they are included for |
|
372 |
completeness, and most users should not bother with them. The |
|
373 |
meta-rules raise exception \xdx{THM} to signal malformed premises,
|
|
374 |
incompatible signatures and similar errors. |
|
| 104 | 375 |
|
| 326 | 376 |
\index{meta-assumptions}
|
| 104 | 377 |
The meta-logic uses natural deduction. Each theorem may depend on |
| 332 | 378 |
meta-level assumptions. Certain rules, such as $({\Imp}I)$,
|
| 104 | 379 |
discharge assumptions; in most other rules, the conclusion depends on all |
380 |
of the assumptions of the premises. Formally, the system works with |
|
381 |
assertions of the form |
|
382 |
\[ \phi \quad [\phi@1,\ldots,\phi@n], \] |
|
| 3108 | 383 |
where $\phi@1$,~\ldots,~$\phi@n$ are the assumptions. This can be |
384 |
also read as a single conclusion sequent $\phi@1,\ldots,\phi@n \vdash |
|
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3135
diff
changeset
|
385 |
\phi$. Do not confuse meta-level assumptions with the object-level |
| 3108 | 386 |
assumptions in a subgoal, which are represented in the meta-logic |
387 |
using~$\Imp$. |
|
| 104 | 388 |
|
389 |
Each theorem has a signature. Certified terms have a signature. When a |
|
390 |
rule takes several premises and certified terms, it merges the signatures |
|
391 |
to make a signature for the conclusion. This fails if the signatures are |
|
392 |
incompatible. |
|
393 |
||
| 5777 | 394 |
\medskip |
395 |
||
396 |
The following presentation of primitive rules ignores sort |
|
397 |
hypotheses\index{sort hypotheses} (see also \S\ref{sec:sort-hyps}). These are
|
|
398 |
handled transparently by the logic implementation. |
|
399 |
||
400 |
\bigskip |
|
401 |
||
| 326 | 402 |
\index{meta-implication}
|
| 8136 | 403 |
The \textbf{implication} rules are $({\Imp}I)$
|
| 104 | 404 |
and $({\Imp}E)$:
|
405 |
\[ \infer[({\Imp}I)]{\phi\Imp \psi}{\infer*{\psi}{[\phi]}} \qquad
|
|
406 |
\infer[({\Imp}E)]{\psi}{\phi\Imp \psi & \phi} \]
|
|
407 |
||
| 326 | 408 |
\index{meta-equality}
|
| 104 | 409 |
Equality of truth values means logical equivalence: |
| 3524 | 410 |
\[ \infer[({\equiv}I)]{\phi\equiv\psi}{\phi\Imp\psi &
|
411 |
\psi\Imp\phi} |
|
| 104 | 412 |
\qquad |
413 |
\infer[({\equiv}E)]{\psi}{\phi\equiv \psi & \phi} \]
|
|
414 |
||
| 8136 | 415 |
The \textbf{equality} rules are reflexivity, symmetry, and transitivity:
|
| 104 | 416 |
\[ {a\equiv a}\,(refl) \qquad
|
417 |
\infer[(sym)]{b\equiv a}{a\equiv b} \qquad
|
|
418 |
\infer[(trans)]{a\equiv c}{a\equiv b & b\equiv c} \]
|
|
419 |
||
| 326 | 420 |
\index{lambda calc@$\lambda$-calculus}
|
| 104 | 421 |
The $\lambda$-conversions are $\alpha$-conversion, $\beta$-conversion, and |
422 |
extensionality:\footnote{$\alpha$-conversion holds if $y$ is not free
|
|
423 |
in~$a$; $(ext)$ holds if $x$ is not free in the assumptions, $f$, or~$g$.} |
|
424 |
\[ {(\lambda x.a) \equiv (\lambda y.a[y/x])} \qquad
|
|
425 |
{((\lambda x.a)(b)) \equiv a[b/x]} \qquad
|
|
426 |
\infer[(ext)]{f\equiv g}{f(x) \equiv g(x)} \]
|
|
427 |
||
| 8136 | 428 |
The \textbf{abstraction} and \textbf{combination} rules let conversions be
|
| 332 | 429 |
applied to subterms:\footnote{Abstraction holds if $x$ is not free in the
|
| 104 | 430 |
assumptions.} |
431 |
\[ \infer[(abs)]{(\lambda x.a) \equiv (\lambda x.b)}{a\equiv b} \qquad
|
|
432 |
\infer[(comb)]{f(a)\equiv g(b)}{f\equiv g & a\equiv b} \]
|
|
433 |
||
| 326 | 434 |
\index{meta-quantifiers}
|
| 8136 | 435 |
The \textbf{universal quantification} rules are $(\Forall I)$ and $(\Forall
|
| 104 | 436 |
E)$:\footnote{$(\Forall I)$ holds if $x$ is not free in the assumptions.}
|
437 |
\[ \infer[(\Forall I)]{\Forall x.\phi}{\phi} \qquad
|
|
| 286 | 438 |
\infer[(\Forall E)]{\phi[b/x]}{\Forall x.\phi} \]
|
| 104 | 439 |
|
440 |
||
| 326 | 441 |
\subsection{Assumption rule}
|
442 |
\index{meta-assumptions}
|
|
| 104 | 443 |
\begin{ttbox}
|
| 3108 | 444 |
assume: cterm -> thm |
| 104 | 445 |
\end{ttbox}
|
| 326 | 446 |
\begin{ttdescription}
|
| 104 | 447 |
\item[\ttindexbold{assume} $ct$]
|
| 332 | 448 |
makes the theorem \(\phi \;[\phi]\), where $\phi$ is the value of~$ct$. |
| 104 | 449 |
The rule checks that $ct$ has type $prop$ and contains no unknowns, which |
| 332 | 450 |
are not allowed in assumptions. |
| 326 | 451 |
\end{ttdescription}
|
| 104 | 452 |
|
| 326 | 453 |
\subsection{Implication rules}
|
454 |
\index{meta-implication}
|
|
| 104 | 455 |
\begin{ttbox}
|
| 3108 | 456 |
implies_intr : cterm -> thm -> thm |
457 |
implies_intr_list : cterm list -> thm -> thm |
|
| 104 | 458 |
implies_intr_hyps : thm -> thm |
459 |
implies_elim : thm -> thm -> thm |
|
460 |
implies_elim_list : thm -> thm list -> thm |
|
461 |
\end{ttbox}
|
|
| 326 | 462 |
\begin{ttdescription}
|
| 104 | 463 |
\item[\ttindexbold{implies_intr} $ct$ $thm$]
|
464 |
is $({\Imp}I)$, where $ct$ is the assumption to discharge, say~$\phi$. It
|
|
| 332 | 465 |
maps the premise~$\psi$ to the conclusion $\phi\Imp\psi$, removing all |
466 |
occurrences of~$\phi$ from the assumptions. The rule checks that $ct$ has |
|
467 |
type $prop$. |
|
| 104 | 468 |
|
469 |
\item[\ttindexbold{implies_intr_list} $cts$ $thm$]
|
|
470 |
applies $({\Imp}I)$ repeatedly, on every element of the list~$cts$.
|
|
471 |
||
472 |
\item[\ttindexbold{implies_intr_hyps} $thm$]
|
|
| 332 | 473 |
applies $({\Imp}I)$ to discharge all the hypotheses (assumptions) of~$thm$.
|
474 |
It maps the premise $\phi \; [\phi@1,\ldots,\phi@n]$ to the conclusion |
|
| 104 | 475 |
$\List{\phi@1,\ldots,\phi@n}\Imp\phi$.
|
476 |
||
477 |
\item[\ttindexbold{implies_elim} $thm@1$ $thm@2$]
|
|
478 |
applies $({\Imp}E)$ to $thm@1$ and~$thm@2$. It maps the premises $\phi\Imp
|
|
479 |
\psi$ and $\phi$ to the conclusion~$\psi$. |
|
480 |
||
481 |
\item[\ttindexbold{implies_elim_list} $thm$ $thms$]
|
|
482 |
applies $({\Imp}E)$ repeatedly to $thm$, using each element of~$thms$ in
|
|
| 151 | 483 |
turn. It maps the premises $\List{\phi@1,\ldots,\phi@n}\Imp\psi$ and
|
| 104 | 484 |
$\phi@1$,\ldots,$\phi@n$ to the conclusion~$\psi$. |
| 326 | 485 |
\end{ttdescription}
|
| 104 | 486 |
|
| 326 | 487 |
\subsection{Logical equivalence rules}
|
488 |
\index{meta-equality}
|
|
| 104 | 489 |
\begin{ttbox}
|
| 326 | 490 |
equal_intr : thm -> thm -> thm |
491 |
equal_elim : thm -> thm -> thm |
|
| 104 | 492 |
\end{ttbox}
|
| 326 | 493 |
\begin{ttdescription}
|
| 104 | 494 |
\item[\ttindexbold{equal_intr} $thm@1$ $thm@2$]
|
| 332 | 495 |
applies $({\equiv}I)$ to $thm@1$ and~$thm@2$. It maps the premises~$\psi$
|
496 |
and~$\phi$ to the conclusion~$\phi\equiv\psi$; the assumptions are those of |
|
497 |
the first premise with~$\phi$ removed, plus those of |
|
498 |
the second premise with~$\psi$ removed. |
|
| 104 | 499 |
|
500 |
\item[\ttindexbold{equal_elim} $thm@1$ $thm@2$]
|
|
501 |
applies $({\equiv}E)$ to $thm@1$ and~$thm@2$. It maps the premises
|
|
502 |
$\phi\equiv\psi$ and $\phi$ to the conclusion~$\psi$. |
|
| 326 | 503 |
\end{ttdescription}
|
| 104 | 504 |
|
505 |
||
506 |
\subsection{Equality rules}
|
|
| 326 | 507 |
\index{meta-equality}
|
| 104 | 508 |
\begin{ttbox}
|
| 3108 | 509 |
reflexive : cterm -> thm |
| 104 | 510 |
symmetric : thm -> thm |
511 |
transitive : thm -> thm -> thm |
|
512 |
\end{ttbox}
|
|
| 326 | 513 |
\begin{ttdescription}
|
| 104 | 514 |
\item[\ttindexbold{reflexive} $ct$]
|
| 151 | 515 |
makes the theorem \(ct\equiv ct\). |
| 104 | 516 |
|
517 |
\item[\ttindexbold{symmetric} $thm$]
|
|
518 |
maps the premise $a\equiv b$ to the conclusion $b\equiv a$. |
|
519 |
||
520 |
\item[\ttindexbold{transitive} $thm@1$ $thm@2$]
|
|
521 |
maps the premises $a\equiv b$ and $b\equiv c$ to the conclusion~${a\equiv c}$.
|
|
| 326 | 522 |
\end{ttdescription}
|
| 104 | 523 |
|
524 |
||
525 |
\subsection{The $\lambda$-conversion rules}
|
|
| 326 | 526 |
\index{lambda calc@$\lambda$-calculus}
|
| 104 | 527 |
\begin{ttbox}
|
| 3108 | 528 |
beta_conversion : cterm -> thm |
| 104 | 529 |
extensional : thm -> thm |
| 3108 | 530 |
abstract_rule : string -> cterm -> thm -> thm |
| 104 | 531 |
combination : thm -> thm -> thm |
532 |
\end{ttbox}
|
|
| 326 | 533 |
There is no rule for $\alpha$-conversion because Isabelle regards |
534 |
$\alpha$-convertible theorems as equal. |
|
535 |
\begin{ttdescription}
|
|
| 104 | 536 |
\item[\ttindexbold{beta_conversion} $ct$]
|
537 |
makes the theorem $((\lambda x.a)(b)) \equiv a[b/x]$, where $ct$ is the |
|
538 |
term $(\lambda x.a)(b)$. |
|
539 |
||
540 |
\item[\ttindexbold{extensional} $thm$]
|
|
541 |
maps the premise $f(x) \equiv g(x)$ to the conclusion $f\equiv g$. |
|
542 |
Parameter~$x$ is taken from the premise. It may be an unknown or a free |
|
| 332 | 543 |
variable (provided it does not occur in the assumptions); it must not occur |
| 104 | 544 |
in $f$ or~$g$. |
545 |
||
546 |
\item[\ttindexbold{abstract_rule} $v$ $x$ $thm$]
|
|
547 |
maps the premise $a\equiv b$ to the conclusion $(\lambda x.a) \equiv |
|
548 |
(\lambda x.b)$, abstracting over all occurrences (if any!) of~$x$. |
|
549 |
Parameter~$x$ is supplied as a cterm. It may be an unknown or a free |
|
| 332 | 550 |
variable (provided it does not occur in the assumptions). In the |
| 104 | 551 |
conclusion, the bound variable is named~$v$. |
552 |
||
553 |
\item[\ttindexbold{combination} $thm@1$ $thm@2$]
|
|
554 |
maps the premises $f\equiv g$ and $a\equiv b$ to the conclusion~$f(a)\equiv |
|
555 |
g(b)$. |
|
| 326 | 556 |
\end{ttdescription}
|
| 104 | 557 |
|
558 |
||
| 326 | 559 |
\subsection{Forall introduction rules}
|
560 |
\index{meta-quantifiers}
|
|
| 104 | 561 |
\begin{ttbox}
|
| 3108 | 562 |
forall_intr : cterm -> thm -> thm |
563 |
forall_intr_list : cterm list -> thm -> thm |
|
564 |
forall_intr_frees : thm -> thm |
|
| 104 | 565 |
\end{ttbox}
|
566 |
||
| 326 | 567 |
\begin{ttdescription}
|
| 104 | 568 |
\item[\ttindexbold{forall_intr} $x$ $thm$]
|
569 |
applies $({\Forall}I)$, abstracting over all occurrences (if any!) of~$x$.
|
|
570 |
The rule maps the premise $\phi$ to the conclusion $\Forall x.\phi$. |
|
571 |
Parameter~$x$ is supplied as a cterm. It may be an unknown or a free |
|
| 332 | 572 |
variable (provided it does not occur in the assumptions). |
| 104 | 573 |
|
574 |
\item[\ttindexbold{forall_intr_list} $xs$ $thm$]
|
|
575 |
applies $({\Forall}I)$ repeatedly, on every element of the list~$xs$.
|
|
576 |
||
577 |
\item[\ttindexbold{forall_intr_frees} $thm$]
|
|
578 |
applies $({\Forall}I)$ repeatedly, generalizing over all the free variables
|
|
579 |
of the premise. |
|
| 326 | 580 |
\end{ttdescription}
|
| 104 | 581 |
|
582 |
||
| 326 | 583 |
\subsection{Forall elimination rules}
|
| 104 | 584 |
\begin{ttbox}
|
| 3108 | 585 |
forall_elim : cterm -> thm -> thm |
586 |
forall_elim_list : cterm list -> thm -> thm |
|
587 |
forall_elim_var : int -> thm -> thm |
|
588 |
forall_elim_vars : int -> thm -> thm |
|
| 104 | 589 |
\end{ttbox}
|
590 |
||
| 326 | 591 |
\begin{ttdescription}
|
| 104 | 592 |
\item[\ttindexbold{forall_elim} $ct$ $thm$]
|
593 |
applies $({\Forall}E)$, mapping the premise $\Forall x.\phi$ to the conclusion
|
|
594 |
$\phi[ct/x]$. The rule checks that $ct$ and $x$ have the same type. |
|
595 |
||
596 |
\item[\ttindexbold{forall_elim_list} $cts$ $thm$]
|
|
597 |
applies $({\Forall}E)$ repeatedly, on every element of the list~$cts$.
|
|
598 |
||
599 |
\item[\ttindexbold{forall_elim_var} $k$ $thm$]
|
|
600 |
applies $({\Forall}E)$, mapping the premise $\Forall x.\phi$ to the conclusion
|
|
601 |
$\phi[\Var{x@k}/x]$. Thus, it replaces the outermost $\Forall$-bound
|
|
602 |
variable by an unknown having subscript~$k$. |
|
603 |
||
604 |
\item[\ttindexbold{forall_elim_vars} $ks$ $thm$]
|
|
605 |
applies {\tt forall_elim_var} repeatedly, for every element of the list~$ks$.
|
|
| 326 | 606 |
\end{ttdescription}
|
| 104 | 607 |
|
|
8135
ad1c4a678196
Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents:
7871
diff
changeset
|
608 |
|
| 326 | 609 |
\subsection{Instantiation of unknowns}
|
610 |
\index{instantiation}
|
|
| 8136 | 611 |
\begin{alltt}\footnotesize
|
| 3135 | 612 |
instantiate: (indexname * ctyp){\thinspace}list * (cterm * cterm){\thinspace}list -> thm -> thm
|
| 8136 | 613 |
\end{alltt}
|
|
8135
ad1c4a678196
Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents:
7871
diff
changeset
|
614 |
There are two versions of this rule. The primitive one is |
|
ad1c4a678196
Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents:
7871
diff
changeset
|
615 |
\ttindexbold{Thm.instantiate}, which merely performs the instantiation and can
|
|
ad1c4a678196
Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents:
7871
diff
changeset
|
616 |
produce a conclusion not in normal form. A derived version is |
|
ad1c4a678196
Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents:
7871
diff
changeset
|
617 |
\ttindexbold{Drule.instantiate}, which normalizes its conclusion.
|
|
ad1c4a678196
Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents:
7871
diff
changeset
|
618 |
|
| 326 | 619 |
\begin{ttdescription}
|
| 8136 | 620 |
\item[\ttindexbold{instantiate} ($tyinsts$,$insts$) $thm$]
|
| 326 | 621 |
simultaneously substitutes types for type unknowns (the |
| 104 | 622 |
$tyinsts$) and terms for term unknowns (the $insts$). Instantiations are |
623 |
given as $(v,t)$ pairs, where $v$ is an unknown and $t$ is a term (of the |
|
624 |
same type as $v$) or a type (of the same sort as~$v$). All the unknowns |
|
|
8135
ad1c4a678196
Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents:
7871
diff
changeset
|
625 |
must be distinct. |
| 4376 | 626 |
|
|
8135
ad1c4a678196
Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents:
7871
diff
changeset
|
627 |
In some cases, \ttindex{instantiate'} (see \S\ref{sec:instantiate})
|
| 4376 | 628 |
provides a more convenient interface to this rule. |
| 326 | 629 |
\end{ttdescription}
|
| 104 | 630 |
|
631 |
||
|
8135
ad1c4a678196
Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents:
7871
diff
changeset
|
632 |
|
|
ad1c4a678196
Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents:
7871
diff
changeset
|
633 |
|
| 326 | 634 |
\subsection{Freezing/thawing type unknowns}
|
635 |
\index{type unknowns!freezing/thawing of}
|
|
| 104 | 636 |
\begin{ttbox}
|
637 |
freezeT: thm -> thm |
|
638 |
varifyT: thm -> thm |
|
639 |
\end{ttbox}
|
|
| 326 | 640 |
\begin{ttdescription}
|
| 104 | 641 |
\item[\ttindexbold{freezeT} $thm$]
|
642 |
converts all the type unknowns in $thm$ to free type variables. |
|
643 |
||
644 |
\item[\ttindexbold{varifyT} $thm$]
|
|
645 |
converts all the free type variables in $thm$ to type unknowns. |
|
| 326 | 646 |
\end{ttdescription}
|
| 104 | 647 |
|
648 |
||
649 |
\section{Derived rules for goal-directed proof}
|
|
650 |
Most of these rules have the sole purpose of implementing particular |
|
651 |
tactics. There are few occasions for applying them directly to a theorem. |
|
652 |
||
653 |
\subsection{Proof by assumption}
|
|
| 326 | 654 |
\index{meta-assumptions}
|
| 104 | 655 |
\begin{ttbox}
|
| 4276 | 656 |
assumption : int -> thm -> thm Seq.seq |
| 104 | 657 |
eq_assumption : int -> thm -> thm |
658 |
\end{ttbox}
|
|
| 326 | 659 |
\begin{ttdescription}
|
| 104 | 660 |
\item[\ttindexbold{assumption} {\it i} $thm$]
|
661 |
attempts to solve premise~$i$ of~$thm$ by assumption. |
|
662 |
||
663 |
\item[\ttindexbold{eq_assumption}]
|
|
664 |
is like {\tt assumption} but does not use unification.
|
|
| 326 | 665 |
\end{ttdescription}
|
| 104 | 666 |
|
667 |
||
668 |
\subsection{Resolution}
|
|
| 326 | 669 |
\index{resolution}
|
| 104 | 670 |
\begin{ttbox}
|
671 |
biresolution : bool -> (bool*thm)list -> int -> thm |
|
| 4276 | 672 |
-> thm Seq.seq |
| 104 | 673 |
\end{ttbox}
|
| 326 | 674 |
\begin{ttdescription}
|
| 104 | 675 |
\item[\ttindexbold{biresolution} $match$ $rules$ $i$ $state$]
|
| 326 | 676 |
performs bi-resolution on subgoal~$i$ of $state$, using the list of $\it |
| 104 | 677 |
(flag,rule)$ pairs. For each pair, it applies resolution if the flag |
678 |
is~{\tt false} and elim-resolution if the flag is~{\tt true}. If $match$
|
|
679 |
is~{\tt true}, the $state$ is not instantiated.
|
|
| 326 | 680 |
\end{ttdescription}
|
| 104 | 681 |
|
682 |
||
683 |
\subsection{Composition: resolution without lifting}
|
|
| 326 | 684 |
\index{resolution!without lifting}
|
| 104 | 685 |
\begin{ttbox}
|
686 |
compose : thm * int * thm -> thm list |
|
687 |
COMP : thm * thm -> thm |
|
688 |
bicompose : bool -> bool * thm * int -> int -> thm |
|
| 4276 | 689 |
-> thm Seq.seq |
| 104 | 690 |
\end{ttbox}
|
691 |
In forward proof, a typical use of composition is to regard an assertion of |
|
692 |
the form $\phi\Imp\psi$ as atomic. Schematic variables are not renamed, so |
|
693 |
beware of clashes! |
|
| 326 | 694 |
\begin{ttdescription}
|
| 104 | 695 |
\item[\ttindexbold{compose} ($thm@1$, $i$, $thm@2$)]
|
696 |
uses $thm@1$, regarded as an atomic formula, to solve premise~$i$ |
|
697 |
of~$thm@2$. Let $thm@1$ and $thm@2$ be $\psi$ and $\List{\phi@1; \ldots;
|
|
698 |
\phi@n} \Imp \phi$. For each $s$ that unifies~$\psi$ and $\phi@i$, the |
|
699 |
result list contains the theorem |
|
700 |
\[ (\List{\phi@1; \ldots; \phi@{i-1}; \phi@{i+1}; \ldots; \phi@n} \Imp \phi)s.
|
|
701 |
\] |
|
702 |
||
| 1119 | 703 |
\item[$thm@1$ \ttindexbold{COMP} $thm@2$]
|
| 104 | 704 |
calls \hbox{\tt compose ($thm@1$, 1, $thm@2$)} and returns the result, if
|
| 326 | 705 |
unique; otherwise, it raises exception~\xdx{THM}\@. It is
|
| 104 | 706 |
analogous to {\tt RS}\@.
|
707 |
||
708 |
For example, suppose that $thm@1$ is $a=b\Imp b=a$, a symmetry rule, and |
|
| 332 | 709 |
that $thm@2$ is $\List{P\Imp Q; \neg Q} \Imp\neg P$, which is the
|
| 104 | 710 |
principle of contrapositives. Then the result would be the |
711 |
derived rule $\neg(b=a)\Imp\neg(a=b)$. |
|
712 |
||
713 |
\item[\ttindexbold{bicompose} $match$ ($flag$, $rule$, $m$) $i$ $state$]
|
|
714 |
refines subgoal~$i$ of $state$ using $rule$, without lifting. The $rule$ |
|
715 |
is taken to have the form $\List{\psi@1; \ldots; \psi@m} \Imp \psi$, where
|
|
| 326 | 716 |
$\psi$ need not be atomic; thus $m$ determines the number of new |
| 104 | 717 |
subgoals. If $flag$ is {\tt true} then it performs elim-resolution --- it
|
718 |
solves the first premise of~$rule$ by assumption and deletes that |
|
719 |
assumption. If $match$ is~{\tt true}, the $state$ is not instantiated.
|
|
| 326 | 720 |
\end{ttdescription}
|
| 104 | 721 |
|
722 |
||
723 |
\subsection{Other meta-rules}
|
|
724 |
\begin{ttbox}
|
|
| 3108 | 725 |
trivial : cterm -> thm |
| 104 | 726 |
lift_rule : (thm * int) -> thm -> thm |
727 |
rename_params_rule : string list * int -> thm -> thm |
|
| 4276 | 728 |
flexflex_rule : thm -> thm Seq.seq |
| 104 | 729 |
\end{ttbox}
|
| 326 | 730 |
\begin{ttdescription}
|
| 104 | 731 |
\item[\ttindexbold{trivial} $ct$]
|
732 |
makes the theorem \(\phi\Imp\phi\), where $\phi$ is the value of~$ct$. |
|
733 |
This is the initial state for a goal-directed proof of~$\phi$. The rule |
|
734 |
checks that $ct$ has type~$prop$. |
|
735 |
||
736 |
\item[\ttindexbold{lift_rule} ($state$, $i$) $rule$] \index{lifting}
|
|
737 |
prepares $rule$ for resolution by lifting it over the parameters and |
|
738 |
assumptions of subgoal~$i$ of~$state$. |
|
739 |
||
740 |
\item[\ttindexbold{rename_params_rule} ({\it names}, {\it i}) $thm$]
|
|
741 |
uses the $names$ to rename the parameters of premise~$i$ of $thm$. The |
|
742 |
names must be distinct. If there are fewer names than parameters, then the |
|
743 |
rule renames the innermost parameters and may modify the remaining ones to |
|
744 |
ensure that all the parameters are distinct. |
|
745 |
\index{parameters!renaming}
|
|
746 |
||
747 |
\item[\ttindexbold{flexflex_rule} $thm$] \index{flex-flex constraints}
|
|
748 |
removes all flex-flex pairs from $thm$ using the trivial unifier. |
|
| 326 | 749 |
\end{ttdescription}
|
| 1590 | 750 |
\index{meta-rules|)}
|
751 |
||
752 |
||
| 1846 | 753 |
\section{Proof objects}\label{sec:proofObjects}
|
| 1590 | 754 |
\index{proof objects|(} Isabelle can record the full meta-level proof of each
|
755 |
theorem. The proof object contains all logical inferences in detail, while |
|
756 |
omitting bookkeeping steps that have no logical meaning to an outside |
|
757 |
observer. Rewriting steps are recorded in similar detail as the output of |
|
758 |
simplifier tracing. The proof object can be inspected by a separate |
|
| 4317 | 759 |
proof-checker, for example. |
| 1590 | 760 |
|
761 |
Full proof objects are large. They multiply storage requirements by about |
|
762 |
seven; attempts to build large logics (such as {\sc zf} and {\sc hol}) may
|
|
763 |
fail. Isabelle normally builds minimal proof objects, which include only uses |
|
764 |
of oracles. You can also request an intermediate level of detail, containing |
|
765 |
uses of oracles, axioms and theorems. These smaller proof objects indicate a |
|
|
6924
7e166f8d412e
Theorems involving oracles will be printed with a suffixed \verb|[!]|;
wenzelm
parents:
6097
diff
changeset
|
766 |
theorem's dependencies. Theorems involving oracles will be printed with a |
|
7e166f8d412e
Theorems involving oracles will be printed with a suffixed \verb|[!]|;
wenzelm
parents:
6097
diff
changeset
|
767 |
suffixed \verb|[!]| to point out the different quality of confidence achieved. |
| 1590 | 768 |
|
769 |
Isabelle provides proof objects for the sake of transparency. Their aim is to |
|
770 |
increase your confidence in Isabelle. They let you inspect proofs constructed |
|
771 |
by the classical reasoner or simplifier, and inform you of all uses of |
|
772 |
oracles. Seldom will proof objects be given whole to an automatic |
|
773 |
proof-checker: none has been written. It is up to you to examine and |
|
774 |
interpret them sensibly. For example, when scrutinizing a theorem's |
|
775 |
derivation for dependence upon some oracle or axiom, remember to scrutinize |
|
776 |
all of its lemmas. Their proofs are included in the main derivation, through |
|
777 |
the {\tt Theorem} constructor.
|
|
778 |
||
779 |
Proof objects are expressed using a polymorphic type of variable-branching |
|
780 |
trees. Proof objects (formally known as {\em derivations\/}) are trees
|
|
781 |
labelled by rules, where {\tt rule} is a complicated datatype declared in the
|
|
782 |
file {\tt Pure/thm.ML}.
|
|
783 |
\begin{ttbox}
|
|
784 |
datatype 'a mtree = Join of 'a * 'a mtree list; |
|
785 |
datatype rule = \(\ldots\); |
|
786 |
type deriv = rule mtree; |
|
787 |
\end{ttbox}
|
|
788 |
% |
|
789 |
Each theorem's derivation is stored as the {\tt der} field of its internal
|
|
790 |
record: |
|
791 |
\begin{ttbox}
|
|
792 |
#der (rep_thm conjI); |
|
| 6097 | 793 |
{\out Join (Theorem ("HOL.conjI", []), [Join (MinProof,[])]) : deriv}
|
| 1590 | 794 |
\end{ttbox}
|
| 4317 | 795 |
This proof object identifies a labelled theorem, {\tt conjI} of theory
|
796 |
\texttt{HOL}, whose underlying proof has not been recorded; all we
|
|
797 |
have is {\tt MinProof}.
|
|
| 1590 | 798 |
|
799 |
Nontrivial proof objects are unreadably large and complex. Isabelle provides |
|
800 |
several functions to help you inspect them informally. These functions omit |
|
801 |
the more obscure inferences and attempt to restructure the others into natural |
|
802 |
formats, linear or tree-structured. |
|
803 |
||
804 |
\begin{ttbox}
|
|
805 |
keep_derivs : deriv_kind ref |
|
806 |
Deriv.size : deriv -> int |
|
807 |
Deriv.drop : 'a mtree * int -> 'a mtree |
|
808 |
Deriv.linear : deriv -> deriv list |
|
| 1876 | 809 |
Deriv.tree : deriv -> Deriv.orule mtree |
| 1590 | 810 |
\end{ttbox}
|
811 |
||
812 |
\begin{ttdescription}
|
|
813 |
\item[\ttindexbold{keep_derivs} := MinDeriv $|$ ThmDeriv $|$ FullDeriv;]
|
|
|
4597
a0bdee64194c
Fixed a lot of overfull and underfull lines (hboxes)
paulson
parents:
4383
diff
changeset
|
814 |
specifies one of the options for keeping derivations. They can be |
| 1590 | 815 |
minimal (oracles only), include theorems and axioms, or be full. |
816 |
||
817 |
\item[\ttindexbold{Deriv.size} $der$] yields the size of a derivation,
|
|
818 |
excluding lemmas. |
|
819 |
||
820 |
\item[\ttindexbold{Deriv.drop} ($tree$,$n$)] returns the subtree $n$ levels
|
|
821 |
down, always following the first child. It is good for stripping off |
|
822 |
outer level inferences that are used to put a theorem into standard form. |
|
823 |
||
824 |
\item[\ttindexbold{Deriv.linear} $der$] converts a derivation into a linear
|
|
825 |
format, replacing the deep nesting by a list of rules. Intuitively, this |
|
826 |
reveals the single-step Isabelle proof that is constructed internally by |
|
827 |
tactics. |
|
828 |
||
829 |
\item[\ttindexbold{Deriv.tree} $der$] converts a derivation into an
|
|
830 |
object-level proof tree. A resolution by an object-rule is converted to a |
|
831 |
tree node labelled by that rule. Complications arise if the object-rule is |
|
832 |
itself derived in some way. Nested resolutions are unravelled, but other |
|
833 |
operations on rules (such as rewriting) are left as-is. |
|
834 |
\end{ttdescription}
|
|
835 |
||
|
2040
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
836 |
Functions {\tt Deriv.linear} and {\tt Deriv.tree} omit the proof of any named
|
|
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
837 |
theorems (constructor {\tt Theorem}) they encounter in a derivation. Applying
|
|
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
838 |
them directly to the derivation of a named theorem is therefore pointless. |
|
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
839 |
Use {\tt Deriv.drop} with argument~1 to skip over the initial {\tt Theorem}
|
|
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
840 |
constructor. |
|
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
paulson
parents:
1876
diff
changeset
|
841 |
|
| 1590 | 842 |
\index{proof objects|)}
|
| 104 | 843 |
\index{theorems|)}
|
| 5371 | 844 |
|
| 7871 | 845 |
\medskip |
846 |
||
847 |
The dependencies of theorems can be viewed using the function \ttindexbold{thm_deps}:
|
|
848 |
\begin{ttbox}
|
|
849 |
thm_deps [\(thm@1\), \(\ldots\), \(thm@n\)]; |
|
850 |
\end{ttbox}
|
|
851 |
generates the dependency graph of the theorems $thm@1$, $\ldots$, $thm@n$ and |
|
852 |
displays it using Isabelle's graph browser. This function expects derivations |
|
853 |
to be enabled. The structure \texttt{ThmDeps} contains the two functions
|
|
854 |
\begin{ttbox}
|
|
855 |
enable : unit -> unit |
|
856 |
disable : unit -> unit |
|
857 |
\end{ttbox}
|
|
858 |
which set \texttt{keep_derivs} appropriately.
|
|
859 |
||
| 5371 | 860 |
|
861 |
%%% Local Variables: |
|
862 |
%%% mode: latex |
|
863 |
%%% TeX-master: "ref" |
|
864 |
%%% End: |