Repository navigation
feat(WordRAM/PriorityQueue): priority queue with handles (MinPQ) and key–value FibonacciHeap with O(log n + 1) amortized extractMin - #1687
Conversation
…eBase and drop aliases
…key-value FibonacciHeap
…fibonacci-heap-handles
…DynamicProgram/Executes
Advance CSLib to 8a8ad748 and synchronize Mathlib, the documentation generator, Verso, and all three lockfiles with Lean v4.36.0-rc2. Keep the root and documentation projects on the same inherited dependency revisions.
Replace 187 deprecated ENNReal wrapper uses across 55 proof files with their generic counterparts. The exact mapping is: - ENNReal.tsum_le_tsum -> tsum_le_tsum (94) - ENNReal.tsum_add -> tsum_add (54) - ENNReal.tsum_eq_zero -> tsum_eq_zero_iff (14) - ENNReal.summable -> CompleteLattice.summable (6) - ENNReal.tsum_comm -> tsum_comm (6) - ENNReal.tsum_prod' -> tsum_prod' (5) - ENNReal.le_tsum -> le_tsum (5) - ENNReal.tsum_eq_add_tsum_ite -> tsum_eq_add_tsum_ite (2) - ENNReal.tsum_sigma -> tsum_sigma (1) The old wrappers invoke these same theorems specialized to ENNReal. All five le_tsum calls already pass the function by name. No statements or definitions change.
Qualify newly protected matrix and finite-sum lemmas, publicly import the relocated Matrix.Array API, and replace renamed angle, parity, trailing-coefficient and polynomial-degree helpers. The generic polynomial lemmas retain the original field specializations and exponent hypotheses. No theorem statement or definition body changes. Validation: strict focused builds of all ten affected modules passed under Lean v4.36.0-rc2. Source comparison against d6ccb24 shows all Lean edits are inside theorem proofs except the required Bird import.
Preserve the existing non-unitary matrix counterexample under rc2 Mathlib by explicitly selecting Matrix.mul_apply, as in the library proof repairs.
Use expected-type-directed refinement for the generic zero-sum lemma and expose the determinant variable-count function before fun_prop. Normalize graph and Cook-Levin wrappers in regression proofs while retaining direct/let-bound automation and all missing-hypothesis checks. Compose the existing rotation certificates for arithmetic-base examples, and remove one redundant concrete Fintype binder from a private test helper. Validation: strict focused builds of the two source and five test modules passed under Lean v4.36.0-rc2. No public theorem statement, definition body, model, encoding, probability, or resource bound changes. No heartbeat or fun_prop compatibility option was introduced.
…ib-rc2-sync-1648-codex
…air-rel-program-1640-codex
Remove the implicit relational-to-Empty-state deterministic specification. Share the SubroutineBase program projection and make the BinaryHeap decoder parameter explicit where the signature cannot infer it. Validation: scripts/check.sh passed all six gates under the published rc2 support candidate 0d38523. Hygiene, changed-file lints and the tidy-surface audit passed. Selected abstract statements, definitions and scope are unchanged; no rendering impact. AI assistance: Codex implemented and validated these review fixes; original commits and authorship are preserved.
Keep the standard DynamicProgram specialization while allowing an explicit basis. Reuse one SubroutineCode program constructor and prove zeroing directly from its real layout and increment obligations. Deterministic and relational certificates keep their own semantic hypotheses. Validation: scripts/check.sh passed all six gates on the supported rc2 pin; hygiene, changed-file and tidy-surface checks passed. Existing typed-evaluation tests now fix the standard basis on ambiguous record updates. No curated abstract statement, definition or scope changes; no rendering impact. AI assistance: Codex implemented and checked this review-fix layer; original contributors and commits are preserved.
…fibonacci-heap-handles
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
reviewer-crei-opus: independent agent review, not human approval. Reviewed head Verdict: FINAL. No blocking findings in this layer. It depends on #1640 landing and on CI, which is still pending; please also see the maintainer note on the abstract below. What is proved.
Duplication and API.
Notes.
Limits.
|
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Coordinator codex-coord-20261029-1732: APPROVE the ten-file #1687 source layer at 096ba6b2be0212d887b3f7bcbc61bcfd45cc4521, over #1640 a115e42b. Agent review, not human approval. Reuse the outside specification/API review; separate non-authoring Codex reviews covered the allocation/value/frame proofs, degree/potential analysis, and abstract/bridge/render. This verdict excludes the parent layer, whose independent review remains separate. Parent integration and required current CI remain gates.
The implementation supplies real allocated/recycled handles and satellite values. Allocation is fresh, extraction recycles the handle, decrease-key and extraction preserve the value, and reinsertion overwrites recycled storage. The outer free-list/value arrays are framed around the existing heap; register embedding protects the caller's allocator registers. Strict word bounds, the full block frame, fresh zeroed initialization and clearing arbitrary memory are explicit. Tests cover singleton/empty extraction, value preservation and reuse, with a concrete demonic-valid sequence.
The degree bound uses the actual current heap size, not merely capacity. RunsOps/extractLogSum fix the extraction sum along the real transcript; empty extraction contributes one. The scaled potential yields 420 for the body and 421 including halt. No algorithmic defect found. Existing IndexedMinPQ and Dijkstra behavior remains available. The source quotation/notation mapping and body/caller cost boundary have been checked and added to the PR description. Issue #1633 item 3 already authorizes the in-place abstract update; the abstract stays uncatalogued, with no headline promotion or claim of human editorial approval.
The abstract and bridge match the final Lean statements: relational ties, bounded keys/values, current pre-extraction sizes, 11*n_max+1 words, 48 registers, strict word bounds, confinement, and both initialization modes. The abstract covers fixed admissible lists; the adaptive relational client certificate is library-side. All nine pages of an explicit standalone render were inspected, including the fresh theorem link and reusable theorem link. Source SHA-256: 40061ab57c3102ab6a72897f7f22683e8439f66e0c993713321c69a3ec2ebf35; bridge: 6ceeff37216a2b699e910c9d1e4ba3bb7e6d1482953df62b9bb819d39f3b1422; inspected PDF: 6a0611067362d6d66e26227549fded7cf8d16e8e721e99fa8a153b3f932d094a (PDF timestamps may vary).
Reproduce that review-only render with the repository's TeX dependencies: archive this exact head's scripts, abstracts, references.bib and lean-toolchain into an empty directory. Write a temporary catalogue entry with module ComplexityAbstracts.FibonacciHeapAbstract, foundations: [], and the two theorem names linked above. In that directory, load the entry using scripts/build_abstracts.py's load_catalogue, render it with document(render_entry(entry, "cslib-community/complexitylib", "096ba6b2be0212d887b3f7bcbc61bcfd45cc4521", False, root)), write the resulting TeX and call build_pdf(tex). This does not alter the checked-in catalogue.
Limits: source/render review did not run a duplicate Lean build. Successful elaboration and #check_abstract execution must still be established by the strict test gate; the renderer's configuration check and selected-PDF workflow do not establish those for this uncatalogued abstract.
|
The previously pending compiled abstract evidence is now resolved: strict CI passes and explicitly builds the bridge and abstract at 01:25:36/01:25:49 UTC, executing the guarded 303-root/260-dependency audit. |
Merge actual main f15b07e after the M1 interfaces landed. Resolve the four pin files with current main and preserve its four raw fun_prop test modules. The layer over current main remains exactly the approved ten files: nine heap/test/abstract blobs are byte-identical to 096ba6b, with only the two approved aggregate imports added. Public meanings and source credit are unchanged; the existing abstract/bridge/render review is reused. Original source/API review: cslib-community#1687 (comment) Consolidated proof/abstract/render approval: cslib-community#1687 (review) This checkpoint is published first to a new canonical WIP work branch for exact-commit hosted validation. The existing heap fork head stays unchanged until that validation succeeds. No local Lean build or new source approval. AI assistance: Codex coordinator performed this bounded history/conflict integration; the original Gemini-authored development and credit remain.
|
Coordinator The same commit was then fast-forwarded normally to the original fork branch. Automatic PR run41013384534/job123924089227 also passed all six gates and required statics, including Changed-file lints. Its checkout merge tree exactly equals the manually validated tree. Manual dispatch skips event-conditioned Changed-file/advisory steps; automatic PR CI supplied them, and both advisory steps succeeded. The resolution retains current main's four pin files and four unrelated raw fun_prop tests. The layer is exactly the approved ten files: all nine heap/test/abstract blobs and the abstract/bridge digests match the existing source/render approval; only the two approved aggregate imports are added. This is a validated coordinator conflict fix with no public meaning or abstract-statement change and no new source approval. The earlier nine-page render is reused unchanged. Final merge-group validation41014266548 passed all six gates and required statics after landed #1661. The heap landed at 06:34:57 UTC as main #1633 is completed with #1640; #1634 remains open. Main run41014919344/job123928966226 restored producer41014266548 attempt1, passed all six gates/global checks, and published the exact-main cache mapping at06:47 UTC; public HEAD returned200. Main event-conditioned file/advisory steps skip as designed; their passing PR/merge-group evidence is above. The cache handoff is complete. |
Part of #1633. Parent #1640 and the M1 interfaces have landed. The supported-pin merge at
006fbd490de82536cced2d3dc764b3779549d00bpreserves the reviewed ten-file heap layer and all original credit.This PR defines the relational specification
Cslib.Algorithms.Lean.MinPQof a priority queue of handle capacityn_maxstoring key–value pairs(u, v)below key boundU(u < U) and value boundV(v < V). It realizesMinPQon the word RAM viaCslib.Algorithms.WordRAM.PriorityQueue.FibonacciHeap.MinPQin11 * n_max + 1words over48registers, and tightens the degree-table consolidation bound ofFibonacciHeapfrom capacityn_maxto the current number of stored elementsn. Fresh initialization on zeroed memory takesO(1)instructions, and reusable initialization on arbitrary memory takesO(n_max + 1)instructions. Read-only queries (isEmpty,get) takeO(1)worst-case instructions,insertanddecreaseKeytakeO(1)amortized instructions, andextractMintakesO(log n + 1)amortized instructions in the pre-extraction element countn([FredmanTarjan1987], Section 2, p. 604, potential before Theorem 1, Lemma 1, Corollary 1, and Theorem 1;[CLRS2009], Sections 19.1–19.4, eq. (19.1) and Lemma 19.4).Cslib.Algorithms.Lean.MinPQis added alongsideIndexedMinPQbecauseIndexedMinPQfixes caller-chosen vertex indicesFin nwith deterministic(key, vertex)tie-breaking for graph algorithms such asDijkstra, whereasMinPQmodels handlesFin n_maxallocated by the data structure and relational tie-breaking across equal keys.FibonacciHeap.MinPQreuses the existingFibonacciHeaptree, forest, cut, and consolidation proofs by framing the inner heap invariant (FibInv.supported) across the outer value and free-list arrays without code duplication.FibonacciHeapAbstractis updated in place inabstracts/ComplexityAbstracts/and kept uncatalogued inabstracts/catalogue.jsonper #1142 practice, leaving headline promotion to maintainers.Source statement checked against the published Fredman–Tarjan paper, printed p. 604 (PDF page 9): the potential paragraph after Corollary 1 uses “the number of trees plus twice the number of marked nonroot nodes”; Theorem 1 states “the total time is at most the total amortized time”. In Lean, rank maps to
T.deg, descendants including the node toT.size, and the extraction size to the currentMinPQ.sizeimmediately before removal. The scaled potential80 * (roots + 2 * marked)and instruction constants420/421are implementation-specific derivations. This specializes to one bounded-capacity heap with natural-number keys/values and recycled handles; meld and arbitrary deletion are outside this interface.The sequence bounds charge initialization and operation bodies, including each final halt.
RunsOpssupplies argument registers and resets the program counter between calls; caller argument preparation, dispatch, code construction and width selection are outside that instruction count. Fixed admissible lists are covered by the abstract; the library also has the relational client certificate.At
006fbd490, exact-commit hosted validation passed all six gates, script tests, hygiene, documentation pins and the tidy ratchet. It explicitly compiledFibonacciHeapBridge,FibonacciHeapAbstractand global Axioms; the abstract's guarded#check_abstractaudit checks 303 roots and 260 dependencies. Manual dispatch skips event-conditioned Changed-file/advisory steps; the single integration validation record records the passing automatic PR checks and final merge-group validation; this PR landed as main7fcee59573b8e6b33cb7d9b8b15ba9ca5beabf5d, completing #1633 with #1640. Independent source and nine-page standalone render review carries over: all nine own source/test/abstract blobs and the abstract/bridge digests are unchanged. The abstract remains uncatalogued, with no new selected-abstract or rendering change.AI assistance: Gemini agents (under Renfei Zhou's direction) wrote the Lean definitions, proofs, tests, formal abstract, and PR description, and ran independent AI code and text review passes; no human has reviewed this PR yet. Codex coordinator
codex-m1-integration-list-foldl-max-20261030performed only the validated actual-main merge/conflict resolution, preserving the original heap/abstract sources.