Diagrams For Actegories

31 Jan 2023 - Dylan Braithwaite

When working with categories of optics, string diagrams are a useful tool for reasoning about and depicting the bidirectional information flow present. For monoidal categories, diagrams for the category of optics over them have a formal standing. Each diagram has a well-defined denotation and we can meaningfully represent dualised objects and counits topologically. In fact Riley proves that the optics construction is in a way the universal category constructed by freely adding counits and dualised objects to any strict symmetric monoidal category. However, in categorical cybernetics we use more exotic forms of optics involving actions of monoidal categories and extra parameters which we draw vertically. It is harder to give formal meaning to diagrams for these things becuase they generally involve collages of morphisms and objects belonging to multiple categories, but we understand what they mean because locally any diagram is a string diagram for one of the categories involved. In this post I am exploring one avenue for making sense of diagrams like this, as diagrams in a category constructed as a collage of actegories when viewed as a kind of categorified profunctor.

Pasted%20image%2020221212222132 Pasted%20image%2020221213022117

As we’ll see, drawing things in this category gives cool colourful string diagrams where we can consider different categories as different coloured regions acting on eachother through their shared boundaries.

I’m assuming throughout the reader is familiar with actegories or ‘actions of monoidal categories’, but if otherwise familiar with monoidal categories and string diagrams, you might get by alright based just on intuition for modules for rings, as actegories are really just a categorification of this concept. Otherwise, Capucci and Gavranović’s Actegories for the Working Amthematician is a great comprehensive reference for the subject.

Section 3 and 8 of Selinger’s survey of graphical languages is a good overview of the kinds of string diagrams being used here.

Strings, collages, and colours

It is well known that monoidal categories are equivalently bicategories with a single object, known as the delooping of the monoidal category, and often denoted as $\mathbb B \mathcal M$ for a monoidal category $\mathcal M$. Objects in the monoidal category correspond to morphisms in the delooping, and morphisms in the monoidal category correspond to 2-cells in $\mathbb B \mathcal M$.

We can in fact take this a step further and similarly consider the “delooping of an actegory” as a 2-object bicategory. Remember that for a monoidal category $\mathcal M$ an $\mathcal M$-module or an $\mathcal M$-actegory is a category $\mathcal C$ with an action of $\mathcal M$ on $\mathcal C$ similar to the action of a monoid on a set.

Given such an $\mathcal M$-actegory $\mathcal C$ we define a bicategory $\mathcal B$ with two objects $L$ and $R$ whose hom-categories are given by:

and where the composition between $\mathcal M$ and $\mathcal C$ is given by the action of $\mathcal M$ on $\mathcal C$. This neatly packages the data of the actegory up into a single bicategory and the actegory structure and properties are represented simply as the structure/properties of the bicategory.

However you might be bothered by how this construction is strangely asymmetric. Partially this is because actegories are only half of a more general picture. Just as how modules over rings can admit new interesting structure when extended to bimodules, there is a lot can be said about category-bimodules that is obscured when we restrict ourselves to only looking at actions on one side.

Definition: $\mathbf{MonCat}$-bimodules

Given two monoidal categories $\mathcal M$ and $\mathcal N$, an $(\mathcal M, \mathcal N)$-bimodule is a category $\mathcal C$ such that

  • $\mathcal M$ acts on $\mathcal C$ on the left: $(\rhd) : \mathcal M \times \mathcal C \to \mathcal C$,
  • $\mathcal N$ acts on $\mathcal C$ on the right: $(\lhd) : \mathcal C \times \mathcal N \to \mathcal C$,
  • $\mathcal C$ has compatibility isomorphisms $m \rhd (c \lhd n) \cong (m \rhd c) \lhd n$.

Elsewhere these things would be referred to as a biactegories. But to avoid confusing with the very similar spelling of bicategories we will instead refer to them as bimodules.

