The cursed families fibration

Posted on August 16, 2023

This post is describing a simple construction I worked out while trying to understand the semantics of quantitative type theory. It is a variant of the families fibration, a well known construction in category theory, which is sensitive to the way that sets are made out of elements, and allows fibres to overlap. Hence it is β€œcursed”, which is like evil but more.

Let’s begin by recalling how the families fibration works. For any category π’ž\mathcal C, we can build a category π…πšπ¦(π’ž)\mathbf{Fam} (\mathcal C). The objects of π…πšπ¦(π’ž)\mathbf{Fam} (\mathcal C) are set-indexed families in π’ž\mathcal C: that is, a pair of an index set XX and a function A:Xβ†’Ob(π’ž)A : X \to \mathrm{Ob} (\mathcal C). A morphism (X,A)β†’(Y,B)(X, A) \to (Y, B) is a pair of a function f:Xβ†’Yf : X \to Y and an XX-indexed family of morphisms of π’ž,A(x)β†’B(f(x))\mathcal C, A (x) \to B (f (x)).

There is a functor π…πšπ¦(π’ž)β†’π’πžπ­\mathbf{Fam} (\mathcal C) \to \mathbf{Set} which forgets everything except the index set. This functor turns out to be a fibration. The fibre over a set XX is exactly π’žX\mathcal C^X, ie. the functor category Xβ†’π’žX \to \mathcal C when XX is seen as a discrete category.

Now let’s specialise to π’ž=π’πžπ­\mathcal C = \mathbf{Set}, so we are considering the fibration π…πšπ¦(π’πžπ­)β†’π’πžπ­\mathbf{Fam} (\mathbf{Set}) \to \mathbf{Set}. A magical property of the category of sets is that π’πžπ­Xβ‰…π’πžπ­/X\mathbf{Set}^X \cong \mathbf{Set} / X. Let’s go through how this equivalence works. In the forwards direction, we have an XX-indexed family A:Xβ†’Ob(π’πžπ­)A : X \to \mathrm{Ob} (\mathbf{Set}), which we turn into its disjoint union equipped with the projection onto the index set, βˆ‘x∈XA(x)β†’X\sum_{x \in X} A (x) \to X. In the backwards direction, we have a function f:Xβ€²β†’Xf : X' \to X, which we turn into an XX-indexed family by inverse images: A(x)={xβ€²βˆˆXβ€²βˆ£f(xβ€²)=x}A (x) = \{ x' \in X' \mid f(x') = x \}. Both of these turn out to be functorial and define an equivalence of categories.

Doing this on the total category gives us an equivalence of categories π…πšπ¦(π’πžπ­)β‰…π’πžπ­β†’\mathbf{Fam} (\mathbf{Set}) \cong \mathbf{Set}^\to, where π’πžπ­β†’\mathbf{Set}^\to is the arrow category, whose objects are functions and morphisms are commuting squares. The equivalence looks basically the same: an object (X,A)(X, A) of π…πšπ¦(π’πžπ­)\mathbf{Fam} (\mathbf{Set}) goes to the object βˆ‘x∈XA(x)β†’X\sum_{x \in X} A(x) \to X of π’πžπ­β†’\mathbf{Set}^\to, and the object f:Xβ€²β†’Xf : X' \to X of π’πžπ­β†’\mathbf{Set}^\to goes to the object (X,fβˆ’1(x)x∈X)(X, f^{-1} (x)_{x \in X}) of π…πšπ¦(π’πžπ­)\mathbf{Fam} (\mathbf{Set}).

This extends to an equivalence of fibrations, where the families fibration corresponds to the codomain fibration cod:π’πžπ­β†’β†’π’πžπ­\mathrm{cod} : \mathbf{Set}^\to \to \mathbf{Set}.

Ok, that concludes our very condensed recap of the families construction. Now let’s make it cursed.

The objects of π”‰π”žπ”ͺ\mathfrak{Fam} (fraktur is the appropriate font for a cursed object) are the same as the objects of π…πšπ¦(π’πžπ­)\mathbf{Fam} (\mathbf{Set}): a pair of a set XX and a function A:Xβ†’Ob(π’πžπ­)A : X \to \mathrm{Ob} (\mathbf{Set}). However, we restrict the morphisms (so we get a wide subcategory). A morphism (X,A)β†’(Y,B)(X, A) \to (Y, B) is a pair of a function f:Xβ†’Yf : X \to Y and an XX-indexed family functions fβ€²(x,βˆ’):A(x)β†’B(f(x))f' (x, -) : A (x) \to B (f (x)) satsifying an additional property: that if a∈A(x1)∩A(x2)a \in A (x_1) \cap A (x_2), then fβ€²(x1,a)=fβ€²(x2,a)f' (x_1, a) = f' (x_2, a), and consequently, both are elements of B(f(x1))∩B(f(x2))B (f (x_1)) \cap B (f (x_2)). (And if this intersection is empty then no morphism of this type can exist.)

This is fundamentally using the fact that π’πžπ­\mathbf{Set} is untyped, and we can talk about the intersection of arbitrary sets.

The intuition is that morphisms are not allowed to use their knowledge of the index, unless it can be deduced from the rest of their input. I’ll go through a detailed example of this later.

