Skip to content

Commit eebd6f6

Browse files
committed
Lean: annotate sail_arith_shiftright and _builtin_mod_nat
1 parent 49d3582 commit eebd6f6

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

lib/mono_rewrites.sail

+2-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ val _builtin_mod_nat = pure {
237237
ocaml: "modulus",
238238
lem: "integerMod",
239239
c: "tmod_int",
240-
coq: "Z.rem"
240+
coq: "Z.rem",
241+
lean: "Nat.mod"
241242
} : forall 'n 'm, 'n >= 0 & 'm >= 0. (int('n), int('m)) -> {'r, 0 <= 'r < 'm. int('r)}
242243

243244
/* Below we need the fact that 2 ^ 'n >= 0, so we axiomatise it in the return

lib/vector.sail

+3-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,9 @@ val sail_shiftright = pure {
363363
_: "shiftr"} : forall 'n ('ord : Order).
364364
(bitvector('n, 'ord), int) -> bitvector('n, 'ord)
365365

366-
val sail_arith_shiftright = pure "arith_shiftr" : forall 'n ('ord : Order).
366+
val sail_arith_shiftright = pure {
367+
lean: "BitVec.rotateRight",
368+
_: "arith_shiftr"} : forall 'n ('ord : Order).
367369
(bitvector('n, 'ord), int) -> bitvector('n, 'ord)
368370

369371
val sail_zeros = pure {

test/lean/extern_bitvec.expected.lean

+3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ def extern_count_leading_zeros (_ : Unit) : Int :=
137137
def extern_count_trailing_zeros (_ : Unit) : Int :=
138138
(BitVec.countTrailingZeros (0x00FF0FF0 : (BitVec 32)))
139139

140+
def extern_arith_shiftright (_ : Unit) : (BitVec 32) :=
141+
(BitVec.rotateRight (0xDEADBEEF : (BitVec 32)) 4)
142+
140143
def initialize_registers (_ : Unit) : Unit :=
141144
()
142145

test/lean/extern_bitvec.sail

+4
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ function extern_count_trailing_zeros() -> int = {
3030
return count_trailing_zeros(0x00FF0FF0)
3131
}
3232

33+
function extern_arith_shiftright() -> bitvector(32) = {
34+
return sail_arith_shiftright(0xDEADBEEF, 4)
35+
}
36+

0 commit comments

Comments
 (0)