Proof using.
intros p; elim p; simpl in |- *; auto.
intros (a1, l1) l H a0 b H0; case (eqA_dec a0 a1); auto.
intros e; case (H0 l1); rewrite e; auto.
intros n; apply (H a0 b); auto.
intros l0; red in |- *; intros H1; case (H0 l0); auto.
Qed.
(* 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.

(* find_val returns an element of the code *)
Theorem find_val_correct1 :
forall (c : code) (a : A) (l : list bool),
find_val l c = Some a -> In (a, l) c.