Comb Diagrams for Discrete-Time Feedback

by   Mario Román, et al.

The data for many useful bidirectional constructions in applied category theory (optics, learners, games, quantum combs) can be expressed in terms of diagrams containing "holes" or "incomplete parts", sometimes known as comb diagrams. We give a possible formalization of what these circuits with incomplete parts represent in terms of symmetric monoidal categories, using the dinaturality equivalence relations arising from a coend. Our main idea is to extend this formal description to allow for infinite circuits with holes indexed by the natural numbers. We show how infinite combs over an arbitrary symmetric monoidal category form again a symmetric monoidal category where notions of delay and feedback can be considered. The constructions presented here are still preliminary work.



There are no comments yet.


page 1

page 2

page 3

page 4


Universal Constructions for (Co)Relations: categories, monoidal categories, and props

Calculi of string diagrams are increasingly used to present the syntax a...

Wiring diagrams as normal forms for computing in symmetric monoidal categories

Applications of category theory often involve symmetric monoidal categor...

Open Diagrams via Coend Calculus

Morphisms in a monoidal category are usually interpreted as processes, a...

Symmetric Monoidal Categories with Attributes

When designing plans in engineering, it is often necessary to consider a...

A Graphical Calculus for Lagrangian Relations

Symplectic vector spaces are the phase space of linear mechanical system...

Evaluating Linear Functions to Symmetric Monoidal Categories

A number of domain specific languages, such as circuits or data-science ...

Coend Calculus and Open Diagrams

Morphisms in a monoidal category are usually interpreted as processes or...
This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction: finite combs

The name “comb diagram” comes from the quantum combs present on the work of Chiribella, D’Ariano and Perinotti [chiribella08], where they are defined as “circuit boards in which one can insert variable subcircuits”. For our purposes, we will assume that each circuit board can have multiple holes waiting for the insertion of potentially different subcircuits. Consider the following circuit [chiribella08, Figure 1] and its adaptation.

Their original work does not mention category theory, but the category theorist will recognize this circuit as a diagram on a, possibly symmetric, monoidal category. Rewording our goal, we want to consider holes or incomplete parts inside symmetric monoidal categories, while keeping a notion of equality between incomplete circuits that preserves the transformations of the graphical calculus of symmetric monoidal categories. A first simplification of the problem comes from the same article.

It is clear that by reshuffling and stretching the internal wires any circuit board can be reshaped in the form of a ”comb”, with an ordered sequence of slots, each between two successive teeth, as in Fig. 3. The order of the slots is the causal order induced by the flow of quantum information in the circuit board.” – [chiribella08]

Which can be translated for the category theorist as saying that we should use the symmetric structure to push the holes to the boundaries of the diagram where possible. The resulting diagram, adapted again for clarity, delineates a characteristic comb shape.

Our goal is to describe circuit boards like these. Assume we want to describe, for instance, the set of all the possible circuit boards with two holes. That means we want to consider all possible triples of morphisms of the following shape.

However, just defining combs to be a triple would miss the point, as it would not equate diagrams that are the same up to the usual transformations in a symmetric monoidal category. We need to keep track of the connecting wire between morphisms; and we do this by explicitly quotienting out by an equivalence relation generated by all pairs of diagrams with the following shapes.

The crucial step is to observe that these quotient relations can be rewritten in a compact way using the dinaturality conditions of a coend, as defined for instance in [maclane78, §IX.6]. The advantage of this description is that coends follow some practical rules of manipulation based on the Yoneda lemma; this is the coend calculus described by [loregian15]. We can regard the same triple, this time as an element of a set described as a coend.

Following this idea, we can propose a definition of comb in terms of coends.

An n-comb between two families of objects and is an element of the following set.

