\documentclass{article}
\input{packages}
\input{def}

\lecture{Monad Algebras}

\begin{document}
\maketitle

\begin{definition}[Algebra of a $\cat{CAT}$-Monad $\langle \cat{C}, M, \mu, \noprf, \eta, \noprf \rangle$]
A tuple $\langle \ob{C}, \mo{a}, \prf{a}, \prf{i} \rangle$ of the following form:
\begin{framed}
\begin{description}
\item[Underlying Object $\ob{C}$:] $\cat{C}$
\item[Operation $\mo{a}$:] $M(\ob{C}) \mto \ob{C}$
\item[Associativity $\prf{a}$:] $M(\mo{a}) \cocomp \mo{a} = \mu_\ob{C} \cocomp \mo{a} : M(M(\ob{C})) \mto \ob{C}$
\item[Identity $\prf{i}$:] $\id_\ob{C} = \eta_\ob{C} \cocomp \mo{a} : \ob{C} \mto \ob{C}$
\end{description}
\end{framed}
\end{definition}

\begin{remark}
The above definition is also known as an Eilenberg-Moore algebra.
\end{remark}

\begin{example}
The algebras for $\List$ are the (unbiased) monoids.
The algebras for $\Multiset$ are the (unbiased) commutative monoids.
The algebras for $\Finset$ are the (unbiased) idempotent commutative monoids.
\end{example}

\begin{definition}[Morphism of Monad Algebras from $\langle \ob{C}_1, \mo{a}_1, \noprf, \noprf \rangle$ to $\langle \ob{C}_2, \mo{a}_2, \noprf, \noprf \rangle$]
A tuple $\langle \mo{f}, \prf{d} \rangle$ where $\mo{f}$ is a morphism from $\ob{C}_1$ to $\ob{C}_2$ and $\prf{d}$ is a proof that $M(\mo{f}) \cocomp \mo{a}_2$ equals $\mo{a}_1 \cocomp \mo{f}$.
\end{definition}

\begin{example}
Just like how an algebra for $\List$ corresponds to a monoid, a morphism of $\List$-algebras corresponds to a monoid homomorphism.
\end{example}

\begin{definition}[$\cat{Alg}(\alg{M})$ where $\alg{M}$ is a $\cat{CAT}$-Monad]
The category whose objects are $\alg{M}$-algebras and whose morphisms are $\alg{M}$-algebra morphisms.
Identities and composition of morphisms are inherited from $\cat{C}$.
\end{definition}

\begin{remark}
$\cat{Alg}(\alg{M})$ is known as the Eilenberg-Moore category of $\alg{M}$.
\end{remark}

\begin{example}
Abusing notation, $\cat{Alg}(\List)$ is $\cat{Mon}_\mathit{Unbiased}$, and $\cat{Alg}(\Multiset)$ is $\cat{CommMon}_\mathit{Unbiased}$.
\end{example}

\begin{exercise}
Show that a monad morphism from $\alg{M}_1$ to $\alg{M}_2$ provides a functor from $\cat{Alg}(\alg{M}_2)$ to $\cat{Alg}(\alg{M}_1)$.
\end{exercise}

