Skip to Main Content

Applied Category Theory in Chemistry, Computing, and Social Networks

John Baez
Simon Cho
Daniel Cicala
Nina Otter
Valeria de Paiva

The authors of this piece are organizers of the AMS 2022 Mathematics Research Communities summer conference Applied Category Theory, one of four topical research conferences offered this year that are focused on collaborative research and professional development for early-career mathematicians. Additional information can be found at https://www.ams.org/programs/research-communities/2022MRC-Categories. Applications are open until February 15, 2022.

1. Introduction

Society is increasingly complex and connected through the internet and social media, planetary climate and ecological challenges, transnational organization and global supply chains. To navigate and thrive in this networked world, we rely on scientific advances to help us manage this complexity by enabling robust communication, cooperation, and collaboration.

Within about the past decade, a growing number of researchers have realized that the aspects of category theory that make it useful in certain pure mathematical contexts also make it useful for the study of the underlying structure of physical and conceptual systems. From this realization, a new field has emerged called Applied Category Theory (ACT). Some major themes currently found in the ACT literature include compositionality, functorial semantics, and implementing these structures into user-friendly software. Indeed, engineers and scientists should benefit from the fruits of ACT, ideally without having to first study category theory which is why producing user-friendly software is a north star of ACT research. In this note, we provide a bird’s eye view of these major themes, describe a road map to relevant literature, and highlight the essence and intuition of the central ideas as well as the payoffs that a category-theoretic approach can bring. Into this narrative, we fit a brief description of specific research projects to be undertaken by participants of the 2022 Mathematical Research Community in Applied Category Theory.

2. Compositionality

To a category theorist, it is not the mathematical objects, but the morphisms between objects that are held to be fundamental. This viewpoint necessarily lifts composition to the fore of mathematical operations. When considering examples of a morphism, many may conjure functions between sets, homomorphisms between rings, or continuous maps between spaces. These examples are certainly important; however, morphisms can truly be anything satisfying the axioms for a category. One main thread of research in applied category theory is to model open systems by arranging them as morphisms in some category. “Open” here means that the systems are equipped with an interface that can interact with other compatible systems.

2.1. Structured cospans

One method of encoding open systems as morphisms is to consider them as “cospans” 3. The idea is to create a category where we interpret each object as a system of some sort, and then define a cospan to be an object with two morphisms into it,

that select which parts of serve as inputs and outputs. Composition of cospans,

is given by a purely categorical construction known as a pushout, which connects the outputs of to the inputs of . In applied category theory we often need structured cospans,

where the object lives in a different category from and , related by a functor . For example, and could be sets, and could be a graph.

Figure 1.

Open Markov process.

Figure 2.

Open SIR model as a Petri net.

The structured cospan approach has been applied to chemical reaction networks, Markov processes (see Figure 1), and electrical circuits. Petri nets, typically found in chemistry and computer science, are a graphical formalism to describe distributed systems. These too can be realized as structured cospans thus offering a way to categorically build complex processes. Figure 2 shows an open Petri net as a structured cospan encoding a simple model of infectious disease. Here stands for a population of “susceptible” people, stands for “infected,” and stands for “resistant.”

It turns out that standard ways to manipulate a system—for example, connecting outputs of one system to the inputs of another, turning an output into an input, considering multiple systems as a single system—are all realized with purely category-theoretic operations. The payoff is that many different systems can be described in the same language: category theory. With different systems on equal footing, comparisons are more readily available. Rigorous, not simply heuristic, diagrammatic languages exist to assist in reasoning about systems of various kinds, and a structural analysis of systems may commence.

2.2. Open reaction networks

Reaction networks are a widely used method of describing chemical reactions. There is a standard method of turning a reaction network into a collection of differential equations describing the time evolution of the concentration of various chemicals in solution. Starting in the 1970s, mathematical chemists formulated a number of deep theorems 11 and conjectures 1 saying how the qualitative behavior of these differential equations depend on topological features of the reaction network.

