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.
Per Jules' request to shift streams:
https://categorytheory.zulipchat.com/#narrow/stream/229111-general/topic/Tools.20for.20diagrams/near/191786550
@Evan Patterson I was thinking more about graph drawing with symmetry and found this paper https://link.springer.com/content/pdf/10.1007/3-540-36151-0_9.pdf
Thanks James, this paper looks extremely relevant. I've even seen commutative diagrams that look like the second panel of Fig 1. The 2D version of it appears in Fong & Spivak's paper on supply, for example.
Their implementation is in Magma, but nauty is used under the hood.
I'll have to read the paper carefully but I really like the idea of this approach.
This is a basic question: I've been playing with a made-up notation for a language I care about, and I was just wondering what software would be the best way to draw things like this:
rho-notation.jpg
Christian Williams said:
This is a basic question: I've been playing with a made-up notation for a language I care about, and I was just wondering what software would be the best way to draw things like this:
rho-notation.jpg
they look like trees? do you just need to draw a few for a paper?
I would go for TikzIt intuitively.
I use a python package called PyX for most of my diagrams... https://pyx-project.org/
@Jelle Herold yes, they are just trees with red/green/blue/black/white nodes. plus a bit more complexity, because they are really "operads with binding"... but I'm still working on a good notation for that.
initially I want to just draw a few for a paper, but in the long run I would love to have a something like what y'all have done for string diagrams, where you can really code with it.
thanks, that looks nice.
@Christian Williams, if you like the idea of editing these trees in ascii art I can extend dednat6 to produce these kinds of diagrams very quickly... take a look at http://angg.twu.net/dednat6.html#a-big-example and http://angg.twu.net/dednat6/demo-underbrace.pdf - btw, I need to fix that PDF! Doing that now!!!
wow this looks exactly like one of the figures in brent yorgey's thesis :eyes:
ok wait it wasnt quite as exact as i was thinking image.png
but! regardless! use his diagrams
library!!!!
(if you like writing code to generate this kind of thing)
i went on a ramble about that library just yesterday over in another stream
@Christian Williams i would not be surprised if you could get a working prototype of something that programmatically generates such trees from abstract syntax in under a few hours, playing around with diagrams
in ihaskell
—uh, well, if you already knew how to use diagrams
:sweat_smile:
initial learning carries some overhead.
In Julia, the package Compose.jl offers similar capabilities. Its authors say it is partly inspired by the Haskell diagrams package.
https://giovineitalia.github.io/Compose.jl/latest/tutorial/
I've used this package a bit, and I like it.
hmm, it looks nice but probably a lot less powerful
yeah this is a ton more limited in scope
but ill keep it in mind if i ever have to use julia instead of haskell c:
Out of curiosity, what does Diagrams have that Compose.jl doesn't? I have never used Diagrams.
well, it does have a whole little ecosystem, but even if we just restrict ourselves to the core library—like, the library diagrams-core
... (actually, the diagrams
package itself pulls in a bunch of extra stuff besides that too)
https://hackage.haskell.org/package/diagrams-core
so like, diagrams is fundamentally built on a bunch of abstractions for geometry
a diagram has spatial extent and stuff
it has an origin
well ok, i think compose has an origin too
but it doesnt look to me like it has an envelope or a trace
yeah, this is awesome. I'm not yet much of a programmer, but I'll try it out
also, diagrams's approach to applying properties seems to be different from Compose.jl's, and I'm not sure I like the latter's as much
this is a topic for another time, but I am amazed that people have not developed a standard notation for operads with binding. rather than just monoids and other algebraic gadgets, you can use this stuff for actual programming languages.
ooh!
that sounds really cool :eyes:
actually i remember one of the talks i went to at POPL was about generalized theories of syntax using monads and stuff and i think maybe binding was part of it
I talked with somebody about building a string diagrams tool around diagrams
(I don't remember who... was it @Jelle Herold?) Idea is that if the data structure you use to represent morphisms is proof trees with and cut (aka kd trees) then turning the proof tree into a diagram is just a fold, more or less out of the box using the things provided by diagrams
but. i dont remember super well :|
yeah jules i started doing something like that once
but it was kinda broken
and i petered out
take a look: https://github.com/sarahzrf/compact-closed/blob/master/StringDiagrams2.ipynb
@Jules Hedges , I implemented something very much like that using Compose.jl. It's a nice approach.
Cool! Looks like what I had in mind
anyway check out the index for diagrams-lib
, which gets pulled in as part of the diagrams
package https://hackage.haskell.org/package/diagrams-lib-1.4.3/docs/doc-index-All.html
it's a hell of a lot more extensive than Compose.jl!
oh wait actually a bunch of this is probably re-exports lol
@Jules Hedges the other thing i did in this repo was uh
abstract index notation @_@
idea being you can write
[tensor| tens^a_x = s w^ba v_xb |]
where s
, w
, and v
are identifiers in scope
and this generates a binding for tens
purely in terms of compact closed category operations
i copied and pasted that line from an actual example that compiles https://github.com/sarahzrf/compact-closed/blob/master/src/CompactClosed/Test.hs
or, well, compiled at one point, good luck figuring out my dependencies :upside_down:
put the two together and you get this
image.png
the code for the index notation is here, but don't ask me to try to figure out how black magic i hacked together 2 years ago works or i'll melt https://github.com/sarahzrf/compact-closed/blob/master/src/CompactClosed/AIN.hs
Cooool!
Christian Williams said:
this is a topic for another time, but I am amazed that people have not developed a standard notation for operads with binding. rather than just monoids and other algebraic gadgets, you can use this stuff for actual programming languages.
it seems less surprising when you consider that people don't really use such operads in the first place, and you don't need to represent what you don't use
but I'd like to see a suggestive notation!
Yes, the real surprise is that there is not yet public awareness that the notion of "substitution structure" (the monoid definition of operad) has binding implicit in it from the start.
Discussing this with the community is a priority for me; rather than waiting for one of us to blog about it, perhaps you and I should start a thread about it tomorrow. Probably in #category theory , I guess.
Early on when thinking about diagrams software I thought about the idea of letting users define and work in an arbitrary operad, rather than hard coding in certain structured monoidal categories. Gave up on that pretty quickly, I still have no idea how the user could communicate an operad to a computer
I guess you partly get that with systems like homotopy.io where you can just truncate n-categories to get the right flavour of monoidal category, but you are still limited to what arises in this way (for instance you do not get traced monoidal categories afaik).
Yeah, traced monoidal categories not fitting in anybody's tool was the main thing that motivated me. In the end I decided life's too short, traces should just be hard-coded as a weird but important special case
Here's something I've been thinking about that I think is kind of interesting. http://www.philipzucker.com/uniform-continuity-is-kind-of-like-a-lens/
I might just be suffering from Lens Madness though
Philip Zucker said:
Here's something I've been thinking about that I think is kind of interesting. http://www.philipzucker.com/uniform-continuity-is-kind-of-like-a-lens/
This is very cool!
@Antonin Delpeuch what do you use to latex surface diagrams? Is there some macro for them?
Something that isn't quite ready to be released yet, so moving to a PM :)
:heart:
oh yeah @Christian Williams did you ever talk about operads & binding?
There was a suggestion by @Gershom after my talk on wednesday when I brought up the question of string diagram compilers, to try hacking on Proto-Quipper-M to take out the quantum and make it general purpose..... I don't remember that suggestion ever coming up before, does anyone have any thoughts?
We looked into Proto-Quipper. It's already not quantum and way more general (Proto-Quipper != Quipper)
It's also written in Haskell, so it could be a good choice if you want to hook it up with your backend
Cool! Any idea how feasible/difficult that would be? I saw Vlad talking about it once or twice, but i never looked at the thing itself
If I remember correctly tho, the point of protoquipper wasn't to "compile string diagrams" (whatever this means), but have a programming language to specify classes of string diagrams, and perform operations on them at once
I think your best bet is to ask directly to vlad or to @Francisco Rios
If you already looked into it at Statebox, why did you choose not to go with it?
Various reasons. One of them is that we need formally verified code, so Haskell doesn't cut it
But then again the main reason is that as I said protoquipper seems suited to talk about string diagrams in a general setting, while we needed a way to map selected string diagrams to some category
so the application domain is different
Ah, it also doesn't function as a compiler? I thought part of the point was it could compile to instructions to control quantum hardware...
So our core is literally the formally verified implementation of the idea that every free symmetric strict monoidal category has a free functor to some other category if you specify some stuff.
I guess so, but there is not such thing as "a compiler", there is a compiler to a very specific domain
So if the target is compiling to quantum hardware I don't know how useful will this be to you. It really depends on the implementation strategy adopted, but there is a possibility that you'll have to rewrite parts of it by yourself
So, for instance, if protoquipper compiles to Haskell in a way that is useful to you (and then from there there's a way to compile Haskell to quantum stuff), then you could just take that bit
I never looked into the implementation stategy of it tho, I merely read the protoquipper paper. So I'd really wait for Francisco to chime in.
Definitely sounds like something worth looking into more closely. For my open games DSL specifically, it might be much less effort to build on top of Proto-Quipper-M than to start from my language and add the missing parts to make it nice, like hooking into the haskell compiler properly
If you like the idea of coding in idris you may also use our implementation of free smc :P
Personally I'd rather run the risk of having bugs. If anyone ever wants to use open games to support business decisions, they can pay for a provably-correct rewrite if they want it.....
I can't blame you xD
Anyone know whether anyone is using Quipper or Proto-Quipper-M in industry right now? (Is anyone from CQC hanging out here?)
Two years ago I remember Francisco was under NDA with an undisclosed party regarding Quipper. I don't know if this is still the case but for sure there'interest in industry for this sort of tech.
.
Hi Jules,
Thanks for your interest in Proto-Quipper-M! Certainly, the language does not compile
to instructions to control quantum hardware. Rather, Proto-Quipper-M is a language for
describing families of morphisms in an arbitrary symmetric monoidal category, of which
quantum circuits are but one example. And, indeed, as Fab mentioned, there has been
interest (and support) for Quipper and Proto-Quipper-M from industry and government
agencies for a while now.
Cheers!
.
Hi! I'm the only weirdo here who uses Lua and LuaLaTeX to typeset diagrams, but
1) I believe that it shouldn't be hard to integrate my package (that is called "Dednat6") with the other ones that people use here - including the ones in Haskell and Scala, and
2) I just made a video about Dednat6! It is here:
http://angg.twu.net/dednat6.html#hacking
A good part of the video is about how Dednat6 can be used outside lualatex as a bunch of Lua libraries, and how I wrote its libraries for planar Heyting Algebras... I started by the code that displayed my HAs and my constructions on them as ASCII art, and I only implemented LaTeX output much, much later.
Cheers! =)
This might be cool: http://penrose.ink/media/Penrose_SIGGRAPH2020_Supplemental_Grammars.pdf
People, where are the good places for asking questions about Tikz?
Is it ok to ask one question about Tikz here besides the meta-question above?
Here it goes... I am working (veeery slowly) on a Tikz back-end for this package for generating categorical diagrams, <http://angg.twu.net/dednat6.html#a-big-example>, and I discovered that I can use <https://tikzcd.yichuanshen.de/> to learn the Tikz syntax for all the modifiers for arrows that I use in the current back-end, that uses diagxy... but tikzcd.yichuanshen.de generates code for tikzcd, like this:
\begin{tikzcd}
A \arrow[r, "foo"] \arrow[rd, "plic"', maps to]
& B \arrow[d, "bar", Rightarrow] \\
& C
\end{tikzcd}
and to port that I need to convert these "\arrow"s to something like the "\draw"s below, that connect nodes that I've defined previously and that can be in arbitrary positions... How do I do that? Or: where should I ask that?
\begin{tikzpicture}
\node (nodeA) at (0.0,0.0) {$A$};
\node (nodeB) at (2.0,0.0) {$B$};
\node (nodeC) at (2.0,-1.5) {$C$};
\draw [->] (nodeA) -- (nodeB);
\draw [{}-{>},double] (nodeB) -- (nodeC);
\draw [{|}-{>}] (nodeA) -- (nodeC);
\end{tikzpicture}
I would have thought the tikz-cd documentation might be a better place to start than generating output from a tool. You can find the source code for tikz-cd here, which will tell you what TikZ tikz-cd is outputting, presuming you're already familiar with TikZ itself.
I am not familiar with Tikz.
People, what do you use to draw string diagrams like these ones?
marsden.png
Most likely tikz
Ooops, sorry! My question has a second half... here it is.
Those diagrams are from Dan Marsden's "Category Theory Using String Diagrams", that is at <https://arxiv.org/abs/1401.7220>, and its source code can be downloaded from there. The code for those diagrams is a series of "tikzpicture"s in the section "Universality from Representables" in string.tex. Most of its coordinates are hardcoded.
I sort of know how to draw this things in Tikz - I am not proficient yet, so drawing a diagram like that still takes me an evening, but let's pretend that I did not confess this...
The question - to the people here who use string diagrams a lot - is: what is your workflow for drawing them? Do you start with a draft on paper, then program it in Tikz by guessing first approximations the coordinates, then adjust them by changing them in the code and recompiling several times until happy? Do you draw the first version on something like Inkscape instead of on paper? Is there a graphics editor "for Tikz"?
Is there a graphics editor "for Tikz"?
I've heard TikZiT is pretty good.
I would guess they were built in TikZit, which generates TikZ code that looks like it wasn't written by a human
Thanks!!!
They were built manually using just raw tikz and no tools other than a text editor. The reason for this is I care about the layout of the diagrams more than just the topology, as some depictions help with understanding more than others. I've drawn 1000s of these by now for papers and book projects, so I've got quite comfortable doing them from scratch. I only use a small handful of "tricks" to get nice layout, so it's not actually that hard to draw them quickly with a bit of practice. I chose not to use tikzit as it produces quite low level tikz code that is harder to make aesthetic adjustments on later. I made that decision a long time ago, so tikzit output may have changed since then. If you're doing research, rather than focused on exposition, your emphasis might be different. So my workflow, with coauthors, is simply draw on paper, layout in tikz in an editor, adjust until happy, done.
I'm equal parts impressed and horrified
I mean I always write raw TikZ too, but you make a lot more diagrams than I do
Well I should probably mention one other thing. We figured out how to use tikz more effectively to parameterise diagrams, for example by colours or labels. You often end up drawing nearly the same diagram again and again, so being able to instantiate a "template" diagram with a few details reconfigured is a good technique to save typing. You can bundle up these template diagrams as macros or something similar. I also used to be a programmer, so coding stuff up like this is very natural to me.
I saw your macros!!! They are super-neat!
I am working with a diagrammatic language that is sort of the opposite of string diagrams - I've drawn thousands of diagrams in it, too -, and at this moment I just need to 1) typeset a handful of string diagrams similar to yours to show how to translate between your diagrams and mine, 2) make the Tikz back-end of my package for drawing diagrams a bit better...
@Eduardo Ochs sounds interesting! Is it a DSL?
Simon Burton said:
Eduardo Ochs sounds interesting! Is it a DSL?
Take a look:
http://angg.twu.net/dednat6.html
https://tug.org/TUGboat/tb39-3/tb123ochs-dednat.pdf
http://angg.twu.net/dednat6/tug-slides.pdf
very nice.
I generated my diagrams for https://arxiv.org/abs/2002.11480 using some custom haskell code that takes a morphism as input and lays out the diagram automatically. Would anyone be interested if I put the effort of making it usable?
I was thinking it might use https://github.com/statebox/monmor-spec as input format, and of course the wonderful Haskell diagrams library
Or actually, if someone else has already done that I would love not to have to do it myself
@fosco was also working on a modular string diagram library: it might be worth discussing with him to see if there's overlap in the use cases.
@Guillaume Boisseau , I am interested!
I will never end writing the documentation :grinning:
Guillaume Boisseau said:
I generated my diagrams for https://arxiv.org/abs/2002.11480 using some custom haskell code that takes a morphism as input and lays out the diagram automatically. Would anyone be interested if I put the effort of making it usable?
What do you think of starting by making the source code of https://arxiv.org/abs/2002.11480 available and explaining how to compile it? Arxiv only has the "LaTeX source" for the paper with the diagrams already in Tikz - it doesn't have the source for the diagrams in the DSL that you invented, and neither the Haskell code needed to compile them...
@Eduardo Ochs It's there: https://github.com/Nadrieril/stridi
But right now you need to write Haskell code to generate diagrams, which is both suboptimal and extremely slow to recompile all of the time. That's why I want to rewrite it to just be a binary, and decouple the DSL from the representation to allow more tools
Let me introduce yet another string diagram renderer: SheetShow, which works for sheet diagrams in bimonoidal categories. https://wetneb.github.io/sheetshow/
sheet_diagram.png
I am trying to compile a list of graphical calculi and their associated tools for manipulating/rewriting and rendering/typesetting them. A quick Google search for "graphical calculi survey" turns up
which was written in 2009 and seems to cover a wide variety of string diagrams (I have only skimmed it). Is that all there is? I'm sure I've seen different-looking diagrams for e.g. operads, Petri nets or open games, but maybe they were just string diagrams with bells and whistles. Also, I would like my list to include plain old diagrams with (labeled) dots as objects, (labeled) arrows as morphisms, (labeled) double arrows as 2-morphisms, etc. Am I using the term "graphical calculus" too liberally if I do this?
On the rewriting front, I am only aware of pyzx. Maybe catlab.jl has this too? Is there anything else?
Any help appreaciated!
A tool for rewriting with string diagrams: cartographer
A tool for drawing opetopic shapes (for higher categories I believe): Opetopic
@Javier Prieto I think it would be great to have an updated version of Selinger's survey. Adding the associated tools to manipulate them would be very useful too. I am not sure to which extent a static paper is the best format for this. Perhaps a wiki could be better suited for that, so that people can add their tool at the appropriate place when it is released, for instance. Perhaps the nLab could be used for that? The page about string diagrams is pretty poor, it lacks a lot of images to illustrate (not too long ago there was not a single image on this page!): https://ncatlab.org/nlab/show/string+diagram
Hi @Javier Prieto,
if by "plain old diagrams" you mean "plain old categorical diagrams (with double arrows as 2-morphisms)" then these notes may be useful to you...
http://angg.twu.net/math-b.html#favorite-conventions
@Antonin Delpeuch An "updated version of Sellinger's survey" is perhaps too big a task for me. I was going more for something like a summary table with lots of hyperlinks for those who want to go deeper and minimal text around it, maybe something like a glossary plus examples of diagrams.
I agree that a website would be a much better format. I will have to produce a pdf at some point because I'm doing this as final project for an undergrad course, but I'm confident I can just produce a website and then take the text and tikz code and stick it in Overleaf.
@Eduardo Ochs thank you! I'm going through it now and it looks very relevant indeed.
On the rewriting front there is also Quantomatic (which is no longer actively developed). There is also homotopy.io, which I haven't used myself
I don't know what you mean by "graphical calculi", but there is a whole barrage of graphical languages for reasoning about quantum computation: the ZX-calculus, ZH-calculus, ZW-calculus. You can learn more about this at https://zxcalculus.com
I'm not a hundred percent sure, but I thought @Cole Comfort was working on a similar project of cataloging PROPs.
John van de Wetering said:
I don't know what you mean by "graphical calculi"
Honestly, neither do I! I was using the term very loosely to refer to anything that "looks like a diagram" and comes with some rewriting rules attached. If there is a (perhaps narrower) rigorous definition, I'd be keen to hear it.
I'm writing a thesis with many string diagrams for 2-categories and equipments. mates-to-equip-square.png From what I've seen, I have to use TikZit or write macros for TikZ and make them from scratch. There isn't a big difference, and both options are very time-consuming. I wish there were a better option, because string diagrams are very simple.
Does anyone have advice for mass-producing string diagrams? (Also, does anyone have a .tikzstyles file with useful macros? I think Dan Marsden has something similar... I'll be making one.) When will someone make a Quiver for strings?
We could host TikZit online, and start building a library of TikZ figures and macros.
Then if you want to make the proof "right adjoints preserve right extensions", you can open Adjunction.tikz and RightExtension.tikz and combine them at the various steps of the proof. (and then upload that proof to the library!)
I think this is a low-tech solution that could make drawing more accessible.
@Aleks Kissinger What do you think about this idea? Do you have any advice for making such a site?
(sent an email)
Please tell me when you get a prototype working - I would love to play with it!
A github repo with a public collection of .tikzstyle
files would be low hanging fruit, presumably anybody could create this and then make a pull request against the TikZit documentation to add a link to it
I first talked a few years ago about how nice it would be to port (in practice totally rewriting from OCaml to Javascript) TikZit to run in browser for purposes of being a plugin of a "1CatLab" (which is what I used to call the combination pedagogical wiki + ACT wiki, an idea that I'm no longer very attached to). This would be a massive undertaking for a programmer...
Jules Hedges said:
I first talked a few years ago about how nice it would be to port (in practice totally rewriting from OCaml to Javascript) TikZit to run in browser for purposes of being a plugin of a "1CatLab" (which is what I used to call the combination pedagogical wiki + ACT wiki, an idea that I'm no longer very attached to). This would be a massive undertaking for a programmer...
I guess that's something different from https://1lab.dev/ ? :)
Yeah, I know about that, it's just the same name (probably more people than the 2 of us came up with it independently, it's kind of obvious), otherwise I think a totally different idea
Also : GReTA ExACT
Jules Hedges said:
I first talked a few years ago about how nice it would be to port (in practice totally rewriting from OCaml to Javascript) TikZit to run in browser
From what I can see it’s written in C++/QT rather than OCaml and QT has some amount of support for compiling to WASM. That would probably still be quite a lot of work, but probably not as much as completely rewriting it
Christian Williams said:
Then if you want to make the proof "right adjoints preserve right extensions", you can open Adjunction.tikz and RightExtension.tikz and combine them at the various steps of the proof. (and then upload that proof to the library!)
My two cents about this: I have worked on papers with hundreds of string diagrams. The problem with reusing them, is that you need to find them first. Sure you might have a adjunction.tikz, but this doesn't tell you what the exact diagram is. The only way I've found that is feasible is to find the diagram I want in the paper and see what the tikz file is called in the latex source. I don't really know how you would make a "tikz diagram browser" where you can search for the diagram you want. The only solution I can think of is to train one of those fancy neural networks that can learn to find a text description of a picture, then you could give a natural language search query to find it. But of course this requires a massive library of annotated tikz diagrams.
That being said, having a GitHub repo with several common style files and macros would certainly be useful
What about something more like detexify where you draw the general shape of what you want and it find diagrams that are close to that.
Christian Williams said:
Does anyone have advice for mass-producing string diagrams? (Also, does anyone have a .tikzstyles file with useful macros? I think Dan Marsden has something similar... I'll be making one.) When will someone make a Quiver for strings?
For what it's worth, if I remember correctly Aleks wrote TikZit version 2 specifically for writing Picturing Quantum Processes, which contains maybe thousands of string diagrams
John van de Wetering said:
The only solution I can think of is to train one of those fancy neural networks that can learn to find a text description of a picture, then you could give a natural language search query to find it.
Very much easier solution: take an open source TeX editor of your choice that supports sync between code and pdf (eg. TeXshop, which is the one I use), fork it and hack it to open files generated by TikZit (or whatever) in TikZit, instead of opening the raw code itself
An emacs wizard could probably hack the emacs TeX mode to do that in 5 minutes
Cf. the standard flowchart Do I need a neural network?
No.
Jules Hedges said:
John van de Wetering said:
The only solution I can think of is to train one of those fancy neural networks that can learn to find a text description of a picture, then you could give a natural language search query to find it.
Very much easier solution: take an open source TeX editor of your choice that supports sync between code and pdf (eg. TeXshop, which is the one I use), fork it and hack it to open files generated by TikZit (or whatever) in TikZit, instead of opening the raw code itself
I have this set-up but it doesn't solve the problem I was raising, which is "I know I have the diagram of this thing I want somewhere in this folder with thousands of other diagrams, how do I find it if I don't know the filename"?
As long as the diagram is already in a file I am using, it is fine, because I can just search through the PDF to find it, but if I say comment it out because I don't need it at that moment, the diagram is essentially lost forever to me, because there is no way to find it back (unless I remember where I commented it out)
Just copy paste all your diagams into a huge pdf in the form
diagram
filename
You can use any ordering you want. Then it's just a matter of scrolling the file