Skip to content

Commit 3804716

Browse files
Add simplification rule for Bytes2Int &Int 4294967295 (#135)
Co-authored-by: devops <devops@runtimeverification.com>
1 parent db011d7 commit 3804716

5 files changed

Lines changed: 7 additions & 3 deletions

File tree

package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.104
1+
0.1.105

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "kriscv"
7-
version = "0.1.104"
7+
version = "0.1.105"
88
description = "K tooling for the RISC-V architecture"
99
readme = "README.md"
1010
requires-python = "~=3.10"

src/kriscv/kdist/riscv-semantics/lemmas/bytes-simplifications.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ module BYTES-SIMPLIFICATIONS [symbolic]
137137
rule [bytes2int-substr-ff00-1]: Bytes2Int (substrBytes(B, I, J), LE, Unsigned) &Int 65280 => B[I +Int 1] <<Int 8
138138
requires 0 <=Int I andBool I +Int 1 <Int J andBool J <=Int lengthBytes(B)
139139
[simplification, preserves-definedness]
140+
rule [bytes2int-ffffffff]: Bytes2Int(B, LE, Unsigned) &Int 4294967295 => Bytes2Int(substrBytes(B, 0, 4), LE, Unsigned)
141+
requires 4 <=Int lengthBytes(B)
142+
[simplification, preserves-definedness]
140143
rule [bytes2int-upperbound]: Bytes2Int(B, _, Unsigned) <Int X => true
141144
requires 2 ^Int (lengthBytes(B) *Int 8) <=Int X
142145
[simplification]

src/tests/integration/test-data/specs/bytes-int.k

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module BYTES-INT
2828
21 |-> (Bytes2Int(reverseBytes(substrBytes(W0, 8, 13)) +Bytes reverseBytes(substrBytes(W0, 5, 8)) +Bytes reverseBytes(substrBytes(W0, 0, 5)) +Bytes reverseBytes(substrBytes(W3, 29, 32)) +Bytes reverseBytes(substrBytes(W3, 24, 29)) +Bytes reverseBytes(substrBytes(W3, 21, 24)) +Bytes reverseBytes(substrBytes(W3, 16, 21)) +Bytes reverseBytes(substrBytes(W3, 13, 16)) +Bytes reverseBytes(substrBytes(W3, 8, 13)) +Bytes reverseBytes(substrBytes(W3, 5, 8)) +Bytes reverseBytes(substrBytes(W3, 0, 5)), LE, Unsigned) => Bytes2Int(reverseBytes(substrBytes(W0, 0, 13)) +Bytes reverseBytes(W3), LE, Unsigned))
2929
22 |-> (Bytes2Int(substrBytes(reverseBytes(W0), 16, 20), LE, Unsigned) &Int 4294967295 => Bytes2Int(substrBytes(reverseBytes(W0), 16, 20), LE, Unsigned))
3030
23 |-> (Bool2Word(Bytes2Int(substrBytes(reverseBytes(W3), 0, 4), LE, Unsigned) +Int Bytes2Int(substrBytes(reverseBytes(W0), 0, 4), LE, Unsigned) &Int 4294967295 <Int Bytes2Int(substrBytes(reverseBytes(W3), 0, 4), LE, Unsigned)) => Bool2Word(4294967295 <Int Bytes2Int(substrBytes(reverseBytes(W3), 0, 4), LE, Unsigned) +Int Bytes2Int(substrBytes(reverseBytes(W0), 0, 4), LE, Unsigned)))
31+
24 |-> (Bytes2Int(b"\x00\x00\x00" +Bytes substrBytes(W0, 24, 28), LE, Unsigned) &Int 4294967295 => Bytes2Int ( b"\x00\x00\x00" +Bytes substrBytes(W0 ,24, 25), LE, Unsigned))
3132
</regs>
3233
<haltCond> ADDRESS ( 0 ) </haltCond>
3334
requires lengthBytes(W0) ==Int 32

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)