## Tropical Algebra and Railway Optimization

24 May, 2018

Simon Willerton pointed out a wonderful workshop, which unfortunately neither he nor I can attend… nor Jamie Vicary, who is at Birmingham:

Tropical Mathematics & Optimisation for Railways, University of Birmingham, School of Engineering, Monday 18 June 2018.

If you can go, please do—and report back!

Tropical algebra involves the numbers $(-\infty, \infty]$ made into a rig with minimization as the addition and addition as the multiplication. It’s called a rig because it’s a “ring without negatives”.

Tropical algebra is important in algebraic geometry, because if you take some polynomial equations and rewrite them replacing + with min and × with +, you get equations that describe shapes with flat pieces replacing curved surfaces, like this:

These simplified shapes are easier to deal with, but they shed light on the original curved ones! Click the picture for more on the subject from Johannes Rau.

Tropical algebra is also important for quantization, since classical mechanics chooses the path with minimum action while quantum mechanics sums over paths. But it’s also important for creating efficient railway time-tables, where you’re trying to minimize the total time it takes to get from one place to another. Finally these worlds are meeting!

Here’s the abstract, which shows that the reference to railway optimization is not just a joke:

Abstract. The main purpose of this workshop is to bring together specialists in tropical mathematics and mathematical optimisation applied in railway engineering and to foster further collaboration between them. It is inspired by some applications of tropical mathematics to the analysis of railway timetables. The most elementary of them is based on a controlled tropically linear dynamic system, which allows for a stability analysis of a regular timetable and can model the delay propagation. Tropical (max-plus) switching systems are one of the extensions of this elementary model. Tropical mathematics also provides appropriate mathematical language and tools for various other applications which willbe presented at the workshop.

The talks on mathematical optimisation in railway engineering will be given by Professor Clive Roberts and other prominent specialists working at the Birmingham Centre for Railway Research and Education (BCRRE). They will inform the workshop participants about the problems that are of actual interest for railways, and suggest efficient and practical methods of their solution.

For a glimpse of some of the category theory lurking in this subject, see:

• Simon Willerton, Project scheduling and copresheaves, The n-Category Café.

## Circuits, Bond Graphs, and Signal-Flow Diagrams

19 May, 2018

My student Brandon Coya finished his thesis, and successfully defended it last Tuesday!

• Brandon Coya, Circuits, Bond Graphs, and Signal-Flow Diagrams: A Categorical Perspective, Ph.D. thesis, U. C. Riverside, 2018.

It’s about networks in engineering. He uses category theory to study the diagrams engineers like to draw, and functors to understand how these diagrams are interpreted.

His thesis raises some really interesting pure mathematical questions about the category of corelations and a ‘weak bimonoid’ that can be found in this category. Weak bimonoids were invented by Pastro and Street in their study of ‘quantum categories’, a generalization of quantum groups. So, it’s fascinating to see a weak bimonoid that plays an important role in electrical engineering!

However, in what follows I’ll stick to less fancy stuff: I’ll just explain the basic idea of Brandon’s thesis, say a bit about circuits and ‘bond graphs’, and outline his main results. What follows is heavily based on the introduction of his thesis, but I’ve baezified it a little.

### The basic idea

People, and especially scientists and engineers, are naturally inclined to draw diagrams and pictures when they want to better understand a problem. One example is when Feynman introduced his famous diagrams in 1949; particle physicists have been using them ever since. But some other diagrams introduced by engineers are far more important to the functioning of the modern world and its technology. It’s outrageous, but sociologically understandable, that mathematicians have figured out more about Feynman diagrams than these other kinds: circuit diagrams, bond graphs and signal-flow diagrams. This is the problem Brandon aims to fix.

I’ve been unable to track down the early history of circuit diagrams, so if you know about that please tell me! But in the 1940s, Harry Olson pointed out analogies in electrical, mechanical, thermodynamic, hydraulic, and chemical systems, which allowed circuit diagrams to be applied to a wide variety of fields. On April 24, 1959, Henry Paynter woke up and invented the diagrammatic language of bond graphs to study generalized versions of voltage and current, called ‘effort’ and ‘flow,’ which are implicit in the analogies found by Olson. Bond graphs are now widely used in engineering. On the other hand, control theorists use diagrams of a different kind, called ‘signal-flow diagrams’, to study linear open dynamical systems.

Although category theory predates some of these diagrams, it was not until the 1980s that Joyal and Street showed string digrams can be used to reason about morphisms in any symmetric monoidal category. This motivates Brandon’s first goal: viewing electrical circuits, signal-flow diagrams, and bond graphs as string diagrams for morphisms in symmetric monoidal categories.

This lets us study networks from a compositional perspective. That is, we can study a big network by describing how it is composed of smaller pieces. Treating networks as morphisms in a symmetric monoidal category lets us build larger ones from smaller ones by composing and tensoring them: this makes the compositional perspective into precise mathematics. To study a network in this way we must first define a notion of ‘input’ and ‘output’ for the network diagram. Then gluing diagrams together, so long as the outputs of one match the inputs of the other, defines the composition for a category.

Network diagrams are typically assigned data, such as the potential and current associated to a wire in an electrical circuit. Since the relation between the data tells us how a network behaves, we call this relation the ‘behavior’ of a network. The way in which we assign behavior to a network comes from first treating a network as a ‘black box’, which is a system with inputs and outputs whose internal mechanisms are unknown or ignored. A simple example is the lock on a doorknob: one can insert a key and try to turn it; it either opens the door or not, and it fulfills this function without us needing to know its inner workings. We can treat a system as a black box through the process called ‘black-boxing’, which forgets its inner workings and records only the relation it imposes between its inputs and outputs.

