Section Count.
Variable (X : eqType).
Definition count (n : nat) (x : X) (xs : t X n) :=
fold_right (fun y c => if Dec (x = y) then S c else c) xs 0.
(* (* Test *)
End Count.
Compute let xs := [|1;2;3;4;5;6|] in
let x  := 2 in
let y  := 1 in
let i  := Fin.F1 in
Dec (x = y) + count x xs = Dec (x = xs[@i]) + count x (replace xs i y).
*)
End Count.

Lemma Vector_dupfree_app {X n1 n2} (v1 : Vector.t X n1) (v2 : Vector.t X n2) :
VectorDupfree.dupfree (Vector.append v1 v2) <-> VectorDupfree.dupfree v1 /\ VectorDupfree.dupfree v2 /\ forall x, Vector.In x v1 -> Vector.In x v2 -> False.