Skip to content

Commit 755ba3b

Browse files
committed
kevm-pyk/__main__: simplify a bit
1 parent f86390f commit 755ba3b

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

kevm-pyk/src/kevm_pyk/__main__.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,14 @@ def exec_foundry_prove(
323323
if unfound_tests:
324324
raise ValueError(f'Test identifiers not found: {unfound_tests}')
325325

326+
# TODO: We should be using lemma_rules for execute endpoint
327+
# lemma_rules = [KRule(KToken(lr, 'K'), att=KAtt({'simplification': ''})) for lr in lemmas]
328+
329+
def _write_cfg(_cfg: KCFG, _cfgpath: Path) -> None:
330+
with open(_cfgpath, 'w') as cfgfile:
331+
cfgfile.write(json.dumps(_cfg.to_dict()))
332+
_LOGGER.info(f'Updated CFG file: {_cfgpath}')
333+
326334
kcfgs: Dict[str, Tuple[KCFG, Path]] = {}
327335
for test in tests:
328336
kcfg_file = kcfgs_dir / f'{test}.json'
@@ -341,21 +349,11 @@ def exec_foundry_prove(
341349
target_simplified = foundry.simplify(CTerm(target_simplified))
342350
cfg = KCFG__replace_node(cfg, cfg.get_unique_target().id, CTerm(target_simplified))
343351
kcfgs[test] = (cfg, kcfg_file)
344-
with open(kcfg_file, 'w') as kf:
345-
kf.write(json.dumps(cfg.to_dict()))
346-
kf.close()
347-
_LOGGER.info(f'Wrote file: {kcfg_file}')
352+
_write_cfg(cfg, kcfg_file)
348353
else:
349354
with open(kcfg_file, 'r') as kf:
350355
kcfgs[test] = (KCFG.from_dict(json.loads(kf.read())), kcfg_file)
351356

352-
lemma_rules = [KRule(KToken(lr, 'K'), att=KAtt({'simplification': ''})) for lr in lemmas]
353-
354-
def _write_cfg(_cfg: KCFG, _cfgpath: Path) -> None:
355-
with open(_cfgpath, 'w') as cfgfile:
356-
cfgfile.write(json.dumps(_cfg.to_dict()))
357-
_LOGGER.info(f'Updated CFG file: {_cfgpath}')
358-
359357
def prove_it(id_and_cfg: Tuple[str, Tuple[KCFG, Path]]) -> bool:
360358
cfgid, (cfg, cfgpath) = id_and_cfg
361359
target_node = cfg.get_unique_target()

0 commit comments

Comments
 (0)