equal
deleted
inserted
replaced
7 |
7 |
8 signature BNF_WRAP = |
8 signature BNF_WRAP = |
9 sig |
9 sig |
10 val mk_half_pairss: 'a list -> ('a * 'a) list list |
10 val mk_half_pairss: 'a list -> ('a * 'a) list list |
11 val mk_ctr: typ list -> term -> term |
11 val mk_ctr: typ list -> term -> term |
|
12 val base_name_of_ctr: term -> string |
12 val wrap_datatype: ({prems: thm list, context: Proof.context} -> tactic) list list -> |
13 val wrap_datatype: ({prems: thm list, context: Proof.context} -> tactic) list list -> |
13 ((bool * term list) * term) * |
14 ((bool * term list) * term) * |
14 (binding list * (binding list list * (binding * term) list list)) -> local_theory -> |
15 (binding list * (binding list list * (binding * term) list list)) -> local_theory -> |
15 (term list list * thm list * thm list list) * local_theory |
16 (term list list * thm list * thm list list) * local_theory |
16 val parse_wrap_options: bool parser |
17 val parse_wrap_options: bool parser |
67 fun mk_ctr Ts ctr = |
68 fun mk_ctr Ts ctr = |
68 let val Type (_, Ts0) = body_type (fastype_of ctr) in |
69 let val Type (_, Ts0) = body_type (fastype_of ctr) in |
69 Term.subst_atomic_types (Ts0 ~~ Ts) ctr |
70 Term.subst_atomic_types (Ts0 ~~ Ts) ctr |
70 end; |
71 end; |
71 |
72 |
72 fun eta_expand_case_arg xs f_xs = fold_rev Term.lambda xs f_xs; |
|
73 |
|
74 fun base_name_of_ctr c = |
73 fun base_name_of_ctr c = |
75 Long_Name.base_name (case head_of c of |
74 Long_Name.base_name (case head_of c of |
76 Const (s, _) => s |
75 Const (s, _) => s |
77 | Free (s, _) => s |
76 | Free (s, _) => s |
78 | _ => error "Cannot extract name of constructor"); |
77 | _ => error "Cannot extract name of constructor"); |
|
78 |
|
79 fun eta_expand_arg xs f_xs = fold_rev Term.lambda xs f_xs; |
79 |
80 |
80 fun prepare_wrap_datatype prep_term (((no_dests, raw_ctrs), raw_case), |
81 fun prepare_wrap_datatype prep_term (((no_dests, raw_ctrs), raw_case), |
81 (raw_disc_bindings, (raw_sel_bindingss, raw_sel_defaultss))) no_defs_lthy = |
82 (raw_disc_bindings, (raw_sel_bindingss, raw_sel_defaultss))) no_defs_lthy = |
82 let |
83 let |
83 (* TODO: sanity checks on arguments *) |
84 (* TODO: sanity checks on arguments *) |
174 val yctrs = map2 (curry Term.list_comb) ctrs yss; |
175 val yctrs = map2 (curry Term.list_comb) ctrs yss; |
175 |
176 |
176 val xfs = map2 (curry Term.list_comb) fs xss; |
177 val xfs = map2 (curry Term.list_comb) fs xss; |
177 val xgs = map2 (curry Term.list_comb) gs xss; |
178 val xgs = map2 (curry Term.list_comb) gs xss; |
178 |
179 |
179 val eta_fs = map2 eta_expand_case_arg xss xfs; |
180 val eta_fs = map2 eta_expand_arg xss xfs; |
180 val eta_gs = map2 eta_expand_case_arg xss xgs; |
181 val eta_gs = map2 eta_expand_arg xss xgs; |
181 |
182 |
182 val fcase = Term.list_comb (casex, eta_fs); |
183 val fcase = Term.list_comb (casex, eta_fs); |
183 val gcase = Term.list_comb (casex, eta_gs); |
184 val gcase = Term.list_comb (casex, eta_gs); |
184 |
185 |
185 val exist_xs_v_eq_ctrs = |
186 val exist_xs_v_eq_ctrs = |
555 |> singleton (Proof_Context.export names_lthy lthy) |
556 |> singleton (Proof_Context.export names_lthy lthy) |
556 in |
557 in |
557 (split_thm, split_asm_thm) |
558 (split_thm, split_asm_thm) |
558 end; |
559 end; |
559 |
560 |
|
561 val exhaust_case_names_attr = Attrib.internal (K (Rule_Cases.case_names exhaust_cases)); |
560 val cases_type_attr = Attrib.internal (K (Induct.cases_type dataT_name)); |
562 val cases_type_attr = Attrib.internal (K (Induct.cases_type dataT_name)); |
561 val exhaust_case_names_attr = Attrib.internal (K (Rule_Cases.case_names exhaust_cases)); |
|
562 |
563 |
563 val notes = |
564 val notes = |
564 [(case_congN, [case_cong_thm], []), |
565 [(case_congN, [case_cong_thm], []), |
565 (case_eqN, case_eq_thms, []), |
566 (case_eqN, case_eq_thms, []), |
566 (casesN, case_thms, simp_attrs), |
567 (casesN, case_thms, simp_attrs), |