fbpx
Wikipedia

Monad (category theory)

In category theory, a branch of mathematics, a monad (also triple, triad, standard construction and fundamental construction)[1] is a monoid in the category of endofunctors of some fixed category. An endofunctor is a functor mapping a category to itself, and a monad is an endofunctor together with two natural transformations required to fulfill certain coherence conditions. Monads are used in the theory of pairs of adjoint functors, and they generalize closure operators on partially ordered sets to arbitrary categories. Monads are also useful in the theory of datatypes, the denotational semantics of imperative programming languages, and in functional programming languages, allowing languages without mutable state to do things such as simulate for-loops; see Monad (functional programming).

Introduction and definition edit

A monad is a certain type of endofunctor. For example, if   and   are a pair of adjoint functors, with   left adjoint to  , then the composition   is a monad. If   and   are inverse functors, the corresponding monad is the identity functor. In general, adjunctions are not equivalences—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 edit

Throughout this article   denotes a category. A monad on   consists of an endofunctor   together with two natural transformations:   (where   denotes the identity functor on  ) and   (where   is the functor   from   to  ). These are required to fulfill the following conditions (sometimes called coherence conditions):

  •   (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:

 
            
 

See the article on natural transformations 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 monoids if we think of   as the monoid's binary operation, and the second axiom is akin to the existence of an identity element (which we think of as given by  ). Indeed, a monad on   can alternatively be defined as a monoid 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 edit

The power set monad is a monad   on the category  : For a set   let   be the power set 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  . The function

 

takes a set of sets to its union. These data describe a monad.

Remarks edit

The axioms of a monad are formally similar to the monoid axioms. In fact, monads are special cases of monoids, namely they are precisely the monoids among endofunctors  , 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.[2]

Comonads edit

The categorical dual 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  . 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 than monoids; however, comonoids in the category of vector spaces with its usual tensor product are important and widely studied under the name of coalgebras.

Terminological history edit

The notion of monad was invented by Roger Godement in 1958 under the name "standard construction". Monad has been called "dual standard construction", "triple", "monoid" and "triad".[3] The term "monad" is used at latest 1967, by Jean Bénabou.[4][5]

Examples edit

Identity edit

The identity functor on a category   is a monad. Its multiplication and unit are the identity function on the objects of  .

Monads arising from adjunctions edit

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   (the category of  -algebras).[6]

Double dualization edit

The double dualization monad, for a fixed field k arises from the adjunction

 

where both functors are given by sending a vector space V to its dual vector space  . The associated monad sends a vector space V to its double dual  . This monad is discussed, in much greater generality, by Kock (1970).

Closure operators on partially ordered sets edit

For categories arising from partially ordered sets   (with a single morphism from   to   if and only if  ), then the formalism becomes much simpler: adjoint pairs are Galois connections and monads are closure operators.

Free-forgetful adjunctions edit

For example, let   be the forgetful functor from the category Grp of groups to the category Set of sets, and let   be the free group 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 or 'flattening' of 'strings of strings'. This amounts to two natural transformations. 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. 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  , and which maps linear maps to their tensor product. We then have a natural transformation corresponding to the embedding of   into its tensor algebra, and a natural transformation corresponding to the map from   to   obtained by simply expanding all tensor products.

Codensity monads edit

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 ultrafilters on X. This and similar examples are discussed in Leinster (2013).

Monads used in denotational semantics edit

The following monads over the category of sets are used in denotational semantics of imperative programming languages, and analogous constructions are used in functional programming.

The maybe monad edit

The endofunctor of the maybe or partiality monad adds a disjoint point:[7]

 
 

The unit is given by the inclusion of a set   into  :

 
 

The multiplication maps elements of   to themselves, and the two disjoint points in   to the one in  .

In both functional programming and denotational semantics, the maybe monad models partial computations, that is, computations that may fail.

The state monad edit

Given a set  , the endofunctor of the state monad maps each set   to the set of functions  . The component of the unit at   maps each element   to the function

 
 

The multiplication maps the function   to the function

 
 

In functional programming and denotational semantics, the state monad models stateful computations.

The environment monad edit

Given a set  , the endofunctor of the reader or environment monad maps each set   to the set of functions  . Thus, the endofunctor of this monad is exactly the hom functor  . The component of the unit at   maps each element   to the constant function  .

In functional programming and denotational semantics, the environment monad models computations with access to some read-only data.

The list and set monads edit

The list or nondeterminism monad maps a set X to the set of finite sequences (i.e., lists) with elements from X. The unit maps an element x in X to the singleton list [x]. The multiplication concatenates a list of lists into a single list.

In functional programming, the list monad is used to model nondeterministic computations. The covariant powerset monad is also known as the set monad, and is also used to model nondeterministic computation.

Algebras for a monad edit

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

  and  

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 edit

Algebras over the free group monad edit

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 edit

Another example is the distribution monad   on the category of sets. It is defined by sending a set   to the set of functions   with finite support and such that their sum is equal to  . In set-builder notation, this is the set

 
By inspection of the definitions, it can be shown that algebras over the distribution monad are equivalent to convex sets, i.e., sets equipped with operations   for   subject to axioms resembling the behavior of convex linear combinations   in Euclidean space.[8]

Algebras over the symmetric monad edit

Another useful example of a monad is the symmetric algebra functor on the category of  -modules for a commutative ring  .

 
sending an  -module   to the direct sum of symmetric tensor powers
 
where  . For example,   where the  -algebra on the right is considered as a module. Then, an algebra over this monad are commutative  -algebras. There are also algebras over the monads for the alternating tensors   and total tensor functors   giving anti-symmetric  -algebras, and free  -algebras, so
 
where the first ring is the free anti-symmetric algebra over   in  -generators and the second ring is the free algebra over   in  -generators.

Commutative algebras in E-infinity ring spectra edit

There is an analogous construction for commutative  -algebras[9]pg 113 which gives commutative  -algebras for a commutative  -algebra  . If   is the category of  -modules, then the functor   is the monad given by

 
where
 
 -times. Then there is an associated category   of commutative  -algebras from the category of algebras over this monad.

Monads and adjunctions edit

As was mentioned above, any adjunction gives rise to a monad. Conversely, every monad arises from some adjunction, namely the free–forgetful adjunction

 

whose left adjoint sends an object X to the free T-algebra T(X). However, there are usually several distinct adjunctions giving rise to a monad: let   be the category whose objects are the adjunctions   such that   and whose arrows are the morphisms of adjunctions that are the identity on  . Then the above free–forgetful adjunction involving the Eilenberg–Moore category   is a terminal object in  . An initial object is the Kleisli category, which is by definition the full subcategory of   consisting only of free T-algebras, i.e., T-algebras of the form   for some object x of C.

Monadic adjunctions edit

Given any adjunction   with associated monad T, the functor G can be factored as

 

i.e., G(Y) can be naturally endowed with a T-algebra structure for any Y in D. The adjunction is called a monadic adjunction if the first functor   yields an equivalence of categories between D and the Eilenberg–Moore category  .[10] By extension, a functor   is said to be monadic if it has a left adjoint   forming a monadic adjunction. For example, the free–forgetful adjunction between groups and sets is monadic, since algebras over the associated monad are groups, as was mentioned above. In general, knowing that an adjunction is monadic allows one to reconstruct objects in D out of objects in C and the T-action.

Beck's monadicity theorem edit

Beck's monadicity theorem gives a necessary and sufficient condition for an adjunction to be monadic. A simplified version of this theorem states that G is monadic if it is conservative (or G reflects isomorphisms, i.e., a morphism in D is an isomorphism if and only if its image under G is an isomorphism in C) and C has and G preserves coequalizers.

For example, the forgetful functor from the category of compact Hausdorff spaces to sets is monadic. However the forgetful functor from all topological spaces to sets is not conservative since there are continuous bijective maps (between non-compact or non-Hausdorff spaces) that fail to be homeomorphisms. Thus, this forgetful functor is not monadic.[11] The dual version of Beck's theorem, characterizing comonadic adjunctions, is relevant in different fields such as topos theory and topics in algebraic geometry related to descent. A first example of a comonadic adjunction is the adjunction

 

for a ring homomorphism   between commutative rings. This adjunction is comonadic, by Beck's theorem, if and only if B is faithfully flat as an A-module. It thus allows to descend B-modules, equipped with a descent datum (i.e., an action of the comonad given by the adjunction) to A-modules. The resulting theory of faithfully flat descent is widely applied in algebraic geometry.

Uses edit

Monads are used in functional programming to express types of sequential computation (sometimes with side-effects). See monads in functional programming, and the more mathematically oriented Wikibook module b:Haskell/Category theory.

Monads are used in the denotational semantics of impure functional and imperative programming languages.[12][13]

In categorical logic, an analogy has been drawn between the monad-comonad theory, and modal logic via closure operators, interior algebras, and their relation to models of S4 and intuitionistic logics.

Generalization edit

It is possible to define monads in a 2-category  . Monads described above are monads for  .

See also edit

References edit

  1. ^ Barr, Michael; Wells, Charles (1985), "Toposes, Triples and Theories" (PDF), Grundlehren der mathematischen Wissenschaften, Springer-Verlag, vol. 278, pp. 82 and 120, ISBN 0-387-96115-1.
  2. ^ Klin; Salamanca (2018), "Iterated Covariant Powerset is not a Monad", Electronic Notes in Theoretical Computer Science, 341: 261–276, doi:10.1016/j.entcs.2018.11.013
  3. ^ Mac Lane 1978, p. 138.
  4. ^ Bénabou, Jean (1967). "Introduction to bicategories". In Bénabou, J.; Davis, R.; Dold, A.; Isbell, J.; MacLane, S.; Oberst, U.; Roos, J. -E. (eds.). Reports of the Midwest Category Seminar. Lecture Notes in Mathematics. Vol. 47. Berlin, Heidelberg: Springer. pp. 1–77. doi:10.1007/BFb0074299. ISBN 978-3-540-35545-8.
  5. ^ . Gmane. 2009-04-04. Archived from the original on 2015-03-26.
  6. ^ Riehl, Emily. "Category Theory in Context" (PDF). p. 162. (PDF) from the original on 5 Apr 2021.
  7. ^ Riehl 2017, p. 155.
  8. ^ Świrszcz, T. (1974), "Monadic functors and convexity", Bull. Acad. Polon. Sci. Sér. Sci. Math. Astron. Phys., 22: 39–42, MR 0390019, Jacobs, Bart (2010), "Convexity, Duality and Effects", Theoretical Computer Science, IFIP Advances in Information and Communication Technology, vol. 323, pp. 1–19, doi:10.1007/978-3-642-15240-5_1, ISBN 978-3-642-15239-9
  9. ^ Basterra, M. (1999-12-15). "André–Quillen cohomology of commutative S-algebras". Journal of Pure and Applied Algebra. 144 (2): 111–143. doi:10.1016/S0022-4049(98)00051-6. ISSN 0022-4049.
  10. ^ MacLane (1978) uses a stronger definition, where the two categories are isomorphic rather than equivalent.
  11. ^ MacLane (1978, §§VI.3, VI.9)
  12. ^ Wadler, Philip (1993). "Monads for functional programming". In Broy, Manfred (ed.). Program Design Calculi. NATO ASI Series. Vol. 118. Berlin, Heidelberg: Springer. pp. 233–264. doi:10.1007/978-3-662-02880-3_8. ISBN 978-3-662-02880-3. "The concept of a monad, which arises from category theory, has been applied by Moggi to structure the denotational semantics of programming languages."
  13. ^ Mulry, Philip S. (1998-01-01). "Monads in Semantics". Electronic Notes in Theoretical Computer Science. US-Brazil Joint Workshops on the Formal Foundations of Software Systems. 14: 275–286. doi:10.1016/S1571-0661(05)80241-5. ISSN 1571-0661.

Further reading edit

  • Barr, Michael; Wells, Charles (1999), Category Theory for Computing Science (PDF)
  • Godement, Roger (1958), Topologie Algébrique et Théorie des Faisceaux., Actualités Sci. Ind., Publ. Math. Univ. Strasbourg, vol. 1252, Paris: Hermann, pp. viii+283 pp
  • Kock, Anders (1970), "On Double Dualization Monads", Mathematica Scandinavica, 27: 151, doi:10.7146/math.scand.a-10995
  • Leinster, Tom (2013), "Codensity and the ultrafilter monad", Theory and Applications of Categories, 28: 332–370, arXiv:1209.3606, Bibcode:2012arXiv1209.3606L
  • MacLane, Saunders (1978), Categories for the Working Mathematician, Graduate Texts in Mathematics, vol. 5, doi:10.1007/978-1-4757-4721-8, ISBN 978-1-4419-3123-8
  • Pedicchio, Maria Cristina; Tholen, Walter, eds. (2004). Categorical Foundations. Special Topics in Order, Topology, Algebra, and Sheaf Theory. Encyclopedia of Mathematics and Its Applications. Vol. 97. Cambridge: Cambridge University Press. ISBN 0-521-83414-7. Zbl 1034.18001.
  • Riehl, Emily (2017), Category Theory in Context, Courier Dover Publications, ISBN 9780486820804
  • Turi, Daniele (1996–2001), Category Theory Lecture Notes (PDF)

External links edit

  • Monads, five short lectures (with one appendix).
  • John Baez's This Week's Finds in Mathematical Physics (Week 89) covers monads in 2-categories.
  • Monads and comonads, video tutorial.

monad, category, theory, confused, with, monad, homological, algebra, uses, monads, computer, software, monads, functional, programming, category, theory, branch, mathematics, monad, also, triple, triad, standard, construction, fundamental, construction, monoi. Not to be confused with Monad homological algebra For the uses of monads in computer software see monads in functional programming In category theory a branch of mathematics a monad also triple triad standard construction and fundamental construction 1 is a monoid in the category of endofunctors of some fixed category An endofunctor is a functor mapping a category to itself and a monad is an endofunctor together with two natural transformations required to fulfill certain coherence conditions Monads are used in the theory of pairs of adjoint functors and they generalize closure operators on partially ordered sets to arbitrary categories Monads are also useful in the theory of datatypes the denotational semantics of imperative programming languages and in functional programming languages allowing languages without mutable state to do things such as simulate for loops see Monad functional programming Contents 1 Introduction and definition 1 1 Formal definition 1 2 The power set monad 1 3 Remarks 1 4 Comonads 1 5 Terminological history 2 Examples 2 1 Identity 2 2 Monads arising from adjunctions 2 2 1 Double dualization 2 2 2 Closure operators on partially ordered sets 2 2 3 Free forgetful adjunctions 2 3 Codensity monads 2 4 Monads used in denotational semantics 2 4 1 The maybe monad 2 4 2 The state monad 2 4 3 The environment monad 2 4 4 The list and set monads 3 Algebras for a monad 3 1 Examples 3 1 1 Algebras over the free group monad 3 1 2 Algebras over the distribution monad 3 1 3 Algebras over the symmetric monad 3 1 4 Commutative algebras in E infinity ring spectra 4 Monads and adjunctions 4 1 Monadic adjunctions 4 2 Beck s monadicity theorem 5 Uses 6 Generalization 7 See also 8 References 9 Further reading 10 External linksIntroduction and definition editA monad is a certain type of endofunctor For example if F displaystyle F nbsp and G displaystyle G nbsp are a pair of adjoint functors with F displaystyle F nbsp left adjoint to G displaystyle G nbsp then the composition G F displaystyle G circ F nbsp is a monad If F displaystyle F nbsp and G displaystyle G nbsp are inverse functors the corresponding monad is the identity functor In general adjunctions are not equivalences 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 F G displaystyle F circ G nbsp is discussed under the dual theory of comonads Formal definition edit Throughout this article C displaystyle C nbsp denotes a category A monad on C displaystyle C nbsp consists of an endofunctor T C C displaystyle T colon C to C nbsp together with two natural transformations h 1 C T displaystyle eta colon 1 C to T nbsp where 1 C displaystyle 1 C nbsp denotes the identity functor on C displaystyle C nbsp and m T 2 T displaystyle mu colon T 2 to T nbsp where T 2 displaystyle T 2 nbsp is the functor T T displaystyle T circ T nbsp from C displaystyle C nbsp to C displaystyle C nbsp These are required to fulfill the following conditions sometimes called coherence conditions m T m m m T displaystyle mu circ T mu mu circ mu T nbsp as natural transformations T 3 T displaystyle T 3 to T nbsp here T m displaystyle T mu nbsp and m T displaystyle mu T nbsp are formed by horizontal composition m T h m h T 1 T displaystyle mu circ T eta mu circ eta T 1 T nbsp as natural transformations T T displaystyle T to T nbsp here 1 T displaystyle 1 T nbsp denotes the identity transformation from T displaystyle T nbsp to T displaystyle T nbsp We can rewrite these conditions using the following commutative diagrams nbsp nbsp See the article on natural transformations for the explanation of the notations T m displaystyle T mu nbsp and m T displaystyle mu T nbsp or see below the commutative diagrams not using these notions nbsp nbsp The first axiom is akin to the associativity in monoids if we think of m displaystyle mu nbsp as the monoid s binary operation and the second axiom is akin to the existence of an identity element which we think of as given by h displaystyle eta nbsp Indeed a monad on C displaystyle C nbsp can alternatively be defined as a monoid in the category E n d C displaystyle mathbf End C nbsp whose objects are the endofunctors of C displaystyle C nbsp and whose morphisms are the natural transformations between them with the monoidal structure induced by the composition of endofunctors The power set monad edit The power set monad is a monad P displaystyle mathcal P nbsp on the category S e t displaystyle mathbf Set nbsp For a set A displaystyle A nbsp let T A displaystyle T A nbsp be the power set of A displaystyle A nbsp and for a function f A B displaystyle f colon A to B nbsp let T f displaystyle T f nbsp be the function between the power sets induced by taking direct images under f displaystyle f nbsp For every set A displaystyle A nbsp we have a map h A A T A displaystyle eta A colon A to T A nbsp which assigns to every a A displaystyle a in A nbsp the singleton a displaystyle a nbsp The function m A T T A T A displaystyle mu A colon T T A to T A nbsp takes a set of sets to its union These data describe a monad Remarks edit The axioms of a monad are formally similar to the monoid axioms In fact monads are special cases of monoids namely they are precisely the monoids among endofunctors End C displaystyle operatorname End C nbsp 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 P P displaystyle mathcal P circ mathcal P nbsp does not admit any monad structure 2 Comonads edit The categorical dual definition is a formal definition of a comonad or cotriple this can be said quickly in the terms that a comonad for a category C displaystyle C nbsp is a monad for the opposite category C o p displaystyle C mathrm op nbsp It is therefore a functor U displaystyle U nbsp from C displaystyle C nbsp 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 than monoids however comonoids in the category of vector spaces with its usual tensor product are important and widely studied under the name of coalgebras Terminological history edit The notion of monad was invented by Roger Godement in 1958 under the name standard construction Monad has been called dual standard construction triple monoid and triad 3 The term monad is used at latest 1967 by Jean Benabou 4 5 Examples editIdentity edit The identity functor on a category C displaystyle C nbsp is a monad Its multiplication and unit are the identity function on the objects of C displaystyle C nbsp Monads arising from adjunctions edit Any adjunction F C D G displaystyle F C rightleftarrows D G nbsp gives rise to a monad on C This very widespread construction works as follows the endofunctor is the composite T G F displaystyle T G circ F nbsp This endofunctor is quickly seen to be a monad where the unit map stems from the unit map id C G F displaystyle operatorname id C to G circ F nbsp of the adjunction and the multiplication map is constructed using the counit map of the adjunction T 2 G F G F G counit F G F T displaystyle T 2 G circ F circ G circ F xrightarrow G circ text counit circ F G circ F T nbsp In fact any monad can be found as an explicit adjunction of functors using the Eilenberg Moore category C T displaystyle C T nbsp the category of T displaystyle T nbsp algebras 6 Double dualization edit The double dualization monad for a fixed field k arises from the adjunction V e c t k V e c t k o p displaystyle mathbf Vect k rightleftarrows mathbf Vect k op nbsp where both functors are given by sending a vector space V to its dual vector space V Hom V k displaystyle V operatorname Hom V k nbsp The associated monad sends a vector space V to its double dual V displaystyle V nbsp This monad is discussed in much greater generality by Kock 1970 Closure operators on partially ordered sets edit For categories arising from partially ordered sets P displaystyle P leq nbsp with a single morphism from x displaystyle x nbsp to y displaystyle y nbsp if and only if x y displaystyle x leq y nbsp then the formalism becomes much simpler adjoint pairs are Galois connections and monads are closure operators Free forgetful adjunctions edit For example let G displaystyle G nbsp be the forgetful functor from the category Grp of groups to the category Set of sets and let F displaystyle F nbsp be the free group functor from the category of sets to the category of groups Then F displaystyle F nbsp is left adjoint of G displaystyle G nbsp In this case the associated monad T G F displaystyle T G circ F nbsp takes a set X displaystyle X nbsp and returns the underlying set of the free group F r e e X displaystyle mathrm Free X nbsp The unit map of this monad is given by the maps X T X displaystyle X to T X nbsp including any set X displaystyle X nbsp into the set F r e e X displaystyle mathrm Free X nbsp in the natural way as strings of length 1 Further the multiplication of this monad is the map T T X T X displaystyle T T X to T X nbsp made out of a natural concatenation or flattening of strings of strings This amounts to two natural transformations 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 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 T displaystyle T nbsp is the endofunctor on the category of vector spaces which maps a vector space V displaystyle V nbsp to its tensor algebra T V displaystyle T V nbsp and which maps linear maps to their tensor product We then have a natural transformation corresponding to the embedding of V displaystyle V nbsp into its tensor algebra and a natural transformation corresponding to the map from T T V displaystyle T T V nbsp to T V displaystyle T V nbsp obtained by simply expanding all tensor products Codensity monads edit Under mild conditions functors not admitting a left adjoint also give rise to a monad the so called codensity monad For example the inclusion F i n S e t S e t displaystyle mathbf FinSet subset mathbf Set nbsp does not admit a left adjoint Its codensity monad is the monad on sets sending any set X to the set of ultrafilters on X This and similar examples are discussed in Leinster 2013 Monads used in denotational semantics edit See also Monad functional programming The following monads over the category of sets are used in denotational semantics of imperative programming languages and analogous constructions are used in functional programming The maybe monad edit The endofunctor of the maybe or partiality monad adds a disjoint point 7 S e t S e t displaystyle mathbf Set to mathbf Set nbsp X X displaystyle X mapsto X cup nbsp The unit is given by the inclusion of a set X displaystyle X nbsp into X displaystyle X nbsp h X X X displaystyle eta X X to X nbsp x x displaystyle x mapsto x nbsp The multiplication maps elements of X displaystyle X nbsp to themselves and the two disjoint points in X displaystyle X nbsp to the one in X displaystyle X nbsp In both functional programming and denotational semantics the maybe monad models partial computations that is computations that may fail The state monad edit This section needs expansion with describe multiplication You can help by adding to it February 2023 Given a set S displaystyle S nbsp the endofunctor of the state monad maps each set X displaystyle X nbsp to the set of functions S S X displaystyle S to S times X nbsp The component of the unit at X displaystyle X nbsp maps each element x X displaystyle x in X nbsp to the function h X x S S X displaystyle eta X x S to S times X nbsp s s x displaystyle s mapsto s x nbsp The multiplication maps the function f S S S S X s s f displaystyle f S to S times S to S times X s mapsto s f nbsp to the function m X f S S X displaystyle mu X f S to S times X nbsp s f s displaystyle s mapsto f s nbsp In functional programming and denotational semantics the state monad models stateful computations The environment monad edit This section needs expansion with describe multiplication You can help by adding to it February 2023 Given a set E displaystyle E nbsp the endofunctor of the reader or environment monad maps each set X displaystyle X nbsp to the set of functions E X displaystyle E to X nbsp Thus the endofunctor of this monad is exactly the hom functor H o m E displaystyle mathrm Hom E nbsp The component of the unit at X displaystyle X nbsp maps each element x X displaystyle x in X nbsp to the constant function e x displaystyle e mapsto x nbsp In functional programming and denotational semantics the environment monad models computations with access to some read only data The list and set monads edit This section needs expansion with describe multiplication You can help by adding to it February 2023 The list or nondeterminism monad maps a set X to the set of finite sequences i e lists with elements from X The unit maps an element x in X to the singleton list x The multiplication concatenates a list of lists into a single list In functional programming the list monad is used to model nondeterministic computations The covariant powerset monad is also known as the set monad and is also used to model nondeterministic computation Algebras for a monad editSee also F algebra and pseudoalgebra Given a monad T h m displaystyle T eta mu nbsp on a category C displaystyle C nbsp it is natural to consider T displaystyle T nbsp algebras i e objects of C displaystyle C nbsp acted upon by T displaystyle T nbsp in a way which is compatible with the unit and multiplication of the monad More formally a T displaystyle T nbsp algebra x h displaystyle x h nbsp is an object x displaystyle x nbsp of C displaystyle C nbsp together with an arrow h T x x displaystyle h colon Tx to x nbsp of C displaystyle C nbsp called the structure map of the algebra such that the diagrams nbsp and nbsp commute A morphism f x h x h displaystyle f colon x h to x h nbsp of T displaystyle T nbsp algebras is an arrow f x x displaystyle f colon x to x nbsp of C displaystyle C nbsp such that the diagram nbsp commutes T displaystyle T nbsp algebras form a category called the Eilenberg Moore category and denoted by C T displaystyle C T nbsp Examples edit Algebras over the free group monad edit For example for the free group monad discussed above a T displaystyle T nbsp algebra is a set X displaystyle X nbsp together with a map from the free group generated by X displaystyle X nbsp towards X displaystyle X nbsp subject to associativity and unitality conditions Such a structure is equivalent to saying that X displaystyle X nbsp is a group itself Algebras over the distribution monad edit Another example is the distribution monad D displaystyle mathcal D nbsp on the category of sets It is defined by sending a set X displaystyle X nbsp to the set of functions f X 0 1 displaystyle f X to 0 1 nbsp with finite support and such that their sum is equal to 1 displaystyle 1 nbsp In set builder notation this is the setD X f X 0 1 supp f lt x X f x 1 displaystyle mathcal D X left f X to 0 1 begin matrix text supp f lt infty sum x in X f x 1 end matrix right nbsp By inspection of the definitions it can be shown that algebras over the distribution monad are equivalent to convex sets i e sets equipped with operations x r y displaystyle x r y nbsp for r 0 1 displaystyle r in 0 1 nbsp subject to axioms resembling the behavior of convex linear combinations r x 1 r y displaystyle rx 1 r y nbsp in Euclidean space 8 Algebras over the symmetric monad edit Another useful example of a monad is the symmetric algebra functor on the category of R displaystyle R nbsp modules for a commutative ring R displaystyle R nbsp Sym Mod R Mod R displaystyle text Sym bullet text Mod R to text Mod R nbsp sending an R displaystyle R nbsp module M displaystyle M nbsp to the direct sum of symmetric tensor powersSym M k 0 Sym k M displaystyle text Sym bullet M bigoplus k 0 infty text Sym k M nbsp where Sym 0 M R displaystyle text Sym 0 M R nbsp For example Sym R n R x 1 x n displaystyle text Sym bullet R oplus n cong R x 1 ldots x n nbsp where the R displaystyle R nbsp algebra on the right is considered as a module Then an algebra over this monad are commutative R displaystyle R nbsp algebras There are also algebras over the monads for the alternating tensors Alt displaystyle text Alt bullet nbsp and total tensor functors T displaystyle T bullet nbsp giving anti symmetric R displaystyle R nbsp algebras and free R displaystyle R nbsp algebras soAlt R n R x 1 x n T R n R x 1 x n displaystyle begin aligned text Alt bullet R oplus n amp R x 1 ldots x n text T bullet R oplus n amp R langle x 1 ldots x n rangle end aligned nbsp where the first ring is the free anti symmetric algebra over R displaystyle R nbsp in n displaystyle n nbsp generators and the second ring is the free algebra over R displaystyle R nbsp in n displaystyle n nbsp generators Commutative algebras in E infinity ring spectra edit There is an analogous construction for commutative S displaystyle mathbb S nbsp algebras 9 pg 113 which gives commutative A displaystyle A nbsp algebras for a commutative S displaystyle mathbb S nbsp algebra A displaystyle A nbsp If M A displaystyle mathcal M A nbsp is the category of A displaystyle A nbsp modules then the functor P M A M A displaystyle mathbb P mathcal M A to mathcal M A nbsp is the monad given byP M j 0 M j S j displaystyle mathbb P M bigvee j geq 0 M j Sigma j nbsp whereM j M A A M displaystyle M j M wedge A cdots wedge A M nbsp j displaystyle j nbsp times Then there is an associated category C A displaystyle mathcal C A nbsp of commutative A displaystyle A nbsp algebras from the category of algebras over this monad Monads and adjunctions editAs was mentioned above any adjunction gives rise to a monad Conversely every monad arises from some adjunction namely the free forgetful adjunction T C C T forget displaystyle T C rightleftarrows C T text forget nbsp whose left adjoint sends an object X to the free T algebra T X However there are usually several distinct adjunctions giving rise to a monad let A d j C T displaystyle mathbf Adj C T nbsp be the category whose objects are the adjunctions F G e e displaystyle F G e varepsilon nbsp such that G F e G e F T h m displaystyle GF e G varepsilon F T eta mu nbsp and whose arrows are the morphisms of adjunctions that are the identity on C displaystyle C nbsp Then the above free forgetful adjunction involving the Eilenberg Moore category C T displaystyle C T nbsp is a terminal object in A d j C T displaystyle mathbf Adj C T nbsp An initial object is the Kleisli category which is by definition the full subcategory of C T displaystyle C T nbsp consisting only of free T algebras i e T algebras of the form T x displaystyle T x nbsp for some object x of C Monadic adjunctions edit Given any adjunction F C D G D C h e displaystyle F C to D G D to C eta varepsilon nbsp with associated monad T the functor G can be factored as D G C T forget C displaystyle D stackrel tilde G to C T stackrel text forget to C nbsp i e G Y can be naturally endowed with a T algebra structure for any Y in D The adjunction is called a monadic adjunction if the first functor G displaystyle tilde G nbsp yields an equivalence of categories between D and the Eilenberg Moore category C T displaystyle C T nbsp 10 By extension a functor G D C displaystyle G colon D to C nbsp is said to be monadic if it has a left adjoint F displaystyle F nbsp forming a monadic adjunction For example the free forgetful adjunction between groups and sets is monadic since algebras over the associated monad are groups as was mentioned above In general knowing that an adjunction is monadic allows one to reconstruct objects in D out of objects in C and the T action Beck s monadicity theorem edit Beck s monadicity theorem gives a necessary and sufficient condition for an adjunction to be monadic A simplified version of this theorem states that G is monadic if it is conservative or G reflects isomorphisms i e a morphism in D is an isomorphism if and only if its image under G is an isomorphism in C and C has and G preserves coequalizers For example the forgetful functor from the category of compact Hausdorff spaces to sets is monadic However the forgetful functor from all topological spaces to sets is not conservative since there are continuous bijective maps between non compact or non Hausdorff spaces that fail to be homeomorphisms Thus this forgetful functor is not monadic 11 The dual version of Beck s theorem characterizing comonadic adjunctions is relevant in different fields such as topos theory and topics in algebraic geometry related to descent A first example of a comonadic adjunction is the adjunction A B M o d A M o d B forget displaystyle otimes A B mathbf Mod A rightleftarrows mathbf Mod B operatorname forget nbsp for a ring homomorphism A B displaystyle A to B nbsp between commutative rings This adjunction is comonadic by Beck s theorem if and only if B is faithfully flat as an A module It thus allows to descend B modules equipped with a descent datum i e an action of the comonad given by the adjunction to A modules The resulting theory of faithfully flat descent is widely applied in algebraic geometry Uses editMonads are used in functional programming to express types of sequential computation sometimes with side effects See monads in functional programming and the more mathematically oriented Wikibook module b Haskell Category theory Monads are used in the denotational semantics of impure functional and imperative programming languages 12 13 In categorical logic an analogy has been drawn between the monad comonad theory and modal logic via closure operators interior algebras and their relation to models of S4 and intuitionistic logics Generalization editIt is possible to define monads in a 2 category C displaystyle C nbsp Monads described above are monads for C C a t displaystyle C mathbf Cat nbsp See also editDistributive law between monads Lawvere theory Monad functional programming Polyad Strong monadReferences edit Barr Michael Wells Charles 1985 Toposes Triples and Theories PDF Grundlehren der mathematischen Wissenschaften Springer Verlag vol 278 pp 82 and 120 ISBN 0 387 96115 1 Klin Salamanca 2018 Iterated Covariant Powerset is not a Monad Electronic Notes in Theoretical Computer Science 341 261 276 doi 10 1016 j entcs 2018 11 013 Mac Lane 1978 p 138 sfn error no target CITEREFMac Lane1978 help Benabou Jean 1967 Introduction to bicategories In Benabou J Davis R Dold A Isbell J MacLane S Oberst U Roos J E eds Reports of the Midwest Category Seminar Lecture Notes in Mathematics Vol 47 Berlin Heidelberg Springer pp 1 77 doi 10 1007 BFb0074299 ISBN 978 3 540 35545 8 RE Monads Gmane 2009 04 04 Archived from the original on 2015 03 26 Riehl Emily Category Theory in Context PDF p 162 Archived PDF from the original on 5 Apr 2021 Riehl 2017 p 155 Swirszcz T 1974 Monadic functors and convexity Bull Acad Polon Sci Ser Sci Math Astron Phys 22 39 42 MR 0390019 Jacobs Bart 2010 Convexity Duality and Effects Theoretical Computer Science IFIP Advances in Information and Communication Technology vol 323 pp 1 19 doi 10 1007 978 3 642 15240 5 1 ISBN 978 3 642 15239 9 Basterra M 1999 12 15 Andre Quillen cohomology of commutative S algebras Journal of Pure and Applied Algebra 144 2 111 143 doi 10 1016 S0022 4049 98 00051 6 ISSN 0022 4049 MacLane 1978 uses a stronger definition where the two categories are isomorphic rather than equivalent MacLane 1978 VI 3 VI 9 Wadler Philip 1993 Monads for functional programming In Broy Manfred ed Program Design Calculi NATO ASI Series Vol 118 Berlin Heidelberg Springer pp 233 264 doi 10 1007 978 3 662 02880 3 8 ISBN 978 3 662 02880 3 The concept of a monad which arises from category theory has been applied by Moggi to structure the denotational semantics of programming languages Mulry Philip S 1998 01 01 Monads in Semantics Electronic Notes in Theoretical Computer Science US Brazil Joint Workshops on the Formal Foundations of Software Systems 14 275 286 doi 10 1016 S1571 0661 05 80241 5 ISSN 1571 0661 Further reading editBarr Michael Wells Charles 1999 Category Theory for Computing Science PDF Godement Roger 1958 Topologie Algebrique et Theorie des Faisceaux Actualites Sci Ind Publ Math Univ Strasbourg vol 1252 Paris Hermann pp viii 283 pp Kock Anders 1970 On Double Dualization Monads Mathematica Scandinavica 27 151 doi 10 7146 math scand a 10995 Leinster Tom 2013 Codensity and the ultrafilter monad Theory and Applications of Categories 28 332 370 arXiv 1209 3606 Bibcode 2012arXiv1209 3606L MacLane Saunders 1978 Categories for the Working Mathematician Graduate Texts in Mathematics vol 5 doi 10 1007 978 1 4757 4721 8 ISBN 978 1 4419 3123 8 Pedicchio Maria Cristina Tholen Walter eds 2004 Categorical Foundations Special Topics in Order Topology Algebra and Sheaf Theory Encyclopedia of Mathematics and Its Applications Vol 97 Cambridge Cambridge University Press ISBN 0 521 83414 7 Zbl 1034 18001 Riehl Emily 2017 Category Theory in Context Courier Dover Publications ISBN 9780486820804 Turi Daniele 1996 2001 Category Theory Lecture Notes PDF External links editMonads five short lectures with one appendix John Baez s This Week s Finds in Mathematical Physics Week 89 covers monads in 2 categories Monads and comonads video tutorial Retrieved from https en wikipedia org w index php title Monad category theory amp oldid 1204289686 Algebras for a monad, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.