l3lab/ntp-mathlib huggingface dataset:
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ₘ)]
    refine' fun hfp => zero_ne_one
      (_root_.trans (zero_mul b).symm (hfp ▸ hb) : (0 : Rₘ) = 1)
  · 

Proof state:
case neg.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
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
⊢ eval₂ (IsLocalization.map Sₘ f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))) ((algebraMap S Sₘ) x)
      (Polynomial.map (algebraMap R Rₘ) p * C b) =
    0

Next tactic:
refine' eval₂_mul_eq_zero_of_left _ _ _ _
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ₘ)]
    refine' fun hfp => zero_ne_one
      (_root_.trans (zero_mul b).symm (hfp ▸ hb) : (0 : Rₘ) = 1)
  · refine' eval₂_mul_eq_zero_of_left _ _ _ _
    

Proof state:
case neg.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
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
⊢ eval₂ (IsLocalization.map Sₘ f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))) ((algebraMap S Sₘ) x)
      (Polynomial.map (algebraMap R Rₘ) p) =
    0

Next tactic:
erw [eval₂_map, IsLocalization.map_comp, ← hom_eval₂ _ f (algebraMap S Sₘ) x]
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ₘ)]
    refine' fun hfp => zero_ne_one
      (_root_.trans (zero_mul b).symm (hfp ▸ hb) : (0 : Rₘ) = 1)
  · refine' eval₂_mul_eq_zero_of_left _ _ _ _
    erw [eval₂_map, IsLocalization.map_comp, ← hom_eval₂ _ f (algebraMap S Sₘ) x]
    

Proof state:
case neg.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
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 S Sₘ) (eval₂ f x p) = 0

