l3lab/ntp-mathlib huggingface dataset:
lemma mem_closure_X_union_C {R : Type*} [Ring R] (p : R[X]) :
    p ∈ Subring.closure (insert X {f | f.degree ≤ 0} : Set R[X]) := by
  refine' Polynomial.induction_on p _ _ _
  · intro r
    apply Subring.subset_closure
    apply Set.mem_insert_of_mem
    

Proof state:
case refine'_1.a.a
R : Type u_1
inst✝ : Ring R
p : R[X]
r : R
⊢ C r ∈ {f | degree f ≤ 0}

Next tactic:
exact degree_C_le
lemma mem_closure_X_union_C {R : Type*} [Ring R] (p : R[X]) :
    p ∈ Subring.closure (insert X {f | f.degree ≤ 0} : Set R[X]) := by
  refine' Polynomial.induction_on p _ _ _
  · intro r
    apply Subring.subset_closure
    apply Set.mem_insert_of_mem
    exact degree_C_le
  · 

Proof state:
case refine'_2
R : Type u_1
inst✝ : Ring R
p : R[X]
⊢ ∀ (p q : R[X]),
    p ∈ Subring.closure (insert X {f | degree f ≤ 0}) →
      q ∈ Subring.closure (insert X {f | degree f ≤ 0}) → p + q ∈ Subring.closure (insert X {f | degree f ≤ 0})

Next tactic:
intros p1 p2 h1 h2
lemma mem_closure_X_union_C {R : Type*} [Ring R] (p : R[X]) :
    p ∈ Subring.closure (insert X {f | f.degree ≤ 0} : Set R[X]) := by
  refine' Polynomial.induction_on p _ _ _
  · intro r
    apply Subring.subset_closure
    apply Set.mem_insert_of_mem
    exact degree_C_le
  · intros p1 p2 h1 h2
    

Proof state:
case refine'_2
R : Type u_1
inst✝ : Ring R
p p1 p2 : R[X]
h1 : p1 ∈ Subring.closure (insert X {f | degree f ≤ 0})
h2 : p2 ∈ Subring.closure (insert X {f | degree f ≤ 0})
⊢ p1 + p2 ∈ Subring.closure (insert X {f | degree f ≤ 0})

Next tactic:
exact Subring.add_mem _ h1 h2
lemma mem_closure_X_union_C {R : Type*} [Ring R] (p : R[X]) :
    p ∈ Subring.closure (insert X {f | f.degree ≤ 0} : Set R[X]) := by
  refine' Polynomial.induction_on p _ _ _
  · intro r
    apply Subring.subset_closure
    apply Set.mem_insert_of_mem
    exact degree_C_le
  · intros p1 p2 h1 h2
    exact Subring.add_mem _ h1 h2
  · 

Proof state:
case refine'_3
R : Type u_1
inst✝ : Ring R
p : R[X]
⊢ ∀ (n : ℕ) (a : R),
    C a * X ^ n ∈ Subring.closure (insert X {f | degree f ≤ 0}) →
      C a * X ^ (n + 1) ∈ Subring.closure (insert X {f | degree f ≤ 0})

Next tactic:
intros n r hr
lemma mem_closure_X_union_C {R : Type*} [Ring R] (p : R[X]) :
    p ∈ Subring.closure (insert X {f | f.degree ≤ 0} : Set R[X]) := by
  refine' Polynomial.induction_on p _ _ _
  · intro r
    apply Subring.subset_closure
    apply Set.mem_insert_of_mem
    exact degree_C_le
  · intros p1 p2 h1 h2
    exact Subring.add_mem _ h1 h2
  · intros n r hr
    

Proof state:
case refine'_3
R : Type u_1
inst✝ : Ring R
p : R[X]
n : ℕ
r : R
hr : C r * X ^ n ∈ Subring.closure (insert X {f | degree f ≤ 0})
⊢ C r * X ^ (n + 1) ∈ Subring.closure (insert X {f | degree f ≤ 0})

