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).
End Positions.
Notation nthe n A := (nth_error A n).

Lemma pos_length X d (x : X) l n : pos d x l = Some n -> n < | l |.