More recently, structured cospans have been used to describe “open” reaction networks—where chemicals can flow in and out—as morphisms in a category 4. We can build larger reaction networks by composing smaller open ones, and the map sending an open reaction network to its differential equation is a functor. In the 2022 MRC in Applied Category Theory, participants will use this framework to study the qualitative behavior of chemical reactions.

2.3. Lenses

Lenses offer another method to connect systems together and are particularly useful to model a scenario involving a bidirectional flow of information between connected systems. A helpful, if rough, approximation of a lens is two interacting systems, each encoded as a set of states , together with one map that “sends information forward” and a second map that “sends information backwards.” To illustrate, imagine that is the set of behaviors of an individual named James and is the set of behaviors of the Category Cafe, James’ favorite coffee house. The forward function captures how the Category Cafe behaves, , in reaction to each of James’ behaviors, . For instance, perhaps “James orders a coffee” maps to “an employee pours a coffee.” The backwards function captures how each state of the cafe affects each of James’ behaviors . If “the cafe is busy,” then might update “orders a coffee” to “leaves the cafe,” hold “uses the restroom” constant so , and update “sit and check emails” to “stand in the corner and wait until customers leave.”

While this toy example imparts the flavor of a lens, it does not impart the lens’ full majesty when the appropriate rigor and generality is considered. Indeed, lenses are so useful that people continue to rediscover them in seemingly unconnected situations. Gödel’s Dialectica interpretation, a model of intuitionistic arithmetic, offers an early discovery of lenses, though without the term. de Paiva placed Gödel’s logical framework into a category whose morphisms are generalized lenses 13. This Dialectica construction has come to establish much of the current understanding about lenses. Contemporary lens applications include database theory 8, a structural perspective on functional learning 6, domain theory 15, and open game theory 10 with an emphasis on economic models. This same structure appearing in so many places excited category theorists who in turn began to study lenses on their own terms, starting with the category of lenses in the category of sets. The objects of this category are sets and the morphisms are lenses, so a pair of functions and are subject to several compatibility laws, that is, commuting diagrams:

A composite of lenses

comprises the functions

respectively defined by and

and are depicted in Figure 3 using a string diagram. This category generalizes in various directions, for instance by taking different permutations of the compatibility laws, by taking lenses in various categories, or, repeatedly, by replacing the Cartesian product with another monoidal product.

Figure 3.

Lens composition as a string diagram.

2.4. Dialectica interpretation

When combing the above-cited literature about lenses, one would notice that there are actually variations of lenses just as there are for any mathematical object. In fact, one of the variants of the lenses discussed in both 6 and 10 seems to be a certain restriction of de Paiva’s Dialectica construction, although it is not immediately obvious to what degree such a restriction preserves the logical structure of the construction. In the 2022 MRC for Applied Category Theory, participants will construct a framework that clarifies in which precise sense the concept of lens as embodied by the Dialectica construction generalizes the variations of lenses discussed above.

3. Functorial Semantics

We have two formal and rigorous methods of building systems from their constituent parts: structured cospans and lenses. The categories we build from structured cospans or from lenses offer a syntax that we can use to reason about the structure of systems. However, we would also like to understand their behavior. Given our interest in composite systems, a natural question to ponder is: how much of a system’s behavior is explained by the behavior of its component parts? To answer this question, we can borrow ideas from one of category theory’s giants.

In his PhD thesis, William Lawvere introduced a category-theoretic perspective on universal algebra called functorial semantics. The idea is to encode the theory for an algebraic object into a category. For example, the category for the theory of a group will have its objects generated by taking all finite products of a single object , giving objects

and so on. The morphisms of this category are generated, via composition and products, by the structure maps , , and . The resulting morphisms are then quotiented by equations between morphisms that describe the properties of identity, invertibility, and associativity. This construction provides a unique morphism for every possible way to turn a string of group elements into a single element; for instance,

has a dedicated morphism of type

