l3lab/ntp-mathlib huggingface dataset:
theorem integerNormalization_eq_zero_iff {p : K[X]} :
    integerNormalization (nonZeroDivisors A) p = 0 ↔ p = 0 := by
  refine' Polynomial.ext_iff.trans (Polynomial.ext_iff.trans _).symm
  obtain ⟨⟨b, nonzero⟩, hb⟩ := integerNormalization_spec (nonZeroDivisors A) p
  constructor <;> intro h i
  · -- Porting note: avoided some defeq abuse
    rw [coeff_zero, ← to_map_eq_zero_iff (K := K), hb i, h i, coeff_zero, smul_zero]
  · have hi := h i
    rw [Polynomial.coeff_zero, ← @to_map_eq_zero_iff A _ K, hb i, Algebra.smul_def] at hi
    apply Or.resolve_left (eq_zero_or_eq_zero_of_mul_eq_zero hi)
    intro h
    

Proof state:
case intro.mk.mpr
R : Type u_1
inst✝⁹ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁸ : CommRing S
inst✝⁷ : Algebra R S
P : Type u_3
inst✝⁶ : CommRing P
A : Type u_4
K : Type u_5
C : Type u_6
inst✝⁵ : CommRing A
inst✝⁴ : IsDomain A
inst✝³ : Field K
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : CommRing C
p : K[X]
b : A
nonzero : b ∈ nonZeroDivisors A
hb :
  ∀ (i : ℕ),
    (algebraMap A K) (coeff (integerNormalization (nonZeroDivisors A) p) i) =
      ↑{ val := b, property := nonzero } • coeff p i
h✝ : ∀ (n : ℕ), coeff (integerNormalization (nonZeroDivisors A) p) n = coeff 0 n
i : ℕ
hi : (algebraMap A K) ↑{ val := b, property := nonzero } * coeff p i = 0
h : (algebraMap A K) ↑{ val := b, property := nonzero } = 0
⊢ False

Next tactic:
apply mem_nonZeroDivisors_iff_ne_zero.mp nonzero
theorem integerNormalization_eq_zero_iff {p : K[X]} :
    integerNormalization (nonZeroDivisors A) p = 0 ↔ p = 0 := by
  refine' Polynomial.ext_iff.trans (Polynomial.ext_iff.trans _).symm
  obtain ⟨⟨b, nonzero⟩, hb⟩ := integerNormalization_spec (nonZeroDivisors A) p
  constructor <;> intro h i
  · -- Porting note: avoided some defeq abuse
    rw [coeff_zero, ← to_map_eq_zero_iff (K := K), hb i, h i, coeff_zero, smul_zero]
  · have hi := h i
    rw [Polynomial.coeff_zero, ← @to_map_eq_zero_iff A _ K, hb i, Algebra.smul_def] at hi
    apply Or.resolve_left (eq_zero_or_eq_zero_of_mul_eq_zero hi)
    intro h
    apply mem_nonZeroDivisors_iff_ne_zero.mp nonzero
    

Proof state:
case intro.mk.mpr
R : Type u_1
inst✝⁹ : CommRing R
M : Submonoid R
S : Type u_2
inst✝⁸ : CommRing S
inst✝⁷ : Algebra R S
P : Type u_3
inst✝⁶ : CommRing P
A : Type u_4
K : Type u_5
C : Type u_6
inst✝⁵ : CommRing A
inst✝⁴ : IsDomain A
inst✝³ : Field K
inst✝² : Algebra A K
inst✝¹ : IsFractionRing A K
inst✝ : CommRing C
p : K[X]
b : A
nonzero : b ∈ nonZeroDivisors A
hb :
  ∀ (i : ℕ),
    (algebraMap A K) (coeff (integerNormalization (nonZeroDivisors A) p) i) =
      ↑{ val := b, property := nonzero } • coeff p i
h✝ : ∀ (n : ℕ), coeff (integerNormalization (nonZeroDivisors A) p) n = coeff 0 n
i : ℕ
hi : (algebraMap A K) ↑{ val := b, property := nonzero } * coeff p i = 0
h : (algebraMap A K) ↑{ val := b, property := nonzero } = 0
⊢ b = 0

Next tactic:
exact to_map_eq_zero_iff.mp h
/-- An element of a ring is algebraic over the ring `A` iff it is algebraic
over the field of fractions of `A`.
-/
theorem isAlgebraic_iff [Algebra A C] [Algebra K C] [IsScalarTower A K C] {x : C} :
    IsAlgebraic A x ↔ IsAlgebraic K x := by
  

