Penrose: create diagrams by typing mathematical notation in plain text 243 points by mathgenius 9 months ago | hide | past | web | favorite | 48 comments

 It's a bit weird to name a project after a living person without mentioning them or the motivation for the name.
 I was curious about that as well. With the project name Penrose there was a suspicion (more like a wish) that maybe this was to be prototype work for an interactive digital rendering of the Roger Penrose Road to Reality physics tome but a quick poke-around of project members bios turned up no personal linkage to Penrose. Just happened to listen to Penrose at Princeton when he promoting that book about 15 years ago.
 Probably a reference to Penrose Diagrams which this looks like it would be good at, or possibly Penrose Graphical Notation. Both creations of Roger Penrose.
 Nah you want to use something like Tikzit for string diagrams.
 WOW! This is an amazing idea and an amazing implementation. Reading the intro paper [1] and checking the example [2] made me eager to try this. If this can indeed be successfully worked into a tool for the "laymen" (in computers and drawing, that is, not in the domains in question) what an great tool it will be!
 Has anybody tried both Penrose and TikZ? How do they compare?
 Penrose currently seems to be a very limited work in progress. Such comparison will have to wait.However, in the few Penrose examples shown, all the positioning seems to be done completely automatically, which is incredibly difficult to make work in all but the simplest and most standardised situations. In TikZ most positioning is manual, which takes more effort, but which I think is likely to produce better results in general.
 Yes, automatic positioning is the goal, and one of the key differences vs. TikZ (the other being a separation of substance--the math--from style--the graphical representation). It's difficult, which is why there is real graphics research in the project.Penrose enables the user to tweak the diagram manually after it is produced. Constraint solving continues to apply during the tweaking so that if you grab a shape, then things attached to it will move as well. Our goal is to get end results as good as, or better than, TikZ, while staying at a higher level of abstraction.
 How deterministic will the results be? One advantage of programmatic systems is that because they don't try to be smart, you know exactly what you're going to get, and e.g. upgrading the system won't move things.Another is that tracking changes with version control systems is easy and clear. Does Penrose have a canonical textual format that changes minimally as tweaks are made?TikZ styles do let you separate substance and style fairly well (though lay users are unlikely to take full advantage).
 We could make things deterministic by fixing the algorithms and a random seed, and/or by fully constraining every object in the diagram so randomness is not used. But that isn't using the real strengths of Penrose, so we expect it to be a secondary use case at best.One way to think about the goal of Penrose is that you will get a result that is predictably good, and you can constrain it to get a diagram of a particular shape if you want to, or alternatively leave it open and have the solver show you 3 good diagrams...then you can pick one and tweak it further (aided by constraint solving as you tweak) to make it great. The problem with drawing-tool style systems is that you have to adjust the location of every label (for example); that's the kind of thing that should be solved for you. TikZ doesn't have a rich constraint language and solver, so in many circumstances you're left with a choice between doing lots of things manually or getting a poor-quality diagram.Penrose will have a canonical textual format, but as it is under active development, it wouldn't make sense to say it has a stable textual format now.
 They seem to be very different things: the focus of Penrose is automatic laying out of figures from a declarative math description; TikZ is a vector graphics description language. In fact, maybe Penrose can actually output TikZ/pgf...
 I have used a lot of TikZ. Its great but obviously has not the best syntax - a problem inherited from latex. Penrose seems to have a clean simple syntax, and I would definitely try it once its more mature.
 Personally I find the tikz syntax to be reasonably good. It’s slightly weird in places but I think it’s much nicer than eg svg
 It would also be helpful to see a comparison to tools like asymptote:
 With Asymptote you specify diagrams directly in terms of low-level graphics primitives and constraints. With Penrose you specify the underlying math, then one or more separate style files are used to automatically generate diagrams based on the math. The typical user of Penrose doesn't have to know anything about graphics, and never specifies any graphical objects; instead, that knowledge is in reusable style files written by domain experts.
 This looks like a very useful tool, and I'm just learning about it now. Do you have experience with it? Would you recommend it?
 > the PENROSE pipeline is designed to be end-to-end differentiable
 I'm so inspired by this vision. I'm excited to interview creator Katherine Ye [1] on my podcast [2] later this month!
 Upon quick glance, it seems limited to diagrams in the field of linear algebra and perhaps a few related fields. Is this correct? How broadly is it applicable?(I'm still hoping for a tool that can make flowcharts with user-defined constraints, such as minimize number of edge crossings, then minimize total edge lengths, etc.)
 Our goal is that you can define domain-specific Style files--analogous to a .sty in LaTeX--that apply to whatever field of mathematics you want. We have prototyped this but there are still too many rough edges to recommend to outside users at this point.Flowcharts are not on our initial list of domains, but we hope that the infrastructure will let any user add a Style extension to support them.
 Might depend on what they've implemented so far. The simplex in figure 2 from the paper looks a lot like some of the simplex plots seen in Keenan Crane's work here: https://www.cs.cmu.edu/~kmcrane/And the authors have at least that connection to the Carnegie Mellon Geometry Collective,'' (see their prior work on his page) so I'd include discrete differential geometry in your list. This has connections (eh hem) all over...Edit: For some reason I missed the Penrose site at the link and skipped straight to the PDF short introduction. I am presenting somewhat redundant information above. Sorry!
 From their paper, it seems you can write a 'style' file for anything you can possibly want. Users then write the declarative code you see which Penrose interprets with respect to that 'style' file to know what to actually do.
 this is the exciting part to me; is there any constraint that the output has to be a 2-dimensional figure? I could imagine a style file that outputs a blender scene with a time dimension, or a VR scene that you can interact with in the same way they describe dragging one of the vector heads and having it recalculate the rest of the model.
 It looks neat, although the installer side of it looks to still be messy enough to warrant my waiting a bit before installing it in linux.
 Yes it is a bit of a palava to get running but you can get it running straight out of eg ~/src/ with \$ git clone https://https://github.com/penrose/penrose.git. Follow https://github.com/penrose/penrose/wiki/Building-and-running I use Arch Linux but I'm sure no one will hold that against me (package names like this):You will need a JDK (I installed jdk8-openjdk) to get a javac (needed when you run make in src). You may also need ghc for Haskell although the thing seems to install another one locally. I installed stack and then happy and then "stack build" finished OK. alias runpenrose=. Substitute "python -m http.server" for "python -m SimpleHTTPServer" because Python3 and the rest of the example works OK.Simples 8)
 Neat; now I am left wondering if this could be also implemented as applying a sty.xsl to a sub.xml in order to get an SVG.
 Well xsl does not include interactivity, and it’s functions are not much fun. So I’m not really sure anyone of sound mind would want to implement a nonlinear constraint optimiser in xslt.
 You can use XSL to generate code to which javascript is later attached. I did that a couple times when I was young and foolish. Also, SVG supports JS natively, I believe.That's not to say I would recommend it. No objection to your other points.
 Cool! Kinda like d3 but without javascript.
 Why use this instead of latex?
 LaTeX is for typesetting and notation, which it's quite good at. On the other hand, designing, laying out, and constructing pretty diagrams in LaTeX is very much NOT where LaTeX shines.
 Tikz (a set of packages for latex) [1] is an excellent tool for programmatically creating figures. I drew half the illustrations during my phd using Tikz. Even if other tools are more powerful, tikz has roughly the same syntax as latex and so there is less to learn. Its a lot of easier to control the flow of the figures in a document if they are drawn using tikz because you can resize or realign them on the fly.[1] Some examples here http://www.texample.net/tikz/examples/
 TikZ is good for pretty diagrams, and is entirely contained within (built with) LaTeX.
 TikZ creates pretty diagrams. I've had partial success using it, with my beginner-level LaTeX knowledge. I'm not convinced that it's possible to become comfortable with TikZ syntax, without hundreds of hours of LaTeX experience. I'd love to be proven wrong, of course.
 I have had thousands of hours of experience with latex and dozens with tikz. I still struggle with it. Its just that Latex has terrible syntax for function declaration, loops and conditionals and tikz inherits all these problems. My workflow is usually to go to http://www.texample.net/tikz/examples/ a lot and use the examples as reference code to whatever I am doing.The manual for tikz exists but I have never really read it.
 That's reassuring, if unfortunate. Thanks.
 Most TikZ syntax is actually pretty different from normal LaTeX syntax (and most other graphics syntax!). It's got a bunch of syntactic features I've never seen anywhere else.If you want to be proficient in TikZ, I think the best way is to read the manual. I put it on my phone and started at the start. It's general understanding of how 2D graphics systems tend to work and learning how TikZ does things that made me comfortable.
 I've read bits of it, trying to accomplish specific things. I always feel like I'm missing some foundational LaTeX knowledge, and it slows me down. Is there a good intro/manual for LaTeX that might help me there?
 At first I just read bits of the TikZ manual, but then decided I'd understand things properly if I read from the beginning and got the foundations.I don't have a single source for LaTeX. Most of the LaTeX I know (which is quite a bit by this point) comes from places like Stack Exchange, which I get to by doing a search to solve a specific problem. I tend to read lots of answers to get an understanding, rather than just using the first one that works; there are often multiple ways of doing things, some better, some worse, some obsolete, some leading to a whole new area of knowledge.The main thing is just to do lots of LaTeX, and it helps to do similar things over and over, improving how you do it each time. E.g. I've written so many maths exams that I have things like mark positioning, mark totalling, the question table on the cover, spare blank pages, starting questions on even numbered pages etc. all completely automated - but it didn't start that way at all, I just make it a bit better each time. Improving the same lecture notes and tutorials every semester is another.Working with and improving someone else's LaTeX code can help a lot, even (or especially) if your reaction is "Wow, that's awful! There must be a better way!".
 I do a lot of the same things you mention here, but I decided to write a python lib with jinja templating. I found my knowledge of python and its nice syntax to allow loads of use cases that I probably would have given up on in latex alone.
 What's the end product? PDF or HTML? Do you have any of them online you can link to?I do lots of Python stuff, but haven't used Jinja. LaTeX is pretty clunky for many things, and I haven't been able to take much advantage of LuaLaTeX, for compatibility reasons.
 Yeah, that sounds like about where I am now, probably a few years behind you. I'm also slower at progressing since doing things in LaTeX isn't part of my normal workflow.
 Some are just searching for anything that will generate the plot they want with better'' workflow. It's subjective. TikZ can be off putting, if you don't want to put the time in, or it doesn't meet some particular need you have. Inkscape is vast. draw.io is limited. 3D modelers, CAD programs, Python with its libs etc. I would say that LaTex and Penrose are compliments, as with any graphic generating tool.The creators of Penrose have this to say in the very first sentence of their introduction: "Typesetting software like LATEX and MathJax has accelerated the pace of scientific communication, but no equivalent exists for mathematical diagramming."
 This seems more a complement to latex. At the moment it generates svgs. But these can use TeX math via mathjax, and the internal representation is quite straightforward.It seems like it would not be much work to add a way to output as eg tikz (or rather, pgf) to this. It could probably output something more low-level too
 I don't understand your question. This and LaTeX are completely different applications for completely different purposes
 Some people are allergic to LaTeX

Search: