Hacker News new | past | comments | ask | show | jobs | submit login
What Is Applied Category Theory? (2018) (arxiv.org)
202 points by behnamoh 31 days ago | hide | past | favorite | 68 comments



As a high schooler interested in things that are probably out of my league, I love reading this kind of stuff. The author mentions their unconventional style at the beginning: hyperlinks, color, italics, exclamations, parentheses, side notes, etc. They address your thoughts and craft their explanations around them instead of being terse and optimizing for length.

The author's blog [1] has more of this style and has really helped me get deeper into category theory. Without it, I wouldn't have even begun to try and understand things like the Yoneda lemma (which still remains a mystery to me).

Does anyone know any other papers or resources with this style? Maybe something like "explorable explanations" [2]?

[1] https://www.math3ma.com/

[2] https://explorabl.es/


Not addressing your question, but the Yoneda Lemma is kind of a charlatan.

On first reading, it seems magical and deep, but once you grok the proof, it feels like a relatively trivial observation. The whole thing is just about arrow composition!

In a way, once you're on the other side, the Yoneda Lemma feels a bit like a checkpoint during the accimatization period where your brain gets used to thinking in categories and commutative diagrams.

Not quite sure it's exactly the style you're talking about, but Bartosz Milewski has a nice series of video lectures going all the way from nothing up to Coend stuff. IIRC the series gets to the Yoneda Lemma somewhere in the second series:

https://invidious.snopyta.org/channel/UC8BtBl8PNgd3vWKtm2yJ7...


> The whole thing is just about arrow composition!

There's much much more to it.

For example, a version of the yoneda lemma also holds for metric spaces (instead of a set of arrows between to things, you simply have a number indicating a distance between two things).

Here's how I like to think about the yoneda lemma:

If you have some kind of objects you want to talk about, one way to do this is by relating these objects to each other. Once you have established such a "method of discourse" (i.e. a way to talk about how your objects relate to each other) the yoneda lemma tells you:

1. You can forget about the inner structure of your objects; Everything is already contained in your "method of discourse".

2. Inversely: The choice of a "method of discourse" severely limits what you can say about your objects.

3. There is no spoon: To understand how you can escape these limitations you need a "method of discourse" for "methods of discourse".


I like your example and perspective. I would just add on that it is not facile to do this for metric spaces, but leads directly to constructive solid geometry [0], where we render images of complex solid objects by exchanging the object for a signed distance function [1], a function which indicates how far the object is from any point in the space.

[0] https://en.wikipedia.org/wiki/Constructive_solid_geometry

[1] https://en.wikipedia.org/wiki/Signed_distance_function


> a number indicating a distance between two things

That *is* a arrow. Arrow composition is adding up the distance along a path.


The correct term would be "composition in an enriched category". The morphism objects in this context are usually not called arrows.

I think the other poster meant "elements in the set of morphisms" when they said "arrows".

The difference is the following: Metric spaces "are" categories enriched over the real numbers, ordinary categories are categories enriched over the category of sets. So in one case the morphism objects are sets while in the other case they are real numbers. "Arrows" then refers to something internal to the morphism object. The distance (a real number) between two points in a metric space does not have any internal structure.


That almost describes discourse about politics and social issues, too.


"On first reading, it seems magical and deep, but once you grok the proof, it feels like a relatively trivial observation. The whole thing is just about ____ composition!"

I think if you replace _____ with the right word almost every result I've seen in my (albeit somewhat limited) exposure to category theory can be described this way.

(not that that detracts from your answer!)


Well yeah, because category theory studies composition. That's what it's for. That's why a category is defined the way it is: a bunch of objects, identity arrows from each to itself, and arrows between them, which enjoy an associative composition operator.


Yoneda just says that we may exchange an object for all of the arrows which point to (dually, from) it. This is extremely deep; it is rather surprising that objects and arrows would have such a duality or exchange!


+1. The lemma is trivial not because the result isn't deep but because we have the right definitions.


This 'triviality' issue has reminded me of Grothendieck's "two styles in mathematics":

http://www.landsburg.com/grothendieck/mclarty1.pdf


