Proof using.
intros a l1; generalize a; elim l1; simpl in |- *; auto; clear a l1.
intros (a1, l1) l H a l2 H1; case (eqA_dec a a1); auto.
generalize H1; case l1; auto.
intros H0; case (H0 a1); simpl in |- *; auto.
cut (not_null l); simpl in |- *; auto.
apply not_null_inv with (1 := H1); auto.
Qed.

(* find_code is invariant under permutation *)
Theorem find_code_permutation :
forall (a : A) (c1 c2 : code),
permutation c1 c2 -> unique_prefix c1 -> find_code a c1 = find_code a c2.