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).
*)

Lemma replace_nochange (n : nat) (xs : Vector.t X n) (p : Fin.t n) :
replace xs p xs[@p] = xs.