Theorem: Rat.add.aux
File: .lake/packages/batteries/Batteries/Data/Rat/Basic.lean

Proof steps:
state_before: a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
⊢ let den := ad * b.den;
  let num := a.num * ↑bd + b.num * ↑ad;
  num.natAbs.gcd g = num.natAbs.gcd den
state_after: a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
⊢ num.natAbs.gcd g = num.natAbs.gcd den
tactic: intro den num
state_before: a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
⊢ num.natAbs.gcd g = num.natAbs.gcd den
state_after: a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
⊢ num.natAbs.gcd g = num.natAbs.gcd den
tactic: have ae : ad * g = a.den := had ▸ Nat.div_mul_cancel (hg ▸ Nat.gcd_dvd_left ..)
state_before: a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
⊢ num.natAbs.gcd g = num.natAbs.gcd den
state_after: a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
be : bd * g = b.den
⊢ num.natAbs.gcd g = num.natAbs.gcd den
tactic: have be : bd * g = b.den := hbd ▸ Nat.div_mul_cancel (hg ▸ Nat.gcd_dvd_right ..)
state_before: a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
be : bd * g = b.den
⊢ num.natAbs.gcd g = num.natAbs.gcd den
state_after: a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
be : bd * g = b.den
hden : den = ad * bd * g
⊢ num.natAbs.gcd g = num.natAbs.gcd den
tactic: have hden : den = ad * bd * g := by rw [Nat.mul_assoc, be]
state_before: a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
be : bd * g = b.den
hden : den = ad * bd * g
⊢ num.natAbs.gcd g = num.natAbs.gcd den
state_after: case H
a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
be : bd * g = b.den
hden : den = ad * bd * g
⊢ (ad * bd).Coprime num.natAbs
tactic: rw [hden, Nat.Coprime.gcd_mul_left_cancel_right]
state_before: case H
a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
be : bd * g = b.den
hden : den = ad * bd * g
⊢ (ad * bd).Coprime num.natAbs
state_after: case H
a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
be : bd * g = b.den
hden : den = ad * bd * g
cop : ad.Coprime bd
⊢ (ad * bd).Coprime num.natAbs
tactic: have cop : ad.Coprime bd := had ▸ hbd ▸ hg ▸
    Nat.coprime_div_gcd_div_gcd (Nat.gcd_pos_of_pos_left _ a.den_pos)
state_before: case H
a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
be : bd * g = b.den
hden : den = ad * bd * g
cop : ad.Coprime bd
⊢ (ad * bd).Coprime num.natAbs
state_after: case H
a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
be : bd * g = b.den
hden : den = ad * bd * g
cop : ad.Coprime bd
H1 : ∀ (d : Nat), d.gcd num.natAbs ∣ a.num.natAbs * bd ↔ d.gcd num.natAbs ∣ b.num.natAbs * ad
⊢ (ad * bd).Coprime num.natAbs
tactic: have H1 (d : Nat) :
      d.gcd num.natAbs ∣ a.num.natAbs * bd ↔ d.gcd num.natAbs ∣ b.num.natAbs * ad := by
    have := d.gcd_dvd_right num.natAbs
    rw [← Int.ofNat_dvd, Int.dvd_natAbs] at this
    have := Int.dvd_iff_dvd_of_dvd_add this
    rwa [← Int.dvd_natAbs, Int.ofNat_dvd, Int.natAbs_mul,
      ← Int.dvd_natAbs, Int.ofNat_dvd, Int.natAbs_mul] at this
state_before: case H
a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
be : bd * g = b.den
hden : den = ad * bd * g
cop : ad.Coprime bd
H1 : ∀ (d : Nat), d.gcd num.natAbs ∣ a.num.natAbs * bd ↔ d.gcd num.natAbs ∣ b.num.natAbs * ad
⊢ (ad * bd).Coprime num.natAbs
state_after: case H.H1
a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
be : bd * g = b.den
hden : den = ad * bd * g
cop : ad.Coprime bd
H1 : ∀ (d : Nat), d.gcd num.natAbs ∣ a.num.natAbs * bd ↔ d.gcd num.natAbs ∣ b.num.natAbs * ad
⊢ ad.Coprime num.natAbs

case H.H2
a b : Rat
g ad bd : Nat
hg : g = a.den.gcd b.den
had : ad = a.den / g
hbd : bd = b.den / g
den : Nat := ad * b.den
num : Int := a.num * ↑bd + b.num * ↑ad
ae : ad * g = a.den
be : bd * g = b.den
hden : den = ad * bd * g
cop : ad.Coprime bd
H1 : ∀ (d : Nat), d.gcd num.natAbs ∣ a.num.natAbs * bd ↔ d.gcd num.natAbs ∣ b.num.natAbs * ad
⊢ bd.Coprime num.natAbs
tactic: apply Nat.Coprime.mul