Skip to content

Commit 58d1958

Browse files
Stevengrerv-auditortothtamas28
authored
Add new lemmas for substrBytes and update pickFront rule (#94)
Co-authored-by: devops <devops@runtimeverification.com> Co-authored-by: Tamás Tóth <tothtamas28@users.noreply.github.com>
1 parent 883fd6e commit 58d1958

5 files changed

Lines changed: 41 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.71
1+
0.1.72

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.71"
7+
version = "0.1.72"
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: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,21 @@ module BYTES-SIMPLIFICATIONS
6868
[simplification]
6969
7070
```
71-
71+
72+
## substrBytes Lemmas
73+
74+
```k
75+
rule [substr-bytes-length]: lengthBytes(substrBytes(B, I, J)) => J -Int I
76+
requires 0 <=Int I
77+
andBool I <=Int J
78+
andBool J <=Int lengthBytes(B)
79+
[simplification, preserves-definedness]
80+
rule [substr-substr]: substrBytes(substrBytes(B, I, J), I0, J0) => substrBytes(B, I +Int I0, I +Int J0)
81+
requires 0 <=Int I andBool I <=Int J andBool J <=Int lengthBytes(B)
82+
andBool 0 <=Int I0 andBool I0 <=Int J0 andBool J0 <=Int J -Int I
83+
[simplification, preserves-definedness]
84+
```
85+
7286
```k
7387
endmodule
7488
```

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ module SPARSE-BYTES-SIMPLIFICATIONS
1515
For symbolic execution, we need to tackle the patterns of `#bytes(B +Bytes _) _` and `#bytes(B +Bytes BS) EF` to obtain as exact as possible values for `pickFront`.
1616

1717
```k
18+
rule pickFront(#bytes(substrBytes(B, I, J) +Bytes _) _ , J0) => substrBytes(substrBytes(B, I, J), 0, J0)
19+
requires 0 <=Int I andBool I <=Int J andBool J <=Int lengthBytes(B)
20+
andBool J0 <=Int lengthBytes(substrBytes(B, I, J))
21+
[simplification(44), preserves-definedness]
1822
rule pickFront(#bytes(B +Bytes _) _ , I) => substrBytes(B, 0, I)
1923
requires I >Int 0 andBool I <=Int lengthBytes(B) [simplification(45)]
2024
rule pickFront(#bytes(B +Bytes BS) EF, I) => B +Bytes pickFront(#bytes(BS) EF, I -Int lengthBytes(B))
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 PICKFRONT0
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+
#bytes(pickFront ( #bytes ( substrBytes ( W0:Bytes , 16 , 32 ) +Bytes W1:Bytes +Bytes b"\x00\x00\x00\x00\x00" ) .SparseBytes , 4 )) .SparseBytes
14+
=> #bytes ( substrBytes ( W0:Bytes , 16 , 20 ) ) .SparseBytes
15+
</mem>
16+
<test>
17+
<haltCond> ADDRESS ( W ( 0 ) ) </haltCond>
18+
</test>
19+
requires lengthBytes(W0) ==Int 32 andBool lengthBytes(W1) ==Int 32
20+
endmodule

0 commit comments

Comments
 (0)