(** Checks that all nats before n are P *)

Fixpoint allbefore (P : nat -> Prop) (n : nat) {struct n} : Prop :=
  match n with
  | O => True
  | S x => allbefore P x /\ P x
  end.(** Checks that some nat before n is P *)

Fixpoint exbefore (P : nat -> Prop) (n : nat) {struct n} : Prop :=
  match n with
  | O => False
  | S x => exbefore P x \/ P x
  end.

Theorem exdec : forall (P : nat -> Prop) (N : nat), (forall n : nat, P n \/ ~ P n) -> (exists x : nat, x < N /\ P x) \/ ~ (exists x : nat, x < N /\ P x).