A Compositional Framework for Reaction Networks
John C. Baez, Blake S. Pollard

TL;DR
This paper develops a compositional categorical framework for open reaction networks, linking their structure to dynamical systems and steady-state behaviors through functors and black-boxing techniques.
Contribution
It introduces a functorial approach to model open reaction networks as morphisms and extends black-boxing to steady states, unifying dynamics and statics in a categorical setting.
Findings
Constructed a functor from open reaction networks to open dynamical systems.
Developed a black-boxing functor relating steady states to input-output relations.
Provided a compositional framework for analyzing reaction network dynamics and steady states.
Abstract
Reaction networks, or equivalently Petri nets, are a general framework for describing processes in which entities of various kinds interact and turn into other entities. In chemistry, where the reactions are assigned "rate constants", any reaction network gives rise to a nonlinear dynamical system called its "rate equation". Here we generalize these ideas to "open" reaction networks, which allow entities to flow in and out at certain designated inputs and outputs. We treat open reaction networks as morphisms in a category. Composing two such morphisms connects the outputs of the first to the inputs of the second. We construct a functor sending any open reaction network to its corresponding "open dynamical system". This provides a compositional framework for studying the dynamics of reaction networks. We then turn to statics: that is, steady state solutions of open dynamical systems. We…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
**A Compositional Framework for Reaction Networks
**
*John C. Baez
Department of Mathematics
University of California
Riverside CA, USA 92521
and
Centre for Quantum Technologies
National University of Singapore
Singapore 117543
*Blake S. Pollard
Department of Physics and Astronomy
University of California
Riverside CA 92521
email: [email protected], [email protected]
May 19, 2017
Abstract
Reaction networks, or equivalently Petri nets, are a general framework for describing processes in which entities of various kinds interact and turn into other entities. In chemistry, where the reactions are assigned ‘rate constants’, any reaction network gives rise to a nonlinear dynamical system called its ‘rate equation’. Here we generalize these ideas to ‘open’ reaction networks, which allow entities to flow in and out at certain designated inputs and outputs. We treat open reaction networks as morphisms in a category. Composing two such morphisms connects the outputs of the first to the inputs of the second. We construct a functor sending any open reaction network to its corresponding ‘open dynamical system’. This provides a compositional framework for studying the dynamics of reaction networks. We then turn to statics: that is, steady state solutions of open dynamical systems. We construct a ‘black-boxing’ functor that sends any open dynamical system to the relation that it imposes between input and output variables in steady states. This extends our earlier work on black-boxing for Markov processes.
1 Introduction
Reaction networks, first formally defined by Aris [2] in 1965, are a framework for describing processes whereby entities interact and transform into other entities. While they first arose in chemistry, and are often called ‘chemical reaction networks’, their applications are widespread. For example, a basic model of infectious disease, the SIRS model, is described by this reaction network:
[TABLE]
We see here three types of entity, called ‘species’:
- •
: susceptible,
- •
: infected,
- •
: resistant.
We also have three ‘reactions’:
- •
: infection, in which a susceptible individual meets an infected one and becomes infected;
- •
: recovery, in which an infected individual gains resistance to the disease;
- •
: loss of resistance, in which a resistant individual becomes susceptible.
In general, a reaction network involves a finite set of species, but reactions go between ‘complexes’, which are finite linear combinations of these species with natural number coefficients. The reaction network is a directed graph whose vertices are certain complexes and whose edges are called ‘reactions’.
If we attach a positive real number called a ‘rate constant’ to each reaction, a reaction network determines a system of differential equations saying how the concentrations of the species change over time. This system of equations is usually called the ‘rate equation’. In the example above, the rate equation is
[TABLE]
Here and are the rate constants for the three reactions, and now stand for the concentrations of the three species, which are treated in a continuum approximation as smooth functions . The rate equation can be derived from the ‘law of mass action’, which says that any reaction occurs at a rate equal to its rate constant times the product of the concentrations of the species entering it as inputs.
A reaction network is more than just a stepping-stone to its rate equation. Interesting qualitative properties of the rate equation, such as existence and uniqueness of steady state solutions, can often be determined simply by examining the reaction network, independent of any particular choice of rate constants. Results in this direction began with Feinberg and Horn’s seminal work in the 1960’s [13, 14], leading to the Deficiency Zero and Deficiency One Theorems [15, 16] and more recently to a proof of the Global Attractor Conjecture [11].
In this paper we present a ‘compositional framework’ for reaction networks: that is, a way to build up a reaction network from smaller pieces, in such a way that its rate equation can be determined from those of the pieces. However, this framework requires that we view reaction networks in a somewhat different way, as ‘Petri nets’.
Petri nets were invented by Carl Petri in 1939, when he was just a teenager, for the purposes of chemistry [32]. Much later, they became popular in theoretical computer science [23, 31], biology [26, 27, 36], and other fields [3, 22, 29]. A Petri net is a bipartite directed graph; vertices of one kind represent species, while those of the other kind represent reactions. The edges into a reaction specify which species are inputs to that reaction, while the edges out specify its outputs. One can easily turn a reaction network into a Petri net and vice versa. For example, the reaction network above translates into this Petri net:
[TABLE]
One should beware that the terminology is diverse, since it comes from several communities. In the Petri net literature, species are called ‘places’ and reactions are called ‘transitions’. Indeed, Petri nets are sometimes called ‘place-transition nets’ or ‘P/T nets’. On the other hand, chemists call them ‘species-reaction graphs’ or ‘SR-graphs’. When each reaction of a Petri net has a rate constant attached to it, it is often called a ‘stochastic Petri net’.
While some qualitative properties of a rate equation can be read off from a reaction network, others are more easily read from the corresponding Petri net. For example, properties of a Petri net can be used to determine whether its rate equation has the capacity to admit multiple steady states [6, 12, 17].
Petri nets are also better suited to a compositional framework. The key new concept required is that of an ‘open’ Petri net. Here is an example:
[TABLE]
The box at left shows a set of ‘inputs’ (which happens to be empty), while the box at right shows a set of ‘outputs’. Both inputs and outputs are points at which entities of various species can flow in or out of the Petri net. We say the open Petri net goes from to , and we shall show how to treat it as a morphism in a category we call .
Given an open Petri net with rate constants assigned to each reaction, we explain how to systematically obtain its ‘open rate equation’, which amounts to the usual rate equation with extra terms describing inflows and outflows. The above example has this open rate equation:
[TABLE]
Here are arbitrary smooth functions describing outflows as a function of time.
Given another open Petri net , for example this:
[TABLE]
it will have its own open rate equation, in this case
[TABLE]
Here are arbitrary smooth functions describing inflows. We can compose and by gluing the outputs of to the inputs of , obtaining a new open Petri net , as follows:
[TABLE]
Since this open Petri net has no inputs or outputs, it amounts to an ordinary Petri net, and its open rate equation is a rate equation of the usual kind. Indeed, this is the Petri net we have already seen, and its open rate equation is Equation (1).
There is a systematic procedure for combining the open rate equations for two open Petri nets to obtain that of their composite. In the case at hand it amounts to identifying the outflows of with the inflows of (setting and ) and then adding the right hand sides of Equations (2) and (3). The first goal of this paper is to precisely describe this procedure, and to prove that it defines a functor
[TABLE]
from to a category where the morphisms are ‘open dynamical systems’. By a dynamical system, we essentially mean a vector field on , which can be used to define a system of first-order ordinary differential equations in variables. An example is the rate equation of a Petri net. An open dynamical system allows for the possibility of extra terms that are arbitrary functions of time, such as the inflows and outflows in an open rate equation.
In fact, we prove that and are symmetric monoidal categories and that {\color[rgb]{.75,.75,.75}\definecolor[named]{pgfstrokecolor}{rgb}{.75,.75,.75}\pgfsys@color@gray@stroke{.75}\pgfsys@color@gray@fill{.75}\blacksquare} is a symmetric monoidal functor. To do this, we use the machinery of ‘decorated cospans’, developed by Fong [18, 19] and already applied to electrical circuits [4] and Markov processes [5]. Decorated cospans provide a powerful general tool for describing open systems. A cospan in any category is a diagram of the form
[TABLE]
We are mostly interested in cospans in , the category of finite sets and functions between these. The set , the apex of the cospan, is the set of states of an open system. The sets and are the inputs and outputs of this system. The legs of the cospan, meaning the morphisms and , describe how these inputs and outputs are included in the system. In our application, is the set of species of a Petri net.
For example, we may take this reaction network:
[TABLE]
treat it as a Petri net with :
[TABLE]
and then turn that into an open Petri net by choosing any finite sets and maps , , for example as follows:
[TABLE]
Notice that the maps including the inputs and outputs into the states of the system need not be one-to-one. This is technically useful, but it introduces some subtleties not yet explained in our discussion of the gray-boxing functor.
An open Petri net can thus be seen as a cospan of finite sets whose apex is ‘decorated’ with some extra information, namely a Petri net with as its set of species. Fong’s theory of decorated cospans lets us define a category with open Petri nets as morphisms, with composition given by gluing the outputs of one open Petri net to the inputs of the other. For details see Appendix A, where we recall some results on constructing decorated cospan categories and functors between these.
We call the functor {\color[rgb]{.75,.75,.75}\definecolor[named]{pgfstrokecolor}{rgb}{.75,.75,.75}\pgfsys@color@gray@stroke{.75}\pgfsys@color@gray@fill{.75}\blacksquare}\colon\mathtt{RxNet}\to\mathtt{Dynam} ‘gray-boxing’ because it hides some but not all the internal details of an open Petri net. We can go further and ‘black-box’ an open dynamical system. This amounts to recording only the relation between input and output variables that must hold in steady state. We prove that black-boxing gives a functor
[TABLE]
to a category of ‘semi-algebraic relations’ between real vector spaces, meaning relations defined by polynomials and inequalities. (This relies on the fact that our dynamical systems involve algebraic vector fields, meaning those whose components are polynomials; more general dynamical systems would give more general relations.) We prove that like the gray-boxing functor, the black-boxing functor is symmetric monoidal.
This paper is structured as follows. In Section 2 we review and compare reaction networks and Petri nets. In Section 3 we construct a category where an object is a finite set and a morphism is an open reaction network (or more precisely, an isomorphism class of open reaction networks). In Section 4 we enhance this construction to define a category where the transitions of the open reaction networks are equipped with rate constants. In Section 5 we explain the open dynamical system associated to an open reaction network, and in Section 6 we construct a category of open dynamical systems. In Section 7 we construct the gray-boxing functor {\color[rgb]{.75,.75,.75}\definecolor[named]{pgfstrokecolor}{rgb}{.75,.75,.75}\pgfsys@color@gray@stroke{.75}\pgfsys@color@gray@fill{.75}\blacksquare}\colon\mathtt{RxNet}\to\mathtt{Dynam}. In Section 8 we construct the black-boxing functor . Finally, in Section 9 we fit our results into a larger ‘network of network theories’.
Acknowledgements
We thank Brendan Fong for many conversations, and David Spivak for pointing out his closely related work on black-boxing open dynamical systems [35]. We thank Daniel Cicala for helping us understand the functor sending any finite set to the set of algebraic vector fields on , as discussed in Section 6. We also thank the Centre for Quantum Technologies and DARPA’s Complex Adaptive System Composition and Design Environment program, who helped support this research.
2 Reaction networks versus Petri nets
We begin by precisely defining reaction networks and Petri nets, so we can see that they are two ways of presenting the same concept.
Definition 1**.**
A reaction network consists of:
- •
a finite set ,
- •
a finite set ,
- •
functions .
We call the elements of species, those of complexes, and those of transitions. Any transition has a source and target . If and we write .
Our terminology here is a compromise: as mentioned before, in the Petri net literature ‘species’ are often called ‘places’, while in the chemistry literature ‘transitions’ are often called ‘reactions’. The alphabetical proximity of and gives our compromise a certain charm.
The set of complexes relevant to a given reaction network is
[TABLE]
The reaction network gives a graph with as its set of vertices and a directed edge from to for each transition . This graph may have multiple edges or self-loops. It is thus the kind of graph sometimes called a ‘directed multigraph’ or ‘quiver’. However, a graph of this kind can only arise from a reaction network if every vertex is the source or target of some edge.
On the other hand, we have Petri nets:
Definition 2**.**
A Petri net consists of:
- •
a finite set ,
- •
a finite set ,
- •
functions .
We call the elements of species and those of transitions. We call any Petri net with as its set of species a Petri net on . Given a species and a transition , we say is the number of times appears as an input of , and is the number of times appears as the output of .
It is easy to convert a reaction network into a Petri net, or vice versa, using the relations
[TABLE]
[TABLE]
Thus, anything we do with reaction networks we can do with Petri nets, and vice versa. However, Petri nets are usually drawn in a different way. Given a Petri net we draw a yellow circle for each species , an aqua square for each transition , a certain number of edges from each species to each transition , and a certain number of edges from each transition to each species . This gives a picture of a Petri net as a bipartite graph. For example, this reaction network
[TABLE]
gives a Petri net that we can draw as follows:
[TABLE]
However, we must be a bit careful. A Petri net does not have a well-defined set of edges from a species to a transition , or vice versa: there is merely a natural number and a natural number . Thus, unlike in a reaction network, the edges in a Petri net do not have ‘names’. For example, in the picture above, we are not allowed to distinguish between the three edges from to : these edges are just a convenient way of indicating that .
In what follows we work with reaction networks, since our applications are especially relevant to chemistry, but we often draw them as Petri nets.
3 Open reaction networks
To treat a reaction network as an open system, we equip it with ‘inputs’ and ‘outputs’:
Definition 3**.**
Given finite sets and , an open reaction network from to is a cospan of finite sets
[TABLE]
together with a reaction network on . We often abbreviate all this data as . We say is the set of inputs and is the set of outputs.
The first thing we want to do with open reaction networks is compose them: that is, glue them together to build larger ones. Given open reaction networks and , we can compose them to get an open reaction network .
The process of composition actually involves two steps. These are easy to visualize if we draw each reaction network as a Petri net as explained in Section 2, and also indicate the maps from inputs and outputs into the set of species. For example, suppose looks like this:
[TABLE]
and looks like this:
[TABLE]
To compose them, the first step is to put the pictures together:
[TABLE]
At this point, if we ignore the sets , we have a new reaction network whose set of species is the disjoint union of those for and . The second step is to identify a species of with a species of whenever both are images of the same point in . After this step we can stop drawing everything involving , and get an open reaction network from to :
[TABLE]
This new open reaction network is the desired composite . Note that we have identified the species and and arbitrarily named the resulting species .
Formalizing all this, and proving that we get a category whose morphisms are open reaction networks, is precisely what Fong’s theory of decorated cospans [18, 19] is designed to accomplish. A bit of notation is useful: given a finite set , let be the set of all reaction networks on . Thus, an open reaction network with rates is a cospan of finite sets with apex together with an element . We say that the cospan is decorated by .
Now, suppose we have open reaction networks and and we wish to define their composite . Thus, we have cospans of finite sets
[TABLE]
decorated by elements and . To define their composite, first we compose the cospans, and then we compose the decorations.
To compose the cospans, first we write them as part of a single diagram:
[TABLE]
Then we form the pushout of and over . This is denoted , and is formed by first taking the disjoint union of and and then taking the quotient of this by the finest equivalence relation such that if and for some . This identifies a species of with one of whenever both are images of the same point in . The pushout comes with canonical maps and , so we get a diagram
[TABLE]
and we define the composite cospan to be
[TABLE]
Next we need to decorate this composite cospan with an element of . To get this element we start with what we have, namely and , and apply two maps. First, we apply the obvious map
[TABLE]
that sends a pair of reaction networks, one on and one on , to one on the disjoint union of these two sets. Then, we apply a map
[TABLE]
that glues together the two pieces of this reaction network to get one on . We explain these maps in turn.
First, the ‘obvious’ map is defined by
[TABLE]
In more detail, for the reaction network on the right hand side:
- •
The set of species is the disjoint union .
- •
The set of transitions is the disjoint union .
- •
The source map sends any transition to and any transition to .
- •
The target map sends any transition to and any transition to .
Second, to define the map , we take the canonical map
[TABLE]
from the disjoint union onto the pushout, and use the fact that the is actually a functor, so it is defined not only on finite sets but also on functions betwen these:
Lemma 4**.**
There is a functor such that:
- •
For any finite set , is the set of all reaction networks on .
- •
For any function between finite sets and any reaction network , we have
[TABLE]
where
[TABLE]
and
[TABLE]
Proof.
To prove that is a functor we need only check that preserves composition and sends identity functions to identity functions. Both are straightforward calculations. ∎
To show that our procedure for composing open reaction networks gives a category, we use a result of Fong: it suffices to show that is ‘lax symmetric monoidal’. We recall this concept at the beginning of Appendix A, and Fong’s result in Lemma 28.
Lemma 5**.**
The functor becomes lax symmetric monoidal from to if we equip it with the natural transformation defined in Equation (4) and the map , where is a chosen one-element set, sending its one element to the unique reaction network with no species and no transitions.
Proof.
Here denotes made into a symmetric monoidal category using disjoint union as its tensor product, while denotes made into a symmetric monoidal category with the cartesian product as its tensor product. To check this lemma we must first show that is natural, which is a straightforward calculation. Commutativity of the diagrams needed for the laxness of follows from the universal property of the coproduct in . ∎
Fong’s result almost gives a category with finite sets as objects and open reaction networks as morphisms. However, since the disjoint union of sets is associative only up to isomorphism, so is composition of open reaction networks. Thus, instead of a category, open reaction networks are really morphisms of a bicategory [10]. To obtain a category, Fong uses certain equivalence classes of open reaction networks as morphisms from to . His result then implies:
Theorem 6**.**
There is a category where:
- •
an object is a finite set,
- •
a morphism from to is an equivalence class of open reaction networks from to ,
- •
Given morphisms represented by an open reaction network from to and one from to :
[TABLE]
their composite is the equivalence class of this cospan constructed via a pushout:
[TABLE]
together with the reaction network on obtained by applying the map
[TABLE]
to the pair .
Proof.
This follows from Lemma 5 together with Lemma 28, where we explain the equivalence relation in detail. ∎
In fact, Fong’s machinery proves more. We can take the ‘tensor product’ of two open reaction networks by setting them side by side. They then act in parallel with no interaction between them. This makes into symmetric monoidal category. In fact it is one of a very nice sort, called a ‘hypergraph category’. For more on this concept, see Fong’s thesis [19].
Theorem 7**.**
The category is a symmetric monoidal category where the tensor product of objects and is their disjoint union , while the tensor product of the morphisms
[TABLE]
is defined to be
[TABLE]
In fact is a hypergraph category, and thus a dagger-compact category.
Proof.
This follows from Theorem 3.4 of Fong’s paper on decorated cospans [18]. ∎
4 Open reaction networks with rates
To get a dynamical system from an open reaction network we need to equip its transitions with nonnegative real numbers called ‘rate constants’:
Definition 8**.**
A reaction network with rates consists of a reaction network together with a function specifying a rate constant for each transition. We call any reaction network with rates having as its set of species a reaction network with rates on .
Just as reaction networks are equivalent to Petri nets, reaction networks with rates are equivalent to Petri nets where each transition is equipped with a rate constant. These are usually called ‘stochastic Petri nets’, because they can be used to define stochastic processes [3, 21, 22].
The results of the last section easily generalize to reaction networks with rates:
Definition 9**.**
Given finite sets and , an open reaction network with rates from to is a cospan of finite sets
[TABLE]
together with a reaction network with rates on on . We often abbreviate all this data as .
Lemma 10**.**
There is a functor such that:
- •
For any finite set , is the set of all reaction networks with rates on .
- •
For any function between finite sets and any reaction network with rates , we have
[TABLE]
where and are defined as in Equations (5) and (6).
Proof.
This is a slight variation on Lemma 4. ∎
Lemma 11**.**
The functor can be made lax symmetric monoidal from to . To do this we equip it with the map sending the one element of to the unique reaction network with rates having no species and no transitions, together with natural transformation such that
[TABLE]
where:
- •
The map sends any transition to and any transition to .
- •
The map sends any transition to and any transition to .
- •
The map sends any transition to and any transition to .
Proof.
This is a slight variation on Lemma 5. ∎
We now come to the star of the show, the category :
Theorem 12**.**
There is a category where:
- •
an object is a finite set,
- •
a morphism from to is an equivalence class of open reaction networks with rates from to ,
- •
Given morphisms represented by an open reaction network with rates from to and one from to :
[TABLE]
their composite consists of the equivalence class of this cospan:
[TABLE]
together with the reaction network with rates on obtained by applying the map
[TABLE]
to the pair .
The category is a symmetric monoidal category where the tensor product of objects and is their disjoint union , while the tensor product of the morphisms
[TABLE]
is defined to be
[TABLE]
In fact is a hypergraph category.
Proof.
This follows from Lemmas 11 and 28, where we explain the equivalence relation in detail. ∎
5 The open rate equation
In chemistry, a reaction network with rates is frequently used as a tool to specify a dynamical system. A dynamical system is often defined as a smooth manifold whose points are ‘states’, together with a smooth vector field on saying how these states evolve in time. In chemistry we take where is the set of species: a point describes the concentration of each species . The corresponding dynamical system is a first-order differential equation called the ‘rate equation’:
[TABLE]
where now describes the concentrations as a function of time, and is a vector field on . Of course, is not a smooth manifold. On the other hand, the vector field is better than smooth: its components are polynomials, so it is algebraic. For mathematical purposes this lets us treat as an vector field on all of , even though negative concentrations are unphysical.
In more detail, suppose is a reaction network with rates. Then the rate equation is determined by a rule called the law of mass action. This says that each transition contributes to by the product of:
- •
the rate constant ,
- •
the concentration of each species raised to the power given by the number of times appears as an input to , namely , and
- •
the vector whose th component is the change in the number of items of the species caused by the transition ,
The second factor is a product over all species, and it deserves an abbreviated notation: given we write
[TABLE]
Thus:
Definition 13**.**
We say the time-dependent concentrations obey the rate equation for the reaction network with rates if
[TABLE]
For short, we can write the rate equation as
[TABLE]
where is the vector field on given by
[TABLE]
at any point . We call the components of this vector field reaction velocities, since in the rate equation they describe rates of change of concentrations.
Given an open reaction network with rates, we can go further: we can obtain an open dynamical system. We give a specialized definition of this concept suited to the case at hand:
Definition 14**.**
Given finite sets and , an open dynamical system from to is a cospan of finite sets
[TABLE]
together with an algebraic vector field on .
The point is that given an open dynamical system of this sort, we can write down a generalization of the rate equation that takes into account ‘inflows’ and ‘outflows’ as well as the intrinsic dynamics given by the vector field .
To make this precise, let the inflows and outflows be arbitrary smooth functions of time. We write the inflow at the point as or simply , and similarly for the outflows. Given an open dynamical system and a choice of inflows and outflows, we define the pushforward by
[TABLE]
and define by
[TABLE]
With this notation, the open rate equation is
[TABLE]
The pushforwards here say that for any species , the time derivative of the concentration takes into account the sum of all inflows at such that , minus the sum of outflows at such that .
To make these ideas more concrete, let us see in an example how to go from an open reaction network with rates to an open dynamical system and then its open rate equation. Let be the following reaction network:
[TABLE]
The set of species is and the set of transitions is just . We can make into a reaction network with rates by saying the rate constant of is some positive number . This gives a vector field
[TABLE]
where we abuse notation in a commonly practiced way and use as the coordinates for a point in : that is, the concentrations of the four species with the same names. The resulting rate equation is
[TABLE]
Next, we can make into an open reaction network as follows:
[TABLE]
Here and , while the functions and are given by
[TABLE]
The corresponding open dynamical system is the cospan
[TABLE]
decorated by the vector field on . Finally, the corresponding open rate equation is
[TABLE]
Note that involves the sum of two inflow terms and since , while involves neither inflow nor outflow terms since is in the range of neither nor .
6 The category of open dynamical systems
There is a category where the morphisms are open dynamical systems —-or more precisely, certain equivalence classes of these. We compose two open dynamical systems by connecting the outputs of the first to the inputs of the second.
To construct the category , we again use the machinery of decorated cospans. For this we need a lax monoidal functor sending any finite set to the set of algebraic vector fields on .
Lemma 15**.**
There is a functor such that:
- •
* maps any finite set to*
[TABLE]
- •
* maps any function between finite sets to the function given as follows:*
[TABLE]
where the pullback is given by
[TABLE]
while the pushforward is given by
[TABLE]
Proof.
The functoriality of follows from the fact that pushforward is a covariant functor and pullback is a contravariant functor:
[TABLE]
Lemma 16**.**
The functor becomes lax symmetric monoidal from to if we equip it with the natural transformation
[TABLE]
given by
[TABLE]
together with the unique map . Here and are the inclusions of and into their disjoint union, and we add vector fields in the usual way.
Proof.
By straightforward calculations one can verify all the conditions in the definition of lax symmetric monoidal functor, Def. 24. ∎
Theorem 17**.**
There is a category where:
- •
an object is a finite set,
- •
a morphism from to is an equivalence class of open dynamical systems from to ,
- •
Given an open dynamical system from to and one from to :
[TABLE]
their composite consists of the equivalence class of this cospan:
[TABLE]
together with the algebraic vector field on obtained by applying the map
[TABLE]
to the pair .
The category is a symmetric monoidal category where the tensor product of objects and is their disjoint union , while the tensor product of the morphisms
[TABLE]
is defined to be
[TABLE]
In fact is a hypergraph category.
Proof.
This follows from Lemmas 16 and 28. ∎
7 The gray-boxing functor
Now we are ready to describe the ‘gray-boxing’ functor {\color[rgb]{.75,.75,.75}\definecolor[named]{pgfstrokecolor}{rgb}{.75,.75,.75}\pgfsys@color@gray@stroke{.75}\pgfsys@color@gray@fill{.75}\blacksquare}\colon\mathtt{RxNet}\to\mathtt{Dynam}. This sends any open reaction network to the open dynamical system that it determines. The functoriality of this process says that we can first compose networks and then find the open dynamical system of the resulting larger network, or first find the open dynamical system for each network and then compose these systems: either way, the result is the same.
To construct the gray-boxing functor we again turn to Fong’s theory of decorated cospans. Just as this theory gives decorated cospan categories from lax symmetric monoidal functors, it gives functors between such categories from monoidal natural transformations. For details, see Theorem 31 in Appendix A.
Theorem 18**.**
There is a symmetric monoidal functor {\color[rgb]{.75,.75,.75}\definecolor[named]{pgfstrokecolor}{rgb}{.75,.75,.75}\pgfsys@color@gray@stroke{.75}\pgfsys@color@gray@fill{.75}\blacksquare}\colon\mathtt{RxNet}\to\mathtt{Dynam} that is the identity on objects and sends each morphism represented by an open reaction network to the morphism represented by the open dynamical system , where is defined by Equation 8. Moreover, {\color[rgb]{.75,.75,.75}\definecolor[named]{pgfstrokecolor}{rgb}{.75,.75,.75}\pgfsys@color@gray@stroke{.75}\pgfsys@color@gray@fill{.75}\blacksquare} is a hypergraph functor.
Proof.
Recall that the functors assign to a set the set of all possible reaction networks on and the set of all algebraic vector fields on , respectively. By Theorem 31, we may obtain a hypergraph functor {\color[rgb]{.75,.75,.75}\definecolor[named]{pgfstrokecolor}{rgb}{.75,.75,.75}\pgfsys@color@gray@stroke{.75}\pgfsys@color@gray@fill{.75}\blacksquare}\colon\mathtt{RxNet}\to\mathtt{Dynam} from a monoidal natural transformation . For any , let us define by
[TABLE]
where the vector field is given by Equation 8.
To check the naturality of , we must prove that the following square commutes:
[TABLE]
where was defined in Lemma 10 and was defined in Lemma 15. So, consider any element : that is, any reaction network with rates
[TABLE]
Let . Thus,
[TABLE]
We need to check that , or in other words,
[TABLE]
To do this, recall from Equation 8 that for any concentrations we have
[TABLE]
Using Equation (7) and the definition of pushforward and pullback, we obtain
[TABLE]
Thus,
[TABLE]
so as desired.
We must also check that is monoidal. By Definition 30, this means showing that
[TABLE]
commutes for all , where was defined in Lemma 11 and was defined in Lemma 16. This is straightforward. ∎
The idea behind this theorem is best explained with an example. Consider two composable open reaction networks with rates. The first, , is this:
[TABLE]
It has species and transitions . The vector field describing its dynamics is
[TABLE]
The corresponding open rate equation is
[TABLE]
The second open reaction network with rates, , is this:
[TABLE]
It has species and transitions . The vector field describing its dynamics is
[TABLE]
The corresponding open rate equation is
[TABLE]
Composing and gives , which looks like this:
[TABLE]
Note that the states and have been identified, and we have arbitrarily called the resulting state . Thus, has species . If we had chosen to call the resulting state something else, we would obtain an equivalent open reaction network with rates, and thus the same morphism in .
At this point we can either compute the vector field or combine the vector fields and following the procedure given in Theorem 17. Because {\color[rgb]{.75,.75,.75}\definecolor[named]{pgfstrokecolor}{rgb}{.75,.75,.75}\pgfsys@color@gray@stroke{.75}\pgfsys@color@gray@fill{.75}\blacksquare} is a functor, we should get the same answer either way.
The vector field can be read off from the above picture of . It is
[TABLE]
[TABLE]
On the other hand, the procedure in Theorem 17 is to apply the composite of these maps:
[TABLE]
to the pair of vector fields . The first map was defined in Lemma 16, and it yields
[TABLE]
If we call this vector field , the second map yields
[TABLE]
Applying to any vector of concentrations yields , since the species and are identified by . Thus,
[TABLE]
Applying to this, we sum the third and fourth components, again because and are identified by . Thus,
[TABLE]
As expected, this vector field equals . The open rate equation of the composite open dynamical system is
[TABLE]
One general lesson here is that when we compose open reaction networks, the process of identifying some of their species via the map has two effects: copying concentrations and summing reaction velocities. Concentrations are copied via the pullback , while reaction velocities are summed via the pushfoward . A similar phenomenon occurs the compositional framework for electrical circuits, where voltages are copied and currents are summed [4]. For a deeper look at this, see Section 6.6 of Fong’s thesis [19].
8 The black-boxing functor
The open rate equation describes the behavior of an open dynamical system for any choice of inflows and outflows. One option is to choose these flows so that the input and output concentrations do not change with time. In chemistry this is called ‘chemostatting’. There will then frequently—though not always—be solutions of the open rate equation where all concentrations are constant in time. These are called ‘steady states’.
In this section we take an open dynamical system and extract from it the relation between input and output concentrations and flows that holds in steady state. We call the process of extracting this relation ‘black-boxing’, since it discards information that cannot be seen at the inputs and ouputs. The relation thus obtained is always ‘semi-algebraic’, meaning that it can be described by polynomials and inequalities. In fact, black-boxing defines a functor
[TABLE]
where is the category of semi-algebraic relations between real vector spaces. The functoriality of black-boxing means that we can compose two open dynamical systems and then black-box them, or black-box each one and compose the resulting relations: either way, the final answer is the same.
We can also black-box open reaction networks with rates. To do this, we simply compose the gray-boxing functor with the black-boxing functor:
[TABLE]
We begin by explaining how to black-box an open dynamical system.
Definition 19**.**
Given an open dynamical system we define the boundary species to be those in , and the internal species to be those in .
The open rate equation says
[TABLE]
but if we fix , and to be constant in time, this reduces to
[TABLE]
This leads to the definition of ‘steady state’:
Definition 20**.**
Given an open dynamical system together with and , a steady state with inflows and outflows is an element such that
[TABLE]
Thus, in a steady state, the inflows and outflows conspire to exactly compensate for the reaction velocities. In particular, we must have
[TABLE]
since the inflows and outflows vanish on internal species.
Definition 21**.**
Given a morphism in represented by the open dynamical system
[TABLE]
define its black-boxing to be the set
[TABLE]
consisting of all 4-tuples where is a steady state with inflows and outflows .
We call the input concentrations and the output concentrations. Thus, black-boxing records the relation between input concentrations, inflows, output concentrations and outflows that holds in steady state. This is the ‘externally observable steady state behavior’ of the open dynamical system.
Category theory enters the picture because relations are morphisms in a category. For any sets and , a relation is a subset . Given relations and , their composite is the set of all pairs such that there exists with and . This gives a category with sets as objects and relations as morphisms.
Black-boxing an open dynamical system gives a relation
[TABLE]
This immediately leads to the question of whether black-boxing is a functor from to .
The answer is yes. To get a sense for this, consider the example from Section 7, where we composed two open dynamical systems. We first considered this open reaction network with rates:
[TABLE]
Gray-boxing this gives a morphism in , say , represented by the open dynamical system
[TABLE]
where the cospan is visible in the figure and is the vector field on given in Equation (9). If we now black-box , we obtain the relation
[TABLE]
Here the inflows and outflows are
[TABLE]
and vector of concentrations is , so the input and output concentrations are
[TABLE]
To find steady states with inflows and outflows we take the open rate equation, Equation (10), and set all concentrations, inflows and outflows to constants:
[TABLE]
Thus,
[TABLE]
[TABLE]
Next we considered this open reaction network with rates:
[TABLE]
Gray-boxing this gives a morphism in represented by the open dynamical system
[TABLE]
where is given by Equation (11). To black-box we can follow the same procedure as for . We take the open rate equation, Equation (12), and look for steady-state solutions:
[TABLE]
Then we form the relation between input concentrations, inflows, output concentrations and outflows that holds in steady state:
[TABLE]
Finally, we can compose these two open reaction networks with rates:
[TABLE]
Gray-boxing the composite gives a morphism represented by the open dynamical system
[TABLE]
where is given in Equation (13). To black-box we take its open rate equation, Equation (14), and look for steady state solutions:
[TABLE]
The concentrations of internal species play only an indirect role after we black-box an open dynamical system, since black-boxing only tells us the steady state relation between input concentrations, inflows, output concentrations and outflows. In and there were no internal species. In there is one, namely . However, in this particular example the concentration is completely determined by the other data, so we can eliminate it from the above equations. This is not true in every example. But we can take advantage of this special feature here, obtaining these equations:
[TABLE]
We thus obtain
[TABLE]
[TABLE]
We leave it to the reader to finish checking the functoriality of black-boxing in this example:
[TABLE]
To do this, it suffices to compose the relations given in Equation (15) and given in Equation (16).
This example was a bit degenerate, because in each open dynamical system considered there was at most one steady state compatible with any choice of input concentrations, inflows, output concentrations and outflows. In other words, even when there was an internal species, its concentration was determined by this ‘boundary data’. This is far from generally true! Even for relatively simple ‘closed’ reaction networks, namely those with no boundary species, multiple steady states may be possible. Such reaction networks often involve features such as ‘autocatalysis’, meaning that a certain species is present as both an input and an output to the same reaction. Criteria for the uniqueness of steady states have been a major focus of reaction network theory ever since its birth [6, 13, 14, 15], and so have criteria for the existence of multiple steady states [12, 16]. We expect the study of open reaction networks to give a new outlook on these questions. However, our proof of the functoriality of black-boxing sidesteps this issue.
Before proving this result, it is nice to refine the framework slightly. The black-boxing of an open dynamical system is far from an arbitrary relation: it is always ‘semialgebraic’. To understand this, we need a lightning review of semialgebraic geometry [9].
Let us use ‘vector space’ to mean a finite-dimensional real vector space. Given a vector space , the collection of semialgebraic subsets of is the smallest collection that contains all sets of the form and , where is any polynomial, and is closed under finite intersections, finite unions and complements. The Tarski–Seidenberg theorem says that if is semialgebraic then so is its projection to , that is, the subset of given by
[TABLE]
If and are vector spaces, a semialgebraic relation is a semialgebraic subset . If and are semialgebraic relations, so is their composite
[TABLE]
thanks to the Tarski–Seidenberg theorem. The identity relation on any vector space is also semialgebraic, so we obtain a category:
Definition 22**.**
Let be the category with vector spaces as objects and semialgebraic relations as morphisms.
This category is symmetric monoidal in a natural way, where the tensor product of objects is given by the direct sum of vector spaces. We can now state the main theorem about black-boxing:
Theorem 23**.**
There is a symmetric monoidal functor sending any finite set to the vector space and any morphism to its black-boxing .
Proof.
For any morphism in represented by the open dynamical system
[TABLE]
the set
[TABLE]
is defined by polynomial equations, since is algebraic. Thus, by the Tarski–Seidenberg theorem, the set
[TABLE]
is semialgebraic.
Next we prove that is a functor. Consider composable morphisms and in . We know that is represented by some open dynamical system
[TABLE]
while is represented by some
[TABLE]
To compose these, we form the pushout
[TABLE]
Then is represented by the open dynamical system
[TABLE]
where
[TABLE]
To prove that is a functor, we first show that
[TABLE]
Thus, given
[TABLE]
with
[TABLE]
we need to prove that
[TABLE]
To do this, it suffices to find concentrations such that
[TABLE]
and is a steady state of with inflows and outflows .
Since this diagram commutes:
[TABLE]
so by the universal property of the pushout there is a unique map such that this commutes:
[TABLE]
This simply says that because the concentrations and agree on the ‘overlap’ of our two open dynamical systems, we can find a concentration for the composite system that restricts to on and on .
We now prove that is a steady state of the composite open dynamical system with inflows and outflows :
[TABLE]
To do this we use the fact that is a steady state of with inflows and outflows :
[TABLE]
and is a steady state of with inflows and outflows :
[TABLE]
We push forward Equation (20) along , push forward Equation (21) along , and sum them:
[TABLE]
Since and , two terms cancel, leaving us with
[TABLE]
Next we combine the terms involving the vector fields and , with the help of Equation (18) and the definition of :
[TABLE]
This leaves us with
[TABLE]
which is Equation (19), precisely what we needed to show.
To finish showing that is a functor, we need to show that
[TABLE]
So, suppose we have
[TABLE]
We need to show
[TABLE]
where
[TABLE]
and
[TABLE]
To do this, we begin by choosing
[TABLE]
This ensures that Equation (23) holds, and since , it also ensures that
[TABLE]
So, to finish the job, we only need to find an element such that is a steady state of with inflows and outflows and is a steady state of with inflows and outflows . Of course, we are given the fact that is a steady state of with inflows and outflows .
In short, we are given Equation (19), and we want to find such that Equations (20) and (21) hold. Thanks to our choices of and , we can use Equation (22) and rewrite Equation (19) as
[TABLE]
Equations (20) and (21) say that
[TABLE]
Now we use the fact that
[TABLE]
is a pushout. Applying the ‘free vector space on a finite set’ functor, which preserves colimits, this implies that
[TABLE]
is a pushout in the category of vector spaces. Since a pushout is formed by taking first a coproduct and then a coequalizer, this implies that
[TABLE]
is a coequalizer. Thus, the kernel of is the image of . Equation (24) says precisely that
[TABLE]
Thus, it is in the image of . In other words, there exists some element such that
[TABLE]
This says that Equations (20) and (21) hold, as desired.
Finally, we need to check that is symmetric monoidal. But this is a straightforward calculation, so we leave it to the reader. ∎
This theorem can also be proved using Fong’s theory of ‘decorated corelations’ [19, 20]. Decorated corelations are generalization of decorated cospans well-suited to extracting the externally observable behavior from an open system. The category is an example of a decorated corelation category that is not a decorated cospan category.
9 Conclusions
It is worth comparing our black-boxing theorem, Theorem 23, to Spivak’s work on open dynamical systems [35]. He describes various categories where the morphisms are open dynamical systems, and constructs functors from these categories to , which describe the steady state relations between inputs and outputs. None of his results subsume ours, but they are philosophically very close. Both are doubtless special cases of a more general theorem that is yet to be formulated.
It is also worth comparing Theorem 23 to our previous black-boxing theorem for open Markov processes [5]. In this previous work, we began by describing a category whose morphisms are equivalence classes of open Markov processes. In fact is equivalent to the subcategory of with all the same objects but only those morphisms coming from open reaction networks for which each transition has exactly one input and one output. There is thus an inclusion of categories
[TABLE]
We did not construct a black-boxing functor for , but only for a related category where the morphisms are equivalence classes of ‘detailed balanced’ Markov process. Since the differential equation describing a Markov process is linear, we obtained a black-boxing functor
[TABLE]
where is the category of vector spaces and linear relations.
Since every open detailed balanced Markov process has an underlying open Markov process, there is a forgetful functor
[TABLE]
Since every linear relation is a semialgebraic relation, there is also a functor
[TABLE]
Combining all the results mentioned so far, we obtain this diagram:
[TABLE]
This commutes up to natural isomorphism, because our previous black-boxing functor agrees with our new procedure in the special case of open detailed balanced Markov processes. Furthermore, our new procedure assigns a linear relation to any open dynamical system coming from an open Markov processes. Thus, there is a functor
[TABLE]
making this diagram commute up to natural isomorphism:
[TABLE]
Our previous work obtained the functor by reducing detailed balanced Markov processes to electrical circuits made of resistors and using an already established procedure for black-boxing these [4]. We constructed a triangle of functors that commutes up to natural isomorphism:
[TABLE]
Here is a category whose morphisms are equivalence classes of open circuits made of resistors, and {\color[rgb]{.25,.25,.25}\definecolor[named]{pgfstrokecolor}{rgb}{.25,.25,.25}\pgfsys@color@gray@stroke{.25}\pgfsys@color@gray@fill{.25}\blacksquare}\colon\mathtt{Circ}\to\mathtt{LinRel} is the black-boxing functor for these.
Combining all these results, we obtain the following diagram of functors:
[TABLE]
This diagram, which commutes up to natural isomorphism, makes our current understanding of these various subjects seem a bit more unified than it actually is. Steady states of circuits made of resistors obey a variational principle: the principle of least power [4]. Similarly, steady states of detailed balanced Markov processes obey the principle of minimum dissipation [5]. We used these variational principles to define the black-boxing functors for these systems, and as a result we obtained not merely linear relations between vector spaces, but Lagrangian relations between symplectic vector spaces. As far as we know, the steady states of more general Markov processes, or reaction networks with rates, do not obey any extremal principle.
Appendix A Decorated cospan categories
For ease of reference, we recall some definitions and theorems from Fong’s work on decorated cospans [18, 19]. We assume some familiarity with basic category theory, such as colimits and symmetric monoidal categories [28]. We need the concept of lax symmetric monoidal functor:
Definition 24**.**
Let and be symmetric monoidal categories. A lax symmetric monoidal functor
[TABLE]
is a functor equipped with a natural transformation
[TABLE]
and a morphism
[TABLE]
where and are the unit objects for and , such that four diagrams commute. These diagrams are the associator hexagon:
[TABLE]
where the horizontal arrows come from the associators for and , the left and right unitor squares:
[TABLE]
and
[TABLE]
where the isomorphisms come from the unitors for and , and the braiding square:
[TABLE]
where the isomorphisms come from the braidings for and .
Let denote the category of sets and functors made into a symmetric monoidal category with the cartesian product as its tensor product. We write for a chosen one-element set serving as the unit for this tensor product. Given a category with finite colimits, we let denote this category made into a symmetric monoidal category with the coproduct as its tensor product, and write [math] for a chosen initial object serving as the unit of this tensor product.
The decorated cospan construction is then as follows. Suppose is a category with finite colimits and
[TABLE]
is a lax symmetric monoidal functor.
Definition 25**.**
Given objects , an -decorated cospan* from to is a pair consisting of a cospan in and an element . We call the decoration.*
Definition 26**.**
Given two decorated cospans
[TABLE]
their composite is the cospan from to constructed via a pushout as follows:
[TABLE]
together with the decoration obtained by applying the map
[TABLE]
to the pair . Here is the canonical morphism from the coproduct to the pushout.
Composition of decorated cospans is not associative until we quotient by the following equivalence relation. It is straightforward to check that composition of decorated cospans is well-defined at the level of equivalence classes.
Definition 27**.**
Two decorated cospans from to
[TABLE]
are said to be equivalent if there is an isomorphism such that and this diagram commutes:
[TABLE]
Lemma 28** (Fong).**
There is a category , whose objects are those of and whose morphisms from to are equivalence classes of decorated cospans from to , composed as above.
Proof.
This is Proposition 3.2 in Fong’s paper on decorated cospans [18]. ∎
In fact is much better than a mere category. To begin with, it is a monoidal category, where the tensor product of objects is the disjoint union of sets and the tensor product of morphisms arising from two decorated cospans
[TABLE]
is the morphism associated to this decorated cospan:
[TABLE]
Fong goes further: he proves that is a specially nice sort of symmetric monoidal category, called a ‘dagger compact category’, in which any morphism can be turned around to give a morphism . The dagger of
[TABLE]
is simply
[TABLE]
but some properties must hold for this operation to give a dagger compact category.
The importance of such categories was highlighted in Abramsky, Coecke and Selinger’s work on quantum theory [1, 34]. But in fact, is a particularly well-behaved sort of dagger compact category: a ‘hypergraph category’. These were first introduced by Carboni [8] under another name, ‘well-supported compact closed categories’. They were renamed ‘hypergraph categories’ by Kissinger [25], in reference to the fact that such categories contain morphisms corresponding to arbitrary hypergraphs: that is, diagrams with wires connecting any number of inputs to any number of outputs. The definition and significance of all these concepts are clearly explained in Fong’s thesis [19].
Theorem 29** (Fong).**
Suppose is a category with finite colimits and
[TABLE]
is a lax symmetric monoidal functor. Then the category is a symmetric monoidal category, and in fact a hypergraph category.
Proof.
This is Theorem 3.4 in Fong’s paper on decorated cospans [18]. ∎
Decorated cospan categories help us understand diagrams of open systems, and how to manipulate them. We also need the ability to take such diagrams and read off their ‘meaning’, for example via the rate equation. For this we need functors between decorated cospan categories. Fong found a way to construct these from monoidal natural transformations [18]. Moreover, he proved that the resulting functors are actually ‘hypergraph functors’, meaning the sort that preserves all the structure of a hypergraph category. As a corollary they are a symmetric monoidal dagger functors.
Definition 30**.**
A monoidal natural transformation from a lax symmetric monoidal functor
[TABLE]
to a lax symmetric monoidal functor
[TABLE]
is a natural transformation such that
[TABLE]
commutes.
Theorem 31** (Fong).**
Let be a category with finite colimits and let
[TABLE]
and
[TABLE]
be lax symmetric monoidal functors. This gives rise to decorated cospan categories and .
Suppose furthermore that we have a monoidal natural transformation . Then there is a symmetric monoidal functor
[TABLE]
mapping each object to the object and each morphism represented by an -decorated cospan
[TABLE]
to the morphism represented by the -decorated cospan
[TABLE]
In fact is a hypergraph functor.
Proof.
This is a special case of Theorem 4.1 in Fong’s paper on decorated cospans [18]. ∎
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] S. Abramsky and B. Coecke, A categorical semantics of quantum protocols, in Proceedings of the 19th IEEE Conference on Logic in Computer Science (LICS 2004), IEEE Computer Science Press, 2004, pp. 415–425. Available as ar Xiv:quant-ph/0402130 .
- 2[2] R. Aris, Prolegomena to the rational analysis of systems of chemical reactions, Arch. Rational Mech. Anal. 19 (1965), 81–99.
- 3[3] J. C. Baez and J. D. Biamonte, Quantum techniques for stochastic mechanics. Available as ar Xiv:1209.3632 .
- 4[4] J. C. Baez and B. Fong, A compositional framework for passive linear networks. Available as ar Xiv:1504.05625 .
- 5[5] J. C. Baez, B. Fong and B. Pollard, A compositional framework for Markov processes, Jour. Math. Phys. 57 (2016), 033301. Available as ar Xiv:1508.06448 .
- 6[6] M. Banaji and G. Craciun, Graph-theoretic criterion for injectivity and unique equilibria in general chemical reaction systems, Adv. Appl. Math. 44 (2010), 168–184. Available as ar Xiv:0809.1308 .
- 7[7] R. Bruni, J. Meseguer, U. Montanari and V. Sassone, Functorial models for Petri nets, Information and Computation 170 (2001), 207–236.
- 8[8] A. Carboni, Matrices, relations and group representations, J. Algebra 138 (1991), 497–529.
