Skip to content

Commit 8bb66d4

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents bb69789 + 796208a commit 8bb66d4

File tree

9 files changed

+107
-33
lines changed

9 files changed

+107
-33
lines changed

deps/llvm-backend_release

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.103
1+
0.1.122

flake.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
description = "K Framework";
33
inputs = {
4-
llvm-backend.url = "github:runtimeverification/llvm-backend/v0.1.103";
4+
llvm-backend.url = "github:runtimeverification/llvm-backend/v0.1.122";
55
haskell-backend = {
66
url = "github:runtimeverification/haskell-backend/v0.1.108";
77
inputs.rv-utils.follows = "llvm-backend/rv-utils";
Binary file not shown.
Binary file not shown.
Submodule llvm-backend updated 158 files

pyk/src/pyk/kllvm/hints/prooftrace.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
kore_header,
1010
llvm_rewrite_event,
1111
llvm_function_event,
12+
llvm_function_exit_event,
1213
llvm_hook_event,
1314
llvm_rewrite_trace,
1415
llvm_rule_event,
@@ -245,6 +246,43 @@ def args(self) -> list[LLVMArgument]:
245246
return [LLVMArgument(arg) for arg in self._function_event.args]
246247

247248

249+
@final
250+
class LLVMFunctionExitEvent(LLVMStepEvent):
251+
"""Represent an LLVM function exit event in a proof trace.
252+
253+
Attributes:
254+
_function_exit_event (llvm_function_exit_event): The underlying LLVM function exit event object.
255+
"""
256+
257+
_function_exit_event: llvm_function_exit_event
258+
259+
def __init__(self, function_exit_event: llvm_function_exit_event) -> None:
260+
"""Initialize a new instance of the LLVMFunctionExitEvent class.
261+
262+
Args:
263+
function_exit_event (llvm_function_exit_event): The LLVM function exit event object.
264+
"""
265+
self._function_exit_event = function_exit_event
266+
267+
def __repr__(self) -> str:
268+
"""Return a string representation of the object.
269+
270+
Returns:
271+
A string representation of the LLVMFunctionExitEvent object using the AST printing method.
272+
"""
273+
return self._function_exit_event.__repr__()
274+
275+
@property
276+
def rule_ordinal(self) -> int:
277+
"""Return the axiom ordinal number associated with the function exit event."""
278+
return self._function_exit_event.rule_ordinal
279+
280+
@property
281+
def is_tail(self) -> bool:
282+
"""Return True if the function exit event is a tail call."""
283+
return self._function_exit_event.is_tail
284+
285+
248286
@final
249287
class LLVMHookEvent(LLVMStepEvent):
250288
"""Represents a hook event in LLVM execution.
@@ -330,6 +368,8 @@ def step_event(self) -> LLVMStepEvent:
330368
return LLVMSideConditionEventExit(self._argument.step_event)
331369
elif isinstance(self._argument.step_event, llvm_function_event):
332370
return LLVMFunctionEvent(self._argument.step_event)
371+
elif isinstance(self._argument.step_event, llvm_function_exit_event):
372+
return LLVMFunctionExitEvent(self._argument.step_event)
333373
elif isinstance(self._argument.step_event, llvm_hook_event):
334374
return LLVMHookEvent(self._argument.step_event)
335375
elif isinstance(self._argument.step_event, llvm_pattern_matching_failure_event):

pyk/src/tests/integration/kllvm/test_prooftrace.py

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test_streaming_parser_iter(self, header: prooftrace.KoreHeader, hints_file:
103103
list_of_events = list(it)
104104

105105
# Test length of the list
106-
assert len(list_of_events) == 13
106+
assert len(list_of_events) == 17
107107

108108
# Test the type of the events
109109
for event in list_of_events:
@@ -190,7 +190,7 @@ def test_parse_proof_hint_single_rewrite(
190190
assert pt is not None
191191

192192
# 10 initialization events
193-
assert len(pt.pre_trace) == 10
193+
assert len(pt.pre_trace) == 14
194194

195195
# 2 post-initial-configuration events
196196
assert len(pt.trace) == 2
@@ -260,10 +260,10 @@ def test_parse_proof_hint_reverse_no_ints(
260260
assert pt is not None
261261

262262
# 10 initialization events
263-
assert len(pt.pre_trace) == 10
263+
assert len(pt.pre_trace) == 14
264264

265265
# 9 post-initial-configuration events
266-
assert len(pt.trace) == 9
266+
assert len(pt.trace) == 12
267267

268268
# Contents of the k cell in the initial configuration
269269
kore_pattern = llvm_to_pattern(pt.initial_config.kore_pattern)
@@ -321,25 +321,43 @@ def test_parse_proof_hint_reverse_no_ints(
321321
assert axiom == axiom_expected
322322
assert len(rule_event.substitution) == 1
323323

324+
# Function exit event (no tail)
325+
function_exit_event = pt.trace[6].step_event
326+
assert isinstance(function_exit_event, prooftrace.LLVMFunctionExitEvent)
327+
assert function_exit_event.rule_ordinal == 158
328+
assert function_exit_event.is_tail == False
329+
324330
# Function event
325-
rule_event = pt.trace[6].step_event
331+
rule_event = pt.trace[7].step_event
326332
assert isinstance(rule_event, prooftrace.LLVMFunctionEvent)
327333
assert rule_event.name == "Lblreverse'LParUndsRParUnds'TREE-REVERSE-SYNTAX'Unds'Tree'Unds'Tree{}"
328334
assert rule_event.relative_position == '1'
329335
# Fun events should not have Kore args unless called with a special flag
330336
assert len(rule_event.args) == 0
331337

332338
# Simplification rule
333-
rule_event = pt.trace[7].step_event
339+
rule_event = pt.trace[8].step_event
334340
assert isinstance(rule_event, prooftrace.LLVMRuleEvent)
335341
axiom = repr(definition.get_axiom_by_ordinal(rule_event.rule_ordinal))
336342
axiom_expected = get_pattern_from_ordinal(definition_text, rule_event.rule_ordinal)
337343
assert axiom == axiom_expected
338344
assert len(rule_event.substitution) == 1
339345

346+
# Function exit event (no tail)
347+
function_exit_event = pt.trace[9].step_event
348+
assert isinstance(function_exit_event, prooftrace.LLVMFunctionExitEvent)
349+
assert function_exit_event.rule_ordinal == 157
350+
assert function_exit_event.is_tail == False
351+
352+
# Function exit event (no tail)
353+
function_exit_event = pt.trace[10].step_event
354+
assert isinstance(function_exit_event, prooftrace.LLVMFunctionExitEvent)
355+
assert function_exit_event.rule_ordinal == 160
356+
assert function_exit_event.is_tail == False
357+
340358
# Then pattern
341-
assert pt.trace[8].is_kore_pattern()
342-
kore_pattern = llvm_to_pattern(pt.trace[8].kore_pattern)
359+
assert pt.trace[11].is_kore_pattern()
360+
kore_pattern = llvm_to_pattern(pt.trace[11].kore_pattern)
343361
k_cell = kore_pattern.patterns[0].dict['args'][0]
344362
assert k_cell['name'] == 'kseq'
345363
assert (
@@ -385,10 +403,10 @@ def test_parse_proof_hint_non_rec_function(
385403
assert pt is not None
386404

387405
# 10 initialization events
388-
assert len(pt.pre_trace) == 10
406+
assert len(pt.pre_trace) == 14
389407

390408
# 6 post-initial-configuration events
391-
assert len(pt.trace) == 6
409+
assert len(pt.trace) == 8
392410

393411
# Contents of the k cell in the initial configuration
394412
kore_pattern = llvm_to_pattern(pt.initial_config.kore_pattern)
@@ -415,24 +433,36 @@ def test_parse_proof_hint_non_rec_function(
415433
inner_rule_event = pt.trace[2].step_event
416434
assert isinstance(inner_rule_event, prooftrace.LLVMRuleEvent)
417435

436+
# Function exit event (no tail)
437+
function_exit_event = pt.trace[3].step_event
438+
assert isinstance(function_exit_event, prooftrace.LLVMFunctionExitEvent)
439+
assert function_exit_event.rule_ordinal == 103
440+
assert function_exit_event.is_tail == False
441+
418442
# Functional event
419-
fun_event = pt.trace[3].step_event
443+
fun_event = pt.trace[4].step_event
420444
assert isinstance(fun_event, prooftrace.LLVMFunctionEvent)
421445
assert fun_event.name == "Lblid'LParUndsRParUnds'NON-REC-FUNCTION-SYNTAX'Unds'Foo'Unds'Foo{}"
422446
assert fun_event.relative_position == '0:0:0'
423447
assert len(fun_event.args) == 0
424448

425449
# Then rule
426-
rule_event = pt.trace[4].step_event
450+
rule_event = pt.trace[5].step_event
427451
assert isinstance(rule_event, prooftrace.LLVMRuleEvent)
428452
axiom = repr(definition.get_axiom_by_ordinal(rule_event.rule_ordinal))
429453
axiom_expected = get_pattern_from_ordinal(definition_text, rule_event.rule_ordinal)
430454
assert axiom == axiom_expected
431455
assert len(rule_event.substitution) == 1
432456

457+
# Function exit event (no tail)
458+
function_exit_event = pt.trace[6].step_event
459+
assert isinstance(function_exit_event, prooftrace.LLVMFunctionExitEvent)
460+
assert function_exit_event.rule_ordinal == 103
461+
assert function_exit_event.is_tail == False
462+
433463
# Then pattern
434-
assert pt.trace[5].is_kore_pattern()
435-
kore_pattern = llvm_to_pattern(pt.trace[5].kore_pattern)
464+
assert pt.trace[7].is_kore_pattern()
465+
kore_pattern = llvm_to_pattern(pt.trace[7].kore_pattern)
436466
k_cell = kore_pattern.patterns[0].dict['args'][0]
437467
assert k_cell['name'] == 'kseq'
438468
assert (
@@ -468,7 +498,7 @@ def test_parse_proof_hint_dv(self, hints: bytes, header: prooftrace.KoreHeader,
468498
assert pt is not None
469499

470500
# 10 initialization events
471-
assert len(pt.pre_trace) == 10
501+
assert len(pt.pre_trace) == 14
472502

473503
# 3 post-initial-configuration events
474504
assert len(pt.trace) == 3
@@ -549,7 +579,7 @@ def test_parse_concurrent_counters(self, hints: bytes, header: prooftrace.KoreHe
549579
assert pt is not None
550580

551581
# 10 initialization events
552-
assert len(pt.pre_trace) == 10
582+
assert len(pt.pre_trace) == 14
553583

554584
# 37 post-initial-configuration events
555585
assert len(pt.trace) == 37
@@ -709,7 +739,7 @@ def test_parse_proof_hint_0_decrement(self, hints: bytes, header: prooftrace.Kor
709739
assert pt is not None
710740

711741
# 10 initialization events
712-
assert len(pt.pre_trace) == 10
742+
assert len(pt.pre_trace) == 14
713743

714744
# 1 post-initial-configuration event
715745
assert len(pt.trace) == 1
@@ -738,7 +768,7 @@ def test_parse_proof_hint_1_decrement(self, hints: bytes, header: prooftrace.Kor
738768
assert pt is not None
739769

740770
# 10 initialization events
741-
assert len(pt.pre_trace) == 10
771+
assert len(pt.pre_trace) == 14
742772

743773
# 2 post-initial-configuration events
744774
assert len(pt.trace) == 2
@@ -767,7 +797,7 @@ def test_parse_proof_hint_2_decrement(self, hints: bytes, header: prooftrace.Kor
767797
assert pt is not None
768798

769799
# 10 initialization events
770-
assert len(pt.pre_trace) == 10
800+
assert len(pt.pre_trace) == 14
771801

772802
# 3 post-initial-configuration events
773803
assert len(pt.trace) == 3
@@ -806,14 +836,14 @@ def test_parse_proof_hint_peano(self, hints: bytes, header: prooftrace.KoreHeade
806836
assert pt is not None
807837

808838
# 10 initialization events
809-
assert len(pt.pre_trace) == 10
839+
assert len(pt.pre_trace) == 14
810840

811841
# 776 post-initial-configuration events
812-
assert len(pt.trace) == 776
842+
assert len(pt.trace) == 916
813843

814844
# Assert that we have a pattern matching failure as the 135th event
815-
assert pt.trace[135].is_step_event() and isinstance(
816-
pt.trace[135].step_event, prooftrace.LLVMPatternMatchingFailureEvent
845+
assert pt.trace[160].is_step_event() and isinstance(
846+
pt.trace[160].step_event, prooftrace.LLVMPatternMatchingFailureEvent
817847
)
818848

819849

@@ -915,7 +945,7 @@ def test_parse_proof_hint_imp5(self, hints: bytes, header: prooftrace.KoreHeader
915945
assert pt is not None
916946

917947
# 14 initialization events
918-
assert len(pt.pre_trace) == 14
948+
assert len(pt.pre_trace) == 20
919949

920950
# 2 post-initial-configuration events
921951
assert len(pt.trace) == 2
@@ -954,7 +984,7 @@ def test_parse_proof_hint_builtin_hook_events(
954984
assert pt is not None
955985

956986
# 10 initialization events
957-
assert len(pt.pre_trace) == 10
987+
assert len(pt.pre_trace) == 14
958988

959989
# 4 post-initial-configuration events
960990
assert len(pt.trace) == 4

pyk/src/tests/integration/test_krun_proof_hints.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ class Test0Decrement(KRunTest, ProofTraceTest):
4848
function: Lblproject'Coln'KItem{} (0:0)
4949
rule: 139 1
5050
VarK = kore[Lbl0'Unds'DECREMENT-SYNTAX'Unds'Nat{}()]
51+
function exit: 139 notail
52+
function exit: 100 notail
5153
function: LblinitGeneratedCounterCell{} (1)
5254
rule: 98 0
55+
function exit: 98 notail
56+
function exit: 99 notail
5357
config: kore[Lbl'-LT-'generatedTop'-GT-'{}(Lbl'-LT-'k'-GT-'{}(kseq{}(Lbl0'Unds'DECREMENT-SYNTAX'Unds'Nat{}(),dotk{}())),Lbl'-LT-'generatedCounter'-GT-'{}(\\dv{SortInt{}}("0")))]
5458
config: kore[Lbl'-LT-'generatedTop'-GT-'{}(Lbl'-LT-'k'-GT-'{}(kseq{}(Lbl0'Unds'DECREMENT-SYNTAX'Unds'Nat{}(),dotk{}())),Lbl'-LT-'generatedCounter'-GT-'{}(\\dv{SortInt{}}("0")))]
5559
"""
@@ -68,7 +72,7 @@ def test_parse_proof_hint_0_decrement(self, krun: KRun, header: prooftrace.KoreH
6872
assert pt is not None
6973

7074
# 10 initialization events
71-
assert len(pt.pre_trace) == 10
75+
assert len(pt.pre_trace) == 14
7276

7377
# 1 post-initial-configuration event
7478
assert len(pt.trace) == 1

0 commit comments

Comments
 (0)