Hacker News new | ask | show | jobs
by exmadscientist 2756 days ago
I had a semester of abstract algebra as an undergrad, and I've always been surprised by how many dividends that semester has paid back over the years. The tools of higher algebra are very powerful in the right situation. This article is a great development of algebraic concepts and introduction to thinking algebraically, which is a really powerful tool to have in your toolbox.

(Closely related is the idea of invariants: properties that are preserved by particular operations or functions. Often invariants are related to some algebraic structure of the system, but can be easier to identify and support a lot of the same insights. Reasoning about invariants of systems is another great way to make progress on hard problems.)

I find that very few engineers (especially in hardware) have had exposure to this stuff. Being the only one in the room who's had an abstract algebra course means I've occasionally been able to provide a completely different line of attack on hard problems. This has been good for my career!

As an example, I once helped a friend debug a complex system that was not behaving correctly. There was an input state, a nasty sequence composed of simple operations applied to that state, and an output state, which was not behaving as expected. A bit of algebraic thinking showed that each of the simple operations preserved an invariant, so no sequence of valid operations, no matter how complex, could produce that output. This meant that debugging attention could be directed at the implementations of those simple operations, which led to finding bugs in short order. This saved a lot of work because the actual sequence came from elsewhere and would have been difficult to audit!

3 comments

I wonder how much better off students would be if the majority of the formal CS classes they take are replaced with more traditional (applied) math classes for that reason. I seem to rely on ideas from those classes more than the ones from my CS classes when I write / reason about code.
I think many folks would consider abstract algebra more of a branch of pure math, rather than applied math.
What was known as "applied math" through the 20th century was actually just one application of math: calculus / differential equations and linear algebra applied to physics (in turn applied to engineering, mechanical or electrical).

But then you have computer science, which is in many ways applied "pure" math. Although if you want to separate "applied" abstract algebra from "pure" abstract algebra, then the subject you'd want to talk about is simply called automata theory.

In fact, in the book Elements of Automata Theory Jacques Sakarovitch characterizes automata theory as the "linear algebra of computer science", in more ways than one:

I suggest that automata theory is the linear algebra of computer science. I mean this in two ways. Properly speaking, automata theory IS non-commutative linear algebra, or can be viewed as such: the theory of matrices with coefficients in suitable algebras. I am more interested, however, in the figurative sense: automata theory as a basic, fundamental subject, known and used by everyone, which has formed part of the intellectual landscape for so long that it is no longer noticed. And yet, there it is, structuring it, organizing it: and knowing it allows us to orient ourselves.

Note: if you look at my other comment in this thread, I suggested that exmadscientist was talking about Floyd's invariance principle, which, if you follow my cited source there, you can see explicitly formulated as an induction proof on transitions of a state machine.

It is (unless you are...well...applying it to something). I just didn't want to limit my statement to pure math topics, since I find, e.g. optimization, to be helpful.
Yes! Although I was an econ major I did the same thing, I dipped my toes into pure math and took some real analysis and abstract algebra. I really found these challenging at times. But the ideas and modes of thinking I gained from these classes have been very rewarding since.

I relate its value in programming to the Torvalds adage "Bad programmers worry about the code. Good programmers worry about data structures and their relationships." Taking some abstract algebra really helps you think about data structures and their relationships, and to architect "good bones" in your code.

It's true but, god I wish people cared about the code more. So many systems could be made great by better naming and an understanding of semantic meaning in functions and/or classes
If I understand exmadscientist correctly, this sounds a lot like Floyd's invariant principle, in which the argument is understood as mathematical induction, where the induction is on (property-preserving) transitions of the state machine (and with the initial state as base case). See section 2 of chapter 6 in Mathematics for Computer Science: https://courses.csail.mit.edu/6.042/spring18/mcs.pdf