open import Cat.Displayed.Base
open import Cat.Prelude

module Cat.Displayed.Cartesian
{o  o′ ℓ′} {B : Precategory o } (E : Displayed B o′ ℓ′) where

open Precategory B
open Displayed E

# Cartesian morphisms and Fibrations🔗

While displayed categories give the essential framework we need to express the idea of families of categories indexed by a category, they do not quite capture the concept precisely. The problem is that while a category $\ca{E}$ displayed over $\ca{B}$ does indeed give a collection of fibre categories $\ca{E}^*(x)$, this assignment isn’t necessarily functorial!

More precisely, we should have that a collection of categories, indexed by a category, should be a pseudofunctor $\ca{B} \to \Cat$, where $\Cat$ is a bicategory of categories. It turns out that we can characterise this assignment entirely in terms of the displayed objects and morphisms in $\ca{E}$!

Fix an arrow $f : a \to b$ in the base category $\ca{B}$, an object $a'$ over $a$ (resp. $b'$ over $b$), and an arrow $f' : a' \to_f b'$ over $f$. We say that $f'$ is cartesian if, up to very strong handwaving, it fits into a “pullback diagram”. The barred arrows with triangle tips here indicate the “projection” from a displayed object to its base, and so are implicit in the type dependency.

record
Cartesian {a b a′ b′} (f : Hom a b) (f′ : Hom[ f ] a′ b′) : Type (o    o′  ℓ′)
where
no-eta-equality

More specifically, let $u : \ca{B}$ and $u'$ be over $u$, and suppose that we have a map $m : u \to a$ (below, in violet), and a map $h' : u' \to_m b'$ lying over the composite $fm$ (in red). The universal property of a Cartesian map says that we have a universal factorisation of $h'$ through a map $u' \to a'$ (in green, marked $\exists!$).

field
universal :  {u u′} (m : Hom u a) (h′ : Hom[ f  m ] u′ b′)  Hom[ m ] u′ a′
commutes  :  {u u′} (m : Hom u a) (h′ : Hom[ f  m ] u′ b′)
f′ ∘′ universal m h′  h′
unique    :  {u u′} {m : Hom u a} {h′ : Hom[ f  m ] u′ b′}
(m′ : Hom[ m ] u′ a′)  f′ ∘′ m′  h′  m′  universal m h′

Given a “right corner” like that of the diagram below, and note that the input data consists of $a$, $b$, $f : a \to b$ and $b'$ over $a$,

we call an object $a'$ over $a$ together with a Cartesian arrow $f' : a' \to b'$ a Cartesian lift of $f$. Cartesian lifts, defined by universal property as they are, are unique when they exist, so that “having Cartesian lifts” is a property, not a structure.

record
Cartesian-lift {x y} (f : Hom x y) (y′ : Ob[ y ]) : Type (o    o′  ℓ′)
where
no-eta-equality
field
{x′}      : Ob[ x ]
lifting   : Hom[ f ] x′ y′
cartesian : Cartesian f lifting
open Cartesian cartesian public

We note that the classical literature often differentiates between fibrations — those displayed categories for which there exist Cartesian lifts for every right corner — and cloven fibrations, those for which the Cartesian lifts are “algebraic” in a sense. This is because, classically, essentially unique means that there are still some choices to be made, and invoking the axiom of choice makes an “arbitrary” set of such choices. But, in the presence of univalence, there is exactly one choice to be made, that is, no choice at all. Thus, we do not dwell on the distinction.

record Cartesian-fibration : Type (o    o′  ℓ′) where
no-eta-equality
field
has-lift :  {x y} (f : Hom x y) (y′ : Ob[ y ])  Cartesian-lift f y′

A Cartesian fibration is a displayed category having Cartesian lifts for every right corner.

## Why?🔗

Admittedly, the notion of Cartesian morphism is slightly artificial. It arises from studying the specific properties of the pullback functors $f^* : \ca{C}/y \to \ca{C}/x$ which exist in a category of pullbacks, hence the similarity in universal property!

In fact, the quintessential example of a Cartesian fibration is the codomain fibration, which is a category displayed over $\ca{C}$, where the fibre over $x$ is the slice category $\ca{C}/x$. We may investigate further (to uncover the name “codomain”): the total space of this fibration is the arrow category $\id{Arr}(\ca{C})$, and the projection functor is the codomain functor $\id{Arr}(\ca{C}) \to \ca{C}$.

This displayed category extends to a pseudofunctor exactly when $\ca{C}$ has all pullbacks, because in a world where the vertical arrows are “just” arrows, a Cartesian morphism is exactly a pullback square.

Other examples exist:

• The family fibration exhibits any category $\ca{C}$ as displayed over $\sets$. The fibres are functor categories (with discrete domains), reindexing is given by composition.
• The category of modules is fibred over the category of rings. The fibre over a ring $R$ is the category of $R$-modules, Cartesian lifts are given by restriction of scalars.