Since systems with inputs and outputs can be seen as morphisms in a category we expect black-boxing to be a functor out of a category of this sort. Assigning each diagram its behavior in a functorial way is formalized by functorial semantics, first introduced in Lawvere’s thesis in 1963. This consists of using categories with specific extra structure as ‘theories’ whose ‘models’ are structure-preserving functors into other such categories. We then think of the diagrams as a syntax, while the behaviors are the semantics. Thus black-boxing is actually an example of functorial semantics. This leads us to another goal: to study the functorial semantics, i.e. black-boxing functors, for electrical circuits, signal-flow diagrams, and bond graphs.

Brendan Fong and I began this type of work by showing how to describe circuits made of wires, resistors, capacitors, and inductors as morphisms in a category using ‘decorated cospans’. Jason Erbele and I, and separately Bonchi, Sobociński and Zanasi, studied signal flow diagrams as morphisms in a category. In other work Brendan Fong, Blake Pollard and I looked at Markov processes, while Blake and I studied chemical reaction networks using decorated cospans. In all of these cases, we also studied the functorial semantics of these diagram languages.

Brandon’s main tool is the framework of ‘props’, also called ‘PROPs’, introduced by Mac Lane in 1965. The acronym stands for “products and permutations”, and these operations roughly describe what a prop can do. More precisely, a prop is a strict symmetric monoidal category equipped with a distinguished object latex X$such that every object is a tensor power $X^{\otimes n}.$ Props arise because very often we think of a network as going between some set of input nodes and some set of output nodes, where the nodes are indistinguishable from each other. Thus we typically think of a network as simply having some natural number as an input and some natural number as an output, so that the network is actually a morphism in a prop. ### Circuits and bond graphs Now let’s take a quick tour of circuits and bond graphs. Much more detail can be found in Brandon’s thesis, but this may help you know what to picture when you hear terminology from electrical engineering. Here is an electrical circuit made of only perfectly conductive wires: This is just a graph, consisting of a set $N$ of nodes, a set $E$ of edges, and maps $s,t\colon E\to N$ sending each edge to its source and target node. We refer to the edges as perfectly conductive wires and say that wires go between nodes. Then associated to each perfectly conductive wire in an electrical circuit is a pair of real numbers called ‘potential’, $\phi,$ and ‘current’, $I.$ Typically each node gets a potential, but in the above case the potential at either end of a wire would be the same so we may as well associate the potential to the wire. Current and potential in circuits like these obey two laws due to Kirchoff. First, at any node, the sum of currents flowing into that node is equal to the sum of currents flowing out of that node. The other law states that any connected wires must have the same potential. We say that the above circuit is closed as opposed to being open because it does not have any inputs or outputs. In order to talk about open circuits and thereby bring the ‘compositional perspective’ into play we need a notion for inputs and outputs of a circuit. We do this using two maps $i\colon X\to N$ and $o\colon Y \to N$ that specifiy the inputs and outputs of a circuit. Here is an example: We call the sets $X, Y,$ and the disjoint union $X + Y$ the inputs, outputs, and terminals of the circuit, respectively. To each terminal we associate a potential and current. In total this gives a space of allowed potentials and currents on the terminals and we call this space the ‘behavior’ of the circuit. Since we do this association without knowing the potentials and currents inside the rest of the circuit we call this process ‘black-boxing’ the circuit. This process hides the internal workings of the circuit and just tells us the relation between inputs and outputs. In fact this association is functorial, but to understand the functoriality first requires that we say how to compose these kinds of circuits. We save this for later. There are also electrical circuits that have ‘components’ such as resistors, inductors, voltage sources, and current sources. These are graphs as above, but with edges now labelled by elements in some set L. Here is one for example: We call this an L-circuit. We may also black-box an L-circuit to get a space of allowed potentials and currents, i.e. the behavior of the L-circuit, and this process is functorial as well. The components in a circuit determine the possible potential and current pairs because they impose additional relationships. For example, a resistor between two nodes has a resistance $R$ and is drawn as: In an L-circuit this would be an edge labelled by some positive real number $R.$ For a resistor like this Kirchhoff’s current law says $I_1=I_2$ and Ohm’s Law says $\phi_2-\phi_1 =I_1R.$ This tells us how to construct the black-boxing functor that extracts the right behavior. Engineers often work with wires that come in pairs where the current on one wire is the negative of the current on the other wire. In such a case engineers care about the difference in potential more than each individual potential. For such pairs of perfectly conductive wires: we call $V=\phi_2-\phi_1$ the ‘voltage’ and $I=I_1=-I_2$ the ‘current’. Note the word current is used for two different, yet related concepts. We call a pair of wires like this a ‘bond’ and a pair of nodes like this a ‘port’. To summarize we say that bonds go between ports, and in a ‘bond graph’ we draw a bond as follows: Note that engineers do not explicitly draw ports at the ends of bonds; we follow this notation and simply draw a bond as a thickened edge. Engineers who work with bond graphs often use the terms ‘effort’ and ‘flow’ instead of voltage and current. Thus a bond between two ports in a bond graph is drawn equipped with an effort and flow, rather than a voltage and current, as follows: A bond graph consists of bonds connected together using ‘1-junctions’ and ‘0-junctions’. These two types of junctions impose equations between the efforts and flows on the attached bonds. The flows on bonds connected together with a 1-junction are all equal, while the efforts sum to zero, after sprinkling in some signs depending on how we orient the bonds. For 0-junctions it works the other way: the efforts are all equal while the flows sum to zero! The duality here is well-known to engineers but perhaps less so to mathematicians. This is one topic Brandon’s thesis explores. Brandon explains bond graphs in more detail in Chapter 5 of his thesis, but here is an example: The arrow at the end of a bond indicates which direction of current flow counts as positive, while the bar is called the ‘causal stroke’. These are unnecessary for Brandon’s work, so he adopts a simplified notation without the arrow or bar. In engineering it’s also important to attach general circuit components, but Brandon doesn’t consider these. ### Outline In Chapter 2 of his thesis, Brandon provides the necessary background for studying four categories as props: • the category of finite sets and spans: $\textrm{FinSpan}$ • the category of finite sets and relations: $\textrm{FinRel}$ • the category of finite sets and cospans: $\textrm{FinCospan}$ • the category of finite sets and corelations: $\textrm{FinCorel}.$ In particular, $\textrm{FinCospan}$ and $\textrm{FinCorel}$ are crucial to the study of networks. In Corollary 2.3.4 he notes that any prop has a presentation in terms of generators and equations. Then he recalls the known presentations for $\textrm{FinSpan},$ $\textrm{FinCospan},$ and $\textrm{FinRel}.$ Proposition 2.3.7 lets us build props as quotients of other props. He begins Chapter 3 by showing that$\mathrm{FinCorel}$is ‘the prop for extraspecial commutative Frobenius monoids’, based on a paper he wrote with Brendan Fong. This result also gives a presentation for $\mathrm{FinCorel}.$ Then he defines an “L-circuit” as a graph with specified inputs and outputs, together with a labelling set for the edges of the graph. L-circuits are morphisms in the prop $\textrm{Circ}_L.$ In Proposition 3.2.8 he uses a result of Rosebrugh, Sabadini and Walters to show that $\textrm{Circ}_L$ can be viewed as the coproduct of $\textrm{FinCospan}$ and the free prop on the set L of labels. Brandon then defines $\textrm{Circ}$ to be the prop $\textrm{Circ}_L$ where L consists of a single element. This example is important, because $\textrm{Circ}$ can be seen as the category whose morphisms are circuits made of only perfectly conductive wires! From any morphism in $\textrm{Circ}$ he extracts a cospan of finite sets and then turns the cospan into a corelation. These two processes are functorial, so he gets a method for sending a circuit made of only perfectly conductive wires to a corelation: $\textrm{Circ} \stackrel{H'}{\longrightarrow} \textrm{FinCospan} \stackrel{H}{\longrightarrow} \textrm{FinCorel}$ There is also a functor $K\colon \textrm{FinCorel} \to \textrm{FinRel}_k$ where $\textrm{FinRel}_k$ is the category whose objects are finite dimensional vector spaces and whose morphisms $R\colon U\to V$ are linear relations, that is, linear subspaces $R\subseteq U \oplus V.$ By composing with the above functors $H'$ and $H$ he associates a linear relation $R$ to any circuit made of perfectly conductive wires. On the other hand he gets a subspace for any such circuit by first assigning potential and current to each terminal, and then subjecting these variables to the appropriate physical laws. It turns out that these two ways of assigning a subspace to a morphism in $\textrm{Circ}$ are the same. So, he calls the linear relation associated to a circuit using the composite $KHH'$ the “behavior” of the circuit and defines the “black-boxing” functor $\blacksquare \colon \textrm{Circ}\to \textrm{FinRel}_k$ to be the composite of these: $\textrm{Circ} \stackrel{H'}{\longrightarrow} \textrm{FinCospan} \stackrel{H}{\longrightarrow} \textrm{FinCorel} \stackrel{K}{\longrightarrow} \textrm{FinRel}_k$ Note that the underlying corelation of a circuit made of perfectly conductive wires completely determines the behavior of the circuit via the functor $K.$ In Chapter 4 he reinterprets the black-boxing functor $\blacksquare$ as a morphism of props. He does this by introducing the category $\textrm{LagRel}_k,$ whose objects are “symplectic” vector spaces and whose morphisms are “Lagrangian” relations. In Proposition 4.1.6 he proves that the functor $K\colon \textrm{FinCorel} \to \textrm{FinRel}_k$ actually picks out a Lagrangian relation for any corelation and thus determines a morphism of props. So, he redefines $K$ to be this morphism $K\colon \mathrm{FinCorel} \to \mathrm{LagRel}_k$ and reinterprets black-boxing as the composite $\mathrm{Circ} \stackrel{H'}{\longrightarrow} \mathrm{FinCospan} \stackrel{H}{\longrightarrow} \mathrm{FinCorel} \stackrel{K}{\longrightarrow} \mathrm{LagRel}_k$ After doing al this hard work for circuits made of perfectly conductive wires—a warmup exercises that engineers might scoff at—Brandon shows the power of his results by easily extending the black-boxing functor to circuits with arbitrary label sets in Theorem 4.2.1. He applies this result to a prop whose morphisms are circuits made of resistors, inductors, and capacitors. Then he considers a more general and mathematically more natural approach to linear circuits using the prop $\textrm{Circ}_k.$ The morphisms here are open circuits with wires labelled by elements of some chosen field $k.$ In Theorem 4.2.4 he prove the existence of a morphism of props $\blacksquare \colon \textrm{Circ}_k \to \textrm{LagRel}_k$ that describes the black-boxing of circuits built from arbitrary linear components. Brandon then picks up where Jason Erbele’s thesis left off, and recalls how control theorists use “signal-flow diagrams” to draw linear relations. These diagrams make up the category $\textrm{SigFlow}_k,$ which is the free prop generated by the same generators as $\textrm{FinRel}_k.$ Similarly he defines the prop $\widetilde{\mathrm{Circ}}_k$ as the free prop generated by the same generators as $\textrm{Circ}_k.$ Then there is a strict symmetric monoidal functor $T\colon \widetilde{\mathrm{Circ}}_k \to \textrm{SigFlow}_k$ giving a commutative square: Of course, circuits made of perfectly conductive wires are a special case of linear circuits. We can express this fact using another commutative square: Combining the diagrams so far, Brandon gets a commutative diagram summarizing the relationship between linear circuits, cospans, corelations, and signal-flow diagrams: Brandon concludes Chapter 4 by extending his work to circuits with voltage and current sources. These types of circuits define affine relations instead of linear relations. The prop framework lets Brandon extend black-boxing to these types of circuits by showing that affine Lagrangian relations are morphisms in a prop $\textrm{AffLagRel}_k.$ This leads to Theorem 4.4.5, which says that for any field $k$ and label set L there is a unique morphism of props $\blacksquare \colon \textrm{Circ}_L \to \textrm{AffLagRel}_k$ extending the other black-boxing functor and sending each element of L to an arbitrarily chosen affine Lagrangian relation between potentials and currents. In Chapter 5, Brandon studies bond graphs as morphisms in a category. His goal is to define a category $\textrm{BondGraph},$ whose morphisms are bond graphs, and then assign a space of efforts and flows as behavior to any bond graph using a functor. He also constructs a functor that assigns a space of potentials and currents to any bond graph, which agrees with the way that potential and current relate to effort and flow. The subtle way he defines $\textrm{BondGraph}$ comes from two different approaches to studying bond graphs, and the problems inherent in each approach. The first approach leads him to a subcategory $\textrm{FinCorel}^\circ$ of $\textrm{FinCorel},$ while the second leads him to a subcategory $\textrm{LagRel}_k^\circ$ of $\textrm{LagRel}_k.$ There isn’t a commutative square relating these four categories, but Brandon obtains a pentagon that commutes up to a natural transformation by inventing a new category $\textrm{BondGraph}$: This category is a way of formalizing Paynter’s idea of bond graphs. In his first approach, Brandon views a bond graph as an electrical circuit. He takes advantage of his earlier work on circuits and corelations by taking $\textrm{FinCorel}$ to be the category whose morphisms are circuits made of perfectly conductive wires. In this approach a terminal is the object 1 and a wire is the identity corelation from 1 to 1, while a circuit from m terminals to n terminals is a corelation from m to n. In this approach Brandon thinks of a port as the object 2, since a port is a pair of nodes. Then he thinks of a bond as a pair of wires and hence the identity corelation from 2 to 2. Lastly, the two junctions are two different ways of connecting ports together, and thus specific corelations from 2m to 2n. It turns out that by following these ideas he can equip the object 2 with two different Frobenius monoid structures, which behave very much like 1-junctions and 0-junctions in bond graphs! It would be great if the morphisms built from these two Frobenius monoids corresponded perfectly to bond graphs. Unfortunately there are some equations which hold between morphisms made from these Frobenius monoids that do not hold for corresponding bond graphs. So, Brandon defines a category $\textrm{FinCorel}^\circ$ using the morphisms that come from these two Frobenius monoids and moves on to a second attempt at defining $\textrm{BondGraph}.$ Since bond graphs impose Lagrangian relations between effort and flow, this second approach starts by looking back at $\textrm{LagRel}_k.$ The relations associated to a 1-junction make $k\oplus k$ into yet another Frobenius monoid, while the relations associated to a 0-junction make $k\oplus k$ into a different Frobenius monoid. These two Frobenius monoid structures interact to form a bimonoid! Unfortunately, a bimonoid has some equations between morphisms that do not correspond to equations between bond graphs, so this approach also does not result in morphisms that are bond graphs. Nonetheless, Brandon defines a category $\textrm{LagRel}_k^\circ$ using the two Frobenius monoid structures $k\oplus k.$ Since it turns out that $\textrm{FinCorel}^\circ$ and $\textrm{LagRel}_k^\circ$ have corresponding generators, Brandon defines $\textrm{BondGraph}$ as a prop that also has corresponding generators, but with only the equations found in both $\textrm{FinCorel}^\circ$ and $\textrm{LagRel}_k^\circ.$ By defining $\textrm{BondGraph}$ in this way he automatically gets two functors $F\colon \textrm{BondGraph} \to \textrm{LagRel}_k^\circ$ and $G\colon \textrm{BondGraph} \to \textrm{FinCorel}^\circ$ The functor $F$ associates effort and flow to a bond graph, while the functor $G$ lets us associate potential and current to a bond graph using the previous work done on $\textrm{FinCorel}.$ Then the Lagrangian subspace relating effort, flow, potential, and current: $\{(V,I,\phi_1,I_1,\phi_2,I_2) | V = \phi_2-\phi_1, I = I_1 = -I_2\}$ defines a natural transformation in the following diagram: Putting this together with the diagram we saw before, Brandon gets a giant diagram which encompasses the relationships between circuits, signal-flow diagrams, bond graphs, and their behaviors in category theoretic terms: This diagram is a nice quick road map of his thesis. Of course, you need to understand all the categories in this diagram, all the functors, and also their applications to engineering, to fully appreciate what he has accomplished! But his thesis explains that. ### To learn more Coya’s thesis has lots of references, but if you want to see diagrams at work in actual engineering, here are some good textbooks on bond graphs: • D. C. Karnopp, D. L. Margolis and R. C. Rosenberg, System Dynamics: A Unified Approach, Wiley, New York, 1990. • F. T. Brown, Engineering System Dynamics: A Unified Graph-Centered Approach, Taylor and Francis, New York, 2007. and here’s a good one on signal-flow diagrams: • B. Friedland, Control System Design: An Introduction to State-Space Methods, S. W. Director (ed.), McGraw–Hill Higher Education, 1985. ## Applied Category Theory 2018 – Videos 30 April, 2018 Some of the talks at Applied Category Theory 2018 were videotaped by the Statebox team. You can watch them on YouTube: • David Spivak, A higher-order temporal logic for dynamical systems. Book available here and slides here. • Fabio Zanasi and Bart Jacobs, Categories in Bayesian networks. Paper available here. (Some sound missing; when you hit silence skip forwards to about 15:00.) • Bob Coecke and Aleks Kissinger, Causality. Paper available here. • Samson Abramsky, Games and constraint satisfaction, Part 1 and Part 2. Paper available here. • Dan Ghica, Diagrammatic semantics for digital circuits. Paper available here. • Kathryn Hess, Towards a categorical approach to neuroscience. • Tom Leinster, Biodiversity and the theory of magnitude. Papers available here and here. • John Baez, Props in network theory. Slides available here, paper here and blog article here. ## Props in Network Theory 27 April, 2018 Long before the invention of Feynman diagrams, engineers were using similar diagrams to reason about electrical circuits and more general networks containing mechanical, hydraulic, thermodynamic and chemical components. We can formalize this reasoning using ‘props’: a certain kind of categories whose objects are natural numbers, with the tensor product of objects given by addition. In this approach, each kind of network corresponds to a prop, and each network of this kind is a morphism in that prop. A network with $m$ inputs and $n$ outputs is a morphism from $m$ to $n.$ Putting networks together in series is composition, and setting them side by side is tensoring. In this paper, we study the props for various kinds of electrical circuits: • John Baez, Brandon Coya and Franciscus Rebro, Props in network theory. We start with circuits made solely of ideal perfectly conductive wires. Then we consider circuits with passive linear components like resistors, capacitors and inductors. Finally we turn on the power and consider circuits that also have voltage and current sources. And here’s the cool part: each kind of circuit corresponds to a prop that pure mathematicians would eventually invent on their own! So, what’s good for engineers is often mathematically natural too. We describe the ‘behavior’ of these various kinds of circuits using morphisms between props. In particular, we give a new proof of the black-boxing theorem proved earlier with Brendan Fong. Unlike the original proof, this new one easily generalizes to circuits with nonlinear components! We also use a morphism of props to clarify the relation between circuit diagrams and the signal-flow diagrams in control theory. Here’s a quick sketch of the main ideas. ### Props in network theory In his 1963 thesis, Lawvere introduced functorial semantics: the use of categories with specified extra structure as ‘theories’ whose ‘models’ are structure-preserving functors into other such categories: • F. W. Lawvere, Functorial semantics of algebraic theories, Ph.D. thesis, Department of Mathematics, Columbia University, 1963. Also in Reprints in Theory and Applications of Categories 5 (2003), 1–121. In particular, a Lawvere theory is a category with finite cartesian products and a distinguished object $X$ such that every object is a power $X^n.$ These can serve as theories of mathematical structures that are sets $X$ equipped with $n$-ary operations $f \colon X^n \to X$ obeying equational laws. However, structures of a more linear-algebraic nature are often vector spaces equipped with operations of the form $f \colon X^{\otimes m} \to X^{\otimes n}$ To extend functorial semantics to these, Mac Lane introduced props—or as he called them, ‘PROPs’. The acronym stands for ‘products and permutations’: • Saunders Mac Lane, Categorical algebra, Bulletin of the American Mathematical Society 71 (1965), 40–106. A prop is a symmetric monoidal category equipped with a distinguished object $X$ such that every object is a tensor power $X^{\otimes n}.$ Working with tensor products rather than cartesian products puts operations having multiple outputs on an equal footing with operations having multiple inputs. Already in 1949 Feynman had introduced his famous diagrams, which he used to describe theories of elementary particles. For a theory with just one type of particle, Feynman’s method amounts to specifying a prop where an operation $f \colon X^{\otimes m} \to X^{\otimes n}$ describes a process with $m$ particles coming in and $n$ going out. Although Feynman diagrams quickly caught on in physics, only in the 1980s did it become clear that they were a method of depicting morphisms in symmetric monoidal categories. A key step was the work of Joyal and Street, which rigorously justified reasoning in any symmetric monoidal category using ‘string diagrams’—a generalization of Feynman diagrams: • André Joyal and Ross Street, The geometry of tensor calculus I, Advances in Mathematics 88 (1991), 55–112. By now, many mathematical physicists are aware of props and the general idea of functorial semantics. In constrast, props seem to be virtually unknown in engineering! But engineers have been using diagrammatic methods ever since the rise of electrical circuits. And in the 1940s, Olson explained how to apply circuit diagrams to networks of mechanical, hydraulic, thermodynamic and chemical components: • Harry F. Olson, Dynamical Analogies, Van Nostrand, New York, 1943. By 1961, Paynter had made the analogies between these various systems mathematically precise using ‘bond graphs’: • Henry M. Paynter, Analysis and Design of Engineering Systems, MIT Press, Cambridge, Massachusetts, 1961. Here he shows a picture of a hydroelectric power plant, and the bond graph that abstractly describes it: By 1963, Forrester was using circuit diagrams in economics: • Jay Wright Forrester, Industrial Dynamics, MIT Press, Cambridge, Massachusetts, 1961. In 1984, Odum published a beautiful and influential book on their use in biology and ecology: • Howard T. Odum, Ecological and General Systems: An Introduction to Systems Ecology, Wiley, New York, 1984. We can use props to study circuit diagrams of all these kinds! The underlying mathematics is similar in each case, so we focus on just one example: electrical circuits. For other examples, take a look at this: • John Baez, Network theory (part 29), Azimuth, 23 April 2013. In our new paper, we illustrate the usefulness of props by giving a new, shorter proof of the ‘black-boxing theorem’ proved here: • John Baez and Brendan Fong, A compositional framework for passive linear networks. (Blog article here.) A ‘black box’ is a system with inputs and outputs whose internal mechanisms are unknown or ignored. A simple example is the lock on a doorknob: one can insert a key and try to turn it; it either opens the door or not, and it fulfills this function without us needing to know its inner workings. We can treat a system as a black box through a process called ‘black-boxing’, which forgets its inner workings and records only the relation it imposes between its inputs and outputs. Systems with inputs and outputs can be seen as morphisms in a category, where composition uses the outputs of the one system as the inputs of another. We thus expect black-boxing to be a functor out of a category of this sort. A ‘black-boxing theorem’ makes this intuition precise. In an electrical circuit, associated to each wire there is a pair of variables called the potential $\phi$ and current $I.$ When we black-box such a circuit, we record only the relation it imposes between the variables on its input and output wires. Since these variables come in pairs, this is a relation between even-dimensional vector spaces. But these vector spaces turn out to be equipped with extra structure: they are symplectic vector spaces, meaning they are equipped with a nondegenerate antisymmetric bilinear form. Black-boxing gives a relation that respects this extra structure: it is a ‘Lagrangian’ relation. Why does symplectic geometry show up when we black-box an electrical circuit? The first proof of the black-boxing theorem answered this question. A circuit made of linear resistors acts to minimize the total power dissipated in the form of heat. More generally, any circuit made of linear resistors, inductors and capacitors obeys a generalization of this ‘principle of minimum power’. Whenever a system obeys a minimum principle, it establishes a Lagrangian relation between input and output variables. This fact was first noticed in classical mechanics, where systems obey the ‘principle of least action’. Indeed, symplectic geometry has its origins in classical mechanics. But it applies more generally: for any sort of system governed by a minimum principle, black-boxing should give a functor to some category where the morphisms are Lagrangian relations. The first step toward such a theorem for electrical circuits is to treat circuits as morphisms in a suitable category. We start with circuits made only of ideal perfectly conductive wires. These are morphisms in a prop we call $\mathrm{Circ},$ defined in Section 3 of our paper. In Section 8 we construct a black-boxing functor $\blacksquare \colon \mathrm{Circ} \to \mathrm{LagRel}_k$ sending each such circuit to the relation it defines between its input and output potentials and currents. Here $\mathrm{LagRel}_k$ is a prop with symplectic vector spaces of the form $k^{2n}$ as objects and linear Lagrangian relations as morphisms, and $\blacksquare$ is a morphism of props. We work in a purely algebraic fashion, so $k$ here can be any field. In Section 9 we extend black-boxing to a larger class of circuits that include linear resistors, inductors and capacitors. This gives a new proof of the black-boxing theorem that Brendan and I proved: namely, there is a morphism of props $\blacksquare \colon \mathrm{Circ}_k \to \mathrm{LagRel}_k$ sending each such linear circuit to the Lagrangian relation it defines between its input and output potentials and currents. The ease with which we can extend the black-boxing functor is due to the fact that all our categories with circuits as morphisms are props. We can describe these props using generators and relations, so that constructing a black-boxing functor simply requires that we choose where it sends each generator, and check that the all the relations hold. In Section 10 we explain how electric circuits are related to signal-flow diagrams, used in control theory. Finally, in Section 11, we illustrate how props can be used to study nonlinear circuits. ### Outline of the results The paper is pretty long, so here’s a more detailed outline of the results. In Section 1 we explain a general notion of `$L$-circuit’ that was first introduced under a different name here: • R. Rosebrugh, N. Sabadini and R. F. C. Walters, Generic commutative separable algebras and cospans of graphs, Theory and Applications of Categories 15 (2005), 164–177. An $L$-circuit is a cospan of finite sets where the apex is the set of nodes of a graph whose edges are labelled by elements of some set $L.$ In applications to electrical engineering, the elements of $L$ describe different ‘circuit elements’ such as resistors, inductors and capacitors. We discuss a symmetric monoidal category $\mathrm{Circ}_L$ whose objects are finite sets and whose morphisms are (isomorphism classes of) $L$-circuits. In Section 2 we study $\mathrm{Circ}_L$ when $L$ is a 1-element set. We call this category simply $\mathrm{Circ}.$ In applications to engineering, a morphism in $\mathrm{Circ}$ describes circuit made solely of ideal conductive wires. We show how such a circuit can be simplified in two successive stages, described by symmetric monoidal functors: $\mathrm{Circ} \stackrel{G}{\longrightarrow} \mathrm{FinCospan} \stackrel{H}{\longrightarrow} \mathrm{FinCorel}$ Here $\mathrm{FinCospan}$ is the category of cospans of finite sets, while $\mathrm{FinCorel}$ is the category of ‘corelations’ between finite sets. Corelations, categorically dual to relations, are already known to play an important role in network theory: • Brendan Fong, Decorated corelations. Just as a relation can be seen as a jointly monic span, a corelation can be seen as a jointly epic cospan. The functor $G$ crushes any graph down to its set of components, while $H$ reduces any cospan to a jointly epic one. In Section 4 we turn to props. Propositions 11 and 12, proved in Appendix A.1 with the help of Steve Lack, characterize which symmetric monoidal categories are equivalent to props and which symmetric monoidal functors are isomorphic to morphisms of props. We use these to find props equivalent to $\mathrm{Circ}_L,$ $\mathrm{Circ},$ $\mathrm{FinCospan}$ and $\mathrm{FinCorel}.$ This lets us reinterpret the arrows here as morphisms of props: $\mathrm{Circ} \stackrel{G}{\longrightarrow} \mathrm{FinCospan} \stackrel{H}{\longrightarrow} \mathrm{FinCorel}$ In Section 5 we discuss presentations of props. Proposition 19, proved in Appendix A.2 using a result of Todd Trimble, shows that the category of props is monadic over the category of signatures, $\mathrm{Set}^{\mathbb{N} \times \mathbb{N}}.$ This lets us work with props using generators and relations. We conclude by recalling a presentation of $\mathrm{FinCospan}$ due to Lack and a presentation of $\mathrm{FinCorel}$ due to Coya and Fong: • Steve Lack, Composing PROPs, Theory and Applications of Categories 13 (2004), 147–163. • Brandon Coya and Brendan Fong, Corelations are the prop for extraspecial commutative Frobenius monoids, Theory and Applications of Categories 32 (2017), 380–395. (Blog article here.) In Section 6 we introduce the prop $\mathrm{FinRel}_k.$ This prop is equivalent to the symmetric monoidal category with finite-dimensional vector spaces over the field $k$ as objects and linear relations as morphisms, with direct sum as its tensor product. A presentation of this prop was given in these papers: • Filippo Bonchi, Pawel Sobociénski and Fabio Zanasi, Interacting Hopf algebras, Journal of Pure and Applied Algebra 221 (2017), 144–184. • John Baez and Jason Erbele, Categories in control, Theory and Application of Categories 30 (2015), 836–881. (Blog article here.) In Section 7 we state the main result in the paper by Rosebrugh, Sabadini and Walters. This gives a presentation of $\mathrm{Circ}_L.$ Equivalently, it says that $\mathrm{Circ}_L$ is the coproduct, in the category of props, of $\mathrm{FinCospan}$ and the free prop on a set of unary operations, one for each element of $L.$ This result makes it easy to construct morphisms from $\mathrm{Circ}_L$ to other props. In Section 8 we introduce the prop $\mathrm{LagRel}_k$ where morphisms are Lagrangian linear relations between symplectic vector spaces, and we construct the black-boxing functor $\blacksquare \colon \mathrm{Circ} \to \mathrm{LagRel}_k.$ Mathematically, this functor is the composite $\mathrm{Circ} \stackrel{G}{\longrightarrow} \mathrm{FinCospan} \stackrel{H}{\longrightarrow} \mathrm{FinCorel} \stackrel{K}{\longrightarrow} \mathrm{LagRel}_k$ where $K$ is a symmetric monoidal functor defined by its action on the generators of $\mathrm{FinCorel}.$ In applications to electrical engineering, the black-boxing functor maps any circuit of ideal conductive wires to its ‘behavior’: that is, to the relation that it imposes on the potentials and currents at its inputs and outputs. In Section 9 we extend the black-boxing functor to circuits that include resistors, inductors, capacitors and certain other linear circuit elements. The most elegant prop having such circuits as morphisms is $\mathrm{Circ}_k,$ meaning $\mathrm{Circ}_L$ with the label set $L$ taken to be a field$k.\$ We characterize the black-boxing functor

