(* 
  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.

Theorem not_null_find_val : forall c : code, not_null c -> find_val nil c = None.