Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
devops committed Sep 22, 2024
2 parents a44767b + d6ff56c commit cf0c431
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
37 changes: 37 additions & 0 deletions pyk/src/pyk/kllvm/hints/prooftrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
llvm_side_condition_end_event,
llvm_side_condition_event,
llvm_step_event,
llvm_pattern_matching_failure_event,
annotated_llvm_event,
llvm_rewrite_trace_iterator,
EventType,
Expand Down Expand Up @@ -168,6 +169,40 @@ def check_result(self) -> bool:
return self._side_condition_end_event.check_result


@final
class LLVMPatternMatchingFailureEvent(LLVMStepEvent):
"""Represents an LLVM pattern matching failure event.
This event is used to indicate that the pattern matching failed during the rewriting process.
Attributes:
_pattern_matching_failure_event (llvm_pattern_matching_failure_event): The underlying pattern matching failure event.
"""

_pattern_matching_failure_event: llvm_pattern_matching_failure_event

def __init__(self, pattern_matching_failure_event: llvm_pattern_matching_failure_event) -> None:
"""Initialize a new instance of the LLVMPatternMatchingFailureEvent class.
Args:
pattern_matching_failure_event (llvm_pattern_matching_failure_event): The LLVM pattern matching failure event object.
"""
self._pattern_matching_failure_event = pattern_matching_failure_event

def __repr__(self) -> str:
"""Return a string representation of the object.
Returns:
A string representation of the LLVMPatternMatchingFailureEvent object using the AST printing method.
"""
return self._pattern_matching_failure_event.__repr__()

@property
def function_name(self) -> str:
"""Return the name of the function that failed to match the pattern."""
return self._pattern_matching_failure_event.function_name


@final
class LLVMFunctionEvent(LLVMStepEvent):
"""Represent an LLVM function event in a proof trace.
Expand Down Expand Up @@ -297,6 +332,8 @@ def step_event(self) -> LLVMStepEvent:
return LLVMFunctionEvent(self._argument.step_event)
elif isinstance(self._argument.step_event, llvm_hook_event):
return LLVMHookEvent(self._argument.step_event)
elif isinstance(self._argument.step_event, llvm_pattern_matching_failure_event):
return LLVMPatternMatchingFailureEvent(self._argument.step_event)
else:
raise AssertionError()

Expand Down
7 changes: 6 additions & 1 deletion pyk/src/tests/integration/kllvm/test_prooftrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,9 +808,14 @@ def test_parse_proof_hint_peano(self, hints: bytes, header: prooftrace.KoreHeade
# 12 initialization events
assert len(pt.pre_trace) == 12

# 404 post-initial-configuration events
# 776 post-initial-configuration events
assert len(pt.trace) == 776

# Assert that we have a pattern matching failure as the 135th event
assert pt.trace[135].is_step_event() and isinstance(
pt.trace[135].step_event, prooftrace.LLVMPatternMatchingFailureEvent
)


class TestIMP5(ProofTraceTest):
KOMPILE_DEFINITION = """
Expand Down

0 comments on commit cf0c431

Please sign in to comment.