| 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 |
|
| 11 |
Require Import Ltac2.Init. |
| 12 |
|
| 13 |
Ltac2 Type t := int. |
| 14 |
|
| 15 |
Ltac2 @ external equal : int -> int -> bool := "rocq-runtime.plugins.ltac2" "int_equal". |
| 16 |
Ltac2 @ external compare : int -> int -> int := "rocq-runtime.plugins.ltac2" "int_compare". |
| 17 |
Ltac2 @ external add : int -> int -> int := "rocq-runtime.plugins.ltac2" "int_add". |
| 18 |
Ltac2 @ external sub : int -> int -> int := "rocq-runtime.plugins.ltac2" "int_sub". |
| 19 |
Ltac2 @ external mul : int -> int -> int := "rocq-runtime.plugins.ltac2" "int_mul". |
| 20 |
|
| 21 |
(* Note: unlike Rocq Z division, Ltac2 matches OCaml division and rounds towards 0, so 1/-2 = 0 *) |
| 22 |
Ltac2 @ external div : int -> int -> int := "rocq-runtime.plugins.ltac2" "int_div". |
| 23 |
|
| 24 |
Ltac2 @ external mod : int -> int -> int := "rocq-runtime.plugins.ltac2" "int_mod". |
| 25 |
Ltac2 @ external neg : int -> int := "rocq-runtime.plugins.ltac2" "int_neg". |
| 26 |
Ltac2 @ external abs : int -> int := "rocq-runtime.plugins.ltac2" "int_abs". |
| 27 |
|
| 28 |
Ltac2 @ external asr : int -> int -> int := "rocq-runtime.plugins.ltac2" "int_asr". |
| 29 |
Ltac2 @ external lsl : int -> int -> int := "rocq-runtime.plugins.ltac2" "int_lsl". |
| 30 |
Ltac2 @ external lsr : int -> int -> int := "rocq-runtime.plugins.ltac2" "int_lsr". |
| 31 |
Ltac2 @ external land : int -> int -> int := "rocq-runtime.plugins.ltac2" "int_land". |
| 32 |
Ltac2 @ external lor : int -> int -> int := "rocq-runtime.plugins.ltac2" "int_lor". |
| 33 |
Ltac2 @ external lxor : int -> int -> int := "rocq-runtime.plugins.ltac2" "int_lxor". |
| 34 |
Ltac2 @ external lnot : int -> int := "rocq-runtime.plugins.ltac2" "int_lnot". |
| 35 |
|
| 36 |
Ltac2 lt (x : int) (y : int) := equal (compare x y) -1. |
| 37 |
Ltac2 gt (x : int) (y : int) := equal (compare x y) 1. |
| 38 |
Ltac2 le (x : int) (y : int) := |
| 39 |
(* we might use [lt x (add y 1)], but that has the wrong behavior on MAX_INT *) |
| 40 |
match equal x y with |
| 41 |
| true => true |
| 42 |
| false => lt x y |
| 43 |
end. |
| 44 |
Ltac2 ge (x : int) (y : int) := |
| 45 |
(* we might use [lt (add x 1) y], but that has the wrong behavior on MAX_INT *) |
| 46 |
match equal x y with |
| 47 |
| true => true |
| 48 |
| false => gt x y |
| 49 |
end. |