l3lab/ntp-mathlib huggingface dataset:
/-- Natural homomorphism sending `x : M`, `M` a `CommMonoid`, to the equivalence class of
`(x, 1)` in the Localization of `M` at a Submonoid. -/
@[to_additive
    "Natural homomorphism sending `x : M`, `M` an `AddCommMonoid`, to the equivalence class of
`(x, 0)` in the Localization of `M` at a Submonoid."]
def monoidOf : Submonoid.LocalizationMap S (Localization S) :=
  { (r S).mk'.comp <| MonoidHom.inl M
        S with
    toFun := fun x ↦ mk x 1
    map_one' := mk_one
    map_mul' := fun x y ↦ by dsimp only; rw [mk_mul, mul_one]
    map_units' := fun y ↦
      isUnit_iff_exists_inv.2 ⟨mk 1 y, by dsimp only; rw [mk_mul, mul_one, one_mul, mk_self]⟩
    surj' := fun z ↦ induction_on z fun x ↦
      ⟨x, by 

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
src✝ : M →* Con.Quotient (r S) := MonoidHom.comp (Con.mk' (r S)) (MonoidHom.inl M ↥S)
z : Localization S
x : M × ↥S
⊢ mk x.1 x.2 *
      OneHom.toFun
        ↑{ toOneHom := { toFun := fun x => mk x 1, map_one' := (_ : mk 1 1 = 1) },
            map_mul' :=
              (_ :
                ∀ (x y : M),
                  OneHom.toFun { toFun := fun x => mk x 1, map_one' := (_ : mk 1 1 = 1) } (x * y) =
                    OneHom.toFun { toFun := fun x => mk x 1, map_one' := (_ : mk 1 1 = 1) } x *
                      OneHom.toFun { toFun := fun x => mk x 1, map_one' := (_ : mk 1 1 = 1) } y) }
        ↑x.2 =
    OneHom.toFun
      (↑{ toOneHom := { toFun := fun x => mk x 1, map_one' := (_ : mk 1 1 = 1) },
          map_mul' :=
            (_ :
              ∀ (x y : M),
                OneHom.toFun { toFun := fun x => mk x 1, map_one' := (_ : mk 1 1 = 1) } (x * y) =
                  OneHom.toFun { toFun := fun x => mk x 1, map_one' := (_ : mk 1 1 = 1) } x *
                    OneHom.toFun { toFun := fun x => mk x 1, map_one' := (_ : mk 1 1 = 1) } y) })
      x.1

Next tactic:
dsimp only
/-- Natural homomorphism sending `x : M`, `M` a `CommMonoid`, to the equivalence class of
`(x, 1)` in the Localization of `M` at a Submonoid. -/
@[to_additive
    "Natural homomorphism sending `x : M`, `M` an `AddCommMonoid`, to the equivalence class of
`(x, 0)` in the Localization of `M` at a Submonoid."]
def monoidOf : Submonoid.LocalizationMap S (Localization S) :=
  { (r S).mk'.comp <| MonoidHom.inl M
        S with
    toFun := fun x ↦ mk x 1
    map_one' := mk_one
    map_mul' := fun x y ↦ by dsimp only; rw [mk_mul, mul_one]
    map_units' := fun y ↦
      isUnit_iff_exists_inv.2 ⟨mk 1 y, by dsimp only; rw [mk_mul, mul_one, one_mul, mk_self]⟩
    surj' := fun z ↦ induction_on z fun x ↦
      ⟨x, by dsimp only; 

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
src✝ : M →* Con.Quotient (r S) := MonoidHom.comp (Con.mk' (r S)) (MonoidHom.inl M ↥S)
z : Localization S
x : M × ↥S
⊢ mk x.1 x.2 * mk (↑x.2) 1 = mk x.1 1

Next tactic:
rw [mk_mul, mul_comm x.fst, ← mk_mul, mk_self, one_mul]
/-- Natural homomorphism sending `x : M`, `M` a `CommMonoid`, to the equivalence class of
`(x, 1)` in the Localization of `M` at a Submonoid. -/
@[to_additive
    "Natural homomorphism sending `x : M`, `M` an `AddCommMonoid`, to the equivalence class of
`(x, 0)` in the Localization of `M` at a Submonoid."]
def monoidOf : Submonoid.LocalizationMap S (Localization S) :=
  { (r S).mk'.comp <| MonoidHom.inl M
        S with
    toFun := fun x ↦ mk x 1
    map_one' := mk_one
    map_mul' := fun x y ↦ by dsimp only; rw [mk_mul, mul_one]
    map_units' := fun y ↦
      isUnit_iff_exists_inv.2 ⟨mk 1 y, by dsimp only; rw [mk_mul, mul_one, one_mul, mk_self]⟩
    surj' := fun z ↦ induction_on z fun x ↦
      ⟨x, by dsimp only; rw [mk_mul, mul_comm x.fst, ← mk_mul, mk_self, one_mul]⟩
    exists_of_eq := fun x y ↦ Iff.mp <|
      mk_eq_mk_iff.trans <|
        r_iff_exists.trans <|
          show (∃ c : S, ↑c * (1 * x) = c * (1 * y)) ↔ _ by 

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
src✝ : M →* Con.Quotient (r S) := MonoidHom.comp (Con.mk' (r S)) (MonoidHom.inl M ↥S)
x y : M
⊢ (∃ c, ↑c * (1 * x) = ↑c * (1 * y)) ↔ ∃ c, ↑c * x = ↑c * y

Next tactic:
rw [one_mul, one_mul]
@[to_additive]
theorem mk_eq_monoidOf_mk'_apply (x y) : mk x y = (monoidOf S).mk' x y :=
  show _ = _ * _ from
    (Submonoid.LocalizationMap.mul_inv_right (monoidOf S).map_units _ _ _).2 <| by
      

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
x : M
y : ↥S
⊢ mk x y * (Submonoid.LocalizationMap.toMap (monoidOf S)) ↑y = (Submonoid.LocalizationMap.toMap (monoidOf S)) x

Next tactic:
rw [← mk_one_eq_monoidOf_mk, ← mk_one_eq_monoidOf_mk, mk_mul x y y 1, mul_comm y 1]
@[to_additive]
theorem mk_eq_monoidOf_mk'_apply (x y) : mk x y = (monoidOf S).mk' x y :=
  show _ = _ * _ from
    (Submonoid.LocalizationMap.mul_inv_right (monoidOf S).map_units _ _ _).2 <| by
      rw [← mk_one_eq_monoidOf_mk, ← mk_one_eq_monoidOf_mk, mk_mul x y y 1, mul_comm y 1]
      

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
x : M
y : ↥S
⊢ mk (x * ↑y) (1 * y) = mk x 1

Next tactic:
conv => rhs; rw [← mul_one 1]; rw [← mul_one x]
@[to_additive]
theorem mk_eq_monoidOf_mk'_apply (x y) : mk x y = (monoidOf S).mk' x y :=
  show _ = _ * _ from
    (Submonoid.LocalizationMap.mul_inv_right (monoidOf S).map_units _ _ _).2 <| by
      rw [← mk_one_eq_monoidOf_mk, ← mk_one_eq_monoidOf_mk, mk_mul x y y 1, mul_comm y 1]
      conv => 

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
x : M
y : ↥S
| mk (x * ↑y) (1 * y) = mk x 1

Next tactic:
rhs; rw [← mul_one 1]; rw [← mul_one x]
@[to_additive]
theorem mk_eq_monoidOf_mk'_apply (x y) : mk x y = (monoidOf S).mk' x y :=
  show _ = _ * _ from
    (Submonoid.LocalizationMap.mul_inv_right (monoidOf S).map_units _ _ _).2 <| by
      rw [← mk_one_eq_monoidOf_mk, ← mk_one_eq_monoidOf_mk, mk_mul x y y 1, mul_comm y 1]
      conv => 

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
x : M
y : ↥S
| mk (x * ↑y) (1 * y) = mk x 1

Next tactic:
rhs
@[to_additive]
theorem mk_eq_monoidOf_mk'_apply (x y) : mk x y = (monoidOf S).mk' x y :=
  show _ = _ * _ from
    (Submonoid.LocalizationMap.mul_inv_right (monoidOf S).map_units _ _ _).2 <| by
      rw [← mk_one_eq_monoidOf_mk, ← mk_one_eq_monoidOf_mk, mk_mul x y y 1, mul_comm y 1]
      conv => rhs; 

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
x : M
y : ↥S
| mk x 1

Next tactic:
rw [← mul_one 1]
@[to_additive]
theorem mk_eq_monoidOf_mk'_apply (x y) : mk x y = (monoidOf S).mk' x y :=
  show _ = _ * _ from
    (Submonoid.LocalizationMap.mul_inv_right (monoidOf S).map_units _ _ _).2 <| by
      rw [← mk_one_eq_monoidOf_mk, ← mk_one_eq_monoidOf_mk, mk_mul x y y 1, mul_comm y 1]
      conv => rhs; rw [← mul_one 1]; 

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
x : M
y : ↥S
| mk x (1 * 1)

Next tactic:
rw [← mul_one x]
@[to_additive]
theorem mk_eq_monoidOf_mk'_apply (x y) : mk x y = (monoidOf S).mk' x y :=
  show _ = _ * _ from
    (Submonoid.LocalizationMap.mul_inv_right (monoidOf S).map_units _ _ _).2 <| by
      rw [← mk_one_eq_monoidOf_mk, ← mk_one_eq_monoidOf_mk, mk_mul x y y 1, mul_comm y 1]
      conv => rhs; rw [← mul_one 1]; rw [← mul_one x]
      

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
x : M
y : ↥S
⊢ mk (x * ↑y) (1 * y) = mk (x * 1) (1 * 1)

Next tactic:
exact mk_eq_mk_iff.2 (Con.symm _ <| (Localization.r S).mul (Con.refl _ (x, 1)) <| one_rel _)
@[to_additive (attr := simp)]
theorem liftOn_mk' {p : Sort u} (f : M → S → p) (H) (a : M) (b : S) :
    liftOn ((monoidOf S).mk' a b) f H = f a b := by 

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
p : Sort u
f : M → ↥S → p
H : ∀ {a c : M} {b d : ↥S}, (r S) (a, b) (c, d) → f a b = f c d
a : M
b : ↥S
⊢ liftOn (Submonoid.LocalizationMap.mk' (monoidOf S) a b) f H = f a b

Next tactic:
rw [← mk_eq_monoidOf_mk', liftOn_mk]
@[to_additive (attr := simp)]
theorem liftOn₂_mk' {p : Sort*} (f : M → S → M → S → p) (H) (a c : M) (b d : S) :
    liftOn₂ ((monoidOf S).mk' a b) ((monoidOf S).mk' c d) f H = f a b c d := by
  

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
p : Sort u_4
f : M → ↥S → M → ↥S → p
H :
  ∀ {a a' : M} {b b' : ↥S} {c c' : M} {d d' : ↥S},
    (r S) (a, b) (a', b') → (r S) (c, d) (c', d') → f a b c d = f a' b' c' d'
a c : M
b d : ↥S
⊢ liftOn₂ (Submonoid.LocalizationMap.mk' (monoidOf S) a b) (Submonoid.LocalizationMap.mk' (monoidOf S) c d) f H =
    f a b c d

Next tactic:
rw [← mk_eq_monoidOf_mk', liftOn₂_mk]
@[to_additive]
theorem mulEquivOfQuotient_mk (x y) : mulEquivOfQuotient f (mk x y) = f.mk' x y := by
  

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
f : Submonoid.LocalizationMap S N
x : M
y : ↥S
⊢ (mulEquivOfQuotient f) (mk x y) = Submonoid.LocalizationMap.mk' f x y

Next tactic:
rw [mk_eq_monoidOf_mk'_apply]
@[to_additive]
theorem mulEquivOfQuotient_mk (x y) : mulEquivOfQuotient f (mk x y) = f.mk' x y := by
  rw [mk_eq_monoidOf_mk'_apply]; 

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
f : Submonoid.LocalizationMap S N
x : M
y : ↥S
⊢ (mulEquivOfQuotient f) (Submonoid.LocalizationMap.mk' (monoidOf S) x y) = Submonoid.LocalizationMap.mk' f x y

Next tactic:
exact mulEquivOfQuotient_mk' _ _
@[to_additive]
theorem mulEquivOfQuotient_monoidOf (x) : mulEquivOfQuotient f ((monoidOf S).toMap x) = f.toMap x :=
  by 

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
f : Submonoid.LocalizationMap S N
x : M
⊢ (mulEquivOfQuotient f) ((Submonoid.LocalizationMap.toMap (monoidOf S)) x) = (Submonoid.LocalizationMap.toMap f) x

Next tactic:
simp
@[to_additive]
theorem mulEquivOfQuotient_symm_mk (x y) : (mulEquivOfQuotient f).symm (f.mk' x y) = mk x y := by
  

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
f : Submonoid.LocalizationMap S N
x : M
y : ↥S
⊢ (MulEquiv.symm (mulEquivOfQuotient f)) (Submonoid.LocalizationMap.mk' f x y) = mk x y

Next tactic:
rw [mk_eq_monoidOf_mk'_apply]
@[to_additive]
theorem mulEquivOfQuotient_symm_mk (x y) : (mulEquivOfQuotient f).symm (f.mk' x y) = mk x y := by
  rw [mk_eq_monoidOf_mk'_apply]; 

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
f : Submonoid.LocalizationMap S N
x : M
y : ↥S
⊢ (MulEquiv.symm (mulEquivOfQuotient f)) (Submonoid.LocalizationMap.mk' f x y) =
    Submonoid.LocalizationMap.mk' (monoidOf S) x y

Next tactic:
exact mulEquivOfQuotient_symm_mk' _ _
@[to_additive]
theorem Away.mk_eq_monoidOf_mk' : mk = (Away.monoidOf x).mk' := by 

Proof state:
M : Type u_1
inst✝² : CommMonoid M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoid N
P : Type u_3
inst✝ : CommMonoid P
f : Submonoid.LocalizationMap S N
x : M
⊢ mk = Submonoid.LocalizationMap.mk' (monoidOf x)

Next tactic:
simp
theorem mk_zero (x : S) : mk 0 (x : S) = 0 :=
  calc
    mk 0 x = mk 0 1 := mk_eq_mk_iff.mpr (r_of_eq (by 

Proof state:
M : Type u_1
inst✝² : CommMonoidWithZero M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoidWithZero N
P : Type u_3
inst✝ : CommMonoidWithZero P
x : ↥S
⊢ ↑(0, 1).2 * (0, x).1 = ↑(0, x).2 * (0, 1).1

Next tactic:
simp
instance : CommMonoidWithZero (Localization S) where
  zero_mul := fun x ↦ Localization.induction_on x fun y => by
    

Proof state:
M : Type u_1
inst✝² : CommMonoidWithZero M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoidWithZero N
P : Type u_3
inst✝ : CommMonoidWithZero P
x : Localization S
y : M × ↥S
⊢ 0 * mk y.1 y.2 = 0

Next tactic:
simp only [← Localization.mk_zero y.2, mk_mul, mk_eq_mk_iff, mul_zero, zero_mul, r_of_eq]
instance : CommMonoidWithZero (Localization S) where
  zero_mul := fun x ↦ Localization.induction_on x fun y => by
    simp only [← Localization.mk_zero y.2, mk_mul, mk_eq_mk_iff, mul_zero, zero_mul, r_of_eq]
  mul_zero := fun x ↦ Localization.induction_on x fun y => by
    

Proof state:
M : Type u_1
inst✝² : CommMonoidWithZero M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoidWithZero N
P : Type u_3
inst✝ : CommMonoidWithZero P
x : Localization S
y : M × ↥S
⊢ mk y.1 y.2 * 0 = 0

Next tactic:
simp only [← Localization.mk_zero y.2, mk_mul, mk_eq_mk_iff, mul_zero, zero_mul, r_of_eq]
theorem liftOn_zero {p : Type*} (f : M → S → p) (H) : liftOn 0 f H = f 0 1 := by
  

Proof state:
M : Type u_1
inst✝² : CommMonoidWithZero M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoidWithZero N
P : Type u_3
inst✝ : CommMonoidWithZero P
p : Type u_4
f : M → ↥S → p
H : ∀ {a c : M} {b d : ↥S}, (r S) (a, b) (c, d) → f a b = f c d
⊢ liftOn 0 f H = f 0 1

Next tactic:
rw [← mk_zero 1, liftOn_mk]
@[simp]
theorem LocalizationMap.sec_zero_fst {f : LocalizationMap S N} : f.toMap (f.sec 0).fst = 0 := by
  

Proof state:
M : Type u_1
inst✝² : CommMonoidWithZero M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoidWithZero N
P : Type u_3
inst✝ : CommMonoidWithZero P
f : LocalizationMap S N
⊢ (toMap f) (sec f 0).1 = 0

Next tactic:
rw [LocalizationMap.sec_spec', mul_zero]
/-- Given a Localization map `f : M →*₀ N` for a Submonoid `S ⊆ M` and a map of
`CommMonoidWithZero`s `g : M →*₀ P` such that `g y` is invertible for all `y : S`, the
homomorphism induced from `N` to `P` sending `z : N` to `g x * (g y)⁻¹`, where `(x, y) : M × S`
are such that `z = f x * (f y)⁻¹`. -/
noncomputable def lift (f : LocalizationWithZeroMap S N) (g : M →*₀ P)
    (hg : ∀ y : S, IsUnit (g y)) : N →*₀ P :=
  { @LocalizationMap.lift _ _ _ _ _ _ _ f.toLocalizationMap g.toMonoidHom hg with
    map_zero' := by
      

Proof state:
M : Type u_1
inst✝² : CommMonoidWithZero M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoidWithZero N
P : Type u_3
inst✝ : CommMonoidWithZero P
f : LocalizationWithZeroMap S N
g : M →*₀ P
hg : ∀ (y : ↥S), IsUnit (g ↑y)
src✝ : N →* P := LocalizationMap.lift f.toLocalizationMap hg
⊢ OneHom.toFun (↑src✝) 0 = 0

Next tactic:
erw [LocalizationMap.lift_spec f.toLocalizationMap hg 0 0]
/-- Given a Localization map `f : M →*₀ N` for a Submonoid `S ⊆ M` and a map of
`CommMonoidWithZero`s `g : M →*₀ P` such that `g y` is invertible for all `y : S`, the
homomorphism induced from `N` to `P` sending `z : N` to `g x * (g y)⁻¹`, where `(x, y) : M × S`
are such that `z = f x * (f y)⁻¹`. -/
noncomputable def lift (f : LocalizationWithZeroMap S N) (g : M →*₀ P)
    (hg : ∀ y : S, IsUnit (g y)) : N →*₀ P :=
  { @LocalizationMap.lift _ _ _ _ _ _ _ f.toLocalizationMap g.toMonoidHom hg with
    map_zero' := by
      erw [LocalizationMap.lift_spec f.toLocalizationMap hg 0 0]
      

Proof state:
M : Type u_1
inst✝² : CommMonoidWithZero M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoidWithZero N
P : Type u_3
inst✝ : CommMonoidWithZero P
f : LocalizationWithZeroMap S N
g : M →*₀ P
hg : ∀ (y : ↥S), IsUnit (g ↑y)
src✝ : N →* P := LocalizationMap.lift f.toLocalizationMap hg
⊢ ↑g (LocalizationMap.sec f.toLocalizationMap 0).1 = ↑g ↑(LocalizationMap.sec f.toLocalizationMap 0).2 * 0

Next tactic:
rw [mul_zero, ← map_zero g, ← g.toMonoidHom_coe]
/-- Given a Localization map `f : M →*₀ N` for a Submonoid `S ⊆ M` and a map of
`CommMonoidWithZero`s `g : M →*₀ P` such that `g y` is invertible for all `y : S`, the
homomorphism induced from `N` to `P` sending `z : N` to `g x * (g y)⁻¹`, where `(x, y) : M × S`
are such that `z = f x * (f y)⁻¹`. -/
noncomputable def lift (f : LocalizationWithZeroMap S N) (g : M →*₀ P)
    (hg : ∀ y : S, IsUnit (g y)) : N →*₀ P :=
  { @LocalizationMap.lift _ _ _ _ _ _ _ f.toLocalizationMap g.toMonoidHom hg with
    map_zero' := by
      erw [LocalizationMap.lift_spec f.toLocalizationMap hg 0 0]
      rw [mul_zero, ← map_zero g, ← g.toMonoidHom_coe]
      

Proof state:
M : Type u_1
inst✝² : CommMonoidWithZero M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoidWithZero N
P : Type u_3
inst✝ : CommMonoidWithZero P
f : LocalizationWithZeroMap S N
g : M →*₀ P
hg : ∀ (y : ↥S), IsUnit (g ↑y)
src✝ : N →* P := LocalizationMap.lift f.toLocalizationMap hg
⊢ ↑g (LocalizationMap.sec f.toLocalizationMap 0).1 = OneHom.toFun (↑↑g) 0

Next tactic:
refine f.toLocalizationMap.eq_of_eq hg ?_
/-- Given a Localization map `f : M →*₀ N` for a Submonoid `S ⊆ M` and a map of
`CommMonoidWithZero`s `g : M →*₀ P` such that `g y` is invertible for all `y : S`, the
homomorphism induced from `N` to `P` sending `z : N` to `g x * (g y)⁻¹`, where `(x, y) : M × S`
are such that `z = f x * (f y)⁻¹`. -/
noncomputable def lift (f : LocalizationWithZeroMap S N) (g : M →*₀ P)
    (hg : ∀ y : S, IsUnit (g y)) : N →*₀ P :=
  { @LocalizationMap.lift _ _ _ _ _ _ _ f.toLocalizationMap g.toMonoidHom hg with
    map_zero' := by
      erw [LocalizationMap.lift_spec f.toLocalizationMap hg 0 0]
      rw [mul_zero, ← map_zero g, ← g.toMonoidHom_coe]
      refine f.toLocalizationMap.eq_of_eq hg ?_
      

Proof state:
M : Type u_1
inst✝² : CommMonoidWithZero M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoidWithZero N
P : Type u_3
inst✝ : CommMonoidWithZero P
f : LocalizationWithZeroMap S N
g : M →*₀ P
hg : ∀ (y : ↥S), IsUnit (g ↑y)
src✝ : N →* P := LocalizationMap.lift f.toLocalizationMap hg
⊢ (LocalizationMap.toMap f.toLocalizationMap) (LocalizationMap.sec f.toLocalizationMap 0).1 =
    (LocalizationMap.toMap f.toLocalizationMap) 0

Next tactic:
rw [LocalizationMap.sec_zero_fst]
/-- Given a Localization map `f : M →*₀ N` for a Submonoid `S ⊆ M` and a map of
`CommMonoidWithZero`s `g : M →*₀ P` such that `g y` is invertible for all `y : S`, the
homomorphism induced from `N` to `P` sending `z : N` to `g x * (g y)⁻¹`, where `(x, y) : M × S`
are such that `z = f x * (f y)⁻¹`. -/
noncomputable def lift (f : LocalizationWithZeroMap S N) (g : M →*₀ P)
    (hg : ∀ y : S, IsUnit (g y)) : N →*₀ P :=
  { @LocalizationMap.lift _ _ _ _ _ _ _ f.toLocalizationMap g.toMonoidHom hg with
    map_zero' := by
      erw [LocalizationMap.lift_spec f.toLocalizationMap hg 0 0]
      rw [mul_zero, ← map_zero g, ← g.toMonoidHom_coe]
      refine f.toLocalizationMap.eq_of_eq hg ?_
      rw [LocalizationMap.sec_zero_fst]
      

Proof state:
M : Type u_1
inst✝² : CommMonoidWithZero M
S : Submonoid M
N : Type u_2
inst✝¹ : CommMonoidWithZero N
P : Type u_3
inst✝ : CommMonoidWithZero P
f : LocalizationWithZeroMap S N
g : M →*₀ P
hg : ∀ (y : ↥S), IsUnit (g ↑y)
src✝ : N →* P := LocalizationMap.lift f.toLocalizationMap hg
⊢ 0 = (LocalizationMap.toMap f.toLocalizationMap) 0

Next tactic:
exact f.toMonoidWithZeroHom.map_zero.symm
@[to_additive]
theorem mk_left_injective (b : s) : Injective fun a => mk a b := fun c d h => by
  -- porting note: times out unless we add this `have`. Even `infer_instance` times out here.
  

Proof state:
α : Type u_1
inst✝ : CancelCommMonoid α
s : Submonoid α
a₁ b₁ : α
a₂ b₂ b : ↥s
c d : α
h : (fun a => mk a b) c = (fun a => mk a b) d
⊢ c = d

Next tactic:
have : Nonempty s := One.nonempty
@[to_additive]
theorem mk_left_injective (b : s) : Injective fun a => mk a b := fun c d h => by
  -- porting note: times out unless we add this `have`. Even `infer_instance` times out here.
  have : Nonempty s := One.nonempty
  

Proof state:
α : Type u_1
inst✝ : CancelCommMonoid α
s : Submonoid α
a₁ b₁ : α
a₂ b₂ b : ↥s
c d : α
h : (fun a => mk a b) c = (fun a => mk a b) d
this : Nonempty ↥s
⊢ c = d

Next tactic:
simpa [-mk_eq_monoidOf_mk', mk_eq_mk_iff, r_iff_exists] using h
@[to_additive]
theorem mk_eq_mk_iff' : mk a₁ a₂ = mk b₁ b₂ ↔ ↑b₂ * a₁ = a₂ * b₁ := by
  -- porting note: times out unless we add this `have`. Even `inferInstance` times out here.
  

Proof state:
α : Type u_1
inst✝ : CancelCommMonoid α
s : Submonoid α
a₁ b₁ : α
a₂ b₂ : ↥s
⊢ mk a₁ a₂ = mk b₁ b₂ ↔ ↑b₂ * a₁ = ↑a₂ * b₁

Next tactic:
have : Nonempty s := One.nonempty
@[to_additive]
theorem mk_eq_mk_iff' : mk a₁ a₂ = mk b₁ b₂ ↔ ↑b₂ * a₁ = a₂ * b₁ := by
  -- porting note: times out unless we add this `have`. Even `inferInstance` times out here.
  have : Nonempty s := One.nonempty
  

Proof state:
α : Type u_1
inst✝ : CancelCommMonoid α
s : Submonoid α
a₁ b₁ : α
a₂ b₂ : ↥s
this : Nonempty ↥s
⊢ mk a₁ a₂ = mk b₁ b₂ ↔ ↑b₂ * a₁ = ↑a₂ * b₁

Next tactic:
simp_rw [mk_eq_mk_iff, r_iff_exists, mul_left_cancel_iff, exists_const]
@[to_additive]
instance le : LE (Localization s) :=
  ⟨fun a b =>
    Localization.liftOn₂ a b (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ ≤ a₂ * b₁)
      @fun a₁ b₁ a₂ b₂ c₁ d₁ c₂ d₂ hab hcd => propext $ by
        

Proof state:
α : Type u_1
inst✝ : OrderedCancelCommMonoid α
s : Submonoid α
a₁✝ b₁✝ : α
a₂✝ b₂✝ : ↥s
a b : Localization s
a₁ b₁ : α
a₂ b₂ : ↥s
c₁ d₁ : α
c₂ d₂ : ↥s
hab : (r s) (a₁, a₂) (b₁, b₂)
hcd : (r s) (c₁, c₂) (d₁, d₂)
⊢ (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ ≤ ↑a₂ * b₁) a₁ a₂ c₁ c₂ ↔ (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ ≤ ↑a₂ * b₁) b₁ b₂ d₁ d₂

Next tactic:
obtain ⟨e, he⟩ := r_iff_exists.1 hab
@[to_additive]
instance le : LE (Localization s) :=
  ⟨fun a b =>
    Localization.liftOn₂ a b (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ ≤ a₂ * b₁)
      @fun a₁ b₁ a₂ b₂ c₁ d₁ c₂ d₂ hab hcd => propext $ by
        obtain ⟨e, he⟩ := r_iff_exists.1 hab
        

Proof state:
case intro
α : Type u_1
inst✝ : OrderedCancelCommMonoid α
s : Submonoid α
a₁✝ b₁✝ : α
a₂✝ b₂✝ : ↥s
a b : Localization s
a₁ b₁ : α
a₂ b₂ : ↥s
c₁ d₁ : α
c₂ d₂ : ↥s
hab : (r s) (a₁, a₂) (b₁, b₂)
hcd : (r s) (c₁, c₂) (d₁, d₂)
e : ↥s
he : ↑e * (↑(b₁, b₂).2 * (a₁, a₂).1) = ↑e * (↑(a₁, a₂).2 * (b₁, b₂).1)
⊢ (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ ≤ ↑a₂ * b₁) a₁ a₂ c₁ c₂ ↔ (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ ≤ ↑a₂ * b₁) b₁ b₂ d₁ d₂

Next tactic:
obtain ⟨f, hf⟩ := r_iff_exists.1 hcd
@[to_additive]
instance le : LE (Localization s) :=
  ⟨fun a b =>
    Localization.liftOn₂ a b (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ ≤ a₂ * b₁)
      @fun a₁ b₁ a₂ b₂ c₁ d₁ c₂ d₂ hab hcd => propext $ by
        obtain ⟨e, he⟩ := r_iff_exists.1 hab
        obtain ⟨f, hf⟩ := r_iff_exists.1 hcd
        

Proof state:
case intro.intro
α : Type u_1
inst✝ : OrderedCancelCommMonoid α
s : Submonoid α
a₁✝ b₁✝ : α
a₂✝ b₂✝ : ↥s
a b : Localization s
a₁ b₁ : α
a₂ b₂ : ↥s
c₁ d₁ : α
c₂ d₂ : ↥s
hab : (r s) (a₁, a₂) (b₁, b₂)
hcd : (r s) (c₁, c₂) (d₁, d₂)
e : ↥s
he : ↑e * (↑(b₁, b₂).2 * (a₁, a₂).1) = ↑e * (↑(a₁, a₂).2 * (b₁, b₂).1)
f : ↥s
hf : ↑f * (↑(d₁, d₂).2 * (c₁, c₂).1) = ↑f * (↑(c₁, c₂).2 * (d₁, d₂).1)
⊢ (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ ≤ ↑a₂ * b₁) a₁ a₂ c₁ c₂ ↔ (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ ≤ ↑a₂ * b₁) b₁ b₂ d₁ d₂

Next tactic:
simp only [mul_right_inj] at he hf
@[to_additive]
instance le : LE (Localization s) :=
  ⟨fun a b =>
    Localization.liftOn₂ a b (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ ≤ a₂ * b₁)
      @fun a₁ b₁ a₂ b₂ c₁ d₁ c₂ d₂ hab hcd => propext $ by
        obtain ⟨e, he⟩ := r_iff_exists.1 hab
        obtain ⟨f, hf⟩ := r_iff_exists.1 hcd
        simp only [mul_right_inj] at he hf
        

Proof state:
case intro.intro
α : Type u_1
inst✝ : OrderedCancelCommMonoid α
s : Submonoid α
a₁✝ b₁✝ : α
a₂✝ b₂✝ : ↥s
a b : Localization s
a₁ b₁ : α
a₂ b₂ : ↥s
c₁ d₁ : α
c₂ d₂ : ↥s
hab : (r s) (a₁, a₂) (b₁, b₂)
hcd : (r s) (c₁, c₂) (d₁, d₂)
e f : ↥s
he : ↑b₂ * a₁ = ↑a₂ * b₁
hf : ↑d₂ * c₁ = ↑c₂ * d₁
⊢ (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ ≤ ↑a₂ * b₁) a₁ a₂ c₁ c₂ ↔ (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ ≤ ↑a₂ * b₁) b₁ b₂ d₁ d₂

Next tactic:
dsimp