author | paulson |
Thu, 25 Sep 1997 13:25:50 +0200 | |
changeset 3716 | 2885b760a4b4 |
parent 3485 | f27a30a18a17 |
child 3720 | a5b9e0ade194 |
permissions | -rw-r--r-- |
104 | 1 |
%% $Id$ |
319 | 2 |
\chapter{The Classical Reasoner}\label{chap:classical} |
286 | 3 |
\index{classical reasoner|(} |
308 | 4 |
\newcommand\ainfer[2]{\begin{array}{r@{\,}l}#2\\ \hline#1\end{array}} |
5 |
||
3108 | 6 |
Although Isabelle is generic, many users will be working in some |
7 |
extension of classical first-order logic. Isabelle's set theory~{\tt |
|
8 |
ZF} is built upon theory~{\tt FOL}, while higher-order logic |
|
9 |
conceptually contains first-order logic as a fragment. |
|
10 |
Theorem-proving in predicate logic is undecidable, but many |
|
308 | 11 |
researchers have developed strategies to assist in this task. |
104 | 12 |
|
286 | 13 |
Isabelle's classical reasoner is an \ML{} functor that accepts certain |
104 | 14 |
information about a logic and delivers a suite of automatic tactics. Each |
15 |
tactic takes a collection of rules and executes a simple, non-clausal proof |
|
16 |
procedure. They are slow and simplistic compared with resolution theorem |
|
17 |
provers, but they can save considerable time and effort. They can prove |
|
18 |
theorems such as Pelletier's~\cite{pelletier86} problems~40 and~41 in |
|
19 |
seconds: |
|
20 |
\[ (\exists y. \forall x. J(y,x) \bimp \neg J(x,x)) |
|
21 |
\imp \neg (\forall x. \exists y. \forall z. J(z,y) \bimp \neg J(z,x)) \] |
|
22 |
\[ (\forall z. \exists y. \forall x. F(x,y) \bimp F(x,z) \conj \neg F(x,x)) |
|
23 |
\imp \neg (\exists z. \forall x. F(x,z)) |
|
24 |
\] |
|
308 | 25 |
% |
26 |
The tactics are generic. They are not restricted to first-order logic, and |
|
27 |
have been heavily used in the development of Isabelle's set theory. Few |
|
28 |
interactive proof assistants provide this much automation. The tactics can |
|
29 |
be traced, and their components can be called directly; in this manner, |
|
30 |
any proof can be viewed interactively. |
|
104 | 31 |
|
3716 | 32 |
The simplest way to apply the classical reasoner (to subgoal~$i$) is to type |
2479 | 33 |
\begin{ttbox} |
3089 | 34 |
by (Blast_tac \(i\)); |
2479 | 35 |
\end{ttbox} |
3716 | 36 |
This command quickly proves most simple formulas of the predicate calculus or |
37 |
set theory. To attempt to prove \emph{all} subgoals using a combination of |
|
38 |
rewriting and classical reasoning, try |
|
3224 | 39 |
\begin{ttbox} |
40 |
by (Auto_tac()); |
|
41 |
\end{ttbox} |
|
3716 | 42 |
To do all obvious logical steps, even if they do not prove the |
43 |
subgoal, type |
|
44 |
\begin{ttbox} |
|
45 |
by (Clarify_tac \(i\)); |
|
46 |
\end{ttbox} |
|
47 |
You need to know how the classical reasoner works in order to use it |
|
48 |
effectively. There are many tactics to choose from, including {\tt |
|
49 |
Fast_tac} and {\tt Best_tac}. |
|
2479 | 50 |
|
3108 | 51 |
We shall first discuss the underlying principles, then present the |
52 |
classical reasoner. Finally, we shall see how to instantiate it for |
|
53 |
new logics. The logics \FOL, \ZF, {\HOL} and {\HOLCF} have it already |
|
54 |
installed. |
|
104 | 55 |
|
56 |
||
57 |
\section{The sequent calculus} |
|
58 |
\index{sequent calculus} |
|
59 |
Isabelle supports natural deduction, which is easy to use for interactive |
|
60 |
proof. But natural deduction does not easily lend itself to automation, |
|
61 |
and has a bias towards intuitionism. For certain proofs in classical |
|
62 |
logic, it can not be called natural. The {\bf sequent calculus}, a |
|
63 |
generalization of natural deduction, is easier to automate. |
|
64 |
||
65 |
A {\bf sequent} has the form $\Gamma\turn\Delta$, where $\Gamma$ |
|
308 | 66 |
and~$\Delta$ are sets of formulae.% |
67 |
\footnote{For first-order logic, sequents can equivalently be made from |
|
68 |
lists or multisets of formulae.} The sequent |
|
104 | 69 |
\[ P@1,\ldots,P@m\turn Q@1,\ldots,Q@n \] |
70 |
is {\bf valid} if $P@1\conj\ldots\conj P@m$ implies $Q@1\disj\ldots\disj |
|
71 |
Q@n$. Thus $P@1,\ldots,P@m$ represent assumptions, each of which is true, |
|
72 |
while $Q@1,\ldots,Q@n$ represent alternative goals. A sequent is {\bf |
|
73 |
basic} if its left and right sides have a common formula, as in $P,Q\turn |
|
74 |
Q,R$; basic sequents are trivially valid. |
|
75 |
||
76 |
Sequent rules are classified as {\bf right} or {\bf left}, indicating which |
|
77 |
side of the $\turn$~symbol they operate on. Rules that operate on the |
|
78 |
right side are analogous to natural deduction's introduction rules, and |
|
308 | 79 |
left rules are analogous to elimination rules. |
80 |
Recall the natural deduction rules for |
|
81 |
first-order logic, |
|
82 |
\iflabelundefined{fol-fig}{from {\it Introduction to Isabelle}}% |
|
83 |
{Fig.\ts\ref{fol-fig}}. |
|
84 |
The sequent calculus analogue of~$({\imp}I)$ is the rule |
|
3108 | 85 |
$$ |
86 |
\ainfer{\Gamma &\turn \Delta, P\imp Q}{P,\Gamma &\turn \Delta,Q} |
|
87 |
\eqno({\imp}R) |
|
88 |
$$ |
|
104 | 89 |
This breaks down some implication on the right side of a sequent; $\Gamma$ |
90 |
and $\Delta$ stand for the sets of formulae that are unaffected by the |
|
91 |
inference. The analogue of the pair~$({\disj}I1)$ and~$({\disj}I2)$ is the |
|
92 |
single rule |
|
3108 | 93 |
$$ |
94 |
\ainfer{\Gamma &\turn \Delta, P\disj Q}{\Gamma &\turn \Delta,P,Q} |
|
95 |
\eqno({\disj}R) |
|
96 |
$$ |
|
104 | 97 |
This breaks down some disjunction on the right side, replacing it by both |
98 |
disjuncts. Thus, the sequent calculus is a kind of multiple-conclusion logic. |
|
99 |
||
100 |
To illustrate the use of multiple formulae on the right, let us prove |
|
101 |
the classical theorem $(P\imp Q)\disj(Q\imp P)$. Working backwards, we |
|
102 |
reduce this formula to a basic sequent: |
|
103 |
\[ \infer[(\disj)R]{\turn(P\imp Q)\disj(Q\imp P)} |
|
104 |
{\infer[(\imp)R]{\turn(P\imp Q), (Q\imp P)\;} |
|
105 |
{\infer[(\imp)R]{P \turn Q, (Q\imp P)\qquad} |
|
106 |
{P, Q \turn Q, P\qquad\qquad}}} |
|
107 |
\] |
|
108 |
This example is typical of the sequent calculus: start with the desired |
|
109 |
theorem and apply rules backwards in a fairly arbitrary manner. This yields a |
|
110 |
surprisingly effective proof procedure. Quantifiers add few complications, |
|
111 |
since Isabelle handles parameters and schematic variables. See Chapter~10 |
|
112 |
of {\em ML for the Working Programmer}~\cite{paulson91} for further |
|
113 |
discussion. |
|
114 |
||
115 |
||
116 |
\section{Simulating sequents by natural deduction} |
|
308 | 117 |
Isabelle can represent sequents directly, as in the object-logic~{\tt LK}\@. |
104 | 118 |
But natural deduction is easier to work with, and most object-logics employ |
119 |
it. Fortunately, we can simulate the sequent $P@1,\ldots,P@m\turn |
|
120 |
Q@1,\ldots,Q@n$ by the Isabelle formula |
|
121 |
\[ \List{P@1;\ldots;P@m; \neg Q@2;\ldots; \neg Q@n}\Imp Q@1, \] |
|
122 |
where the order of the assumptions and the choice of~$Q@1$ are arbitrary. |
|
123 |
Elim-resolution plays a key role in simulating sequent proofs. |
|
124 |
||
125 |
We can easily handle reasoning on the left. |
|
308 | 126 |
As discussed in |
127 |
\iflabelundefined{destruct}{{\it Introduction to Isabelle}}{\S\ref{destruct}}, |
|
104 | 128 |
elim-resolution with the rules $(\disj E)$, $(\bot E)$ and $(\exists E)$ |
129 |
achieves a similar effect as the corresponding sequent rules. For the |
|
130 |
other connectives, we use sequent-style elimination rules instead of |
|
308 | 131 |
destruction rules such as $({\conj}E1,2)$ and $(\forall E)$. But note that |
132 |
the rule $(\neg L)$ has no effect under our representation of sequents! |
|
3108 | 133 |
$$ |
134 |
\ainfer{\neg P,\Gamma &\turn \Delta}{\Gamma &\turn \Delta,P}\eqno({\neg}L) |
|
135 |
$$ |
|
104 | 136 |
What about reasoning on the right? Introduction rules can only affect the |
308 | 137 |
formula in the conclusion, namely~$Q@1$. The other right-side formulae are |
319 | 138 |
represented as negated assumptions, $\neg Q@2$, \ldots,~$\neg Q@n$. |
139 |
\index{assumptions!negated} |
|
140 |
In order to operate on one of these, it must first be exchanged with~$Q@1$. |
|
104 | 141 |
Elim-resolution with the {\bf swap} rule has this effect: |
3108 | 142 |
$$ \List{\neg P; \; \neg R\Imp P} \Imp R \eqno(swap) $$ |
104 | 143 |
To ensure that swaps occur only when necessary, each introduction rule is |
144 |
converted into a swapped form: it is resolved with the second premise |
|
145 |
of~$(swap)$. The swapped form of~$({\conj}I)$, which might be |
|
146 |
called~$({\neg\conj}E)$, is |
|
147 |
\[ \List{\neg(P\conj Q); \; \neg R\Imp P; \; \neg R\Imp Q} \Imp R. \] |
|
148 |
Similarly, the swapped form of~$({\imp}I)$ is |
|
149 |
\[ \List{\neg(P\imp Q); \; \List{\neg R;P}\Imp Q} \Imp R \] |
|
150 |
Swapped introduction rules are applied using elim-resolution, which deletes |
|
151 |
the negated formula. Our representation of sequents also requires the use |
|
152 |
of ordinary introduction rules. If we had no regard for readability, we |
|
153 |
could treat the right side more uniformly by representing sequents as |
|
154 |
\[ \List{P@1;\ldots;P@m; \neg Q@1;\ldots; \neg Q@n}\Imp \bot. \] |
|
155 |
||
156 |
||
157 |
\section{Extra rules for the sequent calculus} |
|
158 |
As mentioned, destruction rules such as $({\conj}E1,2)$ and $(\forall E)$ |
|
159 |
must be replaced by sequent-style elimination rules. In addition, we need |
|
160 |
rules to embody the classical equivalence between $P\imp Q$ and $\neg P\disj |
|
161 |
Q$. The introduction rules~$({\disj}I1,2)$ are replaced by a rule that |
|
162 |
simulates $({\disj}R)$: |
|
163 |
\[ (\neg Q\Imp P) \Imp P\disj Q \] |
|
164 |
The destruction rule $({\imp}E)$ is replaced by |
|
332 | 165 |
\[ \List{P\imp Q;\; \neg P\Imp R;\; Q\Imp R} \Imp R. \] |
104 | 166 |
Quantifier replication also requires special rules. In classical logic, |
308 | 167 |
$\exists x{.}P$ is equivalent to $\neg\forall x{.}\neg P$; the rules |
168 |
$(\exists R)$ and $(\forall L)$ are dual: |
|
104 | 169 |
\[ \ainfer{\Gamma &\turn \Delta, \exists x{.}P} |
170 |
{\Gamma &\turn \Delta, \exists x{.}P, P[t/x]} \; (\exists R) |
|
171 |
\qquad |
|
172 |
\ainfer{\forall x{.}P, \Gamma &\turn \Delta} |
|
173 |
{P[t/x], \forall x{.}P, \Gamma &\turn \Delta} \; (\forall L) |
|
174 |
\] |
|
175 |
Thus both kinds of quantifier may be replicated. Theorems requiring |
|
176 |
multiple uses of a universal formula are easy to invent; consider |
|
308 | 177 |
\[ (\forall x.P(x)\imp P(f(x))) \conj P(a) \imp P(f^n(a)), \] |
178 |
for any~$n>1$. Natural examples of the multiple use of an existential |
|
179 |
formula are rare; a standard one is $\exists x.\forall y. P(x)\imp P(y)$. |
|
104 | 180 |
|
181 |
Forgoing quantifier replication loses completeness, but gains decidability, |
|
182 |
since the search space becomes finite. Many useful theorems can be proved |
|
183 |
without replication, and the search generally delivers its verdict in a |
|
184 |
reasonable time. To adopt this approach, represent the sequent rules |
|
185 |
$(\exists R)$, $(\exists L)$ and $(\forall R)$ by $(\exists I)$, $(\exists |
|
186 |
E)$ and $(\forall I)$, respectively, and put $(\forall E)$ into elimination |
|
187 |
form: |
|
188 |
$$ \List{\forall x{.}P(x); P(t)\Imp Q} \Imp Q \eqno(\forall E@2) $$ |
|
189 |
Elim-resolution with this rule will delete the universal formula after a |
|
190 |
single use. To replicate universal quantifiers, replace the rule by |
|
3108 | 191 |
$$ |
192 |
\List{\forall x{.}P(x);\; \List{P(t); \forall x{.}P(x)}\Imp Q} \Imp Q. |
|
193 |
\eqno(\forall E@3) |
|
194 |
$$ |
|
104 | 195 |
To replicate existential quantifiers, replace $(\exists I)$ by |
332 | 196 |
\[ \List{\neg(\exists x{.}P(x)) \Imp P(t)} \Imp \exists x{.}P(x). \] |
104 | 197 |
All introduction rules mentioned above are also useful in swapped form. |
198 |
||
199 |
Replication makes the search space infinite; we must apply the rules with |
|
286 | 200 |
care. The classical reasoner distinguishes between safe and unsafe |
104 | 201 |
rules, applying the latter only when there is no alternative. Depth-first |
202 |
search may well go down a blind alley; best-first search is better behaved |
|
203 |
in an infinite search space. However, quantifier replication is too |
|
204 |
expensive to prove any but the simplest theorems. |
|
205 |
||
206 |
||
207 |
\section{Classical rule sets} |
|
319 | 208 |
\index{classical sets} |
209 |
Each automatic tactic takes a {\bf classical set} --- a collection of |
|
104 | 210 |
rules, classified as introduction or elimination and as {\bf safe} or {\bf |
211 |
unsafe}. In general, safe rules can be attempted blindly, while unsafe |
|
212 |
rules must be used with care. A safe rule must never reduce a provable |
|
308 | 213 |
goal to an unprovable set of subgoals. |
104 | 214 |
|
308 | 215 |
The rule~$({\disj}I1)$ is unsafe because it reduces $P\disj Q$ to~$P$. Any |
216 |
rule is unsafe whose premises contain new unknowns. The elimination |
|
217 |
rule~$(\forall E@2)$ is unsafe, since it is applied via elim-resolution, |
|
218 |
which discards the assumption $\forall x{.}P(x)$ and replaces it by the |
|
219 |
weaker assumption~$P(\Var{t})$. The rule $({\exists}I)$ is unsafe for |
|
220 |
similar reasons. The rule~$(\forall E@3)$ is unsafe in a different sense: |
|
221 |
since it keeps the assumption $\forall x{.}P(x)$, it is prone to looping. |
|
222 |
In classical first-order logic, all rules are safe except those mentioned |
|
223 |
above. |
|
104 | 224 |
|
225 |
The safe/unsafe distinction is vague, and may be regarded merely as a way |
|
226 |
of giving some rules priority over others. One could argue that |
|
227 |
$({\disj}E)$ is unsafe, because repeated application of it could generate |
|
228 |
exponentially many subgoals. Induction rules are unsafe because inductive |
|
229 |
proofs are difficult to set up automatically. Any inference is unsafe that |
|
230 |
instantiates an unknown in the proof state --- thus \ttindex{match_tac} |
|
231 |
must be used, rather than \ttindex{resolve_tac}. Even proof by assumption |
|
232 |
is unsafe if it instantiates unknowns shared with other subgoals --- thus |
|
233 |
\ttindex{eq_assume_tac} must be used, rather than \ttindex{assume_tac}. |
|
234 |
||
1099 | 235 |
\subsection{Adding rules to classical sets} |
319 | 236 |
Classical rule sets belong to the abstract type \mltydx{claset}, which |
286 | 237 |
supports the following operations (provided the classical reasoner is |
104 | 238 |
installed!): |
239 |
\begin{ttbox} |
|
1099 | 240 |
empty_cs : claset |
241 |
print_cs : claset -> unit |
|
242 |
addSIs : claset * thm list -> claset \hfill{\bf infix 4} |
|
243 |
addSEs : claset * thm list -> claset \hfill{\bf infix 4} |
|
244 |
addSDs : claset * thm list -> claset \hfill{\bf infix 4} |
|
245 |
addIs : claset * thm list -> claset \hfill{\bf infix 4} |
|
246 |
addEs : claset * thm list -> claset \hfill{\bf infix 4} |
|
247 |
addDs : claset * thm list -> claset \hfill{\bf infix 4} |
|
1869 | 248 |
delrules : claset * thm list -> claset \hfill{\bf infix 4} |
104 | 249 |
\end{ttbox} |
3089 | 250 |
The add operations ignore any rule already present in the claset with the same |
251 |
classification (such as Safe Introduction). They print a warning if the rule |
|
252 |
has already been added with some other classification, but add the rule |
|
253 |
anyway. Calling {\tt delrules} deletes all occurrences of a rule from the |
|
254 |
claset, but see the warning below concerning destruction rules. |
|
308 | 255 |
\begin{ttdescription} |
104 | 256 |
\item[\ttindexbold{empty_cs}] is the empty classical set. |
257 |
||
1099 | 258 |
\item[\ttindexbold{print_cs} $cs$] prints the rules of~$cs$. |
259 |
||
308 | 260 |
\item[$cs$ addSIs $rules$] \indexbold{*addSIs} |
261 |
adds safe introduction~$rules$ to~$cs$. |
|
104 | 262 |
|
308 | 263 |
\item[$cs$ addSEs $rules$] \indexbold{*addSEs} |
264 |
adds safe elimination~$rules$ to~$cs$. |
|
104 | 265 |
|
308 | 266 |
\item[$cs$ addSDs $rules$] \indexbold{*addSDs} |
267 |
adds safe destruction~$rules$ to~$cs$. |
|
104 | 268 |
|
308 | 269 |
\item[$cs$ addIs $rules$] \indexbold{*addIs} |
270 |
adds unsafe introduction~$rules$ to~$cs$. |
|
104 | 271 |
|
308 | 272 |
\item[$cs$ addEs $rules$] \indexbold{*addEs} |
273 |
adds unsafe elimination~$rules$ to~$cs$. |
|
104 | 274 |
|
308 | 275 |
\item[$cs$ addDs $rules$] \indexbold{*addDs} |
276 |
adds unsafe destruction~$rules$ to~$cs$. |
|
1869 | 277 |
|
278 |
\item[$cs$ delrules $rules$] \indexbold{*delrules} |
|
3089 | 279 |
deletes~$rules$ from~$cs$. It prints a warning for those rules that are not |
280 |
in~$cs$. |
|
308 | 281 |
\end{ttdescription} |
282 |
||
3089 | 283 |
\begin{warn} |
284 |
If you added $rule$ using {\tt addSDs} or {\tt addDs}, then you must delete |
|
285 |
it as follows: |
|
286 |
\begin{ttbox} |
|
287 |
\(cs\) delrules [make_elim \(rule\)] |
|
288 |
\end{ttbox} |
|
289 |
\par\noindent |
|
290 |
This is necessary because the operators {\tt addSDs} and {\tt addDs} convert |
|
291 |
the destruction rules to elimination rules by applying \ttindex{make_elim}, |
|
292 |
and then insert them using {\tt addSEs} and {\tt addEs}, respectively. |
|
293 |
\end{warn} |
|
294 |
||
104 | 295 |
Introduction rules are those that can be applied using ordinary resolution. |
296 |
The classical set automatically generates their swapped forms, which will |
|
297 |
be applied using elim-resolution. Elimination rules are applied using |
|
286 | 298 |
elim-resolution. In a classical set, rules are sorted by the number of new |
299 |
subgoals they will yield; rules that generate the fewest subgoals will be |
|
300 |
tried first (see \S\ref{biresolve_tac}). |
|
104 | 301 |
|
1099 | 302 |
|
303 |
\subsection{Modifying the search step} |
|
3716 | 304 |
For a given classical set, the proof strategy is simple. Perform as many safe |
305 |
inferences as possible; or else, apply certain safe rules, allowing |
|
306 |
instantiation of unknowns; or else, apply an unsafe rule. The tactics also |
|
307 |
eliminate assumptions of the form $x=t$ by substitution if they have been set |
|
308 |
up to do so (see {\tt hyp_subst_tacs} in~\S\ref{sec:classical-setup} below). |
|
309 |
They may perform a form of Modus Ponens: if there are assumptions $P\imp Q$ |
|
310 |
and~$P$, then replace $P\imp Q$ by~$Q$. |
|
104 | 311 |
|
3108 | 312 |
The classical reasoning tactics --- except {\tt blast_tac}! --- allow |
313 |
you to modify this basic proof strategy by applying two arbitrary {\bf |
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3224
diff
changeset
|
314 |
wrapper tacticals} to it. This affects each step of the search. |
3108 | 315 |
Usually they are the identity tacticals, but they could apply another |
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3224
diff
changeset
|
316 |
tactic before or after the step tactic. The first one, which is |
3108 | 317 |
considered to be safe, affects \ttindex{safe_step_tac} and all the |
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3224
diff
changeset
|
318 |
tactics that call it. The the second one, which may be unsafe, affects |
3108 | 319 |
\ttindex{step_tac}, \ttindex{slow_step_tac} and the tactics that call |
320 |
them. |
|
1099 | 321 |
|
322 |
\begin{ttbox} |
|
2632 | 323 |
addss : claset * simpset -> claset \hfill{\bf infix 4} |
324 |
addSbefore : claset * (int -> tactic) -> claset \hfill{\bf infix 4} |
|
325 |
addSaltern : claset * (int -> tactic) -> claset \hfill{\bf infix 4} |
|
326 |
setSWrapper : claset * ((int -> tactic) -> |
|
327 |
(int -> tactic)) -> claset \hfill{\bf infix 4} |
|
328 |
compSWrapper : claset * ((int -> tactic) -> |
|
329 |
(int -> tactic)) -> claset \hfill{\bf infix 4} |
|
330 |
addbefore : claset * (int -> tactic) -> claset \hfill{\bf infix 4} |
|
331 |
addaltern : claset * (int -> tactic) -> claset \hfill{\bf infix 4} |
|
332 |
setWrapper : claset * ((int -> tactic) -> |
|
333 |
(int -> tactic)) -> claset \hfill{\bf infix 4} |
|
334 |
compWrapper : claset * ((int -> tactic) -> |
|
335 |
(int -> tactic)) -> claset \hfill{\bf infix 4} |
|
1099 | 336 |
\end{ttbox} |
337 |
% |
|
3108 | 338 |
\index{simplification!from classical reasoner} The wrapper tacticals |
339 |
underly the operator addss, which combines each search step by |
|
340 |
simplification. Strictly speaking, {\tt addss} is not part of the |
|
341 |
classical reasoner. It should be defined (using {\tt addSaltern |
|
342 |
(CHANGED o (safe_asm_more_full_simp_tac ss)}) when the simplifier is |
|
343 |
installed. |
|
1099 | 344 |
|
345 |
\begin{ttdescription} |
|
346 |
\item[$cs$ addss $ss$] \indexbold{*addss} |
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3224
diff
changeset
|
347 |
adds the simpset~$ss$ to the classical set. The assumptions and goal will be |
2631
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
348 |
simplified, in a safe way, after the safe steps of the search. |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
349 |
|
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
350 |
\item[$cs$ addSbefore $tac$] \indexbold{*addSbefore} |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
351 |
changes the safe wrapper tactical to apply the given tactic {\em before} |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
352 |
each safe step of the search. |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
353 |
|
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
354 |
\item[$cs$ addSaltern $tac$] \indexbold{*addSaltern} |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
355 |
changes the safe wrapper tactical to apply the given tactic when a safe step |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
356 |
of the search would fail. |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
357 |
|
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
358 |
\item[$cs$ setSWrapper $tactical$] \indexbold{*setSWrapper} |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
359 |
specifies a new safe wrapper tactical. |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
360 |
|
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
361 |
\item[$cs$ compSWrapper $tactical$] \indexbold{*compSWrapper} |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
362 |
composes the $tactical$ with the existing safe wrapper tactical, |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
363 |
to combine their effects. |
1099 | 364 |
|
365 |
\item[$cs$ addbefore $tac$] \indexbold{*addbefore} |
|
2631
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
366 |
changes the (unsafe) wrapper tactical to apply the given tactic, which should |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
367 |
be safe, {\em before} each step of the search. |
1099 | 368 |
|
2631
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
369 |
\item[$cs$ addaltern $tac$] \indexbold{*addaltern} |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
370 |
changes the (unsafe) wrapper tactical to apply the given tactic |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
371 |
{\em alternatively} after each step of the search. |
1099 | 372 |
|
2631
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
373 |
\item[$cs$ setWrapper $tactical$] \indexbold{*setWrapper} |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
374 |
specifies a new (unsafe) wrapper tactical. |
1099 | 375 |
|
2631
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
376 |
\item[$cs$ compWrapper $tactical$] \indexbold{*compWrapper} |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
377 |
composes the $tactical$ with the existing (unsafe) wrapper tactical, |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
378 |
to combine their effects. |
1099 | 379 |
\end{ttdescription} |
380 |
||
104 | 381 |
|
382 |
\section{The classical tactics} |
|
3716 | 383 |
\index{classical reasoner!tactics} If installed, the classical module provides |
384 |
powerful theorem-proving tactics. Most of them have capitalized analogues |
|
385 |
that use the default claset; see \S\ref{sec:current-claset}. |
|
386 |
||
387 |
\subsection{Semi-automatic tactics} |
|
388 |
\begin{ttbox} |
|
389 |
clarify_tac : claset -> int -> tactic |
|
390 |
clarify_step_tac : claset -> int -> tactic |
|
391 |
\end{ttbox} |
|
392 |
Use these when the automatic tactics fail. They perform all the obvious |
|
393 |
logical inferences that do not split the subgoal. The result is a |
|
394 |
simpler subgoal that can be tackled by other means, such as by |
|
395 |
instantiating quantifiers yourself. |
|
396 |
\begin{ttdescription} |
|
397 |
\item[\ttindexbold{clarify_tac} $cs$ $i$] performs a series of safe steps on |
|
398 |
subgoal~$i$, using \texttt{clarify_step_tac}. |
|
399 |
||
400 |
\item[\ttindexbold{clarify_step_tac} $cs$ $i$] performs a safe step on |
|
401 |
subgoal~$i$. No splitting step is applied; for example, the subgoal $A\conj |
|
402 |
B$ is left as a conjunction. Proof by assumption, Modus Ponens, etc., may be |
|
403 |
performed provided they do not instantiate unknowns. Assumptions of the |
|
404 |
form $x=t$ may be eliminated. The user-supplied safe wrapper tactical is |
|
405 |
applied. |
|
406 |
\end{ttdescription} |
|
407 |
||
104 | 408 |
|
3224 | 409 |
\subsection{The tableau prover} |
410 |
The tactic {\tt blast_tac} searches for a proof using a fast tableau prover, |
|
411 |
coded directly in \ML. It then reconstructs the proof using Isabelle |
|
412 |
tactics. It is faster and more powerful than the other classical |
|
413 |
reasoning tactics, but has major limitations too. |
|
3089 | 414 |
\begin{itemize} |
415 |
\item It does not use the wrapper tacticals described above, such as |
|
416 |
\ttindex{addss}. |
|
417 |
\item It ignores types, which can cause problems in \HOL. If it applies a rule |
|
418 |
whose types are inappropriate, then proof reconstruction will fail. |
|
419 |
\item It does not perform higher-order unification, as needed by the rule {\tt |
|
420 |
rangeI} in {\HOL} and {\tt RepFunI} in {\ZF}. There are often |
|
421 |
alternatives to such rules, for example {\tt |
|
422 |
range_eqI} and {\tt RepFun_eqI}. |
|
423 |
\item The message {\small\tt Function Var's argument not a bound variable\ } |
|
424 |
relates to the lack of higher-order unification. Function variables |
|
425 |
may only be applied to parameters of the subgoal. |
|
426 |
\item Its proof strategy is more general than {\tt fast_tac}'s but can be |
|
427 |
slower. If {\tt blast_tac} fails or seems to be running forever, try {\tt |
|
428 |
fast_tac} and the other tactics described below. |
|
429 |
\end{itemize} |
|
430 |
% |
|
431 |
\begin{ttbox} |
|
432 |
blast_tac : claset -> int -> tactic |
|
433 |
Blast.depth_tac : claset -> int -> int -> tactic |
|
434 |
Blast.trace : bool ref \hfill{\bf initially false} |
|
435 |
\end{ttbox} |
|
436 |
The two tactics differ on how they bound the number of unsafe steps used in a |
|
437 |
proof. While {\tt blast_tac} starts with a bound of zero and increases it |
|
438 |
successively to~20, {\tt Blast.depth_tac} applies a user-supplied search bound. |
|
439 |
\begin{ttdescription} |
|
440 |
\item[\ttindexbold{blast_tac} $cs$ $i$] tries to prove |
|
441 |
subgoal~$i$ using iterative deepening to increase the search bound. |
|
442 |
||
443 |
\item[\ttindexbold{Blast.depth_tac} $cs$ $lim$ $i$] tries |
|
444 |
to prove subgoal~$i$ using a search bound of $lim$. Often a slow |
|
445 |
proof using {\tt blast_tac} can be made much faster by supplying the |
|
446 |
successful search bound to this tactic instead. |
|
447 |
||
448 |
\item[\ttindexbold{Blast.trace} := true;] \index{tracing!of classical prover} |
|
449 |
causes the tableau prover to print a trace of its search. At each step it |
|
450 |
displays the formula currently being examined and reports whether the branch |
|
451 |
has been closed, extended or split. |
|
452 |
\end{ttdescription} |
|
453 |
||
3224 | 454 |
|
455 |
\subsection{An automatic tactic} |
|
456 |
\begin{ttbox} |
|
457 |
auto_tac : claset * simpset -> tactic |
|
458 |
auto : unit -> unit |
|
459 |
\end{ttbox} |
|
460 |
The auto-tactic attempts to prove all subgoals using a combination of |
|
461 |
simplification and classical reasoning. It is intended for situations where |
|
462 |
there are a lot of mostly trivial subgoals; it proves all the easy ones, |
|
463 |
leaving the ones it cannot prove. (Unfortunately, attempting to prove the |
|
464 |
hard ones may take a long time.) It must be supplied both a simpset and a |
|
465 |
claset; therefore it is most easily called as \texttt{Auto_tac}, which uses |
|
466 |
the default claset and simpset (see \S\ref{sec:current-claset} below). For |
|
467 |
interactive use, the shorthand \texttt{auto();} abbreviates |
|
468 |
\begin{ttbox} |
|
469 |
by (Auto_tac()); |
|
470 |
\end{ttbox} |
|
471 |
||
472 |
\subsection{Other classical tactics} |
|
332 | 473 |
\begin{ttbox} |
875
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
474 |
fast_tac : claset -> int -> tactic |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
475 |
best_tac : claset -> int -> tactic |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
476 |
slow_tac : claset -> int -> tactic |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
477 |
slow_best_tac : claset -> int -> tactic |
332 | 478 |
\end{ttbox} |
3224 | 479 |
These tactics attempt to prove a subgoal using sequent-style reasoning. |
480 |
Unlike \texttt{blast_tac}, they construct proofs directly in Isabelle. Their |
|
481 |
effect is restricted (by {\tt SELECT_GOAL}) to one subgoal; they either prove |
|
482 |
this subgoal or fail. The {\tt slow_} versions conduct a broader |
|
483 |
search.% |
|
484 |
\footnote{They may, when backtracking from a failed proof attempt, undo even |
|
485 |
the step of proving a subgoal by assumption.} |
|
875
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
486 |
|
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
487 |
The best-first tactics are guided by a heuristic function: typically, the |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
488 |
total size of the proof state. This function is supplied in the functor call |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
489 |
that sets up the classical reasoner. |
332 | 490 |
\begin{ttdescription} |
491 |
\item[\ttindexbold{fast_tac} $cs$ $i$] applies {\tt step_tac} using |
|
3089 | 492 |
depth-first search, to prove subgoal~$i$. |
332 | 493 |
|
494 |
\item[\ttindexbold{best_tac} $cs$ $i$] applies {\tt step_tac} using |
|
3089 | 495 |
best-first search, to prove subgoal~$i$. |
875
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
496 |
|
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
497 |
\item[\ttindexbold{slow_tac} $cs$ $i$] applies {\tt slow_step_tac} using |
3089 | 498 |
depth-first search, to prove subgoal~$i$. |
875
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
499 |
|
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
500 |
\item[\ttindexbold{slow_best_tac} $cs$ $i$] applies {\tt slow_step_tac} using |
3089 | 501 |
best-first search, to prove subgoal~$i$. |
875
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
502 |
\end{ttdescription} |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
503 |
|
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
504 |
|
3716 | 505 |
\subsection{Depth-limited automatic tactics} |
875
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
506 |
\begin{ttbox} |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
507 |
depth_tac : claset -> int -> int -> tactic |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
508 |
deepen_tac : claset -> int -> int -> tactic |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
509 |
\end{ttbox} |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
510 |
These work by exhaustive search up to a specified depth. Unsafe rules are |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
511 |
modified to preserve the formula they act on, so that it be used repeatedly. |
1099 | 512 |
They can prove more goals than {\tt fast_tac} can but are much |
875
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
513 |
slower, for example if the assumptions have many universal quantifiers. |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
514 |
|
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
515 |
The depth limits the number of unsafe steps. If you can estimate the minimum |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
516 |
number of unsafe steps needed, supply this value as~$m$ to save time. |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
517 |
\begin{ttdescription} |
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
518 |
\item[\ttindexbold{depth_tac} $cs$ $m$ $i$] |
3089 | 519 |
tries to prove subgoal~$i$ by exhaustive search up to depth~$m$. |
875
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
520 |
|
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
521 |
\item[\ttindexbold{deepen_tac} $cs$ $m$ $i$] |
3089 | 522 |
tries to prove subgoal~$i$ by iterative deepening. It calls {\tt depth_tac} |
875
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
523 |
repeatedly with increasing depths, starting with~$m$. |
332 | 524 |
\end{ttdescription} |
525 |
||
526 |
||
104 | 527 |
\subsection{Single-step tactics} |
528 |
\begin{ttbox} |
|
529 |
safe_step_tac : claset -> int -> tactic |
|
530 |
safe_tac : claset -> tactic |
|
531 |
inst_step_tac : claset -> int -> tactic |
|
532 |
step_tac : claset -> int -> tactic |
|
533 |
slow_step_tac : claset -> int -> tactic |
|
534 |
\end{ttbox} |
|
535 |
The automatic proof procedures call these tactics. By calling them |
|
536 |
yourself, you can execute these procedures one step at a time. |
|
308 | 537 |
\begin{ttdescription} |
104 | 538 |
\item[\ttindexbold{safe_step_tac} $cs$ $i$] performs a safe step on |
3716 | 539 |
subgoal~$i$. The safe wrapper tactical is applied to a tactic that may |
540 |
include proof by assumption or Modus Ponens (taking care not to instantiate |
|
541 |
unknowns), or substitution. |
|
104 | 542 |
|
543 |
\item[\ttindexbold{safe_tac} $cs$] repeatedly performs safe steps on all |
|
3716 | 544 |
subgoals. It is deterministic, with at most one outcome. |
104 | 545 |
|
546 |
\item[\ttindexbold{inst_step_tac} $cs$ $i$] is like {\tt safe_step_tac}, |
|
547 |
but allows unknowns to be instantiated. |
|
548 |
||
1099 | 549 |
\item[\ttindexbold{step_tac} $cs$ $i$] is the basic step of the proof |
2631
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
550 |
procedure. The (unsafe) wrapper tactical is applied to a tactic that tries |
5e5c78ba955e
description of safe vs. unsafe wrapper and the functions involved
oheimb
parents:
2479
diff
changeset
|
551 |
{\tt safe_tac}, {\tt inst_step_tac}, or applies an unsafe rule from~$cs$. |
104 | 552 |
|
553 |
\item[\ttindexbold{slow_step_tac}] |
|
554 |
resembles {\tt step_tac}, but allows backtracking between using safe |
|
555 |
rules with instantiation ({\tt inst_step_tac}) and using unsafe rules. |
|
875
a0b71a4bbe5e
documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents:
332
diff
changeset
|
556 |
The resulting search space is larger. |
308 | 557 |
\end{ttdescription} |
104 | 558 |
|
3224 | 559 |
\subsection{The current claset}\label{sec:current-claset} |
2479 | 560 |
Some logics (\FOL, {\HOL} and \ZF) support the concept of a current |
561 |
claset\index{claset!current}. This is a default set of classical rules. The |
|
562 |
underlying idea is quite similar to that of a current simpset described in |
|
563 |
\S\ref{sec:simp-for-dummies}; please read that section, including its |
|
564 |
warnings. Just like simpsets, clasets can be associated with theories. The |
|
565 |
tactics |
|
1869 | 566 |
\begin{ttbox} |
3716 | 567 |
Blast_tac : int -> tactic |
568 |
Auto_tac : unit -> tactic |
|
569 |
Fast_tac : int -> tactic |
|
570 |
Best_tac : int -> tactic |
|
571 |
Deepen_tac : int -> int -> tactic |
|
572 |
Clarify_tac : int -> tactic |
|
573 |
Clarify_step_tac : int -> tactic |
|
574 |
Step_tac : int -> tactic |
|
1869 | 575 |
\end{ttbox} |
3224 | 576 |
\indexbold{*Blast_tac}\indexbold{*Auto_tac} |
577 |
\indexbold{*Best_tac}\indexbold{*Fast_tac}% |
|
3716 | 578 |
\indexbold{*Deepen_tac}\indexbold{*Clarify_tac} |
579 |
\indexbold{*Clarify_step_tac}\indexbold{*Step_tac} |
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3224
diff
changeset
|
580 |
make use of the current claset. E.g. {\tt Blast_tac} is defined as follows: |
1869 | 581 |
\begin{ttbox} |
3089 | 582 |
fun Blast_tac i = fast_tac (!claset) i; |
1869 | 583 |
\end{ttbox} |
584 |
where \ttindex{!claset} is the current claset. |
|
585 |
The functions |
|
586 |
\begin{ttbox} |
|
587 |
AddSIs, AddSEs, AddSDs, AddIs, AddEs, AddDs: thm list -> unit |
|
588 |
\end{ttbox} |
|
589 |
\indexbold{*AddSIs} \indexbold{*AddSEs} \indexbold{*AddSDs} |
|
590 |
\indexbold{*AddIs} \indexbold{*AddEs} \indexbold{*AddDs} |
|
3485
f27a30a18a17
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3224
diff
changeset
|
591 |
are used to add rules to the current claset. They work exactly like their |
3224 | 592 |
lower case counterparts, such as {\tt addSIs}. Calling |
1869 | 593 |
\begin{ttbox} |
594 |
Delrules : thm list -> unit |
|
595 |
\end{ttbox} |
|
3224 | 596 |
deletes rules from the current claset. |
104 | 597 |
|
598 |
\subsection{Other useful tactics} |
|
319 | 599 |
\index{tactics!for contradiction} |
600 |
\index{tactics!for Modus Ponens} |
|
104 | 601 |
\begin{ttbox} |
602 |
contr_tac : int -> tactic |
|
603 |
mp_tac : int -> tactic |
|
604 |
eq_mp_tac : int -> tactic |
|
605 |
swap_res_tac : thm list -> int -> tactic |
|
606 |
\end{ttbox} |
|
607 |
These can be used in the body of a specialized search. |
|
308 | 608 |
\begin{ttdescription} |
319 | 609 |
\item[\ttindexbold{contr_tac} {\it i}]\index{assumptions!contradictory} |
610 |
solves subgoal~$i$ by detecting a contradiction among two assumptions of |
|
611 |
the form $P$ and~$\neg P$, or fail. It may instantiate unknowns. The |
|
612 |
tactic can produce multiple outcomes, enumerating all possible |
|
613 |
contradictions. |
|
104 | 614 |
|
615 |
\item[\ttindexbold{mp_tac} {\it i}] |
|
616 |
is like {\tt contr_tac}, but also attempts to perform Modus Ponens in |
|
617 |
subgoal~$i$. If there are assumptions $P\imp Q$ and~$P$, then it replaces |
|
618 |
$P\imp Q$ by~$Q$. It may instantiate unknowns. It fails if it can do |
|
619 |
nothing. |
|
620 |
||
621 |
\item[\ttindexbold{eq_mp_tac} {\it i}] |
|
622 |
is like {\tt mp_tac} {\it i}, but may not instantiate unknowns --- thus, it |
|
623 |
is safe. |
|
624 |
||
625 |
\item[\ttindexbold{swap_res_tac} {\it thms} {\it i}] refines subgoal~$i$ of |
|
626 |
the proof state using {\it thms}, which should be a list of introduction |
|
3089 | 627 |
rules. First, it attempts to prove the goal using {\tt assume_tac} or |
104 | 628 |
{\tt contr_tac}. It then attempts to apply each rule in turn, attempting |
629 |
resolution and also elim-resolution with the swapped form. |
|
308 | 630 |
\end{ttdescription} |
104 | 631 |
|
632 |
\subsection{Creating swapped rules} |
|
633 |
\begin{ttbox} |
|
634 |
swapify : thm list -> thm list |
|
635 |
joinrules : thm list * thm list -> (bool * thm) list |
|
636 |
\end{ttbox} |
|
308 | 637 |
\begin{ttdescription} |
104 | 638 |
\item[\ttindexbold{swapify} {\it thms}] returns a list consisting of the |
639 |
swapped versions of~{\it thms}, regarded as introduction rules. |
|
640 |
||
308 | 641 |
\item[\ttindexbold{joinrules} ({\it intrs}, {\it elims})] |
104 | 642 |
joins introduction rules, their swapped versions, and elimination rules for |
643 |
use with \ttindex{biresolve_tac}. Each rule is paired with~{\tt false} |
|
644 |
(indicating ordinary resolution) or~{\tt true} (indicating |
|
645 |
elim-resolution). |
|
308 | 646 |
\end{ttdescription} |
104 | 647 |
|
648 |
||
3716 | 649 |
\section{Setting up the classical reasoner}\label{sec:classical-setup} |
319 | 650 |
\index{classical reasoner!setting up} |
104 | 651 |
Isabelle's classical object-logics, including {\tt FOL} and {\tt HOL}, have |
286 | 652 |
the classical reasoner already set up. When defining a new classical logic, |
653 |
you should set up the reasoner yourself. It consists of the \ML{} functor |
|
104 | 654 |
\ttindex{ClassicalFun}, which takes the argument |
319 | 655 |
signature {\tt CLASSICAL_DATA}: |
104 | 656 |
\begin{ttbox} |
657 |
signature CLASSICAL_DATA = |
|
658 |
sig |
|
659 |
val mp : thm |
|
660 |
val not_elim : thm |
|
661 |
val swap : thm |
|
662 |
val sizef : thm -> int |
|
663 |
val hyp_subst_tacs : (int -> tactic) list |
|
664 |
end; |
|
665 |
\end{ttbox} |
|
666 |
Thus, the functor requires the following items: |
|
308 | 667 |
\begin{ttdescription} |
319 | 668 |
\item[\tdxbold{mp}] should be the Modus Ponens rule |
104 | 669 |
$\List{\Var{P}\imp\Var{Q};\; \Var{P}} \Imp \Var{Q}$. |
670 |
||
319 | 671 |
\item[\tdxbold{not_elim}] should be the contradiction rule |
104 | 672 |
$\List{\neg\Var{P};\; \Var{P}} \Imp \Var{R}$. |
673 |
||
319 | 674 |
\item[\tdxbold{swap}] should be the swap rule |
104 | 675 |
$\List{\neg \Var{P}; \; \neg \Var{R}\Imp \Var{P}} \Imp \Var{R}$. |
676 |
||
677 |
\item[\ttindexbold{sizef}] is the heuristic function used for best-first |
|
678 |
search. It should estimate the size of the remaining subgoals. A good |
|
679 |
heuristic function is \ttindex{size_of_thm}, which measures the size of the |
|
680 |
proof state. Another size function might ignore certain subgoals (say, |
|
681 |
those concerned with type checking). A heuristic function might simply |
|
682 |
count the subgoals. |
|
683 |
||
319 | 684 |
\item[\ttindexbold{hyp_subst_tacs}] is a list of tactics for substitution in |
104 | 685 |
the hypotheses, typically created by \ttindex{HypsubstFun} (see |
686 |
Chapter~\ref{substitution}). This list can, of course, be empty. The |
|
687 |
tactics are assumed to be safe! |
|
308 | 688 |
\end{ttdescription} |
104 | 689 |
The functor is not at all sensitive to the formalization of the |
3108 | 690 |
object-logic. It does not even examine the rules, but merely applies |
691 |
them according to its fixed strategy. The functor resides in {\tt |
|
692 |
Provers/classical.ML} in the Isabelle sources. |
|
104 | 693 |
|
319 | 694 |
\index{classical reasoner|)} |