A uniform type theory
for internal languages
of substructural categorical logics
Topos Berkeley Seminar
2026-09-29
$$
% https://tex.stackexchange.com/a/269194
$$
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 \]
For categorical logic emphasizing multicategories, see (Shulman 2016).
State of the art: Finding or implementing an internal language is a manual process, done from scratch for each categorical structure.
Aim: Uniformly over a family of categorical structures, present a type theory for each internal language.
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:
Outer type theory (“DoubleTT”) is joint work with Owen Lynch (Lynch and Patterson 2026).
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:
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\)”
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\)”
Formation rule: for any variable \(x\) not in \(\Gamma\),
…that’s it so far!
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!
Interpretation: Rules correspond to loose composition in \(\mathbb{T}\), nullary & binary.
Notation: \(\operatorname{Hom}_{\cal{X}}\) is the loose identity (unit) at \(\cal{X}\).
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} \]
This idealized notion of database schema is inspired by Schultz et al. (2017).
A database schema with a derived column:
Working example from tslil clingman’s prototype for CatColab.
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:
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.
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:
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 have product types, either
How to upgrade double theories so that models have “multiary” morphisms?
This work takes the second approach.
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}\).
For domain terms:
For terms:
Also computation rules corresponding to monad multiplication & unit.
The theory of multicategories is the modal double theory generated by
with key axioms being
\(\quad :=\)
Theory of multicategories is inspired by (Hermida 2000; Cruttwell and Shulman 2010).
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} \]
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} \]
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
}
}Let \(\mathsf{F}\) be a subcategory of (the skeleton of) \(\mathsf{FinSet}\), with certain properties.
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\).
\(\mathsf{F}\) should be a faithful cartesian club (Shulman 2016, Definition 2.6.3).
Categorical structures covered by this framework:
“Mixed” logics like linear/non-linear (LNL) also expected to work.
Further reading: Internal languages for models (Patterson 2026)
![]()