induction b; intuition; simpl in *.
destruct ls1.
simpl in *.
apply Permutation_nil in H.
subst.
eapply Permutation_refl.
simpl in *.
rewrite <- app_cons_eq.
eapply Permutation_trans.
eapply Permutation_app_comm.
rewrite <- app_comm_cons.
econstructor.
eapply Permutation_trans.
eapply Permutation_app_comm.
trivial.
destruct ls1.
simpl in *.
eapply Permutation_nil in H.
subst.
eapply perm_flatten_listReplace_nil .
simpl in *.
eapply Permutation_trans.
eapply Permutation_app.
eapply Permutation_refl.
eapply IHb.
eapply Permutation_refl.
eapply Permutation_trans.
eapply Permutation_app_comm.
rewrite <- app_comm_cons.
econstructor.
eapply Permutation_trans.
eapply Permutation_app_comm.
trivial.
Qed.

Theorem map_cons :
forall (A B : Type)(f : A -> B)(ls : list A)(a : A),
map f (a :: ls) = (f a) :: map f ls.