Double-categorical logic
in theory and practice

Second Virtual Workshop on Double Categories

Evan Patterson

Topos Institute

2024-10-29

Why double categories?

$$

% https://tex.stackexchange.com/a/269194

$$

My personal favorite answers:

  1. Double categories unify functional and relational thinking
    • Understand relations, spans, profunctors, etc via universal properties
  2. Double categories are the setting for open systems:
    • An open system is both an object and a morphism
    • Hence is a proarrow in a double category
  3. Double category theory is an organizing framework for categorical logic

This talk is mostly about (3).

For (1), see blog post: Why double categories? Part 1

Categorical logic

Originates with Lawvere’s functorial semantics of algebraic theories:

Logic Category theory
algebraic theory category 𝖳T with finite products
model of theory functor M:𝖳→𝖲𝖾𝗍M:T→Set preserving finite products
model homomorphism natural transformation M⇒NM⇒N

Lawvere (1963)

Categorical logic, the minimal setting

A minimalist account of relational databases:

Logic Category theory
schema small category 𝖢C
instance of schema functor X:𝖢→𝖲𝖾𝗍X:C→Set
morphism of instances natural transformation X⇒YX⇒Y

Already enough to produce notable capabilities, such as Spivak’s functorial data migration.

Spivak (2012)

Standard dictionary of categorical logic

Logic Category theory
theory 𝖳T category 𝖳T with extra structure
model of 𝖳T in 𝖲S structure-preserving functor M:𝖳→𝖲M:T→S
model morphism structure-preserving natural transformation M⇒NM⇒N


Categorical logic is two-dimensional:

  • Theories, models, and model morphisms form a 2-category
  • Such 2-categories are sometimes called “doctrines”
  • E.g., categories, monoidal categories, categories with finite products, … are objects of different doctrines

Another dictionary of categorical logic?

A sleight of hand in that story:

  • I replaced 𝖲𝖾𝗍Set with an arbitrary “semantics category” 𝖲S
  • That flexibility is useful, but 𝖲𝖾𝗍Set still plays a distinguished role


If we take this seriously, we might propose a different dictionary:

Logic Category theory
theory 𝖳T category 𝖳T with extra structure
model of 𝖳T structure-preserving module (copresheaf) over 𝖳T
model morphism structure-preserving module homomorphism

Categorical logics are double categories

Let us refine the dictionary of categorical logic:

  • interpretations of one theory in another are structure-preserving functors
  • models of a theory are structure-preserving modules (copresheaves)

But the latter are special kinds of bimodules or profunctors. So the two concepts are united within a double category!


Our starting point:

A categorical logic (doctrine) is a double category of categories equipped with extra structure.

This talk is about a systematic way to work with such categorical logics.

Outline

  • Part 1: Theory
    Double theories, a double-categorical framework for categorical logic
  • Interlude: Demo
  • Part 2: Practice
    CatColab, a collaborative environment for modeling in domain-specific categorical logics

Part 1: Double theories

Joint work with Michael Lambert.

Main references:

  1. “Cartesian double theories: A double-categorical framework for categorical logic” (Lambert and Patterson 2024)
  2. “Products in double categories, revisited,” Section 10: “Finite-product double theories” (Patterson 2024)

Toward two-dimensional functorial semantics

A lax functor

F:𝟙→𝕊𝗉𝖺𝗇F:1→Span

is the same thing as a small category.

Moreover, a natural transformation is the same thing as a functor:

Second observation doesn’t work for lax functors between bicategories!

Toward two-dimensional functorial semantics

Generalizing from the terminal double category:

Proposition

Let 𝔻D be a strict double category and let F:𝔻→𝕊𝗉𝖺𝗇F:D→Span be a lax functor.

  • For each object x∈𝔻x∈D, the data (Fx,Fidx,Fx,x,Fx)(Fx,Fidx,Fx,x,Fx) is a category

  • For each arrow f:x→yf:x→y in 𝔻D, the data (Ff,Fidf)(Ff,Fidf) is a functor

  • For each special cell αα in 𝔻D, the image FαFα is a natural transformation:

