In this post, take some notes about Bojańczyk’s paper *Recognisable Languages over Monads*. These notes are mainly for myself (I find it helpful to write stuff down), so I presuppose some category theory, some formal language theory, and a certain acquaintance with Stone duality. I may write about another approach to profinite monads as codensity monads soon. Or not. We’ll see.

## Recognizable languages over Monads

### Algebras for a Monad

In the following, let be a monad on . A *-algebra* is an object of together with an arrow such that

commute. We will write for this -algebra and occasionally also just. The simplest example of a -algebra is , the *free -algebra*.

Given two -algebras and , a -algebra morphism is an arrow such that

commutes. This data defines a category, the *Eilenberg-Moore category* of algebras of with their morphisms.

Our running example will be the monoid monad that arises as the composition of the adjoint functors and , where is the forgetful functor and takes a set to the free monoid with the usual action on maps. In other words, is the set of finite words on . This monad has as its unit the embedding of elements from as words of length one and as its multiplication the collapsing of finite words of finite words over to finite words over . It is easily seen that the algebras for are simply monoids, and the -algebra morphisms are monoid homomorphisms: The idea here is that the free monoid consists of all terms that make sense for a monoid and is the evaluation of these terms to elements of the actual monoid . The laws now simply ensure that this evaluation works as you would expect.

### Recognizable Languages over Monads

Let be a -algebra and any object of . An arrow (in ) is *recognized* be a -morphism if for some arrow in . Such an arrow is *recognized* by a -algebra , if there is a -algebra morphism that recognizes it. Pictographically:

Note how this generalizes the notion of recognition for monoids: A subset of a monoid is *recognized* by a monoid if there exists and a monoid morphism such that . In our definition above, this is the case of and as the characteristic function of . Any -arrow then defines a subset of , and vice-versa. So translates if , therefore .

Also, this definition readily implies that all such arrows are recognized by – which is no problem, since usually we are interested in what arrows can be recognized by ‘finite’ -algebras. Unfortunately, there is no obvious way how to define what finite means for an arbitrary monad. We will presuppose that a sensible choice for *finite* has been made in the context we are considering. The *recognizable arrows of * are then the arrows of that are recognized by finite algebras.

### Profinite Monads, Bojańczyk’s construction

I will first describe how Bojańczyk extends a monad on to its profinite version .

In the following, let and let be a -algebra. A *generalized element* of is a map associating to every surjective -algebra morphism an element such that for every finite -algebra and -algebra morphism

The set of all generalized elements of is written .

The comparison to the case of the free profinite monoid is illuminating: Seen as the completion of with the profinite metric, we see that elements of are either finite words or (equivalence classes of) non-convergent Cauchy-sequences. One of the main points about the profinite completion of is that any monoid homomorphism , where is finite, can be uniquely extended to a uniformly continuous monoid homomorphism . To define , we set whenever , and if is a Cauchy-sequence, we set , which must exist by the definition of the profinite metric. We can now turn this upside down and instead consider the elements of as acting on the morphisms, where each acts as . In the context of Bojańczyk’s work, is written and is defined as .

The set can be equipped with a topology generated by the opens of the form with , , which makes it homeomorphic to the Stone dual of the recognizable languages of . Note that the topology of is generated by the opens with . This suggests that is the homemorphism in question.

Bojańczyk calls my generalized elements of instead *-algebra morphism types* over and refers to as *the compactification* of . I find this nomenclature confusing, since *type* has a rather different meaning for me and there are several ways to compactify as a discrete space.

Now we can define the profinite monad for . It acts on sets via . The operations for , , and are completely fixed by requiring that, for each finite -algebra and each surjective -algebra morphism , the following diagrams commute:

Since each element is defined by its action on each for each finite -algebra , the diagrams actually define the operations.

Again I think it is helpful to see what this means in the familiar case of the free profinite monoid. The embedding is straight forward and turns a word into the generalized element , or the principal ultrafilter of , or the constant sequence , depending on your point of view.

The lifting of functions is given by , which makes use of the fact that is a monoid homomorphism into a finite monoid that can be extended continously. In terms of profinite words this means that , since then .

The case of the multiplication is less obvious. The right-most diagram states that . I am still trying to find meaning in this one.