Skip to content

Commit 4a6c910

Browse files
committed
kevm-pyk/utils: remove sanitize_config
1 parent bccb0e0 commit 4a6c910

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

kevm-pyk/src/kevm_pyk/utils.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,15 @@
44
from pyk.kast.inner import KApply, KInner, KRewrite, KVariable
55
from pyk.kast.manip import (
66
abstract_term_safely,
7-
bool_to_ml_pred,
87
bottom_up,
9-
flatten_label,
10-
free_vars,
118
is_anon_var,
12-
ml_pred_to_bool,
13-
remove_generated_cells,
149
split_config_and_constraints,
1510
split_config_from,
1611
substitute,
17-
undo_aliases,
1812
)
1913
from pyk.kast.outer import KDefinition, KFlatModule, KImport
2014
from pyk.kcfg import KCFG
2115
from pyk.ktool import KPrint
22-
from pyk.prelude.kbool import FALSE
23-
from pyk.prelude.ml import mlAnd
2416

2517

2618
def KDefinition__expand_macros(defn: KDefinition, term: KInner) -> KInner: # noqa: N802
@@ -102,35 +94,3 @@ def abstract_cell_vars(cterm: KInner, keep_vars: Collection[KVariable] = ()) ->
10294
if type(subst[s]) is KVariable and not is_anon_var(subst[s]) and subst[s] not in keep_vars:
10395
subst[s] = abstract_term_safely(KVariable('_'), base_name=s)
10496
return substitute(config, subst)
105-
106-
107-
def sanitize_config(defn: KDefinition, init_term: KInner) -> KInner:
108-
def _var_name(vname: str) -> str:
109-
new_vname = vname
110-
while new_vname.startswith('_') or new_vname.startswith('?'):
111-
new_vname = new_vname[1:]
112-
return new_vname
113-
114-
free_vars_subst = {vname: KVariable(_var_name(vname)) for vname in free_vars(init_term)}
115-
116-
# TODO: This is somewhat hacky. We shouldn't have to touch the config this much.
117-
# Likely, the frontend should just be giving us initial states with these already in place.
118-
def _remove_cell_map_definedness(_kast: KInner) -> KInner:
119-
if type(_kast) is KApply:
120-
if _kast.label.name.endswith('CellMap:in_keys'):
121-
return FALSE
122-
elif _kast.label.name.endswith('CellMapItem'):
123-
return _kast.args[1]
124-
return _kast
125-
126-
new_term = substitute(init_term, free_vars_subst)
127-
new_term = remove_generated_cells(new_term)
128-
new_term = bottom_up(_remove_cell_map_definedness, new_term)
129-
130-
if not (type(new_term) is KApply and new_term.label.name in ['#Top', '#Bottom']):
131-
config, constraint = split_config_and_constraints(new_term)
132-
constraints = [bool_to_ml_pred(ml_pred_to_bool(c, unsafe=True)) for c in flatten_label('#And', constraint)]
133-
new_term = mlAnd([config] + constraints)
134-
new_term = undo_aliases(defn, new_term)
135-
136-
return new_term

0 commit comments

Comments
 (0)