l3lab/ntp-mathlib huggingface dataset:
lemma coeff_minpolyDiv_sub_pow_mem_span {i} (hi : i ≤ natDegree (minpolyDiv R x)) :
    coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) - x ^ i ∈
      Submodule.span R ((x ^ ·) '' Set.Iio i) := by
  induction i with
  | zero => simp [(minpolyDiv_monic hx).leadingCoeff]
  | succ i IH =>
    rw [coeff_minpolyDiv, add_sub_assoc, pow_succ', ← sub_mul, Algebra.algebraMap_eq_smul_one]
    refine add_mem ?_ ?_
    · apply Submodule.smul_mem
      apply Submodule.subset_span
      exact ⟨0, Nat.zero_lt_succ _, pow_zero _⟩
    · rw [Nat.succ_eq_add_one, ← tsub_tsub, tsub_add_cancel_of_le
        (le_tsub_of_add_le_left (b := 1) hi)]
      apply SetLike.le_def.mp ?_
        (Submodule.mul_mem_mul (IH ((Nat.le_succ _).trans hi))
          (Submodule.mem_span_singleton_self x))
      rw [Submodule.span_mul_span, Set.mul_singleton, Set.image_image]
      apply Submodule.span_mono
      rintro _ ⟨j, hj : j < i, rfl⟩
      

Proof state:
case h.intro.intro
R : Type u_2
K : Type ?u.370593
L : Type ?u.370596
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
i : ℕ
IH :
  i ≤ natDegree (minpolyDiv R x) →
    coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) - x ^ i ∈
      Submodule.span R ((fun x_1 => x ^ x_1) '' Set.Iio i)
hi : Nat.succ i ≤ natDegree (minpolyDiv R x)
j : ℕ
hj : j < i
⊢ (fun x_1 => x ^ x_1 * x) j ∈ (fun x_1 => x ^ x_1) '' Set.Iio (i + 1)

Next tactic:
exact ⟨j + 1, Nat.add_lt_of_lt_sub hj, pow_succ' x j⟩
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  

Proof state:
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
⊢ Submodule.span R (Set.range (coeff (minpolyDiv R x))) = Subalgebra.toSubmodule (Algebra.adjoin R {x})

Next tactic:
nontriviality S
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  

Proof state:
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
⊢ Submodule.span R (Set.range (coeff (minpolyDiv R x))) = Subalgebra.toSubmodule (Algebra.adjoin R {x})

Next tactic:
classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    apply coeff_minpolyDiv_mem_adjoin
  · rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _),
      Submodule.span_le]
    simp only [Finset.coe_image, Finset.coe_range, Set.image_subset_iff]
    intro i
    apply Nat.strongInductionOn i
    intro i hi hi'
    have : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈
        Submodule.span R (Set.range (coeff (minpolyDiv R x))) :=
      Submodule.subset_span (Set.mem_range_self _)
    rw [Set.mem_preimage, SetLike.mem_coe, ← Submodule.sub_mem_iff_right _ this]
    refine SetLike.le_def.mp ?_ (coeff_minpolyDiv_sub_pow_mem_span hx ?_)
    · rw [Submodule.span_le, Set.image_subset_iff]
      intro j (hj : j < i)
      exact hi j hj (lt_trans hj hi')
    · rwa [← natDegree_minpolyDiv_succ hx, Set.mem_Iio, Nat.lt_succ_iff] at hi'
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  

Proof state:
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
⊢ Submodule.span R (Set.range (coeff (minpolyDiv R x))) = Subalgebra.toSubmodule (Algebra.adjoin R {x})

Next tactic:
apply le_antisymm
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · 

Proof state:
case a
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
⊢ Submodule.span R (Set.range (coeff (minpolyDiv R x))) ≤ Subalgebra.toSubmodule (Algebra.adjoin R {x})

Next tactic:
rw [Submodule.span_le]
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    

Proof state:
case a
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
⊢ Set.range (coeff (minpolyDiv R x)) ⊆ ↑(Subalgebra.toSubmodule (Algebra.adjoin R {x}))

Next tactic:
rintro _ ⟨i, rfl⟩
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    

Proof state:
case a.intro
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
i : ℕ
⊢ coeff (minpolyDiv R x) i ∈ ↑(Subalgebra.toSubmodule (Algebra.adjoin R {x}))

Next tactic:
apply coeff_minpolyDiv_mem_adjoin
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    apply coeff_minpolyDiv_mem_adjoin
  · 

Proof state:
case a
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
⊢ Subalgebra.toSubmodule (Algebra.adjoin R {x}) ≤ Submodule.span R (Set.range (coeff (minpolyDiv R x)))

Next tactic:
rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _),
      Submodule.span_le]
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    apply coeff_minpolyDiv_mem_adjoin
  · rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _),
      Submodule.span_le]
    

