Context.lagda 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. \AgdaHide{
  2. \begin{code}
  3. module Issue854.Context where
  4. open import Level hiding (zero; suc)
  5. open import Data.Nat hiding (_⊔_)
  6. open import Data.Fin
  7. open import Relation.Binary hiding (Rel)
  8. infix 4 _∋_
  9. infixl 5 _▻_
  10. ------------------------------------------------------------------------
  11. data Snoc {a} (A : Set a) : Set a where
  12. [] : Snoc A
  13. _▻_ : (xs : Snoc A) (x : A) → Snoc A
  14. data _∋_ {a} {A : Set a} : Snoc A → A → Set a where
  15. zero : ∀ {x xs} → xs ▻ x ∋ x
  16. suc : ∀ {x y xs} → xs ∋ x → xs ▻ y ∋ x
  17. length : ∀ {a} {A : Set a} → Snoc A → ℕ
  18. length [] = 0
  19. length (xs ▻ _) = suc (length xs)
  20. index : ∀ {a} {A : Set a} {xs : Snoc A} {x : A} → xs ∋ x → Fin (length xs)
  21. index zero = zero
  22. index (suc p) = suc (index p)
  23. data Rel {a b ℓ} {A : Set a} {B : Set b}
  24. (_∼_ : REL A B ℓ) : Snoc A → Snoc B → Set (a ⊔ b ⊔ ℓ) where
  25. [] : Rel _∼_ [] []
  26. _▻_ : ∀ {x xs y ys} → x ∼ y → Rel _∼_ xs ys → Rel _∼_ (xs ▻ x) (ys ▻ y)
  27. \end{code}
  28. }