Abstract 1 Introduction 2 Categorical Background 3 Codensity Monads = Density + Duality 4 Ultrafilter and Double Dualization Monads 5 Vietoris Monads 6 Probability Monads 7 Conclusion and Future Work References

Demystifying Codensity Monads via Duality

Fabian Lenke ORCID Friedrich-Alexander-Universität Erlangen-Nürnberg, Germany Nico Wittrock ORCID International Iberian Nanotechnology Laboratory (INL), Braga, Portugal
High-Assurance Software Laboratory (HASLab), Braga, Portugal
Department of Computer Science, University of Minho, Braga, Portugal
Stefan Milius ORCID Friedrich-Alexander-Universität Erlangen-Nürnberg, Germany Henning Urbat ORCID Friedrich-Alexander-Universität Erlangen-Nürnberg, Germany
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, Duality
Funding:
Fabian Lenke: Supported by Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – project number 470467389.
Nico Wittrock: Supported by Fundação para a Ciência e Tecnologia (FCT, Portuguese Foundation for Science and Technology) – grant number 2023.02568.BD – and partly by the FCT KaleidosQope project – project number 2023.13603.PEX.
Stefan Milius: Supported by Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – project number 517924115.
Henning Urbat: Supported by Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – project numbers 470467389 and 569130867.
Copyright and License:
[Uncaptioned image] © Fabian Lenke, Nico Wittrock, Stefan Milius, and Henning Urbat; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Models of computation
Related Version:
Full Version: https://arxiv.org/abs/2509.26197
Acknowledgements:
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ắng

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 F:𝐂0𝐂 canonically induces a monad 𝖢𝗈𝖽𝗒(F) on the category 𝐂, the codensity monad of F, provided only that certain limits in 𝐂 exist. It is constructed via the right Kan extension of F 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

Codensity Monads=Density+Duality.

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 F) follow the pattern shown in diagram (1.1), that is, the functor F decomposes as FRG𝗈𝗉E into a dual equivalence E, the opposite of a dense functor G, and a contravariant right adjoint R generating the monad 𝒯. For instance, the presentation of the ultrafilter monad as the codensity monad of the inclusion functor I:𝐒𝐞𝐭𝖿𝐒𝐞𝐭 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 J:𝐁𝐀𝖿𝐁𝐀 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 F.

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 F, and conversely, to discover a simple functor F 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 𝒯=(T,η,μ) on category 𝐂 is given by an endofunctor T on 𝐂 and two natural transformations, the unit η:𝖨𝖽𝐂T and the multiplication μ:TTT, satisfying the usual unit and associative laws. We denote by 𝐊𝐥(𝒯) the Kleisli category for 𝒯; its objects are those of 𝐂, and morphisms from X to Y are morphisms f:XTY 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 U𝒯:𝐊𝐥(𝒯)𝐂 mapping X𝐂 to TX and a Kleisli morphism f:XTY to f#=μXTf:TXTY. Moreover, there is a full embedding I𝒯:𝐊𝐥(𝒯)𝐄𝐌(𝒯) given by X(TX,μX) and ff# 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 U𝒯:𝐊𝐥𝖿(𝒯)𝐒𝐞𝐭 and I𝒯:𝐊𝐥𝖿(𝒯)𝐄𝐌(𝒯).

Algebraic Categories.

One important class of monads are free-algebra monads on 𝐒𝐞𝐭. Every algebraic theory (Σ,E), specified by signature a Σ of finitary operation symbols and a set E of equations between Σ-terms, induces a monad 𝒯 on 𝐒𝐞𝐭 which maps to each set X the free (Σ,E)-algebra generated by X, carried by the set of Σ-terms modulo equations. The category 𝐄𝐌(𝒯) is isomorphic to the category of all (Σ,E)-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 I𝒫:𝐊𝐥(𝒫)𝐄𝐌(𝒫) is identified with the functor I𝒫:𝐊𝐥(𝒫)𝐂𝐉𝐒𝐋 sending a set X to the free complete semilattice 𝒫X. 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 LR:𝐃𝐂, or simply LR, for an adjunction where L:𝐂𝐃 has a right adjoint R:𝐃𝐂. Every adjunction with unit η:𝖨𝖽𝐂RL and counit ε:LR𝖨𝖽𝐃 induces a monad (RL,η,RεL) on 𝐂. We denote this monad by RL, leaving the structure implicit.

