LaTeX Finite Automata and State Diagrams with Tikz
hayesall.com
hayesall.com
For example, naively searching a string of length N for P different substrings will yield an algorithm that has roughly O(N * P) worst case time complexity.
But implementing that algorithm as a DFA yields an efficient construction that has O(N) worst case time complexity.
This results in considerable speedups for complex pattern recognition tasks on large inputs, and yields other useful properties.
As a real world example, a CSV file can be parsed in parallel on a GPU by using a DFA based algorithm [1].
One downside to DFA representations is that they can be difficult to work with as linear text in your editor. Tikz produces great visualizations but I feel the syntax is a bit cumbersome. I’m still searching for that perfect text based format for DFAs - ideally one that can be visualized but also executed.
[1] ParPaRaw: Massively Parallel Parsing of Delimiter-Separated Raw Data https://arxiv.org/abs/1905.13415
I think it is worth saying that this is possible because finite state automata have a set of useful, well-understood operations, like concatenation, union, intersection, negation, kleene closure, determinization, and minimization. This makes it possible to generate complex automata from basic building blocks and to make them deterministic and minimal.
They are the same thing as regular expressions. It's safe to say they're not being dismissed as academic novelties.
If I understand correctly, their work makes diagrams and code isomorphic. Meaning roundtripping between diagrams and code can be done with no loss, no impedance mismatch.
Meaning my long-time dream of a two-way structure editor is now feasible. Edit the diagram, the code updates. Edit the code, the diagram updates. Back and forth.
As you know, the Achilles Heel of CASE tools (and visual programming) has been the inability to roundtrip.
Do I understand correctly?
My science-fu is weak. I've been struggling to wrap my head around grammars and whatnot my entire career. Please forgive.
If you want to go down some rabbit holes, check out the homepage of the Mathematically Structured Programming group at the University of Strathclyde: https://msp.cis.strath.ac.uk/index.html
If anyone writes a Graphviz tutorial, it would be doing the world a service to prefix it with "But seriously, note that Tikz exists".
I have a Theory of Computation text so I have many, many such diagrams. I don't rely on the graphviz output directly. If I have to make a graph where the layout isn't obvious then I write a .dot file and run it through graphviz, specifically, neato. I use that as a model for drawing it with a LaTeX tool (I don't use TikZ, I use Asymptote, but the point is the same). That way I get a pretty good layout, better then I personally could do without the guidance from graphviz, and a visual consistency to the diagrams.
Of course, everyone will have a different opinion on such aesthetic matters. I taught an undergrad comp theory course for a decade or so and I wrote my own similar package[1] for generating diagrams using Metapost that built on the standard boxes package. Students were able to learn the system pretty quickly and the results were usually good, though it was pretty easy to pick out which students did/did not care about how things look.
Also, has anybody tried using Inkscape [1,2] or another vector drawing tool for this? I imagine it would be faster and more intuitive than learning Tikz.
[1] - https://stackoverflow.com/questions/17610717/drawing-an-undi...
[2] - The following appears to be part of a presentation: https://gould.cx/ted/presentations/txlf16/Technical%20Drawin...
It seems like a problem that should be amenable to machine learning approaches. Basically, training a machine as to what is an aesthetically pleasing layout and what is not.
Are there layout engines that use machine learning for layout, as against being implemented in terms of specific tree or graph layout algorithms?
[1] https://tikz.dev/gd-overview
edit: chapter 27 in the online version
Tikz also allows a tight integration to LaTeX documents that no external tools achieve so easily. The drawing inherits colors and fonts, and bits can be reused across the document and can be shared with other documents too.
High learning curve but long term efficiency with quality results.
Tikz is not perfect but it has the great characteristic of existing.
E.g. in my theses all figures (except one in my first thesis) were made with TiKZ with colors and definitions defined in a file that is "imported" during compilation.
This allowed me to fine tune various parts (colors, ...) without having to touch each figure again. Also, all the data files are stored as CSV and read/processed by LaTeX. Between handing in my thesis and publishing the short-paper version of it for a conference I could rerun my analysis (to include the most recent data) with a single command and then just recompile the document to have all figures updated.
The thesis: https://www.ac.tuwien.ac.at/files/pub/hinteregger_18.pdf
And TikZ graphics play somewhat nice with the beamer package. I found it easier to define transitions in technical figures with TikZ/beamer than with PowerPoint or any other tool so far.
In a summer internship I worked on the documentation of a project that tried to optimize pillar-placement for skilifts. This was very Math/Physics heavy.
With TikZ I could define various parts (e.g. pillar, rope, gondola) as "function" and then create figures that combined these parts.
I.e: - place pillars at these locations - connect them with ropes obeying some formula - put gondolas along the rope with some defined distance
Important points where marked with coordinates automatically, allowing explanatory nodes (text box with arrow or paths with labels) to be added (with full LaTeX support).
I haven't looked at that field for a good while but I'm still genuinely interested. And so I'd like to better understand your comment. It is unclear to me whether you are arguing in favor of using another similar tool using a better syntax, or using an automatic graph layout engine, or a manual general purpose vector drawing tool. How would you recommend one to draw such diagrams?