A uniform type theory
for internal languages
of substructural categorical logics

Topos Berkeley Seminar

Evan Patterson

Topos Institute

2026-09-29

Introduction

Internal languages enable reasoning inside categorical structures using “elements” and “function application”.

Examples: using internal languages

  • In the theory of a monoid (here, a multicategory):

    \[ [x,y,z]: [X,X,X] \vdash m[m[x,y],z]: X\]

  • In the theory of a module over a ring (here, a cartesian multicategory):

    \[ [r,x,y]: [R,X,X] \vdash \mathtt{add}[\mathtt{mul}[r,x], \mathtt{mul}[r,y]]: X \]

Motivation

State of the art: Finding or implementing an internal language is a manual process, done from scratch for each categorical structure.

  • Only a few exceptions, such as:
  • Licata et al. (2017)’s “fibrational framework for substructural & modal logics”


Aim: Uniformly over a family of categorical structures, present a type theory for each internal language.

  • Scope: the “substructural” categorical logics

The big picture

Working toward a framework to systematize the dictionary b/w CT and logic:

Level Concept Example Semantics Syntax
2 Doctrine Cartesian multicategories/algebraic theories Modal double theory [WIP with Bryce Goldman]
1 Theory Theory of modules over rings Model of a double theory Outer type theory: a specialized dependent type theory
0 Operation/process/program Scalar multiplication operation Morphism in a model Inner type theory: the internal language of model


This talk:

  • focuses on the bottom right cell, the internal languages of models
  • keeps prerequisite machinery in the background

Unary languages

  • Unary languages do not have product types, even virtually
  • Trivial from type theorist’s point of view but already illustrates key ideas

Loose direction: types

Idea: Loose direction of double theory \(\mathbb{T}\) (virtual equipment with structure) specifies types: object types \(\cal{X}\) and morphism types \(P: \cal{X} \mathrel{\mkern 3mu\vcenter{\hbox{$\scriptstyle+$}}\mkern-13mu{\to}}\cal{Y}\).


Two kinds of judgments in inner type theory:

  1. Domain terms: presupposing \(\mathbb{T} \vDash \cal{X}\) and \(\Gamma \vdash X: \operatorname{Ob}_{\cal{X}}\),

    \[ \Gamma \mid u: X \]

    “\(u\) is domain term of type \(X\) in context \(\Gamma\)”

  1. Terms: presupposing \(\mathbb{T} \vDash (P: \cal{X} \mathrel{\mkern 3mu\vcenter{\hbox{$\scriptstyle+$}}\mkern-13mu{\to}}\cal{Y})\),   \({\Gamma \vdash X: \operatorname{Ob}_{\cal{X}}}\),   \({\Gamma \vdash Y: \operatorname{Ob}_{\cal{Y}}}\), and \(\Gamma \mid u: X\),

    \[ \Gamma \mid u: X \vdash_P t: Y \]

    “\(t\) is term of type \(Y\) with domain \(u: X\) in context \(\Gamma\)”

Domain terms

Formation rule: for any variable \(x\) not in \(\Gamma\),

…that’s it so far!

Terms: composition rules

Identity rule: for any variable \(x\) not in \(\Gamma\),


Post-composition rule: assuming \(P\) and \(Q\) below have a composite,

Note the asymmetric roles of \(P\) and \(Q\) in premises!

  • Term over \(P\), denoting an arbitrary morphism
  • Generating morphism over \(Q\)


Interpretation: Rules correspond to loose composition in \(\mathbb{T}\), nullary & binary.

Example: database schemas

Consider the double theory for database schemas (profunctors):

\[ \mathbb{T} := \big\{\mathsf{Entity}\overset{\mathrm{Attr}}{\mathrel{\mkern 3mu\vcenter{\hbox{$\scriptstyle+$}}\mkern-13mu{\to}}} \mathsf{AttrType}\big\} \cong \mathbb{L}\mathsf{oose}. \]

A particular schema is given by the (outer) context:

\[ \begin{aligned} \Gamma =\; [& \mathrm{Currency}: \operatorname{Ob}_{\mathsf{AttrType}}, \\ &\mathrm{Empl}: \operatorname{Ob}_{\mathsf{Entity}},\ \mathrm{salary}: \mathrm{Attr}(\mathrm{Empl}, \mathrm{Currency}), \\ &\mathrm{Dept}: \operatorname{Ob}_{\mathsf{Entity}},\ \mathrm{head}: \operatorname{Hom}_{\mathsf{Entity}}(\mathrm{Dept}, \mathrm{Empl}) ] \end{aligned} \]

Now derive a term:

\[ \begin{aligned} & \Gamma \mid d: \mathrm{Dept}\vdash_{\operatorname{Hom}_{\mathsf{Entity}}} d: \mathrm{Dept} & \small{(\text{identity})} \\ & \Gamma \mid d: \mathrm{Dept}\vdash_{\operatorname{Hom}_{\mathsf{Entity}}} \mathrm{head}(d): \mathrm{Empl} & \small{(\text{post-composition})} \\ & \Gamma \mid d: \mathrm{Dept}\vdash_{\mathrm{Attr}} \mathrm{salary}(\mathrm{head}(d)): \mathrm{Currency} & \small{(\text{post-composition})} \end{aligned} \]

Database schema in prototype implementation

A database schema with a derived column:

impl EmployeesAndDepartments for Schema {
    const Currency : AttrType;
    const Employee : Entity;
    const Department : Entity;

    const salary : Employee -> Currency;
    const head : Department -> Employee;

    fn head_salary(d : Department) -> Currency {
        salary (head d)
    }
}

Working example from tslil clingman’s prototype for CatColab.

Tight direction: operations

Idea: Tight direction of double theory \(\mathbb{T}\) specifies operations:

  • object operations (tight morphisms) \(F: \cal{X} \to \cal{Y}\) act on types (objects) and domain terms

  • morphism operations (cells) \(\alpha\) act on terms:

Operation application rules

For domain terms:

For terms:

\(\leadsto\)

Flatness assumption

Where is \(\alpha\) in the rule’s conclusion?! Nowhere for it to go in elements-only syntax.

Thus, double theory \(\mathbb{T}\) is assumed to be flat (locally thin), a kind of coherence condition.

Example: promonads

A promonad is a “category with two kinds of morphisms”: tight morphisms, which can be cast to loose morphisms.

The theory of promonads is the double theory \(\mathbb{T}\)…

…generated by:

  • an object \(\cal{X}\)

  • a proarrow \(P: \cal{X} \mathrel{\mkern 3mu\vcenter{\hbox{$\scriptstyle+$}}\mkern-13mu{\to}}\cal{X}\)

  • a globular cell, the unit:

…such that:

  • the composite \(P \odot P = P\) exists
  • equations hold making \(\mathbb{T}\) flat.

Example: promonads

In the context

\[ \Gamma = [X: \operatorname{Ob}_{\cal{X}},\ Y: \operatorname{Ob}_{\cal{X}},\ Z: \operatorname{Ob}_{\cal{X}},\ f: \operatorname{Hom}_{\cal{X}}(X,Y),\ g: P(Y,Z)], \]

derive a term in two different ways…

…by post-composition only:

\[ \begin{aligned} & \Gamma \mid x: X \vdash_{\operatorname{Hom}_{\cal{X}}} x: X & (\text{identity}) \\ & \Gamma \mid x: X \vdash_{\operatorname{Hom}_{\cal{X}}} f(x): Y & (\text{post-comp.}) \\ & \Gamma \mid x: X \vdash_P g(f(x)): Z & (\text{post-comp.}) \end{aligned} \]

(Last line uses \(\operatorname{Hom}_{\cal{X}} \odot P = P\).)

…by casting tight to loose with \(\theta\):