A dual adjunction is an adjunction of type LR:𝐃𝗈𝗉𝐂. 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 S𝐂 and T𝐃 with

|S|=|T|,|LX|𝐂(X,S),and|RY|𝐃(Y,T).

Then the induced monad RL is given by a “double hom-set” construction. For example, the dual adjunction 𝐒𝐞𝐭(,2)𝐒𝐞𝐭(,2):𝐒𝐞𝐭𝗈𝗉𝐒𝐞𝐭 where 2={0,1} yields the neighbourhood monad on 𝐒𝐞𝐭. Similarly, by reading 2 as a Boolean algebra, we obtain a dual adjunction 𝐒𝐞𝐭(,2)𝐁𝐀(,2):𝐁𝐀𝗈𝗉𝐒𝐞𝐭 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 F:𝐀𝐁 and B𝐁, the slice category FB has as objects all morphisms f:FAB for A𝐀, and a morphism from (f:FAB) to (g:FAB) is a morphism h:AA of 𝐀 with f=gFh. There is an obvious projection

πB:FB𝐀,(f:FAB)A.

The functor F is dense [14] if each B𝐁 is the colimit of the (possibly large) diagram FπB, with cocone f (fFB). Equivalently, the functor 𝐁[𝐀𝗈𝗉,𝐒𝐞𝐭] given by B𝐀(F,B) 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. 1.

    The full subcategory I𝒯:𝐊𝐥(𝒯)𝐄𝐌(𝒯) of free algebras is dense.

  2. 2.

    If 𝒯 is finitary, the full subcategory I𝒯:𝐊𝐥𝖿(𝒯)𝐄𝐌(𝒯) of finitely generated free algebras is also dense. Moreover, if there is an algebraic theory presenting the monad 𝒯 with an upper bound n>0 to the arities of operations, the one-object full subcategory {Tn}𝐄𝐌(𝒯) given by the free algebra on n generators is dense [19, Sec. 2.2].

  3. 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 y~:𝐂𝗈𝗉[𝐂,𝐒𝐞𝐭] given by C𝐂(C,) is dense [30, Sec. III.7, Thm. 1].

Dual to density, we have the notion of a codense functor F:𝐀𝐁: every object B𝐁 is the limit of the canonical diagram of all morphisms f:BFA with A𝐀.

Notation 2.3.

For F and B as above and G:𝐀𝐂, we write

colimf:FABA𝐀GAor simplycolimf:FABGA

for the colimit of the diagram GπF:(FB)𝐀𝐂; similarly for limits.

Kan Extensions.

The right Kan extension of a functor F:𝐀𝐂 along a functor J:𝐀𝐁 is given by a functor 𝖱𝖺𝗇JF:𝐁𝐂 and a bijection

[𝐁,𝐂](G,𝖱𝖺𝗇JF)[𝐀,𝐂](GJ,F) (2.1)

natural in G. Concretely, this means that there is natural transformation φ:(𝖱𝖺𝗇JF)JF (called the counit) such that every natural transformation α:GJF factorizes as

α=(GJα^J(𝖱𝖺𝗇JF)J𝜑F) for some unique α^:G𝖱𝖺𝗇JF. (2.2)

If the limit below exists for all X𝐂, the right Kan extension is given by

