equal
deleted
inserted
replaced
1332 val pre_map_defs = map map_def_of_bnf pre_bnfs; |
1332 val pre_map_defs = map map_def_of_bnf pre_bnfs; |
1333 val pre_set_defss = map set_defs_of_bnf pre_bnfs; |
1333 val pre_set_defss = map set_defs_of_bnf pre_bnfs; |
1334 val pre_rel_defs = map rel_def_of_bnf pre_bnfs; |
1334 val pre_rel_defs = map rel_def_of_bnf pre_bnfs; |
1335 val fp_nesting_set_maps = maps set_map_of_bnf fp_nesting_bnfs; |
1335 val fp_nesting_set_maps = maps set_map_of_bnf fp_nesting_bnfs; |
1336 val live_nesting_set_maps = maps set_map_of_bnf live_nesting_bnfs; |
1336 val live_nesting_set_maps = maps set_map_of_bnf live_nesting_bnfs; |
|
1337 val live_nesting_rel_eqs = map rel_eq_of_bnf live_nesting_bnfs; |
|
1338 val live_nesting_map_id0s = map map_id0_of_bnf live_nesting_bnfs; |
1337 |
1339 |
1338 val live = live_of_bnf any_fp_bnf; |
1340 val live = live_of_bnf any_fp_bnf; |
1339 val _ = |
1341 val _ = |
1340 if live = 0 andalso exists (not o Binding.is_empty) (map_bs @ rel_bs) then |
1342 if live = 0 andalso exists (not o Binding.is_empty) (map_bs @ rel_bs) then |
1341 warning "Map function and relator names ignored" |
1343 warning "Map function and relator names ignored" |
1590 |
1592 |
1591 val ctr_transfer_thms = |
1593 val ctr_transfer_thms = |
1592 let val goals = map2 (mk_parametricity_goal names_lthy Rs) ctrAs ctrBs in |
1594 let val goals = map2 (mk_parametricity_goal names_lthy Rs) ctrAs ctrBs in |
1593 Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals) |
1595 Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals) |
1594 (fn {context = ctxt, prems = _} => |
1596 (fn {context = ctxt, prems = _} => |
1595 mk_ctr_transfer_tac ctxt rel_intro_thms (map rel_eq_of_bnf live_nesting_bnfs)) |
1597 mk_ctr_transfer_tac ctxt rel_intro_thms live_nesting_rel_eqs) |
1596 |> Conjunction.elim_balanced (length goals) |
1598 |> Conjunction.elim_balanced (length goals) |
1597 |> Proof_Context.export names_lthy lthy |
1599 |> Proof_Context.export names_lthy lthy |
1598 |> map Thm.close_derivation |
1600 |> map Thm.close_derivation |
1599 end; |
1601 end; |
1600 |
1602 |
1728 else |
1730 else |
1729 Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals) |
1731 Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals) |
1730 (fn {context = ctxt, prems = _} => |
1732 (fn {context = ctxt, prems = _} => |
1731 mk_rel_sel_tac ctxt (certify ctxt ta) (certify ctxt tb) exhaust |
1733 mk_rel_sel_tac ctxt (certify ctxt ta) (certify ctxt tb) exhaust |
1732 (flat disc_thmss) (flat sel_thmss) rel_inject_thms distincts |
1734 (flat disc_thmss) (flat sel_thmss) rel_inject_thms distincts |
1733 rel_distinct_thms (map rel_eq_of_bnf live_nesting_bnfs)) |
1735 rel_distinct_thms live_nesting_rel_eqs) |
1734 |> Conjunction.elim_balanced (length goals) |
1736 |> Conjunction.elim_balanced (length goals) |
1735 |> Proof_Context.export names_lthy lthy |
1737 |> Proof_Context.export names_lthy lthy |
1736 |> map Thm.close_derivation |
1738 |> map Thm.close_derivation |
1737 end; |
1739 end; |
1738 |
1740 |
1762 val (assms, names_lthy) = fold_map2 mk_assms ctrAs ctrBs names_lthy; |
1764 val (assms, names_lthy) = fold_map2 mk_assms ctrAs ctrBs names_lthy; |
1763 val goal = Logic.list_implies (HOLogic.mk_Trueprop rel_Rs_a_b :: assms, thesis); |
1765 val goal = Logic.list_implies (HOLogic.mk_Trueprop rel_Rs_a_b :: assms, thesis); |
1764 val thm = |
1766 val thm = |
1765 Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, prems = _} => |
1767 Goal.prove_sorry lthy [] [] goal (fn {context = ctxt, prems = _} => |
1766 mk_rel_cases_tac ctxt (certify ctxt ta) (certify ctxt tb) exhaust injects |
1768 mk_rel_cases_tac ctxt (certify ctxt ta) (certify ctxt tb) exhaust injects |
1767 rel_inject_thms distincts rel_distinct_thms |
1769 rel_inject_thms distincts rel_distinct_thms live_nesting_rel_eqs) |
1768 (map rel_eq_of_bnf live_nesting_bnfs)) |
|
1769 |> singleton (Proof_Context.export names_lthy lthy) |
1770 |> singleton (Proof_Context.export names_lthy lthy) |
1770 |> Thm.close_derivation; |
1771 |> Thm.close_derivation; |
1771 |
1772 |
1772 val ctr_names = quasi_unambiguous_case_names (map name_of_ctr ctrAs); |
1773 val ctr_names = quasi_unambiguous_case_names (map name_of_ctr ctrAs); |
1773 val case_names_attr = Attrib.internal (K (Rule_Cases.case_names ctr_names)); |
1774 val case_names_attr = Attrib.internal (K (Rule_Cases.case_names ctr_names)); |
1857 [] |
1858 [] |
1858 else |
1859 else |
1859 Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals) |
1860 Goal.prove_sorry lthy [] [] (Logic.mk_conjunction_balanced goals) |
1860 (fn {context = ctxt, prems = _} => |
1861 (fn {context = ctxt, prems = _} => |
1861 mk_map_sel_tac ctxt (certify ctxt ta) exhaust (flat disc_thmss) map_thms |
1862 mk_map_sel_tac ctxt (certify ctxt ta) exhaust (flat disc_thmss) map_thms |
1862 (flat sel_thmss) (map map_id0_of_bnf live_nesting_bnfs)) |
1863 (flat sel_thmss) live_nesting_map_id0s) |
1863 |> Conjunction.elim_balanced (length goals) |
1864 |> Conjunction.elim_balanced (length goals) |
1864 |> Proof_Context.export names_lthy lthy |
1865 |> Proof_Context.export names_lthy lthy |
1865 |> map Thm.close_derivation |
1866 |> map Thm.close_derivation |
1866 end; |
1867 end; |
1867 |
1868 |
2000 else |
2001 else |
2001 let |
2002 let |
2002 val ((rel_induct_thms, common_rel_induct_thm), rel_induct_attrs) = |
2003 val ((rel_induct_thms, common_rel_induct_thm), rel_induct_attrs) = |
2003 derive_rel_induct_thms_for_types lthy fpTs As Bs ctrss ctr_Tsss |
2004 derive_rel_induct_thms_for_types lthy fpTs As Bs ctrss ctr_Tsss |
2004 (map #exhaust ctr_sugars) rel_xtor_co_induct_thm ctr_defss ctor_injects |
2005 (map #exhaust ctr_sugars) rel_xtor_co_induct_thm ctr_defss ctor_injects |
2005 pre_rel_defs abs_inverses (map rel_eq_of_bnf live_nesting_bnfs); |
2006 pre_rel_defs abs_inverses live_nesting_rel_eqs; |
2006 in |
2007 in |
2007 ((map single rel_induct_thms, single common_rel_induct_thm), |
2008 ((map single rel_induct_thms, single common_rel_induct_thm), |
2008 (rel_induct_attrs, rel_induct_attrs)) |
2009 (rel_induct_attrs, rel_induct_attrs)) |
2009 end; |
2010 end; |
2010 |
2011 |
2078 let |
2079 let |
2079 val ((rel_coinduct_thms, common_rel_coinduct_thm), |
2080 val ((rel_coinduct_thms, common_rel_coinduct_thm), |
2080 (rel_coinduct_attrs, common_rel_coinduct_attrs)) = |
2081 (rel_coinduct_attrs, common_rel_coinduct_attrs)) = |
2081 derive_rel_coinduct_thm_for_types lthy fpTs ns As Bs mss ctr_sugars abs_inverses |
2082 derive_rel_coinduct_thm_for_types lthy fpTs ns As Bs mss ctr_sugars abs_inverses |
2082 abs_injects ctor_injects dtor_ctors pre_rel_defs ctr_defss rel_xtor_co_induct_thm |
2083 abs_injects ctor_injects dtor_ctors pre_rel_defs ctr_defss rel_xtor_co_induct_thm |
2083 (map rel_eq_of_bnf live_nesting_bnfs) |
2084 live_nesting_rel_eqs; |
2084 in |
2085 in |
2085 ((map single rel_coinduct_thms, single common_rel_coinduct_thm), |
2086 ((map single rel_coinduct_thms, single common_rel_coinduct_thm), |
2086 (rel_coinduct_attrs, common_rel_coinduct_attrs)) |
2087 (rel_coinduct_attrs, common_rel_coinduct_attrs)) |
2087 end; |
2088 end; |
2088 |
2089 |