Skip to content
This repository was archived by the owner on Apr 25, 2024. It is now read-only.

Better handling of subproof dependencies when executing superproofs #832

Merged
merged 13 commits into from
Jan 25, 2024
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
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
project = 'pyk'
author = 'Runtime Verification, Inc'
copyright = '2024, Runtime Verification, Inc'
version = '0.1.595'
release = '0.1.595'
version = '0.1.596'
release = '0.1.596'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.595
0.1.596
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "pyk"
version = "0.1.595"
version = "0.1.596"
description = ""
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
10 changes: 6 additions & 4 deletions src/pyk/kcfg/kcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,16 +407,18 @@ def to_json(self) -> str:
def from_json(s: str) -> KCFG:
return KCFG.from_dict(json.loads(s))

def to_rules(self, priority: int = 20) -> list[KRuleLike]:
return [e.to_rule('BASIC-BLOCK', priority=priority) for e in self.edges()]

def to_module(
self,
module_name: str | None = None,
imports: Iterable[KImport] = (),
priority: int = 20,
att: KAtt = EMPTY_ATT,
) -> KFlatModule:
module_name = module_name if module_name is not None else 'KCFG'
rules = [e.to_rule('BASIC-BLOCK') for e in self.edges()]
nd_steps = [edge.to_rule('ND-STEP') for ndbranch in self.ndbranches() for edge in ndbranch.edges]
return KFlatModule(module_name, rules + nd_steps, imports=imports, att=att)
module_name = 'KCFG' if module_name is None else module_name
return KFlatModule(module_name, self.to_rules(priority=priority), imports=imports, att=att)

def _resolve_or_none(self, id_like: NodeIdLike) -> int | None:
if type(id_like) is int:
Expand Down
14 changes: 8 additions & 6 deletions src/pyk/proof/reachability.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pathlib import Path
from typing import Any, Final, TypeVar

from ..kast.outer import KClaim, KDefinition, KFlatModuleList
from ..kast.outer import KClaim, KDefinition, KFlatModuleList, KRuleLike
from ..kcfg import KCFGExplore
from ..kcfg.kcfg import NodeIdLike

Expand Down Expand Up @@ -638,7 +638,7 @@ def __init__(
always_check_subsumption: bool = True,
fast_check_subsumption: bool = False,
) -> None:
def _inject_module(module_name: str, import_name: str, sentences: list[KRule]) -> None:
def _inject_module(module_name: str, import_name: str, sentences: list[KRuleLike]) -> None:
_module = KFlatModule(module_name, sentences, [KImport(import_name)])
_kore_module = kflatmodule_to_kore(
self.kcfg_explore.kprint.definition, self.kcfg_explore.kprint.kompiled_kore, _module
Expand All @@ -658,12 +658,14 @@ def _inject_module(module_name: str, import_name: str, sentences: list[KRule]) -
else []
)

apr_subproofs: list[APRProof] = [pf for pf in subproofs if isinstance(pf, APRProof)]

dependencies_as_rules: list[KRule] = [d.as_rule(priority=20) for d in apr_subproofs]
dependencies_as_rules: list[KRuleLike] = []
for apr_subproof in [pf for pf in subproofs if isinstance(pf, APRProof)]:
dependencies_as_rules.extend(apr_subproof.kcfg.to_rules(priority=20))
if apr_subproof.admitted and len(apr_subproof.kcfg.predecessors(apr_subproof.target)) == 0:
dependencies_as_rules.append(apr_subproof.as_rule(priority=20))
circularity_rule = proof.as_rule(priority=20)

module_name = re.sub(r'[%().:,]+', '-', self.proof.id.upper())
module_name = re.sub(r'[_%().:,]+', '-', self.proof.id.upper())
self.dependencies_module_name = module_name + '-DEPENDS-MODULE'
self.circularities_module_name = module_name + '-CIRCULARITIES-MODULE'
_inject_module(self.dependencies_module_name, self.main_module_name, dependencies_as_rules)
Expand Down
2 changes: 1 addition & 1 deletion src/tests/integration/proof/test_imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
None,
[],
False,
ProofStatus.PENDING, # because we do NOT admit the dependency
ProofStatus.FAILED, # because we do NOT admit the dependency
1,
),
(
Expand Down