l3lab/ntp-mathlib huggingface dataset:
instance algebra {S : Type*} [CommSemiring S] [Algebra S R] : Algebra S (Localization M) where
  toRingHom :=
    RingHom.comp
      { Localization.monoidOf M with
        toFun := (monoidOf M).toMap
        map_zero' := by rw [← mk_zero (1 : M), mk_one_eq_monoidOf_mk]
        map_add' := fun x y => by
          simp only [← mk_one_eq_monoidOf_mk, add_mk, Submonoid.coe_one, one_mul, add_comm] }
      (algebraMap S R)
  smul_def' s :=
    Localization.ind <|
      Prod.rec <| 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
S : Type u_4
inst✝¹ : CommSemiring S
inst✝ : Algebra S R
s : S
⊢ ∀ (fst : R) (snd : ↥M),
    s • mk (fst, snd).1 (fst, snd).2 =
      (RingHom.comp
            (let src := monoidOf M;
            {
              toMonoidHom :=
                {
                  toOneHom :=
                    { toFun := ⇑(Submonoid.LocalizationMap.toMap (monoidOf M)),
                      map_one' := (_ : OneHom.toFun (↑src.toMonoidHom) 1 = 1) },
                  map_mul' :=
                    (_ :
                      ∀ (x y : R),
                        OneHom.toFun (↑src.toMonoidHom) (x * y) =
                          OneHom.toFun (↑src.toMonoidHom) x * OneHom.toFun (↑src.toMonoidHom) y) },
              map_zero' :=
                (_ :
                  OneHom.toFun
                      (↑{
                          toOneHom :=
                            { toFun := ⇑(Submonoid.LocalizationMap.toMap (monoidOf M)),
                              map_one' := (_ : OneHom.toFun (↑src.toMonoidHom) 1 = 1) },
                          map_mul' :=
                            (_ :
                              ∀ (x y : R),
                                OneHom.toFun (↑src.toMonoidHom) (x * y) =
                                  OneHom.toFun (↑src.toMonoidHom) x * OneHom.toFun (↑src.toMonoidHom) y) })
                      0 =
                    0),
              map_add' := (_ : ∀ (x y : R), mk (x + y) 1 = mk x 1 + mk y 1) })
            (algebraMap S R))
          s *
        mk (fst, snd).1 (fst, snd).2

Next tactic:
intro r x
instance algebra {S : Type*} [CommSemiring S] [Algebra S R] : Algebra S (Localization M) where
  toRingHom :=
    RingHom.comp
      { Localization.monoidOf M with
        toFun := (monoidOf M).toMap
        map_zero' := by rw [← mk_zero (1 : M), mk_one_eq_monoidOf_mk]
        map_add' := fun x y => by
          simp only [← mk_one_eq_monoidOf_mk, add_mk, Submonoid.coe_one, one_mul, add_comm] }
      (algebraMap S R)
  smul_def' s :=
    Localization.ind <|
      Prod.rec <| by
        intro r x
        

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
S : Type u_4
inst✝¹ : CommSemiring S
inst✝ : Algebra S R
s : S
r : R
x : ↥M
⊢ s • mk (r, x).1 (r, x).2 =
    (RingHom.comp
          (let src := monoidOf M;
          {
            toMonoidHom :=
              {
                toOneHom :=
                  { toFun := ⇑(Submonoid.LocalizationMap.toMap (monoidOf M)),
                    map_one' := (_ : OneHom.toFun (↑src.toMonoidHom) 1 = 1) },
                map_mul' :=
                  (_ :
                    ∀ (x y : R),
                      OneHom.toFun (↑src.toMonoidHom) (x * y) =
                        OneHom.toFun (↑src.toMonoidHom) x * OneHom.toFun (↑src.toMonoidHom) y) },
            map_zero' :=
              (_ :
                OneHom.toFun
                    (↑{
                        toOneHom :=
                          { toFun := ⇑(Submonoid.LocalizationMap.toMap (monoidOf M)),
                            map_one' := (_ : OneHom.toFun (↑src.toMonoidHom) 1 = 1) },
                        map_mul' :=
                          (_ :
                            ∀ (x y : R),
                              OneHom.toFun (↑src.toMonoidHom) (x * y) =
                                OneHom.toFun (↑src.toMonoidHom) x * OneHom.toFun (↑src.toMonoidHom) y) })
                    0 =
                  0),
            map_add' := (_ : ∀ (x y : R), mk (x + y) 1 = mk x 1 + mk y 1) })
          (algebraMap S R))
        s *
      mk (r, x).1 (r, x).2

Next tactic:
dsimp
instance algebra {S : Type*} [CommSemiring S] [Algebra S R] : Algebra S (Localization M) where
  toRingHom :=
    RingHom.comp
      { Localization.monoidOf M with
        toFun := (monoidOf M).toMap
        map_zero' := by rw [← mk_zero (1 : M), mk_one_eq_monoidOf_mk]
        map_add' := fun x y => by
          simp only [← mk_one_eq_monoidOf_mk, add_mk, Submonoid.coe_one, one_mul, add_comm] }
      (algebraMap S R)
  smul_def' s :=
    Localization.ind <|
      Prod.rec <| by
        intro r x
        dsimp
        

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
S : Type u_4
inst✝¹ : CommSemiring S
inst✝ : Algebra S R
s : S
r : R
x : ↥M
⊢ s • mk r x = (Submonoid.LocalizationMap.toMap (monoidOf M)) ((algebraMap S R) s) * mk r x

Next tactic:
simp only [← mk_one_eq_monoidOf_mk, mk_mul, Localization.smul_mk, one_mul,
          Algebra.smul_def]
theorem mk_eq_mk'_apply (x y) : mk x y = IsLocalization.mk' (Localization M) x y := 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
x : R
y : ↥M
⊢ mk x y = mk' (Localization M) x y

Next tactic:
rw [mk_eq_monoidOf_mk'_apply, mk', toLocalizationMap_eq_monoidOf]
theorem mk_algebraMap {A : Type*} [CommSemiring A] [Algebra A R] (m : A) :
    mk (algebraMap A R m) 1 = algebraMap A (Localization M) m := 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
A : Type u_4
inst✝¹ : CommSemiring A
inst✝ : Algebra A R
m : A
⊢ mk ((algebraMap A R) m) 1 = (algebraMap A (Localization M)) m

Next tactic:
rw [mk_eq_mk', mk'_eq_iff_eq_mul, Submonoid.coe_one, map_one, mul_one]
theorem mk_algebraMap {A : Type*} [CommSemiring A] [Algebra A R] (m : A) :
    mk (algebraMap A R m) 1 = algebraMap A (Localization M) m := by
  rw [mk_eq_mk', mk'_eq_iff_eq_mul, Submonoid.coe_one, map_one, mul_one]; 

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
A : Type u_4
inst✝¹ : CommSemiring A
inst✝ : Algebra A R
m : A
⊢ (algebraMap R (Localization M)) ((algebraMap A R) m) = (algebraMap A (Localization M)) m

Next tactic:
rfl
theorem mk_nat_cast (m : ℕ) : (mk m 1 : Localization M) = m := 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
m : ℕ
⊢ mk (↑m) 1 = ↑m

Next tactic:
simpa using mk_algebraMap (R := R) (A := ℕ) _
theorem algEquiv_mk (x y) : algEquiv M S (mk x y) = mk' S x y := 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
x : R
y : ↥M
⊢ (algEquiv M S) (mk x y) = mk' S x y

Next tactic:
rw [mk_eq_mk', algEquiv_mk']
theorem algEquiv_symm_mk (x : R) (y : M) : (algEquiv M S).symm (mk' S x y) = mk x y := 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
x : R
y : ↥M
⊢ (AlgEquiv.symm (algEquiv M S)) (mk' S x y) = mk x y

Next tactic:
rw [mk_eq_mk', algEquiv_symm_mk']
/-- Negation in a ring localization is defined as `-⟨a, b⟩ = ⟨-a, b⟩`. -/
protected irreducible_def neg (z : Localization M) : Localization M :=
  Localization.liftOn z (fun a b => mk (-a) b) fun {a b c d} h =>
    mk_eq_mk_iff.2
      (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
z : Localization M
a b : R
c d : ↥M
h : (r M) (a, c) (b, d)
⊢ (r M) (-a, c) (-b, d)

Next tactic:
rw [r_eq_r'] at h ⊢
/-- Negation in a ring localization is defined as `-⟨a, b⟩ = ⟨-a, b⟩`. -/
protected irreducible_def neg (z : Localization M) : Localization M :=
  Localization.liftOn z (fun a b => mk (-a) b) fun {a b c d} h =>
    mk_eq_mk_iff.2
      (by
        rw [r_eq_r'] at 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
z : Localization M
a b : R
c d : ↥M
h : (r' M) (a, c) (b, d)
⊢ (r' M) (-a, c) (-b, d)

Next tactic:
cases' h with t ht
/-- Negation in a ring localization is defined as `-⟨a, b⟩ = ⟨-a, b⟩`. -/
protected irreducible_def neg (z : Localization M) : Localization M :=
  Localization.liftOn z (fun a b => mk (-a) b) fun {a b c d} h =>
    mk_eq_mk_iff.2
      (by
        rw [r_eq_r'] at h ⊢
        cases' h with t ht
        

Proof state:
case 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
z : Localization M
a b : R
c d t : ↥M
ht : ↑t * (↑(b, d).2 * (a, c).1) = ↑t * (↑(a, c).2 * (b, d).1)
⊢ (r' M) (-a, c) (-b, d)

Next tactic:
use t
/-- Negation in a ring localization is defined as `-⟨a, b⟩ = ⟨-a, b⟩`. -/
protected irreducible_def neg (z : Localization M) : Localization M :=
  Localization.liftOn z (fun a b => mk (-a) b) fun {a b c d} h =>
    mk_eq_mk_iff.2
      (by
        rw [r_eq_r'] at h ⊢
        cases' h with t ht
        use t
        

Proof state:
case h
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
z : Localization M
a b : R
c d t : ↥M
ht : ↑t * (↑(b, d).2 * (a, c).1) = ↑t * (↑(a, c).2 * (b, d).1)
⊢ ↑t * (↑(-b, d).2 * (-a, c).1) = ↑t * (↑(-a, c).2 * (-b, d).1)

Next tactic:
rw [mul_neg, mul_neg, ht]
/-- Negation in a ring localization is defined as `-⟨a, b⟩ = ⟨-a, b⟩`. -/
protected irreducible_def neg (z : Localization M) : Localization M :=
  Localization.liftOn z (fun a b => mk (-a) b) fun {a b c d} h =>
    mk_eq_mk_iff.2
      (by
        rw [r_eq_r'] at h ⊢
        cases' h with t ht
        use t
        rw [mul_neg, mul_neg, ht]
        

Proof state:
case h
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
z : Localization M
a b : R
c d t : ↥M
ht : ↑t * (↑(b, d).2 * (a, c).1) = ↑t * (↑(a, c).2 * (b, d).1)
⊢ -(↑t * (↑(a, c).2 * (b, d).1)) = ↑t * (↑(-a, c).2 * (-b, d).1)

Next tactic:
ring_nf
theorem neg_mk (a b) : -(mk a b : Localization M) = mk (-a) b := 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 : R
b : ↥M
⊢ -mk a b = mk (-a) b

Next tactic:
show Localization.neg (mk a b) = mk (-a) b
theorem neg_mk (a b) : -(mk a b : Localization M) = mk (-a) b := by
  show Localization.neg (mk a b) = mk (-a) b
  

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 : R
b : ↥M
⊢ Localization.neg (mk a b) = mk (-a) b

Next tactic:
rw [Localization.neg_def]
theorem neg_mk (a b) : -(mk a b : Localization M) = mk (-a) b := by
  show Localization.neg (mk a b) = mk (-a) b
  rw [Localization.neg_def]
  

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 : R
b : ↥M
⊢ liftOn (mk a b) (fun a b => mk (-a) b) (_ : ∀ {a b : R} {c d : ↥M}, (r M) (a, c) (b, d) → mk (-a) c = mk (-b) d) =
    mk (-a) b

Next tactic:
apply liftOn_mk
instance : CommRing (Localization M) :=
  { inferInstanceAs (CommSemiring (Localization M)) with
    zsmul := (· • ·)
    zsmul_zero' := fun x =>
      Localization.induction_on x 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
src✝ : CommSemiring (Localization M) := inferInstanceAs (CommSemiring (Localization M))
x✝ : Localization M
x : R × ↥M
⊢ (fun x x_1 => x • x_1) 0 (mk x.1 x.2) = 0

Next tactic:
simp only [smul_mk, zero_zsmul, mk_zero]
instance : CommRing (Localization M) :=
  { inferInstanceAs (CommSemiring (Localization M)) with
    zsmul := (· • ·)
    zsmul_zero' := fun x =>
      Localization.induction_on x fun x => by simp only [smul_mk, zero_zsmul, mk_zero]
    zsmul_succ' := fun n x =>
      Localization.induction_on x 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
src✝ : CommSemiring (Localization M) := inferInstanceAs (CommSemiring (Localization M))
n : ℕ
x✝ : Localization M
x : R × ↥M
⊢ (fun x x_1 => x • x_1) (Int.ofNat (Nat.succ n)) (mk x.1 x.2) =
    mk x.1 x.2 + (fun x x_1 => x • x_1) (Int.ofNat n) (mk x.1 x.2)

Next tactic:
simp [smul_mk, add_mk_self, -mk_eq_monoidOf_mk', add_comm (n : ℤ) 1, add_smul]
instance : CommRing (Localization M) :=
  { inferInstanceAs (CommSemiring (Localization M)) with
    zsmul := (· • ·)
    zsmul_zero' := fun x =>
      Localization.induction_on x fun x => by simp only [smul_mk, zero_zsmul, mk_zero]
    zsmul_succ' := fun n x =>
      Localization.induction_on x fun x => by
        simp [smul_mk, add_mk_self, -mk_eq_monoidOf_mk', add_comm (n : ℤ) 1, add_smul]
    zsmul_neg' := fun n x =>
      Localization.induction_on x 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
src✝ : CommSemiring (Localization M) := inferInstanceAs (CommSemiring (Localization M))
n : ℕ
x✝ : Localization M
x : R × ↥M
⊢ (fun x x_1 => x • x_1) (Int.negSucc n) (mk x.1 x.2) = -(fun x x_1 => x • x_1) (↑(Nat.succ n)) (mk x.1 x.2)

Next tactic:
dsimp only
instance : CommRing (Localization M) :=
  { inferInstanceAs (CommSemiring (Localization M)) with
    zsmul := (· • ·)
    zsmul_zero' := fun x =>
      Localization.induction_on x fun x => by simp only [smul_mk, zero_zsmul, mk_zero]
    zsmul_succ' := fun n x =>
      Localization.induction_on x fun x => by
        simp [smul_mk, add_mk_self, -mk_eq_monoidOf_mk', add_comm (n : ℤ) 1, add_smul]
    zsmul_neg' := fun n x =>
      Localization.induction_on x fun x => by
        dsimp only
        

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
src✝ : CommSemiring (Localization M) := inferInstanceAs (CommSemiring (Localization M))
n : ℕ
x✝ : Localization M
x : R × ↥M
⊢ Int.negSucc n • mk x.1 x.2 = -(↑(Nat.succ n) • mk x.1 x.2)

Next tactic:
rw [smul_mk, smul_mk, neg_mk, ← neg_smul]
instance : CommRing (Localization M) :=
  { inferInstanceAs (CommSemiring (Localization M)) with
    zsmul := (· • ·)
    zsmul_zero' := fun x =>
      Localization.induction_on x fun x => by simp only [smul_mk, zero_zsmul, mk_zero]
    zsmul_succ' := fun n x =>
      Localization.induction_on x fun x => by
        simp [smul_mk, add_mk_self, -mk_eq_monoidOf_mk', add_comm (n : ℤ) 1, add_smul]
    zsmul_neg' := fun n x =>
      Localization.induction_on x fun x => by
        dsimp only
        rw [smul_mk, smul_mk, neg_mk, ← neg_smul]
        

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
src✝ : CommSemiring (Localization M) := inferInstanceAs (CommSemiring (Localization M))
n : ℕ
x✝ : Localization M
x : R × ↥M
⊢ mk (Int.negSucc n • x.1) x.2 = mk (-↑(Nat.succ n) • x.1) x.2

Next tactic:
rfl
instance : CommRing (Localization M) :=
  { inferInstanceAs (CommSemiring (Localization M)) with
    zsmul := (· • ·)
    zsmul_zero' := fun x =>
      Localization.induction_on x fun x => by simp only [smul_mk, zero_zsmul, mk_zero]
    zsmul_succ' := fun n x =>
      Localization.induction_on x fun x => by
        simp [smul_mk, add_mk_self, -mk_eq_monoidOf_mk', add_comm (n : ℤ) 1, add_smul]
    zsmul_neg' := fun n x =>
      Localization.induction_on x fun x => by
        dsimp only
        rw [smul_mk, smul_mk, neg_mk, ← neg_smul]
        rfl
    neg := Neg.neg
    sub := fun x y => x + -y
    sub_eq_add_neg := fun x y => rfl
    add_left_neg := fun y =>
      Localization.induction_on 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
src✝ : CommSemiring (Localization M) := inferInstanceAs (CommSemiring (Localization M))
y : Localization M
⊢ ∀ (y : R × ↥M), -mk y.1 y.2 + mk y.1 y.2 = 0

Next tactic:
intros
instance : CommRing (Localization M) :=
  { inferInstanceAs (CommSemiring (Localization M)) with
    zsmul := (· • ·)
    zsmul_zero' := fun x =>
      Localization.induction_on x fun x => by simp only [smul_mk, zero_zsmul, mk_zero]
    zsmul_succ' := fun n x =>
      Localization.induction_on x fun x => by
        simp [smul_mk, add_mk_self, -mk_eq_monoidOf_mk', add_comm (n : ℤ) 1, add_smul]
    zsmul_neg' := fun n x =>
      Localization.induction_on x fun x => by
        dsimp only
        rw [smul_mk, smul_mk, neg_mk, ← neg_smul]
        rfl
    neg := Neg.neg
    sub := fun x y => x + -y
    sub_eq_add_neg := fun x y => rfl
    add_left_neg := fun y =>
      Localization.induction_on y
        (by
          intros
          

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
src✝ : CommSemiring (Localization M) := inferInstanceAs (CommSemiring (Localization M))
y : Localization M
y✝ : R × ↥M
⊢ -mk y✝.1 y✝.2 + mk y✝.1 y✝.2 = 0

Next tactic:
simp only [add_mk, Localization.mk_mul, neg_mk, ← mk_zero 1]
instance : CommRing (Localization M) :=
  { inferInstanceAs (CommSemiring (Localization M)) with
    zsmul := (· • ·)
    zsmul_zero' := fun x =>
      Localization.induction_on x fun x => by simp only [smul_mk, zero_zsmul, mk_zero]
    zsmul_succ' := fun n x =>
      Localization.induction_on x fun x => by
        simp [smul_mk, add_mk_self, -mk_eq_monoidOf_mk', add_comm (n : ℤ) 1, add_smul]
    zsmul_neg' := fun n x =>
      Localization.induction_on x fun x => by
        dsimp only
        rw [smul_mk, smul_mk, neg_mk, ← neg_smul]
        rfl
    neg := Neg.neg
    sub := fun x y => x + -y
    sub_eq_add_neg := fun x y => rfl
    add_left_neg := fun y =>
      Localization.induction_on y
        (by
          intros
          simp only [add_mk, Localization.mk_mul, neg_mk, ← mk_zero 1]
          

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
src✝ : CommSemiring (Localization M) := inferInstanceAs (CommSemiring (Localization M))
y : Localization M
y✝ : R × ↥M
⊢ mk (↑y✝.2 * y✝.1 + ↑y✝.2 * -y✝.1) (y✝.2 * y✝.2) = mk 0 1

Next tactic:
refine' mk_eq_mk_iff.mpr (r_of_eq _)
instance : CommRing (Localization M) :=
  { inferInstanceAs (CommSemiring (Localization M)) with
    zsmul := (· • ·)
    zsmul_zero' := fun x =>
      Localization.induction_on x fun x => by simp only [smul_mk, zero_zsmul, mk_zero]
    zsmul_succ' := fun n x =>
      Localization.induction_on x fun x => by
        simp [smul_mk, add_mk_self, -mk_eq_monoidOf_mk', add_comm (n : ℤ) 1, add_smul]
    zsmul_neg' := fun n x =>
      Localization.induction_on x fun x => by
        dsimp only
        rw [smul_mk, smul_mk, neg_mk, ← neg_smul]
        rfl
    neg := Neg.neg
    sub := fun x y => x + -y
    sub_eq_add_neg := fun x y => rfl
    add_left_neg := fun y =>
      Localization.induction_on y
        (by
          intros
          simp only [add_mk, Localization.mk_mul, neg_mk, ← mk_zero 1]
          refine' mk_eq_mk_iff.mpr (r_of_eq _)
          

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
src✝ : CommSemiring (Localization M) := inferInstanceAs (CommSemiring (Localization M))
y : Localization M
y✝ : R × ↥M
⊢ ↑(0, 1).2 * (↑y✝.2 * y✝.1 + ↑y✝.2 * -y✝.1, y✝.2 * y✝.2).1 = ↑(↑y✝.2 * y✝.1 + ↑y✝.2 * -y✝.1, y✝.2 * y✝.2).2 * (0, 1).1

Next tactic:
simp only [Submonoid.coe_mul]
instance : CommRing (Localization M) :=
  { inferInstanceAs (CommSemiring (Localization M)) with
    zsmul := (· • ·)
    zsmul_zero' := fun x =>
      Localization.induction_on x fun x => by simp only [smul_mk, zero_zsmul, mk_zero]
    zsmul_succ' := fun n x =>
      Localization.induction_on x fun x => by
        simp [smul_mk, add_mk_self, -mk_eq_monoidOf_mk', add_comm (n : ℤ) 1, add_smul]
    zsmul_neg' := fun n x =>
      Localization.induction_on x fun x => by
        dsimp only
        rw [smul_mk, smul_mk, neg_mk, ← neg_smul]
        rfl
    neg := Neg.neg
    sub := fun x y => x + -y
    sub_eq_add_neg := fun x y => rfl
    add_left_neg := fun y =>
      Localization.induction_on y
        (by
          intros
          simp only [add_mk, Localization.mk_mul, neg_mk, ← mk_zero 1]
          refine' mk_eq_mk_iff.mpr (r_of_eq _)
          simp only [Submonoid.coe_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
src✝ : CommSemiring (Localization M) := inferInstanceAs (CommSemiring (Localization M))
y : Localization M
y✝ : R × ↥M
⊢ ↑1 * (↑y✝.2 * y✝.1 + ↑y✝.2 * -y✝.1) = ↑y✝.2 * ↑y✝.2 * 0

Next tactic:
ring
theorem sub_mk (a c) (b d) : (mk a b : Localization M) - mk c d =
    mk ((d : R) * a - b * c) (b * d) :=
  calc
    mk a b - mk c d = mk a b + -mk c d := sub_eq_add_neg _ _
    _ = mk a b + mk (-c) d := 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 c : R
b d : ↥M
⊢ mk a b + -mk c d = mk a b + mk (-c) d

Next tactic:
rw [neg_mk]
theorem sub_mk (a c) (b d) : (mk a b : Localization M) - mk c d =
    mk ((d : R) * a - b * c) (b * d) :=
  calc
    mk a b - mk c d = mk a b + -mk c d := sub_eq_add_neg _ _
    _ = mk a b + mk (-c) d := by rw [neg_mk]
    _ = mk (b * -c + d * a) (b * d) := (add_mk _ _ _ _)
    _ = mk (d * a - b * c) (b * d) := 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 c : R
b d : ↥M
⊢ mk (↑b * -c + ↑d * a) (b * d) = mk (↑d * a - ↑b * c) (b * d)

Next tactic:
congr
theorem sub_mk (a c) (b d) : (mk a b : Localization M) - mk c d =
    mk ((d : R) * a - b * c) (b * d) :=
  calc
    mk a b - mk c d = mk a b + -mk c d := sub_eq_add_neg _ _
    _ = mk a b + mk (-c) d := by rw [neg_mk]
    _ = mk (b * -c + d * a) (b * d) := (add_mk _ _ _ _)
    _ = mk (d * a - b * c) (b * d) := by congr; 

Proof state:
case e_x
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 c : R
b d : ↥M
⊢ ↑b * -c + ↑d * a = ↑d * a - ↑b * c

Next tactic:
ring
theorem mk_int_cast (m : ℤ) : (mk m 1 : Localization M) = m := 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
m : ℤ
⊢ mk (↑m) 1 = ↑m

Next tactic:
simpa using mk_algebraMap (R := R) (A := ℤ) _
theorem to_map_eq_zero_iff {x : R} (hM : M ≤ nonZeroDivisors R) : algebraMap R S x = 0 ↔ x = 0 := 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
x : R
hM : M ≤ nonZeroDivisors R
⊢ (algebraMap R S) x = 0 ↔ x = 0

Next tactic:
rw [← (algebraMap R S).map_zero]