Skip to content

Commit a966100

Browse files
committed
kevm-pyk/utils: remove unused methods sanitize_config and KDefinition__expand_macros
1 parent 3c39b1e commit a966100

File tree

1 file changed

+3
-66
lines changed

1 file changed

+3
-66
lines changed

kevm-pyk/src/kevm_pyk/utils.py

Lines changed: 3 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
1-
from logging import Logger
2-
from typing import Collection, Iterable, List, Optional, Tuple
1+
from typing import Collection, Iterable, List
32

43
from pyk.cterm import CTerm
54
from pyk.kast.inner import KApply, KInner, KRewrite, KVariable
65
from pyk.kast.manip import (
76
abstract_term_safely,
8-
bool_to_ml_pred,
97
bottom_up,
10-
flatten_label,
11-
free_vars,
128
is_anon_var,
13-
ml_pred_to_bool,
14-
remove_generated_cells,
159
split_config_and_constraints,
1610
split_config_from,
1711
substitute,
18-
undo_aliases,
1912
)
20-
from pyk.kast.outer import KClaim, KDefinition, KFlatModule, KImport, KRule
13+
from pyk.kast.outer import KDefinition, KFlatModule, KImport
2114
from pyk.kcfg import KCFG
22-
from pyk.ktool import KPrint, KProve
23-
from pyk.prelude.kbool import FALSE
24-
from pyk.prelude.ml import mlAnd
15+
from pyk.ktool import KPrint
2516

2617

2718
def KDefinition__expand_macros(defn: KDefinition, term: KInner) -> KInner: # noqa: N802
@@ -82,28 +73,6 @@ def KCFG__replace_node(cfg: KCFG, node_id: str, new_cterm: CTerm) -> KCFG: # no
8273
return cfg
8374

8475

85-
def KProve_prove_claim( # noqa: N802
86-
kprove: KProve,
87-
claim: KClaim,
88-
claim_id: str,
89-
logger: Logger,
90-
depth: Optional[int] = None,
91-
lemmas: Iterable[KRule] = (),
92-
) -> Tuple[bool, KInner]:
93-
logger.info(f'Proving claim: {claim_id}')
94-
prove_args = []
95-
if depth is not None:
96-
prove_args += ['--depth', str(depth)]
97-
result = kprove.prove_claim(claim, claim_id, args=prove_args, lemmas=lemmas)
98-
failed = False
99-
if type(result) is KApply and result.label.name == '#Top':
100-
logger.info(f'Proved claim: {claim_id}')
101-
else:
102-
logger.error(f'Failed to prove claim: {claim_id}')
103-
failed = True
104-
return failed, result
105-
106-
10776
def KPrint_make_unparsing(_self: KPrint, extra_modules: Iterable[KFlatModule] = ()) -> KPrint: # noqa: N802
10877
modules = _self.definition.modules + tuple(extra_modules)
10978
main_module = KFlatModule('UNPARSING', [], [KImport(_m.name) for _m in modules])
@@ -125,35 +94,3 @@ def abstract_cell_vars(cterm: KInner, keep_vars: Collection[KVariable] = ()) ->
12594
if type(subst[s]) is KVariable and not is_anon_var(subst[s]) and subst[s] not in keep_vars:
12695
subst[s] = abstract_term_safely(KVariable('_'), base_name=s)
12796
return substitute(config, subst)
128-
129-
130-
def sanitize_config(defn: KDefinition, init_term: KInner) -> KInner:
131-
def _var_name(vname: str) -> str:
132-
new_vname = vname
133-
while new_vname.startswith('_') or new_vname.startswith('?'):
134-
new_vname = new_vname[1:]
135-
return new_vname
136-
137-
free_vars_subst = {vname: KVariable(_var_name(vname)) for vname in free_vars(init_term)}
138-
139-
# TODO: This is somewhat hacky. We shouldn't have to touch the config this much.
140-
# Likely, the frontend should just be giving us initial states with these already in place.
141-
def _remove_cell_map_definedness(_kast: KInner) -> KInner:
142-
if type(_kast) is KApply:
143-
if _kast.label.name.endswith('CellMap:in_keys'):
144-
return FALSE
145-
elif _kast.label.name.endswith('CellMapItem'):
146-
return _kast.args[1]
147-
return _kast
148-
149-
new_term = substitute(init_term, free_vars_subst)
150-
new_term = remove_generated_cells(new_term)
151-
new_term = bottom_up(_remove_cell_map_definedness, new_term)
152-
153-
if not (type(new_term) is KApply and new_term.label.name in ['#Top', '#Bottom']):
154-
config, constraint = split_config_and_constraints(new_term)
155-
constraints = [bool_to_ml_pred(ml_pred_to_bool(c, unsafe=True)) for c in flatten_label('#And', constraint)]
156-
new_term = mlAnd([config] + constraints)
157-
new_term = undo_aliases(defn, new_term)
158-
159-
return new_term

0 commit comments

Comments
 (0)