(* -*- coding: utf-8 -*- *)
(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \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 (Pierre Crégut, CNET, Lannion, France) *)
Require Export Arith_base.
Local Open Scope Z_scope.
(** Conversions between integers and natural numbers  Seven sections: - chains of conversions (combining two conversions) - module N2Z : from N to Z - module Z2N : from Z to N (negative numbers rounded to 0) - module Zabs2N : from Z to N (via the absolute value) - module Nat2Z : from nat to Z - module Z2Nat : from Z to nat (negative numbers rounded to 0) - module Zabs2Nat : from Z to nat (via the absolute value) *)
(** * Chains of conversions *)
(** When combining successive conversions, we have the following commutative diagram: << ---> Nat ---- |      ^      | |      |      v Pos ---------> Z |      |      ^ |      v      | ----> N ----- >> *)

(* Specifications: *)
Lemma nat_N_Z n : Z.of_N (N.of_nat n) = Z.of_nat n.
Lemma N_nat_Z n : Z.of_nat (N.to_nat n) = Z.of_N n.
Lemma positive_nat_Z p : Z.of_nat (Pos.to_nat p) = Zpos p.
Lemma positive_N_Z p : Z.of_N (Npos p) = Zpos p.
Lemma positive_N_nat p : N.to_nat (Npos p) = Pos.to_nat p.
Lemma positive_nat_N p : N.of_nat (Pos.to_nat p) = Npos p.
Lemma Z_N_nat n : N.to_nat (Z.to_N n) = Z.to_nat n.
Lemma Z_nat_N n : N.of_nat (Z.to_nat n) = Z.to_N n.
Lemma Zabs_N_nat n : N.to_nat (Z.abs_N n) = Z.abs_nat n.
Lemma Zabs_nat_N n : N.of_nat (Z.abs_nat n) = Z.abs_N n.
Module N2Z.