From food chains to ODEs by model migration

Blog / Technical reports

Author

Elin Griffiths

Published

2026-11-23

Abstract

The Lotka-Volterra equations model predator-prey systems. An archetypal example of a predator-prey system is a food-web but more generally we will consider signed graphs. In this post I evaluate theories and methods for a push-pull migration of graphs to ODEs which implements the Lotka-Volterra ODE semantics. This work expands on that by Evan Patterson.

NoneCommunicated by Tim Hosgood

This past summer, Elin joined us as a summer researcher in the Oxford office, along with Amitai Nachmany (whose work is summarised in this Oxford Seminar talk). This blog post is a summary of some of the work that she did during those weeks.

1 Introduction

In the closing remarks of CatColab RFC-0001, Evan paints a picture of how CatColab could be programmed to understand predator-prey systems. Six months passed, then recently I started trying to work through it. Today I will share what I’ve observed.

Let’s start with an example of a predator-prey system: foxes eat rabbits, which eat grass. This system is illustrated in the signed graph below. Obviously being eaten alive damages your population and eating enough supports population growth, hence the signs on the edges.

An example food-chain, expressed as a signed graph. All photos from Wikimedia Commons (Fox, Hare, Grass).

An example food-chain, expressed as a signed graph. All photos from Wikimedia Commons (Fox, Hare, Grass).

There are well-known equations which model such systems: the Lotka-Volterra equations, and the equations in the case of the given example are \begin{align*} \dot G &= K_1 G - \alpha GR \\ \dot R &= K_2 R + \beta GR - \gamma RF \\ \dot F &= K_3 F + \delta RF \end{align*} where G, R and F are the populations of grass, rabbits, and foxes respectively, and the coefficients lie in \mathbb{R}. The general model is indeed quite simple: the base growth rate of a species’ population (in the absence of any other species) is proportional to the instantaneous population size, and each interaction with another species introduces an additional growth/decay term proportional to the product of the population sizes of the two species.

In the RFC we find a sketch of an approach for migrating graphs to Lotka-Volterra ODEs by a push-pull migration through a cleverly defined intermediate theory. The part that’s unwritten is how exactly to do the push-pull migration, so that’s what we’ll focus on today. In the RFC it is proposed that in fact having a theory of ODEs will let us consider implementing ODE semantics for models of other theories by applying suitable model migrations. So whilst I have focussed on the example of migrating graphs to Lotka-Volterra ODEs, I believe that graphs are capable of capturing a variety of ODE semantics and in many cases the general approach I present today could be applied. We will also observe some sticking points in (virtual) double category theory with respect to push-pull migration and these observations will be relevant for any push-pull into the theory of ODEs.

I would like to thank Tim for supervising me through this project and everyone at Topos from whom I learned a lot and was deeply inspired. Special thanks go also to José for introducing me to double categories in the first place as supervisor of my recent masters thesis. Over this summer José supervised Tai, my fellow summer researcher at the Oxford office, on a project about hyper-doctrines.

2 Theories, models and semantics

In science and engineering there are various ways to model the world like graphs, databases, systems of ODEs and Petri nets. As category theorists, we use the definitions of these tools as the data of a category, which we call a theory T. Then a model of a theory T is a functor T \to \mathrm{Set}. For example, when T is the category of a parallel pair of arrows s,t : V \rightrightarrows E it is easy to see that a model of T defines a directed graph.

Some scientific models will require a higher structure such as that afforded by double categories and this results in the study of double theories. Even then, there is a difference between scientific models which are set-theoretic vs. those which are category-theoretic. For example chemical reactions are categorical because there is compositionality of reactions, whereas systems of ODEs are merely set-theoretical because compositionality of first-order ODEs fails, because composites are second-order. This could be reconciled by labeling arrows with natural numbers but this is not something we consider here.

Set-theoretic theories are the subject of the RFC, where they are taken to be virtual double categories (VDCs). This means there is no requirement for loose identities, so in particular a functor of VDCs \mathbf{1} \to \mathbb{S}\mathrm{et} picks out a set rather than a category (as a lax double functor \mathbf{1} \to \mathbb{S}\mathrm{et} would otherwise).

The RFC defines a theory \mathbb{T}_\mathrm{ODE} of ODEs as follows.

  • An object \text{State}. Think of the set of species in our food-chain.

  • An object \text{Term} on which there is a Lawvere theory embedded in the tight direction of our VDC. Think of the set of terms appearing in our ODEs with the Lawvere theory providing multiplication of terms.

  • A tight arrow \text{Term}_\text{State}:\text{State} \rightarrow \text{Term}. Think of the terms in the image of this map as “state variables”.

  • A proarrow \text{Contrib: Term} \nrightarrow \text{State}. Think of the set of coefficients in our equations. Projection onto Term indicates which term the coefficient belongs to, and projection onto State indicates which equation it appears in.