Next tactic:
rw [pow_succ', ← mul_assoc]
lemma mem_closure_X_union_C {R : Type*} [Ring R] (p : R[X]) :
    p ∈ Subring.closure (insert X {f | f.degree ≤ 0} : Set R[X]) := by
  refine' Polynomial.induction_on p _ _ _
  · intro r
    apply Subring.subset_closure
    apply Set.mem_insert_of_mem
    exact degree_C_le
  · intros p1 p2 h1 h2
    exact Subring.add_mem _ h1 h2
  · intros n r hr
    rw [pow_succ', ← mul_assoc]
    

Proof state:
case refine'_3
R : Type u_1
inst✝ : Ring R
p : R[X]
n : ℕ
r : R
hr : C r * X ^ n ∈ Subring.closure (insert X {f | degree f ≤ 0})
⊢ C r * X ^ n * X ∈ Subring.closure (insert X {f | degree f ≤ 0})

Next tactic:
apply Subring.mul_mem _ hr
lemma mem_closure_X_union_C {R : Type*} [Ring R] (p : R[X]) :
    p ∈ Subring.closure (insert X {f | f.degree ≤ 0} : Set R[X]) := by
  refine' Polynomial.induction_on p _ _ _
  · intro r
    apply Subring.subset_closure
    apply Set.mem_insert_of_mem
    exact degree_C_le
  · intros p1 p2 h1 h2
    exact Subring.add_mem _ h1 h2
  · intros n r hr
    rw [pow_succ', ← mul_assoc]
    apply Subring.mul_mem _ hr
    

Proof state:
case refine'_3
R : Type u_1
inst✝ : Ring R
p : R[X]
n : ℕ
r : R
hr : C r * X ^ n ∈ Subring.closure (insert X {f | degree f ≤ 0})
⊢ X ∈ Subring.closure (insert X {f | degree f ≤ 0})

Next tactic:
apply Subring.subset_closure
lemma mem_closure_X_union_C {R : Type*} [Ring R] (p : R[X]) :
    p ∈ Subring.closure (insert X {f | f.degree ≤ 0} : Set R[X]) := by
  refine' Polynomial.induction_on p _ _ _
  · intro r
    apply Subring.subset_closure
    apply Set.mem_insert_of_mem
    exact degree_C_le
  · intros p1 p2 h1 h2
    exact Subring.add_mem _ h1 h2
  · intros n r hr
    rw [pow_succ', ← mul_assoc]
    apply Subring.mul_mem _ hr
    apply Subring.subset_closure
    

Proof state:
case refine'_3.a
R : Type u_1
inst✝ : Ring R
p : R[X]
n : ℕ
r : R
hr : C r * X ^ n ∈ Subring.closure (insert X {f | degree f ≤ 0})
⊢ X ∈ insert X {f | degree f ≤ 0}

Next tactic:
apply Set.mem_insert
/-- If `I` is a prime ideal of `R[X]` and `pX ∈ I` is a non-constant polynomial,
  then the map `R →+* R[x]/I` descends to an integral map when localizing at `pX.leadingCoeff`.
  In particular `X` is integral because it satisfies `pX`, and constants are trivially integral,
  so integrality of the entire extension follows by closure under addition and multiplication. -/
theorem isIntegral_isLocalization_polynomial_quotient
    (P : Ideal R[X]) (pX : R[X]) (hpX : pX ∈ P) [Algebra (R ⧸ P.comap (C : R →+* R[X])) Rₘ]
    [IsLocalization.Away (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff Rₘ]
    [Algebra (R[X] ⧸ P) Sₘ] [IsLocalization ((Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).map (quotientMap P C le_rfl) : Submonoid (R[X] ⧸ P)) Sₘ] :
    (IsLocalization.map Sₘ (quotientMap P C le_rfl) (Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).le_comap_map : Rₘ →+* Sₘ).IsIntegral := by
  

Proof state:
R : Type u_1
S : Type u_2
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : IsDomain S
Rₘ : Type u_3
Sₘ : Type u_4
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
P : Ideal R[X]
pX : R[X]
hpX : pX ∈ P
inst✝³ : Algebra (R ⧸ comap C P) Rₘ
inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ
inst✝¹ : Algebra (R[X] ⧸ P) Sₘ
inst✝ :
  IsLocalization
    (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
      (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))
    Sₘ
⊢ RingHom.IsIntegral
    (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P))
      (_ :
        Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤
          Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P))
            (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
              (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))))

Next tactic:
let P' : Ideal R := P.comap C
/-- If `I` is a prime ideal of `R[X]` and `pX ∈ I` is a non-constant polynomial,
  then the map `R →+* R[x]/I` descends to an integral map when localizing at `pX.leadingCoeff`.
  In particular `X` is integral because it satisfies `pX`, and constants are trivially integral,
  so integrality of the entire extension follows by closure under addition and multiplication. -/
theorem isIntegral_isLocalization_polynomial_quotient
    (P : Ideal R[X]) (pX : R[X]) (hpX : pX ∈ P) [Algebra (R ⧸ P.comap (C : R →+* R[X])) Rₘ]
    [IsLocalization.Away (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff Rₘ]
    [Algebra (R[X] ⧸ P) Sₘ] [IsLocalization ((Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).map (quotientMap P C le_rfl) : Submonoid (R[X] ⧸ P)) Sₘ] :
    (IsLocalization.map Sₘ (quotientMap P C le_rfl) (Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).le_comap_map : Rₘ →+* Sₘ).IsIntegral := by
  let P' : Ideal R := P.comap C
  

Proof state:
R : Type u_1
S : Type u_2
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : IsDomain S
Rₘ : Type u_3
Sₘ : Type u_4
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
P : Ideal R[X]
pX : R[X]
hpX : pX ∈ P
inst✝³ : Algebra (R ⧸ comap C P) Rₘ
inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ
inst✝¹ : Algebra (R[X] ⧸ P) Sₘ
inst✝ :
  IsLocalization
    (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
      (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))
    Sₘ
P' : Ideal R := comap C P
⊢ RingHom.IsIntegral
    (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P))
      (_ :
        Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤
          Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P))
            (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
              (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))))

