Skip to content

Commit c72b80f

Browse files
Stevengrerv-auditortothtamas28
authored
Simp rule 4 (A +Int B) &Int 4294967295 <Int A (#130)
Also fix a bug for `bytes2int-upperbound` --------- Co-authored-by: devops <devops@runtimeverification.com> Co-authored-by: Tamás Tóth <tothtamas28@users.noreply.github.com>
1 parent 0d09047 commit c72b80f

7 files changed

Lines changed: 12 additions & 7 deletions

File tree

package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.102
1+
0.1.103

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.102"
7+
version = "0.1.103"
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ 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-upperbound]: Bytes2Int(B, _, _) <Int X => true
141-
requires 2 ^Int lengthBytes(B) <=Int X
140+
rule [bytes2int-upperbound]: Bytes2Int(B, _, Unsigned) <Int X => true
141+
requires 2 ^Int (lengthBytes(B) *Int 8) <=Int X
142142
[simplification]
143143
rule [bytes2int-lowerbound]: 0 <=Int Bytes2Int(_, _, Unsigned) => true [simplification]
144144
```

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ module INT-SIMPLIFICATIONS [symbolic]
4242
```k
4343
rule [int-and-ineq]: 0 <=Int A &Int B => true requires 0 <=Int A andBool 0 <=Int B [simplification]
4444
rule [int-rhs-ineq]: 0 <=Int A >>Int B => true requires 0 <=Int A andBool 0 <=Int B [simplification]
45+
rule [int-add-ineq]: A <=Int A +Int B => true requires 0 <=Int B [simplification]
46+
rule [int-add-ineq-4294967295]: X &Int 4294967295 <Int A => 4294967295 <Int X
47+
requires 0 <=Int A andBool A <=Int X [simplification]
4548
```
4649

4750
## Int Expression Simplifications for Bytes

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ module BYTES-INT
2626
19 |-> (Bytes2Int(substrBytes(W0, 2, 3) +Bytes substrBytes(W0, 1, 2) +Bytes substrBytes(W0, 0, 1), LE, Unsigned) => Bytes2Int(reverseBytes(substrBytes(W0, 0, 3)), LE, Unsigned))
2727
20 |-> (Bytes2Int(reverseBytes(substrBytes(W0, 10, 12)) +Bytes substrBytes(W0, 9, 10) +Bytes substrBytes(W0, 8, 12), LE, Unsigned) => Bytes2Int(reverseBytes(substrBytes(W0, 9, 12)) +Bytes substrBytes(W0, 8, 12), LE, Unsigned))
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))
29+
22 |-> (Bytes2Int(substrBytes(reverseBytes(W0), 16, 20), LE, Unsigned) &Int 4294967295 => Bytes2Int(substrBytes(reverseBytes(W0), 16, 20), LE, Unsigned))
30+
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)))
2931
</regs>
3032
<haltCond> ADDRESS ( 0 ) </haltCond>
3133
requires lengthBytes(W0) ==Int 32

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module INT-SPEC
1212
5 |-> ((W2 <<Int 16 &Int 4294967295) => W2 <<Int 16)
1313
6 |-> ((b"\x12"[0] <<Int 16 &Int 4294967295) => 1179648)
1414
7 |-> ((Bytes2Int(b"\x00\x00\x12", LE, Unsigned)) => 1179648)
15-
8 |-> ((Bytes2Int(W3, LE, Unsigned) &Int 4294967295) => Bytes2Int(W3, LE, Unsigned))
15+
8 |-> ((Bytes2Int(substrBytes(W3, 0, 4), LE, Unsigned) &Int 4294967295) => Bytes2Int(substrBytes(W3, 0, 4), LE, Unsigned))
1616
9 |-> ((W3[0] <<Int 16 &Int 4294967295) => Bytes2Int(b"\x00\x00" +Bytes substrBytes(W3, 0, 1 ), LE, Unsigned))
1717
10 |-> ((Bytes2Int(b"\x12\x34\x56\x78", LE, Unsigned) >>Int 8) => 7886388)
1818
11 |-> ((Bytes2Int(b"\x34\x56\x78", LE, Unsigned)) => 7886388)

uv.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)