Lambert and Patterson (2024), Section 2

Toward two-dimensional functorial semantics

Proposition

Let 𝔻D be a strict double category and let F:𝔻→𝕊𝗉𝖺𝗇F:D→Span be a lax functor.

  • For each proarrow m:x+→ym:x+→y in 𝔻D, the data (Fm,Fx,m,Fm,y)(Fm,Fx,m,Fm,y) is a bimodule, i.e., a profunctor

  • For each cell αα in 𝔻D, the image FαFα is a bimodule homomorphism, i.e., a natural transformation

These are the basic notions of category theory! Moreover, replacing 𝕊𝗉𝖺𝗇Span with:

  • 𝕊𝗉𝖺𝗇(𝖢)Span(C) gives notions internal to 𝖢C
  • 𝕄𝖺𝗍()Mat(V) gives notions enriched in V

Lambert and Patterson (2024), Section 2

Double theories

With this motivation, we propose that:

  • A “double theory” is a strict double category 𝕋T, possibly equipped with extra structure
  • A model of a double theory is structure-preserving lax functor 𝕋→𝕊𝗉𝖺𝗇T→Span

For a fixed double theory 𝕋T, there will be a (possibly virtual) double category, even a (virtual) equipment, with:

  • objects = models of 𝕋T
  • arrows = morphisms of models (possibly lax, oplax, or pseudo)
  • proarrows = bimodules between models
  • cells = transformations/bimodule homomorphisms

Double-categorical logic

A new dictionary—note the level shift!

Meta-logic Double category theory
logic double theory
theory model of double theory
interpretation between theories model morphism
model of theory module/instance over model
model homomorphism module/instance homomorphism

Flavors of double theory

In order of increasing expressivity:

  1. Discrete double theories
  2. Simple double theories
  3. Cartesian double theories
  4. Finite-product double theories

Simple double theories

Definition

A simple double theory is a small, strict double category.

This is a concept with an attitude, understood as a categorified theory:

  • object = “object type”
  • arrow = “operation on objects”
  • proarrow = “morphism type”
  • cell = “operation on morphisms”
  • ff = object operation with input type xx and output type ww
  • αα = morphism operation with input type mm and output type nn

Lambert and Patterson (2024), Section 3

Models of simple double theories

Definition

A model of a simple double theory 𝕋T is

  • a lax double functor M:𝕋→𝕊𝗉𝖺𝗇M:T→Span, or equivalently
  • a unitary lax double functor M:𝕋→ℙ𝗋𝗈𝖿M:T→Prof

Recall that unitary means that the unitors are identities (Grandis 2019, sec. 3.5.2).

Example: theory of monads

The theory of monads is the simple double theory generated by

  • an object xx

  • an arrow t:x→xt:x→x

  • multiplication and unit cells

subjects to three equations expressing associativity and unitality.

Lambert and Patterson (2024), Theory 3.8

Example: theory of monads

E.g., the associativity axiom:




==

Fact

A model of the theory of monads is precisely a category 𝖢C along with a monad (T,μ,η)(T,μ,η) on 𝖢C.

Lambert and Patterson (2024), Theory 3.8

Simple double theories, the big picture

Concept Definition
Simple double theory Small, strict double category 𝕋T
Model of simple double theory Lax functor F:𝕋→𝕊𝗉𝖺𝗇F:T→Span
Morphism between models (strict, pseudo, op/lax) (Strict, pseudo, op/lax) natural transformation α:F⇒Gα:F⇒G
Bimodule between models Module M:F∣⇒GM:F∣⇒G
Cell between morphisms/bimodules Modulation

Notes

  • Modules and modulations for lax double functors were introduced by Paré (2011, 2013)
  • Generalization from strict to lax natural transformations seems to be original

Cartesian double theories, the big picture

Concept Definition
Cartesian double theory Small, cartesian, strict double category 𝕋T
Model of theory Cartesian lax functor F:𝕋→𝕊𝗉𝖺𝗇F:T→Span
Model morphism (strict, pseudo, op/lax) Cartesian (strict, pseudo, op/lax) natural transformation α:F⇒Gα:F⇒G
Model bimodule Cartesian module M:F∣⇒GM:F∣⇒G
Cell Modulation

