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 listReplace_in : forall (A : Set)(ls : list A)(a1 a2 def : A)(i : nat), In a1 (listReplace ls i a2 def) -> (In a1 ls \/ a1 = a2 \/ a1 = def).