Codensity and the ultrafilter monad

Codensity and the ultrafilter monad

Tom Leinster School of Mathematics, University of Edinburgh, Edinburgh EH9 3JZ, UK; Partially supported by an EPSRC Advanced Research Fellowship.

Even a functor without an adjoint induces a monad, namely, its codensity monad; this is subject only to the existence of certain limits. We clarify the sense in which codensity monads act as substitutes for monads induced by adjunctions. We also expand on an undeservedly ignored theorem of Kennison and Gildenhuys: that the codensity monad of the inclusion of (finite sets) into (sets) is the ultrafilter monad. This result is analogous to the correspondence between measures and integrals. So, for example, we can speak of integration against an ultrafilter. Using this language, we show that the codensity monad of the inclusion of (finite-dimensional vector spaces) into (vector spaces) is double dualization. From this it follows that compact Hausdorff spaces have a linear analogue: linearly compact vector spaces. Finally, we show that ultraproducts are categorically inevitable: the codensity monad of the inclusion of (finite families of sets) into (families of sets) is the ultraproduct monad.




Now we have at last obtained permission to ventilate the facts…

—Arthur Conan Doyle, The Adventure of the Creeping Man (1927)


The codensity monad of a functor can be thought of as the monad induced by and its left adjoint, even when no such adjoint exists. We explore the remarkable fact that when is the inclusion of the category of finite sets into the category of all sets, the codensity monad of is the ultrafilter monad. Thus, the mere notion of finiteness of a set gives rise automatically to the notion of ultrafilter, and so in turn to the notion of compact Hausdorff space.

Many of the results in this paper are known, but not well known. In particular, the characterization of the ultrafilter monad as a codensity monad appeared in the 1971 paper of Kennison and Gildenhuys [KeGi] and the 1976 book of Manes ([ManeAT], Exercise 3.2.12(e)), but has not, to my knowledge, appeared anywhere else. Part of the purpose of this paper is simply to ventilate the facts.

Ultrafilters belong to the minimalist world of set theory. There are several concepts in more structured branches of mathematics of which ultrafilters are the set-theoretic shadow:

Probability measures

An ultrafilter is a finitely additive probability measure in which every event has probability either or (Lemma LABEL:lemma:uf-prob). The elements of an ultrafilter on a set are the subsets that occupy ‘almost all’ of , and the other subsets of are to be regarded as ‘null’, in the sense of measure theory.

Integration operators

Ordinary real-valued integration on a measure space is an operation that takes as input a suitable function and produces as output an element of . We can integrate against ultrafilters, too. Given an ultrafilter on a set , a set , and a function with finite image, we obtain an element of ; it is the unique element of whose -fibre belongs to .


To integrate a function against a probability measure is to take its mean value with respect to that measure. Integrating against an ultrafilter is more like taking the mode: if we think of elements of as ‘large’ then is the unique value of taken by a large number of elements of . Ultrafilters are also used to prove results about more sophisticated types of average. For example, a mean on a group is a left invariant finitely additive probability measure defined on all subsets of ; a group is amenable if it admits at least one mean. Even to prove the amenability of is nontrivial, and is usually done by choosing a nonprincipal ultrafilter on (e.g. [Rund], Exercise 1.1.2).

Voting systems

In an election, each member of a set of voters chooses one element of a set of options. A voting system computes from this a single element of , intended to be some kind of average of the individual choices. In the celebrated theorem of Arrow [Arro], has extra structure: it is the set of total orders on a list of candidates. In our structureless context, ultrafilters can be seen as (unfair!) voting systems: when each member of a possibly-infinite set of voters chooses from a finite set of options, there is—according to any ultrafilter on —a single option chosen by almost all voters, and that is the outcome of the election.

Section 1 is a short introduction to ultrafilters. It includes a very simple and little-known characterization of ultrafilters, as follows. A standard lemma states that if is an ultrafilter on a set , then whenever is partitioned into a finite number of (possibly empty) subsets, exactly one belongs to . But the converse is also true [GaHo]: any set of subsets of satisfying this condition is an ultrafilter. Indeed, it suffices to require this just for partitions into three subsets.

