Theorem: Rat.normalize_add_normalize
File: Std/Data/Rat/Lemmas.lean

tactic: cases e₁ : normalize n₁ d₁ z₁
state_before: n₁ n₂ : Int
d₁ d₂ : Nat
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
⊢ normalize n₁ d₁ + normalize n₂ d₂ = normalize (n₁ * ↑d₂ + n₂ * ↑d₁) (d₁ * d₂)

tactic: rcases normalize_num_den e₁ with ⟨g₁, zg₁, rfl, rfl⟩
state_before: case mk'
n₁ n₂ : Int
d₁ d₂ : Nat
z₁ : d₁ ≠ 0
z₂ : d₂ ≠ 0
num✝ : Int
den✝ : Nat
den_nz✝ : den✝ ≠ 0
reduced✝ : Nat.coprime (Int.natAbs num✝) den✝
e₁ : normalize n₁ d₁ = mk' num✝ den✝
⊢ mk' num✝ den✝ + normalize n₂ d₂ = normalize (n₁ * ↑d₂ + n₂ * ↑d₁) (d₁ * d₂)

tactic: cases e₂ : normalize n₂ d₂ z₂
state_before: case mk'.intro.intro.intro
n₂ : Int
d₂ : Nat
z₂ : d₂ ≠ 0
num✝ : Int
den✝ : Nat
den_nz✝ : den✝ ≠ 0
reduced✝ : Nat.coprime (Int.natAbs num✝) den✝
g₁ : Nat
zg₁ : g₁ ≠ 0
z₁ : den✝ * g₁ ≠ 0
e₁ : normalize (num✝ * ↑g₁) (den✝ * g₁) = mk' num✝ den✝
⊢ mk' num✝ den✝ + normalize n₂ d₂ = normalize (num✝ * ↑g₁ * ↑d₂ + n₂ * ↑(den✝ * g₁)) (den✝ * g₁ * d₂)

tactic: rcases normalize_num_den e₂ with ⟨g₂, zg₂, rfl, rfl⟩
state_before: case mk'.intro.intro.intro.mk'
n₂ : Int
d₂ : Nat
z₂ : d₂ ≠ 0
num✝¹ : Int
den✝¹ : Nat
den_nz✝¹ : den✝¹ ≠ 0
reduced✝¹ : Nat.coprime (Int.natAbs num✝¹) den✝¹
g₁ : Nat
zg₁ : g₁ ≠ 0
z₁ : den✝¹ * g₁ ≠ 0
e₁ : normalize (num✝¹ * ↑g₁) (den✝¹ * g₁) = mk' num✝¹ den✝¹
num✝ : Int
den✝ : Nat
den_nz✝ : den✝ ≠ 0
reduced✝ : Nat.coprime (Int.natAbs num✝) den✝
e₂ : normalize n₂ d₂ = mk' num✝ den✝
⊢ mk' num✝¹ den✝¹ + mk' num✝ den✝ = normalize (num✝¹ * ↑g₁ * ↑d₂ + n₂ * ↑(den✝¹ * g₁)) (den✝¹ * g₁ * d₂)

tactic: simp only [add_def]
state_before: case mk'.intro.intro.intro.mk'.intro.intro.intro
num✝¹ : Int
den✝¹ : Nat
den_nz✝¹ : den✝¹ ≠ 0
reduced✝¹ : Nat.coprime (Int.natAbs num✝¹) den✝¹
g₁ : Nat
zg₁ : g₁ ≠ 0
z₁ : den✝¹ * g₁ ≠ 0
e₁ : normalize (num✝¹ * ↑g₁) (den✝¹ * g₁) = mk' num✝¹ den✝¹
num✝ : Int
den✝ : Nat
den_nz✝ : den✝ ≠ 0
reduced✝ : Nat.coprime (Int.natAbs num✝) den✝
g₂ : Nat
zg₂ : g₂ ≠ 0
z₂ : den✝ * g₂ ≠ 0
e₂ : normalize (num✝ * ↑g₂) (den✝ * g₂) = mk' num✝ den✝
⊢ mk' num✝¹ den✝¹ + mk' num✝ den✝ =
    normalize (num✝¹ * ↑g₁ * ↑(den✝ * g₂) + num✝ * ↑g₂ * ↑(den✝¹ * g₁)) (den✝¹ * g₁ * (den✝ * g₂))

tactic: rw [← normalize_mul_right _ (Nat.mul_ne_zero zg₁ zg₂)]
state_before: case mk'.intro.intro.intro.mk'.intro.intro.intro
num✝¹ : Int
den✝¹ : Nat
den_nz✝¹ : den✝¹ ≠ 0
reduced✝¹ : Nat.coprime (Int.natAbs num✝¹) den✝¹
g₁ : Nat
zg₁ : g₁ ≠ 0
z₁ : den✝¹ * g₁ ≠ 0
e₁ : normalize (num✝¹ * ↑g₁) (den✝¹ * g₁) = mk' num✝¹ den✝¹
num✝ : Int
den✝ : Nat
den_nz✝ : den✝ ≠ 0
reduced✝ : Nat.coprime (Int.natAbs num✝) den✝
g₂ : Nat
zg₂ : g₂ ≠ 0
z₂ : den✝ * g₂ ≠ 0
e₂ : normalize (num✝ * ↑g₂) (den✝ * g₂) = mk' num✝ den✝
⊢ normalize (num✝¹ * ↑den✝ + num✝ * ↑den✝¹) (den✝¹ * den✝) =
    normalize (num✝¹ * ↑g₁ * ↑(den✝ * g₂) + num✝ * ↑g₂ * ↑(den✝¹ * g₁)) (den✝¹ * g₁ * (den✝ * g₂))

