1762 Const (@{const_name HOL.eq}, extT --> extT --> HOLogic.boolT))); |
1762 Const (@{const_name HOL.eq}, extT --> extT --> HOLogic.boolT))); |
1763 fun tac ctxt eq_def = |
1763 fun tac ctxt eq_def = |
1764 Class.intro_classes_tac ctxt [] |
1764 Class.intro_classes_tac ctxt [] |
1765 THEN rewrite_goals_tac ctxt [Simpdata.mk_eq eq_def] |
1765 THEN rewrite_goals_tac ctxt [Simpdata.mk_eq eq_def] |
1766 THEN ALLGOALS (resolve_tac ctxt @{thms refl}); |
1766 THEN ALLGOALS (resolve_tac ctxt @{thms refl}); |
1767 fun mk_eq thy eq_def = |
1767 fun mk_eq ctxt eq_def = |
1768 rewrite_rule (Proof_Context.init_global thy) |
1768 rewrite_rule ctxt |
1769 [Axclass.unoverload thy (Thm.symmetric (Simpdata.mk_eq eq_def))] inject; |
1769 [Axclass.unoverload ctxt (Thm.symmetric (Simpdata.mk_eq eq_def))] inject; |
1770 fun mk_eq_refl thy = |
1770 fun mk_eq_refl ctxt = |
1771 @{thm equal_refl} |
1771 @{thm equal_refl} |
1772 |> Thm.instantiate |
1772 |> Thm.instantiate |
1773 ([((("'a", 0), @{sort equal}), Thm.global_ctyp_of thy (Logic.varifyT_global extT))], []) |
1773 ([((("'a", 0), @{sort equal}), Thm.ctyp_of ctxt (Logic.varifyT_global extT))], []) |
1774 |> Axclass.unoverload thy; |
1774 |> Axclass.unoverload ctxt; |
1775 val ensure_random_record = ensure_sort_record (@{sort random}, mk_random_eq); |
1775 val ensure_random_record = ensure_sort_record (@{sort random}, mk_random_eq); |
1776 val ensure_exhaustive_record = |
1776 val ensure_exhaustive_record = |
1777 ensure_sort_record (@{sort full_exhaustive}, mk_full_exhaustive_eq); |
1777 ensure_sort_record (@{sort full_exhaustive}, mk_full_exhaustive_eq); |
1778 in |
1778 in |
1779 thy |
1779 thy |
1783 |> `(fn lthy => Syntax.check_term lthy eq) |
1783 |> `(fn lthy => Syntax.check_term lthy eq) |
1784 |-> (fn eq => Specification.definition NONE [] (Attrib.empty_binding, eq)) |
1784 |-> (fn eq => Specification.definition NONE [] (Attrib.empty_binding, eq)) |
1785 |-> (fn (_, (_, eq_def)) => |
1785 |-> (fn (_, (_, eq_def)) => |
1786 Class.prove_instantiation_exit_result Morphism.thm tac eq_def) |
1786 Class.prove_instantiation_exit_result Morphism.thm tac eq_def) |
1787 |-> (fn eq_def => fn thy => |
1787 |-> (fn eq_def => fn thy => |
1788 thy |> Code.del_eqn eq_def |> Code.add_default_eqn (mk_eq thy eq_def)) |
1788 thy |
1789 |> (fn thy => Code.add_nbe_default_eqn (mk_eq_refl thy) thy) |
1789 |> Code.del_eqn eq_def |
|
1790 |> Code.add_default_eqn (mk_eq (Proof_Context.init_global thy) eq_def)) |
|
1791 |> (fn thy => Code.add_nbe_default_eqn (mk_eq_refl (Proof_Context.init_global thy)) thy) |
1790 |> ensure_random_record ext_tyco vs (fst ext) (binder_types (snd ext)) |
1792 |> ensure_random_record ext_tyco vs (fst ext) (binder_types (snd ext)) |
1791 |> ensure_exhaustive_record ext_tyco vs (fst ext) (binder_types (snd ext)) |
1793 |> ensure_exhaustive_record ext_tyco vs (fst ext) (binder_types (snd ext)) |
1792 end |
1794 end |
1793 else thy; |
1795 else thy; |
1794 |
1796 |