Next tactic:
let M : Submonoid (R ⧸ P') :=
    Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff
/-- If `I` is a prime ideal of `R[X]` and `pX ∈ I` is a non-constant polynomial,
  then the map `R →+* R[x]/I` descends to an integral map when localizing at `pX.leadingCoeff`.
  In particular `X` is integral because it satisfies `pX`, and constants are trivially integral,
  so integrality of the entire extension follows by closure under addition and multiplication. -/
theorem isIntegral_isLocalization_polynomial_quotient
    (P : Ideal R[X]) (pX : R[X]) (hpX : pX ∈ P) [Algebra (R ⧸ P.comap (C : R →+* R[X])) Rₘ]
    [IsLocalization.Away (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff Rₘ]
    [Algebra (R[X] ⧸ P) Sₘ] [IsLocalization ((Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).map (quotientMap P C le_rfl) : Submonoid (R[X] ⧸ P)) Sₘ] :
    (IsLocalization.map Sₘ (quotientMap P C le_rfl) (Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).le_comap_map : Rₘ →+* Sₘ).IsIntegral := by
  let P' : Ideal R := P.comap C
  let M : Submonoid (R ⧸ P') :=
    Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff
  

Proof state:
R : Type u_1
S : Type u_2
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : IsDomain S
Rₘ : Type u_3
Sₘ : Type u_4
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
P : Ideal R[X]
pX : R[X]
hpX : pX ∈ P
inst✝³ : Algebra (R ⧸ comap C P) Rₘ
inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ
inst✝¹ : Algebra (R[X] ⧸ P) Sₘ
inst✝ :
  IsLocalization
    (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
      (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))
    Sₘ
P' : Ideal R := comap C P
M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))
⊢ RingHom.IsIntegral
    (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P))
      (_ :
        Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤
          Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P))
            (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
              (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))))

Next tactic:
let M' : Submonoid (R[X] ⧸ P) :=
    (Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff).map
      (quotientMap P C le_rfl)
/-- If `I` is a prime ideal of `R[X]` and `pX ∈ I` is a non-constant polynomial,
  then the map `R →+* R[x]/I` descends to an integral map when localizing at `pX.leadingCoeff`.
  In particular `X` is integral because it satisfies `pX`, and constants are trivially integral,
  so integrality of the entire extension follows by closure under addition and multiplication. -/
