----------------------------------------------------------------------------------------------------

-- de Bruijn indices

module A202401.DBI {𝓍} {X : Set 𝓍} where

open import A202401.Prelude public


----------------------------------------------------------------------------------------------------

infix 3 _βˆ‹_
data _βˆ‹_ : Rist X β†’ X β†’ Set 𝓍 where
  zero : βˆ€ {Ξ“ A} β†’ Ξ“ , A βˆ‹ A
  wkβˆ‹  : βˆ€ {B Ξ“ A} (i : Ξ“ βˆ‹ A) β†’ Ξ“ , B βˆ‹ A


----------------------------------------------------------------------------------------------------

-- TODO: delete?

injwkβˆ‹ : βˆ€ {Ξ“ A B} {i iβ€² : Ξ“ βˆ‹ A} β†’ wkβˆ‹ i ≑ wkβˆ‹ {B} iβ€² β†’ i ≑ iβ€²
injwkβˆ‹ refl = refl

infix 4 _β‰Ÿβˆ‹_
_β‰Ÿβˆ‹_ : βˆ€ {Ξ“ A} (i iβ€² : Ξ“ βˆ‹ A) β†’ Dec (i ≑ iβ€²)
zero  β‰Ÿβˆ‹ zero   = yes refl
zero  β‰Ÿβˆ‹ wkβˆ‹ iβ€² = no Ξ» ()
wkβˆ‹ i β‰Ÿβˆ‹ zero   = no Ξ» ()
wkβˆ‹ i β‰Ÿβˆ‹ wkβˆ‹ iβ€² with i β‰Ÿβˆ‹ iβ€²
... | yes refl    = yes refl
... | no Β¬eq      = no Ξ» { refl β†’ refl β†― Β¬eq }


----------------------------------------------------------------------------------------------------