Skip to content

Commit

Permalink
Update Mathlib/Data/Rat/Lemmas.lean
Browse files Browse the repository at this point in the history
Co-authored-by: Bhavik Mehta <[email protected]>
  • Loading branch information
jhanschoo and b-mehta committed Dec 11, 2024
1 parent b0d3512 commit d58b085
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions Mathlib/Data/Rat/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,14 @@ theorem den_mk (n d : ℤ) : (n /. d).den = if d = 0 then 1 else d.natAbs / n.gc
if_neg (Nat.cast_add_one_ne_zero _), this]

theorem add_den_dvd_lcm (q₁ q₂ : ℚ) : (q₁ + q₂).den ∣ q₁.den.lcm q₂.den := by
rw [Rat.add_def, Rat.normalize_eq,
Nat.div_dvd_iff_dvd_mul
(Nat.gcd_dvd_right _ _)
(Nat.gcd_ne_zero_right (mul_ne_zero (Rat.den_ne_zero _) (Rat.den_ne_zero _))),
← Nat.gcd_mul_lcm,
mul_dvd_mul_iff_right (Nat.lcm_ne_zero (Rat.den_ne_zero _) (Rat.den_ne_zero _)),
Nat.dvd_gcd_iff]
constructor
· rw [← Int.natCast_dvd_natCast, Int.dvd_natAbs]
apply Int.dvd_add
<;> apply dvd_mul_of_dvd_right <;> rw [Int.natCast_dvd_natCast]
<;> [exact Nat.gcd_dvd_right _ _; exact Nat.gcd_dvd_left _ _]
· exact dvd_mul_right _ _
rw [add_def, normalize_eq, Nat.div_dvd_iff_dvd_mul (Nat.gcd_dvd_right _ _)
(Nat.gcd_ne_zero_right (by simp)), ← Nat.gcd_mul_lcm,
mul_dvd_mul_iff_right (Nat.lcm_ne_zero (by simp) (by simp)), Nat.dvd_gcd_iff]
refine ⟨?_, dvd_mul_right _ _⟩
rw [← Int.natCast_dvd_natCast, Int.dvd_natAbs]
apply Int.dvd_add
<;> apply dvd_mul_of_dvd_right <;> rw [Int.natCast_dvd_natCast]
<;> [exact Nat.gcd_dvd_right _ _; exact Nat.gcd_dvd_left _ _]

theorem add_den_dvd (q₁ q₂ : ℚ) : (q₁ + q₂).den ∣ q₁.den * q₂.den := by
rw [add_def, normalize_eq]
Expand Down

0 comments on commit d58b085

Please sign in to comment.