So I have this proof which I have no idea how to prove. I believe that solution should be instructive.
Set Implicit Arguments.
Require Import Arith Omega List Bool.
Fixpoint nat_eqb (n m: nat): bool :=
match n, m with
| O, O => true
| S n', S m' => nat_eqb n' m'
| _, _ => false
end.
Theorem nat_eq_reflect: forall n m, reflect (n = m) (nat_eqb n m).
Proof.
refine (fix aux n m :=
match n, m with
| O, O => _
| S n', S m' => _
| _, _ => _
end).
+ apply ReflectT. auto.
+ apply ReflectF. intuition.
+ apply ReflectF. intuition.
+ simpl. destruct (aux n' m').
- apply ReflectT. subst. auto.
- apply ReflectF. congruence.
Qed.
Definition In_bool A (x: A) (L: list A) (beq: A -> A -> bool): bool.
Proof.
induction L.
+ exact false.
+ exact (orb (beq x a) IHL).
Defined.
Theorem In_reflect A (x: A) (L: list A) (beq: A -> A -> bool) (H: forall x y, reflect (x = y) (beq x y)):
reflect (In x L) (In_bool x L beq).
Proof.
induction L.
+ simpl. apply ReflectF. auto.
+ simpl. destruct (H a x).
- subst. assert (beq x x = true). destruct (H x x); auto.
rewrite H0. simpl. apply ReflectT. left. auto.
- destruct IHL.
* replace (beq x a || true) with true by intuition. apply ReflectT. auto.
* assert (beq x a = false). destruct (H x a); congruence.
rewrite H0. simpl. apply ReflectF. tauto.
Qed.
Definition aux2_bool (n: nat) (L: list nat): bool.
Proof.
pose (seq 0 n) as l. induction l.
+ exact true.
+ exact (if (In_bool a L nat_eqb) then IHl else false).
Defined.
Theorem aux2_reflect (n: nat) (L: list nat): reflect (forall x, x < n -> In x L) (aux2_bool n L).
Proof.
unfold aux2_bool.
Admitted.