38 val mk_corec_tac: int -> thm list -> thm -> thm -> thm list -> |
38 val mk_corec_tac: int -> thm list -> thm -> thm -> thm list -> |
39 {prems: 'a, context: Proof.context} -> tactic |
39 {prems: 'a, context: Proof.context} -> tactic |
40 val mk_dtor_map_coinduct_tac: int -> int list -> thm -> thm -> tactic |
40 val mk_dtor_map_coinduct_tac: int -> int list -> thm -> thm -> tactic |
41 val mk_dtor_map_strong_coinduct_tac: int list -> ctyp option list -> cterm option list -> thm -> |
41 val mk_dtor_map_strong_coinduct_tac: int list -> ctyp option list -> cterm option list -> thm -> |
42 thm -> thm -> tactic |
42 thm -> thm -> tactic |
|
43 val mk_dtor_set_tac: int -> thm -> thm -> thm list -> tactic |
43 val mk_dtor_srel_coinduct_tac: 'a list -> thm -> thm -> tactic |
44 val mk_dtor_srel_coinduct_tac: 'a list -> thm -> thm -> tactic |
44 val mk_dtor_srel_strong_coinduct_tac: int -> ctyp option list -> cterm option list -> thm -> |
45 val mk_dtor_srel_strong_coinduct_tac: int -> ctyp option list -> cterm option list -> thm -> |
45 thm list -> thm list -> tactic |
46 thm list -> thm list -> tactic |
46 val mk_dtor_srel_tac: thm list -> int -> thm -> thm -> thm -> thm -> thm list -> thm -> thm -> |
47 val mk_dtor_srel_tac: thm list -> int -> thm -> thm -> thm -> thm -> thm list -> thm -> thm -> |
47 thm list -> thm list -> thm list list -> tactic |
48 thm list -> thm list -> thm list list -> tactic |
108 val mk_set_incl_hset_tac: thm -> thm -> tactic |
109 val mk_set_incl_hset_tac: thm -> thm -> tactic |
109 val mk_set_le_tac: int -> thm -> thm list -> thm list list -> tactic |
110 val mk_set_le_tac: int -> thm -> thm list -> thm list list -> tactic |
110 val mk_set_natural_tac: thm -> thm -> tactic |
111 val mk_set_natural_tac: thm -> thm -> tactic |
111 val mk_set_rv_Lev_tac: int -> cterm option list -> thm list -> thm list -> thm list -> thm list -> |
112 val mk_set_rv_Lev_tac: int -> cterm option list -> thm list -> thm list -> thm list -> thm list -> |
112 thm list list -> thm list list -> tactic |
113 thm list list -> thm list list -> tactic |
113 val mk_set_simp_tac: int -> thm -> thm -> thm list -> tactic |
|
114 val mk_strT_hset_tac: int -> int -> int -> ctyp option list -> ctyp option list -> |
114 val mk_strT_hset_tac: int -> int -> int -> ctyp option list -> ctyp option list -> |
115 cterm option list -> thm list -> thm list -> thm list -> thm list -> thm list list -> |
115 cterm option list -> thm list -> thm list -> thm list -> thm list -> thm list list -> |
116 thm list list -> thm list list -> thm -> thm list list -> tactic |
116 thm list list -> thm list list -> thm -> thm list list -> tactic |
117 val mk_unfold_unique_mor_tac: thm list -> thm -> thm -> thm list -> tactic |
117 val mk_unfold_unique_mor_tac: thm list -> thm -> thm -> thm list -> tactic |
118 val mk_unique_mor_tac: thm list -> thm -> tactic |
118 val mk_unique_mor_tac: thm list -> thm -> tactic |
155 atac) 1; |
155 atac) 1; |
156 |
156 |
157 fun mk_mor_incl_tac mor_def map_id's = |
157 fun mk_mor_incl_tac mor_def map_id's = |
158 (stac mor_def THEN' |
158 (stac mor_def THEN' |
159 rtac conjI THEN' |
159 rtac conjI THEN' |
160 CONJ_WRAP' (K (EVERY' [rtac ballI, etac set_mp, stac @{thm id_apply}, atac])) |
160 CONJ_WRAP' (K (EVERY' [rtac ballI, etac set_mp, stac id_apply, atac])) map_id's THEN' |
161 map_id's THEN' |
|
162 CONJ_WRAP' (fn thm => |
161 CONJ_WRAP' (fn thm => |
163 (EVERY' [rtac ballI, rtac (thm RS trans), rtac sym, rtac (@{thm id_apply} RS arg_cong)])) |
162 (EVERY' [rtac ballI, rtac (thm RS trans), rtac sym, rtac (id_apply RS arg_cong)])) map_id's) 1; |
164 map_id's) 1; |
|
165 |
163 |
166 fun mk_mor_comp_tac mor_def mor_images morEs map_comp_ids = |
164 fun mk_mor_comp_tac mor_def mor_images morEs map_comp_ids = |
167 let |
165 let |
168 fun fbetw_tac image = EVERY' [rtac ballI, stac o_apply, etac image, etac image, atac]; |
166 fun fbetw_tac image = EVERY' [rtac ballI, stac o_apply, etac image, etac image, atac]; |
169 fun mor_tac ((mor_image, morE), map_comp_id) = |
167 fun mor_tac ((mor_image, morE), map_comp_id) = |
408 fun coalg_tac (i, ((passive_sets, active_sets), def)) = |
406 fun coalg_tac (i, ((passive_sets, active_sets), def)) = |
409 EVERY' [rtac ballI, REPEAT_DETERM o eresolve_tac [CollectE, exE, conjE], |
407 EVERY' [rtac ballI, REPEAT_DETERM o eresolve_tac [CollectE, exE, conjE], |
410 hyp_subst_tac, rtac (def RS trans RS @{thm ssubst_mem}), etac (arg_cong RS trans), |
408 hyp_subst_tac, rtac (def RS trans RS @{thm ssubst_mem}), etac (arg_cong RS trans), |
411 rtac (mk_sum_casesN n i), rtac CollectI, |
409 rtac (mk_sum_casesN n i), rtac CollectI, |
412 EVERY' (map (fn thm => EVERY' [rtac conjI, rtac (thm RS ord_eq_le_trans), |
410 EVERY' (map (fn thm => EVERY' [rtac conjI, rtac (thm RS ord_eq_le_trans), |
413 etac ((trans OF [@{thm image_id} RS fun_cong, @{thm id_apply}]) RS ord_eq_le_trans)]) |
411 etac ((trans OF [@{thm image_id} RS fun_cong, id_apply]) RS ord_eq_le_trans)]) |
414 passive_sets), |
412 passive_sets), |
415 CONJ_WRAP' (fn (i, thm) => EVERY' [rtac (thm RS ord_eq_le_trans), |
413 CONJ_WRAP' (fn (i, thm) => EVERY' [rtac (thm RS ord_eq_le_trans), |
416 rtac @{thm image_subsetI}, rtac CollectI, rtac exI, rtac exI, rtac conjI, rtac refl, |
414 rtac @{thm image_subsetI}, rtac CollectI, rtac exI, rtac exI, rtac conjI, rtac refl, |
417 rtac conjI, |
415 rtac conjI, |
418 rtac conjI, etac @{thm empty_Shift}, dtac set_rev_mp, |
416 rtac conjI, etac @{thm empty_Shift}, dtac set_rev_mp, |
562 CONJ_WRAP' (fn (i', (carT_def, isNode_def)) => rtac impI THEN' etac conjE THEN' |
560 CONJ_WRAP' (fn (i', (carT_def, isNode_def)) => rtac impI THEN' etac conjE THEN' |
563 (if i = i' |
561 (if i = i' |
564 then EVERY' [rtac @{thm xt1(4)}, rtac set_incl_hset, |
562 then EVERY' [rtac @{thm xt1(4)}, rtac set_incl_hset, |
565 rtac (strT_def RS arg_cong RS trans), etac (arg_cong RS trans), |
563 rtac (strT_def RS arg_cong RS trans), etac (arg_cong RS trans), |
566 rtac (Thm.permute_prems 0 1 (set_natural RS box_equals)), |
564 rtac (Thm.permute_prems 0 1 (set_natural RS box_equals)), |
567 rtac (trans OF [@{thm image_id} RS fun_cong, @{thm id_apply}]), |
565 rtac (trans OF [@{thm image_id} RS fun_cong, id_apply]), |
568 rtac (mk_sum_casesN n i RS (Drule.instantiate' [cT] [] arg_cong) RS sym)] |
566 rtac (mk_sum_casesN n i RS (Drule.instantiate' [cT] [] arg_cong) RS sym)] |
569 else EVERY' [dtac (carT_def RS equalityD1 RS set_mp), |
567 else EVERY' [dtac (carT_def RS equalityD1 RS set_mp), |
570 REPEAT_DETERM o eresolve_tac [CollectE, exE], etac conjE, |
568 REPEAT_DETERM o eresolve_tac [CollectE, exE], etac conjE, |
571 dtac conjunct2, dtac Pair_eqD, etac conjE, |
569 dtac conjunct2, dtac Pair_eqD, etac conjE, |
572 hyp_subst_tac, dtac (isNode_def RS iffD1), |
570 hyp_subst_tac, dtac (isNode_def RS iffD1), |
1112 fun mk_dtor_o_ctor_tac ctor_def unfold map_comp_id map_congL unfold_o_dtors |
1110 fun mk_dtor_o_ctor_tac ctor_def unfold map_comp_id map_congL unfold_o_dtors |
1113 {context = ctxt, prems = _} = |
1111 {context = ctxt, prems = _} = |
1114 unfold_thms_tac ctxt [ctor_def] THEN EVERY' [rtac ext, rtac trans, rtac o_apply, |
1112 unfold_thms_tac ctxt [ctor_def] THEN EVERY' [rtac ext, rtac trans, rtac o_apply, |
1115 rtac trans, rtac unfold, rtac trans, rtac map_comp_id, rtac trans, rtac map_congL, |
1113 rtac trans, rtac unfold, rtac trans, rtac map_comp_id, rtac trans, rtac map_congL, |
1116 EVERY' (map (fn thm => |
1114 EVERY' (map (fn thm => |
1117 rtac ballI THEN' rtac (trans OF [thm RS fun_cong, @{thm id_apply}])) unfold_o_dtors), |
1115 rtac ballI THEN' rtac (trans OF [thm RS fun_cong, id_apply])) unfold_o_dtors), |
1118 rtac sym, rtac @{thm id_apply}] 1; |
1116 rtac sym, rtac id_apply] 1; |
1119 |
1117 |
1120 fun mk_corec_tac m corec_defs unfold map_cong corec_Inls {context = ctxt, prems = _} = |
1118 fun mk_corec_tac m corec_defs unfold map_cong corec_Inls {context = ctxt, prems = _} = |
1121 unfold_thms_tac ctxt corec_defs THEN EVERY' [rtac trans, rtac (o_apply RS arg_cong), |
1119 unfold_thms_tac ctxt corec_defs THEN EVERY' [rtac trans, rtac (o_apply RS arg_cong), |
1122 rtac trans, rtac unfold, fo_rtac (@{thm sum.cases(2)} RS arg_cong RS trans) ctxt, rtac map_cong, |
1120 rtac trans, rtac unfold, fo_rtac (@{thm sum.cases(2)} RS arg_cong RS trans) ctxt, rtac map_cong, |
1123 REPEAT_DETERM_N m o rtac refl, |
1121 REPEAT_DETERM_N m o rtac refl, |
1166 end; |
1164 end; |
1167 |
1165 |
1168 fun mk_dtor_map_strong_coinduct_tac ks cTs cts dtor_map_coinduct bis_def bis_diag = |
1166 fun mk_dtor_map_strong_coinduct_tac ks cTs cts dtor_map_coinduct bis_def bis_diag = |
1169 EVERY' [rtac rev_mp, rtac (Drule.instantiate' cTs cts dtor_map_coinduct), |
1167 EVERY' [rtac rev_mp, rtac (Drule.instantiate' cTs cts dtor_map_coinduct), |
1170 EVERY' (map (fn i => |
1168 EVERY' (map (fn i => |
1171 EVERY' [etac disjE, REPEAT_DETERM o dtac @{thm meta_spec}, etac @{thm meta_mp}, |
1169 EVERY' [etac disjE, REPEAT_DETERM o dtac @{thm meta_spec}, etac meta_mp, |
1172 atac, rtac rev_mp, rtac subst, rtac bis_def, rtac bis_diag, |
1170 atac, rtac rev_mp, rtac subst, rtac bis_def, rtac bis_diag, |
1173 rtac impI, dtac conjunct2, dtac (mk_conjunctN (length ks) i), REPEAT_DETERM o etac allE, |
1171 rtac impI, dtac conjunct2, dtac (mk_conjunctN (length ks) i), REPEAT_DETERM o etac allE, |
1174 etac impE, etac @{thm diag_UNIV_I}, REPEAT_DETERM o eresolve_tac [bexE, conjE, CollectE], |
1172 etac impE, etac @{thm diag_UNIV_I}, REPEAT_DETERM o eresolve_tac [bexE, conjE, CollectE], |
1175 rtac exI, rtac conjI, etac conjI, atac, |
1173 rtac exI, rtac conjI, etac conjI, atac, |
1176 CONJ_WRAP' (K (EVERY' [REPEAT_DETERM o resolve_tac [allI, impI], |
1174 CONJ_WRAP' (K (EVERY' [REPEAT_DETERM o resolve_tac [allI, impI], |
1194 EVERY' [rtac subsetI, rtac @{thm UnI2}, rtac (mk_UnIN n i), etac @{thm UN_I}, |
1192 EVERY' [rtac subsetI, rtac @{thm UnI2}, rtac (mk_UnIN n i), etac @{thm UN_I}, |
1195 etac UnE, etac set_hset, REPEAT_DETERM_N (n - 1) o etac UnE, |
1193 etac UnE, etac set_hset, REPEAT_DETERM_N (n - 1) o etac UnE, |
1196 EVERY' (map (fn thm => EVERY' [etac @{thm UN_E}, etac thm, atac]) set_hset_hsets)]) |
1194 EVERY' (map (fn thm => EVERY' [etac @{thm UN_E}, etac thm, atac]) set_hset_hsets)]) |
1197 (1 upto n) set_hsets set_hset_hsetss)] 1; |
1195 (1 upto n) set_hsets set_hset_hsetss)] 1; |
1198 |
1196 |
1199 fun mk_set_simp_tac n set_le set_incl_hset set_hset_incl_hsets = |
1197 fun mk_dtor_set_tac n set_le set_incl_hset set_hset_incl_hsets = |
1200 EVERY' [rtac equalityI, rtac set_le, rtac @{thm Un_least}, rtac set_incl_hset, |
1198 EVERY' [rtac equalityI, rtac set_le, rtac @{thm Un_least}, rtac set_incl_hset, |
1201 REPEAT_DETERM_N (n - 1) o rtac @{thm Un_least}, |
1199 REPEAT_DETERM_N (n - 1) o rtac @{thm Un_least}, |
1202 EVERY' (map (fn thm => rtac @{thm UN_least} THEN' etac thm) set_hset_incl_hsets)] 1; |
1200 EVERY' (map (fn thm => rtac @{thm UN_least} THEN' etac thm) set_hset_incl_hsets)] 1; |
1203 |
1201 |
1204 fun mk_map_id_tac maps unfold_unique unfold_dtor = |
1202 fun mk_map_id_tac maps unfold_unique unfold_dtor = |
1230 coinduct_tac] @ |
1228 coinduct_tac] @ |
1231 maps (fn (((((map_comp'_trans, dtor_maps_trans), map_cong), set_naturals), set_hsets), |
1229 maps (fn (((((map_comp'_trans, dtor_maps_trans), map_cong), set_naturals), set_hsets), |
1232 set_hset_hsetss) => |
1230 set_hset_hsetss) => |
1233 [REPEAT_DETERM o eresolve_tac [exE, conjE], hyp_subst_tac, rtac exI, rtac conjI, rtac conjI, |
1231 [REPEAT_DETERM o eresolve_tac [exE, conjE], hyp_subst_tac, rtac exI, rtac conjI, rtac conjI, |
1234 rtac map_comp'_trans, rtac sym, rtac dtor_maps_trans, rtac map_cong, |
1232 rtac map_comp'_trans, rtac sym, rtac dtor_maps_trans, rtac map_cong, |
1235 REPEAT_DETERM_N m o (rtac o_apply_trans_sym THEN' rtac @{thm id_apply}), |
1233 REPEAT_DETERM_N m o (rtac o_apply_trans_sym THEN' rtac id_apply), |
1236 REPEAT_DETERM_N n o rtac fst_convol_fun_cong_sym, |
1234 REPEAT_DETERM_N n o rtac fst_convol_fun_cong_sym, |
1237 rtac map_comp'_trans, rtac sym, rtac dtor_maps_trans, rtac map_cong, |
1235 rtac map_comp'_trans, rtac sym, rtac dtor_maps_trans, rtac map_cong, |
1238 EVERY' (maps (fn set_hset => |
1236 EVERY' (maps (fn set_hset => |
1239 [rtac o_apply_trans_sym, rtac (@{thm id_apply} RS trans), etac CollectE, |
1237 [rtac o_apply_trans_sym, rtac (id_apply RS trans), etac CollectE, |
1240 REPEAT_DETERM o etac conjE, etac bspec, etac set_hset]) set_hsets), |
1238 REPEAT_DETERM o etac conjE, etac bspec, etac set_hset]) set_hsets), |
1241 REPEAT_DETERM_N n o rtac snd_convol_fun_cong_sym, |
1239 REPEAT_DETERM_N n o rtac snd_convol_fun_cong_sym, |
1242 CONJ_WRAP' (fn (set_natural, set_hset_hsets) => |
1240 CONJ_WRAP' (fn (set_natural, set_hset_hsets) => |
1243 EVERY' [REPEAT_DETERM o rtac allI, rtac impI, rtac @{thm image_convolD}, |
1241 EVERY' [REPEAT_DETERM o rtac allI, rtac impI, rtac @{thm image_convolD}, |
1244 etac set_rev_mp, rtac ord_eq_le_trans, rtac set_natural, |
1242 etac set_rev_mp, rtac ord_eq_le_trans, rtac set_natural, |
1471 rtac pick, REPEAT_DETERM_N (m - 1) o etac conjI, atac, |
1469 rtac pick, REPEAT_DETERM_N (m - 1) o etac conjI, atac, |
1472 rtac @{thm set_mp[OF equalityD2[OF thePull_def]]}, rtac CollectI, |
1470 rtac @{thm set_mp[OF equalityD2[OF thePull_def]]}, rtac CollectI, |
1473 rtac @{thm prod_caseI}, etac conjI, etac conjI, atac]) |
1471 rtac @{thm prod_caseI}, etac conjI, etac conjI, atac]) |
1474 (pick_cols ~~ hset_defs)] 1; |
1472 (pick_cols ~~ hset_defs)] 1; |
1475 |
1473 |
1476 fun mk_wit_tac n dtor_ctors set_simp wit coind_wits {context = ctxt, prems = _} = |
1474 fun mk_wit_tac n dtor_ctors dtor_set wit coind_wits {context = ctxt, prems = _} = |
1477 ALLGOALS (TRY o (eresolve_tac coind_wits THEN' rtac refl)) THEN |
1475 ALLGOALS (TRY o (eresolve_tac coind_wits THEN' rtac refl)) THEN |
1478 REPEAT_DETERM (atac 1 ORELSE |
1476 REPEAT_DETERM (atac 1 ORELSE |
1479 EVERY' [dtac set_rev_mp, rtac equalityD1, resolve_tac set_simp, |
1477 EVERY' [dtac set_rev_mp, rtac equalityD1, resolve_tac dtor_set, |
1480 K (unfold_thms_tac ctxt dtor_ctors), |
1478 K (unfold_thms_tac ctxt dtor_ctors), |
1481 REPEAT_DETERM_N n o etac UnE, |
1479 REPEAT_DETERM_N n o etac UnE, |
1482 REPEAT_DETERM o |
1480 REPEAT_DETERM o |
1483 (TRY o REPEAT_DETERM o etac UnE THEN' TRY o etac @{thm UN_E} THEN' |
1481 (TRY o REPEAT_DETERM o etac UnE THEN' TRY o etac @{thm UN_E} THEN' |
1484 (eresolve_tac wit ORELSE' |
1482 (eresolve_tac wit ORELSE' |
1485 (dresolve_tac wit THEN' |
1483 (dresolve_tac wit THEN' |
1486 (etac FalseE ORELSE' |
1484 (etac FalseE ORELSE' |
1487 EVERY' [hyp_subst_tac, dtac set_rev_mp, rtac equalityD1, resolve_tac set_simp, |
1485 EVERY' [hyp_subst_tac, dtac set_rev_mp, rtac equalityD1, resolve_tac dtor_set, |
1488 K (unfold_thms_tac ctxt dtor_ctors), REPEAT_DETERM_N n o etac UnE]))))] 1); |
1486 K (unfold_thms_tac ctxt dtor_ctors), REPEAT_DETERM_N n o etac UnE]))))] 1); |
1489 |
1487 |
1490 fun mk_coind_wit_tac induct unfolds set_nats wits {context = ctxt, prems = _} = |
1488 fun mk_coind_wit_tac induct unfolds set_nats wits {context = ctxt, prems = _} = |
1491 rtac induct 1 THEN ALLGOALS (TRY o rtac impI THEN' TRY o hyp_subst_tac) THEN |
1489 rtac induct 1 THEN ALLGOALS (TRY o rtac impI THEN' TRY o hyp_subst_tac) THEN |
1492 unfold_thms_tac ctxt (unfolds @ set_nats @ @{thms image_id id_apply}) THEN |
1490 unfold_thms_tac ctxt (unfolds @ set_nats @ @{thms image_id id_apply}) THEN |
1522 rtac trans, rtac sym, rtac dtor_map, rtac (dtor_inject RS iffD2), atac]) |
1520 rtac trans, rtac sym, rtac dtor_map, rtac (dtor_inject RS iffD2), atac]) |
1523 @{thms fst_conv snd_conv}]; |
1521 @{thms fst_conv snd_conv}]; |
1524 val only_if_tac = |
1522 val only_if_tac = |
1525 EVERY' [dtac (in_srel RS iffD1), REPEAT_DETERM o eresolve_tac [exE, conjE, CollectE], |
1523 EVERY' [dtac (in_srel RS iffD1), REPEAT_DETERM o eresolve_tac [exE, conjE, CollectE], |
1526 rtac (in_Jsrel RS iffD2), rtac exI, rtac conjI, rtac CollectI, |
1524 rtac (in_Jsrel RS iffD2), rtac exI, rtac conjI, rtac CollectI, |
1527 CONJ_WRAP' (fn (set_simp, passive_set_natural) => |
1525 CONJ_WRAP' (fn (dtor_set, passive_set_natural) => |
1528 EVERY' [rtac ord_eq_le_trans, rtac set_simp, rtac @{thm Un_least}, |
1526 EVERY' [rtac ord_eq_le_trans, rtac dtor_set, rtac @{thm Un_least}, |
1529 rtac ord_eq_le_trans, rtac box_equals, rtac passive_set_natural, |
1527 rtac ord_eq_le_trans, rtac box_equals, rtac passive_set_natural, |
1530 rtac (dtor_ctor RS sym RS arg_cong), rtac trans_fun_cong_image_id_id_apply, atac, |
1528 rtac (dtor_ctor RS sym RS arg_cong), rtac trans_fun_cong_image_id_id_apply, atac, |
1531 CONJ_WRAP_GEN' (rtac (Thm.permute_prems 0 1 @{thm Un_least})) |
1529 CONJ_WRAP_GEN' (rtac (Thm.permute_prems 0 1 @{thm Un_least})) |
1532 (fn (active_set_natural, in_Jsrel) => EVERY' [rtac ord_eq_le_trans, |
1530 (fn (active_set_natural, in_Jsrel) => EVERY' [rtac ord_eq_le_trans, |
1533 rtac @{thm UN_cong[OF _ refl]}, rtac @{thm box_equals[OF _ _ refl]}, |
1531 rtac @{thm UN_cong[OF _ refl]}, rtac @{thm box_equals[OF _ _ refl]}, |