News for hackers. Stuff that matters.
Re:Applied Category Theory in Chemistry, Computing, and Soci... by whatshisface on Tuesday November 01, 2022 @12:46PM (#33423709)
Is it just me, or does "applied category theory" never use anything from category theory other than boxes being connected by arrows?
Re:Applied Category Theory in Chemistry, Computing, and Soci... by larve on Tuesday November 01, 2022 @01:39PM (#33424553)
Arrows and boxes is pretty much what category theory is about. You have objects connected by morphisms, and all further structure and concepts are derived from that.
Re:Applied Category Theory in Chemistry, Computing, and Soci... by whatshisface on Tuesday November 01, 2022 @01:39PM (#33424565)
Yeah, but you can only be said to be applying category theory if you use some of those structures or concepts.
Re:Applied Category Theory in Chemistry, Computing, and Soci... by larve on Tuesday November 01, 2022 @01:53PM (#33424774)
I am asking myself that question regularly, as I'm trying to get more comfortable with "real" category theory. My background is programming, and I've become familiar with a lot of the applied CT (functors, monads, monoids, applicatives, ...).

I think the point of category theory, especially applied category theory, is recognizing what can be further abstracted as an arrow and an object. This turns something that originally is complex and has no apparent structure into a simple dot and arrow, again. Then rinse and repeat.

For example, you can take a for loop that applies a function to a list and then creates a new list. You can't "easily" add another for loop that then applies a second transformation. But if you recognize the functor from the category of types to the category of types, then you can formulate your 2 composed for loops as `list.map(f1 | f2)`, and everything is "trivial" arrows and objects again.

Turn that into a function that returns a list, and you want to concatenate the result. "Annoying" to write, you have to flatten your list. Recognize the monad, back to a simple composition of two morphisms, even though the morphisms encapsulate a lot.

Learning and applying CT I think is recognizing which things can be conceptualized as a morphism, which then magically makes things appear "simple." Yet it is only simple if you have done that recognition work, and more advanced concepts in CT are there to assist you.

Re:Applied Category Theory in Chemistry, Computing, and Soci... by davidgay on Tuesday November 01, 2022 @11:14PM (#33431049)
> For example, you can take a for loop that applies a function to a list and then creates a new list. You can't "easily" add another for loop that then applies a second transformation.

This is quite unconvincing.

Easy solution 1: add a second loop which takes the first loop's output and transforms it with f2.

Easy solution 2: realise you are doing one transform after another and replace out.add(f1(x)) with out.add(f2(f1(x)).

Re:Applied Category Theory in Chemistry, Computing, and Soci... by larve on Wednesday November 02, 2022 @06:09AM (#33433513)
How to derive solutions like solution 2 is what category theory helps me with.

It sounds glaringly obvious in the cases where the abstraction is well understood Mapping on lists, on trees, on Maybe, on Result are all well known at this point, because most APIs offer it. Less obvious is the fact that this applies to say, a serial interface, sensor readings, futures.

If you can then express the concept of a functor in the programming language itself, you can start writing code that only relies on the fact that something is a functor. And then pass it a list, a serial interface, futures, futures of serial interfaces, etc…

For example, you could potentially find use in expressing your above code as:

out = makeMapped(out, [f1, f2])

Now I can just pile 18 more functions defined in a config file without having to write it out.

out = makeMapped(out, configFile.createFunctions())

I’m not saying you need category theory for this, the same way you don’t need algebra every time you add two numbers, but it makes it easier to see these patterns.

I have trouble finding good “practical” examples, because you can use either functors, that every experienced programmer already knows intuitively so well that the concept is ingrained. If you bring up monads, people often react viscerally.

In practice, I often just take the time to write out monads without even mentioning the word or concept, and refactor code so that it leverages that underlying structure, and that usually makes things become apparent. Monads are a really good structure to cut down on absurd complexity for anything dealing with state and concurrency, and turn it into an elegant problem.sequence(step1, step2, step3, step4) formulation.

Re:Applied Category Theory in Chemistry, Computing, and Soci... by anonymousDan on Tuesday November 01, 2022 @07:04PM (#33428986)
How does that differ from plain graph theory (sorry if a naive question)?
Re:Applied Category Theory in Chemistry, Computing, and Soci... by larve on Tuesday November 01, 2022 @07:39PM (#33429365)
I think it’s not a naive question at all. To my naive understanding, categories need to have a composition property (if there is a morphism from a to b, and b to c, then there is a morphism a to c created by composing a to b and b to c), which allows to express “richer” structures than just directed graphs. Now, for the gory details, you better ask a mathematician :]
Re:Applied Category Theory in Chemistry, Computing, and Soci... by Koshkin on Tuesday November 01, 2022 @07:45PM (#33429441)
They are incorrect. While diagrams are indeed (a part of) the language of Category Theory, the theory is certainly not about the language.
Re:Applied Category Theory in Chemistry, Computing, and Soci... by mdm12 on Tuesday November 01, 2022 @07:47PM (#33429464)
Not a dumb question at all!

The short answer is that a category also satisfies two rules: every object has an arrow to itself (identity) and if there are two arrows (a->b) and (b->c) there is an arrow (a->c) (associativity).

Other abstractions such as functors (mappings between categories) are built upon this relatively simple foundation. You can also think about categories of categories (they can be considered an object, after all!), and so on and so forth.

Some complain about the generality of Category Theory ('It is a theory about everything and nothing!'), but its generality makes it compelling for some for study.

Re:Applied Category Theory in Chemistry, Computing, and Soci... by jmt_ on Tuesday November 01, 2022 @01:29PM (#33424391)
I can see why you're saying that, but the use of commutative diagrams communicate the structure between the functions and objects of interest - it is this perspective which is core idea to category theory. So I'd argue that the diagrams are a result of communicating a category-theoretic model rather than the end-result itself, and therefore have much deeper meaning than just "boxes being connected by arrows".
Re:Applied Category Theory in Chemistry, Computing, and Soci... by moralestapia on Tuesday November 01, 2022 @02:11PM (#33425054)
>other than boxes being connected by arrows

Well, that's because that's basically it, lol.

But I get your sentiment and, sure, there's a lot of things where this could be applied and that hasn't happened already. It's definitely a field with a prolific future, though. I've personally applied many ideas I got from there into my smallish ventures with good results.

Re:Applied Category Theory in Chemistry, Computing, and Soci... by whatshisface on Tuesday November 01, 2022 @02:18PM (#33425160)
But that's not "basically it," there are lots of high-flying theorems that make it an entire area of mathematics.
Re:Applied Category Theory in Chemistry, Computing, and Soci... by moralestapia on Tuesday November 01, 2022 @02:22PM (#33425240)
Well, then I have no idea why you asked your previous question. ¯\_(ツ)_/¯
Re:Applied Category Theory in Chemistry, Computing, and Soci... by whatshisface on Tuesday November 01, 2022 @02:23PM (#33425261)
Because applied category theory stops at translating everything into boxes and arrows. There's no "applied Yoneda lemma."
Re:Applied Category Theory in Chemistry, Computing, and Soci... by lgdw on Tuesday November 01, 2022 @03:37PM (#33426347)
It's the actual process of translating everything into boxes and arrows that's the core of ACT.
Re:Applied Category Theory in Chemistry, Computing, and Soci... by larve on Tuesday November 01, 2022 @04:09PM (#33426782)
I'm not sure that's true. This is a surface / introductory article, but if you go deeper into say, categorical databases, modeling of attacks (https://arxiv.org/pdf/2103.00044.pdf), there sure is some wilder CT at work. I'm leaving out programming as applied category theory because there is no shortage of refined concepts there (type theory, all the haskell libraries, many things I don't even comprehend).

But to me, the value in ACT is actually learning how "simple" some of the other fields could be, because it allows me to communicate with non-software engineers, and actually have them contribute to software.

I did a lot of work with state machines as composable abstractions for concurrency and flow control, and mechanical engineers were able to find some really subtle say, race conditions, just by pointing out "hey, isn't there an arrow from this to this, if the limit switch catches early?"

Re:Applied Category Theory in Chemistry, Computing, and Soci... by vladf on Tuesday November 01, 2022 @04:25PM (#33426999)
lol, you picked the one thing category theory actually has examples of not being abstract nonsense for

https://mathoverflow.net/questions/12511/what-is-yonedas-lem...

Re:Applied Category Theory in Chemistry, Computing, and Soci... by hackandthink on Tuesday November 01, 2022 @05:42PM (#33427949)
In computing you can apply Yoneda for optimizations.

"Each of the steps is fairly compelling, except perhaps the second one, which rests on the Yoneda Lemma"

see "Kan Extensions for Program Optimisation"

https://www.cs.ox.ac.uk/ralf.hinze/Kan.pdf

Re:Applied Category Theory in Chemistry, Computing, and Soci... by dqpb on Tuesday November 01, 2022 @03:51PM (#33426528)
So, if I already model systems via boxes and arrows, and use things like petri nets, then am I good, or do I still need to learn category theory?
Re:Applied Category Theory in Chemistry, Computing, and Soci... by larve on Tuesday November 01, 2022 @07:46PM (#33429450)
If that works for you, that’s of course perfect. I find that the study of CT pretty has very much clarified that a lot of diagrams I see in other domains (business processes, supply chain modelling) directly relate to my understand of diagrams.

I think it is a property of human cognition that if we draw an arrow from a to b, and one from b to c, that there is some kind of relation between a to c as well.

What this means concretely is that if I can draw my problem, in my domain, as a diagram with boxes and arrows, there is a reasonable chance that you can actually understand it, and actually contribute to it. Similarly, seeing diagrams from your problem domain is often sometimes I can relate to my design patterns and software architecture foundations, and I might be able to ask quite pointed questions when trying to say, build a mathematical model or build some supply chain software. Questions like “ok, but, is there an arrow from here to here?” and the answer “oh yes, that happens when we actually replenish the inventory by doing X, I forgot about that part”.

Another thing I found people do with CT is that they use it as a toolbox of abstractions that they can try to fit to a problem. Say, “oh, is there maybe a functor from petri nets to databases? ok, there is, but it’s kind of useless. Does this formulation actually work as a monad?” This is useful for finding elegant APIs to problems, say things like optics (lenses, etc…).

Re:Applied Category Theory in Chemistry, Computing, and Soci... by agumonkey on Sunday November 06, 2022 @03:02PM (#33496451)
I never ran into petri net in jobs, I always thought they were still stuck at educational use. Do you get good results using them ?
Re:Applied Category Theory in Chemistry, Computing, and Soci... by YetAnotherNick on Tuesday November 01, 2022 @04:26PM (#33427012)
Well, not exactly. Things till functions and functor are part of almost every big enough theory like set theory or even just natural numbers and used everywhere, and if arrows are only used for describing that, I wouldn't say it is application of category theory.

Only point of category theory starts when you go higher than that and deal with more abstract and generalizable things e.g monads(which again is used in other theories), bigger infinities, ordering of infinities etc.

Re:Applied Category Theory in Chemistry, Computing, and Soci... by abelaer on Tuesday November 01, 2022 @05:48PM (#33428031)
If you’re talking about string diagrams, then these are actually just 2D notation for very precise category theory. Manipulating the diagrams is equivalent to proving things in the category, provided you’ve shown soundness and completeness.