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