Skip to content

feat(fc): define store pruning and prove the finalized-slot memory bound - #73

Merged
adust09 merged 2 commits into
mainfrom
feat/fc-prune-safety
Jul 30, 2026
Merged

feat(fc): define store pruning and prove the finalized-slot memory bound#73
adust09 merged 2 commits into
mainfrom
feat/fc-prune-safety

Conversation

@adust09

@adust09 adust09 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Delivers the memory-bound and invariant halves of #71 (verified safety of store pruning below the finalized root).

New file LeanSpec/Forks/Lstar/Store/Prune.lean:

Memory bound

  • Store.prune — concrete pruning: drop every block/state whose root is not in the finalized subtree, decided by the same checkpointIsAncestor walk fork choice already uses. Control fields (checkpoints, head, vote pools) untouched.
  • mem_prune_blocks_iff — a block survives iff the finalized checkpoint is its ancestor.
  • prune_block_slot_ge / prune_blocks_length_lethe memory bound: the live store after pruning is bounded by the blocks at or above the finalized slot. This is the statable upper bound Verified safety of store pruning below the finalized root (via ST-6 / FC-2) #71 feeds upstream (today the reference store grows without bound).
  • prune_blocks_sublist — pruning only drops entries.

Invariant preservation (second commit)

  • getBlock?_prune_iff / getState?_prune_iff — pruned-store lookups return the original entry exactly when pruning keeps it (assoc-list find?/filter characterization under key uniqueness).
  • ancestorWalk_sound — walk success exhibits the relational ancestry plus the ancestor block at the checkpoint slot (converse of ancestorWalk_complete).
  • keepBlock_of_ancestorOrEqual — every finalized-subtree block survives pruning.
  • properAncestor_prune — finalized-rooted ancestry derivations transfer to the pruned store.
  • prune_wellFormed — pruning preserves WellFormed. The justified anchor survives with its finalized ancestry: the justified root lies on the finalized subtree (M-1 clause), the transferred relation is re-run by walk completeness inside the pruned store (via an auxiliary store whose justified checkpoint is the finalized one, breaking the WellFormed circularity), and congruence maps the result back.

All theorems sorry-free; lake build passes.

Not in this PR (follow-up per #71)

The observational-equivalence half (update_head/on_block/checkpoint evolution agree between st and prune st). It builds directly on the subtree-transfer lemmas proved here.

Refs #71

adust09 added 2 commits July 30, 2026 11:15
Deliver the memory-bound half of #71: a concrete Store.prune dropping
every block/state outside the finalized subtree, with

- mem_prune_blocks_iff: a block survives iff the finalized checkpoint
  is its ancestor,
- prune_block_slot_ge / prune_blocks_length_le: every retained block
  sits at or above the finalized slot, bounding the live store by the
  finalized-slot horizon (the statable memory bound for upstream),
- prune_blocks_sublist: pruning only drops entries.

The observational-equivalence half needs a new prune-congruence lemma
family (existing congruence lemmas require blocks equality, which
pruning breaks) and is split into follow-up work.
Deliver the invariant half of #71 on top of the memory bound:

- getBlock?_prune_iff / getState?_prune_iff: lookups on the pruned
  store return the original entry exactly when pruning keeps it
  (via an association-list find?/filter characterization under key
  uniqueness).
- ancestorWalk_sound: walk success exhibits the relational ancestry
  plus the ancestor block at the checkpoint slot (converse of
  ancestorWalk_complete).
- keepBlock_of_ancestorOrEqual: every finalized-subtree block
  survives pruning.
- properAncestor_prune: finalized-rooted ancestry derivations
  transfer to the pruned store (each visited node is kept).
- prune_wellFormed: pruning preserves WellFormed. The justified
  anchor survives with its finalized ancestry: the justified root
  lies on the finalized subtree (M-1), the transferred relation is
  re-run by walk completeness inside the pruned store via an
  auxiliary store whose justified checkpoint is the finalized one
  (breaking the WellFormed circularity), and congruence maps the
  result back.
@adust09
adust09 merged commit 4ad8e28 into main Jul 30, 2026
1 check passed
@adust09
adust09 deleted the feat/fc-prune-safety branch July 30, 2026 04:12
adust09 added a commit that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant