Proof using.
intros c1 c2 H (H1, H2).
cut (permutation c2 c1); [ intros HP; split | apply permutation_sym; auto ].
intros a1 a2 lb1 lb2 H0 H3 H4.
apply (H1 a1 a2 lb1 lb2); auto.
apply permutation_in with (2 := H0); auto.
apply permutation_in with (2 := H3); auto.
apply unique_key_perm with (2 := H2); auto.
Qed.
(* Find the list of booleans associated with an element, return the empty list if the element does not exists *)
Fixpoint find_code (a : A) (l : code) {struct l} : list bool :=
match l with
| nil => nil
| (b, c) :: l1 =>
match eqA_dec a b with
| left _ => c
| right _ => find_code a l1
end
end.

(* Specifications: *)
(* The result of find_code is in the code *)
Theorem find_code_correct1 :
forall (c : code) (a : A) (b : bool) (l : list bool),
find_code a c = b :: l -> In (a, b :: l) c.