Repository navigation
feat(Algorithms/WordRAM/Dictionary): open-addressed linear probing with 5-wise independent hashing - #1708
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.
…lation hashing programs
… stack-base-1646-1686-r1
… randomized Word RAM
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.
edemaine
left a comment
There was a problem hiding this comment.
reviewer-codex-edemaine (independent agent review, not human approval), exact head bc61368a8eebeb75dc85c11f1b804147908a78c8: changes requested for the source record below.
The PR cites Pagh–Pagh–Ružić (2009) as the result being formalized, but provides no checked source statement, exact theorem/page locator or pinned source version. The repository's “New statements and definitions” rule requires that record. Please add the source statement and map its quantifiers/model to these declarations: uniform 5-wise hashing, fixed seed-independent history, load ≤ 1/8, probeLen counting skipped occupied slots (the stopping inspection is additional), and executable body charge including KWise evaluation. Label the constants 288/3483 and any new proof argument as original adaptations where appropriate, and distinguish the insert-only specialization from source deletion support. A bibliography entry alone does not supply this mapping; no stronger theorem is requested.
I read the complete five-file own layer over the reviewed #1646/#1686 heads and their clean merge. No mathematical or operational blocker found: the conditioned fourth-moment calculation, cluster witness excluding the query key, uniform seed marginal, initialization, bounded insert/update/get code and charged-body sequence theorem fit together. Concrete capacity/word-width instances and operation traces are nonvacuous. No curated-abstract impact.
Lean CI was running when inspected; title and diff-whitespace checks passed. No local Lean build. Live head rechecked before posting.
…ors, and model mapping
|
Updated in
|
edemaine
left a comment
There was a problem hiding this comment.
reviewer-codex-edemaine (independent agent review, not human approval), exact head ae034db16c733f2b8d6ce082f2ca9f81fb7097a9: approve. The source-record finding in my earlier review is resolved; its mathematical/API coverage carries forward.
I read the complete two-file documentation delta and updated PR mapping and verified that Lean code is unchanged. Checked Lemma 2.1, the occupied-run argument in Lemma 4.1, and Theorems 4.3/4.5 against the author’s journal manuscript (§2.3, pp. 4–5; §4, pp. 8–10, 12). The mapping now identifies exact uniform 5-wise hashing, fixed seed-independent histories, load ≤ 1/8, insert-only scope, skipped-slot counting versus the charged stopping inspection/hash evaluation, and the original dyadic adaptation/constants 288 and 3483. Publisher page numbering could not be independently confirmed. The corrected initialization bound agrees with KWise.initTableSteps; no curated-abstract impact.
Lean CI was running when inspected; title and diff-whitespace checks passed. No local Lean build. Live head rechecked immediately before posting.
|
Merged
|
edemaine
left a comment
There was a problem hiding this comment.
reviewer-codex-edemaine: APPROVE at 92a5c285dfd394229c0b7c6a485dc3e6488bb2da (independent agent integration-delta review, not human approval). Reuse my full mathematical/API review and resolved source-record review.
Both main merges preserve the reviewed linear-probing implementation, FiveWise analysis and concrete tests byte-for-byte. Against merged main d0d220c930881f5032a8b5ce8990c5523692ea13, the entire own layer is exactly those three files, their two aggregate imports and the unchanged bibliography entry. Main's pins, automation fixtures and other source files are retained. The fixed-history, load ≤ 1/8, insert-only body-cost scope and original constants remain unchanged; no curated-abstract/rendering impact.
git diff --check passes. Exact-head Lean CI 41025607198 was running when inspected; title CI passes. Required validation remains before integration. No local Lean build was run. Live head rechecked immediately before posting.
|
Coordinator Hosted manual run41030288233/job123978150225 checked out that exact commit and passed all six gates, script tests, hygiene, documentation pins and tidy ratchet. The owned linear-probing tests are in the strict test log. Manual dispatch skips event-conditioned Changed-file/advisory steps; those still require fresh automatic PR CI after any later authorized normal fork fast-forward. The current outside review carries over via exact source identity. Model/resource/source documentation, original authorship and abstract scope remain unchanged; no new mathematical approval is claimed. Parked at the coordinator's requested handoff: original fork head remains |
|
Merged |
edemaine
left a comment
There was a problem hiding this comment.
reviewer-codex-edemaine: APPROVE at 33cda07d0c281831f8032bfb1a23ba13ebc577e9 (independent agent delta review, not human approval). Reuse my previous delta review and its linked mathematics/source coverage.
The main merge preserves all three approved Lean source/test files byte-for-byte. The complete layer over 311e9841f226f46b27d8811a4678674347bfc958 is those files, their two aggregate imports and the unchanged PaghPaghRuzic2009 entry. The bibliography conflict retains main's PaghRodler2004 entry in key order; all other main files are retained. No changed model/resource or curated-abstract scope.
git diff --check passes. Exact-head Lean CI 41033209475 was running when inspected; title CI passes. Author reports all six local gates and hygiene passing; no local build was duplicated. Required hosted checks remain before integration. Live head rechecked before posting.
|
Coordinator The exact main/cache handoff succeeded, restored its queue producer, passed all six gates and applicable audits, and published a publicly retrievable cache mapping. The later verified #1696/#1698 descendant retains this payload too. The fixed-history, load≤1/8, insert-only body-cost scope remains; no selected-abstract impact. Broader #1634 stays open. Original authorship is preserved. |
Part of #1634.
Summary
Formalizes an open-addressed linear-probing dictionary ($k = 5$ ).
Cslib.Algorithms.WordRAM.Dictionary.LinearProbing) forDictionary.spec U V n_max(universeU, value boundV, capacityn_max) on the randomized Word RAM (SubroutineDS), reusingHashing.KWise(isKWiseIndependentHash_trinomialPolyHash,Adapts Pagh, Pagh, and Ružić, Linear Probing with Constant Independence, SIAM J. Comput. 39(3):1107–1120, 2009 ($O((1 - \bar{\alpha})^{-5/2})$ and $O((1 - \bar{\alpha})^{-13/6})$ ($O(1)$ at load $\bar{\alpha} < 1$ ) expected probes per operation.
[PaghPaghRuzic2009]). Section 2.3 (Lemma 2.1, pp. 1110–1111) bounds interval occupancy under 5-wise independence by conditioning on a key's hash and applying a centered 4th-moment bound. Section 4 (Lemma 4.1, Theorems 4.3 and 4.5, pp. 1114–1118) provesSource mapping:
hashFn U n_maxis uniform 5-wise independent (isKWiseIndependentHash_hashFn) intoM = tableLog n_max, loadspace_le). Zeroed{0, 1}flags representDictionary.empty U(tableInv_empty) for insert-onlyDictionary.spec U V n_max. Each probe halts inTableInv.probeLen_le_n_max).288): For queried keyuand stored keysS = (Dictionary.dom s).erase u, anyS(HasClusterWitness,TableInv.hasClusterWitness_probeLen, adapting Lemma 4.1). An original adaptation atscaleWindow). Conditioned 4-wise independence (IsKWiseIndependentHash.expect_prod) bounds scale-$j$ overload byexpect_scaleOverload_le), summing toexpect_probe_le_of_cluster_witness,tsum_uniform_probe_le_of_cluster_witness,tsum_probeLen_le).3483):TableInv.probeLencounts skipped occupied slotst. Probe setup (probeLoopoverget/insertfinish (opCode_execWithin). AddingKWise.evalCode 5gives the original chargecharge U n_max = KWise.evalSteps n_max U (tableLog n_max) 5 + 3483 = O(L^2 + 1)(L = KWise.limbCount n_max U (tableLog n_max)). For fixed(U, V, n_max), widthw, zero runtime initialization parameters (initParams = Fin.elim0), and seed-independentops(ValidHistory),initFresh(3 + setupTime U n_max) andSubroutineDS.ExecStepssatisfyseq_expected_amortized.Scope
Covers self-contained initialization and expected$O(1)$ -probe
getandinsertonBasis.exact(subroutineDS) andBasis.standard(subroutineDSStandard).Validation
Local validation (
scripts/check.sh,check_hygiene.py --check-simp,check_tidy_surface.py,check_changed_files.py, andbuild_abstracts.py --check) passes.AI assistance: Gemini agents (under Renfei Zhou's direction) wrote the Lean definitions, proofs, tests, bibliography entry, and PR description; no human has reviewed this PR yet.