Lambert and Patterson (2024), Section 6

Notes

  • Cartesian double categories were studied by (Aleiferi 2018)
  • Based on theory of limits in double categories (Grandis and Paré 1999)
  • We introduce cartesian lax transformations and cartesian modules (Lambert and Patterson 2024)

Example: theory of pseudomonoids

The theory of pseudomonoids is the cartesian double theory generated by

  • an object xx

  • arrows ⊗:x2→x⊗:x2→x and I:1→xI:1→x

  • associator and unitor cells, along with their external inverses,

subject to two equations, the pentagon and triangle identities.

A model of the theory of pseudomonoids is a (weak) monoidal category.

Interlude: Demo

Two of the logics currently available in CatColab:

  1. Causal loop diagrams
  2. Database schemas


Try it yourself: https://catcolab.org

Warning

CatColab is pre-alpha software under active development.

Part 2: CatColab

CatColab v0.1 was developed in collaboration with:

  • Kris Brown
  • Kevin Carlson
  • Owen Lynch

I am also grateful for support from other colleagues at Topos Institute and our collaborators and funders.

See also the blog post Introducing CatColab (Carlson 2024)

Discrete double theories

Simplifying still further from simple double theories:

Definition

A discrete double theory is

  • a simple double theory having only trivial arrows and cells, or equivalently
  • a double category of the form 𝔻𝗂𝗌𝖼(𝖡):=ℍ(𝖡)Disc(B):=H(B), where 𝖡B is a small category

Such a double theory has only object and morphism types, no operations.

Models of discrete double theories are also known as “displayed categories” (Ahrens and Lumsdaine 2019).

Fact

A model of a discrete double theory 𝔻𝗂𝗌𝖼(𝖡)Disc(B) is equivalent to a category sliced over 𝖡B:

𝖫𝖺𝗑(𝔻𝗂𝗌𝖼(𝖡),𝕊𝗉𝖺𝗇)≃𝖢𝖺𝗍/𝖡.Lax(Disc(B),Span)≃Cat/B.

Causal loop diagrams

Causal loop diagrams (and also regulatory networks) are

  • signed graphs, or
  • free signed categories


Let 𝖲𝗀𝗇:={±1}≅ℤ2Sgn:={±1}≅Z2 be the group of nonzero signs.

Definition

A signed category is a category 𝖢C equipped with a functor 𝖢→𝖲𝗀𝗇C→Sgn.

So, the category of signed categories is the slice

𝖲𝗀𝗇𝖢𝖺𝗍:=𝖢𝖺𝗍/𝖲𝗀𝗇.SgnCat:=Cat/Sgn.

Aduddell et al. (2024), Section 2.1

Causal loop diagrams via double theories

Theory

The theory of signed categories is the discrete double theory generated by

  • a object type xx
  • a morphism type n:x+→xn:x+→x (for “negative”)

subject to the equation n⊙n=idxn⊙n=idx (where idx:x+→xidx:x+→x is “positive”).

Equivalently,

𝕋𝖲𝗀𝗇𝖢𝖺𝗍:=𝔻𝗂𝗌𝖼(𝖲𝗀𝗇),TSgnCat:=Disc(Sgn),

so

𝖫𝖺𝗑(𝕋𝖲𝗀𝗇𝖢𝖺𝗍,𝕊𝗉𝖺𝗇)≃𝖢𝖺𝗍/𝖲𝗀𝗇=𝖲𝗀𝗇𝖢𝖺𝗍.Lax(TSgnCat,Span)≃Cat/Sgn=SgnCat.

CatColab developer docs: signed categories

Free signed categories

What’s the point about thinking of signed graphs as free signed categories?

Motifs are morphisms between free signed categories, e.g.,

  • Positive/reinforcing feedback loops are morphisms out of:

  • Negative/balancing feedback loops are morphisms out of:

