src/HOL/BNF/Tools/bnf_lfp.ML
changeset 51925 e3b7917186f1
parent 51918 3c152334f794
child 52100 e58762f34639
equal deleted inserted replaced
51924:e398ab28eaa7 51925:e3b7917186f1
  1358         rev (Term.add_tfrees goal []))
  1358         rev (Term.add_tfrees goal []))
  1359       end;
  1359       end;
  1360 
  1360 
  1361     val timer = time (timer "induction");
  1361     val timer = time (timer "induction");
  1362 
  1362 
  1363     fun mk_ctor_map_DEADID_thm ctor_inject =
  1363     fun mk_ctor_map_DEADID_thm ctor_inject map_id =
  1364       trans OF [id_apply, iffD2 OF [ctor_inject, id_apply RS sym]];
  1364       trans OF [id_apply, iffD2 OF [ctor_inject, map_id RS sym]];
  1365 
  1365 
  1366     fun mk_ctor_Irel_DEADID_thm ctor_inject bnf =
  1366     fun mk_ctor_Irel_DEADID_thm ctor_inject bnf =
  1367       trans OF [ctor_inject, rel_eq_of_bnf bnf RS @{thm predicate2_eqD} RS sym];
  1367       trans OF [ctor_inject, rel_eq_of_bnf bnf RS @{thm predicate2_eqD} RS sym];
  1368 
  1368 
  1369     val IphiTs = map2 mk_pred2T passiveAs passiveBs;
  1369     val IphiTs = map2 mk_pred2T passiveAs passiveBs;
  1372       |> mk_Frees "R" IphiTs
  1372       |> mk_Frees "R" IphiTs
  1373       ||>> mk_Frees "IR" activeIphiTs;
  1373       ||>> mk_Frees "IR" activeIphiTs;
  1374     val rels = map2 (fn Ds => mk_rel_of_bnf Ds (passiveAs @ Ts) (passiveBs @ Ts')) Dss bnfs;
  1374     val rels = map2 (fn Ds => mk_rel_of_bnf Ds (passiveAs @ Ts) (passiveBs @ Ts')) Dss bnfs;
  1375 
  1375 
  1376     (*register new datatypes as BNFs*)
  1376     (*register new datatypes as BNFs*)
  1377     val (Ibnfs, folded_ctor_map_thms, folded_ctor_set_thmss', ctor_Irel_thms, lthy) =
  1377     val (timer, Ibnfs, folded_ctor_map_thms, folded_ctor_set_thmss', ctor_Irel_thms, lthy) =
  1378       if m = 0 then
  1378       if m = 0 then
  1379         (replicate n DEADID_bnf, map mk_ctor_map_DEADID_thm ctor_inject_thms, replicate n [],
  1379         (timer, replicate n DEADID_bnf, map2 mk_ctor_map_DEADID_thm ctor_inject_thms map_id's,
  1380         map2 mk_ctor_Irel_DEADID_thm ctor_inject_thms bnfs, lthy)
  1380         replicate n [], map2 mk_ctor_Irel_DEADID_thm ctor_inject_thms bnfs, lthy)
  1381       else let
  1381       else let
  1382         val fTs = map2 (curry op -->) passiveAs passiveBs;
  1382         val fTs = map2 (curry op -->) passiveAs passiveBs;
  1383         val f1Ts = map2 (curry op -->) passiveAs passiveYs;
  1383         val f1Ts = map2 (curry op -->) passiveAs passiveYs;
  1384         val f2Ts = map2 (curry op -->) passiveBs passiveYs;
  1384         val f2Ts = map2 (curry op -->) passiveBs passiveYs;
  1385         val p1Ts = map2 (curry op -->) passiveXs passiveAs;
  1385         val p1Ts = map2 (curry op -->) passiveXs passiveAs;
  1801           |> maps (fn (thmN, thmss) =>
  1801           |> maps (fn (thmN, thmss) =>
  1802             map2 (fn b => fn thms =>
  1802             map2 (fn b => fn thms =>
  1803               ((Binding.qualify true (Binding.name_of b) (Binding.name thmN), []), [(thms, [])]))
  1803               ((Binding.qualify true (Binding.name_of b) (Binding.name thmN), []), [(thms, [])]))
  1804             bs thmss)
  1804             bs thmss)
  1805       in
  1805       in
  1806         timer; (Ibnfs, folded_ctor_map_thms, folded_ctor_set_thmss', ctor_Irel_thms,
  1806         (timer, Ibnfs, folded_ctor_map_thms, folded_ctor_set_thmss', ctor_Irel_thms,
  1807           lthy |> Local_Theory.notes (Ibnf_common_notes @ Ibnf_notes) |> snd)
  1807           lthy |> Local_Theory.notes (Ibnf_common_notes @ Ibnf_notes) |> snd)
  1808       end;
  1808       end;
  1809 
  1809 
  1810       val Irel_induct_thm =
  1810       val Irel_induct_thm =
  1811         let
  1811         let
  1852         |> maps (fn (thmN, thmss) =>
  1852         |> maps (fn (thmN, thmss) =>
  1853           map2 (fn b => fn thms =>
  1853           map2 (fn b => fn thms =>
  1854             ((Binding.qualify true (Binding.name_of b) (Binding.name thmN), []), [(thms, [])]))
  1854             ((Binding.qualify true (Binding.name_of b) (Binding.name thmN), []), [(thms, [])]))
  1855           bs thmss)
  1855           bs thmss)
  1856   in
  1856   in
       
  1857     timer;
  1857     ({Ts = Ts, bnfs = Ibnfs, ctors = ctors, dtors = dtors, un_folds = folds, co_recs = recs,
  1858     ({Ts = Ts, bnfs = Ibnfs, ctors = ctors, dtors = dtors, un_folds = folds, co_recs = recs,
  1858       co_induct = ctor_induct_thm, strong_co_induct = ctor_induct_thm, dtor_ctors = dtor_ctor_thms,
  1859       co_induct = ctor_induct_thm, strong_co_induct = ctor_induct_thm, dtor_ctors = dtor_ctor_thms,
  1859       ctor_dtors = ctor_dtor_thms, ctor_injects = ctor_inject_thms, map_thms = folded_ctor_map_thms,
  1860       ctor_dtors = ctor_dtor_thms, ctor_injects = ctor_inject_thms, map_thms = folded_ctor_map_thms,
  1860       set_thmss = folded_ctor_set_thmss', rel_thms = ctor_Irel_thms, un_fold_thms = ctor_fold_thms,
  1861       set_thmss = folded_ctor_set_thmss', rel_thms = ctor_Irel_thms, un_fold_thms = ctor_fold_thms,
  1861       co_rec_thms = ctor_rec_thms},
  1862       co_rec_thms = ctor_rec_thms},