Proof state:
R : Type u_1
inst✝¹² : CommRing R
M : Submonoid R
S : Type u_2
inst✝¹¹ : CommRing S
inst✝¹⁰ : Algebra R S
P : Type u_3
inst✝⁹ : CommRing P
A : Type u_4
K : Type u_5
C : Type u_6
inst✝⁸ : CommRing A
inst✝⁷ : IsDomain A
inst✝⁶ : Field K
inst✝⁵ : Algebra A K
inst✝⁴ : IsFractionRing A K
inst✝³ : CommRing C
inst✝² : Algebra A C
inst✝¹ : Algebra K C
inst✝ : IsScalarTower A K C
x : C
⊢ IsAlgebraic A x ↔ IsAlgebraic K x

Next tactic:
constructor
/-- An element of a ring is algebraic over the ring `A` iff it is algebraic
over the field of fractions of `A`.
-/
theorem isAlgebraic_iff [Algebra A C] [Algebra K C] [IsScalarTower A K C] {x : C} :
    IsAlgebraic A x ↔ IsAlgebraic K x := by
  constructor <;> 

Proof state:
case mp
R : Type u_1
inst✝¹² : CommRing R
M : Submonoid R
S : Type u_2
inst✝¹¹ : CommRing S
inst✝¹⁰ : Algebra R S
P : Type u_3
inst✝⁹ : CommRing P
A : Type u_4
K : Type u_5
C : Type u_6
inst✝⁸ : CommRing A
inst✝⁷ : IsDomain A
inst✝⁶ : Field K
inst✝⁵ : Algebra A K
inst✝⁴ : IsFractionRing A K
inst✝³ : CommRing C
inst✝² : Algebra A C
inst✝¹ : Algebra K C
inst✝ : IsScalarTower A K C
x : C
⊢ IsAlgebraic A x → IsAlgebraic K x

Next tactic:
rintro ⟨p, hp, px⟩
/-- An element of a ring is algebraic over the ring `A` iff it is algebraic
over the field of fractions of `A`.
-/
theorem isAlgebraic_iff [Algebra A C] [Algebra K C] [IsScalarTower A K C] {x : C} :
    IsAlgebraic A x ↔ IsAlgebraic K x := by
  constructor <;> 

Proof state:
case mpr
R : Type u_1
inst✝¹² : CommRing R
M : Submonoid R
S : Type u_2
inst✝¹¹ : CommRing S
inst✝¹⁰ : Algebra R S
P : Type u_3
inst✝⁹ : CommRing P
A : Type u_4
K : Type u_5
C : Type u_6
inst✝⁸ : CommRing A
inst✝⁷ : IsDomain A
inst✝⁶ : Field K
inst✝⁵ : Algebra A K
inst✝⁴ : IsFractionRing A K
inst✝³ : CommRing C
inst✝² : Algebra A C
inst✝¹ : Algebra K C
inst✝ : IsScalarTower A K C
x : C
⊢ IsAlgebraic K x → IsAlgebraic A x

Next tactic:
rintro ⟨p, hp, px⟩
/-- An element of a ring is algebraic over the ring `A` iff it is algebraic
over the field of fractions of `A`.
-/
theorem isAlgebraic_iff [Algebra A C] [Algebra K C] [IsScalarTower A K C] {x : C} :
    IsAlgebraic A x ↔ IsAlgebraic K x := by
  constructor <;> rintro ⟨p, hp, px⟩
  · 

Proof state:
case mp.intro.intro
R : Type u_1
inst✝¹² : CommRing R
M : Submonoid R
S : Type u_2
inst✝¹¹ : CommRing S
inst✝¹⁰ : Algebra R S
P : Type u_3
inst✝⁹ : CommRing P
A : Type u_4
K : Type u_5
C : Type u_6
inst✝⁸ : CommRing A
inst✝⁷ : IsDomain A
inst✝⁶ : Field K
inst✝⁵ : Algebra A K
inst✝⁴ : IsFractionRing A K
inst✝³ : CommRing C
inst✝² : Algebra A C
inst✝¹ : Algebra K C
inst✝ : IsScalarTower A K C
x : C
p : A[X]
hp : p ≠ 0
px : (aeval x) p = 0
⊢ IsAlgebraic K x

Next tactic:
refine' ⟨p.map (algebraMap A K), fun h => hp (Polynomial.ext fun i => _), _⟩
/-- An element of a ring is algebraic over the ring `A` iff it is algebraic
over the field of fractions of `A`.
-/
theorem isAlgebraic_iff [Algebra A C] [Algebra K C] [IsScalarTower A K C] {x : C} :
    IsAlgebraic A x ↔ IsAlgebraic K x := by
  constructor <;> rintro ⟨p, hp, px⟩
  · refine' ⟨p.map (algebraMap A K), fun h => hp (Polynomial.ext fun i => _), _⟩
    · 