(𝖱𝖺𝗇JF)X=limf:XJAFA. (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 F:𝐀𝐂 is the monad

𝖢𝗈𝖽𝗒(F)=(𝖱𝖺𝗇FF,η,μ)

where 𝖱𝖺𝗇FF is the right Kan extension of F along itself (if it exists), and the unit η:𝖨𝖽𝖱𝖺𝗇FF and multiplication μ:(𝖱𝖺𝗇FF)(𝖱𝖺𝗇FF)𝖱𝖺𝗇FF are the natural transformations corresponding to the natural transformations below, where φ is the counit of 𝖱𝖺𝗇FF:

F𝗂𝖽Fand(𝖱𝖺𝗇FF)(𝖱𝖺𝗇FF)F(𝖱𝖺𝗇FF)φ(𝖱𝖺𝗇FF)F𝜑𝖱𝖺𝗇FF.

If the Kan extension 𝖱𝖺𝗇FF is pointwise, then 𝖢𝗈𝖽𝗒(F)X=limf:XFAFA. Moreover, the action of 𝖢𝗈𝖽𝗒(F) on a morphism h:XX and the unit and multiplication at X𝐂 are uniquely determined by the commutative diagrams below, where f ranges over all f:XFA with A𝐀 and πf:𝖢𝗈𝖽𝗒(F)XFA is the corresponding limit projection:

  

A codensity presentation of a monad 𝒯 on 𝐂 is a functor F:𝐀𝐂 such that the monad 𝒯 is isomorphic to the monad 𝖢𝗈𝖽𝗒(F) (in the usual category of monads and monad morphisms).

Remark 2.4.
  1. 1.

    The codensity monad may be seen as a measure of codensity of the functor F; indeed, F is codense if and only if its codensity monad is the identity monad.

  2. 2.

    The construction of codensity monads generalizes the construction of monads from adjunctions: If R has a left adjoint L, the codensity monad of R exists and is isomorphic to the induced monad RL [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) L is left adjoint to R, (2) E is an equivalence, (3) G is dense, and (4) the outside commutes up to natural isomorphism (RG𝗈𝗉FE).

(3.1)

The adjunction LR of a codensity setting induces a monad, and the decomposition of the functor F is enough to deduce that F is a codensity presentation of that monad:

Theorem 3.2.

In every codensity setting (3.1), the codensity monad of the functor F exists, is pointwise, and is isomorphic to the monad induced by the adjunction LR:

RL𝖢𝗈𝖽𝗒(F).

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 X𝐂:

RLX R(colimf:GDLXGD) G dense
limf:GDLXRGD right adjoints preserve limits
limg:XRGDRGD LR:𝐃𝗈𝗉𝐂
limg:XFEDFED RG𝗈𝗉FE
limg:XFCFC E equivalence functor
(𝖱𝖺𝗇FF)X limit formula for 𝖱𝖺𝗇.

This proves that 𝖢𝗈𝖽𝗒(F) is pointwise and that RL𝖢𝗈𝖽𝗒(F) 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 RH of a codense functor H and a right adjoint R, the codensity monad of RH is the monad induced by R. Theorem 3.2 corresponds to the setting H=G𝗈𝗉E1 where E1 is an inverse equivalence of E. Thus, it adds to Doña Mateo’s abstract result the crucial insight that the codense functor H should in practice be decomposed into a dual equivalence and the opposite of a dense functor.

Remark 3.4.
  1. 1.

    Every codensity monad has a codensity setting: for any functor F:𝐂0𝐂 with 𝐂0 small its codensity monad is induced by the conerve-totalization adjunction

    (3.2)

    where NC=𝐂0(C,F()) is the conerve and its right adjoint R is the right Kan extension 𝖱𝖺𝗇y~F of F along the contravariant Yoneda embedding y~:𝐂0[𝐂0,𝐒𝐞𝐭]𝗈𝗉. The Yoneda embedding y:𝐂0[𝐂0𝗈𝗉,𝐒𝐞𝐭] is dense, and the adjunction induces 𝖢𝗈𝖽𝗒(F) by definition [29, Section 2].

    Combining Item 1 with ˜2.4.2 we know that every monad admits some codensity setting, so the goal is again to find a simple and natural one, for example by corestricting the adjunction from (3.2) to a good subcategory of [𝐂0,𝐒𝐞𝐭].

  2. 2.

    Di Liberti [10] showed that if one additionally assumes density of F and cocompleteness of 𝐂 the adjunction (3.2) factorizes through Isbell’s dual adjunction between presheaves and copresheaves over 𝐂0. 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 F:𝐂0𝐂, we employ a uniform recipe:

  1. 1.

    Identify a suitable dual adjunction LR:𝐃𝗈𝗉𝐂 inducing the monad 𝒯.

  2. 2.

    Extend the functor F and the adjunction LR to a codensity setting (3.1).

  3. 3.

    Apply Theorem 3.2 to conclude 𝒯𝖢𝗈𝖽𝗒(F).

In all our applications, the crucial (and sometimes non-trivial) step is the choice of the dual adjunction LR in Step 1. Then Step 2 is typically straightforward: The functor E in (3.1) is given by some simple dual equivalence 𝐃0𝗈𝗉𝐂0 known in the literature, and likewise the density of the functor G 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 B is a subset UB such that (1) U is upwards closed, (2) U is closed under meet, and (3) for every bB, either bU or ¬bU. Equivalently, an ultrafilter is given by a morphism χ𝐁𝐀(B,2), where 2={0,1} is the two-element Boolean algebra, by identifying χ with the preimage χ1(1)B. An ultrafilter on a set X is an ultrafilter on the Boolean algebra 𝐒𝐞𝐭(X,2)𝒫X of predicates (equivalently subsets) of X. The ultrafilter monad 𝒰 on 𝐒𝐞𝐭 sends a set X to the set of 𝒰X=𝐁𝐀(𝐒𝐞𝐭(X,2),2) 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 I and J 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 J is dense by Example 2.1.3; note that since the free Boolean algebra 22X on a finite set X 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 X the space 𝒰¯X=𝐁𝐀(𝐓𝐨𝐩(X,2),2) of ultrafilters of clopens; that is, 𝒰¯ is the monad given by the adjunction in (4.2). Here 2 is the two-element discrete space, 𝐓𝐨𝐩(X,2)ClX is the Boolean algebra of clopen subsets of a space X, and 𝐁𝐀(B,2) is the space of ultrafilters of a Boolean algebra B, viewed as subspace of the space 2|B| 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 I 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 M is a non-empty subset FM that is both upwards closed and closed under meets. A filter corresponds to morphism χ𝐌𝐒𝐋(M,2), where 2={0,1} is the two-element semilattice with the meet given by minimum, by identifying χ with the preimage χ1(1)M. A filter on a set X is a filter on the semilattice 𝐒𝐞𝐭(X,2)𝒫X. The filter monad on 𝐒𝐞𝐭 sends a set X to the set of X=𝐌𝐒𝐋(𝐒𝐞𝐭(X,2),2) 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), U is the forgetful functor, and J 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 M to the semilattice 𝐌𝐒𝐋(M,2) of its filters, with the semilattice structure defined pointwise. This codensity setting restricts to (4.4); to see this, first recall the functors U𝒫𝖿 and I𝒫𝖿 from Section 2 (p. 2, “Monads”) and that I𝒫𝖿 is dense (Example 2.1.2). (Note that it maps a set X to 𝒫𝖿X equipped with as the binary operation.) Here 𝐊𝐥𝖿(𝒫𝖿)𝗈𝗉𝐊𝐥𝖿(𝒫𝖿) is the standard identity-on-objects self-duality of the category of finite sets and relations, sending f:X𝒫𝖿Y to f𝗈𝗉:Y𝒫𝖿X given by f𝗈𝗉(y)={x:yf(x)}. The outer square clearly commutes since both (f𝗈𝗉)#=2f#:𝒫𝖿Y𝒫𝖿X take the preimage of SY under f#.

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 U:𝐌𝐒𝐋𝖿𝐒𝐞𝐭 and U𝒫𝖿:𝐊𝐥𝖿(𝒫𝖿)𝐒𝐞𝐭.