Note, there are no actual elements here, we are just using generalized symbols to describe the morphism. The resulting category is not a group; it is the syntax for groups. This is directly in line with our categories constructed using structured cospans or lenses to capture the syntax of various systems. Then, once we have a syntax, we can use a functor out of that syntax and into another category to realize the semantics. For example, every group is a functor to the category of sets and set functions. Here is the semantics of the group. By changing the semantics, we can obtain the many flavors of groups: each topological group is a functor to the category of topological spaces and continuous maps, each Lie group is a functor into the category of differential manifolds and smooth maps.

Applied category theorists use this idea to study open systems using two categories. The first category has as morphisms the open systems, for example encoded as structured cospans. This category serves as the syntax for the system, governing how we can combine systems to make larger, more complex systems. The second category captures the behavior of these systems. This category serves as the semantics and is typically the category whose objects are sets and morphisms are binary relations, though a category of stronger relations may be appropriate. Then a functor assigns to each system (a morphism in the syntax category), the relationship between behaviors on the system’s inputs and outputs. For example, there is a functor from the category whose morphisms are passive linear circuits to the category LinRel whose objects are for each natural number and morphisms are linear relations, that is, linear subspaces of . This functor assigns to a passive linear network

where comprises the tuples that represent the realizable potential-current pairs that can exist on each port according to Kirchhoff’s Circuit Laws.

In general, these semantics-assigning functors capture the external behavior of a system as a composite of the system’s components. The generality of this approach favors the structural perspective and, by using category theory as a common language, allows for a more readily-made comparison for systems of different types. In an era of increasing interdisciplinarity, the ability to translate knowledge across disciplines is crucial. Applied category theory is one approach towards building such a dictionary.

It is worth noting that functorial semantics as described above does not capture any behavior that is emergent from composing systems. Research is underway in this direction by using so-called lax functors 7.

3.1. Social simplicial complexes

The power of functors goes beyond their ability to describe the deconstruction of systems into their syntax and semantics. They are a powerful organizational tool that encompasses a staggeringly large number of the most famous mathematical operations. Indeed, computing some free algebraic object on a set, the fundamental group on a space, the homology and cohomology of spaces, the tangent or cotangent bundle of a smooth manifold are all functors. Even a space like a sheaf or presheaf can be represented as a functor. By thinking about a space as a functor, the higher-dimensional features can be studied using higher category theory, a perspective that offers new tools to classical subjects. In the field of Topological Data Analysis, functoriality of many constructions is a key ingredient in the study of their robustness 5.

In the 2022 MRC, participants will study social systems using functors and other category-theoretic tools. Many of the methods currently used in network science were first developed by social network scientists, who use nodes to represent agents of a social system, and (un)directed labeled edges to represent binary relations between agents (see Figure 4).

Two of the main properties of social systems that social scientists are interested in studying are positions and roles. For networks, positions are defined as equivalence classes of nodes that are similar, while roles are equivalence classes of compound relations 14. Since the 1970s a lot of research has been done to develop these concepts in a rigorous way 9. Otter and Porter developed methods to relate the analyses of roles and positions in social networks, using a functorial formulation 12. At the 2022 MRC, we intend to extend this functorial framework to account for higher-order interactions between social agents by modeling social systems with simplicial complexes instead of mere graphs.

Figure 4.

An example of social network modeling kinship relationships.

4. Software Development

