@@ -133,6 +133,57 @@ class is_cancel_add (G : Type u) [has_add G]
133133
134134attribute [to_additive] is_cancel_mul
135135
136+ section is_left_cancel_mul
137+ variables [is_left_cancel_mul G] {a b c : G}
138+
139+ @[to_additive]
140+ lemma mul_left_cancel : a * b = a * c → b = c :=
141+ is_left_cancel_mul.mul_left_cancel a b c
142+
143+ @[to_additive]
144+ lemma mul_left_cancel_iff : a * b = a * c ↔ b = c :=
145+ ⟨mul_left_cancel, congr_arg _⟩
146+
147+ @[to_additive]
148+ theorem mul_right_injective (a : G) : function.injective ((*) a) :=
149+ λ b c, mul_left_cancel
150+
151+ @[simp, to_additive]
152+ theorem mul_right_inj (a : G) {b c : G} : a * b = a * c ↔ b = c :=
153+ (mul_right_injective a).eq_iff
154+
155+ @[to_additive]
156+ theorem mul_ne_mul_right (a : G) {b c : G} : a * b ≠ a * c ↔ b ≠ c :=
157+ (mul_right_injective a).ne_iff
158+
159+ end is_left_cancel_mul
160+
161+ section is_right_cancel_mul
162+
163+ variables [is_right_cancel_mul G] {a b c : G}
164+
165+ @[to_additive]
166+ lemma mul_right_cancel : a * b = c * b → a = c :=
167+ is_right_cancel_mul.mul_right_cancel a b c
168+
169+ @[to_additive]
170+ lemma mul_right_cancel_iff : b * a = c * a ↔ b = c :=
171+ ⟨mul_right_cancel, congr_arg _⟩
172+
173+ @[to_additive]
174+ theorem mul_left_injective (a : G) : function.injective (λ x, x * a) :=
175+ λ b c, mul_right_cancel
176+
177+ @[simp, to_additive]
178+ theorem mul_left_inj (a : G) {b c : G} : b * a = c * a ↔ b = c :=
179+ (mul_left_injective a).eq_iff
180+
181+ @[to_additive]
182+ theorem mul_ne_mul_left (a : G) {b c : G} : b * a ≠ c * a ↔ b ≠ c :=
183+ (mul_left_injective a).ne_iff
184+
185+ end is_right_cancel_mul
186+
136187end has_mul
137188
138189/-- A semigroup is a type with an associative `(*)`. -/
@@ -185,11 +236,7 @@ instance comm_semigroup.to_is_commutative : is_commutative G (*) :=
185236`is_right_cancel_add G`." ]
186237lemma comm_semigroup.is_right_cancel_mul.to_is_left_cancel_mul (G : Type u) [comm_semigroup G]
187238 [is_right_cancel_mul G] : is_left_cancel_mul G :=
188- { mul_left_cancel := λ a b c h,
189- begin
190- rw [mul_comm a b, mul_comm a c] at h,
191- exact is_right_cancel_mul.mul_right_cancel _ _ _ h
192- end }
239+ ⟨λ a b c h, mul_right_cancel $ (mul_comm _ _).trans (h.trans $ mul_comm _ _)⟩
193240
194241/-- Any `comm_semigroup G` that satisfies `is_left_cancel_mul G` also satisfies
195242`is_right_cancel_mul G`. -/
@@ -198,37 +245,23 @@ lemma comm_semigroup.is_right_cancel_mul.to_is_left_cancel_mul (G : Type u) [com
198245`is_left_cancel_add G`." ]
199246lemma comm_semigroup.is_left_cancel_mul.to_is_right_cancel_mul (G : Type u) [comm_semigroup G]
200247 [is_left_cancel_mul G] : is_right_cancel_mul G :=
201- { mul_right_cancel := λ a b c h,
202- begin
203- rw [mul_comm a b, mul_comm c b] at h,
204- exact is_left_cancel_mul.mul_left_cancel _ _ _ h
205- end }
248+ ⟨λ a b c h, mul_left_cancel $ (mul_comm _ _).trans (h.trans $ mul_comm _ _)⟩
206249
207250/-- Any `comm_semigroup G` that satisfies `is_left_cancel_mul G` also satisfies
208251`is_cancel_mul G`. -/
209252@[to_additive add_comm_semigroup.is_left_cancel_add.to_is_cancel_add " Any `add_comm_semigroup G`
210253that satisfies `is_left_cancel_add G` also satisfies `is_cancel_add G`." ]
211254lemma comm_semigroup.is_left_cancel_mul.to_is_cancel_mul (G : Type u) [comm_semigroup G]
212255 [is_left_cancel_mul G] : is_cancel_mul G :=
213- { mul_left_cancel := is_left_cancel_mul.mul_left_cancel,
214- mul_right_cancel := λ a b c h,
215- begin
216- rw [mul_comm a b, mul_comm c b] at h,
217- exact is_left_cancel_mul.mul_left_cancel _ _ _ h
218- end }
256+ { .. ‹is_left_cancel_mul G›, .. comm_semigroup.is_left_cancel_mul.to_is_right_cancel_mul G }
219257
220258/-- Any `comm_semigroup G` that satisfies `is_right_cancel_mul G` also satisfies
221259`is_cancel_mul G`. -/
222260@[to_additive add_comm_semigroup.is_right_cancel_add.to_is_cancel_add " Any `add_comm_semigroup G`
223261that satisfies `is_right_cancel_add G` also satisfies `is_cancel_add G`." ]
224262lemma comm_semigroup.is_right_cancel_mul.to_is_cancel_mul (G : Type u) [comm_semigroup G]
225263 [is_right_cancel_mul G] : is_cancel_mul G :=
226- { mul_left_cancel := λ a b c h,
227- begin
228- rw [mul_comm a b, mul_comm a c] at h,
229- exact is_right_cancel_mul.mul_right_cancel _ _ _ h
230- end ,
231- mul_right_cancel := is_right_cancel_mul.mul_right_cancel }
264+ { .. ‹is_right_cancel_mul G›, .. comm_semigroup.is_right_cancel_mul.to_is_left_cancel_mul G }
232265
233266end comm_semigroup
234267
@@ -243,37 +276,12 @@ class add_left_cancel_semigroup (G : Type u) extends add_semigroup G :=
243276(add_left_cancel : ∀ a b c : G, a + b = a + c → b = c)
244277attribute [to_additive add_left_cancel_semigroup] left_cancel_semigroup
245278
246- section left_cancel_semigroup
247- variables [left_cancel_semigroup G] {a b c : G}
248-
249- @[to_additive]
250- lemma mul_left_cancel : a * b = a * c → b = c :=
251- left_cancel_semigroup.mul_left_cancel a b c
252-
253- @[to_additive]
254- lemma mul_left_cancel_iff : a * b = a * c ↔ b = c :=
255- ⟨mul_left_cancel, congr_arg _⟩
256-
257- @[to_additive]
258- theorem mul_right_injective (a : G) : function.injective ((*) a) :=
259- λ b c, mul_left_cancel
260-
261- @[simp, to_additive]
262- theorem mul_right_inj (a : G) {b c : G} : a * b = a * c ↔ b = c :=
263- (mul_right_injective a).eq_iff
264-
265- @[to_additive]
266- theorem mul_ne_mul_right (a : G) {b c : G} : a * b ≠ a * c ↔ b ≠ c :=
267- (mul_right_injective a).ne_iff
268-
269279/-- Any `left_cancel_semigroup` satisfies `is_left_cancel_mul`. -/
270280@[priority 100 , to_additive " Any `add_left_cancel_semigroup` satisfies `is_left_cancel_add`." ]
271281instance left_cancel_semigroup.to_is_left_cancel_mul (G : Type u) [left_cancel_semigroup G] :
272282 is_left_cancel_mul G :=
273283{ mul_left_cancel := left_cancel_semigroup.mul_left_cancel }
274284
275- end left_cancel_semigroup
276-
277285/-- A `right_cancel_semigroup` is a semigroup such that `a * b = c * b` implies `a = c`. -/
278286@[protect_proj, ancestor semigroup, ext]
279287class right_cancel_semigroup (G : Type u) extends semigroup G :=
@@ -286,37 +294,12 @@ class add_right_cancel_semigroup (G : Type u) extends add_semigroup G :=
286294(add_right_cancel : ∀ a b c : G, a + b = c + b → a = c)
287295attribute [to_additive add_right_cancel_semigroup] right_cancel_semigroup
288296
289- section right_cancel_semigroup
290- variables [right_cancel_semigroup G] {a b c : G}
291-
292- @[to_additive]
293- lemma mul_right_cancel : a * b = c * b → a = c :=
294- right_cancel_semigroup.mul_right_cancel a b c
295-
296- @[to_additive]
297- lemma mul_right_cancel_iff : b * a = c * a ↔ b = c :=
298- ⟨mul_right_cancel, congr_arg _⟩
299-
300- @[to_additive]
301- theorem mul_left_injective (a : G) : function.injective (λ x, x * a) :=
302- λ b c, mul_right_cancel
303-
304- @[simp, to_additive]
305- theorem mul_left_inj (a : G) {b c : G} : b * a = c * a ↔ b = c :=
306- (mul_left_injective a).eq_iff
307-
308- @[to_additive]
309- theorem mul_ne_mul_left (a : G) {b c : G} : b * a ≠ c * a ↔ b ≠ c :=
310- (mul_left_injective a).ne_iff
311-
312297/-- Any `right_cancel_semigroup` satisfies `is_right_cancel_mul`. -/
313298@[priority 100 , to_additive " Any `add_right_cancel_semigroup` satisfies `is_right_cancel_add`." ]
314- instance right_cancel_semigroup.to_is_right_cancel_mul (G : Type u)
315- [right_cancel_semigroup G] : is_right_cancel_mul G :=
299+ instance right_cancel_semigroup.to_is_right_cancel_mul (G : Type u) [right_cancel_semigroup G] :
300+ is_right_cancel_mul G :=
316301{ mul_right_cancel := right_cancel_semigroup.mul_right_cancel }
317302
318- end right_cancel_semigroup
319-
320303/-- Typeclass for expressing that a type `M` with multiplication and a one satisfies
321304`1 * a = a` and `a * 1 = a` for all `a : M`. -/
322305@[ancestor has_one has_mul]
@@ -362,8 +345,6 @@ instance mul_one_class.to_is_right_id : is_right_id M (*) 1 :=
362345
363346end mul_one_class
364347
365-
366-
367348section
368349variables {M : Type u}
369350
@@ -580,8 +561,7 @@ class cancel_comm_monoid (M : Type u) extends left_cancel_monoid M, comm_monoid
580561@[priority 100 , to_additive] -- see Note [lower instance priority]
581562instance cancel_comm_monoid.to_cancel_monoid (M : Type u) [cancel_comm_monoid M] :
582563 cancel_monoid M :=
583- { mul_right_cancel := λ a b c h, mul_left_cancel $ by rw [mul_comm, h, mul_comm],
584- .. ‹cancel_comm_monoid M› }
564+ { .. ‹cancel_comm_monoid M›, .. comm_semigroup.is_left_cancel_mul.to_is_right_cancel_mul M }
585565
586566/-- Any `cancel_monoid M` satisfies `is_cancel_mul M`. -/
587567@[priority 100 , to_additive " Any `add_cancel_monoid M` satisfies `is_cancel_add M`." ]
0 commit comments