Library Stdlib.Numbers.Cyclic.Int63.Sint63
From Stdlib Require Import ZArith.
Local Open Scope Z_scope.
From Stdlib Require Export Uint63 Sint63Axioms.
From Stdlib Require Import Lia.
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
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.
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 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.
Centered modulo
Specification of operations that coincide on signed and unsigned ints
Behaviour when there is no under or overflow
Relationship with of_Z
Comparison
Absolute value
ASR