A goal of the ACT community is to bridge the gap between theorists using category-theoretic modeling tools and those who want to use the models to say something useful and true about the world. One can cross their fingers and hope that the “users” will simply take it upon themselves to learn enough category theory to take advantage of ACT-styled models. A more proactive approach would be to build user-friendly (meaning, no category theory knowledge required) tools. Such tools will likely take the form of computer software with intuitive graphical interfaces where the category theory is programmed under-the-hood. A number of researchers are currently working on building such software tools, though this work is very much in its infancy. One example includes Globular,⁠Footnote1 http://globular.science/ a proof assistant that allows one to perform higher-dimensional calculations in categories via a graphical interface. Structured cospans of Petri nets were implemented in the software package Julia to develop an SIR model that is compositional in the sense that various cities can each have their own model that can be connected together to form a composite SIR model 2. Users can set parameters and all the category theory remains underneath the hood. Private enterprise is also entering the picture. The organization Statebox⁠Footnote2 https://statebox.org/ is blending an ACT approach to Petri nets together with blockchain technology to develop a technology stack based on a visual programming language. In addition, they have built a software engine for compositional game-theoretic modeling, a finite state machine oracle. The company Conexus⁠Footnote3 https://conexus.com/ uses applied categorical methods for data integration.

The success of ACT as a discipline largely hinges on its ability to be accessible and available to scientists and engineers, meaning the building of software is central to the ACT program.

5. Conclusion

The ACT community is continuing to grow and is seeking early-career researchers, programmers, scientists, and engineers of all stripes to join us at the 2022 Mathematical Research Community. Those who enjoy a systems-thinking and structural perspective will find that category theory provides a rigorous and robust framework for reasoning about systems, processes, and relationships. Expertise in category theory is not required to join, just a desire to learn.

References

