Skip to content

Commit 77fab5d

Browse files
authored
Add an instance for CTermSymbolic to custom_step (#4700)
Needed for runtimeverification/kontrol#899 to expose the `simplify` endpoint in the `custom_step` function.
1 parent b419a9c commit 77fab5d

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

pyk/src/pyk/kcfg/explore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def extend_cterm(
220220
module_name: str | None = None,
221221
) -> list[KCFGExtendResult]:
222222

223-
custom_step_result = self.kcfg_semantics.custom_step(_cterm)
223+
custom_step_result = self.kcfg_semantics.custom_step(_cterm, self.cterm_symbolic)
224224
if custom_step_result is not None:
225225
return [custom_step_result]
226226

pyk/src/pyk/kcfg/semantics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import TYPE_CHECKING
55

66
if TYPE_CHECKING:
7-
from ..cterm import CTerm
7+
from ..cterm import CTerm, CTermSymbolic
88
from .kcfg import KCFGExtendResult
99

1010

@@ -35,7 +35,7 @@ def can_make_custom_step(self, c: CTerm) -> bool: ...
3535
"""Check whether or not the semantics can make a custom step from a given ``CTerm``."""
3636

3737
@abstractmethod
38-
def custom_step(self, c: CTerm) -> KCFGExtendResult | None: ...
38+
def custom_step(self, c: CTerm, cs: CTermSymbolic) -> KCFGExtendResult | None: ...
3939

4040
"""Implement a custom semantic step."""
4141

@@ -61,7 +61,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
6161
def can_make_custom_step(self, c: CTerm) -> bool:
6262
return False
6363

64-
def custom_step(self, c: CTerm) -> KCFGExtendResult | None:
64+
def custom_step(self, c: CTerm, cs: CTermSymbolic) -> KCFGExtendResult | None:
6565
return None
6666

6767
def is_mergeable(self, c1: CTerm, c2: CTerm) -> bool:

pyk/src/tests/integration/ktool/test_imp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from collections.abc import Iterable
2222
from typing import Final
2323

24-
from pyk.cterm import CTerm
24+
from pyk.cterm import CTerm, CTermSymbolic
2525
from pyk.kast.outer import KDefinition
2626
from pyk.kcfg import KCFGExplore
2727
from pyk.kcfg.kcfg import KCFGExtendResult
@@ -71,7 +71,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
7171
def can_make_custom_step(self, c: CTerm) -> bool:
7272
return False
7373

74-
def custom_step(self, c: CTerm) -> KCFGExtendResult | None:
74+
def custom_step(self, c: CTerm, cs: CTermSymbolic) -> KCFGExtendResult | None:
7575
return None
7676

7777

pyk/src/tests/integration/proof/test_custom_step.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def can_make_custom_step(self, c: CTerm) -> bool:
6868
and k_cell[0].label.name == 'c_CUSTOM-STEP-SYNTAX_Step'
6969
)
7070

71-
def custom_step(self, c: CTerm) -> KCFGExtendResult | None:
71+
def custom_step(self, c: CTerm, cs: CTermSymbolic) -> KCFGExtendResult | None:
7272
if self.can_make_custom_step(c):
7373
new_cterm = CTerm.from_kast(set_cell(c.kast, 'K_CELL', KSequence(KApply('d_CUSTOM-STEP-SYNTAX_Step'))))
7474
return Step(new_cterm, 1, (), ['CUSTOM-STEP.c.d'], cut=True)
@@ -141,11 +141,17 @@ def _create_kcfg_explore(kcfg_semantics: KCFGSemantics) -> KCFGExplore:
141141
CUSTOM_STEP_TEST_DATA_APPLY,
142142
ids=[test_id for test_id, *_ in CUSTOM_STEP_TEST_DATA_APPLY],
143143
)
144-
def test_custom_step_exec(self, test_id: str, cterm: CTerm, expected: KCFGExtendResult | None) -> None:
144+
def test_custom_step_exec(
145+
self,
146+
test_id: str,
147+
cterm: CTerm,
148+
cterm_symbolic: CTermSymbolic,
149+
expected: KCFGExtendResult | None,
150+
) -> None:
145151

146152
# When
147153
kcfg_semantics = CustomStepSemanticsWithStep()
148-
actual = kcfg_semantics.custom_step(cterm)
154+
actual = kcfg_semantics.custom_step(cterm, cterm_symbolic)
149155
# Then
150156
assert expected == actual
151157

0 commit comments

Comments
 (0)