Repository navigation
feat(Algorithms/WordRAM/Dictionary): chained hash table with expected O(1) lookup and insertion - #1690
Conversation
…eBase and drop aliases
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
…air-random-subroutine-1646-codex
Initialize and preserve the source register at one, requiring 1 <= w, so each native rand samples Fin 2. Check exact half-probabilities on a concrete represented state, certify the native caller sample, and exercise initialization plus two operation bodies with expected cost at most four. Existing relocation, framing, initialization and composition clients now use the nondegenerate certificate. Validation: LEAN_NUM_THREADS=2 lake env lean -DwarningAsError=true ComplexityTests/WordRAMRandomizedSubroutine.lean; git diff --check. The targeted strict build reaches the tests but reports pre-existing rc2 ENNReal deprecation warnings in Randomized/Expected.lean and Randomized/Subroutine.lean; the parent worker owns their migration and full six-gate validation after stacking the shared API repair. No curated statement, scope or rendering changes. AI assistance: OpenAI Codex implemented this bounded review-fix patch and checked the test file.
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.
…air-random-subroutine-1646-codex
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.
…air-random-subroutine-1646-codex
…ty APIs Remove surrogate deterministic zeroing and copied argument delivery in favor of the actual basis-preserving SubroutineCode/DynamicProgram APIs. Share the register extension identity across all three rename clients, move general expectation laws to PMF.Expect and reuse Mathlib measure and finite-sum facts. State the fixed-list initialization/body-only cost model and externally delivered arguments. Correct expectation/geometric background locators and migrate deprecated ENNReal names on the supported rc2 pin. The separate test commit checks actual Fin 2 native draws and exact half-probabilities. Validation: default scripts/check.sh passed all six gates; hygiene, changed-file lints against the shared a115e42 layer, and the tidy-surface audit passed. No selected abstract definition, statement or scope changes; no rendering impact. Original geometric/native mathematics is unchanged. AI assistance: Codex implemented and validated the bounded review fixes, preserving all original commits and source credit.
… O(1) lookup and insertion
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 #1646 landing and on CI ( Is the expected-cost statement meaningful? Yes.
Reuse and duplication.
Nits (not blocking).
Tests. The description covers:
I checked the theorem statements but not the 283-line test file in detail. Limits.
|
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Coordinator codex-coord-20261029-1732: changes requested in the model/cost documentation, with the implementation and collision proof otherwise clear. This supplements the existing independent statement review; scope is only the three-file layer over fb42ef60e, not its parent stack. Agent review, not human approval.
Please qualify the module introduction, seq_expected_amortized docstring and PR description together. The program is specialized to fixed U/n_max; bucketBits, hashBits, masks and layout values become instruction literals (initParams = Fin.elim0). Width is an external admissible execution parameter. Initialization and operation bodies have the proved cost; computing configuration/code, supplying operation arguments and running a whole caller/dispatch loop are outside it. The operation history is fixed independently of the sampled seed (oblivious). Suggested scope: “For fixed universe/capacity and an admissible machine width, the specialized program uses precomputed configuration literals. The expected bound charges initialization and operation bodies for a history independent of the seed, excluding argument delivery, caller control and code/configuration construction.” This preserves the theorem and makes the advertised bound inspectable.
Supplemental implementation/PMF review checked the terminating one-based chains, fresh-slot allocation versus update at capacity, value encoding and memory frames; actual uniform odd-seed initialization and preservation of its marginal; 55 + 9·collisions and the resulting expected charge 73; basis transport; and the forced-collision/full-update/miss tests. Those tests use real ExecWithin witnesses and certificate composition, not literal Code.eval runs. No implementation defect found. No local build was duplicated; hosted strict tests are still pending. Add the abstract no-impact assessment. The existing optional source-locator/insert-only documentation suggestions remain useful; a module split is not a merge requirement.
… insert-only pool, and CLRS locator
|
Fixed in
|
|
reviewer-crei-opus (agent review, not human approval). Delta review. Verdict: FINAL. Head The delta is one commit,
The optional file-split nit is not taken up, which is fine. There are no regressions. Limits: I ran no Lean build, so hosted CI on this head is the build evidence. The #1640/#1646 base layers are covered by their own reviews. |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Coordinator codex-coord-20261029-1732: independent agent APPROVE at 21ca308c22b7ab6814d64d61cd926645b8c1f125, not human approval. Reviewed the full documentation delta from 0a826821; unchanged implementation/PMF coverage from my earlier review and the outside delta FINAL carries forward.
The requested model/cost clarification is resolved consistently in the module, sequence theorem docstring and PR description: fixed U/n_max with precomputed literals and external admissible width; oblivious histories independent of the seed; initialization plus operation-body costs excluding argument delivery, caller control and configuration/code construction. Insert-only allocation and the analysis citation are explicit, and the abstract no-impact assessment is present. No statement, definition, proof or test changed; whitespace checks pass. The optional file split remains optional.
The stack is still based on the older parent ancestry; #1640/#1646 integration, final source/parent identity and required current CI remain before merge. No duplicate Lean build was run.
|
Coordinator The author’s source refresh at Exact-head delta approval reuses the whole-layer/model review and outside FINAL. No public meaning, cost convention or selected-abstract/rendering change was introduced. Source credit remains with the author; this is agent review, not human approval. Main validation/publication41021497128 succeeded. The log confirms restoration of producer41020958063 attempt1, all six gates/required scripts, zero |
|
Merged
|
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Coordinator codex-coord-20261029-1732: approve the integration delta at 49cf5878c399dbcc1b519908a418ddfcf1f0fca3. Reuse my whole-layer/model review and the outside FINAL; this is agent review, not human approval.
The author’s normal main merge keeps exactly the original three-path layer on actual landed M1/main 7fcee595: ChainedHash and its tests are byte-identical to reviewed 21ca308c, with one canonical aggregate import. All other main files—including current pins and the four raw automation fixtures—are retained. A clean merge after the current audit candidate preserves the same two source blobs and adds only that import. No public meaning, model/resource convention or selected-abstract/rendering scope changes.
Current-head CI41018965256 passed all six gates and Changed-file lints. The source implementation remains the author’s work; no duplicate local Lean build or fresh whole-mathematics review was run. #1634 remains open.
Part of #1634.
This pull request adds
Complexity/Algorithms/WordRAM/Dictionary/ChainedHash.lean(Cslib.Algorithms.WordRAM.Dictionary.ChainedHash), which formalizes a chained hash table ([CLRS2009], Sections 11.2 and 11.3.3, Theorem 11.3 and Corollary 11.4) for the bounded-capacity dictionary specificationCslib.Algorithms.Lean.Dictionary.spec U V n_maxon the randomized Word RAM over the exact instruction basisBasis.exactand the core instruction basisBasis.standard.Design and results
Fin Uand capacity boundn_max, the table usesnumBuckets n_max = 2 ^ MwithM = bucketBits n_max = Nat.clog 2 (max n_max 2), keeping load factorw₀ = hashBits U n_max = max M (Nat.clog 2 (max U 2))whenever2 * w₀ ≤ wandbase + space n_maxandVfit in aFits w). The contiguous block[base, base + space n_max)usesspace n_max = 4 + 2 ^ M + 3 * n_max ≤ 5 * n_max + 8words (space_le) for a 4-word header,0= empty), and ann_max-slot bump-allocated node pool (key,val,next).initSetupcallsMultiplyShift.initCode w₀(oneInstr.randinstruction) to sample a uniform odd multiplier seedb : Fin (2 ^ (w₀ - 1))and writes the header in13steps total (initFreshtakes16steps on zeroed memory;initCleartakesopCodehashes keys viaMultiplyShift.evalCode w₀ Mand traverses the bucket chain viafindInChainin at most55 + 9 * collCount n_max s (opKey o) bsteps (opCode_spec). By(2 / 2 ^ M)-universality of multiply-shift hashing (isUniversalHash_multiplyShift, [DietzfelbingerHagerupKatajainenPenttonen1997], Lemma 2.4), expected collisions are at mostexpect_collCount_le_card_mul,expect_collCount_le_two), givingSubroutineDScertificatessubroutineDSandsubroutineDSStandardwith uniform seed preservation (seedSlack = 1), zero potential (potential = 0), per-operation body chargechargeVal = 73, and sequence boundseq_expected_amortized.Scope
For fixed
Uandn_maxand admissible word widthw,subroutineCode U n_maxbakes configuration parameters as instruction literals with no runtime initialization arguments (initParams = Fin.elim0), andseq_expected_amortizedcharges initialization and subroutine operation bodies across an oblivious operation sequenceops. The specificationDictionary.spec U V n_maxsupportsgetandinsertwith sequential bump allocation and leavesabstracts/unchanged (scripts/build_abstracts.py --check); local validation (scripts/check.sh) passed on49cf5878c399dbcc1b519908a418ddfcf1f0fca3.AI assistance: Gemini agents (under Renfei Zhou's direction) wrote the Lean definitions, proofs, tests, and PR description; no human has reviewed this PR yet.