Similar to the ultrafilter monad, this reasoning carries over from 𝐒𝐞𝐭 to suitable topological categories. For example, the filter monad ¯ on 𝐓𝐨𝐩 is given by ¯X=𝐌𝐒𝐋(𝐓𝐨𝐩(X,𝕊),2), that is, ¯ is induced by the adjunction in the diagram below. Here 𝕊 is the Sierpinski space carried by 2={0,1} with open sets , {1}, {0,1}, and the set 𝐌𝐒𝐋(M,2) is topologized as a subspace of the product space 𝕊|M|. As open subsets of a space X correspond to continuous maps from X to 𝕊, the monad ¯ sends X to the space ¯X of filters of open sets. Algebras for ¯ carried by T0 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 U𝒫𝖿:𝐊𝐥f(𝒫𝖿)𝐒𝐞𝐭 from (4.3) as a functor to 𝐓𝐨𝐩 by identifying U𝒫𝖿X=𝒫𝖿X with the topological space 𝕊X.

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 U𝒫𝖿:𝐊𝐥𝖿(𝒫𝖿)𝐓𝐨𝐩 sending X to 𝕊X.

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, D is a fixed object of 𝐂, and 𝐂(C,D)𝐂 denotes the internal hom object of C,D𝐂.

      

The other three adjunctions above are concrete instances. Here 𝐕𝐞𝐜𝐭 is the category of vector spaces over a field K and linear maps, and X=𝐕𝐞𝐜𝐭(X,K) is the dual space of a space X 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 X to its double dual space X (whose algebras are linearly compact vector spaces [29, Thm. 7.8]).
Suitable codensity settings for these three monads are given as follows:

Here U:𝐁𝐀𝖿𝐒𝐞𝐭 denotes the forgetful functor, 𝐕𝐞𝐜𝐭𝖿𝖽 is the full subcategory of 𝐕𝐞𝐜𝐭 given by finite dimensional vector spaces, and the functors I 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. 1.

    The neighbourhood monad on 𝐒𝐞𝐭 is the codensity monad of 𝐁𝐀𝖿𝐒𝐞𝐭.

  2. 2.

    The double dualization monad on 𝐌𝐒𝐋 is the codensity monad of 𝐌𝐒𝐋𝖿𝐌𝐒𝐋.

  3. 3.

    The double dualization monad on 𝐕𝐞𝐜𝐭 is the codensity monad of 𝐕𝐞𝐜𝐭𝖿𝖽𝐕𝐞𝐜𝐭.

The last item readily generalizes to modules over a commutative semiring S, where in lieu of 𝐕𝐞𝐜𝐭𝖿𝖽 one takes finitely generated free S-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 S1={x|x|=1}, 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 A to the topological group 𝐀𝐛(A,S1) of all group morphisms into S1, topologized as a subspace of (S1)|A|. Under this duality, the additive group × (the free abelian group on two generators) corresponds to the torus S1×S1, since

S1×S1𝐀𝐛(,S1)×𝐀𝐛(,S1)𝐀𝐛(×,S1).

Thus, we see that Pontryagin duality restricts to a dual equivalence between the one-object full subcategories {×}𝐀𝐛 and {S1×S1}𝐂𝐇𝐀𝐛. The functor U is the composition of the inclusion {S1×S1}𝐂𝐇𝐀𝐛 with the forgetful functor to 𝐀𝐛. The inclusion J:{×}𝐀𝐛 is dense (Example 2.1.2), and the outside of the diagram commutes, since Pontryagin duality is given by the functor 𝐀𝐛(,S1):𝐀𝐛𝗈𝗉𝐂𝐇𝐀𝐛. From Theorem 3.2 we obtain the following new result:

Theorem 4.6.

The double dualization monad on 𝐀𝐛 (with respect to the dualizing object S1) is the codensity monad of the above forgetful functor U:{S1×S1}𝐀𝐛.

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

𝒪(X)=(C[𝐂𝗈𝗉,𝐒𝐞𝐭](X,𝐂(,C)))and𝖲𝗉𝖾𝖼(A)=(C[𝐂,𝐒𝐞𝐭](A,𝐂(C,))).

The two Yoneda embeddings y and y~ give rise to the codensity setting shown below:

y :𝐂[𝐂𝗈𝗉,𝐒𝐞𝐭], C 𝐂(,C),
y~ :𝐂𝗈𝗉[𝐂,𝐒𝐞𝐭], C 𝐂(C,).
(4.5)