\begin{definition}[$\langle \ob{C}, \mo{m}, \mu, \noprf, \eta, \noprf \rangle$-Premodule in a 2-Category $\cat{C}$]
A tuple $\langle \ob{L}, \mo{l}, \lambda, \prf{d}, \prf{i} \rangle$ of the following form:
\begin{framed}
\begin{description}
\item[Object $\ob{L}$:] $\cat{C}$
\item[Morphism $\mo{l}$:] $\ob{L} \mto \ob{C}$
\item[Action $\lambda$:] $\mo{l} \cocomp \mo{m} \nto \mo{l}$
\item[Distributivity $\prf{d}$:] A proof that
\begin{tikzpicture}[baseline=0]
\node(c1) at (0,1) {$\ob{L}$};
\node(c2) at (1,-1) {$\ob{C}$};
\node(c3) at (3,-1) {$\ob{C}$};
\node(c4) at (4,1) {$\ob{C}$};
\draw[->] (c1) -- node[below left]{$\mo{l}$} (c2);
\draw[->] (c2) -- node[below]{$\mo{m}$} (c3);
\draw[->] (c3) -- node[below right]{$\mo{m}$} (c4);
\draw[->] (c1) -- node(f12){} node[above]{$\mo{l}$} (c3);
\draw[->] (c1) -- node(f123){} node[above]{$\mo{l}$} (c4);
\draw[double,double equal sign distance,-implies] (c2) -- node[below right]{$\lambda$} (f12);
\draw[double,double equal sign distance,-implies] (c3) -- node[above right]{$\lambda$} (f123);
\end{tikzpicture}
equals
\begin{tikzpicture}[baseline=0]
\node(c1) at (0,1) {$\ob{L}$};
\node(c2) at (1,-1) {$\ob{C}$};
\node(c3) at (3,-1) {$\ob{C}$};
\node(c4) at (4,1) {$\ob{C}$};
\draw[->] (c1) -- node[below left]{$\mo{l}$} (c2);
\draw[->] (c2) -- node[below]{$\mo{m}$} (c3);
\draw[->] (c3) -- node[below right]{$\mo{m}$} (c4);
\draw[->] (c2) -- node(f23){} node[above]{$\mo{m}$} (c4);
\draw[->] (c1) -- node(f123){} node[above]{$\mo{l}$} (c4);
\draw[double,double equal sign distance,-implies] (c3) -- node[below left]{$\mu$} (f23);
\draw[double,double equal sign distance,-implies] (c2) -- node[above left]{$\lambda$} (f123);
\end{tikzpicture}
.\\
In other words,
\begin{tikzpicture}[baseline=1.5cm]
\node(f1) at (0,0) {$\mo{l}$};
\node(f2) at (2,0) {$\mo{m}$};
\node(f3) at (4,0) {$\mo{m}$};
\node(n1)[circle,draw] at (1,1) {$\lambda$};
\node(n2)[circle,draw] at (2,2) {$\lambda$};
\node(f123) at (2,3) {$\mo{l}$};
\draw[->] (f1) -- (n1);
\draw[->] (f2) -- (n1);
\draw[->] (f3) -- (n2);
\draw[->] (n1) -- node(f12)[above left]{$\mo{l}$} (n2);
\draw[->] (n2) -- (f123);
\node at (.5,2.5) {$\ob{L}$};
\node at (1,.25) {$\ob{C}$};
\node at (2.25,.75) {$\ob{C}$};
\node at (3.5,2) {$\ob{C}$};
\end{tikzpicture}
equals
\begin{tikzpicture}[baseline=1.5cm]
\node(f1) at (0,0) {$\mo{l}$};
\node(f2) at (2,0) {$\mo{m}$};
\node(f3) at (4,0) {$\mo{m}$};
\node(n1)[circle,draw] at (3,1) {$\mu$};
\node(n2)[circle,draw] at (2,2) {$\lambda$};
\node(f123) at (2,3) {$\mo{l}$};
\draw[->] (f1) -- (n2);
\draw[->] (f2) -- (n1);
\draw[->] (f3) -- (n1);
\draw[->] (n1) -- node(f12)[above right]{$\mo{m}$} (n2);
\draw[->] (n2) -- (f123);
\node at (3.5,2.5) {$\ob{C}$};
\node at (3,.25) {$\ob{C}$};
\node at (1.75,.75) {$\ob{C}$};
\node at (.5,2) {$\ob{L}$};
\end{tikzpicture}
.
\item[Identity $\prf{i}$:] A proof that
\begin{tikzpicture}[baseline=(c1.base)]
\node(c1) at (0,0) {$\ob{L}$};
\node(c2) at (4,0) {$\ob{C}$};
\draw[->] (c1) .. controls (1.5,-1.5) and (2.5,-1.5) .. node(f1){} node[below]{$\mo{l}$} (c2);
\draw[->] (c2) .. controls (1.75,-1.5) and (1.75,1.5) .. node(f2){} node[left]{$\mo{m}$} (c2);
\draw[->] (c1) .. controls (1.5,1.5) and (2.5,1.5) .. node(f12){} node[above]{$\mo{l}$} (c2);
\draw[double,double equal sign distance,-implies] (c2) -- node[above]{$\eta$} (f2);
\draw[double,double equal sign distance,-implies] ($(f1.west) !.5! (c2.south)$) .. controls +(-1.5,-.5) and ($(f12.south west) + (-1,-1)$) .. node[left]{$\lambda$} (f12.south west);
\end{tikzpicture}
equals
\begin{tikzpicture}[baseline=(c1.base)]
\node(c1) at (0,0) {$\ob{L}$};
\node(c2) at (1.5,0) {$\ob{C}$};
\draw[->] (c1) to[bend right=30] node[below]{$\mo{l}$} node(f1){} (c2);
\draw[->] (c1) to[bend left=30] node[above]{$\mo{l}$} node(f2){} (c2);
\draw[double,double equal sign distance] (f1) -- (f2);
\end{tikzpicture}
.\\
In other words,
\begin{tikzpicture}[baseline=1.5cm]
\node(f1) at (0,0) {$\mo{l}$};
\node(n1)[circle,draw] at (1,1) {$\eta$};
\node(n2)[circle,draw] at (0,2) {$\lambda$};
\node(f12) at (0,3) {$\mo{l}$};
\draw[->] (f1) -- ++(0,.5) .. controls +(0,.5) and ($(n2.south west) + (-.5,-.5)$) .. (n2.south west);
\draw[->] (n1) -- node[above right]{$\mo{m}$} (n2);
\draw[->] (n2) -- (f12);
\node at (-1,1) {$\ob{L}$};
\node at (1.5,2.25) {$\ob{C}$};
\end{tikzpicture}
equals
\begin{tikzpicture}[baseline=1.5cm]
\node(f1) at (0,0) {$\mo{l}$};
\node(f2) at (0,3) {$\mo{l}$};
\draw[->] (f1) -- (f2);
\node at (-.5,1.5) {$\ob{L}$};
\node at (.5,1.5) {$\ob{C}$};
\end{tikzpicture}
.
\end{description}
\end{framed}
\end{definition}

