Category Theory
Table of Contents
- 1. Category Theory
- 1.1. Introductory
- 1.1.1. A Sensible Introduction to Category Theory
- 1.1.2. What is Category Theory?
- 1.1.3. hmemcpy/milewski-ctfp-pdf: Bartosz Milewski’s ’Category Theory for Programmers’ unofficial PDF and LaTeX source
- 1.1.4. Catalog of Books about Category Theory? : CategoryTheory
- 1.1.5. [1803.05316] Seven Sketches in Compositionality: An Invitation to Applied Category Theory
- 1.1.6. [1912.10642] Notes on Category Theory with examples from basic mathematics
- 1.1.7. Monoid
- 1.1.8. Category Theory: The Beginner’s Introduction (Lesson 1 Video 1) - YouTube
- 1.1.9. https://github.com/BartoszMilewski/Publications
- 1.1.10. CTWTB (Category Theory Without The Baggage)
- 1.1.11. Category Theory Illustrated - index
- 1.2. Learn category theory learn
- 1.3. Category theory apply to everything
- 1.4. Applied Category Theory
- 1.5. Symmetric Monoidal Categories
- 1.6. Resources
- 1.7. From design patterns to category theory
- 1.8. Teaching optics through conspiracy theories | Bartosz Milewski’s Programming Cafe
- 1.9. APPLIED CATEGORY THEORY
- 1.10. A categorical view of computational effects - Emily Riehl
- 1.11. Category Theory for Programmers: The Preface | Bartosz Milewski’s Programming Cafe
- 1.12. David Spivak lectures
- 1.13. Ordering and graphs
- 1.14. Examples of Functors
- 1.15. Examples of Monoids and Groups
- 1.16. Examples of Monads
- 1.17. Anamorphism and Catamorphism
- 1.18. Derivadas, árboles, negativos y fraccionales de tipos
- 1.19. Thin Category
- 1.20. Random
- 1.21. Categorical databases (Spivak on Category Theory and Databases)
- 1.22. Spivak
- 1.23. https://bartoszmilewski.com/2014/12/23/kleisli-categories/
- 1.24. John Baez
- 1.25. Bob Coecke → Categorical Quantum Mechanics
- 1.26. Notes on Category Theory with examples from basic mathematics
- 1.27. Category theory and Geometric Machine Learning
- 1.28. Links with complexity science ?
- 1.1. Introductory
1. Category Theory
http://www.cs.nott.ac.uk/~pszgmh/cat.html
Category Theory for Computing Science
27 Unhelpful Facts About Category Theory
Category theory | Everything I know
1.1. Introductory
1.1.2. What is Category Theory?
1.1.5. [1803.05316] Seven Sketches in Compositionality: An Invitation to Applied Category Theory
Practical examples across several areas
1.1.10. CTWTB (Category Theory Without The Baggage)
1.2. Learn category theory learn
1.3. Category theory apply to everything
1.3.1. Why I am learning category theory | the scapegoat dev
As described in the previous paragraph, I build software by drawing boxes and arrows first and refining them until I can encode them as software.
This structural approach encompasses much more than just code and data structures. I apply it to:
- product thinking
- communication structures
- schema design and evolution (database design, data schema evolution)
- logging and debugging (events, logging schema)
- runtime behavior (event loops, state machines, sequence diagrams)
- module and codebase decoupling
- software engineering workflow (git workflow, issues, and project management)
1.4. Applied Category Theory
https://arxiv.org/pdf/1609.05382.pdf
Table 6.1: Analogies between variables in various physical settings
(Es como lo que vi en termodinámica del no equilibrio)
También habla de sistemas abiertos vs sistemas cerrados
1.5. Symmetric Monoidal Categories
1.6. Resources
1.11. Category Theory for Programmers: The Preface | Bartosz Milewski’s Programming Cafe
1.11.1. Category Theory - YouTube
1.11.2. Category Theory II - YouTube
1.11.3. Category Theory III - YouTube
1.12. David Spivak lectures
1.13. Ordering and graphs
Order | Graph |
Preorder | Direct cyclic graph |
Partial order | Direct acyclyc graph |
Total order | Sequence |
- Preorder
- reflexive (\[a \le a \forall a \in P\]), transitive (\[\text{if } a \le b \text{ and } b \le c \text{ then } a \le \forall a,b,c \in P \])
an antisymmetric preorder is a partial order, and a symmetric preorder is an equivalence relation - Partial order
- reflexive, transitive, and antisymmetric (\[\text{ if } a \le b \text{ and } b \le a \text { then } a = b\])
No two distinct elements precede each other. Some pairs are incomparable, with neither being greater/lesser
Lamport timestamps for example are partial orders - Total order
- reflexive, transitive, antisymmetric and strongly connected (\[a < b \text{ if not } a \ge b\])
- Strictness
- All definitions become strict if equality is not allowed
1.14. Examples of Functors
- Async/Lazy functor
- a → a | Promise/Future
- function composition becomes callbacks
- a → a | Promise/Future
- A Group representation
- The transpose operator on vector spaces, the adjoint/hermitian transpose on Hilbert spaces
- The Laplace transform
- Every Homomorphism is a Functor
The Functor is an extension of the Homomorphism to many other structures that either do not have an underlying set, or are not algebraic (for examples partial order, or relationships of inclusion in a set) - Canonical (Legendre) transformations
Between Lagrangian and Hamiltonian - Functor, Applicative and Monad instances for Reader Full implementation
1.14.1. Examples of bifunctors
- Product and Coproduct (Sum)
- https://blog.ploeh.dk/2019/08/12/rose-tree-bifunctor/ (Tree)
https://en.wikipedia.org/wiki/Rose_tree
1.15. Examples of Monoids and Groups
- Free monoid - Wikipedia
The monoid whose elements are all the finite sequences (or strings) of zero or more elements from that set, with string concatenation as the monoid operation and with the unique sequence of zero elements
Free objects are the direct generalization to categories of the notion of basis in a vector space → a concrete programming language implementation (?) where composition is simply executing one function after another (~“line by line”?)
Docker for example considers each layer dependent on all the previous ones, instead of building a dependency tree
Concatenative programming language - Wikipedia - Trace monoid - Wikipedia
- History monoid - Wikipedia
- Dependency relation - Wikipedia
I think it all comes from this dependency relations.
Free monoid → your program is a string of characters, every character depends on anyone else, in principle. Dependency by default. Trace/history monoid → You have to explicitly define which operations are dependent on another ones. Independency by default - If you can undo your operations, then you got a group (transactions)
- The union of convex hulls form a monoid
- A function or method with a return type that forms a monoid is itself a monoid
1.16. Examples of Monads
- https://www.cs.cmu.edu/~crary/819-f09/Moggi91.pdf
- Partiality: Computations that may not terminate
- Nondeterminism: Computations that may return many results
- Side effects: Computations that access/modify state
- Read-only state, or the environment
- Write-only state, or a log
- Read/write state
- Read-only state, or the environment
- Exceptions: Partial functions that may fail
- Continuations: Ability to save state of the program and then restore it on demand
- Continuation - Wikipedia (coroutines / generators)
Continuations are useful for encoding other control mechanisms in programming languages such as exceptions, generators, coroutines, and so on. - On Recursion, Continuations and Trampolines - Eli Bendersky’s website
Continuation-passing style - Wikipedia
In functional programming, continuation-passing style (CPS) is a style of programming in which control is passed explicitly in the form of a continuation. This is contrasted with direct style, which is the usual style of programming.
A function written in continuation-passing style takes an extra argument: an explicit “continuation”; i.e., a function of one argument. When the CPS function has computed its result value, it “returns” it by calling the continuation function with this value as the argument. That means that when invoking a CPS function, the calling function is required to supply a procedure to be invoked with the subroutine’s “return” value
«Like callbacks»
- Continuation - Wikipedia (coroutines / generators)
- Interactive Input
- Interactive Output
- https://ncatlab.org/nlab/show/monad+%28in+computer+science%29
- Task Monad
1.16.1. Composition of monads
1.16.2. Free Monoid & Free Applicative
https://typelevel.org/cats/datatypes/freeapplicative.html
- An Intuitive Guide to Combining Free Monad & Free Applicative • Cameron Joannidis • YOW! 2018 - YouTube
Free monad is sequential composition, Free Aplicative is parallel composition
1.17. Anamorphism and Catamorphism
Producer-consumer problem
Catamorphism → fold (consumers)
Anamorphism → unfold (generators, producers)
https://thealmarty.com/2022/09/06/anamorphisms-aka-unfolds-explained/
https://bartoszmilewski.com/2022/04/05/teaching-optics-through-conspiracy-theories/
Producers and consumers correspond to covariant and contravariant functors
1.18. Derivadas, árboles, negativos y fraccionales de tipos
https://news.ycombinator.com/item?id=5196708
Derivadas → permite añadir un subárbol a un árbol existente
Árboles
Negativos y fraccionales
Un logaritmo es una llamada a una función? Tiene que estar en la misma base en la que está para que coincidan sus tipos
1.19. Thin Category
https://en.wikipedia.org/wiki/Posetal_category
a posetal category, or thin category is a category whose homsets each contain at most one morphism. As such, a posetal category amounts to a preordered class (or a preordered set, if its objects form a set).
1.20. Random
1.21. Categorical databases (Spivak on Category Theory and Databases)
1.23. https://bartoszmilewski.com/2014/12/23/kleisli-categories/
Composition of Logs is the Writer Monad
1.24. John Baez
- https://en.m.wikipedia.org/wiki/John_C._Baez
- John Baez in nLab
- John Baez’s Stuff
- John Baez - YouTube
- torsors relative quantities like energies, potential, gauges, phases…