cats-for-ai
npx skills add https://github.com/plurigrid/asi --skill cats-for-ai
Agent 安装分布
Skill 文档
cats.for” (Categories for AI)
“Category theory is compositionality made formal” â Bruno GavranoviÄ, cats.for.ai
URL: https://cats.for.ai Trit: 0 (ERGODIC) Color: #26D826 (Green) Status: â Production Ready
Overview
cats.for.ai is the definitive lecture series connecting category theory to machine learning, organized by DeepMind, Qualcomm AI, and academic researchers.
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â cats.for.ai INTEGRATION â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â â
â POLY INACCESSIBLE WORLDS AS COLORS MAXIMAL â
â â
â âââââââââââââââââ âââââââââââââââââ âââââââââââââââââ â
â â Poly(y) â â Inaccessible â â Colors â â
â â Functors ââââââ¶â Worlds ââââââ¶â Maximal â â
â â (-1) â â (0) â â (+1) â â
â âââââââââââââââââ âââââââââââââââââ âââââââââââââââââ â
â â â â â
â â Optics/Lenses â Modal Semantics â GF(3) Coloring â
â â â â â
â ââââââââââââââââââââââââ´âââââââââââââââââââââââ â
â â â
â GF(3): (-1) + 0 + (+1) â¡ 0 â
â â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Organizing Committee
| Name | Affiliation | Role |
|---|---|---|
| Bruno GavranoviÄ | Strathclyde / CyberCat | Optics, Lenses, Backprop |
| Petar VeliÄkoviÄ | DeepMind / Cambridge | GNNs, Categories |
| Pim de Haan | Amsterdam / Qualcomm | Geometric DL, Equivariance |
| Andrew Dudzik | DeepMind | Monads, RNNs |
| João G. Araújo | Cohere / USP | LLMs, Semantics |
Guest Speakers
| Speaker | Topic | Trit |
|---|---|---|
| David Spivak | Poly, Dynamic Systems | 0 (ERGODIC) |
| Jules Hedges | Categorical Cybernetics | 0 (ERGODIC) |
| Tai-Danae Bradley | CT for LLMs | +1 (PLUS) |
| Taco Cohen | Causal Abstraction | -1 (MINUS) |
| Pietro Vertechi | Parametric Spans | 0 (ERGODIC) |
| Thomas Gebhart | Sheaves for AI | -1 (MINUS) |
Lecture Program
Part 1: Introductory Lectures (Completed)
| Week | Topic | Speaker | Key Concepts |
|---|---|---|---|
| 1 | Why Category Theory? | GavranoviÄ | Compositionality, Modularity |
| 2 | Categories & Functors | VeliÄkoviÄ | Objects, Morphisms, Functors |
| 3 | Optics & Lenses | GavranoviÄ | Bidirectional flow, Backprop |
| 4 | Geometric DL & Naturality | de Haan | Equivariance, Natural transformations |
| 5 | Monoids, Monads, LSTMs | Dudzik | Recurrence, State |
Part 2: Research Seminars (Ongoing)
| Date | Topic | Speaker |
|---|---|---|
| Nov 14 | Neural network layers as parametric spans | Vertechi |
| Nov 21 | Causal Model Abstraction | Cohen |
| Dec 12 | Category Theory Inspired by LLMs | Bradley |
| Mar 20 | Categorical Cybernetics | Hedges |
| Mar 27 | Dynamic organizational systems | Spivak |
| May 29 | Sheaves for AI | Gebhart |
Core Concepts
1. Polynomial Functors (Py)
-- Poly = polynomial functors on Set
-- y = representable functor Hom(1, -)
-- â = composition of polynomials
data Poly where
Poly :: { positions :: Type
, directions :: positions -> Type
} -> Poly
-- Key operations
(â) :: Poly -> Poly -> Poly -- parallel (tensor)
(â) :: Poly -> Poly -> Poly -- sequential (composition)
(+) :: Poly -> Poly -> Poly -- coproduct
2. Inaccessible Worlds (Modal Semantics)
-- Kripke frame with inaccessibility
record KripkeFrame : Setâ where
field
World : Set
_âº_ : World â World â Set -- accessibility
inaccessible : World â Set -- worlds with no predecessors
-- Modal operators
â¡ : (World â Prop) â (World â Prop) -- necessity
â¡ Ï w = â v â w ⺠v â Ï v
â : (World â Prop) â (World â Prop) -- possibility
â Ï w = â v â w ⺠v Ã Ï v
-- Inaccessible world: ¬âv. v ⺠w
isInaccessible : World â Prop
isInaccessible w = â v â ¬(v ⺠w)
3. Colors Maximal (GF(3) Saturation)
(ns cats4ai.colors
(:require [gay.core :as gay]))
(defn color-world [world-seed trit]
"Assign maximal color to world based on trit"
(let [hue (case trit
:MINUS (+ 180 (mod (* world-seed 37) 120)) ; cold
:ERGODIC (+ 60 (mod (* world-seed 41) 120)) ; neutral
:PLUS (mod (* world-seed 43) 60)) ; warm
saturation 1.0 ; MAXIMAL
lightness 0.5]
{:hue hue :sat saturation :lit lightness
:hex (gay/hsl->hex hue saturation lightness)}))
(defn worlds-palette [n]
"Generate n inaccessible worlds with maximal colors"
(for [i (range n)
:let [trit (case (mod i 3) 0 :ERGODIC 1 :PLUS 2 :MINUS)]]
{:world-id i
:accessible? false ; inaccessible
:color (color-world i trit)
:trit trit}))
Optics for Machine Learning
Lens = Backpropagation
-- A lens captures forward/backward pass
data Lens s t a b = Lens
{ view :: s -> a -- forward pass
, update :: s -> b -> t -- backward pass (gradient)
}
-- Backprop is lens composition
backprop :: Lens s t a b -> Lens a b c d -> Lens s t c d
backprop l1 l2 = Lens
{ view = view l2 . view l1
, update = \s d ->
let a = view l1 s
b = update l2 a d
in update l1 s b
}
-- Chain rule emerges from lens composition!
-- d(gâf)/dx = dg/df · df/dx
Para = Parametric Morphisms
-- Parametric morphism (neural network layer)
data Para p a b = Para
{ params :: p -- learnable parameters
, forward :: p -> a -> b -- parameterized forward
}
-- Para composition
(>>>) :: Para p a b -> Para q b c -> Para (p, q) a c
(Para p f) >>> (Para q g) = Para (p, q) (\(p,q) a -> g q (f p a))
Optic = Generalized Bidirectional
-- Optic generalizes lens, prism, traversal
type Optic p s t a b = p a b -> p s t
-- Specific optics for ML:
type Lens s t a b = Optic (Star ((->) s)) s t a b -- deterministic
type Prism s t a b = Optic (Costar (Either a)) s t a b -- optional
type Affine s t a b = Optic (Star Maybe) s t a b -- at most one
Integration Map
With Existing Skills
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â cats.for.ai SKILL INTEGRATION â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â â
â cats.for.ai â
â â â
â ââââ¶ open-games (Hedges) â
â â âââ Play/Coplay bidirectional â
â â â
â ââââ¶ catsharp (Spivak) â
â â âââ Cat# = Comod(P) equipment â
â â â
â ââââ¶ topos-catcolab (Patterson) â
â â âââ Double theories, ACSets â
â â â
â ââââ¶ cybernetic-open-game â
â â âââ Agent-O-Rama â Worldnet â STC â
â â â
â ââââ¶ elements-infinity-cats (Riehl-Verity) â
â â âââ â-cosmos model independence â
â â â
â ââââ¶ sheaf-laplacian-coordination (Gebhart) â
â â âââ Sheaf neural networks â
â â â
â ââââ¶ crdt (Automerge) â
â â âââ Join-semilattice merge â
â â â
â ââââ¶ derangement-crdt â
â âââ Colorable permutations â
â â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
GF(3) Triads
# Core cats.for.ai triads
optics-lenses (-1) â cats-for-ai (0) â backprop (+1) = 0 â
sheaves (-1) â cats-for-ai (0) â gnns (+1) = 0 â
cybernetics (-1) â cats-for-ai (0) â open-games (+1) = 0 â
poly-functors (-1) â cats-for-ai (0) â para-morphisms (+1) = 0 â
causal-abstraction (-1) â cats-for-ai (0) â llm-semantics (+1) = 0 â
Inaccessible Worlds Protocol
For each inaccessible world (no predecessor in accessibility relation):
class InaccessibleWorld:
"""A world with no accessible predecessors - epistemic ground truth"""
def __init__(self, seed: int, trit: int):
self.seed = seed
self.trit = trit # -1, 0, +1
self.color = self._maximal_color()
self.accessible_from = set() # empty = inaccessible
def _maximal_color(self) -> dict:
"""Assign maximally saturated color based on trit"""
hue_base = {-1: 240, 0: 120, 1: 0}[self.trit] # blue/green/red
hue = (hue_base + (self.seed * 37) % 60) % 360
return {"h": hue, "s": 1.0, "l": 0.5} # MAXIMAL saturation
def poly_action(self, p: "Poly") -> "InaccessibleWorld":
"""Apply polynomial functor action"""
new_seed = (self.seed * p.positions + sum(p.directions)) % (2**64)
new_trit = (self.trit + p.trit) % 3
return InaccessibleWorld(new_seed, new_trit)
YouTube Resources
All lectures available: YouTube Playlist
| Lecture | Views | Key Insight |
|---|---|---|
| Why Category Theory? | 24K+ | Compositionality = modularity |
| Optics and Lenses | 15K+ | Chain rule = lens composition |
| Categorical Cybernetics | 10K+ | Agency via parametrised optics |
| Sheaves for AI | 8K+ | Local-to-global inference |
Commands
# Watch lecture
just cats4ai-watch LECTURE_NUM
# Run optics demo
just cats4ai-optics-demo
# Generate inaccessible worlds
just cats4ai-worlds N
# Color palette
just cats4ai-colors --maximal
# Integration check
just cats4ai-integrate SKILL_NAME
Babashka Integration
#!/usr/bin/env bb
;; cats4ai.bb - Categories for AI utilities
(ns cats4ai
(:require [babashka.http-client :as http]
[cheshire.core :as json]))
(def LECTURES
[{:week 1 :title "Why Category Theory?" :speaker "GavranoviÄ" :trit 0}
{:week 2 :title "Categories & Functors" :speaker "VeliÄkoviÄ" :trit 0}
{:week 3 :title "Optics & Lenses" :speaker "GavranoviÄ" :trit -1}
{:week 4 :title "Geometric DL" :speaker "de Haan" :trit +1}
{:week 5 :title "Monads & LSTMs" :speaker "Dudzik" :trit 0}])
(defn gf3-conservation? [lectures]
(zero? (mod (reduce + (map :trit lectures)) 3)))
(defn inaccessible-world [seed]
{:seed seed
:trit (case (mod seed 3) 0 :ERGODIC 1 :PLUS 2 :MINUS)
:accessible-from #{}
:color {:h (mod (* seed 37) 360) :s 1.0 :l 0.5}})
(defn -main [& args]
(println "cats.for.ai - Categories for AI")
(println "GF(3) conserved?" (gf3-conservation? LECTURES))
(println "Inaccessible worlds:"
(map inaccessible-world (range 3))))
(when (= *file* (System/getProperty "babashka.file"))
(apply -main *command-line-args*))
References
Primary
- cats.for.ai – Official site
- YouTube Playlist
- Zulip Chat
Papers
- GavranoviÄ et al. “Categorical Foundations of Gradient-Based Learning” (2024)
- Hedges “Compositional Game Theory” (2016)
- Spivak “Poly: An abundant categorical setting” (2020)
- Bradley “Language Models as Semantic Functors” (2023)
- Gebhart “Sheaf Neural Networks” (2022)
Related Skills
open-games– Hedges’ compositional gamescatsharp– Spivak’s Cat# = Comod(P)topos-catcolab– Topos collaborative CTcybernetic-open-game– Cybernetic feedbacksheaf-laplacian-coordination– Gebhart sheavescrdt– Join-semilattice CRDTsderangement-crdt– Colorable derangements
Skill Name: cats-for-ai Type: Categorical Machine Learning Trit: 0 (ERGODIC) Poly: Inaccessible worlds as colors maximal GF(3): Conserved across all triads
SDF Interleaving
This skill connects to Software Design for Flexibility (Hanson & Sussman, 2021):
Primary Chapter: 10. Adventure Game Example
Concepts: autonomous agent, game, synthesis
GF(3) Balanced Triad
cats-for-ai (+) + SDF.Ch10 (+) + [balancer] (+) = 0
Skill Trit: 1 (PLUS – generation)
Secondary Chapters
- Ch7: Propagators
- Ch6: Layering
- Ch2: Domain-Specific Languages
Connection Pattern
Adventure games synthesize techniques. This skill integrates multiple patterns.