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.

Theorem listReplace_getSomes_Permutation_h : forall (A : Set) l1' l2, Permutation l1' l2 -> forall l1 n2 (y : A), l1' = getSomes l1 -> nth n2 l1 None = None -> Permutation (getSomes (listReplace l1 n2 (Some y) None)) (y :: l2).