You're reading the public-facing archive of the Category Theory Zulip server.
To join the server you need an invite. Anybody can get an invite by contacting Matteo Capucci at name dot surname at gmail dot com.
For all things related to this archive refer to the same person.
Hi all! This is the thread of discussion for Fabrizio's tutorial, "An introduction to string diagrams."
Abstract:
We will introduce the basic concepts of surface diagrams for 1-, 2- and n- categories. From there, we will introduce string diagrams for various flavors of monoidal categories (monoidal, compact closed, traced, ...). There are no prerequisites.
still, a pre-talk reading would be useful. thanks in advance.
When and where: Sunday July 5, 15:00 UTC (11 am EDT)
Zoom meeting: https://mit.zoom.us/j/7055345747
See also the main website.
We start in 5 min!
Here are the links given by Fabrizio.
Marsden: Category Theory using string diagrams https://arxiv.org/abs/1401.7220
Selinger: A survey of graphical languages for mon cat https://arxiv.org/abs/0908.3347
He also mentioned this paper by Joyal and Street, where they essentially prove that using string diagrams is valid.
https://www.sciencedirect.com/science/article/pii/000187089190003P
How does one draw a parallel pair (no 2-morphisms between them) with this graphical representation of 2-categories?
Let's ask this question at the end :)
A single string diagram only depicts a single morphism. What I mean is that you can have many morphisms depicted, but they must be composed somehow to get it all down to a single (composite) morphism.
So if you want two different morphisms, but you don't want to talk about composing them, you just have to draw two different diagrams.
Paolo Perrone said:
Let's ask this question at the end :)
Ok, thanks! I wrote it here because the Zoom chat is flowing too fast. I'll save my questions for later.
Joe Moeller said:
So if you want two different morphisms, but you don't want to talk about composing them, you just have to draw two different diagrams.
That makes sense. Thanks.
Someone took notes here, that also includes a bunch of links: https://codi.lassul.us/HqlF3K2CR0eYcpUbiOnneA
I'm still around if there are more questions btw :slight_smile:
@Fabrizio Genovese , from the different 'extensions' of SMC (braided, traced, etc) where does Petri Nets fall?
Heh! It turns out that Petri nets can be thought of as presentations of monoidal categories
There are many different flavors of petri nets and many different flavors of monoidal categories, but roughly:
Petri nets can be linked to commutative and symmetric monoidal categories, depending who you ask to. Relevan papers are:
https://arxiv.org/abs/1808.05415
https://link.springer.com/chapter/10.1007/3-540-59293-8_205
Then there are generalizations, such as:
https://arxiv.org/abs/1805.05988
https://www.researchgate.net/publication/221138189_Pre-nets_Read_Arcs_and_Unfolding_A_Functorial_Presentation/link/09e41511e079fab475000000/download
Hey all! Here's the video.
https://www.youtube.com/watch?v=LY5H9uY7Gns&list=PLCOXjXDLt3pYPE63bVbsVfA41_wa3sZOh
Given a string diagram in an SMC, I'm trying to picture algorithms for converting them into expressions involving tensoring, composition and identities. Let's assume there are no loops. Then the process nodes are partially ordered by the relation where A <= B means that A outputs to wire X, and X inputs to B. Then form a topological sort of the process nodes. We can use this to get an expression for the whole diagram, which is a sequential composition of expressions, one per process node. This corresponds to morphing the diagram by sliding the process nodes around, so that in the result, no two process nodes are drawn concurrently. Then every intermediate stage in the sequential pipeline is a tensoring of all the parallel wires that go from one stage to the next. Each node inputs some wires from the outputs of its predecessor node, and some wires which are "carried over" from earlier stages in the chain. So the expression for that node is the tensoring of the morphism associated with that node, with identities for all of the wires which are carrried over.
This construction seems to work, but it involves what looks like an artificial sequentialization of the diagram.
Maybe this is just one of those things, stemming ultimately from the fact that whereas the string diagram involves a DAG-like structure, any representing expression must be a tree.
You are tapping into a very complicated problem. It seems to me that you want to find a data structure that represents well a string diagram, that is, a data structure which is invariant wrt the topological deformations you do with diagrams.
This is pretty much what we tried to do at Statebox for one year. We absolutely needed such a data structure to get a formally verified implementation of free SMCs in Idris
Then this paper came out: http://cartographer.id/cartographer-calco-2019.pdf
Pawel, Paul and Fabio worked out a data structure that is not quite what we want, but very very close to it. From there, we were able to edit it here and there to finally obtain a data structure that represents string diagrams invariantly
In general, for some "easier" stuff (e.g. manipulating string diagrams in the graphical interface) we just store the diagram as a tree. This is what we do in edit.statebox.cloud, and you can see the tree corresponding to a diagram in the bottom part of the window.
Clearly, there are many different trees depicting the same diagram. We do not pick any particular normal form, the tree you get depends on how you specify the morphisms. This is ok because then we convert such a tree into our invariant data structure in the formally verified idris "core", where the actual computations are carried out
Maybe all this is a bit handwavy, but long story short: Representing string diagrams in a computationally satisfying way is not easy, nor intuitive. This is very similar to what happens with graphs. Mathematicians working with graphs may think "well it's just a graph" but there are many different ways of storing a graph as data, which have absolutely inequivalent properties. Simply put, rivers of words have been written on the problem of computing with graphs, and with string diagrams the situation is similar if not worse :grinning:
Maybe this is just one of those things, stemming ultimately from the fact that whereas the string diagram involves a DAG-like structure, any representing expression must be a tree.
@Evan Patterson implemented a function from StringDiagrams to Expressions in Catlab. It does require arbitrary choices about ordering the diagram in order to force a DAG into a tree. Different choices yield different properties of the resulting trees. That is part of the motivation for unbiased languages for SMCs based on Operads of Wiring Diagrams, which is an ongoing development topic in Catlab.
Thanks James, Catlab does have an algorithm for converting wiring diagrams into expression trees. It is inspired by known algorithms for decomposing series-parallel digraphs (graphs that really wish they were SMCs). The algorithm prefers parallelism, i.e., it favors over in the interchange law. To deal with the arbitrariness of order in tensor products (think vs ) simple heuristics for minimizing edge crossings are used.
That said, I do not understand the mathematical properties of the algorithm. I do not know whether it is "optimal" in finding parallelism or even that it works in all cases, as tricky special cases have a habit of cropping up. So, as Fabrizio said, it is a hard problem.
Personally, I find myself moving away from this approach towards working in fully unbiased structures like wiring diagrams. However, as the Cartographer paper illustrates, the problem of extracting expressions is closely related to the layout of diagrams for drawing, and it is used for that purpose in Catlab, being one of two layout algorithms supported. (The other layout algorithm is Graphviz dot, a layered graph drawing algorithm.) So there will always be uses for such techniques.
Thanks @Fabrizio Genovese , @James Fairbanks and @Evan Patterson for your informative replies!
Fabrizio Genovese said:
Pawel, Paul and Fabio worked out a data structure that is not quite what we want, but very very close to it. From there, we were able to edit it here and there to finally obtain a data structure that represents string diagrams invariantly
I'm interested in what you mean by "invariant" here. One of the things that was always a pain Quantomatic was dealing concretely with graphs and graph rewriting, which are iso-invariant. This involves lots of fiddling with "names" of vertices and edges, with much of the code devoted to renaming and finding fresh names e.g to do direct sums and the like. Does your implementation get around those problems?
Aleks Kissinger said:
Fabrizio Genovese said:
Pawel, Paul and Fabio worked out a data structure that is not quite what we want, but very very close to it. From there, we were able to edit it here and there to finally obtain a data structure that represents string diagrams invariantly
I'm interested in what you mean by "invariant" here. One of the things that was always a pain Quantomatic was dealing concretely with graphs and graph rewriting, which are iso-invariant. This involves lots of fiddling with "names" of vertices and edges, with much of the code devoted to renaming and finding fresh names e.g to do direct sums and the like. Does your implementation get around those problems?
What i mean is that, for instance, you can write the same string diagram as and as . If you write a string diagram as a tree of tensors and compositions, those two things will be different trees. Instead, you want a data structure where those are literally the same thing.
E.g, lists are naturally associative: If I denote a composition of morphisms as a list, then [f,g,h]
both stands for and . In this sense, the list is naturally invariant wrt associativity
So, in your data structure, are any two descriptions of the same string diagram literally equal? Or are they equal upto some equivalence (e.g. alpha-conversion)?
Aleks Kissinger said:
So, in your data structure, are any two descriptions of the same string diagram literally equal? Or are they equal upto some equivalence (e.g. alpha-conversion)?
Literally equal would be the dream. Actually the cartographer data structure goes very close to this modulo some slight reindexing
So what we did is implementing everything in idris, and then we postulated that two terms are equal modulo reindexing
@Fabrizio Genovese I'd be interested to know how things developed since the last time we had a chat about this in Tallinn!
Did you have a chance to get into nominal string diagrams? They felt like a good fix to the problem of alpha conversion etc. https://arxiv.org/abs/1904.07534
It's quite fiddly, but in the end we managed to make it work :grinning:
So the idea is that you create a type called "open hypegraph from l to m". This type is a record, so a term of this type is made of a bunch of other terms. Among those, there is this "wiring" which is just a permutation from a set of nats to another
These nats represent indexings of boundaries and more importantly internal nodes. So you can re-index the internal nodes in any way you want, if you change the permutation accordingly you get the same thing
so in the end we had to postulate this properties for idris typechecker not to complain.
Let me see if we opened up our code already
So this encoding works for hypergraph categories? or symmetric monoidal in general?
https://github.com/statebox/fsm-oracle/blob/master/src/Cartographer/GoodHypergraphCategory.idr
So, goodhypergraphSMC
is the free symmetric strict monoidal category on a signature
this is based on goodHypegraph
which is a restriction of the hypegraph
data structure, which is the one I was talking about.
This is the hypegraph
https://github.com/statebox/fsm-oracle/blob/master/src/Cartographer/Hypergraph.idr
The postulate is on line 69.
I think I remember this "good" business from the last time you explained this stuff. It's checking that each wire is connected to a single port on both ends?
Yes, the idea is this: cartographer graphs can also form feedback loops, and we don't want them
So we notice that:
A singleton hypegraph is free of loops
Permutations (hypegraphs with no internal nodes) are free of loops
Any composition and tensoring of those two building blocks is free of loops
Do you know how much of this invariant encoding would work for non-symmetric cases?
Like, you don't want symmetries around?
This MAY make things easier, since the whole permutation business is a nightmare
Maybe you could just rule the permutations bit out
I'm wondering if the problem gets any easier if you solve it in two stages, first non-symmetric monoidal then symmetry and permutation nightmares?
Nope, it doesn't
because the problem IS the permutation nightmare xD
So, for instance, our code is:
data GoodHypergraph : {s : Type} -> {ai, ao : s -> List o} -> (g : Hypergraph s ai ao k l) -> Type where
Singleton : (edge : s) -> GoodHypergraph (singleton edge)
Permutation : (p : Perm k l) -> GoodHypergraph (permutation p)
HComp : (a : GoodHypergraph g)
-> (b : GoodHypergraph h)
-> GoodHypergraph (compose g h)
VComp : (a : GoodHypergraph g)
-> (b : GoodHypergraph h)
-> GoodHypergraph (add g h)
If you don't want to allow permutations you just rule them out in the record substituting them wit Identities
So you want an identity datatype which is way easier than a permutation
Don't you end up with factorial explosions when you try to handle permutations explicitly? Or did you manage to make the code lazy enough that it never actually run through all of them?
So in this type signature s
is the type of nodes (basic blocks), ai
and ao
are arity functions telling you inputs and outputs of wires, etc
Alexis Toumi said:
Don't you end up with factorial explosions when you try to handle permutations explicitly? Or did you manage to make the code lazy enough that it never actually run through all of them?
You don't, because you don't deal with them explicitly
Cool!
I'm still curious whether/how nominal sets of wires would help for this nightmare
If I write append to list :: a -> [a] -> [a]
I'm not considering all lists over type a
at once
Nominal sets just hide permutations under the rug using a group action
but guess what, we have to implement the group action anyway xD
So at this point it was easier to use idris permutation library xD
What would really help is HoTT
Cos we could just use truncated types and define SMCs without constructing all this explicitly
Which we did btw, actually @Fredrik Nordvall Forsberg did it for us: https://github.com/statebox/idris-ct/pull/32/files
Fabrizio Genovese said:
Aleks Kissinger said:
So, in your data structure, are any two descriptions of the same string diagram literally equal? Or are they equal upto some equivalence (e.g. alpha-conversion)?
Literally equal would be the dream. Actually the cartographer data structure goes very close to this modulo some slight reindexing
Yeah, this is basically what quanto does as well. I see Cartographer has a "HyperEdgeId" type, which is basically an int, which serves to give the hyperedge a unique (but meaningless) name, then you are always working modulo renaming. I don't know if there's really any way around that. There may even be some kind of "no free lunch" principle when it comes to data structures representing string diagrams
i've experimented some with representing string diagrams as Penrose abstract tensor systems (formalised using nominal algebra). theoretically, this looks quite nice. in practice, i lost weeks proving little lemmas about finite supports and equivarience in nominal isabelle, and never quite got it to understand the "obvious" way you can do equational reasoning with the abstract tensor notation.
I think there is no way until we have a type theory that supports quotients well, like HoTT.