Skip to content

Commit 66ddeca

Browse files
Simplify pattern Bytes2Int o substrBytes &Int 65280 (#105)
Co-authored-by: devops <[email protected]>
1 parent 79bf2fd commit 66ddeca

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.77
1+
0.1.78

pyproject.toml

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

55
[tool.poetry]
66
name = "kriscv"
7-
version = "0.1.77"
7+
version = "0.1.78"
88
description = "K tooling for the RISC-V architecture"
99
authors = [
1010
"Runtime Verification, Inc. <[email protected]>",

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ module BYTES-SIMPLIFICATIONS
8383
[simplification, preserves-definedness]
8484
```
8585

86+
## Bytes2Int Lemmas
87+
88+
```k
89+
rule [bytes2int-substr-ff00-0]: Bytes2Int (substrBytes(B, I, J), LE, Unsigned) &Int 65280 => 0
90+
requires 0 <=Int I andBool I <=Int J andBool J <=Int I +Int 1 andBool J <=Int lengthBytes(B)
91+
[simplification, preserves-definedness]
92+
rule [bytes2int-substr-ff00-1]: Bytes2Int (substrBytes(B, I, J), LE, Unsigned) &Int 65280 => B[I +Int 1] <<Int 8
93+
requires 0 <=Int I andBool I +Int 1 <Int J andBool J <=Int lengthBytes(B)
94+
[simplification, preserves-definedness]
95+
```
96+
8697
```k
8798
endmodule
8899
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
requires "riscv-semantics/riscv.md"
2+
3+
module BYTES-INT
4+
imports RISCV
5+
6+
claim [id]:
7+
<instrs> #CHECK_HALT => #HALT </instrs>
8+
<pc> W ( 0 ) </pc>
9+
<regs>
10+
1 |-> (W(Bytes2Int (b"\x12\x34\x56\x78", LE, Unsigned) &Int 65280) => W(13312))
11+
2 |-> (W(b"\x12\x34\x56\x78" [ 1 ] <<Int 8) => W(13312))
12+
3 |-> (W(Bytes2Int (substrBytes(W0, 0, 4), LE, Unsigned ) &Int 65280) => W(W0 [ 1 ] <<Int 8))
13+
4 |-> (W(Bytes2Int(substrBytes(b"\x01\x02", 0, 1), LE, Unsigned) &Int 65280) => W(0))
14+
5 |-> (W(Bytes2Int(substrBytes(W0, 0, 1), LE, Unsigned) &Int 65280) => W(0))
15+
</regs>
16+
<test>
17+
<haltCond> ADDRESS ( W ( 0 ) ) </haltCond>
18+
</test>
19+
requires lengthBytes(W0) ==Int 32
20+
endmodule

0 commit comments

Comments
 (0)