tactic: congr 1
state_before: case mk'.intro.intro.intro.mk'.intro.intro.intro
num✝¹ : Int
den✝¹ : Nat
den_nz✝¹ : den✝¹ ≠ 0
reduced✝¹ : Nat.coprime (Int.natAbs num✝¹) den✝¹
g₁ : Nat
zg₁ : g₁ ≠ 0
z₁ : den✝¹ * g₁ ≠ 0
e₁ : normalize (num✝¹ * ↑g₁) (den✝¹ * g₁) = mk' num✝¹ den✝¹
num✝ : Int
den✝ : Nat
den_nz✝ : den✝ ≠ 0
reduced✝ : Nat.coprime (Int.natAbs num✝) den✝
g₂ : Nat
zg₂ : g₂ ≠ 0
z₂ : den✝ * g₂ ≠ 0
e₂ : normalize (num✝ * ↑g₂) (den✝ * g₂) = mk' num✝ den✝
⊢ normalize ((num✝¹ * ↑den✝ + num✝ * ↑den✝¹) * ↑(g₁ * g₂)) (den✝¹ * den✝ * (g₁ * g₂)) =
    normalize (num✝¹ * ↑g₁ * ↑(den✝ * g₂) + num✝ * ↑g₂ * ↑(den✝¹ * g₁)) (den✝¹ * g₁ * (den✝ * g₂))

tactic: rw [Int.add_mul]
state_before: case mk'.intro.intro.intro.mk'.intro.intro.intro.e_num
num✝¹ : Int
den✝¹ : Nat
den_nz✝¹ : den✝¹ ≠ 0
reduced✝¹ : Nat.coprime (Int.natAbs num✝¹) den✝¹
g₁ : Nat
zg₁ : g₁ ≠ 0
z₁ : den✝¹ * g₁ ≠ 0
e₁ : normalize (num✝¹ * ↑g₁) (den✝¹ * g₁) = mk' num✝¹ den✝¹
num✝ : Int
den✝ : Nat
den_nz✝ : den✝ ≠ 0
reduced✝ : Nat.coprime (Int.natAbs num✝) den✝
g₂ : Nat
zg₂ : g₂ ≠ 0
z₂ : den✝ * g₂ ≠ 0
e₂ : normalize (num✝ * ↑g₂) (den✝ * g₂) = mk' num✝ den✝
⊢ (num✝¹ * ↑den✝ + num✝ * ↑den✝¹) * ↑(g₁ * g₂) = num✝¹ * ↑g₁ * ↑(den✝ * g₂) + num✝ * ↑g₂ * ↑(den✝¹ * g₁)

tactic: simp [Int.ofNat_mul, Int.mul_assoc, Int.mul_left_comm, Int.mul_comm]
state_before: case mk'.intro.intro.intro.mk'.intro.intro.intro.e_num
num✝¹ : Int
den✝¹ : Nat
den_nz✝¹ : den✝¹ ≠ 0
reduced✝¹ : Nat.coprime (Int.natAbs num✝¹) den✝¹
g₁ : Nat
zg₁ : g₁ ≠ 0
z₁ : den✝¹ * g₁ ≠ 0
e₁ : normalize (num✝¹ * ↑g₁) (den✝¹ * g₁) = mk' num✝¹ den✝¹
num✝ : Int
den✝ : Nat
den_nz✝ : den✝ ≠ 0
reduced✝ : Nat.coprime (Int.natAbs num✝) den✝
g₂ : Nat
zg₂ : g₂ ≠ 0
z₂ : den✝ * g₂ ≠ 0
e₂ : normalize (num✝ * ↑g₂) (den✝ * g₂) = mk' num✝ den✝
⊢ num✝¹ * ↑den✝ * ↑(g₁ * g₂) + num✝ * ↑den✝¹ * ↑(g₁ * g₂) = num✝¹ * ↑g₁ * ↑(den✝ * g₂) + num✝ * ↑g₂ * ↑(den✝¹ * g₁)

tactic: simp [Nat.mul_left_comm, Nat.mul_comm]
state_before: case mk'.intro.intro.intro.mk'.intro.intro.intro.e_den
num✝¹ : Int
den✝¹ : Nat
den_nz✝¹ : den✝¹ ≠ 0
reduced✝¹ : Nat.coprime (Int.natAbs num✝¹) den✝¹
g₁ : Nat
zg₁ : g₁ ≠ 0
z₁ : den✝¹ * g₁ ≠ 0
e₁ : normalize (num✝¹ * ↑g₁) (den✝¹ * g₁) = mk' num✝¹ den✝¹
num✝ : Int
den✝ : Nat
den_nz✝ : den✝ ≠ 0
reduced✝ : Nat.coprime (Int.natAbs num✝) den✝
g₂ : Nat
zg₂ : g₂ ≠ 0
z₂ : den✝ * g₂ ≠ 0
e₂ : normalize (num✝ * ↑g₂) (den✝ * g₂) = mk' num✝ den✝
⊢ den✝¹ * den✝ * (g₁ * g₂) = den✝¹ * g₁ * (den✝ * g₂)