Fixpoint nth n A : option X :=
match A, n with
| nil, _ => None
| x::_, 0 => Some x
| _::A', S n' => nth n' A'
end.

(* Specifications: *)
Lemma nth_length A n :
length A > n -> { x | nth n A = Some x }.
Lemma pos_nth x A n :
pos x A = Some n -> nth n A = Some x.
Lemma nth_app_l x n A B :
nth n A = Some x -> nth n (A ++ B) = Some x.