Indeed, the embedding y~ is dense (Example 2.2), and the outside of the diagram commutes up to isomorphism by the Yoneda lemma: for all objects C,D𝐂, we have

𝖲𝗉𝖾𝖼(y~(D))(C)=[𝐂,𝐒𝐞𝐭](𝐂(D,),𝐂(C,))𝐂(C,D)=y(D)(C).

From Theorem 3.2 we obtain:

Theorem 4.7 (Kock [28], Di Liberti [10]).

For every small category 𝐂, the monad on [𝐂𝗈𝗉,𝐒𝐞𝐭] induced by Isbell duality is the codensity monad of y:𝐂[𝐂𝗈𝗉,𝐒𝐞𝐭].

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 𝕍X of a Stone space X is given by the set of all closed subsets of X equipped with the hit-or-miss topology, which has the following subbasic open sets:

U={CX closedCU},U={CX closedCU=},for UX clopen.

We can represent 𝕍X as a double dual space as follows. Let 𝐉𝐒𝐋 be the category of join-semilattices with bottom. Morphisms from J to the join-semilattice 2={0,1} (with join given by maximum) correspond to ideals: non-empty subsets of J that are downwards closed and closed under join. The set 𝐉𝐒𝐋(J,2) of ideals is topologized as a subspace of the product space 2|J|, where 2 carries the discrete topology. We then have the isomorphism 𝕍X𝐉𝐒𝐋(𝐒𝐭𝐨𝐧𝐞(X,2),2) which identifies a closed set CX with the ideal of all clopen sets UX with CU= (i.e. CU). The object mapping X𝕍X thus naturally extends to a monad, for which the appropriate codensity setting is given by (5.1):

(5.1)
(5.2)

Here U𝒫𝖿:𝐊𝐥f(𝒫𝖿)𝐒𝐞𝐭 from (4.4) is lifted to 𝐒𝐭𝐨𝐧𝐞, identifying U𝒫𝖿X=𝒫𝖿X with the discrete space 2X. The functor I𝒫𝖿 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 U𝒫𝖿:𝐊𝐥𝖿(𝒫𝖿)𝐒𝐭𝐨𝐧𝐞.

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 X, the lower Vietoris space is the topological space 𝕍X of all closed subsets of X with the topology generated by the subbasic open sets U (as defined above) for UX open. Similar to 𝕍X, we can represent 𝕍X 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 J to 2={0,1} correspond to complete ideals: subsets of J that are downwards closed and closed under arbitrary joins. The set 𝐂𝐉𝐒𝐋(J,2) of all complete ideals is topologized as a subspace of the product space 𝕊|J|. We then have 𝕍X𝐂𝐉𝐒𝐋(𝐓𝐨𝐩(X,𝕊),2), where the isomorphism identifies a closed set CX with the complete ideal of all open sets UX with CU=. Thus, the object mapping X𝕍X 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 U𝒫:𝐊𝐥(𝒫)𝐒𝐞𝐭 is taken as a functor to 𝐓𝐨𝐩 by identifying U𝒫𝖿X=𝒫𝖿X with the topological space 𝕊X, and I𝒫 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 U𝒫.

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 X which has all finite meets and all joins and which satisfies the infinite distributive law xiIxi=iIxxi for all x,xiX, iI. 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 X to the set X of upwards closed subsets of 𝒫𝖿X [25, C1.1, Lem. 1.1.3].

The sobrification monad on 𝐓𝐨𝐩 is given by 𝒮X=𝐅𝐫𝐦(𝐓𝐨𝐩(X,𝕊),2); 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 J is the inclusion of the full subcategory 𝐒𝐢𝐞𝐫 of 𝐓𝐨𝐩 consisting of powers 𝕊X, where X is any set, and I is the canonical dense inclusion functor from Example 2.1.1. The equivalence functor E and commutation of the diagram are given by the following lemma.

Lemma 5.3.

