Catlab.jl is the Julia library for applied category theory at the heart of the AlgebraicJulia ecosystem: generalized algebraic theories (GATs) via @theory, symbolic presentations via @present, finite sets and functions (FinSet, FinFunction), ACSets (@acset_type, @acset), limits and colimits, wiring diagrams, and graphics.
Sources: Kittenlab (which builds a toy version of Catlab step by step); AlgebraicJulia documentation.
Version note. All Julia code in this wiki was checked against Catlab v0.16.x (the API used by the current documentation and by Kittenlab). Catlab v0.17 moved to GATlab-style explicit models (meet[SubobjectElementWise()](U, V) instead of meet(U, V), etc.); most FinSet/FinFunction/ACSet code is unchanged, but lattice operations on subobjects and some theory-level calls differ.
Running the Julia tabs
using Pkg
Pkg.add(name = "Catlab", version = "0.16") # the version the snippets were run against
Pkg.add(url = "https://github.com/AlgebraicJulia/Kittenlab.jl") # optional: Kittenlab's own package
Pkg.add(name = "AlgebraicRewriting", version = "0.4") # graph rewriting (Double-Pushout Rewriting note)Every Julia tab in the vault begins with a Docs: line pointing at the relevant section of the Catlab v0.16 documentation (e.g. FinSets, Limits, CSets, data migration, graphs, wiring diagrams), the GATlab standard library (theories such as ThCategory), the ACSets.jl API, the Catlab vignettes that follow 7 Sketches, or the Kittenlab lectures. Notes whose code is plain Julia say so. The current Catlab release (v0.17+) is documented at the stable docs; for most FinSet/ACSet code the v0.16 pages still describe the same functions.
Snippets are self-contained unless a Builds on: line says otherwise. The Kittenlab-style mini-library is spread over a few notes, and the chains are:
- Category → Functor (via Prop of Matrices) → Natural Transformation → Functor Category, Category of Categories
- Preorder → Bool (Monoidal Preorder), Cost, Natural Numbers → Monotone Map, Enriched Category → Matrix Multiplication in a Quantale, Lawvere Metric Space → Profunctor → Category of Profunctors, Collage
- Finite Set → Function → Function Composition, Isomorphism, Identity Function, Cardinality
Snippets that start with using Catlab shadow the mini-library’s Category, Functor, FinFunction, …, so run them in a fresh session (or module).
Kittenlab’s own mini-library (src/Categories.jl, FinSets.jl, Functors.jl, NaturalTransformations.jl, FinCats.jl, Diagrams.jl, Graphs.jl) is reproduced across Category, Functor, Natural Transformation, Presentation of a Category, Diagram and Graph; it takes a “middle path”: Julia types guide implementation and dispatch but are not relied on for correctness.
Where to look
| Concept | Catlab |
|---|---|
| Category | Catlab.Theories.ThCategory, FreeCategory |
| Preorder | ThPreorder, FreePreorder, ThThinCategory |
| Symmetric Monoidal Category | ThSymmetricMonoidalCategory, FreeSymmetricMonoidalCategory |
| Category of Finite Sets | FinSet, FinFunction, Catlab.CategoricalAlgebra.FinSets |
| Category of Relations | Catlab.CategoricalAlgebra.FinRelations |
| Presentation of a Category / Database Schema / schemas | @present, FreeSchema, FinCat |
| C-Set / Functor | @acset_type, @acset, FinDomFunctor |
| Natural Transformation / Graph Homomorphism | ACSetTransformation, homomorphism(s), isomorphisms, is_natural |
| Graph, Symmetric Graph | Graph, SymmetricGraph, path_graph, cycle_graph |
| Monoid Action, Finite State Machine, Discrete Dynamical System | ACSets on a one-object schema (@acset_type) |
| Limit, Colimit, Pushout, Pullback | limit, colimit, pushout, pullback, coequalizer |
| Data migration | DeltaMigration, SigmaMigration, migrate |
| Cospan, Decorated Cospan, Structured Cospan | Cospan, StructuredCospan, OpenCSet |
| Hypergraph Category / UWDs | @relation, oapply, UndirectedWiringDiagram |
| Prop / Signal Flow Graph | ThBiproductCategory, @theory, Catlab.Programs |
| Operad | oapply (operad algebras), Catlab.WiringDiagrams |
| Subobject lattice | Subobject, meet, join, top, bottom |