module Algebra.Group.Cat.Monadic {β} where
private F : Functor (Sets β) (Groups β) F = free-objectsβfunctor make-free-group Fβ£U : F β£ _ Fβ£U = free-objectsβleft-adjoint make-free-group K = Comparison-EM Fβ£U T : Monad (Sets β) T = AdjunctionβMonad Fβ£U module F = Functor F module T = Monad T module K = Functor K module Sets^T = Cat.Reasoning (Eilenberg-Moore T)
Monadicity of the category of groupsπ
We prove that the category is monadic over or more specifically that the free group adjunction is monadic. Rather than appealing to a monadicity theorem, we show this directly by calculation. This actually gives us a slightly sharper result, too: rather than showing that the comparison functor is an equivalence, we show directly that it is an isomorphism of categories. This doesnβt exactly matter since and are both univalent categories, but itβs interesting that itβs easier to construct an isomorphism than it is to construct an equivalence.
Let us abbreviate the monad induced by the free group adjunction by What we must show is that any structure on a set gives rise to a group structure on and that this process is reversible: If is our original algebra, applying our process then applying the comparison functor has to give back.
Algebra-onβgroup-on : {G : Set β} β Algebra-on (Sets β) T G β Group-on β£ G β£ Algebra-onβgroup-on {G = G} alg = grp where open Algebra-on alg mult : β£ G β£ β β£ G β£ β β£ G β£ mult x y = Ξ½ (inc x β inc y)
The thing to keep in mind is that a structure is a way of βfoldingβ a word built up from generators in the set so that if we build a word from two generators folding that should be the same thing as a binary multiplication Thatβs the definition of the induced multiplication structure! We now must show that this definition is indeed a group structure, which is an incredibly boring calculation.
Iβm not exaggerating, itβs super boring.
abstract assoc : β x y z β mult x (mult y z) β‘ mult (mult x y) z assoc x y z = sym $ Ξ½ (inc (Ξ½ (inc x β inc y)) β inc z) β‘β¨ (Ξ» i β Ξ½ (inc (Ξ½ (inc x β inc y)) β inc (Ξ½-unit (~ i) z))) β©β‘ Ξ½ (inc (Ξ½ (inc x β inc y)) β inc (Ξ½ (inc z))) β‘β¨ happly Ξ½-mult (inc _ β inc _) β©β‘ Ξ½ (T.mult.Ξ· G (inc (inc x β inc y) β inc (inc z))) β‘Λβ¨ ap Ξ½ (f-assoc _ _ _) β©β‘Λ Ξ½ (T.mult.Ξ· G (inc (inc x) β inc (inc y β inc z))) β‘Λβ¨ happly Ξ½-mult (inc _ β inc _) β©β‘Λ Ξ½ (inc (Ξ½ (inc x)) β inc (Ξ½ (inc y β inc z))) β‘β¨ (Ξ» i β Ξ½ (inc (Ξ½-unit i x) β inc (Ξ½ (inc y β inc z)))) β©β‘ Ξ½ (inc x β inc (Ξ½ (inc y β inc z))) β invl : β x β mult (Ξ½ (inv (inc x))) x β‘ Ξ½ nil invl x = Ξ½ (inc (Ξ½ (inv (inc x))) β inc x) β‘β¨ (Ξ» i β Ξ½ (inc (Ξ½ (inv (inc x))) β inc (Ξ½-unit (~ i) x))) β©β‘ Ξ½ (inc (Ξ½ (inv (inc x))) β inc (Ξ½ (inc x))) β‘β¨ happly Ξ½-mult (inc _ β inc _) β©β‘ Ξ½ (T.mult.Ξ· G (inc (inv (inc x)) β inc (inc x))) β‘β¨ ap Ξ½ (f-invl _) β©β‘ Ξ½ (T.mult.Ξ· G (inc nil)) β‘β¨β© Ξ½ nil β idl' : β x β mult (Ξ½ nil) x β‘ x idl' x = Ξ½ (inc (Ξ½ nil) β inc x) β‘β¨ (Ξ» i β Ξ½ (inc (Ξ½ nil) β inc (Ξ½-unit (~ i) x))) β©β‘ Ξ½ (inc (Ξ½ nil) β inc (Ξ½ (inc x))) β‘β¨ happly Ξ½-mult (inc _ β inc _) β©β‘ Ξ½ (T.mult.Ξ· G (nil β inc (inc x))) β‘β¨ ap Ξ½ (f-idl _) β©β‘ Ξ½ (inc x) β‘β¨ happly Ξ½-unit x β©β‘ x β grp : Group-on β£ G β£ grp .Group-on._β_ = mult grp .Group-on.has-is-group = to-group-on fg .Group-on.has-is-group where fg : make-group β£ G β£ fg .make-group.group-is-set = G .is-tr fg .make-group.unit = Ξ½ nil fg .make-group.mul = mult fg .make-group.inv x = Ξ½ (inv (inc x)) fg .make-group.assoc = assoc fg .make-group.invl = invl fg .make-group.idl = idl'
We now show that this construction fits into defining an inverse (on the nose!) to the comparison functor. This is slightly easier than it sounds like: We must show that the functor is fully faithful, and that our mapping above is indeed invertible.
Fully faithfulness is almost immediate: a homomorphism of preserves underlying multiplication because the algebra structure of (resp. is defined in terms of that multiplication. Since we leave the underlying map intact, and being a homomorphism (either kind) is a property, the comparison functor is fully faithful.
Group-is-monadic : is-monadic Fβ£U Group-is-monadic = is-precat-isoβis-equivalence record { has-is-ff = ff ; has-is-iso = is-isoβis-equiv isom } where open Algebra-on kβinv : β {G H} β Algebra-hom T (K.β G) (K.β H) β Groups.Hom G H kβinv f .hom = f .hom kβinv f .preserves .is-group-hom.pres-β x y = happly (f .preserves) (inc x β inc y) ff : is-fully-faithful K ff = is-isoβis-equiv $ iso kβinv (Ξ» x β trivial!) (Ξ» x β Grp.GrpβͺSets-is-faithful refl)
To show that the object mapping of the comparison functor is invertible, we appeal to univalence. Since the types are kept the same, it suffices to show that passing between a multiplication and an algebra map doesnβt lose any information. This is immediate in one direction, but the other direction is by induction on βwordsβ.
isom : is-iso K.β isom .is-iso.inv (A , alg) = A , Algebra-onβgroup-on alg isom .is-iso.linv x = β«-Path (total-hom (Ξ» x β x) (record { pres-β = Ξ» x y β refl })) id-equiv isom .is-iso.rinv x = Ξ£-pathp refl (Algebra-on-pathp _ _ go) where alg = x .snd grp = Algebra-onβgroup-on alg rec = fold-free-group {G = x .fst , grp} (Ξ» x β x) module G = Group-on grp alg-gh : is-group-hom (Free-Group β x β .snd) grp (x .snd .Ξ½) alg-gh .is-group-hom.pres-β x y = sym (happly (alg .Ξ½-mult) (inc _ β inc _)) go : rec .hom β‘ x .snd .Ξ½ go = funext $ Free-elim-prop _ (Ξ» _ β hlevel 1) (Ξ» x β sym (happly (alg .Ξ½-unit) x)) (Ξ» x p y q β rec .preserves .is-group-hom.pres-β x y Β·Β· apβ G._β_ p q Β·Β· happly (alg .Ξ½-mult) (inc _ β inc _)) (Ξ» x p β is-group-hom.pres-inv (rec .preserves) {x = x} Β·Β· ap G.inverse p Β·Β· sym (is-group-hom.pres-inv alg-gh {x = x})) refl