Graphical Linear Algebra
graphicallinearalgebra.net
graphicallinearalgebra.net
This submission is the latest in a trend of what I would classify as "math-lite" category theory and Haskell articles that reach the HN front page, which purport to explain something interesting but end up just rehashing standard mathematics in opaque ways.
I really wish this would stop. Fortunately (unfortunately?) I've been down this road a few times and know to avoid getting sucked in, but I can easily see a bright, curious person wasting a lot of time before realizing that the content is merely linguistic, not mathematical.
Is (for example) category theory a useful organizational tool in certain abstract branches of mathematics? Sure (those branches being, basically, algebraic topology and algebraic geometry). Is it a grand unified theory of math? No, it's just some useful vocabulary. Most mathematicians go their entire lives without writing a paper mentioning categories. Getting excited about category theory is like getting excited about matrix notation – useful, sure, but not where the meat is.
I also find any claims that category theory is relevant to the average working programmer to be dubious at best.
(And yes, I realize the graphical notation presented in this article is not category theory. I am making a broader point about certain kinds of articles I see, which also applies here.)
> Is category theory a useful organizational tool in certain abstract branches of mathematics?
Yes. Abstracting math in a very general way lets you explore patterns and a result in category theory (e.g. Yoneda lemma) generalizes immediately to other instances of categories.
> I also find any claims that category theory is relevant to the average working programmer to be dubious at best.
I would say there is value in knowing some category theory, especially if the programmer is working in a strongly-typed functional language. Knowing what a functor is, what a catamorphism is and so on, can be useful ways to write more declarative code and teach about abstractions in the same way OOP uses Design Patterns to teach programmers about reusuable code.
Also, I don't really see how learning the abstract definition of a functor is going to help someone write better OCaml programs. But it is possible I am just not imaginative enough. Do you have a concrete example of this?
Well, in the case of functor it's not terribly interesting, but here's an example. A functor F has the property F g . F h = F (g . h), so this means that if you were writing
map f (map g l)
you could write map (f . g) l
instead, (in Haskell the compiler optimizes it anyway) but if your compiler actually traversed the list twice, now it traverses the list once.I could list other things like how monoids, monads, etc. can help make programs more efficient (monoids allow exponentiation with squaring) or structure programs better (monads allow composition of partial/stateful/exceptional functions).
Monoids are very simple objects, and you don't need to use category theory to define them.
Monads might be a more meaty example. But I'm not sure if knowing CT makes it easier to use monads in a programming context.
Sure, monoids are trivial, because they are, but once you're in the categorical setting you can begin to talk about the category of monoids, monoid homomorphisms and so on.
This isn't to say that CT is the answer, but I'm pointing out that it provides a way to understand more complicated concepts.
Functors are trivial, but if you take their fixpoint you get ADTs. Monoids are trivial, but if you apply them to the category of endofunctor you derive monads, and so on.
That's kind of the point.
> "Perhaps the purpose of categorical algebra is to show that which is trivial is trivially trivial." That is, category theory aids in making the softer bits of mathematics look utterly natural and obvious, so that one can more easily isolate the harder nuggets and attack them with abandon ... This is a tremendous service that category theory provides"
https://mathoverflow.net/questions/28788/nontrivial-theorems...
In isolation applications of category theory to programming are going to be trivial, typically. Category theory gives a language and framework for extracting trivialities so one can "attack the harder nuggets" without distraction.
(source: I was a postgrad supervised by Pawel)
My impression is that it ends up being largely some kind of linguistic translation project, or abstraction for the sake of abstraction, but I'm happy to be corrected on this point.
As for whether anyone outside the research programme is actually doing that, I don't know. But in principle it's a useful formal methods type theory.
The series is intended for a general audience and starts by laying the groundwork necessary for exposition of this paper: [1]. Article 4 [2] explains why it is introduced this way.
> end up just rehashing standard mathematics in opaque ways
It's just an explanation of string diagrams [3][4], pretty transparent and standard.
I find it funny that your response to this is so similar to that of the abacists to Fibonacci.[5]
[1]. https://arxiv.org/abs/1403.7048
[2]. https://graphicallinearalgebra.net/2015/04/29/dumbing-down-m...
[3]. https://ncatlab.org/nlab/show/string+diagram
[4]. https://en.wikipedia.org/wiki/String_diagram
[5]. https://graphicallinearalgebra.net/2015/04/26/adding-part-1-...
More importantly, I would like to remark that string diagrams are not standard. The vast majority of mathematicians have never read the definition of a string diagram (or even a monoidal category), precisely because it is not standard and not needed for most (any?) useful mathematical work. They also have obvious disadvantages when compared to the usual notation, as I pointed out earlier.
When I read articles by category theory boosters, I get the sense (rightly or wrongly) that they think the world revolves around them and they have stumbled onto some deep and fundamental truths. This is not the case. It's a niche of a niche.
I'm sorry that you didn't find it well-written -- it wasn't written with you in mind. Originally I wanted to write about my research in a way that was understandable to a lay person, but I quickly abandoned that and went for the mythical "second year undergrad" level.
You have pretty strong thoughts about what is "useful mathematical work". Are you the high priest and decider of the usefulness of mathematics? To be honest, it almost sounds like some category theorist was super mean to you...
One more thing. Arguments like "niche of a niche" are sociological - just because something is niche doesn't mean it's not important (or, god forbid, fun!). Maths is one of the most conservative fields in this sense; what is and is not considered "standard" is extremely political.
Interesting and totally not ad hominem response... I believe Kevin Buzzard (an actual mathematician) had a few words about this last year: https://youtu.be/Dp-mQ3HxgDE?t=1039
I find it interesting that actual mathematicians working in Category Theory, such as Tom Leinster (who wrote a lovely little introductory text on Category Theory [not covering monads though] and made it freely available on arXiv: https://arxiv.org/abs/1612.09375) are able to engage in polite discussion about the contentious viewpoints on the use of CT without resorting to personal attacks (see 2-3 minutes from his talk from a few years back: https://youtu.be/UoutGluNVlI?t=410) ... which stands in sharp contrast to some of the evangelists, whose attitude in response to criticism often reeks of arrogance and puts people off taking CT seriously, which I think is a great shame.
In the context of that video, his comments about category theorists and type theorists make a lot of sense: type theory people and (perhaps to a more limited extent) category theory people tend to be more easily sold on using a proof assistant since the kind of mathematics they do translate more easily into current proof assistants than, say, analysis or topology.
I definitely do not think that Kevin Buzzard is suggesting that type theorists and category theorists are not doing interesting and/or useful work (after all, the proof assistant he is advocating for is based on type theory). At best, he is making a sociological observation that there is a gap between the type theory/category theory community and "mainstream" mathematicians making the widespread adoption of proof assistants in mathematics more difficult.
They're standard in category theory, which is what the series is about.
> precisely because it is not standard and not needed for most (any?) useful mathematical work.
Uh oh, you better let everyone using it know, especially all those pesky type theorists.
> When I read articles by category theory boosters, I get the sense (rightly or wrongly) that they think the world revolves around them and they have stumbled onto some deep and fundamental truths. This is not the case. It's a niche of a niche.
I think this says more about you than the series. You seem upset that a category theorist is presenting their work in the language of category theory and that people are interested in it. Nobody mentioned anything about utility, depth, fundamentality or generality. In fact, he refers to some of his work as "hard and useless." [1]
> There has been intense political pressure on the academy to stop working on hard and useless things over the last 30 years or so. The result is a new generation of academics who do easy and useful things, things that impact the economy in the 5-10 year scale, and which bring in research funding. This is by design, because research funding is closely tied to academic career progression. Unfortunately, it’s not very hard to disguise easy and useless things as easy and useful. This has resulted in a totally out-of-control epidemic of easy and useless research. A symptom of this disease is the ever expanding use of increasingly ridiculous buzzwords. Easy and useless never leads to hard and useful. I’d much rather the government invest my tax money in the hard and useless.
[1]. https://graphicallinearalgebra.net/2015/04/30/spoilers-addin...
(Professional mathematician here)
My sense, from talking to category theory boosters, is not typically that they regard category theory as "deep and fundamental truths". Rather, they often find it a useful way to declutter and describe their work, allowing them to more easily focus on deep truths without getting bogged down in details.
Patience. These kind of work is not worth for verbal readers, but for visual learners and visual creators this is very educative. It's a work of visual learner and these kind of work will not stop.
> replace standard linear algebra notation with an alternative (but mathematically equivalent) graphical notation.
Yes. Modern computation is based on AI which is based on matrices which runs on GPU which does computation on graphical input. This work is a masterpiece for simple solutions for complicated computations.
But this does need to be the case. Sometimes a graphical notation is a great help. For example, many tensor computations in differential geometry become straightforward using Penrose's graphical notation. Is that the case here? It is difficult to say, as the authors fail to present that notation separately to the results.
Incidentally, I partially agree with you on category theory, especially on computer science. In abstract maths, however, category theory has more significance than pure language. It can serve more or less like an algebraic tool. There are abstract mathematicians who see deeper meaning in it too.
One of the things that has made me very successful as a problem solver and software developer has been the ability to apply category theory abstractly to projects and work that comes in. IOW, Using category theory well in day-to-day software engineering isn't about which monad to pick, but which abstraction (or series of abstractions) are the best fit to a problem.
However, to me it reminds me of String Theory, in that it has been sold as Theory of Everything for Mathematics and adjacent fields.
Category Theory might even be somewhat useful for language designers, but, I agree that it offers little benefit for programmers even with languages like Haskell.
Even Bartosz said that Adjoints aren't that interesting in Haskell because every functor is an endofunctor.
Every functor (in the standard library) is an endofunctor, but is also a functor to a specific flavor of full subcategory in Hask. It might be useful to support other flavors of subcategory, and I think there's some ongoing work on this in the SubHask module.
Category theory can be very useful, but you don’t use it the same way you use other kinds of math. You can apply optimization theory, for example, by noticing that a problem has a certain form, and therefore a certain algorithm will converge to a solution. Applications of category theory are usually more subtle. You’re not likely to quote some theorem from category theory that finishes off a problem the way the selecting an optimization algorithm does.
and
I had been skeptical of applications of category theory, and to some extent I still am. Many reported applications of category theory aren’t that applied, and they’re not so much applications as post hoc glosses.
At the same time, I’ve seen real applications of categories, such as the design of LINQ mentioned above. I’ve been a part of projects where we used category theory to guide mathematical modeling and software development. Category theory can spot inconsistencies and errors similar to the way dimensional analysis does in engineering, or type checking in software development. It can help you ask the right questions. It can guide you to including the right things, and leaving the right things out.
The most interesting part of category theory is topos theory, in my opinion. This is a generalisation of set theory, and can thus claim to be indeed useful for foundations.
I disagree with the "merely" here. Half of mathematical practice seems to be finding the right way to think about a thing. If the author were claiming this was a new grand theory, I'd be right there with you, but they seem to be claiming that it's just another way to look at things. I don't see any claims of importance. There's always room for new viewpoints that are content-wise equivalent to old viewpoints but different in how you work with, interpret, and think about them.
> ...but end up just rehashing standard mathematics in opaque ways.
I'd say it's rehashing standard mathematics in strange interesting ways, making it a very fitting curiosity for a site where things like a history of methods of communicating with submarines gets a ton of upvotes.
It's a bit surprising to realist that it seems like we completely agree on what it is and what its contribution to existing standard material is, but for some reason I think it's interesting while you "wish it would stop."
(My spicier opinion is that the machinery of CT is often completely unnecessary for many applications, and actually only serves to obfuscate simple concepts.)
While I rarely find graphical methods useful for performing calculations, I do appreciate visual interpretations of how mathematical concepts work. I personally find that whenever I have to learn a new topic in math, good visualizations help me form an intuition regarding how things fit together, and can often be useful when reasoning about how to attack a problem (back-of-the-envelope sketch before a more rigorous calculation). For actually solving the problem, on paper or in code, I agree that a symbolic approach is superior.
I also think that purely linguistic improvements in math can have a positive effect: a mathematical notation that is easy to learn, understand, and use, will clearly make the math it represents more impactful. I can't find the exact quote at the moment, but I think it was Dirac who said something along the lines that "a good mathematical notation should make correct statements obvious and wrong statements impossible".
> This submission is the latest in a trend of what I would classify as "math-lite" category theory and Haskell articles that reach the HN front page, which purport to explain something interesting but end up just rehashing standard mathematics in opaque ways.
This is, coincidentally, the ambition of APL.
That's pretty arrogant and rude. This is some mathematicians' PhDs and research, not a blog put in front of overpaid programmers to provide them with category-theory porn. Admittedly, the dumbed down language of the blog is misleading and makes it very hard to read.
https://dl.acm.org/doi/pdf/10.1145/3290338
https://www.sciencedirect.com/science/article/pii/S089054011...
Fabio Zanasi. 2015. Interacting Hopf Algebras: the theory of linear systems. Ph.D. Dissertation. Ecole Normale Supérieure de Lyon
(1) The human mind is pretty good at visual pattern recognition. For the same reason that people advocate for a big status monitor that every developer can see for your live service (since you can quickly spot anomalies your monitoring might miss) and for the same reason visualizing a data set is one of the first things you ought to do on your way to understanding it, creating a diagrammatic representation of linear algebra seems helpful for immediately getting a sense of where something feels "off" or for quickly grasping the intuition of a problem.
(2) The right notation (pictures in this case -- not that the idea I'm about to highlight couldn't be presented textually) can help highlight the portions of a problem that matter. Thinking about matrices as boxes of elements that you can individually manipulate is IMO actively harmful to understanding them and puts you in a situation where you miss the forest for the trees.
(2a) The matrix wiring diagram presented here naturally extends to higher order tensors, and for the life of me I can't find the source right now, but it was precisely that representation that made tensors click for me and gave me a foothold into other material about them.
(3) I think the current consensus is that multiple representations of a problem (via some mechanism -- call it "magic") are actively beneficial for learning a topic. From that point of view alone a diagrammatic representation doesn't seem especially bad.
While new notation like this is interesting, I do wonder how useful it is from a pedagogical standpoint for linear algebra. Category theory OTOH is one of the areas of mathematics with diagrams rule over equations because a single diagram can encode so many equations.
For excellent introductions to linear algebra I recommend Linear Algebra Done Right[0], which Springer offered for free for a while (it doesn't seem to be anymore though, contact me if you want the PDF).
This is not true. This may be true from an engineering perspective, or maybe if you've studied in the US, but over here, linear algebra starts with fields, vector spaces, homomorphisms. We establish pretty early on that matrices and linear transformations are in essence the same thing (up to choice of basis), and then we go on to prefer coordinate-free proofs. But, of course, we do discuss the computational aspect (i.e. the Gauss algorithm) because this is exactly what makes linear algebra so useful: many questions can be answered extremely efficiently.
Whether you want to frame things in the language of category theory or not, is up to anyone, but the "standard mathematical treatment" is quite beautiful and intriguing already (if I want to feel inspired, I open up my copy of Halmos's "Finite Dimensional Vector Spaces", not necessarily the best introduction for someone who is new, but very beautifully written for someone who has already seen linear algebra).
OTOH the other day I heard someone in the Netflix doc about Alberto Nisman’s murder that described a terrorist network as a “matrix”.
I grumped as card-carrying pedants are duty-bound to, but then realized that if there’s a 1:1 correspondence between graphs and (adjacency, incidence) matrices, then there’s very little loss of meaning in referring to graphs as “matrices”. Maybe in some communication contexts it’s even clearer.
But it's true, you can envision it as a NxN matrix of N terrorists, where the number in cell i,j represent's the strength of the relationship (it's a weighted graph!), and that might actually be useful for something. I don't doubt that "matrix" might actually exist in numeric form in some CIA or military computer somewhere.
One could say that I'm "part of a terrorist matrix", and that my value in the matrix is zero. We are all part of a terrorist matrix. I hope the CIA is not reading this, because they probably are not mathy enough to know what I'm talking about, and they may just take my quoted statement at face value, but in a mathematical sense we probably all actually have some nonzero value in our rows and columns of the terrorist matrix. You know someone, who knows someone, who knows someone, who is a terrorist. It really just depends how many people and how many degrees of separation you want to include in your matrix.
This is how I was taught linear algebra in the USA too. Almost to a fault, where I lacked practical intuition for how matrices and vectors of real numbers work and had to re-learn that stuff later.
I definitely learned linear algebra from the numerical and matrix perspective (though yes, we did cover the idea of vector spaces and linear transformations too). In engineering school, the focus tended to be on the craft rather than the theory, and in retrospect I think it was the right approach for engineering majors, whose primary concern was execution. It helped engineers use MATLAB to solve problems. The syllabus looked like this:
https://ocw.mit.edu/courses/mathematics/18-06sc-linear-algeb...
And this:
https://math.nyu.edu/media/math/filer_public/a4/00/a4008ffa-...
A syllabus for math majors might look quite different.
The US approach to linear algebra continued to be useful for me in grad school as an engineering major (I have an engineering Ph.D.). To be honest, for what I was/am doing, I don't think I would have derived much benefit from a more theoretical approach (but that's just me. People who work closer to theory may have a different opinion).
In my work, math has a retrospective role -- I first build something and later recognize patterns that fit a certain theory.
For theory-builders however, math has a constructive role. Theory builders however are relatively rare.
The US has a different university structure: the way I understand it, many people don't necessarily choose a major early on or can easily switch it which is why engineers, mathematicians, biologists, etc. often take the same course. Please correct me if I'm wrong.
Over here, this is much rarer. Sometimes computer scientists or physicists take some of the same courses as mathematicians, but hardly engineers. Therefore, we can probably afford to be more theoretical right away (although the computer scientists sometimes complain xD).
I can totally understand that for someone with a focus on application theory is less important, and that some people can get more excited about what you can do with matrices e.g. in computer graphics or machine learning than about abstract morphisms and rigorous proofs.
Incidentally, over here I sometimes feel we learn stuff the other way around: first we hear all the theory, but it's only in the later ODE and numerical methods courses that we actually get substantial practice in calculating more complicated integrals or learn about e.g. QR factorisation or Simpson's rule (although we do prove error bounds by then).
But then, everything was using the same terms, and was relatively simple and straightforward. Fourier transforms? Laplace Transforms? They are all just linear transformations. Functional analysis? It's a lot of inner products, hermitian forms and eigensystems but we were familiar with all the properties, so we only concerned outselves with what's different about it (e.g. the spectral theorem). Coding thoery? It's finite fields, we did those in linear algebra, now it's just applications. Stationary distributions on markov processes? It's application of linear algebra+probability, but works mostly the same whether it's discrete (and representable by a matrix) or continuous (when it isn't).
The syllabus for engineering students was basically the same as for math students, except we only covered proofs in class & homework (but did not have to be able to reproduce them in tests), and that we mostly went through a simple logical progression of ideas rather than a historical one (e.g., cauchy's theorem of analytic complex functions was essentially a two-line application of Green's theorem in the plane, and we spent ~30 minutes discussing it; math students spent ~6 weeks proving it in the way Cauchy historically did, progressing from simpler to complex structures)
Start with [Essence of Linear Algebra](https://www.youtube.com/playlist?list=PLZHQObOWTQDPD3MizzM2x...) by [3 Blue 1 Brown](https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw) for an intuitive overview of all the major concepts.
While working through a full Linear Algebra course, it is important to develop your own software to do things. That is, some sort of command tool to enter matrices and run operations on them. As you go through a course, you will keep adding operations.
You should work on some of the most common tricks, like using 4 by 4 matrices for computer graphics and understanding what a PCA does.
That's definitely possible, but not everyone approaches linear algebra from such a number oriented perspective.
In fact, my linear algebra prof in Uni tried to avoid coordinates (ie numbers) as much as possible. Eg talking about abstract linear transformations instead of emphasising that you can represent them you can represent them as a rectangle of numbers.
X' = aX + bY
Y' = cX + dY
minimizes irrelevant information. But the diagram for one seems to bring it to the fore: a diagram is basically a system of fully parenthesized, unsimplified expressions eg X' = (3X + (2(X+4Y) - 6X)) + Y
...
In fact, it contains even more information than that, since it also tells you if, in (X+Y)+(X+Y), you are supposed to compute (X+Y) once and reuse the value or compute it twice.So in this case, GLA builds the theory of linear transformations from trivial/simple pieces and their various ways of being composed. It also discusses the mechanisms for proof and reduction (you noted how GLA is clear about whether a sub-computation is reused or not, it'll also be clear about how those two choices are equivalent).
So it's really not studying "just" linear transformation (which are, in finite cases, summarized by a matrix of numbers/field elements) but also the theory of their construction, manipulation, simplification. It gives you a rich language for talking about how two linear combinations might be related to one another, something that's more challenging to access from a matrix.
For example, the only thing I can think of is maybe (AB)^T = B^T A^T.
> If you are impatient and want to get to the conclusion quickly, here’s the link to our paper where the basic theory is explained (Spoiler warning!). We will also discuss several applications of graphical linear algebra that have been developed in recent years.
Thanks a bunch, very interesting. I've stumbled upon petri nets as a state machine alternative when looking for graphical modeling tools for functional programming (I'm a designer learning Elixir). Here's a talk: https://www.youtube.com/watch?v=aWnGPaputGE