Proof state:
case mp.intro.intro.refine'_1
R : Type u_1
inst✝¹² : CommRing R
M : Submonoid R
S : Type u_2
inst✝¹¹ : CommRing S
inst✝¹⁰ : Algebra R S
P : Type u_3
inst✝⁹ : CommRing P
A : Type u_4
K : Type u_5
C : Type u_6
inst✝⁸ : CommRing A
inst✝⁷ : IsDomain A
inst✝⁶ : Field K
inst✝⁵ : Algebra A K
inst✝⁴ : IsFractionRing A K
inst✝³ : CommRing C
inst✝² : Algebra A C
inst✝¹ : Algebra K C
inst✝ : IsScalarTower A K C
x : C
p : A[X]
hp : p ≠ 0
px : (aeval x) p = 0
h : Polynomial.map (algebraMap A K) p = 0
i : ℕ
⊢ coeff p i = coeff 0 i

Next tactic:
have : algebraMap A K (p.coeff i) = 0 :=
        _root_.trans (Polynomial.coeff_map _ _).symm (by simp [h])
/-- An element of a ring is algebraic over the ring `A` iff it is algebraic
over the field of fractions of `A`.
-/
theorem isAlgebraic_iff [Algebra A C] [Algebra K C] [IsScalarTower A K C] {x : C} :
    IsAlgebraic A x ↔ IsAlgebraic K x := by
  constructor <;> rintro ⟨p, hp, px⟩
  · refine' ⟨p.map (algebraMap A K), fun h => hp (Polynomial.ext fun i => _), _⟩
    · have : algebraMap A K (p.coeff i) = 0 :=
        _root_.trans (Polynomial.coeff_map _ _).symm (by 

Proof state:
R : Type u_1
inst✝¹² : CommRing R
M : Submonoid R
S : Type u_2
inst✝¹¹ : CommRing S
inst✝¹⁰ : Algebra R S
P : Type u_3
inst✝⁹ : CommRing P
A : Type u_4
K : Type u_5
C : Type u_6
inst✝⁸ : CommRing A
inst✝⁷ : IsDomain A
inst✝⁶ : Field K
inst✝⁵ : Algebra A K
inst✝⁴ : IsFractionRing A K
inst✝³ : CommRing C
inst✝² : Algebra A C
inst✝¹ : Algebra K C
inst✝ : IsScalarTower A K C
x : C
p : A[X]
hp : p ≠ 0
px : (aeval x) p = 0
h : Polynomial.map (algebraMap A K) p = 0
i : ℕ
⊢ coeff (Polynomial.map (algebraMap A K) p) i = 0

Next tactic:
simp [h]
/-- An element of a ring is algebraic over the ring `A` iff it is algebraic
over the field of fractions of `A`.
-/
theorem isAlgebraic_iff [Algebra A C] [Algebra K C] [IsScalarTower A K C] {x : C} :
    IsAlgebraic A x ↔ IsAlgebraic K x := by
  constructor <;> rintro ⟨p, hp, px⟩
  · refine' ⟨p.map (algebraMap A K), fun h => hp (Polynomial.ext fun i => _), _⟩
    · have : algebraMap A K (p.coeff i) = 0 :=
        _root_.trans (Polynomial.coeff_map _ _).symm (by simp [h])
      

Proof state:
case mp.intro.intro.refine'_1
R : Type u_1
inst✝¹² : CommRing R
M : Submonoid R
S : Type u_2
inst✝¹¹ : CommRing S
inst✝¹⁰ : Algebra R S
P : Type u_3
inst✝⁹ : CommRing P
A : Type u_4
K : Type u_5
C : Type u_6
inst✝⁸ : CommRing A
inst✝⁷ : IsDomain A
inst✝⁶ : Field K
inst✝⁵ : Algebra A K
inst✝⁴ : IsFractionRing A K
inst✝³ : CommRing C
inst✝² : Algebra A C
inst✝¹ : Algebra K C
inst✝ : IsScalarTower A K C
x : C
p : A[X]
hp : p ≠ 0
px : (aeval x) p = 0
h : Polynomial.map (algebraMap A K) p = 0
i : ℕ
this : (algebraMap A K) (coeff p i) = 0
⊢ coeff p i = coeff 0 i

Next tactic:
exact to_map_eq_zero_iff.mp this
/-- An element of a ring is algebraic over the ring `A` iff it is algebraic
over the field of fractions of `A`.
-/
theorem isAlgebraic_iff [Algebra A C] [Algebra K C] [IsScalarTower A K C] {x : C} :
    IsAlgebraic A x ↔ IsAlgebraic K x := by
  constructor <;> rintro ⟨p, hp, px⟩
  · refine' ⟨p.map (algebraMap A K), fun h => hp (Polynomial.ext fun i => _), _⟩
    · have : algebraMap A K (p.coeff i) = 0 :=
        _root_.trans (Polynomial.coeff_map _ _).symm (by simp [h])
      exact to_map_eq_zero_iff.mp this
    · 

Proof state:
case mp.intro.intro.refine'_2
R : Type u_1
inst✝¹² : CommRing R
M : Submonoid R
S : Type u_2
inst✝¹¹ : CommRing S
inst✝¹⁰ : Algebra R S
P : Type u_3
inst✝⁹ : CommRing P
A : Type u_4
K : Type u_5
C : Type u_6
inst✝⁸ : CommRing A
inst✝⁷ : IsDomain A
inst✝⁶ : Field K
inst✝⁵ : Algebra A K
inst✝⁴ : IsFractionRing A K
inst✝³ : CommRing C
inst✝² : Algebra A C
inst✝¹ : Algebra K C
inst✝ : IsScalarTower A K C
x : C
p : A[X]
hp : p ≠ 0
px : (aeval x) p = 0
⊢ (aeval x) (Polynomial.map (algebraMap A K) p) = 0

Next tactic:
exact (Polynomial.aeval_map_algebraMap K _ _).trans px
/-- An element of a ring is algebraic over the ring `A` iff it is algebraic
over the field of fractions of `A`.
-/
theorem isAlgebraic_iff [Algebra A C] [Algebra K C] [IsScalarTower A K C] {x : C} :
    IsAlgebraic A x ↔ IsAlgebraic K x := by
  constructor <;> rintro ⟨p, hp, px⟩
  · refine' ⟨p.map (algebraMap A K), fun h => hp (Polynomial.ext fun i => _), _⟩
    · have : algebraMap A K (p.coeff i) = 0 :=
        _root_.trans (Polynomial.coeff_map _ _).symm (by simp [h])
      exact to_map_eq_zero_iff.mp this
    · exact (Polynomial.aeval_map_algebraMap K _ _).trans px
  · 

Proof state:
case mpr.intro.intro
R : Type u_1
inst✝¹² : CommRing R
M : Submonoid R
S : Type u_2
inst✝¹¹ : CommRing S
inst✝¹⁰ : Algebra R S
P : Type u_3
inst✝⁹ : CommRing P
A : Type u_4
K : Type u_5
C : Type u_6
inst✝⁸ : CommRing A
inst✝⁷ : IsDomain A
inst✝⁶ : Field K
inst✝⁵ : Algebra A K
inst✝⁴ : IsFractionRing A K
inst✝³ : CommRing C
inst✝² : Algebra A C
inst✝¹ : Algebra K C
inst✝ : IsScalarTower A K C
x : C
p : K[X]
hp : p ≠ 0
px : (aeval x) p = 0
⊢ IsAlgebraic A x

Next tactic:
exact
      ⟨integerNormalization _ p, mt integerNormalization_eq_zero_iff.mp hp,
        integerNormalization_aeval_eq_zero _ p px⟩
theorem RingHom.isIntegralElem_localization_at_leadingCoeff {R S : Type*} [CommRing R] [CommRing S]
    (f : R →+* S) (x : S) (p : R[X]) (hf : p.eval₂ f x = 0) (M : Submonoid R)
    (hM : p.leadingCoeff ∈ M) {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ] [Algebra R Rₘ]
    [IsLocalization M Rₘ] [Algebra S Sₘ] [IsLocalization (M.map f : Submonoid S) Sₘ] :
    (map Sₘ f M.le_comap_map : Rₘ →+* _).IsIntegralElem (algebraMap S Sₘ x) := by
  

Proof state:
R✝ : Type u_1
inst✝¹⁷ : CommRing R✝
M✝ : Submonoid R✝
S✝ : Type u_2
inst✝¹⁶ : CommRing S✝
inst✝¹⁵ : Algebra R✝ S✝
P : Type u_3
inst✝¹⁴ : CommRing P
Rₘ✝ : Type u_4
Sₘ✝ : Type u_5
inst✝¹³ : CommRing Rₘ✝
inst✝¹² : CommRing Sₘ✝
inst✝¹¹ : Algebra R✝ Rₘ✝
inst✝¹⁰ : IsLocalization M✝ Rₘ✝
inst✝⁹ : Algebra S✝ Sₘ✝
inst✝⁸ : IsLocalization (Algebra.algebraMapSubmonoid S✝ M✝) Sₘ✝
R : Type u_6
S : Type u_7
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
x : S
p : R[X]
hf : eval₂ f x p = 0
M : Submonoid R
hM : leadingCoeff p ∈ M
Rₘ : Type u_8
Sₘ : Type u_9
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
inst✝³ : Algebra R Rₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : Algebra S Sₘ
inst✝ : IsLocalization (Submonoid.map f M) Sₘ
⊢ IsIntegralElem (IsLocalization.map Sₘ f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))) ((algebraMap S Sₘ) x)

Next tactic:
by_cases triv : (1 : Rₘ) = 0
theorem RingHom.isIntegralElem_localization_at_leadingCoeff {R S : Type*} [CommRing R] [CommRing S]
    (f : R →+* S) (x : S) (p : R[X]) (hf : p.eval₂ f x = 0) (M : Submonoid R)
    (hM : p.leadingCoeff ∈ M) {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ] [Algebra R Rₘ]
    [IsLocalization M Rₘ] [Algebra S Sₘ] [IsLocalization (M.map f : Submonoid S) Sₘ] :
    (map Sₘ f M.le_comap_map : Rₘ →+* _).IsIntegralElem (algebraMap S Sₘ x) := by
  by_cases triv : (1 : Rₘ) = 0
  · 

Proof state:
case pos
R✝ : Type u_1
inst✝¹⁷ : CommRing R✝
M✝ : Submonoid R✝
S✝ : Type u_2
inst✝¹⁶ : CommRing S✝
inst✝¹⁵ : Algebra R✝ S✝
P : Type u_3
inst✝¹⁴ : CommRing P
Rₘ✝ : Type u_4
Sₘ✝ : Type u_5
inst✝¹³ : CommRing Rₘ✝
inst✝¹² : CommRing Sₘ✝
inst✝¹¹ : Algebra R✝ Rₘ✝
inst✝¹⁰ : IsLocalization M✝ Rₘ✝
inst✝⁹ : Algebra S✝ Sₘ✝
inst✝⁸ : IsLocalization (Algebra.algebraMapSubmonoid S✝ M✝) Sₘ✝
R : Type u_6
S : Type u_7
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
x : S
p : R[X]
hf : eval₂ f x p = 0
M : Submonoid R
hM : leadingCoeff p ∈ M
Rₘ : Type u_8
Sₘ : Type u_9
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
inst✝³ : Algebra R Rₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : Algebra S Sₘ
inst✝ : IsLocalization (Submonoid.map f M) Sₘ
triv : 1 = 0
⊢ IsIntegralElem (IsLocalization.map Sₘ f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))) ((algebraMap S Sₘ) x)

