feat(fc): prove incremental weight maintenance agrees with the naive tally - #74
Merged
Conversation
…tally Deliver the weight-delta layer of #67: the algebraic core that makes proto-array-style incremental head computation a refinement of the naive spec walk. - Weights.Equiv: extensional equality of weight maps, with get_bump characterizing bump as pointwise +1. - creditChain_get_add / accumulateAncestorWeights_append: the vote tally is pointwise additive, so per-vote weight deltas are well-defined. - accumulateAncestorWeights_perm: the tally is order-free — an incremental maintainer may apply vote updates in any order. - ghostWalk_congr_weights / computeLmdGhostHead_incremental: the GHOST descent (children, threshold, comparison, tie-break) reads weights only through get, so any maintained map extensionally equal to the full tally selects exactly the spec head. creditChain is made public (was private) so the lemmas can reason about each step, mirroring the ghostWalk precedent. The best-child/best-descendant cache layer of proto-array sits on top and is follow-up; its correctness reduces to the walk over the same weight function proved here.
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
Delivers the weight-delta layer of #67 (verified equivalence of incremental LMD-GHOST head vs naive spec walk).
New file
LeanSpec/Forks/Lstar/Store/IncrementalWeights.leanproves the algebraic core that makes proto-array-style incremental maintenance a refinement of the naive re-tally:Weights.Equiv— extensional equality of weight maps (get-equal; entry order and explicit zeros are irrelevant), withWeights.get_bumpcharacterizingbumpas pointwise +1.creditChain_get_add/accumulateAncestorWeights_append— the vote tally is pointwise additive: crediting a batch is the pointwise sum of crediting its parts. This is exactly what makes per-vote weight deltas well-defined.accumulateAncestorWeights_perm— the tally is order-free: any permutation of the vote list yields the same weight function, so incremental updates may be applied in any order.ghostWalk_congr_weights/computeLmdGhostHead_incremental— the GHOST descent (child enumeration, threshold filter, comparison, tie-break included) reads weights only throughget; any maintained map extensionally equal to the full tally selects exactly the head of the naive spec walk.Together: a client maintaining the weight map incrementally — batching and reordering however it likes — computes the same head as
_compute_lmd_ghost_head, provided its map isget-equal to the full tally. Well-posedness of the statement rests on the content-derived tie-break (leanEthereum/leanSpec#1181), already modeled invotePrecedence.creditChainis made public (wasprivate) so the lemmas can reason about each step — same precedent asghostWalk.All theorems sorry-free;
lake buildpasses.Not in this PR (follow-up per #67)
The best-child/best-descendant cache layer of proto-array (propagation invariants, cache validity). Its correctness statement reduces to the walk over the same weight function proved here.
Refs #67