l3lab/ntp-mathlib huggingface dataset:
theorem isIntegral_algHom_iff {x : A} : IsIntegral R (f x) ↔ IsIntegral R x := 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
A : Type u_5
B : Type u_6
inst✝³ : Ring A
inst✝² : Ring B
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f : A →ₐ[R] B
hf : Function.Injective ⇑f
x : A
⊢ IsIntegral R (f x) ↔ IsIntegral R x

Next tactic:
refine ⟨fun ⟨p, hp, hx⟩ ↦ ⟨p, hp, ?_⟩, IsIntegral.map f⟩
theorem isIntegral_algHom_iff {x : A} : IsIntegral R (f x) ↔ IsIntegral R x := by
  refine ⟨fun ⟨p, hp, hx⟩ ↦ ⟨p, hp, ?_⟩, IsIntegral.map f⟩
  

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
A : Type u_5
B : Type u_6
inst✝³ : Ring A
inst✝² : Ring B
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f : A →ₐ[R] B
hf : Function.Injective ⇑f
x : A
x✝ : IsIntegral R (f x)
p : R[X]
hp : Monic p
hx : eval₂ (algebraMap R B) (f x) p = 0
⊢ eval₂ (algebraMap R A) x p = 0

Next tactic:
rwa [← f.comp_algebraMap, ← AlgHom.coe_toRingHom, ← hom_eval₂, AlgHom.coe_toRingHom,
    map_eq_zero_iff f hf] at hx
@[simp]
theorem isIntegral_algEquiv {A B : Type*} [Ring A] [Ring B] [Algebra R A] [Algebra R B]
    (f : A ≃ₐ[R] B) {x : A} : IsIntegral R (f x) ↔ IsIntegral R x :=
  ⟨fun h ↦ 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
A : Type u_5
B : Type u_6
inst✝³ : Ring A
inst✝² : Ring B
inst✝¹ : Algebra R A
inst✝ : Algebra R B
f : A ≃ₐ[R] B
x : A
h : IsIntegral R (f x)
⊢ IsIntegral R x

Next tactic:
simpa using h.map f.symm
/-- If `R → A → B` is an algebra tower,
then if the entire tower is an integral extension so is `A → B`. -/
theorem IsIntegral.tower_top [Algebra A B] [IsScalarTower R A B] {x : B}
    (hx : IsIntegral R x) : IsIntegral A x :=
  let ⟨p, hp, hpx⟩ := hx
  ⟨p.map <| algebraMap R A, hp.map _, 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
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x : B
hx : IsIntegral R x
p : R[X]
hp : Monic p
hpx : eval₂ (algebraMap R B) x p = 0
⊢ eval₂ (algebraMap A B) x (Polynomial.map (algebraMap R A) p) = 0

Next tactic:
rw [← aeval_def, aeval_map_algebraMap, aeval_def, hpx]
protected theorem IsIntegral.algebraMap [Algebra A B] [IsScalarTower R A B] {x : A}
    (h : IsIntegral R x) : IsIntegral R (algebraMap A B x) := 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
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x : A
h : IsIntegral R x
⊢ IsIntegral R ((algebraMap A B) x)

Next tactic:
rcases h with ⟨f, hf, hx⟩
protected theorem IsIntegral.algebraMap [Algebra A B] [IsScalarTower R A B] {x : A}
    (h : IsIntegral R x) : IsIntegral R (algebraMap A B x) := by
  rcases h with ⟨f, hf, hx⟩
  

Proof state:
case intro.intro
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
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x : A
f : R[X]
hf : Monic f
hx : eval₂ (algebraMap R A) x f = 0
⊢ IsIntegral R ((algebraMap A B) x)

Next tactic:
use f, hf
protected theorem IsIntegral.algebraMap [Algebra A B] [IsScalarTower R A B] {x : A}
    (h : IsIntegral R x) : IsIntegral R (algebraMap A B x) := by
  rcases h with ⟨f, hf, hx⟩
  use f, hf
  

