Skip to content

Commit d6382e1

Browse files
committed
Merge remote-tracking branch 'origin/develop' into _update-deps/runtimeverification/haskell-backend
2 parents 282541e + 796208a commit d6382e1

File tree

12 files changed

+128
-35
lines changed

12 files changed

+128
-35
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.109";
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/k2lean4/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .k2lean4 import K2Lean4

pyk/src/pyk/k2lean4/k2lean4.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
from __future__ import annotations
22

3+
import re
34
from dataclasses import dataclass
45
from typing import TYPE_CHECKING
56

7+
from ..konvert import unmunge
68
from ..kore.internal import CollectionKind
79
from ..kore.syntax import SortApp
810
from ..utils import check_type
911
from .model import Abbrev, Ctor, ExplBinder, Inductive, Module, Signature, Term
1012

1113
if TYPE_CHECKING:
14+
from typing import Final
15+
1216
from ..kore.internal import KoreDefn
1317
from .model import Command
1418

1519

20+
_VALID_LEAN_IDENT: Final = re.compile(
21+
"_[a-zA-Z0-9_?!']+|[a-zA-Z][a-zA-Z0-9_?!']*"
22+
) # Simplified to characters permitted in KORE in the first place
23+
24+
1625
@dataclass(frozen=True)
1726
class K2Lean4:
1827
defn: KoreDefn
@@ -46,10 +55,19 @@ def _symbol_ctor(self, sort: str, symbol: str) -> Ctor:
4655
param_sorts = (
4756
check_type(sort, SortApp).name for sort in self.defn.symbols[symbol].param_sorts
4857
) # TODO eliminate check_type
58+
symbol = self._symbol_ident(symbol)
4959
binders = tuple(ExplBinder((f'x{i}',), Term(sort)) for i, sort in enumerate(param_sorts))
50-
symbol = symbol.replace('-', '_')
5160
return Ctor(symbol, Signature(binders, Term(sort)))
5261

62+
@staticmethod
63+
def _symbol_ident(symbol: str) -> str:
64+
if symbol.startswith('Lbl'):
65+
symbol = symbol[3:]
66+
symbol = unmunge(symbol)
67+
if not _VALID_LEAN_IDENT.fullmatch(symbol):
68+
symbol = f'«{symbol}»'
69+
return symbol
70+
5371
def _collections(self) -> list[Command]:
5472
return [self._collection(sort) for sort in sorted(self.defn.collections)]
5573

pyk/src/pyk/k2lean4/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(
7373
def __str__(self) -> str:
7474
modifiers = f'{self.modifiers} ' if self.modifiers else ''
7575
signature = f' {self.signature}' if self.signature else ''
76-
return f'{modifiers} abbrev {self.ident}{signature} := {self.val}'
76+
return f'{modifiers}abbrev {self.ident}{signature} := {self.val}'
7777

7878

7979
@final

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):

0 commit comments

Comments
 (0)