Skip to content

Commit ddf2811

Browse files
Stevengrerv-auditortothtamas28
authored
Simp rule 4 int2bytes o bytes2int (#147)
Co-authored-by: devops <devops@runtimeverification.com> Co-authored-by: Tamás Tóth <tothtamas28@users.noreply.github.com>
1 parent 940f257 commit ddf2811

5 files changed

Lines changed: 29 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.109
1+
0.1.110

pyproject.toml

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

55
[project]
66
name = "kriscv"
7-
version = "0.1.109"
7+
version = "0.1.110"
88
description = "K tooling for the RISC-V architecture"
99
readme = "README.md"
1010
requires-python = "~=3.10"

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@ module BYTES-SIMPLIFICATIONS [symbolic]
162162
[simplification, preserves-definedness]
163163
rule [bytes2int-int2bytes]: Bytes2Int(Int2Bytes(LEN, V, LE), LE, Unsigned) => V &Int (2 ^Int (LEN *Int 8) -Int 1)
164164
requires 0 <=Int LEN [simplification, preserves-definedness]
165+
166+
rule [substr-reverse-bytes]:
167+
substrBytes(reverseBytes(B), START, END)
168+
=> substrBytes(B, lengthBytes(B) -Int END, lengthBytes(B) -Int START)
169+
requires 0 <=Int START andBool START +Int 1 ==Int END andBool END <=Int lengthBytes(B)
170+
[simplification, preserves-definedness]
171+
172+
rule [int2bytes-bytes2int-pad-zeros]:
173+
Int2Bytes(LEN, Bytes2Int(B, LE, Unsigned), LE)
174+
=> B +Bytes Int2Bytes(LEN -Int lengthBytes(B), 0, LE)
175+
requires lengthBytes(B) <=Int LEN
176+
[simplification]
165177
```
166178

167179
```k
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module INT2BYTES-BYTES2INT
2+
imports RISCV
3+
4+
claim [id]:
5+
<instrs> #CHECK_HALT => #HALT </instrs>
6+
<mem>
7+
#bytes ( Int2Bytes ( 4 , Bytes2Int ( substrBytes ( reverseBytes ( VALUE:Bytes ) , 20 , 21 ) , LE , Unsigned ) , LE ) ) .SparseBytes
8+
=>
9+
#bytes ( substrBytes ( VALUE:Bytes , 11 , 12 ) +Bytes b"\x00\x00\x00" ) .SparseBytes
10+
</mem>
11+
<pc> 0 </pc>
12+
<haltCond> ADDRESS ( 0 ) </haltCond>
13+
requires lengthBytes(VALUE) ==Int 32
14+
endmodule

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)