Library ListIndex

Require Import List.

Fixpoint nth {A} (l:list A) (i:nat) : option A :=
  match l with
    | nilNone
    | x :: xsmatch i with
                   | 0 ⇒ Some x
                   | S jnth xs j
                 end
  end.

Lemma nth_map A B l i (f : AB) : nth (map f l) i = option_map f (nth l i).
Proof.
  intros.
  generalize dependent i.
  induction l; intros; simpl. reflexivity.

  destruct i; simpl;auto.
Qed.