(* 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_cons_inv : forall a l1 l m1, ~ In a m1 -> encode ((a, l1) :: l) m1 = encode l m1.