1.1 Contributions

  • A proposed definition of (Definition 1) and (Definition 2.2) in terms of coends, as a way to model holes in monoidal categories. The definition seems to correspond with the intuition in the literature and relate to other similar domain-specific definitions such as quantum combs (§4.2), lenses (§4.3), and learners (§4.4). A discussion on the graphical representation of the quotienting of a coend in terms of monoidal categories, inspired by Riley’s notation for optics [riley18, §2].

  • A symmetric monoidal category of -comb diagrams2.3) over an arbitrary symmetric monoidal category, together with definitions for a delay functor and a feedback operator (§2.4). We show that, in the cartesian case, this category particularizes into a Kleisli category for a suitable comonad (§3).

2 Infinite combs

2.1 Motivation and examples

Morphisms in a monoidal category are usually interpreted as processes; and composition is interpreted as the process happening strictly after the process . Finite combs for a fixed are processes taking inputs and producing outputs, but they do so in a very specific order: they take the first input, , and produce the first output , only after producing this first output they take the second input, and produce the second output, , only after producing this second output they take the third input, , and so on. This distinguishes them from morphisms .

In practice, processes that alternatively take intputs and produce outptus do so in a indeterminate number of stages; they could even be processes that do not terminate. From this perspective, finite combs feel too limited. The purpose of this section is to construct a category where morphisms are circuits that take inputs and produce outputs in a potentially infinite number of stages. The category itself will turn out to be again a symmetric monoidal category that is suitable to define discrete dynamical systems. We anticipate it with two examples.

[Fibonacci sequence] Consider the bialgebra of natural numbers with copying , discarding , addition and zero . This is the setting for Graphical linear algebra [bonchi:diagrammaticalgebra]. The following diagram represents a morphism that computes the Fibonacci sequence.

There are many details to unpack here. This diagram is describing a state in a category of -combs. States happen to correspond to infinite lists of elements of (see §2.5) and, in particular, this state corresponds to the Fibonacci sequence . The two markings for the initial values ( and ) are morphisms in the category of -combs, and they are required to make compositions well-typed. The feedback operator is not a trace, but we will describe it more carefully in §2.4. Finally, the diagram can be unfolded into the -comb it represents.

[Probabilistic dynamical system] The construction can be repeated in arbitrary symmetric monoidal categories that are not necessarily cartesian. Let be the finite distribution monad. Consider a probabilistic discrete version of the Lotka-Volterra equations (also known as “predator-prey”) with two initial populations of rabbits, , and foxes, . These populations evolve in discrete time according to some probabilistic functions and that take both populations as inputs. The following is a valid diagram in the category of -combs over the Kleisli category of the distribution monad, , describing how both populations interact over time.

The diagram is actually describing a state , which happens to correspond to a coherent family of distributions, . The unfolded comb is an incomplete circuit in the Kleisli category of the distribution monad.

2.2 -combs

We will construct infinite combs as elements of the inverse limit of some incomplete n-combs. Let us first introduce some notation. We use the ground symbol () to denote the fact that we consider diagrams of that shape quotiented by the equivalence relation that disregards any morphism on that wire. For instance, the diagram

Secondly, we use holes () in our diagrams, as in the previous section. They are to be understood formally as pairs of diagrams with some wires connected, quotiented by the equivalence relation that slides morphisms along wires. For instance, the diagram

Formally, we shall make use of the dinaturality condition of a coend or a colimit. For instance,

We will obtain our infinite comb diagrams as an inverse limit of finite diagrams. In order to achieve this, we start by defining what a diagram until stage looks like for any arbitrary . We will call to the set of diagrams with this shape. They will be different from the previously defined n-combs (Definition 1) in that they will leave a wire open to be connected to the next stage. For instance, we define

and we construct maps by projecting the first components. Note how the quotient conditions we defined previously are necessary to make this maps well-defined. Formally, given two numerable families of objects , we are defining a set of , with an open wire, for every .

Our definition of infinite comb, , will be as the inverse limit of a chain

where the morphisms are projections. Note the importance of the quotienting to make these maps well-defined.

