author | wenzelm |
Wed, 15 Mar 2000 18:40:03 +0100 | |
changeset 8469 | 482c301041b4 |
parent 8168 | 9d2ac5439089 |
child 8639 | 31bcb6b64d60 |
permissions | -rw-r--r-- |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
1 |
(* Title: Provers/clasimp.ML |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
2 |
ID: $Id$ |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
3 |
Author: David von Oheimb, TU Muenchen |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
4 |
|
5219 | 5 |
Combination of classical reasoner and simplifier (depends on |
8469 | 6 |
simplifier.ML, splitter.ML classical.ML, blast.ML). |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
7 |
*) |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
8 |
|
5554 | 9 |
infix 4 addSIs2 addSEs2 addSDs2 addIs2 addEs2 addDs2 addsimps2 delsimps2; |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
10 |
infix 4 addSss addss; |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
11 |
|
5219 | 12 |
signature CLASIMP_DATA = |
13 |
sig |
|
14 |
structure Simplifier: SIMPLIFIER |
|
8469 | 15 |
structure Splitter: SPLITTER |
5219 | 16 |
structure Classical: CLASSICAL |
17 |
structure Blast: BLAST |
|
18 |
sharing type Classical.claset = Blast.claset |
|
19 |
end |
|
20 |
||
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
21 |
signature CLASIMP = |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
22 |
sig |
5219 | 23 |
include CLASIMP_DATA |
24 |
type claset |
|
25 |
type simpset |
|
26 |
type clasimpset |
|
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
27 |
val addSIs2 : clasimpset * thm list -> clasimpset |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
28 |
val addSEs2 : clasimpset * thm list -> clasimpset |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
29 |
val addSDs2 : clasimpset * thm list -> clasimpset |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
30 |
val addIs2 : clasimpset * thm list -> clasimpset |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
31 |
val addEs2 : clasimpset * thm list -> clasimpset |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
32 |
val addDs2 : clasimpset * thm list -> clasimpset |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
33 |
val addsimps2 : clasimpset * thm list -> clasimpset |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
34 |
val delsimps2 : clasimpset * thm list -> clasimpset |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
35 |
val addSss : claset * simpset -> claset |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
36 |
val addss : claset * simpset -> claset |
5483 | 37 |
val CLASIMPSET :(clasimpset -> tactic) -> tactic |
38 |
val CLASIMPSET' :(clasimpset -> 'a -> tactic) -> 'a -> tactic |
|
39 |
val clarsimp_tac: clasimpset -> int -> tactic |
|
40 |
val Clarsimp_tac: int -> tactic |
|
41 |
val mk_auto_tac : clasimpset -> int -> int -> tactic |
|
42 |
val auto_tac : clasimpset -> tactic |
|
43 |
val Auto_tac : tactic |
|
44 |
val auto : unit -> unit |
|
45 |
val force_tac : clasimpset -> int -> tactic |
|
46 |
val Force_tac : int -> tactic |
|
47 |
val force : int -> unit |
|
5926 | 48 |
val setup : (theory -> theory) list |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
49 |
end; |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
50 |
|
5219 | 51 |
functor ClasimpFun(Data: CLASIMP_DATA): CLASIMP = |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
52 |
struct |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
53 |
|
5219 | 54 |
open Data; |
55 |
||
56 |
type claset = Classical.claset; |
|
57 |
type simpset = Simplifier.simpset; |
|
58 |
type clasimpset = claset * simpset; |
|
59 |
||
60 |
||
61 |
(* clasimpset operations *) |
|
62 |
||
63 |
(*this interface for updating a clasimpset is rudimentary and just for |
|
64 |
convenience for the most common cases*) |
|
65 |
||
66 |
fun pair_upd1 f ((a,b),x) = (f(a,x), b); |
|
67 |
fun pair_upd2 f ((a,b),x) = (a, f(b,x)); |
|
68 |
||
69 |
fun op addSIs2 arg = pair_upd1 Classical.addSIs arg; |
|
70 |
fun op addSEs2 arg = pair_upd1 Classical.addSEs arg; |
|
71 |
fun op addSDs2 arg = pair_upd1 Classical.addSDs arg; |
|
72 |
fun op addIs2 arg = pair_upd1 Classical.addIs arg; |
|
73 |
fun op addEs2 arg = pair_upd1 Classical.addEs arg; |
|
74 |
fun op addDs2 arg = pair_upd1 Classical.addDs arg; |
|
75 |
fun op addsimps2 arg = pair_upd2 Simplifier.addsimps arg; |
|
76 |
fun op delsimps2 arg = pair_upd2 Simplifier.delsimps arg; |
|
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
77 |
|
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
78 |
(*Add a simpset to a classical set!*) |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
79 |
(*Caution: only one simpset added can be added by each of addSss and addss*) |
5567 | 80 |
fun cs addSss ss = Classical.addSaltern (cs, ("safe_asm_full_simp_tac", |
5554 | 81 |
CHANGED o Simplifier.safe_asm_full_simp_tac ss)); |
5567 | 82 |
fun cs addss ss = Classical.addbefore (cs, ("asm_full_simp_tac", |
5554 | 83 |
CHANGED o Simplifier.asm_full_simp_tac ss)); |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
84 |
|
5219 | 85 |
(* tacticals *) |
86 |
||
87 |
fun CLASIMPSET tacf state = |
|
88 |
Classical.CLASET (fn cs => Simplifier.SIMPSET (fn ss => tacf (cs, ss))) state; |
|
89 |
||
90 |
fun CLASIMPSET' tacf i state = |
|
91 |
Classical.CLASET (fn cs => Simplifier.SIMPSET (fn ss => tacf (cs, ss) i)) state; |
|
4888 | 92 |
|
93 |
||
7957
0196b2302e21
clarsimp_tac now copes with the (unwanted) case that the simplifier splits
oheimb
parents:
7559
diff
changeset
|
94 |
fun clarsimp_tac (cs, ss) = Simplifier.safe_asm_full_simp_tac ss THEN_ALL_NEW |
5483 | 95 |
Classical.clarify_tac (cs addSss ss); |
96 |
fun Clarsimp_tac i = clarsimp_tac (Classical.claset(), Simplifier.simpset()) i; |
|
97 |
||
98 |
||
5219 | 99 |
(* auto_tac *) |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
100 |
|
5219 | 101 |
fun blast_depth_tac cs m i thm = |
5554 | 102 |
Blast.depth_tac cs m i thm |
103 |
handle Blast.TRANS s => (warning ("Blast_tac: " ^ s); Seq.empty); |
|
5756
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
104 |
|
5219 | 105 |
(* a variant of depth_tac that avoids interference of the simplifier |
106 |
with dup_step_tac when they are combined by auto_tac *) |
|
5756
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
107 |
local |
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
108 |
fun slow_step_tac' cs = Classical.appWrappers cs |
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
109 |
(Classical.instp_step_tac cs APPEND' Classical.haz_step_tac cs); |
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
110 |
in fun nodup_depth_tac cs m i state = SELECT_GOAL |
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
111 |
(Classical.safe_steps_tac cs 1 THEN_ELSE |
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
112 |
(DEPTH_SOLVE (nodup_depth_tac cs m 1), |
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
113 |
Classical.inst0_step_tac cs 1 APPEND COND (K (m=0)) no_tac |
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
114 |
(slow_step_tac' cs 1 THEN DEPTH_SOLVE (nodup_depth_tac cs (m-1) 1)) |
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
115 |
)) i state; |
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
116 |
end; |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
117 |
|
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
118 |
(*Designed to be idempotent, except if best_tac instantiates variables |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
119 |
in some of the subgoals*) |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
120 |
fun mk_auto_tac (cs, ss) m n = |
5219 | 121 |
let val cs' = cs addss ss |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
122 |
val maintac = |
5756
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
123 |
blast_depth_tac cs m (* fast but can't use wrappers *) |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
124 |
ORELSE' |
5756
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
125 |
(CHANGED o nodup_depth_tac cs' n); (* slower but more general *) |
5219 | 126 |
in EVERY [ALLGOALS (Simplifier.asm_full_simp_tac ss), |
5525 | 127 |
TRY (Classical.safe_tac cs), |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
128 |
REPEAT (FIRSTGOAL maintac), |
5219 | 129 |
TRY (Classical.safe_tac (cs addSss ss)), |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
130 |
prune_params_tac] |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
131 |
end; |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
132 |
|
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
133 |
fun auto_tac (cs,ss) = mk_auto_tac (cs,ss) 4 2; |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
134 |
|
5219 | 135 |
fun Auto_tac st = auto_tac (Classical.claset(), Simplifier.simpset()) st; |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
136 |
|
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
137 |
fun auto () = by Auto_tac; |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
138 |
|
5219 | 139 |
|
140 |
(* force_tac *) |
|
141 |
||
4659 | 142 |
(* aimed to solve the given subgoal totally, using whatever tools possible *) |
4717
1370ad043564
renamed smart_tac to force_tac, slight improvement of force_tac
oheimb
parents:
4659
diff
changeset
|
143 |
fun force_tac (cs,ss) = let val cs' = cs addss ss in SELECT_GOAL (EVERY [ |
5219 | 144 |
Classical.clarify_tac cs' 1, |
145 |
IF_UNSOLVED (Simplifier.asm_full_simp_tac ss 1), |
|
146 |
ALLGOALS (Classical.best_tac cs')]) end; |
|
147 |
fun Force_tac i = force_tac (Classical.claset(), Simplifier.simpset()) i; |
|
4717
1370ad043564
renamed smart_tac to force_tac, slight improvement of force_tac
oheimb
parents:
4659
diff
changeset
|
148 |
fun force i = by (Force_tac i); |
4659 | 149 |
|
5219 | 150 |
|
5926 | 151 |
(* methods *) |
152 |
||
7153 | 153 |
fun get_local_clasimpset ctxt = |
154 |
(Classical.get_local_claset ctxt, Simplifier.get_local_simpset ctxt); |
|
5926 | 155 |
|
8469 | 156 |
val clasimp_modifiers = |
157 |
Simplifier.simp_modifiers @ Splitter.split_modifiers @ Classical.cla_modifiers; |
|
5926 | 158 |
|
7559 | 159 |
fun clasimp_meth tac prems ctxt = Method.METHOD (fn facts => |
160 |
ALLGOALS (Method.insert_tac (prems @ facts)) THEN tac (get_local_clasimpset ctxt)); |
|
7132 | 161 |
|
7559 | 162 |
fun clasimp_meth' tac prems ctxt = Method.METHOD (fn facts => |
8168 | 163 |
HEADGOAL (Method.insert_tac (prems @ facts) THEN' tac (get_local_clasimpset ctxt))); |
5926 | 164 |
|
7559 | 165 |
val clasimp_method = Method.bang_sectioned_args clasimp_modifiers o clasimp_meth; |
166 |
val clasimp_method' = Method.bang_sectioned_args clasimp_modifiers o clasimp_meth'; |
|
5926 | 167 |
|
168 |
||
169 |
val setup = |
|
170 |
[Method.add_methods |
|
7437
0f99a2103ea0
renamed improper method 'clarsimp' to 'clarsimp_tac';
wenzelm
parents:
7424
diff
changeset
|
171 |
[("clarsimp_tac", clasimp_method' clarsimp_tac, "clarsimp (improper!)"), |
7394 | 172 |
("auto", clasimp_method (CHANGED o auto_tac), "auto"), |
7272 | 173 |
("force", clasimp_method' force_tac, "force")]]; |
174 |
||
5926 | 175 |
|
176 |
||
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
177 |
end; |