Skip to content

feat(WordRAM): partition component DT evaluation and remainder MSF solver - #8933

Open
Vvauted wants to merge 2 commits into
cslib-community:mainfrom
Vvauted:feat/wordram-msf-optimal-part-eval
Open

Vvauted wants to merge 2 commits into
cslib-community:mainfrom
Vvauted:feat/wordram-msf-optimal-part-eval

Conversation

@Vvauted

@Vvauted Vvauted commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds Word-RAM partition-round decision-tree component evaluation and remainder-graph contraction MSF solving for the deterministic optimal minimum spanning forest algorithm (part of #8624 toward Theorem 5.8 of [PettieRamachandran2002], Section 5 pp. 23–24 and Section 5.1 pp. 25–27, Theorem 5.8 p. 27, building on #8862, #8863, #8871, #8879, #8903, and #8911):

  • CslibFrontier/Algorithms/WordRAM/MinimumSpanningForest/Partition/Bridges.lean (1,153 lines) and CslibFrontier/Algorithms/WordRAM/MinimumSpanningForest/Partition/Outer.lean (1,520 lines):
    • Defines flat word_enc_structure metadata bundle PartitionRoundMeta (plus PartitionRoundMeta.congr) capturing the 10 shared partition-round graph/component invariants, and simplifies partitionProg_spec to output PartitionRoundMeta directly.
  • CslibFrontier/Algorithms/WordRAM/MinimumSpanningForest/OptimalMSF/PartitionEval.lean (1,441 lines):
    • Defines flat word_enc_structure structures (EvalDTLoopArgs, SolveHRemArgs, SolveHRemResult).
    • Implements and verifies pr02EvalDTLoop (pr02EvalDTLoopSafe, realizes_pr02EvalDTLoop, pr02EvalDTLoop_spec), consuming PartitionRoundMeta with explicit frontier bounds, evaluating each simple component via evalDecisionTreeProg (HoldsDTTable, DTTableInBounds), lifting edges via liftEdgesProg, and concatenating into the output array (holdsIndexedEdges_append) with Realizes .exact (zero register work) and Memory.FramedTriple cost/frontier bounds.
    • Implements and verifies pr02SolveHRemProg (pr02SolveHRemProgSafe, realizes_pr02SolveHRemProg, pr02SolveHRemProg_spec), returning SolveHRemResult by retagging remainder edges (retagIndexedProg), contracting onto conglomerate vertices (contractEdgesProg, compactVerticesProg), solving via denseCaseProg, and lifting selected edges back via liftHRemProg with IsMinSpanningForest, Realizes .exact, and empty-frame Memory.FramedTriple preservation below the initial frontier composed via Memory.Modifies.trans.
  • CslibFrontierTests/Algorithms/WordRAM/MinimumSpanningForest/PartitionOuter.lean (1,226 lines) and CslibFrontierTests/Algorithms/WordRAM/MinimumSpanningForest/OptimalMSFPartitionEval.lean (470 lines):
    • Updates partition-outer tests for PartitionRoundMeta in partitionProg_spec, and exercises empty and 2-round / 4-vertex pr02EvalDTLoop runs (with precomputed HoldsDTTable / DTTableInBounds verification), empty and multi-edge pr02SolveHRemProg runs (consuming SolveHRemResult with lifted IsMinSpanningForest uniqueness), and a composite realize pipeline lowered to deterministic width-blind Program .standard.

Verification

  • lake build CslibFrontier.Algorithms.WordRAM.MinimumSpanningForest.Partition.Bridges CslibFrontier.Algorithms.WordRAM.MinimumSpanningForest.Partition.Outer CslibFrontier.Algorithms.WordRAM.MinimumSpanningForest.OptimalMSF.PartitionEval CslibFrontierTests.Algorithms.WordRAM.MinimumSpanningForest.PartitionOuter CslibFrontierTests.Algorithms.WordRAM.MinimumSpanningForest.OptimalMSFPartitionEval --wfail --iofail — passed (4,080 jobs, exit 0).
  • scripts/lint_module.py on Partition.Bridges (127 decls), Partition.Outer (280 decls), and OptimalMSF.PartitionEval (457 decls) — passed (0 errors across all 15 linters).
  • scripts/check_doc_names.py --base origin/main (3 changed library modules, 1 new test file, 10,949 .ilean files scanned), lake exe mk_all --check, lake exe lint-style, scripts/check_hygiene.py --check-simp --check-metadata, scripts/check_hub_impact.py --base origin/main, scripts/check_encoding_readability.py --base origin/main, scripts/check_projection_chains.py --base origin/main (0 chains), scripts/proof_copies.py --base origin/main, scripts/parallel_defs.py --base origin/main --no-build-check (0/14 declarations and --theorems 0/84), scripts/check_docs.py --config-only, and scripts/check.sh --quick --no-full-fallback --base origin/main (9 affected targets) — all exited 0.

AI assistance

Written and verified with assistance from Antigravity/LLM tooling; all Word-RAM programs, Realizes .exact certificates, Memory.FramedTriple complexity bounds, and concrete test witnesses are machine-checked by Lean 4 (--wfail --iofail).

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-27T07:03:11.406561Z
We couldn’t complete this review. Comment @codex review to try again.
691035c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@edemaine

Copy link
Copy Markdown
Collaborator

CLAIM review head=691035c37f1cc6460a4623b6bfd0f2ba8eb4f706 by=reviewer-codex-edemaine until=2026-11-27T07:46Z

@edemaine edemaine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUEST_CHANGES at 691035c by reviewer-codex-edemaine

The two specifications cover the component decision-tree evaluation and dense remainder steps in §5, using the comparison-depth bound from §5.1. Under a certified table and Partition metadata, the first writes one lifted MSF per component and charges 25 * m' + 15 * optDepthMN m' n + 20 * n memory operations. The second contracts, compacts, solves, and lifts original remainder edges by their retagged positions. It certifies an MSF after contraction, a linear memory-operation bound from the active-conglomerate bound, and a separate bound on frontier growth. These are the intended steps toward #8624. Pettie and Ramachandran, §§5–5.1

The empty cases and four-vertex client exercise the public API. The remainder test verifies that the cheapest of three edges between two conglomerates is lifted with its original ID. Please fix the cell-count mismatch in the public remainder result, share the metadata contract between the Partition producer and consumer, and reuse the existing frame composition lemma as noted inline. Both stage programs and their certificates have downstream callers in the planned composition.

Independent agent review. I read both changed Lean files and the Partition, memory, and edge-array contracts from main. The author reports a strict focused build. Hosted Lean validation and its declaration notices were pending when I checked. Hosted validation

@Vvauted

Vvauted commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

@reviewer-codex-edemaine Thank you for the review! All three review comments have been addressed in fast-forward delta commit 41addc9f4:

  1. Named result struct for pr02SolveHRemProg (RC 4716577045): Added SolveHRemResult (edgeBase, numEdges) in OptimalMSF/PartitionEval.lean and updated pr02SolveHRemProg, pr02SolveHRemProgSafe, realizes_pr02SolveHRemProg, pr02SolveHRemProg_spec, and OptimalMSFPartitionEval.lean to return/consume SolveHRemResult instead of Block.
  2. Shared PartitionRoundMeta bundle (RC 4716577054): Added PartitionRoundMeta and PartitionRoundMeta.congr in Partition/Bridges.lean, updated partitionProg_spec in Partition/Outer.lean (and PartitionOuter.lean) to produce PartitionRoundMeta directly, and refactored pr02EvalDTLoop_spec in OptimalMSF/PartitionEval.lean (and OptimalMSFPartitionEval.lean) to consume PartitionRoundMeta alongside explicit frontier bounds.
  3. Composed empty-frame Memory.Modifies proof (RC 4716577059): Replaced the manual per-stage region-disjointness chain in pr02SolveHRemProg_spec with Memory.Modifies.trans across the five empty-frame stages.

Re-verified on 41addc9f4 against origin/main (f03859b73): 5-target lake build --wfail --iofail (4,080 jobs, exit 0), lint_module.py (0 errors across all 15 linters), check_doc_names.py --base origin/main, mk_all --check, lint-style, check_hygiene.py, check_hub_impact.py, check_encoding_readability.py, check_projection_chains.py (0 chains), proof_copies.py, parallel_defs.py (0/14 and --theorems 0/84), and check.sh --quick --no-full-fallback --base origin/main (9 targets) all passed with exit 0.

@edemaine

Copy link
Copy Markdown
Collaborator

CLAIM review head=41addc9f4ccd0372b191bc9b969afd5e6974fad9 by=reviewer-codex-edemaine until=2026-11-27T08:32Z

@edemaine edemaine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUEST_CHANGES at 41addc9 by reviewer-codex-edemaine

All three original findings are resolved. SolveHRemResult names the edge count and preserves the two output words. The empty path returns the supplied base with zero edges, and the nonempty client checks the original ID of the lifted minimum edge. partitionProg_spec supplies PartitionRoundMeta for the evaluation loop, with its write-boundary condition separate. The producer’s existing clients now use named projections. Memory.Modifies.trans supplies both the pre-lift and final frame.

The metadata change leaves one new duplication. In partitionProg_spec, the proof for PartitionRoundMeta.congr and the proof of the adjacent frontier bounds each derive the same edge and lift prefix-sum bounds from W.hmeta, W.hclaim_card, and W.hcl_dead. Please prove those two per-round bounds once and reuse them in both goals. This is the candidate reported by the exact-head source scan. Source checks

Independent delta review. I read all five changed files, and git diff --check passed. The author reports strict focused elaboration. Hosted Lean was still pending at the start of the review.

have := W.hrounds_len; have := W.hnc_dead; have := hdead_le_n; omega
· have hi := i.isLt
obtain ⟨_, _, hm2, hm3, _⟩ := W.hmeta i.val hi
have hce_sum := list_take_sum_add_le (fun q => q.compLocal.length) W.rounds i.val hi

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same edge-prefix bound is derived again in the next goal. Both goals also derive the same lift-prefix bound. Shared local facts indexed by i would let the two callers supply only their different frontier inequalities.

This branch has not been deployed

No deployments
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.

2 participants