Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyk/src/pyk/kcfg/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def extend_cterm(
module_name: str | None = None,
) -> list[KCFGExtendResult]:

custom_step_result = self.kcfg_semantics.custom_step(_cterm, self.cterm_symbolic)
custom_step_result = self.kcfg_semantics.custom_step(_cterm, self.cterm_symbolic, node_id)
if custom_step_result is not None:
return [custom_step_result]

Expand Down
17 changes: 13 additions & 4 deletions pyk/src/pyk/kcfg/semantics.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ def can_make_custom_step(self, c: CTerm) -> bool: ...
"""Check whether or not the semantics can make a custom step from a given ``CTerm``."""

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

"""Implement a custom semantic step."""
def custom_step(self, c: CTerm, cs: CTermSymbolic, node_id: int) -> KCFGExtendResult | None: ...
Comment thread
tothtamas28 marked this conversation as resolved.

"""Implement a custom semantic step.

Args:
c: Current constrained term representing the state.
cs: ``CTermSymbolic`` for computing the custom step result.
node_id: Current node id.

Returns:
The ``KCFGExtendResult`` produced by this custom step if this custom step can produce one, ``None`` otherwise.
"""

@abstractmethod
def is_mergeable(self, c1: CTerm, c2: CTerm) -> bool: ...
Expand All @@ -61,7 +70,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
def can_make_custom_step(self, c: CTerm) -> bool:
return False

def custom_step(self, c: CTerm, cs: CTermSymbolic) -> KCFGExtendResult | None:
def custom_step(self, c: CTerm, cs: CTermSymbolic, node_id: int) -> KCFGExtendResult | None:
return None

def is_mergeable(self, c1: CTerm, c2: CTerm) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions pyk/src/tests/integration/proof/test_custom_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def can_make_custom_step(self, c: CTerm) -> bool:
and k_cell[0].label.name == 'c_CUSTOM-STEP-SYNTAX_Step'
)

def custom_step(self, c: CTerm, cs: CTermSymbolic) -> KCFGExtendResult | None:
def custom_step(self, c: CTerm, cs: CTermSymbolic, node_id: int) -> KCFGExtendResult | None:
if self.can_make_custom_step(c):
new_cterm = CTerm.from_kast(set_cell(c.kast, 'K_CELL', KSequence(KApply('d_CUSTOM-STEP-SYNTAX_Step'))))
return Step(new_cterm, 1, (), ['CUSTOM-STEP.c.d'], cut=True)
Expand Down Expand Up @@ -153,7 +153,7 @@ def test_custom_step_exec(

# When
kcfg_semantics = CustomStepSemanticsWithStep()
actual = kcfg_semantics.custom_step(cterm, cterm_symbolic)
actual = kcfg_semantics.custom_step(cterm, cterm_symbolic, node_id=0)
# Then
assert expected == actual

Expand Down
2 changes: 1 addition & 1 deletion pyk/src/tests/integration/proof/test_prove_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
def can_make_custom_step(self, c: CTerm) -> bool:
return False

def custom_step(self, c: CTerm, cs: CTermSymbolic) -> KCFGExtendResult | None:
def custom_step(self, c: CTerm, cs: CTermSymbolic, node_id: int) -> KCFGExtendResult | None:
return None


Expand Down
Loading