l3lab/ntp-mathlib huggingface dataset:
theorem IsIntegral.of_mul_unit {x y : B} {r : R} (hr : algebraMap R B r * y = 1)
    (hx : IsIntegral R (x * y)) : IsIntegral R x := by
  obtain ⟨p, p_monic, hp⟩ := hx
  refine ⟨scaleRoots p r, (monic_scaleRoots_iff r).2 p_monic, ?_⟩
  convert scaleRoots_aeval_eq_zero hp
  

Proof state:
case h.e'_2.h.e
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
x y : B
r : R
hr : (algebraMap R B) r * y = 1
p : R[X]
p_monic : Monic p
hp : eval₂ (algebraMap R B) (x * y) p = 0
⊢ eval₂ (algebraMap R B) x = ⇑(aeval ((algebraMap R B) r * (x * y)))

Next tactic:
rw [Algebra.commutes] at hr ⊢
theorem IsIntegral.of_mul_unit {x y : B} {r : R} (hr : algebraMap R B r * y = 1)
    (hx : IsIntegral R (x * y)) : IsIntegral R x := by
  obtain ⟨p, p_monic, hp⟩ := hx
  refine ⟨scaleRoots p r, (monic_scaleRoots_iff r).2 p_monic, ?_⟩
  convert scaleRoots_aeval_eq_zero hp
  rw [Algebra.commutes] at hr ⊢
  

Proof state:
case h.e'_2.h.e
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
x y : B
r : R
hr : y * (algebraMap R B) r = 1
p : R[X]
p_monic : Monic p
hp : eval₂ (algebraMap R B) (x * y) p = 0
⊢ eval₂ (algebraMap R B) x = ⇑(aeval (x * y * (algebraMap R B) r))

Next tactic:
rw [mul_assoc, hr, mul_one]
theorem IsIntegral.of_mul_unit {x y : B} {r : R} (hr : algebraMap R B r * y = 1)
    (hx : IsIntegral R (x * y)) : IsIntegral R x := by
  obtain ⟨p, p_monic, hp⟩ := hx
  refine ⟨scaleRoots p r, (monic_scaleRoots_iff r).2 p_monic, ?_⟩
  convert scaleRoots_aeval_eq_zero hp
  rw [Algebra.commutes] at hr ⊢
  rw [mul_assoc, hr, mul_one]; 

Proof state:
case h.e'_2.h.e
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
x y : B
r : R
hr : y * (algebraMap R B) r = 1
p : R[X]
p_monic : Monic p
hp : eval₂ (algebraMap R B) (x * y) p = 0
⊢ eval₂ (algebraMap R B) x = ⇑(aeval x)

