(** The [unsigned] and [signed] functions return the Coq integer corresponding to the given machine integer, interpreted as unsigned or signed respectively. *)
Definition unsigned (n: int) : Z := intval n.
Definition signed (n: int) : Z :=
let x := unsigned n in
if zlt x half_modulus then x else x - modulus.
(** Conversely, [repr] takes a Coq integer and returns the corresponding machine integer.  The argument is treated modulo [modulus]. *)
Definition repr (x: Z) : int :=
mkint (Z_mod_modulus x) (Z_mod_modulus_range' x).
Definition zero := repr 0.
Definition one  := repr 1.
Definition mone := repr (-1).
Definition iwordsize := repr zwordsize.

(* Specifications: *)
Lemma mkint_eq:
forall x y Px Py, x = y -> mkint x Px = mkint y Py.
Lemma eq_dec: forall (x y: int), {x = y} + {x <> y}.
Remark half_modulus_modulus: modulus = 2 * half_modulus.
Lemma mkint_eq:
forall x y Px Py, x = y -> mkint x Px = mkint y Py.
Lemma eq_dec: forall (x y: int), {x = y} + {x <> y}.
Remark half_modulus_modulus: modulus = 2 * half_modulus.