Category Theory
Zulip Server
Archive

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.


Stream: community: general

Topic: Tools for diagrams


view this post on Zulip Faré (Mar 24 2020 at 20:55):

What tools do you use to draw your string diagrams? Some LaTeX package?

view this post on Zulip Faré (Mar 24 2020 at 20:56):

Are there tools that generate at the same time a diagram and a bunch of Agda or Coq or Idris declarations?

view this post on Zulip Antonin Delpeuch (Mar 24 2020 at 21:00):

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.

view this post on Zulip Joe Moeller (Mar 24 2020 at 21:01):

I've used Tikzit. You draw some pictures and it generates the tikz for it.
https://tikzit.github.io/

view this post on Zulip Grant Roy (Mar 24 2020 at 21:03):

I've followed Penrose.ink (http://penrose.ink, https://github.com/penrose/penrose) for awhile: http://penrose.ink/PenroseIntro2018.pdf. It looks very promising.

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 21:16):

Did you give a look to edit.statebox.cloud ? :)

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 21:17):

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.

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 21:18):

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 :)

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 21:18):

is it possible to try without logging in?

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 21:19):

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

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 21:19):

So no, at the moment you have to register

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 21:20):

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

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 21:20):

(though you've probably already thought about this)

view this post on Zulip Evan Patterson (Mar 24 2020 at 21:43):

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.

view this post on Zulip Evan Patterson (Mar 24 2020 at 21:45):

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.

view this post on Zulip Jules Hedges (Mar 24 2020 at 21:49):

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)

view this post on Zulip Jules Hedges (Mar 24 2020 at 21:50):

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

view this post on Zulip Evan Patterson (Mar 24 2020 at 21:54):

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 :)

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 21:54):

the ideal is never having to write TikZ :+1:

view this post on Zulip Jules Hedges (Mar 24 2020 at 22:02):

It's a nice ideal to aim for. The reality is quite a lot of my day to day live involves writing TikZ code

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:07):

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.

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:08):

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.

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 22:08):

if you could generate the same diagrams you want to draw in TikZ automatically, what would be the downside?

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:09):

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...

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 22:09):

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?

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 22:10):

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

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:10):

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

view this post on Zulip Brendan Fong (Mar 24 2020 at 22:10):

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

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:11):

This library is not bad at all indeed. And it's compositional in spirit, which is nice.

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:12):

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)

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 22:12):

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

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 22:13):

(and for the other use cases, a graphical tool like TikZiT will probably suffice)

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:14):

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

view this post on Zulip Evan Patterson (Mar 24 2020 at 22:16):

Surely you already know the answer to that question :) Because some things are simply tedious, and TikZ is one of them.

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:16):

I definitely don't agree, but ok I guess

view this post on Zulip Evan Patterson (Mar 24 2020 at 22:17):

Fair enough. I guess I should be grateful that some people really care about typesetting for its own sake, because that benefits everyone else.

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 22:17):

it's similar to asking why you wouldn't want to learn ALGOL instead of a modern programming language

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 22:17):

you might like to simply out of interest, but there's no point doing it because it's useful

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 22:18):

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)?

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 22:20):

(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)

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:20):

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

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:22):

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.

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 22:22):

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)

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 22:22):

we're definitely starting to see tools for drawing string diagrams, petri nets and commutative diagrams

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 22:22):

they're not there yet, but one day...

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:23):

We have tools indeed, but let me give a concrete example: https://arxiv.org/pdf/1805.05988.pdf page 137

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:24):

This is the kind of mixed picture I'm talking about, where tools don't help you much.

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:24):

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

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:25):

That's why I like the library Brendan was referring to. It goes in that direction, albeit being still difficult to use :)

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:25):

I guess it would be a nice compromise if learning to use tikz would be as easy as to learn, say, javascript

view this post on Zulip Nathanael Arkor (Mar 24 2020 at 22:26):

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

view this post on Zulip Fabrizio Genovese (Mar 24 2020 at 22:26):

I hope for them they won't, typesetting it was quite hellish >.<

view this post on Zulip James Fairbanks (Mar 25 2020 at 01:09):

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.

view this post on Zulip Evan Patterson (Mar 25 2020 at 01:37):

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.

view this post on Zulip Evan Patterson (Mar 25 2020 at 01:56):

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?

view this post on Zulip Chris Brown (Mar 25 2020 at 02:01):

Presumably, you'd want the symmetries of the diagram be symmetries of the drawing.

view this post on Zulip Evan Patterson (Mar 25 2020 at 02:08):

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.

view this post on Zulip Chris Brown (Mar 25 2020 at 02:21):

The undirected symmetries are spurious. I'd want to break them on purpose.

view this post on Zulip Evan Patterson (Mar 25 2020 at 02:46):

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.

view this post on Zulip James Fairbanks (Mar 25 2020 at 16:56):

By the combinatorial description you mean the underlying port graph right?

view this post on Zulip Antonin Delpeuch (Mar 25 2020 at 17:10):

@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?

view this post on Zulip Nathanael Arkor (Mar 25 2020 at 17:12):

@Antonin Delpeuch: do you think layout of commutative diagrams would not be handled by general graph layout algorithms?

view this post on Zulip Nathanael Arkor (Mar 25 2020 at 17:12):

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

view this post on Zulip Nathanael Arkor (Mar 25 2020 at 17:13):

(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)

view this post on Zulip Antonin Delpeuch (Mar 25 2020 at 17:15):

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.

view this post on Zulip Refurio Anachro (Mar 25 2020 at 17:15):

Am amateur, occasional maths blogger, enthusiast, software architect and entrepreneur.

view this post on Zulip Antonin Delpeuch (Mar 25 2020 at 17:16):

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.

view this post on Zulip Nathanael Arkor (Mar 25 2020 at 17:16):

@Antonin Delpeuch: yes, you're right — specifically planar graphs

view this post on Zulip Evan Patterson (Mar 25 2020 at 17:23):

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.

view this post on Zulip Evan Patterson (Mar 25 2020 at 17:25):

@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.

view this post on Zulip Evan Patterson (Mar 25 2020 at 17:26):

It is cool that you have a forced-directed layout for compact closed categories! I didn't know that. Does it work well?

view this post on Zulip Refurio Anachro (Mar 25 2020 at 17:29):

Sorry for posting my intro to the worng thread. So new.

view this post on Zulip Evan Patterson (Mar 25 2020 at 17:31):

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.

view this post on Zulip Antonin Delpeuch (Mar 25 2020 at 17:31):

@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)

view this post on Zulip Nathanael Arkor (Mar 25 2020 at 17:34):

@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

view this post on Zulip Evan Patterson (Mar 25 2020 at 17:36):

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.

view this post on Zulip Evan Patterson (Mar 25 2020 at 17:38):

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.

view this post on Zulip Jules Hedges (Mar 25 2020 at 17:53):

Proposal to move this thread into #software