(* Encoding is done by iteratively applying find_code *)
Fixpoint encode (c : code) (m : list A) {struct m} : list bool :=
  match m with
  | nil => nil
  | a :: b => find_code a c ++ encode c b
  end.

Theorem encode_permutation : forall (m : list A) (c1 c2 : code), permutation c1 c2 -> unique_prefix c1 -> encode c1 m = encode c2 m.