200 val _ = |
200 val _ = |
201 if (Thm.nprems_of quot_thm > 0) then |
201 if (Thm.nprems_of quot_thm > 0) then |
202 raise QUOT_ERROR [Pretty.block |
202 raise QUOT_ERROR [Pretty.block |
203 [Pretty.str "The Quotient theorem has extra assumptions:", |
203 [Pretty.str "The Quotient theorem has extra assumptions:", |
204 Pretty.brk 1, |
204 Pretty.brk 1, |
205 Display.pretty_thm ctxt quot_thm]] |
205 Thm.pretty_thm ctxt quot_thm]] |
206 else () |
206 else () |
207 val _ = quot_thm |> Thm.concl_of |> HOLogic.dest_Trueprop |> dest_Quotient |
207 val _ = quot_thm |> Thm.concl_of |> HOLogic.dest_Trueprop |> dest_Quotient |
208 handle TERM _ => raise QUOT_ERROR |
208 handle TERM _ => raise QUOT_ERROR |
209 [Pretty.block |
209 [Pretty.block |
210 [Pretty.str "The Quotient theorem is not of the right form:", |
210 [Pretty.str "The Quotient theorem is not of the right form:", |
211 Pretty.brk 1, |
211 Pretty.brk 1, |
212 Display.pretty_thm ctxt quot_thm]] |
212 Thm.pretty_thm ctxt quot_thm]] |
213 val ((_, [quot_thm_fixed]), ctxt') = Variable.importT [quot_thm] ctxt |
213 val ((_, [quot_thm_fixed]), ctxt') = Variable.importT [quot_thm] ctxt |
214 val (rty, qty) = quot_thm_rty_qty quot_thm_fixed |
214 val (rty, qty) = quot_thm_rty_qty quot_thm_fixed |
215 val rty_tfreesT = Term.add_tfree_namesT rty [] |
215 val rty_tfreesT = Term.add_tfree_namesT rty [] |
216 val qty_tfreesT = Term.add_tfree_namesT qty [] |
216 val qty_tfreesT = Term.add_tfree_namesT qty [] |
217 val extra_rty_tfrees = |
217 val extra_rty_tfrees = |
835 val pcr_cr_eq = #pcr_cr_eq pcr |
835 val pcr_cr_eq = #pcr_cr_eq pcr |
836 val (def_lhs, _) = Logic.dest_equals (Thm.prop_of pcrel_def) |
836 val (def_lhs, _) = Logic.dest_equals (Thm.prop_of pcrel_def) |
837 handle TERM _ => raise PCR_ERROR [Pretty.block |
837 handle TERM _ => raise PCR_ERROR [Pretty.block |
838 [Pretty.str "The pcr definiton theorem is not a plain meta equation:", |
838 [Pretty.str "The pcr definiton theorem is not a plain meta equation:", |
839 Pretty.brk 1, |
839 Pretty.brk 1, |
840 Display.pretty_thm ctxt pcrel_def]] |
840 Thm.pretty_thm ctxt pcrel_def]] |
841 val pcr_const_def = head_of def_lhs |
841 val pcr_const_def = head_of def_lhs |
842 val (eq_lhs, eq_rhs) = HOLogic.dest_eq (HOLogic.dest_Trueprop (Thm.prop_of pcr_cr_eq)) |
842 val (eq_lhs, eq_rhs) = HOLogic.dest_eq (HOLogic.dest_Trueprop (Thm.prop_of pcr_cr_eq)) |
843 handle TERM _ => raise PCR_ERROR [Pretty.block |
843 handle TERM _ => raise PCR_ERROR [Pretty.block |
844 [Pretty.str "The pcr_cr equation theorem is not a plain equation:", |
844 [Pretty.str "The pcr_cr equation theorem is not a plain equation:", |
845 Pretty.brk 1, |
845 Pretty.brk 1, |
846 Display.pretty_thm ctxt pcr_cr_eq]] |
846 Thm.pretty_thm ctxt pcr_cr_eq]] |
847 val (pcr_const_eq, eqs) = strip_comb eq_lhs |
847 val (pcr_const_eq, eqs) = strip_comb eq_lhs |
848 fun is_eq (Const (@{const_name HOL.eq}, _)) = true |
848 fun is_eq (Const (@{const_name HOL.eq}, _)) = true |
849 | is_eq _ = false |
849 | is_eq _ = false |
850 fun eq_Const (Const (name1, _)) (Const (name2, _)) = (name1 = name2) |
850 fun eq_Const (Const (name1, _)) (Const (name2, _)) = (name1 = name2) |
851 | eq_Const _ _ = false |
851 | eq_Const _ _ = false |
852 val all_eqs = if not (forall is_eq eqs) then |
852 val all_eqs = if not (forall is_eq eqs) then |
853 [Pretty.block |
853 [Pretty.block |
854 [Pretty.str "Arguments of the lhs of the pcr_cr equation theorem are not only equalities:", |
854 [Pretty.str "Arguments of the lhs of the pcr_cr equation theorem are not only equalities:", |
855 Pretty.brk 1, |
855 Pretty.brk 1, |
856 Display.pretty_thm ctxt pcr_cr_eq]] |
856 Thm.pretty_thm ctxt pcr_cr_eq]] |
857 else [] |
857 else [] |
858 val pcr_consts_not_equal = if not (eq_Const pcr_const_def pcr_const_eq) then |
858 val pcr_consts_not_equal = if not (eq_Const pcr_const_def pcr_const_eq) then |
859 [Pretty.block |
859 [Pretty.block |
860 [Pretty.str "Parametrized correspondence relation constants in pcr_def and pcr_cr_eq are not equal:", |
860 [Pretty.str "Parametrized correspondence relation constants in pcr_def and pcr_cr_eq are not equal:", |
861 Pretty.brk 1, |
861 Pretty.brk 1, |