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