Debian Codegraph @

theories/Corelib/Numbers/Cyclic/Int63/Sint63Axioms.v

raw
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10 (* Benjamin Gregoire, Laurent Thery, INRIA, 2007 *)
11 (************************************************************************)
12
13 From Corelib Require Import BinNums PosDef IntDef.
14 From Corelib Require Export PrimInt63 Uint63Axioms.
15
16 Local Open Scope Z_scope.
17
18 Local Notation "2" := (Zpos 2) : Z_scope.
19 Local Infix "^" := Z.pow : Z_scope.
20 Local Notation "x <= y" := (Z.compare x y <> Gt) : Z_scope.
21 Local Notation "x < y" := (Z.compare x y = Lt) : Z_scope.
22
23 Definition min_int := Eval vm_compute in (lsl 1 62).
24
25 (** Translation to and from Z *)
26 Definition to_Z (i : int) :=
27 if ltb i min_int then to_Z i
28 else Z.opp (to_Z (sub 0 i)).
29
30 (** Specification of operations that differ on signed and unsigned ints *)
31
32 Axiom asr_spec : forall x p, to_Z (asr x p) = Z.div (to_Z x) (2 ^ (to_Z p)).
33
34 Axiom div_spec : forall x y,
35 to_Z x <> to_Z min_int \/ to_Z y <> Zneg 1 ->
36 to_Z (divs x y) = Z.quot (to_Z x) (to_Z y).
37
38 Axiom mod_spec : forall x y, to_Z (mods x y) = Z.rem (to_Z x) (to_Z y).
39
40 Axiom ltb_spec : forall x y, ltsb x y = true <-> to_Z x < to_Z y.
41
42 Axiom leb_spec : forall x y, lesb x y = true <-> to_Z x <= to_Z y.
43
44 Axiom compare_spec : forall x y, compares x y = Z.compare (to_Z x) (to_Z y).