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

Commit 4f75760

Browse files
committed
chore(*/hom,equiv): Split monoid_hom into more fundamental structures, and reuse them elsewhere (#4423)
Notably this adds `add_hom` and `mul_hom`, which become base classes of `add_equiv`, `mul_equiv`, `linear_map`, and `linear_equiv`. Primarily to avoid breaking assumptions of field order in `monoid_hom` and `add_monoid_hom`, this also adds `one_hom` and `zero_hom`. A massive number of lemmas here are totally uninteresting and hold for pretty much all objects that define `coe_to_fun`. This PR translates all those lemmas, but doesn't bother attempting to generalize later ones.
1 parent b4dc912 commit 4f75760

File tree

4 files changed

+255
-70
lines changed

4 files changed

+255
-70
lines changed

src/algebra/group/hom.lean

Lines changed: 232 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -48,75 +48,165 @@ monoid_hom, add_monoid_hom
4848
variables {M : Type*} {N : Type*} {P : Type*} -- monoids
4949
{G : Type*} {H : Type*} -- groups
5050

51-
/-- Bundled add_monoid homomorphisms; use this for bundled add_group homomorphisms too. -/
52-
structure add_monoid_hom (M : Type*) (N : Type*) [add_monoid M] [add_monoid N] :=
51+
-- for easy multiple inheritance
52+
set_option old_structure_cmd true
53+
54+
/-- Homomorphism that preserves zero -/
55+
structure zero_hom (M : Type*) (N : Type*) [has_zero M] [has_zero N] :=
5356
(to_fun : M → N)
5457
(map_zero' : to_fun 0 = 0)
58+
59+
/-- Homomorphism that preserves addition -/
60+
structure add_hom (M : Type*) (N : Type*) [has_add M] [has_add N] :=
61+
(to_fun : M → N)
5562
(map_add' : ∀ x y, to_fun (x + y) = to_fun x + to_fun y)
5663

64+
/-- Bundled add_monoid homomorphisms; use this for bundled add_group homomorphisms too. -/
65+
structure add_monoid_hom (M : Type*) (N : Type*) [add_monoid M] [add_monoid N]
66+
extends zero_hom M N, add_hom M N
67+
68+
attribute [nolint doc_blame] add_monoid_hom.to_add_hom
69+
attribute [nolint doc_blame] add_monoid_hom.to_zero_hom
70+
5771
infixr ` →+ `:25 := add_monoid_hom
5872

59-
/-- Bundled monoid homomorphisms; use this for bundled group homomorphisms too. -/
73+
/-- Homomorphism that preserves one -/
6074
@[to_additive]
61-
structure monoid_hom (M : Type*) (N : Type*) [monoid M] [monoid N] :=
75+
structure one_hom (M : Type*) (N : Type*) [has_one M] [has_one N] :=
6276
(to_fun : M → N)
6377
(map_one' : to_fun 1 = 1)
78+
79+
/-- Homomorphism that preserves multiplication -/
80+
@[to_additive]
81+
structure mul_hom (M : Type*) (N : Type*) [has_mul M] [has_mul N] :=
82+
(to_fun : M → N)
6483
(map_mul' : ∀ x y, to_fun (x * y) = to_fun x * to_fun y)
6584

85+
/-- Bundled monoid homomorphisms; use this for bundled group homomorphisms too. -/
86+
@[to_additive]
87+
structure monoid_hom (M : Type*) (N : Type*) [monoid M] [monoid N] extends one_hom M N, mul_hom M N
88+
89+
attribute [nolint doc_blame] monoid_hom.to_mul_hom
90+
attribute [nolint doc_blame] monoid_hom.to_one_hom
91+
6692
infixr ` →* `:25 := monoid_hom
6793

94+
-- completely uninteresting lemmas about coercion to function, that all homs need
95+
section coes
96+
97+
@[to_additive]
98+
instance {mM : has_one M} {mN : has_one N} : has_coe_to_fun (one_hom M N) :=
99+
⟨_, one_hom.to_fun⟩
68100
@[to_additive]
69-
instance {M : Type*} {N : Type*} {mM : monoid M} {mN : monoid N} : has_coe_to_fun (M →* N) :=
101+
instance {mM : has_mul M} {mN : has_mul N} : has_coe_to_fun (mul_hom M N) :=
102+
⟨_, mul_hom.to_fun⟩
103+
@[to_additive]
104+
instance {mM : monoid M} {mN : monoid N} : has_coe_to_fun (M →* N) :=
70105
⟨_, monoid_hom.to_fun⟩
71106

72-
namespace monoid_hom
73-
variables {mM : monoid M} {mN : monoid N} {mP : monoid P}
74-
variables [group G] [comm_group H]
75-
76-
include mM mN
77-
78107
@[simp, to_additive]
79-
lemma to_fun_eq_coe (f : M →* N) : f.to_fun = f := rfl
108+
lemma one_hom.to_fun_eq_coe [has_one M] [has_one N] (f : one_hom M N) : f.to_fun = f := rfl
109+
@[simp, to_additive]
110+
lemma mul_hom.to_fun_eq_coe [has_mul M] [has_mul N] (f : mul_hom M N) : f.to_fun = f := rfl
111+
@[simp, to_additive]
112+
lemma monoid_hom.to_fun_eq_coe [monoid M] [monoid N] (f : M →* N) : f.to_fun = f := rfl
80113

81114
@[simp, to_additive]
82-
lemma coe_mk (f : M → N) (h1 hmul) : ⇑(monoid_hom.mk f h1 hmul) = f := rfl
115+
lemma one_hom.coe_mk [has_one M] [has_one N]
116+
(f : M → N) (h1) : ⇑(one_hom.mk f h1) = f := rfl
117+
@[simp, to_additive]
118+
lemma mul_hom.coe_mk [has_mul M] [has_mul N]
119+
(f : M → N) (hmul) : ⇑(mul_hom.mk f hmul) = f := rfl
120+
@[simp, to_additive]
121+
lemma monoid_hom.coe_mk [monoid M] [monoid N]
122+
(f : M → N) (h1 hmul) : ⇑(monoid_hom.mk f h1 hmul) = f := rfl
83123

84124
@[to_additive]
85-
theorem congr_fun {f g : M →* N} (h : f = g) (x : M) : f x = g x :=
125+
theorem one_hom.congr_fun [has_one M] [has_one N]
126+
{f g : one_hom M N} (h : f = g) (x : M) : f x = g x :=
127+
congr_arg (λ h : one_hom M N, h x) h
128+
@[to_additive]
129+
theorem mul_hom.congr_fun [has_mul M] [has_mul N]
130+
{f g : mul_hom M N} (h : f = g) (x : M) : f x = g x :=
131+
congr_arg (λ h : mul_hom M N, h x) h
132+
@[to_additive]
133+
theorem monoid_hom.congr_fun [monoid M] [monoid N]
134+
{f g : M →* N} (h : f = g) (x : M) : f x = g x :=
86135
congr_arg (λ h : M →* N, h x) h
87136

88137
@[to_additive]
89-
theorem congr_arg (f : M →* N) {x y : M} (h : x = y) : f x = f y :=
138+
theorem one_hom.congr_arg [has_one M] [has_one N]
139+
(f : one_hom M N) {x y : M} (h : x = y) : f x = f y :=
140+
congr_arg (λ x : M, f x) h
141+
@[to_additive]
142+
theorem mul_hom.congr_arg [has_mul M] [has_mul N]
143+
(f : mul_hom M N) {x y : M} (h : x = y) : f x = f y :=
144+
congr_arg (λ x : M, f x) h
145+
@[to_additive]
146+
theorem monoid_hom.congr_arg [monoid M] [monoid N]
147+
(f : M →* N) {x y : M} (h : x = y) : f x = f y :=
90148
congr_arg (λ x : M, f x) h
91149

92150
@[to_additive]
93-
lemma coe_inj ⦃f g : M →* N⦄ (h : (f : M → N) = g) : f = g :=
151+
lemma one_hom.coe_inj [has_one M] [has_one N] ⦃f g : one_hom M N⦄ (h : (f : M → N) = g) : f = g :=
152+
by cases f; cases g; cases h; refl
153+
@[to_additive]
154+
lemma mul_hom.coe_inj [has_mul M] [has_mul N] ⦃f g : mul_hom M N⦄ (h : (f : M → N) = g) : f = g :=
155+
by cases f; cases g; cases h; refl
156+
@[to_additive]
157+
lemma monoid_hom.coe_inj [monoid M] [monoid N] ⦃f g : M →* N⦄ (h : (f : M → N) = g) : f = g :=
94158
by cases f; cases g; cases h; refl
95159

96160
@[ext, to_additive]
97-
lemma ext ⦃f g : M →* N⦄ (h : ∀ x, f x = g x) : f = g :=
98-
coe_inj (funext h)
161+
lemma one_hom.ext [has_one M] [has_one N] ⦃f g : one_hom M N⦄ (h : ∀ x, f x = g x) : f = g :=
162+
one_hom.coe_inj (funext h)
163+
@[ext, to_additive]
164+
lemma mul_hom.ext [has_mul M] [has_mul N] ⦃f g : mul_hom M N⦄ (h : ∀ x, f x = g x) : f = g :=
165+
mul_hom.coe_inj (funext h)
166+
@[ext, to_additive]
167+
lemma monoid_hom.ext [monoid M] [monoid N] ⦃f g : M →* N⦄ (h : ∀ x, f x = g x) : f = g :=
168+
monoid_hom.coe_inj (funext h)
99169

100-
attribute [ext] _root_.add_monoid_hom.ext
170+
attribute [ext] zero_hom.ext add_hom.ext add_monoid_hom.ext
101171

102172
@[to_additive]
103-
lemma ext_iff {f g : M →* N} : f = g ↔ ∀ x, f x = g x :=
104-
⟨λ h x, h ▸ rfl, λ h, ext h⟩
173+
lemma one_hom.ext_iff [has_one M] [has_one N] {f g : one_hom M N} : f = g ↔ ∀ x, f x = g x :=
174+
⟨λ h x, h ▸ rfl, λ h, one_hom.ext h⟩
175+
@[to_additive]
176+
lemma mul_hom.ext_iff [has_mul M] [has_mul N] {f g : mul_hom M N} : f = g ↔ ∀ x, f x = g x :=
177+
⟨λ h x, h ▸ rfl, λ h, mul_hom.ext h⟩
178+
@[to_additive]
179+
lemma monoid_hom.ext_iff [monoid M] [monoid N] {f g : M →* N} : f = g ↔ ∀ x, f x = g x :=
180+
⟨λ h x, h ▸ rfl, λ h, monoid_hom.ext h⟩
181+
182+
end coes
105183

184+
@[simp, to_additive]
185+
lemma one_hom.map_one [has_one M] [has_one N] (f : one_hom M N) : f 1 = 1 := f.map_one'
106186
/-- If `f` is a monoid homomorphism then `f 1 = 1`. -/
107187
@[simp, to_additive]
108-
lemma map_one (f : M →* N) : f 1 = 1 := f.map_one'
188+
lemma monoid_hom.map_one [monoid M] [monoid N] (f : M →* N) : f 1 = 1 := f.map_one'
109189

110190
/-- If `f` is an additive monoid homomorphism then `f 0 = 0`. -/
111191
add_decl_doc add_monoid_hom.map_zero
112192

193+
@[simp, to_additive]
194+
lemma mul_hom.map_mul [has_mul M] [has_mul N]
195+
(f : mul_hom M N) (a b : M) : f (a * b) = f a * f b := f.map_mul' a b
113196
/-- If `f` is a monoid homomorphism then `f (a * b) = f a * f b`. -/
114197
@[simp, to_additive]
115-
lemma map_mul (f : M →* N) (a b : M) : f (a * b) = f a * f b := f.map_mul' a b
198+
lemma monoid_hom.map_mul [monoid M] [monoid N]
199+
(f : M →* N) (a b : M) : f (a * b) = f a * f b := f.map_mul' a b
116200

117201
/-- If `f` is an additive monoid homomorphism then `f (a + b) = f a + f b`. -/
118202
add_decl_doc add_monoid_hom.map_add
119203

204+
namespace monoid_hom
205+
variables {mM : monoid M} {mN : monoid N} {mP : monoid P}
206+
variables [group G] [comm_group H]
207+
208+
include mM mN
209+
120210
@[to_additive]
121211
lemma map_mul_eq_one (f : M →* N) {a b : M} (h : a * b = 1) : f a * f b = 1 :=
122212
by rw [← f.map_mul, h, f.map_one]
@@ -138,56 +228,126 @@ lemma map_exists_left_inv (f : M →* N) {x : M} (hx : ∃ y, y * x = 1) :
138228
∃ y, y * f x = 1 :=
139229
let ⟨y, hy⟩ := hx in ⟨f y, f.map_mul_eq_one hy⟩
140230

141-
omit mN mM
231+
end monoid_hom
142232

233+
/-- The identity map from a type with 1 to itself. -/
234+
@[to_additive]
235+
def one_hom.id (M : Type*) [has_one M] : one_hom M M :=
236+
{ to_fun := id, map_one' := rfl, }
237+
/-- The identity map from a type with multiplication to itself. -/
238+
@[to_additive]
239+
def mul_hom.id (M : Type*) [has_mul M] : mul_hom M M :=
240+
{ to_fun := id, map_mul' := λ _ _, rfl, }
143241
/-- The identity map from a monoid to itself. -/
144242
@[to_additive]
145-
def id (M : Type*) [monoid M] : M →* M :=
146-
{ to_fun := id,
147-
map_one' := rfl,
148-
map_mul' := λ _ _, rfl }
243+
def monoid_hom.id (M : Type*) [monoid M] : M →* M :=
244+
{ to_fun := id, map_one' := rfl, map_mul' := λ _ _, rfl, }
149245

246+
/-- The identity map from an type with zero to itself. -/
247+
add_decl_doc zero_hom.id
248+
/-- The identity map from an type with addition to itself. -/
249+
add_decl_doc add_hom.id
150250
/-- The identity map from an additive monoid to itself. -/
151251
add_decl_doc add_monoid_hom.id
152252

153-
@[simp, to_additive] lemma id_apply {M : Type*} [monoid M] (x : M) :
154-
id M x = x := rfl
155-
156-
include mM mN mP
253+
@[simp, to_additive] lemma one_hom.id_apply {M : Type*} [has_one M] (x : M) :
254+
one_hom.id M x = x := rfl
255+
@[simp, to_additive] lemma mul_hom.id_apply {M : Type*} [has_mul M] (x : M) :
256+
mul_hom.id M x = x := rfl
257+
@[simp, to_additive] lemma monoid_hom.id_apply {M : Type*} [monoid M] (x : M) :
258+
monoid_hom.id M x = x := rfl
157259

260+
/-- Composition of `one_hom`s as a `one_hom`. -/
261+
@[to_additive]
262+
def one_hom.comp [has_one M] [has_one N] [has_one P]
263+
(hnp : one_hom N P) (hmn : one_hom M N) : one_hom M P :=
264+
{ to_fun := hnp ∘ hmn, map_one' := by simp, }
265+
/-- Composition of `mul_hom`s as a `mul_hom`. -/
266+
@[to_additive]
267+
def mul_hom.comp [has_mul M] [has_mul N] [has_mul P]
268+
(hnp : mul_hom N P) (hmn : mul_hom M N) : mul_hom M P :=
269+
{ to_fun := hnp ∘ hmn, map_mul' := by simp, }
158270
/-- Composition of monoid morphisms as a monoid morphism. -/
159271
@[to_additive]
160-
def comp (hnp : N →* P) (hmn : M →* N) : M →* P :=
161-
{ to_fun := hnp ∘ hmn,
162-
map_one' := by simp,
163-
map_mul' := by simp }
272+
def monoid_hom.comp [monoid M] [monoid N] [monoid P] (hnp : N →* P) (hmn : M →* N) : M →* P :=
273+
{ to_fun := hnp ∘ hmn, map_one' := by simp, map_mul' := by simp, }
164274

275+
/-- Composition of `zero_hom`s as a `zero_hom`. -/
276+
add_decl_doc zero_hom.comp
277+
/-- Composition of `add_hom`s as a `add_hom`. -/
278+
add_decl_doc add_hom.comp
165279
/-- Composition of additive monoid morphisms as an additive monoid morphism. -/
166280
add_decl_doc add_monoid_hom.comp
167281

168-
@[simp, to_additive] lemma comp_apply (g : N →* P) (f : M →* N) (x : M) :
282+
@[simp, to_additive] lemma one_hom.comp_apply [has_one M] [has_one N] [has_one P]
283+
(g : one_hom N P) (f : one_hom M N) (x : M) :
284+
g.comp f x = g (f x) := rfl
285+
@[simp, to_additive] lemma mul_hom.comp_apply [has_mul M] [has_mul N] [has_mul P]
286+
(g : mul_hom N P) (f : mul_hom M N) (x : M) :
287+
g.comp f x = g (f x) := rfl
288+
@[simp, to_additive] lemma monoid_hom.comp_apply [monoid M] [monoid N] [monoid P]
289+
(g : N →* P) (f : M →* N) (x : M) :
169290
g.comp f x = g (f x) := rfl
170291

171292
/-- Composition of monoid homomorphisms is associative. -/
172-
@[to_additive] lemma comp_assoc {Q : Type*} [monoid Q] (f : M →* N) (g : N →* P) (h : P →* Q) :
293+
@[to_additive] lemma one_hom.comp_assoc {Q : Type*} [has_one M] [has_one N] [has_one P] [has_one Q]
294+
(f : one_hom M N) (g : one_hom N P) (h : one_hom P Q) :
295+
(h.comp g).comp f = h.comp (g.comp f) := rfl
296+
@[to_additive] lemma mul_hom.comp_assoc {Q : Type*} [has_mul M] [has_mul N] [has_mul P] [has_mul Q]
297+
(f : mul_hom M N) (g : mul_hom N P) (h : mul_hom P Q) :
298+
(h.comp g).comp f = h.comp (g.comp f) := rfl
299+
@[to_additive] lemma monoid_hom.comp_assoc {Q : Type*} [monoid M] [monoid N] [monoid P] [monoid Q]
300+
(f : M →* N) (g : N →* P) (h : P →* Q) :
173301
(h.comp g).comp f = h.comp (g.comp f) := rfl
174302

175303
@[to_additive]
176-
lemma cancel_right {g₁ g₂ : N →* P} {f : M →* N} (hf : function.surjective f) :
304+
lemma one_hom.cancel_right [has_one M] [has_one N] [has_one P]
305+
{g₁ g₂ : one_hom N P} {f : one_hom M N} (hf : function.surjective f) :
306+
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
307+
⟨λ h, one_hom.ext $ (forall_iff_forall_surj hf).1 (one_hom.ext_iff.1 h), λ h, h ▸ rfl⟩
308+
@[to_additive]
309+
lemma mul_hom.cancel_right [has_mul M] [has_mul N] [has_mul P]
310+
{g₁ g₂ : mul_hom N P} {f : mul_hom M N} (hf : function.surjective f) :
311+
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
312+
⟨λ h, mul_hom.ext $ (forall_iff_forall_surj hf).1 (mul_hom.ext_iff.1 h), λ h, h ▸ rfl⟩
313+
@[to_additive]
314+
lemma monoid_hom.cancel_right [monoid M] [monoid N] [monoid P]
315+
{g₁ g₂ : N →* P} {f : M →* N} (hf : function.surjective f) :
177316
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
178-
⟨λ h, monoid_hom.ext $ (forall_iff_forall_surj hf).1 (ext_iff.1 h), λ h, h ▸ rfl⟩
317+
⟨λ h, monoid_hom.ext $ (forall_iff_forall_surj hf).1 (monoid_hom.ext_iff.1 h), λ h, h ▸ rfl⟩
179318

180319
@[to_additive]
181-
lemma cancel_left {g : N →* P} {f₁ f₂ : M →* N} (hg : function.injective g) :
320+
lemma one_hom.cancel_left [has_one M] [has_one N] [has_one P]
321+
{g : one_hom N P} {f₁ f₂ : one_hom M N} (hg : function.injective g) :
182322
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
183-
⟨λ h, monoid_hom.ext $ λ x, hg $ by rw [← comp_apply, h, comp_apply], λ h, h ▸ rfl⟩
184-
185-
omit mP
186-
187-
@[simp, to_additive] lemma comp_id (f : M →* N) : f.comp (id M) = f := ext $ λ x, rfl
188-
@[simp, to_additive] lemma id_comp (f : M →* N) : (id N).comp f = f := ext $ λ x, rfl
189-
190-
end monoid_hom
323+
⟨λ h, one_hom.ext $ λ x, hg $ by rw [← one_hom.comp_apply, h, one_hom.comp_apply],
324+
λ h, h ▸ rfl⟩
325+
@[to_additive]
326+
lemma mul_hom.cancel_left [has_one M] [has_one N] [has_one P]
327+
{g : one_hom N P} {f₁ f₂ : one_hom M N} (hg : function.injective g) :
328+
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
329+
⟨λ h, one_hom.ext $ λ x, hg $ by rw [← one_hom.comp_apply, h, one_hom.comp_apply],
330+
λ h, h ▸ rfl⟩
331+
@[to_additive]
332+
lemma monoid_hom.cancel_left [monoid M] [monoid N] [monoid P]
333+
{g : N →* P} {f₁ f₂ : M →* N} (hg : function.injective g) :
334+
g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=
335+
⟨λ h, monoid_hom.ext $ λ x, hg $ by rw [← monoid_hom.comp_apply, h, monoid_hom.comp_apply],
336+
λ h, h ▸ rfl⟩
337+
338+
@[simp, to_additive] lemma one_hom.comp_id [has_one M] [has_one N]
339+
(f : one_hom M N) : f.comp (one_hom.id M) = f := one_hom.ext $ λ x, rfl
340+
@[simp, to_additive] lemma mul_hom.comp_id [has_mul M] [has_mul N]
341+
(f : mul_hom M N) : f.comp (mul_hom.id M) = f := mul_hom.ext $ λ x, rfl
342+
@[simp, to_additive] lemma monoid_hom.comp_id [monoid M] [monoid N]
343+
(f : M →* N) : f.comp (monoid_hom.id M) = f := monoid_hom.ext $ λ x, rfl
344+
345+
@[simp, to_additive] lemma one_hom.id_comp [has_one M] [has_one N]
346+
(f : one_hom M N) : (one_hom.id N).comp f = f := one_hom.ext $ λ x, rfl
347+
@[simp, to_additive] lemma mul_hom.id_comp [has_mul M] [has_mul N]
348+
(f : mul_hom M N) : (mul_hom.id N).comp f = f := mul_hom.ext $ λ x, rfl
349+
@[simp, to_additive] lemma monoid_hom.id_comp [monoid M] [monoid N]
350+
(f : M →* N) : (monoid_hom.id N).comp f = f := monoid_hom.ext $ λ x, rfl
191351

192352
section End
193353

@@ -247,24 +407,38 @@ end add_monoid
247407

248408
end End
249409

250-
namespace monoid_hom
251-
variables [mM : monoid M] [mN : monoid N] [mP : monoid P]
252-
variables [group G] [comm_group H]
253-
include mM mN
254-
410+
/-- `1` is the homomorphism sending all elements to `1`. -/
411+
@[to_additive]
412+
instance [has_one M] [has_one N] : has_one (one_hom M N) := ⟨⟨λ _, 1, rfl⟩⟩
413+
/-- `1` is the multiplicative homomorphism sending all elements to `1`. -/
414+
@[to_additive]
415+
instance [has_mul M] [monoid N] : has_one (mul_hom M N) := ⟨⟨λ _, 1, λ _ _, (one_mul 1).symm⟩⟩
255416
/-- `1` is the monoid homomorphism sending all elements to `1`. -/
256417
@[to_additive]
257-
instance : has_one (M →* N) := ⟨⟨λ _, 1, rfl, λ _ _, (one_mul 1).symm⟩⟩
418+
instance [monoid M] [monoid N] : has_one (M →* N) := ⟨⟨λ _, 1, rfl, λ _ _, (one_mul 1).symm⟩⟩
258419

420+
/-- `0` is the homomorphism sending all elements to `0`. -/
421+
add_decl_doc zero_hom.has_zero
422+
/-- `0` is the additive homomorphism sending all elements to `0`. -/
423+
add_decl_doc add_hom.has_zero
259424
/-- `0` is the additive monoid homomorphism sending all elements to `0`. -/
260425
add_decl_doc add_monoid_hom.has_zero
261426

262-
@[simp, to_additive] lemma one_apply (x : M) : (1 : M →* N) x = 1 := rfl
427+
@[simp, to_additive] lemma one_hom.one_apply [has_one M] [has_one N]
428+
(x : M) : (1 : one_hom M N) x = 1 := rfl
429+
@[simp, to_additive] lemma monoid_hom.one_apply [monoid M] [monoid N]
430+
(x : M) : (1 : M →* N) x = 1 := rfl
263431

264432
@[to_additive]
265-
instance : inhabited (M →* N) := ⟨1
433+
instance [has_one M] [has_one N] : inhabited (one_hom M N) := ⟨1
434+
@[to_additive]
435+
instance [has_mul M] [monoid N] : inhabited (mul_hom M N) := ⟨1
436+
@[to_additive]
437+
instance [monoid M] [monoid N] : inhabited (M →* N) := ⟨1
266438

267-
omit mM mN
439+
namespace monoid_hom
440+
variables [mM : monoid M] [mN : monoid N] [mP : monoid P]
441+
variables [group G] [comm_group H]
268442

269443
/-- Given two monoid morphisms `f`, `g` to a commutative monoid, `f * g` is the monoid morphism
270444
sending `x` to `f x * g x`. -/

0 commit comments

Comments
 (0)