Fixpoint revflatten {A: Type} (xss: list (list A)) : list A :=
match xss with
| []       => []
| xs::xss' => revflatten xss' ++ xs
end.

Lemma count_occ_flat_map A B eq_B_dec (f: A -> list B) b l :
count_occ eq_B_dec (flat_map f l) b =
suml (map (fun a => count_occ eq_B_dec (f a) b) l).