l3lab/ntp-mathlib huggingface dataset:
/-- A `CommRing` `S` which is the localization of a ring `R` without zero divisors at a subset of
non-zero elements does not have zero divisors.
See note [reducible non-instances]. -/
@[reducible]
theorem noZeroDivisors_of_le_nonZeroDivisors [Algebra A S] {M : Submonoid A} [IsLocalization M S]
    (hM : M ≤ nonZeroDivisors A) : NoZeroDivisors S :=
  { eq_zero_or_eq_zero_of_mul_eq_zero := by
      intro z w h
      cases' surj M z with x hx
      cases' surj M w with y hy
      have :
        z * w * algebraMap A S y.2 * algebraMap A S x.2 = algebraMap A S x.1 * algebraMap A S y.1 :=
        by rw [mul_assoc z, hy, ← hx]; ring
      

Proof state:
case 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
K : Type u_4
inst✝⁶ : IsLocalization M✝ S
Q : Type u_5
inst✝⁵ : CommRing Q
g : R →+* P
inst✝⁴ : Algebra P Q
A : Type u_6
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : Algebra A S
M : Submonoid A
inst✝ : IsLocalization M S
hM : M ≤ nonZeroDivisors A
z w : S
h : z * w = 0
x : A × ↥M
hx : z * (algebraMap A S) ↑x.2 = (algebraMap A S) x.1
y : A × ↥M
hy : w * (algebraMap A S) ↑y.2 = (algebraMap A S) y.1
this : z * w * (algebraMap A S) ↑y.2 * (algebraMap A S) ↑x.2 = (algebraMap A S) x.1 * (algebraMap A S) y.1
⊢ z = 0 ∨ w = 0

Next tactic:
rw [h, zero_mul, zero_mul, ← (algebraMap A S).map_mul] at this
/-- A `CommRing` `S` which is the localization of a ring `R` without zero divisors at a subset of
non-zero elements does not have zero divisors.
See note [reducible non-instances]. -/
@[reducible]
theorem noZeroDivisors_of_le_nonZeroDivisors [Algebra A S] {M : Submonoid A} [IsLocalization M S]
    (hM : M ≤ nonZeroDivisors A) : NoZeroDivisors S :=
  { eq_zero_or_eq_zero_of_mul_eq_zero := by
      intro z w h
      cases' surj M z with x hx
      cases' surj M w with y hy
      have :
        z * w * algebraMap A S y.2 * algebraMap A S x.2 = algebraMap A S x.1 * algebraMap A S y.1 :=
        by rw [mul_assoc z, hy, ← hx]; ring
      rw [h, zero_mul, zero_mul, ← (algebraMap A S).map_mul] at this
      

Proof state:
case 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
K : Type u_4
inst✝⁶ : IsLocalization M✝ S
Q : Type u_5
inst✝⁵ : CommRing Q
g : R →+* P
inst✝⁴ : Algebra P Q
A : Type u_6
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : Algebra A S
M : Submonoid A
inst✝ : IsLocalization M S
hM : M ≤ nonZeroDivisors A
z w : S
h : z * w = 0
x : A × ↥M
hx : z * (algebraMap A S) ↑x.2 = (algebraMap A S) x.1
y : A × ↥M
hy : w * (algebraMap A S) ↑y.2 = (algebraMap A S) y.1
this : 0 = (algebraMap A S) (x.1 * y.1)
⊢ z = 0 ∨ w = 0

Next tactic:
cases' eq_zero_or_eq_zero_of_mul_eq_zero ((to_map_eq_zero_iff S hM).mp this.symm) with H H
/-- A `CommRing` `S` which is the localization of a ring `R` without zero divisors at a subset of
non-zero elements does not have zero divisors.
See note [reducible non-instances]. -/
@[reducible]
theorem noZeroDivisors_of_le_nonZeroDivisors [Algebra A S] {M : Submonoid A} [IsLocalization M S]
    (hM : M ≤ nonZeroDivisors A) : NoZeroDivisors S :=
  { eq_zero_or_eq_zero_of_mul_eq_zero := by
      intro z w h
      cases' surj M z with x hx
      cases' surj M w with y hy
      have :
        z * w * algebraMap A S y.2 * algebraMap A S x.2 = algebraMap A S x.1 * algebraMap A S y.1 :=
        by rw [mul_assoc z, hy, ← hx]; ring
      rw [h, zero_mul, zero_mul, ← (algebraMap A S).map_mul] at this
      cases' eq_zero_or_eq_zero_of_mul_eq_zero ((to_map_eq_zero_iff S hM).mp this.symm) with H H
      · 

Proof state:
case intro.intro.inl
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
K : Type u_4
inst✝⁶ : IsLocalization M✝ S
Q : Type u_5
inst✝⁵ : CommRing Q
g : R →+* P
inst✝⁴ : Algebra P Q
A : Type u_6
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : Algebra A S
M : Submonoid A
inst✝ : IsLocalization M S
hM : M ≤ nonZeroDivisors A
z w : S
h : z * w = 0
x : A × ↥M
hx : z * (algebraMap A S) ↑x.2 = (algebraMap A S) x.1
y : A × ↥M
hy : w * (algebraMap A S) ↑y.2 = (algebraMap A S) y.1
this : 0 = (algebraMap A S) (x.1 * y.1)
H : x.1 = 0
⊢ z = 0 ∨ w = 0

Next tactic:
exact Or.inl (eq_zero_of_fst_eq_zero hx H)
/-- A `CommRing` `S` which is the localization of a ring `R` without zero divisors at a subset of
non-zero elements does not have zero divisors.
See note [reducible non-instances]. -/
@[reducible]
theorem noZeroDivisors_of_le_nonZeroDivisors [Algebra A S] {M : Submonoid A} [IsLocalization M S]
    (hM : M ≤ nonZeroDivisors A) : NoZeroDivisors S :=
  { eq_zero_or_eq_zero_of_mul_eq_zero := by
      intro z w h
      cases' surj M z with x hx
      cases' surj M w with y hy
      have :
        z * w * algebraMap A S y.2 * algebraMap A S x.2 = algebraMap A S x.1 * algebraMap A S y.1 :=
        by rw [mul_assoc z, hy, ← hx]; ring
      rw [h, zero_mul, zero_mul, ← (algebraMap A S).map_mul] at this
      cases' eq_zero_or_eq_zero_of_mul_eq_zero ((to_map_eq_zero_iff S hM).mp this.symm) with H H
      · exact Or.inl (eq_zero_of_fst_eq_zero hx H)
      · 

Proof state:
case intro.intro.inr
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
K : Type u_4
inst✝⁶ : IsLocalization M✝ S
Q : Type u_5
inst✝⁵ : CommRing Q
g : R →+* P
inst✝⁴ : Algebra P Q
A : Type u_6
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : Algebra A S
M : Submonoid A
inst✝ : IsLocalization M S
hM : M ≤ nonZeroDivisors A
z w : S
h : z * w = 0
x : A × ↥M
hx : z * (algebraMap A S) ↑x.2 = (algebraMap A S) x.1
y : A × ↥M
hy : w * (algebraMap A S) ↑y.2 = (algebraMap A S) y.1
this : 0 = (algebraMap A S) (x.1 * y.1)
H : y.1 = 0
⊢ z = 0 ∨ w = 0

Next tactic:
exact Or.inr (eq_zero_of_fst_eq_zero hy H)
/-- A `CommRing` `S` which is the localization of an integral domain `R` at a subset of
non-zero elements is an integral domain.
See note [reducible non-instances]. -/
@[reducible]
theorem isDomain_of_le_nonZeroDivisors [Algebra A S] {M : Submonoid A} [IsLocalization M S]
    (hM : M ≤ nonZeroDivisors A) : IsDomain S := 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
K : Type u_4
inst✝⁶ : IsLocalization M✝ S
Q : Type u_5
inst✝⁵ : CommRing Q
g : R →+* P
inst✝⁴ : Algebra P Q
A : Type u_6
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : Algebra A S
M : Submonoid A
inst✝ : IsLocalization M S
hM : M ≤ nonZeroDivisors A
⊢ IsDomain S

Next tactic:
apply @NoZeroDivisors.to_isDomain _ _ (id _) (id _)
/-- A `CommRing` `S` which is the localization of an integral domain `R` at a subset of
non-zero elements is an integral domain.
See note [reducible non-instances]. -/
@[reducible]
theorem isDomain_of_le_nonZeroDivisors [Algebra A S] {M : Submonoid A} [IsLocalization M S]
    (hM : M ≤ nonZeroDivisors A) : IsDomain S := by
  apply @NoZeroDivisors.to_isDomain _ _ (id _) (id _)
  · 

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
K : Type u_4
inst✝⁶ : IsLocalization M✝ S
Q : Type u_5
inst✝⁵ : CommRing Q
g : R →+* P
inst✝⁴ : Algebra P Q
A : Type u_6
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : Algebra A S
M : Submonoid A
inst✝ : IsLocalization M S
hM : M ≤ nonZeroDivisors A
⊢ Nontrivial S

Next tactic:
exact
      ⟨⟨(algebraMap A S) 0, (algebraMap A S) 1, fun h =>
          zero_ne_one (IsLocalization.injective S hM h)⟩⟩
/-- A `CommRing` `S` which is the localization of an integral domain `R` at a subset of
non-zero elements is an integral domain.
See note [reducible non-instances]. -/
@[reducible]
theorem isDomain_of_le_nonZeroDivisors [Algebra A S] {M : Submonoid A} [IsLocalization M S]
    (hM : M ≤ nonZeroDivisors A) : IsDomain S := by
  apply @NoZeroDivisors.to_isDomain _ _ (id _) (id _)
  · exact
      ⟨⟨(algebraMap A S) 0, (algebraMap A S) 1, fun h =>
          zero_ne_one (IsLocalization.injective S hM h)⟩⟩
  · 

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
K : Type u_4
inst✝⁶ : IsLocalization M✝ S
Q : Type u_5
inst✝⁵ : CommRing Q
g : R →+* P
inst✝⁴ : Algebra P Q
A : Type u_6
inst✝³ : CommRing A
inst✝² : IsDomain A
inst✝¹ : Algebra A S
M : Submonoid A
inst✝ : IsLocalization M S
hM : M ≤ nonZeroDivisors A
⊢ NoZeroDivisors S

Next tactic:
exact noZeroDivisors_of_le_nonZeroDivisors _ hM
/-- If `R` is a field, then localizing at a submonoid not containing `0` adds no new elements. -/
theorem IsField.localization_map_bijective {R Rₘ : Type*} [CommRing R] [CommRing Rₘ]
    {M : Submonoid R} (hM : (0 : R) ∉ M) (hR : IsField R) [Algebra R Rₘ] [IsLocalization M Rₘ] :
    Function.Bijective (algebraMap R Rₘ) := 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
Rₘ : Type u_5
inst✝³ : CommRing R
inst✝² : CommRing Rₘ
M : Submonoid R
hM : 0 ∉ M
hR : IsField R
inst✝¹ : Algebra R Rₘ
inst✝ : IsLocalization M Rₘ
⊢ Bijective ⇑(algebraMap R Rₘ)

Next tactic:
letI := hR.toField
/-- If `R` is a field, then localizing at a submonoid not containing `0` adds no new elements. -/
theorem IsField.localization_map_bijective {R Rₘ : Type*} [CommRing R] [CommRing Rₘ]
    {M : Submonoid R} (hM : (0 : R) ∉ M) (hR : IsField R) [Algebra R Rₘ] [IsLocalization M Rₘ] :
    Function.Bijective (algebraMap R Rₘ) := by
  letI := hR.toField
  

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
Rₘ : Type u_5
inst✝³ : CommRing R
inst✝² : CommRing Rₘ
M : Submonoid R
hM : 0 ∉ M
hR : IsField R
inst✝¹ : Algebra R Rₘ
inst✝ : IsLocalization M Rₘ
this : Field R := toField hR
⊢ Bijective ⇑(algebraMap R Rₘ)

Next tactic:
replace hM := le_nonZeroDivisors_of_noZeroDivisors hM
/-- If `R` is a field, then localizing at a submonoid not containing `0` adds no new elements. -/
theorem IsField.localization_map_bijective {R Rₘ : Type*} [CommRing R] [CommRing Rₘ]
    {M : Submonoid R} (hM : (0 : R) ∉ M) (hR : IsField R) [Algebra R Rₘ] [IsLocalization M Rₘ] :
    Function.Bijective (algebraMap R Rₘ) := by
  letI := hR.toField
  replace hM := le_nonZeroDivisors_of_noZeroDivisors hM
  

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
Rₘ : Type u_5
inst✝³ : CommRing R
inst✝² : CommRing Rₘ
M : Submonoid R
hR : IsField R
inst✝¹ : Algebra R Rₘ
inst✝ : IsLocalization M Rₘ
this : Field R := toField hR
hM : M ≤ nonZeroDivisors R
⊢ Bijective ⇑(algebraMap R Rₘ)

Next tactic:
refine' ⟨IsLocalization.injective _ hM, fun x => _⟩
/-- If `R` is a field, then localizing at a submonoid not containing `0` adds no new elements. -/
theorem IsField.localization_map_bijective {R Rₘ : Type*} [CommRing R] [CommRing Rₘ]
    {M : Submonoid R} (hM : (0 : R) ∉ M) (hR : IsField R) [Algebra R Rₘ] [IsLocalization M Rₘ] :
    Function.Bijective (algebraMap R Rₘ) := by
  letI := hR.toField
  replace hM := le_nonZeroDivisors_of_noZeroDivisors hM
  refine' ⟨IsLocalization.injective _ hM, fun 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
Rₘ : Type u_5
inst✝³ : CommRing R
inst✝² : CommRing Rₘ
M : Submonoid R
hR : IsField R
inst✝¹ : Algebra R Rₘ
inst✝ : IsLocalization M Rₘ
this : Field R := toField hR
hM : M ≤ nonZeroDivisors R
x : Rₘ
⊢ ∃ a, (algebraMap R Rₘ) a = x

Next tactic:
obtain ⟨r, ⟨m, hm⟩, rfl⟩ := mk'_surjective M x
/-- If `R` is a field, then localizing at a submonoid not containing `0` adds no new elements. -/
theorem IsField.localization_map_bijective {R Rₘ : Type*} [CommRing R] [CommRing Rₘ]
    {M : Submonoid R} (hM : (0 : R) ∉ M) (hR : IsField R) [Algebra R Rₘ] [IsLocalization M Rₘ] :
    Function.Bijective (algebraMap R Rₘ) := by
  letI := hR.toField
  replace hM := le_nonZeroDivisors_of_noZeroDivisors hM
  refine' ⟨IsLocalization.injective _ hM, fun x => _⟩
  obtain ⟨r, ⟨m, hm⟩, rfl⟩ := mk'_surjective M x
  

Proof state:
case intro.intro.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
Rₘ : Type u_5
inst✝³ : CommRing R
inst✝² : CommRing Rₘ
M : Submonoid R
hR : IsField R
inst✝¹ : Algebra R Rₘ
inst✝ : IsLocalization M Rₘ
this : Field R := toField hR
hM : M ≤ nonZeroDivisors R
r m : R
hm : m ∈ M
⊢ ∃ a, (algebraMap R Rₘ) a = mk' Rₘ r { val := m, property := hm }

Next tactic:
obtain ⟨n, hn⟩ := hR.mul_inv_cancel (nonZeroDivisors.ne_zero <| hM hm)
/-- If `R` is a field, then localizing at a submonoid not containing `0` adds no new elements. -/
theorem IsField.localization_map_bijective {R Rₘ : Type*} [CommRing R] [CommRing Rₘ]
    {M : Submonoid R} (hM : (0 : R) ∉ M) (hR : IsField R) [Algebra R Rₘ] [IsLocalization M Rₘ] :
    Function.Bijective (algebraMap R Rₘ) := by
  letI := hR.toField
  replace hM := le_nonZeroDivisors_of_noZeroDivisors hM
  refine' ⟨IsLocalization.injective _ hM, fun x => _⟩
  obtain ⟨r, ⟨m, hm⟩, rfl⟩ := mk'_surjective M x
  obtain ⟨n, hn⟩ := hR.mul_inv_cancel (nonZeroDivisors.ne_zero <| hM hm)
  

Proof state:
case intro.intro.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
Rₘ : Type u_5
inst✝³ : CommRing R
inst✝² : CommRing Rₘ
M : Submonoid R
hR : IsField R
inst✝¹ : Algebra R Rₘ
inst✝ : IsLocalization M Rₘ
this : Field R := toField hR
hM : M ≤ nonZeroDivisors R
r m : R
hm : m ∈ M
n : R
hn : m * n = 1
⊢ ∃ a, (algebraMap R Rₘ) a = mk' Rₘ r { val := m, property := hm }

Next tactic:
exact ⟨r * n, by erw [eq_mk'_iff_mul_eq, ← map_mul, mul_assoc, _root_.mul_comm n, hn, mul_one]⟩
/-- If `R` is a field, then localizing at a submonoid not containing `0` adds no new elements. -/
theorem IsField.localization_map_bijective {R Rₘ : Type*} [CommRing R] [CommRing Rₘ]
    {M : Submonoid R} (hM : (0 : R) ∉ M) (hR : IsField R) [Algebra R Rₘ] [IsLocalization M Rₘ] :
    Function.Bijective (algebraMap R Rₘ) := by
  letI := hR.toField
  replace hM := le_nonZeroDivisors_of_noZeroDivisors hM
  refine' ⟨IsLocalization.injective _ hM, fun x => _⟩
  obtain ⟨r, ⟨m, hm⟩, rfl⟩ := mk'_surjective M x
  obtain ⟨n, hn⟩ := hR.mul_inv_cancel (nonZeroDivisors.ne_zero <| hM hm)
  exact ⟨r * n, 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
Rₘ : Type u_5
inst✝³ : CommRing R
inst✝² : CommRing Rₘ
M : Submonoid R
hR : IsField R
inst✝¹ : Algebra R Rₘ
inst✝ : IsLocalization M Rₘ
this : Field R := toField hR
hM : M ≤ nonZeroDivisors R
r m : R
hm : m ∈ M
n : R
hn : m * n = 1
⊢ (algebraMap R Rₘ) (r * n) = mk' Rₘ r { val := m, property := hm }

Next tactic:
erw [eq_mk'_iff_mul_eq, ← map_mul, mul_assoc, _root_.mul_comm n, hn, mul_one]
theorem IsLocalization.map_units_map_submonoid (y : M) : IsUnit (algebraMap R Sₘ y) := 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ₘ
i : IsLocalization (Algebra.algebraMapSubmonoid S M) Sₘ
inst✝³ : Algebra Rₘ Sₘ
inst✝² : Algebra R Sₘ
inst✝¹ : IsScalarTower R Rₘ Sₘ
inst✝ : IsScalarTower R S Sₘ
y : ↥M
⊢ IsUnit ((algebraMap R Sₘ) ↑y)

Next tactic:
rw [IsScalarTower.algebraMap_apply _ S]
theorem IsLocalization.map_units_map_submonoid (y : M) : IsUnit (algebraMap R Sₘ y) := by
  rw [IsScalarTower.algebraMap_apply _ S]
  

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ₘ
i : IsLocalization (Algebra.algebraMapSubmonoid S M) Sₘ
inst✝³ : Algebra Rₘ Sₘ
inst✝² : Algebra R Sₘ
inst✝¹ : IsScalarTower R Rₘ Sₘ
inst✝ : IsScalarTower R S Sₘ
y : ↥M
⊢ IsUnit ((algebraMap S Sₘ) ((algebraMap R S) ↑y))

Next tactic:
exact IsLocalization.map_units Sₘ ⟨algebraMap R S y, Algebra.mem_algebraMapSubmonoid_of_mem y⟩
theorem IsLocalization.algebraMap_mk' (x : R) (y : M) :
    algebraMap Rₘ Sₘ (IsLocalization.mk' Rₘ x y) =
      IsLocalization.mk' Sₘ (algebraMap R S x)
        ⟨algebraMap R S y, Algebra.mem_algebraMapSubmonoid_of_mem y⟩ := 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ₘ
i : IsLocalization (Algebra.algebraMapSubmonoid S M) Sₘ
inst✝³ : Algebra Rₘ Sₘ
inst✝² : Algebra R Sₘ
inst✝¹ : IsScalarTower R Rₘ Sₘ
inst✝ : IsScalarTower R S Sₘ
x : R
y : ↥M
⊢ (algebraMap Rₘ Sₘ) (mk' Rₘ x y) =
    mk' Sₘ ((algebraMap R S) x)
      { val := (algebraMap R S) ↑y, property := (_ : (algebraMap R S) ↑y ∈ Algebra.algebraMapSubmonoid S M) }

Next tactic:
rw [IsLocalization.eq_mk'_iff_mul_eq, Subtype.coe_mk, ← IsScalarTower.algebraMap_apply, ←
    IsScalarTower.algebraMap_apply, IsScalarTower.algebraMap_apply R Rₘ Sₘ,
    IsScalarTower.algebraMap_apply R Rₘ Sₘ, ← _root_.map_mul, mul_comm,
    IsLocalization.mul_mk'_eq_mk'_of_mul]
theorem IsLocalization.algebraMap_mk' (x : R) (y : M) :
    algebraMap Rₘ Sₘ (IsLocalization.mk' Rₘ x y) =
      IsLocalization.mk' Sₘ (algebraMap R S x)
        ⟨algebraMap R S y, Algebra.mem_algebraMapSubmonoid_of_mem y⟩ := by
  rw [IsLocalization.eq_mk'_iff_mul_eq, Subtype.coe_mk, ← IsScalarTower.algebraMap_apply, ←
    IsScalarTower.algebraMap_apply, IsScalarTower.algebraMap_apply R Rₘ Sₘ,
    IsScalarTower.algebraMap_apply R Rₘ Sₘ, ← _root_.map_mul, mul_comm,
    IsLocalization.mul_mk'_eq_mk'_of_mul]
  

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ₘ
i : IsLocalization (Algebra.algebraMapSubmonoid S M) Sₘ
inst✝³ : Algebra Rₘ Sₘ
inst✝² : Algebra R Sₘ
inst✝¹ : IsScalarTower R Rₘ Sₘ
inst✝ : IsScalarTower R S Sₘ
x : R
y : ↥M
⊢ (algebraMap Rₘ Sₘ) (mk' Rₘ (↑y * x) y) = (algebraMap Rₘ Sₘ) ((algebraMap R Rₘ) x)

Next tactic:
exact congr_arg (algebraMap Rₘ Sₘ) (IsLocalization.mk'_mul_cancel_left x y)
/-- If the square below commutes, the bottom map is uniquely specified:
```
R  →  S
↓     ↓
Rₘ → Sₘ
```
-/
theorem IsLocalization.algebraMap_eq_map_map_submonoid :
    algebraMap Rₘ Sₘ =
      map Sₘ (algebraMap R S)
        (show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :=
  Eq.symm <|
    IsLocalization.map_unique _ (algebraMap Rₘ Sₘ) fun 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ₘ
i : IsLocalization (Algebra.algebraMapSubmonoid S M) Sₘ
inst✝³ : Algebra Rₘ Sₘ
inst✝² : Algebra R Sₘ
inst✝¹ : IsScalarTower R Rₘ Sₘ
inst✝ : IsScalarTower R S Sₘ
x : R
⊢ (algebraMap Rₘ Sₘ) ((algebraMap R Rₘ) x) = (algebraMap S Sₘ) ((algebraMap R S) x)

Next tactic:
rw [← IsScalarTower.algebraMap_apply R S Sₘ, ← IsScalarTower.algebraMap_apply R Rₘ Sₘ]
instance decidablePredExistsNat : DecidablePred fun n' : ℕ => ∃ (n : ℕ+) (_ : n' = n), p n :=
  fun n' =>
  decidable_of_iff' (∃ h : 0 < n', p ⟨n', h⟩) <|
    Subtype.exists.trans <| by
      

Proof state:
p q : ℕ+ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
h : ∃ n, p n
n' : ℕ
⊢ (∃ a, ∃ (b : 0 < a) (_ : n' = ↑{ val := a, property := b }), p { val := a, property := b }) ↔
    ∃ (h : 0 < n'), p { val := n', property := h }

Next tactic:
simp_rw [mk_coe, @exists_comm (_ < _) (_ = _), exists_prop, exists_eq_left']
/-- The `PNat` version of `Nat.findX` -/
protected def findX : { n // p n ∧ ∀ m : ℕ+, m < n → ¬p m } := by
  

Proof state:
p q : ℕ+ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
h : ∃ n, p n
⊢ { n // p n ∧ ∀ m < n, ¬p m }

Next tactic:
have : ∃ (n' : ℕ) (n : ℕ+) (_ : n' = n), p n := Exists.elim h fun n hn => ⟨n, n, rfl, hn⟩
/-- The `PNat` version of `Nat.findX` -/
protected def findX : { n // p n ∧ ∀ m : ℕ+, m < n → ¬p m } := by
  have : ∃ (n' : ℕ) (n : ℕ+) (_ : n' = n), p n := Exists.elim h fun n hn => ⟨n, n, rfl, hn⟩
  

Proof state:
p q : ℕ+ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
h : ∃ n, p n
this : ∃ n' n, ∃ (_ : n' = ↑n), p n
⊢ { n // p n ∧ ∀ m < n, ¬p m }

Next tactic:
have n := Nat.findX this
/-- The `PNat` version of `Nat.findX` -/
protected def findX : { n // p n ∧ ∀ m : ℕ+, m < n → ¬p m } := by
  have : ∃ (n' : ℕ) (n : ℕ+) (_ : n' = n), p n := Exists.elim h fun n hn => ⟨n, n, rfl, hn⟩
  have n := Nat.findX this
  

Proof state:
p q : ℕ+ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
h : ∃ n, p n
this : ∃ n' n, ∃ (_ : n' = ↑n), p n
n : { n // (∃ n_1, ∃ (_ : n = ↑n_1), p n_1) ∧ ∀ m < n, ¬∃ n, ∃ (_ : m = ↑n), p n }
⊢ { n // p n ∧ ∀ m < n, ¬p m }

Next tactic:
refine' ⟨⟨n, _⟩, _, fun m hm pm => _⟩
/-- The `PNat` version of `Nat.findX` -/
protected def findX : { n // p n ∧ ∀ m : ℕ+, m < n → ¬p m } := by
  have : ∃ (n' : ℕ) (n : ℕ+) (_ : n' = n), p n := Exists.elim h fun n hn => ⟨n, n, rfl, hn⟩
  have n := Nat.findX this
  refine' ⟨⟨n, _⟩, _, fun m hm pm => _⟩
  · 

Proof state:
case refine'_1
p q : ℕ+ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
h : ∃ n, p n
this : ∃ n' n, ∃ (_ : n' = ↑n), p n
n : { n // (∃ n_1, ∃ (_ : n = ↑n_1), p n_1) ∧ ∀ m < n, ¬∃ n, ∃ (_ : m = ↑n), p n }
⊢ 0 < ↑n

Next tactic:
obtain ⟨n', hn', -⟩ := n.prop.1
/-- The `PNat` version of `Nat.findX` -/
protected def findX : { n // p n ∧ ∀ m : ℕ+, m < n → ¬p m } := by
  have : ∃ (n' : ℕ) (n : ℕ+) (_ : n' = n), p n := Exists.elim h fun n hn => ⟨n, n, rfl, hn⟩
  have n := Nat.findX this
  refine' ⟨⟨n, _⟩, _, fun m hm pm => _⟩
  · obtain ⟨n', hn', -⟩ := n.prop.1
    

Proof state:
case refine'_1.intro.intro
p q : ℕ+ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
h : ∃ n, p n
this : ∃ n' n, ∃ (_ : n' = ↑n), p n
n : { n // (∃ n_1, ∃ (_ : n = ↑n_1), p n_1) ∧ ∀ m < n, ¬∃ n, ∃ (_ : m = ↑n), p n }
n' : ℕ+
hn' : ↑n = ↑n'
⊢ 0 < ↑n

Next tactic:
rw [hn']
/-- The `PNat` version of `Nat.findX` -/
protected def findX : { n // p n ∧ ∀ m : ℕ+, m < n → ¬p m } := by
  have : ∃ (n' : ℕ) (n : ℕ+) (_ : n' = n), p n := Exists.elim h fun n hn => ⟨n, n, rfl, hn⟩
  have n := Nat.findX this
  refine' ⟨⟨n, _⟩, _, fun m hm pm => _⟩
  · obtain ⟨n', hn', -⟩ := n.prop.1
    rw [hn']
    

Proof state:
case refine'_1.intro.intro
p q : ℕ+ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
h : ∃ n, p n
this : ∃ n' n, ∃ (_ : n' = ↑n), p n
n : { n // (∃ n_1, ∃ (_ : n = ↑n_1), p n_1) ∧ ∀ m < n, ¬∃ n, ∃ (_ : m = ↑n), p n }
n' : ℕ+
hn' : ↑n = ↑n'
⊢ 0 < ↑n'

Next tactic:
exact n'.prop
/-- The `PNat` version of `Nat.findX` -/
protected def findX : { n // p n ∧ ∀ m : ℕ+, m < n → ¬p m } := by
  have : ∃ (n' : ℕ) (n : ℕ+) (_ : n' = n), p n := Exists.elim h fun n hn => ⟨n, n, rfl, hn⟩
  have n := Nat.findX this
  refine' ⟨⟨n, _⟩, _, fun m hm pm => _⟩
  · obtain ⟨n', hn', -⟩ := n.prop.1
    rw [hn']
    exact n'.prop
  · 

Proof state:
case refine'_2
p q : ℕ+ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
h : ∃ n, p n
this : ∃ n' n, ∃ (_ : n' = ↑n), p n
n : { n // (∃ n_1, ∃ (_ : n = ↑n_1), p n_1) ∧ ∀ m < n, ¬∃ n, ∃ (_ : m = ↑n), p n }
⊢ p { val := ↑n, property := (_ : 0 < ↑n) }

Next tactic:
obtain ⟨n', hn', pn'⟩ := n.prop.1