(************************************************************************)
(*         *      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)         *)
(************************************************************************)
Require Export Uint63 Sint63Axioms.
Notation min_int := Sint63Axioms.min_int (only parsing).
Notation to_Z := Sint63Axioms.to_Z (only parsing).
Notation asr_spec := Sint63Axioms.asr_spec (only parsing).
Notation div_spec := Sint63Axioms.div_spec (only parsing).
Notation mod_spec := Sint63Axioms.mod_spec (only parsing).
Notation ltb_spec := Sint63Axioms.ltb_spec (only parsing).
Notation leb_spec := Sint63Axioms.leb_spec (only parsing).
Notation compare_spec := Sint63Axioms.compare_spec (only parsing).
Declare Scope sint63_scope.
Definition printer (x : int_wrapper) : pos_neg_int63 :=
if (int_wrap x <? 4611686018427387904)%uint63 then (* 2^62 *)
Pos (int_wrap x)
else
Neg ((int_wrap x) lxor max_int + 1)%uint63.
Definition parser (x : pos_neg_int63) : option int :=
match x with
| Pos p => if (p <? 4611686018427387904)%uint63 then Some p else None
| Neg n => if (n <=? 4611686018427387904)%uint63
then Some ((n - 1) lxor max_int)%uint63 else None
end.
Number Notation int parser printer : sint63_scope.
Module Import Sint63NotationsInternalA.
Delimit Scope sint63_scope with sint63.
Bind Scope sint63_scope with int.
End Sint63NotationsInternalA.
Module Import Sint63NotationsInternalB.
Infix "<<" := PrimInt63.lsl (at level 30, no associativity) : sint63_scope.
(* TODO do we want >> to be asr or lsr? And is there a notation for the other one? *)
Infix ">>" := asr (at level 30, no associativity) : sint63_scope.
Infix "land" := PrimInt63.land (at level 40, left associativity) : sint63_scope.
Infix "lor" := PrimInt63.lor (at level 40, left associativity) : sint63_scope.
Infix "lxor" := PrimInt63.lxor (at level 40, left associativity) : sint63_scope.
Infix "+" := PrimInt63.add : sint63_scope.
Infix "-" := PrimInt63.sub : sint63_scope.
Infix "*" := PrimInt63.mul : sint63_scope.
Infix "/" := divs : sint63_scope.
Infix "mod" := mods (at level 40, no associativity) : sint63_scope.
Infix "=?" := PrimInt63.eqb (at level 70, no associativity) : sint63_scope.
Infix "<?" := ltsb (at level 70, no associativity) : sint63_scope.
Infix "<=?" := lesb (at level 70, no associativity) : sint63_scope.
Infix "≤?" := lesb (at level 70, no associativity) : sint63_scope.
Notation "- x" := (opp x) : sint63_scope.
Notation "n ?= m" := (compares n m)
(at level 70, no associativity) : sint63_scope.
End Sint63NotationsInternalB.
Definition max_int := Eval vm_compute in (min_int - 1)%sint63.

Lemma of_to_Z : forall x, of_Z (to_Z x) = x.