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