$\blacksquare \colon \mathrm{Circ}_k \to \mathrm{LagRel}_k$

in Theorem 41.

In Section 10 we expand the scope of inquiry to include ‘signal-flow diagrams’, which are important in control theory. We explain how signal-flow diagrams serve as a syntax for linear relations. Concretely, this means that signal-flow diagrams are morphisms in a free prop $\mathrm{SigFlow}_k$ with the same generators as $\mathrm{FinRel}_k,$ but no relations. There is thus a morphism of props

$\square \colon \mathrm{SigFlow}_k \to \mathrm{FinRel}_k$

mapping any signal-flow diagrams to the linear relation that it denotes. It is natural to wonder how this is related to the black-boxing functor

$\blacksquare \colon \mathrm{Circ}_k \to \mathrm{LagRel}_k$

The answer involves the free prop $\widetilde{\mathrm{Circ}}_k$ which arises when we take the simplest presentation of $\mathrm{Circ}_k$ and omit the relations. This comes with a map

$P \colon \widetilde{\mathrm{Circ}}_k \to \mathrm{Circ}_k$

which reinstates those relations, and in Theorem 44 we show there is a map of props $T \colon \widetilde{\mathrm{Circ}}_k \to \mathrm{SigFlow}_k$ making this diagram commute:

