Skip to content

Commit 0f400ee

Browse files
authored
Skip loading circularity module for non-circularity proofs (#4860)
Some proofs we're loading are quite large in terms of the configuration and the unevaluated functions in it. They end up taking a long time to load the circularity module dynamically into the backend, even though it won't be used. This simply skips loading the circularities module for proofs that are not marked as circularities. It should not affect the functionality of the prover at all, and if it does it's likely a bug where we're using the circularities module in a place we shouldn't. This does mean, that for the pyk prover, circularities _must_ be marked as such (like the sum-spec.k which is marked as such here), otherwise they won't be included automatically as an axiom.
1 parent d5b9cbf commit 0f400ee

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

pyk/regression-new/kprove-haskell/sum-spec.k

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ module SUM-SPEC
1313
N >=Int 0
1414
ensures
1515
?S ==Int S +Int N *Int C +Int (N -Int 1) *Int N /Int 2
16+
[circularity]
1617
endmodule

pyk/src/pyk/proof/reachability.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ def get_steps(self) -> list[APRProofStep]:
188188
shortest_path.append(succ.source)
189189

190190
nonzero_depth = self.nonzero_depth(node)
191-
module_name = self.circularities_module_name if nonzero_depth else self.dependencies_module_name
191+
module_name = (
192+
self.circularities_module_name if nonzero_depth and self.circularity else self.dependencies_module_name
193+
)
192194

193195
predecessor_edges = self.kcfg.edges(target_id=node.id)
194196
predecessor_node_id: NodeIdLike | None = (
@@ -773,10 +775,11 @@ def _inject_module(module_name: str, import_name: str, sentences: list[KRule]) -
773775
if isinstance(subproof, APRProof)
774776
for rule in subproof.as_rules(priority=20, direct_rule=self.direct_subproof_rules)
775777
]
776-
circularity_rule = proof.as_rule(priority=20)
777-
778778
_inject_module(proof.dependencies_module_name, main_module_name, dependencies_as_rules)
779-
_inject_module(proof.circularities_module_name, proof.dependencies_module_name, [circularity_rule])
779+
780+
if proof.circularity:
781+
circularity_rule = proof.as_rule(priority=20)
782+
_inject_module(proof.circularities_module_name, proof.dependencies_module_name, [circularity_rule])
780783

781784
for node_id in [proof.init, proof.target]:
782785
if self.kcfg_explore.kcfg_semantics.is_terminal(proof.kcfg.node(node_id).cterm):

0 commit comments

Comments
 (0)