Skip to content

feat(fc): prove incremental weight maintenance agrees with the naive tally - #74

Merged
adust09 merged 1 commit into
mainfrom
feat/fc-incremental-weights
Jul 30, 2026
Merged

feat(fc): prove incremental weight maintenance agrees with the naive tally#74
adust09 merged 1 commit into
mainfrom
feat/fc-incremental-weights

Conversation

@adust09

@adust09 adust09 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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.lean proves 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), with Weights.get_bump characterizing bump as 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 through get; 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 is get-equal to the full tally. Well-posedness of the statement rests on the content-derived tie-break (leanEthereum/leanSpec#1181), already modeled in votePrecedence.

creditChain is made public (was private) so the lemmas can reason about each step — same precedent as ghostWalk.

All theorems sorry-free; lake build passes.

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

…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.
@adust09
adust09 merged commit c9253b7 into main Jul 30, 2026
1 check passed
@adust09
adust09 deleted the feat/fc-incremental-weights 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