This blog is about migrating graphs to ODEs, so we should probably have a double theory of graphs. In the RFC, \mathbb{T}_\mathrm{Gph} is the VDC freely generated by a proarrow E : V \nrightarrow V. Notice that for simplicity we have started working with general graphs rather than signed graphs, but rest assured that adapting the migration to work for signed graphs would be simple and is briefly outlined at the end. The migration we will achieve is just as we saw for the food chain in the introduction. That is, the vertices of the graph become the states of the system, and then \dot{V_i} is the sum of a V_i term and for each j and each edge V_i \to V_j a V_iV_j term with coefficients freely added, though a signed graph would dictate their signs. What I am describing is \dot{V_i} = \rho_i V_i + \sum_{j=1}^n \beta_{i,j}V_i V_j for i=1,\ldots,n, which is indeed indeed the general Lotka-Volterra system of equations (Aduddell et al. 2024, 3). Now we consider how to migrate.

3 Categorical migrations

Given theories \mathbb{T} and \mathbb{T}', a model migration is a way of transforming a \mathbb{T}-model to a \mathbb{T}’-model. Really what we’re talking about is a functor [\mathbb{T},\mathbb{S}\mathsf{et}] \rightarrow [\mathbb{T}',\mathbb{S}\mathsf{et}], but we’re only going to focus on those which come from some F:\mathbb{T} \rightarrow\mathbb{T}'. The simplest migration of this form is just to compose a \mathbb{T}'-model with F in what’s called a pullback or \Delta-migration. Morally, pullback migrations do duplication and deletion. The left adjoints of \Delta-migrations are another type of model migration called pushforward or \Sigma-migrations. These use F to migrate \mathbb{T}-models to \mathbb{T}'-models and are capable of uniting data in a model. David Spivak discusses categorical migrations in a similar context in (Spivak 2012, sec. 2.2).

Notice that we define a \Delta-migration constructively as a composition whereas we define a \Sigma-migration by the universal property of being a left adjoint to the \Delta-migration. In 1-dimension there are several constructive definitions of \Sigma-migration. Firstly, the universal property is equivalent to that of the left Kan extension of the model along F, and in 1-dimension such Kan extensions can always be explicitly constructed using colimits in Set. Moreover, the same left Kan extension can be constructed by converting the T-model to a profunctor 1 \nrightarrow T in the obvious way and composing with the companion T'(F - , - ):T \nrightarrow T' of F. In this form there is a nice dual construction for \Delta-migrations given by composing a T’-model with the conjoint T'( - ,F - ):T' \nrightarrow T of F.

Often we combine pushforward and pullback migrations into a push-pull migration via some intermediate theory. In the special case that the push-pull is along two disjoint inclusions then the composite of the associated companion and conjoint is exactly the restriction of the hom functor of the intermediate category to T^{op} \times T' \rightarrow \mathsf{Set} thus neatly bonding the push and pull together in a “one-stop” construction of the push-pull migration. If in addition the objects of the intermediate theory are exactly the disjoint union of the objects of the two existing theories and the only additional arrows are directed from T to T’ then the intermediate theory is called a collage and it is uniquely identified by the restriction of its hom functor to T^{op} \times T' \rightarrow \mathsf{Set}.

Compared to the 1-dimensional case, migrations involving double theories are less well-studied, let alone when they are virtual double categories. For example, there is no widely accepted double category whose arrows are lax double functors and proarrows are double profunctors and hence there are no grounds for considering conjoints and companions of lax double functors. However, in the next section we will see that generalising the “one-stop” construction for push-pull migrations via a collage intermediate theory works well given our goal is to obtain Lotka-Volterra ODE systems from graphs.

4 Migrating through Lotka–Volterra ODE semantics

The RFC tells us to attempt a push-pull migration from graphs to ODEs via a virtual double category of Lotka-Volterra ODE semantics \mathbb{T}_\mathrm{LV} defined below. It is not obvious from the literature how to conduct this migration. In the 1-dimensional case, a pushforward migration is a left Kan extension, and since \mathrm{Set} is suitably well behaved there is an explicit recipe for computing this. For double categories (Grandis and Paré 2007) describes a similar recipe for double categories and in the appendix to this blog post I attempt to apply Grandis and Paré’s results to our migration. However, the adaptations which must be made to \mathbb{T}_\mathrm{LV} are unsettling, as is the fact that I am forced to think of our virtual double categories like double categories, but the difference between the two was the basis for the RFC’s definition of set-theoretic theories all along. A much more satisfying approach is by using collages, as presented in this section.