Having seen this definition, it might become apparent how a second action fits into the above bicategorical picture. The object $L$ is the delooping of $\mathcal M$ and the object $R$ is the delooping of $\mathcal N$, then the extra data between these objects describes $\mathcal C$ as well as the way in which the two monoidal categories act on $\mathcal C$. Putting this together, the full construction is as so:

Definition: The collage of a bimodule

Given an $(\mathcal M, \mathcal N)$-bimodule on a category $\mathcal C$ we define a bicategory $\mathcal B$ with two objects $L$ and $R$ whose hom-categories are given by:

  • $\mathcal B(L, L) = \mathcal M$,
  • $\mathcal B(L, R) = \mathcal C$,
  • $\mathcal B(R, R) = \mathcal N$,
  • $\mathcal B(R, L) = 0$.

Those who have seen the collage of a profunctor might find this familiar. The collage is a construction on a profunctor that incorporates into a single category, the data of the source and target categories, as well as the sets over them. Indeed a profunctor is like a bimodule between two categories, whereas a biactegory is a kind of bimodule between two monoidal categories. So this really is the same idea as the collage of a profunctor, but carried out internal to a category other than $\mathbf{Set}$.

To be specific, viewing monoidal categories as certain 1-object double categories, the bimodules are the same as bimodules for double categories. These form the loose arrows a double category of (fibrant) double categories, and the collage of a bimodule is a certain kind of double-colimit: a cotabulator. This exactly coincides with how we could define the collage of a profunctor as a colimit in the double category of categories and profunctors. And this is what motivates us calling this construction the collage of a bimodule.

This started to get pretty technical, but we don’t actually need most of this for what we’re doing in this post. We can forget about all these details and start drawing pictures now!

The delooping of a monoidal category is interesting in that it is the way in which string diagrams for bicategories directly generalise string diagrams for monoidal categories. String diagrams for morphisms in $\mathcal M$ look the same as string diagrams for the corresponding 2-cells in $\mathbb B \mathcal M$. This maybe hints that it could be interesting to look at string diagrams for the collage of an actegory. As well as sounding like a fun arts-and-crafts project, collage string-diagrams give a neat setting for depicting the interaction between morphisms of $\mathcal M$, $\mathcal N$ and $\mathcal C$.

In general a string diagram for a 2-cell betweeen morphisms in $\mathcal B(L, R)$ consists of two string diagrams, one for a morphism in $M$, and one for a morphism in $N$, and joined along a boundary encoding a morphism of $C$.

Pasted%20image%2020221208223021

Having a construction like this, defined on both monoidal categories and bimodules between them, we might ask if this defines some sort of functor into $\mathbf{Bicat}$. Indeed there is a bicategory $\mathbf{Act}$ of monoidal categories and bimodules where:

Then this can be assembled into a lax pseudofunctor $\mathbf{Col}: \mathbf{Act} \to \mathbf{Cospan(Bicat)}$:

For those interested, this functor is the notion of the cospan representation of a double category. Thanks to Matteo Capucci for pointing this out!

The laxity of this functor may seem like an annoying technical detail, but in fact it is an important feature of the embedding. The additional object allows us to represent the structure of the tensor product in an intuitive way, depicting the things being quotiented out as another region in our string diagrams. For example the bimodule isomorphisms are drawn: Pasted%20image%2020221212221201 More generally this provides a diagramatic language for morphisms of $\mathcal C$ and $\mathcal D$ that interact via the action of $\mathcal N$, allowing us to capture emergent behaviours of the interactions by introducing new regions. The functors that introduce these additional regions are faithful, so all diagrams like this denote one in the smaller category. For example, a morphism of the form

Pasted%20image%2020221212222132 is a $(\mathcal C, \mathcal D)$-mixed-optic $\binom c d \rightleftarrows \binom{c’}{d’}$. This is a neat way to visualise optics, but when we draw diagrams for them informally we like to represent the $\mathcal D$ component as flowing backwards. We’ll take a moment to see how we can do this properly because I think it is a good illustration of how this approach to constructing diagrams can really shine. But if you don’t care about optics, you can rightly skip to the next section without missing anything else.