Proof state:
case a
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
⊢ ↑(Finset.image (fun x_1 => x ^ x_1) (Finset.range (natDegree (minpoly R x)))) ⊆
    ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))

Next tactic:
simp only [Finset.coe_image, Finset.coe_range, Set.image_subset_iff]
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    apply coeff_minpolyDiv_mem_adjoin
  · rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _),
      Submodule.span_le]
    simp only [Finset.coe_image, Finset.coe_range, Set.image_subset_iff]
    

Proof state:
case a
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
⊢ Set.Iio (natDegree (minpoly R x)) ⊆ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))

Next tactic:
intro i
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    apply coeff_minpolyDiv_mem_adjoin
  · rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _),
      Submodule.span_le]
    simp only [Finset.coe_image, Finset.coe_range, Set.image_subset_iff]
    intro i
    

Proof state:
case a
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
i : ℕ
⊢ i ∈ Set.Iio (natDegree (minpoly R x)) →
    i ∈ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))

Next tactic:
apply Nat.strongInductionOn i
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    apply coeff_minpolyDiv_mem_adjoin
  · rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _),
      Submodule.span_le]
    simp only [Finset.coe_image, Finset.coe_range, Set.image_subset_iff]
    intro i
    apply Nat.strongInductionOn i
    

Proof state:
case a
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
i : ℕ
⊢ ∀ (n : ℕ),
    (∀ m < n,
        m ∈ Set.Iio (natDegree (minpoly R x)) →
          m ∈ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))) →
      n ∈ Set.Iio (natDegree (minpoly R x)) →
        n ∈ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))

Next tactic:
intro i hi hi'
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    apply coeff_minpolyDiv_mem_adjoin
  · rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _),
      Submodule.span_le]
    simp only [Finset.coe_image, Finset.coe_range, Set.image_subset_iff]
    intro i
    apply Nat.strongInductionOn i
    intro i hi hi'
    

Proof state:
case a
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
i✝ i : ℕ
hi :
  ∀ m < i,
    m ∈ Set.Iio (natDegree (minpoly R x)) →
      m ∈ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))
hi' : i ∈ Set.Iio (natDegree (minpoly R x))
⊢ i ∈ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))

Next tactic:
have : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈
        Submodule.span R (Set.range (coeff (minpolyDiv R x))) :=
      Submodule.subset_span (Set.mem_range_self _)
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    apply coeff_minpolyDiv_mem_adjoin
  · rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _),
      Submodule.span_le]
    simp only [Finset.coe_image, Finset.coe_range, Set.image_subset_iff]
    intro i
    apply Nat.strongInductionOn i
    intro i hi hi'
    have : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈
        Submodule.span R (Set.range (coeff (minpolyDiv R x))) :=
      Submodule.subset_span (Set.mem_range_self _)
    

Proof state:
case a
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
i✝ i : ℕ
hi :
  ∀ m < i,
    m ∈ Set.Iio (natDegree (minpoly R x)) →
      m ∈ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))
hi' : i ∈ Set.Iio (natDegree (minpoly R x))
this : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈ Submodule.span R (Set.range (coeff (minpolyDiv R x)))
⊢ i ∈ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))

