joint with Brendan Fong
We’re getting ready for the Turin workshop on the
Categorical Foundations of Network Theory. So, we’re trying to get our thoughts in order.
Last time we talked about understanding types of networks as categories of decorated cospans. Earlier, David Spivak told us about understanding networks as algebras of an operad. Both these frameworks work at capturing notions of modularity and interconnection. Are they then related? How?
In this post we want to discuss some similarities between decorated cospan categories and algebras for Spivak’s operad of wiring diagrams. The main idea is that the two approaches are ‘essentially’ equivalent, but that compared to decorated cospans, Spivak’s operad formalism puts greater emphasis on the distinction between the ‘duplication’ and ‘deletion’ morphisms and other morphisms in our category.
The precise details are still to be worked out—jump in and help us!
We begin with a bit about operads in general. Recall that an operad is similar to a category, except that instead of a set of morphisms from any object to any object you have a set of operations from any finite list of objects to any object If we have an operation we can call the inputs of and call the output of
We can compose operations in an operad. To understand how, it’s easiest to use pictures. We draw an operation in as a little box with wires coming in and one wire coming out:
The input wires should be labelled with the objects and the output wire with the object but I haven’t done this.
We are allowed to compose these operations as follows:
as long as the outputs of the operations match the inputs of the operation The result is a new operation which we call
We demand that there be unary operations serving as identities for composition, and we impose an associative law that makes a composite of composites like this well-defined:
So far this is the definition of a operad without permutations. In a full-fledged permutative operad, we can also permute the inputs of an operation and get a new operation:
which we call if is the the permutation of the inputs. We demand that And finally, we demand that permutations act in a way that is compatible with composition. For example:
Here we see that is equal to some obvious other thing.
Finally, there is a law saying
for some choice of that you can cook up from the permuations in an obvious way. We leave it as an exercise to work out the details. By the way, one well-known book on operads accidentally omits this law, so here’s a rather more lengthy exercise: read this book, see which theorems require this law, and correct their proofs!
Operads are similar to symmetric monoidal categories. The idea is that in a symmetric monoidal category you can just form the tensor product and talk about the set of morphisms Indeed any symmetric monoidal category gives an operad in this way: just define to be If we do this with Set, which is a symmetric monoidal category using the usual cartesian product of sets, we get an operad called
An algebra for an operad is an operad homomorphism We haven’t said what an operad homomorphism is, but you can probably figure it out yourself. The point is this: an algebra for turns the abstract operations in into actual operations on sets!
Finally, we should warn you that operads come in several flavors, and we’ve been talking about ‘typed permutative operads’. ‘Typed’ means that there’s more than one object; ‘permutative’ means that we have the ability to permute the input wires. When people say ‘operad’, they often mean an untyped permutative operad. For that, just specialize down to the case where there’s only one object
You can see a fully precise definition of untyped permutative operads here:
• Operad theory, Wikipedia.
along with the definition of an untyped operad without permutations.
The operad of wiring diagrams
Spivak’s favorite operad is the operad of wiring diagrams. The operad of wiring diagrams is an operad version of constructed in the vein suggested above: the objects are finite sets, and an operation from a list of sets to a set is a cospan
Spivak draws such a thing as a big circle with small circles cut out from the interior:
The outside of the big circle has a set of terminals marked on it, and each small circle has a set of terminals marked on it. Then in the interior of this shape there are wires connecting these terminals. This what he calls a wiring diagrams.
You compose these wiring diagrams by pasting other wiring diagrams into each of the small circles.
The relationship with our Frobenius monoid diagrams is pretty simple: we draw our ‘wiring diagrams’ in a square, with the terminals on the left and terminals on the right. To get a Spivak-approved wiring diagram, glue the top and bottom edges of this square together, then flatten the cylinder you get down into an annulus, with the -side on the inside and -side on the outside. If you can imagine gluing opposite edges of the inside circle together to divide it into two small circles accordingly, and so on.
Relational algebras of type A
Algebras for wiring diagrams tell you what components you have available to wire together with your diagrams. An algebra for the operad of wiring diagrams is an operad homomorphism
What does this look like? Just like a functor for categories, it assigns to each natural number a set, and each wiring diagram a function.
In work related to decorated cospans (such as our paper on circuits or John and Jason’s work on signal flow diagrams), our semantics usually is constructed from a field of values—not a physicist’s ‘field’, bt an algebraist’s sort of ‘field’, where you can add, multiply, subtract and divide. For example, we like being able to assign a real number like a velocity, or potential, or current to a variable. This gives us vector spaces and a bunch of nice linear-algebraic structures.
Spivak works more generally: he’s interested in the structure when you just have a set of values. While this means we can’t do some of the nice things we could do with a field, it also means this framework can do things like talk about logic gates, where the variables are boolean ones, or number theoretic questions, where you’re interested in the natural numbers.
So to discuss semantics we pick a set of values, such as the real numbers or natural numbers or booleans or colors. We imagine then associating elements of this set to each wire in a wiring diagram. More technically, the algebra
then maps each finite set to the power set of the set of functions
On the morphisms (the wiring diagrams themselves), this functor behaves as follows. Note that a function () can be thought of as an ‘X-vector’ of ‘A-coordinates’. A wiring diagram is just a cospan
in so it can be thought of as some compares
followed by some copies
Thus, given a wiring diagram we can consider a partial function that maps an -vector to the -vector by doing these compares, and if it passes them does the copies and returns the resulting -vector, but if not returns ‘undefined’. We can then define a map which takes a set of -vectors to its image under this partial function.
This semantics is called the relational -algebra of type A. We can think of it as being like the ‘light operations’ fragment of the signal flow calculus. By ‘light operations’, we mean the operations of duplication and deletion, which form a cocommutative comonoid:
and their time-reversed versions, ‘coduplication’ and ‘codeletion’, which form a commutatative monoid:
These fit together to form a Frobenius monoid, meaning that these equations hold:
And it’s actually extra-special, meaning that these equations hold:
(If you don’t understand these hieroglyphics, please reread our post about categories in control theory, and ask some questions!)
Note that we can’t do the ‘dark operations’, because we only have a set of values, not a field, and the dark operations involve addition and zero!
Operads and the behavioral approach
In formulating Frobenius monoids this way, Spivak achieves something that we’ve been working hard to find ways to achieve: a separation of the behavioral structure from the interconnection structure.
What do I mean by this? In his ‘behavioral approach‘, Willems makes the point that for all their elaborate and elegant formulation, in the end physical laws just come down to dividing the set of what might a priori be possible (the ‘universum’) into the set of things that actually are possible (the ‘behavior’), and the set of things that aren’t). Here the universum is the set : a priori, on each of the wires in we might associate any value of For example, to the two wires at the ends of a resistor, we might a priori associate any pair of currents. But physical law, here Kirchhoff’s current law, says otherwise: the currents must be equal and opposite. So the ‘behavior’ is the subset of the universum
So you can say that to each object in the operad of wiring diagrams the relational algebra of type associates the set of possible behaviors—the universum is ( forms some sort of meta-universum, where you can discuss physical laws about physical laws, commonly called ‘principles’.)
The second key aspect of the behavioral approach is that the behaviors of larger systems can be constructed from the behaviors of its subsystems, if we understand the so-called ‘interconnection structure’ well enough. This is a key principle in engineering: we build big, complicated systems from a much smaller set of components, whether it be electronics from resistors and inductors, or mechanical devices from wheels and rods and ropes, or houses from Lego bricks. The various interconnection structures here are the wiring diagrams, and our relational algebras say they act by what Willems calls ‘variable sharing’.
This division between behavior and interconnection motivates the decorated cospan construction (where the decorations are the ‘components’, the cospans the ‘interconnection’) and also the multigraph categories discussed by Aleks Kissinger (where morphisms are the ‘components’, and the Frobenius monoid operations are the ‘interconnection’):
• Aleks Kissinger, Finite matrices are complete for (dagger-)multigraph categories.
So it’s good to have this additional way of thinking about things in our repertoire: operads describe ‘interconnection’, their algebras ‘behaviors’.
The separation Spivak achieves, however, seems to me to come at the cost of neat ways to talk about individual components, and perhaps this can be seen as the essential difference between the two approaches. By including our components as morphisms, we can talk more carefully about them and additional structure individual components have. On the other hand, by lumping all the components into the objects, Spivak can talk more carefully about how the interconnection structure acts on all behaviors at once.
Other operads of wiring diagrams
One advantage of the operad approach is that you can easily tweak your operad to talk about different sorts of network structure. Sometimes you can make similar adjustments with decorated cospans too, such as working over the category of typed finite sets, rather than just finite sets, to discuss networks in which wires have types, and only wires of the same types can be connected together. A physical example is a model of a hydroelectric power plant, where you don’t want to connect a water pipe with an electrical cable! This is also a common technique in computer science, where you don’t want to try to multiply two strings of text, or try to interpret a telephone number as a truth value.
But some modifications are harder to do with decorated cospans. In some other papers, Spivak employs a more restricted operad of wiring diagrams, in which joining wires and terminating wires is not allowed, among other things. He uses this to formalise graphical languages for certain types of discrete-time processes, open dynamical systems, including mode-dependent ones.
For more detail, read these:
• Brendan Fong, Decorated cospans.
• David Spivak, The operad of wiring diagrams: formalizing a graphical language for databases, recursion, and plug-and-play circuits.