Drawing Optics

In the previous example both categories are drawn with their morphisms moving left-to-right, but we would like to depict the wires from $\mathcal D$ as flowing in the opposite direction to those of $\mathcal C$. To do this we could embed $\mathcal N$ in some larger monoidal category which has dualisable objects and counits. A well known class of categories satisfying this are compact closed categories, however this is a stronger notion than we need. Compact categories allow for bending wires in both directions whereas we only need counits to picture optics. The definition one arrives at by following this thread is that of a teleological category (Hedges). In fact, as mentioned in the introduction, the non-mixed-optics construction can be seen as the free teleological category on a symmetric monoidal category (Riley).

In particular, for any object $m$ there is a counit optic $\varepsilon_m: \binom m i \otimes \binom i m \rightleftarrows \binom i i$.

So in order to depict the bent wire when drawing mixed optics, we need to embed the residual category into optics? This starts to feel a bit circular but in fact there’s no problem with this! Mixed optics have no formal diagramatic representation, but ordinary optics don’t face this problem, so we can draw counits in it perfectly fine: Pasted%20image%2020221213001215

So how do we relate this to our actegory diagrams? One way to apply this is by noticing that $\mathbf{Optic}(\mathcal N)$ is in fact itself an $(\mathcal N, \mathcal N^\text{op})$-bimodule:

we have a left action $m \rhd \binom x y = \binom {m \otimes x} y$ and a right action $\binom x y \lhd n = \binom x {y \otimes n}$.

So instead of $\mathcal C \otimes_N \mathcal D$ we could consider inserting optics in the middle of our diagrams, by working in $\mathcal C \otimes_N \mathbf{Optic}(\mathcal N) \otimes_{N^\text{op}} \mathcal D^\text{op}$.

What exactly is this category? In fact, it is equivalent to the category of mixed $(C, D)$-optics. An object of this tensor product is a tuple $\left(c, \binom n m, d\right)$, but the tensor isomorphisms mean that this is isomorphic to $\left(c \lhd n, \binom i i, m \rhd d\right)$. And so, we can identify any pair of morphisms $f: c \to c’ \lhd m$ and $g: m \rhd d’ \to d$ representing an optic, with the composition

[\left(c, \binom i i, d \right) \xrightarrow{\left(f, 1, g\right)} \left(c’ \lhd m, \binom i i, m \rhd d’\right) \cong \left(c’, \binom m m, d’\right) \xrightarrow{\left(1, \varepsilon_m, 1\right)} \left(c’, \binom i i, d’\right).]

So in a way we can see the tensoring with $\mathbf{Optic}(\mathcal N)$ as precisely capturing the mechanism for passing the residual from $\mathcal C$ to ${\mathcal D}^\text{op}$. Using the laxator for this composition we can expose the intermediate optics in our string diagrams, but unfortunately this still doesn’t look exactly the way we would hope:

Pasted%20image%2020221213003446

To draw the counit in $\mathbf{Optic}(\mathcal N)$ we need to consider it with its monoidal structure - here it is drawn simply as a 1-category. Put another way, $\mathbf{Optic}(\mathcal N)$ in the diagram above is depicted 1-dimensionally. We want to expand the line into a 2D region where we can draw the bent wire.

One way to relate the monoidal structure of $\mathbf{Optic}(\mathcal N)$ to the actegorical structure is by observing that the monoidal structure induces an bimodule structure: $\mathbf{Optic}(\mathcal N)$ is canonically an $\mathbf{Optic}(\mathcal N)$-actegory by tensoring, and this satisfies the bimodule condition with the action of $\mathcal N$. So we can expand the tensor product $C \otimes_N \mathbf{Optic}(\mathcal N) \otimes_{N^\text{op}} D^\text{op}$ further as [C \otimes_N \mathbf{Optic}(\mathcal N) \otimes_{\mathbf{Optic}(N)} \mathbf{Optic}(\mathcal N) \otimes_{N^\text{op}} \mathcal D^\text{op}]

