author | traytel |
Tue, 16 Feb 2016 22:28:19 +0100 | |
changeset 62324 | ae44f16dcea5 |
parent 61841 | 4d3527b94f2a |
child 62329 | 9f7fa08d2307 |
permissions | -rw-r--r-- |
55061 | 1 |
(* Title: HOL/Tools/BNF/bnf_def_tactics.ML |
49284 | 2 |
Author: Dmitriy Traytel, TU Muenchen |
3 |
Author: Jasmin Blanchette, TU Muenchen |
|
57668 | 4 |
Author: Martin Desharnais, TU Muenchen |
62324 | 5 |
Author: Ondrej Kuncar, TU Muenchen |
6 |
Copyright 2012, 2013, 2014, 2015 |
|
49284 | 7 |
|
8 |
Tactics for definition of bounded natural functors. |
|
9 |
*) |
|
10 |
||
11 |
signature BNF_DEF_TACTICS = |
|
12 |
sig |
|
60728 | 13 |
val mk_collect_set_map_tac: Proof.context -> thm list -> tactic |
14 |
val mk_in_mono_tac: Proof.context -> int -> tactic |
|
57970 | 15 |
val mk_inj_map_strong_tac: Proof.context -> thm -> thm list -> thm -> tactic |
60728 | 16 |
val mk_inj_map_tac: Proof.context -> int -> thm -> thm -> thm -> thm -> tactic |
53285 | 17 |
val mk_map_id: thm -> thm |
56903 | 18 |
val mk_map_ident: Proof.context -> thm -> thm |
53288 | 19 |
val mk_map_comp: thm -> thm |
51798 | 20 |
val mk_map_cong_tac: Proof.context -> thm -> tactic |
53290 | 21 |
val mk_set_map: thm -> thm |
58106 | 22 |
val mk_set_transfer_tac: Proof.context -> thm -> thm list -> tactic |
49284 | 23 |
|
55197 | 24 |
val mk_rel_Grp_tac: Proof.context -> thm list -> thm -> thm -> thm -> thm -> thm list -> tactic |
60728 | 25 |
val mk_rel_eq_tac: Proof.context -> int -> thm -> thm -> thm -> tactic |
55197 | 26 |
val mk_rel_OO_le_tac: Proof.context -> thm list -> thm -> thm -> thm -> thm list -> tactic |
60728 | 27 |
val mk_rel_conversep_tac: Proof.context -> thm -> thm -> tactic |
55197 | 28 |
val mk_rel_conversep_le_tac: Proof.context -> thm list -> thm -> thm -> thm -> thm list -> tactic |
57932 | 29 |
val mk_rel_map0_tac: Proof.context -> int -> thm -> thm -> thm -> thm -> tactic |
60728 | 30 |
val mk_rel_mono_tac: Proof.context -> thm list -> thm -> tactic |
57967 | 31 |
val mk_rel_mono_strong0_tac: Proof.context -> thm -> thm list -> tactic |
61242 | 32 |
val mk_rel_cong_tac: Proof.context -> thm list * thm list -> thm -> tactic |
58104 | 33 |
val mk_rel_transfer_tac: Proof.context -> thm -> thm list -> thm -> tactic |
62324 | 34 |
val mk_rel_eq_onp_tac: Proof.context -> thm -> thm -> thm -> tactic |
35 |
val mk_pred_mono_strong0_tac: Proof.context -> thm -> thm -> tactic |
|
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
36 |
|
55197 | 37 |
val mk_map_transfer_tac: Proof.context -> thm -> thm -> thm list -> thm -> thm -> tactic |
52719
480a3479fa47
transfer rule for map (not yet registered as a transfer rule)
traytel
parents:
52659
diff
changeset
|
38 |
|
55197 | 39 |
val mk_in_bd_tac: Proof.context -> int -> thm -> thm -> thm -> thm -> thm list -> thm list -> |
40 |
thm -> thm -> thm -> thm -> tactic |
|
54189
c0186a0d8cb3
define a trivial nonemptiness witness if none is provided
traytel
parents:
53562
diff
changeset
|
41 |
|
55197 | 42 |
val mk_trivial_wit_tac: Proof.context -> thm list -> thm list -> tactic |
49284 | 43 |
end; |
44 |
||
45 |
structure BNF_Def_Tactics : BNF_DEF_TACTICS = |
|
46 |
struct |
|
47 |
||
48 |
open BNF_Util |
|
49 |
open BNF_Tactics |
|
50 |
||
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
51 |
val ord_eq_le_trans = @{thm ord_eq_le_trans}; |
52844
66fa0f602cc4
more robust tactics (don't use unfolding when RHS might contain schematics not contained on the LHS)
traytel
parents:
52813
diff
changeset
|
52 |
val ord_le_eq_trans = @{thm ord_le_eq_trans}; |
52749 | 53 |
val conversep_shift = @{thm conversep_le_swap} RS iffD1; |
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
54 |
|
53285 | 55 |
fun mk_map_id id = mk_trans (fun_cong OF [id]) @{thm id_apply}; |
56903 | 56 |
fun mk_map_ident ctxt = unfold_thms ctxt @{thms id_def}; |
55067 | 57 |
fun mk_map_comp comp = @{thm comp_eq_dest_lhs} OF [mk_sym comp]; |
51798 | 58 |
fun mk_map_cong_tac ctxt cong0 = |
60728 | 59 |
(hyp_subst_tac ctxt THEN' rtac ctxt cong0 THEN' |
60752 | 60 |
REPEAT_DETERM o (dtac ctxt meta_spec THEN' etac ctxt meta_mp THEN' assume_tac ctxt)) 1; |
53290 | 61 |
fun mk_set_map set_map0 = set_map0 RS @{thm comp_eq_dest}; |
60757 | 62 |
|
63 |
fun mk_in_mono_tac ctxt n = |
|
64 |
if n = 0 then rtac ctxt subset_UNIV 1 |
|
65 |
else |
|
66 |
(rtac ctxt subsetI THEN' rtac ctxt CollectI) 1 THEN |
|
67 |
REPEAT_DETERM (eresolve_tac ctxt [CollectE, conjE] 1) THEN |
|
68 |
REPEAT_DETERM_N (n - 1) |
|
69 |
((rtac ctxt conjI THEN' etac ctxt subset_trans THEN' assume_tac ctxt) 1) THEN |
|
70 |
(etac ctxt subset_trans THEN' assume_tac ctxt) 1; |
|
49284 | 71 |
|
60728 | 72 |
fun mk_inj_map_tac ctxt n map_id map_comp map_cong0 map_cong = |
56635 | 73 |
let |
74 |
val map_cong' = map_cong OF (asm_rl :: replicate n refl); |
|
75 |
val map_cong0' = map_cong0 OF (replicate n @{thm the_inv_f_o_f_id}); |
|
76 |
in |
|
60728 | 77 |
HEADGOAL (rtac ctxt @{thm injI} THEN' etac ctxt (map_cong' RS box_equals) THEN' |
78 |
REPEAT_DETERM_N 2 o (rtac ctxt (box_equals OF [map_cong0', map_comp RS sym, map_id]) THEN' |
|
60752 | 79 |
REPEAT_DETERM_N n o assume_tac ctxt)) |
56635 | 80 |
end; |
81 |
||
57970 | 82 |
fun mk_inj_map_strong_tac ctxt rel_eq rel_maps rel_mono_strong = |
83 |
let |
|
84 |
val rel_eq' = rel_eq RS @{thm predicate2_eqD}; |
|
85 |
val rel_maps' = map (fn thm => thm RS iffD1) rel_maps; |
|
86 |
in |
|
60728 | 87 |
HEADGOAL (dtac ctxt (rel_eq' RS iffD2) THEN' rtac ctxt (rel_eq' RS iffD1)) THEN |
88 |
EVERY (map (HEADGOAL o dtac ctxt) rel_maps') THEN |
|
89 |
HEADGOAL (etac ctxt rel_mono_strong) THEN |
|
57970 | 90 |
TRYALL (Goal.assume_rule_tac ctxt) |
91 |
end; |
|
92 |
||
60728 | 93 |
fun mk_collect_set_map_tac ctxt set_map0s = |
94 |
(rtac ctxt (@{thm collect_comp} RS trans) THEN' rtac ctxt @{thm arg_cong[of _ _ collect]} THEN' |
|
53289 | 95 |
EVERY' (map (fn set_map0 => |
60728 | 96 |
rtac ctxt (mk_trans @{thm image_insert} @{thm arg_cong2[of _ _ _ _ insert]}) THEN' |
97 |
rtac ctxt set_map0) set_map0s) THEN' |
|
98 |
rtac ctxt @{thm image_empty}) 1; |
|
49284 | 99 |
|
55197 | 100 |
fun mk_rel_Grp_tac ctxt rel_OO_Grps map_id0 map_cong0 map_id map_comp set_maps = |
49284 | 101 |
let |
54792 | 102 |
val n = length set_maps; |
61760 | 103 |
val rel_OO_Grps_tac = |
104 |
if null rel_OO_Grps then K all_tac else rtac ctxt (hd rel_OO_Grps RS trans); |
|
49284 | 105 |
in |
54792 | 106 |
if null set_maps then |
53270 | 107 |
unfold_thms_tac ctxt ((map_id0 RS @{thm Grp_UNIV_id}) :: rel_OO_Grps) THEN |
60728 | 108 |
rtac ctxt @{thm Grp_UNIV_idI[OF refl]} 1 |
52844
66fa0f602cc4
more robust tactics (don't use unfolding when RHS might contain schematics not contained on the LHS)
traytel
parents:
52813
diff
changeset
|
109 |
else |
60728 | 110 |
EVERY' [rel_OO_Grps_tac, rtac ctxt @{thm antisym}, rtac ctxt @{thm predicate2I}, |
61760 | 111 |
REPEAT_DETERM o eresolve_tac ctxt |
112 |
[CollectE, exE, conjE, @{thm GrpE}, @{thm relcomppE}, @{thm conversepE}], |
|
113 |
hyp_subst_tac ctxt, rtac ctxt @{thm GrpI}, rtac ctxt trans, rtac ctxt map_comp, |
|
114 |
rtac ctxt map_cong0, |
|
115 |
REPEAT_DETERM_N n o EVERY' [rtac ctxt @{thm Collect_case_prod_Grp_eqD}, |
|
116 |
etac ctxt @{thm set_mp}, assume_tac ctxt], |
|
60728 | 117 |
rtac ctxt CollectI, |
118 |
CONJ_WRAP' (fn thm => EVERY' [rtac ctxt (thm RS ord_eq_le_trans), |
|
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
61242
diff
changeset
|
119 |
rtac ctxt @{thm image_subsetI}, rtac ctxt @{thm Collect_case_prod_Grp_in}, |
60752 | 120 |
etac ctxt @{thm set_mp}, assume_tac ctxt]) |
54792 | 121 |
set_maps, |
60728 | 122 |
rtac ctxt @{thm predicate2I}, REPEAT_DETERM o eresolve_tac ctxt [@{thm GrpE}, exE, conjE], |
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51798
diff
changeset
|
123 |
hyp_subst_tac ctxt, |
60728 | 124 |
rtac ctxt @{thm relcomppI}, rtac ctxt @{thm conversepI}, |
53270 | 125 |
EVERY' (map2 (fn convol => fn map_id0 => |
60728 | 126 |
EVERY' [rtac ctxt @{thm GrpI}, |
127 |
rtac ctxt (@{thm box_equals} OF [map_cong0, map_comp RS sym, map_id0]), |
|
128 |
REPEAT_DETERM_N n o rtac ctxt (convol RS fun_cong), |
|
59498
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents:
58446
diff
changeset
|
129 |
REPEAT_DETERM o eresolve_tac ctxt [CollectE, conjE], |
60728 | 130 |
rtac ctxt CollectI, |
49495 | 131 |
CONJ_WRAP' (fn thm => |
60728 | 132 |
EVERY' [rtac ctxt ord_eq_le_trans, rtac ctxt thm, rtac ctxt @{thm image_subsetI}, |
60752 | 133 |
rtac ctxt @{thm convol_mem_GrpI}, etac ctxt set_mp, assume_tac ctxt]) |
54792 | 134 |
set_maps]) |
53285 | 135 |
@{thms fst_convol snd_convol} [map_id, refl])] 1 |
49284 | 136 |
end; |
137 |
||
60728 | 138 |
fun mk_rel_eq_tac ctxt n rel_Grp rel_cong map_id0 = |
139 |
(EVERY' (rtac ctxt (rel_cong RS trans) :: replicate n (rtac ctxt @{thm eq_alt})) THEN' |
|
140 |
rtac ctxt (rel_Grp RSN (2, @{thm box_equals[OF _ sym sym[OF eq_alt]]})) THEN' |
|
141 |
(if n = 0 then rtac ctxt refl |
|
142 |
else EVERY' [rtac ctxt @{thm arg_cong2[of _ _ _ _ "Grp"]}, |
|
143 |
rtac ctxt @{thm equalityI}, rtac ctxt subset_UNIV, rtac ctxt subsetI, rtac ctxt CollectI, |
|
144 |
CONJ_WRAP' (K (rtac ctxt subset_UNIV)) (1 upto n), rtac ctxt map_id0])) 1; |
|
49284 | 145 |
|
57932 | 146 |
fun mk_rel_map0_tac ctxt live rel_compp rel_conversep rel_Grp map_id = |
147 |
if live = 0 then |
|
148 |
HEADGOAL (Goal.conjunction_tac) THEN |
|
149 |
unfold_thms_tac ctxt @{thms id_apply} THEN |
|
60728 | 150 |
ALLGOALS (rtac ctxt refl) |
57932 | 151 |
else |
152 |
let |
|
153 |
val ks = 1 upto live; |
|
154 |
in |
|
155 |
Goal.conjunction_tac 1 THEN |
|
156 |
unfold_thms_tac ctxt [rel_compp, rel_conversep, rel_Grp, @{thm vimage2p_Grp}] THEN |
|
60728 | 157 |
TRYALL (EVERY' [rtac ctxt iffI, rtac ctxt @{thm relcomppI}, rtac ctxt @{thm GrpI}, |
158 |
resolve_tac ctxt [map_id, refl], rtac ctxt CollectI, |
|
61760 | 159 |
CONJ_WRAP' (K (rtac ctxt @{thm subset_UNIV})) ks, rtac ctxt @{thm relcomppI}, |
160 |
assume_tac ctxt, rtac ctxt @{thm conversepI}, rtac ctxt @{thm GrpI}, |
|
161 |
resolve_tac ctxt [map_id, refl], rtac ctxt CollectI, |
|
60728 | 162 |
CONJ_WRAP' (K (rtac ctxt @{thm subset_UNIV})) ks, |
59498
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents:
58446
diff
changeset
|
163 |
REPEAT_DETERM o eresolve_tac ctxt @{thms relcomppE conversepE GrpE}, |
60752 | 164 |
dtac ctxt (trans OF [sym, map_id]), hyp_subst_tac ctxt, assume_tac ctxt]) |
57932 | 165 |
end; |
166 |
||
60728 | 167 |
fun mk_rel_mono_tac ctxt rel_OO_Grps in_mono = |
52844
66fa0f602cc4
more robust tactics (don't use unfolding when RHS might contain schematics not contained on the LHS)
traytel
parents:
52813
diff
changeset
|
168 |
let |
66fa0f602cc4
more robust tactics (don't use unfolding when RHS might contain schematics not contained on the LHS)
traytel
parents:
52813
diff
changeset
|
169 |
val rel_OO_Grps_tac = if null rel_OO_Grps then K all_tac |
60728 | 170 |
else rtac ctxt (hd rel_OO_Grps RS ord_eq_le_trans) THEN' |
171 |
rtac ctxt (hd rel_OO_Grps RS sym RSN (2, ord_le_eq_trans)); |
|
52844
66fa0f602cc4
more robust tactics (don't use unfolding when RHS might contain schematics not contained on the LHS)
traytel
parents:
52813
diff
changeset
|
172 |
in |
60728 | 173 |
EVERY' [rel_OO_Grps_tac, rtac ctxt @{thm relcompp_mono}, rtac ctxt @{thm iffD2[OF conversep_mono]}, |
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
61242
diff
changeset
|
174 |
rtac ctxt @{thm Grp_mono}, rtac ctxt in_mono, REPEAT_DETERM o etac ctxt @{thm Collect_case_prod_mono}, |
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
61242
diff
changeset
|
175 |
rtac ctxt @{thm Grp_mono}, rtac ctxt in_mono, REPEAT_DETERM o etac ctxt @{thm Collect_case_prod_mono}] 1 |
52844
66fa0f602cc4
more robust tactics (don't use unfolding when RHS might contain schematics not contained on the LHS)
traytel
parents:
52813
diff
changeset
|
176 |
end; |
49284 | 177 |
|
55197 | 178 |
fun mk_rel_conversep_le_tac ctxt rel_OO_Grps rel_eq map_cong0 map_comp set_maps = |
49284 | 179 |
let |
54792 | 180 |
val n = length set_maps; |
52844
66fa0f602cc4
more robust tactics (don't use unfolding when RHS might contain schematics not contained on the LHS)
traytel
parents:
52813
diff
changeset
|
181 |
val rel_OO_Grps_tac = if null rel_OO_Grps then K all_tac |
60728 | 182 |
else rtac ctxt (hd rel_OO_Grps RS ord_eq_le_trans) THEN' |
183 |
rtac ctxt (hd rel_OO_Grps RS sym RS @{thm arg_cong[of _ _ conversep]} RSN (2, ord_le_eq_trans)); |
|
49284 | 184 |
in |
60728 | 185 |
if null set_maps then rtac ctxt (rel_eq RS @{thm leq_conversepI}) 1 |
52844
66fa0f602cc4
more robust tactics (don't use unfolding when RHS might contain schematics not contained on the LHS)
traytel
parents:
52813
diff
changeset
|
186 |
else |
60728 | 187 |
EVERY' [rel_OO_Grps_tac, rtac ctxt @{thm predicate2I}, |
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51798
diff
changeset
|
188 |
REPEAT_DETERM o |
59498
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents:
58446
diff
changeset
|
189 |
eresolve_tac ctxt [CollectE, exE, conjE, @{thm GrpE}, @{thm relcomppE}, @{thm conversepE}], |
60728 | 190 |
hyp_subst_tac ctxt, rtac ctxt @{thm conversepI}, rtac ctxt @{thm relcomppI}, rtac ctxt @{thm conversepI}, |
191 |
EVERY' (map (fn thm => EVERY' [rtac ctxt @{thm GrpI}, rtac ctxt sym, rtac ctxt trans, |
|
192 |
rtac ctxt map_cong0, REPEAT_DETERM_N n o rtac ctxt thm, |
|
193 |
rtac ctxt (map_comp RS sym), rtac ctxt CollectI, |
|
194 |
CONJ_WRAP' (fn thm => EVERY' [rtac ctxt (thm RS ord_eq_le_trans), |
|
195 |
etac ctxt @{thm flip_pred}]) set_maps]) [@{thm snd_fst_flip}, @{thm fst_snd_flip}])] 1 |
|
49284 | 196 |
end; |
197 |
||
60728 | 198 |
fun mk_rel_conversep_tac ctxt le_conversep rel_mono = |
199 |
EVERY' [rtac ctxt @{thm antisym}, rtac ctxt le_conversep, rtac ctxt @{thm xt1(6)}, rtac ctxt conversep_shift, |
|
200 |
rtac ctxt le_conversep, rtac ctxt @{thm iffD2[OF conversep_mono]}, rtac ctxt rel_mono, |
|
201 |
REPEAT_DETERM o rtac ctxt @{thm eq_refl[OF sym[OF conversep_conversep]]}] 1; |
|
49284 | 202 |
|
55197 | 203 |
fun mk_rel_OO_le_tac ctxt rel_OO_Grps rel_eq map_cong0 map_comp set_maps = |
49284 | 204 |
let |
54792 | 205 |
val n = length set_maps; |
60728 | 206 |
fun in_tac nthO_in = rtac ctxt CollectI THEN' |
207 |
CONJ_WRAP' (fn thm => EVERY' [rtac ctxt (thm RS ord_eq_le_trans), |
|
60752 | 208 |
rtac ctxt @{thm image_subsetI}, rtac ctxt nthO_in, etac ctxt set_mp, assume_tac ctxt]) set_maps; |
52844
66fa0f602cc4
more robust tactics (don't use unfolding when RHS might contain schematics not contained on the LHS)
traytel
parents:
52813
diff
changeset
|
209 |
val rel_OO_Grps_tac = if null rel_OO_Grps then K all_tac |
60728 | 210 |
else rtac ctxt (hd rel_OO_Grps RS ord_eq_le_trans) THEN' |
211 |
rtac ctxt (@{thm arg_cong2[of _ _ _ _ "op OO"]} OF (replicate 2 (hd rel_OO_Grps RS sym)) RSN |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54792
diff
changeset
|
212 |
(2, ord_le_eq_trans)); |
49284 | 213 |
in |
60728 | 214 |
if null set_maps then rtac ctxt (rel_eq RS @{thm leq_OOI}) 1 |
52844
66fa0f602cc4
more robust tactics (don't use unfolding when RHS might contain schematics not contained on the LHS)
traytel
parents:
52813
diff
changeset
|
215 |
else |
60728 | 216 |
EVERY' [rel_OO_Grps_tac, rtac ctxt @{thm predicate2I}, |
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51798
diff
changeset
|
217 |
REPEAT_DETERM o |
59498
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents:
58446
diff
changeset
|
218 |
eresolve_tac ctxt [CollectE, exE, conjE, @{thm GrpE}, @{thm relcomppE}, @{thm conversepE}], |
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51798
diff
changeset
|
219 |
hyp_subst_tac ctxt, |
60728 | 220 |
rtac ctxt @{thm relcomppI}, rtac ctxt @{thm relcomppI}, rtac ctxt @{thm conversepI}, rtac ctxt @{thm GrpI}, |
221 |
rtac ctxt trans, rtac ctxt map_comp, rtac ctxt sym, rtac ctxt map_cong0, |
|
222 |
REPEAT_DETERM_N n o rtac ctxt @{thm fst_fstOp}, |
|
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51798
diff
changeset
|
223 |
in_tac @{thm fstOp_in}, |
60728 | 224 |
rtac ctxt @{thm GrpI}, rtac ctxt trans, rtac ctxt map_comp, rtac ctxt map_cong0, |
225 |
REPEAT_DETERM_N n o EVERY' [rtac ctxt trans, rtac ctxt o_apply, |
|
226 |
rtac ctxt ballE, rtac ctxt subst, |
|
60752 | 227 |
rtac ctxt @{thm csquare_def}, rtac ctxt @{thm csquare_fstOp_sndOp}, assume_tac ctxt, |
228 |
etac ctxt notE, etac ctxt set_mp, assume_tac ctxt], |
|
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51798
diff
changeset
|
229 |
in_tac @{thm fstOp_in}, |
60728 | 230 |
rtac ctxt @{thm relcomppI}, rtac ctxt @{thm conversepI}, rtac ctxt @{thm GrpI}, |
231 |
rtac ctxt trans, rtac ctxt map_comp, rtac ctxt map_cong0, |
|
232 |
REPEAT_DETERM_N n o rtac ctxt o_apply, |
|
51893
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
traytel
parents:
51798
diff
changeset
|
233 |
in_tac @{thm sndOp_in}, |
60728 | 234 |
rtac ctxt @{thm GrpI}, rtac ctxt trans, rtac ctxt map_comp, rtac ctxt sym, rtac ctxt map_cong0, |
235 |
REPEAT_DETERM_N n o rtac ctxt @{thm snd_sndOp}, |
|
54841
af71b753c459
express weak pullback property of bnfs only in terms of the relator
traytel
parents:
54792
diff
changeset
|
236 |
in_tac @{thm sndOp_in}] 1 |
49284 | 237 |
end; |
238 |
||
57967 | 239 |
fun mk_rel_mono_strong0_tac ctxt in_rel set_maps = |
60752 | 240 |
if null set_maps then assume_tac ctxt 1 |
51916 | 241 |
else |
54998 | 242 |
unfold_tac ctxt [in_rel] THEN |
59498
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents:
58446
diff
changeset
|
243 |
REPEAT_DETERM (eresolve_tac ctxt [exE, CollectE, conjE] 1) THEN |
51916 | 244 |
hyp_subst_tac ctxt 1 THEN |
60728 | 245 |
EVERY' [rtac ctxt exI, rtac ctxt @{thm conjI[OF CollectI conjI[OF refl refl]]}, |
55163 | 246 |
CONJ_WRAP' (fn thm => |
60752 | 247 |
(etac ctxt (@{thm Collect_split_mono_strong} OF [thm, thm]) THEN' assume_tac ctxt)) |
55163 | 248 |
set_maps] 1; |
51916 | 249 |
|
58104 | 250 |
fun mk_rel_transfer_tac ctxt in_rel rel_map rel_mono_strong = |
251 |
let |
|
252 |
fun last_tac iffD = |
|
60728 | 253 |
HEADGOAL (etac ctxt rel_mono_strong) THEN |
254 |
REPEAT_DETERM (HEADGOAL (etac ctxt (@{thm predicate2_transferD} RS iffD) THEN' |
|
60752 | 255 |
REPEAT_DETERM o assume_tac ctxt)); |
58104 | 256 |
in |
60728 | 257 |
REPEAT_DETERM (HEADGOAL (rtac ctxt rel_funI)) THEN |
258 |
(HEADGOAL (hyp_subst_tac ctxt THEN' rtac ctxt refl) ORELSE |
|
59498
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents:
58446
diff
changeset
|
259 |
REPEAT_DETERM (HEADGOAL (eresolve_tac ctxt (Tactic.make_elim (in_rel RS iffD1) :: |
58104 | 260 |
@{thms exE conjE CollectE}))) THEN |
60728 | 261 |
HEADGOAL (hyp_subst_tac ctxt) THEN unfold_thms_tac ctxt rel_map THEN HEADGOAL (rtac ctxt iffI) THEN |
58104 | 262 |
last_tac iffD1 THEN last_tac iffD2) |
263 |
end; |
|
264 |
||
55197 | 265 |
fun mk_map_transfer_tac ctxt rel_mono in_rel set_maps map_cong0 map_comp = |
52719
480a3479fa47
transfer rule for map (not yet registered as a transfer rule)
traytel
parents:
52659
diff
changeset
|
266 |
let |
53290 | 267 |
val n = length set_maps; |
60728 | 268 |
val in_tac = if n = 0 then rtac ctxt UNIV_I else |
269 |
rtac ctxt CollectI THEN' CONJ_WRAP' (fn thm => |
|
270 |
etac ctxt (thm RS |
|
53562 | 271 |
@{thm ord_eq_le_trans[OF _ subset_trans[OF image_mono convol_image_vimage2p]]})) |
272 |
set_maps; |
|
52719
480a3479fa47
transfer rule for map (not yet registered as a transfer rule)
traytel
parents:
52659
diff
changeset
|
273 |
in |
60728 | 274 |
REPEAT_DETERM_N n (HEADGOAL (rtac ctxt rel_funI)) THEN |
55945 | 275 |
unfold_thms_tac ctxt @{thms rel_fun_iff_leq_vimage2p} THEN |
60752 | 276 |
HEADGOAL (EVERY' [rtac ctxt @{thm order_trans}, rtac ctxt rel_mono, |
277 |
REPEAT_DETERM_N n o assume_tac ctxt, |
|
60728 | 278 |
rtac ctxt @{thm predicate2I}, dtac ctxt (in_rel RS iffD1), |
59498
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents:
58446
diff
changeset
|
279 |
REPEAT_DETERM o eresolve_tac ctxt [exE, CollectE, conjE], hyp_subst_tac ctxt, |
60728 | 280 |
rtac ctxt @{thm vimage2pI}, rtac ctxt (in_rel RS iffD2), rtac ctxt exI, rtac ctxt conjI, in_tac, |
281 |
rtac ctxt conjI, |
|
52719
480a3479fa47
transfer rule for map (not yet registered as a transfer rule)
traytel
parents:
52659
diff
changeset
|
282 |
EVERY' (map (fn convol => |
60728 | 283 |
rtac ctxt (@{thm box_equals} OF [map_cong0, map_comp RS sym, map_comp RS sym]) THEN' |
284 |
REPEAT_DETERM_N n o rtac ctxt (convol RS fun_cong)) @{thms fst_convol snd_convol})]) |
|
52719
480a3479fa47
transfer rule for map (not yet registered as a transfer rule)
traytel
parents:
52659
diff
changeset
|
285 |
end; |
480a3479fa47
transfer rule for map (not yet registered as a transfer rule)
traytel
parents:
52659
diff
changeset
|
286 |
|
55197 | 287 |
fun mk_in_bd_tac ctxt live surj_imp_ordLeq_inst map_comp map_id map_cong0 set_maps set_bds |
288 |
bd_card_order bd_Card_order bd_Cinfinite bd_Cnotzero = |
|
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
289 |
if live = 0 then |
60728 | 290 |
rtac ctxt @{thm ordLeq_transitive[OF ordLeq_csum2[OF card_of_Card_order] |
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
291 |
ordLeq_cexp2[OF ordLeq_refl[OF Card_order_ctwo] Card_order_csum]]} 1 |
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
292 |
else |
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
293 |
let |
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
294 |
val bd'_Cinfinite = bd_Cinfinite RS @{thm Cinfinite_csum1}; |
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
295 |
val inserts = |
57970 | 296 |
map (fn set_bd => |
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
297 |
iffD2 OF [@{thm card_of_ordLeq}, @{thm ordLeq_ordIso_trans} OF |
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
298 |
[set_bd, bd_Card_order RS @{thm card_of_Field_ordIso} RS @{thm ordIso_symmetric}]]) |
57970 | 299 |
set_bds; |
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
300 |
in |
60728 | 301 |
EVERY' [rtac ctxt (Drule.rotate_prems 1 ctrans), rtac ctxt @{thm cprod_cinfinite_bound}, |
302 |
rtac ctxt (ctrans OF @{thms ordLeq_csum2 ordLeq_cexp2}), rtac ctxt @{thm card_of_Card_order}, |
|
303 |
rtac ctxt @{thm ordLeq_csum2}, rtac ctxt @{thm Card_order_ctwo}, rtac ctxt @{thm Card_order_csum}, |
|
304 |
rtac ctxt @{thm ordIso_ordLeq_trans}, rtac ctxt @{thm cexp_cong1}, |
|
305 |
if live = 1 then rtac ctxt @{thm ordIso_refl[OF Card_order_csum]} |
|
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
306 |
else |
60728 | 307 |
REPEAT_DETERM_N (live - 2) o rtac ctxt @{thm ordIso_transitive[OF csum_cong2]} THEN' |
308 |
REPEAT_DETERM_N (live - 1) o rtac ctxt @{thm csum_csum}, |
|
309 |
rtac ctxt bd_Card_order, rtac ctxt (@{thm cexp_mono2_Cnotzero} RS ctrans), rtac ctxt @{thm ordLeq_csum1}, |
|
310 |
rtac ctxt bd_Card_order, rtac ctxt @{thm Card_order_csum}, rtac ctxt bd_Cnotzero, |
|
311 |
rtac ctxt @{thm csum_Cfinite_cexp_Cinfinite}, |
|
312 |
rtac ctxt (if live = 1 then @{thm card_of_Card_order} else @{thm Card_order_csum}), |
|
313 |
CONJ_WRAP_GEN' (rtac ctxt @{thm Cfinite_csum}) (K (rtac ctxt @{thm Cfinite_cone})) set_maps, |
|
314 |
rtac ctxt bd'_Cinfinite, rtac ctxt @{thm card_of_Card_order}, |
|
315 |
rtac ctxt @{thm Card_order_cexp}, rtac ctxt @{thm Cinfinite_cexp}, rtac ctxt @{thm ordLeq_csum2}, |
|
316 |
rtac ctxt @{thm Card_order_ctwo}, rtac ctxt bd'_Cinfinite, |
|
317 |
rtac ctxt (Drule.rotate_prems 1 (@{thm cprod_mono2} RSN (2, ctrans))), |
|
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
318 |
REPEAT_DETERM_N (live - 1) o |
60728 | 319 |
(rtac ctxt (bd_Cinfinite RS @{thm cprod_cexp_csum_cexp_Cinfinite} RSN (2, ctrans)) THEN' |
320 |
rtac ctxt @{thm ordLeq_ordIso_trans[OF cprod_mono2 ordIso_symmetric[OF cprod_cexp]]}), |
|
321 |
rtac ctxt @{thm ordLeq_refl[OF Card_order_cexp]}] 1 THEN |
|
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
322 |
unfold_thms_tac ctxt [bd_card_order RS @{thm card_order_csum_cone_cexp_def}] THEN |
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
323 |
unfold_thms_tac ctxt @{thms cprod_def Field_card_of} THEN |
60728 | 324 |
EVERY' [rtac ctxt (Drule.rotate_prems 1 ctrans), rtac ctxt surj_imp_ordLeq_inst, rtac ctxt subsetI, |
61841
4d3527b94f2a
more general types Proof.method / context_tactic;
wenzelm
parents:
61760
diff
changeset
|
325 |
Method.insert_tac ctxt inserts, REPEAT_DETERM o dtac ctxt meta_spec, |
60728 | 326 |
REPEAT_DETERM o eresolve_tac ctxt [exE, Tactic.make_elim conjunct1], etac ctxt CollectE, |
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
327 |
if live = 1 then K all_tac |
60728 | 328 |
else REPEAT_DETERM_N (live - 2) o (etac ctxt conjE THEN' rotate_tac ~1) THEN' etac ctxt conjE, |
329 |
rtac ctxt (Drule.rotate_prems 1 @{thm image_eqI}), rtac ctxt @{thm SigmaI}, rtac ctxt @{thm UNIV_I}, |
|
330 |
CONJ_WRAP_GEN' (rtac ctxt @{thm SigmaI}) |
|
60752 | 331 |
(K (etac ctxt @{thm If_the_inv_into_in_Func} THEN' assume_tac ctxt)) set_maps, |
60728 | 332 |
rtac ctxt sym, |
333 |
rtac ctxt (Drule.rotate_prems 1 |
|
55990 | 334 |
((@{thm box_equals} OF [map_cong0 OF replicate live @{thm If_the_inv_into_f_f}, |
53288 | 335 |
map_comp RS sym, map_id]) RSN (2, trans))), |
60752 | 336 |
REPEAT_DETERM_N (2 * live) o assume_tac ctxt, |
60728 | 337 |
REPEAT_DETERM_N live o rtac ctxt (@{thm prod.case} RS trans), |
338 |
rtac ctxt refl, |
|
339 |
rtac ctxt @{thm surj_imp_ordLeq}, rtac ctxt subsetI, rtac ctxt (Drule.rotate_prems 1 @{thm image_eqI}), |
|
340 |
REPEAT_DETERM o eresolve_tac ctxt [CollectE, conjE], rtac ctxt CollectI, |
|
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
341 |
CONJ_WRAP' (fn thm => |
60728 | 342 |
rtac ctxt (thm RS ord_eq_le_trans) THEN' etac ctxt @{thm subset_trans[OF image_mono Un_upper1]}) |
53290 | 343 |
set_maps, |
60728 | 344 |
rtac ctxt sym, |
345 |
rtac ctxt (@{thm box_equals} OF [map_cong0 OF replicate live @{thm fun_cong[OF case_sum_o_inj(1)]}, |
|
53288 | 346 |
map_comp RS sym, map_id])] 1 |
52635
4f84b730c489
got rid of in_bd BNF property (derivable from set_bd+map_cong+map_comp+map_id)
traytel
parents:
51916
diff
changeset
|
347 |
end; |
51916 | 348 |
|
55197 | 349 |
fun mk_trivial_wit_tac ctxt wit_defs set_maps = |
60752 | 350 |
unfold_thms_tac ctxt wit_defs THEN |
351 |
HEADGOAL (EVERY' (map (fn thm => |
|
352 |
dtac ctxt (thm RS equalityD1 RS set_mp) THEN' etac ctxt imageE THEN' assume_tac ctxt) set_maps)) THEN |
|
353 |
ALLGOALS (assume_tac ctxt); |
|
54189
c0186a0d8cb3
define a trivial nonemptiness witness if none is provided
traytel
parents:
53562
diff
changeset
|
354 |
|
58106 | 355 |
fun mk_set_transfer_tac ctxt in_rel set_maps = |
356 |
Goal.conjunction_tac 1 THEN |
|
60728 | 357 |
EVERY (map (fn set_map => HEADGOAL (rtac ctxt rel_funI) THEN |
59498
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents:
58446
diff
changeset
|
358 |
REPEAT_DETERM (HEADGOAL (eresolve_tac ctxt (Tactic.make_elim (in_rel RS iffD1) :: |
58106 | 359 |
@{thms exE conjE CollectE}))) THEN |
60728 | 360 |
HEADGOAL (hyp_subst_tac ctxt THEN' rtac ctxt (@{thm iffD2[OF arg_cong2]} OF [set_map, set_map]) THEN' |
361 |
rtac ctxt @{thm rel_setI}) THEN |
|
60752 | 362 |
REPEAT (HEADGOAL (etac ctxt imageE THEN' dtac ctxt @{thm set_mp} THEN' assume_tac ctxt THEN' |
59498
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents:
58446
diff
changeset
|
363 |
REPEAT_DETERM o (eresolve_tac ctxt @{thms CollectE case_prodE}) THEN' hyp_subst_tac ctxt THEN' |
60728 | 364 |
rtac ctxt bexI THEN' etac ctxt @{thm subst_Pair[OF _ refl]} THEN' etac ctxt imageI))) set_maps); |
58106 | 365 |
|
61242 | 366 |
fun mk_rel_cong_tac ctxt (eqs, prems) mono = |
367 |
let |
|
368 |
fun mk_tac thm = etac ctxt thm THEN_ALL_NEW assume_tac ctxt; |
|
62324 | 369 |
fun mk_tacs iffD = etac ctxt mono :: |
61242 | 370 |
map (fn thm => (unfold_thms ctxt @{thms simp_implies_def} thm RS iffD) |
371 |
|> Drule.rotate_prems ~1 |> mk_tac) prems; |
|
372 |
in |
|
373 |
unfold_thms_tac ctxt eqs THEN |
|
374 |
HEADGOAL (EVERY' (rtac ctxt iffI :: mk_tacs iffD1 @ mk_tacs iffD2)) |
|
375 |
end; |
|
376 |
||
62324 | 377 |
fun subst_conv ctxt thm = |
378 |
Conv.arg_conv (Conv.arg_conv |
|
379 |
(Conv.top_sweep_conv (K (Conv.rewr_conv (safe_mk_meta_eq thm))) ctxt)); |
|
380 |
||
381 |
fun mk_rel_eq_onp_tac ctxt pred_def map_id0 rel_Grp = |
|
382 |
HEADGOAL (EVERY' |
|
383 |
[SELECT_GOAL (unfold_thms_tac ctxt (pred_def :: @{thms UNIV_def eq_onp_Grp Ball_Collect})), |
|
384 |
CONVERSION (subst_conv ctxt (map_id0 RS sym)), |
|
385 |
rtac ctxt (unfold_thms ctxt @{thms UNIV_def} rel_Grp)]); |
|
386 |
||
387 |
fun mk_pred_mono_strong0_tac ctxt pred_rel rel_mono_strong0 = |
|
388 |
unfold_thms_tac ctxt [pred_rel] THEN |
|
389 |
HEADGOAL (etac ctxt rel_mono_strong0 THEN_ALL_NEW etac ctxt @{thm eq_onp_mono0}); |
|
390 |
||
49284 | 391 |
end; |