Aduddell et al. (2024), Section 2.2

Diagrams as free categorical structures

This phenomenon is generic:

Slogan

Diagrammatic languages are free categorical structures whenever it makes sense for arrows to compose.

A famous example:

Example

Petri nets are free symmetric/commutative monoidal categories.

Coming in a future version of CatColab!

On Petri nets and SMCS: Baez et al. (2021)

Database schemas

A basic notion of database schema is a finitely presented profunctor

where Mapping:=HomEntityMapping:=HomEntity and AttrOp:=HomAttrTypeAttrOp:=HomAttrType.

In SQL jargon:

  • “Entity” = table
  • “Mapping” = foreign key
  • “Attr” = data attribute = column that is not a foreign key

Schultz et al. (2017), Patterson, Lynch, and Fairbanks (2022), Roig, Meyers, and Minichiello (2024)

Schemas via double theories

Theory

The theory of profunctors is the “walking proarrow” 𝔻𝗂𝗌𝖼(𝟤)Disc(2), a discrete double theory freely generated by

  • two objects 0,10,1
  • one proarrow 0+→10+→1.

A model is a profunctor, either directly or indirectly via “barrels”:

𝖫𝖺𝗑(𝔻𝗂𝗌𝖼(𝟤),𝕊𝗉𝖺𝗇)≃𝖢𝖺𝗍/𝟤.Lax(Disc(2),Span)≃Cat/2.

In future versions of CatColab:

  • Database instances as modules over models of double theories
  • Algebraic databases a la Schultz et al. (2017)

Distributors and barrels on Joyal’s CatLab, esp. Proposition 2.4

Design of CatColab

  • Going from math to technology is more than just implementing a spec!
  • The embodiment of mathematics in technology requires as much creative input as the math itself

Desiderata

The system should enable formal, interoperable, conceptual modeling in domain-specific logics

  • assuming that the user knows something about a domain of interest
  • not assuming that the user knows about the meta-logical foundation

Intended users have variable levels of technical expertise and might be…

  • scientist
  • engineer
  • policy analyst
  • local expert/community leader

Structure editing

CatColab is a structure editor for categorical structures:

  • content being edited is not just a string
  • but rather a structured object (such as a model of a double theory)

Interpolates between text editors and fully graphical editors:

  • Unlike a text editor, can provide heavy scaffolding and enforce correct syntax by construction
  • Unlike a graphical editor, there seems to be hope of doing it generically across structures!

Hypothesis

It is possible and practical to build a structure editor for collaborative modeling that is ergonomic, yet parametric over the logic.

Another example is Hazel, a structure editor for functional programs (Omar et al. 2017)

User interface

We emphasize formal modeling, but informal narrative is indispensable.

CatColab has a notebook-style interface, mixing

  • formal elements handled by the structure editor
  • natural language text handled by a rich text editor

Note

Interface familiar from computational notebooks like Jupyter but very different execution model:

  • In a Jupyter notebook, cells execute individually and produce side effects
  • A CatColab notebook declaratively specifies a single structure

References