where the first $\mathbf{Optic}(\mathcal N)$ factor is regarded as an $(\mathcal N, \mathbf{Optic}(\mathcal N))$-bimodule, and the second factor is regarded as an $(\mathbf{Optic}(\mathcal N), \mathcal N^\text{op})$-bimodule.

Because these new actions are coming from the monoidal product, the boundary between the two monoidal categories is somehow trivial. Any object $x$ that appears there can be pulled into the region it borders by considering it as $x$ acting on the monoidal unit, using the equation $x \cong i \otimes x$. For this reason we can assume without loss of generality that the object on this boundary is always $i$, so we will draw it as a faded line rather than the bold black lines appearing on the boundary in our earlier diagrams.

This is an example of a more general phenomenon which we’ll look at in the next section, but for now lets see what optics look like when we draw this expanded representation of the category. The fully laxated collage of this is a 5 object bicategory, whose diagrams look like the following:

Pasted%20image%2020221213022117

Remember we observed earlier than because of the tensor isomorphisms, any objects in the optic region of the diagram can be moved in and out of the $\mathcal N$ and $\mathcal N^\text{op}$ regions, so we may as well assume that all of the content happens outside the middle region. The bent wire is simply the counit described earlier. Since this is natural we can genuinely slide morphisms around the wire, meaning reparameterisations of the optics are depicted exactly as they are often informally drawn for optics:

Pasted%20image%2020221229210118

There’s a little bit swept under the rug here however. The fact that we obtain an $(\mathbf{Optic}(\mathcal N), \mathcal N)$-bimodule structure on $\mathbf{Optic}(\mathcal N)$ in this way does not occur for every action on a monoidal category $\mathcal N$. So let’s look at why this works and what all can we do with it.

Strong boundaries

In the previous section we were looking at the action of a monoidal category on another category that happens to be monoidal. When this was $\mathcal N$ acting on $\mathbf{Optic}(\mathcal N)$ we found that this could be viewed as a bimodule where the other action was just the tensor product of $\mathbf{Optic}(\mathcal N)$. What exactly does the bimodule condition amount to in this case?

If $\mathcal M$ acts on the left of another monoidal category $\mathcal N$, and we consider $\mathcal N$ as acting on itself on the right by monoidal product when the bimodule condition amounts to a right strength on the action:

[ (m \rhd n) \otimes n’ \cong m \rhd (n \otimes n’).]

We could ask if there is an neat characterisation of the actegories that satisfy this condition. Indeed in Capucci and Gavranovic there is a table in section 5.3 of the various forms of “monoidal actegory”. Each is obtained by taking either monoidal or actegorical structures in categories of monoidal categories or actegories.

The structure we have here of strong actegories is an example of the structure of an action internal in a category of actegories with its cartesian product. Specifically given a monoidal category $\mathcal C$, we can see it as a object of $\mathbf{Act}(\mathcal C)$, the category of $\mathcal C$-actegories, with the self-action given by $\mathcal C$s tensor product. If a monoidal category $\mathcal X$ acts on another category $\mathcal Y$, then we can define a notion of an action of a monoid object in $\mathcal X$ on an object in $\mathcal Y$. Indeed, $\mathbf{Cat}$ acts on $\mathbf{Act}(\mathcal C)$ by cartesian product, so we can define a notion of an action of a monoid in $\mathbf{Cat}$ (a monoidal category), on a $\mathcal C$-actegory. A strong actegory is hence an action in this sense, of a monoidal category on the object $\mathcal C \in \mathbf{Act}(\mathcal C)$.

However, there is another simpler characterisation of these actions. The strength of the action gives us a kind of reduced representation of the action as a tensor product in $\mathcal N$:

[ m \rhd n = (m \rhd i) \otimes n. ]

Note that the data of this action does not actually depend on the value of $n$. It is determined entirely on the action of $m$ on the monoidal unit. Drawing this action in a diagram an interesting picture starts to emerge.

