Fixpoint pos (X : Type) (d : forall x y : X, {x = y} + {x <> y}) (x : X) l : option nat :=
match l with
| nil => None
| y :: l => if d x y then Some 0 else match pos d x l with Some f => Some (S f) | None => None end
end.

Lemma in_omap_iff X Y (f : X -> option Y) l y : y el omap f l <-> exists x, x el l /\ f x = Some y.