Theorem: Submonoid.LocalizationWithZeroMap.leftCancelMulZero_of_le_isLeftRegular
File: Mathlib/GroupTheory/MonoidLocalization/MonoidWithZero.lean

Proof steps:
state_before: 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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
⊢ IsLeftCancelMulZero N
state_after: 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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
⊢ IsLeftCancelMulZero N
tactic: let fl := f.toLocalizationMap
state_before: 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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
⊢ IsLeftCancelMulZero N
state_after: 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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
⊢ IsLeftCancelMulZero N
tactic: let g := f.toMap
state_before: 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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
⊢ IsLeftCancelMulZero N
state_after: case mul_left_cancel_of_ne_zero
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
⊢ ∀ {a b c : N}, a ≠ 0 → a * b = a * c → b = c
tactic: constructor
state_before: case mul_left_cancel_of_ne_zero
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
⊢ ∀ {a b c : N}, a ≠ 0 → a * b = a * c → b = c
state_after: case mul_left_cancel_of_ne_zero
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
⊢ z = w
tactic: intro a z w ha hazw
state_before: case mul_left_cancel_of_ne_zero
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
⊢ z = w
state_after: case mul_left_cancel_of_ne_zero.intro
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
⊢ z = w
tactic: obtain ⟨b, hb⟩ := LocalizationMap.surj fl a
state_before: case mul_left_cancel_of_ne_zero.intro
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
⊢ z = w
state_after: case mul_left_cancel_of_ne_zero.intro.intro
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
⊢ z = w
tactic: obtain ⟨x, hx⟩ := LocalizationMap.surj fl z
state_before: case mul_left_cancel_of_ne_zero.intro.intro
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
⊢ z = w
state_after: case mul_left_cancel_of_ne_zero.intro.intro.intro
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
y : M × ↥S
hy : w * fl.toMap ↑y.2 = fl.toMap y.1
⊢ z = w
tactic: obtain ⟨y, hy⟩ := LocalizationMap.surj fl w
state_before: case mul_left_cancel_of_ne_zero.intro.intro.intro
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
y : M × ↥S
hy : w * fl.toMap ↑y.2 = fl.toMap y.1
⊢ z = w
state_after: case mul_left_cancel_of_ne_zero.intro.intro.intro
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
y : M × ↥S
hy : w * fl.toMap ↑y.2 = fl.toMap y.1
⊢ ∃ c, ↑c * (↑y.2 * x.1) = ↑c * (↑x.2 * y.1)
tactic: rw [(LocalizationMap.eq_mk'_iff_mul_eq fl).mpr hx,
    (LocalizationMap.eq_mk'_iff_mul_eq fl).mpr hy, LocalizationMap.eq]
state_before: case mul_left_cancel_of_ne_zero.intro.intro.intro
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
y : M × ↥S
hy : w * fl.toMap ↑y.2 = fl.toMap y.1
⊢ ∃ c, ↑c * (↑y.2 * x.1) = ↑c * (↑x.2 * y.1)
state_after: case h
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
y : M × ↥S
hy : w * fl.toMap ↑y.2 = fl.toMap y.1
⊢ ↑1 * (↑y.2 * x.1) = ↑1 * (↑x.2 * y.1)
tactic: use 1
state_before: case h
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
y : M × ↥S
hy : w * fl.toMap ↑y.2 = fl.toMap y.1
⊢ ↑1 * (↑y.2 * x.1) = ↑1 * (↑x.2 * y.1)
state_after: case h
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
y : M × ↥S
hy : w * fl.toMap ↑y.2 = fl.toMap y.1
⊢ ↑y.2 * x.1 = ↑x.2 * y.1
tactic: rw [OneMemClass.coe_one, one_mul, one_mul]
state_before: case h
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
y : M × ↥S
hy : w * fl.toMap ↑y.2 = fl.toMap y.1
⊢ ↑y.2 * x.1 = ↑x.2 * y.1
state_after: case h
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
y : M × ↥S
hy : w * fl.toMap ↑y.2 = fl.toMap y.1
b1ne0 : b.1 ≠ 0
⊢ ↑y.2 * x.1 = ↑x.2 * y.1
tactic: have b1ne0 : b.1 ≠ 0 := by
    intro hb1
    have m0 : (LocalizationMap.toMap fl) 0 = 0 := f.map_zero'
    have a0 : a * (LocalizationMap.toMap fl) b.2 = 0 ↔ a = 0 :=
      (f.toLocalizationMap.map_units' b.2).mul_left_eq_zero
    rw [hb1, m0, a0] at hb
    exact ha hb
state_before: case h
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
y : M × ↥S
hy : w * fl.toMap ↑y.2 = fl.toMap y.1
b1ne0 : b.1 ≠ 0
⊢ ↑y.2 * x.1 = ↑x.2 * y.1
state_after: case h
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
y : M × ↥S
hy : w * fl.toMap ↑y.2 = fl.toMap y.1
b1ne0 : b.1 ≠ 0
main : g (b.1 * (↑x.2 * y.1)) = g (b.1 * (↑y.2 * x.1))
⊢ ↑y.2 * x.1 = ↑x.2 * y.1
tactic: have main : g (b.1 * (x.2 * y.1)) = g (b.1 * (y.2 * x.1)) :=
    calc
      g (b.1 * (x.2 * y.1)) = g b.1 * (g x.2 * g y.1) := by rw [map_mul g,map_mul g]
      _ = a * g b.2 * (g x.2 * (w * g y.2)) := by rw [hb, hy]
      _ = a * w * g b.2 * (g x.2 * g y.2) := by
        rw [← mul_assoc, ← mul_assoc _ w, mul_comm _ w, mul_assoc w, mul_assoc,
          ← mul_assoc w, ← mul_assoc w, mul_comm w]
      _ = a * z * g b.2 * (g x.2 * g y.2) := by rw [hazw]
      _ = a * g b.2 * (z * g x.2 * g y.2) := by
        rw [mul_assoc a, mul_comm z, ← mul_assoc a, mul_assoc, mul_assoc z]
      _ = g b.1 * g (y.2 * x.1) := by rw [hx, hb, mul_comm (g x.1), ← map_mul g]
      _ = g (b.1 * (y.2 * x.1)) := by rw [← map_mul g]
state_before: case h
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 : S.LocalizationWithZeroMap N
inst✝ : IsLeftCancelMulZero M
h : ∀ ⦃x : M⦄, x ∈ S → IsLeftRegular x
fl : S.LocalizationMap N := f.toLocalizationMap
g : M →* N := f.toMap
a z w : N
ha : a ≠ 0
hazw : a * z = a * w
b : M × ↥S
hb : a * fl.toMap ↑b.2 = fl.toMap b.1
x : M × ↥S
hx : z * fl.toMap ↑x.2 = fl.toMap x.1
y : M × ↥S
hy : w * fl.toMap ↑y.2 = fl.toMap y.1
b1ne0 : b.1 ≠ 0
main : g (b.1 * (↑x.2 * y.1)) = g (b.1 * (↑y.2 * x.1))
⊢ ↑y.2 * x.1 = ↑x.2 * y.1
state_after: no goals
tactic: exact (IsLeftCancelMulZero.mul_left_cancel_of_ne_zero b1ne0
      ((LocalizationMap.toMap_injective_iff fl).mpr h main)).symm