Not exactly unexpected conceptually though, given that objects have no intrinsic structure. What may be surprising is that this fact has useful consequences in applications to concrete mathematical objects that do have structure.


I don't have any resources to share on this, but I was also interested in this type of thing at your age (still am). If it interests you, never assume something is out of your league.

You have time on your side. Sustained effort compounded over time is unreasonably powerful. Keep pushing!


> Sustained effort compounded over time is unreasonably powerful.

Thank you, this hits close to home and is great advice, I appreciate it.


90s-ish videogame lore, “Time is an ally, not an enemy. Patience can sharpen even the smallest of efforts into a weapon that can strike the heart of an empire.”

On my cube walls, whenever I get back to my cube: “magic is just cleverly concealed patience.” The approximate η-expansion: you can generally figure out what professional magicians do, you just dismiss it, “I mean of course she coulda known what card I was going to pull if she bought 52 decks of cards and assembled an entire card made out of the Jack of Spades... but that’s expensive and difficult and who would do that.” Penn Jillette puts the same point a different way, saying that he is going to have to perform the same trick over and over again and so it cannot be 99% likely to not injure him, that is far, far too low, he has to be 100% certain his tricks are safe. If he is firing a nail gun at Teller’s neck it must surely be incapable of firing a nail at Teller, and if he waxes on about how much he has memorized the pattern of the nails in the gun then he must be cleverly concealing whatever patience went into making that nail gun and the illusion that it is loaded.

But the key is that once you see this one place you see it everywhere. A restaurant works by the same magic. You say what you want and it magically appears before you. How did that happen? Prep work for hours in advance of the meal, so that when the time comes I just need to put tab A in slot B. Like a beef wellington; pre-cooked steak wrapped into a nice little bundle that just needs to be finished in the oven for 20 minutes and sliced. Something to think about next date night—you can impress your date immensely if you make the wellingtons the night before, so that your focus is on your lover and not on your cutting board.

You don’t usually think about the prep work that went into the Mother of All Demos, but you should. Sometimes when Alan Kay shows a clip from there, he mentions something like, “you might notice that they get sub-second latency on all these operations, but the terminal was here and the computer was over there so I like to ask students how they got sub-second latency on all these operations, and only one time have I got the right answer, one student said ‘because they wanted sub-second latency?’ and that is absolutely correct, they-goddamn-wanted-subsecond-latency, these things are there for you if you really want them.”


https://betterexplained.com if you haven’t been through it yet.

Already often quoted on HN, and some discussions are interesting with the author bringing feedback. https://hn.algolia.com/?q=https%3A%2F%2Fbetterexplained.com


You may like the books Conceptual Mathematics: A First Introduction to Categories, Creative Mathematics, Advanced Calculus: A Differential Forms Approach, and Geomtrical Vectors.

https://www.amazon.com/dp/052171916X/

https://www.amazon.com/dp/0883857502/

https://www.amazon.com/dp/0817637079/

https://www.amazon.com/dp/0226890481/


Not exactly what you asked for, but this explanation of the Yoneda Lemma is amazing: https://youtu.be/h64yZs8ThtQ


If you’re interested in machine learning I can recommend Christopher Olah’s blog: https://colah.github.io/


Although they might be very out of your league depending on what your interests are, Anthony Zee has a similar writing style (in print)


I'm not a natural mathematician (emphatically not!) and pretty much every attempt I've made to wrap my head around Category Theory has foundered on an onslaught of formalism by paragraph 2.

To be clear, I'm not knoocking that: for those who can and do grok things from that sort of treatment, all power to your elbow (and no small amount of admiration).

But it's not how my brain works. I need an intuitive understanding first: exemplars, informal pictures, whatever. I can only start unscrambling the formalism once I have the intuition.

The author's introductory blog post is a great example [0]. It's without doubt the best "bootstrap" I've come across - where "best" means "most understanable to me". I really admire people who can take abstract/complex subject matters and lay them out in a clear and accessible way for the layperson. Tai-Danae Bradley definitely fits in that Category (dubious pun intended!).

