l3lab/ntp-mathlib huggingface dataset:
/-- `RatFunc.numDenom` are numerator and denominator of a rational function over a field,
normalized such that the denominator is monic. -/
def numDenom (x : RatFunc K) : K[X] × K[X] :=
  x.liftOn'
    (fun p q =>
      if q = 0 then ⟨0, 1⟩
      else
        let r := gcd p q
        ⟨Polynomial.C (q / r).leadingCoeff⁻¹ * (p / r),
          Polynomial.C (q / r).leadingCoeff⁻¹ * (q / r)⟩)
  (by
      intros p q a hq ha
      dsimp
      rw [if_neg hq, if_neg (mul_ne_zero ha hq)]
      have ha' : a.leadingCoeff ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr ha
      have hainv : a.leadingCoeff⁻¹ ≠ 0 := inv_ne_zero ha'
      simp only [Prod.ext_iff, gcd_mul_left, normalize_apply, Polynomial.coe_normUnit, mul_assoc,
        CommGroupWithZero.coe_normUnit _ ha']
      have hdeg : (gcd p q).degree ≤ q.degree := degree_gcd_le_right _ hq
      have hdeg' : (Polynomial.C a.leadingCoeff⁻¹ * gcd p q).degree ≤ q.degree := by
        rw [Polynomial.degree_mul, Polynomial.degree_C hainv, zero_add]
        exact hdeg
      have hdivp : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ p :=
        (C_mul_dvd hainv).mpr (gcd_dvd_left p q)
      have hdivq : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ q :=
        (C_mul_dvd hainv).mpr (gcd_dvd_right p q)
      -- porting note: added `simp only [...]` and `rw [mul_assoc]`
      -- porting note: note the unfolding of `normalize` and `normUnit`!
      simp only [normalize, normUnit, coe_normUnit, leadingCoeff_eq_zero, MonoidWithZeroHom.coe_mk,
        ZeroHom.coe_mk, ha, dite_false, Units.val_inv_eq_inv_val, Units.val_mk0]
      

Proof state:
K : Type u
inst✝ : Field K
x : RatFunc K
p q a : K[X]
hq : q ≠ 0
ha : a ≠ 0
ha' : leadingCoeff a ≠ 0
hainv : (leadingCoeff a)⁻¹ ≠ 0
hdeg : degree (gcd p q) ≤ degree q
hdeg' : degree (C (leadingCoeff a)⁻¹ * gcd p q) ≤ degree q
hdivp : C (leadingCoeff a)⁻¹ * gcd p q ∣ p
hdivq : C (leadingCoeff a)⁻¹ * gcd p q ∣ q
⊢ C (leadingCoeff (a * q / (a * C (leadingCoeff a)⁻¹ * gcd p q)))⁻¹ * (a * p / (a * C (leadingCoeff a)⁻¹ * gcd p q)) =
      C (leadingCoeff (q / gcd p q))⁻¹ * (p / gcd p q) ∧
    C (leadingCoeff (a * q / (a * C (leadingCoeff a)⁻¹ * gcd p q)))⁻¹ * (a * q / (a * C (leadingCoeff a)⁻¹ * gcd p q)) =
      C (leadingCoeff (q / gcd p q))⁻¹ * (q / gcd p q)

Next tactic:
rw [mul_assoc]
/-- `RatFunc.numDenom` are numerator and denominator of a rational function over a field,
normalized such that the denominator is monic. -/
def numDenom (x : RatFunc K) : K[X] × K[X] :=
  x.liftOn'
    (fun p q =>
      if q = 0 then ⟨0, 1⟩
      else
        let r := gcd p q
        ⟨Polynomial.C (q / r).leadingCoeff⁻¹ * (p / r),
          Polynomial.C (q / r).leadingCoeff⁻¹ * (q / r)⟩)
  (by
      intros p q a hq ha
      dsimp
      rw [if_neg hq, if_neg (mul_ne_zero ha hq)]
      have ha' : a.leadingCoeff ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr ha
      have hainv : a.leadingCoeff⁻¹ ≠ 0 := inv_ne_zero ha'
      simp only [Prod.ext_iff, gcd_mul_left, normalize_apply, Polynomial.coe_normUnit, mul_assoc,
        CommGroupWithZero.coe_normUnit _ ha']
      have hdeg : (gcd p q).degree ≤ q.degree := degree_gcd_le_right _ hq
      have hdeg' : (Polynomial.C a.leadingCoeff⁻¹ * gcd p q).degree ≤ q.degree := by
        rw [Polynomial.degree_mul, Polynomial.degree_C hainv, zero_add]
        exact hdeg
      have hdivp : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ p :=
        (C_mul_dvd hainv).mpr (gcd_dvd_left p q)
      have hdivq : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ q :=
        (C_mul_dvd hainv).mpr (gcd_dvd_right p q)
      -- porting note: added `simp only [...]` and `rw [mul_assoc]`
      -- porting note: note the unfolding of `normalize` and `normUnit`!
      simp only [normalize, normUnit, coe_normUnit, leadingCoeff_eq_zero, MonoidWithZeroHom.coe_mk,
        ZeroHom.coe_mk, ha, dite_false, Units.val_inv_eq_inv_val, Units.val_mk0]
      rw [mul_assoc]
      

Proof state:
K : Type u
inst✝ : Field K
x : RatFunc K
p q a : K[X]
hq : q ≠ 0
ha : a ≠ 0
ha' : leadingCoeff a ≠ 0
hainv : (leadingCoeff a)⁻¹ ≠ 0
hdeg : degree (gcd p q) ≤ degree q
hdeg' : degree (C (leadingCoeff a)⁻¹ * gcd p q) ≤ degree q
hdivp : C (leadingCoeff a)⁻¹ * gcd p q ∣ p
hdivq : C (leadingCoeff a)⁻¹ * gcd p q ∣ q
⊢ C (leadingCoeff (a * q / (a * (C (leadingCoeff a)⁻¹ * gcd p q))))⁻¹ *
        (a * p / (a * (C (leadingCoeff a)⁻¹ * gcd p q))) =
      C (leadingCoeff (q / gcd p q))⁻¹ * (p / gcd p q) ∧
    C (leadingCoeff (a * q / (a * (C (leadingCoeff a)⁻¹ * gcd p q))))⁻¹ *
        (a * q / (a * (C (leadingCoeff a)⁻¹ * gcd p q))) =
      C (leadingCoeff (q / gcd p q))⁻¹ * (q / gcd p q)

Next tactic:
rw [EuclideanDomain.mul_div_mul_cancel ha hdivp, EuclideanDomain.mul_div_mul_cancel ha hdivq,
        leadingCoeff_div hdeg, leadingCoeff_div hdeg', Polynomial.leadingCoeff_mul,
        Polynomial.leadingCoeff_C, div_C_mul, div_C_mul, ← mul_assoc, ← Polynomial.C_mul, ←
        mul_assoc, ← Polynomial.C_mul]
/-- `RatFunc.numDenom` are numerator and denominator of a rational function over a field,
normalized such that the denominator is monic. -/
def numDenom (x : RatFunc K) : K[X] × K[X] :=
  x.liftOn'
    (fun p q =>
      if q = 0 then ⟨0, 1⟩
      else
        let r := gcd p q
        ⟨Polynomial.C (q / r).leadingCoeff⁻¹ * (p / r),
          Polynomial.C (q / r).leadingCoeff⁻¹ * (q / r)⟩)
  (by
      intros p q a hq ha
      dsimp
      rw [if_neg hq, if_neg (mul_ne_zero ha hq)]
      have ha' : a.leadingCoeff ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr ha
      have hainv : a.leadingCoeff⁻¹ ≠ 0 := inv_ne_zero ha'
      simp only [Prod.ext_iff, gcd_mul_left, normalize_apply, Polynomial.coe_normUnit, mul_assoc,
        CommGroupWithZero.coe_normUnit _ ha']
      have hdeg : (gcd p q).degree ≤ q.degree := degree_gcd_le_right _ hq
      have hdeg' : (Polynomial.C a.leadingCoeff⁻¹ * gcd p q).degree ≤ q.degree := by
        rw [Polynomial.degree_mul, Polynomial.degree_C hainv, zero_add]
        exact hdeg
      have hdivp : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ p :=
        (C_mul_dvd hainv).mpr (gcd_dvd_left p q)
      have hdivq : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ q :=
        (C_mul_dvd hainv).mpr (gcd_dvd_right p q)
      -- porting note: added `simp only [...]` and `rw [mul_assoc]`
      -- porting note: note the unfolding of `normalize` and `normUnit`!
      simp only [normalize, normUnit, coe_normUnit, leadingCoeff_eq_zero, MonoidWithZeroHom.coe_mk,
        ZeroHom.coe_mk, ha, dite_false, Units.val_inv_eq_inv_val, Units.val_mk0]
      rw [mul_assoc]
      rw [EuclideanDomain.mul_div_mul_cancel ha hdivp, EuclideanDomain.mul_div_mul_cancel ha hdivq,
        leadingCoeff_div hdeg, leadingCoeff_div hdeg', Polynomial.leadingCoeff_mul,
        Polynomial.leadingCoeff_C, div_C_mul, div_C_mul, ← mul_assoc, ← Polynomial.C_mul, ←
        mul_assoc, ← Polynomial.C_mul]
      

Proof state:
K : Type u
inst✝ : Field K
x : RatFunc K
p q a : K[X]
hq : q ≠ 0
ha : a ≠ 0
ha' : leadingCoeff a ≠ 0
hainv : (leadingCoeff a)⁻¹ ≠ 0
hdeg : degree (gcd p q) ≤ degree q
hdeg' : degree (C (leadingCoeff a)⁻¹ * gcd p q) ≤ degree q
hdivp : C (leadingCoeff a)⁻¹ * gcd p q ∣ p
hdivq : C (leadingCoeff a)⁻¹ * gcd p q ∣ q
⊢ C ((leadingCoeff q / ((leadingCoeff a)⁻¹ * leadingCoeff (gcd p q)))⁻¹ * (leadingCoeff a)⁻¹⁻¹) * (p / gcd p q) =
      C (leadingCoeff q / leadingCoeff (gcd p q))⁻¹ * (p / gcd p q) ∧
    C ((leadingCoeff q / ((leadingCoeff a)⁻¹ * leadingCoeff (gcd p q)))⁻¹ * (leadingCoeff a)⁻¹⁻¹) * (q / gcd p q) =
      C (leadingCoeff q / leadingCoeff (gcd p q))⁻¹ * (q / gcd p q)

Next tactic:
constructor
/-- `RatFunc.numDenom` are numerator and denominator of a rational function over a field,
normalized such that the denominator is monic. -/
def numDenom (x : RatFunc K) : K[X] × K[X] :=
  x.liftOn'
    (fun p q =>
      if q = 0 then ⟨0, 1⟩
      else
        let r := gcd p q
        ⟨Polynomial.C (q / r).leadingCoeff⁻¹ * (p / r),
          Polynomial.C (q / r).leadingCoeff⁻¹ * (q / r)⟩)
  (by
      intros p q a hq ha
      dsimp
      rw [if_neg hq, if_neg (mul_ne_zero ha hq)]
      have ha' : a.leadingCoeff ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr ha
      have hainv : a.leadingCoeff⁻¹ ≠ 0 := inv_ne_zero ha'
      simp only [Prod.ext_iff, gcd_mul_left, normalize_apply, Polynomial.coe_normUnit, mul_assoc,
        CommGroupWithZero.coe_normUnit _ ha']
      have hdeg : (gcd p q).degree ≤ q.degree := degree_gcd_le_right _ hq
      have hdeg' : (Polynomial.C a.leadingCoeff⁻¹ * gcd p q).degree ≤ q.degree := by
        rw [Polynomial.degree_mul, Polynomial.degree_C hainv, zero_add]
        exact hdeg
      have hdivp : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ p :=
        (C_mul_dvd hainv).mpr (gcd_dvd_left p q)
      have hdivq : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ q :=
        (C_mul_dvd hainv).mpr (gcd_dvd_right p q)
      -- porting note: added `simp only [...]` and `rw [mul_assoc]`
      -- porting note: note the unfolding of `normalize` and `normUnit`!
      simp only [normalize, normUnit, coe_normUnit, leadingCoeff_eq_zero, MonoidWithZeroHom.coe_mk,
        ZeroHom.coe_mk, ha, dite_false, Units.val_inv_eq_inv_val, Units.val_mk0]
      rw [mul_assoc]
      rw [EuclideanDomain.mul_div_mul_cancel ha hdivp, EuclideanDomain.mul_div_mul_cancel ha hdivq,
        leadingCoeff_div hdeg, leadingCoeff_div hdeg', Polynomial.leadingCoeff_mul,
        Polynomial.leadingCoeff_C, div_C_mul, div_C_mul, ← mul_assoc, ← Polynomial.C_mul, ←
        mul_assoc, ← Polynomial.C_mul]
      constructor <;> 

Proof state:
case left
K : Type u
inst✝ : Field K
x : RatFunc K
p q a : K[X]
hq : q ≠ 0
ha : a ≠ 0
ha' : leadingCoeff a ≠ 0
hainv : (leadingCoeff a)⁻¹ ≠ 0
hdeg : degree (gcd p q) ≤ degree q
hdeg' : degree (C (leadingCoeff a)⁻¹ * gcd p q) ≤ degree q
hdivp : C (leadingCoeff a)⁻¹ * gcd p q ∣ p
hdivq : C (leadingCoeff a)⁻¹ * gcd p q ∣ q
⊢ C ((leadingCoeff q / ((leadingCoeff a)⁻¹ * leadingCoeff (gcd p q)))⁻¹ * (leadingCoeff a)⁻¹⁻¹) * (p / gcd p q) =
    C (leadingCoeff q / leadingCoeff (gcd p q))⁻¹ * (p / gcd p q)

Next tactic:
congr
/-- `RatFunc.numDenom` are numerator and denominator of a rational function over a field,
normalized such that the denominator is monic. -/
def numDenom (x : RatFunc K) : K[X] × K[X] :=
  x.liftOn'
    (fun p q =>
      if q = 0 then ⟨0, 1⟩
      else
        let r := gcd p q
        ⟨Polynomial.C (q / r).leadingCoeff⁻¹ * (p / r),
          Polynomial.C (q / r).leadingCoeff⁻¹ * (q / r)⟩)
  (by
      intros p q a hq ha
      dsimp
      rw [if_neg hq, if_neg (mul_ne_zero ha hq)]
      have ha' : a.leadingCoeff ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr ha
      have hainv : a.leadingCoeff⁻¹ ≠ 0 := inv_ne_zero ha'
      simp only [Prod.ext_iff, gcd_mul_left, normalize_apply, Polynomial.coe_normUnit, mul_assoc,
        CommGroupWithZero.coe_normUnit _ ha']
      have hdeg : (gcd p q).degree ≤ q.degree := degree_gcd_le_right _ hq
      have hdeg' : (Polynomial.C a.leadingCoeff⁻¹ * gcd p q).degree ≤ q.degree := by
        rw [Polynomial.degree_mul, Polynomial.degree_C hainv, zero_add]
        exact hdeg
      have hdivp : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ p :=
        (C_mul_dvd hainv).mpr (gcd_dvd_left p q)
      have hdivq : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ q :=
        (C_mul_dvd hainv).mpr (gcd_dvd_right p q)
      -- porting note: added `simp only [...]` and `rw [mul_assoc]`
      -- porting note: note the unfolding of `normalize` and `normUnit`!
      simp only [normalize, normUnit, coe_normUnit, leadingCoeff_eq_zero, MonoidWithZeroHom.coe_mk,
        ZeroHom.coe_mk, ha, dite_false, Units.val_inv_eq_inv_val, Units.val_mk0]
      rw [mul_assoc]
      rw [EuclideanDomain.mul_div_mul_cancel ha hdivp, EuclideanDomain.mul_div_mul_cancel ha hdivq,
        leadingCoeff_div hdeg, leadingCoeff_div hdeg', Polynomial.leadingCoeff_mul,
        Polynomial.leadingCoeff_C, div_C_mul, div_C_mul, ← mul_assoc, ← Polynomial.C_mul, ←
        mul_assoc, ← Polynomial.C_mul]
      constructor <;> 

Proof state:
case right
K : Type u
inst✝ : Field K
x : RatFunc K
p q a : K[X]
hq : q ≠ 0
ha : a ≠ 0
ha' : leadingCoeff a ≠ 0
hainv : (leadingCoeff a)⁻¹ ≠ 0
hdeg : degree (gcd p q) ≤ degree q
hdeg' : degree (C (leadingCoeff a)⁻¹ * gcd p q) ≤ degree q
hdivp : C (leadingCoeff a)⁻¹ * gcd p q ∣ p
hdivq : C (leadingCoeff a)⁻¹ * gcd p q ∣ q
⊢ C ((leadingCoeff q / ((leadingCoeff a)⁻¹ * leadingCoeff (gcd p q)))⁻¹ * (leadingCoeff a)⁻¹⁻¹) * (q / gcd p q) =
    C (leadingCoeff q / leadingCoeff (gcd p q))⁻¹ * (q / gcd p q)

Next tactic:
congr
/-- `RatFunc.numDenom` are numerator and denominator of a rational function over a field,
normalized such that the denominator is monic. -/
def numDenom (x : RatFunc K) : K[X] × K[X] :=
  x.liftOn'
    (fun p q =>
      if q = 0 then ⟨0, 1⟩
      else
        let r := gcd p q
        ⟨Polynomial.C (q / r).leadingCoeff⁻¹ * (p / r),
          Polynomial.C (q / r).leadingCoeff⁻¹ * (q / r)⟩)
  (by
      intros p q a hq ha
      dsimp
      rw [if_neg hq, if_neg (mul_ne_zero ha hq)]
      have ha' : a.leadingCoeff ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr ha
      have hainv : a.leadingCoeff⁻¹ ≠ 0 := inv_ne_zero ha'
      simp only [Prod.ext_iff, gcd_mul_left, normalize_apply, Polynomial.coe_normUnit, mul_assoc,
        CommGroupWithZero.coe_normUnit _ ha']
      have hdeg : (gcd p q).degree ≤ q.degree := degree_gcd_le_right _ hq
      have hdeg' : (Polynomial.C a.leadingCoeff⁻¹ * gcd p q).degree ≤ q.degree := by
        rw [Polynomial.degree_mul, Polynomial.degree_C hainv, zero_add]
        exact hdeg
      have hdivp : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ p :=
        (C_mul_dvd hainv).mpr (gcd_dvd_left p q)
      have hdivq : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ q :=
        (C_mul_dvd hainv).mpr (gcd_dvd_right p q)
      -- porting note: added `simp only [...]` and `rw [mul_assoc]`
      -- porting note: note the unfolding of `normalize` and `normUnit`!
      simp only [normalize, normUnit, coe_normUnit, leadingCoeff_eq_zero, MonoidWithZeroHom.coe_mk,
        ZeroHom.coe_mk, ha, dite_false, Units.val_inv_eq_inv_val, Units.val_mk0]
      rw [mul_assoc]
      rw [EuclideanDomain.mul_div_mul_cancel ha hdivp, EuclideanDomain.mul_div_mul_cancel ha hdivq,
        leadingCoeff_div hdeg, leadingCoeff_div hdeg', Polynomial.leadingCoeff_mul,
        Polynomial.leadingCoeff_C, div_C_mul, div_C_mul, ← mul_assoc, ← Polynomial.C_mul, ←
        mul_assoc, ← Polynomial.C_mul]
      constructor <;> congr <;>
        

Proof state:
case left.e_a.h.e_6.h
K : Type u
inst✝ : Field K
x : RatFunc K
p q a : K[X]
hq : q ≠ 0
ha : a ≠ 0
ha' : leadingCoeff a ≠ 0
hainv : (leadingCoeff a)⁻¹ ≠ 0
hdeg : degree (gcd p q) ≤ degree q
hdeg' : degree (C (leadingCoeff a)⁻¹ * gcd p q) ≤ degree q
hdivp : C (leadingCoeff a)⁻¹ * gcd p q ∣ p
hdivq : C (leadingCoeff a)⁻¹ * gcd p q ∣ q
⊢ (leadingCoeff q / ((leadingCoeff a)⁻¹ * leadingCoeff (gcd p q)))⁻¹ * (leadingCoeff a)⁻¹⁻¹ =
    (leadingCoeff q / leadingCoeff (gcd p q))⁻¹

Next tactic:
rw [inv_div, mul_comm, mul_div_assoc, ← mul_assoc, inv_inv, _root_.mul_inv_cancel ha',
          one_mul, inv_div]
/-- `RatFunc.numDenom` are numerator and denominator of a rational function over a field,
normalized such that the denominator is monic. -/
def numDenom (x : RatFunc K) : K[X] × K[X] :=
  x.liftOn'
    (fun p q =>
      if q = 0 then ⟨0, 1⟩
      else
        let r := gcd p q
        ⟨Polynomial.C (q / r).leadingCoeff⁻¹ * (p / r),
          Polynomial.C (q / r).leadingCoeff⁻¹ * (q / r)⟩)
  (by
      intros p q a hq ha
      dsimp
      rw [if_neg hq, if_neg (mul_ne_zero ha hq)]
      have ha' : a.leadingCoeff ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr ha
      have hainv : a.leadingCoeff⁻¹ ≠ 0 := inv_ne_zero ha'
      simp only [Prod.ext_iff, gcd_mul_left, normalize_apply, Polynomial.coe_normUnit, mul_assoc,
        CommGroupWithZero.coe_normUnit _ ha']
      have hdeg : (gcd p q).degree ≤ q.degree := degree_gcd_le_right _ hq
      have hdeg' : (Polynomial.C a.leadingCoeff⁻¹ * gcd p q).degree ≤ q.degree := by
        rw [Polynomial.degree_mul, Polynomial.degree_C hainv, zero_add]
        exact hdeg
      have hdivp : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ p :=
        (C_mul_dvd hainv).mpr (gcd_dvd_left p q)
      have hdivq : Polynomial.C a.leadingCoeff⁻¹ * gcd p q ∣ q :=
        (C_mul_dvd hainv).mpr (gcd_dvd_right p q)
      -- porting note: added `simp only [...]` and `rw [mul_assoc]`
      -- porting note: note the unfolding of `normalize` and `normUnit`!
      simp only [normalize, normUnit, coe_normUnit, leadingCoeff_eq_zero, MonoidWithZeroHom.coe_mk,
        ZeroHom.coe_mk, ha, dite_false, Units.val_inv_eq_inv_val, Units.val_mk0]
      rw [mul_assoc]
      rw [EuclideanDomain.mul_div_mul_cancel ha hdivp, EuclideanDomain.mul_div_mul_cancel ha hdivq,
        leadingCoeff_div hdeg, leadingCoeff_div hdeg', Polynomial.leadingCoeff_mul,
        Polynomial.leadingCoeff_C, div_C_mul, div_C_mul, ← mul_assoc, ← Polynomial.C_mul, ←
        mul_assoc, ← Polynomial.C_mul]
      constructor <;> congr <;>
        

Proof state:
case right.e_a.h.e_6.h
K : Type u
inst✝ : Field K
x : RatFunc K
p q a : K[X]
hq : q ≠ 0
ha : a ≠ 0
ha' : leadingCoeff a ≠ 0
hainv : (leadingCoeff a)⁻¹ ≠ 0
hdeg : degree (gcd p q) ≤ degree q
hdeg' : degree (C (leadingCoeff a)⁻¹ * gcd p q) ≤ degree q
hdivp : C (leadingCoeff a)⁻¹ * gcd p q ∣ p
hdivq : C (leadingCoeff a)⁻¹ * gcd p q ∣ q
⊢ (leadingCoeff q / ((leadingCoeff a)⁻¹ * leadingCoeff (gcd p q)))⁻¹ * (leadingCoeff a)⁻¹⁻¹ =
    (leadingCoeff q / leadingCoeff (gcd p q))⁻¹

Next tactic:
rw [inv_div, mul_comm, mul_div_assoc, ← mul_assoc, inv_inv, _root_.mul_inv_cancel ha',
          one_mul, inv_div]
@[simp]
theorem numDenom_div (p : K[X]) {q : K[X]} (hq : q ≠ 0) :
    numDenom (algebraMap _ _ p / algebraMap _ _ q) =
      (Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (p / gcd p q),
        Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (q / gcd p q)) := by
  

Proof state:
K : Type u
inst✝ : Field K
p q : K[X]
hq : q ≠ 0
⊢ numDenom ((algebraMap K[X] (RatFunc K)) p / (algebraMap K[X] (RatFunc K)) q) =
    (C (leadingCoeff (q / gcd p q))⁻¹ * (p / gcd p q), C (leadingCoeff (q / gcd p q))⁻¹ * (q / gcd p q))

Next tactic:
rw [numDenom, liftOn'_div, if_neg hq]
@[simp]
theorem numDenom_div (p : K[X]) {q : K[X]} (hq : q ≠ 0) :
    numDenom (algebraMap _ _ p / algebraMap _ _ q) =
      (Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (p / gcd p q),
        Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (q / gcd p q)) := by
  rw [numDenom, liftOn'_div, if_neg hq]
  

Proof state:
case f0
K : Type u
inst✝ : Field K
p q : K[X]
hq : q ≠ 0
⊢ ∀ (p : K[X]),
    (if 0 = 0 then (0, 1)
      else
        let r := gcd p 0;
        (C (leadingCoeff (0 / r))⁻¹ * (p / r), C (leadingCoeff (0 / r))⁻¹ * (0 / r))) =
      if 1 = 0 then (0, 1)
      else
        let r := gcd 0 1;
        (C (leadingCoeff (1 / r))⁻¹ * (0 / r), C (leadingCoeff (1 / r))⁻¹ * (1 / r))

Next tactic:
intro p
@[simp]
theorem numDenom_div (p : K[X]) {q : K[X]} (hq : q ≠ 0) :
    numDenom (algebraMap _ _ p / algebraMap _ _ q) =
      (Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (p / gcd p q),
        Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (q / gcd p q)) := by
  rw [numDenom, liftOn'_div, if_neg hq]
  intro p
  

Proof state:
case f0
K : Type u
inst✝ : Field K
p✝ q : K[X]
hq : q ≠ 0
p : K[X]
⊢ (if 0 = 0 then (0, 1)
    else
      let r := gcd p 0;
      (C (leadingCoeff (0 / r))⁻¹ * (p / r), C (leadingCoeff (0 / r))⁻¹ * (0 / r))) =
    if 1 = 0 then (0, 1)
    else
      let r := gcd 0 1;
      (C (leadingCoeff (1 / r))⁻¹ * (0 / r), C (leadingCoeff (1 / r))⁻¹ * (1 / r))

Next tactic:
rw [if_pos rfl, if_neg (one_ne_zero' K[X])]
@[simp]
theorem numDenom_div (p : K[X]) {q : K[X]} (hq : q ≠ 0) :
    numDenom (algebraMap _ _ p / algebraMap _ _ q) =
      (Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (p / gcd p q),
        Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (q / gcd p q)) := by
  rw [numDenom, liftOn'_div, if_neg hq]
  intro p
  rw [if_pos rfl, if_neg (one_ne_zero' K[X])]
  

Proof state:
case f0
K : Type u
inst✝ : Field K
p✝ q : K[X]
hq : q ≠ 0
p : K[X]
⊢ (0, 1) =
    let r := gcd 0 1;
    (C (leadingCoeff (1 / r))⁻¹ * (0 / r), C (leadingCoeff (1 / r))⁻¹ * (1 / r))

Next tactic:
simp
private theorem num_div' (p : K[X]) {q : K[X]} (hq : q ≠ 0) :
    num (algebraMap _ _ p / algebraMap _ _ q) =
      Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (p / gcd p q) := by
  

Proof state:
K : Type u
inst✝ : Field K
p q : K[X]
hq : q ≠ 0
⊢ num ((algebraMap K[X] (RatFunc K)) p / (algebraMap K[X] (RatFunc K)) q) =
    C (leadingCoeff (q / gcd p q))⁻¹ * (p / gcd p q)

Next tactic:
rw [num, numDenom_div _ hq]
@[simp]
theorem num_zero : num (0 : RatFunc K) = 0 := by 

Proof state:
K : Type u
inst✝ : Field K
⊢ num 0 = 0

Next tactic:
convert num_div' (0 : K[X]) one_ne_zero
@[simp]
theorem num_zero : num (0 : RatFunc K) = 0 := by convert num_div' (0 : K[X]) one_ne_zero <;> 

Proof state:
case h.e'_2.h.e'_3
K : Type u
inst✝ : Field K
⊢ 0 = (algebraMap K[X] (RatFunc K)) 0 / (algebraMap K[X] (RatFunc K)) 1

Next tactic:
simp
@[simp]
theorem num_zero : num (0 : RatFunc K) = 0 := by convert num_div' (0 : K[X]) one_ne_zero <;> 

Proof state:
case h.e'_3
K : Type u
inst✝ : Field K
⊢ 0 = C (leadingCoeff (1 / gcd 0 1))⁻¹ * (0 / gcd 0 1)

Next tactic:
simp
@[simp]
theorem num_div (p q : K[X]) :
    num (algebraMap _ _ p / algebraMap _ _ q) =
      Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (p / gcd p q) := by
  

Proof state:
K : Type u
inst✝ : Field K
p q : K[X]
⊢ num ((algebraMap K[X] (RatFunc K)) p / (algebraMap K[X] (RatFunc K)) q) =
    C (leadingCoeff (q / gcd p q))⁻¹ * (p / gcd p q)

Next tactic:
by_cases hq : q = 0
@[simp]
theorem num_div (p q : K[X]) :
    num (algebraMap _ _ p / algebraMap _ _ q) =
      Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (p / gcd p q) := by
  by_cases hq : q = 0
  · 

Proof state:
case pos
K : Type u
inst✝ : Field K
p q : K[X]
hq : q = 0
⊢ num ((algebraMap K[X] (RatFunc K)) p / (algebraMap K[X] (RatFunc K)) q) =
    C (leadingCoeff (q / gcd p q))⁻¹ * (p / gcd p q)

Next tactic:
simp [hq]
@[simp]
theorem num_div (p q : K[X]) :
    num (algebraMap _ _ p / algebraMap _ _ q) =
      Polynomial.C (q / gcd p q).leadingCoeff⁻¹ * (p / gcd p q) := by
  by_cases hq : q = 0
  · simp [hq]
  · 

Proof state:
case neg
K : Type u
inst✝ : Field K
p q : K[X]
hq : ¬q = 0
⊢ num ((algebraMap K[X] (RatFunc K)) p / (algebraMap K[X] (RatFunc K)) q) =
    C (leadingCoeff (q / gcd p q))⁻¹ * (p / gcd p q)

Next tactic:
exact num_div' p hq
@[simp]
theorem num_one : num (1 : RatFunc K) = 1 := by 

Proof state:
K : Type u
inst✝ : Field K
⊢ num 1 = 1

Next tactic:
convert num_div (1 : K[X]) 1
@[simp]
theorem num_one : num (1 : RatFunc K) = 1 := by convert num_div (1 : K[X]) 1 <;> 

Proof state:
case h.e'_2.h.e'_3
K : Type u
inst✝ : Field K
⊢ 1 = (algebraMap K[X] (RatFunc K)) 1 / (algebraMap K[X] (RatFunc K)) 1

Next tactic:
simp
@[simp]
theorem num_one : num (1 : RatFunc K) = 1 := by convert num_div (1 : K[X]) 1 <;> 

Proof state:
case h.e'_3
K : Type u
inst✝ : Field K
⊢ 1 = C (leadingCoeff (1 / gcd 1 1))⁻¹ * (1 / gcd 1 1)

Next tactic:
simp
@[simp]
theorem num_algebraMap (p : K[X]) : num (algebraMap _ _ p) = p := by 

Proof state:
K : Type u
inst✝ : Field K
p : K[X]
⊢ num ((algebraMap K[X] (RatFunc K)) p) = p

Next tactic:
convert num_div p 1
@[simp]
theorem num_algebraMap (p : K[X]) : num (algebraMap _ _ p) = p := by convert num_div p 1 <;> 

Proof state:
case h.e'_2.h.e'_3
K : Type u
inst✝ : Field K
p : K[X]
⊢ (algebraMap K[X] (RatFunc K)) p = (algebraMap K[X] (RatFunc K)) p / (algebraMap K[X] (RatFunc K)) 1

Next tactic:
simp
@[simp]
theorem num_algebraMap (p : K[X]) : num (algebraMap _ _ p) = p := by convert num_div p 1 <;> 

Proof state:
case h.e'_3
K : Type u
inst✝ : Field K
p : K[X]
⊢ p = C (leadingCoeff (1 / gcd p 1))⁻¹ * (p / gcd p 1)

Next tactic:
simp
theorem num_div_dvd (p : K[X]) {q : K[X]} (hq : q ≠ 0) :
    num (algebraMap _ _ p / algebraMap _ _ q) ∣ p := by
  

Proof state:
K : Type u
inst✝ : Field K
p q : K[X]
hq : q ≠ 0
⊢ num ((algebraMap K[X] (RatFunc K)) p / (algebraMap K[X] (RatFunc K)) q) ∣ p

Next tactic:
rw [num_div _ q, C_mul_dvd]
theorem num_div_dvd (p : K[X]) {q : K[X]} (hq : q ≠ 0) :
    num (algebraMap _ _ p / algebraMap _ _ q) ∣ p := by
  rw [num_div _ q, C_mul_dvd]
  · 

Proof state:
K : Type u
inst✝ : Field K
p q : K[X]
hq : q ≠ 0
⊢ p / gcd p q ∣ p

Next tactic:
exact EuclideanDomain.div_dvd_of_dvd (gcd_dvd_left p q)