\begin{remark}
A premodule is more commonly called a left module.
\end{remark}

\begin{remark}
An algebra for a $\cat{CAT}$-monad is simply a premodule where $\ob{L}$ is $\cat{1}$.
\end{remark}

\begin{theorem}
For every monad $\langle \ob{C}, \mo{m}, \mu, \prf{d}, \eta, \prf{i} \rangle$, the tuple~$\langle \ob{C}, \mo{m}, \mu, \prf{d}, \prf{i} \rangle$ is a premodule of that monad.
\end{theorem}

\begin{example}
Suppose we have a $\cat{CAT}$-monad $\alg{M}$ whose components are $\langle \cat{C}, M, \mu, \noprf, \eta, \noprf \rangle$.
Let $U$ be the functor from $\cat{Alg}(\alg{M})$ to $\cat{C}$ that maps each algebra $\langle \ob{C}, \mo{a}, \noprf, \noprf \rangle$ to $\ob{C}$ and each algebra morphism $\langle \mo{f}, \noprf \rangle$ to $\mo{f}$.
Let $\alpha : U \cocomp M \nto M$ be the natural transformation mapping each algebra $\langle \ob{C}, \mo{a}, \noprf, \noprf \rangle$ to the morphism $\mo{a} : M(U(\langle \ob{C}, \mo{a}, \noprf, \noprf \rangle)) = M(\ob{C}) \mto \ob{C}$.
This forms a $\alg{M}$-premodule: $\alpha$ distributes and preserves identity because each operation $\mo{a}$ is associative and preserves identity.
\end{example}

\begin{exercise}
Prove that for any $\cat{CAT}$-monad $\alg{M}$ and $\alg{M}$-premodule $\langle \cat{L}, L, \lambda, \noprf, \noprf \rangle$, there is a unique functor $L' : \cat{L} \mto \cat{Alg}(\alg{M})$ such that $L = L' \cocomp U$ and $\lambda = L' \cdot \alpha$.
\end{exercise}

\begin{remark}
Given a 2-category~$\cat{C}$, one can construct an opetory with the same 0-cells and 1-cells and with a 2-cell for each 2-cell from the composition of the inputs to the output.
$\cat{1}$ is the opetory with one 0-cell~$\ob{C}$, one 1-cell~$\mo{m} : \ob{C} \mto \ob{C}$, and one 2-cell from $\mo{m}^n \nto \mo{m}$ for each $n : \N$.
A monad~$\alg{M}$ in $\cat{C}$ corresponds to a functor~$M$ of opetories from $\cat{1}$ to $\cat{C}$.
Let $\cat{1}_\ell$ be the operatory with two 0-cells~$\ob{L}$ and $\ob{C}$, two 1-cells~$\mo{l} : \ob{L} \mto \ob{C}$ and $\mo{m} : \ob{C} \mto \ob{C}$, and one 2-cell from $\mo{l}\mo{m}^n$ to $\mo{l}$ for each $n : \N$ and one 2-cell from $\mo{m}^n \nto \mo{m}$ for each $n : \N$.
There is a unique functor of opetories from $\cat{1}$ to $\cat{1}_\ell$, which we will call $I_\ell$.
An $\alg{M}$-premodule~$\alg{L}$, then, corresponds to a functor~$L$ of opetories from $\cat{1}_\ell$ to $\cat{C}$ such that $I_\ell \cocomp L$ equals $M$.
\end{remark}

\begin{exercise}
Show that a monad morphism from $\alg{M}_1$ to $\alg{M}_2$ provides a functor from $\cat{Alg}(\alg{M}_2)$ to $\cat{Alg}(\alg{M}_1)$.
\end{exercise}

\begin{remark}
The monad morphism from the $\List$~monad to the $\Multiset$~monad corresponds to the inclusion functor from $\cat{CommMon}$ to $\cat{Mon}$.
\end{remark}

\end{document}
