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.
What tools do you use to draw your string diagrams? Some LaTeX package?
Are there tools that generate at the same time a diagram and a bunch of Agda or Coq or Idris declarations?
Thanks for starting this very important discussion! I generally use TikZ by default, but I would not call that a satisfactory solution. I am currently moving away from that and building web-based renderers that generate SVG, which can then be included in LaTeX reasonably well thanks to Inkscape's converter.
I've used Tikzit. You draw some pictures and it generates the tikz for it.
https://tikzit.github.io/
I've followed Penrose.ink (http://penrose.ink, https://github.com/penrose/penrose) for awhile: http://penrose.ink/PenroseIntro2018.pdf. It looks very promising.
Did you give a look to edit.statebox.cloud ? :)
It's for string diagrams, you can export the composition tree to JSON and a lot of common symbols like cups, caps, spiders etc are supported.
It would be very nice to have a backend to automatically produce tikz code out of these diagrams. We don't have time for it unfortunately, but if someone wants to try and make a PR we'd be glad to help :)
is it possible to try without logging in?
Registration is totally free and there's no verification required. We implemented it because in the future we want to give the possibility to save diagrams and load them at latter stages
So no, at the moment you have to register
one thing you could try is allowing users to edit diagrams, and then only prompt them to log in/sign up when they want to save a diagram, which I imagine would decrease the bounce rate
(though you've probably already thought about this)
As Joe said, lots of people seem to like Tikzit. If you'd rather generate diagrams programmatically than draw them manually, you might check out Catlab. It supports rendering in TikZ and also directly in SVG and other formats:
https://epatters.github.io/Catlab.jl/latest/generated/graphics/tikz_wiring_diagrams/
https://epatters.github.io/Catlab.jl/latest/generated/graphics/composejl_wiring_diagrams/
It's not perfect but it's usable and we're gradually improving it.
Regarding interoperation with other tools, Catlab can read/write wiring diagrams from JSON and XML formats. It doesn't talk to Agda et al but a bridge could be added by an interested person. Everything is open source.
I believe TikZit is the "canonical" answer, in fact I think TikZit v2 was written specifically for writing the book Picturing Quantum Processes with. (And I can't use it because my OS is too out of date, so I have to suffer instead)
Personally I can recommend spending a couple of days of quarantine getting cosy with the TikZ manual. You don't have to read all 900 pages to get started
Not bad advice, but I think our goal as a community should be to build good enough tools that people do NOT have to read the TikZ manual :)
the ideal is never having to write TikZ :+1:
It's a nice ideal to aim for. The reality is quite a lot of my day to day live involves writing TikZ code
Jules Hedges said:
Personally I can recommend spending a couple of days of quarantine getting cosy with the TikZ manual. You don't have to read all 900 pages to get started
Second that big time.
Nathanael Arkor said:
the ideal is never having to write TikZ :+1:
I don't agree. I spend much of my latex time thinking that if I were better with tikz I'd be superfast. Learning TiKz WILL always come in handy in a way or another. It's not a matter of if but a matter of when.
if you could generate the same diagrams you want to draw in TikZ automatically, what would be the downside?
Nathanael Arkor said:
one thing you could try is allowing users to edit diagrams, and then only prompt them to log in/sign up when they want to save a diagram, which I imagine would decrease the bounce rate
Yes. The point is that this tool is used as part of our stack, that is, it is used in the statebox programming language. Incidentally it seems to be also useful for academia, so we are trying to make researchers happy as well. But, being us a company, that's obviously not our primary focus...
if you could just plug some equations into Catlab.jl, for instance, and have it give you code to paste into LaTeX, wouldn't that make everything much simpler?
Yes. The point is that this tool is used as part of our stack, that is, it is used in the statebox programming language.
ah, I see
Nathanael Arkor said:
if you could generate the same diagrams you want to draw in TikZ automatically, what would be the downside?
No downside, but this kind of solutions will help only up to some point. E.g. we can write something to port statebox string diagrams to tikz. Perfect, but there will come a time when statebox diagrams won't do what you want. And at that point you'll have to get your hands dirty anyway
This is a small library of macros begun by Patrick Schultz and David Spivak; it's my favourite way to draw string diagrams so far:
http://github.com/appliedcategorytheory/TikZWD
This library is not bad at all indeed. And it's compositional in spirit, which is nice.
The downside is that the code is not super easy and it takes quite a long time to understand what's going on if you need to change something, but diving into it is a good investment (even better if you do it in the context of learning TiKz)
Perfect, but there will come a time when statebox diagrams won't do what you want. And at that point you'll have to get your hands dirty anyway
I think it's true that there will always be some people who need what tools can't offer — but I think you can get the tools to the point where 90% of people don't have to touch TikZ ever, or very rarely
(and for the other use cases, a graphical tool like TikZiT will probably suffice)
But why don't you want to touch tikz ever? I get that it may be inconvenient sometimes, but "not wanting to learn something" is a strange goal to set :D
Surely you already know the answer to that question :) Because some things are simply tedious, and TikZ is one of them.
I definitely don't agree, but ok I guess
Fair enough. I guess I should be grateful that some people really care about typesetting for its own sake, because that benefits everyone else.
it's similar to asking why you wouldn't want to learn ALGOL instead of a modern programming language
you might like to simply out of interest, but there's no point doing it because it's useful
if you can do everything TikZ can in a simpler and faster way, why would you want to use TikZ, which is quite difficult (even if it is an amazing tool, technically)?
(maybe an assembly language and a programming language is a better comparison — some people still need to deal with the low-level code, but most people would prefer not to)
Because you can't. That's my point. learning ALGOL indeed makes sense if there are libraries written only in ALGOL to do some stuff, which would require ages to port. This is why FORTRAN is still used in mathematics. Now, to my knowledge, there is only one way to draw everything you can think of using code in latex, and this is tikz. There aren't any alternatives that are universal as tikz is, so any other tool will only get you far up to some point
So I guess if you always deal with one particular kind of graphics (e.g. string diagrams) you can use a tool (e.g. TikZit), but if you don't (like in my case I have to use string diagrams, petri nets, graphs, and often mix all of these in the same picture) then TiKz is the only way.
yes, this is all in a hypothetical world where it is possible to create beautiful diagrams without writing TikZ manually (and predicated on the assumption that there could be better ways to draw diagrams than TikZ)
we're definitely starting to see tools for drawing string diagrams, petri nets and commutative diagrams
they're not there yet, but one day...
We have tools indeed, but let me give a concrete example: https://arxiv.org/pdf/1805.05988.pdf page 137
This is the kind of mixed picture I'm talking about, where tools don't help you much.
I guess that the thing closer to what you want is not a tool, but a nice, decent set of high-level macros for tikz
That's why I like the library Brendan was referring to. It goes in that direction, albeit being still difficult to use :)
I guess it would be a nice compromise if learning to use tikz would be as easy as to learn, say, javascript
I agree that it's likely that sort of diagram will never be supported in such an editor — but I believe most users won't need to draw diagrams like that
I hope for them they won't, typesetting it was quite hellish >.<
I use Catlab for wiringdiagrams. it’s really nice. It uses Graphviz or Tikz as a backend to handle the low level rendering details. I’d like it also to make commutative diagrams, but we would need an automated layout algorithm for that.
Thanks for mentioning that. If anyone knows about algorithms for laying out commutative diagrams, I am all ears!
In general, I think that graph drawing is an interesting algorithmic area with mathematical aspects that are not always appreciated. For example, the problem of drawing a string diagram given its combinatorial description is closely related to the problem of finding an expression, in terms of composition, products, and so on, for it, but the latter problem is purely computer-algebraic.
Commutative diagrams have their own strongly geometric flavor. Often you want to draw them a certain way, e.g., the pentagon equation is customarily drawn as a regular pentagon. Is there a general way to know the "right" diagram shape from a set of equations, or is that problem hopelessly ill-posed?
Presumably, you'd want the symmetries of the diagram be symmetries of the drawing.
Yes, I like that idea! I guess you would use the symmetries of the underlying undirected diagram to get the symmetries of the drawing. Could you then use the directionality of the diagram to orient the drawing?
As a practical note, there is already very effective software to compute the symmetries groups of graphs, directed and undirected.
The undirected symmetries are spurious. I'd want to break them on purpose.
I'm not sure. Consider the basic commutative square. The symmetry group of the undirected diagram is the symmetry group (including reflections) of a geometric square, the right shape. OTOH, the symmetry group of the directed diagram has only two elements (it is Z2). How do you get the right shape from that data? In general, it seems helpful to use the extra symmetries given by the undirected symmetry group.
By the combinatorial description you mean the underlying port graph right?
@Evan Patterson about algorithms for laying out commutative diagrams, that sounds like a very interesting problem! I have been thinking about layout algorithms for string diagrams for a while (which is a different problem, but perhaps things could be reused by Poincaré duality?). Our group (Quantum Group, Oxford) gathers quite a lot of experience in layout algorithms for string diagrams, via the tools we develop: https://homotopy.io/ does that in 2D and 3D, Quantomatic does force-directed layouts for compact closed categories if I remember correctly…
Unfortunately all this knowledge is rarely published - because it's really about computer graphics, not category theory, so it is hard to motivate people to write these things up. How could we promote this as a valid problem to be spending time on, and therefore, to publish about?
@Antonin Delpeuch: do you think layout of commutative diagrams would not be handled by general graph layout algorithms?
I would have imagined it could probably be done quite effectively with some additional constraints, like a bias towards directing the graph towards the bottom left
(though I imagine more sophisticated commutative diagrams, such as those involving 2-cells or similar would probably not be covered by the existing graph layout literature)
Sounds like a good idea! So those algorithms would be specifically to lay out planar graphs, or rather planar maps - graphs with a given embedding in the plane, right? Because you need to preserve the faces (the commuting squares), it's a bit different from a simple directed graph layout, I feel.
Am amateur, occasional maths blogger, enthusiast, software architect and entrepreneur.
I wonder if anyone has tried reusing existing algorithms for that - if the input format is convenient to work with, it could be a very useful thing to have, I guess.
@Antonin Delpeuch: yes, you're right — specifically planar graphs
James Fairbanks said:
By the combinatorial description you mean the underlying port graph right?
That's right. I was trying to be careful to distinguish between string diagrams as drawings versus string diagrams as graph-like things.
@Antonin Delpeuch, admittedly I haven't tried drawing commutative diagrams with standard graph layout algorithms, say in Graphviz, but my guess is that won't produce the "right" shapes, like you say.
It is cool that you have a forced-directed layout for compact closed categories! I didn't know that. Does it work well?
Sorry for posting my intro to the worng thread. So new.
In Catlab, we don't have that, but I did implement a totally different layout algorithm for string diagrams. It is adapted from ideas in the literature on series-parallel digraphs. Basically, you start with full diagram and you repeatedly apply certain moves, mainly series reduction, parallel reduction, and transitive reduction, until the diagram is reduced to a single box. If you keep track of the moves, you end up with a hierarchical decomposition of the diagram into composition, products, and identities.
@Evan Patterson it does a good job for this sort of diagrams if I remember correctly, but I am not actually sure what is the underlying algorithm - we can ask Alex Kissinger if he shows up. You can get a sense of what it does here: https://quantomatic.github.io/ (just search for "relax" in that page) (sorry, my turn to post in the wrong place)
@Antonin Delpeuch: if you post in the wrong place, you can move your post by editing it and changing the topic to the one you intended to post in
To your point about publishing, the algorithm in Catlab has not been properly documented, nor have I proved that it actually works! In fact there are a lot of subtleties. At some point it would be a good project to carefully work all this out and record it. If anyone is interested in doing this, I'd be happy to work with them on it.
Perhaps one way to encourage such work is to give people familiar venues in which to publish it. My understanding is that the ACT conference is receptive to such things.
Proposal to move this thread into #software