Putting everything together, we get this grand commuting diagram relating circuit diagrams, linear circuits, signal flow diagrams, cospans, corelations, Lagrangian relations, and linear relations:

Finally, in Section 11 we illustrate how props can also be used to study nonlinear circuits. Namely, we show how to include voltage and current sources. Black-boxing these gives Lagrangian affine relations between symplectic vector spaces! Eventually we’ll get around to studying more general nonlinear circuits… but not today.

## Applied Category Theory at NIST (Part 1)

17 February, 2018

I think it’s really cool how applied category theory is catching on. My former student Blake Pollard is working at the National Institute of Standards and Technology on applications of category theory to electrical engineering. He’s working with Spencer Breiner… and now Breiner is helping run a workshop on this stuff:

• Applied Category Theory: Bridging Theory & Practice, March 15–16, 2018, NIST, Gaithersburg, Maryland, USA. Organized by Spencer Breiner and Eswaran Subrahmanian.

It’s by invitation only, but I can’t resist mentioning its existence. Here’s the idea:

What: The Information Technology Laboratory at NIST is pleased to announce a workshop on Applied Category Theory to be held at NIST’s Gaithersburg, Maryland campus on March 15 & 16, 2018. The meeting will focus on practical avenues for introducing methods from category theory into real-world applications, with an emphasis on examples rather than theorems.

