l3lab/ntp-mathlib huggingface dataset:
/-- If A is an R-algebra all of whose elements are integral over R,
and x is an element of an A-algebra that is integral over A, then x is integral over R.-/
theorem isIntegral_trans (A_int : Algebra.IsIntegral R A) (x : B) (hx : IsIntegral A x) :
    IsIntegral R x := by
  rcases hx with ⟨p, pmonic, hp⟩
  let S := adjoin R (p.frange : Set A)
  have : Module.Finite R S := ⟨(Subalgebra.toSubmodule S).fg_top.mpr <|
    fg_adjoin_of_finite p.frange.finite_toSet fun a _ ↦ A_int a⟩
  let p' : S[X] := p.toSubring S.toSubring subset_adjoin
  have hSx : IsIntegral S x := ⟨p', (p.monic_toSubring _ _).mpr pmonic, by
    rw [IsScalarTower.algebraMap_eq S A B, ← eval₂_map]
    

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S✝
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S✝
g : S✝ →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
A_int : Algebra.IsIntegral R A
x : B
p : A[X]
pmonic : Monic p
hp : eval₂ (algebraMap A B) x p = 0
S : Subalgebra R A := adjoin R ↑(frange p)
this : Module.Finite R ↥S
p' : (↥S)[X] := toSubring p (Subalgebra.toSubring S) (_ : ↑(frange p) ⊆ ↑(adjoin R ↑(frange p)))
⊢ eval₂ (algebraMap A B) x (Polynomial.map (algebraMap (↥S) A) p') = 0

Next tactic:
convert hp
/-- If A is an R-algebra all of whose elements are integral over R,
and x is an element of an A-algebra that is integral over A, then x is integral over R.-/
theorem isIntegral_trans (A_int : Algebra.IsIntegral R A) (x : B) (hx : IsIntegral A x) :
    IsIntegral R x := by
  rcases hx with ⟨p, pmonic, hp⟩
  let S := adjoin R (p.frange : Set A)
  have : Module.Finite R S := ⟨(Subalgebra.toSubmodule S).fg_top.mpr <|
    fg_adjoin_of_finite p.frange.finite_toSet fun a _ ↦ A_int a⟩
  let p' : S[X] := p.toSubring S.toSubring subset_adjoin
  have hSx : IsIntegral S x := ⟨p', (p.monic_toSubring _ _).mpr pmonic, by
    rw [IsScalarTower.algebraMap_eq S A B, ← eval₂_map]
    convert hp; 

Proof state:
case h.e'_2.h.e'_7
R : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S✝
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S✝
g : S✝ →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
A_int : Algebra.IsIntegral R A
x : B
p : A[X]
pmonic : Monic p
hp : eval₂ (algebraMap A B) x p = 0
S : Subalgebra R A := adjoin R ↑(frange p)
this : Module.Finite R ↥S
p' : (↥S)[X] := toSubring p (Subalgebra.toSubring S) (_ : ↑(frange p) ⊆ ↑(adjoin R ↑(frange p)))
⊢ Polynomial.map (algebraMap (↥S) A) p' = p

Next tactic:
apply p.map_toSubring S.toSubring
/-- If A is an R-algebra all of whose elements are integral over R,
and x is an element of an A-algebra that is integral over A, then x is integral over R.-/
theorem isIntegral_trans (A_int : Algebra.IsIntegral R A) (x : B) (hx : IsIntegral A x) :
    IsIntegral R x := by
  rcases hx with ⟨p, pmonic, hp⟩
  let S := adjoin R (p.frange : Set A)
  have : Module.Finite R S := ⟨(Subalgebra.toSubmodule S).fg_top.mpr <|
    fg_adjoin_of_finite p.frange.finite_toSet fun a _ ↦ A_int a⟩
  let p' : S[X] := p.toSubring S.toSubring subset_adjoin
  have hSx : IsIntegral S x := ⟨p', (p.monic_toSubring _ _).mpr pmonic, by
    rw [IsScalarTower.algebraMap_eq S A B, ← eval₂_map]
    convert hp; apply p.map_toSubring S.toSubring⟩
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S✝
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S✝
g : S✝ →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
A_int : Algebra.IsIntegral R A
x : B
p : A[X]
pmonic : Monic p
hp : eval₂ (algebraMap A B) x p = 0
S : Subalgebra R A := adjoin R ↑(frange p)
this : Module.Finite R ↥S
p' : (↥S)[X] := toSubring p (Subalgebra.toSubring S) (_ : ↑(frange p) ⊆ ↑(adjoin R ↑(frange p)))
hSx : IsIntegral (↥S) x
⊢ IsIntegral R x

Next tactic:
let Sx := Subalgebra.toSubmodule (adjoin S {x})
/-- If A is an R-algebra all of whose elements are integral over R,
and x is an element of an A-algebra that is integral over A, then x is integral over R.-/
theorem isIntegral_trans (A_int : Algebra.IsIntegral R A) (x : B) (hx : IsIntegral A x) :
    IsIntegral R x := by
  rcases hx with ⟨p, pmonic, hp⟩
  let S := adjoin R (p.frange : Set A)
  have : Module.Finite R S := ⟨(Subalgebra.toSubmodule S).fg_top.mpr <|
    fg_adjoin_of_finite p.frange.finite_toSet fun a _ ↦ A_int a⟩
  let p' : S[X] := p.toSubring S.toSubring subset_adjoin
  have hSx : IsIntegral S x := ⟨p', (p.monic_toSubring _ _).mpr pmonic, by
    rw [IsScalarTower.algebraMap_eq S A B, ← eval₂_map]
    convert hp; apply p.map_toSubring S.toSubring⟩
  let Sx := Subalgebra.toSubmodule (adjoin S {x})
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S✝
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S✝
g : S✝ →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
A_int : Algebra.IsIntegral R A
x : B
p : A[X]
pmonic : Monic p
hp : eval₂ (algebraMap A B) x p = 0
S : Subalgebra R A := adjoin R ↑(frange p)
this : Module.Finite R ↥S
p' : (↥S)[X] := toSubring p (Subalgebra.toSubring S) (_ : ↑(frange p) ⊆ ↑(adjoin R ↑(frange p)))
hSx : IsIntegral (↥S) x
Sx : Submodule (↥S) B := Subalgebra.toSubmodule (adjoin ↥S {x})
⊢ IsIntegral R x

Next tactic:
let MSx : Module S Sx := SMulMemClass.toModule _
/-- If A is an R-algebra all of whose elements are integral over R,
and x is an element of an A-algebra that is integral over A, then x is integral over R.-/
theorem isIntegral_trans (A_int : Algebra.IsIntegral R A) (x : B) (hx : IsIntegral A x) :
    IsIntegral R x := by
  rcases hx with ⟨p, pmonic, hp⟩
  let S := adjoin R (p.frange : Set A)
  have : Module.Finite R S := ⟨(Subalgebra.toSubmodule S).fg_top.mpr <|
    fg_adjoin_of_finite p.frange.finite_toSet fun a _ ↦ A_int a⟩
  let p' : S[X] := p.toSubring S.toSubring subset_adjoin
  have hSx : IsIntegral S x := ⟨p', (p.monic_toSubring _ _).mpr pmonic, by
    rw [IsScalarTower.algebraMap_eq S A B, ← eval₂_map]
    convert hp; apply p.map_toSubring S.toSubring⟩
  let Sx := Subalgebra.toSubmodule (adjoin S {x})
  let MSx : Module S Sx := SMulMemClass.toModule _ -- the next line times out without this
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S✝
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S✝
g : S✝ →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
A_int : Algebra.IsIntegral R A
x : B
p : A[X]
pmonic : Monic p
hp : eval₂ (algebraMap A B) x p = 0
S : Subalgebra R A := adjoin R ↑(frange p)
this : Module.Finite R ↥S
p' : (↥S)[X] := toSubring p (Subalgebra.toSubring S) (_ : ↑(frange p) ⊆ ↑(adjoin R ↑(frange p)))
hSx : IsIntegral (↥S) x
Sx : Submodule (↥S) B := Subalgebra.toSubmodule (adjoin ↥S {x})
MSx : Module ↥S ↥Sx := SMulMemClass.toModule Sx
⊢ IsIntegral R x

Next tactic:
have : Module.Finite S Sx := ⟨(Submodule.fg_top _).mpr hSx.fg_adjoin_singleton⟩
/-- If A is an R-algebra all of whose elements are integral over R,
and x is an element of an A-algebra that is integral over A, then x is integral over R.-/
theorem isIntegral_trans (A_int : Algebra.IsIntegral R A) (x : B) (hx : IsIntegral A x) :
    IsIntegral R x := by
  rcases hx with ⟨p, pmonic, hp⟩
  let S := adjoin R (p.frange : Set A)
  have : Module.Finite R S := ⟨(Subalgebra.toSubmodule S).fg_top.mpr <|
    fg_adjoin_of_finite p.frange.finite_toSet fun a _ ↦ A_int a⟩
  let p' : S[X] := p.toSubring S.toSubring subset_adjoin
  have hSx : IsIntegral S x := ⟨p', (p.monic_toSubring _ _).mpr pmonic, by
    rw [IsScalarTower.algebraMap_eq S A B, ← eval₂_map]
    convert hp; apply p.map_toSubring S.toSubring⟩
  let Sx := Subalgebra.toSubmodule (adjoin S {x})
  let MSx : Module S Sx := SMulMemClass.toModule _ -- the next line times out without this
  have : Module.Finite S Sx := ⟨(Submodule.fg_top _).mpr hSx.fg_adjoin_singleton⟩
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S✝
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S✝
g : S✝ →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
A_int : Algebra.IsIntegral R A
x : B
p : A[X]
pmonic : Monic p
hp : eval₂ (algebraMap A B) x p = 0
S : Subalgebra R A := adjoin R ↑(frange p)
this✝ : Module.Finite R ↥S
p' : (↥S)[X] := toSubring p (Subalgebra.toSubring S) (_ : ↑(frange p) ⊆ ↑(adjoin R ↑(frange p)))
hSx : IsIntegral (↥S) x
Sx : Submodule (↥S) B := Subalgebra.toSubmodule (adjoin ↥S {x})
MSx : Module ↥S ↥Sx := SMulMemClass.toModule Sx
this : Module.Finite ↥S ↥Sx
⊢ IsIntegral R x

Next tactic:
refine .of_mem_of_fg ((adjoin S {x}).restrictScalars R) ?_ _
    ((Subalgebra.mem_restrictScalars R).mpr <| subset_adjoin rfl)
/-- If A is an R-algebra all of whose elements are integral over R,
and x is an element of an A-algebra that is integral over A, then x is integral over R.-/
theorem isIntegral_trans (A_int : Algebra.IsIntegral R A) (x : B) (hx : IsIntegral A x) :
    IsIntegral R x := by
  rcases hx with ⟨p, pmonic, hp⟩
  let S := adjoin R (p.frange : Set A)
  have : Module.Finite R S := ⟨(Subalgebra.toSubmodule S).fg_top.mpr <|
    fg_adjoin_of_finite p.frange.finite_toSet fun a _ ↦ A_int a⟩
  let p' : S[X] := p.toSubring S.toSubring subset_adjoin
  have hSx : IsIntegral S x := ⟨p', (p.monic_toSubring _ _).mpr pmonic, by
    rw [IsScalarTower.algebraMap_eq S A B, ← eval₂_map]
    convert hp; apply p.map_toSubring S.toSubring⟩
  let Sx := Subalgebra.toSubmodule (adjoin S {x})
  let MSx : Module S Sx := SMulMemClass.toModule _ -- the next line times out without this
  have : Module.Finite S Sx := ⟨(Submodule.fg_top _).mpr hSx.fg_adjoin_singleton⟩
  refine .of_mem_of_fg ((adjoin S {x}).restrictScalars R) ?_ _
    ((Subalgebra.mem_restrictScalars R).mpr <| subset_adjoin rfl)
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S✝
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S✝
g : S✝ →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
A_int : Algebra.IsIntegral R A
x : B
p : A[X]
pmonic : Monic p
hp : eval₂ (algebraMap A B) x p = 0
S : Subalgebra R A := adjoin R ↑(frange p)
this✝ : Module.Finite R ↥S
p' : (↥S)[X] := toSubring p (Subalgebra.toSubring S) (_ : ↑(frange p) ⊆ ↑(adjoin R ↑(frange p)))
hSx : IsIntegral (↥S) x
Sx : Submodule (↥S) B := Subalgebra.toSubmodule (adjoin ↥S {x})
MSx : Module ↥S ↥Sx := SMulMemClass.toModule Sx
this : Module.Finite ↥S ↥Sx
⊢ FG (Subalgebra.toSubmodule (Subalgebra.restrictScalars R (adjoin ↥S {x})))

Next tactic:
rw [← Submodule.fg_top, ← Module.finite_def]
/-- If A is an R-algebra all of whose elements are integral over R,
and x is an element of an A-algebra that is integral over A, then x is integral over R.-/
theorem isIntegral_trans (A_int : Algebra.IsIntegral R A) (x : B) (hx : IsIntegral A x) :
    IsIntegral R x := by
  rcases hx with ⟨p, pmonic, hp⟩
  let S := adjoin R (p.frange : Set A)
  have : Module.Finite R S := ⟨(Subalgebra.toSubmodule S).fg_top.mpr <|
    fg_adjoin_of_finite p.frange.finite_toSet fun a _ ↦ A_int a⟩
  let p' : S[X] := p.toSubring S.toSubring subset_adjoin
  have hSx : IsIntegral S x := ⟨p', (p.monic_toSubring _ _).mpr pmonic, by
    rw [IsScalarTower.algebraMap_eq S A B, ← eval₂_map]
    convert hp; apply p.map_toSubring S.toSubring⟩
  let Sx := Subalgebra.toSubmodule (adjoin S {x})
  let MSx : Module S Sx := SMulMemClass.toModule _ -- the next line times out without this
  have : Module.Finite S Sx := ⟨(Submodule.fg_top _).mpr hSx.fg_adjoin_singleton⟩
  refine .of_mem_of_fg ((adjoin S {x}).restrictScalars R) ?_ _
    ((Subalgebra.mem_restrictScalars R).mpr <| subset_adjoin rfl)
  rw [← Submodule.fg_top, ← Module.finite_def]
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S✝
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S✝
g : S✝ →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
A_int : Algebra.IsIntegral R A
x : B
p : A[X]
pmonic : Monic p
hp : eval₂ (algebraMap A B) x p = 0
S : Subalgebra R A := adjoin R ↑(frange p)
this✝ : Module.Finite R ↥S
p' : (↥S)[X] := toSubring p (Subalgebra.toSubring S) (_ : ↑(frange p) ⊆ ↑(adjoin R ↑(frange p)))
hSx : IsIntegral (↥S) x
Sx : Submodule (↥S) B := Subalgebra.toSubmodule (adjoin ↥S {x})
MSx : Module ↥S ↥Sx := SMulMemClass.toModule Sx
this : Module.Finite ↥S ↥Sx
⊢ Module.Finite R ↥(Subalgebra.toSubmodule (Subalgebra.restrictScalars R (adjoin ↥S {x})))

Next tactic:
letI : SMul S Sx := { MSx with }
/-- If A is an R-algebra all of whose elements are integral over R,
and x is an element of an A-algebra that is integral over A, then x is integral over R.-/
theorem isIntegral_trans (A_int : Algebra.IsIntegral R A) (x : B) (hx : IsIntegral A x) :
    IsIntegral R x := by
  rcases hx with ⟨p, pmonic, hp⟩
  let S := adjoin R (p.frange : Set A)
  have : Module.Finite R S := ⟨(Subalgebra.toSubmodule S).fg_top.mpr <|
    fg_adjoin_of_finite p.frange.finite_toSet fun a _ ↦ A_int a⟩
  let p' : S[X] := p.toSubring S.toSubring subset_adjoin
  have hSx : IsIntegral S x := ⟨p', (p.monic_toSubring _ _).mpr pmonic, by
    rw [IsScalarTower.algebraMap_eq S A B, ← eval₂_map]
    convert hp; apply p.map_toSubring S.toSubring⟩
  let Sx := Subalgebra.toSubmodule (adjoin S {x})
  let MSx : Module S Sx := SMulMemClass.toModule _ -- the next line times out without this
  have : Module.Finite S Sx := ⟨(Submodule.fg_top _).mpr hSx.fg_adjoin_singleton⟩
  refine .of_mem_of_fg ((adjoin S {x}).restrictScalars R) ?_ _
    ((Subalgebra.mem_restrictScalars R).mpr <| subset_adjoin rfl)
  rw [← Submodule.fg_top, ← Module.finite_def]
  letI : SMul S Sx := { MSx with } -- need this even though MSx is there
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S✝
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S✝
g : S✝ →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
A_int : Algebra.IsIntegral R A
x : B
p : A[X]
pmonic : Monic p
hp : eval₂ (algebraMap A B) x p = 0
S : Subalgebra R A := adjoin R ↑(frange p)
this✝¹ : Module.Finite R ↥S
p' : (↥S)[X] := toSubring p (Subalgebra.toSubring S) (_ : ↑(frange p) ⊆ ↑(adjoin R ↑(frange p)))
hSx : IsIntegral (↥S) x
Sx : Submodule (↥S) B := Subalgebra.toSubmodule (adjoin ↥S {x})
MSx : Module ↥S ↥Sx := SMulMemClass.toModule Sx
this✝ : Module.Finite ↥S ↥Sx
this : SMul ↥S ↥Sx := { smul := SMul.smul }
⊢ Module.Finite R ↥(Subalgebra.toSubmodule (Subalgebra.restrictScalars R (adjoin ↥S {x})))

Next tactic:
have : IsScalarTower R S Sx :=
    Submodule.isScalarTower Sx
/-- If A is an R-algebra all of whose elements are integral over R,
and x is an element of an A-algebra that is integral over A, then x is integral over R.-/
theorem isIntegral_trans (A_int : Algebra.IsIntegral R A) (x : B) (hx : IsIntegral A x) :
    IsIntegral R x := by
  rcases hx with ⟨p, pmonic, hp⟩
  let S := adjoin R (p.frange : Set A)
  have : Module.Finite R S := ⟨(Subalgebra.toSubmodule S).fg_top.mpr <|
    fg_adjoin_of_finite p.frange.finite_toSet fun a _ ↦ A_int a⟩
  let p' : S[X] := p.toSubring S.toSubring subset_adjoin
  have hSx : IsIntegral S x := ⟨p', (p.monic_toSubring _ _).mpr pmonic, by
    rw [IsScalarTower.algebraMap_eq S A B, ← eval₂_map]
    convert hp; apply p.map_toSubring S.toSubring⟩
  let Sx := Subalgebra.toSubmodule (adjoin S {x})
  let MSx : Module S Sx := SMulMemClass.toModule _ -- the next line times out without this
  have : Module.Finite S Sx := ⟨(Submodule.fg_top _).mpr hSx.fg_adjoin_singleton⟩
  refine .of_mem_of_fg ((adjoin S {x}).restrictScalars R) ?_ _
    ((Subalgebra.mem_restrictScalars R).mpr <| subset_adjoin rfl)
  rw [← Submodule.fg_top, ← Module.finite_def]
  letI : SMul S Sx := { MSx with } -- need this even though MSx is there
  have : IsScalarTower R S Sx :=
    Submodule.isScalarTower Sx -- Lean looks for `Module A Sx` without this
  

Proof state:
case intro.intro
R : Type u_1
A : Type u_2
B : Type u_3
S✝ : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S✝
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S✝
g : S✝ →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
A_int : Algebra.IsIntegral R A
x : B
p : A[X]
pmonic : Monic p
hp : eval₂ (algebraMap A B) x p = 0
S : Subalgebra R A := adjoin R ↑(frange p)
this✝² : Module.Finite R ↥S
p' : (↥S)[X] := toSubring p (Subalgebra.toSubring S) (_ : ↑(frange p) ⊆ ↑(adjoin R ↑(frange p)))
hSx : IsIntegral (↥S) x
Sx : Submodule (↥S) B := Subalgebra.toSubmodule (adjoin ↥S {x})
MSx : Module ↥S ↥Sx := SMulMemClass.toModule Sx
this✝¹ : Module.Finite ↥S ↥Sx
this✝ : SMul ↥S ↥Sx := { smul := SMul.smul }
this : IsScalarTower R ↥S ↥Sx
⊢ Module.Finite R ↥(Subalgebra.toSubmodule (Subalgebra.restrictScalars R (adjoin ↥S {x})))

Next tactic:
exact Module.Finite.trans S Sx
theorem RingHom.isIntegralElem.of_comp {x : T} (h : (g.comp f).IsIntegralElem x) :
    g.IsIntegralElem x :=
  let ⟨p, hp, hp'⟩ := h
  ⟨p.map f, hp.map f, by 

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S
g : S →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
x : T
h : IsIntegralElem (comp g f) x
p : R[X]
hp : Monic p
hp' : eval₂ (comp g f) x p = 0
⊢ eval₂ g x (Polynomial.map f p) = 0

Next tactic:
rwa [← eval₂_map] at hp'
theorem RingHom.IsIntegral.quotient {I : Ideal S} (hf : f.IsIntegral) :
    (Ideal.quotientMap I f le_rfl).IsIntegral := by
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S
g : S →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
I : Ideal S
hf : IsIntegral f
⊢ IsIntegral (Ideal.quotientMap I f (_ : Ideal.comap f I ≤ Ideal.comap f I))

Next tactic:
rintro ⟨x⟩
theorem RingHom.IsIntegral.quotient {I : Ideal S} (hf : f.IsIntegral) :
    (Ideal.quotientMap I f le_rfl).IsIntegral := by
  rintro ⟨x⟩
  

Proof state:
case mk
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S
g : S →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
I : Ideal S
hf : IsIntegral f
x✝ : S ⧸ I
x : S
⊢ IsIntegralElem (Ideal.quotientMap I f (_ : Ideal.comap f I ≤ Ideal.comap f I)) (Quot.mk Setoid.r x)

Next tactic:
obtain ⟨p, p_monic, hpx⟩ := hf x
theorem RingHom.IsIntegral.quotient {I : Ideal S} (hf : f.IsIntegral) :
    (Ideal.quotientMap I f le_rfl).IsIntegral := by
  rintro ⟨x⟩
  obtain ⟨p, p_monic, hpx⟩ := hf x
  

Proof state:
case mk.intro.intro
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S
g : S →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
I : Ideal S
hf : IsIntegral f
x✝ : S ⧸ I
x : S
p : R[X]
p_monic : Monic p
hpx : eval₂ f x p = 0
⊢ IsIntegralElem (Ideal.quotientMap I f (_ : Ideal.comap f I ≤ Ideal.comap f I)) (Quot.mk Setoid.r x)

Next tactic:
refine ⟨p.map (Ideal.Quotient.mk _), p_monic.map _, ?_⟩
theorem RingHom.IsIntegral.quotient {I : Ideal S} (hf : f.IsIntegral) :
    (Ideal.quotientMap I f le_rfl).IsIntegral := by
  rintro ⟨x⟩
  obtain ⟨p, p_monic, hpx⟩ := hf x
  refine ⟨p.map (Ideal.Quotient.mk _), p_monic.map _, ?_⟩
  

Proof state:
case mk.intro.intro
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S
g : S →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
I : Ideal S
hf : IsIntegral f
x✝ : S ⧸ I
x : S
p : R[X]
p_monic : Monic p
hpx : eval₂ f x p = 0
⊢ eval₂ (Ideal.quotientMap I f (_ : Ideal.comap f I ≤ Ideal.comap f I)) (Quot.mk Setoid.r x)
      (Polynomial.map (Ideal.Quotient.mk (Ideal.comap f I)) p) =
    0

Next tactic:
simpa only [hom_eval₂, eval₂_map] using congr_arg (Ideal.Quotient.mk I) hpx
theorem isIntegral_quotientMap_iff {I : Ideal S} :
    (Ideal.quotientMap I f le_rfl).IsIntegral ↔
      ((Ideal.Quotient.mk I).comp f : R →+* S ⧸ I).IsIntegral := by
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S
g : S →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
I : Ideal S
⊢ RingHom.IsIntegral (Ideal.quotientMap I f (_ : Ideal.comap f I ≤ Ideal.comap f I)) ↔
    RingHom.IsIntegral (RingHom.comp (Ideal.Quotient.mk I) f)

Next tactic:
let g := Ideal.Quotient.mk (I.comap f)
theorem isIntegral_quotientMap_iff {I : Ideal S} :
    (Ideal.quotientMap I f le_rfl).IsIntegral ↔
      ((Ideal.Quotient.mk I).comp f : R →+* S ⧸ I).IsIntegral := by
  let g := Ideal.Quotient.mk (I.comap f)
  -- Porting note: added type ascription
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S
g✝ : S →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
I : Ideal S
g : R →+* R ⧸ Ideal.comap f I := Ideal.Quotient.mk (Ideal.comap f I)
⊢ RingHom.IsIntegral (Ideal.quotientMap I f (_ : Ideal.comap f I ≤ Ideal.comap f I)) ↔
    RingHom.IsIntegral (RingHom.comp (Ideal.Quotient.mk I) f)

Next tactic:
have : (Ideal.quotientMap I f le_rfl).comp g = (Ideal.Quotient.mk I).comp f :=
    Ideal.quotientMap_comp_mk le_rfl
theorem isIntegral_quotientMap_iff {I : Ideal S} :
    (Ideal.quotientMap I f le_rfl).IsIntegral ↔
      ((Ideal.Quotient.mk I).comp f : R →+* S ⧸ I).IsIntegral := by
  let g := Ideal.Quotient.mk (I.comap f)
  -- Porting note: added type ascription
  have : (Ideal.quotientMap I f le_rfl).comp g = (Ideal.Quotient.mk I).comp f :=
    Ideal.quotientMap_comp_mk le_rfl
  

Proof state:
R : Type u_1
A : Type u_2
B : Type u_3
S : Type u_4
T : Type u_5
inst✝⁸ : CommRing R
inst✝⁷ : CommRing A
inst✝⁶ : Ring B
inst✝⁵ : CommRing S
inst✝⁴ : CommRing T
inst✝³ : Algebra A B
inst✝² : Algebra R B
f : R →+* S
g✝ : S →+* T
inst✝¹ : Algebra R A
inst✝ : IsScalarTower R A B
I : Ideal S
g : R →+* R ⧸ Ideal.comap f I := Ideal.Quotient.mk (Ideal.comap f I)
this :
  RingHom.comp (Ideal.quotientMap I f (_ : Ideal.comap f I ≤ Ideal.comap f I)) g = RingHom.comp (Ideal.Quotient.mk I) f
⊢ RingHom.IsIntegral (Ideal.quotientMap I f (_ : Ideal.comap f I ≤ Ideal.comap f I)) ↔
    RingHom.IsIntegral (RingHom.comp (Ideal.Quotient.mk I) f)

Next tactic:
refine' ⟨fun h => _, fun h => RingHom.IsIntegral.tower_top g _ (this ▸ h)⟩