diff --git a/package/version b/package/version index c29f5f75..72400828 100644 --- a/package/version +++ b/package/version @@ -1 +1 @@ -0.1.114 +0.1.115 diff --git a/pyproject.toml b/pyproject.toml index 44a23b14..40193db8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "kriscv" -version = "0.1.114" +version = "0.1.115" description = "K tooling for the RISC-V architecture" readme = "README.md" requires-python = "~=3.10" diff --git a/src/kriscv/kdist/riscv-semantics/lemmas/int-simplifications.md b/src/kriscv/kdist/riscv-semantics/lemmas/int-simplifications.md index 1dcc1499..b2d486f8 100644 --- a/src/kriscv/kdist/riscv-semantics/lemmas/int-simplifications.md +++ b/src/kriscv/kdist/riscv-semantics/lemmas/int-simplifications.md @@ -39,6 +39,10 @@ module INT-SIMPLIFICATIONS [symbolic] ```k rule [int-and-ineq]: 0 <=Int A &Int B => true requires 0 <=Int A andBool 0 <=Int B [simplification] + rule [int-and-ineq-4294967295]: 0 <=Int _ &Int 4294967295 => true [simplification(45)] + rule [int-and-ineq-65535]: 0 <=Int _ &Int 65535 => true [simplification(45)] + rule [int-and-ineq-255]: 0 <=Int _ &Int 255 => true [simplification(45)] + rule [int-or-gt]: 0 true requires 0 >Int B => true requires 0 <=Int A andBool 0 <=Int B [simplification] rule [int-add-ineq]: A <=Int A +Int B => true requires 0 <=Int B [simplification] rule [int-add-ineq-0]: 0 <=Int A +Int B => true requires 0 <=Int A andBool 0 <=Int B [simplification] diff --git a/src/kriscv/kdist/riscv-semantics/lemmas/lemmas.k b/src/kriscv/kdist/riscv-semantics/lemmas/lemmas.k index 0094d1d1..0062b65d 100644 --- a/src/kriscv/kdist/riscv-semantics/lemmas/lemmas.k +++ b/src/kriscv/kdist/riscv-semantics/lemmas/lemmas.k @@ -2,10 +2,12 @@ requires "sparse-bytes-simplifications.md" requires "bytes-simplifications.md" requires "int-simplifications.md" requires "word-simplifications.md" +requires "zkevm-harness-simplifications.md" module LEMMAS imports SPARSE-BYTES-SIMPLIFICATIONS imports BYTES-SIMPLIFICATIONS imports INT-SIMPLIFICATIONS imports WORD-SIMPLIFICATIONS + imports ZKEVM-HARNESS-SIMPLIFICATIONS endmodule diff --git a/src/kriscv/kdist/riscv-semantics/lemmas/zkevm-harness-simplifications.md b/src/kriscv/kdist/riscv-semantics/lemmas/zkevm-harness-simplifications.md new file mode 100644 index 00000000..192c4206 --- /dev/null +++ b/src/kriscv/kdist/riscv-semantics/lemmas/zkevm-harness-simplifications.md @@ -0,0 +1,47 @@ +# ZKEVM Harness Simplifications + +This file contains simplification rules for the [zkevm-harness](https://github.com/runtimeverification/zkevm-harness). Although these simplification rules are not specific to this project, they are rules that were discovered to be needed within this project. However, we currently do not want to perform a comprehensive organization of rules, so we place these rules here for quick addition of simplification rules. + +Why not put them in the zkevm-harness repository? +1. We currently do not have an out-of-the-box simplification rule testing framework, so we would need to spend additional time creating a new testing framework in the zkevm-harness repository; +2. These rules actually have some general applicability, but considering performance, we may not need to adopt these rules for all verification targets. + +```k +requires "../word.md" +module ZKEVM-HARNESS-SIMPLIFICATIONS [symbolic] + imports INT + imports BYTES + imports K-EQUAL + imports BOOL + imports WORD +``` + +## MSTORE + +The following rules are required to prove the claim in `tests/integration/test-data/specs/zkevm-mstore.k`: + +```k +rule 0 true requires 0 true requires 0 <=Int A andBool 0 true requires 0 Bytes2Int (B, LE, Unsigned) [simplification(45)] +``` + +The following additional rules would be needed to handle the 5th register in the zkevm-mstore claim, but they interfere with the targeted rewriting of the 4th register. Therefore, they are not included in the module above: +``` +rule X false requires 2 ^Int (lengthBytes(B) *Int 8) -Int 1 <=Int X [simplification] +rule A A -Int C X [simplification] +``` + +To handle the 6-th and 7-th registers in the zkevm-mstore claim, we need the following rules: +```k +rule Bool2Word(B) ==Int 0 => notBool B [simplification] +rule Bool2Word(B) ==Int 1 => B [simplification] +``` + +```k +endmodule +``` \ No newline at end of file diff --git a/src/tests/integration/test-data/specs/zkevm-mstore-0.k b/src/tests/integration/test-data/specs/zkevm-mstore-0.k new file mode 100644 index 00000000..9fa0675a --- /dev/null +++ b/src/tests/integration/test-data/specs/zkevm-mstore-0.k @@ -0,0 +1,21 @@ +module ZKEVM-MSTORE-0 + imports RISCV + + claim [id]: + #CHECK_HALT => #HALT + 0 + + 1 |-> (Bool2Word(0 1) + 2 |-> (Bool2Word(0 <=Int Bytes2Int ( OFFSET:Bytes +Bytes b"\x00\x00\x00" , LE , Unsigned )) => 1) + 3 |-> (Bool2Word(0 1) + 4 |-> (Bool2Word(0 1) + // 5 |-> (Bool2Word(4294967295 0) + 6 |-> (Bool2Word(Y <=Int Z) => 0) + 7 |-> (Bool2Word(Z <=Int 4294967295) => 1) + + ADDRESS ( 0 ) + requires 0