104
|
1 |
%% $Id$
|
|
2 |
\chapter{Theorems and Forward Proof}
|
|
3 |
\index{theorems|(}
|
|
4 |
Theorems, which represent the axioms, theorems and rules of object-logics,
|
|
5 |
have type {\tt thm}\indexbold{*thm}. This chapter begins by describing
|
|
6 |
operations that print theorems and that join them in forward proof. Most
|
|
7 |
theorem operations are intended for advanced applications, such as
|
|
8 |
programming new proof procedures. Many of these operations refer to
|
|
9 |
signatures, certified terms and certified types, which have the \ML{} types
|
|
10 |
{\tt Sign.sg}, {\tt Sign.cterm} and {\tt Sign.ctyp} and are discussed in
|
|
11 |
Chapter~\ref{theories}. Beginning users should ignore such complexities
|
|
12 |
--- and skip all but the first section of this chapter.
|
|
13 |
|
|
14 |
The theorem operations do not print error messages. Instead, they raise
|
|
15 |
exception~\ttindex{THM}\@. Use \ttindex{print_exn} to display
|
|
16 |
exceptions nicely:
|
|
17 |
\begin{ttbox}
|
|
18 |
allI RS mp handle e => print_exn e;
|
|
19 |
{\out Exception THM raised:}
|
|
20 |
{\out RSN: no unifiers -- premise 1}
|
|
21 |
{\out (!!x. ?P(x)) ==> ALL x. ?P(x)}
|
|
22 |
{\out [| ?P --> ?Q; ?P |] ==> ?Q}
|
|
23 |
{\out}
|
|
24 |
{\out uncaught exception THM}
|
|
25 |
\end{ttbox}
|
|
26 |
|
|
27 |
|
|
28 |
\section{Basic operations on theorems}
|
|
29 |
\subsection{Pretty-printing a theorem}
|
|
30 |
\index{theorems!printing|bold}\index{printing!theorems|bold}
|
|
31 |
\subsubsection{Top-level commands}
|
|
32 |
\begin{ttbox}
|
|
33 |
prth: thm -> thm
|
|
34 |
prths: thm list -> thm list
|
|
35 |
prthq: thm Sequence.seq -> thm Sequence.seq
|
|
36 |
\end{ttbox}
|
|
37 |
These are for interactive use. They are identity functions that display,
|
|
38 |
then return, their argument. The \ML{} identifier {\tt it} will refer to
|
|
39 |
the value just displayed.
|
|
40 |
\begin{description}
|
|
41 |
\item[\ttindexbold{prth} {\it thm}]
|
|
42 |
prints {\it thm\/} at the terminal.
|
|
43 |
|
|
44 |
\item[\ttindexbold{prths} {\it thms}]
|
|
45 |
prints {\it thms}, a list of theorems.
|
|
46 |
|
|
47 |
\item[\ttindexbold{prthq} {\it thmq}]
|
|
48 |
prints {\it thmq}, a sequence of theorems. It is useful for inspecting
|
|
49 |
the output of a tactic.
|
|
50 |
\end{description}
|
|
51 |
|
|
52 |
\subsubsection{Operations for programming}
|
|
53 |
\begin{ttbox}
|
|
54 |
print_thm : thm -> unit
|
|
55 |
print_goals : int -> thm -> unit
|
|
56 |
string_of_thm : thm -> string
|
|
57 |
\end{ttbox}
|
|
58 |
Functions with result type {\tt unit} are convenient for imperative
|
|
59 |
programming.
|
|
60 |
\begin{description}
|
|
61 |
\item[\ttindexbold{print_thm} {\it thm}]
|
|
62 |
prints {\it thm\/} at the terminal.
|
|
63 |
|
|
64 |
\item[\ttindexbold{print_goals} {\it limit\/} {\it thm}]
|
|
65 |
prints {\it thm\/} in goal style, with the premises as subgoals. It prints
|
|
66 |
at most {\it limit\/} subgoals. The subgoal module calls {\tt print_goals}
|
|
67 |
to display proof states.
|
|
68 |
|
|
69 |
\item[\ttindexbold{string_of_thm} {\it thm}]
|
|
70 |
converts {\it thm\/} to a string.
|
|
71 |
\end{description}
|
|
72 |
|
|
73 |
|
|
74 |
\subsection{Forwards proof: joining rules by resolution}
|
|
75 |
\index{theorems!joining by resolution|bold}
|
|
76 |
\index{meta-rules!resolution|bold}
|
|
77 |
\begin{ttbox}
|
|
78 |
RSN : thm * (int * thm) -> thm \hfill{\bf infix}
|
|
79 |
RS : thm * thm -> thm \hfill{\bf infix}
|
|
80 |
MRS : thm list * thm -> thm \hfill{\bf infix}
|
|
81 |
RLN : thm list * (int * thm list) -> thm list \hfill{\bf infix}
|
|
82 |
RL : thm list * thm list -> thm list \hfill{\bf infix}
|
|
83 |
MRL: thm list list * thm list -> thm list \hfill{\bf infix}
|
|
84 |
\end{ttbox}
|
|
85 |
Putting rules together is a simple way of deriving new rules. These
|
|
86 |
functions are especially useful with destruction rules.
|
|
87 |
\begin{description}
|
|
88 |
\item[\tt$thm@1$ RSN $(i,thm@2)$] \indexbold{*RSN}
|
|
89 |
resolves the conclusion of $thm@1$ with the $i$th premise of~$thm@2$. It
|
|
90 |
raises exception \ttindex{THM} unless there is precisely one resolvent.
|
|
91 |
|
|
92 |
\item[\tt$thm@1$ RS $thm@2$] \indexbold{*RS}
|
|
93 |
abbreviates \hbox{\tt$thm@1$ RSN $(1,thm@2)$}. Thus, it resolves the
|
|
94 |
conclusion of $thm@1$ with the first premise of~$thm@2$.
|
|
95 |
|
|
96 |
\item[\tt {$[thm@1,\ldots,thm@n]$} MRS $thm$] \indexbold{*MRS}
|
|
97 |
uses {\tt RLN} to resolve $thm@i$ against premise~$i$ of $thm$, for
|
|
98 |
$i=n$, \ldots,~1. This applies $thm@n$, \ldots, $thm@1$ to the first $n$
|
|
99 |
premises of $thm$. Because the theorems are used from right to left, it
|
|
100 |
does not matter if the $thm@i$ create new premises. {\tt MRS} is useful
|
|
101 |
for expressing proof trees.
|
|
102 |
|
|
103 |
\item[\tt$thms1$ RLN $(i,thms2)$] \indexbold{*RLN}
|
|
104 |
for every $thm@1$ in $thms1$ and $thm@2$ in $thms2$, it resolves the
|
|
105 |
conclusion of $thm@1$ with the $i$th premise of~$thm@2$, accumulating the
|
|
106 |
results. It is useful for combining lists of theorems.
|
|
107 |
|
|
108 |
\item[\tt$thms1$ RL $thms2$] \indexbold{*RL}
|
|
109 |
abbreviates \hbox{\tt$thms1$ RLN $(1,thms2)$}.
|
|
110 |
|
|
111 |
\item[\tt {$[thms@1,\ldots,thms@n]$} MRL $thms$] \indexbold{*MRL}
|
|
112 |
is analogous to {\tt MRS}, but combines theorem lists rather than theorems.
|
|
113 |
It too is useful for expressing proof trees.
|
|
114 |
\end{description}
|
|
115 |
|
|
116 |
|
|
117 |
\subsection{Expanding definitions in theorems}
|
|
118 |
\index{theorems!meta-level rewriting in|bold}\index{rewriting!meta-level}
|
|
119 |
\begin{ttbox}
|
|
120 |
rewrite_rule : thm list -> thm -> thm
|
|
121 |
rewrite_goals_rule : thm list -> thm -> thm
|
|
122 |
\end{ttbox}
|
|
123 |
\begin{description}
|
|
124 |
\item[\ttindexbold{rewrite_rule} {\it defs} {\it thm}]
|
|
125 |
unfolds the {\it defs} throughout the theorem~{\it thm}.
|
|
126 |
|
|
127 |
\item[\ttindexbold{rewrite_goals_rule} {\it defs} {\it thm}]
|
|
128 |
unfolds the {\it defs} in the premises of~{\it thm}, but leaves the
|
|
129 |
conclusion unchanged. This rule underlies \ttindex{rewrite_goals_tac}, but
|
|
130 |
serves little purpose in forward proof.
|
|
131 |
\end{description}
|
|
132 |
|
|
133 |
|
|
134 |
\subsection{Instantiating a theorem} \index{theorems!instantiating|bold}
|
|
135 |
\begin{ttbox}
|
|
136 |
read_instantiate : (string*string)list -> thm -> thm
|
|
137 |
read_instantiate_sg : Sign.sg -> (string*string)list -> thm -> thm
|
|
138 |
cterm_instantiate : (Sign.cterm*Sign.cterm)list -> thm -> thm
|
|
139 |
\end{ttbox}
|
|
140 |
These meta-rules instantiate type and term unknowns in a theorem. They are
|
|
141 |
occasionally useful. They can prevent difficulties with higher-order
|
|
142 |
unification, and define specialized versions of rules.
|
|
143 |
\begin{description}
|
|
144 |
\item[\ttindexbold{read_instantiate} {\it insts} {\it thm}]
|
|
145 |
processes the instantiations {\it insts} and instantiates the rule~{\it
|
|
146 |
thm}. The processing of instantiations is described
|
|
147 |
in~\S\ref{res_inst_tac}, under {\tt res_inst_tac}.
|
|
148 |
|
|
149 |
Use {\tt res_inst_tac}, not {\tt read_instantiate}, to instantiate a rule
|
|
150 |
and refine a particular subgoal. The tactic allows instantiation by the
|
|
151 |
subgoal's parameters, and reads the instantiations using the signature
|
|
152 |
associated with the proof state. The remaining two instantiation functions
|
|
153 |
are highly specialized; most users should ignore them.
|
|
154 |
|
|
155 |
\item[\ttindexbold{read_instantiate_sg} {\it sg} {\it insts} {\it thm}]
|
|
156 |
resembles \hbox{\tt read_instantiate {\it insts} {\it thm}}, but reads the
|
|
157 |
instantiates under signature~{\it sg}. This is necessary when you want to
|
|
158 |
instantiate a rule from a general theory, such as first-order logic, using
|
|
159 |
the notation of some specialized theory. Use the function {\tt
|
|
160 |
sign_of} to get the signature of a theory.
|
|
161 |
|
|
162 |
\item[\ttindexbold{cterm_instantiate} {\it ctpairs} {\it thm}]
|
|
163 |
is similar to {\tt read_instantiate}, but the instantiations are provided
|
|
164 |
as pairs of certified terms, not as strings to be read.
|
|
165 |
\end{description}
|
|
166 |
|
|
167 |
|
|
168 |
\subsection{Miscellaneous forward rules}
|
|
169 |
\index{theorems!standardizing|bold}
|
|
170 |
\begin{ttbox}
|
|
171 |
standard : thm -> thm
|
|
172 |
zero_var_indexes : thm -> thm
|
|
173 |
make_elim : thm -> thm
|
|
174 |
rule_by_tactic : tactic -> thm -> thm
|
|
175 |
\end{ttbox}
|
|
176 |
\begin{description}
|
|
177 |
\item[\ttindexbold{standard} $thm$]
|
|
178 |
puts $thm$ into the standard form of object-rules. It discharges all
|
|
179 |
meta-hypotheses, replaces free variables by schematic variables, and
|
|
180 |
renames schematic variables to have subscript zero.
|
|
181 |
|
|
182 |
\item[\ttindexbold{zero_var_indexes} $thm$]
|
|
183 |
makes all schematic variables have subscript zero, renaming them to avoid
|
|
184 |
clashes.
|
|
185 |
|
|
186 |
\item[\ttindexbold{make_elim} $thm$]
|
|
187 |
\index{rules!converting destruction to elimination}
|
|
188 |
converts $thm$, a destruction rule of the form $\List{P@1;\ldots;P@m}\Imp
|
|
189 |
Q$, to the elimination rule $\List{P@1; \ldots; P@m; Q\Imp R}\Imp R$. This
|
|
190 |
is the basis for destruct-resolution: {\tt dresolve_tac}, etc.
|
|
191 |
|
|
192 |
\item[\ttindexbold{rule_by_tactic} {\it tac} {\it thm}]
|
|
193 |
applies {\it tac\/} to the {\it thm}, freezing its variables first, then
|
|
194 |
yields the proof state returned by the tactic. In typical usage, the
|
|
195 |
{\it thm\/} represents an instance of a rule with several premises, some
|
|
196 |
with contradictory assumptions (because of the instantiation). The
|
|
197 |
tactic proves those subgoals and does whatever else it can, and returns
|
|
198 |
whatever is left.
|
|
199 |
\end{description}
|
|
200 |
|
|
201 |
|
|
202 |
\subsection{Taking a theorem apart}
|
|
203 |
\index{theorems!taking apart|bold}
|
|
204 |
\index{flex-flex constraints}
|
|
205 |
\begin{ttbox}
|
|
206 |
concl_of : thm -> term
|
|
207 |
prems_of : thm -> term list
|
|
208 |
nprems_of : thm -> int
|
|
209 |
tpairs_of : thm -> (term*term)list
|
|
210 |
stamps_of_thy : thm -> string ref list
|
|
211 |
dest_state : thm*int -> (term*term)list * term list * term * term
|
|
212 |
rep_thm : thm -> \{prop:term, hyps:term list,
|
|
213 |
maxidx:int, sign:Sign.sg\}
|
|
214 |
\end{ttbox}
|
|
215 |
\begin{description}
|
|
216 |
\item[\ttindexbold{concl_of} $thm$]
|
|
217 |
returns the conclusion of $thm$ as a term.
|
|
218 |
|
|
219 |
\item[\ttindexbold{prems_of} $thm$]
|
|
220 |
returns the premises of $thm$ as a list of terms.
|
|
221 |
|
|
222 |
\item[\ttindexbold{nprems_of} $thm$]
|
|
223 |
returns the number of premises in $thm$: {\tt length(prems_of~$thm$)}.
|
|
224 |
|
|
225 |
\item[\ttindexbold{tpairs_of} $thm$]
|
|
226 |
returns the flex-flex constraints of $thm$.
|
|
227 |
|
|
228 |
\item[\ttindexbold{stamps_of_thm} $thm$]
|
|
229 |
returns the stamps of the signature associated with~$thm$.
|
|
230 |
|
|
231 |
\item[\ttindexbold{dest_state} $(thm,i)$]
|
|
232 |
decomposes $thm$ as a tuple containing a list of flex-flex constraints, a
|
|
233 |
list of the subgoals~1 to~$i-1$, subgoal~$i$, and the rest of the theorem
|
|
234 |
(this will be an implication if there are more than $i$ subgoals).
|
|
235 |
|
|
236 |
\item[\ttindexbold{rep_thm} $thm$]
|
|
237 |
decomposes $thm$ as a record containing the statement of~$thm$, its list of
|
|
238 |
meta-hypotheses, the maximum subscript of its unknowns, and its signature.
|
|
239 |
\end{description}
|
|
240 |
|
|
241 |
|
|
242 |
\subsection{Tracing flags for unification}
|
|
243 |
\index{tracing!of unification}
|
|
244 |
\begin{ttbox}
|
|
245 |
Unify.trace_simp : bool ref \hfill{\bf initially false}
|
|
246 |
Unify.trace_types : bool ref \hfill{\bf initially false}
|
|
247 |
Unify.trace_bound : int ref \hfill{\bf initially 10}
|
|
248 |
Unify.search_bound : int ref \hfill{\bf initially 20}
|
|
249 |
\end{ttbox}
|
|
250 |
Tracing the search may be useful when higher-order unification behaves
|
|
251 |
unexpectedly. Letting {\tt res_inst_tac} circumvent the problem is easier,
|
|
252 |
though.
|
|
253 |
\begin{description}
|
|
254 |
\item[\ttindexbold{Unify.trace_simp} \tt:= true;]
|
|
255 |
causes tracing of the simplification phase.
|
|
256 |
|
|
257 |
\item[\ttindexbold{Unify.trace_types} \tt:= true;]
|
|
258 |
generates warnings of incompleteness, when unification is not considering
|
|
259 |
all possible instantiations of type unknowns.
|
|
260 |
|
|
261 |
\item[\ttindexbold{Unify.trace_bound} \tt:= $n$]
|
|
262 |
causes unification to print tracing information once it reaches depth~$n$.
|
|
263 |
Use $n=0$ for full tracing. At the default value of~10, tracing
|
|
264 |
information is almost never printed.
|
|
265 |
|
|
266 |
\item[\ttindexbold{Unify.search_bound} \tt:= $n$]
|
|
267 |
causes unification to limit its search to depth~$n$. Because of this
|
|
268 |
bound, higher-order unification cannot return an infinite sequence, though
|
|
269 |
it can return a very long one. The search rarely approaches the default
|
|
270 |
value of~20. If the search is cut off, unification prints {\tt
|
|
271 |
***Unification bound exceeded}.
|
|
272 |
\end{description}
|
|
273 |
|
|
274 |
|
|
275 |
\section{Primitive meta-level inference rules}
|
|
276 |
\index{meta-rules|(}
|
|
277 |
These implement the meta-logic in {\sc lcf} style, as functions from theorems
|
|
278 |
to theorems. They are, rarely, useful for deriving results in the pure
|
|
279 |
theory. Mainly, they are included for completeness, and most users should
|
|
280 |
not bother with them. The meta-rules raise exception \ttindex{THM} to signal
|
|
281 |
malformed premises, incompatible signatures and similar errors.
|
|
282 |
|
|
283 |
The meta-logic uses natural deduction. Each theorem may depend on
|
|
284 |
meta-hypotheses, or assumptions. Certain rules, such as $({\Imp}I)$,
|
|
285 |
discharge assumptions; in most other rules, the conclusion depends on all
|
|
286 |
of the assumptions of the premises. Formally, the system works with
|
|
287 |
assertions of the form
|
|
288 |
\[ \phi \quad [\phi@1,\ldots,\phi@n], \]
|
|
289 |
where $\phi@1$,~\ldots,~$\phi@n$ are the hypotheses. Do not confuse
|
|
290 |
meta-level assumptions with the object-level assumptions in a subgoal,
|
|
291 |
which are represented in the meta-logic using~$\Imp$.
|
|
292 |
|
|
293 |
Each theorem has a signature. Certified terms have a signature. When a
|
|
294 |
rule takes several premises and certified terms, it merges the signatures
|
|
295 |
to make a signature for the conclusion. This fails if the signatures are
|
|
296 |
incompatible.
|
|
297 |
|
|
298 |
The {\em implication\/} rules are $({\Imp}I)$
|
|
299 |
and $({\Imp}E)$:
|
|
300 |
\[ \infer[({\Imp}I)]{\phi\Imp \psi}{\infer*{\psi}{[\phi]}} \qquad
|
|
301 |
\infer[({\Imp}E)]{\psi}{\phi\Imp \psi & \phi} \]
|
|
302 |
|
|
303 |
Equality of truth values means logical equivalence:
|
|
304 |
\[ \infer[({\equiv}I)]{\phi\equiv\psi}{\infer*{\psi}{[\phi]} &
|
|
305 |
\infer*{\phi}{[\psi]}}
|
|
306 |
\qquad
|
|
307 |
\infer[({\equiv}E)]{\psi}{\phi\equiv \psi & \phi} \]
|
|
308 |
|
|
309 |
The {\em equality\/} rules are reflexivity, symmetry, and transitivity:
|
|
310 |
\[ {a\equiv a}\,(refl) \qquad
|
|
311 |
\infer[(sym)]{b\equiv a}{a\equiv b} \qquad
|
|
312 |
\infer[(trans)]{a\equiv c}{a\equiv b & b\equiv c} \]
|
|
313 |
|
|
314 |
The $\lambda$-conversions are $\alpha$-conversion, $\beta$-conversion, and
|
|
315 |
extensionality:\footnote{$\alpha$-conversion holds if $y$ is not free
|
|
316 |
in~$a$; $(ext)$ holds if $x$ is not free in the assumptions, $f$, or~$g$.}
|
|
317 |
\[ {(\lambda x.a) \equiv (\lambda y.a[y/x])} \qquad
|
|
318 |
{((\lambda x.a)(b)) \equiv a[b/x]} \qquad
|
|
319 |
\infer[(ext)]{f\equiv g}{f(x) \equiv g(x)} \]
|
|
320 |
|
|
321 |
The {\it abstraction\/} and {\it combination\/} rules permit the conversion
|
|
322 |
of subterms:\footnote{Abstraction holds if $x$ is not free in the
|
|
323 |
assumptions.}
|
|
324 |
\[ \infer[(abs)]{(\lambda x.a) \equiv (\lambda x.b)}{a\equiv b} \qquad
|
|
325 |
\infer[(comb)]{f(a)\equiv g(b)}{f\equiv g & a\equiv b} \]
|
|
326 |
|
|
327 |
The {\em universal quantification\/} rules are $(\Forall I)$ and $(\Forall
|
|
328 |
E)$:\footnote{$(\Forall I)$ holds if $x$ is not free in the assumptions.}
|
|
329 |
\[ \infer[(\Forall I)]{\Forall x.\phi}{\phi} \qquad
|
|
330 |
\infer[(\Forall I)]{\phi[b/x]}{\Forall x.\phi} \]
|
|
331 |
|
|
332 |
|
|
333 |
\subsection{Propositional rules}
|
|
334 |
\index{meta-rules!assumption|bold}
|
|
335 |
\subsubsection{Assumption}
|
|
336 |
\begin{ttbox}
|
|
337 |
assume: Sign.cterm -> thm
|
|
338 |
\end{ttbox}
|
|
339 |
\begin{description}
|
|
340 |
\item[\ttindexbold{assume} $ct$]
|
|
341 |
makes the theorem \(\phi \quad[\phi]\), where $\phi$ is the value of~$ct$.
|
|
342 |
The rule checks that $ct$ has type $prop$ and contains no unknowns, which
|
|
343 |
are not allowed in hypotheses.
|
|
344 |
\end{description}
|
|
345 |
|
|
346 |
\subsubsection{Implication}
|
|
347 |
\index{meta-rules!implication|bold}
|
|
348 |
\begin{ttbox}
|
|
349 |
implies_intr : Sign.cterm -> thm -> thm
|
|
350 |
implies_intr_list : Sign.cterm list -> thm -> thm
|
|
351 |
implies_intr_hyps : thm -> thm
|
|
352 |
implies_elim : thm -> thm -> thm
|
|
353 |
implies_elim_list : thm -> thm list -> thm
|
|
354 |
\end{ttbox}
|
|
355 |
\begin{description}
|
|
356 |
\item[\ttindexbold{implies_intr} $ct$ $thm$]
|
|
357 |
is $({\Imp}I)$, where $ct$ is the assumption to discharge, say~$\phi$. It
|
|
358 |
maps the premise $\psi\quad[\phi]$ to the conclusion $\phi\Imp\psi$. The
|
|
359 |
rule checks that $ct$ has type $prop$.
|
|
360 |
|
|
361 |
\item[\ttindexbold{implies_intr_list} $cts$ $thm$]
|
|
362 |
applies $({\Imp}I)$ repeatedly, on every element of the list~$cts$.
|
|
363 |
|
|
364 |
\item[\ttindexbold{implies_intr_hyps} $thm$]
|
|
365 |
applies $({\Imp}I)$ to discharge all the hypotheses of~$thm$. It maps the
|
|
366 |
premise $\phi \quad [\phi@1,\ldots,\phi@n]$ to the conclusion
|
|
367 |
$\List{\phi@1,\ldots,\phi@n}\Imp\phi$.
|
|
368 |
|
|
369 |
\item[\ttindexbold{implies_elim} $thm@1$ $thm@2$]
|
|
370 |
applies $({\Imp}E)$ to $thm@1$ and~$thm@2$. It maps the premises $\phi\Imp
|
|
371 |
\psi$ and $\phi$ to the conclusion~$\psi$.
|
|
372 |
|
|
373 |
\item[\ttindexbold{implies_elim_list} $thm$ $thms$]
|
|
374 |
applies $({\Imp}E)$ repeatedly to $thm$, using each element of~$thms$ in
|
|
375 |
turn. It maps the premises $[\phi@1,\ldots,\phi@n]\Imp\psi$ and
|
|
376 |
$\phi@1$,\ldots,$\phi@n$ to the conclusion~$\psi$.
|
|
377 |
\end{description}
|
|
378 |
|
|
379 |
\subsubsection{Logical equivalence (equality)}
|
|
380 |
\index{meta-rules!logical equivalence|bold}
|
|
381 |
\begin{ttbox}
|
|
382 |
equal_intr : thm -> thm -> thm equal_elim : thm -> thm -> thm
|
|
383 |
\end{ttbox}
|
|
384 |
\begin{description}
|
|
385 |
\item[\ttindexbold{equal_intr} $thm@1$ $thm@2$]
|
|
386 |
applies $({\equiv}I)$ to $thm@1$ and~$thm@2$. It maps the premises
|
|
387 |
$\psi\quad[\phi]$ and $\phi\quad[\psi]$ to the conclusion~$\phi\equiv\psi$.
|
|
388 |
|
|
389 |
\item[\ttindexbold{equal_elim} $thm@1$ $thm@2$]
|
|
390 |
applies $({\equiv}E)$ to $thm@1$ and~$thm@2$. It maps the premises
|
|
391 |
$\phi\equiv\psi$ and $\phi$ to the conclusion~$\psi$.
|
|
392 |
\end{description}
|
|
393 |
|
|
394 |
|
|
395 |
\subsection{Equality rules}
|
|
396 |
\index{meta-rules!equality|bold}
|
|
397 |
\begin{ttbox}
|
|
398 |
reflexive : Sign.cterm -> thm
|
|
399 |
symmetric : thm -> thm
|
|
400 |
transitive : thm -> thm -> thm
|
|
401 |
\end{ttbox}
|
|
402 |
\begin{description}
|
|
403 |
\item[\ttindexbold{reflexive} $ct$]
|
|
404 |
makes the theorem \(ct=ct\).
|
|
405 |
|
|
406 |
\item[\ttindexbold{symmetric} $thm$]
|
|
407 |
maps the premise $a\equiv b$ to the conclusion $b\equiv a$.
|
|
408 |
|
|
409 |
\item[\ttindexbold{transitive} $thm@1$ $thm@2$]
|
|
410 |
maps the premises $a\equiv b$ and $b\equiv c$ to the conclusion~${a\equiv c}$.
|
|
411 |
\end{description}
|
|
412 |
|
|
413 |
|
|
414 |
\subsection{The $\lambda$-conversion rules}
|
|
415 |
\index{meta-rules!$\lambda$-conversion|bold}
|
|
416 |
\begin{ttbox}
|
|
417 |
beta_conversion : Sign.cterm -> thm
|
|
418 |
extensional : thm -> thm
|
|
419 |
abstract_rule : string -> Sign.cterm -> thm -> thm
|
|
420 |
combination : thm -> thm -> thm
|
|
421 |
\end{ttbox}
|
|
422 |
There is no rule for $\alpha$-conversion because Isabelle's internal
|
|
423 |
representation ignores bound variable names, except when communicating with
|
|
424 |
the user.
|
|
425 |
\begin{description}
|
|
426 |
\item[\ttindexbold{beta_conversion} $ct$]
|
|
427 |
makes the theorem $((\lambda x.a)(b)) \equiv a[b/x]$, where $ct$ is the
|
|
428 |
term $(\lambda x.a)(b)$.
|
|
429 |
|
|
430 |
\item[\ttindexbold{extensional} $thm$]
|
|
431 |
maps the premise $f(x) \equiv g(x)$ to the conclusion $f\equiv g$.
|
|
432 |
Parameter~$x$ is taken from the premise. It may be an unknown or a free
|
|
433 |
variable (provided it does not occur in the hypotheses); it must not occur
|
|
434 |
in $f$ or~$g$.
|
|
435 |
|
|
436 |
\item[\ttindexbold{abstract_rule} $v$ $x$ $thm$]
|
|
437 |
maps the premise $a\equiv b$ to the conclusion $(\lambda x.a) \equiv
|
|
438 |
(\lambda x.b)$, abstracting over all occurrences (if any!) of~$x$.
|
|
439 |
Parameter~$x$ is supplied as a cterm. It may be an unknown or a free
|
|
440 |
variable (provided it does not occur in the hypotheses). In the
|
|
441 |
conclusion, the bound variable is named~$v$.
|
|
442 |
|
|
443 |
\item[\ttindexbold{combination} $thm@1$ $thm@2$]
|
|
444 |
maps the premises $f\equiv g$ and $a\equiv b$ to the conclusion~$f(a)\equiv
|
|
445 |
g(b)$.
|
|
446 |
\end{description}
|
|
447 |
|
|
448 |
|
|
449 |
\subsection{Universal quantifier rules}
|
|
450 |
\index{meta-rules!quantifier|bold}
|
|
451 |
\subsubsection{Forall introduction}
|
|
452 |
\begin{ttbox}
|
|
453 |
forall_intr : Sign.cterm -> thm -> thm
|
|
454 |
forall_intr_list : Sign.cterm list -> thm -> thm
|
|
455 |
forall_intr_frees : thm -> thm
|
|
456 |
\end{ttbox}
|
|
457 |
|
|
458 |
\begin{description}
|
|
459 |
\item[\ttindexbold{forall_intr} $x$ $thm$]
|
|
460 |
applies $({\Forall}I)$, abstracting over all occurrences (if any!) of~$x$.
|
|
461 |
The rule maps the premise $\phi$ to the conclusion $\Forall x.\phi$.
|
|
462 |
Parameter~$x$ is supplied as a cterm. It may be an unknown or a free
|
|
463 |
variable (provided it does not occur in the hypotheses).
|
|
464 |
|
|
465 |
\item[\ttindexbold{forall_intr_list} $xs$ $thm$]
|
|
466 |
applies $({\Forall}I)$ repeatedly, on every element of the list~$xs$.
|
|
467 |
|
|
468 |
\item[\ttindexbold{forall_intr_frees} $thm$]
|
|
469 |
applies $({\Forall}I)$ repeatedly, generalizing over all the free variables
|
|
470 |
of the premise.
|
|
471 |
\end{description}
|
|
472 |
|
|
473 |
|
|
474 |
\subsubsection{Forall elimination}
|
|
475 |
\begin{ttbox}
|
|
476 |
forall_elim : Sign.cterm -> thm -> thm
|
|
477 |
forall_elim_list : Sign.cterm list -> thm -> thm
|
|
478 |
forall_elim_var : int -> thm -> thm
|
|
479 |
forall_elim_vars : int -> thm -> thm
|
|
480 |
\end{ttbox}
|
|
481 |
|
|
482 |
\begin{description}
|
|
483 |
\item[\ttindexbold{forall_elim} $ct$ $thm$]
|
|
484 |
applies $({\Forall}E)$, mapping the premise $\Forall x.\phi$ to the conclusion
|
|
485 |
$\phi[ct/x]$. The rule checks that $ct$ and $x$ have the same type.
|
|
486 |
|
|
487 |
\item[\ttindexbold{forall_elim_list} $cts$ $thm$]
|
|
488 |
applies $({\Forall}E)$ repeatedly, on every element of the list~$cts$.
|
|
489 |
|
|
490 |
\item[\ttindexbold{forall_elim_var} $k$ $thm$]
|
|
491 |
applies $({\Forall}E)$, mapping the premise $\Forall x.\phi$ to the conclusion
|
|
492 |
$\phi[\Var{x@k}/x]$. Thus, it replaces the outermost $\Forall$-bound
|
|
493 |
variable by an unknown having subscript~$k$.
|
|
494 |
|
|
495 |
\item[\ttindexbold{forall_elim_vars} $ks$ $thm$]
|
|
496 |
applies {\tt forall_elim_var} repeatedly, for every element of the list~$ks$.
|
|
497 |
\end{description}
|
|
498 |
|
|
499 |
\subsubsection{Instantiation of unknowns}
|
|
500 |
\index{meta-rules!instantiation|bold}
|
|
501 |
\begin{ttbox}
|
|
502 |
instantiate: (indexname*Sign.ctyp)list * (Sign.cterm*Sign.cterm)list
|
|
503 |
-> thm -> thm
|
|
504 |
\end{ttbox}
|
|
505 |
\begin{description}
|
|
506 |
\item[\ttindexbold{instantiate} $tyinsts$ $insts$ $thm$]
|
|
507 |
performs simultaneous substitution of types for type unknowns (the
|
|
508 |
$tyinsts$) and terms for term unknowns (the $insts$). Instantiations are
|
|
509 |
given as $(v,t)$ pairs, where $v$ is an unknown and $t$ is a term (of the
|
|
510 |
same type as $v$) or a type (of the same sort as~$v$). All the unknowns
|
|
511 |
must be distinct. The rule normalizes its conclusion.
|
|
512 |
\end{description}
|
|
513 |
|
|
514 |
|
|
515 |
\subsection{Freezing/thawing type variables}
|
|
516 |
\index{meta-rules!for type variables|bold}
|
|
517 |
\begin{ttbox}
|
|
518 |
freezeT: thm -> thm
|
|
519 |
varifyT: thm -> thm
|
|
520 |
\end{ttbox}
|
|
521 |
\begin{description}
|
|
522 |
\item[\ttindexbold{freezeT} $thm$]
|
|
523 |
converts all the type unknowns in $thm$ to free type variables.
|
|
524 |
|
|
525 |
\item[\ttindexbold{varifyT} $thm$]
|
|
526 |
converts all the free type variables in $thm$ to type unknowns.
|
|
527 |
\end{description}
|
|
528 |
|
|
529 |
|
|
530 |
\section{Derived rules for goal-directed proof}
|
|
531 |
Most of these rules have the sole purpose of implementing particular
|
|
532 |
tactics. There are few occasions for applying them directly to a theorem.
|
|
533 |
|
|
534 |
\subsection{Proof by assumption}
|
|
535 |
\index{meta-rules!assumption|bold}
|
|
536 |
\begin{ttbox}
|
|
537 |
assumption : int -> thm -> thm Sequence.seq
|
|
538 |
eq_assumption : int -> thm -> thm
|
|
539 |
\end{ttbox}
|
|
540 |
\begin{description}
|
|
541 |
\item[\ttindexbold{assumption} {\it i} $thm$]
|
|
542 |
attempts to solve premise~$i$ of~$thm$ by assumption.
|
|
543 |
|
|
544 |
\item[\ttindexbold{eq_assumption}]
|
|
545 |
is like {\tt assumption} but does not use unification.
|
|
546 |
\end{description}
|
|
547 |
|
|
548 |
|
|
549 |
\subsection{Resolution}
|
|
550 |
\index{meta-rules!resolution|bold}
|
|
551 |
\begin{ttbox}
|
|
552 |
biresolution : bool -> (bool*thm)list -> int -> thm
|
|
553 |
-> thm Sequence.seq
|
|
554 |
\end{ttbox}
|
|
555 |
\begin{description}
|
|
556 |
\item[\ttindexbold{biresolution} $match$ $rules$ $i$ $state$]
|
|
557 |
performs bi-resolution on subgoal~$i$ of~$state$, using the list of $\it
|
|
558 |
(flag,rule)$ pairs. For each pair, it applies resolution if the flag
|
|
559 |
is~{\tt false} and elim-resolution if the flag is~{\tt true}. If $match$
|
|
560 |
is~{\tt true}, the $state$ is not instantiated.
|
|
561 |
\end{description}
|
|
562 |
|
|
563 |
|
|
564 |
\subsection{Composition: resolution without lifting}
|
|
565 |
\index{meta-rules!for composition|bold}
|
|
566 |
\begin{ttbox}
|
|
567 |
compose : thm * int * thm -> thm list
|
|
568 |
COMP : thm * thm -> thm
|
|
569 |
bicompose : bool -> bool * thm * int -> int -> thm
|
|
570 |
-> thm Sequence.seq
|
|
571 |
\end{ttbox}
|
|
572 |
In forward proof, a typical use of composition is to regard an assertion of
|
|
573 |
the form $\phi\Imp\psi$ as atomic. Schematic variables are not renamed, so
|
|
574 |
beware of clashes!
|
|
575 |
\begin{description}
|
|
576 |
\item[\ttindexbold{compose} ($thm@1$, $i$, $thm@2$)]
|
|
577 |
uses $thm@1$, regarded as an atomic formula, to solve premise~$i$
|
|
578 |
of~$thm@2$. Let $thm@1$ and $thm@2$ be $\psi$ and $\List{\phi@1; \ldots;
|
|
579 |
\phi@n} \Imp \phi$. For each $s$ that unifies~$\psi$ and $\phi@i$, the
|
|
580 |
result list contains the theorem
|
|
581 |
\[ (\List{\phi@1; \ldots; \phi@{i-1}; \phi@{i+1}; \ldots; \phi@n} \Imp \phi)s.
|
|
582 |
\]
|
|
583 |
|
|
584 |
\item[\tt $thm@1$ COMP $thm@2$]
|
|
585 |
calls \hbox{\tt compose ($thm@1$, 1, $thm@2$)} and returns the result, if
|
|
586 |
unique; otherwise, it raises exception~\ttindex{THM}\@. It is
|
|
587 |
analogous to {\tt RS}\@.
|
|
588 |
|
|
589 |
For example, suppose that $thm@1$ is $a=b\Imp b=a$, a symmetry rule, and
|
|
590 |
that $thm@2$ is $\List{P\Imp Q; \neg Q} \Imp\neg A)$, which is the
|
|
591 |
principle of contrapositives. Then the result would be the
|
|
592 |
derived rule $\neg(b=a)\Imp\neg(a=b)$.
|
|
593 |
|
|
594 |
\item[\ttindexbold{bicompose} $match$ ($flag$, $rule$, $m$) $i$ $state$]
|
|
595 |
refines subgoal~$i$ of $state$ using $rule$, without lifting. The $rule$
|
|
596 |
is taken to have the form $\List{\psi@1; \ldots; \psi@m} \Imp \psi$, where
|
|
597 |
$\psi$ need {\bf not} be atomic; thus $m$ determines the number of new
|
|
598 |
subgoals. If $flag$ is {\tt true} then it performs elim-resolution --- it
|
|
599 |
solves the first premise of~$rule$ by assumption and deletes that
|
|
600 |
assumption. If $match$ is~{\tt true}, the $state$ is not instantiated.
|
|
601 |
\end{description}
|
|
602 |
|
|
603 |
|
|
604 |
\subsection{Other meta-rules}
|
|
605 |
\begin{ttbox}
|
|
606 |
trivial : Sign.cterm -> thm
|
|
607 |
lift_rule : (thm * int) -> thm -> thm
|
|
608 |
rename_params_rule : string list * int -> thm -> thm
|
|
609 |
rewrite_cterm : thm list -> Sign.cterm -> thm
|
|
610 |
flexflex_rule : thm -> thm Sequence.seq
|
|
611 |
\end{ttbox}
|
|
612 |
\begin{description}
|
|
613 |
\item[\ttindexbold{trivial} $ct$]
|
|
614 |
makes the theorem \(\phi\Imp\phi\), where $\phi$ is the value of~$ct$.
|
|
615 |
This is the initial state for a goal-directed proof of~$\phi$. The rule
|
|
616 |
checks that $ct$ has type~$prop$.
|
|
617 |
|
|
618 |
\item[\ttindexbold{lift_rule} ($state$, $i$) $rule$] \index{lifting}
|
|
619 |
prepares $rule$ for resolution by lifting it over the parameters and
|
|
620 |
assumptions of subgoal~$i$ of~$state$.
|
|
621 |
|
|
622 |
\item[\ttindexbold{rename_params_rule} ({\it names}, {\it i}) $thm$]
|
|
623 |
uses the $names$ to rename the parameters of premise~$i$ of $thm$. The
|
|
624 |
names must be distinct. If there are fewer names than parameters, then the
|
|
625 |
rule renames the innermost parameters and may modify the remaining ones to
|
|
626 |
ensure that all the parameters are distinct.
|
|
627 |
\index{parameters!renaming}
|
|
628 |
|
|
629 |
\item[\ttindexbold{rewrite_cterm} $defs$ $ct$]
|
|
630 |
transforms $ct$ to $ct'$ by repeatedly applying $defs$ as rewrite rules; it
|
|
631 |
returns the conclusion~$ct\equiv ct'$. This underlies the meta-rewriting
|
|
632 |
tactics and rules.
|
|
633 |
\index{terms!meta-level rewriting in|bold}\index{rewriting!meta-level}
|
|
634 |
|
|
635 |
\item[\ttindexbold{flexflex_rule} $thm$] \index{flex-flex constraints}
|
|
636 |
\index{meta-rules!for flex-flex constraints|bold}
|
|
637 |
removes all flex-flex pairs from $thm$ using the trivial unifier.
|
|
638 |
\end{description}
|
|
639 |
\index{theorems|)}
|
|
640 |
\index{meta-rules|)}
|