(*+ Stdlib: some list functions *)
Fixpoint nth_upd {A} (l : list A) i x :=
match l with
| nil => nil
| y :: l =>
match i with
| O => x :: l
| S i => y :: nth_upd l i x
end
end.

Lemma nth_upd_app_1 {A} (l1 l2 : list A) i x y :
nth l1 i = Some x ->
nth_upd l1 i y ++ l2 = nth_upd (l1 ++ l2) i y.