[1]
David F. Anderson, A proof of the global attractor conjecture in the single linkage class case, SIAM J. Appl. Math. 71 (2011), no. 4, 1487–1508, DOI 10.1137/11082631X. MR2835244Show rawAMSref\bib{Anderson}{article}{ author={Anderson, David F.}, title={A proof of the global attractor conjecture in the single linkage class case}, journal={SIAM J. Appl. Math.}, volume={71}, date={2011}, number={4}, pages={1487--1508}, issn={0036-1399}, review={\MR {2835244}}, doi={10.1137/11082631X}, } Close amsref.
[2]
A. Baas, J. Fairbanks, S. Libkind, and E. Patterson, Operadic modeling of dynamical systems: Mathematics and computation, arXiv:2105.12282, 2021.
[3]
John C. Baez and Kenny Courser, Structured cospans, Theory Appl. Categ. 35 (2020), Paper No. 48, 1771–1822. MR4170469Show rawAMSref\bib{strcospans}{article}{ author={Baez, John C.}, author={Courser, Kenny}, title={Structured cospans}, journal={Theory Appl. Categ.}, volume={35}, date={2020}, pages={Paper No. 48, 1771--1822}, review={\MR {4170469}}, } Close amsref.
[4]
John C. Baez and Blake S. Pollard, A compositional framework for reaction networks, Rev. Math. Phys. 29 (2017), no. 9, 1750028, 41, DOI 10.1142/S0129055X17500283. MR3694082Show rawAMSref\bib{baezpollard}{article}{ author={Baez, John C.}, author={Pollard, Blake S.}, title={A compositional framework for reaction networks}, journal={Rev. Math. Phys.}, volume={29}, date={2017}, number={9}, pages={1750028, 41}, issn={0129-055X}, review={\MR {3694082}}, doi={10.1142/S0129055X17500283}, } Close amsref.
[5]
Gunnar Carlsson, Topology and data, Bull. Amer. Math. Soc. (N.S.) 46 (2009), no. 2, 255–308, DOI 10.1090/S0273-0979-09-01249-X. MR2476414Show rawAMSref\bib{Carlsson08}{article}{ author={Carlsson, Gunnar}, title={Topology and data}, journal={Bull. Amer. Math. Soc. (N.S.)}, volume={46}, date={2009}, number={2}, pages={255--308}, issn={0273-0979}, review={\MR {2476414}}, doi={10.1090/S0273-0979-09-01249-X}, } Close amsref.
[6]
Brendan Fong, David Spivak, and Remy Tuyéras, Backprop as functor: a compositional perspective on supervised learning, 2019 34th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS), IEEE, Piscataway, NJ, 2019, pp. 1–13. MR4142439Show rawAMSref\bib{backprop}{article}{ author={Fong, Brendan}, author={Spivak, David}, author={Tuy\'{e}ras, Remy}, title={Backprop as functor: a compositional perspective on supervised learning}, conference={ title={2019 34th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)}, }, book={ publisher={IEEE, Piscataway, NJ}, }, date={2019}, pages={1--13}, review={\MR {4142439}}, } Close amsref.
[7]
Brendan Fong and David I. Spivak, An invitation to applied category theory: Seven sketches in compositionality, Cambridge University Press, Cambridge, 2019, DOI 10.1017/9781108668804. MR3966447Show rawAMSref\bib{sevensketches}{book}{ author={Fong, Brendan}, author={Spivak, David I.}, title={An invitation to applied category theory}, subtitle={Seven sketches in compositionality}, publisher={Cambridge University Press, Cambridge}, date={2019}, pages={xii+338}, isbn={978-1-108-71182-1}, isbn={978-1-108-48229-5}, review={\MR {3966447}}, doi={10.1017/9781108668804}, } Close amsref.
[8]
J. N. Foster, M. B. Greenwald, J. T. Moore, B. C. Pierce, and A. Schmitt, Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem, ACM Transactions on Programming Languages and Systems 29 (2007), no. 3, 17-es.
[9]
L. Freeman, The development of social network analysis, Empirical Press, 2004.
[10]
Neil Ghani, Jules Hedges, Viktor Winschel, and Philipp Zahn, Compositional game theory, LICS ’18—33rd Annual ACM/IEEE Symposium on Logic in Computer Science, ACM, New York, 2018, pp. 472–481, DOI 10.1145/3209108.3209165. MR3883754Show rawAMSref\bib{compgames}{article}{ author={Ghani, Neil}, author={Hedges, Jules}, author={Winschel, Viktor}, author={Zahn, Philipp}, title={Compositional game theory}, conference={ title={LICS '18---33rd Annual ACM/IEEE Symposium on Logic in Computer Science}, }, book={ publisher={ACM, New York}, }, date={2018}, pages={472--481}, review={\MR {3883754}}, doi={10.1145/3209108.3209165}, } Close amsref.
[11]
F. Horn and R. Jackson, General mass action kinetics, Arch. Rational Mech. Anal. 47 (1972), 81–116, DOI 10.1007/BF00251225. MR400923Show rawAMSref\bib{HornJackson}{article}{ author={Horn, F.}, author={Jackson, R.}, title={General mass action kinetics}, journal={Arch. Rational Mech. Anal.}, volume={47}, date={1972}, pages={81--116}, issn={0003-9527}, review={\MR {400923}}, doi={10.1007/BF00251225}, } Close amsref.
[12]
N. Otter and M. A. Porter, A unified framework for equivalences in social networks, arXiv:2006.10733, 2020.
[13]
V. C. V. de Paiva, The Dialectica categories, Categories in computer science and logic (Boulder, CO, 1987), Contemp. Math., vol. 92, Amer. Math. Soc., Providence, RI, 1989, pp. 47–62, DOI 10.1090/conm/092/1003194. MR1003194Show rawAMSref\bib{dialectica}{article}{ author={de Paiva, V. C. V.}, title={The Dialectica categories}, conference={ title={Categories in computer science and logic}, address={Boulder, CO}, date={1987}, }, book={ series={Contemp. Math.}, volume={92}, publisher={Amer. Math. Soc., Providence, RI}, }, date={1989}, pages={47--62}, review={\MR {1003194}}, doi={10.1090/conm/092/1003194}, } Close amsref.
[14]
S. Wasserman and K. Faust, Social network analysis, Cambridge University Press, 1994.
[15]
G. Winskel, Domain theory and interaction, British Computer Science FACS (Formal Aspects of Computer Science) Newsletter, British Computer Society. Available at https://www.bcs.org/media/7577/facs-jul21.pdf.

Credits

Figures 1 and 2 are courtesy of John Baez.