The object mapping X𝕊X𝐅𝐫𝐦(X,2) defines a dual equivalence E 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 X is a finitely additive probability measure on the discrete measurable space (X,ΣX=𝒫X), that is, a map p:𝒫X[0,1] with p(X)=1 and p(A+B)=p(A)+p(B) for disjoint A,B𝒫X. If X is finite, then every finitely additive probability measure on X is discrete: recall that a discrete finite probability measure on X is a map p:X[0,1] with xXp(x)=1 and p(x)=0 for all but finitely many xX. We denote the set of finitely additive probability measures on a set X by X, and the set of discrete finite probability measures by 𝒟𝖿X. 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 (A,,0) together with an operator ():AA satisfying that x is the unique element in A with xx=1, where 1=0, and x1 is defined iff x=0. Morphisms of effect algebras preserve all this structure, forming a category 𝐄𝐀. The unit interval [0,1] forms an effect algebra with rs=r+s defined if r+s1, and r=1r. Boolean algebras form a full subcategory of effect algebras, with ab=ab defined whenever ab=0, and a=¬a. 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 J:𝐁𝐀𝖿𝐄𝐀 is dense.

Effect algebras carry a monoidal structure such that AB represents bilinear morphisms [22], analogous to commutative monoids, with tensor unit 2={0,1}. The unit interval [0,1] with multiplication forms a monoid [0,1][0,1][0,1] for this monoidal structure.

An effect module is an effect algebra E that is a [0,1]-module for this tensor product, that is, E is equipped with a bilinear map [0,1]×EE of effect algebras. Effect module morphisms are effect algebra morphisms preserving the action, forming a category 𝐄𝐌𝐨𝐝. Its forgetful functor to 𝐄𝐀 has a left adjoint A[0,1]A. This adjunction yields a monad on 𝐄𝐀 given by A=[0,1]A. On finite Boolean algebras we have (2X)[0,1]X. 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 I:𝐊𝐥𝐁𝐀𝖿()𝐄𝐌𝐨𝐝, 2X[0,1]X, is dense.

Finitely additive probability measures on a set X correspond to effect algebra morphisms from 2X to [0,1], that is, X𝐄𝐀(2X,[0,1]). They also correspond to effect module morphisms from [0,1]X to [0,1], which is the content of the following discrete integral representation theorem [23, Prop. 33]:

Theorem 6.3.

For every set X, there is a natural bijection

𝐄𝐌𝐨𝐝([0,1]X,[0,1])𝐄𝐀(2X,[0,1]).

The bijection sends f𝐄𝐌𝐨𝐝([0,1]X,[0,1]) to the measure p with p(A)=f(χA), where χA is the characteristic map of AX given by χA(x)=1 if xA, and χA(x)=0 if xA.

We thus define the expectation monad on 𝐒𝐞𝐭 by X=𝐄𝐌𝐨𝐝([0,1]X,[0,1]); more precisely, is given by the adjunction in the codensity setting below:

The inclusion I is dense by ˜6.2 and the outer square commutes since 2=[0,1]21[0,1]. The duality of the left extends the duality 𝐁𝐀𝖿𝗈𝗉𝐒𝐞𝐭𝖿. Indeed, for A,B𝐒𝐞𝐭𝖿 we have the following natural bijection:

𝐊𝐥𝖿(𝒟𝖿)(A,B)=𝐒𝐞𝐭(A,𝒟𝖿B)𝐄𝐀(2B,[0,1]A)𝐊𝐥𝐁𝐀𝖿()(2B,2A).

From Theorem 3.2 we obtain a novel codensity presentation of :

Theorem 6.4.

The expectation monad is the codensity monad of U𝒟𝖿:𝐊𝐥𝖿(𝒟𝖿)𝐒𝐞𝐭.

Remark 6.5.

