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

Commit 3d6291e

Browse files
committed
chore(algebra/group/with_one): Use bundled morphisms (#4957)
The comment "We have no bundled semigroup homomorphisms" has become false, these exist as `mul_hom`. This also adds `with_one.coe_mul_hom` and `with_zero.coe_add_hom`
1 parent f30200e commit 3d6291e

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/algebra/group/hom.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ structure mul_hom (M : Type*) (N : Type*) [has_mul M] [has_mul N] :=
8686
@[to_additive]
8787
structure monoid_hom (M : Type*) (N : Type*) [monoid M] [monoid N] extends one_hom M N, mul_hom M N
8888

89-
attribute [nolint doc_blame] monoid_hom.to_mul_hom
90-
attribute [nolint doc_blame] monoid_hom.to_one_hom
89+
attribute [nolint doc_blame, to_additive] monoid_hom.to_mul_hom
90+
attribute [nolint doc_blame, to_additive] monoid_hom.to_one_hom
9191

9292
infixr ` →* `:25 := monoid_hom
9393

src/algebra/group/with_one.lean

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,35 +79,35 @@ instance [comm_semigroup α] : comm_monoid (with_one α) :=
7979
{ mul_comm := (option.lift_or_get_comm _).1,
8080
..with_one.monoid }
8181

82+
/-- `coe` as a bundled morphism -/
83+
@[simps apply, to_additive "`coe` as a bundled morphism"]
84+
def coe_mul_hom [has_mul α] : mul_hom α (with_one α) :=
85+
{ to_fun := coe, map_mul' := λ x y, rfl }
86+
8287
section lift
8388

8489
variables [semigroup α] {β : Type v} [monoid β]
8590

86-
/-- Lift a semigroup homomorphism `f` to a bundled monoid homorphism.
87-
We have no bundled semigroup homomorphisms, so this function
88-
takes `∀ x y, f (x * y) = f x * f y` as an explicit argument. -/
89-
@[to_additive "Lift an add_semigroup homomorphism `f` to a bundled add_monoid homorphism.
90-
We have no bundled add_semigroup homomorphisms, so this function
91-
takes `∀ x y, f (x + y) = f x + f y` as an explicit argument."]
92-
def lift (f : α → β) (hf : ∀ x y, f (x * y) = f x * f y) :
93-
(with_one α) →* β :=
91+
/-- Lift a semigroup homomorphism `f` to a bundled monoid homorphism. -/
92+
@[to_additive "Lift an add_semigroup homomorphism `f` to a bundled add_monoid homorphism."]
93+
def lift (f : mul_hom α β) : (with_one α) →* β :=
9494
{ to_fun := λ x, option.cases_on x 1 f,
9595
map_one' := rfl,
9696
map_mul' := λ x y,
9797
with_one.cases_on x (by { rw one_mul, exact (one_mul _).symm }) $ λ x,
9898
with_one.cases_on y (by { rw mul_one, exact (mul_one _).symm }) $ λ y,
99-
hf x y }
99+
f.map_mul x y }
100100

101-
variables (f : α → β) (hf : ∀ x y, f (x * y) = f x * f y)
101+
variables (f : mul_hom α β)
102102

103103
@[simp, to_additive]
104-
lemma lift_coe (x : α) : lift f hf x = f x := rfl
104+
lemma lift_coe (x : α) : lift f x = f x := rfl
105105

106106
@[simp, to_additive]
107-
lemma lift_one : lift f hf 1 = 1 := rfl
107+
lemma lift_one : lift f 1 = 1 := rfl
108108

109109
@[to_additive]
110-
theorem lift_unique (f : with_one α →* β) : f = lift (f ∘ coe) (λ x y, f.map_mul x y) :=
110+
theorem lift_unique (f : with_one α →* β) : f = lift (f.to_mul_hom.comp coe_mul_hom) :=
111111
monoid_hom.ext $ λ x, with_one.cases_on x f.map_one $ λ x, rfl
112112

113113
end lift
@@ -120,9 +120,8 @@ variables {β : Type v} [semigroup α] [semigroup β]
120120
from `with_one α` to `with_one β` -/
121121
@[to_additive "Given an additive map from `α → β` returns an add_monoid homomorphism
122122
from `with_zero α` to `with_zero β`"]
123-
def map (f : α → β) (hf : ∀ x y, f (x * y) = f x * f y) :
124-
with_one α →* with_one β :=
125-
lift (coe ∘ f) (λ x y, coe_inj.2 $ hf x y)
123+
def map (f : mul_hom α β) : with_one α →* with_one β :=
124+
lift (coe_mul_hom.comp f)
126125

127126
end map
128127

0 commit comments

Comments
 (0)