Skip to content

Commit 56d7e1b

Browse files
authored
Usability fixes for Foundry integration (#1429)
* foundry.md: add LEMMAS module to FOUNDRY * word.md: add notMaxUInt160 * kevm-pyk/kevm: add parens for |Int, &Int, modInt * tests/lemmas-spec: add address reprojection tests * include/lemmas: add lemmas for projection specs * kevm-pyk/kevm: add parens for typedArgs too * kevm-pyk/kevm: only update typedArgs if its present * kevm-pyk/__main__: no need for lemmas or int-simplification requires anymore * kevm-pyk/kevm: add more unparsing overrides * kevm-pyk/kevm: add more parens to unparsing * kevm-pyk/kevm: more parens * tests/foundry: update expected output * tests/foundry: update expected output * include/lemmas.k: promote bool2Word lemmas to common module * word: add notMaxUInt224 as well
1 parent 4b49f34 commit 56d7e1b

File tree

7 files changed

+64
-122
lines changed

7 files changed

+64
-122
lines changed

foundry.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@ requires "evm.md"
7575
requires "hashed-locations.md"
7676
requires "abi.md"
7777
requires "edsl.md"
78+
requires "lemmas/lemmas.k"
7879
7980
module FOUNDRY
8081
imports FOUNDRY-SUCCESS
8182
imports FOUNDRY-CHEAT-CODES
8283
imports FOUNDRY-ACCOUNTS
8384
imports EDSL
85+
imports LEMMAS
8486
8587
configuration
8688
<foundry>

kevm-pyk/src/kevm_pyk/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ def exec_foundry_kompile(
130130
foundry_definition_dir = foundry_out / 'kompiled'
131131
foundry_main_file = foundry_definition_dir / 'foundry.k'
132132
kompiled_timestamp = foundry_definition_dir / 'timestamp'
133-
requires = ['foundry.md', 'lemmas/lemmas.k', 'lemmas/int-simplification.k'] + list(requires)
134-
imports = ['FOUNDRY', 'LEMMAS', 'INT-SIMPLIFICATION'] + list(imports)
133+
requires = ['foundry.md'] + list(requires)
134+
imports = ['FOUNDRY'] + list(imports)
135135

136136
if not foundry_definition_dir.exists():
137137
foundry_definition_dir.mkdir()

kevm-pyk/src/kevm_pyk/kevm.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def kompile(
7070
@staticmethod
7171
def _patch_symbol_table(symbol_table: Dict[str, Any]) -> None:
7272
# fmt: off
73+
symbol_table['#Bottom'] = lambda: '#Bottom'
7374
symbol_table['_orBool_'] = paren(symbol_table['_orBool_'])
7475
symbol_table['_andBool_'] = paren(symbol_table['_andBool_'])
7576
symbol_table['_impliesBool_'] = paren(symbol_table['_impliesBool_'])
@@ -78,6 +79,9 @@ def _patch_symbol_table(symbol_table: Dict[str, Any]) -> None:
7879
symbol_table['_*Int_'] = paren(symbol_table['_*Int_'])
7980
symbol_table['_-Int_'] = paren(symbol_table['_-Int_'])
8081
symbol_table['_+Int_'] = paren(symbol_table['_+Int_'])
82+
symbol_table['_&Int_'] = paren(symbol_table['_&Int_'])
83+
symbol_table['_|Int_'] = paren(symbol_table['_|Int_'])
84+
symbol_table['_modInt_'] = paren(symbol_table['_modInt_'])
8185
symbol_table['#Or'] = paren(symbol_table['#Or'])
8286
symbol_table['#And'] = paren(symbol_table['#And'])
8387
symbol_table['#Implies'] = paren(symbol_table['#Implies'])
@@ -87,14 +91,20 @@ def _patch_symbol_table(symbol_table: Dict[str, Any]) -> None:
8791
symbol_table['_AccountCellMap_'] = paren(lambda a1, a2: a1 + '\n' + a2)
8892
symbol_table['.AccountCellMap'] = lambda: '.Bag'
8993
symbol_table['AccountCellMapItem'] = lambda k, v: v
90-
symbol_table['_[_:=_]_EVM-TYPES_Memory_Memory_Int_ByteArray'] = lambda m, k, v: m + ' [ ' + k + ' := (' + v + '):ByteArray ]'
94+
symbol_table['_[_:=_]_EVM-TYPES_Memory_Memory_Int_ByteArray'] = paren(lambda m, k, v: m + ' [ ' + k + ' := (' + v + '):ByteArray ]')
9195
symbol_table['_[_.._]_EVM-TYPES_ByteArray_ByteArray_Int_Int'] = lambda m, s, w: '(' + m + ' [ ' + s + ' .. ' + w + ' ]):ByteArray'
96+
symbol_table['_:__EVM-TYPES_WordStack_Int_WordStack'] = paren(symbol_table['_:__EVM-TYPES_WordStack_Int_WordStack'])
9297
symbol_table['_<Word__EVM-TYPES_Int_Int_Int'] = paren(lambda a1, a2: '(' + a1 + ') <Word (' + a2 + ')')
9398
symbol_table['_>Word__EVM-TYPES_Int_Int_Int'] = paren(lambda a1, a2: '(' + a1 + ') >Word (' + a2 + ')')
9499
symbol_table['_<=Word__EVM-TYPES_Int_Int_Int'] = paren(lambda a1, a2: '(' + a1 + ') <=Word (' + a2 + ')')
95100
symbol_table['_>=Word__EVM-TYPES_Int_Int_Int'] = paren(lambda a1, a2: '(' + a1 + ') >=Word (' + a2 + ')')
96101
symbol_table['_==Word__EVM-TYPES_Int_Int_Int'] = paren(lambda a1, a2: '(' + a1 + ') ==Word (' + a2 + ')')
97102
symbol_table['_s<Word__EVM-TYPES_Int_Int_Int'] = paren(lambda a1, a2: '(' + a1 + ') s<Word (' + a2 + ')')
103+
symbol_table['_[_]_EVM-TYPES_Int_WordStack_Int'] = paren(symbol_table['_[_]_EVM-TYPES_Int_WordStack_Int'])
104+
symbol_table['_++__EVM-TYPES_ByteArray_ByteArray_ByteArray'] = paren(symbol_table['_++__EVM-TYPES_ByteArray_ByteArray_ByteArray'])
105+
symbol_table['_[_.._]_EVM-TYPES_ByteArray_ByteArray_Int_Int'] = paren(symbol_table['_[_.._]_EVM-TYPES_ByteArray_ByteArray_Int_Int'])
106+
if 'typedArgs' in symbol_table:
107+
symbol_table['typedArgs'] = paren(symbol_table['typedArgs'])
98108
# fmt: on
99109

100110
class Sorts:

0 commit comments

Comments
 (0)