Proof state:
case right
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
inst✝¹ : Algebra A B
inst✝ : IsScalarTower R A B
x : A
f : R[X]
hf : Monic f
hx : eval₂ (algebraMap R A) x f = 0
⊢ eval₂ (algebraMap R B) ((algebraMap A B) x) f = 0

Next tactic:
rw [IsScalarTower.algebraMap_eq R A B, ← hom_eval₂, hx, RingHom.map_zero]
theorem isIntegral_iff_isIntegral_closure_finite {r : B} :
    IsIntegral R r ↔ ∃ s : Set R, s.Finite ∧ IsIntegral (Subring.closure s) r := 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
r : B
⊢ IsIntegral R r ↔ ∃ s, Set.Finite s ∧ IsIntegral (↥(Subring.closure s)) r

Next tactic:
constructor
theorem isIntegral_iff_isIntegral_closure_finite {r : B} :
    IsIntegral R r ↔ ∃ s : Set R, s.Finite ∧ IsIntegral (Subring.closure s) r := by
  constructor <;> 

Proof state:
case mp
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
r : B
⊢ IsIntegral R r → ∃ s, Set.Finite s ∧ IsIntegral (↥(Subring.closure s)) r

Next tactic:
intro hr
theorem isIntegral_iff_isIntegral_closure_finite {r : B} :
    IsIntegral R r ↔ ∃ s : Set R, s.Finite ∧ IsIntegral (Subring.closure s) r := by
  constructor <;> 

Proof state:
case mpr
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
r : B
⊢ (∃ s, Set.Finite s ∧ IsIntegral (↥(Subring.closure s)) r) → IsIntegral R r

Next tactic:
intro hr
theorem isIntegral_iff_isIntegral_closure_finite {r : B} :
    IsIntegral R r ↔ ∃ s : Set R, s.Finite ∧ IsIntegral (Subring.closure s) r := by
  constructor <;> intro hr
  · 

Proof state:
case mp
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
r : B
hr : IsIntegral R r
⊢ ∃ s, Set.Finite s ∧ IsIntegral (↥(Subring.closure s)) r

Next tactic:
rcases hr with ⟨p, hmp, hpr⟩
theorem isIntegral_iff_isIntegral_closure_finite {r : B} :
    IsIntegral R r ↔ ∃ s : Set R, s.Finite ∧ IsIntegral (Subring.closure s) r := by
  constructor <;> intro hr
  · rcases hr with ⟨p, hmp, hpr⟩
    

Proof state:
case mp.intro.intro
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
r : B
p : R[X]
hmp : Monic p
hpr : eval₂ (algebraMap R B) r p = 0
⊢ ∃ s, Set.Finite s ∧ IsIntegral (↥(Subring.closure s)) r

Next tactic:
refine' ⟨_, Finset.finite_toSet _, p.restriction, monic_restriction.2 hmp, _⟩
theorem isIntegral_iff_isIntegral_closure_finite {r : B} :
    IsIntegral R r ↔ ∃ s : Set R, s.Finite ∧ IsIntegral (Subring.closure s) r := by
  constructor <;> intro hr
  · rcases hr with ⟨p, hmp, hpr⟩
    refine' ⟨_, Finset.finite_toSet _, p.restriction, monic_restriction.2 hmp, _⟩
    

Proof state:
case mp.intro.intro
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
r : B
p : R[X]
hmp : Monic p
hpr : eval₂ (algebraMap R B) r p = 0
⊢ eval₂ (algebraMap (↥(Subring.closure ↑(frange p))) B) r (restriction p) = 0

