open import Cat.Functor.Equivalence.Path
open import Cat.Functor.Equivalence
open import Cat.Displayed.Functor
open import Cat.Displayed.Total
open import Cat.Displayed.Base
open import Cat.Prelude

module Cat.Displayed.Path where

open Precategory
open Displayed

Paths of displayed categoriesπŸ”—

If you have a pair of displayed categories EB0\mathcal{E} {\mathrel{\htmlClass{liesover}{\hspace{1.366em}}}}\mathcal{B}_0 and FB1\mathcal{F} {\mathrel{\htmlClass{liesover}{\hspace{1.366em}}}}\mathcal{B}_1 over a line of precategories Bi,i:I\mathcal{B}_i, i : {\mathbb{I}}, it might be interesting β€” if you, like me, are a lunatic β€” to know when they can be connected by a PathP over B\mathcal{B}. This module answers that! A path between displayed categories, over a path of their corresponding bases, is a displayed functor

which is componentwise an equivalence.

The first stepπŸ”—

We write this proof in two steps: First, we write a helper function which abstracts over the contentful part of the path (the displayed object spaces, displayed Hom spaces, etc) and automatically fills in the proofs that the laws are preserved. We have a record displayed-pathp-data which contains paths for all the interesting components:

    record displayed-pathp-data : Type (lsuc (o βŠ” β„“ βŠ” oβ€² βŠ” β„“β€²)) where
        obp  : PathP (Ξ» i β†’ B i .Ob β†’ Type oβ€²) E.Ob[_] F.Ob[_]
        homp : PathP
          (Ξ» i β†’ {x y : B i .Ob} (f : B i .Hom x y) β†’ obp i x β†’ obp i y β†’ Type β„“β€²)
          E.Hom[_] F.Hom[_]

The types get increasingly unhinged as we go: The identification between displayed object spaces lies over the identification of objects of the underlying category; The identification between displayed Hom spaces lies over a path in the base category and the path of displayed object spaces we just defined.

The paths between the identity morphisms and composite morphisms lie over both of those, and they have to quantify over every implicit argument inside the path! That’s why this record is in a private helper module, you see.

        idp : PathP (Ξ» i β†’ βˆ€ {x} {xβ€² : obp i x} β†’ homp i (B i .id) xβ€² xβ€²) E.idβ€² F.idβ€²
        compp : PathP
          (Ξ» i β†’ βˆ€ {x y z}    {f : B i .Hom y z}    {g : B i .Hom x y}
               β†’ βˆ€ {xβ€² yβ€² zβ€²} (fβ€² : homp i f yβ€² zβ€²) (gβ€² : homp i g xβ€² yβ€²)
               β†’ homp i (B i ._∘_ f g) xβ€² zβ€²)
          E._βˆ˜β€²_ F._βˆ˜β€²_

An instance of this record determines a path of displayed categories,

      : displayed-pathp-data β†’ PathP (Ξ» i β†’ Displayed (B i) oβ€² β„“β€²) E F
    displayed-pathp-worker input = go where
      open displayed-pathp-data input

such that all the interesting components are literal, and the coherence components are, by definition, unimportant.

      go : PathP (Ξ» i β†’ Displayed (B i) oβ€² β„“β€²) E F
      Ob[ go i ] x = obp i x
      Hom[ go i ] = homp i
      Hom[ go i ]-set {a} {b} f x y = homp-set i a b f x y
      go i .idβ€² = idp i
      go i ._βˆ˜β€²_ = compp i

Complicating itπŸ”—

Suppose that we have EB\mathcal{E} {\mathrel{\htmlClass{liesover}{\hspace{1.366em}}}}\mathcal{B} and FC\mathcal{F} {\mathrel{\htmlClass{liesover}{\hspace{1.366em}}}}\mathcal{C}, together with a functor F:B→CF : \mathcal{B} \to \mathcal{C} which is an isomorphism of precategories, and a functor G:E→FG : \mathcal{E} \to \mathcal{F} over FF. This is the situation in the introduction, but where the line Bi\mathcal{B}_i comes from the identity system on precategories given by isomorphisms of precategories.

The functor GG must be componentwise an isomorphism of types: This is the displayed equivalent of an isomorphism of precategories.

    : (eqv : is-precat-iso F)
    β†’ (βˆ€ a β†’ is-equiv {A = β„°.Ob[ a ]} G.Fβ‚€β€²)
    β†’ ( βˆ€ {a b} {f} {aβ€² : β„°.Ob[ a ]} {bβ€² : β„°.Ob[ b ]}
      β†’ is-equiv {A = β„°.Hom[ f ] aβ€² bβ€²} G.F₁′)
    β†’ PathP (Ξ» i β†’ Displayed (Precategory-path F eqv i) oβ€² β„“β€²) β„° β„±
  Displayed-pathp eqv obeqv homeqv = displayed-pathp-worker input where
    ps = Precategory-path F eqv

We’ll define a displayed-pathp-data. We define the paths between displayed object spaces and displayed path spaces by gluing against the ungluing of the paths in the underlying category, in the right endpoint category F\mathcal{F}. Diagramatically, this looks something like

    p1 : PathP (Ξ» i β†’ ps i .Ob β†’ Type oβ€²) β„°.Ob[_] β„±.Ob[_]
    p1 i x = Glue β„±.Ob[ unglue (βˆ‚ i) x ] Ξ» where
      (i = i0) β†’ β„°.Ob[ x ] , G.Fβ‚€β€² , obeqv x
      (i = i1) β†’ β„±.Ob[ x ] , _ , id-equiv

