Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reusing backend information to construct KCFGs more efficiently #4590

Merged
merged 31 commits into from
Aug 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5630763
different approach
PetarMax Aug 15, 2024
6ff9f37
no changes to .toml
PetarMax Aug 15, 2024
cb9e98c
reverting changes
PetarMax Aug 15, 2024
00d519e
adding predecessor to APRProofStep
PetarMax Aug 15, 2024
f2158a8
correction
PetarMax Aug 15, 2024
733d089
overhaul
PetarMax Aug 15, 2024
33fcde3
Merge branch 'develop' into petar/streamlining-branching
PetarMax Aug 15, 2024
869e7b2
formatting correction
PetarMax Aug 15, 2024
b20e4c6
better logging message
PetarMax Aug 15, 2024
a60b914
further messages
PetarMax Aug 15, 2024
45fd80b
minor further messages
PetarMax Aug 16, 2024
0018b2a
moving logic to APRProof
PetarMax Aug 16, 2024
b0bc50e
corrections
PetarMax Aug 16, 2024
8d4ab1f
documentation and circularity precision
PetarMax Aug 16, 2024
69b3c98
Merge branch 'develop' into petar/streamlining-branching
PetarMax Aug 16, 2024
e865465
second attempt at understanding circularities
PetarMax Aug 16, 2024
12b0fc0
additional precision re circular rules
PetarMax Aug 16, 2024
5ce87e8
correction
PetarMax Aug 16, 2024
68ba0b1
more corrections
PetarMax Aug 16, 2024
3321f48
comments
PetarMax Aug 16, 2024
9c86d7e
formatting
PetarMax Aug 16, 2024
207e325
even more formatting
PetarMax Aug 16, 2024
c19f63d
removing always_check_subsumption, more comments
PetarMax Aug 16, 2024
4d695ad
correction
PetarMax Aug 16, 2024
d3d3cae
Final correction
PetarMax Aug 17, 2024
4d54908
Update pyk/src/pyk/kcfg/explore.py
PetarMax Aug 17, 2024
a661700
Update pyk/src/pyk/kcfg/explore.py
PetarMax Aug 17, 2024
852fba4
minor corrections
PetarMax Aug 19, 2024
76e9f1e
refactoring proof results
PetarMax Aug 19, 2024
c3e6e8d
Update pyk/src/pyk/proof/reachability.py
PetarMax Aug 19, 2024
e60d2be
Update semantics.py
PetarMax Aug 19, 2024
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
15 changes: 10 additions & 5 deletions pyk/src/pyk/proof/reachability.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class APRProofResult:
class APRProofExtendResult(APRProofResult):
tothtamas28 marked this conversation as resolved.
Show resolved Hide resolved
extend_results: list[KCFGExtendResult]
to_cache: bool = field(default=False)
use_cache: NodeIdLike | None = field(default=None)


@dataclass
Expand Down Expand Up @@ -202,9 +203,10 @@ def commit(self, result: APRProofResult) -> None:
self.prior_loops_cache[result.node_id] = result.prior_loops_cache_update
if isinstance(result, APRProofExtendResult):
# Result has been cached, use the cache
if len(result.extend_results) == 0:
assert result.node_id in self._next_steps
extend_result = self._next_steps.pop(result.node_id)
if result.use_cache is not None:
assert len(result.extend_results) == 0
assert result.use_cache in self._next_steps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, all these assertions indicate that APRProofExtendResult could be broken up into multiple subclasses with stronger typing guarantees.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100%. I will think about this a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've redesigned them now.

extend_result = self._next_steps.pop(result.use_cache)
# Result contains two steps, first to be applied, second to be cached
elif result.to_cache:
assert result.node_id not in self._next_steps
Expand Down Expand Up @@ -778,6 +780,9 @@ def _check_subsume(self, node: KCFG.Node, target_node: KCFG.Node, proof_id: str)
return csubst

def step_proof(self, step: APRProofStep) -> list[APRProofResult]:
to_cache: bool = False
use_cache: NodeIdLike | None = None

prior_loops: tuple[int, ...] = ()
if step.bmc_depth is not None:
for node in step.shortest_path_to_node:
Expand Down Expand Up @@ -826,6 +831,7 @@ def step_proof(self, step: APRProofStep) -> list[APRProofResult]:
if step.cached:
_LOGGER.info(f'Using cached step for edge {step.predecessor_node_id} --> {step.node.id}')
extend_results = []
use_cache = step.predecessor_node_id
else:
extend_results = self.kcfg_explore.extend_cterm(
step.node.cterm,
Expand All @@ -836,8 +842,6 @@ def step_proof(self, step: APRProofStep) -> list[APRProofResult]:
node_id=step.node.id,
)

to_cache: bool = False

assert len(extend_results) <= 2
if len(extend_results) == 2:
_LOGGER.info(f'Caching next step for edge starting from {step.node.id}')
Expand All @@ -849,6 +853,7 @@ def step_proof(self, step: APRProofStep) -> list[APRProofResult]:
extend_results=extend_results,
prior_loops_cache_update=prior_loops,
to_cache=to_cache,
use_cache=use_cache,
)
]

Expand Down
Loading