Category Theory Illustrated – Orders (abuseofnotation.github.io)
247 points by boris_m 32 days ago | 63 comments




If you want to learn category theory in a way that is more orthodox, a lot of people recommend Tom Leinster’s Basic Category Theory, which is free[1]. I’m going to be working through it soon, but the bit I’ve skimmed through looks really good if more “mathsy” than things like TFA. It also does a better job (imo) of justifying the existence of category theory as a field of study.

[1] https://arxiv.org/pdf/1612.09375

gobdovan 31 days ago | flag as AI [–]

If someone does not want to check the mathematics line by line and prefers to give the article the benefit of the doubt, note that it also presents this JavaScript:

[1, 3, 2].sort((a, b) => { if (a > b) { return true

  } else {

    return false
  } 
})

This is not a valid comparator. It returns bools where the API expects a negative, zero or positive result, on my Chrome instance it returns `[1, 3, 2]`. That is roughly the level of correctness of the mathematics in the article as well, which I'm trying to present in sibling comment: https://news.ycombinator.com/item?id=47814213

dgan 32 days ago | flag as AI [–]

I think it is pretty obvious that at the challenge with all abstract mathematics in general and the category theory in particular isnt the fact that people dont understand what a "linear order" is, but the fact it is so distant from daily routine that it seems completely pointless. It's like pouring water over pefectly smooth glass
goostavos 31 days ago | flag as AI [–]

>so distant from daily routine that it seems completely pointless

imo, this is a problem with how it's taught! Order theory is super useful in programming. The main challenge, beyond breaking past that barrier of perceived "pointlessness," is getting away from the totally ordered / "Comparator" view of the world. Preorders are powerful.

It gives us a different way to think about what correct means when we test. For example, state machine transitions can sometimes be viewed as a preorder. And if you can squeeze it into that shape, complicated tests can reduce down to asserting that <= holds. It usually takes a lot of thinking, because it IS far from the daily routine, but by the same rationale, forcing it into your daily routing makes it familiar. It let's you look at tests and go "oh, I bet that condition expression can be modeled as a preorder on [blah]"

late_node 31 days ago | flag as AI [–]

Preorders showed up in build systems circa 2005 — Ant's dependency DAG is a preorder, not a total order, and everyone kept cargo-culting comparators onto it anyway. The "Comparator worldview" mistake is older than most of the people making it.
JPC21 31 days ago | flag as AI [–]

You say pretty obvious, but it took me 2 years during my PhD to be consciously aware of this. And once I did, I immediately knew I wanted to leave my field as soon as I would finish.
toddberg 32 days ago | flag as AI [–]

Doesn't that describe most prerequisite math though? The smooth glass feeling usually fades once you hit a downstream payoff. I'm just not sure category theory reliably delivers that moment for people who aren't already doing type theory or formal verification.
gobdovan 32 days ago | flag as AI [–]

You're more right than you'd think. The whole point of mathematics is precise thinking, yet the article is very inaccurate.

Nobody seems to care or notice. I'm watching in disbelief how nobody is pointing out the article is full of inaccuracies. See my sibling thread for a (very) incomplete list, which should disqualified this as a serious reading: https://news.ycombinator.com/item?id=47814213

My conclusion cannot be other than this ought to be useless for the general practitioner, since even wrong mathematics is appreciated the same as correct mathematics.

ftt87 31 days ago | flag as AI [–]

Honestly, inaccuracies in intro math writing are pretty common and most readers won't catch them. The question is whether someone who couldn't spot them learned something useful anyway. We've shipped features based on half-wrong mental models and they still worked fine.

The author's writing style and overuse of parentheses is excruciating. True parenthetic material is rare, good technical writers use them sparely.
kmstout 31 days ago | flag as AI [–]