Just as there is an equivalence of categories π…πšπ¦(π’πžπ­)β‰…π’πžπ­β†’\mathbf{Fam} (\mathbf{Set}) \cong \mathbf{Set}^\to, there is a cursed counterpart of π’πžπ­β†’\mathbf{Set}^\to that is equivalent to π”‰π”žπ”ͺ\mathfrak{Fam}. I’ll call this category$ ^$. An object of π’πžπ­β†”\mathbf{Set}^\leftrightarrow is a pair of sets equipped with a binary relation RβŠ†XΓ—Xβ€²R \subseteq X \times X'. A morphism from RβŠ†XΓ—Xβ€²R \subseteq X \times X' to SβŠ†YΓ—Yβ€²S \subseteq Y \times Y' is a pair of functions f:Xβ†’Yf : X \to Y and fβ€²:Xβ€²β†’Yβ€²f' : X' \to Y' such that if xRxβ€²x R x' then f(x)Sfβ€²(xβ€²)f (x) S f' (x').

One perspective on π’πžπ­β†”\mathbf{Set}^\leftrightarrow is that it’s the category of morphisms in the double category π‘πžπ₯\mathbf{Rel} whose proarrows are binary relations.

We can turn an object (X,A)(X, A) of π”‰π”žπ”ͺ\mathfrak{Fam} into an object of π’πžπ­β†”\mathbf{Set}^\leftrightarrow by taking the non-disjoint union βˆͺx∈XA(x)\cup_{x \in X} A (x) together with the relation RβŠ†XΓ—βˆͺx∈XA(x)R \subseteq X \times \cup_{x \in X} A (x) given by xRxβ€²x R x' if xβ€²βˆˆA(x)x' \in A (x). Conversely, a binary relation RβŠ†XΓ—Xβ€²R \subseteq X \times X' we can do the relational equivalent of inverse images to get the XX-indexed set A(x)={xβ€²βˆˆXβ€²βˆ£xRxβ€²}A (x) = \{ x' \in X' \mid x R x' \}.

Both π”‰π”žπ”ͺ\mathfrak{Fam} and π’πžπ­β†”\mathbf{Set}^\leftrightarrow are fibred over π’πžπ­\mathbf{Set}, the latter being by the relational version of codomain, and the equivalence of categories π”‰π”žπ”ͺβ‰…π’πžπ­β†”\mathfrak{Fam} \cong \mathbf{Set}^\leftrightarrow extends to an equivalence of fibrations.

Here is a simple example, which was suggested by Zanzi. Given a set XX, we have the set X*X^* of lists, the set XnX^n of lists of length nn, and the set X*≀nX^{* \leq n} of lists of length at most nn. The sets XnX^n are non-overlapping for distinct nn, that is to say, two lists of different lengths cannot be equal. X*X^* is in natural bijection with the disjoint union βˆ‘nβˆˆβ„•Xn\sum_{n \in \mathbb N} X^n (whose elements are pairs of a number and a list of that length), and is equal on the nose to the non-disjoint union βˆͺnβˆˆβ„•Xn\cup_{n \in \mathbb N} X^n.

On the other hand, the sets X*≀nX^{* \leq n} overlap: X*≀mβŠ†X*≀nX^{* \leq m} \subseteq X^{* \leq n} iff m≀nm \leq n. The disjoint union βˆ‘nβˆˆβ„•X*≀n\sum_{n \in \mathbb N} X^{* \leq n} consists of pairs of a list and an upper bound on its length. But the non-disjoint union βˆͺnβˆˆβ„•X*≀n\cup_{n \in \mathbb N} X^{* \leq n} is still equal on the nose to X*X^*.

Suppose we want to talk about the length function, in π”‰π”žπ”ͺ\mathfrak{Fam} considered as a baby model of quantitative type theory. Consider the object (β„•,Xnβˆˆβ„•*≀n)(\mathbb N, X^{* \leq n}_{n \in \mathbb N}), which models an β€œirrelevant Sigma type” where an upper bound on the length is available at the type level but may not be used at the value level.

The set β„•\mathbb N is not a dependent type, so we consider it trivially 11-indexed, by the object ({*},β„•*∈{*})(\{ * \}, \mathbb N_{* \in \{ * \}}). There is a morphism (β„•,Xnβˆˆβ„•*≀n)β†’({*},β„•*∈{*})(\mathbb N, X^{* \leq n}_{n \in \mathbb N}) \to (\{ * \}, \mathbb N_{* \in \{ * \}}), given by the unique function β„•β†’{*}\mathbb N \to \{ * \} together with the β„•\mathbb N-indexed family of functions f(n,βˆ’):X*≀nβ†’β„•f (n, -) : X^{* \leq n} \to \mathbb N that ignores nn and returns the actual length of the list. This satisfies the condition to be a morphism of π”‰π”žπ”ͺ\mathfrak{Fam}.

We can say the same thing equivalently in π’πžπ­β†”\mathbf{Set}^\leftrightarrow, where the corresponding object is the relation RβŠ†β„•Γ—X*R \subseteq \mathbb N \times X^* given by nRxn R x if the length of xx is at most nn. The object corresponding to β„•\mathbb N is the relation SβŠ†{*}Γ—β„•S \subseteq \{ * \} \times \mathbb N given by *Sn* S n for all nn. The corresponding morphism is given by the unique function β„•β†’{*}\mathbb N \to \{ * \} and the length function X*β†’β„•X^* \to \mathbb N. This satisfies the condition to be a morphism of π’πžπ­β†”\mathbf{Set}^\leftrightarrow.

That’s all for today, but I’ll leave a puzzle. All of this was very heavily specialised to working concretely with sets. What structure could we put on a category in order that we can talk about β€œintersections of objects” in this way? Bruno suggested that what we need is a Grothendieck (possibly pre-)topology. I find this very plausible: two objects have nonempty overlap if they admit covering families with an object in common. But I’ll definitely leave the details of this for another day.