An -comb between two families of objects is an element of the inverse limit

Combs in this sense are to be seen as sequences of morphisms quotiented by an equivalence relation that equates

for every family of suitably typed in . Let us introduce diagramatic notation for these morphisms. A generic morphism will be written from now on as the following diagram.

We could have also defined in terms of as

In fact, when is a semicartesian category, meaning that the monoidal unit is a terminal object, both definitions coincide because of the Yoneda lemma.

For semicartesian categories, the definition of -combs can be rewritten as follows.

2.3 The symmetric monoidal category of -combs

The category is symmetric monoidal with the structure inherited from applying the monoidal product of pointwise. This, in turn, will induce a symmetric monoidal structure on . Given two -combs and , we can sequentially compose them into , as in the following diagram.

Given two -combs and , we can compose them in parallel into a comb , as in the following diagram.

Moreover, we can lift a family of morphisms to the following comb. This will later define an identity-on-objects functor .

The previous data determines a symmetric monoidal category with a strict monoidal identity-on-objects functor .


Let us start by showing that the sequential composition previously defined is indeed associative. In fact, the following two diagrams represent the same comb.

The identity -comb can be lifted from the identity in , and it can be checked to be the unit of composition. The same can be done with the unitors and associators, as the monoidal product coincides on objects; checking that they satisfy the required axioms is straigthforward in the graphical calculus. ∎

2.4 Delay and feedback

There exists a fully-faithful and strong monoidal functor that shifts by one every sequence of objects, defined as for . The lifting of this functor to the category of combs is what we will call the delay functor . Given any , we can define as in the following diagram, making the first morphism be the empty diagram. This assignment can be shown to be functorial.

The feedback operator is defined as sending the following generic -comb ,

to the following -comb .

This feedback operator enjoys a trace-like property, in the sense that for every and , it holds that . After applying convenient swappings of the wires, proving this equation amounts to check that the morphisms representing can be slided past the holes.

However, the absence of the yanking equation and the requirement for the start of the trace to be on the image of the delay functor clash with the axioms of a trace. We employ a graphical calculus similar to the one for spherical traced categories [selinger10, §4.5.3] in the examples, with the important caveat that the type of the feedback operator () does not coincide with that of the trace, and considering that it does not satisfy the same graphical equations of a trace. We use this calculus in Examples 2.1 and 2.1.

Apart from naturality, that can be stated graphically in the same way as for traces; the property we have shown before amounts to the following graphical equation.

2.5 States

Let us describe what states are in the category of -combs. Note first that the monoidal unit on the category of combs is the monoidal unit on natural-number-indexed objects , which is in turn the constant family of objects given by the unit.

For an arbitrary symmetric monoidal category, , and

As a consequence, we have a description of states in .


We shall apply induction again. In the case, both sides of the isomorphism are equal. In the case we can see that

Finally, note that . ∎

The description of can be made more concrete in the case where the category is semicartesian. In this case, n-combs coincide with n-combs, see Remark 2.2, which makes

Finally, when the semicartesian category has the required limit, these states in the category of combs can be rewritten simply as states of type .

3 Cartesian infinite combs

Cartesian -combs are interesting because of their simplified structure, which helps intuition with their monoidal counterparts. We will characterize -combs in a cartesian category as Kleisli morphisms for a comonad. Let us first characterize finite cartesian combs.

Let be a cartesian monoidal category. Let .


Recall the definition of . The following isomorphism follows from continuity of the hom-functor.

A similar isomorphism can be shown for . The rest of the proof is a straightforward application of induction over the length of the comb and the Yoneda lemma. For the case , we have the following isomorphism because of the cartesian structure and the Yoneda lemma.

Finally, for the case , the induction hypothesis can be used in conjunction with the previous observation to prove an isomorphism.

Let be a cartesian category. We can characterize -combs in as


