Skip to content

Commit 2755c4c

Browse files
Add writeByteBF simplification rules (#82)
Co-authored-by: devops <devops@runtimeverification.com>
1 parent 98eea27 commit 2755c4c

4 files changed

Lines changed: 40 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.60
1+
0.1.61

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

src/kriscv/kdist/riscv-semantics/lemmas/sparse-bytes-simplificaitons.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ For symbolic execution, we need to tackle the patterns of `#bytes(B +Bytes _) _`
2121
requires I >=Int lengthBytes(B) [simplification(45)]
2222
```
2323

24+
25+
## writeByteBF
26+
27+
To write a byte to a symbolic sparse byte region, we need to:
28+
29+
```k
30+
rule writeByteBF(#bytes(B +Bytes BS) EF, I, V) => #bytes(B[ I <- V ] +Bytes BS) EF
31+
requires I >=Int 0 andBool I <Int lengthBytes(B) [simplification(45)]
32+
rule writeByteBF(#bytes(B +Bytes BS) EF, I, V) => prepend(B, writeByteBF(#bytes(BS) EF, I -Int lengthBytes(B), V))
33+
requires I >=Int lengthBytes(B) [simplification(45)]
34+
```
35+
2436
```k
2537
endmodule
2638
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
requires "riscv-semantics/riscv.md"
2+
3+
module SW-SPEC
4+
imports RISCV
5+
6+
claim [id]:
7+
<instrs> (.K => #HALT) ~> #EXECUTE ... </instrs>
8+
<regs>
9+
1 |-> W(12)
10+
2 |-> W(24)
11+
3 |-> W(28)
12+
4 |-> W(4)
13+
</regs>
14+
<pc> W ( 0 => 8 ) </pc>
15+
<mem>
16+
#bytes ( b"\x23\xa0\x40\x00\x23\x20\x41\x00" ) // sw x4, 0(x1) ; sw x4, 0(x3)
17+
#empty ( 4 )
18+
(#bytes ( b"\x00\x00\x00\x00" +Bytes X +Bytes b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") =>
19+
#bytes ( b"\x04\x00\x00\x00" +Bytes X +Bytes b"\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00"))
20+
.SparseBytes
21+
</mem>
22+
<test>
23+
<haltCond> ADDRESS ( W ( 8 ) ) </haltCond>
24+
</test>
25+
requires lengthBytes(X) ==Int 4
26+
endmodule

0 commit comments

Comments
 (0)