Who: The workshop aims to bring together two distinct groups. First, category theorists interested in pursuing applications outside of the usual mathematical fields. Second, domain experts and research managers from industry, government, science and engineering who have in mind potential domain applications for categorical methods.

Intended Outcomes: A proposed landscape of potential CT applications and the infrastructure needed to realize them, together with a 5-10 year roadmap for developing the field of applied category theory. This should include perspectives from industry, academia and government as well as major milestones, potential funding sources, avenues for technology transfer and necessary improvements in tool support and methodology. Exploratory collaborations between category theorists and domain experts. We will ask that each group come prepared to meet the other side. Mathematicians should be prepared with concrete examples that demonstrate practical applications of CT in an intuitive way. Domain experts should bring to the table specific problems to which they can devote time and/or funding as well as some reasons about why they think CT might be relevant to this application.

Invited Speakers:
John Baez (University of California at Riverside) and John Foley (Metron Scientific Solutions).
Bob Coecke (University of Oxford).
Dusko Pavlovic (University of Hawaii).

Some other likely participants include Chris Boner (Metron), Arquimedes Canedo (Siemens at Princeton), Stephane Dugowson (Supméca), William Edmonson (North Carolina A&T), Brendan Fong (MIT), Mark Fuge (University of Maryland), Jack Gray (Penumbra), Helle Hansen (Delft), Jelle Herold (Statebox), Marisa Hughes (Johns Hopkins), Steve Huntsman (BAE Systems), Patrick Johnson (Dassault Systèmes), Al Jones (NIST), Cliff Joslyn (Pacific Northwest National Laboratory), Richard Malek (NSF), Tom Mifflin (Metron), Ira Monarch (Carnegie Mellon), John Paschkewitz (DARPA), Evan Patterson (Stanford), Blake Pollard (NIST), Emilie Purvine (Pacific Northwest National Laboratory), Mark Raugas (Pacific Northwest National Laboratory), Bill Regli (University of Maryland), Michael Robinson (American U.) Alberto Speranzon (Honeywell Aerospace), David Spivak (MIT), Eswaran Subrahmanian (Carnegie Mellon), Jamie Vicary (Birmingham and Oxford), and Ryan Wisnesky (Categorical Informatics).

