In
category theory
Category theory is a general theory of mathematical structures and their relations that was introduced by Samuel Eilenberg and Saunders Mac Lane in the middle of the 20th century in their foundational work on algebraic topology. Nowadays, cate ...
, a branch of
mathematics
Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, a monad (also triple, triad, standard construction and fundamental construction) is a
monoid
In abstract algebra, a branch of mathematics, a monoid is a set equipped with an associative binary operation and an identity element. For example, the nonnegative integers with addition form a monoid, the identity element being 0.
Monoids ...
in the
category
Category, plural categories, may refer to:
Philosophy and general uses
* Categorization, categories in cognitive science, information science and generally
*Category of being
* ''Categories'' (Aristotle)
*Category (Kant)
*Categories (Peirce)
* ...
of
endofunctor
In mathematics, specifically category theory, a functor is a mapping between categories. Functors were first considered in algebraic topology, where algebraic objects (such as the fundamental group) are associated to topological spaces, and ma ...
s. An endofunctor is a
functor
In mathematics, specifically category theory, a functor is a Map (mathematics), mapping between Category (mathematics), categories. Functors were first considered in algebraic topology, where algebraic objects (such as the fundamental group) ar ...
mapping a category to itself, and a monad is an endofunctor together with two
natural transformation
In category theory, a branch of mathematics, a natural transformation provides a way of transforming one functor into another while respecting the internal structure (i.e., the composition of morphisms) of the categories involved. Hence, a natur ...
s required to fulfill certain
coherence condition
In mathematics, and particularly category theory, a coherence condition is a collection of conditions requiring that various compositions of elementary morphisms are equal. Typically the elementary morphisms are part of the data of the category. A ...
s. Monads are used in the theory of pairs of
adjoint functors
In mathematics, specifically category theory, adjunction is a relationship that two functors may exhibit, intuitively corresponding to a weak form of equivalence between two related categories. Two functors that stand in this relationship are kno ...
, and they generalize
closure operator In mathematics, a closure operator on a set ''S'' is a function \operatorname: \mathcal(S)\rightarrow \mathcal(S) from the power set of ''S'' to itself that satisfies the following conditions for all sets X,Y\subseteq S
:
Closure operators are dete ...
s on
partially ordered set
In mathematics, especially order theory, a partially ordered set (also poset) formalizes and generalizes the intuitive concept of an ordering, sequencing, or arrangement of the elements of a Set (mathematics), set. A poset consists of a set toget ...
s to arbitrary categories. Monads are also useful in the
theory of datatypes and in
functional programming language
In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. It is a declarative programming paradigm in which function definitions are trees of expressions that m ...
s, allowing languages with non-mutable states to do things such as simulate for-loops; see
Monad (functional programming)
In functional programming, a monad is a software design pattern with a structure that combines program fragments (Function (computer programming), functions) and wraps their return values in a Type system, type with additional computation. In add ...
.
Introduction and definition
A monad is a certain type of
endofunctor
In mathematics, specifically category theory, a functor is a mapping between categories. Functors were first considered in algebraic topology, where algebraic objects (such as the fundamental group) are associated to topological spaces, and ma ...
. For example, if
and
are a pair of
adjoint functors
In mathematics, specifically category theory, adjunction is a relationship that two functors may exhibit, intuitively corresponding to a weak form of equivalence between two related categories. Two functors that stand in this relationship are kno ...
, with
left adjoint to
, then the composition
is a monad. If
and
are inverse functors, the corresponding monad is the
identity functor
In mathematics, specifically category theory, a functor is a mapping between categories. Functors were first considered in algebraic topology, where algebraic objects (such as the fundamental group) are associated to topological spaces, and ma ...
. In general, adjunctions are not
equivalences
Equivalence or Equivalent may refer to:
Arts and entertainment
*Album-equivalent unit, a measurement unit in the music industry
*Equivalence class (music)
*''Equivalent VIII'', or ''The Bricks'', a minimalist sculpture by Carl Andre
*'' Equival ...
—they relate categories of different natures. The monad theory matters as part of the effort to capture what it is that adjunctions 'preserve'. The other half of the theory, of what can be learned likewise from consideration of
, is discussed under the dual theory of ''comonads''.
Formal definition
Throughout this article
denotes a
category
Category, plural categories, may refer to:
Philosophy and general uses
* Categorization, categories in cognitive science, information science and generally
*Category of being
* ''Categories'' (Aristotle)
*Category (Kant)
*Categories (Peirce)
* ...
. A ''monad'' on
consists of an endofunctor
together with two
natural transformation
In category theory, a branch of mathematics, a natural transformation provides a way of transforming one functor into another while respecting the internal structure (i.e., the composition of morphisms) of the categories involved. Hence, a natur ...
s:
(where
denotes the identity functor on
) and
(where
is the functor
from
to
). These are required to fulfill the following conditions (sometimes called
coherence condition
In mathematics, and particularly category theory, a coherence condition is a collection of conditions requiring that various compositions of elementary morphisms are equal. Typically the elementary morphisms are part of the data of the category. A ...
s):
*
(as natural transformations
); here
and
are formed by "
horizontal composition"
*
(as natural transformations
; here
denotes the identity transformation from
to
).
We can rewrite these conditions using the following
commutative diagrams
350px, The commutative diagram used in the proof of the five lemma.
In mathematics, and especially in category theory, a commutative diagram is a diagram such that all directed paths in the diagram with the same start and endpoints lead to th ...
:
See the article on
natural transformations
In category theory, a branch of mathematics, a natural transformation provides a way of transforming one functor into another while respecting the internal structure (i.e., the composition of morphisms) of the categories involved. Hence, a natural ...
for the explanation of the notations
and
, or see below the commutative diagrams not using these notions:
The first axiom is akin to the
associativity
In mathematics, the associative property is a property of some binary operations, which means that rearranging the parentheses in an expression will not change the result. In propositional logic, associativity is a valid rule of replacement f ...
in
monoids
In abstract algebra, a branch of mathematics, a monoid is a set equipped with an associative binary operation and an identity element. For example, the nonnegative integers with addition form a monoid, the identity element being 0.
Monoids ...
if we think of
as the monoid's binary operation, and the second axiom is akin to the existence of an
identity element
In mathematics, an identity element, or neutral element, of a binary operation operating on a set is an element of the set that leaves unchanged every element of the set when the operation is applied. This concept is used in algebraic structures su ...
(which we think of as given by
). Indeed, a monad on
can alternatively be defined as a
monoid
In abstract algebra, a branch of mathematics, a monoid is a set equipped with an associative binary operation and an identity element. For example, the nonnegative integers with addition form a monoid, the identity element being 0.
Monoids ...
in the category
whose objects are the endofunctors of
and whose morphisms are the natural transformations between them, with the
monoidal structure induced by the composition of endofunctors.
The power set monad
The ''power set monad'' is a monad
on the category
: For a set
let
be the
power set
In mathematics, the power set (or powerset) of a set is the set of all subsets of , including the empty set and itself. In axiomatic set theory (as developed, for example, in the ZFC axioms), the existence of the power set of any set is po ...
of
and for a function
let
be the function between the power sets induced by taking
direct images under
. For every set
, we have a map
, which assigns to every
the
singleton
Singleton may refer to:
Sciences, technology Mathematics
* Singleton (mathematics), a set with exactly one element
* Singleton field, used in conformal field theory Computing
* Singleton pattern, a design pattern that allows only one instance ...
. The function
:
takes a set of sets to its
union
Union commonly refers to:
* Trade union, an organization of workers
* Union (set theory), in mathematics, a fundamental operation on sets
Union may also refer to:
Arts and entertainment
Music
* Union (band), an American rock group
** ''Un ...
. These data describe a monad.
Remarks
The axioms of a monad are formally similar to the
monoid
In abstract algebra, a branch of mathematics, a monoid is a set equipped with an associative binary operation and an identity element. For example, the nonnegative integers with addition form a monoid, the identity element being 0.
Monoids ...
axioms. In fact, monads are special cases of monoids, namely they are precisely the monoids among
endofunctor
In mathematics, specifically category theory, a functor is a mapping between categories. Functors were first considered in algebraic topology, where algebraic objects (such as the fundamental group) are associated to topological spaces, and ma ...
s
, which is equipped with the multiplication given by composition of endofunctors.
Composition of monads is not, in general, a monad. For example, the double power set functor
does not admit any monad structure.
Comonads
The
categorical dual
In category theory, a branch of mathematics, duality is a correspondence between the properties of a category ''C'' and the dual properties of the opposite category ''C''op. Given a statement regarding the category ''C'', by interchanging the sou ...
definition is a formal definition of a ''comonad'' (or ''cotriple''); this can be said quickly in the terms that a comonad for a category
is a monad for the
opposite category
In category theory, a branch of mathematics, the opposite category or dual category ''C''op of a given category ''C'' is formed by reversing the morphisms, i.e. interchanging the source and target of each morphism. Doing the reversal twice yields t ...
. It is therefore a functor
from
to itself, with a set of axioms for ''counit'' and ''comultiplication'' that come from reversing the arrows everywhere in the definition just given.
Monads are to monoids as comonads are to ''
comonoids''. Every set is a comonoid in a unique way, so comonoids are less familiar in
abstract algebra
In mathematics, more specifically algebra, abstract algebra or modern algebra is the study of algebraic structures. Algebraic structures include groups, rings, fields, modules, vector spaces, lattices, and algebras over a field. The term ''a ...
than monoids; however, comonoids in the category of vector spaces with its usual tensor product are important and widely studied under the name of
coalgebra In mathematics, coalgebras or cogebras are structures that are dual (in the category-theoretic sense of reversing arrows) to unital associative algebras. The axioms of unital associative algebras can be formulated in terms of commutative diagrams ...
s.
Terminological history
The notion of monad was invented by
Roger Godement
Roger Godement (; 1 October 1921 – 21 July 2016) was a French mathematician, known for his work in functional analysis as well as his expository books.
Biography
Godement started as a student at the École normale supérieure in 1940, where he ...
in 1958 under the name "standard construction". Monad has been called "dual standard construction", "triple", "monoid" and "triad". The term "monad" is used at latest 1967, by
Jean Bénabou
Jean Bénabou (1932 – 11 February 2022) was a Moroccan-born French mathematician, known for his contributions to category theory.
He directed the Research Seminar in Category Theory at the Institut Henri Poincaré
The Henri Poincaré Insti ...
.
Examples
Monads arising from adjunctions
Any
adjunction
:
gives rise to a monad on ''C''. This very widespread construction works as follows: the endofunctor is the composite
:
This endofunctor is quickly seen to be a monad, where the unit map stems from the unit map
of the adjunction, and the multiplication map is constructed using the counit map of the adjunction:
:
In fact,
any monad can be found as an explicit adjunction of functors using the
Eilenberg–Moore category
In category theory, a branch of mathematics, a monad (also triple, triad, standard construction and fundamental construction) is a monoid in the category of endofunctors. An endofunctor is a functor mapping a category to itself, and a monad is ...
(the category of
-algebras).
Double dualization
The ''double dualization monad'', for a fixed
field
Field may refer to:
Expanses of open ground
* Field (agriculture), an area of land used for agricultural purposes
* Airfield, an aerodrome that lacks the infrastructure of an airport
* Battlefield
* Lawn, an area of mowed grass
* Meadow, a grass ...
''k'' arises from the adjunction
:
where both functors are given by sending a
vector space
In mathematics and physics, a vector space (also called a linear space) is a set whose elements, often called ''vectors'', may be added together and multiplied ("scaled") by numbers called '' scalars''. Scalars are often real numbers, but can ...
''V'' to its
dual vector space
In mathematics, any vector space ''V'' has a corresponding dual vector space (or just dual space for short) consisting of all linear forms on ''V'', together with the vector space structure of pointwise addition and scalar multiplication by const ...
. The associated monad sends a vector space ''V'' to its
double dual
In mathematics, any vector space ''V'' has a corresponding dual vector space (or just dual space for short) consisting of all linear forms on ''V'', together with the vector space structure of pointwise addition and scalar multiplication by con ...
. This monad is discussed, in much greater generality, by .
Closure operators on partially ordered sets
For categories arising from
partially ordered set
In mathematics, especially order theory, a partially ordered set (also poset) formalizes and generalizes the intuitive concept of an ordering, sequencing, or arrangement of the elements of a Set (mathematics), set. A poset consists of a set toget ...
s
(with a single morphism from
to
if and only if
In logic and related fields such as mathematics and philosophy, "if and only if" (shortened as "iff") is a biconditional logical connective between statements, where either both statements are true or both are false.
The connective is bicondi ...
), then the formalism becomes much simpler: adjoint pairs are
Galois connection In mathematics, especially in order theory, a Galois connection is a particular correspondence (typically) between two partially ordered sets (posets). Galois connections find applications in various mathematical theories. They generalize the funda ...
s and monads are
closure operators
Closure may refer to:
Conceptual Psychology
* Closure (psychology), the state of experiencing an emotional conclusion to a difficult life event
Computer science
* Closure (computer programming), an abstraction binding a function to its scope
* ...
.
Free-forgetful adjunctions
For example, let
be the
forgetful functor In mathematics, in the area of category theory, a forgetful functor (also known as a stripping functor) 'forgets' or drops some or all of the input's structure or properties 'before' mapping to the output. For an algebraic structure of a given signa ...
from
the category Grp of
groups
A group is a number of persons or things that are located, gathered, or classed together.
Groups of people
* Cultural group, a group whose members share the same cultural identity
* Ethnic group, a group whose members share the same ethnic ide ...
to the
category Set of sets, and let
be the
free group
In mathematics, the free group ''F'S'' over a given set ''S'' consists of all words that can be built from members of ''S'', considering two words to be different unless their equality follows from the group axioms (e.g. ''st'' = ''suu''−1' ...
functor from the category of sets to the category of groups. Then
is left adjoint of
. In this case, the associated monad
takes a set
and returns the underlying set of the free group
.
The unit map of this monad is given by the maps
:
including any set
into the set
in the natural way, as strings of length 1. Further, the multiplication of this monad is the map
:
made out of a natural
concatenation
In formal language, formal language theory and computer programming, string concatenation is the operation of joining character string (computer science), character strings wikt:end-to-end, end-to-end. For example, the concatenation of "sno ...
or 'flattening' of 'strings of strings'. This amounts to two
natural transformation
In category theory, a branch of mathematics, a natural transformation provides a way of transforming one functor into another while respecting the internal structure (i.e., the composition of morphisms) of the categories involved. Hence, a natur ...
s.
The preceding example about free groups can be generalized to any type of algebra in the sense of a
variety of algebras in
universal algebra
Universal algebra (sometimes called general algebra) is the field of mathematics that studies algebraic structures themselves, not examples ("models") of algebraic structures.
For instance, rather than take particular groups as the object of study, ...
. Thus, every such type of algebra gives rise to a monad on the category of sets. Importantly, the algebra type can be recovered from the monad (as the category of Eilenberg–Moore algebras), so monads can also be seen as generalizing varieties of universal algebras.
Another monad arising from an adjunction is when
is the endofunctor on the category of vector spaces which maps a vector space
to its
tensor algebra
In mathematics, the tensor algebra of a vector space ''V'', denoted ''T''(''V'') or ''T''(''V''), is the algebra of tensors on ''V'' (of any rank) with multiplication being the tensor product. It is the free algebra on ''V'', in the sense of being ...
, and which maps linear maps to their tensor product. We then have a natural transformation corresponding to the embedding of
into its
tensor algebra
In mathematics, the tensor algebra of a vector space ''V'', denoted ''T''(''V'') or ''T''(''V''), is the algebra of tensors on ''V'' (of any rank) with multiplication being the tensor product. It is the free algebra on ''V'', in the sense of being ...
, and a natural transformation corresponding to the map from
to
obtained by simply expanding all tensor products.
Codensity monads
Under mild conditions, functors not admitting a left adjoint also give rise to a monad, the so-called
codensity monad. For example, the inclusion
:
does not admit a left adjoint. Its codensity monad is the monad on sets sending any set ''X'' to the set of
ultrafilter
In the mathematical field of order theory, an ultrafilter on a given partially ordered set (or "poset") P is a certain subset of P, namely a maximal filter on P; that is, a proper filter on P that cannot be enlarged to a bigger proper filter on ...
s on ''X''. This and similar examples are discussed in .
Algebras for a monad
Given a monad
on a category
, it is natural to consider ''
-algebras'', i.e., objects of
acted upon by
in a way which is compatible with the unit and multiplication of the monad. More formally, a
-algebra
is an object
of
together with an arrow
of
called the ''structure map'' of the algebra such that the diagrams
commute.
A morphism
of
-algebras is an arrow
of
such that the diagram commutes.
-algebras form a category called the ''Eilenberg–Moore category'' and denoted by
.
Examples
Algebras over the free group monad
For example, for the free group monad discussed above, a
-algebra is a set
together with a map from the free group generated by
towards
subject to associativity and unitality conditions. Such a structure is equivalent to saying that
is a group itself.
Algebras over the distribution monad
Another example is the ''distribution monad''
on the category of sets. It is defined by sending a set
to the set of functions