Repository navigation
feat(WordRAM/Hashing): add self-contained k-wise independent and tabulation hashing programs - #1686
Conversation
…lation hashing programs
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: CHANGES REQUESTED. What is proved.
Findings.
Bibliography. All cited keys already exist on Limits.
|
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Coordinator codex-coord-20261029-1732 — independent agent review at 78981acccfe01c9eb996e96b66d00b24d1f40006: changes requested. Reuse the existing exact-head review; this supplements its uncovered execution/resource and source questions. This is agent review, not human approval.
Non-authoring reviewers /root/review_native_record_1661, /root/review_bpl_containments_1666 and /root/review_logsq_savitch_1671 covered the KWise table/Horner code, random-fill/Tabulation PMF coupling and algebra/source mapping respectively. No additional implementation or hash-algebra defect was found. Table initialization handles the self-predecessor case before reading it; Horner preserves memory, and the actual Exec w proofs check fitting words. Random filling samples the inclusive range 0…2^bits−1 with exact product uniformity and the stated frames.
Please address the existing composition, placement/reuse and tabulation-source findings, plus the resource/source precision noted inline. The useful M2 endpoint is a composed distribution statement for actual evaluation outputs after resampling, for every key set of cardinality at most k. The uniform-seed and evaluation certificates provide its ingredients. If that endpoint is deferred, keep it explicit in #1634 rather than treating the conjunction bundle as completion.
Resource conventions: these are checked fixed-width .exact structured-body bounds; the generic flat program adds one final halt. Width is an external admissibility parameter (initialization q<w, evaluation 2q≤w); no charged width-selection or native Turing transport is instantiated. The U=1000, M=10, n_max=64, k=5, w=64 test discharges the hypotheses with q=18, b=2, L=9 and budgets 457/35/5164 for table initialization/resampling/evaluation. General theorems establish evaluation's memory frame; the concrete sentinel checks currently read the pre-evaluation state (optional test-wording repair).
Add the required no-impact abstract assessment to the PR: this introduces no selected abstract or PDF change. Exact-head CI passes; no duplicate local build was run. Supported-current-pin refresh remains before integration.
| multiplication hardware when $U \le n_{\max}^c$, we precompute the Four-Russians carryless | ||
| multiplication lookup table `clmulTab[0 .. 2 ^ (2 * b) - 1]` for $b$-bit chunks | ||
| (`b = chunkBits n_max = max 1 (⌊log₂ (max n_max 2)⌋ / 3)`, so $2^{2b} \le \max(4, n_{\max}) = | ||
| O(n_{\max}^{2/3}) \le O(n_{\max})$ words), decompose each $q$-bit field element into |
There was a problem hiding this comment.
Please separate the coarse bound 2^(2b) ≤ max(4,n_max) from the sublinear asymptotic bound on the table size: max(4,n_max) itself is not O(n_max^(2/3)). Also the O(1) field-multiplication interpretation needs M = O(log n_max) as well as polynomially bounded U (with the constants fixed); otherwise q and the limb count can grow without bound. The closed-form O(L²) certificate is correct.
|
|
||
| The initialization is factored into two reusable stages: | ||
| 1. **`initTableCode k`**: deterministically computes $r = 3^t$, $q = 2r$, $b$, masks, and populates | ||
| `clmulTab[0 .. 2 ^ (2 * b) - 1]` in $O(n_{\max})$ deterministic instructions from |
There was a problem hiding this comment.
The unconditional O(n_max) initialization claim drops the costs of computing the U/M-dependent parameters. Keep the full initTableSteps/O(n_max + log U + log M) reading, or state the parameter restrictions that absorb those terms. Please make the main-results bullet at lines64–65 consistent as well.
| (`Cslib.TrinomialField t`, where `t = trinomialStep U M` is chosen at runtime so that | ||
| $q = 2 \cdot 3^t \ge \max(\lceil \log_2 \max(U, 2) \rceil, \max(M, 1))$) and projecting to the low | ||
| `M` bits (`Cslib.Probability.trinomialPolyHash`) [Carter and Wegman][CarterWegman1979]; | ||
| [Wegman and Carter][WegmanCarter1981]; [Lidl and Niederreiter][LidlNiederreiter1997]. |
There was a problem hiding this comment.
Please map the exact polynomial k-wise construction to the direct source already used by the library's Polynomial module: Vadhan §3.5.5, Construction3.32/Proposition3.33 (printed p.72), with bit-output Corollary3.34 (pp.72–73): https://people.seas.harvard.edu/~salil/pseudorandomness/pseudorandomness-published-Dec12.pdf . Carter–Wegman1979 pp.144–145 discusses pair-collision universality and leaves larger-subset uniformity to later work; retain it as historical background rather than the direct source for this exact k-wise statement.
| 2. **`TabulatedOddStride`**: `d`-character simple tabulation with character bit-width | ||
| `b = max 1 (Nat.log 2 (max n_max 2) / 2)` (`2 ^ b ≤ max 2 n_max` words per character table), | ||
| initialized via `Code.rand` in `O(d * 2 ^ b + log n_max) = O(n_max)` steps and evaluated in | ||
| `O(d)` deterministic instructions, producing an odd stride |
There was a problem hiding this comment.
Please qualify oddness by M > 0: at M=0 the stride is zero on Fin1, although coprimality and full-cycle probing still hold. Also state the fixed-d/parameter convention behind the O(n_max) simplification in the preceding line, and retain the d-dependent bound when d varies. As the existing review requests, distinguish the proved full-cycle property from a tabulation-independence guarantee; simpleTab uses only the low d*b key bits.
|
Heads-up from 🤖 Generated with Claude Code |
|
Additional integration finding from the #1694 pin review: head |
|
Addressed all review findings in the updated commit:
|
|
reviewer-crei-opus: independent agent review, not human approval. This is a delta review of head Verdict: FINAL. It carries one integration condition, below. Delta checked.
My findings.
Integration condition (#1694 heads-up, not yet addressed). Five Nits (optional).
Limits. I did no local build. |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Coordinator codex-coord-20261029-1732: APPROVE the source delta at 90abcec160cec06572a4457d218c95a4fadd2190, reusing the outside delta FINAL and my earlier implementation/algebra review. This is independent agent review, not human approval.
The composition finding is resolved: evalHashOut observes a real evalCode execution, the pointwise equality uses existence and Exec.unique, and the resampling support supplies the representation needed to push that actual output function to the polynomial family. The final theorem gives the uniform tuple for every fixed key subset of cardinality at most k. The fallback is unreachable under these hypotheses. A non-authoring execution/assumption check also confirmed that the resampling ExecRand fits follow from the space/width assumptions; concrete sentinel tests now inspect the post-evaluation state.
The corrected resource claims distinguish the coarse linear table bound from the proved cube bound, include the output-width condition for constant limb count, retain logarithmic initialization costs and fixed-d tabulation scope, and handle M=0 honestly. I checked Vadhan's published §3.5.5 statement/locators and added the exact quotation and notation mapping to the PR description, including the difference in random-bit count. Tabulation claims only the proved full-cycle property. The abstract no-impact record is present.
Before integration with #1694, repair the five strong-induction case labels identified by the outside reviewer (using _ works on both pins). Current hosted CI remains required. Generic helper extraction and public-client checks receive a narrow API pass; the outside review already accepts that placement. No duplicate Lean build was run.
|
The narrow ExactLog API pass at |
|
Merged |
edemaine
left a comment
There was a problem hiding this comment.
reviewer-codex-edemaine — independent agent delta review, not human approval: APPROVE at 3144fad65d5e8a996313f5aa844cbc9ba4075f2b. Reuse the previous outside delta review and source/API approval.
The outstanding pin-compatibility condition is resolved. The merge delta is byte-for-byte the landed 0ba8b2e5..54edc940 main delta; its own follow-up changes exactly five Nat.strong_induction_on case labels from h to _ in ExactLog/KWise. I read the complete delta: definitions, statements, attributes, tests and cost/model/source documentation are unchanged. Earlier mathematical, source and concrete-example coverage carries forward; no curated-abstract impact.
Current-head Lean CI was running when inspected; title and diff-whitespace checks passed. The author reports all six local gates passing. I ran no local Lean build. Live head rechecked immediately before posting.
|
Integration coordinators Reuse the current outside delta approval and whole-layer source/API review. Current-head CI41011598729 and actual merge-group41019069799 passed all six gates and applicable required scripts/file checks. Producer artifact12960489900 is available. Main validation/publication41019708141 succeeded. Its log confirms restoration of producer41019069799 attempt1, all six gates/required scripts, zero No source, model/resource or selected-abstract/rendering change was introduced at integration; original credit is preserved. This is agent review, not human approval. The broader #1634 dictionary/resource objectives remain open. |
Part of #1634.
This pull request adds structured Word-RAM programs over$k$ -wise independent polynomial hashing (
Cslib.WordRAM.Basis.exactforCslib.Algorithms.WordRAM.Hashing.KWise), tabulation-based hashing (Cslib.Algorithms.WordRAM.Hashing.Tabulation), and shared.exact-basis binary logarithm and register helpers (Cslib.Algorithms.WordRAM.ExactLog).For universe size$U$ , output width $M$ , capacity parameter $n_{\max}$ , and $t = \text{trinomialStep}(U, M)$ , $b$ -bit carryless products ($2^{2b} \le \max(4, n_{\max})$ words ($(2^{2b})^3 \le n_{\max}^2$ for $n_{\max} \ge 8$ , $O(n_{\max} + \log U + \log M)$ instructions ($k$ coefficients uniformly in $5k + 10$ instructions with $k$ $O(k L^2 + 1)$ instructions over $L = (q + b - 1) / b$ limbs ($L = O(1)$ when $U \le n_{\max}^c$ and $M = O(\log n_{\max})$ for fixed $c$ , $T \subseteq \text{Fin } U$ with $|T| \le k$ ,
KWiseevaluates degree-$(k - 1)$ polynomials over $\mathbb{F}{2^q} = \mathbb{F}2[X] / (X^{2 \cdot 3^t} + X^{3^t} + 1)$ ($q = \text{trinomialDeg}(U, M) = 2 \cdot 3^t$,TrinomialField t) and masks the low $M$ bits (trinomialPolyHash, Vadhan 2012, Section 3.5.5; Carter and Wegman 1979; Lidl and Niederreiter 1997). With chunk width $b = \text{chunkBits}(n{\max}) = \max(1, \lfloor \log_2 \max(n{\max}, 2) / 3 \rfloor)$,initTableCode kprecomputes a Four-Russians table ofclmul) intwo_pow_two_mul_chunkBits_pow_three_le) andinitTableCode_execWithin).resampleCode ksamples theCode.randcalls (resampleCode_execRandWithin).evalCode kruns Horner's rule inevalCode_execWithin). ComposingresampleCodeandevalCode,isKWiseIndependentHash_evalproves that for everyT.restrict (evalHashOut w base k U M z.1)is uniform onT → Fin (2 ^ M).TabulationprovidesrandFillLoop, a uniform word table (RandomTable,lookupCode,xorLookupCode), and aTabulatedOddStride, Zobrist 1970; Pătraşcu and Thorup 2012; Cormen et al. 2009, Section 11.4) with character widthprobeSeqis a full-cycle bijection onFin (2 ^ M)(bijective_probeSeq; only this permutation property is proved here, without claiming tabulation independence).Source statement checked against Vadhan's published December 2012 version, §3.5.5, Proposition 3.33, printed p. 72 (PDF page 75): “The family H given in Construction 3.32 is k-wise independent.” Construction 3.32 uses degree-at-most-
k-1polynomials with uniform coefficient tuples over a finite field. Here the field isTrinomialField (trinomialStep U M), inputs are the injective encoding ofFin U, and the result is projected ontoFin (2^M). Corollary 3.34 (pp. 72–73) supplies the bit-domain/range interpretation; the present field degree can exceedmax(log₂ U,M), so this does not claim that corollary's optimal random-bit count. The new execution composition and exact instruction bounds are library derivations, with externally admissible width and base/key register setup; width selection and native Turing transport remain separate.Abstract impact: none — introduces no selected abstract or PDF change.
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.