Proof using.
intros m; elim m; simpl in |- *; auto.
intros a; exists (nil (A:=A)); split; auto with datatypes.
intros a l H a0.
case (eqA_dec a0 a); simpl in |- *; intros H1.
case (H a0); intros m1 (H2, H3).
exists m1; split; auto.
pattern a0 at 1 in |- *; rewrite H1; auto.
case (H a0); intros m1 (H2, H3).
exists (a :: m1); split; auto.
apply
permutation_trans
with ((a :: m1) ++ id_list a0 (number_of_occurrences a0 l));
auto.
simpl in |- *; apply permutation_skip; auto.
apply permutation_trans with (1 := H2); auto.
simpl in |- *; Contradict H3; case H3; intros H4; auto; case H1; auto.
Qed.

(* Specifications: *)
(* Number of occurrences in an appended list is the sum of the occurrences *)
Theorem number_of_occurrences_app :
forall l1 l2 a,
number_of_occurrences a (l1 ++ l2) =
number_of_occurrences a l1 + number_of_occurrences a l2.