Theorem: Rat.normalize_eq_iff
File: .lake/packages/batteries/Batteries/Data/Rat/Lemmas.lean

tactic: constructor <;> intro h
state_before: d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
⊢ normalize n₁ d₁ z₁ = normalize n₂ d₂ z₂ ↔ n₁ * ↑d₂ = n₂ * ↑d₁
state_after: case mp
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : normalize n₁ d₁ z₁ = normalize n₂ d₂ z₂
⊢ n₁ * ↑d₂ = n₂ * ↑d₁

case mpr
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : n₁ * ↑d₂ = n₂ * ↑d₁
⊢ normalize n₁ d₁ z₁ = normalize n₂ d₂ z₂

tactic: simp only [normalize_eq, mk'.injEq] at h
state_before: case mp
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : normalize n₁ d₁ z₁ = normalize n₂ d₂ z₂
⊢ n₁ * ↑d₂ = n₂ * ↑d₁
state_after: case mp
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : n₁ / ↑(n₁.natAbs.gcd d₁) = n₂ / ↑(n₂.natAbs.gcd d₂) ∧ d₁ / n₁.natAbs.gcd d₁ = d₂ / n₂.natAbs.gcd d₂
⊢ n₁ * ↑d₂ = n₂ * ↑d₁

tactic: have' hn₁ := Int.ofNat_dvd_left.2 <| Nat.gcd_dvd_left n₁.natAbs d₁
state_before: case mp
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : n₁ / ↑(n₁.natAbs.gcd d₁) = n₂ / ↑(n₂.natAbs.gcd d₂) ∧ d₁ / n₁.natAbs.gcd d₁ = d₂ / n₂.natAbs.gcd d₂
⊢ n₁ * ↑d₂ = n₂ * ↑d₁
state_after: case mp
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : n₁ / ↑(n₁.natAbs.gcd d₁) = n₂ / ↑(n₂.natAbs.gcd d₂) ∧ d₁ / n₁.natAbs.gcd d₁ = d₂ / n₂.natAbs.gcd d₂
hn₁ : ↑(n₁.natAbs.gcd d₁) ∣ n₁
⊢ n₁ * ↑d₂ = n₂ * ↑d₁

tactic: have' hn₂ := Int.ofNat_dvd_left.2 <| Nat.gcd_dvd_left n₂.natAbs d₂
state_before: case mp
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : n₁ / ↑(n₁.natAbs.gcd d₁) = n₂ / ↑(n₂.natAbs.gcd d₂) ∧ d₁ / n₁.natAbs.gcd d₁ = d₂ / n₂.natAbs.gcd d₂
hn₁ : ↑(n₁.natAbs.gcd d₁) ∣ n₁
⊢ n₁ * ↑d₂ = n₂ * ↑d₁
state_after: case mp
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : n₁ / ↑(n₁.natAbs.gcd d₁) = n₂ / ↑(n₂.natAbs.gcd d₂) ∧ d₁ / n₁.natAbs.gcd d₁ = d₂ / n₂.natAbs.gcd d₂
hn₁ : ↑(n₁.natAbs.gcd d₁) ∣ n₁
hn₂ : ↑(n₂.natAbs.gcd d₂) ∣ n₂
⊢ n₁ * ↑d₂ = n₂ * ↑d₁

tactic: have' hd₁ := Int.ofNat_dvd.2 <| Nat.gcd_dvd_right n₁.natAbs d₁
state_before: case mp
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : n₁ / ↑(n₁.natAbs.gcd d₁) = n₂ / ↑(n₂.natAbs.gcd d₂) ∧ d₁ / n₁.natAbs.gcd d₁ = d₂ / n₂.natAbs.gcd d₂
hn₁ : ↑(n₁.natAbs.gcd d₁) ∣ n₁
hn₂ : ↑(n₂.natAbs.gcd d₂) ∣ n₂
⊢ n₁ * ↑d₂ = n₂ * ↑d₁
state_after: case mp
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : n₁ / ↑(n₁.natAbs.gcd d₁) = n₂ / ↑(n₂.natAbs.gcd d₂) ∧ d₁ / n₁.natAbs.gcd d₁ = d₂ / n₂.natAbs.gcd d₂
hn₁ : ↑(n₁.natAbs.gcd d₁) ∣ n₁
hn₂ : ↑(n₂.natAbs.gcd d₂) ∣ n₂
hd₁ : ↑(n₁.natAbs.gcd d₁) ∣ ↑d₁
⊢ n₁ * ↑d₂ = n₂ * ↑d₁

tactic: have' hd₂ := Int.ofNat_dvd.2 <| Nat.gcd_dvd_right n₂.natAbs d₂
state_before: case mp
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : n₁ / ↑(n₁.natAbs.gcd d₁) = n₂ / ↑(n₂.natAbs.gcd d₂) ∧ d₁ / n₁.natAbs.gcd d₁ = d₂ / n₂.natAbs.gcd d₂
hn₁ : ↑(n₁.natAbs.gcd d₁) ∣ n₁
hn₂ : ↑(n₂.natAbs.gcd d₂) ∣ n₂
hd₁ : ↑(n₁.natAbs.gcd d₁) ∣ ↑d₁
⊢ n₁ * ↑d₂ = n₂ * ↑d₁
state_after: case mp
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : n₁ / ↑(n₁.natAbs.gcd d₁) = n₂ / ↑(n₂.natAbs.gcd d₂) ∧ d₁ / n₁.natAbs.gcd d₁ = d₂ / n₂.natAbs.gcd d₂
hn₁ : ↑(n₁.natAbs.gcd d₁) ∣ n₁
hn₂ : ↑(n₂.natAbs.gcd d₂) ∣ n₂
hd₁ : ↑(n₁.natAbs.gcd d₁) ∣ ↑d₁
hd₂ : ↑(n₂.natAbs.gcd d₂) ∣ ↑d₂
⊢ n₁ * ↑d₂ = n₂ * ↑d₁

tactic: rw [← Int.ediv_mul_cancel (Int.dvd_trans hd₂ (Int.dvd_mul_left ..)),
  Int.mul_ediv_assoc _ hd₂, ← Int.ofNat_ediv, ← h.2, Int.ofNat_ediv,
  ← Int.mul_ediv_assoc _ hd₁, Int.mul_ediv_assoc' _ hn₁,
  Int.mul_right_comm, h.1, Int.ediv_mul_cancel hn₂]
state_before: case mp
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : n₁ / ↑(n₁.natAbs.gcd d₁) = n₂ / ↑(n₂.natAbs.gcd d₂) ∧ d₁ / n₁.natAbs.gcd d₁ = d₂ / n₂.natAbs.gcd d₂
hn₁ : ↑(n₁.natAbs.gcd d₁) ∣ n₁
hn₂ : ↑(n₂.natAbs.gcd d₂) ∣ n₂
hd₁ : ↑(n₁.natAbs.gcd d₁) ∣ ↑d₁
hd₂ : ↑(n₂.natAbs.gcd d₂) ∣ ↑d₂
⊢ n₁ * ↑d₂ = n₂ * ↑d₁
state_after: no goals

tactic: rw [← normalize_mul_right _ z₂, ← normalize_mul_left z₂ z₁, Int.mul_comm d₁, h]
state_before: case mpr
d₁ d₂ : Nat
n₁ n₂ : Int
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
h : n₁ * ↑d₂ = n₂ * ↑d₁
⊢ normalize n₁ d₁ z₁ = normalize n₂ d₂ z₂
state_after: no goals