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).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.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.Definition max_int := Eval vm_compute in (min_int - 1)%sint63.

(* Specifications: *)
Lemma to_Z_0 : to_Z 0 = 0.
Lemma to_Z_min : to_Z min_int = - (wB / 2).
Lemma to_Z_max : to_Z max_int = wB / 2 - 1.
Lemma to_Z_bounded : forall x, (to_Z min_int <= to_Z x <= to_Z max_int)%Z.
Lemma of_to_Z : forall x, of_Z (to_Z x) = x.
Lemma to_Z_inj (x y : int) : to_Z x = to_Z y -> x = y.
Lemma to_Z_mod_Uint63to_Z (x : int) : to_Z x mod wB = φ x%uint63.