l3lab/ntp-mathlib huggingface dataset:
theorem isLocalization_iff_of_base_ringEquiv (h : R ≃+* P) :
    IsLocalization M S ↔
      haveI := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
      IsLocalization (M.map h.toMonoidHom) S := by
  

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
h : R ≃+* P
⊢ IsLocalization M S ↔ IsLocalization (Submonoid.map (RingEquiv.toMonoidHom h) M) S

Next tactic:
letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
theorem isLocalization_iff_of_base_ringEquiv (h : R ≃+* P) :
    IsLocalization M S ↔
      haveI := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
      IsLocalization (M.map h.toMonoidHom) S := by
  letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
  

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
h : R ≃+* P
this : Algebra P S := RingHom.toAlgebra (RingHom.comp (algebraMap R S) (RingEquiv.toRingHom (RingEquiv.symm h)))
⊢ IsLocalization M S ↔ IsLocalization (Submonoid.map (RingEquiv.toMonoidHom h) M) S

Next tactic:
refine' ⟨fun _ => isLocalization_of_base_ringEquiv M S h, _⟩
theorem isLocalization_iff_of_base_ringEquiv (h : R ≃+* P) :
    IsLocalization M S ↔
      haveI := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
      IsLocalization (M.map h.toMonoidHom) S := by
  letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
  refine' ⟨fun _ => isLocalization_of_base_ringEquiv M S h, _⟩
  

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
h : R ≃+* P
this : Algebra P S := RingHom.toAlgebra (RingHom.comp (algebraMap R S) (RingEquiv.toRingHom (RingEquiv.symm h)))
⊢ IsLocalization (Submonoid.map (RingEquiv.toMonoidHom h) M) S → IsLocalization M S

Next tactic:
intro H
theorem isLocalization_iff_of_base_ringEquiv (h : R ≃+* P) :
    IsLocalization M S ↔
      haveI := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
      IsLocalization (M.map h.toMonoidHom) S := by
  letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
  refine' ⟨fun _ => isLocalization_of_base_ringEquiv M S h, _⟩
  intro H
  

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
h : R ≃+* P
this : Algebra P S := RingHom.toAlgebra (RingHom.comp (algebraMap R S) (RingEquiv.toRingHom (RingEquiv.symm h)))
H : IsLocalization (Submonoid.map (RingEquiv.toMonoidHom h) M) S
⊢ IsLocalization M S

Next tactic:
convert isLocalization_of_base_ringEquiv (Submonoid.map (RingEquiv.toMonoidHom h) M) S h.symm
theorem isLocalization_iff_of_base_ringEquiv (h : R ≃+* P) :
    IsLocalization M S ↔
      haveI := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
      IsLocalization (M.map h.toMonoidHom) S := by
  letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
  refine' ⟨fun _ => isLocalization_of_base_ringEquiv M S h, _⟩
  intro H
  convert isLocalization_of_base_ringEquiv (Submonoid.map (RingEquiv.toMonoidHom h) M) S h.symm
  · 

Proof state:
case h.e'_3
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
h : R ≃+* P
this : Algebra P S := RingHom.toAlgebra (RingHom.comp (algebraMap R S) (RingEquiv.toRingHom (RingEquiv.symm h)))
H : IsLocalization (Submonoid.map (RingEquiv.toMonoidHom h) M) S
⊢ M = Submonoid.map (RingEquiv.toMonoidHom (RingEquiv.symm h)) (Submonoid.map (RingEquiv.toMonoidHom h) M)

Next tactic:
erw [Submonoid.map_equiv_eq_comap_symm, Submonoid.comap_map_eq_of_injective]
theorem isLocalization_iff_of_base_ringEquiv (h : R ≃+* P) :
    IsLocalization M S ↔
      haveI := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
      IsLocalization (M.map h.toMonoidHom) S := by
  letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
  refine' ⟨fun _ => isLocalization_of_base_ringEquiv M S h, _⟩
  intro H
  convert isLocalization_of_base_ringEquiv (Submonoid.map (RingEquiv.toMonoidHom h) M) S h.symm
  · erw [Submonoid.map_equiv_eq_comap_symm, Submonoid.comap_map_eq_of_injective]
    

