Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 03e6d0e

Browse files
urkudmergify[bot]
authored andcommitted
chore(algebra/group/hom): add is_monoid_hom.of_mul, use it (#1225)
* Let `to_additive` generate `is_add_monoid_hom.map_add` * Converting `is_mul_hom` into `is_monoid_hom` doesn't require `α` to be a group * Simplify the proof of `is_add_group_hom.map_sub` Avoid `simp` (without `only`)
1 parent 51f2645 commit 03e6d0e

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

src/algebra/group/hom.lean

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/-
22
Copyright (c) 2014 Patrick Massot. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
4-
Authors: Patrick Massot, Kevin Buzzard, Scott Morrison, Johan Commelin, Chris Hughes, Johannes Hölzl
4+
Authors: Patrick Massot, Kevin Buzzard, Scott Morrison, Johan Commelin, Chris Hughes, Johannes Hölzl, Yury Kudryashov
55
66
Homomorphisms of multiplicative and additive (semi)groups and monoids.
77
-/
@@ -73,20 +73,16 @@ attribute [to_additive is_add_monoid_hom.map_zero] is_monoid_hom.map_one
7373
namespace is_monoid_hom
7474
variables [monoid α] [monoid β] (f : α → β) [is_monoid_hom f]
7575

76+
@[to_additive is_add_monoid_hom.map_add]
7677
lemma map_mul (x y) : f (x * y) = f x * f y :=
7778
is_mul_hom.map_mul f x y
7879

7980
end is_monoid_hom
8081

81-
namespace is_add_monoid_hom
82-
variables [add_monoid α] [add_monoid β] (f : α → β) [is_add_monoid_hom f]
83-
84-
lemma map_add (x y) : f (x + y) = f x + f y :=
85-
is_add_hom.map_add f x y
86-
87-
attribute [to_additive is_add_monoid_hom.map_add] is_monoid_hom.map_mul
88-
89-
end is_add_monoid_hom
82+
@[to_additive is_add_monoid_hom.of_add]
83+
theorem is_monoid_hom.of_mul [monoid α] [group β] (f : α → β) [is_mul_hom f] :
84+
is_monoid_hom f :=
85+
{ map_one := mul_self_iff_eq_one.1 $ by rw [← is_mul_hom.map_mul f, one_mul] }
9086

9187
namespace is_monoid_hom
9288
variables [monoid α] [monoid β] (f : α → β) [is_monoid_hom f]
@@ -137,9 +133,12 @@ namespace is_group_hom
137133
variables [group α] [group β] (f : α → β) [is_group_hom f]
138134
open is_mul_hom (map_mul)
139135

136+
@[to_additive is_add_group_hom.to_is_add_monoid_hom]
137+
instance to_is_monoid_hom : is_monoid_hom f :=
138+
is_monoid_hom.of_mul f
139+
140140
@[to_additive is_add_group_hom.map_zero]
141-
theorem map_one : f 1 = 1 :=
142-
mul_self_iff_eq_one.1 $ by rw [← map_mul f, one_mul]
141+
lemma map_one : f 1 = 1 := is_monoid_hom.map_one f
143142

144143
@[to_additive is_add_group_hom.map_neg]
145144
theorem map_inv (a : α) : f a⁻¹ = (f a)⁻¹ :=
@@ -151,10 +150,6 @@ instance id : is_group_hom (@id α) := { }
151150
@[to_additive is_add_group_hom.comp]
152151
instance comp {γ} [group γ] (g : β → γ) [is_group_hom g] : is_group_hom (g ∘ f) := { }
153152

154-
@[to_additive is_add_group_hom.to_is_add_monoid_hom]
155-
lemma to_is_monoid_hom (f : α → β) [is_group_hom f] : is_monoid_hom f :=
156-
{ map_one := map_one f }
157-
158153
@[to_additive is_add_group_hom.injective_iff]
159154
lemma injective_iff (f : α → β) [is_group_hom f] :
160155
function.injective f ↔ (∀ a, f a = 1 → a = 1) :=
@@ -163,9 +158,6 @@ lemma injective_iff (f : α → β) [is_group_hom f] :
163158
← map_mul f] at hxy;
164159
simpa using inv_eq_of_mul_eq_one (h _ hxy)⟩
165160

166-
attribute [instance] is_group_hom.to_is_monoid_hom
167-
is_add_group_hom.to_is_add_monoid_hom
168-
169161
@[to_additive is_add_group_hom.add]
170162
lemma mul {α β} [group α] [comm_group β]
171163
(f g : α → β) [is_group_hom f] [is_group_hom g] :
@@ -193,9 +185,8 @@ namespace is_add_group_hom
193185
variables [add_group α] [add_group β] (f : α → β) [is_add_group_hom f]
194186

195187
lemma map_sub (a b) : f (a - b) = f a - f b :=
196-
calc f (a - b) = f (a + -b) : rfl
197-
... = f a + f (-b) : is_add_hom.map_add f _ _
198-
... = f a - f b : by simp[map_neg f]
188+
calc f (a + -b) = f a + f (-b) : is_add_hom.map_add f _ _
189+
... = f a + -f b : by rw [map_neg f]
199190

200191
end is_add_group_hom
201192

0 commit comments

Comments
 (0)