theorem isIntegral_isLocalization_polynomial_quotient
    (P : Ideal R[X]) (pX : R[X]) (hpX : pX ∈ P) [Algebra (R ⧸ P.comap (C : R →+* R[X])) Rₘ]
    [IsLocalization.Away (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff Rₘ]
    [Algebra (R[X] ⧸ P) Sₘ] [IsLocalization ((Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).map (quotientMap P C le_rfl) : Submonoid (R[X] ⧸ P)) Sₘ] :
    (IsLocalization.map Sₘ (quotientMap P C le_rfl) (Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).le_comap_map : Rₘ →+* Sₘ).IsIntegral := by
  let P' : Ideal R := P.comap C
  let M : Submonoid (R ⧸ P') :=
    Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff
  let M' : Submonoid (R[X] ⧸ P) :=
    (Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff).map
      (quotientMap P C le_rfl)
  

Proof state:
R : Type u_1
S : Type u_2
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : IsDomain S
Rₘ : Type u_3
Sₘ : Type u_4
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
P : Ideal R[X]
pX : R[X]
hpX : pX ∈ P
inst✝³ : Algebra (R ⧸ comap C P) Rₘ
inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ
inst✝¹ : Algebra (R[X] ⧸ P) Sₘ
inst✝ :
  IsLocalization
    (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
      (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))
    Sₘ
P' : Ideal R := comap C P
M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))
M' : Submonoid (R[X] ⧸ P) :=
  Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
    (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))
⊢ RingHom.IsIntegral
    (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P))
      (_ :
        Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤
          Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P))
            (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
              (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))))

Next tactic:
let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C le_rfl
/-- If `I` is a prime ideal of `R[X]` and `pX ∈ I` is a non-constant polynomial,
  then the map `R →+* R[x]/I` descends to an integral map when localizing at `pX.leadingCoeff`.
  In particular `X` is integral because it satisfies `pX`, and constants are trivially integral,
  so integrality of the entire extension follows by closure under addition and multiplication. -/
theorem isIntegral_isLocalization_polynomial_quotient
    (P : Ideal R[X]) (pX : R[X]) (hpX : pX ∈ P) [Algebra (R ⧸ P.comap (C : R →+* R[X])) Rₘ]
    [IsLocalization.Away (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff Rₘ]
    [Algebra (R[X] ⧸ P) Sₘ] [IsLocalization ((Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).map (quotientMap P C le_rfl) : Submonoid (R[X] ⧸ P)) Sₘ] :
    (IsLocalization.map Sₘ (quotientMap P C le_rfl) (Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).le_comap_map : Rₘ →+* Sₘ).IsIntegral := by
  let P' : Ideal R := P.comap C
  let M : Submonoid (R ⧸ P') :=
    Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff
  let M' : Submonoid (R[X] ⧸ P) :=
    (Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff).map
      (quotientMap P C le_rfl)
  let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C le_rfl
  

Proof state:
R : Type u_1
S : Type u_2
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : IsDomain S
Rₘ : Type u_3
Sₘ : Type u_4
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
P : Ideal R[X]
pX : R[X]
hpX : pX ∈ P
inst✝³ : Algebra (R ⧸ comap C P) Rₘ
inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ
inst✝¹ : Algebra (R[X] ⧸ P) Sₘ
inst✝ :
  IsLocalization
    (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
      (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))
    Sₘ
P' : Ideal R := comap C P
M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))
M' : Submonoid (R[X] ⧸ P) :=
  Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
    (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))
φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P')
⊢ RingHom.IsIntegral
    (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P))
      (_ :
        Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤
          Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P))
            (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
              (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))))

Next tactic:
let φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ M.le_comap_map
/-- If `I` is a prime ideal of `R[X]` and `pX ∈ I` is a non-constant polynomial,
  then the map `R →+* R[x]/I` descends to an integral map when localizing at `pX.leadingCoeff`.
  In particular `X` is integral because it satisfies `pX`, and constants are trivially integral,
  so integrality of the entire extension follows by closure under addition and multiplication. -/
