Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
rv-jenkins committed Sep 25, 2024
2 parents b499f06 + fa987c2 commit ca1d5a2
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 29 deletions.
2 changes: 1 addition & 1 deletion deps/k_release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.1.149
7.1.150
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "A flake for the KEVM Semantics";

inputs = {
k-framework.url = "github:runtimeverification/k/v7.1.149";
k-framework.url = "github:runtimeverification/k/v7.1.150";
nixpkgs.follows = "k-framework/nixpkgs";
flake-utils.follows = "k-framework/flake-utils";
rv-utils.follows = "k-framework/rv-utils";
Expand Down
8 changes: 4 additions & 4 deletions kevm-pyk/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion kevm-pyk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ authors = [
[tool.poetry.dependencies]
python = "^3.10"
pathos = "*"
kframework = "7.1.149"
kframework = "7.1.150"
tomlkit = "^0.11.6"

[tool.poetry.group.dev.dependencies]
Expand Down
27 changes: 9 additions & 18 deletions kevm-pyk/src/kevm_pyk/kevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
from pyk.kast.manip import abstract_term_safely, flatten_label, set_cell
from pyk.kast.pretty import paren
from pyk.kcfg.kcfg import Step
from pyk.kcfg.semantics import KCFGSemantics
from pyk.kcfg.semantics import DefaultSemantics
from pyk.kcfg.show import NodePrinter
from pyk.ktool.kprove import KProve
from pyk.ktool.krun import KRun
from pyk.prelude.bytes import BYTES, pretty_bytes
from pyk.prelude.kbool import notBool
from pyk.prelude.kint import INT, eqInt, gtInt, intToken, ltInt
from pyk.prelude.kint import INT, gtInt, intToken, ltInt
from pyk.prelude.ml import mlEqualsFalse, mlEqualsTrue
from pyk.prelude.string import stringToken
from pyk.prelude.utils import token
Expand All @@ -50,7 +49,7 @@
# KEVM class


class KEVMSemantics(KCFGSemantics):
class KEVMSemantics(DefaultSemantics):
auto_abstract_gas: bool
allow_symbolic_program: bool
_cached_subst: Subst | None
Expand Down Expand Up @@ -98,6 +97,12 @@ def is_terminal(self, cterm: CTerm) -> bool:

return False

def is_loop(self, cterm: CTerm) -> bool:
jumpi_pattern = KEVM.jumpi_applied(KVariable('###PCOUNT'), KVariable('###COND'))
pc_next_pattern = KEVM.pc_applied(KEVM.jumpi())
branch_pattern = KSequence([jumpi_pattern, pc_next_pattern, KEVM.sharp_execute(), KVariable('###CONTINUATION')])
return branch_pattern.match(cterm.cell('K_CELL')) is not None

def same_loop(self, cterm1: CTerm, cterm2: CTerm) -> bool:
# In the same program, at the same calldepth, at the same program counter
for cell in ['PC_CELL', 'CALLDEPTH_CELL', 'PROGRAM_CELL']:
Expand All @@ -116,20 +121,6 @@ def same_loop(self, cterm1: CTerm, cterm2: CTerm) -> bool:
return True
return False

def extract_branches(self, cterm: CTerm) -> list[KInner]:
k_cell = cterm.cell('K_CELL')
jumpi_pattern = KEVM.jumpi_applied(KVariable('###PCOUNT'), KVariable('###COND'))
pc_next_pattern = KEVM.pc_applied(KEVM.jumpi())
branch_pattern = KSequence([jumpi_pattern, pc_next_pattern, KEVM.sharp_execute(), KVariable('###CONTINUATION')])
if subst := branch_pattern.match(k_cell):
cond = subst['###COND']
if cond_subst := KEVM.bool_2_word(KVariable('###BOOL_2_WORD')).match(cond):
cond = cond_subst['###BOOL_2_WORD']
else:
cond = eqInt(cond, intToken(0))
return [mlEqualsTrue(cond), mlEqualsTrue(notBool(cond))]
return []

def abstract_node(self, cterm: CTerm) -> CTerm:
if not self.auto_abstract_gas:
return cterm
Expand Down

0 comments on commit ca1d5a2

Please sign in to comment.