feat(fc): prove FC-6 update_head preserves the store invariants - #61
Merged
Conversation
The head-walk theorems (FC-2/FC-4) assumed Store.WellFormed without any proof that the store's own operations maintain it. This closes the gap for update_head, the one modeled mutator: all six clauses survive. Five clauses carry over untouched (update_head rewrites only head and latest_finalized). The substantive clause is justifiedDescendsFromFinalized, proved from: - descendToSlot_ancestorOrEqual: the finalized re-derivation walk never leaves the head's ancestor chain. - properAncestor_comparable / ancestors_comparable: parent links are unique, so two ancestors of one block sit on one chain; the wrong order is killed by slot arithmetic. - ancestorWalk_complete: completeness of the Boolean _checkpoint_is_ancestor walk against the relational ancestry. The fuel argument counts distinct stored blocks at or below the walk's position (slotCount), which strictly shrinks every step, so blocks.length + 1 fuel always suffices. - checkpointIsAncestor_of_ancestorOrEqual packages the walk guard and completeness into the stored clause. Two store invariants that on_block maintains outside update_head's reach enter as explicit hypotheses rather than growing WellFormed: the justified checkpoint records its own block's slot, and no stored post-state finalizes past the store's justified slot (backed by ST-4). ancestorWalk and descendToSlot are de-privatized so the lemmas can reason about each step, mirroring the earlier ghostWalk treatment. Catalog: FC-6 entry added; progress table now 32 proved / 1 axiom.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The head-walk theorems (FC-2/FC-4) assume
Store.WellFormed, but nothing proved the store's own operations maintain it — the main gap flagged in the safety audit. This PR closes it forupdate_head, the one mutator the Lean model currently has: all sixWellFormedclauses surviveupdateHead(Store.updateHead_wellFormed).Argument
update_headrewrites onlyheadandlatest_finalized, so five clauses carry over untouched. The substantive clause isjustifiedDescendsFromFinalized— the re-derived finalized checkpoint (the head chain's ancestor at the head state's finalized slot) must still sit on the justified chain:descendToSlot_ancestorOrEqual— the finalized re-derivation walk never leaves the head's ancestor chain.computeLmdGhostHead_descends— the head descends from the justified root.properAncestor_comparable/ancestors_comparable— parent links are unique, so two ancestors of one block are slot-ordered on one chain; the wrong order contradicts the slot bounds.ancestorWalk_complete— completeness of the Boolean_checkpoint_is_ancestorwalk against the relational ancestry. The fuel argument counts distinct stored blocks at or below the walk's position (slotCount), which strictly shrinks every step, soblocks.length + 1fuel always suffices (a slot-difference bound would not — slot gaps can exceed the block count).Two store invariants that
on_blockmaintains outsideupdate_head's reach enter as explicit hypotheses rather than growingWellFormed: the justified checkpoint records its own block's slot, and no stored post-state finalizes past the store's justified slot (backed by ST-4). Both are documented in the theorem docstring and the catalog entry.ancestorWalkanddescendToSlotare de-privatized so the lemmas can reason about each step — the same treatmentghostWalkgot for FC-2.Catalog
FC-6 entry added; progress table now 32 proved / 1 axiom / 33 total.
Verification
lake buildsucceeds (36 jobs);#print axiomsforupdateHead_wellFormed→[propext, Classical.choice, Quot.sound]only; nosorry.