9 open LK; |
9 open LK; |
10 |
10 |
11 (*Higher precedence than := facilitates use of references*) |
11 (*Higher precedence than := facilitates use of references*) |
12 infix 4 add_safes add_unsafes; |
12 infix 4 add_safes add_unsafes; |
13 |
13 |
14 signature LK_RESOLVE = |
|
15 sig |
|
16 datatype pack = Pack of thm list * thm list |
|
17 val add_safes: pack * thm list -> pack |
|
18 val add_unsafes: pack * thm list -> pack |
|
19 val allL_thin: thm |
|
20 val best_tac: pack -> int -> tactic |
|
21 val could_res: term * term -> bool |
|
22 val could_resolve_seq: term * term -> bool |
|
23 val cutL_tac: string -> int -> tactic |
|
24 val cutR_tac: string -> int -> tactic |
|
25 val conL: thm |
|
26 val conR: thm |
|
27 val empty_pack: pack |
|
28 val exR_thin: thm |
|
29 val fast_tac: pack -> int -> tactic |
|
30 val filseq_resolve_tac: thm list -> int -> int -> tactic |
|
31 val forms_of_seq: term -> term list |
|
32 val has_prems: int -> thm -> bool |
|
33 val iffL: thm |
|
34 val iffR: thm |
|
35 val less: thm * thm -> bool |
|
36 val LK_dup_pack: pack |
|
37 val LK_pack: pack |
|
38 val pc_tac: pack -> int -> tactic |
|
39 val prop_pack: pack |
|
40 val repeat_goal_tac: pack -> int -> tactic |
|
41 val reresolve_tac: thm list -> int -> tactic |
|
42 val RESOLVE_THEN: thm list -> (int -> tactic) -> int -> tactic |
|
43 val safe_goal_tac: pack -> int -> tactic |
|
44 val step_tac: pack -> int -> tactic |
|
45 val symL: thm |
|
46 val TrueR: thm |
|
47 end; |
|
48 |
|
49 |
|
50 structure LK_Resolve : LK_RESOLVE = |
|
51 struct |
|
52 |
|
53 (*Cut and thin, replacing the right-side formula*) |
14 (*Cut and thin, replacing the right-side formula*) |
54 fun cutR_tac (sP: string) i = |
15 fun cutR_tac (sP: string) i = |
55 res_inst_tac [ ("P",sP) ] cut i THEN rtac thinR i; |
16 res_inst_tac [ ("P",sP) ] cut i THEN rtac thinR i; |
56 |
17 |
57 (*Cut and thin, replacing the left-side formula*) |
18 (*Cut and thin, replacing the left-side formula*) |
58 fun cutL_tac (sP: string) i = |
19 fun cutL_tac (sP: string) i = |
59 res_inst_tac [ ("P",sP) ] cut i THEN rtac thinL (i+1); |
20 res_inst_tac [ ("P",sP) ] cut i THEN rtac thinL (i+1); |
60 |
21 |
61 |
22 |
62 (** If-and-only-if rules **) |
23 (** If-and-only-if rules **) |
63 val iffR = prove_goalw LK.thy [iff_def] |
24 qed_goalw "iffR" LK.thy [iff_def] |
64 "[| $H,P |- $E,Q,$F; $H,Q |- $E,P,$F |] ==> $H |- $E, P <-> Q, $F" |
25 "[| $H,P |- $E,Q,$F; $H,Q |- $E,P,$F |] ==> $H |- $E, P <-> Q, $F" |
65 (fn prems=> [ (REPEAT (resolve_tac (prems@[conjR,impR]) 1)) ]); |
26 (fn prems=> [ (REPEAT (resolve_tac (prems@[conjR,impR]) 1)) ]); |
66 |
27 |
67 val iffL = prove_goalw LK.thy [iff_def] |
28 qed_goalw "iffL" LK.thy [iff_def] |
68 "[| $H,$G |- $E,P,Q; $H,Q,P,$G |- $E |] ==> $H, P <-> Q, $G |- $E" |
29 "[| $H,$G |- $E,P,Q; $H,Q,P,$G |- $E |] ==> $H, P <-> Q, $G |- $E" |
69 (fn prems=> [ (REPEAT (resolve_tac (prems@[conjL,impL,basic]) 1)) ]); |
30 (fn prems=> [ (REPEAT (resolve_tac (prems@[conjL,impL,basic]) 1)) ]); |
70 |
31 |
71 val TrueR = prove_goalw LK.thy [True_def] |
32 qed_goalw "TrueR" LK.thy [True_def] |
72 "$H |- $E, True, $F" |
33 "$H |- $E, True, $F" |
73 (fn _=> [ rtac impR 1, rtac basic 1 ]); |
34 (fn _=> [ rtac impR 1, rtac basic 1 ]); |
74 |
35 |
75 |
36 |
76 (** Weakened quantifier rules. Incomplete, they let the search terminate.**) |
37 (** Weakened quantifier rules. Incomplete, they let the search terminate.**) |
77 |
38 |
78 val allL_thin = prove_goal LK.thy |
39 qed_goal "allL_thin" LK.thy |
79 "$H, P(x), $G |- $E ==> $H, ALL x.P(x), $G |- $E" |
40 "$H, P(x), $G |- $E ==> $H, ALL x.P(x), $G |- $E" |
80 (fn prems=> [ (rtac allL 1), (rtac thinL 1), (resolve_tac prems 1) ]); |
41 (fn prems=> [ (rtac allL 1), (rtac thinL 1), (resolve_tac prems 1) ]); |
81 |
42 |
82 val exR_thin = prove_goal LK.thy |
43 qed_goal "exR_thin" LK.thy |
83 "$H |- $E, P(x), $F ==> $H |- $E, EX x.P(x), $F" |
44 "$H |- $E, P(x), $F ==> $H |- $E, EX x.P(x), $F" |
84 (fn prems=> [ (rtac exR 1), (rtac thinR 1), (resolve_tac prems 1) ]); |
45 (fn prems=> [ (rtac exR 1), (rtac thinR 1), (resolve_tac prems 1) ]); |
85 |
46 |
86 (* Symmetry of equality in hypotheses *) |
47 (* Symmetry of equality in hypotheses *) |
87 val symL = prove_goal LK.thy |
48 qed_goal "symL" LK.thy |
88 "$H, $G, B = A |- $E ==> $H, A = B, $G |- $E" |
49 "$H, $G, B = A |- $E ==> $H, A = B, $G |- $E" |
89 (fn prems=> |
50 (fn prems=> |
90 [ (rtac cut 1), |
51 [ (rtac cut 1), |
91 (rtac thinL 2), |
52 (rtac thinL 2), |
92 (resolve_tac prems 2), |
53 (resolve_tac prems 2), |
220 SELECT_GOAL (BEST_FIRST (has_fewer_prems 1, size_of_thm) |
181 SELECT_GOAL (BEST_FIRST (has_fewer_prems 1, size_of_thm) |
221 (step_tac thm_pack 1)); |
182 (step_tac thm_pack 1)); |
222 |
183 |
223 (** Contraction. Useful since some rules are not complete. **) |
184 (** Contraction. Useful since some rules are not complete. **) |
224 |
185 |
225 val conR = prove_goal LK.thy |
186 qed_goal "conR" LK.thy |
226 "$H |- $E, P, $F, P ==> $H |- $E, P, $F" |
187 "$H |- $E, P, $F, P ==> $H |- $E, P, $F" |
227 (fn prems=> |
188 (fn prems=> |
228 [ (rtac cut 1), (REPEAT (resolve_tac (prems@[basic]) 1)) ]); |
189 [ (rtac cut 1), (REPEAT (resolve_tac (prems@[basic]) 1)) ]); |
229 |
190 |
230 val conL = prove_goal LK.thy |
191 qed_goal "conL" LK.thy |
231 "$H, P, $G, P |- $E ==> $H, P, $G |- $E" |
192 "$H, P, $G, P |- $E ==> $H, P, $G |- $E" |
232 (fn prems=> |
193 (fn prems=> |
233 [ (rtac cut 1), (REPEAT (resolve_tac (prems@[basic]) 1)) ]); |
194 [ (rtac cut 1), (REPEAT (resolve_tac (prems@[basic]) 1)) ]); |
234 |
|
235 end; |
|
236 |
|
237 open LK_Resolve; |
|