open import 1Lab.Path.Groupoid
open import 1Lab.Type.Sigma
open import 1Lab.HLevel
open import 1Lab.Equiv
open import 1Lab.Path
open import 1Lab.Type

module 1Lab.Univalence where

UnivalenceπŸ”—

In Homotopy Type Theory, univalence is the principle stating that equivalent types can be identified. When the book first came out, there was no widely-accepted computational interpretation of this principle, so it was added to the theory as an axiom: the univalence axiom.

Precisely, the axiom as presented in the book consists of the following data (right under remark Β§2.10.4):

  • A map which turns equivalences into identifications of types. This map is called ua.

  • A rule for eliminating identifications of types, by turning them into equivalences: pathβ†’equiv

  • The propositional computation rule, stating that transport along ua(f) is identical to applying f: uaΞ².

In the book, there is an extra postulated datum asserting that ua is an inverse to pathβ†’equiv. This datum does not have a name in this development, because it’s proved in-line in the construction of the term univalence.

The point of cubical type theory is to give these terms constructive interpretations, i.e., make them definable in the theory, in terms of constructions that have computational behaviour. Let’s see how this is done.

GlueπŸ”—

To even state univalence, we first have to make sure that the concept of β€œpaths between types” makes sense in the first place. In β€œBook HoTT”, paths between types are a well-formed concept because the path type is uniformly inductively defined for everything β€” including universes. This is not the case in Cubical type theory, where for paths in TT to be well-behaved, TT must be fibrant.

Since there’s no obvious choice for how to interpret hcomp in Type, a fine solution is to make hcomp its own type former. This is the approach taken by some Cubical type theories in the RedPRL school. Univalence in those type theories is then achieved by adding a type former, called V, which turns an equivalence into a path.

In CCHM β€” and therefore Cubical Agda β€” a different approach is taken, which combines proving univalence with defining a fibrancy structure for the universe. The core idea is to define a new type former, Glue, which β€œglues” a partial type, along an equivalence, to a total type.

