equal
deleted
inserted
replaced
22 (BNF_Def.bnf * (typ list * typ list)) * (unfold_set * Proof.context) |
22 (BNF_Def.bnf * (typ list * typ list)) * (unfold_set * Proof.context) |
23 val default_comp_sort: (string * sort) list list -> (string * sort) list |
23 val default_comp_sort: (string * sort) list list -> (string * sort) list |
24 val normalize_bnfs: (int -> binding -> binding) -> ''a list list -> ''a list -> |
24 val normalize_bnfs: (int -> binding -> binding) -> ''a list list -> ''a list -> |
25 (''a list list -> ''a list) -> BNF_Def.bnf list -> unfold_set -> Proof.context -> |
25 (''a list list -> ''a list) -> BNF_Def.bnf list -> unfold_set -> Proof.context -> |
26 (int list list * ''a list) * (BNF_Def.bnf list * (unfold_set * Proof.context)) |
26 (int list list * ''a list) * (BNF_Def.bnf list * (unfold_set * Proof.context)) |
27 val seal_bnf: unfold_set -> binding -> typ list -> BNF_Def.bnf -> Proof.context -> |
27 val seal_bnf: (binding -> binding) -> unfold_set -> binding -> typ list -> BNF_Def.bnf -> |
28 (BNF_Def.bnf * typ list) * local_theory |
28 Proof.context -> (BNF_Def.bnf * typ list) * local_theory |
29 end; |
29 end; |
30 |
30 |
31 structure BNF_Comp : BNF_COMP = |
31 structure BNF_Comp : BNF_COMP = |
32 struct |
32 struct |
33 |
33 |
432 fun wit_tac _ = mk_simple_wit_tac (wit_thms_of_bnf bnf); |
432 fun wit_tac _ = mk_simple_wit_tac (wit_thms_of_bnf bnf); |
433 |
433 |
434 val (bnf', lthy') = |
434 val (bnf', lthy') = |
435 bnf_def Smart_Inline (K Dont_Note) qualify tacs wit_tac (SOME Ds) Binding.empty Binding.empty |
435 bnf_def Smart_Inline (K Dont_Note) qualify tacs wit_tac (SOME Ds) Binding.empty Binding.empty |
436 [] (((((b, mapx), sets), Term.absdummy T bd), wits), SOME rel) lthy; |
436 [] (((((b, mapx), sets), Term.absdummy T bd), wits), SOME rel) lthy; |
437 |
|
438 in |
437 in |
439 (bnf', (add_bnf_to_unfolds bnf' unfold_set, lthy')) |
438 (bnf', (add_bnf_to_unfolds bnf' unfold_set, lthy')) |
440 end; |
439 end; |
441 |
440 |
442 (* Changing the order of live variables *) |
441 (* Changing the order of live variables *) |
569 (clean_compose_bnf const_policy (qualify 0) b outer inners' (unfold_set', lthy')) |
568 (clean_compose_bnf const_policy (qualify 0) b outer inners' (unfold_set', lthy')) |
570 end; |
569 end; |
571 |
570 |
572 (* Hide the type of the bound (optimization) and unfold the definitions (nicer to the user) *) |
571 (* Hide the type of the bound (optimization) and unfold the definitions (nicer to the user) *) |
573 |
572 |
574 fun seal_bnf (unfold_set : unfold_set) b Ds bnf lthy = |
573 fun seal_bnf qualify (unfold_set : unfold_set) b Ds bnf lthy = |
575 let |
574 let |
576 val live = live_of_bnf bnf; |
575 val live = live_of_bnf bnf; |
577 val nwits = nwits_of_bnf bnf; |
576 val nwits = nwits_of_bnf bnf; |
578 |
577 |
579 val (As, lthy1) = apfst (map TFree) |
578 val (As, lthy1) = apfst (map TFree) |
602 val bnf_rel = expand_rels (mk_rel_of_bnf Ds As Bs bnf); |
601 val bnf_rel = expand_rels (mk_rel_of_bnf Ds As Bs bnf); |
603 val T = mk_T_of_bnf Ds As bnf; |
602 val T = mk_T_of_bnf Ds As bnf; |
604 |
603 |
605 (*bd should only depend on dead type variables!*) |
604 (*bd should only depend on dead type variables!*) |
606 val bd_repT = fst (dest_relT (fastype_of bnf_bd)); |
605 val bd_repT = fst (dest_relT (fastype_of bnf_bd)); |
607 val bdT_bind = Binding.suffix_name ("_" ^ bdTN) b; |
606 val bdT_bind = qualify (Binding.suffix_name ("_" ^ bdTN) b); |
608 val params = fold Term.add_tfreesT Ds []; |
607 val params = fold Term.add_tfreesT Ds []; |
609 val deads = map TFree params; |
608 val deads = map TFree params; |
610 |
609 |
611 val ((bdT_name, (bdT_glob_info, bdT_loc_info)), lthy) = |
610 val ((bdT_name, (bdT_glob_info, bdT_loc_info)), lthy) = |
612 typedef (bdT_bind, params, NoSyn) |
611 typedef (bdT_bind, params, NoSyn) |
639 |
638 |
640 val bnf_wits = map snd (mk_wits_of_bnf (replicate nwits Ds) (replicate nwits As) bnf); |
639 val bnf_wits = map snd (mk_wits_of_bnf (replicate nwits Ds) (replicate nwits As) bnf); |
641 |
640 |
642 fun wit_tac _ = mk_simple_wit_tac (map unfold_all (wit_thms_of_bnf bnf)); |
641 fun wit_tac _ = mk_simple_wit_tac (map unfold_all (wit_thms_of_bnf bnf)); |
643 |
642 |
644 val (bnf', lthy') = bnf_def Hardly_Inline (user_policy Dont_Note) I tacs wit_tac (SOME deads) |
643 val (bnf', lthy') = |
645 Binding.empty Binding.empty [] |
644 bnf_def Hardly_Inline (user_policy Dont_Note) qualify tacs wit_tac (SOME deads) |
646 (((((b, bnf_map), bnf_sets), Term.absdummy T bnf_bd'), bnf_wits), SOME bnf_rel) lthy; |
645 Binding.empty Binding.empty [] |
|
646 (((((b, bnf_map), bnf_sets), Term.absdummy T bnf_bd'), bnf_wits), SOME bnf_rel) lthy; |
647 in |
647 in |
648 ((bnf', deads), lthy') |
648 ((bnf', deads), lthy') |
649 end; |
649 end; |
650 |
650 |
651 exception BAD_DEAD of typ * typ; |
651 exception BAD_DEAD of typ * typ; |