Fixpoint getSomes(A : Type)(ls : list (option A)) :=
  match ls with
    | nil => nil
    | o :: ls' =>
      match o with
        | None => getSomes ls'
        | Some x => x :: (getSomes ls')
      end
  end.

Lemma nth_listReplace_ne : forall (i1 i2 : nat)(A : Set)(ls : list A)(a def : A), i1 <> i2 -> nth i1 (listReplace ls i2 a def) def = nth i1 ls def.