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

Lemma length_count_occ a b l :
(forall n, In n l -> a <= n < a + b) ->
length l = suml (map (count_occ eq_nat_dec l) (seq a b)).