module 1Lab.Path.IdentitySystem where

Identity systemsπŸ”—

An identity system is a way of characterising the path spaces of a particular type, without necessarily having to construct a full encode-decode equaivalence. Essentially, the data of an identity system is precisely the data required to implement path induction, a.k.a. the J eliminator. Any type with the data of an identity system satisfies its own J, and conversely, if the type satisfies J, it is an identity system.

We unravel the definition of being an identity system into the following data, using a translation that takes advantage of cubical type theory’s native support for paths-over-paths:

  is-identity-system {β„“ β„“β€²} {A : Type β„“}
    (R : A β†’ A β†’ Type β„“β€²)
    (refl : βˆ€ a β†’ R a a)
    : Type (β„“ βŠ” β„“β€²)
    to-path      : βˆ€ {a b} β†’ R a b β†’ a ≑ b
      : βˆ€ {a b} (p : R a b)
      β†’ PathP (Ξ» i β†’ R a (to-path p i)) (refl a) p

  is-contr-Ξ£R : βˆ€ {a} β†’ is-contr (Ξ£ A (R a))
  is-contr-Ξ£R .centre    = _ , refl _
  is-contr-Ξ£R .paths x i = to-path (x .snd) i , to-path-over (x .snd) i

open is-identity-system public

As mentioned before, the data of an identity system gives is exactly what is required to prove J for the relation RR. This is essentially the decomposition of J into contractibility of singletons, but with singletons replaced by RR-singletons.

  : βˆ€ {β„“ β„“β€² β„“β€²β€²} {A : Type β„“} {R : A β†’ A β†’ Type β„“β€²} {r : βˆ€ a β†’ R a a} {a : A}
  β†’ is-identity-system R r
  β†’ (P : βˆ€ b β†’ R a b β†’ Type β„“β€²β€²)
  β†’ P a (r a)
  β†’ βˆ€ {b} s β†’ P b s
IdsJ ids P pr s =
  transport (Ξ» i β†’ P (ids .to-path s i) (ids .to-path-over s i)) pr

If we have a relation RR together with reflexivity witness rr, then any equivalence f:R(a,b)≃(a≑b)f : R(a, b) \simeq (a \equiv b) which maps f(r)=reflf(r) = \id{refl} equips (R,r)(R, r) with the structure of an identity system. Of course if we do not particularly care about the specific reflexivity witness, we can simply define rr as fβˆ’1(refl)f^{-1}(\id{refl}).

  : βˆ€ {β„“ β„“β€²} {A : Type β„“} {R : A β†’ A β†’ Type β„“β€²} {r : βˆ€ a β†’ R a a}
  β†’ (eqv : βˆ€ {a b} β†’ R a b ≃ (a ≑ b))
  β†’ (βˆ€ a β†’ Equiv.from eqv refl ≑ r a)
  β†’ is-identity-system R r
equiv-path→identity-system {R = R} {r = r} eqv pres′ = ids where
  contract : βˆ€ {a} β†’ is-contr (Ξ£ _ (R a))
  contract = is-hlevel≃ 0 ((total (Ξ» _ β†’ eqv .fst) , equivβ†’total (eqv .snd)))
    (contr _ Singleton-is-contr)

  pres : βˆ€ {a} β†’ eqv .fst (r a) ≑ refl
  pres {a = a} = Equiv.injectiveβ‚‚ (eqv e⁻¹) (Equiv.Ξ· eqv _) (presβ€² _)

  ids : is-identity-system R r
  ids .to-path = eqv .fst
  ids .to-path-over {a = a} {b = b} p i =
    (Ξ» i β†’ is-contrβ†’is-prop (eqv .snd .is-eqv Ξ» j β†’ eqv .fst p (i ∧ j)))
    (r a , pres)
    (p , refl)
    i .fst

Note that for any (R,r)(R, r), the type of identity sytem data on (R,r)(R, r) is a proposition. This is because it is exactly equivalent to the type βˆ‘a(Ra)\sum_a (R a) being contractible for every aa, which is a proposition by standard results.

  : βˆ€ {β„“ β„“β€²} {A : Type β„“} {R : A β†’ A β†’ Type β„“β€²} {r : βˆ€ a β†’ R a a}
  β†’ is-identity-system R r
  β†’ βˆ€ {a b} β†’ R a b ≃ (a ≑ b)