We also review two characterizations of monads: one of Börger [BoerCU]:

the ultrafilter monad is the terminal monad on that preserves finite coproducts

and one of Manes [ManeTTC]:

the ultrafilter monad is the monad for compact Hausdorff spaces.

Density and codensity are reviewed in Section 2. A functor is either codense or not: yes or no. Finer-grained information can be obtained by calculating the codensity monad of . This is a monad on , defined subject only to the existence of certain limits, and it is the identity exactly when is codense. Thus, the codensity monad of a functor measures its failure to be codense.

This prepares us for the codensity theorem of Kennison and Gildenhuys (Section LABEL:sec:uf-co): writing for the category of finite sets,

the ultrafilter monad is the codensity monad of the inclusion .

(In particular, since nontrivial ultrafilters exist, is not codense in .) We actually prove a more general theorem, which has as corollaries both this and an unpublished result of Lawvere.

Writing for the codensity monad of , the elements of can be thought of as integration operators on , while the ultrafilters on are thought of as measures on . The theorem of Kennison and Gildenhuys states that integration operators correspond one-to-one with measures, as in analysis. In general, the notions of integration and codensity monad are bound together tightly. This is one of our major themes.

Integration is most familiar when the integrands take values in some kind of algebraic structure, such as . In Section LABEL:sec:rigs, we describe integration against an ultrafilter for functions taking values in a rig (semiring). We prove that when the rig is sufficiently nontrivial, ultrafilters on correspond one-to-one with integration operators for -valued functions on .

To continue, we need to review some further basic results on codensity monads, including their construction as Kan extensions (Section LABEL:sec:kan). This leads to another characterization:

the ultrafilter monad is the terminal monad on that restricts to the identity on .

In Section LABEL:sec:co-adj, we justify the opening assertion of this introduction: that the codensity monad of a functor is a surrogate for the monad induced by and its left adjoint (which might not exist). For a start, if a left adjoint exists then the two monads are the same. More subtly, any monad on induces a functor into (the forgetful functor on its category of algebras), and, under a completeness hypothesis, any functor into induces a monad on (its codensity monad). Theorem LABEL:thm:co-adj, due to Dubuc [Dubu], states that the two processes are adjoint. From this we deduce:

is the codomain of the universal functor from to

a category monadic over .

(This phrasing is slightly loose; see Corollary LABEL:cor:CptHff for the precise statement.) Here is the category of compact Hausdorff spaces.

We have seen that when standard categorical constructions are applied to the inclusions , we obtain the notions of ultrafilter and compact Hausdorff space. In Section LABEL:sec:dd we ask what happens when sets are replaced by vector spaces. The answers give us the following table of analogues:

sets vector spaces
finite sets finite-dimensional vector spaces
ultrafilters elements of the double dual
compact Hausdorff spaces linearly compact vector spaces.

The main results here are that the codensity monad of is double dualization, and that its algebras are the linearly compact vector spaces (defined below). The close resemblance between the and cases raises the question: can analogous results be proved for other algebraic theories? We leave this open.

It has long been a challenge to synthesize the complementary insights offered by category theory and model theory. For example, model theory allows insights into parts of algebraic geometry where present-day category theory seems to offer little. (This is especially so when it comes to transferring results between fields of positive characteristic and characteristic zero, as exemplified by Ax’s model-theoretic proof that every injective endomorphism of a complex algebraic variety is surjective [Ax].) A small part of this challenge is to find a categorical home for the ultraproduct construction.

Section LABEL:sec:ups does this. The theorem of Kennison and Gildenhuys shows that the notion of finiteness of a set leads inevitably to the notion of ultrafilter. Similarly, we show here that the notion of finiteness of a family of sets leads inevitably to the notion of ultraproduct. More specifically, we define a category of families of sets, and prove that the codensity monad of the full subcategory of finitely-indexed families is the ultraproduct monad. This theorem (with a different proof) was transmitted to me by the anonymous referee, to whom I am very grateful.

