Vec.agda 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. module Vec where
  2. open import Star
  3. open import Nat
  4. data Step (A : Set) : Nat -> Nat -> Set where
  5. step : (x : A){n : Nat} -> Step A (suc n) n
  6. Vec : (A : Set) -> Nat -> Set
  7. Vec A n = Star (Step A) n zero
  8. [] : {A : Set} -> Vec A zero
  9. [] = ε
  10. _::_ : {A : Set}{n : Nat} -> A -> Vec A n -> Vec A (suc n)
  11. x :: xs = step x • xs
  12. _+++_ : {A : Set}{n m : Nat} -> Vec A n -> Vec A m -> Vec A (n + m)
  13. _+++_ {A}{m = m} xs ys = map +m step+m xs ++ ys
  14. where
  15. +m = \z -> z + m
  16. step+m : Step A =[ +m ]=> Step A
  17. step+m (step x) = step x
  18. vec : {A : Set}{n : Nat} -> A -> Vec A n
  19. vec {n = ε} x = []
  20. vec {n = _ • n} x = x :: vec x
  21. _⊗_ : {A B : Set}{n : Nat} -> Vec (A -> B) n -> Vec A n -> Vec B n
  22. ε ⊗ ε = []
  23. (step f • fs) ⊗ (step x • xs) = f x :: (fs ⊗ xs)
  24. ε ⊗ (() • _)
  25. {- Some proof about _-_ needed...
  26. vreverse : {A : Set}{n : Nat} -> Vec A n -> Vec A n
  27. vreverse {A}{n} xs = {! !} -- map i f (reverse xs)
  28. where
  29. i : Nat -> Nat
  30. i m = n - m
  31. f : Step A op =[ i ]=> Step A
  32. f (step x) = {! !} -- step x
  33. -}