theorem isIntegral_isLocalization_polynomial_quotient
    (P : Ideal R[X]) (pX : R[X]) (hpX : pX ∈ P) [Algebra (R ⧸ P.comap (C : R →+* R[X])) Rₘ]
    [IsLocalization.Away (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff Rₘ]
    [Algebra (R[X] ⧸ P) Sₘ] [IsLocalization ((Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).map (quotientMap P C le_rfl) : Submonoid (R[X] ⧸ P)) Sₘ] :
    (IsLocalization.map Sₘ (quotientMap P C le_rfl) (Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).le_comap_map : Rₘ →+* Sₘ).IsIntegral := by
  let P' : Ideal R := P.comap C
  let M : Submonoid (R ⧸ P') :=
    Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff
  let M' : Submonoid (R[X] ⧸ P) :=
    (Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff).map
      (quotientMap P C le_rfl)
  let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C le_rfl
  let φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ M.le_comap_map
  

Proof state:
R : Type u_1
S : Type u_2
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : IsDomain S
Rₘ : Type u_3
Sₘ : Type u_4
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
P : Ideal R[X]
pX : R[X]
hpX : pX ∈ P
inst✝³ : Algebra (R ⧸ comap C P) Rₘ
inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ
inst✝¹ : Algebra (R[X] ⧸ P) Sₘ
inst✝ :
  IsLocalization
    (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
      (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))
    Sₘ
P' : Ideal R := comap C P
M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))
M' : Submonoid (R[X] ⧸ P) :=
  Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
    (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))
φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P')
φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))
⊢ RingHom.IsIntegral
    (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P))
      (_ :
        Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤
          Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P))
            (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
              (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))))

Next tactic:
have hφ' : φ.comp (Quotient.mk P') = (Quotient.mk P).comp C := rfl
/-- If `I` is a prime ideal of `R[X]` and `pX ∈ I` is a non-constant polynomial,
  then the map `R →+* R[x]/I` descends to an integral map when localizing at `pX.leadingCoeff`.
  In particular `X` is integral because it satisfies `pX`, and constants are trivially integral,
  so integrality of the entire extension follows by closure under addition and multiplication. -/
theorem isIntegral_isLocalization_polynomial_quotient
    (P : Ideal R[X]) (pX : R[X]) (hpX : pX ∈ P) [Algebra (R ⧸ P.comap (C : R →+* R[X])) Rₘ]
    [IsLocalization.Away (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff Rₘ]
    [Algebra (R[X] ⧸ P) Sₘ] [IsLocalization ((Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).map (quotientMap P C le_rfl) : Submonoid (R[X] ⧸ P)) Sₘ] :
    (IsLocalization.map Sₘ (quotientMap P C le_rfl) (Submonoid.powers (pX.map (Quotient.mk (P.comap
      (C : R →+* R[X])))).leadingCoeff).le_comap_map : Rₘ →+* Sₘ).IsIntegral := by
  let P' : Ideal R := P.comap C
  let M : Submonoid (R ⧸ P') :=
    Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff
  let M' : Submonoid (R[X] ⧸ P) :=
    (Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff).map
      (quotientMap P C le_rfl)
  let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C le_rfl
  let φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ M.le_comap_map
  have hφ' : φ.comp (Quotient.mk P') = (Quotient.mk P).comp C := rfl
  

Proof state:
R : Type u_1
S : Type u_2
inst✝⁸ : CommRing R
inst✝⁷ : CommRing S
inst✝⁶ : IsDomain S
Rₘ : Type u_3
Sₘ : Type u_4
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
P : Ideal R[X]
pX : R[X]
hpX : pX ∈ P
inst✝³ : Algebra (R ⧸ comap C P) Rₘ
inst✝² : IsLocalization.Away (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) Rₘ
inst✝¹ : Algebra (R[X] ⧸ P) Sₘ
inst✝ :
  IsLocalization
    (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
      (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))
    Sₘ
P' : Ideal R := comap C P
M : Submonoid (R ⧸ P') := Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))
M' : Submonoid (R[X] ⧸ P) :=
  Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
    (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))
φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C (_ : P' ≤ P')
φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ (_ : M ≤ Submonoid.comap φ (Submonoid.map φ M))
hφ' : RingHom.comp φ (Quotient.mk P') = RingHom.comp (Quotient.mk P) C
⊢ RingHom.IsIntegral
    (IsLocalization.map Sₘ (quotientMap P C (_ : comap C P ≤ comap C P))
      (_ :
        Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)) ≤
          Submonoid.comap (quotientMap P C (_ : comap C P ≤ comap C P))
            (Submonoid.map (quotientMap P C (_ : comap C P ≤ comap C P))
              (Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))))))

Next tactic:
intro p