diff --git a/kevm-pyk/pyproject.toml b/kevm-pyk/pyproject.toml index 94b8e1a206..72b28ed8bd 100644 --- a/kevm-pyk/pyproject.toml +++ b/kevm-pyk/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "kevm-pyk" -version = "1.0.413" +version = "1.0.414" description = "" authors = [ "Runtime Verification, Inc. ", diff --git a/kevm-pyk/src/kevm_pyk/__init__.py b/kevm-pyk/src/kevm_pyk/__init__.py index 4be637f809..723ba5a060 100644 --- a/kevm-pyk/src/kevm_pyk/__init__.py +++ b/kevm-pyk/src/kevm_pyk/__init__.py @@ -6,4 +6,4 @@ from typing import Final -VERSION: Final = '1.0.413' +VERSION: Final = '1.0.414' diff --git a/kevm-pyk/src/kevm_pyk/kproj/evm-semantics/lemmas/bitwise-simplification.k b/kevm-pyk/src/kevm_pyk/kproj/evm-semantics/lemmas/bitwise-simplification.k index c857bb8da8..6484391392 100644 --- a/kevm-pyk/src/kevm_pyk/kproj/evm-semantics/lemmas/bitwise-simplification.k +++ b/kevm-pyk/src/kevm_pyk/kproj/evm-semantics/lemmas/bitwise-simplification.k @@ -34,11 +34,12 @@ module BITWISE-SIMPLIFICATION [symbolic] rule maxUInt48 &Int X true requires 0 <=Int X [simplification, smt-lemma] rule maxUInt160 &Int X true requires 0 <=Int X [simplification, smt-lemma] - rule [bitwise-and-identity]: + // Generalization of: maxUIntXXX &Int Y => Y requires #rangeUInt(XXX, Y) + rule [bitwise-and-maxUInt-identity]: X &Int Y => Y requires 0 <=Int X andBool X +Int 1 ==Int 2 ^Int log2Int(X +Int 1) - andBool 0 <=Int Y andBool Y true requires 0 <=Int X andBool 0 <=Int Y [simplification] @@ -47,36 +48,28 @@ module BITWISE-SIMPLIFICATION [symbolic] rule [bitwise-and-lt]: (X &Int Y) true requires 0 <=Int X andBool 0 <=Int Y andBool (X true requires 0 <=Int X andBool 0 <=Int Y andBool X 0 requires #rangeUInt( 5, X) [simplification] - rule notMaxUInt8 &Int X => 0 requires #rangeUInt( 8, X) [simplification] - rule notMaxUInt16 &Int X => 0 requires #rangeUInt( 16, X) [simplification] - rule notMaxUInt32 &Int X => 0 requires #rangeUInt( 32, X) [simplification] - rule notMaxUInt64 &Int X => 0 requires #rangeUInt( 64, X) [simplification] - rule notMaxUInt96 &Int X => 0 requires #rangeUInt( 96, X) [simplification] - rule notMaxUInt128 &Int X => 0 requires #rangeUInt(128, X) [simplification] - rule notMaxUInt160 &Int X => 0 requires #rangeUInt(160, X) [simplification] - rule notMaxUInt192 &Int X => 0 requires #rangeUInt(192, X) [simplification] - rule notMaxUInt208 &Int X => 0 requires #rangeUInt(208, X) [simplification] - rule notMaxUInt224 &Int X => 0 requires #rangeUInt(224, X) [simplification] - rule notMaxUInt240 &Int X => 0 requires #rangeUInt(240, X) [simplification] - rule notMaxUInt248 &Int X => 0 requires #rangeUInt(248, X) [simplification] - - rule notMaxUInt240 &Int (X < X < X < maxUInt8 &Int X [simplification] - rule maxUInt16 &Int (X |Int (notMaxUInt16 &Int _)) => maxUInt16 &Int X [simplification] - rule maxUInt32 &Int (X |Int (notMaxUInt32 &Int _)) => maxUInt32 &Int X [simplification] - rule maxUInt64 &Int (X |Int (notMaxUInt64 &Int _)) => maxUInt64 &Int X [simplification] - rule maxUInt96 &Int (X |Int (notMaxUInt96 &Int _)) => maxUInt96 &Int X [simplification] - rule maxUInt128 &Int (X |Int (notMaxUInt128 &Int _)) => maxUInt128 &Int X [simplification] - rule maxUInt160 &Int (X |Int (notMaxUInt160 &Int _)) => maxUInt160 &Int X [simplification] - rule maxUInt192 &Int (X |Int (notMaxUInt192 &Int _)) => maxUInt192 &Int X [simplification] - rule maxUInt208 &Int (X |Int (notMaxUInt208 &Int _)) => maxUInt208 &Int X [simplification] - rule maxUInt224 &Int (X |Int (notMaxUInt224 &Int _)) => maxUInt224 &Int X [simplification] - rule maxUInt240 &Int (X |Int (notMaxUInt240 &Int _)) => maxUInt240 &Int X [simplification] - rule maxUInt248 &Int (X |Int (notMaxUInt248 &Int _)) => maxUInt248 &Int X [simplification] + // Generalization of: notMaxUIntXXX &Int Y => 0 requires #rangeUInt(XXX, Y) + rule [bitwise-and-notMaxUInt-zero]: + X &Int Y => 0 + requires #rangeUInt(256, X) + andBool 2 ^Int ( log2Int ( pow256 -Int X ) ) ==Int pow256 -Int X + andBool 0 <=Int Y andBool Y Y < Y < maxUIntXXX &Int Y + rule X &Int (Y |Int (Z &Int T)) => X &Int Y + requires 0 <=Int X andBool 0 <=Int Y andBool 0 <=Int Z andBool 0 <=Int T + andBool X +Int 1 ==Int 2 ^Int log2Int(X +Int 1) + andBool X +Int Z ==Int maxUInt256 + [simplification, concrete(X, Z), comm] rule [lengthBytes-upInt-32-lower-bound]: lengthBytes(X) <=Int notMaxUInt5 &Int ( lengthBytes(X) +Int 31 ) => true diff --git a/package/version b/package/version index a72006d007..7ce89ff651 100644 --- a/package/version +++ b/package/version @@ -1 +1 @@ -1.0.413 +1.0.414 diff --git a/tests/specs/functional/lemmas-spec.k b/tests/specs/functional/lemmas-spec.k index 9fd2b506de..dee3b618a4 100644 --- a/tests/specs/functional/lemmas-spec.k +++ b/tests/specs/functional/lemmas-spec.k @@ -465,35 +465,47 @@ module LEMMAS-SPEC // bitwise // ------- - claim runLemma ( notMaxUInt5 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 5 , X ) - claim runLemma ( notMaxUInt8 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 8 , X ) - claim runLemma ( notMaxUInt16 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 16 , X ) - claim runLemma ( notMaxUInt32 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 32 , X ) - claim runLemma ( notMaxUInt64 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 64 , X ) - claim runLemma ( notMaxUInt96 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 96 , X ) - claim runLemma ( notMaxUInt128 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 128 , X ) - claim runLemma ( notMaxUInt160 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 160 , X ) - claim runLemma ( notMaxUInt192 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 192 , X ) - claim runLemma ( notMaxUInt208 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 208 , X ) - claim runLemma ( notMaxUInt224 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 224 , X ) - claim runLemma ( notMaxUInt240 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 240 , X ) - claim runLemma ( notMaxUInt248 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 248 , X ) - - claim runLemma ( notMaxUInt240 &Int ( X < doneLemma( X < requires #rangeUInt ( 16 , X ) - claim runLemma ( notMaxUInt248 &Int ( X < doneLemma( X < requires #rangeUInt ( 8 , X ) - - claim runLemma ( maxUInt8 &Int ( X |Int ( notMaxUInt8 &Int _ ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 8 , X ) - claim runLemma ( maxUInt16 &Int ( X |Int ( notMaxUInt16 &Int _ ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 16 , X ) - claim runLemma ( maxUInt32 &Int ( X |Int ( notMaxUInt32 &Int _ ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 32 , X ) - claim runLemma ( maxUInt64 &Int ( X |Int ( notMaxUInt64 &Int _ ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 64 , X ) - claim runLemma ( maxUInt96 &Int ( X |Int ( notMaxUInt96 &Int _ ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 96 , X ) - claim runLemma ( maxUInt128 &Int ( X |Int ( notMaxUInt128 &Int _ ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 128 , X ) - claim runLemma ( maxUInt160 &Int ( X |Int ( notMaxUInt160 &Int _ ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 160 , X ) - claim runLemma ( maxUInt192 &Int ( X |Int ( notMaxUInt192 &Int _ ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 192 , X ) - claim runLemma ( maxUInt208 &Int ( X |Int ( notMaxUInt208 &Int _ ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 208 , X ) - claim runLemma ( maxUInt224 &Int ( X |Int ( notMaxUInt224 &Int _ ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 224 , X ) - claim runLemma ( maxUInt240 &Int ( X |Int ( notMaxUInt240 &Int _ ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 240 , X ) - claim runLemma ( maxUInt248 &Int ( X |Int ( notMaxUInt248 &Int _ ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 248 , X ) + claim [bit-n005-0]: runLemma ( notMaxUInt5 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 5 , X ) + claim [bit-n008-0]: runLemma ( notMaxUInt8 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 8 , X ) + claim [bit-n016-0]: runLemma ( notMaxUInt16 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 16 , X ) + claim [bit-n032-0]: runLemma ( notMaxUInt32 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 32 , X ) + claim [bit-n064-0]: runLemma ( notMaxUInt64 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 64 , X ) + claim [bit-n096-0]: runLemma ( notMaxUInt96 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 96 , X ) + claim [bit-n128-0]: runLemma ( notMaxUInt128 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 128 , X ) + claim [bit-n160-0]: runLemma ( notMaxUInt160 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 160 , X ) + claim [bit-n192-0]: runLemma ( notMaxUInt192 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 192 , X ) + claim [bit-n208-0]: runLemma ( notMaxUInt208 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 208 , X ) + claim [bit-n224-0]: runLemma ( notMaxUInt224 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 224 , X ) + claim [bit-n240-0]: runLemma ( notMaxUInt240 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 240 , X ) + claim [bit-n248-0]: runLemma ( notMaxUInt248 &Int X ) => doneLemma( 0 ) ... requires #rangeUInt ( 248 , X ) + + claim [bit-n005-shl]: runLemma ( notMaxUInt5 &Int ( X < doneLemma( X < requires 0 <=Int X andBool X runLemma ( notMaxUInt8 &Int ( X < doneLemma( X < requires #rangeUInt ( 248 , X ) + claim [bit-n016-shl]: runLemma ( notMaxUInt16 &Int ( X < doneLemma( X < requires #rangeUInt ( 240 , X ) + claim [bit-n032-shl]: runLemma ( notMaxUInt32 &Int ( X < doneLemma( X < requires #rangeUInt ( 224 , X ) + claim [bit-n064-shl]: runLemma ( notMaxUInt64 &Int ( X < doneLemma( X < requires #rangeUInt ( 192 , X ) + claim [bit-n096-shl]: runLemma ( notMaxUInt96 &Int ( X < doneLemma( X < requires #rangeUInt ( 160 , X ) + claim [bit-n128-shl]: runLemma ( notMaxUInt128 &Int ( X < doneLemma( X < requires #rangeUInt ( 128 , X ) + claim [bit-n160-shl]: runLemma ( notMaxUInt160 &Int ( X < doneLemma( X < requires #rangeUInt ( 96 , X ) + claim [bit-n192-shl]: runLemma ( notMaxUInt192 &Int ( X < doneLemma( X < requires #rangeUInt ( 64 , X ) + claim [bit-n208-shl]: runLemma ( notMaxUInt208 &Int ( X < doneLemma( X < requires #rangeUInt ( 48 , X ) + claim [bit-n224-shl]: runLemma ( notMaxUInt224 &Int ( X < doneLemma( X < requires #rangeUInt ( 32 , X ) + claim [bit-n240-shl]: runLemma ( notMaxUInt240 &Int ( X < doneLemma( X < requires #rangeUInt ( 16 , X ) + claim [bit-n248-shl]: runLemma ( notMaxUInt248 &Int ( X < doneLemma( X < requires #rangeUInt ( 8 , X ) + + claim [bit-005-m-or-nm]: runLemma ( maxUInt5 &Int ( X |Int ( notMaxUInt5 &Int T ) ) ) => doneLemma( X ) ... requires 0 <=Int X andBool X runLemma ( maxUInt8 &Int ( X |Int ( notMaxUInt8 &Int T ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 8 , X ) andBool 0 <=Int T + claim [bit-016-m-or-nm]: runLemma ( maxUInt16 &Int ( X |Int ( notMaxUInt16 &Int T ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 16 , X ) andBool 0 <=Int T + claim [bit-032-m-or-nm]: runLemma ( maxUInt32 &Int ( X |Int ( notMaxUInt32 &Int T ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 32 , X ) andBool 0 <=Int T + claim [bit-064-m-or-nm]: runLemma ( maxUInt64 &Int ( X |Int ( notMaxUInt64 &Int T ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 64 , X ) andBool 0 <=Int T + claim [bit-096-m-or-nm]: runLemma ( maxUInt96 &Int ( X |Int ( notMaxUInt96 &Int T ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 96 , X ) andBool 0 <=Int T + claim [bit-128-m-or-nm]: runLemma ( maxUInt128 &Int ( X |Int ( notMaxUInt128 &Int T ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 128 , X ) andBool 0 <=Int T + claim [bit-160-m-or-nm]: runLemma ( maxUInt160 &Int ( X |Int ( notMaxUInt160 &Int T ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 160 , X ) andBool 0 <=Int T + claim [bit-192-m-or-nm]: runLemma ( maxUInt192 &Int ( X |Int ( notMaxUInt192 &Int T ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 192 , X ) andBool 0 <=Int T + claim [bit-208-m-or-nm]: runLemma ( maxUInt208 &Int ( X |Int ( notMaxUInt208 &Int T ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 208 , X ) andBool 0 <=Int T + claim [bit-224-m-or-nm]: runLemma ( maxUInt224 &Int ( X |Int ( notMaxUInt224 &Int T ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 224 , X ) andBool 0 <=Int T + claim [bit-240-m-or-nm]: runLemma ( maxUInt240 &Int ( X |Int ( notMaxUInt240 &Int T ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 240 , X ) andBool 0 <=Int T + claim [bit-248-m-or-nm]: runLemma ( maxUInt248 &Int ( X |Int ( notMaxUInt248 &Int T ) ) ) => doneLemma( X ) ... requires #rangeUInt ( 248 , X ) andBool 0 <=Int T claim runLemma ( #buf ( 32 , #asWord ( X ) ) ) => doneLemma( X ) requires lengthBytes(X) ==Int 32 claim runLemma ( #buf ( 32 , X < doneLemma( #buf ( 1 , X ) +Bytes #buf ( 31 , 0 ) ) ... requires #rangeUInt ( 8 , X )