8 |
8 |
9 signature BNF_LFP_TACTICS = |
9 signature BNF_LFP_TACTICS = |
10 sig |
10 sig |
11 val mk_alg_min_alg_tac: int -> thm -> thm list -> thm -> thm -> thm list list -> thm list -> |
11 val mk_alg_min_alg_tac: int -> thm -> thm list -> thm -> thm -> thm list list -> thm list -> |
12 thm list -> tactic |
12 thm list -> tactic |
13 val mk_alg_not_empty_tac: thm -> thm list -> thm list -> tactic |
13 val mk_alg_not_empty_tac: Proof.context -> thm -> thm list -> thm list -> tactic |
14 val mk_alg_select_tac: thm -> {prems: 'a, context: Proof.context} -> tactic |
14 val mk_alg_select_tac: thm -> {prems: 'a, context: Proof.context} -> tactic |
15 val mk_alg_set_tac: thm -> tactic |
15 val mk_alg_set_tac: thm -> tactic |
16 val mk_bd_card_order_tac: thm list -> tactic |
16 val mk_bd_card_order_tac: thm list -> tactic |
17 val mk_bd_limit_tac: int -> thm -> tactic |
17 val mk_bd_limit_tac: int -> thm -> tactic |
18 val mk_card_of_min_alg_tac: thm -> thm -> thm -> thm -> thm -> tactic |
18 val mk_card_of_min_alg_tac: thm -> thm -> thm -> thm -> thm -> tactic |
19 val mk_copy_alg_tac: thm list list -> thm list -> thm -> thm -> thm -> tactic |
19 val mk_copy_alg_tac: thm list list -> thm list -> thm -> thm -> thm -> tactic |
20 val mk_copy_str_tac: thm list list -> thm -> thm list -> tactic |
20 val mk_copy_str_tac: thm list list -> thm -> thm list -> tactic |
21 val mk_ctor_induct_tac: int -> thm list list -> thm -> thm list -> thm -> thm list -> thm list -> |
21 val mk_ctor_induct_tac: Proof.context -> int -> thm list list -> thm -> thm list -> thm -> |
22 thm list -> tactic |
22 thm list -> thm list -> thm list -> tactic |
23 val mk_ctor_induct2_tac: ctyp option list -> cterm option list -> thm -> thm list -> |
23 val mk_ctor_induct2_tac: ctyp option list -> cterm option list -> thm -> thm list -> |
24 {prems: 'a, context: Proof.context} -> tactic |
24 {prems: 'a, context: Proof.context} -> tactic |
25 val mk_ctor_set_tac: thm -> thm -> thm list -> tactic |
25 val mk_ctor_set_tac: thm -> thm -> thm list -> tactic |
26 val mk_ctor_srel_tac: thm list -> int -> thm -> thm -> thm -> thm -> thm list -> thm -> thm -> |
26 val mk_ctor_srel_tac: Proof.context -> thm list -> int -> thm -> thm -> thm -> thm -> thm list -> |
27 thm list -> thm list -> thm list list -> tactic |
27 thm -> thm -> thm list -> thm list -> thm list list -> tactic |
28 val mk_dtor_o_ctor_tac: thm -> thm -> thm -> thm -> thm list -> tactic |
28 val mk_dtor_o_ctor_tac: thm -> thm -> thm -> thm -> thm list -> tactic |
29 val mk_ex_copy_alg_tac: int -> thm -> thm -> tactic |
29 val mk_ex_copy_alg_tac: int -> thm -> thm -> tactic |
30 val mk_in_bd_tac: thm -> thm -> thm -> thm -> tactic |
30 val mk_in_bd_tac: thm -> thm -> thm -> thm -> tactic |
31 val mk_incl_min_alg_tac: (int -> tactic) -> thm list list list -> thm list -> thm -> |
31 val mk_incl_min_alg_tac: (int -> tactic) -> thm list list list -> thm list -> thm -> |
32 {prems: 'a, context: Proof.context} -> tactic |
32 {prems: 'a, context: Proof.context} -> tactic |
36 val mk_init_unique_mor_tac: int -> thm -> thm -> thm list -> thm list -> thm list -> thm list -> |
36 val mk_init_unique_mor_tac: int -> thm -> thm -> thm list -> thm list -> thm list -> thm list -> |
37 thm list -> tactic |
37 thm list -> tactic |
38 val mk_iso_alt_tac: thm list -> thm -> tactic |
38 val mk_iso_alt_tac: thm list -> thm -> tactic |
39 val mk_fold_unique_mor_tac: thm list -> thm list -> thm list -> thm -> thm -> thm -> tactic |
39 val mk_fold_unique_mor_tac: thm list -> thm list -> thm list -> thm -> thm -> thm -> tactic |
40 val mk_least_min_alg_tac: thm -> thm -> tactic |
40 val mk_least_min_alg_tac: thm -> thm -> tactic |
41 val mk_lfp_map_wpull_tac: int -> (int -> tactic) -> thm list -> thm list -> thm list list -> |
41 val mk_lfp_map_wpull_tac: Proof.context -> int -> (int -> tactic) -> thm list -> thm list -> |
42 thm list list list -> thm list -> tactic |
42 thm list list -> thm list list list -> thm list -> tactic |
43 val mk_map_comp_tac: thm list -> thm list -> thm -> int -> tactic |
43 val mk_map_comp_tac: thm list -> thm list -> thm -> int -> tactic |
44 val mk_map_id_tac: thm list -> thm -> tactic |
44 val mk_map_id_tac: thm list -> thm -> tactic |
45 val mk_map_tac: int -> int -> thm -> thm -> thm -> tactic |
45 val mk_map_tac: int -> int -> thm -> thm -> thm -> tactic |
46 val mk_ctor_map_unique_tac: int -> thm -> thm -> thm list -> thm list -> tactic |
46 val mk_ctor_map_unique_tac: int -> thm -> thm -> thm list -> thm list -> tactic |
47 val mk_mcong_tac: (int -> tactic) -> thm list list list -> thm list -> thm list -> |
47 val mk_mcong_tac: (int -> tactic) -> thm list list list -> thm list -> thm list -> |
48 {prems: 'a, context: Proof.context} -> tactic |
48 {prems: 'a, context: Proof.context} -> tactic |
49 val mk_min_algs_card_of_tac: ctyp -> cterm -> int -> thm -> thm list -> thm list -> thm -> thm -> |
49 val mk_min_algs_card_of_tac: ctyp -> cterm -> int -> thm -> thm list -> thm list -> thm -> thm -> |
50 thm -> thm -> thm -> thm -> thm -> thm -> tactic |
50 thm -> thm -> thm -> thm -> thm -> thm -> tactic |
51 val mk_min_algs_least_tac: ctyp -> cterm -> thm -> thm list -> thm list -> tactic |
51 val mk_min_algs_least_tac: ctyp -> cterm -> thm -> thm list -> thm list -> tactic |
52 val mk_min_algs_mono_tac: thm -> tactic |
52 val mk_min_algs_mono_tac: Proof.context -> thm -> tactic |
53 val mk_min_algs_tac: thm -> thm list -> tactic |
53 val mk_min_algs_tac: thm -> thm list -> tactic |
54 val mk_mor_Abs_tac: thm -> thm list -> thm list -> tactic |
54 val mk_mor_Abs_tac: thm -> thm list -> thm list -> tactic |
55 val mk_mor_Rep_tac: thm list -> thm -> thm list -> thm list -> thm list -> |
55 val mk_mor_Rep_tac: thm list -> thm -> thm list -> thm list -> thm list -> |
56 {prems: 'a, context: Proof.context} -> tactic |
56 {prems: 'a, context: Proof.context} -> tactic |
57 val mk_mor_UNIV_tac: int -> thm list -> thm -> tactic |
57 val mk_mor_UNIV_tac: int -> thm list -> thm -> tactic |
71 {prems: 'a, context: Proof.context} -> tactic |
71 {prems: 'a, context: Proof.context} -> tactic |
72 val mk_set_nat_tac: int -> (int -> tactic) -> thm list list -> thm list -> cterm list -> |
72 val mk_set_nat_tac: int -> (int -> tactic) -> thm list list -> thm list -> cterm list -> |
73 thm list -> int -> {prems: 'a, context: Proof.context} -> tactic |
73 thm list -> int -> {prems: 'a, context: Proof.context} -> tactic |
74 val mk_set_map_tac: thm -> tactic |
74 val mk_set_map_tac: thm -> tactic |
75 val mk_set_tac: thm -> tactic |
75 val mk_set_tac: thm -> tactic |
76 val mk_wit_tac: int -> thm list -> thm list -> tactic |
76 val mk_wit_tac: Proof.context -> int -> thm list -> thm list -> tactic |
77 val mk_wpull_tac: thm -> tactic |
77 val mk_wpull_tac: thm -> tactic |
78 end; |
78 end; |
79 |
79 |
80 structure BNF_LFP_Tactics : BNF_LFP_TACTICS = |
80 structure BNF_LFP_Tactics : BNF_LFP_TACTICS = |
81 struct |
81 struct |
93 dtac (alg_def RS iffD1) 1 THEN |
93 dtac (alg_def RS iffD1) 1 THEN |
94 REPEAT_DETERM (etac conjE 1) THEN |
94 REPEAT_DETERM (etac conjE 1) THEN |
95 EVERY' [etac bspec, rtac CollectI] 1 THEN |
95 EVERY' [etac bspec, rtac CollectI] 1 THEN |
96 REPEAT_DETERM (etac conjI 1) THEN atac 1; |
96 REPEAT_DETERM (etac conjI 1) THEN atac 1; |
97 |
97 |
98 fun mk_alg_not_empty_tac alg_set alg_sets wits = |
98 fun mk_alg_not_empty_tac ctxt alg_set alg_sets wits = |
99 (EVERY' [rtac notI, hyp_subst_tac, ftac alg_set] THEN' |
99 (EVERY' [rtac notI, hyp_subst_tac ctxt, ftac alg_set] THEN' |
100 REPEAT_DETERM o FIRST' |
100 REPEAT_DETERM o FIRST' |
101 [rtac subset_UNIV, |
101 [rtac subset_UNIV, |
102 EVERY' [rtac @{thm subset_emptyI}, eresolve_tac wits], |
102 EVERY' [rtac @{thm subset_emptyI}, eresolve_tac wits], |
103 EVERY' [rtac subsetI, rtac FalseE, eresolve_tac wits], |
103 EVERY' [rtac subsetI, rtac FalseE, eresolve_tac wits], |
104 EVERY' [rtac subsetI, dresolve_tac wits, hyp_subst_tac, |
104 EVERY' [rtac subsetI, dresolve_tac wits, hyp_subst_tac ctxt, |
105 FIRST' (map (fn thm => rtac thm THEN' atac) alg_sets)]] THEN' |
105 FIRST' (map (fn thm => rtac thm THEN' atac) alg_sets)]] THEN' |
106 etac @{thm emptyE}) 1; |
106 etac @{thm emptyE}) 1; |
107 |
107 |
108 fun mk_mor_elim_tac mor_def = |
108 fun mk_mor_elim_tac mor_def = |
109 (dtac (subst OF [mor_def]) THEN' |
109 (dtac (subst OF [mor_def]) THEN' |
278 rtac meta_eq_to_obj_eq THEN' rtac (worel RS @{thm wo_rel.adm_wo_def}) THEN' |
278 rtac meta_eq_to_obj_eq THEN' rtac (worel RS @{thm wo_rel.adm_wo_def}) THEN' |
279 REPEAT_DETERM_N 3 o rtac allI THEN' rtac impI THEN' |
279 REPEAT_DETERM_N 3 o rtac allI THEN' rtac impI THEN' |
280 CONJ_WRAP_GEN' (EVERY' [rtac Pair_eqI, rtac conjI]) minH_tac in_congs) 1 |
280 CONJ_WRAP_GEN' (EVERY' [rtac Pair_eqI, rtac conjI]) minH_tac in_congs) 1 |
281 end; |
281 end; |
282 |
282 |
283 fun mk_min_algs_mono_tac min_algs = EVERY' [stac @{thm relChain_def}, rtac allI, rtac allI, |
283 fun mk_min_algs_mono_tac ctxt min_algs = EVERY' [stac @{thm relChain_def}, rtac allI, rtac allI, |
284 rtac impI, rtac @{thm case_split}, rtac @{thm xt1(3)}, rtac min_algs, etac @{thm FieldI2}, |
284 rtac impI, rtac @{thm case_split}, rtac @{thm xt1(3)}, rtac min_algs, etac @{thm FieldI2}, |
285 rtac subsetI, rtac UnI1, rtac @{thm UN_I}, etac @{thm underS_I}, atac, atac, |
285 rtac subsetI, rtac UnI1, rtac @{thm UN_I}, etac @{thm underS_I}, atac, atac, |
286 rtac equalityD1, dtac @{thm notnotD}, hyp_subst_tac, rtac refl] 1; |
286 rtac equalityD1, dtac @{thm notnotD}, hyp_subst_tac ctxt, rtac refl] 1; |
287 |
287 |
288 fun mk_min_algs_card_of_tac cT ct m worel min_algs in_bds bd_Card_order bd_Cnotzero |
288 fun mk_min_algs_card_of_tac cT ct m worel min_algs in_bds bd_Card_order bd_Cnotzero |
289 suc_Card_order suc_Cinfinite suc_Cnotzero suc_Asuc Asuc_Cinfinite Asuc_Cnotzero = |
289 suc_Card_order suc_Cinfinite suc_Cnotzero suc_Asuc Asuc_Cinfinite Asuc_Cnotzero = |
290 let |
290 let |
291 val induct = worel RS |
291 val induct = worel RS |
382 fun mk_least_min_alg_tac min_alg_def least = |
382 fun mk_least_min_alg_tac min_alg_def least = |
383 EVERY' [stac min_alg_def, rtac @{thm UN_least}, dtac least, dtac mp, atac, |
383 EVERY' [stac min_alg_def, rtac @{thm UN_least}, dtac least, dtac mp, atac, |
384 REPEAT_DETERM o etac conjE, atac] 1; |
384 REPEAT_DETERM o etac conjE, atac] 1; |
385 |
385 |
386 fun mk_alg_select_tac Abs_inverse {context = ctxt, prems = _} = |
386 fun mk_alg_select_tac Abs_inverse {context = ctxt, prems = _} = |
387 EVERY' [rtac ballI, REPEAT_DETERM o eresolve_tac [CollectE, exE, conjE], hyp_subst_tac] 1 THEN |
387 EVERY' [rtac ballI, REPEAT_DETERM o eresolve_tac [CollectE, exE, conjE], hyp_subst_tac ctxt] 1 THEN |
388 unfold_thms_tac ctxt (Abs_inverse :: fst_snd_convs) THEN atac 1; |
388 unfold_thms_tac ctxt (Abs_inverse :: fst_snd_convs) THEN atac 1; |
389 |
389 |
390 fun mk_mor_select_tac mor_def mor_cong mor_comp mor_incl_min_alg alg_def alg_select |
390 fun mk_mor_select_tac mor_def mor_cong mor_comp mor_incl_min_alg alg_def alg_select |
391 alg_sets set_map's str_init_defs = |
391 alg_sets set_map's str_init_defs = |
392 let |
392 let |
529 fun mk_rec_unique_mor_tac rec_defs fst_recs fold_unique_mor {context = ctxt, prems = _} = |
529 fun mk_rec_unique_mor_tac rec_defs fst_recs fold_unique_mor {context = ctxt, prems = _} = |
530 unfold_thms_tac ctxt |
530 unfold_thms_tac ctxt |
531 (rec_defs @ map (fn thm => thm RS @{thm convol_expand_snd'}) fst_recs) THEN |
531 (rec_defs @ map (fn thm => thm RS @{thm convol_expand_snd'}) fst_recs) THEN |
532 etac fold_unique_mor 1; |
532 etac fold_unique_mor 1; |
533 |
533 |
534 fun mk_ctor_induct_tac m set_map'ss init_induct morEs mor_Abs Rep_invs Abs_invs Reps = |
534 fun mk_ctor_induct_tac ctxt m set_map'ss init_induct morEs mor_Abs Rep_invs Abs_invs Reps = |
535 let |
535 let |
536 val n = length set_map'ss; |
536 val n = length set_map'ss; |
537 val ks = 1 upto n; |
537 val ks = 1 upto n; |
538 |
538 |
539 fun mk_IH_tac Rep_inv Abs_inv set_map' = |
539 fun mk_IH_tac Rep_inv Abs_inv set_map' = |
540 DETERM o EVERY' [dtac meta_mp, rtac (Rep_inv RS arg_cong RS subst), etac bspec, |
540 DETERM o EVERY' [dtac meta_mp, rtac (Rep_inv RS arg_cong RS subst), etac bspec, |
541 dtac set_rev_mp, rtac equalityD1, rtac set_map', etac imageE, |
541 dtac set_rev_mp, rtac equalityD1, rtac set_map', etac imageE, |
542 hyp_subst_tac, rtac (Abs_inv RS ssubst), etac set_mp, atac, atac]; |
542 hyp_subst_tac ctxt, rtac (Abs_inv RS ssubst), etac set_mp, atac, atac]; |
543 |
543 |
544 fun mk_closed_tac (k, (morE, set_map's)) = |
544 fun mk_closed_tac (k, (morE, set_map's)) = |
545 EVERY' [select_prem_tac n (dtac asm_rl) k, rtac ballI, rtac impI, |
545 EVERY' [select_prem_tac n (dtac asm_rl) k, rtac ballI, rtac impI, |
546 rtac (mor_Abs RS morE RS arg_cong RS ssubst), atac, |
546 rtac (mor_Abs RS morE RS arg_cong RS ssubst), atac, |
547 REPEAT_DETERM o eresolve_tac [CollectE, conjE], dtac @{thm meta_spec}, |
547 REPEAT_DETERM o eresolve_tac [CollectE, conjE], dtac @{thm meta_spec}, |
716 CONJ_WRAP' (K (rtac subset_refl)) ks, |
716 CONJ_WRAP' (K (rtac subset_refl)) ks, |
717 rtac conjI, rtac CollectI, EVERY' (map (use_pass_asm o hd) set_setss), |
717 rtac conjI, rtac CollectI, EVERY' (map (use_pass_asm o hd) set_setss), |
718 CONJ_WRAP' (K (rtac subset_refl)) ks, |
718 CONJ_WRAP' (K (rtac subset_refl)) ks, |
719 rtac subst, rtac ctor_inject, rtac trans, rtac sym, rtac ctor_map, |
719 rtac subst, rtac ctor_inject, rtac trans, rtac sym, rtac ctor_map, |
720 rtac trans, atac, rtac ctor_map, REPEAT_DETERM o eresolve_tac [CollectE, conjE, bexE], |
720 rtac trans, atac, rtac ctor_map, REPEAT_DETERM o eresolve_tac [CollectE, conjE, bexE], |
721 hyp_subst_tac, rtac bexI, rtac conjI, rtac ctor_map, rtac ctor_map, rtac CollectI, |
721 hyp_subst_tac ctxt, rtac bexI, rtac conjI, rtac ctor_map, rtac ctor_map, rtac CollectI, |
722 CONJ_WRAP' mk_subset ctor_sets]; |
722 CONJ_WRAP' mk_subset ctor_sets]; |
723 in |
723 in |
724 (induct_tac THEN' EVERY' (map5 mk_wpull wpulls ctor_maps ctor_setss set_setsss ctor_injects)) 1 |
724 (induct_tac THEN' EVERY' (map5 mk_wpull wpulls ctor_maps ctor_setss set_setsss ctor_injects)) 1 |
725 end; |
725 end; |
726 |
726 |
761 |
761 |
762 fun mk_wpull_tac wpull = |
762 fun mk_wpull_tac wpull = |
763 EVERY' [rtac ssubst, rtac @{thm wpull_def}, rtac allI, rtac allI, |
763 EVERY' [rtac ssubst, rtac @{thm wpull_def}, rtac allI, rtac allI, |
764 rtac wpull, REPEAT_DETERM o atac] 1; |
764 rtac wpull, REPEAT_DETERM o atac] 1; |
765 |
765 |
766 fun mk_wit_tac n ctor_set wit = |
766 fun mk_wit_tac ctxt n ctor_set wit = |
767 REPEAT_DETERM (atac 1 ORELSE |
767 REPEAT_DETERM (atac 1 ORELSE |
768 EVERY' [dtac set_rev_mp, rtac equalityD1, resolve_tac ctor_set, |
768 EVERY' [dtac set_rev_mp, rtac equalityD1, resolve_tac ctor_set, |
769 REPEAT_DETERM o |
769 REPEAT_DETERM o |
770 (TRY o REPEAT_DETERM o etac UnE THEN' TRY o etac @{thm UN_E} THEN' |
770 (TRY o REPEAT_DETERM o etac UnE THEN' TRY o etac @{thm UN_E} THEN' |
771 (eresolve_tac wit ORELSE' |
771 (eresolve_tac wit ORELSE' |
772 (dresolve_tac wit THEN' |
772 (dresolve_tac wit THEN' |
773 (etac FalseE ORELSE' |
773 (etac FalseE ORELSE' |
774 EVERY' [hyp_subst_tac, dtac set_rev_mp, rtac equalityD1, resolve_tac ctor_set, |
774 EVERY' [hyp_subst_tac ctxt, dtac set_rev_mp, rtac equalityD1, resolve_tac ctor_set, |
775 REPEAT_DETERM_N n o etac UnE]))))] 1); |
775 REPEAT_DETERM_N n o etac UnE]))))] 1); |
776 |
776 |
777 fun mk_ctor_srel_tac in_Isrels i in_srel map_comp map_cong0 ctor_map ctor_sets ctor_inject |
777 fun mk_ctor_srel_tac ctxt in_Isrels i in_srel map_comp map_cong0 ctor_map ctor_sets ctor_inject |
778 ctor_dtor set_maps ctor_set_incls ctor_set_set_inclss = |
778 ctor_dtor set_maps ctor_set_incls ctor_set_set_inclss = |
779 let |
779 let |
780 val m = length ctor_set_incls; |
780 val m = length ctor_set_incls; |
781 val n = length ctor_set_set_inclss; |
781 val n = length ctor_set_set_inclss; |
782 |
782 |
819 rtac @{thm UN_cong[OF _ refl]}, rtac active_set_map, rtac @{thm UN_least}, |
819 rtac @{thm UN_cong[OF _ refl]}, rtac active_set_map, rtac @{thm UN_least}, |
820 dtac set_rev_mp, etac @{thm image_mono}, etac imageE, |
820 dtac set_rev_mp, etac @{thm image_mono}, etac imageE, |
821 dtac @{thm ssubst_mem[OF pair_collapse]}, dtac (in_Isrel RS iffD1), |
821 dtac @{thm ssubst_mem[OF pair_collapse]}, dtac (in_Isrel RS iffD1), |
822 dtac @{thm someI_ex}, REPEAT_DETERM o etac conjE, |
822 dtac @{thm someI_ex}, REPEAT_DETERM o etac conjE, |
823 dtac (Thm.permute_prems 0 1 @{thm ssubst_mem}), atac, |
823 dtac (Thm.permute_prems 0 1 @{thm ssubst_mem}), atac, |
824 hyp_subst_tac, REPEAT_DETERM o eresolve_tac [CollectE, conjE], atac]) |
824 hyp_subst_tac ctxt, REPEAT_DETERM o eresolve_tac [CollectE, conjE], atac]) |
825 (rev (active_set_maps ~~ in_Isrels))]) |
825 (rev (active_set_maps ~~ in_Isrels))]) |
826 (ctor_sets ~~ passive_set_maps), |
826 (ctor_sets ~~ passive_set_maps), |
827 rtac conjI, |
827 rtac conjI, |
828 REPEAT_DETERM_N 2 o EVERY' [rtac trans, rtac ctor_map, rtac (ctor_inject RS iffD2), |
828 REPEAT_DETERM_N 2 o EVERY' [rtac trans, rtac ctor_map, rtac (ctor_inject RS iffD2), |
829 rtac trans, rtac map_comp, rtac trans, rtac map_cong0, |
829 rtac trans, rtac map_comp, rtac trans, rtac map_cong0, |