Proof state:
case h.e'_3.hf
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
h : R ≃+* P
this : Algebra P S := RingHom.toAlgebra (RingHom.comp (algebraMap R S) (RingEquiv.toRingHom (RingEquiv.symm h)))
H : IsLocalization (Submonoid.map (RingEquiv.toMonoidHom h) M) S
⊢ Injective ⇑(MulEquiv.toMonoidHom (MulEquiv.symm (RingEquiv.toMulEquiv (RingEquiv.symm h))))

Next tactic:
exact h.toEquiv.injective
theorem isLocalization_iff_of_base_ringEquiv (h : R ≃+* P) :
    IsLocalization M S ↔
      haveI := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
      IsLocalization (M.map h.toMonoidHom) S := by
  letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
  refine' ⟨fun _ => isLocalization_of_base_ringEquiv M S h, _⟩
  intro H
  convert isLocalization_of_base_ringEquiv (Submonoid.map (RingEquiv.toMonoidHom h) M) S h.symm
  · erw [Submonoid.map_equiv_eq_comap_symm, Submonoid.comap_map_eq_of_injective]
    exact h.toEquiv.injective
  

Proof state:
case h.e'_6
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
h : R ≃+* P
this : Algebra P S := RingHom.toAlgebra (RingHom.comp (algebraMap R S) (RingEquiv.toRingHom (RingEquiv.symm h)))
H : IsLocalization (Submonoid.map (RingEquiv.toMonoidHom h) M) S
⊢ inst✝¹ = RingHom.toAlgebra (RingHom.comp (algebraMap P S) (RingEquiv.toRingHom (RingEquiv.symm (RingEquiv.symm h))))

Next tactic:
rw [RingHom.algebraMap_toAlgebra, RingHom.comp_assoc]
theorem isLocalization_iff_of_base_ringEquiv (h : R ≃+* P) :
    IsLocalization M S ↔
      haveI := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
      IsLocalization (M.map h.toMonoidHom) S := by
  letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
  refine' ⟨fun _ => isLocalization_of_base_ringEquiv M S h, _⟩
  intro H
  convert isLocalization_of_base_ringEquiv (Submonoid.map (RingEquiv.toMonoidHom h) M) S h.symm
  · erw [Submonoid.map_equiv_eq_comap_symm, Submonoid.comap_map_eq_of_injective]
    exact h.toEquiv.injective
  rw [RingHom.algebraMap_toAlgebra, RingHom.comp_assoc]
  

Proof state:
case h.e'_6
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
h : R ≃+* P
this : Algebra P S := RingHom.toAlgebra (RingHom.comp (algebraMap R S) (RingEquiv.toRingHom (RingEquiv.symm h)))
H : IsLocalization (Submonoid.map (RingEquiv.toMonoidHom h) M) S
⊢ inst✝¹ =
    RingHom.toAlgebra
      (RingHom.comp (algebraMap R S)
        (RingHom.comp (RingEquiv.toRingHom (RingEquiv.symm h))
          (RingEquiv.toRingHom (RingEquiv.symm (RingEquiv.symm h)))))

Next tactic:
simp only [RingHom.comp_id, RingEquiv.symm_symm, RingEquiv.symm_toRingHom_comp_toRingHom]
theorem isLocalization_iff_of_base_ringEquiv (h : R ≃+* P) :
    IsLocalization M S ↔
      haveI := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
      IsLocalization (M.map h.toMonoidHom) S := by
  letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
  refine' ⟨fun _ => isLocalization_of_base_ringEquiv M S h, _⟩
  intro H
  convert isLocalization_of_base_ringEquiv (Submonoid.map (RingEquiv.toMonoidHom h) M) S h.symm
  · erw [Submonoid.map_equiv_eq_comap_symm, Submonoid.comap_map_eq_of_injective]
    exact h.toEquiv.injective
  rw [RingHom.algebraMap_toAlgebra, RingHom.comp_assoc]
  simp only [RingHom.comp_id, RingEquiv.symm_symm, RingEquiv.symm_toRingHom_comp_toRingHom]
  

Proof state:
case h.e'_6
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
h : R ≃+* P
this : Algebra P S := RingHom.toAlgebra (RingHom.comp (algebraMap R S) (RingEquiv.toRingHom (RingEquiv.symm h)))
H : IsLocalization (Submonoid.map (RingEquiv.toMonoidHom h) M) S
⊢ inst✝¹ = RingHom.toAlgebra (algebraMap R S)

Next tactic:
apply Algebra.algebra_ext
theorem isLocalization_iff_of_base_ringEquiv (h : R ≃+* P) :
    IsLocalization M S ↔
      haveI := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
      IsLocalization (M.map h.toMonoidHom) S := by
  letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
  refine' ⟨fun _ => isLocalization_of_base_ringEquiv M S h, _⟩
  intro H
  convert isLocalization_of_base_ringEquiv (Submonoid.map (RingEquiv.toMonoidHom h) M) S h.symm
  · erw [Submonoid.map_equiv_eq_comap_symm, Submonoid.comap_map_eq_of_injective]
    exact h.toEquiv.injective
  rw [RingHom.algebraMap_toAlgebra, RingHom.comp_assoc]
  simp only [RingHom.comp_id, RingEquiv.symm_symm, RingEquiv.symm_toRingHom_comp_toRingHom]
  apply Algebra.algebra_ext
  

Proof state:
case h.e'_6.h
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
h : R ≃+* P
this : Algebra P S := RingHom.toAlgebra (RingHom.comp (algebraMap R S) (RingEquiv.toRingHom (RingEquiv.symm h)))
H : IsLocalization (Submonoid.map (RingEquiv.toMonoidHom h) M) S
⊢ ∀ (r : R), (algebraMap R S) r = (algebraMap R S) r

Next tactic:
intro r
theorem isLocalization_iff_of_base_ringEquiv (h : R ≃+* P) :
    IsLocalization M S ↔
      haveI := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
      IsLocalization (M.map h.toMonoidHom) S := by
  letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
  refine' ⟨fun _ => isLocalization_of_base_ringEquiv M S h, _⟩
  intro H
  convert isLocalization_of_base_ringEquiv (Submonoid.map (RingEquiv.toMonoidHom h) M) S h.symm
  · erw [Submonoid.map_equiv_eq_comap_symm, Submonoid.comap_map_eq_of_injective]
    exact h.toEquiv.injective
  rw [RingHom.algebraMap_toAlgebra, RingHom.comp_assoc]
  simp only [RingHom.comp_id, RingEquiv.symm_symm, RingEquiv.symm_toRingHom_comp_toRingHom]
  apply Algebra.algebra_ext
  intro r
  

Proof state:
case h.e'_6.h
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
h : R ≃+* P
this : Algebra P S := RingHom.toAlgebra (RingHom.comp (algebraMap R S) (RingEquiv.toRingHom (RingEquiv.symm h)))
H : IsLocalization (Submonoid.map (RingEquiv.toMonoidHom h) M) S
r : R
⊢ (algebraMap R S) r = (algebraMap R S) r

Next tactic:
rw [RingHom.algebraMap_toAlgebra]
theorem nonZeroDivisors_le_comap [IsLocalization M S] :
    nonZeroDivisors R ≤ (nonZeroDivisors S).comap (algebraMap R S) := by
  

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
⊢ nonZeroDivisors R ≤ Submonoid.comap (algebraMap R S) (nonZeroDivisors S)

Next tactic:
rintro a ha b (e : b * algebraMap R S a = 0)
theorem nonZeroDivisors_le_comap [IsLocalization M S] :
    nonZeroDivisors R ≤ (nonZeroDivisors S).comap (algebraMap R S) := by
  rintro a ha b (e : b * algebraMap R S a = 0)
  

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
a : R
ha : a ∈ nonZeroDivisors R
b : S
e : b * (algebraMap R S) a = 0
⊢ b = 0

