Skip to content

Commit 8f5e5b7

Browse files
Stevengretothtamas28rv-auditor
authored
Add Byte simplification rules from evm semantics (#83)
Co-authored-by: Tamás Tóth <tothtamas28@users.noreply.github.com> Co-authored-by: devops <devops@runtimeverification.com>
1 parent c6b16ef commit 8f5e5b7

6 files changed

Lines changed: 54 additions & 4 deletions

File tree

package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.62
1+
0.1.63

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.62"
7+
version = "0.1.63"
88
description = "K tooling for the RISC-V architecture"
99
authors = [
1010
"Runtime Verification, Inc. <contact@runtimeverification.com>",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Bytes Simplifications
2+
3+
## Preliminaries
4+
5+
```k
6+
module BYTES-SIMPLIFICATIONS
7+
imports BYTES
8+
imports INT
9+
imports K-EQUAL
10+
imports BOOL
11+
```
12+
13+
## Bytes Equality Lemmas
14+
15+
```k
16+
rule [bytes-not-equal-length]:
17+
BA1:Bytes ==K BA2:Bytes => false
18+
requires lengthBytes(BA1) =/=Int lengthBytes(BA2)
19+
[simplification]
20+
21+
```
22+
23+
## Bytes Concatenation Lemmas
24+
25+
```k
26+
rule [bytes-equal-concat-split-k]:
27+
A:Bytes +Bytes B:Bytes ==K C:Bytes +Bytes D:Bytes => A ==K C andBool B ==K D
28+
requires lengthBytes(A) ==Int lengthBytes(C)
29+
orBool lengthBytes(B) ==Int lengthBytes(D)
30+
[simplification]
31+
32+
rule [bytes-equal-concat-split-ml]:
33+
{ A:Bytes +Bytes B:Bytes #Equals C:Bytes +Bytes D:Bytes } => { A #Equals C } #And { B #Equals D }
34+
requires lengthBytes(A) ==Int lengthBytes(C)
35+
orBool lengthBytes(B) ==Int lengthBytes(D)
36+
[simplification]
37+
38+
rule [bytes-concat-empty-right]: B:Bytes +Bytes .Bytes => B [simplification]
39+
rule [bytes-concat-empty-left]: .Bytes +Bytes B:Bytes => B [simplification]
40+
41+
rule [bytes-concat-right-assoc-symb-l]: (B1:Bytes +Bytes B2:Bytes) +Bytes B3:Bytes => B1 +Bytes (B2 +Bytes B3) [symbolic(B1), simplification(40)]
42+
rule [bytes-concat-right-assoc-symb-r]: (B1:Bytes +Bytes B2:Bytes) +Bytes B3:Bytes => B1 +Bytes (B2 +Bytes B3) [symbolic(B2), simplification(40)]
43+
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)]
44+
```
45+
46+
```k
47+
endmodule
48+
```
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
requires "sparse-bytes-simplificaitons.md"
1+
requires "sparse-bytes-simplifications.md"
2+
requires "bytes-simplifications.md"
23

34
module LEMMAS
45
imports SPARSE-BYTES-SIMPLIFICATIONS
6+
imports BYTES-SIMPLIFICATIONS
57
endmodule

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

File renamed without changes.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module SW-SPEC
1515
<mem>
1616
#bytes ( b"\x23\xa0\x40\x00\x23\x20\x41\x00" ) // sw x4, 0(x1) ; sw x4, 0(x3)
1717
#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") =>
18+
(#bytes ( (b"\x00\x00\x00\x00" +Bytes X) +Bytes b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") =>
1919
#bytes ( b"\x04\x00\x00\x00" +Bytes X +Bytes b"\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00"))
2020
.SparseBytes
2121
</mem>

0 commit comments

Comments
 (0)