Pasted%20image%2020221213020405

As we noted before, when one of the actions is simply the tensor product the boundary between the monoidal regions trivialises. The compatibilities for the self action of $N$ mean any non-trivial object can be written as that object acting on the monoidal unit $i$. Because the action is determined fully by the action on the unit we assume without loss of generality that the object labelling the boundary is $i$. To look at this another way, this is expressing the identity

In the presence of this property the string diagrams for this action take an interesting shape. The action of $m$ on $i$ looks like an embedding of $\mathcal M$ into $\mathcal N$. This fact suggests we could view $(\rhd)$ as a functor $\mathcal M \to \mathcal N$. That is, from the action we obtain a functor $m \mapsto m \rhd i$. This is moreover a monoidal functor because [(m \otimes m’) \rhd i \cong m \rhd (m’ \rhd i) \cong (m \rhd i) \otimes (m’ \rhd i).] Graphically this looks trivial!

Pasted%20image%2020221229232852

In fact, these strong actegories are equivalent to strong monoidal functors: as we noted, from the left action of $M$ on $N$, we can define a functor $M \to N$ by $m \mapsto m \rhd i_N$, and given a functor $F : M \to N$ we can define an action $m \rhd n = F(m) \otimes n$. So a general monoidal functor can be drawn as so:

Pasted%20image%2020221213021057

The functor defines a boundary between the two monoidal categories, and the action of the functor is depicted as an object crossing the boundary, into the codomain of the functor.

For optics the monoidal functors corresponding to the actions we used earlier are inclusions $N \to \mathbf{Optic}(N)$ sending

[n \mapsto \binom n i]

and $N^\text{op} \to \mathbf{Optic}(N)$ sending

[n \mapsto \binom i n.]

Of course where we defined a left action from $F$ before, we could also define a right action, giving rise to an $(N, M)$-bimodule. This is the companion and conjoint structure of the fibrant double categories of monoidal categories, monoidal functors and bimodules. The left action defined by $F$ makes up the companion of F, and the right action defines the conjoint of $F$.

Diagrams for conjoints work similarly to companions, but have the evaluation of the functors flowing from bottom to top.

Pasted%20image%2020221229235112

This contributes to the depiction of bidirectionality when we draw optics, because we draw the inclusion of $\mathcal N^\text{op} \to \mathbf{Optic}(\mathcal N)$ “backwards” relative to the other inclusion $\mathcal N \to \mathbf{Optic}(\mathcal N)$.

Another application of pairing of companions and conjoints is that they allow you to draw something akin to functor boxes:

Pasted%20image%2020221230002555

However, the relationship between either side of the equation here is slightly vague, because to split the functor box into two, we actually pass into a larger category with an extra copy of $\mathcal M$ and $\mathcal N$.

I think there are a lot more interesting avenues to explore with diagrams like this. I only mentioned optics, but I think the construction could be used to give a more formal status to diagrams for the para and copara constructions. Also the cotabulator construction works for other actions of double categories, which can be used to construct indexed optics where the monoidal action is replaced by the action of a double category of matrices. This has similar string diagrams to above but where the coloured regions are further split into multiple regions corresponding to the different sets indexing the wires.

I’m interested as well in exploring how this related to other approaches for drawing diagrams for optic-ey things. In particular Boisseau shows how mixed optics can be drawn as string diagrams in the bicategory of tambara modules, but the category these are drawn in contain a lot of things that aren’t optics too. The construction here seems to pick out minimal subcategories of this that contain only optics. I think there’s a double bicategory in the sense of Morton of monoidal categories, bimodules, and tambara modules between bimodules, so maybe this is a good setting for some abstract nonesense relating these.

Finally, I started thinking about this construction while wondering if there’s a way to generalise the free cornering construction from Boisseau, Nester, and Roman to mixed optics, but I never managed to connect it back to the kind of diagrams that their construction allows. I’d love to see if there’s some way to connect this to the kind of free proarrow equipment used in thier paper.