[0]: https://www.math3ma.com/blog/what-is-category-theory-anyway

EDIT: fixed typo


The Graphical Linear Algebra[0] series is a fantastic introduction to a really fascinating application of category theory, representing vectors & matrices as flow diagrams (ie. monoidal categories) and deriving useful properties from those.

The style is super friendly and builds up intuition slowly, while being completely rigorous. For a great example, check out the "Crema di Mascarpone"[1] chapter which introduces all the tools for writing rigorous mathematical proofs using flow diagrams.

[0]: https://graphicallinearalgebra.net/

[1]: https://graphicallinearalgebra.net/2015/05/06/crema-di-masca...


Samuel Eilenberg, one of the founders of category theory, used to tell to his students "You should have you own category". Meaning, that when you work on category theory you should have in mind applications to something. One of his students used to say "my category is Cat". Cat means the category of categories.


If the author’s name sounds familiar despite you not being in this field: she is writing the excellent blog at https://www.math3ma.com and you might know her from there. Articles of this blog are submitted here from time to time.


She also hosted the YouTube math channel PBS Infinite Series.

https://www.youtube.com/c/pbsinfiniteseries/featured


Two points to you for nerd-sniping a physicist with the "assassin problem" episode that auto-ran when I followed the link. Have a nice day!


I've never actually gotten around to diving into this topic before, but every time one of Tai-Danae Bradley's publications pops up I am awed by how much care she puts into crafting these from the layout to the illustrations


I think she's using the LaTeX package for Edward Tufte's style:

https://edwardtufte.github.io/

