Fixpoint repeat {A:Type}(n:nat)(x:A) : list A :=
match n with
| 0 => nil
| S n' => x :: repeat n' x
end.

(* Specifications: *)
Lemma firstn_repeat_le :
forall A (x:A) m n,
m <= n ->
firstn m (repeat n x) = repeat m x.
Lemma in_repeat_eq : forall A (x y:A) n, In x (repeat n y) -> x=y.
Lemma map_repeat : forall A B (f:A->B) n x, map f (repeat n x) = repeat n (f x).
Lemma multl_repeat_power : forall n x, multl (repeat n x) = power x n.
Definition move_forward {A}(i j:nat)(l:list A)(d:A) : list A :=
firstn i l ++ firstn j (skipn (S i) l) ++ (nth i l d :: skipn (S (i+j)) l).
Lemma move_forward_map A B d1 d2 i j (f:A->B) l :
f d1 = d2 ->
move_forward i j (map f l) d2 = map f (move_forward i j l d1).
Lemma length_move_forward :
forall A i j (l:list A) d, i+j < length l -> length (move_forward i j l d) = length l.
Lemma in_move_forward_iff :
forall A x i j d (l:list A), i < length l -> (In x (move_forward i j l d) <-> In x l).
Lemma firstn_simpl : forall A B (l : list A) (l2 : list B),
length l2 = length l ->
firstn (length l2) l = l.
Lemma firstn_app2 : forall (A : Type) (l l' : list A) n,
length l = n -> firstn n (l ++ l') = l .
Lemma In_firstn : forall A n a (l : list A),
In a (firstn n l) -> In a l.