For a push-pull migration from graphs to ODEs, the RFC defines a double theory of Lotka-Volterra ODE semantics \mathbb{T}_\mathrm{LV} by the disjoint union of \mathbb{T}_\mathrm{Gph} and \mathbb{T}_\mathrm{ODE} together with an additional tight arrow b_\mathrm{State} : V \to \mathrm{State} and two additional cells

where \mathtt{T}E is the tabulator of E. The tabulator of a span in \mathbb{S}\mathrm{et} is the span itself.

Given that the tight boundaries of the builder cells are recorded as composites, it was unclear to me whether the component arrows should be included in the definition of \mathbb{T}_\text{LV}. Similarly, I questioned to what extent the universal properties of objects such as V^2 and \mathtt{T}E are present in \mathbb{T}_\text{LV}. I propose that the collage approach works best when we include everything, and include it as early as possible. That is to say I propose an adapted theory of graphs \mathbb{T}_\mathrm{Gph}' defined as the VDC freely generated by the following

  • An object V and a proarrow E : V \nrightarrow V,

  • An object \mathtt{T}E together with a pair of tight arrows \pi_0, \pi_1 : \mathtt{T}E \to V forming the tight boundaries of a nullary cell \tau so that (\mathtt{T}E, \tau) is the tabulator of E,

  • An object V^2 and all the necessary tight arrows so that V^2 satisfies the universal property of the product of V with itself.

I also propose a specialized theory \mathbb{T}'_\mathrm{ODE} of ODEs which is identical to \mathbb{T}_\mathrm{ODE} except for the additional equation \mu \Delta = 1_\mathrm{Term}, where \Delta := \langle 1_\mathrm{Term}, 1_\mathrm{Term} \rangle : \mathrm{Term} \to \mathrm{Term}^2. This is to reflect the fact that the Lotka-Volterra equations only concern linear and bilinear terms. Then I take \mathbb{T}'_\mathrm{LV} to be the disjoint union of \mathbb{T}'_\mathrm{Gph} and \mathbb{T}'_\mathrm{ODE} with the addition of b_\mathrm{State}, \beta_\mathrm{Growth} and \beta_\mathrm{Interaction} as before. There is a canonical functor \mathbb{T}_\mathrm{ODE} \to \mathbb{T}'_\mathrm{ODE} so any model of \mathbb{T}'_\mathrm{ODE} can easily be pulled back to a model of \mathbb{T}_\mathrm{ODE}.

