(* Sequence indexing. *)
Fixpoint set_nth s n y {struct n} :=
if s is x :: s' then if n is n'.+1 then x :: @set_nth s' n' y else y :: s'
else ncons n x0 [:: y].

Lemma size_set_nth s n y : size (set_nth s n y) = maxn n.+1 (size s).