Skip to content

Commit 60f10e1

Browse files
Add simplification rule for storing symbolic bytes (#85)
Co-authored-by: devops <devops@runtimeverification.com>
1 parent 778e705 commit 60f10e1

4 files changed

Lines changed: 48 additions & 2 deletions

File tree

package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.66
1+
0.1.67

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.66"
7+
version = "0.1.67"
88
description = "K tooling for the RISC-V architecture"
99
authors = [
1010
"Runtime Verification, Inc. <contact@runtimeverification.com>",

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,33 @@ module BYTES-SIMPLIFICATIONS
3737
3838
rule [bytes-concat-empty-right]: B:Bytes +Bytes .Bytes => B [simplification]
3939
rule [bytes-concat-empty-left]: .Bytes +Bytes B:Bytes => B [simplification]
40+
rule [bytes-concat-concrete-empty-right]: B:Bytes +Bytes b"" => B [simplification]
41+
rule [bytes-concat-concrete-empty-left]: b"" +Bytes B:Bytes => B [simplification]
4042
4143
rule [bytes-concat-right-assoc-symb-l]: (B1:Bytes +Bytes B2:Bytes) +Bytes B3:Bytes => B1 +Bytes (B2 +Bytes B3) [symbolic(B1), simplification(40)]
4244
rule [bytes-concat-right-assoc-symb-r]: (B1:Bytes +Bytes B2:Bytes) +Bytes B3:Bytes => B1 +Bytes (B2 +Bytes B3) [symbolic(B2), simplification(40)]
4345
rule [bytes-concat-left-assoc-conc]: B1:Bytes +Bytes (B2:Bytes +Bytes B3:Bytes) => (B1 +Bytes B2) +Bytes B3 [concrete(B1, B2), symbolic(B3), simplification(40)]
4446
```
4547

48+
## Bytes Update Lemmas
49+
50+
```k
51+
rule [bytes-update-symbolic-value]:
52+
B:Bytes [I <- V] => substrBytes(B, 0, I) +Bytes Int2Bytes(1, V, LE) +Bytes substrBytes(B, I +Int 1, lengthBytes(B) -Int I -Int 1)
53+
requires I <Int lengthBytes(B)
54+
[simplification, concrete(B, I), symbolic(V), preserves-definedness]
55+
```
56+
57+
58+
## Int2Bytes Lemmas
59+
60+
```k
61+
rule [int2bytes-length]:
62+
lengthBytes(Int2Bytes(N, _:Int, _:Endianness)) => N
63+
[simplification]
64+
65+
```
66+
4667
```k
4768
endmodule
4869
```
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
requires "riscv-semantics/riscv.md"
2+
3+
module STORE-SYMBOLIC-BYTES
4+
imports RISCV
5+
6+
claim [id]:
7+
<instrs> #CHECK_HALT => #HALT </instrs>
8+
<regs>
9+
.Map
10+
</regs>
11+
<pc> W ( 0 ) </pc>
12+
<mem>
13+
storeBytes(
14+
#bytes ( b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" ) .SparseBytes,
15+
W(0),
16+
X:Int,
17+
4
18+
) =>
19+
#bytes ( Int2Bytes ( 1 , X:Int &Int 255 , LE ) +Bytes Int2Bytes ( 1 , X:Int >>Int 8 &Int 255 , LE ) +Bytes Int2Bytes ( 1 , X:Int >>Int 8 >>Int 8 &Int 255 , LE ) +Bytes Int2Bytes ( 1 , X:Int >>Int 8 >>Int 8 >>Int 8 , LE ) +Bytes b"\x00\x00\x00\x00" ) .SparseBytes
20+
</mem>
21+
<test>
22+
<haltCond> ADDRESS ( W ( 0 ) ) </haltCond>
23+
</test>
24+
requires lengthBytes(W0) ==Int 4
25+
endmodule

0 commit comments

Comments
 (0)