Demystifying Codensity Monads via Duality
Abstract
Codensity monads provide a universal method to generate complex monads from simple functors. Recently, a wide range of important monads in logic, denotational semantics, and probabilistic computation, such as several incarnations of the ultrafilter monad, the Vietoris monad, and the Giry monad, have been presented as codensity monads, using complex arguments. We propose a unifying categorical approach to codensity presentations of monads, based on the idea of relating the presenting functor to a dense functor via a suitable duality between categories. We prove a general presentation result applying to every such situation and demonstrate that most codensity presentations known in the literature emerge from this strikingly simple duality-based setup, drastically alleviating the complexity of their proofs and in many cases completely reducing them to standard duality results. Additionally, we derive a number of novel codensity presentations using our framework, including the first non-trivial codensity presentations for the filter monads on sets and topological spaces, the lower Vietoris monad on topological spaces, and the expectation monad on sets.
Keywords and phrases:
Codensity, Monad, DualityFunding:
Fabian Lenke: Supported by Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – project number 470467389.Copyright and License:
2012 ACM Subject Classification:
Theory of computation Models of computationAcknowledgements:
The authors wish to thank Nathanel Arkor for pointing out the connection between our Theorem 3.2 and the recent work by Doña Mateo [32] (˜3.3).Editors:
Meena Mahajan, Florin Manea, Annabelle McIver, and Nguyễn Kim ThắngSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
Monads are among the most fundamental concepts of category theory. They provide a common abstraction of algebraic theories [31] and notions of computation [33], and the tight interplay between both viewpoints has inspired decades of fruitful research in theoretical computer science. While monads and their underlying structure can be defined from scratch, it is often simpler and more informative to generate monads via a universal construction. A powerful method to do so has been discovered by Kock [28] in the 1960s: Every functor canonically induces a monad on the category , the codensity monad of , provided only that certain limits in exist. It is constructed via the right Kan extension of along itself and generalizes the familiar construction of monads from adjunctions. The prototypical example is the ultrafilter monad on the category of sets (whose algebras are compact Hausdorff spaces [31]), which has been characterized as the codensity monad of the inclusion of the category of finite sets into sets [27]. Generally, while every monad can be presented as the codensity monad of some functor (e.g. the forgetful functor of its Eilenberg-Moore category), the goal is to come up with the simplest possible presentation.
In recent years, codensity monads have found a growing number of applications in computer science; in particular, they have been identified as an elegant categorical underpinning of profinite methods in automata theory [7, 41, 15, 1], program optimizations in functional languages [18], and the construction of liftings of monads along fibrations relevant in type theory [26]. Furthermore, a number of key monads appearing in logic, denotational semantics, and probabilistic computation have been presented as codensity monads, most notably generalizations of the ultrafilter monad to algebraic and topological categories [29, 3], the Vietoris hyperspace monad on Stone spaces [15], and probability monads such as the all-important Giry monad on measurable spaces and many of its variants [5, 42, 36, 37]. The importance of such codensity presentations is that they relate the given (fairly complex) monads to structurally much simpler generating functors and endow those monads with a universal property. This provides new insights into the structure of the monads themselves, facilitating their use in theory and practice. For example, desirable properties of probability monads such as commutativity or affinity, which are instrumental in the synthetic approach to probability theory based on Markov categories [8, 11] or effectuses [21], and somewhat tedious to prove directly, can be derived in a principled manner from their codensity presentation [37].
All the above codensity presentations are non-trivial results. Their proofs in the literature rely on a careful analysis of the structure of the respective monads and on domain-specific knowledge, such as advanced results from measure theory for probability monads. Overall, this leads to technically challenging and largely ad hoc proofs of codensity presentations.
In the present paper, we address this issue by developing a simple, general and uniform method to synthesize codensity presentations of monads, putting a common umbrella over most known instances, and many more. The core insight underlying our contribution is that
More specifically, our approach to codensity monads rests on a simple but effective
observation: all “interesting” codensity presentations (where is the codensity
monad of some functor )
follow the pattern shown in diagram
(1.1), that is, the functor decomposes as into a dual equivalence , the opposite of a
dense functor , and a contravariant right adjoint
generating the monad . For instance, the presentation of the ultrafilter monad as the
codensity monad of the inclusion functor is captured by diagram (1.2). Here we use the familiar duality between finite Boolean algebras and finite sets, and density of the inclusion functor
is the standard fact that every Boolean algebra is a canonical colimit of finite
Boolean algebras.
| (1.1) |
| (1.2) |
Such a decomposition, which we call a codensity setting, is all that is needed to get a codensity presentation of the monad . Our main result (Theorem 3.2) states that:
In every codensity setting (1.1), the monad is the codensity monad of the functor .
While not technically difficult, this theorem is the conceptual gist behind most known codensity presentations of monads. In fact, it can be used in two different ways: to characterize the codensity monad of a given functor , and conversely, to discover a simple functor presenting a given monad as a codensity monad. In both cases, it simplifies the proofs of codensity presentations by reducing a question regarding codensity to one about density. Formally these are of course dual concepts, but in practice density is well-understood, especially in algebraic contexts, and usually follows from general results, while codensity rarely occurs when working with “everyday” categories of algebras or spaces.
We demonstrate the strength and scope of our main theorem by deriving codensity presentations for a wide variety of different monads. Our applications not only cover most codensity presentations known in the literature, including all of the monads mentioned above [29, 3, 15, 42, 36, 27, 5, 37], but also several new examples, notably the first non-trivial codensity presentations for the filter monads on sets and topological spaces, for the (lower) Vietoris hyperspace monad on topological spaces, and for the expectation monad on sets. In all these cases, establishing the codensity presentation boils down to simply instantiating our theorem to a suitable codensity setting (1.1). Much like in the setting (1.2) for the ultrafilter monad, the choice of the duality and of the dense functor is usually fairly obvious and suggested by standard results on the corresponding algebraic categories, and the chosen dualities are very basic ones between categories of finite algebras or categories of relations.
For all monads with a known codensity presentation covered in our paper, the principled and modular nature of our approach leads to proofs that are dramatically shorter and more transparent compared to those found in the original literature. In fact, a lot of the complexity of the latter can be attributed to the fact that the authors (implicitly) rediscover the arguments underlying the duality and density results appearing in the respective instantiation of (1.1). By applying our categorical framework, we can instead appeal to well-known properties of the respective categories and get this work entirely for free. In this way, all our codensity presentations of (ultra)filter and Vietoris-type monads become an essentially straightforward instance of our main theorem. For probability monads like the Giry monad, the (only) non-straightforward part lies in identifying a suitable dual adjunction inducing the given monad, which requires representation theorems relating linear functionals to probability measures. This identifies precisely the part of the reasoning where measure theory is needed.
2 Categorical Background
We assume some familiarity with basic category theory [30], such as equivalence functors, (co)limits, adjunctions, and monads. In the following we introduce the notation used in the paper, and review the key concepts of (co)dense functors and codensity monads.
Monads.
Recall that a monad on category is given by an endofunctor on and two natural transformations, the unit and the multiplication , satisfying the usual unit and associative laws. We denote by the Kleisli category for ; its objects are those of , and morphisms from to are morphisms with the usual Kleisli composition. Moreover, we write for the Eilenberg-Moore category for , the category of -algebras and their morphisms. The category comes with a forgetful functor mapping to and a Kleisli morphism to . Moreover, there is a full embedding given by and that identifies the Kleisli category with the full subcategory of given by free -algebras. For a monad on , the category of sets and functions, we write for the full subcategory of given by finite sets, or equivalently, the category of finitely generated free -algebras. We denote the domain restrictions of the above functors also by and .
Algebraic Categories.
One important class of monads are free-algebra monads on . Every algebraic theory , specified by signature a of finitary operation symbols and a set of equations between -terms, induces a monad on which maps to each set the free -algebra generated by , carried by the set of -terms modulo equations. The category is isomorphic to the category of all -algebras. The monad is finitary (i.e. preserves directed colimits), and conversely, every finitary monad on is induced by some algebraic theory. In fact, all monads on have an algebraic presentation by operations and equations, provided that large signatures and infinitary operations are admitted. For example, the category of algebras for the finite power set monad is isomorphic the category of join-semilattices with bottom (equivalently, the category of meet-semilattices with top). The full power set monad yields the category of complete (semi)lattices and join-preserving maps. We tacitly identify isomorphic categories; for instance, the functor is identified with the functor sending a set to the free complete semilattice . See Manes [31] for more background on the relation between monads and algebraic theories.
Dual Adjunctions.
Another natural source of monads are adjunctions. We use the notation , or simply , for an adjunction where has a right adjoint . Every adjunction with unit and counit induces a monad on . We denote this monad by , leaving the structure implicit.
A dual adjunction is an adjunction of type . Many dual adjunctions of interest are given by dualizing objects [24, Sec. VI.4], that is, and are concrete categories (with respective forgetful functors to ), and there are objects and with
Then the induced monad is given by a “double hom-set” construction. For example, the dual adjunction where yields the neighbourhood monad on . Similarly, by reading as a Boolean algebra, we obtain a dual adjunction between the categories of sets and Boolean algebras that induces the ultrafilter monad. Both monads are studied in detail in Section 4.
Dense Functors.
Given a functor and , the slice category has as objects all morphisms for , and a morphism from to is a morphism of with . There is an obvious projection
The functor is dense [14] if each is the colimit of the (possibly large) diagram , with cocone (). Equivalently, the functor given by is fully faithful. (Here is the possibly superlarge category of functors between categories and and natural transformations.) A subcategory is dense if its inclusion is dense. Informally, this says that each object of can be canonically built from objects of .
Example 2.1.
In most of our applications, we will consider dense full subcategories of for a monad on . There are several generic choices of such subcategories:
-
1.
The full subcategory of free algebras is dense.
-
2.
If is finitary, the full subcategory of finitely generated free algebras is also dense. Moreover, if there is an algebraic theory presenting the monad with an upper bound to the arities of operations, the one-object full subcategory given by the free algebra on generators is dense [19, Sec. 2.2].
-
3.
If is finitary, another dense full subcategory is given by the finitely presentable algebras (i.e. algebras presentable by finitely many generators and relations). This follows from the fact that is locally finitely presentable [2, Cor. 3.7] and that in any such category the finitely presentable objects form a dense subcategory [2, Ex. 1.24.1]. Note that in the case where the monad preserves finite sets, coincides with the full subcategory of finite algebras.
Example 2.2.
For every small category , the Yoneda embedding given by is dense [30, Sec. III.7, Thm. 1].
Dual to density, we have the notion of a codense functor : every object is the limit of the canonical diagram of all morphisms with .
Notation 2.3.
For and as above and , we write
for the colimit of the diagram ; similarly for limits.
Kan Extensions.
The right Kan extension of a functor along a functor is given by a functor and a bijection
| (2.1) |
natural in . Concretely, this means that there is natural transformation (called the counit) such that every natural transformation factorizes as
| (2.2) |
If the limit below exists for all , the right Kan extension is given by
| (2.3) |
This holds, for instance, if the category is small and is complete. Right Kan extensions of this type are called pointwise. All Kan extensions emerging in our applications are pointwise.
Codensity Monads.
The codensity monad [28] of a functor is the monad
where is the right Kan extension of along itself (if it exists), and the unit and multiplication are the natural transformations corresponding to the natural transformations below, where is the counit of :
If the Kan extension is pointwise, then . Moreover, the action of on a morphism and the unit and multiplication at are uniquely determined by the commutative diagrams below, where ranges over all with and is the corresponding limit projection:
A codensity presentation of a monad on is a functor such that the monad is isomorphic to the monad (in the usual category of monads and monad morphisms).
Remark 2.4.
-
1.
The codensity monad may be seen as a measure of codensity of the functor ; indeed, is codense if and only if its codensity monad is the identity monad.
-
2.
The construction of codensity monads generalizes the construction of monads from adjunctions: If has a left adjoint , the codensity monad of exists and is isomorphic to the induced monad [29]. In particular, since every monad arises from an adjunction, every monad is a codensity monad. This means that the challenge is not to find some codensity presentation of a given monad, but rather to find a simple and natural one.
3 Codensity Monads = Density + Duality
In this section we present our core technical result, a simple and general criterion for a monad induced by a given dual adjunction to be the codensity monad of a given functor. The following setting generalizes a common pattern: a dual adjunction between two categories restricting to an adjoint equivalence of certain subcategories.
Definition 3.1 (Codensity Setting).
A codensity setting is given by categories and functors as in diagram (3.1), where (1) is left adjoint to , (2) is an equivalence, (3) is dense, and (4) the outside commutes up to natural isomorphism ().
| (3.1) |
The adjunction of a codensity setting induces a monad, and the decomposition of the functor is enough to deduce that is a codensity presentation of that monad:
Theorem 3.2.
In every codensity setting (3.1), the codensity monad of the functor exists, is pointwise, and is isomorphic to the monad induced by the adjunction :
Below we sketch an elementary proof of this theorem via computations of (co)limits. Two more conceptual arguments based on general properties of Kan extensions and on string diagrams, respectively, can be found in the full arXiv paper.
Proof sketch.
We have the following isomorphisms natural in :
| dense | ||||
| right adjoints preserve limits | ||||
| equivalence functor | ||||
This proves that is pointwise and that as functors. A routine verification shows that this is an isomorphism of monads, i.e. the unit and multiplication are preserved.
Remark 3.3.
Theorem 3.2 is related to a recent result by Doña Mateo [32, Prop. 2.15] who independently proved that for every composite of a codense functor and a right adjoint , the codensity monad of is the monad induced by . Theorem 3.2 corresponds to the setting where is an inverse equivalence of . Thus, it adds to Doña Mateo’s abstract result the crucial insight that the codense functor should in practice be decomposed into a dual equivalence and the opposite of a dense functor.
Remark 3.4.
-
1.
Every codensity monad has a codensity setting: for any functor with small its codensity monad is induced by the conerve-totalization adjunction
(3.2) where is the conerve and its right adjoint is the right Kan extension of along the contravariant Yoneda embedding . The Yoneda embedding is dense, and the adjunction induces by definition [29, Section 2].
-
2.
Di Liberti [10] showed that if one additionally assumes density of and cocompleteness of the adjunction (3.2) factorizes through Isbell’s dual adjunction between presheaves and copresheaves over . While this result is conceptually interesting (especially for the algebras of such codensity monads) it does not simplify finding concrete codensity presentations without substantial additional effort. Besides, for a wide class of codensity presentations we consider, for example for probability monads (see Section 6), the density assumption is not satisfied.
In the following sections, we will illustrate the wide scope of Theorem 3.2 and use it to derive codensity presentations for a number of popular monads. To show that a given monad on is the codensity monad of a functor , we employ a uniform recipe:
-
1.
Identify a suitable dual adjunction inducing the monad .
-
2.
Extend the functor and the adjunction to a codensity setting (3.1).
-
3.
Apply Theorem 3.2 to conclude .
In all our applications, the crucial (and sometimes non-trivial) step is the choice of the dual adjunction in Step 1. Then Step 2 is typically straightforward: The functor in (3.1) is given by some simple dual equivalence known in the literature, and likewise the density of the functor amounts to some standard property of the category .
4 Ultrafilter and Double Dualization Monads
The first class of codensity monads that we cover as instances of Theorem 3.2 are (ultra)filter monads and their close relatives, double dualization monads [29, 3, 10, 27].
4.1 Ultrafilter Monads
We start with what is probably the best known instance of a codensity monad: the characterization of the ultrafilter monad on as the codensity monad of the inclusion of finite sets into sets. This classical result goes back to Kennison and Gildenhuys [27]; see also Leinster [29] for a streamlined exposition.
Let denote the category of Boolean algebras. An ultrafilter on a Boolean
algebra is a subset such that (1) is upwards closed, (2) is
closed under meet, and (3) for every , either or . Equivalently, an ultrafilter is given by a morphism , where
is the two-element Boolean algebra, by identifying with the preimage
. An ultrafilter on a set is an ultrafilter on the
Boolean algebra of predicates (equivalently subsets) of . The
ultrafilter monad on sends a set to the set of
of its ultrafilters; more precisely, is the monad induced by the adjunction in (4.1) below.
The category of algebras for is isomorphic to the category of compact Hausdorff spaces and continuous maps [31, 1.5.24–33]; hence the ultrafilter monad provides a bridge between algebra, Boolean logic, and topology.
The ultrafilter monad is captured by codensity setting (4.1) shown below on the left:
| (4.1) |
| (4.2) |
Here and are the inclusions of the full subcategories of finite sets and finite Boolean algebras, respectively, and the equivalence functor on the left is the restriction of Birkhoff duality [6] between distributive lattices and finite posets to finite sets (discrete posets). The functor is dense by Example 2.1.3; note that since the free Boolean algebra on a finite set is finite, we have . From Theorem 3.2 we obtain:
Theorem 4.1 (Kennison and Gildenhuys [27]).
The ultrafilter monad on is the codensity monad of the inclusion .
A similar result was given by Sipoş [38] for the ultrafilter monad on the category of topological spaces and continuous maps assigning to a space the space of ultrafilters of clopens; that is, is the monad given by the adjunction in (4.2). Here is the two-element discrete space, is the Boolean algebra of clopen subsets of a space , and is the space of ultrafilters of a Boolean algebra , viewed as subspace of the space equipped with the product topology. Algebras for correspond to Stone spaces (compact Hausdorff spaces with a basis of clopens) [38].
To capture the topological ultrafilter monad in our setting, we just use in lieu of in (4.1), which leads to the codensity setting (4.2). Here identifies a finite set with a discrete topological space. From Theorem 3.2 we obtain:
Theorem 4.2 (Sipoş [38]).
The ultrafilter monad on is the codensity monad of the inclusion .
4.2 Filter Monads
A natural generalization of ultrafilter monads are filter monads. They are captured in our setting as well by working with semilattices in lieu of Boolean algebras.
In more detail, let denote the category of meet-semilattices with a top element
(equivalently, algebras for the finite power set monad ). A filter on a
meet-semilattice is a non-empty subset
that is both upwards closed and closed under meets. A filter corresponds to morphism , where is the
two-element semilattice with the meet given by minimum, by identifying with the
preimage . A filter on a set
is a filter on the semilattice . The filter monad on
sends a set to the set of of its filters; that is, is the monad induced by the adjunction in (4.3). Algebras for correspond to complete lattices where finite meets distribute over directed joins [9]. Two suitable codensity settings for are given below:
| (4.3) |
| (4.4) |
In setting (4.3), is the forgetful functor, and is the dense inclusion (Example 2.1.3), where we use that (viewing as the algebraic category of commutative idempotent monoids) and that finitely presentable semilattices coincide with the finite ones. Moreover, we make use of the self-duality of finite meet-semilattices [24, Sec. VI.3.6], which maps a finite meet-semilattice to the semilattice of its filters, with the semilattice structure defined pointwise. This codensity setting restricts to (4.4); to see this, first recall the functors and from Section 2 (p. 2, “Monads”) and that is dense (Example 2.1.2). (Note that it maps a set to equipped with as the binary operation.) Here is the standard identity-on-objects self-duality of the category of finite sets and relations, sending to given by . The outer square clearly commutes since both take the preimage of under .
From Theorem 3.2 we obtain two novel codensity presentations of the filter monad:
Theorem 4.3.
The filter monad on is the codensity monad of the forgetful functors and .
Similar to the ultrafilter monad, this reasoning carries over from to suitable topological categories. For example, the filter monad on is given by , that is, is induced by the adjunction in the diagram below. Here is the Sierpinski space carried by with open sets , , , and the set is topologized as a subspace of the product space . As open subsets of a space correspond to continuous maps from to , the monad sends to the space of filters of open sets. Algebras for carried by spaces correspond to continuous lattices [9]. To capture as a codensity monad, we modify the codensity setting (4.4) to the one shown below. Here we regard the functor from (4.3) as a functor to by identifying with the topological space .
From Theorem 3.2 we obtain a novel codensity presentation of :
Theorem 4.4.
The filter monad on is the codensity monad of the functor sending to .
4.3 Double Dualization Monads
Another interesting class of codensity monads that naturally emerge in our framework are certain double dualization monads, which are monads given by dual adjunctions as shown in the first diagram below, where is a symmetric monoidal closed category, is a fixed object of , and denotes the internal hom object of .
The other three adjunctions above are concrete instances. Here is the category of vector spaces over a field and
linear maps, and is the dual space of a space with pointwise
structure. The induced monads are the neighbourhood monad on (whose
algebras are complete atomic Boolean algebras [31, 1.5.17–23]), the monad on
sending a semilattice to its semilattice of filters of
filters, and the monad sending a vector space to its double dual space (whose algebras are linearly compact vector spaces [29, Thm. 7.8]).
Suitable codensity settings for these three monads are given as follows:
Here denotes the forgetful functor, is the full subcategory of given by finite dimensional vector spaces, and the functors are inclusion functors, which are dense (Example 2.1.3). In the first two diagrams we use the dualities and encountered before, and in the third one we use the familiar self-duality of the category of finite dimensional vector spaces, which amounts to the fact that every such space is naturally isomorphic to its double dual. All three diagrams clearly commute.
From Theorem 3.2 we obtain the following codensity presentations; the first appears to be new, the second is due to Adámek and Sousa [3], and the third due to Leinster [29].
Theorem 4.5.
-
1.
The neighbourhood monad on is the codensity monad of .
-
2.
The double dualization monad on is the codensity monad of .
-
3.
The double dualization monad on is the codensity monad of .
The last item readily generalizes to modules over a commutative semiring , where in lieu of one takes finitely generated free -modules. Note that all vector spaces are free.
For a slightly more intricate example, we consider the category of abelian groups and as the dualizing object the circle group , a subgroup of the multiplicative group of non-zero complex numbers. It forms a (compact Hausdorff) topological group w.r.t. the Euclidian topology on . A suitable codensity setting is given by:
While all previous examples are based on simple dualities, we now use a corollary of a more advanced duality result: (discrete) Pontryagin duality [35, 34], the dual equivalence between and the category of compact Hausdorff abelian groups and continuous group morphisms. The equivalence sends an abelian group to the topological group of all group morphisms into , topologized as a subspace of . Under this duality, the additive group (the free abelian group on two generators) corresponds to the torus , since
Thus, we see that Pontryagin duality restricts to a dual equivalence between the one-object full subcategories and . The functor is the composition of the inclusion with the forgetful functor to . The inclusion is dense (Example 2.1.2), and the outside of the diagram commutes, since Pontryagin duality is given by the functor . From Theorem 3.2 we obtain the following new result:
Theorem 4.6.
The double dualization monad on (with respect to the dualizing object ) is the codensity monad of the above forgetful functor .
4.4 Isbell Duality
We conclude this section with an example of a more abstract nature: for every small category , the codensity monad of the Yoneda embedding is the monad given by Isbell duality [19]. This result due to Kock [28] originally motivated the introduction of codensity monads. Recall that Isbell duality is the dual adjunction in (4.5) between the categories of contravariant and covariant presheaves on defined by
The two Yoneda embeddings and give rise to the codensity setting shown below:
| (4.5) |
Indeed, the embedding is dense (Example 2.2), and the outside of the diagram commutes up to isomorphism by the Yoneda lemma: for all objects , we have
From Theorem 3.2 we obtain:
5 Vietoris Monads
As another important class of codensity monads, we study monads on categories of topological spaces that associate to a given space a suitably topologized space of interesting subsets.
5.1 The Vietoris Monad on Stone Spaces
We start with the Vietoris monad on the category of Stone spaces and continuous maps. The Vietoris space of a Stone space is given by the set of all closed subsets of equipped with the hit-or-miss topology, which has the following subbasic open sets:
We can represent as a double dual space as follows. Let be the category of
join-semilattices with bottom. Morphisms from to the join-semilattice (with
join given by maximum) correspond to ideals: non-empty subsets of that are downwards
closed and closed under join. The set of ideals is topologized as a subspace of
the product space , where carries the discrete topology. We then have the
isomorphism
which identifies a closed set with the ideal of all clopen sets
with (i.e. ). The object mapping
thus naturally extends to a monad,
for which the appropriate codensity setting is given by (5.1):
| (5.1) |
| (5.2) |
Here from (4.4) is lifted to , identifying with the discrete space . The functor is the dense inclusion (Example 2.1.2), using . Commutativity of (5.1) is shown like for (4.4). From Theorem 3.2 we obtain:
Theorem 5.1 (Gehrke, Petrişan, Reggio [15]).
The Vietoris monad on is the codensity monad of the functor .
5.2 The Lower Vietoris Monad on Topological Spaces
By varying the ingredients of the above setting a bit, codensity presentations for other Vietoris-type monads emerge easily. Here we consider the lower Vietoris monad, a.k.a. Hoare hyperspace monad [12], on the category of topological spaces. Given a topological space , the lower Vietoris space is the topological space of all closed subsets of with the topology generated by the subbasic open sets (as defined above) for open. Similar to , we can represent as a double dual space. Let be the category of complete join-semilattices and join-preserving maps (i.e. algebras for the power set monad ). Morphisms in from to correspond to complete ideals: subsets of that are downwards closed and closed under arbitrary joins. The set of all complete ideals is topologized as a subspace of the product space . We then have where the isomorphism identifies a closed set with the complete ideal of all open sets with . Thus, the object mapping extends to a monad, whose codensity setting is given by (5.2). Note that this setup is very similar to the filter monad on from Section 4.2, except that we now work with complete join-semilattices in lieu of (finitary) meet-semilattices and with the full Kleisli category for the monad in lieu of its finite restriction. The canonical functor is taken as a functor to by identifying with the topological space , and is the dense inclusion (Example 2.1.1), using that . The outside commutes analogously to (5.1). From Theorem 3.2 we obtain the following new result:
Theorem 5.2.
The lower Vietoris monad on is the codensity monad of .
5.3 The Sobrification Monad on Topological Spaces
Just like Stone spaces correspond to algebras for the filter monad on (Section 4.2), the well-studied subcategory of sober spaces [20, 24] is captured by the sobrification monad, introduced by Sipoş [38]. It emerges in our framework by working with frames in lieu of meet-semilattices. Recall that a frame is a poset which has all finite meets and all joins and which satisfies the infinite distributive law for all , . We denote by the category of frames and maps preserving finite meets and all joins. It is isomorphic to the category of algebras for the free frame monad on sending a set to the set of upwards closed subsets of [25, C1.1, Lem. 1.1.3].
The sobrification monad on is given by ; more precisely, is the monad induced by the dual adjunction in (5.3). Sipoş [38] has shown that algebras for correspond to sober spaces and has given a codensity presentation of this monad, which in our duality-based framework corresponds to the codensity setting given by:
| (5.3) |
Here is the inclusion of the full subcategory of consisting of powers , where is any set, and is the canonical dense inclusion functor from Example 2.1.1. The equivalence functor and commutation of the diagram are given by the following lemma.
Lemma 5.3.
The object mapping defines a dual equivalence between the Kleisli category and the full subcategory .
From Theorem 3.2 we obtain:
Theorem 5.4 (Sipoş [38]).
The sobrification monad on is the codensity monad of the embedding .
6 Probability Monads
Finally, we investigate monads of interest in probabilistic and quantum computation, and give a uniform treatment of their codensity presentations based on restrictions of the Kleisli category of the (countable) distribution monad as suggested in the work of Shirazi [37]. As noted by van Belle [42], integral representation theorems play a key role in such presentations, and we show that in order to apply our framework, they are in fact the only non-trivial part.
6.1 The Expectation Monad
We start with the expectation monad [44, 23], a probability monad that has recieved a lot of attention in recent years, e.g. in quantum foundations. A finitely additive probability measure on a set is a finitely additive probability measure on the discrete measurable space , that is, a map with and for disjoint . If is finite, then every finitely additive probability measure on is discrete: recall that a discrete finite probability measure on is a map with and for all but finitely many . We denote the set of finitely additive probability measures on a set by , and the set of discrete finite probability measures by . For the codensity presentation of the expectation monad we embed these notions into an algebraic setting given by effect algebras and effect modules [22, 17].
An effect algebra is a partial commutative monoid together with an operator satisfying that is the unique element in with , where , and is defined iff . Morphisms of effect algebras preserve all this structure, forming a category . The unit interval forms an effect algebra with defined if , and . Boolean algebras form a full subcategory of effect algebras, with defined whenever , and . The following non-trivial density result, which is not covered by Example 2.1, is due to Staton and Uijlen [39, Cor. 10]:
Proposition 6.1.
The inclusion is dense.
Effect algebras carry a monoidal structure such that represents bilinear morphisms [22], analogous to commutative monoids, with tensor unit . The unit interval with multiplication forms a monoid for this monoidal structure.
An effect module is an effect algebra that is a -module for this tensor product, that is, is equipped with a bilinear map of effect algebras. Effect module morphisms are effect algebra morphisms preserving the action, forming a category . Its forgetful functor to has a left adjoint . This adjunction yields a monad on given by . On finite Boolean algebras we have . We extend the density result from ˜6.1 to effect modules, where we denote the full subcategory of on finite Boolean algebras by :
Proposition 6.2.
The inclusion , , is dense.
Finitely additive probability measures on a set correspond to effect algebra morphisms from to , that is, . They also correspond to effect module morphisms from to , which is the content of the following discrete integral representation theorem [23, Prop. 33]:
Theorem 6.3.
For every set , there is a natural bijection
The bijection sends to the measure with , where is the characteristic map of given by if , and if .
We thus define the expectation monad on by ; more precisely, is given by the adjunction in the codensity setting below:
The inclusion is dense by ˜6.2 and the outer square commutes since . The duality of the left extends the duality . Indeed, for we have the following natural bijection:
From Theorem 3.2 we obtain a novel codensity presentation of :
Theorem 6.4.
The expectation monad is the codensity monad of .
Remark 6.5.
The expectation functor has a much simpler presentation: One can show, by (co)limit manipulation very similar to our proof of Theorem 3.2, that is the right Kan extension of along . This only requires density of (˜6.1), not the representation result for (Theorem 6.3).
6.2 The Giry Monad
To capture general probability theory, we move from finitely additive to countably additive probability measures. A probability measure on a measurable space is a map such that and for every countable family of pairwise disjoint sets. We denote the set of probability measures on by . The assignment forms a monad on the category of measurable spaces and measurable maps called the Giry monad [16]. Here, is equipped with the -subalgebra of the power of in , where carries the usual Borel -algebra. On a countable discrete space , a probability measure corresponds to a map with . We denote the set of all such discrete probability measures by . If we equip with the -subalgebra of , then forms a functor, where denotes the full subcategory of countable sets.
Again, these constructions can be expressed in the language of effect algebras, though we have to use a countably infinitary sum operation. A -effect algebra [4] is an effect algebra with a partial commutative associative operation that behaves as expected with unit and addition of (here commutativity means that the operation is independent of permutation of the arguments). Morphisms of -effect algebras preserve all this structure, forming a category . It contains the category of -algebras and the category of countably complete Boolean algebras as subcategories. The familiar dual equivalence between and the category of complete atomic Boolean algebras [24, Sec. VI.4.6] restricts to countable sets, yielding a dual equivalence between and the category of countably complete Boolean algebras of the form for a countable set .
The codensity presentation of again rests on a representation theorem [42, Cor. 3.8]:
Theorem 6.6.
For every we have .
The isomorphism is analogous to that of Theorem 6.3. This means that the Giry monad is given by the adjunction in the diagram below, which also establishes a codensity setting:
Here is the inclusion, and we have:
Lemma 6.7.
The inclusion is dense.
From Theorem 3.2 we obtain the codensity presentation of due to van Belle [42].
Theorem 6.8 (van Belle [42]).
The Giry monad on measurable spaces is the codensity monad of .
Let us mention that in much the same way, Theorem 3.2 yields codensity presentations of
-
1.
the Giry monad by the forgetful functor , analogous to Theorem 6.4;
-
2.
the countable expectation monad on by the functor , analogous to Theorem 6.8.
Here is the category of -effect modules [4], the infinitary version of effect modules. Both results rest on the fact that every -morphism of type is an -morphism, i.e. linear [42, Lem. A.3]. More details are given in the full arXiv version.
Remark 6.9.
As already noted in [42, Rem. 4.3], the Giry functor can also be presented as the right Kan extension of along the inclusion equipping a countable set with the discrete -algebra. Similar to the case of (˜6.5), this follows via an easy computation as in the proof of Theorem 3.2, and does not need an integral representation theorem.
6.3 The Radon Monad and the Kantorovich Monad
Variants of the Giry monad on subcategories of measurable spaces are treated similarly in our framework. Here we consider the Radon monad [13], which captures an important subclass of probability measures. A Radon probability measure on a compact Hausdorff space is a probability measure on (the Borel -algebra generated by the open sets of ) satisfying the condition for all . The set of all Radon probability measures on is denoted by ; it forms a compact Hausdorff space when topologized as a subspace of the product space in .
Similar to Theorem 6.6, Radon measures come with a representation theorem, which yields a particularly simple codensity presentation. It is a variant of the Riesz-Markov representation theorem and proved via the Daniell-Stone representation theorem in [42]:
Theorem 6.10.
For every , we have .
This representation theorem reduces the Radon monad to the codensity setting shown below:
Here is topologized as a subspace of the hypercube , and is the inclusion functor, which is dense by ˜6.1. From Theorem 3.2 we obtain the following codensity presentation of the Radon monad, which is due to van Belle [42]:
Theorem 6.11 (van Belle [42]).
The Radon monad on compact Hausdorff spaces is the codensity monad of .
Remark 6.12.
The Radon monad restricts to the Kantorovich [43] or bounded Lipschitz monad [42] on the category of compact metric spaces and nonexpansive maps by equipping it with the Kantorovich metric. Similarly, the above functors and corestrict to by equipping them with the Kantorovich and supremum metric, respectively. Replacing in the above codensity setting by and the functors by their metric counterparts yields the codensity presentation of the Kantorovich monad by [42].
6.4 Finitely Additive Measures in a Finite Semiring
As our last example, we depart from classical probability measures and generalize to measures valued in a semiring [36]. Fix a finite semiring , viewed as a discrete topological space. An -valued measure on a Stone space is a map satisfying and for disjoint clopens . Let denote the set of such measures.
The set is a closed subspace [36, Lem. 3.4] and hence a Stone space. The integral representation theorem in this case is particularly simple: Recall that an -module is an abelian group with an action satisfying the usual compatibility conditions with respect to the operations of and . For example, the set is an -module under pointwise operations. A morphism of -modules is a morphism of the underlying abelian groups commuting with the action, giving a category . It is isomorphic to the category of algebras for the free-semimodule monad on , where . Given we topologize as a subspace of . Then the following is easy to see:
Lemma 6.13.
For every Stone space we have .
This implies that a suitable codensity setting for is given by the diagram below:
The inclusion is dense by Example 2.1.2, using that , and the outer square commutes similar to (4.4). From Theorem 3.2 we obtain the following result:
Theorem 6.14 (Reggio [36]).
The monad on is the codensity monad of the functor .
7 Conclusion and Future Work
We have introduced a general, unifying approach to codensity presentations of monads, based on the simple core principle of relating codensity to density via duality. We have shown that numerous known and new codensity presentations for important monads, e.g. (ultra)filter, Vietoris, and probability monads, emerge as instances of our framework, in many cases almost for free.
One interesting direction for future work is developing our Theorem 3.2 in the formal theory of monads (i.e. monads in -categories) and generalize it to monad extensions [40], also known as pushforward monads [32]. The latter yield a general method to extend a monad along a -cell; codensity monads correspond to extensions of the identity monad.
A previous approach towards a general understanding of codensity presentations is due to Adámek and Sousa [3]. These authors introduce a notion of ultrafilter monad on a general symmetric monoidal closed category that is locally finitely presentable, and prove that this monad is the codensity monad of the full subcategory of finite presentable objects provided that the category has a nice cogenerator. Most of their concrete instances of ultrafilter monads are easily captured by our duality framework (along the lines of Section 4.1); whether their general presentation result is an instance of our Theorem 3.2 is an open problem.
Finally, on the more applied side, we aim to use our framework to study codensity presentations of additional monads. We are particularly interested in variants of the Vietoris monad related to compact spaces and probabilistic powerdomains [12]. Here, the choice of the corresponding dual adjunction (and even of the dualizing objects) is far from obvious.
References
- [1] Jirí Adámek, Liang-Ting Chen, Stefan Milius, and Henning Urbat. Reiterman’s theorem on finite algebras for a monad. ACM Trans. Comput. Log., 22(4):23:1–23:48, 2021. doi:10.1145/3464691.
- [2] Jiří Adámek and Jiří Rosický. Locally Presentable and Accessible Categories. London Mathematical Society Lecture Note Series. Cambridge University Press, 1994.
- [3] Jiří Adámek and Lurdes Sousa. D-ultrafilters and their monads. Advances in Mathematics, 377:107486, 2021. doi:10.1016/j.aim.2020.107486.
- [4] A. Aizpuru and M. Tamayo. Classical properties of measure theory on effect algebras. Fuzzy Sets and Systems, 157(15):2139–2143, 2006. doi:10.1016/j.fss.2006.03.010.
- [5] Tom Avery. Codensity and the Giry monad. Journal of Pure and Applied Algebra, 220(3):1229–1251, 2016. doi:10.1016/j.jpaa.2015.08.017.
- [6] Garrett Birkhoff. Rings of sets. Duke Mathematical Journal, 3(3):443–454, 1937. doi:10.1215/S0012-7094-37-00334-X.
- [7] Liang-Ting Chen, Jirí Adámek, Stefan Milius, and Henning Urbat. Profinite monads, profinite equations, and Reiterman’s theorem. In 19th International Conference on Foundations of Software Science and Computation Structures (FOSSACS 2016), volume 9634 of Lecture Notes in Computer Science, pages 531–547. Springer, 2016. doi:10.1007/978-3-662-49630-5_31.
- [8] Kenta Cho and Bart Jacobs. Disintegration and Bayesian inversion via string diagrams. Mathematical Structures in Computer Science, 29(7):938–971, 2019. doi:10.1017/S0960129518000488.
- [9] Alan Day. Filter monads, continuous lattices and closure systems. Canadian Journal of Mathematics, 27(1):50–59, 1975. doi:10.4153/CJM-1975-008-8.
- [10] Ivan Di Liberti. Codensity: Isbell duality, pro-objects, compactness and accessibility. Journal of Pure and Applied Algebra, 224(10):106379, 2020. doi:10.1016/j.jpaa.2020.106379.
- [11] Tobias Fritz. A synthetic approach to Markov kernels, conditional independence and theorems on sufficient statistics. Advances in Mathematics, 370:107239, 2020. doi:10.1016/j.aim.2020.107239.
- [12] Tobias Fritz, Paolo Perrone, and Sharwin Rezagholi. Probability, valuations, hyperspace: Three monads on top and the support as a morphism. Mathematical Structures in Computer Science, 31(8):850–897, 2021. doi:10.1017/S0960129521000414.
- [13] Robert W. J. Furber and Bart Jacobs. From Kleisli categories to commutative C*-algebras: Probabilistic Gelfand duality. Log. Methods Comput. Sci., 11(2), 2015. doi:10.2168/LMCS-11(2:5)2015.
- [14] Peter Gabriel and Friedrich Ulmer. Lokal präsentierbare Kategorien, volume 221 of Lecture Notes in Mathematics. Springer-Verlag, Berlin, Heidelberg, 1971. doi:10.1007/BFb0059396.
- [15] Mai Gehrke, Daniela Petrisan, and Luca Reggio. Quantifiers on languages and codensity monads. Math. Struct. Comput. Sci., 30(10):1054–1088, 2020. doi:10.1017/S0960129521000074.
- [16] Michèle Giry. A categorical approach to probability theory. In Categorical Aspects of Topology and Analysis, volume 915 of Lecture Notes in Mathematics, pages 68–85. Springer, 1982. doi:10.1007/BFb0092872.
- [17] Stanley Gudder. Convex structures and effect algebras. International Journal of Theoretical Physics, 38(12):3179–3187, December 1999. doi:10.1023/A:1026678114856.
- [18] Ralf Hinze. Kan extensions for program optimisation or: Art and Dan explain an old trick. In 11th International Conference on Mathematics of Program Construction (MPC 2012), pages 324–362. Springer, 2012. doi:10.1007/978-3-642-31113-0_16.
- [19] J. R. Isbell. Structure of categories. Bulletin of the American Mathematical Society, 72(4):619–655, 1966.
- [20] John R. Isbell. Atomless parts of spaces. MATHEMATICA SCANDINAVICA, 31:5–32, June 1972. doi:10.7146/math.scand.a-11409.
- [21] Bart Jacobs. From probability monads to commutative effectuses. J. Log. Algebraic Methods Program., 94:200–237, 2018. doi:10.1016/J.JLAMP.2016.11.006.
- [22] Bart Jacobs and Jorik Mandemaker. Coreflections in algebraic quantum logic. Foundations of Physics, 42(7):932–958, July 2012. doi:10.1007/s10701-012-9654-8.
- [23] Bart Jacobs, Jorik Mandemaker, and Robert Furber. The expectation monad in quantum foundations. Inf. Comput., 250:87–114, 2016. doi:10.1016/J.IC.2016.02.009.
- [24] Peter T. Johnstone. Stone Spaces. Cambridge Studies in Advanced Mathematics. Cambridge University Press, 1982.
- [25] Peter T. Johnstone. Sketches of an Elephant: A Topos Theory Compendium, Volume 1. Clarendon Press, 2002.
- [26] Shin-ya Katsumata, Tetsuya Sato, and Tarmo Uustalu. Codensity lifting of monads and its dual. Log. Methods Comput. Sci., 14(4), 2018. doi:10.23638/LMCS-14(4:6)2018.
- [27] J. F. Kennison and Dion Gildenhuys. Equational completion, model induced triples and pro-objects. J. Pure Appl. Algebra, 1:317–346, 1971. doi:10.1016/0022-4049(71)90001-6.
- [28] Anders Kock. Continuous yoneda representation of a small category. Preprint, October 1966. URL: https://tildeweb.au.dk/au76680/CYRSC.pdf.
- [29] Tom Leinster. Codensity and the ultrafilter monad. Theory and Applications of Categories, 28(13):332–370, 2013. doi:10.70930/tac/zpkjwf4q.
- [30] Saunders Mac Lane. Categories for the Working Mathematician. Springer, 1998. doi:10.1007/978-1-4757-4721-8.
- [31] Ernest G. Manes. Algebraic Theories, volume 26 of Graduate Texts in Math. Springer, 1976.
- [32] Adrián Doña Mateo. Pushforward monads, 2025. arXiv:2406.15256.
- [33] Eugenio Moggi. Notions of computation and monads. Information and Computation, 93(1):55–92, 1991. doi:10.1016/0890-5401(91)90052-4.
- [34] Sidney A. Morris. Pontryagin Duality and the Structure of Locally Compact Abelian Groups, volume 29 of London Mathematical Society Lecture Note Series. Cambridge University Press, Cambridge, 1977. doi:10.1017/CBO9780511600722.
- [35] Lev Semenovich Pontryagin. Topological Groups. Princeton University Press, Princeton, NJ, 1946.
- [36] Luca Reggio. Codensity, profiniteness and algebras of semiring-valued measures. Journal of Pure and Applied Algebra, 224(1):181–205, 2020. doi:10.1016/j.jpaa.2019.05.002.
- [37] Zev Shirazi. Commutativity and liftings of codensity monads of probability measures, 2024. arXiv:2405.12917.
- [38] Andrei Sipoş. Codensity and Stone spaces. Mathematica Slovaca, 68(1):57–70, 2018. doi:10.1515/ms-2017-0080.
- [39] Sam Staton and Sander Uijlen. Effect algebras, presheaves, non-locality and contextuality. Inf. Comput., 261:336–354, 2018. doi:10.1016/J.IC.2018.02.012.
- [40] Ross Street. The formal theory of monads. Journal of Pure and Applied Algebra, 2(2):149–168, 1972. doi:10.1016/0022-4049(72)90019-9.
- [41] Henning Urbat, Jirí Adámek, Liang-Ting Chen, and Stefan Milius. Eilenberg theorems for free. In 42nd International Symposium on Mathematical Foundations of Computer Science (MFCS 2017), volume 83 of LIPIcs, pages 43:1–43:15. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2017. doi:10.4230/LIPIcs.MFCS.2017.43.
- [42] Ruben Van Belle. Probability monads as codensity monads. Theory and Applications of Categories, 38(21):811–842, 2022. arXiv:2111.01250.
- [43] Franck van Breugel. The metric monad for probabilistic nondeterminism, 2005. URL: http://www.cse.yorku.ca/˜franck/research/drafts/monad.pdf.
- [44] Santiago Zanella-Béguelin. Formal certification of game-based cryptographic proofs. PhD thesis, École Nationale Supérieure des Mines de Paris, 2010. URL: https://pastel.hal.science/pastel-00584350.
