(* Create a list of a given length with a given element  *)
Fixpoint id_list (a : A) (n : nat) {struct n} : list A :=
  match n with
  | O => nil
  | S n1 => a :: id_list a n1
  end.(* An element in a frequency list *)
Fixpoint add_frequency_list (a : A) (l : list (A * nat)) {struct l} :
 list (A * nat) :=
  match l with
  | nil => (a, 1) :: nil
  | (b, n) :: l1 =>
      match eqA_dec a b with
      | left _ => (a, S n) :: l1
      | right _ => (b, n) :: add_frequency_list a l1
      end
  end.

Theorem add_frequency_list_in_inv : forall (a1 a2 : A) (b1 : nat) l, In (a1, b1) (add_frequency_list a2 l) -> a1 = a2 \/ In (a1, b1) l.