Next tactic:
rfl
theorem IsIntegral.pow {x : B} (h : IsIntegral R x) (n : ℕ) : IsIntegral R (x ^ n) :=
  .of_mem_of_fg _ h.fg_adjoin_singleton _ <|
    Subalgebra.pow_mem _ (by 

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
x : B
h : IsIntegral R x
n : ℕ
⊢ x ∈ Algebra.adjoin R {x}

Next tactic:
exact Algebra.subset_adjoin rfl
theorem IsIntegral.det {n : Type*} [Fintype n] [DecidableEq n] {M : Matrix n n A}
    (h : ∀ i j, IsIntegral R (M i j)) : IsIntegral R M.det := by
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Ring B
inst✝⁴ : CommRing S
inst✝³ : Algebra R A
inst✝² : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
n : Type u_5
inst✝¹ : Fintype n
inst✝ : DecidableEq n
M : Matrix n n A
h : ∀ (i j : n), IsIntegral R (M i j)
⊢ IsIntegral R (Matrix.det M)

Next tactic:
rw [Matrix.det_apply]
theorem IsIntegral.det {n : Type*} [Fintype n] [DecidableEq n] {M : Matrix n n A}
    (h : ∀ i j, IsIntegral R (M i j)) : IsIntegral R M.det := by
  rw [Matrix.det_apply]
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁷ : CommRing R
inst✝⁶ : CommRing A
inst✝⁵ : Ring B
inst✝⁴ : CommRing S
inst✝³ : Algebra R A
inst✝² : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
n : Type u_5
inst✝¹ : Fintype n
inst✝ : DecidableEq n
M : Matrix n n A
h : ∀ (i j : n), IsIntegral R (M i j)
⊢ IsIntegral R (∑ σ : Equiv.Perm n, Equiv.Perm.sign σ • ∏ i : n, M (σ i) i)

Next tactic:
exact IsIntegral.sum _ fun σ _hσ ↦ (IsIntegral.prod _ fun i _hi => h _ _).zsmul _
theorem IsIntegral.tmul (x : A) {y : B} (h : IsIntegral R y) : IsIntegral A (x ⊗ₜ[R] y) := by
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
x : A
y : B
h : IsIntegral R y
⊢ IsIntegral A (x ⊗ₜ[R] y)

Next tactic:
rw [← mul_one x, ← smul_eq_mul, ← smul_tmul']
theorem IsIntegral.tmul (x : A) {y : B} (h : IsIntegral R y) : IsIntegral A (x ⊗ₜ[R] y) := by
  rw [← mul_one x, ← smul_eq_mul, ← smul_tmul']
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
x : A
y : B
h : IsIntegral R y
⊢ IsIntegral A (x • 1 ⊗ₜ[R] y)

Next tactic:
exact smul _ (h.map_of_comp_eq (algebraMap R A)
    (Algebra.TensorProduct.includeRight (R := R) (A := A) (B := B)).toRingHom
    Algebra.TensorProduct.includeLeftRingHom_comp_algebraMap)
theorem normalizeScaleRoots_coeff_mul_leadingCoeff_pow (i : ℕ) (hp : 1 ≤ natDegree p) :
    (normalizeScaleRoots p).coeff i * p.leadingCoeff ^ i =
      p.coeff i * p.leadingCoeff ^ (p.natDegree - 1) := by
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x : S
i : ℕ
hp : 1 ≤ natDegree p
⊢ coeff (normalizeScaleRoots p) i * leadingCoeff p ^ i = coeff p i * leadingCoeff p ^ (natDegree p - 1)

Next tactic:
simp only [normalizeScaleRoots, finset_sum_coeff, coeff_monomial, Finset.sum_ite_eq', one_mul,
    zero_mul, mem_support_iff, ite_mul, Ne.def, ite_not]
theorem normalizeScaleRoots_coeff_mul_leadingCoeff_pow (i : ℕ) (hp : 1 ≤ natDegree p) :
    (normalizeScaleRoots p).coeff i * p.leadingCoeff ^ i =
      p.coeff i * p.leadingCoeff ^ (p.natDegree - 1) := by
  simp only [normalizeScaleRoots, finset_sum_coeff, coeff_monomial, Finset.sum_ite_eq', one_mul,
    zero_mul, mem_support_iff, ite_mul, Ne.def, ite_not]
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x : S
i : ℕ
hp : 1 ≤ natDegree p
⊢ (if coeff p i = 0 then 0
    else
      if i = natDegree p then leadingCoeff p ^ i
      else coeff p i * leadingCoeff p ^ (natDegree p - 1 - i) * leadingCoeff p ^ i) =
    coeff p i * leadingCoeff p ^ (natDegree p - 1)

Next tactic:
split_ifs with h₁ h₂
theorem normalizeScaleRoots_coeff_mul_leadingCoeff_pow (i : ℕ) (hp : 1 ≤ natDegree p) :
    (normalizeScaleRoots p).coeff i * p.leadingCoeff ^ i =
      p.coeff i * p.leadingCoeff ^ (p.natDegree - 1) := by
  simp only [normalizeScaleRoots, finset_sum_coeff, coeff_monomial, Finset.sum_ite_eq', one_mul,
    zero_mul, mem_support_iff, ite_mul, Ne.def, ite_not]
  split_ifs with h₁ h₂
  · 

Proof state:
case pos
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x : S
i : ℕ
hp : 1 ≤ natDegree p
h₁ : coeff p i = 0
⊢ 0 = coeff p i * leadingCoeff p ^ (natDegree p - 1)

Next tactic:
simp [h₁]
theorem normalizeScaleRoots_coeff_mul_leadingCoeff_pow (i : ℕ) (hp : 1 ≤ natDegree p) :
    (normalizeScaleRoots p).coeff i * p.leadingCoeff ^ i =
      p.coeff i * p.leadingCoeff ^ (p.natDegree - 1) := by
  simp only [normalizeScaleRoots, finset_sum_coeff, coeff_monomial, Finset.sum_ite_eq', one_mul,
    zero_mul, mem_support_iff, ite_mul, Ne.def, ite_not]
  split_ifs with h₁ h₂
  · simp [h₁]
  · 

Proof state:
case pos
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x : S
i : ℕ
hp : 1 ≤ natDegree p
h₁ : ¬coeff p i = 0
h₂ : i = natDegree p
⊢ leadingCoeff p ^ i = coeff p i * leadingCoeff p ^ (natDegree p - 1)

Next tactic:
rw [h₂, leadingCoeff, ← pow_succ, tsub_add_cancel_of_le hp]
theorem normalizeScaleRoots_coeff_mul_leadingCoeff_pow (i : ℕ) (hp : 1 ≤ natDegree p) :
    (normalizeScaleRoots p).coeff i * p.leadingCoeff ^ i =
      p.coeff i * p.leadingCoeff ^ (p.natDegree - 1) := by
  simp only [normalizeScaleRoots, finset_sum_coeff, coeff_monomial, Finset.sum_ite_eq', one_mul,
    zero_mul, mem_support_iff, ite_mul, Ne.def, ite_not]
  split_ifs with h₁ h₂
  · simp [h₁]
  · rw [h₂, leadingCoeff, ← pow_succ, tsub_add_cancel_of_le hp]
  · 

Proof state:
case neg
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x : S
i : ℕ
hp : 1 ≤ natDegree p
h₁ : ¬coeff p i = 0
h₂ : ¬i = natDegree p
⊢ coeff p i * leadingCoeff p ^ (natDegree p - 1 - i) * leadingCoeff p ^ i =
    coeff p i * leadingCoeff p ^ (natDegree p - 1)

Next tactic:
rw [mul_assoc, ← pow_add, tsub_add_cancel_of_le]
theorem normalizeScaleRoots_coeff_mul_leadingCoeff_pow (i : ℕ) (hp : 1 ≤ natDegree p) :
    (normalizeScaleRoots p).coeff i * p.leadingCoeff ^ i =
      p.coeff i * p.leadingCoeff ^ (p.natDegree - 1) := by
  simp only [normalizeScaleRoots, finset_sum_coeff, coeff_monomial, Finset.sum_ite_eq', one_mul,
    zero_mul, mem_support_iff, ite_mul, Ne.def, ite_not]
  split_ifs with h₁ h₂
  · simp [h₁]
  · rw [h₂, leadingCoeff, ← pow_succ, tsub_add_cancel_of_le hp]
  · rw [mul_assoc, ← pow_add, tsub_add_cancel_of_le]
    

Proof state:
case neg
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x : S
i : ℕ
hp : 1 ≤ natDegree p
h₁ : ¬coeff p i = 0
h₂ : ¬i = natDegree p
⊢ i ≤ natDegree p - 1

Next tactic:
apply Nat.le_sub_one_of_lt
theorem normalizeScaleRoots_coeff_mul_leadingCoeff_pow (i : ℕ) (hp : 1 ≤ natDegree p) :
    (normalizeScaleRoots p).coeff i * p.leadingCoeff ^ i =
      p.coeff i * p.leadingCoeff ^ (p.natDegree - 1) := by
  simp only [normalizeScaleRoots, finset_sum_coeff, coeff_monomial, Finset.sum_ite_eq', one_mul,
    zero_mul, mem_support_iff, ite_mul, Ne.def, ite_not]
  split_ifs with h₁ h₂
  · simp [h₁]
  · rw [h₂, leadingCoeff, ← pow_succ, tsub_add_cancel_of_le hp]
  · rw [mul_assoc, ← pow_add, tsub_add_cancel_of_le]
    apply Nat.le_sub_one_of_lt
    

Proof state:
case neg.a
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x : S
i : ℕ
hp : 1 ≤ natDegree p
h₁ : ¬coeff p i = 0
h₂ : ¬i = natDegree p
⊢ i < natDegree p

Next tactic:
rw [lt_iff_le_and_ne]
theorem normalizeScaleRoots_coeff_mul_leadingCoeff_pow (i : ℕ) (hp : 1 ≤ natDegree p) :
    (normalizeScaleRoots p).coeff i * p.leadingCoeff ^ i =
      p.coeff i * p.leadingCoeff ^ (p.natDegree - 1) := by
  simp only [normalizeScaleRoots, finset_sum_coeff, coeff_monomial, Finset.sum_ite_eq', one_mul,
    zero_mul, mem_support_iff, ite_mul, Ne.def, ite_not]
  split_ifs with h₁ h₂
  · simp [h₁]
  · rw [h₂, leadingCoeff, ← pow_succ, tsub_add_cancel_of_le hp]
  · rw [mul_assoc, ← pow_add, tsub_add_cancel_of_le]
    apply Nat.le_sub_one_of_lt
    rw [lt_iff_le_and_ne]
    

Proof state:
case neg.a
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x : S
i : ℕ
hp : 1 ≤ natDegree p
h₁ : ¬coeff p i = 0
h₂ : ¬i = natDegree p
⊢ i ≤ natDegree p ∧ i ≠ natDegree p

Next tactic:
exact ⟨le_natDegree_of_ne_zero h₁, h₂⟩
theorem leadingCoeff_smul_normalizeScaleRoots (p : R[X]) :
    p.leadingCoeff • normalizeScaleRoots p = scaleRoots p p.leadingCoeff := by
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p✝ : R[X]
x : S
p : R[X]
⊢ leadingCoeff p • normalizeScaleRoots p = scaleRoots p (leadingCoeff p)

Next tactic:
ext
theorem leadingCoeff_smul_normalizeScaleRoots (p : R[X]) :
    p.leadingCoeff • normalizeScaleRoots p = scaleRoots p p.leadingCoeff := by
  ext
  

Proof state:
case a
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p✝ : R[X]
x : S
p : R[X]
n✝ : ℕ
⊢ coeff (leadingCoeff p • normalizeScaleRoots p) n✝ = coeff (scaleRoots p (leadingCoeff p)) n✝

Next tactic:
simp only [coeff_scaleRoots, normalizeScaleRoots, coeff_monomial, coeff_smul, Finset.smul_sum,
    Ne.def, Finset.sum_ite_eq', finset_sum_coeff, smul_ite, smul_zero, mem_support_iff]
theorem leadingCoeff_smul_normalizeScaleRoots (p : R[X]) :
    p.leadingCoeff • normalizeScaleRoots p = scaleRoots p p.leadingCoeff := by
  ext
  simp only [coeff_scaleRoots, normalizeScaleRoots, coeff_monomial, coeff_smul, Finset.smul_sum,
    Ne.def, Finset.sum_ite_eq', finset_sum_coeff, smul_ite, smul_zero, mem_support_iff]
  -- porting note: added the following `simp only`
  

Proof state:
case a
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p✝ : R[X]
x : S
p : R[X]
n✝ : ℕ
⊢ (∑ x in support p,
      leadingCoeff p •
        if x = n✝ then if x = natDegree p then 1 else coeff p x * leadingCoeff p ^ (natDegree p - 1 - x) else 0) =
    coeff p n✝ * leadingCoeff p ^ (natDegree p - n✝)

Next tactic:
simp only [ge_iff_le, tsub_le_iff_right, smul_eq_mul, mul_ite, mul_one, mul_zero,
    Finset.sum_ite_eq', mem_support_iff, ne_eq, ite_not]
theorem leadingCoeff_smul_normalizeScaleRoots (p : R[X]) :
    p.leadingCoeff • normalizeScaleRoots p = scaleRoots p p.leadingCoeff := by
  ext
  simp only [coeff_scaleRoots, normalizeScaleRoots, coeff_monomial, coeff_smul, Finset.smul_sum,
    Ne.def, Finset.sum_ite_eq', finset_sum_coeff, smul_ite, smul_zero, mem_support_iff]
  -- porting note: added the following `simp only`
  simp only [ge_iff_le, tsub_le_iff_right, smul_eq_mul, mul_ite, mul_one, mul_zero,
    Finset.sum_ite_eq', mem_support_iff, ne_eq, ite_not]
  

Proof state:
case a
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p✝ : R[X]
x : S
p : R[X]
n✝ : ℕ
⊢ (if coeff p n✝ = 0 then 0
    else
      if n✝ = natDegree p then leadingCoeff p
      else leadingCoeff p * (coeff p n✝ * leadingCoeff p ^ (natDegree p - 1 - n✝))) =
    coeff p n✝ * leadingCoeff p ^ (natDegree p - n✝)

Next tactic:
split_ifs with h₁ h₂
theorem leadingCoeff_smul_normalizeScaleRoots (p : R[X]) :
    p.leadingCoeff • normalizeScaleRoots p = scaleRoots p p.leadingCoeff := by
  ext
  simp only [coeff_scaleRoots, normalizeScaleRoots, coeff_monomial, coeff_smul, Finset.smul_sum,
    Ne.def, Finset.sum_ite_eq', finset_sum_coeff, smul_ite, smul_zero, mem_support_iff]
  -- porting note: added the following `simp only`
  simp only [ge_iff_le, tsub_le_iff_right, smul_eq_mul, mul_ite, mul_one, mul_zero,
    Finset.sum_ite_eq', mem_support_iff, ne_eq, ite_not]
  split_ifs with h₁ h₂
  · 

Proof state:
case pos
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p✝ : R[X]
x : S
p : R[X]
n✝ : ℕ
h₁ : coeff p n✝ = 0
⊢ 0 = coeff p n✝ * leadingCoeff p ^ (natDegree p - n✝)

Next tactic:
simp [*]
theorem leadingCoeff_smul_normalizeScaleRoots (p : R[X]) :
    p.leadingCoeff • normalizeScaleRoots p = scaleRoots p p.leadingCoeff := by
  ext
  simp only [coeff_scaleRoots, normalizeScaleRoots, coeff_monomial, coeff_smul, Finset.smul_sum,
    Ne.def, Finset.sum_ite_eq', finset_sum_coeff, smul_ite, smul_zero, mem_support_iff]
  -- porting note: added the following `simp only`
  simp only [ge_iff_le, tsub_le_iff_right, smul_eq_mul, mul_ite, mul_one, mul_zero,
    Finset.sum_ite_eq', mem_support_iff, ne_eq, ite_not]
  split_ifs with h₁ h₂
  · simp [*]
  · 

Proof state:
case pos
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p✝ : R[X]
x : S
p : R[X]
n✝ : ℕ
h₁ : ¬coeff p n✝ = 0
h₂ : n✝ = natDegree p
⊢ leadingCoeff p = coeff p n✝ * leadingCoeff p ^ (natDegree p - n✝)

Next tactic:
simp [*]
theorem leadingCoeff_smul_normalizeScaleRoots (p : R[X]) :
    p.leadingCoeff • normalizeScaleRoots p = scaleRoots p p.leadingCoeff := by
  ext
  simp only [coeff_scaleRoots, normalizeScaleRoots, coeff_monomial, coeff_smul, Finset.smul_sum,
    Ne.def, Finset.sum_ite_eq', finset_sum_coeff, smul_ite, smul_zero, mem_support_iff]
  -- porting note: added the following `simp only`
  simp only [ge_iff_le, tsub_le_iff_right, smul_eq_mul, mul_ite, mul_one, mul_zero,
    Finset.sum_ite_eq', mem_support_iff, ne_eq, ite_not]
  split_ifs with h₁ h₂
  · simp [*]
  · simp [*]
  · 

Proof state:
case neg
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p✝ : R[X]
x : S
p : R[X]
n✝ : ℕ
h₁ : ¬coeff p n✝ = 0
h₂ : ¬n✝ = natDegree p
⊢ leadingCoeff p * (coeff p n✝ * leadingCoeff p ^ (natDegree p - 1 - n✝)) =
    coeff p n✝ * leadingCoeff p ^ (natDegree p - n✝)

Next tactic:
rw [mul_comm, mul_assoc, ← pow_succ', tsub_right_comm,
      tsub_add_cancel_of_le]
theorem leadingCoeff_smul_normalizeScaleRoots (p : R[X]) :
    p.leadingCoeff • normalizeScaleRoots p = scaleRoots p p.leadingCoeff := by
  ext
  simp only [coeff_scaleRoots, normalizeScaleRoots, coeff_monomial, coeff_smul, Finset.smul_sum,
    Ne.def, Finset.sum_ite_eq', finset_sum_coeff, smul_ite, smul_zero, mem_support_iff]
  -- porting note: added the following `simp only`
  simp only [ge_iff_le, tsub_le_iff_right, smul_eq_mul, mul_ite, mul_one, mul_zero,
    Finset.sum_ite_eq', mem_support_iff, ne_eq, ite_not]
  split_ifs with h₁ h₂
  · simp [*]
  · simp [*]
  · rw [mul_comm, mul_assoc, ← pow_succ', tsub_right_comm,
      tsub_add_cancel_of_le]
    

Proof state:
case neg
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p✝ : R[X]
x : S
p : R[X]
n✝ : ℕ
h₁ : ¬coeff p n✝ = 0
h₂ : ¬n✝ = natDegree p
⊢ 1 ≤ natDegree p - n✝

Next tactic:
rw [Nat.succ_le_iff]
theorem leadingCoeff_smul_normalizeScaleRoots (p : R[X]) :
    p.leadingCoeff • normalizeScaleRoots p = scaleRoots p p.leadingCoeff := by
  ext
  simp only [coeff_scaleRoots, normalizeScaleRoots, coeff_monomial, coeff_smul, Finset.smul_sum,
    Ne.def, Finset.sum_ite_eq', finset_sum_coeff, smul_ite, smul_zero, mem_support_iff]
  -- porting note: added the following `simp only`
  simp only [ge_iff_le, tsub_le_iff_right, smul_eq_mul, mul_ite, mul_one, mul_zero,
    Finset.sum_ite_eq', mem_support_iff, ne_eq, ite_not]
  split_ifs with h₁ h₂
  · simp [*]
  · simp [*]
  · rw [mul_comm, mul_assoc, ← pow_succ', tsub_right_comm,
      tsub_add_cancel_of_le]
    rw [Nat.succ_le_iff]
    

Proof state:
case neg
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p✝ : R[X]
x : S
p : R[X]
n✝ : ℕ
h₁ : ¬coeff p n✝ = 0
h₂ : ¬n✝ = natDegree p
⊢ 0 < natDegree p - n✝

Next tactic:
exact tsub_pos_of_lt (lt_of_le_of_ne (le_natDegree_of_ne_zero h₁) h₂)
theorem normalizeScaleRoots_support : (normalizeScaleRoots p).support ≤ p.support := by
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x : S
⊢ support (normalizeScaleRoots p) ≤ support p

Next tactic:
intro x
theorem normalizeScaleRoots_support : (normalizeScaleRoots p).support ≤ p.support := by
  intro x
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x✝ : S
x : ℕ
⊢ x ∈ support (normalizeScaleRoots p) → x ∈ support p

Next tactic:
contrapose
theorem normalizeScaleRoots_support : (normalizeScaleRoots p).support ≤ p.support := by
  intro x
  contrapose
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x✝ : S
x : ℕ
⊢ x ∉ support p → x ∉ support (normalizeScaleRoots p)

Next tactic:
simp only [not_mem_support_iff, normalizeScaleRoots, finset_sum_coeff, coeff_monomial,
    Finset.sum_ite_eq', mem_support_iff, Ne.def, Classical.not_not, ite_eq_right_iff]
theorem normalizeScaleRoots_support : (normalizeScaleRoots p).support ≤ p.support := by
  intro x
  contrapose
  simp only [not_mem_support_iff, normalizeScaleRoots, finset_sum_coeff, coeff_monomial,
    Finset.sum_ite_eq', mem_support_iff, Ne.def, Classical.not_not, ite_eq_right_iff]
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x✝ : S
x : ℕ
⊢ coeff p x = 0 →
    ¬coeff p x = 0 → (if x = natDegree p then 1 else coeff p x * leadingCoeff p ^ (natDegree p - 1 - x)) = 0

Next tactic:
intro h₁ h₂
theorem normalizeScaleRoots_support : (normalizeScaleRoots p).support ≤ p.support := by
  intro x
  contrapose
  simp only [not_mem_support_iff, normalizeScaleRoots, finset_sum_coeff, coeff_monomial,
    Finset.sum_ite_eq', mem_support_iff, Ne.def, Classical.not_not, ite_eq_right_iff]
  intro h₁ h₂
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x✝ : S
x : ℕ
h₁ : coeff p x = 0
h₂ : ¬coeff p x = 0
⊢ (if x = natDegree p then 1 else coeff p x * leadingCoeff p ^ (natDegree p - 1 - x)) = 0

Next tactic:
exact (h₂ h₁).elim
theorem normalizeScaleRoots_degree : (normalizeScaleRoots p).degree = p.degree := by
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x : S
⊢ degree (normalizeScaleRoots p) = degree p

Next tactic:
apply le_antisymm
theorem normalizeScaleRoots_degree : (normalizeScaleRoots p).degree = p.degree := by
  apply le_antisymm
  · 

Proof state:
case a
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : CommRing S
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f✝¹ : R →+* S
f✝ : R →+* B
f : R →+* S
p : R[X]
x : S
⊢ degree (normalizeScaleRoots p) ≤ degree p

Next tactic:
exact Finset.sup_mono (normalizeScaleRoots_support p)