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

Lemma count_occ_cons A eq_dec (a a': A) l :
count_occ eq_dec (a::l) a' =
if eq_dec a a' then S (count_occ eq_dec l a') else count_occ eq_dec l a'.