Glue : (A : Type β„“)
     β†’ {Ο† : I}
     β†’ (Te : Partial Ο† (Ξ£[ T ∈ Type β„“' ] (T ≃ A)))
     β†’ Type β„“'

The public interface of Glue demands a type AA, called the base type, a formula Ο†\varphi, and a partial type TT which is equivalent to AA. Since the equivalence is defined inside the partial element, it can also (potentially) vary over the interval, so in reality we have a family of partial types TT and a family of partial equivalences T≃AT \simeq A.

In the specific case where we set Ο†=Β¬i∨i\varphi = \neg i \lor i, we can illustrate Glue A (T, f) as the dashed line in the square diagram below. The conceptual idea is that by β€œgluing” TT onto a totally defined type, we get a type which extends TT.

For Glue to extend TT, we add a computation rule which could be called a boundary condition, since it specifies how Glue behaves on the boundaries of cubes. Concisely, when Ο†=i1\varphi = i1, we have that Glue evaluates to the partial type. This is exactly what it means for Glue to extend TT!

module _ {A B : Type} {e : A ≃ B} where
  private
    Glue-boundary : Glue B {i1} (Ξ» x β†’ A , e) ≑ A
    Glue-boundary i = A

Furthermore, since we can turn any family of paths into a family of equivalences, we can use the Glue construct to implement something with precisely the same interface as hcomp for Type:

glue-hfill
  : βˆ€ {β„“} Ο† (u : I β†’ Partial Ο† (Type β„“)) (u0 : Type β„“ [ Ο† ↦ u i0 ])
  β†’ βˆ€ i β†’ Type β„“ [ _ ↦ (Ξ» { (i = i0) β†’ outS u0
                          ; (Ο† = i1) β†’ u i 1=1 }) ]

The type of glue-hfill is the same as that of hfill, but the type is stated much more verbosely β€” so that we may define it without previous reference to a hcomp analogue. Like hfill, glue-hfill extends an open box of types to a totally-defined cube. The type of glue-hfill expresses this in terms of extensions: We have a path (that’s the βˆ€ i β†’ binder) of Types which agrees with outS u0 on the left endpoint, and with u everywhere.

glue-hfill Ο† u u0 i = inS (
  Glue (outS u0) {Ο† = Ο† ∨ ~ i}
    Ξ» { (Ο† = i1) β†’ u i 1=1 , lineβ†’equiv (Ξ» j β†’ u (i ∧ ~ j) 1=1)
      ; (i = i0) → outS u0 , line→equiv (λ i → outS u0)
      })

In the case for i=i0i = \id{i0}, we must glue u0u0 onto itself using the identity equivalence. This guarantees that the boundary of the stated type for glue-hfill is satisfied. However, since different faces of partial elements must agree where they are defined, we can not use the identity equivalence directly, since line→equiv refl is not definitionally the identity equivalence.

When Ο†=Ο•\varphi = \id{\phi}, hence where uu is defined, we glue the endpoint uu onto u0u0 using the equivalence generated by the path provided by uu itself! It’s a family of partial paths, after all, and that can be turned into a family of partial equivalences.

To show that glue-hfill expresses the fibrancy structure of the universe, we prove a theorem that says anything with the same interface as hfill must agree with hcomp on i1, and from this conclude that hcomp on Type agrees with the definition of glue-hfill.

hcomp-unique : βˆ€ {β„“} {A : Type β„“} {Ο†}
               (u : I β†’ Partial Ο† A)
               (u0 : A [ Ο† ↦ u i0 ])
             β†’ (h2 : βˆ€ i β†’ A [ _ ↦ (Ξ» { (i = i0) β†’ outS u0
                                      ; (Ο† = i1) β†’ u i 1=1 }) ])
             β†’ hcomp u (outS u0) ≑ outS (h2 i1)
hcomp-unique {Ο† = Ο†} u u0 h2 i =
  hcomp (Ξ» k β†’ Ξ» { (Ο† = i1) β†’ u k 1=1
                 ; (i = i1) β†’ outS (h2 k) })
        (outS u0)

Using hcomp-unique and glue-hfill together, we get a internal characterisation of the fibrancy structure of the universe. While hcomp-unique may appear surprising, it is essentially a generalisation of the uniqueness of path compositions: Any open box has a contractible space of fillers.

hcomp≑Glue : βˆ€ {β„“} {Ο†} (u : I β†’ Partial Ο† (Type β„“)) (u0 : Type β„“ [ Ο† ↦ u i0 ])
           β†’ hcomp u (outS u0)
           ≑ Glue (outS u0)
              (λ { (φ = i1) → u i1 1=1 , line→equiv (λ j → u (~ j) 1=1) })
hcomp≑Glue u u0 = hcomp-unique u u0 (glue-hfill _ u u0)

Paths from GlueπŸ”—

Since Glue generalises hcomp by allowing a partial equivalence as its β€œtube”, rather than a partial path, it allows us to turn any equivalence into a path, using a sort of β€œtrick”: We consider the line with endpoints AA and BB as an open cube to be filled. A filler for this line is exactly a path A≑BA \equiv B. Since Glue fills open boxes of types using equivalences, this path exists!

ua : {A B : Type β„“} β†’ A ≃ B β†’ A ≑ B
ua {A = A} {B} eqv i = Glue B Ξ» { (i = i0) β†’ A , eqv
                                ; (i = i1) β†’ B , _ , id-equiv
                                }

Semantically, the explanation of ua as completing a partial line is sufficient. But we can also ask ourselves: Why does this definition go through, syntactically? Because of the boundary condition for Glue: when i = i0, the whole thing evaluates to A, meaning that the left endpoint of the path is correct. The same thing happens with the right endpoint.

The action of transporting along ua(f) can be described by chasing an element around the diagram that illustrates Glue in the Ο†=i∨¬i\varphi = i \lor \neg i case, specialising to ua. Keep in mind that, since the right face of the diagram β€œpoints in the wrong direction”, it must be inverted. However, the inverse of the identity equivalence is the identity equivalence, so nothing changes (for this example).

  1. The action that corresponds to the left face of the diagram is to apply the underlying function of f. This contributes the f .fst x part of the uaΞ² term below.
  1. For the bottom face, we have a path rather than an equivalence, so we must transport along it. In this case, the path is the reflexivity on B, but in a more general Glue construction, it might be a non-trivial path.

To compensate for this extra transport, we use coe1β†’i, which connects f .fst x and transport (Ξ» i β†’ B) (f .fst x).

  1. Finally, we apply the inverse of the identity equivalence, corresponding to the right face in the diagram. This immediately computes away, and thus contributes nothing to the uaΞ² path.
uaΞ² : {A B : Type β„“} (f : A ≃ B) (x : A) β†’ transport (ua f) x ≑ f .fst x
uaΞ² {A = A} {B} f x i = coe1β†’i (Ξ» _ β†’ B) i (f .fst x)

Since ua is a map that turns equivalences into paths, we can compose it with a function that turns isomorphisms into equivalences to get the map Iso→Path.

Isoβ†’Path : {A B : Type β„“} β†’ Iso A B β†’ A ≑ B
Iso→Path (f , iiso) = ua (f , is-iso→is-equiv iiso)

Paths over uaπŸ”—

The introduction and elimination forms for Glue can be specialised to the case of ua, leading to the definitions of ua-glue and ua-unglue below. Their types are written in terms of interval variables and extensions, rather than using Paths, because these typings make the structure of Glue more explicit.

The first, ua-unglue, tells us that if we have some x : ua e i (varying over an interval variable i), then we have an element of B which agrees with e .fst x on the left and with x on the right.

ua-unglue : βˆ€ {A B : Type β„“} (e : A ≃ B) (i : I) (x : ua e i)
            β†’ B [ _ ↦ (Ξ» { (i = i0) β†’ e .fst x
                         ; (i = i1) β†’ x }) ]
ua-unglue e i x = inS (unglue (i ∨ ~ i) x)

We can factor the interval variable out, to get a type in terms of PathP, leading to an explanation of ua-unglue without mentioning extensions: A path x ≑ y over ua e induces a path e .fst x ≑ y.

ua-pathpβ†’path : βˆ€ {A B : Type β„“} (e : A ≃ B) {x : A} {y : B}
              β†’ PathP (Ξ» i β†’ ua e i) x y
              β†’ e .fst x ≑ y
ua-pathp→path e p i = outS (ua-unglue e i (p i))

In the other direction, we have ua-glue, which expresses that a path e .fst x ≑ y implies that x ≑ y over ua e. For the type of ua-glue, suppose that we have a partial element xx defined on the left endpoint of the interval, together with an extension yy of e(x)e(x) where xx is defined. What ua-glue expresses is that we can complete this to a path in ua(e)\id{ua}(e), which agrees with xx and yy where these are defined.

ua-glue : βˆ€ {A B : Type β„“} (e : A ≃ B) (i : I)
            (x : Partial (~ i) A)
            (y : B [ _ ↦ (Ξ» { (i = i0) β†’ e .fst (x 1=1) }) ])
          β†’ ua e i [ _ ↦ (Ξ» { (i = i0) β†’ x 1=1
                            ; (i = i1) β†’ outS y
                            }) ]
ua-glue e i x y = inS (prim^glue {Ο† = i ∨ ~ i}
                                 (Ξ» { (i = i0) β†’ x 1=1
                                    ; (i = i1) β†’ outS y })
                                 (outS y))

Observe that, since yy is partially in the image of xx, this essentially constrains xx to be a β€œpartial preimage” of yy under the equivalence ee. Factoring in the type of the interval, we get the promised map between dependent paths over ua and paths in B.

pathβ†’ua-pathp : βˆ€ {A B : Type β„“} (e : A ≃ B) {x : A} {y : B}
              β†’ e .fst x ≑ y
              β†’ PathP (Ξ» i β†’ ua e i) x y
path→ua-pathp e {x = x} p i = outS (ua-glue e i (λ { (i = i0) → x }) (inS (p i)))

The β€œpathp to path” versions of the above lemmas are definitionally inverses, so they provide a characterisation of PathP (ua f) in terms of non-dependent paths.

ua-pathp≃path : βˆ€ {A B : Type β„“} (e : A ≃ B) {x : A} {y : B}
              β†’ (e .fst x ≑ y) ≃ (PathP (Ξ» i β†’ ua e i) x y)
ua-pathp≃path eqv .fst = pathβ†’ua-pathp eqv
ua-pathp≃path eqv .snd .is-eqv y .centre = strict-fibres (ua-pathpβ†’path eqv) y .fst
ua-pathp≃path eqv .snd .is-eqv y .paths = strict-fibres (ua-pathpβ†’path eqv) y .snd

The β€œaxiomβ€πŸ”—

The actual β€œunivalence axiom”, as stated in the HoTT book, says that the canonical map A ≑ B, defined using J, is an equivalence. This map is idβ†’equiv, defined right above. In more intuitive terms, it’s β€œcasting” the identity equivalence A ≃ A along a proof that A ≑ B to get an equivalence A ≃ B.

module _ where private
  idβ†’equiv : {A B : Type β„“} β†’ A ≑ B β†’ A ≃ B
  idβ†’equiv {A = A} {B} = J (Ξ» x _ β†’ A ≃ x) (_ , id-equiv)

  idβ†’equiv-refl : {A : Type β„“} β†’ idβ†’equiv (Ξ» i β†’ A) ≑ (_ , id-equiv)
  idβ†’equiv-refl {A = A} = J-refl (Ξ» x _ β†’ A ≃ x) (_ , id-equiv)

However, because of efficiency concerns (Agda is a programming language, after all), instead of using id→equiv defined using J, we use path→equiv, which is defined in an auxilliary module.

pathβ†’equiv : {A B : Type β„“} β†’ A ≑ B β†’ A ≃ B
path→equiv p = line→equiv (λ i → p i)

Since identity of equivalences is determined by identity of their underlying functions, to show that path→equiv of refl is the identity equivalence, we use coe1→i to show that transport by refl is the identity.

pathβ†’equiv-refl : {A : Type β„“} β†’ pathβ†’equiv (refl {x = A}) ≑ (id , id-equiv)
path→equiv-refl {A = A} =
  Ξ£-path (Ξ» i x β†’ coe1β†’i (Ξ» i β†’ A) i x)
         (is-prop→pathp (λ i → is-equiv-is-prop _) _ _)

For the other direction, we must show that ua of id-equiv is refl. We can do this quite efficiently using Glue. Since this is a path between paths, we have two interval variables.

ua-id-equiv : {A : Type β„“} β†’ ua (_ , id-equiv {A = A}) ≑ refl
ua-id-equiv {A = A} i j = Glue A {Ο† = i ∨ ~ j ∨ j} (Ξ» _ β†’ A , _ , id-equiv)

We can then prove that the map pathβ†’equiv is an isomorphism, hence an equivalence. It’s very useful to have explicit names for the proofs that pathβ†’equiv and ua are equivalences without referring to components of Path≃Equiv, so we introduce names for them as well.

Path≃Equiv   : {A B : Type β„“} β†’ Iso (A ≑ B) (A ≃ B)
univalence   : {A B : Type ℓ} → is-equiv (path→equiv {A = A} {B})
univalence⁻¹ : {A B : Type β„“} β†’ is-equiv (ua {A = A} {B})

Path≃Equiv {A = A} {B = B} = pathβ†’equiv , iiso where
  iiso : is-iso path→equiv
  is-iso.inv iiso = ua

We show that path→equiv inverts ua, which means proving that one can recover the original equivalence from the generated path. Because of the computational nature of Cubical Agda, all we have to do is apply uaβ:

  is-iso.rinv iiso (f , is-eqv) =
    Ξ£-path (funext (uaΞ² (f , is-eqv))) (is-equiv-is-prop f _ _)

For the other direction, we use path induction to reduce the problem from showing that ua inverts path→equiv for an arbitrary path (which is hard) to showing that path→equiv takes refl to the identity equivalence (path→equiv-refl), and that ua takes the identity equivalence to refl (ua-id-equiv).

  is-iso.linv iiso =
    J (Ξ» _ p β†’ ua (pathβ†’equiv p) ≑ p)
      (ap ua pathβ†’equiv-refl βˆ™ ua-id-equiv)

univalence {A = A} {B} = is-isoβ†’is-equiv (Path≃Equiv .snd)
univalence⁻¹ {A = A} {B} = is-isoβ†’is-equiv (is-iso.inverse (Path≃Equiv .snd))

In some situations, it is helpful to have a proof that path→equiv followed by an adjustment of levels is still an equivalence:

univalence-lift : {A B : Type ℓ} → is-equiv (λ e → lift (path→equiv {A = A} {B} e))
univalence-lift {ℓ = ℓ} = is-iso→is-equiv morp where
  morp : is-iso (λ e → lift {ℓ = lsuc ℓ} (path→equiv e))
  morp .is-iso.inv x = ua (x .Lift.lower)
  morp .is-iso.rinv x =
    lift (pathβ†’equiv (ua (x .Lift.lower))) β‰‘βŸ¨ ap lift (Path≃Equiv .snd .is-iso.rinv _) βŸ©β‰‘
    x                                      ∎
  morp .is-iso.linv x = Path≃Equiv .snd .is-iso.linv _

Equivalence InductionπŸ”—

One useful consequence of (A≑B)≃(A≃B)(A \equiv B) \simeq (A \simeq B)1 is that the type of equivalences satisfies the same induction principle as the type of identifications. By analogy with how path induction can be characterised as contractibility of singletons and transport, β€œequivalence induction” can be characterised as transport and contractibility of singletons up to equivalence:

Equiv-is-contr : βˆ€ {β„“} (A : Type β„“) β†’ is-contr (Ξ£[ B ∈ Type β„“ ] A ≃ B)
is-contr.centre (Equiv-is-contr A)            = A , _ , id-equiv
is-contr.paths (Equiv-is-contr A) (B , A≃B) i = ua A≃B i , p i , q i where
  p : PathP (Ξ» i β†’ A β†’ ua A≃B i) id (A≃B .fst)
  p i x = outS (ua-glue A≃B i (Ξ» { (i = i0) β†’ x }) (inS (A≃B .fst x)))

  q : PathP (Ξ» i β†’ is-equiv (p i)) id-equiv (A≃B .snd)
  q = is-prop→pathp (λ i → is-equiv-is-prop (p i)) _ _

Combining Equiv-is-contr with subst, we get an induction principle for the type of equivalences based at AA: To prove P(B,e)P(B,e) for any e:A≃Be : A \simeq B, it suffices to consider the case where BB is AA and ee is the identity equivalence.

EquivJ : βˆ€ {β„“ β„“'} {A : Type β„“}
       β†’ (P : (B : Type β„“) β†’ A ≃ B β†’ Type β„“')
       β†’ P A (_ , id-equiv)
       β†’ {B : Type β„“} (e : A ≃ B)
       β†’ P B e
EquivJ P pid eqv =
  subst (Ξ» e β†’ P (e .fst) (e .snd)) (Equiv-is-contr _ .is-contr.paths (_ , eqv)) pid

Equivalence induction simplifies the proofs of many properties about equivalences. For example, if ff is an equivalence, then so is its action on paths ap(f)\id{ap}(f).

is-equivβ†’is-embedding : βˆ€ {β„“} {A B : Type β„“}
                      β†’ (f : A β†’ B) β†’ is-equiv f
                      β†’ {x y : A}
                      β†’ is-equiv (ap f {x = x} {y = y})
is-equiv→is-embedding f eqv =
  EquivJ (Ξ» B e β†’ is-equiv (ap (e .fst))) id-equiv (f , eqv)

The proof can be rendered in English roughly as follows:

Suppose f:Aβ†’Bf : A \to B is an equivalence. We want to show that, for any choice of x,y:Ax, y : A, the map ap(f)x,y:x≑yβ†’f(x)≑f(y)\id{ap}(f)_{x,y} : x \equiv y \to f(x) \equiv f(y) is an equivalence.

By induction, it suffices to cover the case where BB is AA, and ff is the identity function.

But then, we have that ap(id)\id{ap}(\id{id}) is definitionally equal to id\id{id}, which is known to be an equivalence. β– \blacksquare

Object ClassifiersπŸ”—

In category theory, the idea of classifiers (or classifying objects) often comes up when categories applied to the study of logic. For example, any elementary topos has a subobject classifier: an object Ξ©\Omega such that maps Bβ†’Ξ©B \to \Omega corresponds to maps Aβ†’BA \to B with propositional fibres (equivalently, inclusions Aβ†ͺBA \hookrightarrow B). In higher categorical analyses of logic, classifying objects exist for more maps: an elementary 2-topos has a discrete object classifier, which classify maps with discrete fibres.

Since a (1,1)(1,1)-topos has classifiers for maps with (βˆ’1)(-1)-truncated fibres, and a (2,1)(2,1)-topos has classifiers for maps with 00-truncated fibres, one might expect that an (∞,1)\io-topos would have classifiers for maps with fibres that are not truncated at all. This is indeed the case! In HoTT, this fact is internalised using the univalent universes, and we can prove that univalent universes are object classifiers.

As an intermediate step, we prove that the value B(a)B(a) of a type family BB at a point aa is equivalent to the fibre of fst:Ξ£(x:A)B(x)β†’A\id{fst} : \Sigma_{(x : A)}B(x) \to A over aa. The proof follows from the De Morgan structure on the interval, and the β€œspread” operation coe1β†’i.

-- HoTT book lemma 4.8.1
Fibre-equiv : (B : A β†’ Type β„“') (a : A)
            β†’ fibre (fst {B = B}) a ≃ B a
Fibre-equiv B a = Iso→Equiv isom where
  isom : Iso _ _
  isom .fst ((x , y) , p) = subst B p y
  isom .snd .inv x        = (a , x) , refl
  isom .snd .rinv x i     = coe1β†’i (Ξ» _ β†’ B a) i x
  isom .snd .linv ((x , y) , p) i =
    (p (~ i) , coe1β†’i (Ξ» j β†’ B (p (~ i ∧ ~ j))) i y) , Ξ» j β†’ p (~ i ∨ j)

Another fact from homotopy theory that we can import into homotopy type theory is that any map is equivalent to a fibration. More specifically, given a map p:Eβ†’Bp : E \to B, the total space EE is equivalent to the dependent sum of the fibres. The theorems Total-equiv and Fibre-equiv are what justify referring to Ξ£ the β€œtotal space” of a type family.

Total-equiv : (p : E β†’ B) β†’ E ≃ Ξ£ (fibre p)
Total-equiv p = Iso→Equiv isom where
  isom : Iso _ (Ξ£ (fibre p))
  isom .fst x                   = p x , x , refl
  isom .snd .inv (_ , x , _)    = x
  isom .snd .rinv (b , x , q) i = q i , x , Ξ» j β†’ q (i ∧ j)
  isom .snd .linv x             = refl

Putting these together, we get the promised theorem: The space of maps Bβ†’TypeB \to \ty is equivalent to the space of fibrations with base space BB and variable total space EE, Ξ£(E:Type)(Eβ†’B)\Sigma_{(E : \ty)} (E \to B). If we allow EE and BB to live in different universes, then the maps are classified by the biggest universe in which they both fit, namely Type (β„“ βŠ” β„“'). Note that the proof of Fibration-equiv makes fundamental use of ua, to construct the witnesses that taking fibres and taking total spaces are inverses. Without ua, we could only get an β€œisomorphism-up-to-equivalence” of types.

Fibration-equiv : βˆ€ {β„“ β„“'} {B : Type β„“}
                β†’ (Ξ£[ E ∈ Type (β„“ βŠ” β„“') ] (E β†’ B))
                ≃ (B β†’ Type (β„“ βŠ” β„“'))
Fibration-equiv {B = B} = Iso→Equiv isom where
  isom : Iso (Ξ£[ E ∈ Type _ ] (E β†’ B)) (B β†’ Type _)
  isom .fst (E , p)       = fibre p
  isom .snd .inv p⁻¹      = Σ p⁻¹ , fst
  isom .snd .rinv prep i x = ua (Fibre-equiv prep x) i
  isom .snd .linv (E , p) i
    = ua e (~ i) , Ξ» x β†’ fst (outS (ua-unglue e (~ i) x))
    where e = Total-equiv p

To solidify the explanation that object classifiers generalise the (nβˆ’2)(n-2)-truncated object classifiers you would find in a (n,1)(n,1)-topos, we prove that any class of maps described by a property PP which holds of all of its fibres (or even structure on all of its fibres!) has a classifying object β€” the total space Ξ£P\Sigma P.

For instance, if we take PP to be the property of being a proposition, this theorem tells us that Ξ£ is-prop classifies subobjects. With the slight caveat that Ξ£ is-prop is not closed under impredicative quantification, this corresponds exactly to the notion of subobject classifier in a (1,1)(1,1)-topos, since the maps with propositional fibres are precisely the injective maps.

Since the type of β€œmaps into B with variable domain and P fibres” has a very unwieldy description β€” both in words or in Agda syntax β€” we abbreviate it by β„“/[P]B\ell /_{[P]} B. The notation is meant to evoke the idea of a slice category: The objects of C/cC/c are objects of the category CC equipped with choices of maps into cc. Similarly, the objects of β„“/[P]B\ell/_{[P]}B are objects of the universe TypeΒ β„“\ty\ \ell, with a choice of map ff into BB, such that PP holds for all the fibres of ff.

_/[_]_ : βˆ€ {β„“' β„“''} (β„“ : Level) β†’ (Type (β„“ βŠ” β„“') β†’ Type β„“'') β†’ Type β„“' β†’ Type _
_/[_]_ {β„“} β„“' P B =
  Ξ£ Ξ» (A : Type (β„“ βŠ” β„“')) β†’
  Ξ£ Ξ» (f : A β†’ B) β†’
  (x : B) β†’ P (fibre f x)

The proof that the slice β„“/[P]B\ell /_{[P]} B is classified by Ξ£P\Sigma P follows from elementary properties of Ξ£\Sigma types (namely: reassociation, distributivity of Ξ£\Sigma over Ξ \Pi), and the classification theorem Fibration-equiv. Really, the most complicated part of this proof is rearranging the nested sum and product types to a form to which we can apply Fibration-equiv.

Map-classifier
  : βˆ€ {β„“ β„“' β„“''} {B : Type β„“'} (P : Type (β„“ βŠ” β„“') β†’ Type β„“'')
  β†’ (β„“ /[ P ] B) ≃ (B β†’ Ξ£ P)
Map-classifier {β„“ = β„“} {B = B} P =
  (Ξ£ Ξ» A β†’ Ξ£ Ξ» f β†’ (x : B) β†’ P (fibre f x))     β‰ƒβŸ¨ Ξ£-assoc βŸ©β‰ƒ
  (Ξ£ Ξ» { (x , f) β†’ (x : B) β†’ P (fibre f x) })   β‰ƒβŸ¨ Ξ£-ap-fst (Fibration-equiv {β„“' = β„“}) βŸ©β‰ƒ
  (Ξ£ Ξ» A β†’ (x : B) β†’ P (A x))                   β‰ƒβŸ¨ Ξ£-Ξ -distrib e⁻¹ βŸ©β‰ƒ
  (B β†’ Ξ£ P)                                     β‰ƒβˆŽ

  1. Not the fundamental theorem of engineering!β†©οΈŽ