theory Quotient_Rat imports HOL.Archimedean_Field "HOL-Library.Quotient_Product" begin
definition
ratrel :: "(int × int) → (int × int) → bool" (infix‹≈›50) where
[simp]: "x ≈ y ⟷ snd x ≠ 0 ∧ snd y ≠ 0 ∧ fst x * snd y = fst y * snd x"
lemma ratrel_equivp: "part_equivp ratrel" proof (auto intro!: part_equivpI reflpI sympI transpI exI[of _ "1 :: int"]) fix a b c d e f :: int assume nz: "d ≠ 0""b ≠ 0" assume y: "a * d = c * b" assume x: "c * f = e * d" thenhave"c * b * f = e * d * b"using nz by simp thenhave"a * d * f = e * d * b"using y by simp thenshow"a * f = e * b"using nz by simp qed
quotient_type rat = "int × int" / partial: ratrel using ratrel_equivp .
instantiation rat :: "{zero, one, plus, uminus, minus, times, ord, abs, sgn}" begin
fun le_rat_raw where "le_rat_raw (a :: int, b) (c, d) ⟷ (a * d) * (b * d) ≤ (c * b) * (b * d)"
quotient_definition "(≤) :: rat → rat → bool"is"le_rat_raw" proof -
{ fix a b c d e f g h :: int assume"a * f * (b * f) ≤ e * b * (b * f)" thenhave le: "a * f * b * f ≤ e * b * b * f"by simp assume nz: "b ≠ 0""d ≠ 0""f ≠ 0""h ≠ 0" thenhave b2: "b * b > 0" by (metis linorder_neqE_linordered_idom mult_eq_0_iff not_square_less_zero) have f2: "f * f > 0"using nz(3) by (metis linorder_neqE_linordered_idom mult_eq_0_iff not_square_less_zero) assume eq: "a * d = c * b""e * h = g * f" have"a * f * b * f * d * d ≤ e * b * b * f * d * d"using le nz(2) by (metis linorder_le_cases mult_right_mono mult_right_mono_neg) thenhave"c * f * f * d * (b * b) ≤ e * f * d * d * (b * b)"using eq by (metis (no_types) mult.assoc mult.commute) thenhave"c * f * f * d ≤ e * f * d * d"using b2 by (metis leD linorder_le_less_linear mult_strict_right_mono) thenhave"c * f * f * d * h * h ≤ e * f * d * d * h * h"using nz(4) by (metis linorder_le_cases mult_right_mono mult_right_mono_neg) thenhave"c * h * (d * h) * (f * f) ≤ g * d * (d * h) * (f * f)"using eq by (metis (no_types) mult.assoc mult.commute) thenhave"c * h * (d * h) ≤ g * d * (d * h)"using f2 by (metis leD linorder_le_less_linear mult_strict_right_mono)
} thenshow"∧x y xa ya. x ≈ y ==> xa ≈ ya ==> le_rat_raw x xa = le_rat_raw y ya"by auto qed
definition
less_rat_def: "(z::rat) < w = (z ≤ w ∧ z ≠ w)"
definition
rabs_rat_def: "∣i::rat∣ = (if i < 0 then - i else i)"
definition
sgn_rat_def: "sgn (i::rat) = (if i = 0 then 0 else if 0 < i then 1 else - 1)"
instance ..
end
definition
Fract_raw :: "int → int → (int × int)" where [simp]: "Fract_raw a b = (if b = 0 then (0, 1) else (a, b))"
quotient_definition "Fract :: int → int → rat"is
Fract_raw by simp
instanceproof fixq::rat assume"q\<noteq>0" thenshow"inverseq*q=1" bypartiality_descendingauto next fixqr::rat show"q/r=q*inverser"by(simpadd:divide_rat_def) next show"inverse0=(0::rat)"bypartiality_descendingauto qed
end
instantiationrat::linorder begin
instanceproof fixqrs::rat { assume"q\<le>r"and"r\<le>s" thenshow"q\<le>s" proof(partiality_descending,autosimpadd:mult.assoc[symmetric]) fixabcdef::int assumenz:"b\<noteq>0""d\<noteq>0""f\<noteq>0" thenhaved2:"d*d>0" by(metislinorder_neqE_linordered_idommult_eq_0_iffnot_square_less_zero) assumele:"a*d*b*d\<le>c*b*b*d""c*f*d*f\<le>e*d*d*f" thenhavea:"a*d*b*d*f*f\<le>c*b*b*d*f*f"usingnz(3) by(metislinorder_le_casesmult_right_monomult_right_mono_neg) have"c*f*d*f*b*b\<le>e*d*d*f*b*b"usingnz(1)le by(metislinorder_le_casesmult_right_monomult_right_mono_neg) thenhave"a*f*b*f*(d*d)\<le>e*b*b*f*(d*d)"usinga by(simpadd:algebra_simps) thenshow"a*f*b*f\<le>e*b*b*f"usingd2 by(metisleDlinorder_le_less_linearmult_strict_right_mono) qed next assume"q\<le>r"and"r\<le>q" thenshow"q=r" apply(partiality_descending,auto) apply(case_tac"b>0",case_tac[!]"ba>0") applysimp_all done next show"q\<le>q"bypartiality_descendingauto show"(q<r)=(q\<le>r\<and>\<not>r\<le>q)" unfoldingless_rat_def bypartiality_descending(autosimpadd:le_lessmult.commute) show"q\<le>r\<or>r\<le>q" bypartiality_descending(autosimpadd:mult.commutelinorder_linear) } qed
end
instancerat::archimedean_field proof fixqrs::rat show"q\<le>r==>s+q\<le>s+r" proof(partiality_descending,autosimpadd:algebra_simps,simpadd:mult.assoc[symmetric]) fixabcde::int assume"e\<noteq>0" thenhavee2:"e*e>0" by(metislinorder_neqE_linordered_idommult_eq_0_iffnot_square_less_zero) assume"a*b*d*d\<le>b*b*c*d" thenshow"a*b*d*d*e*e*e*e\<le>b*b*c*d*e*e*e*e" usinge2by(metismult_left_monomult.commutelinorder_le_cases mult_left_mono_neg) qed show"q<r==>0<s==>s*q<s*r"unfoldingless_rat_def proof(partiality_descending,autosimpadd:algebra_simps,simpadd:mult.assoc[symmetric]) fixabcdef::int assumea:"e\<noteq>0""f\<noteq>0""0\<le>e*f""a*b*d*d\<le>b*b*c*d" have"a*b*d*d*(e*f)\<le>b*b*c*d*(e*f)"usinga by(simpadd:mult_right_mono) thenshow"a*b*d*d*e*f*f*f\<le>b*b*c*d*e*f*f*f" by(simpadd:mult.assoc[symmetric])(metisa(3)mult_left_mono mult.commutemult_left_mono_negzero_le_mult_iff) qed show"\<exists>z.r\<le>of_intz" unfoldingof_int_rat proof(partiality_descending,auto) fixab::int assume"b\<noteq>0" thenhave"a*b\<le>(adivb+1)*b*b" by(metismult.commutenonzero_mult_div_cancel_leftless_int_deflinorder_le_caseszdiv_mono1zdiv_mono1_negzle_add1_eq_le) thenshow"\<exists>z::int.a*b\<le>z*b*b"byauto qed qed
*)
end
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-30)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.