induction y; intuition; simpl in *.
rewrite plus_0_r.
trivial.
destruct ls.
rewrite nth_nil.
rewrite nth_nil.
trivial.
rewrite plus_comm.
simpl.
rewrite plus_comm.
eapply
IHy.
Qed.

Theorem perm_flatten_listReplace_nil :
forall b (A : Set)(a : A),
Permutation (flatten (listReplace nil b (a :: nil) nil)) (a :: nil).