Proof using.
intros m c1 c2 H H0; unfold weight in |- *.
apply f_equal with (f := length (A:=bool)).
apply encode_permutation; auto.
Qed.
Definition restrict_code (m : list A) (c : code A) :
code A :=
map (fun x => (fst x, find_code eqA_dec (fst x) c))
(frequency_list eqA_dec m).

(* Specifications: *)
Theorem ulist_unique_key :
forall (A B : Type) (l : list (A * B)),
ulist (map (fst (B:=_)) l) -> unique_key l.