### Algebra for a Monad

Given a monad: T: C -> C , 1 =>_{η} T <=_{µ} T denoted by the triple <T,η,µ>

An algebra for a monad <T,η,µ> is an object AC equipped with an 'action': a morphism θ:TA->A so that the following diagrams commute:

Axioms of an algebra A: |

### Relationship to an Algebraic Theory

If the monad T represents an algebraic theory.

Then an 'algebra for a monad' represents a model for the algebraic theory, that is, an implementation of it.

Monad | an algebraic theory | Syntax | Holds all the operations that may be needed. | Let us form algebras |

Algebra for a monad | a model for the algebraic theory | Semantics | An implementation of those operations. | Let us evaluate (collapse) algebras |

### Informal Introduction

We can think of the endofunctor of a monad in terms of an expression |

We are first introduced to 'algebra' as a part of mathematics where we can use letters (variables) to stand in for numbers that are unknown or we don't wish to use the literal value. We can then use this to express axioms like: x+y =y+x.

Here we relate algebras to monads. The monad will allow us to build up expressions and the algebra will allow us to evaluate it back to a single value.

In order to construct a monad, in this case, we start with an endofunctor A -> T A. This takes a variable and gives us an expression in that variable.

Examples:

- x -> x² + 3
- x -> x + 2

We can compose these by substituting one in the other, like this

- x -> (x+2)² + 3

So where x appears in the first we have substituted (x+2) which is the second.

We now have the two natural transformations:

- A -> T A
- T T A -> T A

Which gives us a monad.

On the remainder of this page we investigate questions such as:

- Are there other monads which model algebras?
- What is the link to adjunctions?
- Is there a similar structure for co-algebras?

### Monads and Algebras

There is a connection between monads, adjunctions and algebras. |

An algebra can have two levels:

- An algebraic theory - defines function signatures and axioms.
- A model of that theory - defines the implementation of the functions.

### Algebras and Coalgebras

Algebras have a structure based on products, so a subalgebra is a quotient. Coalgebras have a structure and substructure based on sum.

### Monad as Algebraic Theory

A monad <T,η,µ> can represent an algebraic theory as might be given by function signatures and axioms.

### Category of Algebras

We can generalise this concept to a category of algebras (alg T) where the objects are the morphisms θ:TA->A

### Monadisity

Given any category 'C', is it an alg T for some T?

There is a whole category of algebras with two extremes:

- The Eilenberg-Moore algebra (C
^{T}) is terminal in this category of algebras. It has different objects but the same arrows as C. - The Kleisli algebra is initial (C
_{T})in this category of algebras. It has the same objects but different arrows as C.

### Adjunctions and Algebras

Here we will talk about 'an algebra' to talk about specific mathematical 'equational theories' (The theory of fields is not equational because not every element has a multiplicative inverse).

An 'equational theory' is called a 'T-Algebra'. This gives rise to a free -| forgetful adjunction between sets and the category of models of the theory.

- forgetful functor U: T-Alg -> Sets
- free functor F: Sets -> T-Alg

The 'initial algebra' for an endofunctor P:S->S is a 'least fixed point' for P. Such algebras can be used in computer science to model 'recursive datatypes'.