2174 val fld_corec_thms = map3 mk_fld_unf_coiter_like_thm unf_inject_thms unf_fld_thms corec_thms; |
2174 val fld_corec_thms = map3 mk_fld_unf_coiter_like_thm unf_inject_thms unf_fld_thms corec_thms; |
2175 |
2175 |
2176 val timer = time (timer "corec definitions & thms"); |
2176 val timer = time (timer "corec definitions & thms"); |
2177 |
2177 |
2178 val (unf_coinduct_thm, coinduct_params, rel_coinduct_thm, pred_coinduct_thm, |
2178 val (unf_coinduct_thm, coinduct_params, rel_coinduct_thm, pred_coinduct_thm, |
2179 unf_coinduct_upto_thm, rel_coinduct_upto_thm, pred_coinduct_upto_thm) = |
2179 unf_strong_coinduct_thm, rel_strong_coinduct_thm, pred_strong_coinduct_thm) = |
2180 let |
2180 let |
2181 val zs = Jzs1 @ Jzs2; |
2181 val zs = Jzs1 @ Jzs2; |
2182 val frees = phis @ zs; |
2182 val frees = phis @ zs; |
2183 |
2183 |
2184 fun mk_Ids Id = if Id then map Id_const passiveAs else map mk_diag passive_UNIVs; |
2184 fun mk_Ids Id = if Id then map Id_const passiveAs else map mk_diag passive_UNIVs; |
2251 |> Thm.close_derivation; |
2251 |> Thm.close_derivation; |
2252 |
2252 |
2253 val cTs = map (SOME o certifyT lthy o TFree) coinduct_params; |
2253 val cTs = map (SOME o certifyT lthy o TFree) coinduct_params; |
2254 val cts = map3 (SOME o certify lthy ooo mk_phi true) phis Jzs1 Jzs2; |
2254 val cts = map3 (SOME o certify lthy ooo mk_phi true) phis Jzs1 Jzs2; |
2255 |
2255 |
2256 val rel_coinduct_upto = singleton (Proof_Context.export names_lthy lthy) |
2256 val rel_strong_coinduct = singleton (Proof_Context.export names_lthy lthy) |
2257 (Skip_Proof.prove lthy [] [] |
2257 (Skip_Proof.prove lthy [] [] |
2258 (fold_rev Logic.all zs (Logic.list_implies (rel_upto_prems, concl))) |
2258 (fold_rev Logic.all zs (Logic.list_implies (rel_upto_prems, concl))) |
2259 (K (mk_rel_coinduct_upto_tac m cTs cts rel_coinduct rel_monos rel_Ids))) |
2259 (K (mk_rel_strong_coinduct_tac m cTs cts rel_coinduct rel_monos rel_Ids))) |
2260 |> Thm.close_derivation; |
2260 |> Thm.close_derivation; |
2261 |
2261 |
2262 val unf_coinduct_upto = singleton (Proof_Context.export names_lthy lthy) |
2262 val unf_strong_coinduct = singleton (Proof_Context.export names_lthy lthy) |
2263 (Skip_Proof.prove lthy [] [] |
2263 (Skip_Proof.prove lthy [] [] |
2264 (fold_rev Logic.all zs (Logic.list_implies (unf_upto_prems, concl))) |
2264 (fold_rev Logic.all zs (Logic.list_implies (unf_upto_prems, concl))) |
2265 (K (mk_unf_coinduct_upto_tac ks cTs cts unf_coinduct bis_def |
2265 (K (mk_unf_strong_coinduct_tac ks cTs cts unf_coinduct bis_def |
2266 (tcoalg_thm RS bis_diag_thm)))) |
2266 (tcoalg_thm RS bis_diag_thm)))) |
2267 |> Thm.close_derivation; |
2267 |> Thm.close_derivation; |
2268 |
2268 |
2269 val pred_of_rel_thms = |
2269 val pred_of_rel_thms = |
2270 rel_defs @ @{thms Id_def' mem_Collect_eq fst_conv snd_conv split_conv}; |
2270 rel_defs @ @{thms Id_def' mem_Collect_eq fst_conv snd_conv split_conv}; |
2271 |
2271 |
2272 val pred_coinduct = unfold_defs lthy pred_of_rel_thms rel_coinduct; |
2272 val pred_coinduct = unfold_defs lthy pred_of_rel_thms rel_coinduct; |
2273 val pred_coinduct_upto = unfold_defs lthy pred_of_rel_thms rel_coinduct_upto; |
2273 val pred_strong_coinduct = unfold_defs lthy pred_of_rel_thms rel_strong_coinduct; |
2274 in |
2274 in |
2275 (unf_coinduct, rev (Term.add_tfrees unf_coinduct_goal []), rel_coinduct, pred_coinduct, |
2275 (unf_coinduct, rev (Term.add_tfrees unf_coinduct_goal []), rel_coinduct, pred_coinduct, |
2276 unf_coinduct_upto, rel_coinduct_upto, pred_coinduct_upto) |
2276 unf_strong_coinduct, rel_strong_coinduct, pred_strong_coinduct) |
2277 end; |
2277 end; |
2278 |
2278 |
2279 val timer = time (timer "coinduction"); |
2279 val timer = time (timer "coinduction"); |
2280 |
2280 |
2281 (*register new codatatypes as BNFs*) |
2281 (*register new codatatypes as BNFs*) |
2953 |
2953 |
2954 val common_notes = |
2954 val common_notes = |
2955 [(unf_coinductN, [unf_coinduct_thm]), |
2955 [(unf_coinductN, [unf_coinduct_thm]), |
2956 (rel_coinductN, [rel_coinduct_thm]), |
2956 (rel_coinductN, [rel_coinduct_thm]), |
2957 (pred_coinductN, [pred_coinduct_thm]), |
2957 (pred_coinductN, [pred_coinduct_thm]), |
2958 (unf_coinduct_uptoN, [unf_coinduct_upto_thm]), |
2958 (unf_strong_coinductN, [unf_strong_coinduct_thm]), |
2959 (rel_coinduct_uptoN, [rel_coinduct_upto_thm]), |
2959 (rel_strong_coinductN, [rel_strong_coinduct_thm]), |
2960 (pred_coinduct_uptoN, [pred_coinduct_upto_thm])] |
2960 (pred_strong_coinductN, [pred_strong_coinduct_thm])] |
2961 |> map (fn (thmN, thms) => |
2961 |> map (fn (thmN, thms) => |
2962 ((Binding.qualify true (Binding.name_of b) (Binding.name thmN), []), [(thms, [])])); |
2962 ((Binding.qualify true (Binding.name_of b) (Binding.name thmN), []), [(thms, [])])); |
2963 |
2963 |
2964 val notes = |
2964 val notes = |
2965 [(unf_coitersN, coiter_thms), |
2965 [(unf_coitersN, coiter_thms), |