End count_occ.

Lemma NoDup_flat_map A B (f : A -> list B) l :
(forall x, In x l -> NoDup (f x)) ->
NoDup l ->
(forall x y, In x l -> In y l -> x <> y -> (forall z, In z (f x) <-> ~ In z (f y))) ->
NoDup (flat_map f l).