Aduddell, Rebekah, James Fairbanks, Amit Kumar, Pablo S. Ocal, Evan Patterson, and Brandon T. Shapiro. 2024. “A Compositional Account of Motifs, Mechanisms, and Dynamics in Biochemical Regulatory Networks.” Compositionality 6 (2). https://doi.org/10.32408/compositionality-6-2.
Ahrens, Benedikt, and Peter LeFanu Lumsdaine. 2019. “Displayed Categories.” Logical Methods in Computer Science 15 (1). https://doi.org/10.23638/LMCS-15(1:20)2019.
Aleiferi, Evangelia. 2018. “Cartesian Double Categories with an Emphasis on Characterizing Spans.” PhD thesis, Dalhousie University. https://arxiv.org/abs/1809.06940.
Baez, John C., Fabrizio Genovese, Jade Master, and Michael Shulman. 2021. “Categories of Nets.” In 2021 36th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS), 1–13. https://doi.org/10.1109/LICS52264.2021.9470566.
Carlson, Kevin. 2024. “Introducing CatColab.” Topos Institute. 2024. https://topos.site/blog/2024-10-02-introducing-catcolab/.
Grandis, Marco. 2019. Higher Dimensional Categories: From Double to Multiple Categories. World Scientific. https://doi.org/10.1142/11406.
Grandis, Marco, and Robert Paré. 1999. “Limits in Double Categories.” Cahiers de Topologie Et géométrie Différentielle Catégoriques 40 (3): 162–220.
Lambert, Michael, and Evan Patterson. 2024. “Cartesian Double Theories: A Double-Categorical Framework for Categorical Doctrines.” Advances in Mathematics 444: 109630. https://doi.org/10.1016/j.aim.2024.109630.
Lawvere, F. William. 1963. “Functorial Semantics of Algebraic Theories.” PhD thesis, Columbia University. http://www.tac.mta.ca/tac/reprints/articles/5/tr5abs.html.
Omar, Cyrus, Ian Voysey, Michael Hilton, Joshua Sunshine, Claire Le Goues, Jonathan Aldrich, and Matthew A. Hammer. 2017. “Toward Semantic Foundations for Program Editors.” In Summit on Advances in Programming Languagess (SNAPL), 71:11:1–12. LIPIcs. https://arxiv.org/abs/1703.08694.
Paré, Robert. 2011. “Yoneda Theory for Double Categories.” Theory and Applications of Categories 25 (17): 436–89. http://www.tac.mta.ca/tac/volumes/25/17/25-17abs.html.
———. 2013. “Composition of Modules for Lax Functors.” Theory and Applications of Categories 27 (16): 393–444. http://www.tac.mta.ca/tac/volumes/27/16/27-16abs.html.
Patterson, Evan. 2024. “Products in Double Categories, Revisited.” https://arxiv.org/abs/2401.08990.
Patterson, Evan, Owen Lynch, and James Fairbanks. 2022. “Categorical Data Structures for Technical Computing.” Compositionality 4 (5). https://doi.org/10.32408/compositionality-4-5.
Roig, Gabriel Goren, Joshua Meyers, and Emilio Minichiello. 2024. “Presenting Profunctors.” https://arxiv.org/abs/2404.01406.
Schultz, Patrick, David I. Spivak, Christina Vasilakopoulou, and Ryan Wisnesky. 2017. “Algebraic Databases.” Theory and Applications of Categories 32 (16): 547–619. http://www.tac.mta.ca/tac/volumes/32/16/32-16abs.html.
Spivak, David I. 2012. “Functorial Data Migration.” Information and Computation 217: 31–51. https://doi.org/10.1016/j.ic.2012.05.001.

1
Double-categorical logic in theory and practice Second Virtual Workshop on Double Categories Evan Patterson 2024-10-29

  1. Slides

  2. Tools

  3. Close
  • Double-categorical logic in theory and practice
  • Why double categories?
  • Categorical logic
  • Categorical logic, the minimal setting
  • Standard dictionary of categorical logic
  • Another dictionary of categorical logic?
  • Categorical logics are double categories
  • Outline
  • Part 1: Double theories
  • Toward two-dimensional functorial semantics
  • Toward two-dimensional functorial semantics
  • Toward two-dimensional functorial semantics
  • Double theories
  • Double-categorical logic
  • Flavors of double theory
  • Simple double theories
  • Models of simple double theories
  • Example: theory of monads
  • Example: theory of monads
  • Simple double theories, the big picture
  • Cartesian double theories, the big picture
  • Example: theory of pseudomonoids
  • Interlude: Demo
  • Part 2: CatColab
  • Discrete double theories
  • Causal loop diagrams
  • Causal loop diagrams via double theories
  • Free signed categories
  • Diagrams as free categorical structures
  • Database schemas
  • Schemas via double theories
  • Design of CatColab
  • Desiderata
  • Structure editing
  • User interface
  • References
  • f Fullscreen
  • s Speaker View
  • o Slide Overview
  • e PDF Export Mode
  • ? Keyboard Help