module DPRLR.Simplicial.Discrete where

open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Bool.Base renaming (Bool to Bool₂)
open import Cubical.Data.Sigma

open import DPRLR.Simplicial.Hom

private
  variable
     : Level
    A : Type 

idtoarr :
  {x y : A}
   x  y
   x  y
idtoarr =
  path→hom

idtoarr-refl :
  {x : A}
   idtoarr (refl {x = x})  hom-refl x
idtoarr-refl {x = x} =
  substRefl {B = λ y  x  y} (hom-refl x)

isDiscrete : Type   Type 
isDiscrete A =
  (x y : A)  isEquiv (idtoarr {A = A} {x = x} {y = y})

arr→path :
  {A : Type }
   isDiscrete A
   {x y : A}
   x  y
   x  y
arr→path d {x = x} {y = y} =
  invIsEq (d x y)

idtoarr-arr→path :
  {A : Type }
   (d : isDiscrete A)
   {x y : A}
   (f : x  y)
   idtoarr (arr→path d f)  f
idtoarr-arr→path d {x = x} {y = y} =
  secIsEq (d x y)

path-to-isContr :
  {A : Type }
   (a : A)
   isContr (Σ A  x  x  a))
path-to-isContr a =
  isOfHLevelRespectEquiv 0
    (Σ-cong-equiv-snd  _  isoToEquiv (iso sym sym  _  refl)  _  refl))))
    (isContrSingl a)

hom-to-isContr :
  {A : Type }
   isDiscrete A
   (a : A)
   isContr (Σ A  x  x  a))
hom-to-isContr d a =
  isOfHLevelRespectEquiv 0
    (Σ-cong-equiv-snd  x  idtoarr , d x a))
    (path-to-isContr a)

postulate
  Bool₂-isDiscrete : isDiscrete Bool₂