(* Create a frequency list from a message *)
Fixpoint frequency_list (l : list A) : list (A * nat) :=
  match l with
  | nil => nil
  | a :: l1 => add_frequency_list a (frequency_list l1)
  end.

(* Specifications: *)
Theorem frequency_list_in : forall a n m, In (a, n) (frequency_list m) -> In a m.
Theorem frequency_list_perm : forall l : list A, permutation l (flat_map (fun p => id_list (fst p) (snd p)) (frequency_list l)).
Theorem frequency_list_unique : forall l : list A, unique_key (frequency_list l).
Theorem in_frequency_map : forall l a, In a l -> In a (map fst (frequency_list l)).
Theorem in_frequency_map_inv : forall l a, In a (map (fst (B:=_)) (frequency_list l)) -> In a l.