In category theory, a Kleisli category is a category naturally associated to any monad T. It is equivalent to the category of free T-algebras. The Kleisli category is one of two extremal solutions to the question Does every monad arise from an adjunction? The other extremal solution is the Eilenberg–Moore category. Kleisli categories are named for the mathematician Heinrich Kleisli.
Formal definition
Let ⟨T, η, μ⟩ be a monad over a category C. The Kleisli category of C is the category CT whose objects and morphisms are given by
![{\displaystyle {\begin{aligned}\mathrm {Obj} (((\mathcal {C))_{T)))&=\mathrm {Obj} ({\mathcal {C))),\\\mathrm {Hom} _((\mathcal {C))_{T))(X,Y)&=\mathrm {Hom} _{\mathcal {C))(X,TY).\end{aligned))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/45e2cb20afd5db3fc7544bd06a39f0543284a35f)
That is, every morphism f: X → T Y in C (with codomain TY) can also be regarded as a morphism in CT (but with codomain Y). Composition of morphisms in CT is given by
![{\displaystyle g\circ _{T}f=\mu _{Z}\circ Tg\circ f:X\to TY\to T^{2}Z\to TZ}](https://wikimedia.org/api/rest_v1/media/math/render/svg/e954f4fc3a00865d5717e3901ee9c9ead32735f8)
where f: X → T Y and g: Y → T Z. The identity morphism is given by the monad unit η:
.
An alternative way of writing this, which clarifies the category in which each object lives, is used by Mac Lane.[1] We use very slightly different notation for this presentation. Given the same monad and category
as above, we associate with each object
in
a new object
, and for each morphism
in
a morphism
. Together, these objects and morphisms form our category
, where we define
![{\displaystyle g^{*}\circ _{T}f^{*}=(\mu _{Z}\circ Tg\circ f)^{*}.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/23122a40ccc366a3fad6595c07999658f4c14d30)
Then the identity morphism in
is
![{\displaystyle \mathrm {id} _{X_{T))=(\eta _{X})^{*}.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/90f35a3ad71622e51900c2aeb955fbeaaeaa8fbb)
Extension operators and Kleisli triples
Composition of Kleisli arrows can be expressed succinctly by means of the extension operator (–)# : Hom(X, TY) → Hom(TX, TY). Given a monad ⟨T, η, μ⟩ over a category C and a morphism f : X → TY let
![{\displaystyle f^{\sharp }=\mu _{Y}\circ Tf.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/409a2aa3c2047915e0119777b51d220f579c4bdb)
Composition in the Kleisli category CT can then be written
![{\displaystyle g\circ _{T}f=g^{\sharp }\circ f.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/2b5ab2f0bf8c6c1e3578be7f6c397873a9c74e26)
The extension operator satisfies the identities:
![{\displaystyle {\begin{aligned}\eta _{X}^{\sharp }&=\mathrm {id} _{TX}\\f^{\sharp }\circ \eta _{X}&=f\\(g^{\sharp }\circ f)^{\sharp }&=g^{\sharp }\circ f^{\sharp }\end{aligned))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/48137ac89b8b0124a00b01855d4df368d6e5fd30)
where f : X → TY and g : Y → TZ. It follows trivially from these properties that Kleisli composition is associative and that ηX is the identity.
In fact, to give a monad is to give a Kleisli triple ⟨T, η, (–)#⟩, i.e.
- A function
;
- For each object
in
, a morphism
;
- For each morphism
in
, a morphism ![{\displaystyle f^{\sharp }\colon T(A)\to T(B)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/90b55ca1a0cf35619feb3e5050759eecf0f73d00)
such that the above three equations for extension operators are satisfied.
Kleisli adjunction
Kleisli categories were originally defined in order to show that every monad arises from an adjunction. That construction is as follows.
Let ⟨T, η, μ⟩ be a monad over a category C and let CT be the associated Kleisli category. Using Mac Lane's notation mentioned in the “Formal definition” section above, define a functor F: C → CT by
![{\displaystyle FX=X_{T}\;}](https://wikimedia.org/api/rest_v1/media/math/render/svg/62c0e63d288a022752d939a22f90e37aac7ebba3)
![{\displaystyle F(f\colon X\to Y)=(\eta _{Y}\circ f)^{*))](https://wikimedia.org/api/rest_v1/media/math/render/svg/0c605a70f2d6c21cfb08cdcf3d56cb6dba57f236)
and a functor G : CT → C by
![{\displaystyle GY_{T}=TY\;}](https://wikimedia.org/api/rest_v1/media/math/render/svg/0514da4b535c657f7a0ba887eb403abaccb62680)
![{\displaystyle G(f^{*}\colon X_{T}\to Y_{T})=\mu _{Y}\circ Tf\;}](https://wikimedia.org/api/rest_v1/media/math/render/svg/0538c475718fb02a9b6e2b1369addf67a659127b)
One can show that F and G are indeed functors and that F is left adjoint to G. The counit of the adjunction is given by
![{\displaystyle \varepsilon _{Y_{T))=(\mathrm {id} _{TY})^{*}:(TY)_{T}\to Y_{T}.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/d3167c0e7059751163757930ddcacb6e57017d4c)
Finally, one can show that T = GF and μ = GεF so that ⟨T, η, μ⟩ is the monad associated to the adjunction ⟨F, G, η, ε⟩.
Showing that GF = T
For any object X in category C:
![{\displaystyle {\begin{aligned}(G\circ F)(X)&=G(F(X))\\&=G(X_{T})\\&=TX.\end{aligned))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/b78f8efdb42126242d82faea42744794053bedbc)
For any
in category C:
![{\displaystyle {\begin{aligned}(G\circ F)(f)&=G(F(f))\\&=G((\eta _{Y}\circ f)^{*})\\&=\mu _{Y}\circ T(\eta _{Y}\circ f)\\&=\mu _{Y}\circ T\eta _{Y}\circ Tf\\&={\text{id))_{TY}\circ Tf\\&=Tf.\end{aligned))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/6ed735acbb875d84ef9c7972ebde06a0c3dcdaf8)
Since
is true for any object X in C and
is true for any morphism f in C, then
. Q.E.D.