Bruno Gavranović

Home Posts Papers Research Programme About
Posted on September 12, 2019

Dinatural transformations

To kick off my first blog post I decided to write a short technical exposition. Its topic will be a concept from category theory I recently came across: dinatural transformations. As this is a pretty abstract concept, and as expository materials are few and far in between, I decided to share some insights I had while learning about it. I’ll walk you through the main idea, and show how you could have arrived at the definition of a dinatural transformation yourself!

I’ll assume you understand categories, functors, natural transformations, and the notion of covariance/contravariance. I’ll also assume you have looked at (but not necessarily understood) the definition of a dinatural transformation. I won’t highlight any uses of dinatural transformations or convince you to start thinking about them. The goal of this blog post is merely to give you intuition of why their intimidating definition is the way is. So let’s start! I’ll begin with the high-level idea.

From the high-level, while a natural transformation can be defined between functors on any two categories (called \(\alpha\) below left), a dinatural transformation requires that the domain category is a product of a category and its opposite (called \(\beta\) below right).

These two aspects – that the domain is a product and that it is in opposing variance – will be central for defining dinaturality. The product will allow us to define components of the dinatural transformation by taking advantage of the diagonal of this product.1 That is where its name comes from! And the opposing variance will allow us to state a generalised naturality condition, producing the hexagonal diagram seen in the definition of a dinatural transformation. Essentially, we will see how by removing some pieces from natural transformations on functors of type \(\mathcal{C}^{op} \times \mathcal{C} \to \mathcal{D}\) we will end up with dinatural ones. And thus will be able to see that every such natural transformation is also dinatural, but not vice-versa.

So let’s dive in. We start with the category \(\mathcal{C}^{op} \times \mathcal{C}\). This is a category that has a simple property: given any morphism \(f: A \rightarrow B\) in the original category \(\mathcal{C}\), the following square in \(\mathcal{C}^{op} \times \mathcal{C}\) commutes:2

What commutativity means is that, starting at the top-left corner \((B, A)\), using just \(f\) (and identity maps) it does not matter which of the three ways we use to arrive at the bottom-right corner \((A, B)\). We can first move right, and then down, or down and then right, or right and down at the same time (this diagonal arrow isn’t drawn). It does not matter which of these we choose - they’re all equivalent.

Now we can move on to a functor \(F: \mathcal{C}^{op} \times \mathcal{C} \rightarrow \mathcal{D}\). Since every functor has to preserve commutative diagrams, the previously mentioned simple property can be extended. This means that, given any morphism \(f : A \rightarrow B\) in \(\mathcal{C}\) and a functor \(F: \mathcal{C}^{op} \times \mathcal{C} \rightarrow \mathcal{D}\), the following square in \(\mathcal{D}\) commutes:

Simple enough! Now, recall that a natural transformation

assigns to every object \(A\) in \(\mathcal{C}\) a morphism \(\alpha_A: F(A) \rightarrow G(A)\) such that the square below commutes.

One consequence of this definition is that we can replace the top and bottom arrows of this commutative square with commutative squares themselves, and obtain a commutative cube. In our case – where functors \(F, G\) are of type \(\mathcal{C}^{op} \times \mathcal{C} \to \mathcal{D}\) – the objects \(A\) and \(B\) are pairs of objects, and \(F(f)\) and \(G(f)\) represent pairs of morphisms. And the particular commutative square we will be interested in is the one formed out of a single morphism \(f\), that we mentioned above in the context of the product category \(\mathcal{C}^{op} \times \mathcal{C}\). Let’s draw it out, and state the naturality condition for it again. Given a morphism \(f : A \rightarrow B\) in \(\mathcal{C}\), the fact that \(\alpha\) is a natural transformation implies that the following cube commutes:


We are now ready to understand dinatural transformations, which are a mere step away. They crucially rely on the fact that our domain category is a product, and that we need not index our naturality morphisms \(\alpha_{A, B} : F(A, B) \to G(A, B)\) by pairs of objects in \(\mathcal{C}\), but only a single object. I’ll show you the new diagram, and then explain what’s going on.



What happened here is two things. First, since our base \(\mathcal{C}^{op} \times \mathcal{C}\) is a square – we’ve taken the opportunity to index by the diagonal of that square, instead of by its outer edges. This is where the name dinatural transformation comes in. This means we have removed all the non-diagonal naturality morphisms, leaving only those of the form \(\alpha_{X, X} : F(X, X) \rightarrow G(X, X)\). Since we are indexing only by one object, this means that we can leave out the second index \(\alpha_{X, X}\) – we refer to the dinaturality component with just a single subscript.

The story is almost complete. A dinatural transformation \(\beta: F \ddot\rightarrow G\) between two functors \(F, G: \mathcal{C}^{op} \times \mathcal{C} \rightarrow \mathcal{D}\) is a map which to every object \(X\) in \(\mathcal{C}\) associates a map \(\beta_X : F(X, X) \rightarrow G(X, X)\) such that… what commutes? This new naturality condition now has some loose ends. Let’s see what is going on. Naturality condition is supposed to equate different path choices in a graph that contain the naturality morphisms. Observe that some morphisms (colored blue) are not part of any new paths that contain the new naturality morphisms (that is, you can’t find a path that contains both a red and a blue morphism).



This means that we can safely remove the blue morphisms, since they do not play any role in our dinatural transformation.



After doing so, we end up with a new, hexagonal diagram. And we can notice that this is exactly the hexagonal diagram used in the definition of a dinatural transformation as found on Wikipedia or nLab! If you look closely you will see it is just a rotated version of the one I’ve drawn here. This really means that if you were confused by the rationale for having such a hexagonal diagram in the definition of a dinatural transformation – it’s because the rest of the cube isn’t drawn. But it’s good to draw it when learning, and to understand where the diagram comes from.

And this is it, we have defined a dinatural transformation! A dinatural transformation \(\beta: F \ddot\rightarrow G\) between two functors \(F, G: \mathcal{C}^{op} \times \mathcal{C} \rightarrow \mathcal{D}\) is a map which to every object \(X\) in \(\mathcal{C}\) associates a map \(\beta_X : F(X, X) \rightarrow G(X, X)\) such that the diagram above commutes. This allows us to see that the hexagonal diagram is just a diagram of the commutative cube with some morphisms removed. This also allows us to see how every natural transformation between these functors is also a dinatural transformation: one that has non-diagonal naturality morphisms, and one which assumes that the entire cube commutes, instead of just the hexagon.


  1. If you think of a product like a square, then the diagonal of the product is precisely the diagonal of the square: points where the index for the \(X\) coordinate is the same as the index for the \(Y\) coordinate.↩︎

  2. In this diagram each morphism is a pair of morphisms in \(\mathcal{C}\). Also, every drawn morphism always has one component of the pair set to identity.↩︎

Licensed under CC BY-SA 4.0 Site proudly generated by Hakyll. The theme originates in the Hakyll-CSSGarden.