Next tactic:
exact ⟨0, ⟨_root_.trans leadingCoeff_zero triv.symm, eval₂_zero _ _⟩⟩
theorem RingHom.isIntegralElem_localization_at_leadingCoeff {R S : Type*} [CommRing R] [CommRing S]
    (f : R →+* S) (x : S) (p : R[X]) (hf : p.eval₂ f x = 0) (M : Submonoid R)
    (hM : p.leadingCoeff ∈ M) {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ] [Algebra R Rₘ]
    [IsLocalization M Rₘ] [Algebra S Sₘ] [IsLocalization (M.map f : Submonoid S) Sₘ] :
    (map Sₘ f M.le_comap_map : Rₘ →+* _).IsIntegralElem (algebraMap S Sₘ x) := by
  by_cases triv : (1 : Rₘ) = 0
  · exact ⟨0, ⟨_root_.trans leadingCoeff_zero triv.symm, eval₂_zero _ _⟩⟩
  

Proof state:
case neg
R✝ : Type u_1
inst✝¹⁷ : CommRing R✝
M✝ : Submonoid R✝
S✝ : Type u_2
inst✝¹⁶ : CommRing S✝
inst✝¹⁵ : Algebra R✝ S✝
P : Type u_3
inst✝¹⁴ : CommRing P
Rₘ✝ : Type u_4
Sₘ✝ : Type u_5
inst✝¹³ : CommRing Rₘ✝
inst✝¹² : CommRing Sₘ✝
inst✝¹¹ : Algebra R✝ Rₘ✝
inst✝¹⁰ : IsLocalization M✝ Rₘ✝
inst✝⁹ : Algebra S✝ Sₘ✝
inst✝⁸ : IsLocalization (Algebra.algebraMapSubmonoid S✝ M✝) Sₘ✝
R : Type u_6
S : Type u_7
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
x : S
p : R[X]
hf : eval₂ f x p = 0
M : Submonoid R
hM : leadingCoeff p ∈ M
Rₘ : Type u_8
Sₘ : Type u_9
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
inst✝³ : Algebra R Rₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : Algebra S Sₘ
inst✝ : IsLocalization (Submonoid.map f M) Sₘ
triv : ¬1 = 0
⊢ IsIntegralElem (IsLocalization.map Sₘ f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))) ((algebraMap S Sₘ) x)