Next tactic:
rw [Set.mem_preimage, SetLike.mem_coe, ← Submodule.sub_mem_iff_right _ this]
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    apply coeff_minpolyDiv_mem_adjoin
  · rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _),
      Submodule.span_le]
    simp only [Finset.coe_image, Finset.coe_range, Set.image_subset_iff]
    intro i
    apply Nat.strongInductionOn i
    intro i hi hi'
    have : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈
        Submodule.span R (Set.range (coeff (minpolyDiv R x))) :=
      Submodule.subset_span (Set.mem_range_self _)
    rw [Set.mem_preimage, SetLike.mem_coe, ← Submodule.sub_mem_iff_right _ this]
    

Proof state:
case a
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
i✝ i : ℕ
hi :
  ∀ m < i,
    m ∈ Set.Iio (natDegree (minpoly R x)) →
      m ∈ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))
hi' : i ∈ Set.Iio (natDegree (minpoly R x))
this : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈ Submodule.span R (Set.range (coeff (minpolyDiv R x)))
⊢ coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) - x ^ i ∈
    Submodule.span R (Set.range (coeff (minpolyDiv R x)))

Next tactic:
refine SetLike.le_def.mp ?_ (coeff_minpolyDiv_sub_pow_mem_span hx ?_)
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    apply coeff_minpolyDiv_mem_adjoin
  · rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _),
      Submodule.span_le]
    simp only [Finset.coe_image, Finset.coe_range, Set.image_subset_iff]
    intro i
    apply Nat.strongInductionOn i
    intro i hi hi'
    have : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈
        Submodule.span R (Set.range (coeff (minpolyDiv R x))) :=
      Submodule.subset_span (Set.mem_range_self _)
    rw [Set.mem_preimage, SetLike.mem_coe, ← Submodule.sub_mem_iff_right _ this]
    refine SetLike.le_def.mp ?_ (coeff_minpolyDiv_sub_pow_mem_span hx ?_)
    · 

Proof state:
case a.refine_1
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
i✝ i : ℕ
hi :
  ∀ m < i,
    m ∈ Set.Iio (natDegree (minpoly R x)) →
      m ∈ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))
hi' : i ∈ Set.Iio (natDegree (minpoly R x))
this : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈ Submodule.span R (Set.range (coeff (minpolyDiv R x)))
⊢ Submodule.span R ((fun x_1 => x ^ x_1) '' Set.Iio i) ≤ Submodule.span R (Set.range (coeff (minpolyDiv R x)))

Next tactic:
rw [Submodule.span_le, Set.image_subset_iff]
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    apply coeff_minpolyDiv_mem_adjoin
  · rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _),
      Submodule.span_le]
    simp only [Finset.coe_image, Finset.coe_range, Set.image_subset_iff]
    intro i
    apply Nat.strongInductionOn i
    intro i hi hi'
    have : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈
        Submodule.span R (Set.range (coeff (minpolyDiv R x))) :=
      Submodule.subset_span (Set.mem_range_self _)
    rw [Set.mem_preimage, SetLike.mem_coe, ← Submodule.sub_mem_iff_right _ this]
    refine SetLike.le_def.mp ?_ (coeff_minpolyDiv_sub_pow_mem_span hx ?_)
    · rw [Submodule.span_le, Set.image_subset_iff]
      

Proof state:
case a.refine_1
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
i✝ i : ℕ
hi :
  ∀ m < i,
    m ∈ Set.Iio (natDegree (minpoly R x)) →
      m ∈ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))
hi' : i ∈ Set.Iio (natDegree (minpoly R x))
this : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈ Submodule.span R (Set.range (coeff (minpolyDiv R x)))
⊢ Set.Iio i ⊆ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))

Next tactic:
intro j (hj : j < i)
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    apply coeff_minpolyDiv_mem_adjoin
  · rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _),
      Submodule.span_le]
    simp only [Finset.coe_image, Finset.coe_range, Set.image_subset_iff]
    intro i
    apply Nat.strongInductionOn i
    intro i hi hi'
    have : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈
        Submodule.span R (Set.range (coeff (minpolyDiv R x))) :=
      Submodule.subset_span (Set.mem_range_self _)
    rw [Set.mem_preimage, SetLike.mem_coe, ← Submodule.sub_mem_iff_right _ this]
    refine SetLike.le_def.mp ?_ (coeff_minpolyDiv_sub_pow_mem_span hx ?_)
    · rw [Submodule.span_le, Set.image_subset_iff]
      intro j (hj : j < i)
      

