nLab action monad

Redirected from "action monads".
Contents

Context

Algebra

Higher algebra

Representation theory

Contents

Idea

The action monad or writer monad is a construction generalizing many seemingly different concepts across mathematics and computer science. It may intuitively be understood in the following ways, where throughout we fix a group or monoid MM.

If one, more generally, replaces sets and a monoid with a monoidal category and an internal monoid, a similar construction can be given. This generalizes, for example, the action that rings have on their modules, and that Lie groups have on manifolds.

Definition

In Sets

Let MM be a monoid with unit e:1Me:1\to M and multiplication :M×MM\cdot:M\times M \to M. The (left) MM-action monad is a monad on Set where

  • The endofunctor maps a set XX to the set M×XM\times X;

  • The unit is given by

for each object XX;

  • The multiplication is given by

for each object XX.

The monad axioms follow from the monoid axioms for MM.

There exists an analogous monad for right actions, whose endofunctor maps XX to X×MX\times M.

In any monoidal category

More generally, let (C,,1)(C,\otimes,1) be a monoidal category. Let MM be a monoid object in CC with unit e:1Me:1\to M and multiplication :MMM\cdot:M\otimes M \to M. The (left) MM-action monad is a monad on CC where

  • The endofunctor maps an object XX of CC to the object MXM\otimes X;

  • The unit is given by

for each object XX;

  • The multiplication is given by

for each object XX.

Again, the monad axioms follow from the monoid axioms for MM. (And again there is an analogous notion for right actions).

Algebras

The algebras over the action monad for a monoid (or group) MM can be seen as the M M -spaces, i.e. sets or spaces equipped with an action of MM (hence the name).

Plugging in the definition, an algebra over this monad is then a set AA together with a map e:M×AAe:M\times A\to A, such that the following diagrams commute. The algebra diagrams

say equivalently that for all aAa\in A and m,nMm,n\in M,

1a=a,(mn)a=m(na). 1\cdot a= a, \qquad (m n)\cdot a = m\cdot (n\cdot a) .

In other words, a T MT_M-algebra is exactly a set equipped with an MM-action in the traditional group-theoretical sense.

This gives a way to talk about monoid and group actions internally to any monoidal category, giving the notion of a module object.

Examples

Properties

Examples

As logging-effect in computer science

As a monad in computer science, the action monad is known under the name of writer monad, since it encodes the computational effect of programs “writing logging messages” like into a stream.

The following explanation is taken from Perrone, Example 5.1.14.

Let MM be a monoid, and let’s write it additively. Denote by T MT_M its right writer monad.

A Kleisli morphism of T MT_M is a morphism k:XY×Mk \colon X \to Y \times M. We can interpret it as a process which, when given an input xXx\in X, does not just produce an output yYy\in Y, but also an element of MM.

For example, it could be energy released by a chemical reaction, or waste, or a cost of the transaction. In computer science, this is the behaviour of a function that computes a certain value, but that also writes into a log file (or to the standard output) that something has happened (the monoid operation being the concatenation of strings). For example, when you compile a TeX document, a log file is produced alongside your output file. Hence the name “writer monad”.

Let’s now look at the Kleisli composition. If we have processes k:XY×Mk \colon X \to Y\times M and h:YZ×Mh \colon Y\to Z\times M, then k klY:XZ×Mk\circ_{kl} Y \colon X\to Z\times M is given by

What it does is the following:

  1. It executes the process kk with an input xXx\in X, giving as output an element of yYy\in Y as well as a cost (or extra output) mMm\in M.

  2. It executes the process kk taking as input the yYy\in Y produced by kk, giving an element zZz\in Z as well as an extra cost nMn\in M. (All of this while keeping track of the first cost mm.)

  3. The two costs mm and nn are summed (or the extra outputs are concatenated).

So, for example, the cost of executing two processes one after another is the sum of the costs. The same is true about the release of energy in a chemical reaction, and about waste.

Just as well, executing two programs one after another will produce a concatenation of text in a log file (or two log files).

Quantum measurement

For BB a finite set, and fixing any ground field kk (such as the complex numbers), consider the commutative monoid in kk-vector spaces (i.e. the ordinary commutative algebra)

𝟙 B= BkCMon(Vect k)=CAlg k \mathbb{1}^B \;=\; \oplus_B k \;\in\; CMon\big(Vect_k\big) \,=\, CAlg_k

which may be thought of as generated from a BB-indexed set of mutually orthogonal projection operators.

Then the induced 𝟙 B\mathbb{1}^B-writer monad on kk-VectorSpaces (in the sense above) is isomorphic to the linear version of the BB-reader monad. This is related to the notion of quantum measurement, and as such is discussed at: quantum reader monad.

(co)monad nameunderlying endofunctor(co)monad structure induced by
reader monadW(-)W \to (\text{-}) on cartesian typesunique comonoid structure on WW
coreader comonadW×(-)W \times (\text{-}) on cartesian typesunique comonoid structure on WW
writer monadA(-)A \otimes (\text{-}) on monoidal typeschosen monoid structure on AA
cowriter comonadA(-) A(-)\array{A \to (\text{-}) \\ \\ A \otimes (\text{-})} on monoidal typeschosen monoid structure on AA

chosen comonoid structure on AA
Frobenius (co)writerA(-) A(-)\array{A \to (\text{-}) \\ A \otimes (\text{-})} on monoidal typeschosen Frobenius monoid structure

References

General

Elementary exposition:

Proof that the construction of actions monads from monoids is part of an adjunction between monoids and strong monads:

Generalization of this discussion to Frobenius algebras/Frobenius monads (cf. cowriter comonads):

and analogous discussion in dagger-categories:

Discussion of the Eilenberg-Moore category of action monads:

Brief discussion in the context of algebraic geometry:

In computer science

Discussion of the writer monad as an effect-monad in computer science:

Last revised on December 3, 2024 at 10:15:09. See the history of this page for a list of all contributions to it.