Next tactic:
haveI : Nontrivial Rₘ := nontrivial_of_ne 1 0 triv
theorem RingHom.isIntegralElem_localization_at_leadingCoeff {R S : Type*} [CommRing R] [CommRing S]
    (f : R →+* S) (x : S) (p : R[X]) (hf : p.eval₂ f x = 0) (M : Submonoid R)
    (hM : p.leadingCoeff ∈ M) {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ] [Algebra R Rₘ]
    [IsLocalization M Rₘ] [Algebra S Sₘ] [IsLocalization (M.map f : Submonoid S) Sₘ] :
    (map Sₘ f M.le_comap_map : Rₘ →+* _).IsIntegralElem (algebraMap S Sₘ x) := by
  by_cases triv : (1 : Rₘ) = 0
  · exact ⟨0, ⟨_root_.trans leadingCoeff_zero triv.symm, eval₂_zero _ _⟩⟩
  haveI : Nontrivial Rₘ := nontrivial_of_ne 1 0 triv
  

Proof state:
case neg
R✝ : Type u_1
inst✝¹⁷ : CommRing R✝
M✝ : Submonoid R✝
S✝ : Type u_2
inst✝¹⁶ : CommRing S✝
inst✝¹⁵ : Algebra R✝ S✝
P : Type u_3
inst✝¹⁴ : CommRing P
Rₘ✝ : Type u_4
Sₘ✝ : Type u_5
inst✝¹³ : CommRing Rₘ✝
inst✝¹² : CommRing Sₘ✝
inst✝¹¹ : Algebra R✝ Rₘ✝
inst✝¹⁰ : IsLocalization M✝ Rₘ✝
inst✝⁹ : Algebra S✝ Sₘ✝
inst✝⁸ : IsLocalization (Algebra.algebraMapSubmonoid S✝ M✝) Sₘ✝
R : Type u_6
S : Type u_7
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
x : S
p : R[X]
hf : eval₂ f x p = 0
M : Submonoid R
hM : leadingCoeff p ∈ M
Rₘ : Type u_8
Sₘ : Type u_9
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
inst✝³ : Algebra R Rₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : Algebra S Sₘ
inst✝ : IsLocalization (Submonoid.map f M) Sₘ
triv : ¬1 = 0
this : Nontrivial Rₘ
⊢ IsIntegralElem (IsLocalization.map Sₘ f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))) ((algebraMap S Sₘ) x)

Next tactic:
obtain ⟨b, hb⟩ := isUnit_iff_exists_inv.mp (map_units Rₘ ⟨p.leadingCoeff, hM⟩)
theorem RingHom.isIntegralElem_localization_at_leadingCoeff {R S : Type*} [CommRing R] [CommRing S]
    (f : R →+* S) (x : S) (p : R[X]) (hf : p.eval₂ f x = 0) (M : Submonoid R)
    (hM : p.leadingCoeff ∈ M) {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ] [Algebra R Rₘ]
    [IsLocalization M Rₘ] [Algebra S Sₘ] [IsLocalization (M.map f : Submonoid S) Sₘ] :
    (map Sₘ f M.le_comap_map : Rₘ →+* _).IsIntegralElem (algebraMap S Sₘ x) := by
  by_cases triv : (1 : Rₘ) = 0
  · exact ⟨0, ⟨_root_.trans leadingCoeff_zero triv.symm, eval₂_zero _ _⟩⟩
  haveI : Nontrivial Rₘ := nontrivial_of_ne 1 0 triv
  obtain ⟨b, hb⟩ := isUnit_iff_exists_inv.mp (map_units Rₘ ⟨p.leadingCoeff, hM⟩)
  

Proof state:
case neg.intro
R✝ : Type u_1
inst✝¹⁷ : CommRing R✝
M✝ : Submonoid R✝
S✝ : Type u_2
inst✝¹⁶ : CommRing S✝
inst✝¹⁵ : Algebra R✝ S✝
P : Type u_3
inst✝¹⁴ : CommRing P
Rₘ✝ : Type u_4
Sₘ✝ : Type u_5
inst✝¹³ : CommRing Rₘ✝
inst✝¹² : CommRing Sₘ✝
inst✝¹¹ : Algebra R✝ Rₘ✝
inst✝¹⁰ : IsLocalization M✝ Rₘ✝
inst✝⁹ : Algebra S✝ Sₘ✝
inst✝⁸ : IsLocalization (Algebra.algebraMapSubmonoid S✝ M✝) Sₘ✝
R : Type u_6
S : Type u_7
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
x : S
p : R[X]
hf : eval₂ f x p = 0
M : Submonoid R
hM : leadingCoeff p ∈ M
Rₘ : Type u_8
Sₘ : Type u_9
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
inst✝³ : Algebra R Rₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : Algebra S Sₘ
inst✝ : IsLocalization (Submonoid.map f M) Sₘ
triv : ¬1 = 0
this : Nontrivial Rₘ
b : Rₘ
hb : (algebraMap R Rₘ) ↑{ val := leadingCoeff p, property := hM } * b = 1
⊢ IsIntegralElem (IsLocalization.map Sₘ f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))) ((algebraMap S Sₘ) x)

