Standard library of theories

Through the module Catlab.Theories, Catlab provides a standard library of generalized algebraic theories for categories, monoidal categories, and other categorical structures. The theories correspond, in most cases, to standard definitions in category theory and they are used throughout Catlab and the AlgebraicJulia ecosystem to structure programs and provide a common interface for applied category theory. The module also provides default syntax systems for many of the theories.

Categorical structures for which theories are provided include:

  • categories
  • monoidal and symmetric monoidal categories
  • cartesian and cocartesian categories
  • semiadditive categories/biproduct categories
  • hypergraph categories
  • bicategories of relations
  • categories with two monoidal products, such as distributive monoidal categories

The contents of this module can be supplemented by the user, and it is even possible to use many parts of Catlab without using this module. The user is free to create new syntax systems for the theories defined here and also to define entirely new theories.


Catlab's standard library of generalized algebraic theories.

The focus is on categories and monoidal categories, but other related structures are also included.


Theory of additive categories

An additive category is a biproduct category enriched in abelian groups. Thus, it is a semiadditive category where the hom-monoids have negatives.


Theory of lattices as algebraic structures

This is one of two standard axiomatizations of a lattice, the other being Lattice. Because the partial order is not present, this theory is merely an algebraic theory (no dependent types).

The partial order is recovered as $A ≤ B$ iff $A ∧ B = A$ iff $A ∨ B = B$. This definition could be reintroduced into a generalized algebraic theory using an equality type Eq(lhs::El, rhs::El)::TYPE combined with term constructors `meet_leq(eq::Eq(A∧B, A))::(A ≤ B) and join_leq(eq::Eq(A∨B, B))::(A ≤ B). We do not employ that trick here because at that point it is more convenient to just start with the poset structure, as in Lattice.


Theory of bicategories of relations

TODO: The 2-morphisms are missing.


  • Carboni & Walters, 1987, "Cartesian bicategories I"
  • Walters, 2009, blog post, "Categorical algebras of relations",

Theory of cartesian closed categories, aka CCCs

A CCC is a cartesian category with internal homs (aka, exponential objects).

FIXME: This theory should also extend ClosedMonoidalCategory, but multiple inheritance is not yet supported.


Theory of categories (with no extra structure)

Warning: We compose functions from left to right, i.e., if f:A→B and g:B→C then compose(f,g):A→C. Under this convention function are applied on the right, e.g., if a∈A then af∈B.

We retain the usual meaning of the symbol ∘ (\circ), i.e., g∘f = compose(f,g). This usage is too entrenched to overturn, inconvenient though it may be. We use symbol ⋅ (\cdot) for diagrammatic composition: f⋅g = compose(f,g).


Theory of a category with (finite) products

Finite products are presented in biased style, via the nullary case (terminal objects) and the binary case (binary products). The equational axioms are standard, especially in type theory (Lambek & Scott, 1986, Section 0.5 or Section I.3). Strictly speaking, this theory is not of a "category with finite products" (a category in which finite products exist) but of a "category with chosen finite products".

For a monoidal category axiomatization, see CartesianCategory.


Theory of a (finitely) complete category

Finite limits are presented in biased style, via finite products and equalizers. The equational axioms for equalizers are obscure, but can found in (Lambek & Scott, 1986, Section 0.5), which follow "Burroni's pioneering ideas". Strictly speaking, this theory is not of a "finitely complete category" (a category in which finite limits exist) but of a "category with chosen finite limits".


Theory of dagger compact categories

In a dagger compact category, there are two kinds of adjoints of a morphism f::Hom(A,B), the adjoint mate mate(f)::Hom(dual(B),dual(A)) and the dagger adjoint dagger(f)::Hom(B,A). In the category of Hilbert spaces, these are respectively the Banach space adjoint and the Hilbert space adjoint (Reed-Simon, Vol I, Sec VI.2). In Julia, they would correspond to transpose and adjoint in the official LinearAlegbra module. For the general relationship between mates and daggers, see Selinger's survey of graphical languages for monoidal categories.

FIXME: This theory should also extend DaggerCategory, but multiple inheritance is not yet supported.


Theory of a displayed category.

More precisely, this is the theory of a base category $C$ (Ob,Hom) and a displayed category (El,Act) over $C$. Displayed categories axiomatize lax functors $C → **Span**$ or equivalently objects in $**Cat**/C$ in a pleasant, generalized algebraic style.

Reference: Ahrens & Lumsdaine 2019, "Displayed categories", Definition 3.1.


Theory of a distributive bicategory of relations


  • Carboni & Walters, 1987, "Cartesian bicategories I", Remark 3.7 (mention in passing only)
  • Patterson, 2017, "Knowledge representation in bicategories of relations", Section 9.2

FIXME: Should also inherit BicategoryOfRelations, but multiple inheritance is not yet supported.


Theory of a distributive (symmetric) monoidal category

Reference: Jay, 1992, LFCS tech report LFCS-92-205, "Tail recursion through universal invariants", Section 3.2

FIXME: Should also inherit CocartesianCategory.


Theory of a distributive semiadditive category

This terminology is not standard but the concept occurs frequently. A distributive semiadditive category is a semiadditive category (or biproduct) category, written additively, with a tensor product that distributes over the biproduct.

FIXME: Should also inherit SemiadditiveCategory


Theory of hypergraph categories

Hypergraph categories are also known as "well-supported compact closed categories" and "spidered/dungeon categories", among other things.

FIXME: Should also inherit ClosedMonoidalCategory and DaggerCategory, but multiple inheritance is not yet supported.


Theory of lattices as posets

A (bounded) lattice is a poset with all finite meets and joins. Viewed as a thin category, this means that the category has all finite products and coproducts, hence the names for the inequality constructors in the theory. Compare with CartesianCategory and CocartesianCategory.

This is one of two standard axiomatizations of a lattice, the other being AlgebraicLattice.


Theory of monoidal categories

To avoid associators and unitors, we assume the monoidal category is strict. By the coherence theorem there is no loss of generality, but we may add a theory for weak monoidal categories later.


Theory of monoidal categories with bidiagonals

The terminology is nonstandard (is there any standard terminology?) but is supposed to mean a monoidal category with coherent diagonals and codiagonals. Unlike in a biproduct category, the naturality axioms need not be satisfied.


Theory of monoidal categories with codiagonals

A monoidal category with codiagonals is a symmetric monoidal category equipped with coherent collections of merging and creating morphisms (monoids). Unlike in a cocartesian category, the naturality axioms need not be satisfied.

For references, see MonoidalCategoryWithDiagonals.


Theory of monoidal categories with diagonals

A monoidal category with diagonals is a symmetric monoidal category equipped with coherent operations of copying and deleting, also known as a supply of commutative comonoids. Unlike in a cartesian category, the naturality axioms need not be satisfied.


  • Fong & Spivak, 2019, "Supplying bells and whistles in symmetric monoidal categories" (arxiv:1908.02633)
  • Selinger, 2010, "A survey of graphical languages for monoidal categories", Section 6.6: "Cartesian center"
  • Selinger, 1999, "Categorical structure of asynchrony"

Theory of monoidal double categories

To avoid associators and unitors, we assume the monoidal double category is strict in both the horizontal and vertical directions. Apart from assuming strictness, this theory follows the definition of a monoidal double category in (Shulman, 2010, Constructing symmetric monoidal bicategories) and other recent papers, starting from an internal category $(S,T: D₁ ⇉ D₀, U: D₀ → D₁, *: D₁ ×_{D₀} D₁ → D₁)$ in Cat where

  • the objects of $D₀$ are objects
  • the morphisms of $D₀$ are vertical 1-cells
  • the objects of $D₁$ are horizontal 1-cells
  • the morphisms of $D₁$ are 2-cells.

The top and bottom of a 2-cell are given by domain and codomain in $D₁$ and the left and right are given by the functors $S,T$. In a monoidal double category, $D₀$ and $D₁$ are each required to be monoidal categories, subject to further axioms such as $S$ and $T$ being strict monoidal functors.

Despite the apparent asymmetry in this setup, the definition of a monoidal double category unpacks to be nearly symmetric with respect to horizontal and vertical, except that the monoidal unit $I$ of $D₀$ induces the monoidal unit of $D₁$ as $U(I)$, which I think has no analogue in the vertical direction.


Theory of preorders

The generalized algebraic theory of preorders encodes inequalities $A≤B$ as dependent types `$Leq(A,B)$ and the axioms of reflexivity and transitivity as term constructors.


Theory of a rig category, also known as a bimonoidal category

Rig categories are the most general in the hierarchy of distributive monoidal structures.

TODO: Do we also want the distributivty and absorption isomorphisms? Usually we ignore coherence isomorphisms such as associators and unitors.

FIXME: This theory should also inherit MonoidalCategory, but multiple inheritance is not supported.


The GAT that parameterizes Attributed C-sets A schema is comprised of a category C, a discrete category D, and a profunctor Attr : C^op x D → Set. In GAT form, this is given by extending the theory of categories with two extra types, AttrType for objects of D, and Attr, for elements of the sets given by the profunctor.


Theory of a symmetric monoidal copresheaf

The name is not standard but refers to a lax symmetric monoidal functor into Set. This can be interpreted as an action of a symmetric monoidal category, just as a copresheaf (set-valued functor) is an action of a category. The theory is simpler than that of a general lax monoidal functor because (1) the domain is a strict monoidal category and (2) the codomain is fixed to the cartesian monoidal category Set.

FIXME: This theory should also extend Copresheaf but multiple inheritance is not yet supported.


Theory of thin categories

Thin categories have at most one morphism between any two objects and are isomorphic to preorders.


Collect generators of object in monoidal category as a vector.


Number of "dimensions" of object in monoidal category.