After the application of Lemma 3, we only need to observe that the inverse limit of the following diagram is the desired product with the comb maps coinciding with the projections.

After this characterization, it is straightforward to show that, for a cartesian category, is equivalent to the Kleisli category for a comonad defined on objects as .

4 Related work

4.1 Feedback, trace, and fixed-point semantics

After writing this text, the author found a remarkable similarity between the ideas of delay and feedback explained here and the informative work of Katis, Sabadini and Walters on feedback and trace [katis:feedback]. Even the terminology coincides quite closely. It seems plausible that we can link our construction to theirs, and that -combs could be made a concrete example of a category with feedback as defined there. However, a direct attempt will not work because of the type of our feedback operator, that requires a delay on the domain. Particularly relevant for us is also their construction, which is almost the data for a piece of an -comb.

[katis:feedback, Definition 2.4] Let be a monoidal category. For any two objects , we define

We can give category structure. The requirement for the coend to be taken over , the maximal subgrupoid of , instead of , distinguishes this category from what we would have defined, by analogy, to be a piece of a comb.

4.2 Quantum causal structures

Our original source of inspiration was the categorical treatment of combs of Kissinger and Uijlen [uijlen17], where they refer to [chiribella08]. However, our usage of combs, and our definition, seem slightly different. In order to compare them, we can study two particular cases.

  • 1-Combs in compact closed category are four-partite states, as in [uijlen17, §2.1]. Fixing , we can compute

  • The data for a comb (as in Definition 1) in a symmetric monoidal closed category does not coincide with the definition of states typed by a comb in [uijlen17, Definition 6.6]. This can be explained by the fact that combs as in [uijlen17, Definition 6.6] are just notation for morphisms in a precausal category.

    Let be symmetric monoidal closed.


    We proceed by induction. For , we have . For the case , we note that

This author, however, does not feel qualified to evaluate how the current construction relates or if it can be of any use to causal structures and prefers to refer the reader to the extensive work of Kissinger and Uijlen [uijlen17] for a categorical treatment of these quantum combs.

4.3 Lenses and optics

An inspiration for these diagrams and the treatment with coends is the lucid account of profunctor optics in functional programming by Riley [riley18]. The reader may notice that the data for the definition of an optic in a monoidal category coincides with that of a 1-comb; moreover, when discussing lawful optics [riley18, §3], Riley introduces notation that suggests the idea of 0-combs and 2-combs.

A popular example of optics are lenses, pairs of functions named and . After the diagrams in [riley18], one can check that the data for a lens in a cartesian category is exactly that of a 1-comb.

However, there is a crucial difference between optics (and in particular, lenses) and 1-combs. Optics come equipped with a given composition rule, namely, that of including one comb inside the other. In other words, the second part of a lens is contravariant. 1-Combs can be composed in at least two ways (see the following diagrams), and the composition of arbitrary finite combs admits a rich combinatorial structure of possible interleavings that we leave as further work.

Related to this discussion, Spivak [spivak19, Example 2.5] observes that the data for a dynamical system coincides with that of lenses of a particular shape . The combs we have described could maybe help to further justify this coincidence and the connection with wiring diagrams [schultz16].

4.4 Learners

The work of Fong and Johnson [fong19]

proposes a compositional approach to machine learning by exhibiting a monoidal category whose morphisms represent supervised learning algorithms. A morphism in this category is given by a

learner, quotiented by a suitable equivalence relation.

[fong19, Definition 4.1] A learner taking inputs on a set and producing outputs on a set is given by

  • a set of parameters ,

  • an implementation function ,

  • an update function , and

  • a request function .

The advantage of this definition is that it is very close to our intuition of what a learner should be. However, in the same article on optics as bidirectional data accessors [riley18], Riley notices a sharp alternative definition in terms of coends that can be generalized to arbitrary monoidal categories.

[riley18] Let be a monoidal category. A learner taking inputs on and producing outputs on is an element of the following set represented as a coend.