History and related work

The concept of density was first isolated in a 1960 paper by Isbell [IsbeAS], who gave a definition of dense (or in his terminology, left adequate) full subcategory. Ulmer generalized the definition to arbitrary functors, not just inclusions of full subcategories, and introduced the word ‘dense’ [Ulme]. At about the same time, the codensity monad of a functor was defined by Kock [KockCYR] (who gave it its name) and, independently, by Appelgate and Tierney [ApTi] (who concentrated on the dual notion, calling it the model-induced cotriple).

Other early sources on codensity monads are the papers of Linton [LintOFS] and Dubuc [Dubu]. (Co)density of functors is covered in Chapter X of Mac Lane’s book [MacLCWM], with codensity monads appearing in the very last exercise. Kelly’s book [KellBCE] treats (co)dense functors in detail, but omits (co)density (co)monads.

The codensity characterization of the ultrafilter monad seems to have first appeared in the paper [KeGi] of Kennison and Gildenhuys, and is also included as Exercise 3.2.12(e) of Manes’s book [ManeAT]. (Manes used the term ‘algebraic completion’ for codensity monad.) It is curious that no result resembling this appears in Isbell’s 1960 paper, as even though he did not have the notion of codensity monad available, he performed similar and more set-theoretically sophisticated calculations. However, his paper does not mention ultrafilters. On the other hand, a 2010 paper of Litt, Abel and Kominers [LAK] proves a result equivalent to a weak form of Kennison and Gildenhuys’s theorem, but does not mention codensity.

The integral notation that we use so heavily has been used in similar ways by Kock [KockCEQ, KockMEQ] and Lucyshyn-Wright [Lucy] (and slightly differently by Lawvere and Rosebrugh in Chapter 8 of [LaRo]). In [KockMEQ], Kock traces the idea back to work of Linton and Wraith.

Richter [Rich] found a different proof of Theorem 1.7 below, originally due to Börger. Section 3 of Kennison and Gildenhuys [KeGi] may provide some help in answering the question posed at the end of Section LABEL:sec:dd.


We fix a category of sets satisfying the axiom of choice. is the category of all topological spaces and continuous maps, and is the category of locally small categories. When is a set and is an object of some category, denotes the -power of , that is, the product of copies of . In particular, when and are sets, is the set of maps from to . For categories and , we write for the category of functors from to . Where necessary, we silently assume that our general categories are locally small.

1 Ultrafilters

We begin with the standard definitions. Write for the power set of a set .

Definition 1.1

Let be a set. A filter on is a subset of such that:

  1. is upwards closed: if with then

  2. is closed under finite intersections: , and if then .

Filters on amount to meet-semilattice homomorphisms from to the two-element totally ordered set , with corresponding to the filter .

It is helpful to view the elements of a filter as the ‘large’ subsets of , and their complements as ‘small’. Thus, the union of a finite number of small sets is small. An ultrafilter is a filter in which every subset is either large or small, but not both.

Definition 1.2

Let be a set. An ultrafilter on is a filter such that for all , either or , but not both.

Ultrafilters on correspond to lattice homomorphisms .

Example 1.3

Let be a set and . The principal ultrafilter on is the ultrafilter . Every ultrafilter on a finite set is principal.

The set of filters on is ordered by inclusion. The largest filter is ; every other filter is called proper. (What we call proper filters are often just called filters.) A standard lemma (Proposition 1.1 of [Eklo]) states that the ultrafilters are precisely the maximal proper filters. Zorn’s lemma then implies that every proper filter is contained in some ultrafilter. No explicit example of a nonprincipal ultrafilter can be given, since their existence implies a weak form of the axiom of choice. However:

Example 1.4

