(* 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 set_nth_nil n y : set_nth [::] n y = ncons n x0 [:: y].