(* This code is copyrighted by its authors; it is distributed under  *)
(* the terms of the LGPL license (see LICENSE and description files) *)
(* Contribution to the Coq Library   V6.3 (July 1999)                    *)
(****************************************************************************)
(*                                                                          *)
(*                                                                          *)
(*                   Solange Coupet-Grimal & Line Jakubiec                  *)
(*                                                                          *)
(*                                                                          *)
(*              Laboratoire d'Informatique de Marseille                     *)
(*               CMI-Technopole de Chateau-Gombert                          *)
(*                   39, Rue F. Joliot Curie                                *)
(*                   13453 MARSEILLE Cedex 13                               *)
(*           e-mail:{Solange. Coupet,Line. Jakubiec}@lim.univ-mrs.fr          *)
(*                                                                          *)
(*                                                                          *)
(*                                Coq V5.10                                 *)
(*                              May 30th 1996                               *)
(*                                                                          *)
(****************************************************************************)
(*                            Lib_Div_Even_Odd.v                            *)
(****************************************************************************)
Require Export Lib_Mult.
(****************************** even/odd *********************************)
Inductive even (n : nat) : Prop :=
even_intro : forall q : nat, n = 2 * q -> even n.
Inductive odd (n : nat) : Prop :=
odd_intro : forall q : nat, n = 2 * q + 1 -> odd n.
(************************* quotients and divisors ***********************)
simple induction q.
intro.
absurd (0 = n).
apply lt_O_neq; auto with arith.
rewrite (mult_n_O m); auto with arith.
auto with arith.
Qed.
intros.
rewrite (plus_n_O q).
rewrite H0.
elim plus_mult.
apply plus_lt_compat_l.
apply (no_zero_div n 2 H q H0).
Qed.
Hint Resolve lt_quotient2_n.
intros.
rewrite H0.
elim (mult_O_le b a); auto with arith.
intro.
absurd (n = 0).
unfold not in |- *; intro.
elim (lt_irrefl n).
pattern n at 1 in |- *.
rewrite H2; auto with arith.
rewrite H0.
rewrite H1; auto with arith.
Qed.
(************************************************************************)
simple induction n.
left; apply (even_intro 0 0); auto with arith.
intros y hrec.
elim hrec.
intro eveny.
right; elim eveny.
intros q hy; apply (odd_intro (S y) q).
elim hy.
elim plus_n_Sm.
auto with arith.
intro oddy; left.
elim oddy.
intros q hy; apply (even_intro (S y) (S q)).
rewrite hy.
rewrite plus_n_Sm.
elim (mult_comm (S q) 2).
elim (mult_comm q 2).
elim plus_comm.
auto with arith.
Qed.

Lemma even_odd : forall a : nat, even a -> ~ odd a.