Let be an infinite set. The subsets of with finite complement form a proper filter on . Then is contained in some ultrafilter, which cannot be principal. Thus, every infinite set admits at least one nonprincipal ultrafilter.

We will use the following simple characterization of ultrafilters. The equivalence of (i) and (ii) appears to be due to Galvin and Horn [GaHo], whose result nearly implies the equivalence with (iii), too.

Proposition 1.5 (Galvin and Horn)

Let be a set and . The following are equivalent:

  1. is an ultrafilter

  2. satisfies the partition condition: for all and partitions

    of into pairwise disjoint (possibly empty) subsets, there is exactly one such that .

Moreover, for any , these conditions are equivalent to:

  1. satisfies the partition condition for .

  • Proof  Let . The implication (i)(ii) is standard, and (ii)(iii) is trivial. Now assume (iii); we prove (i).

    From the partition and the fact that , we deduce that and . It follows that satisfies the partition condition for all . Taking , this implies that for all , either or , but not both. It remains to prove that is upwards closed and closed under binary intersections.

    For upwards closure, let with . We have

    with , so . Hence .

    To prove closure under binary intersections, first note that if then : for if then , so by upwards closure, so , a contradiction. Now let and consider the partition

    Exactly one of these three subsets, say , is in . But , so , so ; similarly, . Hence , as required.

Perhaps the most striking part of this result is:

Corollary 1.6

Let be a set and a set of subsets of such that whenever is expressed as a disjoint union of three subsets, exactly one belongs to . Then is an ultrafilter.

The number three cannot be lowered to two: consider a three-element set and the set of subsets with at least two elements.

Given a map of sets and a filter on , there is an induced filter

on . If is an ultrafilter then so is . This defines a functor

in which is the set of ultrafilters on .

In fact, carries the structure of a monad, . The unit map sends to the principal ultrafilter . We will avoid writing down the multiplication explicitly. (The contravariant power set functor from to is self-adjoint on the right, and therefore induces a monad on ; it contains as a submonad.) What excuses us from this duty is the following powerful pair of results, both due to Börger [BoerCU].

Theorem 1.7 (Börger)

The ultrafilter endofunctor is terminal among all endofunctors of that preserve finite coproducts.

  • Sketch proof  Given a finite-coproduct-preserving endofunctor of , the unique natural transformation is described as follows: for each set and element ,

    For details, see Theorem 2.1 of [BoerCU].

Corollary 1.8 (Börger)

The ultrafilter endofunctor has a unique monad structure. With this structure, it is terminal among all finite-coproduct-preserving monads on .

  • Proof  (Corollary 2.3 of [BoerCU].) Since and the identity preserve finite coproducts, there are unique natural transformations and . The monad axioms follow by terminality of the endofunctor , as does terminality of the monad.

There is also a topological description of the ultrafilter monad. As shown by Manes [ManeTTC], it is the monad induced by the forgetful functor and its left adjoint. In particular, the Stone–Čech compactification of a discrete space is the set of ultrafilters on it.

2 Codensity

Here we review the definitions of codense functor and codensity monad. The dual notion, density, has historically been more prominent, so we begin our review there.

As shown by Kan, any functor from a small category to a cocomplete category induces an adjunction

Comments 0
Request Comment
You are adding the first comment!
How to quickly get a good reply:
  • Give credit where it’s due by listing out the positive aspects of a paper before getting into which changes should be made.
  • Be specific in your critique, and provide supporting evidence with appropriate references to substantiate general statements.
  • Your comment should inspire ideas to flow and help the author improves the paper.

The better we are at sharing our knowledge with each other, the faster we move forward.
The feedback must be of minimum 40 characters and the title a minimum of 5 characters
Add comment
Loading ...
This is a comment super asjknd jkasnjk adsnkj
The feedback must be of minumum 40 characters
The feedback must be of minumum 40 characters

You are asking your first question!
How to quickly get a good answer:
  • Keep your question short and to the point
  • Check for grammar or spelling errors.
  • Phrase it like a question
Test description