Next tactic:
refine' ⟨p.map (algebraMap R Rₘ) * C b, ⟨_, _⟩⟩
theorem RingHom.isIntegralElem_localization_at_leadingCoeff {R S : Type*} [CommRing R] [CommRing S]
    (f : R →+* S) (x : S) (p : R[X]) (hf : p.eval₂ f x = 0) (M : Submonoid R)
    (hM : p.leadingCoeff ∈ M) {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ] [Algebra R Rₘ]
    [IsLocalization M Rₘ] [Algebra S Sₘ] [IsLocalization (M.map f : Submonoid S) Sₘ] :
    (map Sₘ f M.le_comap_map : Rₘ →+* _).IsIntegralElem (algebraMap S Sₘ x) := by
  by_cases triv : (1 : Rₘ) = 0
  · exact ⟨0, ⟨_root_.trans leadingCoeff_zero triv.symm, eval₂_zero _ _⟩⟩
  haveI : Nontrivial Rₘ := nontrivial_of_ne 1 0 triv
  obtain ⟨b, hb⟩ := isUnit_iff_exists_inv.mp (map_units Rₘ ⟨p.leadingCoeff, hM⟩)
  refine' ⟨p.map (algebraMap R Rₘ) * C b, ⟨_, _⟩⟩
  · 

Proof state:
case neg.intro.refine'_1
R✝ : Type u_1
inst✝¹⁷ : CommRing R✝
M✝ : Submonoid R✝
S✝ : Type u_2
inst✝¹⁶ : CommRing S✝
inst✝¹⁵ : Algebra R✝ S✝
P : Type u_3
inst✝¹⁴ : CommRing P
Rₘ✝ : Type u_4
Sₘ✝ : Type u_5
inst✝¹³ : CommRing Rₘ✝
inst✝¹² : CommRing Sₘ✝
inst✝¹¹ : Algebra R✝ Rₘ✝
inst✝¹⁰ : IsLocalization M✝ Rₘ✝
inst✝⁹ : Algebra S✝ Sₘ✝
inst✝⁸ : IsLocalization (Algebra.algebraMapSubmonoid S✝ M✝) Sₘ✝
R : Type u_6
S : Type u_7
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
x : S
p : R[X]
hf : eval₂ f x p = 0
M : Submonoid R
hM : leadingCoeff p ∈ M
Rₘ : Type u_8
Sₘ : Type u_9
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
inst✝³ : Algebra R Rₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : Algebra S Sₘ
inst✝ : IsLocalization (Submonoid.map f M) Sₘ
triv : ¬1 = 0
this : Nontrivial Rₘ
b : Rₘ
hb : (algebraMap R Rₘ) ↑{ val := leadingCoeff p, property := hM } * b = 1
⊢ Monic (Polynomial.map (algebraMap R Rₘ) p * C b)

Next tactic:
refine' monic_mul_C_of_leadingCoeff_mul_eq_one _
theorem RingHom.isIntegralElem_localization_at_leadingCoeff {R S : Type*} [CommRing R] [CommRing S]
    (f : R →+* S) (x : S) (p : R[X]) (hf : p.eval₂ f x = 0) (M : Submonoid R)
    (hM : p.leadingCoeff ∈ M) {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ] [Algebra R Rₘ]
    [IsLocalization M Rₘ] [Algebra S Sₘ] [IsLocalization (M.map f : Submonoid S) Sₘ] :
    (map Sₘ f M.le_comap_map : Rₘ →+* _).IsIntegralElem (algebraMap S Sₘ x) := by
  by_cases triv : (1 : Rₘ) = 0
  · exact ⟨0, ⟨_root_.trans leadingCoeff_zero triv.symm, eval₂_zero _ _⟩⟩
  haveI : Nontrivial Rₘ := nontrivial_of_ne 1 0 triv
  obtain ⟨b, hb⟩ := isUnit_iff_exists_inv.mp (map_units Rₘ ⟨p.leadingCoeff, hM⟩)
  refine' ⟨p.map (algebraMap R Rₘ) * C b, ⟨_, _⟩⟩
  · refine' monic_mul_C_of_leadingCoeff_mul_eq_one _
    