Proof state:
case a.refine_1
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
i✝ i : ℕ
hi :
  ∀ m < i,
    m ∈ Set.Iio (natDegree (minpoly R x)) →
      m ∈ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))
hi' : i ∈ Set.Iio (natDegree (minpoly R x))
this : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈ Submodule.span R (Set.range (coeff (minpolyDiv R x)))
j : ℕ
hj : j < i
⊢ j ∈ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))

Next tactic:
exact hi j hj (lt_trans hj hi')
lemma span_coeff_minpolyDiv :
    Submodule.span R (Set.range (coeff (minpolyDiv R x))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality S
  classical
  apply le_antisymm
  · rw [Submodule.span_le]
    rintro _ ⟨i, rfl⟩
    apply coeff_minpolyDiv_mem_adjoin
  · rw [← Submodule.span_range_natDegree_eq_adjoin (minpoly.monic hx) (minpoly.aeval _ _),
      Submodule.span_le]
    simp only [Finset.coe_image, Finset.coe_range, Set.image_subset_iff]
    intro i
    apply Nat.strongInductionOn i
    intro i hi hi'
    have : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈
        Submodule.span R (Set.range (coeff (minpolyDiv R x))) :=
      Submodule.subset_span (Set.mem_range_self _)
    rw [Set.mem_preimage, SetLike.mem_coe, ← Submodule.sub_mem_iff_right _ this]
    refine SetLike.le_def.mp ?_ (coeff_minpolyDiv_sub_pow_mem_span hx ?_)
    · rw [Submodule.span_le, Set.image_subset_iff]
      intro j (hj : j < i)
      exact hi j hj (lt_trans hj hi')
    · 

Proof state:
case a.refine_2
R : Type u_2
K : Type ?u.380010
L : Type ?u.380013
S : Type u_1
inst✝⁵ : CommRing R
inst✝⁴ : Field K
inst✝³ : Field L
inst✝² : CommRing S
inst✝¹ : Algebra R S
inst✝ : Algebra K L
x : S
hx : IsIntegral R x
✝ : Nontrivial S
i✝ i : ℕ
hi :
  ∀ m < i,
    m ∈ Set.Iio (natDegree (minpoly R x)) →
      m ∈ (fun x_1 => x ^ x_1) ⁻¹' ↑(Submodule.span R (Set.range (coeff (minpolyDiv R x))))
hi' : i ∈ Set.Iio (natDegree (minpoly R x))
this : coeff (minpolyDiv R x) (natDegree (minpolyDiv R x) - i) ∈ Submodule.span R (Set.range (coeff (minpolyDiv R x)))
⊢ i ≤ natDegree (minpolyDiv R x)

Next tactic:
rwa [← natDegree_minpolyDiv_succ hx, Set.mem_Iio, Nat.lt_succ_iff] at hi'
lemma sum_smul_minpolyDiv_eq_X_pow (E) [Field E] [Algebra K E] [IsAlgClosed E]
    [FiniteDimensional K L] [IsSeparable K L]
    {x : L} (hxL : Algebra.adjoin K {x} = ⊤) {r : ℕ} (hr : r < finrank K L) :
    ∑ σ : L →ₐ[K] E, ((x ^ r / aeval x (derivative <| minpoly K x)) •
      minpolyDiv K x).map σ = (X ^ r : E[X]) := by
  

Proof state:
R : Type ?u.413236
K : Type u_2
L : Type u_3
S : Type ?u.413245
inst✝¹⁰ : CommRing R
inst✝⁹ : Field K
inst✝⁸ : Field L
inst✝⁷ : CommRing S
inst✝⁶ : Algebra R S
inst✝⁵ : Algebra K L
x✝ : S
hx : IsIntegral R x✝
E : Type u_1
inst✝⁴ : Field E
inst✝³ : Algebra K E
inst✝² : IsAlgClosed E
inst✝¹ : FiniteDimensional K L
inst✝ : IsSeparable K L
x : L
hxL : Algebra.adjoin K {x} = ⊤
r : ℕ
hr : r < finrank K L
⊢ ∑ σ : L →ₐ[K] E, map (↑σ) ((x ^ r / (aeval x) (derivative (minpoly K x))) • minpolyDiv K x) = X ^ r

Next tactic:
classical
  rw [← sub_eq_zero]
  have : Function.Injective (fun σ : L →ₐ[K] E ↦ σ x) := fun _ _ h =>
    AlgHom.ext_of_adjoin_eq_top hxL (fun _ hx ↦ hx ▸ h)
  apply Polynomial.eq_zero_of_natDegree_lt_card_of_eval_eq_zero _ this
  · intro σ
    simp only [Polynomial.map_smul, map_div₀, map_pow, RingHom.coe_coe, eval_sub, eval_finset_sum,
      eval_smul, eval_map, eval₂_minpolyDiv_self, this.eq_iff, smul_eq_mul, mul_ite, mul_zero,
      Finset.sum_ite_eq', Finset.mem_univ, ite_true, eval_pow, eval_X]
    rw [sub_eq_zero, div_mul_cancel]
    rw [ne_eq, map_eq_zero_iff σ σ.toRingHom.injective]
    exact (IsSeparable.separable _ _).aeval_derivative_ne_zero (minpoly.aeval _ _)
  · refine (Polynomial.natDegree_sub_le _ _).trans_lt
      (max_lt ((Polynomial.natDegree_sum_le _ _).trans_lt ?_) ?_)
    · simp only [AlgEquiv.toAlgHom_eq_coe, Polynomial.map_smul,
        map_div₀, map_pow, RingHom.coe_coe, AlgHom.coe_coe, Function.comp_apply,
        Finset.mem_univ, forall_true_left, true_and, Finset.fold_max_lt, AlgHom.card]
      refine ⟨finrank_pos, ?_⟩
      intro σ
      exact ((Polynomial.natDegree_smul_le _ _).trans (natDegree_map_le _ _)).trans_lt
        ((natDegree_minpolyDiv_lt (Algebra.IsIntegral.of_finite _ _ x)).trans_le
          (minpoly.natDegree_le _))
    · rwa [natDegree_pow, natDegree_X, mul_one, AlgHom.card]
lemma sum_smul_minpolyDiv_eq_X_pow (E) [Field E] [Algebra K E] [IsAlgClosed E]
    [FiniteDimensional K L] [IsSeparable K L]
    {x : L} (hxL : Algebra.adjoin K {x} = ⊤) {r : ℕ} (hr : r < finrank K L) :
    ∑ σ : L →ₐ[K] E, ((x ^ r / aeval x (derivative <| minpoly K x)) •
      minpolyDiv K x).map σ = (X ^ r : E[X]) := by
  classical
  

Proof state:
R : Type ?u.413236
K : Type u_2
L : Type u_3
S : Type ?u.413245
inst✝¹⁰ : CommRing R
inst✝⁹ : Field K
inst✝⁸ : Field L
inst✝⁷ : CommRing S
inst✝⁶ : Algebra R S
inst✝⁵ : Algebra K L
x✝ : S
hx : IsIntegral R x✝
E : Type u_1
inst✝⁴ : Field E
inst✝³ : Algebra K E
inst✝² : IsAlgClosed E
inst✝¹ : FiniteDimensional K L
inst✝ : IsSeparable K L
x : L
hxL : Algebra.adjoin K {x} = ⊤
r : ℕ
hr : r < finrank K L
⊢ ∑ σ : L →ₐ[K] E, map (↑σ) ((x ^ r / (aeval x) (derivative (minpoly K x))) • minpolyDiv K x) = X ^ r

Next tactic:
rw [← sub_eq_zero]