Skip to content
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

Upstream lemmas from Wormhole engagement #1866

Merged
merged 40 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
aa76e2c
Add notMaxUInt constants
qian-hu May 27, 2023
8327f39
Add bitwise-arithmetic lemmas
qian-hu May 27, 2023
26a1589
Upstream bytes-simplification lemmas from Wormhole
qian-hu May 27, 2023
22f8392
Upstream lemmas from Wormhole engagement
qian-hu May 27, 2023
f45dcab
Set Version: 1.0.187
May 27, 2023
dcca53c
Revert "Upstream lemmas from Wormhole engagement"
qian-hu May 27, 2023
1812eb9
Merge branch 'master' into wormhole-lemmas
qian-hu Jun 14, 2023
a975eb5
Set Version: 1.0.210
Jun 14, 2023
2f1dfaf
Update include/kframework/word.md
qian-hu Jun 14, 2023
214859c
Merge branch 'master' into wormhole-lemmas
qian-hu Jun 19, 2023
eab32d5
Set Version: 1.0.211
Jun 19, 2023
7137fac
Merge remote-tracking branch 'origin/master' into wormhole-lemmas
qian-hu Jun 20, 2023
97e4f9e
Set Version: 1.0.212
Jun 20, 2023
5789fc0
Merge branch 'master' into wormhole-lemmas
qian-hu Jun 21, 2023
3a66b8e
Set Version: 1.0.213
Jun 21, 2023
93abade
Merge branch 'master' into wormhole-lemmas
qian-hu Jun 22, 2023
ad7f4a4
Merge branch 'master' into wormhole-lemmas
qian-hu Jun 26, 2023
c79870e
Set Version: 1.0.219
Jun 26, 2023
17bd534
Merge branch 'master' into wormhole-lemmas
qian-hu Jul 4, 2023
384077f
Set Version: 1.0.227
Jul 4, 2023
e0b8a2d
Merge branch 'master' into wormhole-lemmas
qian-hu Jul 4, 2023
5fd741c
Set Version: 1.0.228
Jul 4, 2023
e8814f3
generalize lemmas
qian-hu Aug 1, 2023
3d48739
Merge branch 'master' into wormhole-lemmas
qian-hu Aug 1, 2023
d590543
Set Version: 1.0.244
Aug 1, 2023
9b7bb4f
Merge branch 'master' into wormhole-lemmas
qian-hu Aug 8, 2023
ec5beed
Set Version: 1.0.249
Aug 8, 2023
533dc1d
Merge branch 'master' into wormhole-lemmas
qian-hu Sep 19, 2023
63c4407
Set Version: 1.0.296
Sep 19, 2023
d9262f5
merge with master
PetarMax Oct 2, 2023
4a80da5
Set Version: 1.0.309
Oct 2, 2023
8cad2bb
cleanup
PetarMax Oct 2, 2023
3365bcd
simplification fix
PetarMax Oct 2, 2023
f575742
Merge branch 'master' into wormhole-lemmas
PetarMax Oct 2, 2023
10f6b18
Set Version: 1.0.310
Oct 2, 2023
4a726fa
removing simplification
PetarMax Oct 2, 2023
5647759
Fix simplification
qian-hu Oct 2, 2023
b3f8251
Add claims for lemmas
qian-hu Oct 2, 2023
8e0ff8c
Update bytes-simplification.k
qian-hu Oct 2, 2023
7d00d95
Add more claims for lemmas
qian-hu Oct 3, 2023
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
30 changes: 30 additions & 0 deletions include/kframework/lemmas/bitwise-simplification.k
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ module BITWISE-SIMPLIFICATION [symbolic]
rule A |Int 0 => A [simplification]
rule A |Int A => A [simplification]

rule 1 |Int _ ==Int 0 => false [simplification]
rule (A |Int B) ==Int (B |Int A) => true [simplification, smt-lemma]

// ###########################################################################
// bit-and
// ###########################################################################
Expand All @@ -20,6 +23,8 @@ module BITWISE-SIMPLIFICATION [symbolic]
rule _ &Int 0 => 0 [simplification]
rule A &Int A => A [simplification]

rule A &Int B => B &Int A [symbolic(A), concrete(B), simplification]

rule chop ( ( maxUInt48 &Int X:Int ) *Int Y:Int ) => ( maxUInt48 &Int X:Int ) *Int Y
requires 0 <=Int X andBool 0 <=Int Y andBool Y <=Int pow208 [simplification]

Expand All @@ -40,7 +45,20 @@ module BITWISE-SIMPLIFICATION [symbolic]
rule [bitwise-and-lt]: (X &Int Y) <Int Z => true requires 0 <=Int X andBool 0 <=Int Y andBool (X <Int Z orBool Y <Int Z) [simplification]
rule [bitwise-or-lt-pow256]: (X |Int Y) <Int pow256 => true requires 0 <=Int X andBool 0 <=Int Y andBool X <Int pow256 andBool Y <Int pow256 [simplification]

// We should probably generalize the simplifications below for relevant powers of two.
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 notMaxUInt160 &Int X => 0 requires #rangeUInt(160, X) [simplification]

rule notMaxUInt240 &Int (X <<Int 240) => X <<Int 240 requires #rangeUInt(16, X) [simplification]
rule notMaxUInt248 &Int (X <<Int 248) => X <<Int 248 requires #rangeUInt( 8, X) [simplification]