This could be related to a piece of an infinite comb, but a naive embedding of learners into -combs will fail to be functorial, again because of the contravariant nature of the second part of the learner. In any case, it is interesting to note how the construction (in §4.1 and [katis:feedback, Definition 2.4]) seems precisely to be a learner without the contravariant part. In other words, the data for an element of , before considering the necessary quotienting, is given by

  • a set of parameters , and

  • an implementation-update function .

This contrasts as a simpler description, but the absence of a contravariant part makes it conceptually different.

5 Conclusions

A category whose morphisms can be used to encode discrete dynamical systems can be constructed from the same ideas that give rise to quantum combs, lenses and learners. We have not yet related this idea to other notions of discrete dynamical system, nor to other notions of feedback, and thus this work is still at a very early stage. However, the construction itself seems to be useful to describe examples in a wide range of categories; and it helps explain, in elementary terms, why lenses, learners, and discrete time dynamical systems should be related. In the context of an increasing interest on optics, we may consider useful to take the time to describe this naive approach, if only to compare it with further developments.

5.1 Further directions

  • A crucial next step is to axiomatize the most important properties from this construction and study the universal property of this construction. We probably would need to axiomatize the properties a fully-faithful strong monoidal pointed delay functor and a feedback operator.

  • We have defined infinite comb diagrams, but diagrams usually only open at the extremes. A naive notion of infinite diagram following the technique we have presented would degenerate into a discrete category due to the strong conditions on the quotient relation. Which other ways of defining infinite diagrams are avaliable? Related to this, the choice of as a symbol is deliberately ambiguous; the naming scheme for these constructions should be decided after some generalization is proposed. Using the natural numbers as indexing set is purely motivated by our applications, but repeating the reasoning with different totally ordered sets, or even posets, seems promising.

  • A straightforward generalization restricts the category over which we take coends. We do not need the in the definition of comb to live on , but on any category with a strong monoidal functor to . Intuitively, this would limit the memory or the communication of every process with its future self. Are there interesting applications that are modelled by this kind of limitation?

  • We hope that our diagrammatic description of the similarities and differences between lenses, combs, feedback and learners using coend calculus inspires and helps the intuition on their study. The trace-like feedback structure of the category of learners is mentioned by Fong, Spivak and Tuyéras [tuyeras19, §7.5]

    , together with the need of a construction that helps on the study of recurrent neural networks. Can we apply infinite comb diagrams and their feedback operator to the study of recurrent neural networks?

  • Open games [ghani18] make an extensive use of lenses to model the two-stage process of moving and receiving a utility. How do open games compare to 2-combs? How to handle or rewrite the contravariant part of open games? Can we apply -combs to the study of repeated games?

  • The structure of infinite combs naturally suggests the idea of dialogue. In the field of Categorical Compositional Distributional models of meaning (DisCoCat), there is an ongoing proposal [coecke:discocirc] of modelling sentence composition using wires of indefinite length representing how agents expand across the dialogue. Can we use -combs to model dialoguing agents in DisCoCat?

  • Signal flow diagrams [bonchi:signalflow], as described by Bonchi, Sobociński and Zanasi, share properties with -combs, and their right trace looks close to the feedback operator. In fact, Example 2.1 is a repetition of [bonchi:signalflow, Example 7.3]. What is the precise relation? Can we use -combs to provide semantics of signal flow diagrams?

6 Acknowledgements

The author first noticed a connection between combs and lenses thanks to an exposition of the work of Kissinger and Uijlen [uijlen17] by Daphne Wang. The ideas that developed here took inspiration and benefited greatly from discussions with Jules Hedges and Edward Morehouse about the combinatorial structure of the composition of finite combs; and from discussions with Elena Di Lavore on repeated games.

Mario Román was supported by the European Union through the ESF funded Estonian IT Academy research measure (project 2014-2020.4.05.19-0001).