Natural transformations between cofunctors
Polynomial comonads can be identified with categories, but the morphisms between them are not functors; they’re called cofunctors. There is a reasonable notion of natural transformation between cofunctors, but I always found remembering how it goes to be a slog. Recently I realized that they have a very reasonable form in terms of polynomial comonads. In this short post, I’ll introduce the subject, give the formula for natural transformations between cofunctors and explain it, discuss identities and compositions, and then conclude with a summary.
1 Introduction
A category has what I call an outfacing polynomial, 1 which I’ll denote , given by the formula As you can see, the positions of are the objects of , and for each such object , the directions of at are all the outfacing maps . This polynomial comes equipped with two polynomial morphisms the counit and comultiplication, which satisfy comonoid axioms; that is, we get a polynomial comonad. Ahman and Uustalu showed that, up to isomorphism, categories and polynomial comonads are the same thing. But the morphisms of polynomial comonads are not functors; they’re called cofunctors. A cofunctor can be defined as a map of outfacing polynomials that commutes with the counits and with the comultiplications.
Marcelo Aguiar defined cofunctors, albeit in the direction opposite to comonoid maps, in his thesis. He also defined what he called natural cotransformations between them. I like Clarke-Di Meglio’s description of this concept in their 2022 paper, where they change the name to natural transformations.
For some reason, I have always found the notion of natural transformation between cofunctors to be a bit difficult to recall and also to work with. I always had to either consult a reference or sit there and try to figure out what it had to be, constantly fiddling with notation; it just wasn’t simple. Being a person who gets lost easily in complexity, I even found myself wondering if this was the right notion of map between cofunctors, because “why is it so fiddly?!” But the notion seemed right from a number of different perspectives, so I begrudgingly had to accept it.
But recently I noticed a syntactic poly-ish way to express what a natural transformation of cofunctors is. It was quite a relief, so I thought I’d share it here.
2 Transformations of cofunctors: formula and explanation
You can remember the direction because in the parallel arrows and above, you can see that comes before and comes after . But what does a map satisfying (1) mean?
Recall that a map is a global section (Aguiar calls it an admissible section). It assigns to each object an outfacing morphism , from to some other object . The counit is such a thing: it assigns to each the identity on , as an outfacing morphism. But in general, is like a vector field—or we could call it a direction field—on your category: wherever you are, this is the direction is telling you to go. Let’s denote the set of direction fields on by .
So the data of a natural transformation between cofunctors out of is just a direction field . Untangling the commutative diagram (1) is a matter of careful element-tracking, and I find it to be most easily done using polyboxes. Allow me to unpack it for you.
Given any object , define and . So we have a map in and an object . Finally, let be any map out of . The commutativity of (1) says two things:
there is an equality of objects
letting and , there is an equality of morphisms
Here’s a picture, with top layer in and bottom layer in , with maps drawn blue rightward and maps drawn red leftward, and with the natural transformation data shown as dashed.
For every object in we get such a dashed map for some , and for every morphism out of the mutual image downstairs, we get a commuting square upstairs.
It’s not hard to see the analogy with natural transformations between functors. For functors, the data is a morphism in for every object in ; for cofunctors it is a morphism in for every object in . For functors, any morphism in gives you a commuting square in ; for cofunctors you only need to pay attention to morphisms out of objects in the image of , but for any such morphism you get a commuting square in . And just like how natural transformations between functors don’t really involve the identities or compositions on the domain side (other than for defining the functors), natural transformations between cofunctors don’t really use the identities or compositions on the codomain side (other than for defining the cofunctors).
By the way, discrete opfibrations can be regarded both as functors and as cofunctors, so it’s reasonable to wonder whether the two notions of natural transformation—between them as functors and as cofunctors—coincide. Brandon Shapiro and I convinced ourselves with a convoluted argument that they do coincide, except that the two notions point in opposite directions. I reached out to Bryce Clarke to confirm, and he responded with a very elegant proof that this is correct, so thanks to him for that! But because the two notions point in opposite directions in the best of cases and are even more deeply opposite in other cases, I feel a bit torn as to whether we should call the maps between cofunctors ‘cotransformations’ (following Aguiar) or ‘transformations’ (following Clarke and di Meglio). For this blog post, which is pretty low-stakes, I’ve decided it’s best to follow Clarke.
3 Vertical and horizontal composition
It’s pretty easy to guess what the identity natural transformation on some should be. We need a direction field , and we have floating around. Trying it, we see that it works: the unitality of and imply that (1) commutes.
The vertical composition of natural transformations
is slightly more surprising: given two polynomial maps , how should you “compose” them? It turns out that the set of direction fields on a category carries the structure of a monoid. The idea is pretty easy: gives a morphism out of any object , and gives a morphism out of its codomain , and you can simply compose them to get a morphism out of . Mathematically, the “composite” of and is given by the map
We have thus described a candidate for the composite , but does it make the diagram (1) commute? It’s pretty easy to visualize why it should, by looking at the diagram (2). And the formal proof is easy too: it involves this diagram:
Finally, suppose given natural transformations as follows:
note that gives rise to a unique polynomial map from to , namely . Let’s call this . We can compose it with to get a map , and this is the composite.
It’s often easier to think about whiskering than full-on horizontal composition. The whiskering of with is simple: it’s just the composite direction field . The whiskering of with is even simpler: it’s just !
4 Conclusion
Anyway, that’s it for now. I hope you agree that, once you know that the data of a natural transformation between cofunctors is just a map satisfying something..., you can kind of guess the rest, namely that it should make the two maps agree:
I find it striking that a single monoid, , faithfully controls all the natural transformations between any two cofunctors out of , as well as their identity and composition. That is, for any category , there’s a faithful functor to as a one-object category. Have you ever seen anything like that?
Let me know your thoughts in the comments below!
Footnotes
In this post I’ll assume you know what a polynomial functor (in one variable, in ) is, my particular “positions and directions” vocabulary for it, and the notation to refer to the “on-positions” and “on-directions” parts of a natural transformation, i.e. morphism of polynomial functors, .↩︎