299 val rel = Term.list_comb (mk_rel_of_bnf Ds As Bs bnf, map HOLogic.eq_const killedAs); |
299 val rel = Term.list_comb (mk_rel_of_bnf Ds As Bs bnf, map HOLogic.eq_const killedAs); |
300 |
300 |
301 val bnf_sets = mk_sets_of_bnf (replicate live Ds) (replicate live As) bnf; |
301 val bnf_sets = mk_sets_of_bnf (replicate live Ds) (replicate live As) bnf; |
302 val sets = drop n bnf_sets; |
302 val sets = drop n bnf_sets; |
303 |
303 |
304 (*(|UNIV :: A1 set| +c ... +c |UNIV :: An set|) *c bnf.bd*) |
304 val bd = mk_bd_of_bnf Ds As bnf; |
305 val bnf_bd = mk_bd_of_bnf Ds As bnf; |
|
306 val bd = mk_cprod |
|
307 (Library.foldr1 (uncurry mk_csum) (map (mk_card_of o HOLogic.mk_UNIV) killedAs)) bnf_bd; |
|
308 |
305 |
309 fun map_id0_tac _ = rtac (map_id0_of_bnf bnf) 1; |
306 fun map_id0_tac _ = rtac (map_id0_of_bnf bnf) 1; |
310 fun map_comp0_tac ctxt = |
307 fun map_comp0_tac ctxt = |
311 unfold_thms_tac ctxt ((map_comp0_of_bnf bnf RS sym) :: |
308 unfold_thms_tac ctxt ((map_comp0_of_bnf bnf RS sym) :: |
312 @{thms comp_assoc id_comp comp_id}) THEN rtac refl 1; |
309 @{thms comp_assoc id_comp comp_id}) THEN rtac refl 1; |
313 fun map_cong0_tac ctxt = |
310 fun map_cong0_tac ctxt = |
314 mk_kill_map_cong0_tac ctxt n (live - n) (map_cong0_of_bnf bnf); |
311 mk_kill_map_cong0_tac ctxt n (live - n) (map_cong0_of_bnf bnf); |
315 val set_map0_tacs = map (fn thm => fn _ => rtac thm 1) (drop n (set_map0_of_bnf bnf)); |
312 val set_map0_tacs = map (fn thm => fn _ => rtac thm 1) (drop n (set_map0_of_bnf bnf)); |
316 fun bd_card_order_tac _ = mk_kill_bd_card_order_tac n (bd_card_order_of_bnf bnf); |
313 fun bd_card_order_tac _ = rtac (bd_card_order_of_bnf bnf) 1; |
317 fun bd_cinfinite_tac _ = mk_kill_bd_cinfinite_tac (bd_Cinfinite_of_bnf bnf); |
314 fun bd_cinfinite_tac _ = rtac (bd_cinfinite_of_bnf bnf) 1; |
318 val set_bd_tacs = |
315 val set_bd_tacs = map (fn thm => fn _ => rtac thm 1) (drop n (set_bd_of_bnf bnf)); |
319 map (fn thm => fn _ => mk_kill_set_bd_tac (bd_Card_order_of_bnf bnf) thm) |
|
320 (drop n (set_bd_of_bnf bnf)); |
|
321 |
316 |
322 val in_alt_thm = |
317 val in_alt_thm = |
323 let |
318 let |
324 val inx = mk_in Asets sets T; |
319 val inx = mk_in Asets sets T; |
325 val in_alt = mk_in (map HOLogic.mk_UNIV killedAs @ Asets) bnf_sets T; |
320 val in_alt = mk_in (map HOLogic.mk_UNIV killedAs @ Asets) bnf_sets T; |
609 val T = mk_T_of_bnf Ds As bnf; |
604 val T = mk_T_of_bnf Ds As bnf; |
610 |
605 |
611 (*bd may depend only on dead type variables*) |
606 (*bd may depend only on dead type variables*) |
612 val bd_repT = fst (dest_relT (fastype_of bnf_bd)); |
607 val bd_repT = fst (dest_relT (fastype_of bnf_bd)); |
613 val bdT_bind = qualify (Binding.suffix_name ("_" ^ bdTN) b); |
608 val bdT_bind = qualify (Binding.suffix_name ("_" ^ bdTN) b); |
614 val params = fold Term.add_tfreesT Ds []; |
609 val params = Term.add_tfreesT bd_repT []; |
615 val deads = map TFree params; |
610 val deads = map TFree params; |
|
611 val all_deads = map TFree (fold Term.add_tfreesT Ds []); |
616 |
612 |
617 val ((bdT_name, (bdT_glob_info, bdT_loc_info)), lthy) = |
613 val ((bdT_name, (bdT_glob_info, bdT_loc_info)), lthy) = |
618 typedef (bdT_bind, params, NoSyn) |
614 typedef (bdT_bind, params, NoSyn) |
619 (HOLogic.mk_UNIV bd_repT) NONE (EVERY' [rtac exI, rtac UNIV_I] 1) lthy; |
615 (HOLogic.mk_UNIV bd_repT) NONE (EVERY' [rtac exI, rtac UNIV_I] 1) lthy; |
620 |
616 |
647 |
643 |
648 fun wit_tac ctxt = |
644 fun wit_tac ctxt = |
649 mk_simple_wit_tac (map (unfold_all ctxt) (wit_thms_of_bnf bnf)); |
645 mk_simple_wit_tac (map (unfold_all ctxt) (wit_thms_of_bnf bnf)); |
650 |
646 |
651 val (bnf', lthy') = |
647 val (bnf', lthy') = |
652 bnf_def Hardly_Inline (user_policy Dont_Note) qualify tacs wit_tac (SOME deads) |
648 bnf_def Hardly_Inline (user_policy Dont_Note) qualify tacs wit_tac (SOME all_deads) |
653 Binding.empty Binding.empty [] |
649 Binding.empty Binding.empty [] |
654 ((((((b, T), bnf_map), bnf_sets), bnf_bd'), bnf_wits), SOME bnf_rel) lthy; |
650 ((((((b, T), bnf_map), bnf_sets), bnf_bd'), bnf_wits), SOME bnf_rel) lthy; |
655 in |
651 in |
656 ((bnf', deads), lthy') |
652 ((bnf', all_deads), lthy') |
657 end; |
653 end; |
658 |
654 |
659 fun key_of_types Ts = Type ("", Ts); |
655 fun key_of_types Ts = Type ("", Ts); |
660 val key_of_typess = key_of_types o map key_of_types; |
656 val key_of_typess = key_of_types o map key_of_types; |
661 fun key_of_comp oDs Dss Ass T = key_of_types (map key_of_typess [[oDs], Dss, Ass, [[T]]]); |
657 fun key_of_comp oDs Dss Ass T = key_of_types (map key_of_typess [[oDs], Dss, Ass, [[T]]]); |