Skip to content

Commit 29bfa6c

Browse files
committed
feat: define morphism type StarMonoidHom
1 parent 4a14c8e commit 29bfa6c

2 files changed

Lines changed: 335 additions & 0 deletions

File tree

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,7 @@ import Mathlib.Algebra.Star.CentroidHom
11211121
import Mathlib.Algebra.Star.Conjneg
11221122
import Mathlib.Algebra.Star.Free
11231123
import Mathlib.Algebra.Star.Module
1124+
import Mathlib.Algebra.Star.MonoidHom
11241125
import Mathlib.Algebra.Star.NonUnitalSubalgebra
11251126
import Mathlib.Algebra.Star.NonUnitalSubsemiring
11261127
import Mathlib.Algebra.Star.Pi
Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
/-
2+
Copyright (c) 2025 Jireh Loreaux. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Jireh Loreaux
5+
-/
6+
import Mathlib.Algebra.Star.Basic
7+
/-!
8+
# Morphisms of star monoids
9+
10+
This file defines the type of morphisms `StarMonoidHom` between monoids `A` and `B` where both
11+
`A` and `B` are equipped with a `star` operation. These morphisms are star-preserving monoid
12+
homomorphisms and are equipped with the notation `A →⋆* B`.
13+
14+
The primary motivation for these morphisms is to provide a target type for morphisms which induce
15+
a corresponding morphism between the unitary groups in a star monoid.
16+
17+
## Main definitions
18+
19+
* `StarMonoidHom`
20+
* `StarMulEquiv`
21+
22+
## Tags
23+
24+
monoid, star
25+
-/
26+
27+
variable {F A B C D : Type*}
28+
29+
/-! ### Star monoid homomorphisms -/
30+
31+
/-- A *star monoid homomorphism* is a monoid homomorphism which is `star`-preserving. -/
32+
structure StarMonoidHom (A B : Type*) [Monoid A] [Star A] [Monoid B] [Star B]
33+
extends A →* B where
34+
/-- By definition, a star monoid homomorphism preserves the `star` operation. -/
35+
map_star' : ∀ a : A, toFun (star a) = star (toFun a)
36+
37+
/-- `α →⋆* β` denotes the type of star monoid homomorphisms from `α` to `β`. -/
38+
infixr:25 " →⋆* " => StarMonoidHom
39+
40+
/-- Reinterpret a star monoid homomorphism as a monoid homomorphism
41+
by forgetting the interaction with the star operation. -/
42+
add_decl_doc StarMonoidHom.toMonoidHom
43+
44+
namespace StarMonoidHom
45+
46+
variable [Monoid A] [Star A] [Monoid B] [Star B]
47+
48+
instance : FunLike (A →⋆* B) A B where
49+
coe f := f.toFun
50+
coe_injective' f g h := by cases f; cases g; simp_all
51+
52+
instance : MonoidHomClass (A →⋆* B) A B where
53+
map_mul f := f.map_mul'
54+
map_one f := f.map_one'
55+
56+
instance : StarHomClass (A →⋆* B) A B where
57+
map_star f := f.map_star'
58+
59+
/-- See Note [custom simps projection] -/
60+
def Simps.coe (f : A →⋆* B) : A → B := f
61+
62+
initialize_simps_projections StarMonoidHom (toFun → coe)
63+
64+
/-- Construct a `StarMonoidHom` from a morphism in some type which preserves `1`, `*` and `star`. -/
65+
@[simps]
66+
def ofClass [FunLike F A B] [MonoidHomClass F A B] [StarHomClass F A B] (f : F) :
67+
A →⋆* B where
68+
toFun := f
69+
map_one' := map_one f
70+
map_mul' := map_mul f
71+
map_star' := map_star f
72+
73+
@[simp]
74+
theorem coe_toMonoidHom (f : A →⋆* B) : ⇑f.toMonoidHom = f :=
75+
rfl
76+
77+
@[ext]
78+
theorem ext {f g : A →⋆* B} (h : ∀ x, f x = g x) : f = g :=
79+
DFunLike.ext _ _ h
80+
81+
/-- Copy of a `StarMonoidHom` with a new `toFun` equal to the old one. Useful
82+
to fix definitional equalities. -/
83+
protected def copy (f : A →⋆* B) (f' : A → B) (h : f' = f) : A →⋆* B where
84+
toFun := f'
85+
map_one' := h.symm ▸ map_one f
86+
map_mul' := h.symm ▸ map_mul f
87+
map_star' := h.symm ▸ map_star f
88+
89+
@[simp]
90+
theorem coe_copy (f : A →⋆* B) (f' : A → B) (h : f' = f) : ⇑(f.copy f' h) = f' :=
91+
rfl
92+
93+
theorem copy_eq (f : A →⋆* B) (f' : A → B) (h : f' = f) : f.copy f' h = f :=
94+
DFunLike.ext' h
95+
96+
@[simp]
97+
theorem coe_mk (f : A →* B) (h) :
98+
((⟨f, h⟩ : A →⋆* B) : A → B) = f :=
99+
rfl
100+
101+
section Id
102+
103+
variable (A)
104+
105+
/-- The identity as a star monoid homomorphism. -/
106+
protected def id : A →⋆* A :=
107+
{ (.id A : A →* A) with map_star' := fun _ ↦ rfl }
108+
109+
@[simp, norm_cast]
110+
theorem coe_id : ⇑(StarMonoidHom.id A) = id :=
111+
rfl
112+
113+
end Id
114+
115+
section Comp
116+
117+
variable [Monoid C] [Star C] [Monoid D] [Star D]
118+
119+
/-- The composition of star monoid homomorphisms, as a star monoid homomorphism. -/
120+
def comp (f : B →⋆* C) (g : A →⋆* B) : A →⋆* C :=
121+
{ f.toMonoidHom.comp g.toMonoidHom with
122+
map_star' := fun a => by simp [map_star] }
123+
124+
@[simp]
125+
theorem coe_comp (f : B →⋆* C) (g : A →⋆* B) : ⇑(comp f g) = f ∘ g :=
126+
rfl
127+
128+
@[simp]
129+
theorem comp_apply (f : B →⋆* C) (g : A →⋆* B) (a : A) : comp f g a = f (g a) :=
130+
rfl
131+
132+
@[simp]
133+
theorem comp_assoc (f : C →⋆* D) (g : B →⋆* C) (h : A →⋆* B) :
134+
(f.comp g).comp h = f.comp (g.comp h) :=
135+
rfl
136+
137+
@[simp]
138+
theorem id_comp (f : A →⋆* B) : (StarMonoidHom.id B).comp f = f :=
139+
ext fun _ => rfl
140+
141+
@[simp]
142+
theorem comp_id (f : A →⋆* B) : f.comp (.id _) = f :=
143+
ext fun _ => rfl
144+
145+
instance : Monoid (A →⋆* A) where
146+
mul := comp
147+
mul_assoc := comp_assoc
148+
one := .id A
149+
one_mul := id_comp
150+
mul_one := comp_id
151+
152+
@[simp]
153+
theorem coe_one : ((1 : A →⋆* A) : A → A) = id :=
154+
rfl
155+
156+
theorem one_apply (a : A) : (1 : A →⋆* A) a = a :=
157+
rfl
158+
159+
end Comp
160+
161+
end StarMonoidHom
162+
163+
164+
/-! ### Star monoid equivalences -/
165+
166+
/-- A *star monoid equivalence* is an equivalence preserving multiplication and the star
167+
operation. -/
168+
structure StarMulEquiv (A B : Type*) [Mul A] [Mul B] [Star A] [Star B]
169+
extends A ≃* B where
170+
/-- By definition, a star monoid equivalence preserves the `star` operation. -/
171+
map_star' : ∀ a : A, toFun (star a) = star (toFun a)
172+
173+
@[inherit_doc] notation:25 A " ≃⋆* " B => StarMulEquiv A B
174+
175+
/-- Reinterpret a star monoid equivalence as a `MulEquiv` by forgetting the interaction with the
176+
star operation. -/
177+
add_decl_doc StarMulEquiv.toMulEquiv
178+
179+
namespace StarMulEquiv
180+
181+
section Basic
182+
183+
variable [Mul A] [Mul B] [Mul C] [Mul D]
184+
variable [Star A] [Star B] [Star C] [Star D]
185+
186+
instance : EquivLike (A ≃⋆* B) A B where
187+
coe e := e.toFun
188+
inv e := e.invFun
189+
left_inv e := e.left_inv
190+
right_inv e := e.right_inv
191+
coe_injective' f g h := by cases f; cases g; simp_all
192+
193+
instance : MulEquivClass (A ≃⋆* B) A B where
194+
map_mul f := f.map_mul'
195+
196+
instance : StarHomClass (A ≃⋆* B) A B where
197+
map_star f := f.map_star'
198+
199+
@[ext]
200+
theorem ext {f g : A ≃⋆* B} (h : ∀ a, f a = g a) : f = g :=
201+
DFunLike.ext f g h
202+
203+
variable (A) in
204+
/-- The identity map as a star monoid isomorphism. -/
205+
@[refl]
206+
protected def refl : A ≃⋆* A :=
207+
{ MulEquiv.refl A with
208+
map_star' := fun _ => rfl }
209+
210+
instance : Inhabited (A ≃⋆* A) :=
211+
⟨.refl A⟩
212+
213+
@[simp]
214+
theorem coe_refl : ⇑(.refl A : A ≃⋆* A) = id :=
215+
rfl
216+
217+
/-- The inverse of a star monoid isomorphism is a star monoid isomorphism. -/
218+
@[symm]
219+
nonrec def symm (e : A ≃⋆* B) : B ≃⋆* A :=
220+
{ e.symm with
221+
map_star' := fun b => by
222+
simpa only [EquivLike.apply_inv_apply, EquivLike.inv_apply_apply] using
223+
congr_arg (EquivLike.inv e) (map_star e (EquivLike.inv e b)).symm }
224+
225+
/-- See Note [custom simps projection] -/
226+
def Simps.apply (e : A ≃⋆* B) : A → B := e
227+
228+
/-- See Note [custom simps projection] -/
229+
def Simps.symm_apply (e : A ≃⋆* B) : B → A :=
230+
e.symm
231+
232+
initialize_simps_projections StarMulEquiv (toFun → apply, invFun → symm_apply)
233+
234+
@[simp]
235+
theorem invFun_eq_symm {e : A ≃⋆* B} : EquivLike.inv e = e.symm :=
236+
rfl
237+
238+
@[simp]
239+
theorem symm_symm (e : A ≃⋆* B) : e.symm.symm = e := rfl
240+
241+
theorem symm_bijective : Function.Bijective (symm : (A ≃⋆* B) → B ≃⋆* A) :=
242+
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
243+
244+
theorem coe_mk (e h₁) : ⇑(⟨e, h₁⟩ : A ≃⋆* B) = e := rfl
245+
246+
/-- Construct a `StarMulEquiv` from an equivalence in some type which preserves `*` and `star`. -/
247+
@[simps]
248+
def ofClass [EquivLike F A B] [MulEquivClass F A B] [StarHomClass F A B] (f : F) :
249+
A ≃⋆* B where
250+
toFun := f
251+
invFun := EquivLike.inv f
252+
left_inv := EquivLike.left_inv f
253+
right_inv := EquivLike.right_inv f
254+
map_mul' := map_mul f
255+
map_star' := map_star f
256+
257+
@[simp]
258+
theorem coe_toMulEquiv (f : A ≃⋆* B) : ⇑f.toMulEquiv = f :=
259+
rfl
260+
261+
@[simp]
262+
theorem refl_symm : (.refl A : A ≃⋆* A).symm = .refl A :=
263+
rfl
264+
265+
/-- Transitivity of `StarMulEquiv`. -/
266+
@[trans]
267+
def trans (e₁ : A ≃⋆* B) (e₂ : B ≃⋆* C) : A ≃⋆* C :=
268+
{ e₁.toMulEquiv.trans e₂.toMulEquiv with
269+
map_star' := fun a =>
270+
show e₂.toFun (e₁.toFun (star a)) = star (e₂.toFun (e₁.toFun a)) by
271+
rw [e₁.map_star', e₂.map_star'] }
272+
273+
@[simp]
274+
theorem apply_symm_apply (e : A ≃⋆* B) : ∀ x, e (e.symm x) = x :=
275+
e.toMulEquiv.apply_symm_apply
276+
277+
@[simp]
278+
theorem symm_apply_apply (e : A ≃⋆* B) : ∀ x, e.symm (e x) = x :=
279+
e.toMulEquiv.symm_apply_apply
280+
281+
@[simp]
282+
theorem symm_trans_apply (e₁ : A ≃⋆* B) (e₂ : B ≃⋆* C) (x : C) :
283+
(e₁.trans e₂).symm x = e₁.symm (e₂.symm x) :=
284+
rfl
285+
286+
@[simp]
287+
theorem coe_trans (e₁ : A ≃⋆* B) (e₂ : B ≃⋆* C) : ⇑(e₁.trans e₂) = e₂ ∘ e₁ :=
288+
rfl
289+
290+
@[simp]
291+
theorem trans_apply (e₁ : A ≃⋆* B) (e₂ : B ≃⋆* C) (x : A) : (e₁.trans e₂) x = e₂ (e₁ x) :=
292+
rfl
293+
294+
theorem leftInverse_symm (e : A ≃⋆* B) : Function.LeftInverse e.symm e :=
295+
e.left_inv
296+
297+
theorem rightInverse_symm (e : A ≃⋆* B) : Function.RightInverse e.symm e :=
298+
e.right_inv
299+
300+
end Basic
301+
302+
section Bijective
303+
304+
variable [Monoid A] [Monoid B] [Star A] [Star B]
305+
306+
/-- If a star monoid morphism has an inverse, it is an isomorphism of star monoids. -/
307+
@[simps]
308+
def ofStarMonoidHom (f : A →⋆* B) (g : B →⋆* A) (h₁ : g.comp f = .id _) (h₂ : f.comp g = .id _) :
309+
A ≃⋆* B where
310+
toFun := f
311+
invFun := g
312+
left_inv := DFunLike.ext_iff.mp h₁
313+
right_inv := DFunLike.ext_iff.mp h₂
314+
map_mul' := map_mul f
315+
map_star' := map_star f
316+
317+
/-- Promote a bijective star monoid homomorphism to a star monoid equivalence. -/
318+
noncomputable def ofBijective (f : A →⋆* B) (hf : Function.Bijective f) : A ≃⋆* B :=
319+
{ MulEquiv.ofBijective f (hf : Function.Bijective (f : A → B)) with
320+
toFun := f
321+
map_star' := map_star f }
322+
323+
@[simp]
324+
theorem coe_ofBijective {f : A →⋆* B} (hf : Function.Bijective f) :
325+
(StarMulEquiv.ofBijective f hf : A → B) = f :=
326+
rfl
327+
328+
theorem ofBijective_apply {f : A →⋆* B} (hf : Function.Bijective f) (a : A) :
329+
StarMulEquiv.ofBijective f hf a = f a :=
330+
rfl
331+
332+
end Bijective
333+
334+
end StarMulEquiv

0 commit comments

Comments
 (0)