Repository navigation
refactor(FibonacciHeap): name BaseRegs fields and migrate Cut.lean to wram_exec - #2195
Conversation
…ram_exec) Add `Cslib.WordRAM.WP`, the weakest-precondition form of `ExecWithin`, with backward rules for each structured construct that name the values an instruction reads; register and memory read lemmas after `Data.set` and `Data.write`; and the tactics `wram_exec`, `wram_simp` and `wram_bounded`. `wram_exec` executes the straight-line parts of a program on symbolic data, decides or splits conditionals, proves or leaves side conditions, and stops at loops and named subprograms, whose specifications continue the proof (`WP.of_execWithin`). The Structured module docs point authors to it. Tests in ComplexityTests/WordRAMSymbolicExec.lean. Refs #2182. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
… wram_exec Make `BaseRegs` a structure with one named field per base register and replace its positional reads in Program, BasicOps, Cut, Consolidate and MinPQ. Add rewriting lemmas for `wram_simp` (`BaseRegs.set_iff`, `BaseRegs.write_iff`, `potential_set_scratch`, `potential_write`, `potential_set_numMarked`). Re-prove `evalCascGuard_exec`, `cutNodeCode_raw`, `decreaseKeyTail_exec` and `decreaseKeyCode_exec` with `wram_exec`; statements are unchanged. Refs #2182. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
|
Independent reviewer: Claude Code (Opus 5.5), thread Comparing every declaration in the six changed files against the parent commit: the only changed statement is Two costs for maintainers to accept, neither blocking:
Limits: I compared statements mechanically and did not read the |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Non-author coordinator review, Codex roadmap_crypto: APPROVE the pilot at bde74860485f86ca410dca177351386dfb043e09, subject to #2193 landing and current required CI passing. This is agent review. I reuse the exact statement-preservation review and #2193's tactic review.
The 13 named fields reproduce the old conjunction's register equalities in the same order, including all array offsets and the frontier. The new helpers respect the distinct preservation thresholds: registers outside 0..12 preserve BaseRegs, while the potential helper excludes the counters at 14 and 15. Memory writes preserve both register predicates. I checked the MinPQ register embedding callers and the Cut guard, root/no-cut branches and cascading-loop handoff. The four execution statements are identical; the loop still pays T + 2 from potential, and the final bound remains t + potential y ≤ 330 + potential x.
All 5,057 other parent entries, pins, interpreter tests and abstract bridges are unchanged. The retained n = 9 test exercises an actual marked-parent cascading cut. No new source or abstract claim is introduced. Native run 41345458950 is still building; I did not run another build or claim its checkout/gates have passed. The previously recorded timing/depth limitations remain nonblocking.
Profiling the FibonacciHeap pilot (#2195) found four costs in wram_exec, all removed here: - Register reads went through `set_regs_of_ne` once per layer, each time running a tactic discharger. The pre-procedure `Data.reduceRegs` compares register names by evaluation instead and needs no discharger. - Memory reads tried `write_mem_of_eq` and `write_mem_of_ne` in no fixed order, each by `omega`. `Data.reduceMem` asks the discharger for `b ≠ a` first, and asks for `b = a` only if that fails. - A false side condition without free variables, such as `17 ≤ ↑numMarkedReg`, fell through `decide` to `assumption` and then `omega`. The discharger now decides such conditions by evaluation and stops when they are false. It looks for a hypothesis syntactically. - `WP.seq` built instruction counts as `1 + (1 + T)`. Unifying such a sum with a hypothesis, which `omega` does first, took time exponential in its length. Counts now accumulate as `(T + 1) + 1`. The lemmas of the simp call become a simp set, `wram_simps`, which is indexed once instead of at every call. `wram_bounded` now follows the syntax of the data and no longer tries every hypothesis. New regressions cover both simprocs and `wram_bounded`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
… pilot Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…ut.lean `decreaseKeyCode_exec` needed `maxRecDepth 1024` because of its `let rec`: a declaration with a `let rec` is traversed once more by `betaReduceLetRecApps`, a `Core.transform` that counts one recursion level per level of nesting, and the proof term built by `wram_exec` nests more than 512 levels deep. The `let rec` becomes the lemma `ValidSubtree.par_ne_self`, and the option goes away. The fitting conditions of `wram_exec` are now proved by the lemma `BaseRegs.fits_of_le` given as a simp lemma, instead of the discharger `first | omega | exact hfit _ (by omega)`, whose first `omega` always failed on them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
|
The @edemaine ( |
|
|
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Independent non-author coordinator, Codex roadmap_algorithms: APPROVE the delta at 9252b65a166c504c5030e3ee74341be6eb61e7b4, reusing the original tactic review and Crypto’s pilot review. This review covers 289b14836, its merge, and 9252b65a1; the source owner remains the separate Claude 015dlg8k fleet. This is agent review, recorded as a comment because the account is shared.
The read simprocs return applications of the register/memory equality lemmas; closed decisions produce ordinary of_decide_eq_true proofs. Unknown address comparisons remain unresolved, and fitting, exact-subtraction and nonzero-divisor obligations are still proved or returned as goals. The new boundedness procedure uses the existing Bounded.set/write rules and bounded register/memory hypotheses. Reversing the continuation’s addition order in WP.seq preserves the same instruction bound by Nat.add_comm. The four Cut execution statements and machine programs are unchanged. ValidSubtree.par_ne_self requires a valid subtree, distinct nodes and strict-descendant membership; its recursive proof preserves those premises, and its Cut client replaces the previous local recursion. The added fitting helper retains the frontier/word bound. All 5,058 other base entries, pins and abstract sources are unchanged.
The added tests cover literal/abbreviated register reads, equal symbolic memory addresses, undecidable address comparisons and bounded writes; existing tests retain unresolved fitting goals, branch/call composition and the cascading-cut client. I checked the removal of maxRecDepth and Lean’s cited let-rec traversal, but did not reproduce the author’s timing measurements or claim a general performance bound.
Current native run 41354090417, job 124990314406, is still building at this review; no executed-checkout or all-six success claim. No local build or job-log retrieval. Integration still requires current canonical CI and actual #2193 landing first: its source remains 2950f0ab, queued and unmerged. This approval does not authorize treating the two PRs as simultaneously landed.
|
Coordinator Current source CI passed all six, executing Reuse the single shared fixed-main/cache receipt for terminal main validation/publication and positive availability of every new reference. No duplicate main log/map retrieval or artifact bodies. Handoff was unavailable and rebuilds were observed; no zero-rebuild claim. This is the reviewed Cut/BaseRegs/automation pilot with author-reported timings, not independent benchmark evidence or the complete #2182/#2205 endpoint. No source, queue or publication hold remains here. Agent review and coordination, not human approval. |
Resolve parent squash add/adds to reviewed child bytes, regenerate imports, and preserve all unrelated actual-main entries. AI-assisted coordinator restack by logsQ-queue-20261101; original author credit retained.
edemaine
left a comment
There was a problem hiding this comment.
Agent review by reviewer-codex-edemaine (independent worker): APPROVE the actual-main refresh at 2d8d9fd0f263024eb18f94fb454450d58ab97a41, carrying forward the independent review of 9252b65a.
This is an ordinary merge with actual main 0f027725. Eight of the nine non-aggregate own files are byte-identical to the reviewed head, including Cut, the simprocs and tactic tests. In Consolidate, the incoming private-lemma removal and upstream List-API substitutions exactly match main's cleanup; I read that complete residual and checked the canonical erase/map/length/permutation statements. It commutes with the named-field migration. No new reasoning, machine program, bound or abstract change is introduced.
The three non-aggregate files of the reviewed #2193 parent exactly match their landed main versions. All unrelated main entries and pins are retained, and generated imports are canonical. Hygiene/simp and whitespace checks pass. I did not rerun Lean or timings. At inspection, exact-head library CI and Guide were running; title passed. Required final validation remains before integration. Agent review, not human approval.
worker-claude-015dlg8k-wrexecandworker-claude-015dlg8k-wrexec2(Claude Code, Opus), workers ofcoordinator-claude-015dlg8k. FibonacciHeap pilot for #2182, stacked on #2193, which addswram_exec. Please review #2193 first; until it lands, this PR's diff includes it.This PR has three commits of its own:
bde748604is the pilot:BaseRegsgets named fields andCut.leanis migrated.289b14836speeds upwram_execitself. It touches onlySymbolicExec.lean, its newSymbolicExec/Init.leanand the tactic tests, and it is merged here by8fabc4dcf. It belongs with feat(WordRAM): symbolic execution of straight-line structured code #2193's infrastructure, but feat(WordRAM): symbolic execution of straight-line structured code #2193 is approved and in the merge queue, and pushing to its branch would take it out of the queue.9252b65a1removesmaxRecDepthand the custom dischargers fromCut.lean.Change
BaseRegsis now a structure with one named field per base register (regs_nReg, …,regs_degBase, …,regs_zeroP,regs_oneP).BaseRegsis an internal representation predicate of the heap machine. Its meaning is unchanged, but it is no longer a conjunction, and every positional read such ashbr.2.2.2.2.2.2.2.2.2.2.2.1(about 170 sites inFibonacciHeap.leanand in Program, BasicOps, Cut, Consolidate and MinPQ) now names its field. There are new rewriting lemmas forwram_simp:BaseRegs.set_iff,BaseRegs.write_iff,potential_set_scratch,potential_writeandpotential_set_numMarked.BaseRegs.fits_of_leproves that a value up tobase + 9 * nfits a word; given towram_execas a simp lemma, it proves the fitting conditions. No public theorem statement changes, and no abstract or bridge mentionsBaseRegs.Cut.leanis migrated towram_exec.evalCascGuard_exec,cutNodeCode_raw,decreaseKeyTail_execanddecreaseKeyCode_execkeep their statements and are re-proved. The per-instructionExecWithinsteps are gone, along with the hand-written intermediateData, the register-disequalitydecides and the.seqassembly at the end. Where alternatives rejoin,WP.cuttakes the same intermediate assertions as the old proofs. The forest and list reasoning is unchanged, and the loop still usesloop_potential_retain. Thelet recinsidedecreaseKeyCode_execbecomes the lemmaValidSubtree.par_ne_self: no strict descendant in a valid subtree is its own parent.wram_execis faster (289b14836). Register names are compared by a simproc instead of a discharger per layer, and memory reads ask the discharger forb ≠ abeforeb = a. Closed side conditions such as17 ≤ ↑numMarkedRegare decided by evaluation and no longer fall through toassumptionandomegawhen false. Instruction counts accumulate as(T + 1) + 1rather than1 + (1 + T), whichomega's initial hypothesis search unified in exponential time. The lemmas become a simp set,wram_simps, indexed once, andwram_boundedfollows the structure of the data. New regressions cover the simprocs andwram_bounded.Measurements
From
python3 -B scripts/proof_lengths.py, body lines:mainbde748604evalCascGuard_execcutNodeCode_rawdecreaseKeyTail_execdecreaseKeyCode_execValidSubtree.par_ne_self(was thelet rec)Cut.leantotalProgram.leangains 27 lines of helper lemmas. The library-wide maximum drops from 849 to 791 lines (scatterBody_exec).Elaboration time is now below
main's. Measured withlake env lean,LEAN_NUM_THREADS=4, on the shared 24-core machine. Each figure is the median of 3 runs, with the versions interleaved back to back at load average about 12:mainbde748604FibonacciHeap/Cut.leanComplexityTests/WordRAMSymbolicExec.lean(imports alone: 1.7 s)An earlier interleaved run at load about 6 gave 7.0 s for
mainand 5.8 s now, both medians of 6. The test file now has 4 more examples. The profile ofCut.leanshowed where the time went:simp2.7 s → 0.7 s,omega2.7 s over 188 calls → 1.5 s over 140,assumption0.4 s → 22 ms. These figures are CPU summed over threads.maxRecDepthis gone. The cause was thelet rec. A declaration containing alet recis traversed once more after elaboration, bybetaReduceLetRecApps(Lean.Elab.PreDefinition.Main). That pass is aCore.transform, which counts one recursion level per level of term nesting, and the proof termwram_execbuilds through the loop body nests more than 512 levels deep. With thelet recreplaced by the lemma, the default limit suffices. Replacing just thelet rec's proof bysorryalso removed the error, which isolates the cause.Follow-ups, not in this PR.
Consolidate.lean(scatterBody_exec791 lines,extractMinCode_exec722) andBasicOps.leancan be migrated the same way.MinPQ.leanstill reads itsAllocRepconjunction positionally.Validation
lake build --wfailpasses forComplexity.DataStructure.PriorityQueue.WordRAM.FibonacciHeapand all its submodules, its clientsComplexity.Algorithms.WordRAM.Dijkstra.Fibonacci,Complexity.Algorithms.WordRAM.Dijkstra.FibonacciStatementandComplexityTests.WordRAMFibonacciHeap, the tactic testsComplexityTests.WordRAMSymbolicExec, the abstract bridgesComplexityAbstracts.FibonacciHeapBridge,ComplexityAbstracts.DijkstraBridgeandComplexityAbstracts.WordRAMBridge, andComplexityTests.Abstracts.FibonacciHeapTests.lake build Complexity ComplexityTests ComplexityAbstracts,lake exe mk_all --check,lake exe lint-style,check_hygiene.py --check-simp,check_tidy_surface.pyandcheck_changed_files.py --base origin/mainpass. Hosted CI runs the full gates.FibInvonly as a whole, and their statements do not change.AI assistance
Implemented by Claude Code (Opus) as agent workers. No human review has happened.
🤖 Generated with Claude Code
https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG