Martin Escardo, July 2026.
The type of egroups.
An egroup is a setoid (defined in EGroups.Setoid) equipped with a
compatible group structure, that is, an operation that is a congruence
for the equivalence relation, whose group laws hold up to the
equivalence relation rather than up to the identity type _๏ผ_.
This is the analogue, for setoids, of the module Groups.Type. Compared
with Groups.Type:
* The requirement "is-set X" is removed, as all types are considered
to be sets in the setoid world.
* The operation is required to be a congruence.
* Every remaining occurrence of the identity type becomes the
equivalence relation.
\begin{code}
{-# OPTIONS --safe --without-K #-}
module EGroups.Type where
open import MLTT.Spartan
open import EGroups.Setoid
\end{code}
The axioms of a compatible group structure on a setoid S, and the
structure and type of EGroups. As in Groups.Type, the inverse is given
existentially, as part of the axioms, where ฮฃ is used for existence in
the setoid world.
\begin{code}
egroup-axioms : (S : Setoid ๐ค ๐ฅ) โ (โฃ S โฃ โ โฃ S โฃ โ โฃ S โฃ) โ ๐ค โ ๐ฅ ฬ
egroup-axioms S _ยท_ =
is-congruence (setoid-relation S) _ยท_
ร โ-associative (setoid-relation S) _ยท_
ร (ฮฃ e ๊ โฃ S โฃ , โ-left-neutral (setoid-relation S) e _ยท_
ร โ-right-neutral (setoid-relation S) e _ยท_
ร ((x : โฃ S โฃ) โ ฮฃ x' ๊ โฃ S โฃ , ((x' ยท x) โโฆ S โง e)
ร ((x ยท x') โโฆ S โง e)))
egroup-structure : Setoid ๐ค ๐ฅ โ ๐ค โ ๐ฅ ฬ
egroup-structure S = ฮฃ _ยท_ ๊ (โฃ S โฃ โ โฃ S โฃ โ โฃ S โฃ) , (egroup-axioms S _ยท_)
EGroup : (๐ค ๐ฅ : Universe) โ (๐ค โ ๐ฅ) โบ ฬ
EGroup ๐ค ๐ฅ = ฮฃ S ๊ Setoid ๐ค ๐ฅ , egroup-structure S
\end{code}
We write โจ G โฉ for the underlying type and x โโจ G โฉ y for the
equivalence relation.
\begin{code}
underlying-setoid : EGroup ๐ค ๐ฅ โ Setoid ๐ค ๐ฅ
underlying-setoid (S , _) = S
โจ_โฉ : EGroup ๐ค ๐ฅ โ ๐ค ฬ
โจ G โฉ = โฃ underlying-setoid G โฃ
underlying-relation : (G : EGroup ๐ค ๐ฅ) โ โจ G โฉ โ โจ G โฉ โ ๐ฅ ฬ
underlying-relation G = setoid-relation (underlying-setoid G)
syntax underlying-relation G x y = x โโจ G โฉ y
E-refl : (G : EGroup ๐ค ๐ฅ) โ reflexive (underlying-relation G)
E-refl G = setoid-refl (underlying-setoid G)
E-sym : (G : EGroup ๐ค ๐ฅ) โ symmetric (underlying-relation G)
E-sym G = setoid-sym (underlying-setoid G)
E-trans : (G : EGroup ๐ค ๐ฅ) โ transitive (underlying-relation G)
E-trans G = setoid-trans (underlying-setoid G)
E-multiplication : (G : EGroup ๐ค ๐ฅ) โ โจ G โฉ โ โจ G โฉ โ โจ G โฉ
E-multiplication (S , _ยท_ , _) = _ยท_
syntax E-multiplication G x y = x ยทโจ G โฉ y
E-is-congruence : (G : EGroup ๐ค ๐ฅ)
โ is-congruence (underlying-relation G) (E-multiplication G)
E-is-congruence (S , _ยท_ , cong , _) = cong
E-assoc : (G : EGroup ๐ค ๐ฅ)
โ โ-associative (underlying-relation G) (E-multiplication G)
E-assoc (S , _ยท_ , cong , assoc , _) = assoc
E-unit : (G : EGroup ๐ค ๐ฅ) โ โจ G โฉ
E-unit (S , _ยท_ , cong , assoc , e , _) = e
E-unit-left : (G : EGroup ๐ค ๐ฅ)
โ โ-left-neutral (underlying-relation G) (E-unit G) (E-multiplication G)
E-unit-left (S , _ยท_ , cong , assoc , e , ln , _) = ln
E-unit-right : (G : EGroup ๐ค ๐ฅ)
โ โ-right-neutral (underlying-relation G) (E-unit G) (E-multiplication G)
E-unit-right (S , _ยท_ , cong , assoc , e , ln , rn , _) = rn
E-inv : (G : EGroup ๐ค ๐ฅ) โ โจ G โฉ โ โจ G โฉ
E-inv (S , _ยท_ , cong , assoc , e , ln , rn , inverses) x = prโ (inverses x)
E-inv-left : (G : EGroup ๐ค ๐ฅ) (x : โจ G โฉ) โ (E-inv G x ยทโจ G โฉ x) โโจ G โฉ E-unit G
E-inv-left (S , _ยท_ , cong , assoc , e , ln , rn , inverses) x = prโ (prโ (inverses x))
E-inv-right : (G : EGroup ๐ค ๐ฅ) (x : โจ G โฉ) โ (x ยทโจ G โฉ E-inv G x) โโจ G โฉ E-unit G
E-inv-right (S , _ยท_ , cong , assoc , e , ln , rn , inverses) x = prโ (prโ (inverses x))
\end{code}
Homomorphisms of egroups: maps of the underlying types that respect the
equivalence relations and are multiplicative up to the equivalence
relation of the codomain. As in Groups.Type, preservation of the unit
and of inverses is not required but is derivable.
\begin{code}
is-hom : (G : EGroup ๐ค ๐ฅ) (H : EGroup ๐ค' ๐ฅ')
โ (โจ G โฉ โ โจ H โฉ) โ ๐ค โ ๐ฅ โ ๐ฅ' ฬ
is-hom G H f =
({x y : โจ G โฉ} โ x โโจ G โฉ y โ f x โโจ H โฉ f y)
ร ({x y : โจ G โฉ} โ f (x ยทโจ G โฉ y) โโจ H โฉ (f x ยทโจ H โฉ f y))
\end{code}
Some minimal group theory up to the equivalence relation, needed for
the universal property of free EGroups. This is a transcription of the
relevant parts of Groups.Type, with the identity type replaced by the
equivalence relation and with the congruence of the operation used
explicitly.
\begin{code}
module E-group-theory (G : EGroup ๐ค ๐ฅ) where
private
_โ_ = underlying-relation G
_*_ = E-multiplication G
e = E-unit G
inv = E-inv G
open โ-reasoning _โ_ (E-refl G) (E-trans G)
โ-inv-lemma : (x y z : โจ G โฉ) โ (y * x) โ e โ (x * z) โ e โ y โ z
โ-inv-lemma x y z q p =
y โ[ E-sym G _ _ (E-unit-right G y) ]
(y * e) โ[ E-is-congruence G (E-refl G y) (E-sym G _ _ p) ]
(y * (x * z)) โ[ E-sym G _ _ (E-assoc G y x z) ]
((y * x) * z) โ[ E-is-congruence G q (E-refl G z) ]
(e * z) โ[ E-unit-left G z ]
z โโ
one-left-inv : (x y : โจ G โฉ) โ (y * x) โ e โ y โ inv x
one-left-inv x y q = โ-inv-lemma x y (inv x) q (E-inv-right G x)
โ-idempotent-is-unit : (x : โจ G โฉ) โ (x * x) โ x โ x โ e
โ-idempotent-is-unit x p =
x โ[ E-sym G _ _ (E-unit-left G x) ]
(e * x) โ[ E-is-congruence G (E-sym G _ _ (E-inv-left G x)) (E-refl G x) ]
((inv x * x) * x) โ[ E-assoc G (inv x) x x ]
(inv x * (x * x)) โ[ E-is-congruence G (E-refl G (inv x)) p ]
(inv x * x) โ[ E-inv-left G x ]
e โโ
โ-inv-cong : (x y : โจ G โฉ) โ x โ y โ inv x โ inv y
โ-inv-cong x y p = one-left-inv y (inv x)
(inv x * y โ[ E-is-congruence G (E-refl G (inv x)) (E-sym G _ _ p) ]
inv x * x โ[ E-inv-left G x ]
e โโ)
\end{code}
Homomorphisms preserve the unit and inverses. As in Groups.Type, these
are derived from the definition of homomorphism.
\begin{code}
homs-preserve-unit : (G : EGroup ๐ค ๐ฅ) (H : EGroup ๐ค' ๐ฅ')
(f : โจ G โฉ โ โจ H โฉ)
โ is-hom G H f
โ f (E-unit G) โโจ H โฉ E-unit H
homs-preserve-unit G H f (f-resp , f-mult) =
โ-idempotent-is-unit (f eG)
(f eG ยทโจ H โฉ f eG โ[ E-sym H _ _ (f-mult {eG} {eG}) ]
f (eG ยทโจ G โฉ eG) โ[ f-resp (E-unit-left G eG) ]
f eG โโ)
where
open E-group-theory H
open โ-reasoning (underlying-relation H) (E-refl H) (E-trans H)
eG = E-unit G
homs-preserve-inv : (G : EGroup ๐ค ๐ฅ) (H : EGroup ๐ค' ๐ฅ')
(f : โจ G โฉ โ โจ H โฉ)
โ is-hom G H f
โ (x : โจ G โฉ) โ f (E-inv G x) โโจ H โฉ E-inv H (f x)
homs-preserve-inv G H f fh@(f-resp , f-mult) x =
one-left-inv (f x) (f (E-inv G x))
(f (E-inv G x) ยทโจ H โฉ f x โ[ E-sym H _ _ (f-mult {E-inv G x} {x}) ]
f (E-inv G x ยทโจ G โฉ x) โ[ f-resp (E-inv-left G x) ]
f (E-unit G) โ[ homs-preserve-unit G H f fh ]
E-unit H โโ)
where
open E-group-theory H
open โ-reasoning (underlying-relation H) (E-refl H) (E-trans H)
\end{code}
The identity is a homomorphism, and homomorphisms compose.
\begin{code}
id-is-hom : (G : EGroup ๐ค ๐ฅ) โ is-hom G G id
id-is-hom G = (ฮป p โ p) , (ฮป {x} {y} โ E-refl G (x ยทโจ G โฉ y))
โ-is-hom : (F : EGroup ๐ค ๐ฅ) (G : EGroup ๐ค' ๐ฅ') (H : EGroup ๐ฆ ๐ฆ')
(f : โจ F โฉ โ โจ G โฉ) (g : โจ G โฉ โ โจ H โฉ)
โ is-hom F G f โ is-hom G H g โ is-hom F H (g โ f)
โ-is-hom F G H f g (f-resp , f-mult) (g-resp , g-mult) =
(ฮป p โ g-resp (f-resp p))
, (ฮป {x} {y} โ E-trans H _ _ _ (g-resp (f-mult {x} {y})) (g-mult {f x} {f y}))
\end{code}
An isomorphism of egroups is a homomorphism with a homomorphism
inverse, up to the equivalence relations.
\begin{code}
is-iso : (G : EGroup ๐ค ๐ฅ) (H : EGroup ๐ค' ๐ฅ')
โ (โจ G โฉ โ โจ H โฉ) โ ๐ค โ ๐ฅ โ ๐ค' โ ๐ฅ' ฬ
is-iso G H f = is-hom G H f
ร (ฮฃ g ๊ (โจ H โฉ โ โจ G โฉ) , is-hom H G g
ร ((y : โจ H โฉ) โ f (g y) โโจ H โฉ y)
ร ((x : โจ G โฉ) โ g (f x) โโจ G โฉ x))
_โ
_ : EGroup ๐ค ๐ฅ โ EGroup ๐ค' ๐ฅ' โ ๐ค โ ๐ฅ โ ๐ค' โ ๐ฅ' ฬ
G โ
H = ฮฃ f ๊ (โจ G โฉ โ โจ H โฉ) , is-iso G H f
โ
-refl : (G : EGroup ๐ค ๐ฅ) โ G โ
G
โ
-refl G = id , id-is-hom G , id , id-is-hom G , E-refl G , E-refl G
โ
-sym : (G : EGroup ๐ค ๐ฅ) (H : EGroup ๐ค' ๐ฅ') โ G โ
H โ H โ
G
โ
-sym G H (f , fhom , g , ghom , f-ฮต , f-ฮธ) =
g , ghom , f , fhom , f-ฮธ , f-ฮต
โ
-trans : (F : EGroup ๐ค ๐ฅ) (G : EGroup ๐ค' ๐ฅ') (H : EGroup ๐ฆ ๐ฆ')
โ F โ
G โ G โ
H โ F โ
H
โ
-trans F G H (f , fhom , fโป , fโปhom@(fโป-resp , _) , f-ฮต , f-ฮธ)
(g , ghom@(g-resp , _) , gโป , gโปhom , g-ฮต , g-ฮธ) =
g โ f
, โ-is-hom F G H f g fhom ghom
, fโป โ gโป
, โ-is-hom H G F gโป fโป gโปhom fโปhom
, (ฮป w โ E-trans H _ _ _ (g-resp (f-ฮต (gโป w))) (g-ฮต w))
, (ฮป x โ E-trans F _ _ _ (fโป-resp (g-ฮธ (f x))) (f-ฮธ x))
\end{code}
The setoid of homomorphisms between two egroups, with the pointwise
equivalence relation.
\begin{code}
hom-setoid : (G : EGroup ๐ค ๐ฅ) (H : EGroup ๐ค' ๐ฅ')
โ Setoid (๐ค โ ๐ค' โ ๐ฅ โ ๐ฅ') (๐ค โ ๐ฅ')
hom-setoid G H =
(ฮฃ f ๊ (โจ G โฉ โ โจ H โฉ) , is-hom G H f)
, (ฮป u v โ (x : โจ G โฉ) โ prโ u x โโจ H โฉ prโ v x)
, (ฮป u x โ E-refl H (prโ u x))
, (ฮป u v p x โ E-sym H (prโ u x) (prโ v x) (p x))
, (ฮป u v w p q x โ E-trans H (prโ u x) (prโ v x) (prโ w x) (p x) (q x))
\end{code}