95 fun case_of_case_rewrite case_rewrite = |
94 fun case_of_case_rewrite case_rewrite = |
96 head_of (fst (HOLogic.dest_eq (HOLogic.dest_Trueprop (prop_of case_rewrite)))); |
95 head_of (fst (HOLogic.dest_eq (HOLogic.dest_Trueprop (prop_of case_rewrite)))); |
97 |
96 |
98 fun ctr_sugar_of_info ({exhaust, nchotomy, inject, distinct, case_rewrites, case_cong, |
97 fun ctr_sugar_of_info ({exhaust, nchotomy, inject, distinct, case_rewrites, case_cong, |
99 case_cong_weak, split, split_asm, ...} : Old_Datatype_Aux.info) = |
98 case_cong_weak, split, split_asm, ...} : Old_Datatype_Aux.info) = |
100 {ctrs = ctrs_of_exhaust exhaust, |
99 let val ctrs as ctr1 :: _ = ctrs_of_exhaust exhaust in |
101 casex = case_of_case_rewrite (hd case_rewrites), |
100 {T = body_type (fastype_of ctr1), |
102 discs = [], |
101 ctrs = ctrs, |
103 selss = [], |
102 casex = case_of_case_rewrite (hd case_rewrites), |
104 exhaust = exhaust, |
103 discs = [], |
105 nchotomy = nchotomy, |
104 selss = [], |
106 injects = inject, |
105 exhaust = exhaust, |
107 distincts = distinct, |
106 nchotomy = nchotomy, |
108 case_thms = case_rewrites, |
107 injects = inject, |
109 case_cong = case_cong, |
108 distincts = distinct, |
110 case_cong_weak = case_cong_weak, |
109 case_thms = case_rewrites, |
111 split = split, |
110 case_cong = case_cong, |
112 split_asm = split_asm, |
111 case_cong_weak = case_cong_weak, |
113 disc_defs = [], |
112 split = split, |
114 disc_thmss = [], |
113 split_asm = split_asm, |
115 discIs = [], |
114 disc_defs = [], |
116 sel_defs = [], |
115 disc_thmss = [], |
117 sel_thmss = [], |
116 discIs = [], |
118 distinct_discsss = [], |
117 sel_defs = [], |
119 exhaust_discs = [], |
118 sel_thmss = [], |
120 exhaust_sels = [], |
119 distinct_discsss = [], |
121 collapses = [], |
120 exhaust_discs = [], |
122 expands = [], |
121 exhaust_sels = [], |
123 split_sels = [], |
122 collapses = [], |
124 split_sel_asms = [], |
123 expands = [], |
125 case_eq_ifs = []}; |
124 split_sels = [], |
|
125 split_sel_asms = [], |
|
126 case_eq_ifs = []} |
|
127 end; |
126 |
128 |
127 fun register dt_infos = |
129 fun register dt_infos = |
128 Data.map (fn {types, constrs, cases} => |
130 Data.map (fn {types, constrs, cases} => |
129 {types = types |> fold Symtab.update dt_infos, |
131 {types = types |> fold Symtab.update dt_infos, |
130 constrs = constrs |> fold (fn (constr, dtname_info) => |
132 constrs = constrs |> fold (fn (constr, dtname_info) => |
131 Symtab.map_default (constr, []) (cons dtname_info)) |
133 Symtab.map_default (constr, []) (cons dtname_info)) |
132 (maps (fn (dtname, info as {descr, index, ...}) => |
134 (maps (fn (dtname, info as {descr, index, ...}) => |
133 map (rpair (dtname, info) o fst) (#3 (the (AList.lookup op = descr index)))) dt_infos), |
135 map (rpair (dtname, info) o fst) (#3 (the (AList.lookup op = descr index)))) dt_infos), |
134 cases = cases |> fold Symtab.update |
136 cases = cases |> fold Symtab.update |
135 (map (fn (_, info as {case_name, ...}) => (case_name, info)) dt_infos)}) #> |
137 (map (fn (_, info as {case_name, ...}) => (case_name, info)) dt_infos)}) #> |
136 fold (fn (key, info) => |
138 fold (Ctr_Sugar.default_register_ctr_sugar_global o ctr_sugar_of_info o snd) dt_infos; |
137 Ctr_Sugar.default_register_ctr_sugar_global key (ctr_sugar_of_info info)) dt_infos; |
|
138 |
139 |
139 |
140 |
140 (* complex queries *) |
141 (* complex queries *) |
141 |
142 |
142 fun the_spec thy dtco = |
143 fun the_spec thy dtco = |