/-- 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
  intro p
  obtain ⟨⟨p', ⟨q, hq⟩⟩, hp⟩ := IsLocalization.surj M' p
  suffices φ'.IsIntegralElem (algebraMap (R[X] ⧸ P) Sₘ p') by
    obtain ⟨q', hq', rfl⟩ := hq
    obtain ⟨q'', hq''⟩ := isUnit_iff_exists_inv'.1 (IsLocalization.map_units Rₘ (⟨q', hq'⟩ : M))
    refine (hp.symm ▸ this).of_mul_unit φ' p (algebraMap (R[X] ⧸ P) Sₘ (φ q')) q'' ?_
    rw [← φ'.map_one, ← congr_arg φ' hq'', φ'.map_mul, ← φ'.comp_apply]
    

Proof state:
case intro.intro.intro
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
p : Sₘ
p' : R[X] ⧸ P
this : RingHom.IsIntegralElem φ' ((algebraMap (R[X] ⧸ P) Sₘ) p')
q' : R ⧸ comap C P
hq' : q' ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX)))
hp :
  p *
      (algebraMap (R[X] ⧸ P) Sₘ)
        ↑(p',
              { val := (quotientMap P C (_ : comap C P ≤ comap C P)) q',
                property :=
                  (_ :
                    ∃ a ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))),
                      (quotientMap P C (_ : comap C P ≤ comap C P)) a =
                        (quotientMap P C (_ : comap C P ≤ comap C P)) q') }).2 =
    (algebraMap (R[X] ⧸ P) Sₘ)
      (p',
          { val := (quotientMap P C (_ : comap C P ≤ comap C P)) q',
            property :=
              (_ :
                ∃ a ∈ ↑(Submonoid.powers (Polynomial.leadingCoeff (Polynomial.map (Quotient.mk (comap C P)) pX))),
                  (quotientMap P C (_ : comap C P ≤ comap C P)) a =
                    (quotientMap P C (_ : comap C P ≤ comap C P)) q') }).1
q'' : Rₘ
hq'' : q'' * (algebraMap (R ⧸ P') Rₘ) ↑{ val := q', property := hq' } = 1
⊢ φ' q'' * (algebraMap (R[X] ⧸ P) Sₘ) (φ q') =
    φ' q'' * (RingHom.comp φ' (algebraMap (R ⧸ P') Rₘ)) ↑{ val := q', property := hq' }

Next tactic:
simp only [IsLocalization.map_comp _]