(* 
  Find the element associated with a list of booleans,
  return None if it does not exist in the code
*)
Fixpoint find_val (a : list bool) (l : code) {struct l} : option A :=
  match l with
  | nil => None
  | (b, c) :: l1 =>
      match list_eq_dec eq_bool_dec a c with
      | left _ => Some b
      | right _ => find_val a l1
      end
  end.

(* Specifications: *)
Theorem find_val_correct1 : forall (c : code) (a : A) (l : list bool), find_val l c = Some a -> In (a, l) c.
Theorem find_val_correct2 : forall (c : code) (a : A) (l : list bool), unique_prefix c -> In (a, l) c -> find_val l c = Some a.
Theorem not_null_find_val : forall c : code, not_null c -> find_val nil c = None.