Skip to content

Commit 8921b79

Browse files
ehildenbrv-auditor
authored andcommitted
Fix claim selection process for unlabeled claims (runtimeverification/pyk#866)
Here: runtimeverification/pyk#842, a mistake was made where claims without labels were filtered out of the claims to be processed and returned by `KProve.get_claims`. This PR addresses that and adds tests. In particular: - Two claims in the `multi-claim-spec.k` which were ill-formed because of dependencies (but not tested for it) are removed. - An ill-formed (because of dependencies) claim is added in a separate module, and a new test added which exercises that a `ValueError` is thrown when loading this module. - A new test is added which asserts that the correct number of claims is loaded from the main module. On `master`, this test is failing because it skips claims without labels, but is fixed on this PR. - Adjustments to how claims are filtered are made, so that it's simpler and includes all claims, even ones without explicit module names in the label. --------- Co-authored-by: devops <[email protected]>
1 parent e04cdc1 commit 8921b79

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

pyk/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.615'
13-
release = '0.1.615'
12+
version = '0.1.616'
13+
release = '0.1.616'
1414

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

pyk/package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.615
1+
0.1.616

pyk/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.615"
7+
version = "0.1.616"
88
description = ""
99
authors = [
1010
"Runtime Verification, Inc. <[email protected]>",

pyk/src/pyk/ktool/kprove.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,7 @@ def _get_claim_module(_label: str) -> str | None:
364364
return None
365365

366366
all_claims = {
367-
claim.label: (claim, _get_claim_module(claim.label))
368-
for module in flat_module_list.modules
369-
for claim in module.claims
370-
if _get_claim_module(claim.label) is not None
367+
claim.label: (claim, module.name) for module in flat_module_list.modules for claim in module.claims
371368
}
372369

373370
claim_labels = list(all_claims.keys()) if claim_labels is None else list(claim_labels)

pyk/src/tests/integration/k-files/multi-claim-spec.k

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@ module MULTI-CLAIM-SPEC
2626

2727
claim <k> a => b </k>
2828

29+
claim <k> a => c </k>
30+
2931
claim [dep]: <k> c => a </k>
3032

3133
claim [main.1]: <k> a => c </k> [depends(dep,MULTI-CLAIM-SPEC-DEPENDENCY-1.dep-1.1)]
3234

33-
claim [main.2]: <k> a => c </k> [depends(dep,MULTI-CLAIM-SPEC-DEPENDENCY-1.dep-1.2)]
34-
3535
claim [main.3]: <k> a => c </k> [depends(MULTI-CLAIM-SPEC.dep)]
3636

37-
claim [main.4]: <k> a => c </k> [depends(dep-1.2)]
38-
3937
claim [rep-dep]: <k> c => b </k>
4038
endmodule
39+
40+
module MULTI-CLAIM-BROKEN-SPEC
41+
imports MULTI-CLAIM-SPEC
42+
43+
claim [bad-dep]: <k> a => b </k> [depends(non-existent-1)]
44+
endmodule

pyk/src/tests/integration/kprove/test_get_claims.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,11 @@ def test_get_claims(
9595
assert set(expected_graph.keys()) == set(actual_graph.keys())
9696
for claim_label, deps in expected_graph.items():
9797
assert set(deps) == set(actual_graph[claim_label])
98+
99+
def test_get_claims_unlabeled(self, kprove: KProve) -> None:
100+
claims = kprove.get_claims(self.KOMPILE_MAIN_FILE, self.SPEC_MODULE_NAME)
101+
assert len(claims) == 10
102+
103+
def test_get_claims_broken(self, kprove: KProve) -> None:
104+
with pytest.raises(ValueError):
105+
kprove.get_claims(self.KOMPILE_MAIN_FILE, 'MULTI-CLAIM-BROKEN-SPEC')

0 commit comments

Comments
 (0)