identity-system-gives-path ids {a = a} =
  ids .to-path {a = a}
  , total→equiv {f = λ x → ids .to-path {a = a} {b = x}}
    (is-contr→is-equiv (is-contr-ΣR ids) (contr _ Singleton-is-contr))

In subtypesπŸ”—

Let f:Aβ†ͺBf : A \mono B be an embedding. If (R,r)(R, r) is an identity system on BB, then it can be pulled back along ff to an identity system on AA.

  _ {β„“ β„“β€² β„“β€²β€²} {A : Type β„“} {B : Type β„“β€²}
    {R : B β†’ B β†’ Type β„“β€²β€²} {r : βˆ€ a β†’ R a a}
    (ids : is-identity-system R r)
    (f : A β†ͺ B)

    : is-identity-system (Ξ» x y β†’ R (f .fst x) (f .fst y)) (Ξ» _ β†’ r _)
  pullback-identity-system .to-path {a} {b} x = ap fst $
    f .snd (f .fst b) (a , ids .to-path x) (b , refl)
  pullback-identity-system .to-path-over {a} {b} p i =
      (Ξ» j β†’ R (f .fst a) (f .snd (f .fst b) (a , ids .to-path p) (b , refl) i .snd (~ j)))
      (βˆ‚ i) Ξ» where
      k (k = i0) β†’ ids .to-path-over p (~ k)
      k (i = i0) β†’ ids .to-path-over p (~ k ∨ i)
      k (i = i1) β†’ p


Note that univalence is precisely the statement that equivalences are an identity system on the universe:

  : βˆ€ {β„“} β†’ is-identity-system {A = Type β„“} _≃_ Ξ» _ β†’ id , id-equiv
univalence-identity-system .to-path = ua
univalence-identity-system .to-path-over p =
  Σ-prop-pathp (λ _ → is-equiv-is-prop) $ funextP $ λ a → path→ua-pathp p refl

Sets and Hedberg’s theoremπŸ”—

We now apply the general theory of identity systems to something a lot more mundane: recognising sets. An immediate consequence of having an identity system (R,r)(R, r) on a type AA is that, if RR is pointwise an nn-type, then AA is an (n+1)(n+1)-type. Now, if RR is a reflexive family of propositions, then all we need for (R,r)(R, r) to be an identity system is that R(x,y)β†’x=yR(x, y) \to x = y, by the previous observation, this implies AA is a set.

  : βˆ€ {β„“ β„“β€²} {A : Type β„“} {R : A β†’ A β†’ Type β„“β€²} {r : βˆ€ x β†’ R x x}
  β†’ (βˆ€ x y β†’ is-prop (R x y))
  β†’ (βˆ€ {x y} β†’ R x y β†’ x ≑ y)
  β†’ is-identity-system R r
set-identity-system rprop rpath .to-path = rpath
set-identity-system rprop rpath .to-path-over p =
  is-prop→pathp (λ i → rprop _ _) _ p

If AA is a type with ¬¬-stable equality, then by the theorem above, the pointwise double negation of its identity types is an identity system: and so, if a type has decidable (thus ¬¬-stable) equality, it is a set.

  : βˆ€ {β„“} {A : Type β„“}
  β†’ (βˆ€ {x y} β†’ ((Path A x y β†’ βŠ₯) β†’ βŠ₯) β†’ x ≑ y)
  β†’ is-identity-system (Ξ» x y β†’ (Path A x y β†’ βŠ₯) β†’ βŠ₯) Ξ» a k β†’ k refl
¬¬-stable-identity-system = set-identity-system Ξ» x y f g β†’
  funext Ξ» h β†’ absurd (g h)

Discreteβ†’is-set : βˆ€ {β„“} {A : Type β„“} β†’ Discrete A β†’ is-set A
Discrete→is-set {A = A} dec =
  identity-systemβ†’hlevel 1 (¬¬-stable-identity-system stable) Ξ» x y f g β†’
    funext Ξ» h β†’ absurd (g h)
    stable : {x y : A} β†’ ((x ≑ y β†’ βŠ₯) β†’ βŠ₯) β†’ x ≑ y
    stable {x = x} {y = y} ¬¬p with dec x y
    ... | yes p = p
    ... | no ¬p = absurd (¬¬p ¬p)