Repository navigation
feat: prove and execute balance aggregation - #9
Merged
Merged
Conversation
weigh still takes the three balances as arguments. This records the pinned caller that computes them and the instruction sequence that will implement that caller, before the loop proof and ELF checks.
Complete the caller-side balance aggregation so the modeled RV64 routine has a resource-preserving proof and bounded return, not just an instruction listing. Validate emitted artifacts against the pinned official operation, reject malformed inputs and mutated images, and measure checked interpreter execution. Keep ELF validation outside the formal proof boundary and preserve the existing weigh routine.
adust09
marked this pull request as ready for review
November 12, 2026 04:46
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
Complete the standalone balance aggregation used by the pinned caller of
weigh_justification_and_finalization.max(10^9, sum)floor.52 * N + 24steps. Include a satisfiable concrete calling witness and the transitive axiom audit.aggregate.elf(312 code bytes), add a JSON-lines runner with strict admission and ELF validation, and provide a checked host-interpreter benchmark.-208, own every used register in the contract, preserve consumed cells through induction, and add LUI/SUB emission and independent encoding checks.weighand its ZisK wrapper are unchanged.Validation
lake --no-cache --wfail build: pass without warnings.lake env lean scripts/CheckAxioms.lean: pass; 4,848 declarations, onlyClassical.choice,Quot.sound, andpropext..lake/build/bin/cl-asm buildand.lake/build/bin/cl-asm-test build: pass, including preservation corruption, non-return, and unaligned-access rejection..venv/bin/python -m unittest discover -s tests -v: 32 tests pass, including CLI usage diagnostics (verified failing before the fix).weighregression: 4,796 official differential cases, 99–147 steps.The local interpreter executes
21 + 52 * N + esteps, whereecounts the raw sums at least10^9(0–3). The proved upper bound is52 * N + 24.Boundaries
Lean proves the modeled instruction sequence, not the ELF itself. Assembly/linking/loading, interpreter conversion, JSON admission, and agreement with the pinned Python operation are tested. The layout is internal, not SSZ. Aggregation ZisK integration and proof-generation benchmarks remain separate work.
Review and finding dispositions
The required
implementation_donegate reviewed the complete 31-file candidate in 10 chunks.gpt-oss-120bresponded to every chunk;bonsai2,glm5.3, andqwen-flashtimed out and are not counted as approvals. Six responding chunk reviews reported findings. This is not unanimous panel approval.One issue was fixed. A second
implementation_donerun reviewed the resulting two-file, 11-line follow-up against the exact first reviewed tree. Its sole responding reviewer alleged an undefinedusage; this is declined becauseAggregateMain.lean:5defines it, and the rebuilt executable passes the regression test and--helpcheck. The other three reviewers remained unavailable, not approving. No source edits followed that review.All other first-round findings were checked and explicitly declined as follows; none is silently deferred. IDs refer to the chunk and its numbered finding (or severity section).
callRegisters a input nadvances each pointer by its stride timesnand sets the counter tolength - n = 0; it does not restore the initial pointers.signForty095ClAsm/Aggregate/Loop.lean:33, imported byCorrectness.lean.executeLoopchecks return before fuel, so an already-returned state succeeds with zero fuel and would fail theisNonerequirement rather than pass it. Validated routine entry differs from return; differential cases require at least 21 steps.0xa0000000; none can underflow when subtracting eight. Moreover, LeanNatsubtraction saturates at zero, not a huge wrapped value.[0:32]is supported Lean range notation; compilation and preservation tests pass.Correctnesson line 1 and opens the namespace on line 3. Required hypotheses are inloop_frame's signature; the chunk omitted this earlier context. The full module compiles.ValidInput.slashedand the explicithslashedhypothesis require 0 or 1; the induction passes this hypothesis onward. All arithmetic proof goals are discharged by Lean.0,1,0x3B9AD,0x7FFFF,0x80000,0xFFF00, and0xFFFFF, plus SUB. Masking-256gives the same encoding as0xFFF00.AggregateMain.leanexists at repository root and builds the executable exercised by the tests; it appeared in an earlier review chunk.epoch + 1 <= 2^59 < 2^64. These intentionally admitted boundary cases pass the official-reference differential test.Aggregate.Test.checkHarnesscall compiles and runs. Hypothetical future unqualified references are not a present defect.docs/build.mdanddocs/aggregate.mdexist in the same directory; the relative link is valid.weighandaggregate), not external input. Assembler/linker calls use argument arrays, not a shell.a, bandcare bound before opcode dispatch. The typed generated manifests supply valid operand counts; the complete independent-encoding tests and the extra GNU experiment pass.weigh; existing two-argument calls retain their behavior. No failing caller was identified.