Proof state:
case neg.intro.refine'_1
R✝ : Type u_1
inst✝¹⁷ : CommRing R✝
M✝ : Submonoid R✝
S✝ : Type u_2
inst✝¹⁶ : CommRing S✝
inst✝¹⁵ : Algebra R✝ S✝
P : Type u_3
inst✝¹⁴ : CommRing P
Rₘ✝ : Type u_4
Sₘ✝ : Type u_5
inst✝¹³ : CommRing Rₘ✝
inst✝¹² : CommRing Sₘ✝
inst✝¹¹ : Algebra R✝ Rₘ✝
inst✝¹⁰ : IsLocalization M✝ Rₘ✝
inst✝⁹ : Algebra S✝ Sₘ✝
inst✝⁸ : IsLocalization (Algebra.algebraMapSubmonoid S✝ M✝) Sₘ✝
R : Type u_6
S : Type u_7
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
x : S
p : R[X]
hf : eval₂ f x p = 0
M : Submonoid R
hM : leadingCoeff p ∈ M
Rₘ : Type u_8
Sₘ : Type u_9
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
inst✝³ : Algebra R Rₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : Algebra S Sₘ
inst✝ : IsLocalization (Submonoid.map f M) Sₘ
triv : ¬1 = 0
this : Nontrivial Rₘ
b : Rₘ
hb : (algebraMap R Rₘ) ↑{ val := leadingCoeff p, property := hM } * b = 1
⊢ leadingCoeff (Polynomial.map (algebraMap R Rₘ) p) * b = 1

Next tactic:
rwa [leadingCoeff_map_of_leadingCoeff_ne_zero (algebraMap R Rₘ)]
theorem RingHom.isIntegralElem_localization_at_leadingCoeff {R S : Type*} [CommRing R] [CommRing S]
    (f : R →+* S) (x : S) (p : R[X]) (hf : p.eval₂ f x = 0) (M : Submonoid R)
    (hM : p.leadingCoeff ∈ M) {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ] [Algebra R Rₘ]
    [IsLocalization M Rₘ] [Algebra S Sₘ] [IsLocalization (M.map f : Submonoid S) Sₘ] :
    (map Sₘ f M.le_comap_map : Rₘ →+* _).IsIntegralElem (algebraMap S Sₘ x) := by
  by_cases triv : (1 : Rₘ) = 0
  · exact ⟨0, ⟨_root_.trans leadingCoeff_zero triv.symm, eval₂_zero _ _⟩⟩
  haveI : Nontrivial Rₘ := nontrivial_of_ne 1 0 triv
  obtain ⟨b, hb⟩ := isUnit_iff_exists_inv.mp (map_units Rₘ ⟨p.leadingCoeff, hM⟩)
  refine' ⟨p.map (algebraMap R Rₘ) * C b, ⟨_, _⟩⟩
  · refine' monic_mul_C_of_leadingCoeff_mul_eq_one _
    rwa [leadingCoeff_map_of_leadingCoeff_ne_zero (algebraMap R Rₘ)]
    

Proof state:
case neg.intro.refine'_1
R✝ : Type u_1
inst✝¹⁷ : CommRing R✝
M✝ : Submonoid R✝
S✝ : Type u_2
inst✝¹⁶ : CommRing S✝
inst✝¹⁵ : Algebra R✝ S✝
P : Type u_3
inst✝¹⁴ : CommRing P
Rₘ✝ : Type u_4
Sₘ✝ : Type u_5
inst✝¹³ : CommRing Rₘ✝
inst✝¹² : CommRing Sₘ✝
inst✝¹¹ : Algebra R✝ Rₘ✝
inst✝¹⁰ : IsLocalization M✝ Rₘ✝
inst✝⁹ : Algebra S✝ Sₘ✝
inst✝⁸ : IsLocalization (Algebra.algebraMapSubmonoid S✝ M✝) Sₘ✝
R : Type u_6
S : Type u_7
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
x : S
p : R[X]
hf : eval₂ f x p = 0
M : Submonoid R
hM : leadingCoeff p ∈ M
Rₘ : Type u_8
Sₘ : Type u_9
inst✝⁵ : CommRing Rₘ
inst✝⁴ : CommRing Sₘ
inst✝³ : Algebra R Rₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : Algebra S Sₘ
inst✝ : IsLocalization (Submonoid.map f M) Sₘ
triv : ¬1 = 0
this : Nontrivial Rₘ
b : Rₘ
hb : (algebraMap R Rₘ) ↑{ val := leadingCoeff p, property := hM } * b = 1
⊢ (algebraMap R Rₘ) (leadingCoeff p) ≠ 0

Next tactic:
refine' fun hfp => zero_ne_one
      (_root_.trans (zero_mul b).symm (hfp ▸ hb) : (0 : Rₘ) = 1)