Next tactic:
exact _root_.trans (congr_arg (algebraMap S Sₘ) hf) (RingHom.map_zero _)
/-- If `R → S` is an integral extension, `M` is a submonoid of `R`,
`Rₘ` is the localization of `R` at `M`,
and `Sₘ` is the localization of `S` at the image of `M` under the extension map,
then the induced map `Rₘ → Sₘ` is also an integral extension -/
theorem isIntegral_localization (H : Algebra.IsIntegral R S) :
    (map Sₘ (algebraMap R S)
          (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
        Rₘ →+* _).IsIntegral := 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ₘ
H : Algebra.IsIntegral R S
⊢ RingHom.IsIntegral
    (IsLocalization.map Sₘ (algebraMap R S)
      (_ : M ≤ Submonoid.comap (algebraMap R S) (Algebra.algebraMapSubmonoid S M)))

Next tactic:
intro x
/-- If `R → S` is an integral extension, `M` is a submonoid of `R`,
`Rₘ` is the localization of `R` at `M`,
and `Sₘ` is the localization of `S` at the image of `M` under the extension map,
then the induced map `Rₘ → Sₘ` is also an integral extension -/
theorem isIntegral_localization (H : Algebra.IsIntegral R S) :
    (map Sₘ (algebraMap R S)
          (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
        Rₘ →+* _).IsIntegral := by
  intro x
  

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ₘ
H : Algebra.IsIntegral R S
x : Sₘ
⊢ RingHom.IsIntegralElem
    (IsLocalization.map Sₘ (algebraMap R S)
      (_ : M ≤ Submonoid.comap (algebraMap R S) (Algebra.algebraMapSubmonoid S M)))
    x

Next tactic:
obtain ⟨⟨s, ⟨u, hu⟩⟩, hx⟩ := surj (Algebra.algebraMapSubmonoid S M) x
/-- If `R → S` is an integral extension, `M` is a submonoid of `R`,
`Rₘ` is the localization of `R` at `M`,
and `Sₘ` is the localization of `S` at the image of `M` under the extension map,
then the induced map `Rₘ → Sₘ` is also an integral extension -/
theorem isIntegral_localization (H : Algebra.IsIntegral R S) :
    (map Sₘ (algebraMap R S)
          (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
        Rₘ →+* _).IsIntegral := by
  intro x
  obtain ⟨⟨s, ⟨u, hu⟩⟩, hx⟩ := surj (Algebra.algebraMapSubmonoid S M) x
  

Proof state:
case intro.mk.mk
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ₘ
H : Algebra.IsIntegral R S
x : Sₘ
s u : S
hu : u ∈ Algebra.algebraMapSubmonoid S M
hx : x * (algebraMap S Sₘ) ↑(s, { val := u, property := hu }).2 = (algebraMap S Sₘ) (s, { val := u, property := hu }).1
⊢ RingHom.IsIntegralElem
    (IsLocalization.map Sₘ (algebraMap R S)
      (_ : M ≤ Submonoid.comap (algebraMap R S) (Algebra.algebraMapSubmonoid S M)))
    x

Next tactic:
obtain ⟨v, hv⟩ := hu
/-- If `R → S` is an integral extension, `M` is a submonoid of `R`,
`Rₘ` is the localization of `R` at `M`,
and `Sₘ` is the localization of `S` at the image of `M` under the extension map,
then the induced map `Rₘ → Sₘ` is also an integral extension -/
theorem isIntegral_localization (H : Algebra.IsIntegral R S) :
    (map Sₘ (algebraMap R S)
          (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
        Rₘ →+* _).IsIntegral := by
  intro x
  obtain ⟨⟨s, ⟨u, hu⟩⟩, hx⟩ := surj (Algebra.algebraMapSubmonoid S M) x
  obtain ⟨v, hv⟩ := hu
  

Proof state:
case intro.mk.mk.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ₘ
H : Algebra.IsIntegral R S
x : Sₘ
s u : S
v : R
hv : v ∈ ↑M ∧ (algebraMap R S) v = u
hx :
  x * (algebraMap S Sₘ) ↑(s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).2 =
    (algebraMap S Sₘ) (s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).1
⊢ RingHom.IsIntegralElem
    (IsLocalization.map Sₘ (algebraMap R S)
      (_ : M ≤ Submonoid.comap (algebraMap R S) (Algebra.algebraMapSubmonoid S M)))
    x

Next tactic:
obtain ⟨v', hv'⟩ := isUnit_iff_exists_inv'.1 (map_units Rₘ ⟨v, hv.1⟩)
/-- If `R → S` is an integral extension, `M` is a submonoid of `R`,
`Rₘ` is the localization of `R` at `M`,
and `Sₘ` is the localization of `S` at the image of `M` under the extension map,
then the induced map `Rₘ → Sₘ` is also an integral extension -/
theorem isIntegral_localization (H : Algebra.IsIntegral R S) :
    (map Sₘ (algebraMap R S)
          (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
        Rₘ →+* _).IsIntegral := by
  intro x
  obtain ⟨⟨s, ⟨u, hu⟩⟩, hx⟩ := surj (Algebra.algebraMapSubmonoid S M) x
  obtain ⟨v, hv⟩ := hu
  obtain ⟨v', hv'⟩ := isUnit_iff_exists_inv'.1 (map_units Rₘ ⟨v, hv.1⟩)
  

Proof state:
case intro.mk.mk.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
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ₘ
H : Algebra.IsIntegral R S
x : Sₘ
s u : S
v : R
hv : v ∈ ↑M ∧ (algebraMap R S) v = u
hx :
  x * (algebraMap S Sₘ) ↑(s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).2 =
    (algebraMap S Sₘ) (s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).1
v' : Rₘ
hv' : v' * (algebraMap R Rₘ) ↑{ val := v, property := (_ : v ∈ ↑M) } = 1
⊢ RingHom.IsIntegralElem
    (IsLocalization.map Sₘ (algebraMap R S)
      (_ : M ≤ Submonoid.comap (algebraMap R S) (Algebra.algebraMapSubmonoid S M)))
    x

Next tactic:
refine @IsIntegral.of_mul_unit Rₘ _ _ _ (localizationAlgebra M S) x (algebraMap S Sₘ u) v' ?_ ?_
/-- If `R → S` is an integral extension, `M` is a submonoid of `R`,
`Rₘ` is the localization of `R` at `M`,
and `Sₘ` is the localization of `S` at the image of `M` under the extension map,
then the induced map `Rₘ → Sₘ` is also an integral extension -/
theorem isIntegral_localization (H : Algebra.IsIntegral R S) :
    (map Sₘ (algebraMap R S)
          (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
        Rₘ →+* _).IsIntegral := by
  intro x
  obtain ⟨⟨s, ⟨u, hu⟩⟩, hx⟩ := surj (Algebra.algebraMapSubmonoid S M) x
  obtain ⟨v, hv⟩ := hu
  obtain ⟨v', hv'⟩ := isUnit_iff_exists_inv'.1 (map_units Rₘ ⟨v, hv.1⟩)
  refine @IsIntegral.of_mul_unit Rₘ _ _ _ (localizationAlgebra M S) x (algebraMap S Sₘ u) v' ?_ ?_
  · 

Proof state:
case intro.mk.mk.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
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ₘ
H : Algebra.IsIntegral R S
x : Sₘ
s u : S
v : R
hv : v ∈ ↑M ∧ (algebraMap R S) v = u
hx :
  x * (algebraMap S Sₘ) ↑(s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).2 =
    (algebraMap S Sₘ) (s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).1
v' : Rₘ
hv' : v' * (algebraMap R Rₘ) ↑{ val := v, property := (_ : v ∈ ↑M) } = 1
⊢ (algebraMap Rₘ Sₘ) v' * (algebraMap S Sₘ) u = 1

Next tactic:
replace hv' := congr_arg (@algebraMap Rₘ Sₘ _ _ (localizationAlgebra M S)) hv'
/-- If `R → S` is an integral extension, `M` is a submonoid of `R`,
`Rₘ` is the localization of `R` at `M`,
and `Sₘ` is the localization of `S` at the image of `M` under the extension map,
then the induced map `Rₘ → Sₘ` is also an integral extension -/
theorem isIntegral_localization (H : Algebra.IsIntegral R S) :
    (map Sₘ (algebraMap R S)
          (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
        Rₘ →+* _).IsIntegral := by
  intro x
  obtain ⟨⟨s, ⟨u, hu⟩⟩, hx⟩ := surj (Algebra.algebraMapSubmonoid S M) x
  obtain ⟨v, hv⟩ := hu
  obtain ⟨v', hv'⟩ := isUnit_iff_exists_inv'.1 (map_units Rₘ ⟨v, hv.1⟩)
  refine @IsIntegral.of_mul_unit Rₘ _ _ _ (localizationAlgebra M S) x (algebraMap S Sₘ u) v' ?_ ?_
  · replace hv' := congr_arg (@algebraMap Rₘ Sₘ _ _ (localizationAlgebra M S)) hv'
    

Proof state:
case intro.mk.mk.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
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ₘ
H : Algebra.IsIntegral R S
x : Sₘ
s u : S
v : R
hv : v ∈ ↑M ∧ (algebraMap R S) v = u
hx :
  x * (algebraMap S Sₘ) ↑(s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).2 =
    (algebraMap S Sₘ) (s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).1
v' : Rₘ
hv' : (algebraMap Rₘ Sₘ) (v' * (algebraMap R Rₘ) ↑{ val := v, property := (_ : v ∈ ↑M) }) = (algebraMap Rₘ Sₘ) 1
⊢ (algebraMap Rₘ Sₘ) v' * (algebraMap S Sₘ) u = 1

Next tactic:
rw [RingHom.map_mul, RingHom.map_one, ← RingHom.comp_apply _ (algebraMap R Rₘ)] at hv'
/-- If `R → S` is an integral extension, `M` is a submonoid of `R`,
`Rₘ` is the localization of `R` at `M`,
and `Sₘ` is the localization of `S` at the image of `M` under the extension map,
then the induced map `Rₘ → Sₘ` is also an integral extension -/
theorem isIntegral_localization (H : Algebra.IsIntegral R S) :
    (map Sₘ (algebraMap R S)
          (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
        Rₘ →+* _).IsIntegral := by
  intro x
  obtain ⟨⟨s, ⟨u, hu⟩⟩, hx⟩ := surj (Algebra.algebraMapSubmonoid S M) x
  obtain ⟨v, hv⟩ := hu
  obtain ⟨v', hv'⟩ := isUnit_iff_exists_inv'.1 (map_units Rₘ ⟨v, hv.1⟩)
  refine @IsIntegral.of_mul_unit Rₘ _ _ _ (localizationAlgebra M S) x (algebraMap S Sₘ u) v' ?_ ?_
  · replace hv' := congr_arg (@algebraMap Rₘ Sₘ _ _ (localizationAlgebra M S)) hv'
    rw [RingHom.map_mul, RingHom.map_one, ← RingHom.comp_apply _ (algebraMap R Rₘ)] at hv'
    -- Porting note: added argument
    

Proof state:
case intro.mk.mk.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
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ₘ
H : Algebra.IsIntegral R S
x : Sₘ
s u : S
v : R
hv : v ∈ ↑M ∧ (algebraMap R S) v = u
hx :
  x * (algebraMap S Sₘ) ↑(s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).2 =
    (algebraMap S Sₘ) (s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).1
v' : Rₘ
hv' :
  (algebraMap Rₘ Sₘ) v' * (RingHom.comp (algebraMap Rₘ Sₘ) (algebraMap R Rₘ)) ↑{ val := v, property := (_ : v ∈ ↑M) } =
    1
⊢ (algebraMap Rₘ Sₘ) v' * (algebraMap S Sₘ) u = 1

Next tactic:
erw [IsLocalization.map_comp
      (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map)] at hv'
/-- If `R → S` is an integral extension, `M` is a submonoid of `R`,
`Rₘ` is the localization of `R` at `M`,
and `Sₘ` is the localization of `S` at the image of `M` under the extension map,
then the induced map `Rₘ → Sₘ` is also an integral extension -/
theorem isIntegral_localization (H : Algebra.IsIntegral R S) :
    (map Sₘ (algebraMap R S)
          (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
        Rₘ →+* _).IsIntegral := by
  intro x
  obtain ⟨⟨s, ⟨u, hu⟩⟩, hx⟩ := surj (Algebra.algebraMapSubmonoid S M) x
  obtain ⟨v, hv⟩ := hu
  obtain ⟨v', hv'⟩ := isUnit_iff_exists_inv'.1 (map_units Rₘ ⟨v, hv.1⟩)
  refine @IsIntegral.of_mul_unit Rₘ _ _ _ (localizationAlgebra M S) x (algebraMap S Sₘ u) v' ?_ ?_
  · replace hv' := congr_arg (@algebraMap Rₘ Sₘ _ _ (localizationAlgebra M S)) hv'
    rw [RingHom.map_mul, RingHom.map_one, ← RingHom.comp_apply _ (algebraMap R Rₘ)] at hv'
    -- Porting note: added argument
    erw [IsLocalization.map_comp
      (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map)] at hv'
    

Proof state:
case intro.mk.mk.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
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ₘ
H : Algebra.IsIntegral R S
x : Sₘ
s u : S
v : R
hv : v ∈ ↑M ∧ (algebraMap R S) v = u
hx :
  x * (algebraMap S Sₘ) ↑(s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).2 =
    (algebraMap S Sₘ) (s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).1
v' : Rₘ
hv' :
  (algebraMap Rₘ Sₘ) v' * (RingHom.comp (algebraMap S Sₘ) (algebraMap R S)) ↑{ val := v, property := (_ : v ∈ ↑M) } = 1
⊢ (algebraMap Rₘ Sₘ) v' * (algebraMap S Sₘ) u = 1

Next tactic:
exact hv.2 ▸ hv'
/-- If `R → S` is an integral extension, `M` is a submonoid of `R`,
`Rₘ` is the localization of `R` at `M`,
and `Sₘ` is the localization of `S` at the image of `M` under the extension map,
then the induced map `Rₘ → Sₘ` is also an integral extension -/
theorem isIntegral_localization (H : Algebra.IsIntegral R S) :
    (map Sₘ (algebraMap R S)
          (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
        Rₘ →+* _).IsIntegral := by
  intro x
  obtain ⟨⟨s, ⟨u, hu⟩⟩, hx⟩ := surj (Algebra.algebraMapSubmonoid S M) x
  obtain ⟨v, hv⟩ := hu
  obtain ⟨v', hv'⟩ := isUnit_iff_exists_inv'.1 (map_units Rₘ ⟨v, hv.1⟩)
  refine @IsIntegral.of_mul_unit Rₘ _ _ _ (localizationAlgebra M S) x (algebraMap S Sₘ u) v' ?_ ?_
  · replace hv' := congr_arg (@algebraMap Rₘ Sₘ _ _ (localizationAlgebra M S)) hv'
    rw [RingHom.map_mul, RingHom.map_one, ← RingHom.comp_apply _ (algebraMap R Rₘ)] at hv'
    -- Porting note: added argument
    erw [IsLocalization.map_comp
      (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map)] at hv'
    exact hv.2 ▸ hv'
  · 

Proof state:
case intro.mk.mk.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
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ₘ
H : Algebra.IsIntegral R S
x : Sₘ
s u : S
v : R
hv : v ∈ ↑M ∧ (algebraMap R S) v = u
hx :
  x * (algebraMap S Sₘ) ↑(s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).2 =
    (algebraMap S Sₘ) (s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).1
v' : Rₘ
hv' : v' * (algebraMap R Rₘ) ↑{ val := v, property := (_ : v ∈ ↑M) } = 1
⊢ IsIntegral Rₘ (x * (algebraMap S Sₘ) u)

Next tactic:
obtain ⟨p, hp⟩ := H s
/-- If `R → S` is an integral extension, `M` is a submonoid of `R`,
`Rₘ` is the localization of `R` at `M`,
and `Sₘ` is the localization of `S` at the image of `M` under the extension map,
then the induced map `Rₘ → Sₘ` is also an integral extension -/
theorem isIntegral_localization (H : Algebra.IsIntegral R S) :
    (map Sₘ (algebraMap R S)
          (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
        Rₘ →+* _).IsIntegral := by
  intro x
  obtain ⟨⟨s, ⟨u, hu⟩⟩, hx⟩ := surj (Algebra.algebraMapSubmonoid S M) x
  obtain ⟨v, hv⟩ := hu
  obtain ⟨v', hv'⟩ := isUnit_iff_exists_inv'.1 (map_units Rₘ ⟨v, hv.1⟩)
  refine @IsIntegral.of_mul_unit Rₘ _ _ _ (localizationAlgebra M S) x (algebraMap S Sₘ u) v' ?_ ?_
  · replace hv' := congr_arg (@algebraMap Rₘ Sₘ _ _ (localizationAlgebra M S)) hv'
    rw [RingHom.map_mul, RingHom.map_one, ← RingHom.comp_apply _ (algebraMap R Rₘ)] at hv'
    -- Porting note: added argument
    erw [IsLocalization.map_comp
      (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map)] at hv'
    exact hv.2 ▸ hv'
  · obtain ⟨p, hp⟩ := H s
    

Proof state:
case intro.mk.mk.intro.intro.refine_2.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ₘ
H : Algebra.IsIntegral R S
x : Sₘ
s u : S
v : R
hv : v ∈ ↑M ∧ (algebraMap R S) v = u
hx :
  x * (algebraMap S Sₘ) ↑(s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).2 =
    (algebraMap S Sₘ) (s, { val := u, property := (_ : ∃ a ∈ ↑M, (algebraMap R S) a = u) }).1
v' : Rₘ
hv' : v' * (algebraMap R Rₘ) ↑{ val := v, property := (_ : v ∈ ↑M) } = 1
p : R[X]
hp : Monic p ∧ eval₂ (algebraMap R S) s p = 0
⊢ IsIntegral Rₘ (x * (algebraMap S Sₘ) u)

Next tactic:
exact hx.symm ▸ is_integral_localization_at_leadingCoeff p hp.2 (hp.1.symm ▸ M.one_mem)