@@ -0,0 +1,29 @@
1+module Data.Vect
2+
3+import Language.Reflection
4+
5+--------------------------------------------------------------------------------
6+-- Elem
7+--------------------------------------------------------------------------------
8+
9+data Elem : a -> Vect a k -> Type where
10+ Here : {xs : Vect a k} -> Elem x (x::xs)
11+ There : {xs : Vect a k} -> Elem x xs -> Elem x (y::xs)
12+
13+findElem : Nat -> List (TTName, Binder TT) -> TT -> Tactic
14+findElem O ctxt goal = Refine "Here" `Seq` Solve
15+findElem (S n) ctxt goal = GoalType "Elem" (Try (Refine "Here" `Seq` Solve) (Refine "There" `Seq` (Solve `Seq` findElem n ctxt goal)))
16+
17+replaceElem : (xs : Vect t k) -> Elem x xs -> (y : t) -> (ys : Vect t k ** Elem y ys)
18+replaceElem (x::xs) Here y = (y :: xs ** Here)
19+replaceElem (x::xs) (There xinxs) y with (replaceElem xs xinxs y)
20+ | (ys ** yinys) = (x :: ys ** There yinys)
21+
22+replaceByElem : (xs : Vect t k) -> Elem x xs -> t -> Vect t k
23+replaceByElem (x::xs) Here y = y :: xs
24+replaceByElem (x::xs) (There xinxs) y = x :: replaceByElem xs xinxs y
25+
26+mapElem : {xs : Vect t k} -> {f : t -> u} -> Elem x xs -> Elem (f x) (map f xs)
27+mapElem Here = Here
28+mapElem (There e) = There (mapElem e)
29+