src/HOL/Tools/BNF/bnf_gfp.ML
changeset 60728 26ffdb966759
parent 59936 b8ffc3dc9e24
child 60784 4f590c08fd5d
equal deleted inserted replaced
60727:53697011b03a 60728:26ffdb966759
   255             (mk_Ball (set $ x) (Term.absfree z' (HOLogic.mk_eq (f $ z, z))));
   255             (mk_Ball (set $ x) (Term.absfree z' (HOLogic.mk_eq (f $ z, z))));
   256         val prems = @{map 4} mk_prem (drop m sets) self_fs zs zs';
   256         val prems = @{map 4} mk_prem (drop m sets) self_fs zs zs';
   257         val goal = mk_Trueprop_eq (Term.list_comb (mapAsAs, passive_ids @ self_fs) $ x, x);
   257         val goal = mk_Trueprop_eq (Term.list_comb (mapAsAs, passive_ids @ self_fs) $ x, x);
   258       in
   258       in
   259         Goal.prove_sorry lthy [] [] (Logic.list_implies (prems, goal))
   259         Goal.prove_sorry lthy [] [] (Logic.list_implies (prems, goal))
   260           (K (mk_map_cong0L_tac m map_cong0 map_id))
   260           (fn {context = ctxt, prems = _} => mk_map_cong0L_tac ctxt m map_cong0 map_id)
   261         |> Thm.close_derivation
   261         |> Thm.close_derivation
   262         |> singleton (Proof_Context.export names_lthy lthy)
   262         |> singleton (Proof_Context.export names_lthy lthy)
   263       end;
   263       end;
   264 
   264 
   265     val map_cong0L_thms = @{map 5} mk_map_cong0L xFs mapsAsAs setssAs map_cong0s map_ids;
   265     val map_cong0L_thms = @{map 5} mk_map_cong0L xFs mapsAsAs setssAs map_cong0s map_ids;
   274           @{map 3} (fn x => fn y => fn mapx => mk_Trueprop_eq (mapx $ x, mapx $ y))
   274           @{map 3} (fn x => fn y => fn mapx => mk_Trueprop_eq (mapx $ x, mapx $ y))
   275             yFs yFs_copy maps;
   275             yFs yFs_copy maps;
   276         val goals = map2 (fn prem => fn concl => Logic.mk_implies (prem, concl)) prems concls;
   276         val goals = map2 (fn prem => fn concl => Logic.mk_implies (prem, concl)) prems concls;
   277       in
   277       in
   278         map (fn goal =>
   278         map (fn goal =>
   279           Goal.prove_sorry lthy [] [] goal (K ((hyp_subst_tac lthy THEN' rtac refl) 1))
   279           Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, prems = _} =>
       
   280             (hyp_subst_tac ctxt THEN' rtac ctxt refl) 1)
   280           |> Thm.close_derivation
   281           |> Thm.close_derivation
   281           |> singleton (Proof_Context.export names_lthy lthy)) goals
   282           |> singleton (Proof_Context.export names_lthy lthy)) goals
   282       end;
   283       end;
   283 
   284 
   284     val timer = time (timer "Derived simple theorems");
   285     val timer = time (timer "Derived simple theorems");
   333           ss zs setssAs;
   334           ss zs setssAs;
   334         val goalss = map2 (fn prem => fn concls => map (fn concl =>
   335         val goalss = map2 (fn prem => fn concls => map (fn concl =>
   335           Logic.list_implies (coalg_prem :: [prem], concl)) concls) prems conclss;
   336           Logic.list_implies (coalg_prem :: [prem], concl)) concls) prems conclss;
   336       in
   337       in
   337         map (fn goals => map (fn goal =>
   338         map (fn goals => map (fn goal =>
   338           Goal.prove_sorry lthy [] [] goal (K (mk_coalg_set_tac coalg_def))
   339           Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, prems = _} =>
       
   340             mk_coalg_set_tac ctxt coalg_def)
   339           |> Thm.close_derivation
   341           |> Thm.close_derivation
   340           |> singleton (Proof_Context.export names_lthy lthy)) goals) goalss
   342           |> singleton (Proof_Context.export names_lthy lthy)) goals) goalss
   341       end;
   343       end;
   342 
   344 
   343     fun mk_tcoalg BTs = mk_coalg (map HOLogic.mk_UNIV BTs);
   345     fun mk_tcoalg BTs = mk_coalg (map HOLogic.mk_UNIV BTs);
   345     val tcoalg_thm =
   347     val tcoalg_thm =
   346       let
   348       let
   347         val goal = HOLogic.mk_Trueprop (mk_tcoalg activeAs ss)
   349         val goal = HOLogic.mk_Trueprop (mk_tcoalg activeAs ss)
   348       in
   350       in
   349         Goal.prove_sorry lthy [] [] goal
   351         Goal.prove_sorry lthy [] [] goal
   350           (K (rtac (coalg_def RS iffD2) 1 THEN CONJ_WRAP
   352           (fn {context = ctxt, prems = _} => (rtac ctxt (coalg_def RS iffD2) 1 THEN CONJ_WRAP
   351             (K (EVERY' [rtac ballI, rtac CollectI,
   353             (K (EVERY' [rtac ctxt ballI, rtac ctxt CollectI,
   352               CONJ_WRAP' (K (EVERY' [rtac @{thm subset_UNIV}])) allAs] 1)) ss))
   354               CONJ_WRAP' (K (EVERY' [rtac ctxt @{thm subset_UNIV}])) allAs] 1)) ss))
   353         |> Thm.close_derivation
   355         |> Thm.close_derivation
   354         |> singleton (Proof_Context.export names_lthy lthy)
   356         |> singleton (Proof_Context.export names_lthy lthy)
   355       end;
   357       end;
   356 
   358 
   357     val timer = time (timer "Coalgebra definition & thms");
   359     val timer = time (timer "Coalgebra definition & thms");
   407         fun mk_elim_goal B mapAsBs f s s' x =
   409         fun mk_elim_goal B mapAsBs f s s' x =
   408           Logic.list_implies ([prem, mk_Trueprop_mem (x, B)],
   410           Logic.list_implies ([prem, mk_Trueprop_mem (x, B)],
   409             mk_Trueprop_eq (Term.list_comb (mapAsBs, passive_ids @ fs @ [s $ x]), s' $ (f $ x)));
   411             mk_Trueprop_eq (Term.list_comb (mapAsBs, passive_ids @ fs @ [s $ x]), s' $ (f $ x)));
   410         val elim_goals = @{map 6} mk_elim_goal Bs mapsAsBs fs ss s's zs;
   412         val elim_goals = @{map 6} mk_elim_goal Bs mapsAsBs fs ss s's zs;
   411         fun prove goal =
   413         fun prove goal =
   412           Goal.prove_sorry lthy [] [] goal (K (mk_mor_elim_tac mor_def))
   414           Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, prems = _} =>
       
   415             mk_mor_elim_tac ctxt mor_def)
   413           |> Thm.close_derivation
   416           |> Thm.close_derivation
   414           |> singleton (Proof_Context.export names_lthy lthy);
   417           |> singleton (Proof_Context.export names_lthy lthy);
   415       in
   418       in
   416         (map prove image_goals, map prove elim_goals)
   419         (map prove image_goals, map prove elim_goals)
   417       end;
   420       end;
   422       let
   425       let
   423         val prems = map2 (HOLogic.mk_Trueprop oo mk_leq) Bs Bs_copy;
   426         val prems = map2 (HOLogic.mk_Trueprop oo mk_leq) Bs Bs_copy;
   424         val concl = HOLogic.mk_Trueprop (mk_mor Bs ss Bs_copy ss active_ids);
   427         val concl = HOLogic.mk_Trueprop (mk_mor Bs ss Bs_copy ss active_ids);
   425       in
   428       in
   426         Goal.prove_sorry lthy [] [] (Logic.list_implies (prems, concl))
   429         Goal.prove_sorry lthy [] [] (Logic.list_implies (prems, concl))
   427           (K (mk_mor_incl_tac mor_def map_ids))
   430           (fn {context = ctxt, prems = _} => mk_mor_incl_tac ctxt mor_def map_ids)
   428         |> Thm.close_derivation
   431         |> Thm.close_derivation
   429         |> singleton (Proof_Context.export names_lthy lthy)
   432         |> singleton (Proof_Context.export names_lthy lthy)
   430       end;
   433       end;
   431 
   434 
   432     val mor_id_thm = mor_incl_thm OF (replicate n subset_refl);
   435     val mor_id_thm = mor_incl_thm OF (replicate n subset_refl);
   464             HOLogic.mk_comp (s', f));
   467             HOLogic.mk_comp (s', f));
   465         val lhs = mk_mor active_UNIVs ss (map HOLogic.mk_UNIV activeBs) s's fs;
   468         val lhs = mk_mor active_UNIVs ss (map HOLogic.mk_UNIV activeBs) s's fs;
   466         val rhs = Library.foldr1 HOLogic.mk_conj (@{map 4} mk_conjunct mapsAsBs fs ss s's);
   469         val rhs = Library.foldr1 HOLogic.mk_conj (@{map 4} mk_conjunct mapsAsBs fs ss s's);
   467       in
   470       in
   468         Goal.prove_sorry lthy [] [] (mk_Trueprop_eq (lhs, rhs))
   471         Goal.prove_sorry lthy [] [] (mk_Trueprop_eq (lhs, rhs))
   469           (K (mk_mor_UNIV_tac morE_thms mor_def))
   472           (fn {context = ctxt, prems = _} => mk_mor_UNIV_tac ctxt morE_thms mor_def)
   470         |> Thm.close_derivation
   473         |> Thm.close_derivation
   471         |> singleton (Proof_Context.export names_lthy lthy)
   474         |> singleton (Proof_Context.export names_lthy lthy)
   472       end;
   475       end;
   473 
   476 
   474     val mor_str_thm =
   477     val mor_str_thm =
   476         val maps = map2 (fn Ds => fn bnf => Term.list_comb
   479         val maps = map2 (fn Ds => fn bnf => Term.list_comb
   477           (mk_map_of_bnf Ds allAs (passiveAs @ FTsAs) bnf, passive_ids @ ss)) Dss bnfs;
   480           (mk_map_of_bnf Ds allAs (passiveAs @ FTsAs) bnf, passive_ids @ ss)) Dss bnfs;
   478       in
   481       in
   479         Goal.prove_sorry lthy [] []
   482         Goal.prove_sorry lthy [] []
   480           (HOLogic.mk_Trueprop (mk_mor active_UNIVs ss (map HOLogic.mk_UNIV FTsAs) maps ss))
   483           (HOLogic.mk_Trueprop (mk_mor active_UNIVs ss (map HOLogic.mk_UNIV FTsAs) maps ss))
   481           (K (mk_mor_str_tac ks mor_UNIV_thm))
   484           (fn {context = ctxt, prems = _} => mk_mor_str_tac ctxt ks mor_UNIV_thm)
   482         |> Thm.close_derivation
   485         |> Thm.close_derivation
   483         |> singleton (Proof_Context.export names_lthy lthy)
   486         |> singleton (Proof_Context.export names_lthy lthy)
   484       end;
   487       end;
   485 
   488 
   486     val mor_case_sum_thm =
   489     val mor_case_sum_thm =
   489           mk_case_sum (HOLogic.mk_comp (Term.list_comb (mapx, passive_ids @ Inls), s), sum_s))
   492           mk_case_sum (HOLogic.mk_comp (Term.list_comb (mapx, passive_ids @ Inls), s), sum_s))
   490           s's sum_ss map_Inls;
   493           s's sum_ss map_Inls;
   491       in
   494       in
   492         Goal.prove_sorry lthy [] []
   495         Goal.prove_sorry lthy [] []
   493           (HOLogic.mk_Trueprop (mk_mor (map HOLogic.mk_UNIV activeBs) s's sum_UNIVs maps Inls))
   496           (HOLogic.mk_Trueprop (mk_mor (map HOLogic.mk_UNIV activeBs) s's sum_UNIVs maps Inls))
   494           (K (mk_mor_case_sum_tac ks mor_UNIV_thm))
   497           (fn {context = ctxt, prems = _} => mk_mor_case_sum_tac ctxt ks mor_UNIV_thm)
   495         |> Thm.close_derivation
   498         |> Thm.close_derivation
   496         |> singleton (Proof_Context.export names_lthy lthy)
   499         |> singleton (Proof_Context.export names_lthy lthy)
   497       end;
   500       end;
   498 
   501 
   499     val timer = time (timer "Morphism definition & thms");
   502     val timer = time (timer "Morphism definition & thms");
   565         val rhs = HOLogic.mk_conj
   568         val rhs = HOLogic.mk_conj
   566           (bis_le, Library.foldr1 HOLogic.mk_conj
   569           (bis_le, Library.foldr1 HOLogic.mk_conj
   567             (@{map 6} mk_conjunct Rs ss s's zs z's relsAsBs))
   570             (@{map 6} mk_conjunct Rs ss s's zs z's relsAsBs))
   568       in
   571       in
   569         Goal.prove_sorry lthy [] [] (mk_Trueprop_eq (mk_bis Bs ss B's s's Rs, rhs))
   572         Goal.prove_sorry lthy [] [] (mk_Trueprop_eq (mk_bis Bs ss B's s's Rs, rhs))
   570           (K (mk_bis_rel_tac m bis_def in_rels map_comps map_cong0s set_mapss))
   573           (fn {context = ctxt, prems = _} => mk_bis_rel_tac ctxt m bis_def in_rels map_comps
       
   574             map_cong0s set_mapss)
   571         |> Thm.close_derivation
   575         |> Thm.close_derivation
   572         |> singleton (Proof_Context.export names_lthy lthy)
   576         |> singleton (Proof_Context.export names_lthy lthy)
   573       end;
   577       end;
   574 
   578 
   575     val bis_converse_thm =
   579     val bis_converse_thm =
   576       Goal.prove_sorry lthy [] []
   580       Goal.prove_sorry lthy [] []
   577         (Logic.mk_implies (HOLogic.mk_Trueprop (mk_bis Bs ss B's s's Rs),
   581         (Logic.mk_implies (HOLogic.mk_Trueprop (mk_bis Bs ss B's s's Rs),
   578           HOLogic.mk_Trueprop (mk_bis B's s's Bs ss (map mk_converse Rs))))
   582           HOLogic.mk_Trueprop (mk_bis B's s's Bs ss (map mk_converse Rs))))
   579         (K (mk_bis_converse_tac m bis_rel_thm rel_congs rel_converseps))
   583         (fn {context = ctxt, prems = _} => mk_bis_converse_tac ctxt m bis_rel_thm rel_congs
       
   584           rel_converseps)
   580       |> Thm.close_derivation
   585       |> Thm.close_derivation
   581       |> singleton (Proof_Context.export names_lthy lthy);
   586       |> singleton (Proof_Context.export names_lthy lthy);
   582 
   587 
   583     val bis_O_thm =
   588     val bis_O_thm =
   584       let
   589       let
   684       let
   689       let
   685         fun mk_concl i R = HOLogic.mk_Trueprop (mk_leq R (mk_lsbis Bs ss i));
   690         fun mk_concl i R = HOLogic.mk_Trueprop (mk_leq R (mk_lsbis Bs ss i));
   686         val goals = map2 (fn i => fn R => Logic.mk_implies (sbis_prem, mk_concl i R)) ks sRs;
   691         val goals = map2 (fn i => fn R => Logic.mk_implies (sbis_prem, mk_concl i R)) ks sRs;
   687       in
   692       in
   688         @{map 3} (fn goal => fn i => fn def =>
   693         @{map 3} (fn goal => fn i => fn def =>
   689           Goal.prove_sorry lthy [] [] goal (K (mk_incl_lsbis_tac n i def))
   694           Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, prems = _} =>
       
   695             mk_incl_lsbis_tac ctxt n i def)
   690           |> Thm.close_derivation
   696           |> Thm.close_derivation
   691           |> singleton (Proof_Context.export names_lthy lthy)) goals ks lsbis_defs
   697           |> singleton (Proof_Context.export names_lthy lthy)) goals ks lsbis_defs
   692       end;
   698       end;
   693 
   699 
   694     val equiv_lsbis_thms =
   700     val equiv_lsbis_thms =
   696         fun mk_concl i B = HOLogic.mk_Trueprop (mk_equiv B (mk_lsbis Bs ss i));
   702         fun mk_concl i B = HOLogic.mk_Trueprop (mk_equiv B (mk_lsbis Bs ss i));
   697         val goals = map2 (fn i => fn B => Logic.mk_implies (coalg_prem, mk_concl i B)) ks Bs;
   703         val goals = map2 (fn i => fn B => Logic.mk_implies (coalg_prem, mk_concl i B)) ks Bs;
   698       in
   704       in
   699         @{map 3} (fn goal => fn l_incl => fn incl_l =>
   705         @{map 3} (fn goal => fn l_incl => fn incl_l =>
   700           Goal.prove_sorry lthy [] [] goal
   706           Goal.prove_sorry lthy [] [] goal
   701             (K (mk_equiv_lsbis_tac sbis_lsbis_thm l_incl incl_l
   707             (fn {context = ctxt, prems = _} => mk_equiv_lsbis_tac ctxt sbis_lsbis_thm l_incl incl_l
   702               bis_Id_on_thm bis_converse_thm bis_O_thm))
   708               bis_Id_on_thm bis_converse_thm bis_O_thm)
   703           |> Thm.close_derivation
   709           |> Thm.close_derivation
   704           |> singleton (Proof_Context.export names_lthy lthy))
   710           |> singleton (Proof_Context.export names_lthy lthy))
   705         goals lsbis_incl_thms incl_lsbis_thms
   711         goals lsbis_incl_thms incl_lsbis_thms
   706       end;
   712       end;
   707 
   713 
   717         let
   723         let
   718           val sbdT_bind = mk_internal_b sum_bdTN;
   724           val sbdT_bind = mk_internal_b sum_bdTN;
   719 
   725 
   720           val ((sbdT_name, (sbdT_glob_info, sbdT_loc_info)), lthy) =
   726           val ((sbdT_name, (sbdT_glob_info, sbdT_loc_info)), lthy) =
   721             typedef (sbdT_bind, sum_bdT_params', NoSyn)
   727             typedef (sbdT_bind, sum_bdT_params', NoSyn)
   722               (HOLogic.mk_UNIV sum_bdT) NONE (fn _ => EVERY' [rtac exI, rtac UNIV_I] 1) lthy;
   728               (HOLogic.mk_UNIV sum_bdT) NONE (fn ctxt =>
       
   729                 EVERY' [rtac ctxt exI, rtac ctxt UNIV_I] 1) lthy;
   723 
   730 
   724           val sbdT = Type (sbdT_name, sum_bdT_params);
   731           val sbdT = Type (sbdT_name, sum_bdT_params);
   725           val Abs_sbdT = Const (#Abs_name sbdT_glob_info, sum_bdT --> sbdT);
   732           val Abs_sbdT = Const (#Abs_name sbdT_glob_info, sum_bdT --> sbdT);
   726 
   733 
   727           val sbd_bind = mk_internal_b sum_bdN;
   734           val sbd_bind = mk_internal_b sum_bdN;
  1095             (mk_Trueprop_mem (kl, mk_Lev ss nat i $ z),
  1102             (mk_Trueprop_mem (kl, mk_Lev ss nat i $ z),
  1096             mk_Trueprop_mem (kl, mk_Lev ss (mk_size kl) i $ z));
  1103             mk_Trueprop_mem (kl, mk_Lev ss (mk_size kl) i $ z));
  1097         val goals = map2 mk_goal ks zs;
  1104         val goals = map2 mk_goal ks zs;
  1098 
  1105 
  1099         val length_Levs' = map2 (fn goal => fn length_Lev =>
  1106         val length_Levs' = map2 (fn goal => fn length_Lev =>
  1100           Goal.prove_sorry lthy [] [] goal (K (mk_length_Lev'_tac length_Lev))
  1107           Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, prems = _} =>
       
  1108             mk_length_Lev'_tac ctxt length_Lev)
  1101           |> Thm.close_derivation
  1109           |> Thm.close_derivation
  1102           |> singleton (Proof_Context.export names_lthy lthy)) goals length_Levs;
  1110           |> singleton (Proof_Context.export names_lthy lthy)) goals length_Levs;
  1103       in
  1111       in
  1104         (length_Levs, length_Levs')
  1112         (length_Levs, length_Levs')
  1105       end;
  1113       end;
  1118         val cTs = [SOME (Thm.ctyp_of lthy sum_sbdT)];
  1126         val cTs = [SOME (Thm.ctyp_of lthy sum_sbdT)];
  1119         val cts = map (SOME o Thm.cterm_of lthy) [Term.absfree kl' goal, kl];
  1127         val cts = map (SOME o Thm.cterm_of lthy) [Term.absfree kl' goal, kl];
  1120 
  1128 
  1121         val rv_last =
  1129         val rv_last =
  1122           Goal.prove_sorry lthy [] [] (HOLogic.mk_Trueprop goal)
  1130           Goal.prove_sorry lthy [] [] (HOLogic.mk_Trueprop goal)
  1123             (K (mk_rv_last_tac cTs cts rv_Nils rv_Conss))
  1131             (fn {context = ctxt, prems = _} => mk_rv_last_tac ctxt cTs cts rv_Nils rv_Conss)
  1124           |> Thm.close_derivation
  1132           |> Thm.close_derivation
  1125           |> singleton (Proof_Context.export names_lthy lthy);
  1133           |> singleton (Proof_Context.export names_lthy lthy);
  1126 
  1134 
  1127         val rv_last' = mk_specN (n + 1) rv_last;
  1135         val rv_last' = mk_specN (n + 1) rv_last;
  1128       in
  1136       in
  1242 
  1250 
  1243         val goals = @{map 3} mk_goal lsbisAs final_maps strTAs;
  1251         val goals = @{map 3} mk_goal lsbisAs final_maps strTAs;
  1244       in
  1252       in
  1245         @{map 4} (fn goal => fn lsbisE => fn map_comp_id => fn map_cong0 =>
  1253         @{map 4} (fn goal => fn lsbisE => fn map_comp_id => fn map_cong0 =>
  1246           Goal.prove_sorry lthy [] [] goal
  1254           Goal.prove_sorry lthy [] [] goal
  1247             (K (mk_congruent_str_final_tac m lsbisE map_comp_id map_cong0 equiv_LSBIS_thms))
  1255             (fn {context = ctxt, prems = _} => mk_congruent_str_final_tac ctxt m lsbisE map_comp_id
       
  1256               map_cong0 equiv_LSBIS_thms)
  1248           |> Thm.close_derivation)
  1257           |> Thm.close_derivation)
  1249         goals lsbisE_thms map_comp_id_thms map_cong0s
  1258         goals lsbisE_thms map_comp_id_thms map_cong0s
  1250       end;
  1259       end;
  1251 
  1260 
  1252     val coalg_final_thm = Goal.prove_sorry lthy [] []
  1261     val coalg_final_thm = Goal.prove_sorry lthy [] []
  1253       (HOLogic.mk_Trueprop (mk_coalg car_finals str_finals))
  1262       (HOLogic.mk_Trueprop (mk_coalg car_finals str_finals))
  1254       (K (mk_coalg_final_tac m coalg_def congruent_str_final_thms equiv_LSBIS_thms
  1263       (fn {context = ctxt, prems = _} => mk_coalg_final_tac ctxt m coalg_def
  1255         set_mapss coalgT_set_thmss))
  1264         congruent_str_final_thms equiv_LSBIS_thms set_mapss coalgT_set_thmss)
  1256       |> Thm.close_derivation;
  1265       |> Thm.close_derivation;
  1257 
  1266 
  1258     val mor_T_final_thm = Goal.prove_sorry lthy [] []
  1267     val mor_T_final_thm = Goal.prove_sorry lthy [] []
  1259       (HOLogic.mk_Trueprop (mk_mor carTAs strTAs car_finals str_finals (map mk_proj lsbisAs)))
  1268       (HOLogic.mk_Trueprop (mk_mor carTAs strTAs car_finals str_finals (map mk_proj lsbisAs)))
  1260       (K (mk_mor_T_final_tac mor_def congruent_str_final_thms equiv_LSBIS_thms))
  1269       (fn {context = ctxt, prems = _} => mk_mor_T_final_tac ctxt mor_def congruent_str_final_thms
       
  1270         equiv_LSBIS_thms)
  1261       |> Thm.close_derivation;
  1271       |> Thm.close_derivation;
  1262 
  1272 
  1263     val mor_final_thm = mor_comp_thm OF [mor_beh_thm, mor_T_final_thm];
  1273     val mor_final_thm = mor_comp_thm OF [mor_beh_thm, mor_T_final_thm];
  1264     val in_car_final_thms = map (fn thm => thm OF [mor_final_thm, UNIV_I]) mor_image'_thms;
  1274     val in_car_final_thms = map (fn thm => thm OF [mor_final_thm, UNIV_I]) mor_image'_thms;
  1265 
  1275 
  1266     val timer = time (timer "Final coalgebra");
  1276     val timer = time (timer "Final coalgebra");
  1267 
  1277 
  1268     val ((T_names, (T_glob_infos, T_loc_infos)), lthy) =
  1278     val ((T_names, (T_glob_infos, T_loc_infos)), lthy) =
  1269       lthy
  1279       lthy
  1270       |> @{fold_map 4} (fn b => fn mx => fn car_final => fn in_car_final =>
  1280       |> @{fold_map 4} (fn b => fn mx => fn car_final => fn in_car_final =>
  1271         typedef (b, params, mx) car_final NONE
  1281           typedef (b, params, mx) car_final NONE
  1272           (fn _ => EVERY' [rtac exI, rtac in_car_final] 1)) bs mixfixes car_finals in_car_final_thms
  1282             (fn ctxt => EVERY' [rtac ctxt exI, rtac ctxt in_car_final] 1))
       
  1283         bs mixfixes car_finals in_car_final_thms
  1273       |>> apsnd split_list o split_list;
  1284       |>> apsnd split_list o split_list;
  1274 
  1285 
  1275     val Ts = map (fn name => Type (name, params')) T_names;
  1286     val Ts = map (fn name => Type (name, params')) T_names;
  1276     fun mk_Ts passive = map (Term.typ_subst_atomic (passiveAs ~~ passive)) Ts;
  1287     fun mk_Ts passive = map (Term.typ_subst_atomic (passiveAs ~~ passive)) Ts;
  1277     val Ts' = mk_Ts passiveBs;
  1288     val Ts' = mk_Ts passiveBs;
  1395         val Abs_inverses' = map2 (curry op RS) in_car_final_thms Abs_inverses;
  1406         val Abs_inverses' = map2 (curry op RS) in_car_final_thms Abs_inverses;
  1396         val morEs' = map (fn thm => (thm OF [mor_final_thm, UNIV_I]) RS sym) morE_thms;
  1407         val morEs' = map (fn thm => (thm OF [mor_final_thm, UNIV_I]) RS sym) morE_thms;
  1397       in
  1408       in
  1398         Goal.prove_sorry lthy [] []
  1409         Goal.prove_sorry lthy [] []
  1399           (HOLogic.mk_Trueprop (mk_mor active_UNIVs ss UNIVs dtors (map (mk_unfold Ts ss) ks)))
  1410           (HOLogic.mk_Trueprop (mk_mor active_UNIVs ss UNIVs dtors (map (mk_unfold Ts ss) ks)))
  1400           (K (mk_mor_unfold_tac m mor_UNIV_thm dtor_defs unfold_defs Abs_inverses' morEs'
  1411           (fn {context = ctxt, prems = _} => mk_mor_unfold_tac ctxt m mor_UNIV_thm dtor_defs
  1401             map_comp_id_thms map_cong0s))
  1412             unfold_defs Abs_inverses' morEs' map_comp_id_thms map_cong0s)
  1402         |> Thm.close_derivation
  1413         |> Thm.close_derivation
  1403         |> singleton (Proof_Context.export names_lthy lthy)
  1414         |> singleton (Proof_Context.export names_lthy lthy)
  1404       end;
  1415       end;
  1405     val dtor_unfold_thms = map (fn thm => (thm OF [mor_unfold_thm, UNIV_I]) RS sym) morE_thms;
  1416     val dtor_unfold_thms = map (fn thm => (thm OF [mor_unfold_thm, UNIV_I]) RS sym) morE_thms;
  1406 
  1417 
  1409         val prem = HOLogic.mk_Trueprop (mk_sbis UNIVs dtors TRs);
  1420         val prem = HOLogic.mk_Trueprop (mk_sbis UNIVs dtors TRs);
  1410         val concl = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj
  1421         val concl = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj
  1411           (map2 (fn R => fn T => mk_leq R (Id_const T)) TRs Ts));
  1422           (map2 (fn R => fn T => mk_leq R (Id_const T)) TRs Ts));
  1412       in
  1423       in
  1413         `split_conj_thm (Goal.prove_sorry lthy [] [] (Logic.mk_implies (prem, concl))
  1424         `split_conj_thm (Goal.prove_sorry lthy [] [] (Logic.mk_implies (prem, concl))
  1414           (K (mk_raw_coind_tac bis_def bis_cong_thm bis_O_thm bis_converse_thm bis_Gr_thm
  1425           (fn {context = ctxt, prems = _} => mk_raw_coind_tac ctxt bis_def bis_cong_thm bis_O_thm
  1415             tcoalg_thm coalgT_thm mor_T_final_thm sbis_lsbis_thm
  1426             bis_converse_thm bis_Gr_thm tcoalg_thm coalgT_thm mor_T_final_thm sbis_lsbis_thm
  1416             lsbis_incl_thms incl_lsbis_thms equiv_LSBIS_thms mor_Rep_thm Rep_injects))
  1427             lsbis_incl_thms incl_lsbis_thms equiv_LSBIS_thms mor_Rep_thm Rep_injects)
  1417           |> Thm.close_derivation
  1428           |> Thm.close_derivation
  1418           |> singleton (Proof_Context.export names_lthy lthy))
  1429           |> singleton (Proof_Context.export names_lthy lthy))
  1419       end;
  1430       end;
  1420 
  1431 
  1421     val (unfold_unique_mor_thms, unfold_unique_mor_thm) =
  1432     val (unfold_unique_mor_thms, unfold_unique_mor_thm) =
  1427 
  1438 
  1428         val bis_thm = tcoalg_thm RSN (2, tcoalg_thm RS bis_image2_thm);
  1439         val bis_thm = tcoalg_thm RSN (2, tcoalg_thm RS bis_image2_thm);
  1429         val mor_thm = mor_comp_thm OF [mor_final_thm, mor_Abs_thm];
  1440         val mor_thm = mor_comp_thm OF [mor_final_thm, mor_Abs_thm];
  1430 
  1441 
  1431         val unique_mor = Goal.prove_sorry lthy [] [] (Logic.mk_implies (prem, unique))
  1442         val unique_mor = Goal.prove_sorry lthy [] [] (Logic.mk_implies (prem, unique))
  1432           (K (mk_unfold_unique_mor_tac raw_coind_thms bis_thm mor_thm unfold_defs))
  1443           (fn {context = ctxt, prems = _} => mk_unfold_unique_mor_tac ctxt raw_coind_thms
       
  1444             bis_thm mor_thm unfold_defs)
  1433           |> Thm.close_derivation
  1445           |> Thm.close_derivation
  1434           |> singleton (Proof_Context.export names_lthy lthy);
  1446           |> singleton (Proof_Context.export names_lthy lthy);
  1435       in
  1447       in
  1436         `split_conj_thm unique_mor
  1448         `split_conj_thm unique_mor
  1437       end;
  1449       end;
  1627         val rel_prems = @{map 5} mk_rel_prem phis dtors rels Jzs Jzs_copy;
  1639         val rel_prems = @{map 5} mk_rel_prem phis dtors rels Jzs Jzs_copy;
  1628         val dtor_coinduct_goal = Logic.list_implies (rel_prems, concl);
  1640         val dtor_coinduct_goal = Logic.list_implies (rel_prems, concl);
  1629 
  1641 
  1630         val dtor_coinduct =
  1642         val dtor_coinduct =
  1631           Goal.prove_sorry lthy [] [] dtor_coinduct_goal
  1643           Goal.prove_sorry lthy [] [] dtor_coinduct_goal
  1632             (K (mk_dtor_coinduct_tac m raw_coind_thm bis_rel_thm rel_congs))
  1644             (fn {context = ctxt, prems = _} => mk_dtor_coinduct_tac ctxt m raw_coind_thm bis_rel_thm
       
  1645               rel_congs)
  1633           |> Thm.close_derivation
  1646           |> Thm.close_derivation
  1634           |> singleton (Proof_Context.export names_lthy lthy);
  1647           |> singleton (Proof_Context.export names_lthy lthy);
  1635       in
  1648       in
  1636         (rev (Term.add_tfrees dtor_coinduct_goal []), dtor_coinduct)
  1649         (rev (Term.add_tfrees dtor_coinduct_goal []), dtor_coinduct)
  1637       end;
  1650       end;
  1662 
  1675 
  1663     fun mk_Jrel_DEADID_coinduct_thm () =
  1676     fun mk_Jrel_DEADID_coinduct_thm () =
  1664       mk_xtor_rel_co_induct_thm Greatest_FP rels activeJphis (map HOLogic.eq_const Ts) Jphis
  1677       mk_xtor_rel_co_induct_thm Greatest_FP rels activeJphis (map HOLogic.eq_const Ts) Jphis
  1665         Jzs Jz's dtors dtor's (fn {context = ctxt, prems} =>
  1678         Jzs Jz's dtors dtor's (fn {context = ctxt, prems} =>
  1666           (unfold_thms_tac ctxt @{thms le_fun_def le_bool_def all_simps(1,2)[symmetric]} THEN
  1679           (unfold_thms_tac ctxt @{thms le_fun_def le_bool_def all_simps(1,2)[symmetric]} THEN
  1667           REPEAT_DETERM (rtac allI 1) THEN rtac (dtor_coinduct_thm OF prems) 1)) lthy;
  1680           REPEAT_DETERM (rtac ctxt allI 1) THEN rtac ctxt (dtor_coinduct_thm OF prems) 1)) lthy;
  1668 
  1681 
  1669     (*register new codatatypes as BNFs*)
  1682     (*register new codatatypes as BNFs*)
  1670     val (timer, Jbnfs, (dtor_Jmap_o_thms, dtor_Jmap_thms), dtor_Jmap_unique_thms, dtor_Jset_thmss',
  1683     val (timer, Jbnfs, (dtor_Jmap_o_thms, dtor_Jmap_thms), dtor_Jmap_unique_thms, dtor_Jset_thmss',
  1671       dtor_Jrel_thms, Jrel_coinduct_thm, Jbnf_notes, dtor_Jset_induct_thms, lthy) =
  1684       dtor_Jrel_thms, Jrel_coinduct_thm, Jbnf_notes, dtor_Jset_induct_thms, lthy) =
  1672       if m = 0 then
  1685       if m = 0 then
  1798             val goals = @{map 4} mk_goal fs_Jmaps map_FTFT's dtors dtor's;
  1811             val goals = @{map 4} mk_goal fs_Jmaps map_FTFT's dtors dtor's;
  1799             val maps =
  1812             val maps =
  1800               @{map 5} (fn goal => fn unfold => fn map_comp => fn map_cong0 => fn map_arg_cong =>
  1813               @{map 5} (fn goal => fn unfold => fn map_comp => fn map_cong0 => fn map_arg_cong =>
  1801                 Goal.prove_sorry lthy [] [] goal
  1814                 Goal.prove_sorry lthy [] [] goal
  1802                   (fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jmap_defs THEN
  1815                   (fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jmap_defs THEN
  1803                      mk_map_tac m n map_arg_cong unfold map_comp map_cong0)
  1816                      mk_map_tac ctxt m n map_arg_cong unfold map_comp map_cong0)
  1804                 |> Thm.close_derivation
  1817                 |> Thm.close_derivation
  1805                 |> singleton (Proof_Context.export names_lthy lthy))
  1818                 |> singleton (Proof_Context.export names_lthy lthy))
  1806               goals dtor_unfold_thms map_comps map_cong0s map_arg_cong_thms;
  1819               goals dtor_unfold_thms map_comps map_cong0s map_arg_cong_thms;
  1807           in
  1820           in
  1808             map_split (fn thm => (thm RS @{thm comp_eq_dest}, thm)) maps
  1821             map_split (fn thm => (thm RS @{thm comp_eq_dest}, thm)) maps
  1831               (@{map 3} (fn fmap => fn gmap => fn fgmap =>
  1844               (@{map 3} (fn fmap => fn gmap => fn fgmap =>
  1832                  HOLogic.mk_eq (HOLogic.mk_comp (gmap, fmap), fgmap))
  1845                  HOLogic.mk_eq (HOLogic.mk_comp (gmap, fmap), fgmap))
  1833               fs_Jmaps gs_Jmaps fgs_Jmaps))
  1846               fs_Jmaps gs_Jmaps fgs_Jmaps))
  1834           in
  1847           in
  1835             split_conj_thm (Goal.prove_sorry lthy [] [] goal
  1848             split_conj_thm (Goal.prove_sorry lthy [] [] goal
  1836               (K (mk_map_comp0_tac Jmap_thms map_comp0s dtor_Jmap_unique_thm))
  1849               (fn {context = ctxt, prems = _} =>
       
  1850                 mk_map_comp0_tac ctxt Jmap_thms map_comp0s dtor_Jmap_unique_thm)
  1837               |> Thm.close_derivation
  1851               |> Thm.close_derivation
  1838               |> singleton (Proof_Context.export names_lthy lthy))
  1852               |> singleton (Proof_Context.export names_lthy lthy))
  1839           end;
  1853           end;
  1840 
  1854 
  1841         val timer = time (timer "map functions for the new codatatypes");
  1855         val timer = time (timer "map functions for the new codatatypes");
  1918           in
  1932           in
  1919             (map2 (fn goals => fn rec_Sucs =>
  1933             (map2 (fn goals => fn rec_Sucs =>
  1920               map2 (fn goal => fn rec_Suc =>
  1934               map2 (fn goal => fn rec_Suc =>
  1921                 Goal.prove_sorry lthy [] [] goal
  1935                 Goal.prove_sorry lthy [] [] goal
  1922                   (fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jset_defs THEN
  1936                   (fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jset_defs THEN
  1923                     mk_set_incl_Jset_tac rec_Suc)
  1937                     mk_set_incl_Jset_tac ctxt rec_Suc)
  1924                 |> Thm.close_derivation
  1938                 |> Thm.close_derivation
  1925                 |> singleton (Proof_Context.export names_lthy lthy))
  1939                 |> singleton (Proof_Context.export names_lthy lthy))
  1926               goals rec_Sucs)
  1940               goals rec_Sucs)
  1927             set_incl_Jset_goalss col_Sucss,
  1941             set_incl_Jset_goalss col_Sucss,
  1928             map2 (fn goalss => fn rec_Sucs =>
  1942             map2 (fn goalss => fn rec_Sucs =>
  1929               map2 (fn k => fn goals =>
  1943               map2 (fn k => fn goals =>
  1930                 map2 (fn goal => fn rec_Suc =>
  1944                 map2 (fn goal => fn rec_Suc =>
  1931                   Goal.prove_sorry lthy [] [] goal
  1945                   Goal.prove_sorry lthy [] [] goal
  1932                     (fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jset_defs THEN
  1946                     (fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jset_defs THEN
  1933                       mk_set_Jset_incl_Jset_tac n rec_Suc k)
  1947                       mk_set_Jset_incl_Jset_tac ctxt n rec_Suc k)
  1934                   |> Thm.close_derivation
  1948                   |> Thm.close_derivation
  1935                   |> singleton (Proof_Context.export names_lthy lthy))
  1949                   |> singleton (Proof_Context.export names_lthy lthy))
  1936                 goals rec_Sucs)
  1950                 goals rec_Sucs)
  1937               ks goalss)
  1951               ks goalss)
  1938             set_Jset_incl_Jset_goalsss col_Sucss)
  1952             set_Jset_incl_Jset_goalsss col_Sucss)
  1964                 |> Drule.instantiate' cTs (mk_induct_tinst phis jsets y y')
  1978                 |> Drule.instantiate' cTs (mk_induct_tinst phis jsets y y')
  1965                 |> unfold_thms lthy incls) OF
  1979                 |> unfold_thms lthy incls) OF
  1966                 (replicate n ballI @
  1980                 (replicate n ballI @
  1967                   maps (map (fn thm => thm RS @{thm subset_CollectI})) set_set_inclss))
  1981                   maps (map (fn thm => thm RS @{thm subset_CollectI})) set_set_inclss))
  1968               |> singleton (Proof_Context.export names_lthy lthy)
  1982               |> singleton (Proof_Context.export names_lthy lthy)
  1969               |> rule_by_tactic lthy (ALLGOALS (TRY o etac asm_rl)))
  1983               |> rule_by_tactic lthy (ALLGOALS (TRY o etac lthy asm_rl)))
  1970             Jset_minimal_thms set_Jset_incl_Jset_thmsss' Jsetss_by_range ys ys' dtor_set_induct_phiss
  1984             Jset_minimal_thms set_Jset_incl_Jset_thmsss' Jsetss_by_range ys ys' dtor_set_induct_phiss
  1971           end;
  1985           end;
  1972 
  1986 
  1973         val (dtor_Jset_thmss', dtor_Jset_thmss) =
  1987         val (dtor_Jset_thmss', dtor_Jset_thmss) =
  1974           let
  1988           let
  1986             val le_goals = map (HOLogic.mk_Trueprop o Library.foldr1 HOLogic.mk_conj)
  2000             val le_goals = map (HOLogic.mk_Trueprop o Library.foldr1 HOLogic.mk_conj)
  1987               (mk_goals (uncurry mk_leq));
  2001               (mk_goals (uncurry mk_leq));
  1988             val set_le_thmss = map split_conj_thm
  2002             val set_le_thmss = map split_conj_thm
  1989               (@{map 4} (fn goal => fn Jset_minimal => fn set_Jsets => fn set_Jset_Jsetss =>
  2003               (@{map 4} (fn goal => fn Jset_minimal => fn set_Jsets => fn set_Jset_Jsetss =>
  1990                 Goal.prove_sorry lthy [] [] goal
  2004                 Goal.prove_sorry lthy [] [] goal
  1991                   (K (mk_set_le_tac n Jset_minimal set_Jsets set_Jset_Jsetss))
  2005                   (fn {context = ctxt, prems = _} =>
       
  2006                     mk_set_le_tac ctxt n Jset_minimal set_Jsets set_Jset_Jsetss)
  1992                 |> Thm.close_derivation
  2007                 |> Thm.close_derivation
  1993                 |> singleton (Proof_Context.export names_lthy lthy))
  2008                 |> singleton (Proof_Context.export names_lthy lthy))
  1994               le_goals Jset_minimal_thms set_Jset_thmss' set_Jset_Jset_thmsss');
  2009               le_goals Jset_minimal_thms set_Jset_thmss' set_Jset_Jset_thmsss');
  1995 
  2010 
  1996             val ge_goalss = map (map HOLogic.mk_Trueprop) (mk_goals (uncurry mk_leq o swap));
  2011             val ge_goalss = map (map HOLogic.mk_Trueprop) (mk_goals (uncurry mk_leq o swap));
  1997             val set_ge_thmss =
  2012             val set_ge_thmss =
  1998               @{map 3} (@{map 3} (fn goal => fn set_incl_Jset => fn set_Jset_incl_Jsets =>
  2013               @{map 3} (@{map 3} (fn goal => fn set_incl_Jset => fn set_Jset_incl_Jsets =>
  1999                 Goal.prove_sorry lthy [] [] goal
  2014                 Goal.prove_sorry lthy [] [] goal
  2000                   (K (mk_set_ge_tac n set_incl_Jset set_Jset_incl_Jsets))
  2015                   (fn {context = ctxt, prems = _} =>
       
  2016                     mk_set_ge_tac ctxt n set_incl_Jset set_Jset_incl_Jsets)
  2001                 |> Thm.close_derivation
  2017                 |> Thm.close_derivation
  2002                 |> singleton (Proof_Context.export names_lthy lthy)))
  2018                 |> singleton (Proof_Context.export names_lthy lthy)))
  2003               ge_goalss set_incl_Jset_thmss' set_Jset_incl_Jset_thmsss'
  2019               ge_goalss set_incl_Jset_thmss' set_Jset_incl_Jset_thmsss'
  2004           in
  2020           in
  2005             map2 (map2 (fn le => fn ge => equalityI OF [le, ge])) set_le_thmss set_ge_thmss
  2021             map2 (map2 (fn le => fn ge => equalityI OF [le, ge])) set_le_thmss set_ge_thmss
  2052 
  2068 
  2053             val thms =
  2069             val thms =
  2054               @{map 5} (fn j => fn goal => fn cts => fn rec_0s => fn rec_Sucs =>
  2070               @{map 5} (fn j => fn goal => fn cts => fn rec_0s => fn rec_Sucs =>
  2055                 Goal.prove_sorry lthy [] [] (HOLogic.mk_Trueprop goal)
  2071                 Goal.prove_sorry lthy [] [] (HOLogic.mk_Trueprop goal)
  2056                   (fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jbd_defs THEN
  2072                   (fn {context = ctxt, prems = _} => unfold_thms_tac ctxt Jbd_defs THEN
  2057                     mk_col_bd_tac m j cts rec_0s rec_Sucs sbd_Card_order sbd_Cinfinite set_sbdss)
  2073                     mk_col_bd_tac ctxt m j cts rec_0s rec_Sucs sbd_Card_order sbd_Cinfinite set_sbdss)
  2058                 |> Thm.close_derivation
  2074                 |> Thm.close_derivation
  2059                 |> singleton (Proof_Context.export names_lthy lthy))
  2075                 |> singleton (Proof_Context.export names_lthy lthy))
  2060               ls goals ctss col_0ss' col_Sucss';
  2076               ls goals ctss col_0ss' col_Sucss';
  2061           in
  2077           in
  2062             map (split_conj_thm o mk_specN n) thms
  2078             map (split_conj_thm o mk_specN n) thms
  2097               HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj
  2113               HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj
  2098                 (@{map 4} mk_map_cong0 Jsetss_by_bnf Jzs fs_Jmaps fs_copy_Jmaps));
  2114                 (@{map 4} mk_map_cong0 Jsetss_by_bnf Jzs fs_Jmaps fs_copy_Jmaps));
  2099 
  2115 
  2100             val thm =
  2116             val thm =
  2101               Goal.prove_sorry lthy [] [] goal
  2117               Goal.prove_sorry lthy [] [] goal
  2102                 (K (mk_mcong_tac lthy m (rtac coinduct) map_comps dtor_Jmap_thms map_cong0s
  2118                 (fn {context = ctxt, prems = _} => mk_mcong_tac ctxt m (rtac ctxt coinduct) map_comps
  2103                   set_mapss set_Jset_thmss set_Jset_Jset_thmsss in_rels))
  2119                   dtor_Jmap_thms map_cong0s
       
  2120                   set_mapss set_Jset_thmss set_Jset_Jset_thmsss in_rels)
  2104               |> Thm.close_derivation
  2121               |> Thm.close_derivation
  2105               |>  singleton (Proof_Context.export names_lthy lthy);
  2122               |>  singleton (Proof_Context.export names_lthy lthy);
  2106           in
  2123           in
  2107             split_conj_thm thm
  2124             split_conj_thm thm
  2108           end;
  2125           end;
  2266               mk_leq (mk_rel_compp (Jrelpsi1, Jrelpsi2)) Jrelpsi12;
  2283               mk_leq (mk_rel_compp (Jrelpsi1, Jrelpsi2)) Jrelpsi12;
  2267             val goals = @{map 3} mk_le_Jrel_OO Jrelpsi1s Jrelpsi2s Jrelpsi12s;
  2284             val goals = @{map 3} mk_le_Jrel_OO Jrelpsi1s Jrelpsi2s Jrelpsi12s;
  2268 
  2285 
  2269             val goal = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj goals);
  2286             val goal = HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj goals);
  2270           in
  2287           in
  2271             Goal.prove_sorry lthy [] [] goal
  2288             Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, prems = _} =>
  2272               (K (mk_le_rel_OO_tac Jrel_coinduct_thm dtor_Jrel_thms le_rel_OOs))
  2289               mk_le_rel_OO_tac ctxt Jrel_coinduct_thm dtor_Jrel_thms le_rel_OOs)
  2273             |> Thm.close_derivation
  2290             |> Thm.close_derivation
  2274             |> singleton (Proof_Context.export names_lthy lthy)
  2291             |> singleton (Proof_Context.export names_lthy lthy)
  2275           end;
  2292           end;
  2276 
  2293 
  2277         val timer = time (timer "helpers for BNF properties");
  2294         val timer = time (timer "helpers for BNF properties");
  2410           |> split_list;
  2427           |> split_list;
  2411 
  2428 
  2412         val timer = time (timer "witnesses");
  2429         val timer = time (timer "witnesses");
  2413 
  2430 
  2414         val map_id0_tacs =
  2431         val map_id0_tacs =
  2415           map2 (K oo mk_map_id0_tac Jmap_thms) dtor_unfold_unique_thms unfold_dtor_thms;
  2432           map2 (fn thm => fn thm' => fn ctxt =>
  2416         val map_comp0_tacs = map (fn thm => K (rtac (thm RS sym) 1)) Jmap_comp0_thms;
  2433             mk_map_id0_tac ctxt Jmap_thms thm thm')
       
  2434           dtor_unfold_unique_thms unfold_dtor_thms;
       
  2435         val map_comp0_tacs = map (fn thm => fn ctxt => rtac ctxt (thm RS sym) 1) Jmap_comp0_thms;
  2417         val map_cong0_tacs = map (fn thm => fn ctxt => mk_map_cong0_tac ctxt m thm) map_cong0_thms;
  2436         val map_cong0_tacs = map (fn thm => fn ctxt => mk_map_cong0_tac ctxt m thm) map_cong0_thms;
  2418         val set_map0_tacss =
  2437         val set_map0_tacss =
  2419           map (map (fn col => fn ctxt => unfold_thms_tac ctxt Jset_defs THEN mk_set_map0_tac col))
  2438           map (map (fn col => fn ctxt =>
  2420             (transpose col_natural_thmss);
  2439             unfold_thms_tac ctxt Jset_defs THEN mk_set_map0_tac ctxt col))
       
  2440           (transpose col_natural_thmss);
  2421 
  2441 
  2422         val Jbd_card_orders = map (fn def => fold_thms lthy [def] sbd_card_order) Jbd_defs;
  2442         val Jbd_card_orders = map (fn def => fold_thms lthy [def] sbd_card_order) Jbd_defs;
  2423         val Jbd_Cinfinites = map (fn def => fold_thms lthy [def] sbd_Cinfinite) Jbd_defs;
  2443         val Jbd_Cinfinites = map (fn def => fold_thms lthy [def] sbd_Cinfinite) Jbd_defs;
  2424 
  2444 
  2425         val bd_co_tacs = map (fn thm => K (rtac thm 1)) Jbd_card_orders;
  2445         val bd_co_tacs = map (fn thm => fn ctxt => rtac ctxt thm 1) Jbd_card_orders;
  2426         val bd_cinf_tacs = map (fn thm => K (rtac (thm RS conjunct1) 1)) Jbd_Cinfinites;
  2446         val bd_cinf_tacs = map (fn thm => fn ctxt => rtac ctxt (thm RS conjunct1) 1) Jbd_Cinfinites;
  2427 
  2447 
  2428         val set_bd_tacss =
  2448         val set_bd_tacss =
  2429           map2 (fn Cinf => map (fn col => fn ctxt =>
  2449           map2 (fn Cinf => map (fn col => fn ctxt =>
  2430             unfold_thms_tac ctxt Jset_defs THEN mk_set_bd_tac Cinf col))
  2450             unfold_thms_tac ctxt Jset_defs THEN mk_set_bd_tac ctxt Cinf col))
  2431           Jbd_Cinfinites (transpose col_bd_thmss);
  2451           Jbd_Cinfinites (transpose col_bd_thmss);
  2432 
  2452 
  2433         val le_rel_OO_tacs = map (fn i => K (rtac (le_Jrel_OO_thm RS mk_conjunctN n i) 1)) ks;
  2453         val le_rel_OO_tacs = map (fn i => fn ctxt =>
  2434 
  2454           rtac ctxt (le_Jrel_OO_thm RS mk_conjunctN n i) 1) ks;
  2435         val rel_OO_Grp_tacs = map (fn def => K (rtac def 1)) Jrel_unabs_defs;
  2455 
       
  2456         val rel_OO_Grp_tacs = map (fn def => fn ctxt => rtac ctxt def 1) Jrel_unabs_defs;
  2436 
  2457 
  2437         val tacss = @{map 9} zip_axioms map_id0_tacs map_comp0_tacs map_cong0_tacs set_map0_tacss
  2458         val tacss = @{map 9} zip_axioms map_id0_tacs map_comp0_tacs map_cong0_tacs set_map0_tacss
  2438           bd_co_tacs bd_cinf_tacs set_bd_tacss le_rel_OO_tacs rel_OO_Grp_tacs;
  2459           bd_co_tacs bd_cinf_tacs set_bd_tacss le_rel_OO_tacs rel_OO_Grp_tacs;
  2439 
  2460 
  2440         fun wit_tac thms ctxt =
  2461         fun wit_tac thms ctxt =