Next tactic:
rw [← aeval_def, ← aeval_map_algebraMap R r p.restriction, map_restriction, aeval_def, hpr]
theorem isIntegral_iff_isIntegral_closure_finite {r : B} :
    IsIntegral R r ↔ ∃ s : Set R, s.Finite ∧ IsIntegral (Subring.closure s) r := by
  constructor <;> intro hr
  · rcases hr with ⟨p, hmp, hpr⟩
    refine' ⟨_, Finset.finite_toSet _, p.restriction, monic_restriction.2 hmp, _⟩
    rw [← aeval_def, ← aeval_map_algebraMap R r p.restriction, map_restriction, aeval_def, hpr]
  

Proof state:
case mpr
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
r : B
hr : ∃ s, Set.Finite s ∧ IsIntegral (↥(Subring.closure s)) r
⊢ IsIntegral R r

Next tactic:
rcases hr with ⟨s, _, hsr⟩
theorem isIntegral_iff_isIntegral_closure_finite {r : B} :
    IsIntegral R r ↔ ∃ s : Set R, s.Finite ∧ IsIntegral (Subring.closure s) r := by
  constructor <;> intro hr
  · rcases hr with ⟨p, hmp, hpr⟩
    refine' ⟨_, Finset.finite_toSet _, p.restriction, monic_restriction.2 hmp, _⟩
    rw [← aeval_def, ← aeval_map_algebraMap R r p.restriction, map_restriction, aeval_def, hpr]
  rcases hr with ⟨s, _, hsr⟩
  

Proof state:
case mpr.intro.intro
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
r : B
s : Set R
left✝ : Set.Finite s
hsr : IsIntegral (↥(Subring.closure s)) r
⊢ IsIntegral R r