\[ \begin{aligned} & \Gamma \mid x: X \vdash_{\operatorname{Hom}_{\cal{X}}} x: X & (\text{identity}) \\ & \Gamma \mid x: X \vdash_{\operatorname{Hom}_{\cal{X}}} f(x): Y & (\text{post-comp.}) \\ & \Gamma \mid x: X \vdash_P f(x): Y & (\text{apply } \theta) \\ & \Gamma \mid x: X \vdash_P g(f(x)): Z & (\text{post-comp.}) \end{aligned} \]

(Last line uses \(P \odot P = P\).)

Note: Flatness ensures that the two derivations agree semantically.

Multiary languages

Multiary languages have product types, either

  • literally, as in monoidal or cartesian categories
  • virtually, as in (cartesian) multicategories

Meta-logical approaches

How to upgrade double theories so that models have “multiary” morphisms?

  • Add cartesian products to theories (Lambert and Patterson 2024)
    • Default strategy, suggested by microcosm principle
    • Leads to biased presentations of categorical structures
  • Add modalities like list monad to theories
    • Less conventional, but leads to unbiased presentations
    • Takes seriously that lists/arrays are first-class data structures in CS

This work takes the second approach.

Lists

A modal double theory \(\mathbb{T}\) is equipped with a double monad \(\operatorname{List}: \mathbb{T} \to \mathbb{T}\), interpreted in models as the double list monad on \(\mathbb{S}\mathsf{et}\).


List formation rules

For domain terms:

For terms:


Also computation rules corresponding to monad multiplication & unit.

Example: multicategories

The theory of multicategories is the modal double theory generated by

  • an object \(\cal{X}\)
  • a loose morphism \(P: \operatorname{List}(\cal{X}) \mathrel{\mkern 3mu\vcenter{\hbox{$\scriptstyle+$}}\mkern-13mu{\to}}\cal{X}\),

with key axioms being

  • composition: \(\operatorname{List}(P) \odot P = P(\mu_{\cal{X}}, 1_{\cal{X}})\)
  • normalization: \(\operatorname{Hom}_{\cal{X}} = P(\eta_{\cal{X}}, 1_{\cal{X}})\).

\(\quad :=\)

Example: multicategories

Take signature of the theory of monoids,

\[ \Gamma := [X: \operatorname{Ob}_{\cal{X}},\ m: P([X, X], X),\ e: P([\,], X)]. \]

Goal: derive term

\[ \Gamma \mid [x,y]: [X,X] \vdash_P m[x,y]: X. \]

Derivation

\[ \begin{aligned} & \Gamma \mid x: X \vdash_{\operatorname{Hom}_{\cal{X}}} x: X & \small{(\text{identity})} \\ & \Gamma \mid y: X \vdash_{\operatorname{Hom}_{\cal{X}}} y: X & \small{(\text{identity})} \\ & \Gamma \mid [x,y]: [X,X] \vdash_{\operatorname{List}\operatorname{Hom}_{\cal{X}}} [x,y]: [X,X] & \small{(\text{list formation})} \\ & \Gamma \mid [x,y]: [X,X] \vdash_{\operatorname{Hom}_{\operatorname{List}\cal{X}}} [x,y]: [X,X] & \small{(\text{strictness of modality on $\mathbb{T}$})} \\ & \Gamma \mid [x,y]: [X,X] \vdash_P m[x,y]: X & \small{(\text{post-composition})} \end{aligned} \]

Example: multicategories

Goal: derive term for left-hand side of associativity axiom,

\[ \Gamma \mid [x,y,z]: [X,X,X] \vdash_P m[m[x,y],z]: X. \]

Derivation

\[ \begin{aligned} & \Gamma \mid [x,y]: [X,X] \vdash_P m[x,y]: X & \small{(\text{previous slide})} \\ & \Gamma \mid z: X \vdash_{\operatorname{Hom}_{\cal{X}}} z: X & \small{(\text{identity})} \\ & \Gamma \mid [z]: [X] \vdash_P z: X & \small{(\text{application of restriction cell})} \\ & \Gamma \mid [[x,y],[z]]: [[X,X],[X]] \vdash_{\operatorname{List}P} [m[x,y],z]: [X,X] & \small{(\text{list formation})} \\ & \Gamma \mid [[x,y],[z]]: [[X,X],[X]] \vdash_{P(\mu_{\cal{X}},1)} m[m[x,y],z]: X & \small{(\text{post-composition})} \\ & \Gamma \mid [x,y,z]: [X,X,X] \vdash_P m[m[x,y],z]: X & \small{(\text{application of restriction cell})} \end{aligned} \]