Next tactic:
obtain ⟨x, s, rfl⟩ := mk'_surjective M b
theorem nonZeroDivisors_le_comap [IsLocalization M S] :
    nonZeroDivisors R ≤ (nonZeroDivisors S).comap (algebraMap R S) := by
  rintro a ha b (e : b * algebraMap R S a = 0)
  obtain ⟨x, s, rfl⟩ := mk'_surjective M b
  

Proof state:
case intro.intro
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
a : R
ha : a ∈ nonZeroDivisors R
x : R
s : ↥M
e : mk' S x s * (algebraMap R S) a = 0
⊢ mk' S x s = 0

Next tactic:
rw [← @mk'_one R _ M, ← mk'_mul, ← (algebraMap R S).map_zero, ← @mk'_one R _ M,
    IsLocalization.eq] at e
theorem nonZeroDivisors_le_comap [IsLocalization M S] :
    nonZeroDivisors R ≤ (nonZeroDivisors S).comap (algebraMap R S) := by
  rintro a ha b (e : b * algebraMap R S a = 0)
  obtain ⟨x, s, rfl⟩ := mk'_surjective M b
  rw [← @mk'_one R _ M, ← mk'_mul, ← (algebraMap R S).map_zero, ← @mk'_one R _ M,
    IsLocalization.eq] at e
  

Proof state:
case intro.intro
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
a : R
ha : a ∈ nonZeroDivisors R
x : R
s : ↥M
e : ∃ c, ↑c * (↑1 * (x * a)) = ↑c * (↑(s * 1) * 0)
⊢ mk' S x s = 0

Next tactic:
obtain ⟨c, e⟩ := e
theorem nonZeroDivisors_le_comap [IsLocalization M S] :
    nonZeroDivisors R ≤ (nonZeroDivisors S).comap (algebraMap R S) := by
  rintro a ha b (e : b * algebraMap R S a = 0)
  obtain ⟨x, s, rfl⟩ := mk'_surjective M b
  rw [← @mk'_one R _ M, ← mk'_mul, ← (algebraMap R S).map_zero, ← @mk'_one R _ M,
    IsLocalization.eq] at e
  obtain ⟨c, e⟩ := e
  

Proof state:
case intro.intro.intro
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
a : R
ha : a ∈ nonZeroDivisors R
x : R
s c : ↥M
e : ↑c * (↑1 * (x * a)) = ↑c * (↑(s * 1) * 0)
⊢ mk' S x s = 0

Next tactic:
rw [mul_zero, mul_zero, Submonoid.coe_one, one_mul, ← mul_assoc] at e
theorem nonZeroDivisors_le_comap [IsLocalization M S] :
    nonZeroDivisors R ≤ (nonZeroDivisors S).comap (algebraMap R S) := by
  rintro a ha b (e : b * algebraMap R S a = 0)
  obtain ⟨x, s, rfl⟩ := mk'_surjective M b
  rw [← @mk'_one R _ M, ← mk'_mul, ← (algebraMap R S).map_zero, ← @mk'_one R _ M,
    IsLocalization.eq] at e
  obtain ⟨c, e⟩ := e
  rw [mul_zero, mul_zero, Submonoid.coe_one, one_mul, ← mul_assoc] at e
  

Proof state:
case intro.intro.intro
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
a : R
ha : a ∈ nonZeroDivisors R
x : R
s c : ↥M
e : ↑c * x * a = 0
⊢ mk' S x s = 0

