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

Commit d7b42ff

Browse files
lucasmtLucas MTrv-auditor
authored
Fix bugs in node refutation functionality (#877)
This PR fixes bugs in the implementation of node refutation, in advance of implementing a `kontrol refute-node` command as part of runtimeverification/evm-semantics#1752. The following changes are introduced: 1. Fix the way node refutations are read from a JSON file: 1. When iterating over the `node_refutations` dictionary, the `.items()` method was missing, meaning that only the keys were being iterated over, rather than both keys and values. 2. In the same line, the node id needed to be converted back to an int before being passed to `_resolve`, since the JSON file stores the key as a string. 2. Prevent refuting a node that has successors (otherwise execution of the refuted branch, which should have been paused, will continue from the successor nodes). 3. Add `refuted` to the list of attributes for a node when displaying the KCFG. --------- Co-authored-by: Lucas MT <[email protected]> Co-authored-by: devops <[email protected]>
1 parent 6ed3f28 commit d7b42ff

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
project = 'pyk'
1010
author = 'Runtime Verification, Inc'
1111
copyright = '2024, Runtime Verification, Inc'
12-
version = '0.1.622'
13-
release = '0.1.622'
12+
version = '0.1.623'
13+
release = '0.1.623'
1414

1515
# -- General configuration ---------------------------------------------------
1616
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.622
1+
0.1.623

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "pyk"
7-
version = "0.1.622"
7+
version = "0.1.623"
88
description = ""
99
authors = [
1010
"Runtime Verification, Inc. <[email protected]>",

src/pyk/proof/reachability.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ def from_dict(cls: type[APRProof], dct: Mapping[str, Any], proof_dir: Path | Non
198198
subproof_ids = dct['subproof_ids'] if 'subproof_ids' in dct else []
199199
node_refutations: dict[int, str] = {}
200200
if 'node_refutation' in dct:
201-
node_refutations = {kcfg._resolve(node_id): proof_id for (node_id, proof_id) in dct['node_refutations']}
201+
node_refutations = {
202+
kcfg._resolve(int(node_id)): proof_id for node_id, proof_id in dct['node_refutations'].items()
203+
}
202204
if 'logs' in dct:
203205
logs = {int(k): tuple(LogEntry.from_dict(l) for l in ls) for k, ls in dct['logs'].items()}
204206
else:
@@ -404,7 +406,9 @@ def read_proof_data(proof_dir: Path, id: str) -> APRProof:
404406
terminal = proof_dict['terminal']
405407
logs = {int(k): tuple(LogEntry.from_dict(l) for l in ls) for k, ls in proof_dict['logs'].items()}
406408
subproof_ids = proof_dict['subproof_ids']
407-
node_refutations = {kcfg._resolve(node_id): proof_id for (node_id, proof_id) in proof_dict['node_refutations']}
409+
node_refutations = {
410+
kcfg._resolve(int(node_id)): proof_id for node_id, proof_id in proof_dict['node_refutations'].items()
411+
}
408412

409413
return APRProof(
410414
id=id,
@@ -474,6 +478,10 @@ def unrefute_node(self, node: KCFG.Node) -> None:
474478
_LOGGER.info(f'Disabled refutation of node {node.id}.')
475479

476480
def construct_node_refutation(self, node: KCFG.Node) -> RefutationProof | None: # TODO put into prover class
481+
if len(self.kcfg.successors(node.id)) > 0:
482+
_LOGGER.error(f'Cannot refute node {node.id} that already has successors')
483+
return None
484+
477485
path = single(self.kcfg.paths_between(source_id=self.init, target_id=node.id))
478486
branches_on_path = list(filter(lambda x: type(x) is KCFG.Split or type(x) is KCFG.NDBranch, reversed(path)))
479487
if len(branches_on_path) == 0:

src/pyk/proof/show.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def node_attrs(self, kcfg: KCFG, node: KCFG.Node) -> list[str]:
3636
attrs.append('target')
3737
if self.proof.is_pending(node.id):
3838
attrs.append('pending')
39+
if self.proof.is_refuted(node.id):
40+
attrs.append('refuted')
3941
if self.proof.is_terminal(node.id):
4042
attrs.append('terminal')
4143
if 'stuck' in attrs:

0 commit comments

Comments
 (0)