Section Positions.
Variables (X: Type) (d: forall x y : X, {x = y} + {x <> y}).
Implicit Types (x y: X) (A B : list X).
Fixpoint pos x A : option nat :=
match A with
| nil => None
| y :: A' => if d x y then Some 0
else match pos x A' with
| Some n => Some (S n)
| None => None
end
end.
Notation nthe n A := (nth_error A n).

Lemma nthe_app_l x n A B :
nthe n A = Some x -> nthe n (A ++ B) = Some x.