A bunch of us will stay on into the weekend and talk some more. I hope we make a lot of progress—and I plan to let you know how it goes!

I’ll be giving a joint talk with John Foley about our work using operads to design networks. This work is part of the Complex Adaptive System Composition and Design Environment project being done by Metron Scientific Solutions and managed by John Paschkewitz at DARPA.

## Postdoc in Applied Category Theory

8 September, 2017

guest post by Spencer Breiner

### One Year Postdoc Position at Carnegie Mellon/NIST

We are seeking an early-career researcher with a background in category theory, functional programming and/or electrical engineering for a one-year post-doctoral position supported by an Early-concept Grant (EAGER) from the NSF’s Systems Science program. The position will be managed through Carnegie Mellon University (PI: Eswaran Subrahmanian), but the position itself will be located at the US National Institute for Standards and Technology (NIST), located in Gaithersburg, Maryland outside of Washington, DC.

The project aims to develop a compositional semantics for electrical networks which is suitable for system prediction, analysis and control. This work will extend existing methods for linear circuits (featured on this blog!) to include (i) probabilistic estimates of future consumption and (ii) top-down incentives for load management. We will model a multi-layered system of such “distributed energy resources” including loads and generators (e.g., solar array vs. power plant), different types of resource aggregation (e.g., apartment to apartment building), and across several time scales. We hope to demonstrate that such a system can balance local load and generation in order to minimize expected instability at higher levels of the electrical grid.

This post is available full-time (40 hours/5 days per week) for 12 months, and can begin as early as October 1st.