We glue the type E[x]\mathcal{E}[x] along F0β€²F_0' β€” the action of the displayed functor on objects β€” against the line of types given by applying the space of displayed objects of F\mathcal{F} to the ungluing of xx, giving a line of type families p1 ranging from E[βˆ’]β†’F[βˆ’]\mathcal{E}[-] \to \mathcal{F}[-]. The situation for Hom spaces is analogous.

    sys : βˆ€ i (x y : ps i .Ob) (f : ps i .Hom x y) (xβ€² : p1 i x) (yβ€² : p1 i y)
        β†’ Partial (i ∨ ~ i) _
    sys i x y f xβ€² yβ€² (i = i0) = β„°.Hom[ f ] xβ€² yβ€² , G.F₁′ , homeqv
    sys i x y f xβ€² yβ€² (i = i1) = β„±.Hom[ f ] xβ€² yβ€² , _ , id-equiv

    p2 : PathP
      (Ξ» i β†’ {x y : ps i .Ob} (f : ps i .Hom x y) β†’ p1 i x β†’ p1 i y β†’ Type β„“β€²)
      β„°.Hom[_] β„±.Hom[_]
    p2 i {x} {y} f xβ€² yβ€² = Glue
      (β„±.Hom[ unglue (βˆ‚ i) f ] (unglue (βˆ‚ i) xβ€²) (unglue (βˆ‚ i) yβ€²))
      (sys i x y f xβ€² yβ€²)

    open displayed-pathp-data
    input : displayed-pathp-data
    input .obp  = p1
    input .homp = p2

We now β€œjust” have to produce inhabitants of p2 along i:Ii : {\mathbb{I}} which restrict to E\mathcal{E} and F\mathcal{F}’s identity morphisms (and composition morphisms) at the endoints of ii. We can do so by gluing, now at the level of terms, against a heterogeneous composition. The details are quite nasty, but the core of it is extending the witness that GG respects identity to a path, over line given by gluing F1β€²F_1' and ungluing the domain/codomain, between the identity maps in E\mathcal{E} and F\mathcal{F}.

    input .idp i {x} {xβ€²} = glue-inc (βˆ‚ i)
      {Tf = sys i x x (ps i .id {x}) xβ€² xβ€²}
      (Ξ» { (i = i0) β†’ β„°.idβ€² ; (i = i1) β†’ β„±.idβ€² })
      (inS (comp (Ξ» j β†’ β„±.Hom[ p (~ j) ] (unglue (βˆ‚ i) xβ€²) (unglue (βˆ‚ i) xβ€²)) (βˆ‚ i)
        Ξ» { j (j = i0) β†’ β„±.idβ€²
          ; j (i = i0) β†’ G.F-idβ€² (~ j)
          ; j (i = i1) β†’ β„±.idβ€² }))
        p : unglue (βˆ‚ i) (ps i .id {x}) ≑
        p j = hfill (βˆ‚ i) (~ j) Ξ» where
          k (k = i0) β†’
          k (i = i0) β†’ F.F-id (~ k)
          k (i = i1) β†’
The case for compositions is analogous and yet much nastier, so I won’t comment on it. You can’t make me.
    input .compp i {x} {y} {z} {f} {g} {xβ€²} {yβ€²} {zβ€²} fβ€² gβ€² = glue-inc (βˆ‚ i)
        {Tf = sys i x z (ps i ._∘_ {x} {y} {z} f g) xβ€² zβ€²}
        (Ξ» { (i = i0) β†’ fβ€² β„°.βˆ˜β€² gβ€² ; (i = i1) β†’ fβ€² β„±.βˆ˜β€² gβ€² })
        (inS (comp (Ξ» j β†’ β„±.Hom[ p j ] (unglue (βˆ‚ i) xβ€²) (unglue (βˆ‚ i) zβ€²)) (βˆ‚ i)
          Ξ» { k (k = i0) β†’
                   unglue (βˆ‚ i) {T = Ξ» .βˆ‚i=i1 β†’ sys i y z f yβ€² zβ€² βˆ‚i=i1 .fst} fβ€²
              β„±.βˆ˜β€² unglue (βˆ‚ i) gβ€²
            ; k (i = i0) β†’ G.F-βˆ˜β€² {fβ€² = fβ€²} {gβ€² = gβ€²} (~ k)
            ; k (i = i1) β†’ fβ€² β„±.βˆ˜β€² gβ€² }))
        p : I β†’ C .Hom (unglue (i ∨ ~ i) x) (unglue (i ∨ ~ i) z)
        p j = hfill (βˆ‚ i) j Ξ» where
          k (i = i0) β†’ F.F-∘ f g (~ k)
          k (i = i1) β†’ f C.∘ g
          k (k = i0) β†’ unglue (βˆ‚ i) f C.∘ unglue (βˆ‚ i) g

As one last step, we show that if the functor GG is displayed over the identity, the path E→F\mathcal{E} \to \mathcal{F} is an actual identity, rather than a PathP.

    : (Fβ‚€-eqv : βˆ€ a β†’ is-equiv F.β‚€β€²)
    β†’ (F₁-eqv : βˆ€ {a b} {f : B .Hom a b} {aβ€² : β„°.Ob[ a ]} {bβ€² : β„°.Ob[ b ]}
              β†’ is-equiv (F.₁′ {f = f} {aβ€² = aβ€²} {bβ€² = bβ€²}))
    β†’ β„° ≑ β„±
  Displayed-path Fβ‚€-eqv F₁-eqv =
      (Ξ» i β†’ PathP
        (Ξ» j β†’ Displayed
          (to-path-refl {a = B} Precategory-identity-system i j) oβ€² β„“β€²) β„° β„±)
      (Displayed-pathp Id F (iso id-equiv id-equiv) Fβ‚€-eqv F₁-eqv)