Evan Patterson
(joint with Michael Lambert)
September 6, 2022
\[ \newcommand{cat}[1]{\mathsf{#1}} \newcommand{bicat}[1]{\mathbf{#1}} \newcommand{dbl}[1]{\mathbb{#1}} \newcommand{\Set}{\mathsf{Set}} \newcommand{\Cat}{\mathbf{Cat}} \newcommand{\Dbl}{\mathbf{Dbl}} \newcommand{\RelBi}{\mathbf{Rel}} \newcommand{\Rel}{\mathbb{R}\mathsf{el}} \newcommand{\Span}{\mathbb{S}\mathsf{pan}} \newcommand{\Mat}[1]{{#1}\text{-}\mathbb{M}\mathsf{at}} \newcommand{\Prof}{\mathbb{P}\mathsf{rof}} \DeclareMathOperator{\id}{id} \newcommand{\proTo}{\mathrel{\mkern3mu\vcenter{\hbox{$\scriptstyle+$}}\mkern-10mu{\to}}} \]
Category theory for knowledge representation:
Databases and knowledge representation (KR) are
Distinguishing between schemas and instance data,
This matters for implementation! But the unity is more important.
Ontology logs (ologs), introdued by Spivak and Kent, are
In an olog:
I’ll call these functional ologs.
Spivak and Kent (2012)
Because KR systems like OWL are relational, I proposed relational ologs:
In a relation olog:
\(\Downarrow\)
Example fact: transitivity of ancestor relationFunctional ologs | Relational ologs | |
---|---|---|
Structure | Category \(\cat{C}\) (simple) |
Bicategory of relations \(\bicat{B}\) (not so simple) |
Instance data | \(\cat{C} \to \Set\) | \(\bicat{B} \to \RelBi\) |
Functions | ✅ | ✅ (via “maps”, not first class) |
Relations | ❌ (only via spans, cannot compose) |
✅ |
Internal logic | ❌ (only via sketches) | regular logic |
Data migration | ✅ | ❌ |
Functorial data migration: Spivak (2012).
Can we get the best of both worlds by working in a double category?
Data lives in double category \(\Rel\):
Generic cell in \(\Rel\):
\(R(x,y) \implies S(f(x), g(y))\) for all \(x \in X, y \in Y\)
Double categories of relations (Lambert 2021)
To make a KR system, we need to understand the abstract structure of \(\Rel\):
Briefly, a double category \(\dbl{D}\) is a (pseudo)category internal to \(\Cat\):
\[ \dbl{D}_1 \overset{s,t}{\rightrightarrows} \dbl{D}_0, \qquad \dbl{D}_1 \times_{\dbl{D}_0} \dbl{D}_1 \xrightarrow{\odot} \dbl{D}_1, \qquad \dbl{D}_0 \xrightarrow{\id} \dbl{D}_1 \]
A double category \(\dbl{D}\) is cartesian if the diagonal and terminal double functors
\[ \Delta: \dbl{D} \to \dbl{D} \times \dbl{D}, \qquad !: \dbl{D} \to \dbl{1} \]
have right adoints in \(\Dbl\). Essentially, this means that
PhD thesis of Aleiferi (2018)
A crucial feature of \(\Rel\) is that functions (arrows) can viewed as relations (proarrows) in two different ways:
Moreover, these come with certain cells:
An equipment is a double category such that
Examples: double categories of…
Equipments are also called framed bicategories (Shulman 2008) and fibrant double categories (Aleiferi 2018).
The last two statements mean that niches and coniches have universal fillings:
Later, we’ll see how to use restriction and extension for data manipulation.
A cartesian equipment is a cartesian double category that is an equipment.
Examples:
All examples above are treated by Aleiferi (2018).
Suppose our KB, a cartesian equipment \(\dbl{D}\), includes the 4-ary relation
Instance data, a cartesian double functor \(\dbl{D} \to \Rel\), can be shown as a table:
date | location | purpose | team |
---|---|---|---|
1998-02-06 | P41-771 | search & rescue | SG3 |
1998-07-31 | Cimmeria | assist Cimmerians | SG1 |
1999-01-02 | P3R-272 | investigate inscriptions | SG1 |
1999-10-22 | Netu | search & rescue | SG1 |
2004-08-06 | Tegalus | negotiation | SG9 |
To select columns, extend along projection maps.
Query:
Result:
date | team |
---|---|
1998-02-06 | SG3 |
1998-07-31 | SG1 |
1999-01-02 | SG1 |
1999-10-22 | SG1 |
2004-08-06 | SG9 |
To filter rows, restrict along an individual.
Given:
Query:
Result:
date | location | purpose | team |
---|---|---|---|
1998-07-31 | Cimmeria | assist Cimmerians | SG1 |
1999-01-02 | P3R-272 | investigate inscriptions | SG1 |
1999-10-22 | Ne’tu | search & rescue | SG1 |
To compute an inner join, say of
along \(B\), restrict the product \(p \times q\) along the diagonal \(\Delta: B \to B \times B\):
Suppose have relations
with data
Query:
Result:
person | skill | team |
---|---|---|
Kovacek | law | SG9 |
Morrison | combat | SG3 |
Rothman | archaeology | SG11 |
In categorical databases based on functors \(\cat{C} \to \Set\):
As examples show, in double-categorical databases \(\dbl{D} \to \Rel\):
In future work, we hope to implement double categories of relations as
Further reading
Blog post by Michael Lambert: Data Operations are Functorial Semantics