author | wenzelm |
Sat, 31 Dec 2005 21:49:36 +0100 | |
changeset 18529 | 540da2415751 |
parent 18448 | 6e805f389355 |
child 18630 | 69fe387b3b6e |
permissions | -rw-r--r-- |
9772 | 1 |
(* Title: Provers/clasimp.ML |
4652
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 |
16019 | 6 |
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 |
|
9860 | 9 |
infix 4 addSIs2 addSEs2 addSDs2 addIs2 addEs2 addDs2 addsimps2 delsimps2 |
13603
57f364d1d3b2
Introduced addss', which adds asm_lr_simp_tac as a wrapper to the claset.
berghofe
parents:
13026
diff
changeset
|
10 |
addSss addss addss' addIffs delIffs; |
4652
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 |
|
8469 | 14 |
structure Splitter: SPLITTER |
5219 | 15 |
structure Classical: CLASSICAL |
16 |
structure Blast: BLAST |
|
17 |
sharing type Classical.claset = Blast.claset |
|
9860 | 18 |
val notE: thm |
19 |
val iffD1: thm |
|
20 |
val iffD2: thm |
|
5219 | 21 |
end |
22 |
||
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
23 |
signature CLASIMP = |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
24 |
sig |
5219 | 25 |
include CLASIMP_DATA |
26 |
type claset |
|
27 |
type clasimpset |
|
17879 | 28 |
val change_clasimpset: (clasimpset -> clasimpset) -> unit |
10317 | 29 |
val clasimpset: unit -> clasimpset |
9860 | 30 |
val addSIs2: clasimpset * thm list -> clasimpset |
31 |
val addSEs2: clasimpset * thm list -> clasimpset |
|
32 |
val addSDs2: clasimpset * thm list -> clasimpset |
|
33 |
val addIs2: clasimpset * thm list -> clasimpset |
|
34 |
val addEs2: clasimpset * thm list -> clasimpset |
|
35 |
val addDs2: clasimpset * thm list -> clasimpset |
|
36 |
val addsimps2: clasimpset * thm list -> clasimpset |
|
37 |
val delsimps2: clasimpset * thm list -> clasimpset |
|
38 |
val addSss: claset * simpset -> claset |
|
39 |
val addss: claset * simpset -> claset |
|
13603
57f364d1d3b2
Introduced addss', which adds asm_lr_simp_tac as a wrapper to the claset.
berghofe
parents:
13026
diff
changeset
|
40 |
val addss': claset * simpset -> claset |
9860 | 41 |
val addIffs: clasimpset * thm list -> clasimpset |
42 |
val delIffs: clasimpset * thm list -> clasimpset |
|
43 |
val AddIffs: thm list -> unit |
|
44 |
val DelIffs: thm list -> unit |
|
45 |
val CLASIMPSET: (clasimpset -> tactic) -> tactic |
|
46 |
val CLASIMPSET': (clasimpset -> 'a -> tactic) -> 'a -> tactic |
|
5483 | 47 |
val clarsimp_tac: clasimpset -> int -> tactic |
9860 | 48 |
val Clarsimp_tac: int -> tactic |
49 |
val mk_auto_tac: clasimpset -> int -> int -> tactic |
|
50 |
val auto_tac: clasimpset -> tactic |
|
51 |
val Auto_tac: tactic |
|
52 |
val auto: unit -> unit |
|
53 |
val force_tac: clasimpset -> int -> tactic |
|
54 |
val Force_tac: int -> tactic |
|
55 |
val force: int -> unit |
|
56 |
val fast_simp_tac: clasimpset -> int -> tactic |
|
57 |
val slow_simp_tac: clasimpset -> int -> tactic |
|
58 |
val best_simp_tac: clasimpset -> int -> tactic |
|
8639 | 59 |
val change_global_css: (clasimpset * thm list -> clasimpset) -> theory attribute |
60 |
val change_local_css: (clasimpset * thm list -> clasimpset) -> Proof.context attribute |
|
9506 | 61 |
val get_local_clasimpset: Proof.context -> clasimpset |
15032 | 62 |
val local_clasimpset_of: Proof.context -> clasimpset |
9860 | 63 |
val iff_add_global: theory attribute |
10033
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
64 |
val iff_add_global': theory attribute |
9860 | 65 |
val iff_del_global: theory attribute |
66 |
val iff_add_local: Proof.context attribute |
|
10033
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
67 |
val iff_add_local': Proof.context attribute |
9860 | 68 |
val iff_del_local: Proof.context attribute |
69 |
val iff_modifiers: (Args.T list -> (Method.modifier * Args.T list)) list |
|
9506 | 70 |
val clasimp_modifiers: (Args.T list -> (Method.modifier * Args.T list)) list |
9860 | 71 |
val setup: (theory -> theory) list |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
72 |
end; |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
73 |
|
5219 | 74 |
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
|
75 |
struct |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
76 |
|
5219 | 77 |
open Data; |
78 |
||
79 |
type claset = Classical.claset; |
|
80 |
type clasimpset = claset * simpset; |
|
81 |
||
17879 | 82 |
fun change_clasimpset_of thy f = |
83 |
let val (cs', ss') = f (Classical.get_claset thy, Simplifier.get_simpset thy) in |
|
84 |
Classical.change_claset_of thy (fn _ => cs'); |
|
85 |
Simplifier.change_simpset_of thy (fn _ => ss') |
|
86 |
end; |
|
87 |
||
88 |
fun change_clasimpset f = change_clasimpset_of (Context.the_context ()) f; |
|
10317 | 89 |
fun clasimpset () = (Classical.claset (), Simplifier.simpset ()); |
90 |
||
5219 | 91 |
|
92 |
(* clasimpset operations *) |
|
93 |
||
94 |
(*this interface for updating a clasimpset is rudimentary and just for |
|
95 |
convenience for the most common cases*) |
|
96 |
||
97 |
fun pair_upd1 f ((a,b),x) = (f(a,x), b); |
|
98 |
fun pair_upd2 f ((a,b),x) = (a, f(b,x)); |
|
99 |
||
100 |
fun op addSIs2 arg = pair_upd1 Classical.addSIs arg; |
|
101 |
fun op addSEs2 arg = pair_upd1 Classical.addSEs arg; |
|
102 |
fun op addSDs2 arg = pair_upd1 Classical.addSDs arg; |
|
103 |
fun op addIs2 arg = pair_upd1 Classical.addIs arg; |
|
104 |
fun op addEs2 arg = pair_upd1 Classical.addEs arg; |
|
105 |
fun op addDs2 arg = pair_upd1 Classical.addDs arg; |
|
106 |
fun op addsimps2 arg = pair_upd2 Simplifier.addsimps arg; |
|
107 |
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
|
108 |
|
9402 | 109 |
(*not totally safe: may instantiate unknowns that appear also in other subgoals*) |
110 |
val safe_asm_full_simp_tac = Simplifier.generic_simp_tac true (true,true,true); |
|
111 |
||
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
112 |
(*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
|
113 |
(*Caution: only one simpset added can be added by each of addSss and addss*) |
11181
d04f57b91166
renamed addaltern to addafter, addSaltern to addSafter
oheimb
parents:
10821
diff
changeset
|
114 |
fun cs addSss ss = Classical.addSafter (cs, ("safe_asm_full_simp_tac", |
9772 | 115 |
CHANGED o safe_asm_full_simp_tac ss)); |
116 |
fun cs addss ss = Classical.addbefore (cs, ("asm_full_simp_tac", |
|
117 |
CHANGED o Simplifier.asm_full_simp_tac ss)); |
|
13603
57f364d1d3b2
Introduced addss', which adds asm_lr_simp_tac as a wrapper to the claset.
berghofe
parents:
13026
diff
changeset
|
118 |
fun cs addss' ss = Classical.addbefore (cs, ("asm_full_simp_tac", |
57f364d1d3b2
Introduced addss', which adds asm_lr_simp_tac as a wrapper to the claset.
berghofe
parents:
13026
diff
changeset
|
119 |
CHANGED o Simplifier.asm_lr_simp_tac ss)); |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
120 |
|
17084
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
121 |
(*Attach a suffix, provided we have a name to start with.*) |
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
122 |
fun suffix_thm "" _ th = th |
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
123 |
| suffix_thm a b th = Thm.name_thm (a^b, th); |
9860 | 124 |
|
125 |
(* iffs: addition of rules to simpsets and clasets simultaneously *) |
|
126 |
||
11344 | 127 |
(*Takes (possibly conditional) theorems of the form A<->B to |
9860 | 128 |
the Safe Intr rule B==>A and |
129 |
the Safe Destruct rule A==>B. |
|
130 |
Also ~A goes to the Safe Elim rule A ==> ?R |
|
11462 | 131 |
Failing other cases, A is added as a Safe Intr rule*) |
9860 | 132 |
local |
133 |
||
13026 | 134 |
fun addIff decls1 decls2 simp ((cs, ss), th) = |
135 |
let |
|
17084
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
136 |
val name = Thm.name_of_thm th; |
13026 | 137 |
val n = nprems_of th; |
17084
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
138 |
val (elim, intro) = if n = 0 then decls1 else decls2; |
13026 | 139 |
val zero_rotate = zero_var_indexes o rotate_prems n; |
140 |
in |
|
17084
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
141 |
(elim (intro (cs, [suffix_thm name "_iff2" (zero_rotate (th RS Data.iffD2))]), |
18529 | 142 |
[suffix_thm name "_iff1" (Tactic.make_elim (zero_rotate (th RS Data.iffD1)))]) |
18448 | 143 |
handle THM _ => (elim (cs, [suffix_thm name "_iff1" (zero_rotate (th RS Data.notE))]) |
11902 | 144 |
handle THM _ => intro (cs, [th])), |
145 |
simp (ss, [th])) |
|
146 |
end; |
|
9860 | 147 |
|
12375 | 148 |
fun delIff delcs delss ((cs, ss), th) = |
11902 | 149 |
let val zero_rotate = zero_var_indexes o rotate_prems (nprems_of th) in |
12375 | 150 |
(delcs (cs, [zero_rotate (th RS Data.iffD2), |
18529 | 151 |
Tactic.make_elim (zero_rotate (th RS Data.iffD1))]) |
12375 | 152 |
handle THM _ => (delcs (cs, [zero_rotate (th RS Data.notE)]) |
153 |
handle THM _ => delcs (cs, [th])), |
|
154 |
delss (ss, [th])) |
|
11902 | 155 |
end; |
9860 | 156 |
|
157 |
in |
|
158 |
||
10033
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
159 |
val op addIffs = |
17084
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
160 |
Library.foldl |
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
161 |
(addIff (Classical.addSEs, Classical.addSIs) |
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
162 |
(Classical.addEs, Classical.addIs) |
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
163 |
Simplifier.addsimps); |
15570 | 164 |
val op delIffs = Library.foldl (delIff Classical.delrules Simplifier.delsimps); |
10033
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
165 |
|
17879 | 166 |
fun AddIffs thms = change_clasimpset (fn css => css addIffs thms); |
167 |
fun DelIffs thms = change_clasimpset (fn css => css delIffs thms); |
|
9860 | 168 |
|
12375 | 169 |
fun addIffs_global (thy, ths) = |
15570 | 170 |
Library.foldl (addIff |
17084
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
171 |
(ContextRules.addXEs_global, ContextRules.addXIs_global) |
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
172 |
(ContextRules.addXEs_global, ContextRules.addXIs_global) #1) |
13026 | 173 |
((thy, ()), ths) |> #1; |
12375 | 174 |
|
175 |
fun addIffs_local (ctxt, ths) = |
|
15570 | 176 |
Library.foldl (addIff |
17084
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
177 |
(ContextRules.addXEs_local, ContextRules.addXIs_local) |
fb0a80aef0be
classical rules must have names for ATP integration
paulson
parents:
16019
diff
changeset
|
178 |
(ContextRules.addXEs_local, ContextRules.addXIs_local) #1) |
13026 | 179 |
((ctxt, ()), ths) |> #1; |
12375 | 180 |
|
181 |
fun delIffs_global (thy, ths) = |
|
15570 | 182 |
Library.foldl (delIff ContextRules.delrules_global #1) ((thy, ()), ths) |> #1; |
12375 | 183 |
|
184 |
fun delIffs_local (ctxt, ths) = |
|
15570 | 185 |
Library.foldl (delIff ContextRules.delrules_local #1) ((ctxt, ()), ths) |> #1; |
12375 | 186 |
|
9860 | 187 |
end; |
188 |
||
189 |
||
5219 | 190 |
(* tacticals *) |
191 |
||
192 |
fun CLASIMPSET tacf state = |
|
193 |
Classical.CLASET (fn cs => Simplifier.SIMPSET (fn ss => tacf (cs, ss))) state; |
|
194 |
||
195 |
fun CLASIMPSET' tacf i state = |
|
196 |
Classical.CLASET (fn cs => Simplifier.SIMPSET (fn ss => tacf (cs, ss) i)) state; |
|
4888 | 197 |
|
198 |
||
12375 | 199 |
fun clarsimp_tac (cs, ss) = |
200 |
safe_asm_full_simp_tac ss THEN_ALL_NEW |
|
201 |
Classical.clarify_tac (cs addSss ss); |
|
202 |
||
10317 | 203 |
fun Clarsimp_tac i = clarsimp_tac (clasimpset ()) i; |
5483 | 204 |
|
205 |
||
5219 | 206 |
(* auto_tac *) |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
207 |
|
5219 | 208 |
fun blast_depth_tac cs m i thm = |
9772 | 209 |
Blast.depth_tac cs m i thm |
5554 | 210 |
handle Blast.TRANS s => (warning ("Blast_tac: " ^ s); Seq.empty); |
9772 | 211 |
|
212 |
(* a variant of depth_tac that avoids interference of the simplifier |
|
5219 | 213 |
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
|
214 |
local |
9772 | 215 |
fun slow_step_tac' cs = Classical.appWrappers cs |
216 |
(Classical.instp_step_tac cs APPEND' Classical.haz_step_tac cs); |
|
217 |
in fun nodup_depth_tac cs m i state = SELECT_GOAL |
|
218 |
(Classical.safe_steps_tac cs 1 THEN_ELSE |
|
219 |
(DEPTH_SOLVE (nodup_depth_tac cs m 1), |
|
220 |
Classical.inst0_step_tac cs 1 APPEND COND (K (m=0)) no_tac |
|
221 |
(slow_step_tac' cs 1 THEN DEPTH_SOLVE (nodup_depth_tac cs (m-1) 1)) |
|
5756
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
222 |
)) i state; |
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
223 |
end; |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
224 |
|
9402 | 225 |
(*Designed to be idempotent, except if blast_depth_tac instantiates variables |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
226 |
in some of the subgoals*) |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
227 |
fun mk_auto_tac (cs, ss) m n = |
5219 | 228 |
let val cs' = cs addss ss |
9772 | 229 |
val maintac = |
230 |
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
|
231 |
ORELSE' |
5756
8ef5288c24b0
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5567
diff
changeset
|
232 |
(CHANGED o nodup_depth_tac cs' n); (* slower but more general *) |
5219 | 233 |
in EVERY [ALLGOALS (Simplifier.asm_full_simp_tac ss), |
9772 | 234 |
TRY (Classical.safe_tac cs), |
235 |
REPEAT (FIRSTGOAL maintac), |
|
5219 | 236 |
TRY (Classical.safe_tac (cs addSss ss)), |
9772 | 237 |
prune_params_tac] |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
238 |
end; |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
239 |
|
9772 | 240 |
fun auto_tac css = mk_auto_tac css 4 2; |
10317 | 241 |
fun Auto_tac st = auto_tac (clasimpset ()) st; |
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
242 |
fun auto () = by Auto_tac; |
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
243 |
|
9772 | 244 |
|
5219 | 245 |
(* force_tac *) |
246 |
||
4659 | 247 |
(* 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
|
248 |
fun force_tac (cs,ss) = let val cs' = cs addss ss in SELECT_GOAL (EVERY [ |
9772 | 249 |
Classical.clarify_tac cs' 1, |
250 |
IF_UNSOLVED (Simplifier.asm_full_simp_tac ss 1), |
|
251 |
ALLGOALS (Classical.first_best_tac cs')]) end; |
|
10317 | 252 |
fun Force_tac i = force_tac (clasimpset ()) i; |
4717
1370ad043564
renamed smart_tac to force_tac, slight improvement of force_tac
oheimb
parents:
4659
diff
changeset
|
253 |
fun force i = by (Force_tac i); |
4659 | 254 |
|
5219 | 255 |
|
9805 | 256 |
(* basic combinations *) |
257 |
||
258 |
fun ADDSS tac (cs, ss) = let val cs' = cs addss ss in tac cs' end; |
|
9591 | 259 |
|
9805 | 260 |
val fast_simp_tac = ADDSS Classical.fast_tac; |
261 |
val slow_simp_tac = ADDSS Classical.slow_tac; |
|
262 |
val best_simp_tac = ADDSS Classical.best_tac; |
|
9591 | 263 |
|
264 |
||
9860 | 265 |
(* access clasimpset *) |
8639 | 266 |
|
267 |
fun change_global_css f (thy, th) = |
|
17879 | 268 |
(change_clasimpset_of thy (fn css => f (css, [th])); (thy, th)); |
8639 | 269 |
|
270 |
fun change_local_css f (ctxt, th) = |
|
271 |
let |
|
272 |
val cs = Classical.get_local_claset ctxt; |
|
273 |
val ss = Simplifier.get_local_simpset ctxt; |
|
274 |
val (cs', ss') = f ((cs, ss), [th]); |
|
275 |
val ctxt' = |
|
276 |
ctxt |
|
277 |
|> Classical.put_local_claset cs' |
|
278 |
|> Simplifier.put_local_simpset ss'; |
|
279 |
in (ctxt', th) end; |
|
280 |
||
7153 | 281 |
fun get_local_clasimpset ctxt = |
282 |
(Classical.get_local_claset ctxt, Simplifier.get_local_simpset ctxt); |
|
5926 | 283 |
|
15032 | 284 |
fun local_clasimpset_of ctxt = |
285 |
(Classical.local_claset_of ctxt, Simplifier.local_simpset_of ctxt); |
|
286 |
||
9860 | 287 |
|
288 |
(* attributes *) |
|
289 |
||
12375 | 290 |
fun change_rules f (x, th) = (f (x, [th]), th); |
291 |
||
9860 | 292 |
val iff_add_global = change_global_css (op addIffs); |
12375 | 293 |
val iff_add_global' = change_rules addIffs_global; |
294 |
val iff_del_global = change_global_css (op delIffs) o change_rules delIffs_global; |
|
9860 | 295 |
val iff_add_local = change_local_css (op addIffs); |
12375 | 296 |
val iff_add_local' = change_rules addIffs_local; |
297 |
val iff_del_local = change_local_css (op delIffs) o change_rules delIffs_local; |
|
9860 | 298 |
|
10033
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
299 |
fun iff_att add add' del = Attrib.syntax (Scan.lift |
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
300 |
(Args.del >> K del || |
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
301 |
Scan.option Args.add -- Args.query >> K add' || |
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
302 |
Scan.option Args.add >> K add)); |
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
303 |
|
9860 | 304 |
val iff_attr = |
10033
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
305 |
(iff_att iff_add_global iff_add_global' iff_del_global, |
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
306 |
iff_att iff_add_local iff_add_local' iff_del_local); |
9860 | 307 |
|
308 |
||
309 |
(* method modifiers *) |
|
310 |
||
311 |
val iffN = "iff"; |
|
312 |
||
313 |
val iff_modifiers = |
|
10033
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
314 |
[Args.$$$ iffN -- Scan.option Args.add -- Args.colon >> K ((I, iff_add_local): Method.modifier), |
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
315 |
Args.$$$ iffN -- Scan.option Args.add -- Args.query_colon >> K (I, iff_add_local'), |
fc4e7432b2b1
added iff_add_global', iff_add_local' (syntax "iff?");
wenzelm
parents:
9952
diff
changeset
|
316 |
Args.$$$ iffN -- Args.del -- Args.colon >> K (I, iff_del_local)]; |
9860 | 317 |
|
8469 | 318 |
val clasimp_modifiers = |
9860 | 319 |
Simplifier.simp_modifiers @ Splitter.split_modifiers @ |
320 |
Classical.cla_modifiers @ iff_modifiers; |
|
321 |
||
322 |
||
323 |
(* methods *) |
|
5926 | 324 |
|
7559 | 325 |
fun clasimp_meth tac prems ctxt = Method.METHOD (fn facts => |
15032 | 326 |
ALLGOALS (Method.insert_tac (prems @ facts)) THEN tac (local_clasimpset_of ctxt)); |
7132 | 327 |
|
7559 | 328 |
fun clasimp_meth' tac prems ctxt = Method.METHOD (fn facts => |
15032 | 329 |
HEADGOAL (Method.insert_tac (prems @ facts) THEN' tac (local_clasimpset_of ctxt))); |
5926 | 330 |
|
7559 | 331 |
val clasimp_method = Method.bang_sectioned_args clasimp_modifiers o clasimp_meth; |
332 |
val clasimp_method' = Method.bang_sectioned_args clasimp_modifiers o clasimp_meth'; |
|
5926 | 333 |
|
334 |
||
9772 | 335 |
fun auto_args m = |
336 |
Method.bang_sectioned_args' clasimp_modifiers (Scan.lift (Scan.option (Args.nat -- Args.nat))) m; |
|
337 |
||
15531 | 338 |
fun auto_meth NONE = clasimp_meth (CHANGED_PROP o auto_tac) |
339 |
| auto_meth (SOME (m, n)) = clasimp_meth (CHANGED_PROP o (fn css => mk_auto_tac css m n)); |
|
9772 | 340 |
|
341 |
||
342 |
(* theory setup *) |
|
343 |
||
5926 | 344 |
val setup = |
9860 | 345 |
[Attrib.add_attributes |
9893 | 346 |
[("iff", iff_attr, "declaration of Simplifier / Classical rules")], |
9860 | 347 |
Method.add_methods |
9591 | 348 |
[("fastsimp", clasimp_method' fast_simp_tac, "combined fast and simp"), |
9805 | 349 |
("slowsimp", clasimp_method' slow_simp_tac, "combined slow and simp"), |
350 |
("bestsimp", clasimp_method' best_simp_tac, "combined best and simp"), |
|
9591 | 351 |
("force", clasimp_method' force_tac, "force"), |
9772 | 352 |
("auto", auto_args auto_meth, "auto"), |
10821 | 353 |
("clarsimp", clasimp_method' (CHANGED_PROP oo clarsimp_tac), "clarify simplified goal")]]; |
5926 | 354 |
|
4652
d24cca140eeb
factored out common code of HOL/simpdata.ML and FOL/simpdata.ML concerning
oheimb
parents:
diff
changeset
|
355 |
end; |