The expectation functor X𝐄𝐀(2X,[0,1]) 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 I:𝐒𝐞𝐭𝖿𝐒𝐞𝐭. 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 (X,ΣX) is a map p:ΣX[0,1] such that p(X)=1 and p(iAi)=ip(Ai) for every countable family (Ai)i of pairwise disjoint sets. We denote the set of probability measures on X by 𝒢X. The assignment X𝒢X forms a monad on the category 𝐌𝐞𝐚𝐬 of measurable spaces and measurable maps called the Giry monad [16]. Here, 𝒢X is equipped with the Σ-subalgebra of the power [0,1]ΣX of [0,1] in 𝐌𝐞𝐚𝐬, where [0,1] carries the usual Borel σ-algebra. On a countable discrete space (X,ΣX=2X), a probability measure corresponds to a map p:X[0,1] with xp(x)=1. We denote the set of all such discrete probability measures by 𝒟X. If we equip 𝒟X with the Σ-subalgebra of [0,1]X, 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 A with a partial commutative associative operation n<ω:AωA that behaves as expected with unit 0 and addition of A (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 2A for a countable set A.

The codensity presentation of 𝒢 again rests on a representation theorem [42, Cor. 3.8]:

Theorem 6.6.

For every X𝐌𝐞𝐚𝐬 we have 𝒢X𝐄𝐀σ(𝐌𝐞𝐚𝐬(X,[0,1]),[0,1]).

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 I is the inclusion, and we have:

Lemma 6.7.

The inclusion I:𝐂𝐀𝐁𝐀𝖼𝐄𝐀σ 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. 1.

    the Giry monad by the forgetful functor U𝒟:𝐊𝐥𝖼(𝒟)𝐌𝐞𝐚𝐬, analogous to Theorem 6.4;

  2. 2.

    the countable expectation monad σX=𝐄𝐌𝐨𝐝σ([0,1]X,[0,1]) 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 [0,1]X[0,1] 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 I:𝐒𝐞𝐭𝖼𝐌𝐞𝐚𝐬 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 X is a probability measure μ on 𝖡𝗈X (the Borel σ-algebra generated by the open sets of X) satisfying the condition μ(A)=sup{μ(K)KA and K compact} for all A𝖡𝗈X. The set of all Radon probability measures on X is denoted by X; it forms a compact Hausdorff space when topologized as a subspace of the product space [0,1]𝖡𝗈X 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 X𝐂𝐇𝐚𝐮𝐬, we have X𝐄𝐀(𝐂𝐇𝐚𝐮𝐬(X,[0,1]),[0,1]).

This representation theorem reduces the Radon monad to the codensity setting shown below:

Here 𝒟X is topologized as a subspace of the hypercube [0,1]X, and J 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 𝐄𝐀(,[0,1]) 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 S, viewed as a discrete topological space. An S-valued measure on a Stone space X is a map p:ClXS satisfying p()=0 and p(A+B)=p(A)+p(B) for disjoint clopens A,B. Let SX denote the set of such measures.

The set SXSClX 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 S-module is an abelian group A with an action S×AA satisfying the usual compatibility conditions with respect to the operations of S and A. For example, the set 𝐒𝐭𝐨𝐧𝐞(X,S) is an S-module under pointwise operations. A morphism of S-modules is a morphism of the underlying abelian groups commuting with the action, giving a category 𝐌𝐨𝐝S. It is isomorphic to the category of algebras for the free-semimodule monad 𝒮 on 𝐒𝐞𝐭, where 𝒮X={f:XSf(x)=0 for all but finitely many x}. Given X𝐒𝐭𝐨𝐧𝐞 we topologize 𝐌𝐨𝐝S(𝐒𝐭𝐨𝐧𝐞(X,S),S) as a subspace of S𝐒𝐭𝐨𝐧𝐞(X,S). Then the following is easy to see:

Lemma 6.13.

For every Stone space X we have SX𝐌𝐨𝐝S(𝐒𝐭𝐨𝐧𝐞(X,S),S).

This implies that a suitable codensity setting for S is given by the diagram below:

The inclusion I𝒮 is dense by Example 2.1.2, using that 𝐄𝐌(𝒮)𝐌𝐨𝐝S, 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 S on 𝐒𝐭𝐨𝐧𝐞 is the codensity monad of the functor U𝒮:𝐊𝐥𝖿(𝒮)𝐒𝐭𝐨𝐧𝐞.

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 2-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 1-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.