(If you like the design, you'd like Tufte's books.) Anyway, her paper is fun to read and one of the most beautiful papers I've read in terms of layout and design - I like the contrast between the hand-drawn illustrations and the abstract content. It reminds me of Lin Clark's Code Cartoons (https://code-cartoons.com/) .


Category Theory is one of those things which I know are important and has applications in many engineering fields. I also have an intuition that its obviously because things need to flow into each other and composability is how we achieve that. But man, whenever I try to get into this I feel like someone is hitting me on the head with equations.


Maybe for a value of "has applications" that doesn't necessarily include anyone actually applying it.

As a generalisation, I don't think anyone by people into category theory actually cares about or applies category theory.


I was about to agree, but then I realized it's not immediate that Set Theory has practical applications either.

However, Set Theory is essential to build mathematics.

Taking points from: https://mathoverflow.net/questions/10334/what-practical-appl...

Analysis, Number theory, most of modern mathematics rely on set theory, even computer science in the definition of Turing machines and dealing with infinities there are implicit axioms of set theory.

Likewise, perhaps category theory may not yield immediate applications, but it can be useful as a language (like a programming language, natural or mathematical) to express mathematical ideas, and to build mathematical systems and foundations.

I'm not sure how closely it relates to Category theory, but Homotopy Type Theory has yielded the fantastic Univalent foundations, a seemingly more modern and simple foundation for mathematics. This line of work also yielded a solid basis for Proof assistants.

I don't know enough about functional programming to comment...


It CAN be useful, you say, but is it actually? Is anyone using it? Beyond a handful of exceptions, I would say no.

Set theory actually IS used as the foundation of other work. But category theory isn't, as far as I know.


Shouldn't it be easier to explain a general concept than a specific one? The only reason I can think of why this isn't happening is because you need to learn a large amount of information before any of the category theory stuff can be applied in real life. But honestly speaking, that can't be true because languages like Haskell exist and isn't that on the whole programming using category theory? (I am be completely wrong about this).

OTOH it can also be just a pedagogy issue. That nobody has figured out how to condense it into an undergraduate level so working engineers can grasp basics.


> languages like Haskell exist and isn't that on the whole programming using category theory?

It's not. However claims like that get thrown around a fair amount so the confusion is understandable.

That said, some important Haskell abstractions were designed using category theory. So it can be helpful to know some of the lingo (since it will show up in abstraction names and descriptions).

And if you're looking to design the next breakthrough Haskell abstraction it might be extremely helpful, but that's not 99% of programmers. However, the people who can do that are super cool, eg https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors....


> Shouldn't it be easier to explain a general concept than a specific one?

It depends. Are you an abstract or a concrete thinker? That's one axis of one the standard ways of describing personalities. (Yeah, I know, psychology... but it does seem to describe an actual difference in how people think.)

Now, people with one kind of personality can learn to think in the other way, but they won't find it as easy.


I'm applying it.


Getting to feel a bit sour about how I get downvoted for talking about hacking on Hacker News and upvoted when I write about politics rubbish.

Anyone wanna talk about my applied category theory paper at the fall AAAI symposium? https://arxiv.org/abs/2011.11063


It is not that the HN community is diminishing your credentials in applied category theory or in any other fields, more so the inherited snarkiness in your short comment provides no one a favor and surely doesn't add any value to the discussion.


There is an applied category theory course that is currently in the process of wrapping up: https://applied-compositional-thinking.engineering/

The examples in the course offer a complementary entry point to category theory compared to an approach that leverages programmers' knowledge of functional programming.

Personally, the more examples the better. I'm grateful to be able to rely on the example of a category as a collection of objects corresponding to types, and arrows between types corresponding to functions with that type signature, and arrow composition corresponding to function composition (and functors, and natural transformations, and ... corresponding to familiar concepts like polymorphic types, and map, and polymorphic functions and ...). I believe that many programmers can [come to] understand this one specific example of category theory objects, even if the words are unfamiliar. And there are so many more examples! There is a great pleasure in formalizing the analogies across different aspects of math and engineering.

To get a flavor of and gentle introduction to the analogy-making power of category theory, I recommend this talk by Eugenia Cheng: https://www.youtube.com/watch?v=ho7oagHeqNc


Worth mentioning that we are offering a high-quality (paid) course https://training.statebox.org


Category theory has applications to quantum circuit minimisation: https://zxcalculus.com/pyzx.html and functional programming.


To give you an idea of how we are using this pdf..

I am reapplying category theory to use functions in dart-Flutter to avoid using statefull widgets and instead use a reactive function approach to state management.

Side benefits is it's easier to explain to beg flutter devs than statefull widgets.

Thanks behnamoh for posting this link


In re: CT see also Conal Elliott's "Compiling to categories"

http://conal.net/papers/compiling-to-categories/

Also, "concatinative" languages like Joy.

https://en.wikipedia.org/wiki/Joy_(programming_language)


FWIW, here's an example of a simple programming task in Joy, the derivation of the step combinator. It might not make a lot of sense without familiarity with Joy, however, the thing to notice is the smooth algebraic form of programming. Making simple obvious decisions at each point leads to a concise and correct program. That's "the function-level programming style of John Backus's FP." in action. You can do it in Haskell (et. al.) too but I find it much easier in Joy. YMMV.

The step combinator accepts a list and a quoted program and runs the program on each item in the list in turn. (Use it to write e.g. sum of list of ints, etc.)

     [] [P] step
  -----------------  Empty list, no-op.


     [X|Xs] [P] step
  -----------------------  Non-empty list, run P and recur.
     X P [Xs] [P] step

 In terms of branch and x:

   step == [F] x

 So:

   [L] [P] step
   ------------------
   [L] [P] [F] x
   ------------------
   [L] [P] [F] F

 First, get the flag value and roll< it to the top for a branch:

   F  == F′ F″
   F′ == [?] dipd roll<

   [L] [P] [F] F
   ---------------------------
   [L] [P] [F′ F″] F′ F″
   ---------------------------------------
   [L] [P] [F′ F″] [?] dipd roll< F″

 How that works out:

   [L]   [P] [F] [?] dipd roll< F″
   [L] ? [P] [F]          roll< F″
   [L] b [P] [F]          roll< F″
   [L]   [P] [F] b              F″

 Now we can write a branch:

   F″ == [Ff] [Ft] branch

   [L] [P] [F] b F″
   ------------------------------------
   [L] [P] [F] b [Ff] [Ft] branch

 The false case is easy:

   Ff == pop popop

   ... [] [P] [F] Ff
   ... [] [P] [F] pop popop
   ... [] [P]         popop
   ... 


 The true case is a little more fun:

   ... [X|Xs] [P] [F] Ft

 We need to uncons that first term, run a copy of P, and recur (recurse?
 I think re-curse means to "curse again" so it must be "recur".)

   Ft == Ft′ Ft″
   Ft′ == [uncons] dipd

   ... [X|Xs]        [P] [F] [uncons] dipd Ft″
   ... [X|Xs] uncons [P] [F]               Ft″
   ... X [Xs]        [P] [F]               Ft″

 So now we run a copy of P:

   ... X [Xs] [P] [F] Ft″

   Ft″ == [dup dipd] dip Ft‴

   ... X   [Xs] [P]          [F] Ft″
   ... X   [Xs] [P]          [F] [dup dipd] dip Ft‴
   ... X   [Xs] [P] dup dipd [F] Ft‴
   ... X   [Xs] [P] [P] dipd [F] Ft‴
   ... X P [Xs] [P]          [F] Ft‴

 And now all that remains is to recur on F:

   Ft‴ == x

   ... X P [Xs] [P] [F] x


 Collecting the definitions, we have:

   step == [F] x
     F  == F′ [Ff] [Ft] branch
     F′ == [?] dipd roll<
     Ff == pop popop
     Ft == Ft′ Ft″ x
    Ft′ == [uncons] dipd
    Ft″ == [dup dipd] dip


If anybody interested the best book to learn the category theory: https://www.maths.ed.ac.uk/~v1ranick/papers/maclanecat.pdf


Mac Lane was one of the founders of category theory - see for example:

"General Theory of Natural Equivalences" - Samuel Eilenberg and Saunders MacLane. Transactions of the American Mathematical Society, Vol. 58, No. 2, (Sep., 1945), pp. 231-294

His "Categorical algebra" paper from 1964 is open-access:

https://projecteuclid.org/euclid.bams/1183526392

When his book came out it was the standard work for a while. I think some of the terminology he uses is no longer standard, and there are now many very good modern introductions. But his book is still a pretty good read, primarily because he was a wonderful writer with a very distinctive style.

That said, the examples (given the time the book was written) are almost exclusively mathematical. The proofs and exercises are usually not difficult, but at a high level of abstraction (not surprisingly).


This book is intended for a "working mathematician." Also, the subject has progressed since the book was written.


For anyone else interested, Tom Leinster (also of Edinburgh Uni) has also written a good short book for beginners:

https://www.maths.ed.ac.uk/~tl/bct/

I did his course at uni that used this book as a basis and it was great. Tough, but great.


Why do you think this is the best book? And would someone's background, or lack thereof, in other fields of mathematics not have a bearing on that assessment?


Cause that's it's reputation in math circles. And recommended by most of my teachers. Also because I used it a lot. You don't need to read it top to bottom. I think people here are interested by monoid and stuff. But to do the monoid part you don't really need category. An Algebra course about monoid is good enough actually.


If someone lacks interest in math I’m not sure category theory makes sense even in the FOMO way.


To someone who is not interested in math per se but rather in its applications to engineering, category theory, too, has something to offer.


As an aside, I love the look and feel of this document. It is a beautiful read.


Just a nice set of ideas to be used for social signalling.

In with type systems, a typeclass is all you need. The mantra is "to be an X (being substituted for an X) is to be able to perform (implement) such and such actions (or have this or that biochemical properties).

It is that general, that deep, it could be even seen in molecular biology.

Category theory, on the other hand, is just a few nested abstract concepts, of which only monoid has some connection to reality, which ends up empty, like most abstract pseudo- philosophical bullshit.

And yes, I have watched and read everything by Bartosz. It is empty.


There are a lot of claims made to try to apply CT to programming; I agree most of that effort is overhyped.

But CT in general has nothing to do with programming, it's proper role is in pure mathematics


Every type theory gives a categorical logic [0]. Category theory is all about describing the structures which definitely exist around mathematical objects even if we don't acknowledge them very often. This isn't social signalling; I'm not posting under my real name and I'm not trying to get accolades. This is mathematics; we teach it to each other.

[0] https://mikeshulman.github.io/catlog/catlog.pdf


I would claim that such structures are imaginary, not structures at all, and the whole field is a sect (a socially constructed movement based on sectarian consensus which regards "knowledge" of details of abstractions, which does not make any sense outside of sectarian contexts).

Let's talk the most basic algebraic laws. Yes, there is indeed no difference in adding 2 apples to 3 apples, or adding 3 of them to 2. The question is from which pile to start, and the result is the same. (Multiplication, being just repeated addition, is also obvious - there is really no difference which side of a rectangle comes first).

Notice, that there is still a fundamental connection to reality. Adding C to O has exactly the same properties. There is no difference which comes first.

The identity element is more tricky, because nothing of this sort existed in nature. Nature has distinct start and stop sequence, and does structural pattern matching in the literal sense.

So, we would superimpose an element upon reality which lacks it, the same way as it goes with zero. Let's say, that trying to add what's can't be added (by physical properties) produces no change to the original element, and it is equivalent to addition of a zero.

Generalising this noop we will get something similar to identify.

1 for multiplication, is natural , while an identify matrix is an artificial construction.

Okay, this is all common sense. The important thing that there is literally nothing deeper than this shaky generalisation which we call monoid. First, because only addition and multiplication are "true monoid".

Protein production by an enzyme is almost it, but no identity.

There is no identities outside your head. A list is a monoid because of added '() - the empty list, which, again, does not exist anywhere. There is no such thing as an empty DNA sequence, empty molecule, etc.

I could go on, but maybe you already see where it goes. Everything is imaginary and too abstract to have any applicable, meaningful context.


This sounds facetious. After all, the humble empty set is not physical either, and yet most set theorists will claim that it is Platonically real.

More generally, mathematics is a social construction, yes. The word literally means "things we teach each other", and the defining quality of mathematical facts is that they are non-obvious but can be verified for oneself without any additional help or context.

Denying the usefulness of category theory will only make theoretical physics harder. It doesn't make physics any simpler.

Edit: I was going to just link you to the Encyclopedia of Philosophy, but I'll spell out the definitions explicitly instead.

A formal logic is a system with some propositions and some deductive rules. Each rule takes a (family of) propositions and sends them to new propositions, changing their syntax but not their truth. Rules may be composed associatively, and for each proposition, there is a trivial identity rule which changes nothing.

This is a category, right? So every formal logic has a corresponding category whose objects represent its propositions and whose arrows represent its rules.


If you have to appeal to Platonism to make the "realness" of a concept less controversial, your claim will not be strong, as Platonism itself is controversial, and by definition supposes the existence of things which cannot be perceived. This makes it more difficult to argue for the realness of a concept, not less, since any means of "observing" the existence of that concept must be indirect to a Platonist.

It is also inconsistent to claim that mathematics is a social construction, while agreeing with these Platonic mathematicians enough to use their view as evidence.


Okay, but like, every logic has a corresponding category, right? Please focus on the maths and stop struggling; you're only making things harder for yourself.


That doesn't contradict the previous notion that category theory is "empty" or adds nothing to the original understanding of the logic. At best, you've just changed how you describe precisely the same elements of the system. And once you start using categories to talk about categories you lose concrete referents entirely, describing description.

If the point was modelling linguistic syllogisms, or accounting for the stock of apples in your warehouse, why bother? These tasks are better served by analyzing the objects in question, rather than you, the describer.

> Please focus on the maths and stop struggling; you're only making things harder for yourself.

This is condescending – I could say the same thing and ask you to "stop struggling with philosophy". But neither of us should.


There is nothing wrong with abstract thinking. It is indeed useful. It is, in fact, one of the things that separate the higher animal species like humans from the rest.


This is the social signalling I am talking about.


Hi Karma.


This is the first time someone recognised me. By writing style, I suppose.


I've read a lot of your work and appreciate it. I don't agree with all of it. But all of it is good.

And indeed you have a distinct style.


(2018)




Applications are open for YC Summer 2021

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: