Module Nat
<: NAxiomsSig
<: UsualDecidableTypeFull
<: OrderedTypeFull
<: TotalOrder.
(** Operations over [nat] are defined in a separate module *)
Include Coq.Init.Nat.
(** When including property functors, inline t eq zero one two lt le succ *)
Set Inline Level 50.
(** All operations are well-defined (trivial here since eq is Leibniz) *)
Definition eq_equiv : Equivalence (@eq nat) := eq_equivalence.
Local Obligation Tactic := simpl_relation.
Program Instance succ_wd : Proper (eq==>eq) S.
Program Instance pred_wd : Proper (eq==>eq) pred.
Program Instance add_wd : Proper (eq==>eq==>eq) plus.
Program Instance sub_wd : Proper (eq==>eq==>eq) minus.
Program Instance mul_wd : Proper (eq==>eq==>eq) mult.
Program Instance pow_wd : Proper (eq==>eq==>eq) pow.
Program Instance div_wd : Proper (eq==>eq==>eq) div.
Program Instance mod_wd : Proper (eq==>eq==>eq) modulo.
Program Instance lt_wd : Proper (eq==>eq==>iff) lt.
Program Instance testbit_wd : Proper (eq==>eq==>eq) testbit.
(** Bi-directional induction. *)
(** Recursion function *)
Definition recursion {A} : A -> (nat -> A -> A) -> nat -> A :=
nat_rect (fun _ => A).
Instance recursion_wd {A} (Aeq : relation A) :
Proper (Aeq ==> (eq==>Aeq==>Aeq) ==> eq ==> Aeq) recursion.
(** ** Remaining constants not defined in Coq.Init.Nat *)
(** NB: Aliasing [le] is mandatory, since only a Definition can implement an interface Parameter... *)
Definition eq := @Logic.eq nat.
Definition le := Peano.le.
Definition lt := Peano.lt.
(** ** Basic specifications : pred add sub mul *)
(** ** Boolean comparisons *)
(** ** Decidability of equality over [nat]. *)
(* BUG: Ajout d'un cas * après preuve finie (deuxième niveau +++*** ) : *  --->   Anomaly: Uncaught exception Proofview.IndexOutOfRange(_). Please report. *)
(** ** Minimum, maximum *)
(** Some more advanced properties of comparison and orders, including [compare_spec] and [lt_irrefl] and [lt_eq_cases]. *)
Include BoolOrderFacts.
(** We can now derive all properties of basic functions and orders, and use these properties for proving the specs of more advanced functions. *)
Include NBasicProp <+ UsualMinMaxLogicalProperties <+ UsualMinMaxDecProperties.
(** ** Power *)
End Private_Parity.
(** ** Division *)
(** ** Square root *)
Definition sqrt_spec a (Ha:0<=a) := sqrt_specif a.
(** ** Gcd *)
Definition divide x y := exists z, y=z*x.
Notation "( x | y )" := (divide x y) (at level 0) : nat_scope.

Lemma testbit_bitwise_2 : forall op, op false false = false ->
forall n m a b, a<=n -> b<=n ->
testbit (bitwise op n a b) m = op (testbit a m) (testbit b m).