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

Commit 3417ee0

Browse files
committed
chore(deprecated/group): relax monoid to mul_one_class (#7556)
This fixes an annoyance where `monoid_hom.is_monoid_hom` didn't work on non-associative monoids.
1 parent 477af65 commit 3417ee0

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/data/dfinsupp.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def eval_add_monoid_hom [Π i, add_zero_class (β i)] (i : ι) : (Π₀ i, β i)
163163

164164
instance is_add_monoid_hom [Π i, add_zero_class (β i)] {i : ι} :
165165
is_add_monoid_hom (λ g : Π₀ i : ι, β i, g i) :=
166-
{ map_add := λ f g, add_apply f g i, map_zero := zero_apply i }
166+
(eval_add_monoid_hom i).is_add_monoid_hom
167167

168168
instance [Π i, add_group (β i)] : has_neg (Π₀ i, β i) :=
169169
⟨λ f, f.map_range (λ _, has_neg.neg) (λ _, neg_zero)⟩

src/deprecated/group.lean

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,10 @@ class is_monoid_hom [mul_one_class α] [mul_one_class β] (f : α → β) extend
100100
namespace monoid_hom
101101

102102
/-!
103-
Throughout this section, some `monoid` arguments are specified with `{}` instead of `[]`.
103+
Throughout this section, some `mul_one_class` arguments are specified with `{}` instead of `[]`.
104104
See note [implicit instance arguments].
105105
-/
106-
variables {M : Type*} {N : Type*} {P : Type*} [mM : monoid M] [mN : monoid N] {mP : monoid P}
107-
variables {G : Type*} {H : Type*} [group G] [comm_group H]
106+
variables {M : Type*} {N : Type*} [mM : mul_one_class M] [mN : mul_one_class N]
108107

109108
include mM mN
110109
/-- Interpret a map `f : M → N` as a homomorphism `M →* N`. -/
@@ -114,7 +113,7 @@ def of (f : M → N) [h : is_monoid_hom f] : M →* N :=
114113
map_one' := h.2,
115114
map_mul' := h.1.1 }
116115

117-
variables {mM mN mP}
116+
variables {mM mN}
118117
@[simp, to_additive]
119118
lemma coe_of (f : M → N) [is_monoid_hom f] : ⇑ (monoid_hom.of f) = f :=
120119
rfl
@@ -128,22 +127,21 @@ end monoid_hom
128127

129128
namespace mul_equiv
130129

131-
variables {M : Type*} {N : Type*} [monoid M] [monoid N]
130+
variables {M : Type*} {N : Type*} [mul_one_class M] [mul_one_class N]
132131

133132
/-- A multiplicative isomorphism preserves multiplication (deprecated). -/
134133
@[to_additive]
135134
instance (h : M ≃* N) : is_mul_hom h := ⟨h.map_mul⟩
136135

137136
/-- A multiplicative bijection between two monoids is a monoid hom
138-
(deprecated -- use to_monoid_hom). -/
137+
(deprecated -- use `mul_equiv.to_monoid_hom`). -/
139138
@[to_additive]
140-
instance {M N} [monoid M] [monoid N] (h : M ≃* N) : is_monoid_hom h :=
141-
⟨h.map_one⟩
139+
instance (h : M ≃* N) : is_monoid_hom h := ⟨h.map_one⟩
142140

143141
end mul_equiv
144142

145143
namespace is_monoid_hom
146-
variables [monoid α] [monoid β] (f : α → β) [is_monoid_hom f]
144+
variables [mul_one_class α] [mul_one_class β] (f : α → β) [is_monoid_hom f]
147145

148146
/-- A monoid homomorphism preserves multiplication. -/
149147
@[to_additive]
@@ -154,20 +152,20 @@ end is_monoid_hom
154152

155153
/-- A map to a group preserving multiplication is a monoid homomorphism. -/
156154
@[to_additive]
157-
theorem is_monoid_hom.of_mul [monoid α] [group β] (f : α → β) [is_mul_hom f] :
155+
theorem is_monoid_hom.of_mul [mul_one_class α] [group β] (f : α → β) [is_mul_hom f] :
158156
is_monoid_hom f :=
159157
{ map_one := mul_right_eq_self.1 $ by rw [← is_mul_hom.map_mul f, one_mul] }
160158

161159
namespace is_monoid_hom
162-
variables [monoid α] [monoid β] (f : α → β) [is_monoid_hom f]
160+
variables [mul_one_class α] [mul_one_class β] (f : α → β) [is_monoid_hom f]
163161

164162
/-- The identity map is a monoid homomorphism. -/
165163
@[to_additive]
166164
instance id : is_monoid_hom (@id α) := { map_one := rfl }
167165

168166
/-- The composite of two monoid homomorphisms is a monoid homomorphism. -/
169167
@[to_additive] -- see Note [no instance on morphisms]
170-
lemma comp {γ} [monoid γ] (g : β → γ) [is_monoid_hom g] :
168+
lemma comp {γ} [mul_one_class γ] (g : β → γ) [is_monoid_hom g] :
171169
is_monoid_hom (g ∘ f) :=
172170
{ map_one := show g _ = 1, by rw [map_one f, map_one g], ..is_mul_hom.comp _ _ }
173171

@@ -350,12 +348,13 @@ lemma multiplicative.is_mul_hom [has_add α] [has_add β] (f : α → β) [is_ad
350348
@is_mul_hom (multiplicative α) (multiplicative β) _ _ f :=
351349
{ map_mul := @is_add_hom.map_add α β _ _ f _ }
352350

353-
lemma additive.is_add_monoid_hom [monoid α] [monoid β] (f : α → β) [is_monoid_hom f] :
351+
lemma additive.is_add_monoid_hom [mul_one_class α] [mul_one_class β] (f : α → β) [is_monoid_hom f] :
354352
@is_add_monoid_hom (additive α) (additive β) _ _ f :=
355353
{ map_zero := @is_monoid_hom.map_one α β _ _ f _,
356354
..additive.is_add_hom f }
357355

358-
lemma multiplicative.is_monoid_hom [add_monoid α] [add_monoid β] (f : α → β) [is_add_monoid_hom f] :
356+
lemma multiplicative.is_monoid_hom
357+
[add_zero_class α] [add_zero_class β] (f : α → β) [is_add_monoid_hom f] :
359358
@is_monoid_hom (multiplicative α) (multiplicative β) _ _ f :=
360359
{ map_one := @is_add_monoid_hom.map_zero α β _ _ f _,
361360
..multiplicative.is_mul_hom f }

0 commit comments

Comments
 (0)