Multicategory in prototype implementation

Another working example, the theory of monoids as a multicategory:

impl Monoid for Multicategory {
    const X : Object;
    const op : [X, X] -> X;
    const unit : [] -> X;

    fn left_assoc([a, b, c] : [X, X, X]) -> X {
        op [op [a, b], c]
    }
    fn right_assoc([a, b, c] : [X, X, X]) -> X {
        op [a, op [b, c]]
    }
    rel assoc([x, y, z] : [X, X, X]) -> X {
        left_assoc [x, y, z] == right_assoc [x, y, z]
    }

    rel left_id([x] : [X]) -> X {
        op [unit [], x] == x
    }
    rel right_id([x] : [X]) -> X {
        op [x, unit []] == x
    }
}

Beyond plain lists

Let \(\mathsf{F}\) be a subcategory of (the skeleton of) \(\mathsf{FinSet}\), with certain properties.

  • E.g., identities (“planar”), bijections (“symmetric”), functions (“cartesian”)

Construction. The generalized list double monad \(\operatorname{List}_{\mathsf{F}}: \mathbb{S}\mathsf{et}\to \mathbb{S}\mathsf{et}\) takes an element over \(P: A \mathrel{\mkern 3mu\vcenter{\hbox{$\scriptstyle+$}}\mkern-13mu{\to}}B\) to be

\[ (\sigma, [p_1, \dots, p_m]): [a_1, \dots, a_n] \mathrel{\mkern 3mu\vcenter{\hbox{$\scriptstyle+$}}\mkern-13mu{\to}}[b_1, \dots, b_m] \]

where \(\sigma: [m] \to [n]\) is in \(\mathsf{F}\) and \(p_i: a_{\sigma(i)} \mathrel{\mkern 3mu\vcenter{\hbox{$\scriptstyle+$}}\mkern-13mu{\to}}b_i\) for \(i = 1,\dots,m\).

List formation rule, generalized

Outlook

Categorical structures covered by this framework:

“Mixed” logics like linear/non-linear (LNL) also expected to work.

Thanks!

Further reading: Internal languages for models (Patterson 2026)

References

Cruttwell, G. S. H, and Michael A. Shulman. 2010. “A Unified Framework for Generalized Multicategories.” Theory and Applications of Categories 24 (21): 580–655. https://arxiv.org/abs/0907.2460.
Hermida, Claudio. 2000. “Representable Multicategories.” Advances in Mathematics 151 (2): 164–225. https://doi.org/10.1006/aima.1999.1877.
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.
Licata, Daniel R., Michael Shulman, and Mitchell Riley. 2017. “A Fibrational Framework for Substructural and Modal Logics.” 2nd International Conference on Formal Structures for Computation and Deduction (FSCD 2017), 25:1–22. https://doi.org/10.4230/LIPIcs.FSCD.2017.25.
Lynch, Owen, and Evan Patterson. 2026. “DoubleTT.” CatColab RFC. https://next.catcolab.org/rfc/0002.
Patterson, Evan. 2026. “Internal Languages for Models of Double Theories.” CatColab RFC. https://next.catcolab.org/rfc/0004.
Schultz, Patrick, David I. Spivak, Christina Vasilakopoulou, and Ryan Wisnesky. 2017. “Algebraic Databases.” Theory and Applications of Categories 32 (16): 547–619. https://arxiv.org/abs/1602.03501.
Shulman, Michael. 2016. Categorical Logic from a Categorical Point of View. https://mikeshulman.github.io/catlog/catlog.pdf.