Skip to content

Simp rule 4 zkevm project's PUSH #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: jh/sstore
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.117
0.1.118
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "kriscv"
version = "0.1.117"
version = "0.1.118"
description = "K tooling for the RISC-V architecture"
readme = "README.md"
requires-python = "~=3.10"
Expand Down
15 changes: 15 additions & 0 deletions src/kriscv/kdist/riscv-semantics/lemmas/int-simplifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ module INT-SIMPLIFICATIONS [symbolic]
[simplification]
rule [int-and-add-assoc-32]: ((X &Int 4294967295) +Int Y) &Int 4294967295 => (X +Int Y) &Int 4294967295
[simplification]
rule [bytes2int-and-255]: Bytes2Int(X, LE, Unsigned) &Int 255 => Bytes2Int(X, LE, Unsigned)
requires lengthBytes(X) <=Int 1 [simplification]
rule [bytes2int-or-under-255]: Bytes2Int(b"\x00" +Bytes X, LE, Unsigned) |Int Y => Bytes2Int(Int2Bytes(Y, LE, Unsigned) +Bytes X, LE, Unsigned)
requires Y <Int 256 [simplification, concrete(Y)]
```

## Equality Lemmas

```k
rule [int-eq-bytes2int]: X ==Int Bytes2Int(B0 +Bytes B1, LE, Unsigned) =>
(X &Int ((1 <<Int (lengthBytes(B0) *Int 8)) -Int 1)) ==Int Bytes2Int(B0, LE, Unsigned)
andBool
(X >>Int (lengthBytes(B0) *Int 8)) ==Int Bytes2Int(B1, LE, Unsigned)
[simplification, concrete(B0), preserves-definedness]
// without preserves-definedness, the rule is not applicable to B1 == substrBytes(B2, I, J)
```

## Inequality Lemmas
Expand Down
14 changes: 14 additions & 0 deletions src/tests/integration/test-data/specs/zkevm-push.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module ZKEVM-PUSH
imports RISCV

claim [id]:
<instrs> #CHECK_HALT => #HALT </instrs>
<pc> 0 </pc>
<regs>
1 |-> ((Bytes2Int(OP0, LE, Unsigned) &Int 255) <<Int 8 &Int 4294967295 |Int 96 => Bytes2Int(b"`" +Bytes OP0, LE, Unsigned))
2 |-> (Bool2Word(239 ==Int Bytes2Int(b"`" +Bytes OP0, LE, Unsigned)) => 0)
3 |-> (Bool2Word(239 ==Int Bytes2Int(b"a" +Bytes substrBytes(OP1, 0, 1), LE, Unsigned)) => 0)
</regs>
<haltCond> ADDRESS(0) </haltCond>
requires lengthBytes(OP0) ==Int 1 andBool lengthBytes(OP1) ==Int 2
endmodule
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.