(************************************************************************)
(*         *   The Coq Proof Assistant / The Coq Development Team       *)
(*  v      *   INRIA, CNRS and contributors - Copyright 1999-2018       *)
(* <O___,, *       (see CREDITS file for the list of authors)           *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)
(** Binary Integers : Parity and Division by Two *)
(** Initial author : Pierre Crégut (CNET, Lannion, France) *)
(** THIS FILE IS DEPRECATED. It is now almost entirely made of compatibility formulations for results already present in BinInt.Z. *)
Open Scope Z_scope.
(** Historical formulation of even and odd predicates, based on case analysis. We now rather recommend using [Z.Even] and [Z.Odd], which are based on the exist predicate. *)
Definition Zeven (z:Z) :=
match z with
| Z0 => True
| Zpos (xO _) => True
| Zneg (xO _) => True
| _ => False
end.
Definition Zodd (z:Z) :=
match z with
| Zpos xH => True
| Zneg xH => True
| Zpos (xI _) => True
| Zneg (xI _) => True
| _ => False
end.
Proof (Zeven_equiv n).
Proof (Zodd_equiv n).
(** Boolean tests of parity (now in BinInt.Z) *)
Notation Zeven_bool := Z.even (only parsing).
Notation Zodd_bool := Z.odd (only parsing).
Ltac boolify_even_odd := rewrite <- ?Zeven_bool_iff, <- ?Zodd_bool_iff.
Definition Zeven_odd_dec n : {Zeven n} + {Zodd n}.
Hint Unfold Zeven Zodd: zarith.
Notation Zeven_bool_succ := Z.even_succ (only parsing).
Notation Zeven_bool_pred := Z.even_pred (only parsing).
Notation Zodd_bool_succ := Z.odd_succ (only parsing).
Notation Zodd_bool_pred := Z.odd_pred (only parsing).
(******************************************************************)
(** * Definition of [Z.quot2], [Z.div2] and properties wrt [Zeven] and [Zodd] *)
(** Properties of [Z.div2] *)
Proof (Z.div2_odd n).

Lemma Zodd_div2 n : Zodd n -> n = 2 * Z.div2 n + 1.