induction ls; intuition; simpl in *.
econstructor.
inversion H; clear H; subst.
eapply app_NoDup; intuition.
eapply in_flatten in H3.
destruct H3.
intuition.
eapply app_NoDup_inv.
eapply H1.
right.
eapply H6.
left.
reflexivity.
intuition.
subst.
intuition.
eauto.
trivial.
eapply in_flatten in H2.
destruct H2.
intuition.
eapply app_NoDup_inv.
eapply H1.
right.
eapply H6.
left.
reflexivity.
intuition.
subst.
intuition.
eauto.
trivial.
Qed.

Lemma map_NoDup'
: forall (A B : Set) (ls : list A) (f : A -> B),
NoDup ls ->
(forall a1 a2 : A, In a1 ls -> In a2 ls ->a1 <> a2 -> f a1 <> f a2) ->
NoDup (map f ls).