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

Add parameter to advance_proof to split into subproofs after enough branches have been created #638

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
eb9be59
Add option to split into subproofs when a branching threshold is reached
nwatson22 Sep 6, 2023
ca4156c
Merge remote-tracking branch 'origin/master' into noah/subproof-split
nwatson22 Sep 6, 2023
c1ce995
Make max_iterations disabled by default
nwatson22 Sep 6, 2023
5d6cfb3
Add test for subproof delegation
nwatson22 Sep 6, 2023
5aee4b1
Merge 5d6cfb3d11cf4b010f3bb640e9137a46cdf48ad9 into 465cca1f37317807b…
nwatson22 Sep 6, 2023
9379310
Set Version: 0.1.434
Sep 6, 2023
0a09655
Merge 9379310c36e0f607550124cada5dc7c478881c46 into 465cca1f37317807b…
nwatson22 Sep 6, 2023
efe6ceb
Set Version: 0.1.435
Sep 6, 2023
43953f4
Fix formatting and typing
nwatson22 Sep 6, 2023
ec88901
Merge branch 'noah/subproof-split' of https://github.com/runtimeverif…
nwatson22 Sep 6, 2023
6166076
Merge master into branch
nwatson22 Sep 6, 2023
dd18600
Add new APRProof-level node status for nodes that have been subproofed
nwatson22 Sep 7, 2023
caac8e9
Merge branch 'master' into noah/subproof-split
nwatson22 Sep 7, 2023
d4a66b4
Merge caac8e91e480d3d57593c61ab64456b1e2485989 into e87862c070793908b…
nwatson22 Sep 7, 2023
5a768d4
Set Version: 0.1.437
Sep 7, 2023
0d12594
Add custom function arg to determine IDs of generated subproofs
nwatson22 Sep 13, 2023
d259f23
Make branch extraction more intelligent
nwatson22 Sep 13, 2023
51d7729
Merge d259f23fe282348402f9fd018d567959460004d0 into d19598b275c2ee741…
nwatson22 Sep 13, 2023
2863769
Set Version: 0.1.440
Sep 13, 2023
2826395
Do not immediately apply simplifications, only count non-bottom nodes
nwatson22 Sep 13, 2023
6de4680
Merge branch 'noah/extract-branches-fix' of https://github.com/runtim…
nwatson22 Sep 13, 2023
07574aa
Use kast_simplify
nwatson22 Sep 13, 2023
f8f3249
Merge master into branch, add proof parameter to generate_subproof_name
nwatson22 Sep 15, 2023
8eec373
Merge branch 'master' into noah/subproof-split
nwatson22 Sep 15, 2023
62fe105
Merge 8eec373e0e226b3c619906eef045af48f9eb8007 into da0e4eae92248661b…
nwatson22 Sep 15, 2023
6abe235
Set Version: 0.1.443
Sep 15, 2023
433df12
Merge master into branch
nwatson22 Sep 15, 2023
39703aa
Merge 433df12918490de5578bdd56205b94116b013e69 into 31ca5378c8cb2109c…
nwatson22 Sep 15, 2023
5bf02dd
Set Version: 0.1.444
Sep 15, 2023
8b267aa
Fix subproof_nodes not being saved/loaded
nwatson22 Sep 16, 2023
bac8047
Merge branch 'noah/subproof-split' of https://github.com/runtimeverif…
nwatson22 Sep 16, 2023
a84c6f0
Merge branch 'master' into noah/subproof-split
nwatson22 Sep 18, 2023
c451595
Merge a84c6f014700f96471704aad746fe517bc6b7444 into eee504ee653696c20…
nwatson22 Sep 18, 2023
9628585
Set Version: 0.1.446
Sep 18, 2023
11072b5
Fix is_pending name conflict
nwatson22 Sep 18, 2023
286b04e
Update src/pyk/kcfg/show.py
nwatson22 Sep 18, 2023
88dfe83
Fix formatting
nwatson22 Sep 18, 2023
e60ba7a
Merge branch 'noah/subproof-split' of https://github.com/runtimeverif…
nwatson22 Sep 18, 2023
0d95e58
fix test
nwatson22 Sep 19, 2023
c5bf0c2
Merge branch 'master' into noah/subproof-split
nwatson22 Sep 20, 2023
c3f0d05
Merge c5bf0c2082f954dc30098b028b280e2103a9deb4 into abed8298b54de758d…
nwatson22 Sep 20, 2023
2a99cfc
Set Version: 0.1.448
Sep 20, 2023
b4d0c8a
Add generate_subproof_name to APRBMCProof
nwatson22 Sep 21, 2023
78bfded
Merge branch 'noah/subproof-split' of https://github.com/runtimeverif…
nwatson22 Sep 21, 2023
b63fe59
Make subproof loading more lazy
nwatson22 Sep 22, 2023
c6e8aea
Fix infinite recursion
nwatson22 Sep 22, 2023
fe2849b
Fix _subproofs map key error
nwatson22 Sep 22, 2023
fa20b9b
Remove guard on create_node
nwatson22 Sep 22, 2023
a315547
readd guard on create_node
nwatson22 Sep 22, 2023
d7e8a78
Merge remote-tracking branch 'origin/master' into noah/subproof-split
nwatson22 Sep 25, 2023
51d3778
Merge d7e8a783927af84b7e551f30f741049d5b249188 into ca97bb1caf81ddbb7…
nwatson22 Sep 25, 2023
694f2a5
Set Version: 0.1.449
Sep 25, 2023
5c188fd
Make add_node private
nwatson22 Sep 25, 2023
a2b386a
Merge branch 'noah/subproof-split' of https://github.com/runtimeverif…
nwatson22 Sep 25, 2023
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
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.448
0.1.449
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.448"
version = "0.1.449"
description = ""
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
6 changes: 3 additions & 3 deletions src/pyk/kcfg/kcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def from_dict(dct: Mapping[str, Any]) -> KCFG:
max_id = max(max_id, node_id)
cterm = CTerm.from_dict(node_dict['cterm'])
node = KCFG.Node(node_id, cterm)
cfg.add_node(node)
cfg._add_node(node)