Next tactic:
exact hsr.of_subring _
theorem Submodule.span_range_natDegree_eq_adjoin {R A} [CommRing R] [Semiring A] [Algebra R A]
    {x : A} {f : R[X]} (hf : f.Monic) (hfx : aeval x f = 0) :
    span R (Finset.image (x ^ ·) (Finset.range (natDegree f))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := 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
R : Type u_5
A : Type u_6
inst✝² : CommRing R
inst✝¹ : Semiring A
inst✝ : Algebra R A
x : A
f : R[X]
hf : Monic f
hfx : (aeval x) f = 0
⊢ span R ↑(Finset.image (fun x_1 => x ^ x_1) (Finset.range (natDegree f))) =
    Subalgebra.toSubmodule (Algebra.adjoin R {x})

Next tactic:
nontriviality A
theorem Submodule.span_range_natDegree_eq_adjoin {R A} [CommRing R] [Semiring A] [Algebra R A]
    {x : A} {f : R[X]} (hf : f.Monic) (hfx : aeval x f = 0) :
    span R (Finset.image (x ^ ·) (Finset.range (natDegree f))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality A
  

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
R : Type u_5
A : Type u_6
inst✝² : CommRing R
inst✝¹ : Semiring A
inst✝ : Algebra R A
x : A
f : R[X]
hf : Monic f
hfx : (aeval x) f = 0
✝ : Nontrivial A
⊢ span R ↑(Finset.image (fun x_1 => x ^ x_1) (Finset.range (natDegree f))) =
    Subalgebra.toSubmodule (Algebra.adjoin R {x})

Next tactic:
have hf1 : f ≠ 1 := by rintro rfl; simp [one_ne_zero' A] at hfx
theorem Submodule.span_range_natDegree_eq_adjoin {R A} [CommRing R] [Semiring A] [Algebra R A]
    {x : A} {f : R[X]} (hf : f.Monic) (hfx : aeval x f = 0) :
    span R (Finset.image (x ^ ·) (Finset.range (natDegree f))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality A
  have hf1 : f ≠ 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
R : Type u_5
A : Type u_6
inst✝² : CommRing R
inst✝¹ : Semiring A
inst✝ : Algebra R A
x : A
f : R[X]
hf : Monic f
hfx : (aeval x) f = 0
✝ : Nontrivial A
⊢ f ≠ 1

Next tactic:
rintro rfl
theorem Submodule.span_range_natDegree_eq_adjoin {R A} [CommRing R] [Semiring A] [Algebra R A]
    {x : A} {f : R[X]} (hf : f.Monic) (hfx : aeval x f = 0) :
    span R (Finset.image (x ^ ·) (Finset.range (natDegree f))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality A
  have hf1 : f ≠ 1 := by rintro rfl; 

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
R : Type u_5
A : Type u_6
inst✝² : CommRing R
inst✝¹ : Semiring A
inst✝ : Algebra R A
x : A
✝ : Nontrivial A
hf : Monic 1
hfx : (aeval x) 1 = 0
⊢ False

Next tactic:
simp [one_ne_zero' A] at hfx
theorem Submodule.span_range_natDegree_eq_adjoin {R A} [CommRing R] [Semiring A] [Algebra R A]
    {x : A} {f : R[X]} (hf : f.Monic) (hfx : aeval x f = 0) :
    span R (Finset.image (x ^ ·) (Finset.range (natDegree f))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality A
  have hf1 : f ≠ 1 := by rintro rfl; simp [one_ne_zero' A] at hfx
  

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
R : Type u_5
A : Type u_6
inst✝² : CommRing R
inst✝¹ : Semiring A
inst✝ : Algebra R A
x : A
f : R[X]
hf : Monic f
hfx : (aeval x) f = 0
✝ : Nontrivial A
hf1 : f ≠ 1
⊢ span R ↑(Finset.image (fun x_1 => x ^ x_1) (Finset.range (natDegree f))) =
    Subalgebra.toSubmodule (Algebra.adjoin R {x})

Next tactic:
refine (span_le.mpr fun s hs ↦ ?_).antisymm fun r hr ↦ ?_
theorem Submodule.span_range_natDegree_eq_adjoin {R A} [CommRing R] [Semiring A] [Algebra R A]
    {x : A} {f : R[X]} (hf : f.Monic) (hfx : aeval x f = 0) :
    span R (Finset.image (x ^ ·) (Finset.range (natDegree f))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality A
  have hf1 : f ≠ 1 := by rintro rfl; simp [one_ne_zero' A] at hfx
  refine (span_le.mpr fun s hs ↦ ?_).antisymm fun r hr ↦ ?_
  · 

Proof state:
case refine_1
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
R : Type u_5
A : Type u_6
inst✝² : CommRing R
inst✝¹ : Semiring A
inst✝ : Algebra R A
x : A
f : R[X]
hf : Monic f
hfx : (aeval x) f = 0
✝ : Nontrivial A
hf1 : f ≠ 1
s : A
hs : s ∈ ↑(Finset.image (fun x_1 => x ^ x_1) (Finset.range (natDegree f)))
⊢ s ∈ ↑(Subalgebra.toSubmodule (Algebra.adjoin R {x}))

Next tactic:
rcases Finset.mem_image.1 hs with ⟨k, -, rfl⟩
theorem Submodule.span_range_natDegree_eq_adjoin {R A} [CommRing R] [Semiring A] [Algebra R A]
    {x : A} {f : R[X]} (hf : f.Monic) (hfx : aeval x f = 0) :
    span R (Finset.image (x ^ ·) (Finset.range (natDegree f))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality A
  have hf1 : f ≠ 1 := by rintro rfl; simp [one_ne_zero' A] at hfx
  refine (span_le.mpr fun s hs ↦ ?_).antisymm fun r hr ↦ ?_
  · rcases Finset.mem_image.1 hs with ⟨k, -, rfl⟩
    

Proof state:
case refine_1.intro.intro
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
R : Type u_5
A : Type u_6
inst✝² : CommRing R
inst✝¹ : Semiring A
inst✝ : Algebra R A
x : A
f : R[X]
hf : Monic f
hfx : (aeval x) f = 0
✝ : Nontrivial A
hf1 : f ≠ 1
k : ℕ
hs : x ^ k ∈ ↑(Finset.image (fun x_1 => x ^ x_1) (Finset.range (natDegree f)))
⊢ x ^ k ∈ ↑(Subalgebra.toSubmodule (Algebra.adjoin R {x}))

Next tactic:
exact (Algebra.adjoin R {x}).pow_mem (Algebra.subset_adjoin rfl) k
theorem Submodule.span_range_natDegree_eq_adjoin {R A} [CommRing R] [Semiring A] [Algebra R A]
    {x : A} {f : R[X]} (hf : f.Monic) (hfx : aeval x f = 0) :
    span R (Finset.image (x ^ ·) (Finset.range (natDegree f))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality A
  have hf1 : f ≠ 1 := by rintro rfl; simp [one_ne_zero' A] at hfx
  refine (span_le.mpr fun s hs ↦ ?_).antisymm fun r hr ↦ ?_
  · rcases Finset.mem_image.1 hs with ⟨k, -, rfl⟩
    exact (Algebra.adjoin R {x}).pow_mem (Algebra.subset_adjoin rfl) k
  

Proof state:
case refine_2
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
R : Type u_5
A : Type u_6
inst✝² : CommRing R
inst✝¹ : Semiring A
inst✝ : Algebra R A
x : A
f : R[X]
hf : Monic f
hfx : (aeval x) f = 0
✝ : Nontrivial A
hf1 : f ≠ 1
r : A
hr : r ∈ Subalgebra.toSubmodule (Algebra.adjoin R {x})
⊢ r ∈ span R ↑(Finset.image (fun x_1 => x ^ x_1) (Finset.range (natDegree f)))

Next tactic:
rw [Subalgebra.mem_toSubmodule, Algebra.adjoin_singleton_eq_range_aeval] at hr
theorem Submodule.span_range_natDegree_eq_adjoin {R A} [CommRing R] [Semiring A] [Algebra R A]
    {x : A} {f : R[X]} (hf : f.Monic) (hfx : aeval x f = 0) :
    span R (Finset.image (x ^ ·) (Finset.range (natDegree f))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality A
  have hf1 : f ≠ 1 := by rintro rfl; simp [one_ne_zero' A] at hfx
  refine (span_le.mpr fun s hs ↦ ?_).antisymm fun r hr ↦ ?_
  · rcases Finset.mem_image.1 hs with ⟨k, -, rfl⟩
    exact (Algebra.adjoin R {x}).pow_mem (Algebra.subset_adjoin rfl) k
  rw [Subalgebra.mem_toSubmodule, Algebra.adjoin_singleton_eq_range_aeval] at hr
  

Proof state:
case refine_2
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
R : Type u_5
A : Type u_6
inst✝² : CommRing R
inst✝¹ : Semiring A
inst✝ : Algebra R A
x : A
f : R[X]
hf : Monic f
hfx : (aeval x) f = 0
✝ : Nontrivial A
hf1 : f ≠ 1
r : A
hr : r ∈ AlgHom.range (aeval x)
⊢ r ∈ span R ↑(Finset.image (fun x_1 => x ^ x_1) (Finset.range (natDegree f)))

Next tactic:
rcases (aeval x).mem_range.mp hr with ⟨p, rfl⟩
theorem Submodule.span_range_natDegree_eq_adjoin {R A} [CommRing R] [Semiring A] [Algebra R A]
    {x : A} {f : R[X]} (hf : f.Monic) (hfx : aeval x f = 0) :
    span R (Finset.image (x ^ ·) (Finset.range (natDegree f))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality A
  have hf1 : f ≠ 1 := by rintro rfl; simp [one_ne_zero' A] at hfx
  refine (span_le.mpr fun s hs ↦ ?_).antisymm fun r hr ↦ ?_
  · rcases Finset.mem_image.1 hs with ⟨k, -, rfl⟩
    exact (Algebra.adjoin R {x}).pow_mem (Algebra.subset_adjoin rfl) k
  rw [Subalgebra.mem_toSubmodule, Algebra.adjoin_singleton_eq_range_aeval] at hr
  rcases (aeval x).mem_range.mp hr with ⟨p, rfl⟩
  

Proof state:
case refine_2.intro
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
R : Type u_5
A : Type u_6
inst✝² : CommRing R
inst✝¹ : Semiring A
inst✝ : Algebra R A
x : A
f : R[X]
hf : Monic f
hfx : (aeval x) f = 0
✝ : Nontrivial A
hf1 : f ≠ 1
p : R[X]
hr : (aeval x) p ∈ AlgHom.range (aeval x)
⊢ (aeval x) p ∈ span R ↑(Finset.image (fun x_1 => x ^ x_1) (Finset.range (natDegree f)))

Next tactic:
rw [← modByMonic_add_div p hf, map_add, map_mul, hfx,
      zero_mul, add_zero, ← sum_C_mul_X_pow_eq (p %ₘ f), aeval_def, eval₂_sum, sum_def]
theorem Submodule.span_range_natDegree_eq_adjoin {R A} [CommRing R] [Semiring A] [Algebra R A]
    {x : A} {f : R[X]} (hf : f.Monic) (hfx : aeval x f = 0) :
    span R (Finset.image (x ^ ·) (Finset.range (natDegree f))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality A
  have hf1 : f ≠ 1 := by rintro rfl; simp [one_ne_zero' A] at hfx
  refine (span_le.mpr fun s hs ↦ ?_).antisymm fun r hr ↦ ?_
  · rcases Finset.mem_image.1 hs with ⟨k, -, rfl⟩
    exact (Algebra.adjoin R {x}).pow_mem (Algebra.subset_adjoin rfl) k
  rw [Subalgebra.mem_toSubmodule, Algebra.adjoin_singleton_eq_range_aeval] at hr
  rcases (aeval x).mem_range.mp hr with ⟨p, rfl⟩
  rw [← modByMonic_add_div p hf, map_add, map_mul, hfx,
      zero_mul, add_zero, ← sum_C_mul_X_pow_eq (p %ₘ f), aeval_def, eval₂_sum, sum_def]
  

Proof state:
case refine_2.intro
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
R : Type u_5
A : Type u_6
inst✝² : CommRing R
inst✝¹ : Semiring A
inst✝ : Algebra R A
x : A
f : R[X]
hf : Monic f
hfx : (aeval x) f = 0
✝ : Nontrivial A
hf1 : f ≠ 1
p : R[X]
hr : (aeval x) p ∈ AlgHom.range (aeval x)
⊢ ∑ n in support (p %ₘ f), eval₂ (algebraMap R A) x (C (coeff (p %ₘ f) n) * X ^ n) ∈
    span R ↑(Finset.image (fun x_1 => x ^ x_1) (Finset.range (natDegree f)))

Next tactic:
refine sum_mem fun k hkq ↦ ?_
theorem Submodule.span_range_natDegree_eq_adjoin {R A} [CommRing R] [Semiring A] [Algebra R A]
    {x : A} {f : R[X]} (hf : f.Monic) (hfx : aeval x f = 0) :
    span R (Finset.image (x ^ ·) (Finset.range (natDegree f))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality A
  have hf1 : f ≠ 1 := by rintro rfl; simp [one_ne_zero' A] at hfx
  refine (span_le.mpr fun s hs ↦ ?_).antisymm fun r hr ↦ ?_
  · rcases Finset.mem_image.1 hs with ⟨k, -, rfl⟩
    exact (Algebra.adjoin R {x}).pow_mem (Algebra.subset_adjoin rfl) k
  rw [Subalgebra.mem_toSubmodule, Algebra.adjoin_singleton_eq_range_aeval] at hr
  rcases (aeval x).mem_range.mp hr with ⟨p, rfl⟩
  rw [← modByMonic_add_div p hf, map_add, map_mul, hfx,
      zero_mul, add_zero, ← sum_C_mul_X_pow_eq (p %ₘ f), aeval_def, eval₂_sum, sum_def]
  refine sum_mem fun k hkq ↦ ?_
  

Proof state:
case refine_2.intro
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
R : Type u_5
A : Type u_6
inst✝² : CommRing R
inst✝¹ : Semiring A
inst✝ : Algebra R A
x : A
f : R[X]
hf : Monic f
hfx : (aeval x) f = 0
✝ : Nontrivial A
hf1 : f ≠ 1
p : R[X]
hr : (aeval x) p ∈ AlgHom.range (aeval x)
k : ℕ
hkq : k ∈ support (p %ₘ f)
⊢ eval₂ (algebraMap R A) x (C (coeff (p %ₘ f) k) * X ^ k) ∈
    span R ↑(Finset.image (fun x_1 => x ^ x_1) (Finset.range (natDegree f)))

Next tactic:
rw [C_mul_X_pow_eq_monomial, eval₂_monomial, ← Algebra.smul_def]
theorem Submodule.span_range_natDegree_eq_adjoin {R A} [CommRing R] [Semiring A] [Algebra R A]
    {x : A} {f : R[X]} (hf : f.Monic) (hfx : aeval x f = 0) :
    span R (Finset.image (x ^ ·) (Finset.range (natDegree f))) =
      Subalgebra.toSubmodule (Algebra.adjoin R {x}) := by
  nontriviality A
  have hf1 : f ≠ 1 := by rintro rfl; simp [one_ne_zero' A] at hfx
  refine (span_le.mpr fun s hs ↦ ?_).antisymm fun r hr ↦ ?_
  · rcases Finset.mem_image.1 hs with ⟨k, -, rfl⟩
    exact (Algebra.adjoin R {x}).pow_mem (Algebra.subset_adjoin rfl) k
  rw [Subalgebra.mem_toSubmodule, Algebra.adjoin_singleton_eq_range_aeval] at hr
  rcases (aeval x).mem_range.mp hr with ⟨p, rfl⟩
  rw [← modByMonic_add_div p hf, map_add, map_mul, hfx,
      zero_mul, add_zero, ← sum_C_mul_X_pow_eq (p %ₘ f), aeval_def, eval₂_sum, sum_def]
  refine sum_mem fun k hkq ↦ ?_
  rw [C_mul_X_pow_eq_monomial, eval₂_monomial, ← Algebra.smul_def]
  

Proof state:
case refine_2.intro
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
R : Type u_5
A : Type u_6
inst✝² : CommRing R
inst✝¹ : Semiring A
inst✝ : Algebra R A
x : A
f : R[X]
hf : Monic f
hfx : (aeval x) f = 0
✝ : Nontrivial A
hf1 : f ≠ 1
p : R[X]
hr : (aeval x) p ∈ AlgHom.range (aeval x)
k : ℕ
hkq : k ∈ support (p %ₘ f)
⊢ coeff (p %ₘ f) k • x ^ k ∈ span R ↑(Finset.image (fun x_1 => x ^ x_1) (Finset.range (natDegree f)))

Next tactic:
exact smul_mem _ _ (subset_span <| Finset.mem_image_of_mem _ <| Finset.mem_range.mpr <|
    (le_natDegree_of_mem_supp _ hkq).trans_lt <| natDegree_modByMonic_lt p hf hf1)
theorem IsIntegral.fg_adjoin_singleton {x : B} (hx : IsIntegral R x) :
    (Algebra.adjoin R {x}).toSubmodule.FG := 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
x : B
hx : IsIntegral R x
⊢ FG (Subalgebra.toSubmodule (Algebra.adjoin R {x}))

Next tactic:
rcases hx with ⟨f, hfm, hfx⟩