40 co_rec_disc_iffs: thm list, |
40 co_rec_disc_iffs: thm list, |
41 co_rec_selss: thm list list, |
41 co_rec_selss: thm list list, |
42 co_rec_codes: thm list, |
42 co_rec_codes: thm list, |
43 co_rec_transfers: thm list, |
43 co_rec_transfers: thm list, |
44 common_rel_co_inducts: thm list, |
44 common_rel_co_inducts: thm list, |
45 rel_co_inducts: thm list} |
45 rel_co_inducts: thm list, |
|
46 common_set_inducts: thm list} |
46 |
47 |
47 type fp_sugar = |
48 type fp_sugar = |
48 {T: typ, |
49 {T: typ, |
49 BT: typ, |
50 BT: typ, |
50 X: typ, |
51 X: typ, |
209 co_rec_disc_iffs: thm list, |
210 co_rec_disc_iffs: thm list, |
210 co_rec_selss: thm list list, |
211 co_rec_selss: thm list list, |
211 co_rec_codes: thm list, |
212 co_rec_codes: thm list, |
212 co_rec_transfers: thm list, |
213 co_rec_transfers: thm list, |
213 common_rel_co_inducts: thm list, |
214 common_rel_co_inducts: thm list, |
214 rel_co_inducts: thm list}; |
215 rel_co_inducts: thm list, |
|
216 common_set_inducts: thm list}; |
215 |
217 |
216 type fp_sugar = |
218 type fp_sugar = |
217 {T: typ, |
219 {T: typ, |
218 BT: typ, |
220 BT: typ, |
219 X: typ, |
221 X: typ, |
243 set_intros = map (Morphism.thm phi) set_intros, |
245 set_intros = map (Morphism.thm phi) set_intros, |
244 set_cases = map (Morphism.thm phi) set_cases}; |
246 set_cases = map (Morphism.thm phi) set_cases}; |
245 |
247 |
246 fun morph_fp_co_induct_sugar phi ({co_rec, common_co_inducts, co_inducts, co_rec_def, co_rec_thms, |
248 fun morph_fp_co_induct_sugar phi ({co_rec, common_co_inducts, co_inducts, co_rec_def, co_rec_thms, |
247 co_rec_discs, co_rec_disc_iffs, co_rec_selss, co_rec_codes, co_rec_transfers, |
249 co_rec_discs, co_rec_disc_iffs, co_rec_selss, co_rec_codes, co_rec_transfers, |
248 common_rel_co_inducts, rel_co_inducts} : fp_co_induct_sugar) = |
250 common_rel_co_inducts, rel_co_inducts, common_set_inducts} : fp_co_induct_sugar) = |
249 {co_rec = Morphism.term phi co_rec, |
251 {co_rec = Morphism.term phi co_rec, |
250 common_co_inducts = map (Morphism.thm phi) common_co_inducts, |
252 common_co_inducts = map (Morphism.thm phi) common_co_inducts, |
251 co_inducts = map (Morphism.thm phi) co_inducts, |
253 co_inducts = map (Morphism.thm phi) co_inducts, |
252 co_rec_def = Morphism.thm phi co_rec_def, |
254 co_rec_def = Morphism.thm phi co_rec_def, |
253 co_rec_thms = map (Morphism.thm phi) co_rec_thms, |
255 co_rec_thms = map (Morphism.thm phi) co_rec_thms, |
255 co_rec_disc_iffs = map (Morphism.thm phi) co_rec_disc_iffs, |
257 co_rec_disc_iffs = map (Morphism.thm phi) co_rec_disc_iffs, |
256 co_rec_selss = map (map (Morphism.thm phi)) co_rec_selss, |
258 co_rec_selss = map (map (Morphism.thm phi)) co_rec_selss, |
257 co_rec_codes = map (Morphism.thm phi) co_rec_codes, |
259 co_rec_codes = map (Morphism.thm phi) co_rec_codes, |
258 co_rec_transfers = map (Morphism.thm phi) co_rec_transfers, |
260 co_rec_transfers = map (Morphism.thm phi) co_rec_transfers, |
259 common_rel_co_inducts = map (Morphism.thm phi) common_rel_co_inducts, |
261 common_rel_co_inducts = map (Morphism.thm phi) common_rel_co_inducts, |
260 rel_co_inducts = map (Morphism.thm phi) rel_co_inducts}; |
262 rel_co_inducts = map (Morphism.thm phi) rel_co_inducts, |
|
263 common_set_inducts = map (Morphism.thm phi) common_set_inducts}; |
261 |
264 |
262 fun morph_fp_ctr_sugar phi ({ctrXs_Tss, ctr_defs, ctr_sugar, ctr_transfers, case_transfers, |
265 fun morph_fp_ctr_sugar phi ({ctrXs_Tss, ctr_defs, ctr_sugar, ctr_transfers, case_transfers, |
263 disc_transfers} : fp_ctr_sugar) = |
266 disc_transfers} : fp_ctr_sugar) = |
264 {ctrXs_Tss = map (map (Morphism.typ phi)) ctrXs_Tss, |
267 {ctrXs_Tss = map (map (Morphism.typ phi)) ctrXs_Tss, |
265 ctr_defs = map (Morphism.thm phi) ctr_defs, |
268 ctr_defs = map (Morphism.thm phi) ctr_defs, |
335 fun interpret_bnfs_register_fp_sugars plugins Ts BTs Xs fp pre_bnfs absT_infos fp_nesting_bnfs |
338 fun interpret_bnfs_register_fp_sugars plugins Ts BTs Xs fp pre_bnfs absT_infos fp_nesting_bnfs |
336 live_nesting_bnfs fp_res ctrXs_Tsss ctr_defss ctr_sugars co_recs co_rec_defs map_thmss |
339 live_nesting_bnfs fp_res ctrXs_Tsss ctr_defss ctr_sugars co_recs co_rec_defs map_thmss |
337 common_co_inducts co_inductss co_rec_thmss co_rec_discss co_rec_selsss rel_injectss |
340 common_co_inducts co_inductss co_rec_thmss co_rec_discss co_rec_selsss rel_injectss |
338 rel_distinctss map_disc_iffss map_selss rel_selss rel_intross rel_casess set_thmss set_selss |
341 rel_distinctss map_disc_iffss map_selss rel_selss rel_intross rel_casess set_thmss set_selss |
339 set_intross set_casess ctr_transferss case_transferss disc_transferss co_rec_disc_iffss |
342 set_intross set_casess ctr_transferss case_transferss disc_transferss co_rec_disc_iffss |
340 co_rec_codess co_rec_transferss common_rel_co_inducts rel_co_inductss noted = |
343 co_rec_codess co_rec_transferss common_rel_co_inducts rel_co_inductss common_set_inducts noted = |
341 let |
344 let |
342 val fp_sugars = |
345 val fp_sugars = |
343 map_index (fn (kk, T) => |
346 map_index (fn (kk, T) => |
344 {T = T, BT = nth BTs kk, X = nth Xs kk, fp = fp, fp_res = fp_res, fp_res_index = kk, |
347 {T = T, BT = nth BTs kk, X = nth Xs kk, fp = fp, fp_res = fp_res, fp_res_index = kk, |
345 pre_bnf = nth pre_bnfs kk, absT_info = nth absT_infos kk, |
348 pre_bnf = nth pre_bnfs kk, absT_info = nth absT_infos kk, |
374 co_rec_disc_iffs = nth co_rec_disc_iffss kk, |
377 co_rec_disc_iffs = nth co_rec_disc_iffss kk, |
375 co_rec_selss = nth co_rec_selsss kk, |
378 co_rec_selss = nth co_rec_selsss kk, |
376 co_rec_codes = nth co_rec_codess kk, |
379 co_rec_codes = nth co_rec_codess kk, |
377 co_rec_transfers = nth co_rec_transferss kk, |
380 co_rec_transfers = nth co_rec_transferss kk, |
378 common_rel_co_inducts = common_rel_co_inducts, |
381 common_rel_co_inducts = common_rel_co_inducts, |
379 rel_co_inducts = nth rel_co_inductss kk}} |
382 rel_co_inducts = nth rel_co_inductss kk, |
|
383 common_set_inducts = common_set_inducts}} |
380 |> morph_fp_sugar (substitute_noted_thm noted)) Ts; |
384 |> morph_fp_sugar (substitute_noted_thm noted)) Ts; |
381 in |
385 in |
382 register_fp_sugars_raw fp_sugars |
386 register_fp_sugars_raw fp_sugars |
383 #> fold (interpret_bnf plugins) (#bnfs fp_res) |
387 #> fold (interpret_bnf plugins) (#bnfs fp_res) |
384 #> interpret_fp_sugars plugins fp_sugars |
388 #> interpret_fp_sugars plugins fp_sugars |
2222 fp_nesting_bnfs live_nesting_bnfs fp_res ctrXs_Tsss ctr_defss ctr_sugars recs rec_defs |
2226 fp_nesting_bnfs live_nesting_bnfs fp_res ctrXs_Tsss ctr_defss ctr_sugars recs rec_defs |
2223 map_thmss [induct_thm] (map single induct_thms) rec_thmss (replicate nn []) |
2227 map_thmss [induct_thm] (map single induct_thms) rec_thmss (replicate nn []) |
2224 (replicate nn []) rel_injectss rel_distinctss map_disc_iffss map_selss rel_selss |
2228 (replicate nn []) rel_injectss rel_distinctss map_disc_iffss map_selss rel_selss |
2225 rel_intross rel_casess set_thmss set_selss set_intross set_casess ctr_transferss |
2229 rel_intross rel_casess set_thmss set_selss set_intross set_casess ctr_transferss |
2226 case_transferss disc_transferss (replicate nn []) (replicate nn []) rec_transfer_thmss |
2230 case_transferss disc_transferss (replicate nn []) (replicate nn []) rec_transfer_thmss |
2227 common_rel_induct_thms rel_induct_thmss |
2231 common_rel_induct_thms rel_induct_thmss [] |
2228 end; |
2232 end; |
2229 |
2233 |
2230 fun derive_corec_transfer_thms lthy corecs corec_defs = |
2234 fun derive_corec_transfer_thms lthy corecs corec_defs = |
2231 let |
2235 let |
2232 val (Rs, Ss, goals, names_lthy) = mk_co_rec_transfer_goals lthy corecs; |
2236 val (Rs, Ss, goals, names_lthy) = mk_co_rec_transfer_goals lthy corecs; |
2341 map_thmss [coinduct_thm, coinduct_strong_thm] |
2345 map_thmss [coinduct_thm, coinduct_strong_thm] |
2342 (transpose [coinduct_thms, coinduct_strong_thms]) corec_thmss corec_disc_thmss |
2346 (transpose [coinduct_thms, coinduct_strong_thms]) corec_thmss corec_disc_thmss |
2343 corec_sel_thmsss rel_injectss rel_distinctss map_disc_iffss map_selss rel_selss |
2347 corec_sel_thmsss rel_injectss rel_distinctss map_disc_iffss map_selss rel_selss |
2344 rel_intross rel_casess set_thmss set_selss set_intross set_casess ctr_transferss |
2348 rel_intross rel_casess set_thmss set_selss set_intross set_casess ctr_transferss |
2345 case_transferss disc_transferss corec_disc_iff_thmss (map single corec_code_thms) |
2349 case_transferss disc_transferss corec_disc_iff_thmss (map single corec_code_thms) |
2346 corec_transfer_thmss common_rel_coinduct_thms rel_coinduct_thmss |
2350 corec_transfer_thmss common_rel_coinduct_thms rel_coinduct_thmss set_induct_thms |
2347 end; |
2351 end; |
2348 |
2352 |
2349 val lthy'' = lthy' |
2353 val lthy'' = lthy' |
2350 |> live > 0 ? fold2 (fn Type (s, _) => fn bnf => register_bnf_raw s bnf) fpTs fp_bnfs |
2354 |> live > 0 ? fold2 (fn Type (s, _) => fn bnf => register_bnf_raw s bnf) fpTs fp_bnfs |
2351 |> fold_map define_ctrs_dtrs_for_type (fp_bnfs ~~ fp_bs ~~ fpTs ~~ ctors ~~ dtors ~~ |
2355 |> fold_map define_ctrs_dtrs_for_type (fp_bnfs ~~ fp_bs ~~ fpTs ~~ ctors ~~ dtors ~~ |