cfg._node_id = dct.get('next', max_id + 1)

Expand Down Expand Up @@ -449,7 +449,7 @@ def get_node(self, node_id: NodeIdLike) -> Node | None:
def contains_node(self, node: Node) -> bool:
return bool(self.get_node(node.id))

def add_node(self, node: Node) -> None:
def _add_node(self, node: Node) -> None:
if node.id in self._nodes:
raise ValueError(f'Node with id already exists: {node.id}')
self._nodes[node.id] = node
Expand Down Expand Up @@ -982,7 +982,7 @@ def read_cfg_data(cfg_dir: Path, id: str) -> KCFG:
node_dict = json.loads(node_json.read_text())
cterm = CTerm.from_dict(node_dict['cterm'])
node = KCFG.Node(node_id, cterm)
cfg.add_node(node)
cfg._add_node(node)

cfg._node_id = dct.get('next', max_id + 1)

Expand Down
44 changes: 36 additions & 8 deletions src/pyk/proof/proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,19 @@ class Proof(ABC):

id: str
proof_dir: Path | None
_subproofs: dict[str, Proof]
_subproofs: dict[str, Proof | None]
admitted: bool

def get_subproof(self, proof_id: str) -> Proof:
if proof_id not in self._subproofs:
raise ValueError(f'subproof: {proof_id} not found in subproofs of {self.id}')
proof = self._subproofs[proof_id]
if proof is None:
proof = self.fetch_subproof_data(proof_id)

assert isinstance(proof, Proof)
return proof

@property
def proof_subdir(self) -> Path | None:
if self.proof_dir is None:
Expand All @@ -57,7 +67,7 @@ def __init__(
raise ValueError(f'Cannot read subproofs {subproof_ids} of proof {self.id} with no proof_dir')
if len(list(subproof_ids)) > 0:
for proof_id in subproof_ids:
self.fetch_subproof_data(proof_id, force_reread=True)
self._subproofs[proof_id] = None
if proof_dir is not None:
ensure_dir_path(proof_dir)
if self.proof_dir is not None:
Expand All @@ -68,7 +78,7 @@ def admit(self) -> None:

@property
def subproof_ids(self) -> list[str]:
return [sp.id for sp in self._subproofs.values()]
return list(self._subproofs.keys())

def write_proof(self, subproofs: bool = False) -> None:
if not self.proof_dir:
Expand Down Expand Up @@ -136,29 +146,43 @@ def fetch_subproof(
) -> Proof:
"""Get a subproof, re-reading from disk if it's not up-to-date"""

if self.proof_dir is not None and (force_reread or not self._subproofs[proof_id].up_to_date):
assert self.proof_dir is not None

subproof = self._subproofs[proof_id]

if force_reread or subproof is None or subproof.up_to_date:
updated_subproof = Proof.read_proof(proof_id, self.proof_dir)
self._subproofs[proof_id] = updated_subproof
return updated_subproof
else:
return self._subproofs[proof_id]
return subproof

def fetch_subproof_data(
self, proof_id: str, force_reread: bool = False, uptodate_check_method: str = 'timestamp'
) -> Proof:
"""Get a subproof, re-reading from disk if it's not up-to-date"""

if self.proof_dir is not None and (force_reread or not self._subproofs[proof_id].up_to_date):
assert self.proof_dir is not None

subproof = self._subproofs[proof_id] if proof_id in self._subproofs else None

if force_reread or subproof is None or subproof.up_to_date:
updated_subproof = Proof.read_proof_data(self.proof_dir, proof_id)
self._subproofs[proof_id] = updated_subproof
return updated_subproof
else:
return self._subproofs[proof_id]
return subproof

@property
def subproofs(self) -> Iterable[Proof]:
"""Return the subproofs, re-reading from disk the ones that changed"""
return self._subproofs.values()
for subproof_id in self._subproofs.keys():
self.fetch_subproof_data(subproof_id)
subproofs_all_loaded: list[Proof] = []
for subproof in self._subproofs.values():
assert subproof is not None
subproofs_all_loaded.append(subproof)
return subproofs_all_loaded

@property
def subproofs_status(self) -> ProofStatus:
Expand All @@ -182,6 +206,10 @@ def failed(self) -> bool:
def passed(self) -> bool:
return self.status == ProofStatus.PASSED

@property
def is_proof_pending(self) -> bool:
return self.status == ProofStatus.PENDING

@property
def dict(self) -> dict[str, Any]:
return {
Expand Down
Loading