Next tactic:
rw [mk'_eq_zero_iff]
theorem nonZeroDivisors_le_comap [IsLocalization M S] :
    nonZeroDivisors R ≤ (nonZeroDivisors S).comap (algebraMap R S) := by
  rintro a ha b (e : b * algebraMap R S a = 0)
  obtain ⟨x, s, rfl⟩ := mk'_surjective M b
  rw [← @mk'_one R _ M, ← mk'_mul, ← (algebraMap R S).map_zero, ← @mk'_one R _ M,
    IsLocalization.eq] at e
  obtain ⟨c, e⟩ := e
  rw [mul_zero, mul_zero, Submonoid.coe_one, one_mul, ← mul_assoc] at e
  rw [mk'_eq_zero_iff]
  

Proof state:
case intro.intro.intro
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : IsLocalization M S
a : R
ha : a ∈ nonZeroDivisors R
x : R
s c : ↥M
e : ↑c * x * a = 0
⊢ ∃ m, ↑m * x = 0

Next tactic:
exact ⟨c, ha _ e⟩
instance instUniqueLocalization [Subsingleton R] : Unique (Localization M) where
  uniq a := show a = mk 1 1 from
    Localization.induction_on a fun _ => by
      

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : Subsingleton R
a : Localization M
x✝ : R × ↥M
⊢ mk x✝.1 x✝.2 = mk 1 1

Next tactic:
congr
instance instUniqueLocalization [Subsingleton R] : Unique (Localization M) where
  uniq a := show a = mk 1 1 from
    Localization.induction_on a fun _ => by
      congr <;> 

Proof state:
case e_x
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : Subsingleton R
a : Localization M
x✝ : R × ↥M
⊢ x✝.1 = 1

Next tactic:
apply Subsingleton.elim
instance instUniqueLocalization [Subsingleton R] : Unique (Localization M) where
  uniq a := show a = mk 1 1 from
    Localization.induction_on a fun _ => by
      congr <;> 

Proof state:
case e_y
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P : Type u_3
inst✝¹ : CommSemiring P
inst✝ : Subsingleton R
a : Localization M
x✝ : R × ↥M
⊢ x✝.2 = 1

Next tactic:
apply Subsingleton.elim
/-- Addition in a ring localization is defined as `⟨a, b⟩ + ⟨c, d⟩ = ⟨b * c + d * a, b * d⟩`.

Should not be confused with `AddLocalization.add`, which is defined as
`⟨a, b⟩ + ⟨c, d⟩ = ⟨a + c, b + d⟩`.
-/
protected irreducible_def add (z w : Localization M) : Localization M :=
  Localization.liftOn₂ z w (fun a b c d => mk ((b : R) * c + d * a) (b * d))
    fun {a a' b b' c c' d d'} h1 h2 =>
    mk_eq_mk_iff.2
      (by
        

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
z w : Localization M
a a' : R
b b' : ↥M
c c' : R
d d' : ↥M
h1 : (r M) (a, b) (a', b')
h2 : (r M) (c, d) (c', d')
⊢ (r M) (↑b * c + ↑d * a, b * d) (↑b' * c' + ↑d' * a', b' * d')

Next tactic:
rw [r_eq_r'] at h1 h2 ⊢
/-- Addition in a ring localization is defined as `⟨a, b⟩ + ⟨c, d⟩ = ⟨b * c + d * a, b * d⟩`.

Should not be confused with `AddLocalization.add`, which is defined as
`⟨a, b⟩ + ⟨c, d⟩ = ⟨a + c, b + d⟩`.
-/
protected irreducible_def add (z w : Localization M) : Localization M :=
  Localization.liftOn₂ z w (fun a b c d => mk ((b : R) * c + d * a) (b * d))
    fun {a a' b b' c c' d d'} h1 h2 =>
    mk_eq_mk_iff.2
      (by
        rw [r_eq_r'] at h1 h2 ⊢
        

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
z w : Localization M
a a' : R
b b' : ↥M
c c' : R
d d' : ↥M
h1 : (r' M) (a, b) (a', b')
h2 : (r' M) (c, d) (c', d')
⊢ (r' M) (↑b * c + ↑d * a, b * d) (↑b' * c' + ↑d' * a', b' * d')

Next tactic:
cases' h1 with t₅ ht₅
/-- Addition in a ring localization is defined as `⟨a, b⟩ + ⟨c, d⟩ = ⟨b * c + d * a, b * d⟩`.

Should not be confused with `AddLocalization.add`, which is defined as
`⟨a, b⟩ + ⟨c, d⟩ = ⟨a + c, b + d⟩`.
-/
protected irreducible_def add (z w : Localization M) : Localization M :=
  Localization.liftOn₂ z w (fun a b c d => mk ((b : R) * c + d * a) (b * d))
    fun {a a' b b' c c' d d'} h1 h2 =>
    mk_eq_mk_iff.2
      (by
        rw [r_eq_r'] at h1 h2 ⊢
        cases' h1 with t₅ ht₅
        

Proof state:
case intro
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
z w : Localization M
a a' : R
b b' : ↥M
c c' : R
d d' : ↥M
h2 : (r' M) (c, d) (c', d')
t₅ : ↥M
ht₅ : ↑t₅ * (↑(a', b').2 * (a, b).1) = ↑t₅ * (↑(a, b).2 * (a', b').1)
⊢ (r' M) (↑b * c + ↑d * a, b * d) (↑b' * c' + ↑d' * a', b' * d')

Next tactic:
cases' h2 with t₆ ht₆
/-- Addition in a ring localization is defined as `⟨a, b⟩ + ⟨c, d⟩ = ⟨b * c + d * a, b * d⟩`.

Should not be confused with `AddLocalization.add`, which is defined as
`⟨a, b⟩ + ⟨c, d⟩ = ⟨a + c, b + d⟩`.
-/
protected irreducible_def add (z w : Localization M) : Localization M :=
  Localization.liftOn₂ z w (fun a b c d => mk ((b : R) * c + d * a) (b * d))
    fun {a a' b b' c c' d d'} h1 h2 =>
    mk_eq_mk_iff.2
      (by
        rw [r_eq_r'] at h1 h2 ⊢
        cases' h1 with t₅ ht₅
        cases' h2 with t₆ ht₆
        

Proof state:
case intro.intro
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
z w : Localization M
a a' : R
b b' : ↥M
c c' : R
d d' t₅ : ↥M
ht₅ : ↑t₅ * (↑(a', b').2 * (a, b).1) = ↑t₅ * (↑(a, b).2 * (a', b').1)
t₆ : ↥M
ht₆ : ↑t₆ * (↑(c', d').2 * (c, d).1) = ↑t₆ * (↑(c, d).2 * (c', d').1)
⊢ (r' M) (↑b * c + ↑d * a, b * d) (↑b' * c' + ↑d' * a', b' * d')

Next tactic:
use t₅ * t₆
/-- Addition in a ring localization is defined as `⟨a, b⟩ + ⟨c, d⟩ = ⟨b * c + d * a, b * d⟩`.

Should not be confused with `AddLocalization.add`, which is defined as
`⟨a, b⟩ + ⟨c, d⟩ = ⟨a + c, b + d⟩`.
-/
protected irreducible_def add (z w : Localization M) : Localization M :=
  Localization.liftOn₂ z w (fun a b c d => mk ((b : R) * c + d * a) (b * d))
    fun {a a' b b' c c' d d'} h1 h2 =>
    mk_eq_mk_iff.2
      (by
        rw [r_eq_r'] at h1 h2 ⊢
        cases' h1 with t₅ ht₅
        cases' h2 with t₆ ht₆
        use t₅ * t₆
        

Proof state:
case h
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
z w : Localization M
a a' : R
b b' : ↥M
c c' : R
d d' t₅ : ↥M
ht₅ : ↑t₅ * (↑(a', b').2 * (a, b).1) = ↑t₅ * (↑(a, b).2 * (a', b').1)
t₆ : ↥M
ht₆ : ↑t₆ * (↑(c', d').2 * (c, d).1) = ↑t₆ * (↑(c, d).2 * (c', d').1)
⊢ ↑(t₅ * t₆) * (↑(↑b' * c' + ↑d' * a', b' * d').2 * (↑b * c + ↑d * a, b * d).1) =
    ↑(t₅ * t₆) * (↑(↑b * c + ↑d * a, b * d).2 * (↑b' * c' + ↑d' * a', b' * d').1)

Next tactic:
dsimp only
/-- Addition in a ring localization is defined as `⟨a, b⟩ + ⟨c, d⟩ = ⟨b * c + d * a, b * d⟩`.

Should not be confused with `AddLocalization.add`, which is defined as
`⟨a, b⟩ + ⟨c, d⟩ = ⟨a + c, b + d⟩`.
-/
protected irreducible_def add (z w : Localization M) : Localization M :=
  Localization.liftOn₂ z w (fun a b c d => mk ((b : R) * c + d * a) (b * d))
    fun {a a' b b' c c' d d'} h1 h2 =>
    mk_eq_mk_iff.2
      (by
        rw [r_eq_r'] at h1 h2 ⊢
        cases' h1 with t₅ ht₅
        cases' h2 with t₆ ht₆
        use t₅ * t₆
        dsimp only
        

Proof state:
case h
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
z w : Localization M
a a' : R
b b' : ↥M
c c' : R
d d' t₅ : ↥M
ht₅ : ↑t₅ * (↑(a', b').2 * (a, b).1) = ↑t₅ * (↑(a, b).2 * (a', b').1)
t₆ : ↥M
ht₆ : ↑t₆ * (↑(c', d').2 * (c, d).1) = ↑t₆ * (↑(c, d).2 * (c', d').1)
⊢ ↑(t₅ * t₆) * (↑(b' * d') * (↑b * c + ↑d * a)) = ↑(t₅ * t₆) * (↑(b * d) * (↑b' * c' + ↑d' * a'))

Next tactic:
calc
          ↑t₅ * ↑t₆ * (↑b' * ↑d' * ((b : R) * c + d * a)) =
              t₆ * (d' * c) * (t₅ * (b' * b)) + t₅ * (b' * a) * (t₆ * (d' * d)) :=
            by ring
          _ = t₅ * t₆ * (b * d * (b' * c' + d' * a')) := by rw [ht₆, ht₅]; ring
/-- Addition in a ring localization is defined as `⟨a, b⟩ + ⟨c, d⟩ = ⟨b * c + d * a, b * d⟩`.

Should not be confused with `AddLocalization.add`, which is defined as
`⟨a, b⟩ + ⟨c, d⟩ = ⟨a + c, b + d⟩`.
-/
protected irreducible_def add (z w : Localization M) : Localization M :=
  Localization.liftOn₂ z w (fun a b c d => mk ((b : R) * c + d * a) (b * d))
    fun {a a' b b' c c' d d'} h1 h2 =>
    mk_eq_mk_iff.2
      (by
        rw [r_eq_r'] at h1 h2 ⊢
        cases' h1 with t₅ ht₅
        cases' h2 with t₆ ht₆
        use t₅ * t₆
        dsimp only
        calc
          ↑t₅ * ↑t₆ * (↑b' * ↑d' * ((b : R) * c + d * a)) =
              t₆ * (d' * c) * (t₅ * (b' * b)) + t₅ * (b' * a) * (t₆ * (d' * d)) :=
            by 

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
z w : Localization M
a a' : R
b b' : ↥M
c c' : R
d d' t₅ : ↥M
ht₅ : ↑t₅ * (↑(a', b').2 * (a, b).1) = ↑t₅ * (↑(a, b).2 * (a', b').1)
t₆ : ↥M
ht₆ : ↑t₆ * (↑(c', d').2 * (c, d).1) = ↑t₆ * (↑(c, d).2 * (c', d').1)
⊢ ↑t₅ * ↑t₆ * (↑b' * ↑d' * (↑b * c + ↑d * a)) =
    ↑t₆ * (↑d' * c) * (↑t₅ * (↑b' * ↑b)) + ↑t₅ * (↑b' * a) * (↑t₆ * (↑d' * ↑d))

Next tactic:
ring