The main sticking point for the collage approach is the lack of obvious definitions for collages and profunctor composition for virtual double categories. However, assuming the following working definitions 1 \mathbb{T'}_\mathrm{LV} is a college of \mathbb{T}'_\mathrm{Gph} and \mathbb{T}'_\mathrm{ODE}.

NoneWorking Definition

A profunctor P : \mathbb{A}\nrightarrow \mathbb{B} between virtual double categories consists of a 1-profunctor P_0 : \mathbb{A}_0\nrightarrow \mathbb{B}_0 together with an assignment of a span P(A_0 \stackrel{a_1}{\nrightarrow } A_1 \stackrel{a_2}{\nrightarrow } ... \stackrel{a_n}{\nrightarrow } A_n, B_0 \stackrel{b}{\nrightarrow } B_1) : P_0(A_0, B_0) \to P_0(A_n, B_1) for each string of proarrows A_0 \stackrel{a_1}{\nrightarrow } A_1 \stackrel{a_2}{\nrightarrow } ... \stackrel{a_n}{\nrightarrow } A_n in \mathbb{A} and each proarrow B_0 \stackrel{b}{\nrightarrow } B_1 in \mathbb{B}, and a functorial assignment of a span homomorphism \begin{align*} P(\alpha_1 | \alpha_2 |\ldots \alpha_n , \beta) &: P(A_0 \stackrel{a_1}{\nrightarrow } \ldots \stackrel{a_n}{\nrightarrow } A_n, B_0 \stackrel{b}{\nrightarrow } B_1) \\ &\Rightarrow P(\tilde A_0 \stackrel{ a_{1,1}}{\nrightarrow } \ldots \stackrel{ a_{1,m_1}}{\nrightarrow } \tilde A_1 \stackrel{ a_{2,1}}{\nrightarrow } \ldots \stackrel{ a_{2,m_2}}{\nrightarrow } \tilde A_2 \stackrel{ a_{3,1}}{\nrightarrow } \ldots \stackrel{ a_{n,m_n}}{\nrightarrow } \tilde A_n, \tilde B_0 \stackrel{\tilde b}{\nrightarrow } \tilde B_1) \end{align*} for every horizontally compatible string of multi-cells \alpha_1 | \alpha_2 |\ldots \alpha_n in \mathbb{A} of the form

and cell \beta : b \Rightarrow \tilde b in \mathbb{B}.

A collage of P is the VDC which is the disjoint union of \mathbb{A} and \mathbb{B} together with additional tight arrows given by the assignments of P_0 on objects and additional cells given by the assignments of P on proarrows and all those freely generated (in the sense of composition along tights) by the new cells. Composition of cells along proarrows is given by the assignment of P on cells.

Composition of profunctors P : \mathbb{A} \nrightarrow \mathbb{B} and Q : \mathbb{B} \nrightarrow \mathbb{C} is by gluing their collages along the copy of \mathbb{B} as in the 1-dimensional case.

The profunctor P_\mathrm{LV} : \mathbb{T}_\mathrm{Gph}' \nrightarrow \mathbb{T}'_\mathrm{ODE} whose collage is \mathbb{T}'_\mathrm{LV} is constructed in the familiar way of counting arrows in \mathbb{T}'_\mathrm{LV} . Then a model M of \mathbb{T}'_\mathrm{Gph} composes with P_\mathrm{LV} : \mathbb{T}'_\mathrm{Gph} \nrightarrow \mathbb{T}'_\mathrm{ODE} yielding a model of ODEs with Lotka-Volterra ODE semantics as follows.

NoneTheorem

Given M : \mathbb{T}'_\mathrm{Gph} \to \mathbb{S}\mathrm{et}, let \tilde M : \mathbf{1} \nrightarrow \mathbb{T}'_\mathrm{Gph} be the corresponding profunctor. Then the composite P_{LV}\otimes\tilde{M} : \mathbb{T}'_\mathrm{ODE} \to \mathbb{S}\mathrm{et} satisfies the following assignments.

  1. (P_{LV}\otimes\tilde{M})(1, \text{Term}) \cong M(V) \coprod (M(V^2)\setminus\operatorname{Im}(M\Delta))

  2. (P_{LV}\otimes\tilde{M})(1, \text{State}) \cong M(V)

  3. (P_{LV}\otimes\tilde{M})(1, \text{Contrib}) \cong M(V) \coprod M(\mathtt{T}E) with projection onto M(V) \coprod (M(V^2)\setminus\operatorname{Im}(M\Delta)) and M(V) given by the inclusion and identity for M(V), and M(\langle s, t \rangle) and M(t) for M(\mathtt{T}E).

The key result here is (iii) which shows a copy of the set of vertices M(V) and the set of edges M(\mathtt{T}E) making up the contributions to the system of ODEs. If we interpret M\langle s,t \rangle as multiplication of source and target, and Mt as target, then the projections given by (iii) correspond exactly to the Lotka-Volterra ODE semantics.

Proof. The proofs get progressively less computational. For (i) we know that (P_{LV}\otimes\tilde{M})(1, \text{Term}) is the set of equivalence classes of pairs (\ x \in M(X),\ g \in \mathrm{Hom}_{\mathbb{T}'_\mathrm{LV}}[X, \mathrm{Term}] \ ) where (x,g) \sim (y,h) iff there exists some f:X \to Y in \mathbb{T}'_\mathrm{Gph} such that y = Mf(x) and g = hf or there exists some f' : Y \to X in \mathbb{T}'_\mathrm{Gph} such that x = Mf'(y) and h = gf'.

Given some pair (x,g), first try to write g in the form X \xrightarrow{g_0} V \xrightarrow{h} \mathrm{Term} where h := \mathrm{Term}_\mathrm{State}b_\mathrm{State}. In this case (x,g) is equivalent to (Mg_0(x), h). If g does not have the above form, it instead has the form X \xrightarrow{g_0} V^2 \xrightarrow{\mu h^2} \mathrm{Term} for some g_0, and so (x,g) is equivalent to (Mg_0(x), \mu h^2).

Therefore we have shown that every equivalence class has a representative of the form (v \in M(V), h ) \text{ or } (u \in M(V^2), \mu h^2). There is no f': V^2 \to V such that \mu h^2 = hf' and the only f: V \to V^2 satisfying the dual condition is \Delta_V because \mu h^2 \Delta_V = \mu \Delta_\mathrm{Term} h = h. So (v, h) \sim (M\Delta (v), \mu h^2) for all v\in M(V), so we are left with the fact that the following representatives form a minimal representative set \left\{ \begin{aligned} (v, h) &\text{ for all }v\in M(V). \\(u, \mu h^2) &\text{ for all }u\in (M(V^2)\setminus\operatorname{Im}(M\Delta)). \end{aligned} \right. By projecting onto the first term of each pair we obtain an isomorphism \begin{align*} (\tilde M \otimes P_\mathrm{LV}) (1, \mathrm{Term}) &\xrightarrow{\cong} M(V) \coprod (M(V^2)\setminus\operatorname{Im}(M\Delta)) \\ (x,g) &\mapsto Mg_0(x). \end{align*}

For (ii) apply the same approach as above to the observation that every g : X \to \mathrm{State} in \mathbb{T}'_\mathrm{LV} factors as X \xrightarrow{g_0} V \xrightarrow{b_\mathrm{State}} \mathrm{State}.

For (iii) we know that (\tilde M \otimes P_\mathrm{LV}) (1, \mathrm{Contrib}) : (\tilde M \otimes P_\mathrm{LV}) (1, \mathrm{Term}) \nrightarrow (\tilde M \otimes P_\mathrm{LV}) (1, \mathrm{State}) consists of pairs (x, \beta) where \beta is a cell in \mathbb{T}'_\mathrm{LV} whose codomain is \mathrm{Contrib} and whose domain \mathrm{dom}\beta is in the copy of \mathbb{T}'_\mathrm{Gph}, and x is an element of M(\mathrm{dom}\beta). The equivalence relation is discrete due to the absence of any factorizations of cells in \mathbb{T}'_\mathrm{LV}. The projections are inheritted from M(\mathrm{dom}\beta) and the external source and target of \beta. Of course we have only two cells \beta_\mathrm{Growth} and \beta_\mathrm{Interaction} so we can explicitly write down the projections. The projection onto (\tilde M \otimes P_\mathrm{LV}) (1, \mathrm{Term}) is given by (v, \beta_\mathrm{Growth}) \mapsto (v, h) \cong v \quad \text{ and } \quad (e, \beta_\mathrm{Interaction}) \mapsto (e, \mu h^2 \langle s,t \rangle) \cong M\langle s,t \rangle(e) and the projection onto (\tilde M \otimes P_\mathrm{LV}) (1, \mathrm{Term}) \cong M(V) is (v, \beta_\mathrm{Growth}) \mapsto (v, b_\mathrm{State}) \cong v \quad \text{ and } \quad (e, \beta_\mathrm{Interaction}) \mapsto (e, b_\mathrm{State}t) \cong Mt(e). This completes the proof.

For signed graphs, we would use \mathbb{T}_\mathrm{SgnGph}, the theory freely generated by a parallel pair of proarrows E_+ and E_- : V \nrightarrow V. Similarly, \mathbb{T}_\mathrm{SgnLV} would contain three cells: \beta_\mathrm{Growth}, \beta_\mathrm{Interaction}^+ and \beta_\mathrm{Interaction}^- interpreted as should be obvious. The approach above could be easily adapted.

In terms of where we could go after this blog post, you could consider updating your graph, theory of ODEs, or semantics, and then consider how you would efficiently update the system of ODEs corresponding to the original migration in response. Such considerations might get close to ongoing work such as on incremental query updating for databases.

References

Aduddell, Rebekah, James Fairbanks, Amit Kumar, Pablo S. Ocal, Evan Patterson, and Brandon T. Shapiro. 2024. “A Compositional Account of Motifs, Mechanisms, and Dynamics in Biochemical Regulatory Networks.” Compositionality 6. https://doi.org/10.32408/compositionality-6-2.
Grandis, Mario, and Robert Paré. 2007. “Lax Kan Extensions for Double Categories (on Weak Double Categories, Part IV).” Cahiers de Topologie Et Géométrie Différentielle Catégoriques 48: 163–99. https://www.numdam.org/article/CTGDC_2007__48_3_163_0.pdf.
Spivak, David I. 2012. “Functorial Data Migration.” Information and Computation 217: 31–51. https://doi.org/10.1016/j.ic.2012.05.001.

Footnotes

  1. These definitions result from a tradeoff between the equivalence of collages and profunctors vs. profunctors and functors \mathbb{A}^{\mathrm{op}} \times \mathbb{B} \to \mathbb{S}\mathrm{et}. I and the nlab page side with collages. On the other hand, double profunctors and double collages are well-defined. Our definition of virtual double profunctor composition can be understood for double profunctors but it would fail to be entirely well-defined, probably due to associativity, as is the case for all proposed definitions of composition of double profunctors.↩︎

Comments