1 %% $Id$ |
1 %% $Id$ |
2 \chapter{The Classical Reasoner} |
2 \chapter{The Classical Reasoner} |
3 \index{classical reasoner|(} |
3 \index{classical reasoner|(} |
4 \newcommand\ainfer[2]{\begin{array}{r@{}l}#2\\ \hline#1\end{array}} |
4 \newcommand\ainfer[2]{\begin{array}{r@{\,}l}#2\\ \hline#1\end{array}} |
|
5 |
5 Although Isabelle is generic, many users will be working in some extension |
6 Although Isabelle is generic, many users will be working in some extension |
6 of classical first-order logic (FOL). Isabelle's set theory is built upon |
7 of classical first-order logic. Isabelle's set theory~{\tt ZF} is built |
7 FOL, while higher-order logic contains FOL as a fragment. Theorem-proving |
8 upon theory~{\tt FOL}, while higher-order logic contains first-order logic |
8 in FOL is of course undecidable, but many researchers have developed |
9 as a fragment. Theorem-proving in predicate logic is undecidable, but many |
9 strategies to assist in this task. |
10 researchers have developed strategies to assist in this task. |
10 |
11 |
11 Isabelle's classical reasoner is an \ML{} functor that accepts certain |
12 Isabelle's classical reasoner is an \ML{} functor that accepts certain |
12 information about a logic and delivers a suite of automatic tactics. Each |
13 information about a logic and delivers a suite of automatic tactics. Each |
13 tactic takes a collection of rules and executes a simple, non-clausal proof |
14 tactic takes a collection of rules and executes a simple, non-clausal proof |
14 procedure. They are slow and simplistic compared with resolution theorem |
15 procedure. They are slow and simplistic compared with resolution theorem |
18 \[ (\exists y. \forall x. J(y,x) \bimp \neg J(x,x)) |
19 \[ (\exists y. \forall x. J(y,x) \bimp \neg J(x,x)) |
19 \imp \neg (\forall x. \exists y. \forall z. J(z,y) \bimp \neg J(z,x)) \] |
20 \imp \neg (\forall x. \exists y. \forall z. J(z,y) \bimp \neg J(z,x)) \] |
20 \[ (\forall z. \exists y. \forall x. F(x,y) \bimp F(x,z) \conj \neg F(x,x)) |
21 \[ (\forall z. \exists y. \forall x. F(x,y) \bimp F(x,z) \conj \neg F(x,x)) |
21 \imp \neg (\exists z. \forall x. F(x,z)) |
22 \imp \neg (\exists z. \forall x. F(x,z)) |
22 \] |
23 \] |
23 The tactics are generic. They are not restricted to~FOL, and have been |
24 % |
24 heavily used in the development of Isabelle's set theory. Few interactive |
25 The tactics are generic. They are not restricted to first-order logic, and |
25 proof assistants provide this much automation. Isabelle does not record |
26 have been heavily used in the development of Isabelle's set theory. Few |
26 proofs, but the tactics can be traced, and their components can be called |
27 interactive proof assistants provide this much automation. The tactics can |
27 directly. In this manner, any proof can be viewed interactively. |
28 be traced, and their components can be called directly; in this manner, |
28 |
29 any proof can be viewed interactively. |
29 The logics FOL, HOL and ZF have the classical reasoner already installed. We |
30 |
30 shall first consider how to use it, then see how to instantiate it for new |
31 The logics {\tt FOL}, {\tt HOL} and {\tt ZF} have the classical reasoner |
31 logics. |
32 already installed. We shall first consider how to use it, then see how to |
|
33 instantiate it for new logics. |
32 |
34 |
33 |
35 |
34 \section{The sequent calculus} |
36 \section{The sequent calculus} |
35 \index{sequent calculus} |
37 \index{sequent calculus} |
36 Isabelle supports natural deduction, which is easy to use for interactive |
38 Isabelle supports natural deduction, which is easy to use for interactive |
38 and has a bias towards intuitionism. For certain proofs in classical |
40 and has a bias towards intuitionism. For certain proofs in classical |
39 logic, it can not be called natural. The {\bf sequent calculus}, a |
41 logic, it can not be called natural. The {\bf sequent calculus}, a |
40 generalization of natural deduction, is easier to automate. |
42 generalization of natural deduction, is easier to automate. |
41 |
43 |
42 A {\bf sequent} has the form $\Gamma\turn\Delta$, where $\Gamma$ |
44 A {\bf sequent} has the form $\Gamma\turn\Delta$, where $\Gamma$ |
43 and~$\Delta$ are sets of formulae.\footnote{For FOL, sequents can |
45 and~$\Delta$ are sets of formulae.% |
44 equivalently be made from lists or multisets of formulae.} The sequent |
46 \footnote{For first-order logic, sequents can equivalently be made from |
|
47 lists or multisets of formulae.} The sequent |
45 \[ P@1,\ldots,P@m\turn Q@1,\ldots,Q@n \] |
48 \[ P@1,\ldots,P@m\turn Q@1,\ldots,Q@n \] |
46 is {\bf valid} if $P@1\conj\ldots\conj P@m$ implies $Q@1\disj\ldots\disj |
49 is {\bf valid} if $P@1\conj\ldots\conj P@m$ implies $Q@1\disj\ldots\disj |
47 Q@n$. Thus $P@1,\ldots,P@m$ represent assumptions, each of which is true, |
50 Q@n$. Thus $P@1,\ldots,P@m$ represent assumptions, each of which is true, |
48 while $Q@1,\ldots,Q@n$ represent alternative goals. A sequent is {\bf |
51 while $Q@1,\ldots,Q@n$ represent alternative goals. A sequent is {\bf |
49 basic} if its left and right sides have a common formula, as in $P,Q\turn |
52 basic} if its left and right sides have a common formula, as in $P,Q\turn |
50 Q,R$; basic sequents are trivially valid. |
53 Q,R$; basic sequents are trivially valid. |
51 |
54 |
52 Sequent rules are classified as {\bf right} or {\bf left}, indicating which |
55 Sequent rules are classified as {\bf right} or {\bf left}, indicating which |
53 side of the $\turn$~symbol they operate on. Rules that operate on the |
56 side of the $\turn$~symbol they operate on. Rules that operate on the |
54 right side are analogous to natural deduction's introduction rules, and |
57 right side are analogous to natural deduction's introduction rules, and |
55 left rules are analogous to elimination rules. The sequent calculus |
58 left rules are analogous to elimination rules. |
56 analogue of~$({\imp}I)$ is the rule |
59 Recall the natural deduction rules for |
|
60 first-order logic, |
|
61 \iflabelundefined{fol-fig}{from {\it Introduction to Isabelle}}% |
|
62 {Fig.\ts\ref{fol-fig}}. |
|
63 The sequent calculus analogue of~$({\imp}I)$ is the rule |
57 $$ \ainfer{\Gamma &\turn \Delta, P\imp Q}{P,\Gamma &\turn \Delta,Q} |
64 $$ \ainfer{\Gamma &\turn \Delta, P\imp Q}{P,\Gamma &\turn \Delta,Q} |
58 \eqno({\imp}R) $$ |
65 \eqno({\imp}R) $$ |
59 This breaks down some implication on the right side of a sequent; $\Gamma$ |
66 This breaks down some implication on the right side of a sequent; $\Gamma$ |
60 and $\Delta$ stand for the sets of formulae that are unaffected by the |
67 and $\Delta$ stand for the sets of formulae that are unaffected by the |
61 inference. The analogue of the pair~$({\disj}I1)$ and~$({\disj}I2)$ is the |
68 inference. The analogue of the pair~$({\disj}I1)$ and~$({\disj}I2)$ is the |
80 of {\em ML for the Working Programmer}~\cite{paulson91} for further |
87 of {\em ML for the Working Programmer}~\cite{paulson91} for further |
81 discussion. |
88 discussion. |
82 |
89 |
83 |
90 |
84 \section{Simulating sequents by natural deduction} |
91 \section{Simulating sequents by natural deduction} |
85 Isabelle can represent sequents directly, as in the object-logic~{\sc lk}. |
92 Isabelle can represent sequents directly, as in the object-logic~{\tt LK}\@. |
86 But natural deduction is easier to work with, and most object-logics employ |
93 But natural deduction is easier to work with, and most object-logics employ |
87 it. Fortunately, we can simulate the sequent $P@1,\ldots,P@m\turn |
94 it. Fortunately, we can simulate the sequent $P@1,\ldots,P@m\turn |
88 Q@1,\ldots,Q@n$ by the Isabelle formula |
95 Q@1,\ldots,Q@n$ by the Isabelle formula |
89 \[ \List{P@1;\ldots;P@m; \neg Q@2;\ldots; \neg Q@n}\Imp Q@1, \] |
96 \[ \List{P@1;\ldots;P@m; \neg Q@2;\ldots; \neg Q@n}\Imp Q@1, \] |
90 where the order of the assumptions and the choice of~$Q@1$ are arbitrary. |
97 where the order of the assumptions and the choice of~$Q@1$ are arbitrary. |
91 Elim-resolution plays a key role in simulating sequent proofs. |
98 Elim-resolution plays a key role in simulating sequent proofs. |
92 |
99 |
93 We can easily handle reasoning on the left. |
100 We can easily handle reasoning on the left. |
94 As discussed in the {\em Introduction to Isabelle}, |
101 As discussed in |
|
102 \iflabelundefined{destruct}{{\it Introduction to Isabelle}}{\S\ref{destruct}}, |
95 elim-resolution with the rules $(\disj E)$, $(\bot E)$ and $(\exists E)$ |
103 elim-resolution with the rules $(\disj E)$, $(\bot E)$ and $(\exists E)$ |
96 achieves a similar effect as the corresponding sequent rules. For the |
104 achieves a similar effect as the corresponding sequent rules. For the |
97 other connectives, we use sequent-style elimination rules instead of |
105 other connectives, we use sequent-style elimination rules instead of |
98 destruction rules. But note that the rule $(\neg L)$ has no effect |
106 destruction rules such as $({\conj}E1,2)$ and $(\forall E)$. But note that |
99 under our representation of sequents! |
107 the rule $(\neg L)$ has no effect under our representation of sequents! |
100 $$ \ainfer{\neg P,\Gamma &\turn \Delta}{\Gamma &\turn \Delta,P} |
108 $$ \ainfer{\neg P,\Gamma &\turn \Delta}{\Gamma &\turn \Delta,P} |
101 \eqno({\neg}L) $$ |
109 \eqno({\neg}L) $$ |
102 What about reasoning on the right? Introduction rules can only affect the |
110 What about reasoning on the right? Introduction rules can only affect the |
103 formula in the conclusion, namely~$Q@1$. The other right-side formula are |
111 formula in the conclusion, namely~$Q@1$. The other right-side formulae are |
104 represented as negated assumptions, $\neg Q@2$, \ldots,~$\neg Q@n$. In |
112 represented as negated assumptions, $\neg Q@2$, \ldots,~$\neg Q@n$. In |
105 order to operate on one of these, it must first be exchanged with~$Q@1$. |
113 order to operate on one of these, it must first be exchanged with~$Q@1$. |
106 Elim-resolution with the {\bf swap} rule has this effect: |
114 Elim-resolution with the {\bf swap} rule has this effect: |
107 $$ \List{\neg P; \; \neg R\Imp P} \Imp R \eqno(swap)$$ |
115 $$ \List{\neg P; \; \neg R\Imp P} \Imp R \eqno(swap)$$ |
108 To ensure that swaps occur only when necessary, each introduction rule is |
116 To ensure that swaps occur only when necessary, each introduction rule is |
127 simulates $({\disj}R)$: |
135 simulates $({\disj}R)$: |
128 \[ (\neg Q\Imp P) \Imp P\disj Q \] |
136 \[ (\neg Q\Imp P) \Imp P\disj Q \] |
129 The destruction rule $({\imp}E)$ is replaced by |
137 The destruction rule $({\imp}E)$ is replaced by |
130 \[ \List{P\imp Q;\; \neg P\imp R;\; Q\imp R} \Imp R. \] |
138 \[ \List{P\imp Q;\; \neg P\imp R;\; Q\imp R} \Imp R. \] |
131 Quantifier replication also requires special rules. In classical logic, |
139 Quantifier replication also requires special rules. In classical logic, |
132 $\exists x{.}P$ is equivalent to $\forall x{.}P$, and the rules $(\exists R)$ |
140 $\exists x{.}P$ is equivalent to $\neg\forall x{.}\neg P$; the rules |
133 and $(\forall L)$ are dual: |
141 $(\exists R)$ and $(\forall L)$ are dual: |
134 \[ \ainfer{\Gamma &\turn \Delta, \exists x{.}P} |
142 \[ \ainfer{\Gamma &\turn \Delta, \exists x{.}P} |
135 {\Gamma &\turn \Delta, \exists x{.}P, P[t/x]} \; (\exists R) |
143 {\Gamma &\turn \Delta, \exists x{.}P, P[t/x]} \; (\exists R) |
136 \qquad |
144 \qquad |
137 \ainfer{\forall x{.}P, \Gamma &\turn \Delta} |
145 \ainfer{\forall x{.}P, \Gamma &\turn \Delta} |
138 {P[t/x], \forall x{.}P, \Gamma &\turn \Delta} \; (\forall L) |
146 {P[t/x], \forall x{.}P, \Gamma &\turn \Delta} \; (\forall L) |
139 \] |
147 \] |
140 Thus both kinds of quantifier may be replicated. Theorems requiring |
148 Thus both kinds of quantifier may be replicated. Theorems requiring |
141 multiple uses of a universal formula are easy to invent; consider |
149 multiple uses of a universal formula are easy to invent; consider |
142 $(\forall x.P(x)\imp P(f(x))) \conj P(a) \imp P(f^n(x))$, for any~$n>1$. |
150 \[ (\forall x.P(x)\imp P(f(x))) \conj P(a) \imp P(f^n(a)), \] |
143 Natural examples of the multiple use of an existential formula are rare; a |
151 for any~$n>1$. Natural examples of the multiple use of an existential |
144 standard one is $\exists x.\forall y. P(x)\imp P(y)$. |
152 formula are rare; a standard one is $\exists x.\forall y. P(x)\imp P(y)$. |
145 |
153 |
146 Forgoing quantifier replication loses completeness, but gains decidability, |
154 Forgoing quantifier replication loses completeness, but gains decidability, |
147 since the search space becomes finite. Many useful theorems can be proved |
155 since the search space becomes finite. Many useful theorems can be proved |
148 without replication, and the search generally delivers its verdict in a |
156 without replication, and the search generally delivers its verdict in a |
149 reasonable time. To adopt this approach, represent the sequent rules |
157 reasonable time. To adopt this approach, represent the sequent rules |
167 expensive to prove any but the simplest theorems. |
175 expensive to prove any but the simplest theorems. |
168 |
176 |
169 |
177 |
170 \section{Classical rule sets} |
178 \section{Classical rule sets} |
171 \index{classical sets|bold} |
179 \index{classical sets|bold} |
172 Each automatic tactic takes a {\bf classical rule set} -- a collection of |
180 Each automatic tactic takes a {\bf classical rule set} --- a collection of |
173 rules, classified as introduction or elimination and as {\bf safe} or {\bf |
181 rules, classified as introduction or elimination and as {\bf safe} or {\bf |
174 unsafe}. In general, safe rules can be attempted blindly, while unsafe |
182 unsafe}. In general, safe rules can be attempted blindly, while unsafe |
175 rules must be used with care. A safe rule must never reduce a provable |
183 rules must be used with care. A safe rule must never reduce a provable |
176 goal to an unprovable set of subgoals. The rule~$({\disj}I1)$ is obviously |
184 goal to an unprovable set of subgoals. |
177 unsafe, since it reduces $P\disj Q$ to~$P$; fortunately, we do not require |
185 |
178 this rule. |
186 The rule~$({\disj}I1)$ is unsafe because it reduces $P\disj Q$ to~$P$. Any |
179 |
187 rule is unsafe whose premises contain new unknowns. The elimination |
180 In general, any rule is unsafe whose premises contain new unknowns. The |
188 rule~$(\forall E@2)$ is unsafe, since it is applied via elim-resolution, |
181 elimination rule~$(\forall E@2)$ is unsafe, since it is applied via |
189 which discards the assumption $\forall x{.}P(x)$ and replaces it by the |
182 elim-resolution, which discards the assumption $\forall x{.}P(x)$ and |
190 weaker assumption~$P(\Var{t})$. The rule $({\exists}I)$ is unsafe for |
183 replaces it by the weaker assumption~$P(\Var{t})$. The rule $({\exists}I)$ |
191 similar reasons. The rule~$(\forall E@3)$ is unsafe in a different sense: |
184 is unsafe for similar reasons. The rule~$(\forall E@3)$ is unsafe in a |
192 since it keeps the assumption $\forall x{.}P(x)$, it is prone to looping. |
185 different sense: since it keeps the assumption $\forall x{.}P(x)$, it is |
193 In classical first-order logic, all rules are safe except those mentioned |
186 prone to looping. In classical first-order logic, all rules are safe |
194 above. |
187 except those mentioned above. |
|
188 |
195 |
189 The safe/unsafe distinction is vague, and may be regarded merely as a way |
196 The safe/unsafe distinction is vague, and may be regarded merely as a way |
190 of giving some rules priority over others. One could argue that |
197 of giving some rules priority over others. One could argue that |
191 $({\disj}E)$ is unsafe, because repeated application of it could generate |
198 $({\disj}E)$ is unsafe, because repeated application of it could generate |
192 exponentially many subgoals. Induction rules are unsafe because inductive |
199 exponentially many subgoals. Induction rules are unsafe because inductive |
209 addDs : claset * thm list -> claset \hfill{\bf infix 4} |
216 addDs : claset * thm list -> claset \hfill{\bf infix 4} |
210 print_cs : claset -> unit |
217 print_cs : claset -> unit |
211 \end{ttbox} |
218 \end{ttbox} |
212 There are no operations for deletion from a classical set. The add |
219 There are no operations for deletion from a classical set. The add |
213 operations do not check for repetitions. |
220 operations do not check for repetitions. |
214 \begin{description} |
221 \begin{ttdescription} |
215 \item[\ttindexbold{empty_cs}] is the empty classical set. |
222 \item[\ttindexbold{empty_cs}] is the empty classical set. |
216 |
223 |
217 \item[\tt $cs$ addSIs $rules$] \indexbold{*addSIs} |
224 \item[$cs$ addSIs $rules$] \indexbold{*addSIs} |
218 adds some safe introduction~$rules$ to the classical set~$cs$. |
225 adds safe introduction~$rules$ to~$cs$. |
219 |
226 |
220 \item[\tt $cs$ addSEs $rules$] \indexbold{*addSEs} |
227 \item[$cs$ addSEs $rules$] \indexbold{*addSEs} |
221 adds some safe elimination~$rules$ to the classical set~$cs$. |
228 adds safe elimination~$rules$ to~$cs$. |
222 |
229 |
223 \item[\tt $cs$ addSDs $rules$] \indexbold{*addSDs} |
230 \item[$cs$ addSDs $rules$] \indexbold{*addSDs} |
224 adds some safe destruction~$rules$ to the classical set~$cs$. |
231 adds safe destruction~$rules$ to~$cs$. |
225 |
232 |
226 \item[\tt $cs$ addIs $rules$] \indexbold{*addIs} |
233 \item[$cs$ addIs $rules$] \indexbold{*addIs} |
227 adds some unsafe introduction~$rules$ to the classical set~$cs$. |
234 adds unsafe introduction~$rules$ to~$cs$. |
228 |
235 |
229 \item[\tt $cs$ addEs $rules$] \indexbold{*addEs} |
236 \item[$cs$ addEs $rules$] \indexbold{*addEs} |
230 adds some unsafe elimination~$rules$ to the classical set~$cs$. |
237 adds unsafe elimination~$rules$ to~$cs$. |
231 |
238 |
232 \item[\tt $cs$ addDs $rules$] \indexbold{*addDs} |
239 \item[$cs$ addDs $rules$] \indexbold{*addDs} |
233 adds some unsafe destruction~$rules$ to the classical set~$cs$. |
240 adds unsafe destruction~$rules$ to~$cs$. |
234 |
241 |
235 \item[\ttindexbold{print_cs} $cs$] prints the rules of the classical set~$cs$. |
242 \item[\ttindexbold{print_cs} $cs$] prints the rules of~$cs$. |
236 \end{description} |
243 \end{ttdescription} |
|
244 |
237 Introduction rules are those that can be applied using ordinary resolution. |
245 Introduction rules are those that can be applied using ordinary resolution. |
238 The classical set automatically generates their swapped forms, which will |
246 The classical set automatically generates their swapped forms, which will |
239 be applied using elim-resolution. Elimination rules are applied using |
247 be applied using elim-resolution. Elimination rules are applied using |
240 elim-resolution. In a classical set, rules are sorted by the number of new |
248 elim-resolution. In a classical set, rules are sorted by the number of new |
241 subgoals they will yield; rules that generate the fewest subgoals will be |
249 subgoals they will yield; rules that generate the fewest subgoals will be |
263 step_tac : claset -> int -> tactic |
271 step_tac : claset -> int -> tactic |
264 slow_step_tac : claset -> int -> tactic |
272 slow_step_tac : claset -> int -> tactic |
265 \end{ttbox} |
273 \end{ttbox} |
266 The automatic proof procedures call these tactics. By calling them |
274 The automatic proof procedures call these tactics. By calling them |
267 yourself, you can execute these procedures one step at a time. |
275 yourself, you can execute these procedures one step at a time. |
268 \begin{description} |
276 \begin{ttdescription} |
269 \item[\ttindexbold{safe_step_tac} $cs$ $i$] performs a safe step on |
277 \item[\ttindexbold{safe_step_tac} $cs$ $i$] performs a safe step on |
270 subgoal~$i$. This may include proof by assumption or Modus Ponens, taking |
278 subgoal~$i$. This may include proof by assumption or Modus Ponens, taking |
271 care not to instantiate unknowns, or \ttindex{hyp_subst_tac}. |
279 care not to instantiate unknowns, or \ttindex{hyp_subst_tac}. |
272 |
280 |
273 \item[\ttindexbold{safe_tac} $cs$] repeatedly performs safe steps on all |
281 \item[\ttindexbold{safe_tac} $cs$] repeatedly performs safe steps on all |
286 resembles {\tt step_tac}, but allows backtracking between using safe |
294 resembles {\tt step_tac}, but allows backtracking between using safe |
287 rules with instantiation ({\tt inst_step_tac}) and using unsafe rules. |
295 rules with instantiation ({\tt inst_step_tac}) and using unsafe rules. |
288 The resulting search space is too large for use in the standard proof |
296 The resulting search space is too large for use in the standard proof |
289 procedures, but {\tt slow_step_tac} is worth considering in special |
297 procedures, but {\tt slow_step_tac} is worth considering in special |
290 situations. |
298 situations. |
291 \end{description} |
299 \end{ttdescription} |
292 |
300 |
293 |
301 |
294 \subsection{The automatic tactics} |
302 \subsection{The automatic tactics} |
295 \begin{ttbox} |
303 \begin{ttbox} |
296 fast_tac : claset -> int -> tactic |
304 fast_tac : claset -> int -> tactic |
297 best_tac : claset -> int -> tactic |
305 best_tac : claset -> int -> tactic |
298 \end{ttbox} |
306 \end{ttbox} |
299 Both of these tactics work by applying {\tt step_tac} repeatedly. Their |
307 Both of these tactics work by applying {\tt step_tac} repeatedly. Their |
300 effect is restricted (by {\tt SELECT_GOAL}) to one subgoal; they either |
308 effect is restricted (by {\tt SELECT_GOAL}) to one subgoal; they either |
301 solve this subgoal or fail. |
309 solve this subgoal or fail. |
302 \begin{description} |
310 \begin{ttdescription} |
303 \item[\ttindexbold{fast_tac} $cs$ $i$] applies {\tt step_tac} using |
311 \item[\ttindexbold{fast_tac} $cs$ $i$] applies {\tt step_tac} using |
304 depth-first search, to solve subgoal~$i$. |
312 depth-first search, to solve subgoal~$i$. |
305 |
313 |
306 \item[\ttindexbold{best_tac} $cs$ $i$] applies {\tt step_tac} using |
314 \item[\ttindexbold{best_tac} $cs$ $i$] applies {\tt step_tac} using |
307 best-first search, to solve subgoal~$i$. A heuristic function --- |
315 best-first search, to solve subgoal~$i$. A heuristic function --- |
308 typically, the total size of the proof state --- guides the search. This |
316 typically, the total size of the proof state --- guides the search. This |
309 function is supplied when the classical reasoner is set up. |
317 function is supplied when the classical reasoner is set up. |
310 \end{description} |
318 \end{ttdescription} |
311 |
319 |
312 |
320 |
313 \subsection{Other useful tactics} |
321 \subsection{Other useful tactics} |
314 \index{tactics!for contradiction|bold} |
322 \index{tactics!for contradiction|bold} |
315 \index{tactics!for Modus Ponens|bold} |
323 \index{tactics!for Modus Ponens|bold} |
318 mp_tac : int -> tactic |
326 mp_tac : int -> tactic |
319 eq_mp_tac : int -> tactic |
327 eq_mp_tac : int -> tactic |
320 swap_res_tac : thm list -> int -> tactic |
328 swap_res_tac : thm list -> int -> tactic |
321 \end{ttbox} |
329 \end{ttbox} |
322 These can be used in the body of a specialized search. |
330 These can be used in the body of a specialized search. |
323 \begin{description} |
331 \begin{ttdescription} |
324 \item[\ttindexbold{contr_tac} {\it i}] solves subgoal~$i$ by detecting a |
332 \item[\ttindexbold{contr_tac} {\it i}] solves subgoal~$i$ by detecting a |
325 contradiction among two assumptions of the form $P$ and~$\neg P$, or fail. |
333 contradiction among two assumptions of the form $P$ and~$\neg P$, or fail. |
326 It may instantiate unknowns. The tactic can produce multiple outcomes, |
334 It may instantiate unknowns. The tactic can produce multiple outcomes, |
327 enumerating all possible contradictions. |
335 enumerating all possible contradictions. |
328 |
336 |
339 \item[\ttindexbold{swap_res_tac} {\it thms} {\it i}] refines subgoal~$i$ of |
347 \item[\ttindexbold{swap_res_tac} {\it thms} {\it i}] refines subgoal~$i$ of |
340 the proof state using {\it thms}, which should be a list of introduction |
348 the proof state using {\it thms}, which should be a list of introduction |
341 rules. First, it attempts to solve the goal using \ttindex{assume_tac} or |
349 rules. First, it attempts to solve the goal using \ttindex{assume_tac} or |
342 {\tt contr_tac}. It then attempts to apply each rule in turn, attempting |
350 {\tt contr_tac}. It then attempts to apply each rule in turn, attempting |
343 resolution and also elim-resolution with the swapped form. |
351 resolution and also elim-resolution with the swapped form. |
344 \end{description} |
352 \end{ttdescription} |
345 |
353 |
346 \subsection{Creating swapped rules} |
354 \subsection{Creating swapped rules} |
347 \begin{ttbox} |
355 \begin{ttbox} |
348 swapify : thm list -> thm list |
356 swapify : thm list -> thm list |
349 joinrules : thm list * thm list -> (bool * thm) list |
357 joinrules : thm list * thm list -> (bool * thm) list |
350 \end{ttbox} |
358 \end{ttbox} |
351 \begin{description} |
359 \begin{ttdescription} |
352 \item[\ttindexbold{swapify} {\it thms}] returns a list consisting of the |
360 \item[\ttindexbold{swapify} {\it thms}] returns a list consisting of the |
353 swapped versions of~{\it thms}, regarded as introduction rules. |
361 swapped versions of~{\it thms}, regarded as introduction rules. |
354 |
362 |
355 \item[\ttindexbold{joinrules} \tt({\it intrs}, {\it elims})] |
363 \item[\ttindexbold{joinrules} ({\it intrs}, {\it elims})] |
356 joins introduction rules, their swapped versions, and elimination rules for |
364 joins introduction rules, their swapped versions, and elimination rules for |
357 use with \ttindex{biresolve_tac}. Each rule is paired with~{\tt false} |
365 use with \ttindex{biresolve_tac}. Each rule is paired with~{\tt false} |
358 (indicating ordinary resolution) or~{\tt true} (indicating |
366 (indicating ordinary resolution) or~{\tt true} (indicating |
359 elim-resolution). |
367 elim-resolution). |
360 \end{description} |
368 \end{ttdescription} |
361 |
369 |
362 |
370 |
363 \section{Setting up the classical reasoner} |
371 \section{Setting up the classical reasoner} |
364 \index{classical reasoner!setting up|bold} |
372 \index{classical reasoner!setting up|bold} |
365 Isabelle's classical object-logics, including {\tt FOL} and {\tt HOL}, have |
373 Isabelle's classical object-logics, including {\tt FOL} and {\tt HOL}, have |
376 val sizef : thm -> int |
384 val sizef : thm -> int |
377 val hyp_subst_tacs : (int -> tactic) list |
385 val hyp_subst_tacs : (int -> tactic) list |
378 end; |
386 end; |
379 \end{ttbox} |
387 \end{ttbox} |
380 Thus, the functor requires the following items: |
388 Thus, the functor requires the following items: |
381 \begin{description} |
389 \begin{ttdescription} |
382 \item[\ttindexbold{mp}] should be the Modus Ponens rule |
390 \item[\ttindexbold{mp}] should be the Modus Ponens rule |
383 $\List{\Var{P}\imp\Var{Q};\; \Var{P}} \Imp \Var{Q}$. |
391 $\List{\Var{P}\imp\Var{Q};\; \Var{P}} \Imp \Var{Q}$. |
384 |
392 |
385 \item[\ttindexbold{not_elim}] should be the contradiction rule |
393 \item[\ttindexbold{not_elim}] should be the contradiction rule |
386 $\List{\neg\Var{P};\; \Var{P}} \Imp \Var{R}$. |
394 $\List{\neg\Var{P};\; \Var{P}} \Imp \Var{R}$. |
397 |
405 |
398 \item[\ttindexbold{hyp_subst_tac}] is a list of tactics for substitution in |
406 \item[\ttindexbold{hyp_subst_tac}] is a list of tactics for substitution in |
399 the hypotheses, typically created by \ttindex{HypsubstFun} (see |
407 the hypotheses, typically created by \ttindex{HypsubstFun} (see |
400 Chapter~\ref{substitution}). This list can, of course, be empty. The |
408 Chapter~\ref{substitution}). This list can, of course, be empty. The |
401 tactics are assumed to be safe! |
409 tactics are assumed to be safe! |
402 \end{description} |
410 \end{ttdescription} |
403 The functor is not at all sensitive to the formalization of the |
411 The functor is not at all sensitive to the formalization of the |
404 object-logic. It does not even examine the rules, but merely applies them |
412 object-logic. It does not even examine the rules, but merely applies them |
405 according to its fixed strategy. The functor resides in {\tt |
413 according to its fixed strategy. The functor resides in {\tt |
406 Provers/classical.ML} on the Isabelle distribution directory. |
414 Provers/classical.ML} on the Isabelle distribution directory. |
407 |
415 |