rule maxUInt8 &Int (X |Int ( notMaxUInt8 &Int Y:Int)) => X requires #rangeUInt( 8, X) andBool 0 <=Int Y [simplification]
rule maxUInt16 &Int (X |Int ( notMaxUInt16 &Int Y:Int)) => X requires #rangeUInt( 16, X) andBool 0 <=Int Y [simplification]
rule maxUInt32 &Int (X |Int ( notMaxUInt32 &Int Y:Int)) => X requires #rangeUInt( 32, X) andBool 0 <=Int Y [simplification]
rule maxUInt64 &Int (X |Int ( notMaxUInt64 &Int Y:Int)) => X requires #rangeUInt( 64, X) andBool 0 <=Int Y [simplification]
rule maxUInt160 &Int (X |Int (notMaxUInt160 &Int Y:Int)) => X requires #rangeUInt(160, X) andBool 0 <=Int Y [simplification]

rule [lengthBytes-upInt-32-lower-bound]:
Expand All @@ -52,4 +70,16 @@ module BITWISE-SIMPLIFICATION [symbolic]
lengthBytes(X) +Int 32 >Int notMaxUInt5 &Int ( lengthBytes(X) +Int 31 ) => true
[simplification, smt-lemma]

// ###########################################################################
// shift
// ###########################################################################

rule (X <<Int 16) <Int pow256 => true requires #rangeUInt(240, X) [simplification]
rule (X <<Int 240) <Int pow256 => true requires #rangeUInt( 16, X) [simplification]
rule (X <<Int 248) <Int pow256 => true requires #rangeUInt( 8, X) [simplification]
qian-hu marked this conversation as resolved.
Show resolved Hide resolved

rule (X <<Int 16) ==Int (X *Int pow16) => true requires 0 <=Int X [simplification, smt-lemma]
qian-hu marked this conversation as resolved.
Show resolved Hide resolved

rule 0 <=Int (X <<Int Y) => true requires 0 <=Int X andBool 0 <=Int Y [simplification]

endmodule
5 changes: 5 additions & 0 deletions include/kframework/lemmas/bytes-simplification.k
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ module BYTES-SIMPLIFICATION [symbolic]
requires 0 <=Int W1 andBool 0 <=Int W2
[simplification]

rule #buf(32 , #asWord(B:Bytes)) => B requires lengthBytes(B) ==Int 32 [simplification]
qian-hu marked this conversation as resolved.
Show resolved Hide resolved

rule #buf(32, X <<Int 248) => #buf(1, X) +Bytes #buf(31, 0) requires #rangeUInt( 8, X) [simplification]
rule #buf(32, X <<Int 240) => #buf(2, X) +Bytes #buf(30, 0) requires #rangeUInt(16, X) [simplification]
qian-hu marked this conversation as resolved.
Show resolved Hide resolved

// #range

rule [range-empty]:
Expand Down
12 changes: 12 additions & 0 deletions include/kframework/word.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,32 @@ The maximum and minimum values of each type are defined below.
rule maxUFixed128x10 => 3402823669209384634633746074317682114550000000000 /* ( 2^128 - 1) * 10^10 */

syntax Int ::= "notMaxUInt5" [alias] /* FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0 */
| "notMaxUInt8" [alias] /* FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 */
| "notMaxUInt16" [alias] /* FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000 */
| "notMaxUInt32" [alias] /* FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000 */
| "notMaxUInt64" [alias] /* FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000 */
| "notMaxUInt96" [alias] /* FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000 */
| "notMaxUInt128" [alias] /* FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000 */
| "notMaxUInt160" [alias] /* FFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000 */
| "notMaxUInt192" [alias] /* FFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 */
| "notMaxUInt208" [alias] /* FFFFFFFFFFFF0000000000000000000000000000000000000000000000000000 */
| "notMaxUInt224" [alias] /* FFFFFFFF00000000000000000000000000000000000000000000000000000000 */
| "notMaxUInt240" [alias] /* FFFF000000000000000000000000000000000000000000000000000000000000 */
| "notMaxUInt248" [alias] /* FF00000000000000000000000000000000000000000000000000000000000000 */
// -------------------------------------------------------------------------------------------------------------
rule notMaxUInt5 => 115792089237316195423570985008687907853269984665640564039457584007913129639904
rule notMaxUInt8 => 115792089237316195423570985008687907853269984665640564039457584007913129639680
rule notMaxUInt16 => 115792089237316195423570985008687907853269984665640564039457584007913129574400
rule notMaxUInt32 => 115792089237316195423570985008687907853269984665640564039457584007908834672640
rule notMaxUInt64 => 115792089237316195423570985008687907853269984665640564039439137263839420088320
qian-hu marked this conversation as resolved.
Show resolved Hide resolved
rule notMaxUInt96 => 115792089237316195423570985008687907853269984665561335876943319670319585689600
rule notMaxUInt128 => 115792089237316195423570985008687907852929702298719625575994209400481361428480
rule notMaxUInt160 => 115792089237316195423570985007226406215939081747436879206741300988257197096960
rule notMaxUInt192 => 115792089237316195417293883273301227089434195242432897623355228563449095127040
rule notMaxUInt208 => 115792089237315784047431654707177369110974345328014318355491175612947292487680
rule notMaxUInt224 => 115792089210356248756420345214020892766250353992003419616917011526809519390720
rule notMaxUInt240 => 115790322390251417039241401711187164934754157181743688420499462401711837020160
rule notMaxUInt248 => 115339776388732929035197660848497720713218148788040405586178452820382218977280

syntax Int ::= "eth" [macro]
| "maxBlockNum" [macro] /* 7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF == (2 ^ 256) - (2 ^ 255) - 1 */
Expand Down
2 changes: 1 addition & 1 deletion kevm-pyk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "kevm-pyk"
version = "1.0.186"
version = "1.0.187"
description = ""
authors = [
"Runtime Verification, Inc. <contact@runtimeverification.com>",
Expand Down
2 changes: 1 addition & 1 deletion package/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kevm (1.0.186) unstable; urgency=medium
kevm (1.0.187) unstable; urgency=medium

* Initial Release.

Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.186
1.0.187