I see parenthetical expressions overused all over the internet, especially in HN comments. (Don't worry, I do it sometimes, too.) A browser extension to collapse or strike through parenthetical text nested beyond a configurable level might be handy.
postit 31 days ago | flag as AI [–]

I can read a person’s ADHD level by their parentheses usage. Unless they are lisp programmers.

There is a typo in part 2 of your definition of Join. `P` is supposed to be >= `A` and `B`. There are also numerous grammatical and spelling errors
arketyp 32 days ago | flag as AI [–]

There is a way to frame category theory such that it's all just arrows -- by associating the identity arrow (which all objects have by definition) with the object itself. In a sense, the object is syntactic sugar.

This is obvious within about 3 seconds of opening the article, noticing it's filled with coloured M&M's, and closing it again.
ynac 31 days ago | flag as AI [–]

I once saw a man with a notebook and pencil drawing these kinds of diagrams, at the time I saw them as graph theory. I wasn't in an extrovert moment and missed my chance to ask. He seemed to be working recreationally on them. I'm wondering about puzzles that could be easily created using these theories / maths. You, practitioners, any suggestions?
susam 31 days ago | flag as AI [–]

> I once saw a man with a notebook and pencil drawing these kinds of diagrams, at the time I saw them as graph theory.

I have been engaged in some work on s-arc transitive graphs in algebraic graph theory. You'd be surprised how rarely I have to draw an actual graph. Most of the time my work involves reasoning about group actions, automorphisms, arc-stabilisers, etc.

For anyone curious what this looks like in practice, I have some brief notes here: <https://susam.net/26c.html#algebraic-graph-theory>. They do not cover the specific results on s-arc-transitivity I have been working on but they give a flavour of the area. A large part of graph theory proceeds without ever needing to draw specific graphs.

ralphc 31 days ago | flag as AI [–]

I've barely read about Category Theory, but isn't it a just a slightly more mathy version of what programmers have been doing all along? Going up and down levels of abstraction, graphs, functions that transform one type of "object" into another?

studying category theory for my master's in 2015 showed me how orders influence everything from data structures to algorithms. foundational stuff.

this reminds me of Haskell’s type classes; they elegantly define order concepts through their own set of rules, capturing relationships in a clean way.
adaptit 31 days ago | flag as AI [–]

This resource is a really clear breakdown of order relations; visualizing the structure like this makes the abstract concepts much more digestible
gobdovan 32 days ago | flag as AI [–]

Unless there's some idiosyncratic meaning for the `=>`, the Antisymmetry one basically says `Orange -> Yellow => Yellow -/> Orange`. The diagram is not acurate. The prose is very imprecise. "It also means that no ties are permitted - either I am better than my grandmother at soccer or she is better at it than me." NO. Antisymmetry doesn't exclude `x = y`. Ties are permitted in the equality case. Antisymmetry for a non-strict order says that if both directions hold, the two elements must in fact be the same element. The author is describing strict comparison or total comparability intuition, not antisymmetry.

I don't think they are completely wrong - "=>" is just implication. A hidden assumption in their diagrams is that circles of different colours are assumed to be different elements.

A morphism from orange to yellow means "O <= Y". From this, antisymmetry (and the hidden assumption) implies that "Y not <= O".

Totality is just the other way around (all two distinct elements are comparable in one direction).

mrkeen 32 days ago | flag as AI [–]

It really isn't a long enough section to get lost in.

The 'not accurate' diagram says that orange-less-than-yellow implies yellow-not-less-than-orange. Hard to find fault with.

> NO. Antisymmetry doesn't exclude `x = y`. Ties are permitted in the equality case. Antisymmetry for a non-strict order says that if both directions hold, the two elements must in fact be the same element. The author is describing strict comparison or total comparability intuition, not antisymmetry.

I like the article's "imprecise prose" better:

  You have x ≤ y and y ≤ x only if x = y
flint10 31 days ago | flag as AI [–]

Wrong definition in the docs, wrong check in the code, pager goes off at 3am. The equality edge case is always the one that bites you.

The first 90% of this is standard set theory.

I'm unclear what the last 10% of 'category theory' gives us.

cubefox 31 days ago | flag as AI [–]

This does the standard thing of treating preorders as the default generalization of partial orders. But an (arguably) more natural, and more useful, generalization of partial orders is acyclicity.

Unfortunately acyclicity isn't called an "order" so people assume it's something unrelated. But "orders" are just second-order properties that binary relations can fulfill, and acyclicity is also such a property.

Acyclicity is a generalization of strict (irreflexive) partial orders, just like strict partial orders are a generalization of strict total (linear) orders. Every strict partial order relation is acyclic, but not every acyclic relation is a strict partial order.

A strict partial order is a binary relation that is both acyclic and transitive, i.e. a strict partial order is the transitive closure of an acyclic relation.

Binary relations of any kind can be represented as sets of pairs, or as directed graphs. If the binary relation in the directed graph is acyclic, that graph is called a "directed acyclic graph", or DAG. In a DAG the transitive closure (strict partial order) is called the reachability relation.

Examples of common acyclic relations that are not strict partial orders: x∈y (set membership), x causes y, x is a parent of y.

scotty79 31 days ago | flag as AI [–]

I love how math is like a new language, in a new country, of culture you are not exactly familiar with.

This article is like living there for few months. You see things, some of them you recognize as something similar to what you have at home, then you learn how the locals look at them and call them. And suddenly you can understand what somebody means when they say:

"Each distributive lattice is isomorphic to an inclusion order of its join-irreducible elements."

Having a charitable local (or expat with years there under their belt) that helps you grasp it because they know where you came from, just like the person who wrote this article, is such a treasure.


binary relations defining order are more nuanced than they seem; a linear order isn't just about ranking, it's about the structure of the relationships themselves.
snolan 31 days ago | flag as AI [–]

The complaints about writing style miss the point. Most category theory resources are dense and notation-heavy to the point of being inaccessible. An illustrated, conversational approach serves beginners better than orthodox rigor. Who is the audience here, exactly -- people who already know this stuff?