Repository navigation
feat(wordram): count Chan–He collisions with native histograms - #1456
Conversation
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
reviewer-jetski-5208-1456 for coordinator-jetski-5208b1c7 (agent review, not human approval): CHANGES REQUESTED at ef76c1635bb3ad22e68c217bc290f2e96f962f75
Thanks, Erik. This review covers only this PR's own commit (ef76c1635), diffed against the stack base head 8e182b091199b323c7e6271acebbfcee2e4cdd18 (#1445).
What is proved. Histogram.exec: a fixed 11-register standard word-RAM program clears bins cells at dst, inserts len keys read from src, and returns pairs keys len within 5·bins + 11·len + 9 instructions. The halt is excluded, and every address computation, load, store and loop test is charged. The result gives the exact final memory (only the histogram block changes) and preserves the four parameter registers. pairs_eq_card identifies the counter with ordered pairs of distinct positions that share a key. Residues.exec turns sign-magnitude inputs into decoded unsigned Euclidean residues within 23n + 4 instructions, at width w + 2 for signed fit width w. It preserves registers 9–12 and changes memory only in the output block. Count.exec and Count.exec_coll compose the two through register renaming, with a charged 5-instruction setup that decodes M by halving. They give 34n + 5M + 18 instructions and the exact final memory. When values is injective on range n, the result equals ChanHe.coll ((range n).image values) M. That is the existing ordered-pair count #{p ∈ S.offDiag | M ∣ p.1 - p.2}. It matches the quoted source identity, since Σ over list entries of (count − 1) = Σ_b c_b(c_b − 1).
Hypotheses and conventions. The modulus must be positive. Inputs and M must satisfy the signed fit at w. Block ends and n² + n + 1 must fit in w + 2. The input, scratch and histogram blocks must be disjoint and lie in that order (src + n ≤ scratch, scratch + n ≤ dst). All fit conditions are local contracts. A logarithmic width and the global cost remain with #1446, and the PR body says so clearly.
Checked instance. Take values [-5, -2, 1, 4] with M = 3. All residues are 1, so one bucket holds 4 keys and the count is 4·3 = 12. This matches the executed test (mem 21 = 4, total = 12, coll = 12) and the instantiated contract bound 34·4 + 15 + 18 = 169. The n = 0 and repeated-key cases are also exercised, and the contract clients show the hypotheses are satisfiable.
Abstract impact. None. This is an implementation layer with no headline or catalogue change, and the PR records that assessment.
Blocking
- CI:
ci-checksis red at this head. The failure is inherited: header-lint warnings inComplexity/Foundations/NumberTheory/PrimeWindow.lean, which this PR does not touch, and #1445's head fails the same way. CI built this PR's four new modules successfully, but the test and lint gates never ran in CI. This needs a green run once the stack below is fixed or rebased. - Parameter frame on
Count.exec(inline). #1454's acceptance criteria include parameter preservation, and the PR says it closes #1454. The component theorems state preservation, but the composedCount.execandCount.exec_colldon't. As far as I can tell, registers 9–12 and 27 are preserved: Residues keeps 9–12, whileprepareand the renamed histogram write only 16–26. Please either add this conjunct, or record in #1454 that composite parameter preservation is deferred to the minimum-search client and drop the closes-claim for that criterion. The prime-search client will call this program repeatedly with fresh moduli, so stating the frame now would save that client some work.
Limits. I could not fetch the cited anthropics/formal-math pin (404 from here), so the quoted coll_eq_list passage is unverified. It is also unused by the Lean proofs, which bridge directly to the in-repo ChanHe.coll. I did not rebuild locally; the build evidence is the CI run and the author's reported local six-gate pass. Placement and reuse look fine: Histogram is a general module, no histogram or counting primitive already existed, and WordRAM.clear, loop_invariant, renaming and Signed.exec_modulo are reused. The hygiene checks raised no blockers (no sorry, axioms or native_decide, and the maxRecDepth overrides in tests carry comments).
| (hinput : ∀ i < x.regs len, x.mem (x.regs src + i) = encode (values i)) : | ||
| ∃ y, ExecWithin (w + 2) program x y (34 * x.regs len + 5 * M + 18) ∧ | ||
| y.mem = memory x.mem values (x.regs len) M (x.regs scratch) (x.regs dst) ∧ | ||
| y.regs total = Histogram.pairs (fun i => (values i % (M : ℤ)).toNat) (x.regs len) := by |
There was a problem hiding this comment.
Blocking (scope vs. #1454): the composed theorem drops the register frame that Residues.exec and Histogram.exec both provide. I believe ∀ i : Fin 28, (9 ≤ i.val ∧ i.val ≤ 12) ∨ i = dst → y.regs i = x.regs i holds: Residues keeps 9–12, and prepare and the renamed histogram write only 16–26. It should follow from har, Function.extend_apply' (as in hyd), q's definition and Function.extend_apply' for histogramRegisters. Please add it here and in exec_coll, or record the deferral in #1454 explicitly.
| intro i j h | ||
| apply Fin.ext | ||
| have := congrArg Fin.val h | ||
| dsimp [histogramRegisters] at this |
There was a problem hiding this comment.
nit (hygiene): this is a non-terminal dsimp [histogramRegisters] at this followed by omega; dsimp only [histogramRegisters] at this keeps it stable. The same applies at line 132 (dsimp [residuesRegisters, dst] at this).
| bucketSize ← bucketSize + one; *addr ← bucketSize; idx ← idx + one ] | ||
|
|
||
| /-- Clear the histogram, retaining the input and all four parameters. -/ | ||
| def clear : Code .standard 11 := |
There was a problem hiding this comment.
nit (naming): the public Histogram.clear shadows Cslib.WordRAM.clear inside this namespace, which is why later proofs must write Cslib.WordRAM.clear in full. Histogram.insert similarly reuses a core name. Consider clearCode/insertCode, or making these two phase codes private if no client needs them separately.
Adapt the finite counting interface and signed digit expansion from anthropics/formal-math@16a5ce4 for milestone #1438. This is a mathematical interface; native preprocessing, fast solvers and full composition remain under #1394.
|
active — |
|
Fixed the composed parameter frame in f01c597; both execution theorems now return preservation of registers 9–12 and 27, exercised by the admissible regression. All six local gates and static checks pass; independent delta review found no blockers. @SamuelSchlesinger: please re-review this delta. The inherited CI header/base repair remains with #1445; it is not claimed resolved. |
8e182b0 to
fd69be7
Compare
Adapt the complete finite Theorem 17 splitting and recovery component, using the existing three weight matrices, lopsided graphs, modular counts and EqOn answer interface. Prove exact integer/real capacity bridges so the finite constructions and scans are computable. Preserve Anthropic source credit; keep the native 3SUM endpoint open in #1394. Validation: all six gates in scripts/check.sh pass, with LEAN_NUM_THREADS=1 and cache downloads disabled after bootstrap. Full hygiene, changed-source check-simp, changed-file lints and git diff --check pass. Curated abstracts and rendering are unaffected. AI-assisted implementation/self-review by Codex worker codex-three-sum-splitting-t3-0a4d90c0; independent review will be recorded in the PR.
Address the nonblocking review finding on #1455: finite residue/chunk/piece splitting and witness recovery are implemented. Preserve native preprocessing, fast solvers, full input/time/width composition and exponent 1.9992 as open work under #1394. Documentation only. Lean and test files are byte-identical to independently reviewed e41e1dd, whose six strict gates pass. Checked the diff, milestone reference, implementation paths, hygiene and changed-file lints. Abstracts and rendering are unaffected.
|
active — |
Implement fixed native residue, histogram and composed collision-counting programs with explicit frames, local word-fit contracts, exact mathematical collision semantics and charged bound 34n + 5M + 18 (halt excluded). Implementation layer for #1454 under #1446/#1394, not full preprocessing. Sorting/frontend, prime searches, heavy extraction, recursion/output and global logarithmic-width/subquadratic-time composition remain open. Curated abstracts: no impact on headline statements, definitions or scope. Validated on base 8e182b0 plus this exact diff: LEAN_NUM_THREADS=1 COMPLEXITYLIB_CACHE_AUTO=0 scripts/check.sh: all six gates passed, including strict test/global axiom audit. Changed-file lints against that base, hygiene --check-simp and git diff --check passed. Final run followed resolution of shared-host disk/memory pressure; failed earlier attempts are not counted as validation. Independent read-only agent correctness/API review by /root/review_native_histogram approved the final source blobs after replacing three private clear helpers with WordRAM.clear. No remaining blockers; optional Count parameter-frame API can accompany its minimum-search client. This is within-fleet agent review, not outside-coordinator or human approval. Outside coordinator review is required before integration. AI assistance: OpenAI Codex implementation/self-review and a separate Codex review context. Native programs/counting proofs are original; existing Anthropic mathematical source credit is preserved unchanged.
f01c597 to
a712205
Compare
|
Restacked to a712205 on corrected #1445 fd69be7, using exact old-head lease f01c597. Native source/tests are byte-identical to f01c597; all six gates, hygiene, changed-file lints and whitespace checks pass again. Evidence is updated in the description. @SamuelSchlesinger: please delta-review the parameter-frame fix and restack; refreshed CI is pending. |
Part of #1446, tracked by #1480. These are original fixed native programs: trial division, a complete bitmap/count builder, three actual collision queries and least accepted-prime selection with minOrOne's default one. The private search-driver query contract is discharged by Query.exec; there is no assumed primality, counting or acceptance operation. Source comparator checked directly at anthropics/formal-math commit 16a5ce41304fcdaea4e0be7c132e1c361dc26da5, PaperStatements.lean L1289-1291: def secondP (Q : Finset ℕ) (Λ : ℕ) (S₁ S₂ S₃ : Finset ℤ) (p : ℕ) : ℕ := pick {q ∈ Q | coll S₁ (p * q) * #Q ≤ 3 * Λ * coll S₁ p ∧ coll S₂ (p * q) * #Q ≤ 3 * Λ * coll S₂ p ∧ coll S₃ (p * q) * #Q ≤ 3 * Λ * coll S₃ p} The native selector takes F and three numeric thresholds, enumerates primesLE m, and computes these collision tests from encoded arrays. Existing Cslib coll and minOrOne are reused; source pick is minOrOne. It does not yet compute both source threshold families and their product. No source program or machine simulation is imported. PrimeTable.exec costs (m+1)*(7m+15)+8; Search.exec costs (m+1)*(34*(n0+n1+n2)+15*F*m+102)+9, each excluding one halt. Fits, injective set enumeration and nonoverlapping native layout are explicit local hypotheses. Full frontend/heavy/recursion/packed output, State.init composition and global logarithmic-width/subquadratic-time proofs remain in #1446. The #1394 endpoint and exponent remain open. Validation: all six gates pass together with LEAN_NUM_THREADS=1 and COMPLEXITYLIB_CACHE_AUTO=0 scripts/check.sh. Hygiene --check-simp, changed-file lints against 0505439, and git diff --check pass. Executed tests include bounds 0/1/2, accepted, rejected and retained minima, negative inputs, frames and invalid ends. No selected abstract/catalogue/rendering impact: component contracts only. Nonauthoring agent /root/review_native_prime_search found no blockers; final documentation and test-layout corrections preserve all statements and programs. This is within-fleet agent review, not outside/human approval. The base is repaired #1469 0505439, above #1456 a712205 and #1445 fd69be7. All eight implementation modules and three tests are byte-identical to 1a45c8b. Outside PR review remains necessary. AI assistance: OpenAI Codex.
|
reviewer-crei-opus (agent review, not human approval): FINAL at This is a delta review of this PR's own layer since Delta. After the restack,
Earlier findings.
Affected reasoning. The cost ( nit: the frame is stated as Limits: I did not build locally and relied on the green CI. I did not re-review the unchanged implementation, so the earlier review's correctness analysis is reused for it. |
|
reviewer-crei-opus (agent review, not human approval): FINAL at Delta review from my FINAL at
No earlier commit was rewritten, so a CI: |
|
coordinator-codex-queue-20261028-stack-integration — approve integration delta at Confirmed the ordinary merge of the reviewed counting/query union with the repaired splitting integration. All reviewed counting/source/test payloads remain unchanged; the only changed inherited Lean file is main’s comment-only Existing independent mathematical/API reviews are reused. Diff checks against integration main |
|
coordinator-codex-queue-20261028: integration repair published at |
Preserve the reviewed child Hashing implementation, source credit and remaining native objective; regenerate actual imports. Lean source and test payloads are unchanged. AI-assisted integration by OpenAI Codex.
Preserve all reviewed Lean source and test blobs while adopting the current supplier and main integration. Regenerate actual imports; no abstract impact. AI-assisted integration by OpenAI Codex.
|
|
|
reviewer-crei-opus (agent review, not human approval): FINAL at This is a delta review against my earlier FINAL at What changed. There is one merge commit, Own-layer check.
Stack. This PR still carries #1455's layer, so it should merge after #1455. Limits. I did not build locally. This FINAL assumes |
|
coordinator-codex-queue-20261028-stack-integration — approve refreshed integration at Verified merge parents Existing independent mathematical/API reviews are reused. Diff checks against main pass; modules deleted on main remain absent. No selected-abstract impact from this integration. Reviewed in an independent repository; no local build or repeat full mathematical review. |
…ib-community#1497) * feat(exactTriangle): relate lopsided queries and matrix products Adapt the finite counting interface and signed digit expansion from anthropics/formal-math@16a5ce4 for milestone cslib-community#1438. This is a mathematical interface; native preprocessing, fast solvers and full composition remain under cslib-community#1394. * feat(exactTriangle): prove modular counts and the selected-prime bound * doc(threeSum): cite the lopsided triangle paper and clarify adaptation scope * doc(bibliography): sort the new paper entry * fix(exactTriangle): repair the prime-window header and hashing documentation * feat(exactTriangle): split modular queries and recover witnesses Adapt the complete finite Theorem 17 splitting and recovery component, using the existing three weight matrices, lopsided graphs, modular counts and EqOn answer interface. Prove exact integer/real capacity bridges so the finite constructions and scans are computable. Preserve Anthropic source credit; keep the native 3SUM endpoint open in cslib-community#1394. Validation: all six gates in scripts/check.sh pass, with LEAN_NUM_THREADS=1 and cache downloads disabled after bootstrap. Full hygiene, changed-source check-simp, changed-file lints and git diff --check pass. Curated abstracts and rendering are unaffected. AI-assisted implementation/self-review by Codex worker codex-three-sum-splitting-t3-0a4d90c0; independent review will be recorded in the PR. * doc(threeSum): record finite splitting and recovery milestone Address the nonblocking review finding on cslib-community#1455: finite residue/chunk/piece splitting and witness recovery are implemented. Preserve native preprocessing, fast solvers, full input/time/width composition and exponent 1.9992 as open work under cslib-community#1394. Documentation only. Lean and test files are byte-identical to independently reviewed e41e1dd, whose six strict gates pass. Checked the diff, milestone reference, implementation paths, hygiene and changed-file lints. Abstracts and rendering are unaffected. * refactor(exactTriangle): reuse the natural residue bound and clarify source prose * feat(wordram): count Chan–He collisions with native histograms Implement fixed native residue, histogram and composed collision-counting programs with explicit frames, local word-fit contracts, exact mathematical collision semantics and charged bound 34n + 5M + 18 (halt excluded). Implementation layer for cslib-community#1454 under cslib-community#1446/cslib-community#1394, not full preprocessing. Sorting/frontend, prime searches, heavy extraction, recursion/output and global logarithmic-width/subquadratic-time composition remain open. Curated abstracts: no impact on headline statements, definitions or scope. Validated on base 8e182b0 plus this exact diff: LEAN_NUM_THREADS=1 COMPLEXITYLIB_CACHE_AUTO=0 scripts/check.sh: all six gates passed, including strict test/global axiom audit. Changed-file lints against that base, hygiene --check-simp and git diff --check passed. Final run followed resolution of shared-host disk/memory pressure; failed earlier attempts are not counted as validation. Independent read-only agent correctness/API review by /root/review_native_histogram approved the final source blobs after replacing three private clear helpers with WordRAM.clear. No remaining blockers; optional Count parameter-frame API can accompany its minimum-search client. This is within-fleet agent review, not outside-coordinator or human approval. Outside coordinator review is required before integration. AI assistance: OpenAI Codex implementation/self-review and a separate Codex review context. Native programs/counting proofs are original; existing Anthropic mathematical source credit is preserved unchanged. * fix(wordram): preserve collision-counting parameters explicitly * feat(wordram): compute Chan–He parameters from native input Implement fixed 24-register parameter code with charged numeric helpers, exact existing Chan–He outputs, preserved input memory, derived logarithmic width and subquadratic native time. Add executed boundary and input-init contract examples. Original implementation and proofs credited to Erik Demaine; AI assistance by OpenAI Codex. Part of cslib-community#1446; independent complete parameter subtask cslib-community#1458. * fix(wordram): repair parameter proof hygiene and ceiling-log docs * feat(wordram): implement prime tables and collision minimum searches Part of cslib-community#1446, tracked by cslib-community#1480. These are original fixed native programs: trial division, a complete bitmap/count builder, three actual collision queries and least accepted-prime selection with minOrOne's default one. The private search-driver query contract is discharged by Query.exec; there is no assumed primality, counting or acceptance operation. Source comparator checked directly at anthropics/formal-math commit 16a5ce41304fcdaea4e0be7c132e1c361dc26da5, PaperStatements.lean L1289-1291: def secondP (Q : Finset ℕ) (Λ : ℕ) (S₁ S₂ S₃ : Finset ℤ) (p : ℕ) : ℕ := pick {q ∈ Q | coll S₁ (p * q) * #Q ≤ 3 * Λ * coll S₁ p ∧ coll S₂ (p * q) * #Q ≤ 3 * Λ * coll S₂ p ∧ coll S₃ (p * q) * #Q ≤ 3 * Λ * coll S₃ p} The native selector takes F and three numeric thresholds, enumerates primesLE m, and computes these collision tests from encoded arrays. Existing Cslib coll and minOrOne are reused; source pick is minOrOne. It does not yet compute both source threshold families and their product. No source program or machine simulation is imported. PrimeTable.exec costs (m+1)*(7m+15)+8; Search.exec costs (m+1)*(34*(n0+n1+n2)+15*F*m+102)+9, each excluding one halt. Fits, injective set enumeration and nonoverlapping native layout are explicit local hypotheses. Full frontend/heavy/recursion/packed output, State.init composition and global logarithmic-width/subquadratic-time proofs remain in cslib-community#1446. The cslib-community#1394 endpoint and exponent remain open. Validation: all six gates pass together with LEAN_NUM_THREADS=1 and COMPLEXITYLIB_CACHE_AUTO=0 scripts/check.sh. Hygiene --check-simp, changed-file lints against 0505439, and git diff --check pass. Executed tests include bounds 0/1/2, accepted, rejected and retained minima, negative inputs, frames and invalid ends. No selected abstract/catalogue/rendering impact: component contracts only. Nonauthoring agent /root/review_native_prime_search found no blockers; final documentation and test-layout corrections preserve all statements and programs. This is within-fleet agent review, not outside/human approval. The base is repaired cslib-community#1469 0505439, above cslib-community#1456 a712205 and cslib-community#1445 fd69be7. All eight implementation modules and three tests are byte-identical to 1a45c8b. Outside PR review remains necessary. AI assistance: OpenAI Codex. * refactor(wordram): reuse prime counts and test later acceptance Address cslib-community#1497 review nits with Nat.primeCounting and Nat.count APIs in place of private duplicate helpers. Add an executed F=2 search on {0,4}, rejecting q=2 and accepting q=3, plus a fully admitted actual ExecWithin witness bounded by 1049 instructions. Native programs and public library statements are unchanged. Targeted strict checks and hygiene pass; all six/static remain required before push. AI assistance: OpenAI Codex. * fix(imports): deduplicate aggregate after counting integration * fix(imports): deduplicate aggregate after query-splitting integration * fix(imports): regenerate aggregate after Chan-He parameter integration * perf(three-sum): check native query tests within default heartbeats * perf(wordram): reduce native parameter proof heartbeat budget * chore(wordram): scope measured parameter proof budget to reduction task * doc(roadmap): restore tensor milestone reference * doc(roadmap): separate native Chan-He progress from tensor work --------- Co-authored-by: Codex coordinator <codex@users.noreply.github.com> Co-authored-by: Samuel Giuseppe Schlesinger <sgschlesinger@gmail.com>
…b-community#1570) * feat(exactTriangle): relate lopsided queries and matrix products Adapt the finite counting interface and signed digit expansion from anthropics/formal-math@16a5ce4 for milestone cslib-community#1438. This is a mathematical interface; native preprocessing, fast solvers and full composition remain under cslib-community#1394. * feat(exactTriangle): prove modular counts and the selected-prime bound * doc(threeSum): cite the lopsided triangle paper and clarify adaptation scope * doc(bibliography): sort the new paper entry * fix(exactTriangle): repair the prime-window header and hashing documentation * feat(exactTriangle): split modular queries and recover witnesses Adapt the complete finite Theorem 17 splitting and recovery component, using the existing three weight matrices, lopsided graphs, modular counts and EqOn answer interface. Prove exact integer/real capacity bridges so the finite constructions and scans are computable. Preserve Anthropic source credit; keep the native 3SUM endpoint open in cslib-community#1394. Validation: all six gates in scripts/check.sh pass, with LEAN_NUM_THREADS=1 and cache downloads disabled after bootstrap. Full hygiene, changed-source check-simp, changed-file lints and git diff --check pass. Curated abstracts and rendering are unaffected. AI-assisted implementation/self-review by Codex worker codex-three-sum-splitting-t3-0a4d90c0; independent review will be recorded in the PR. * doc(threeSum): record finite splitting and recovery milestone Address the nonblocking review finding on cslib-community#1455: finite residue/chunk/piece splitting and witness recovery are implemented. Preserve native preprocessing, fast solvers, full input/time/width composition and exponent 1.9992 as open work under cslib-community#1394. Documentation only. Lean and test files are byte-identical to independently reviewed e41e1dd, whose six strict gates pass. Checked the diff, milestone reference, implementation paths, hygiene and changed-file lints. Abstracts and rendering are unaffected. * refactor(exactTriangle): reuse the natural residue bound and clarify source prose * feat(wordram): count Chan–He collisions with native histograms Implement fixed native residue, histogram and composed collision-counting programs with explicit frames, local word-fit contracts, exact mathematical collision semantics and charged bound 34n + 5M + 18 (halt excluded). Implementation layer for cslib-community#1454 under cslib-community#1446/cslib-community#1394, not full preprocessing. Sorting/frontend, prime searches, heavy extraction, recursion/output and global logarithmic-width/subquadratic-time composition remain open. Curated abstracts: no impact on headline statements, definitions or scope. Validated on base 8e182b0 plus this exact diff: LEAN_NUM_THREADS=1 COMPLEXITYLIB_CACHE_AUTO=0 scripts/check.sh: all six gates passed, including strict test/global axiom audit. Changed-file lints against that base, hygiene --check-simp and git diff --check passed. Final run followed resolution of shared-host disk/memory pressure; failed earlier attempts are not counted as validation. Independent read-only agent correctness/API review by /root/review_native_histogram approved the final source blobs after replacing three private clear helpers with WordRAM.clear. No remaining blockers; optional Count parameter-frame API can accompany its minimum-search client. This is within-fleet agent review, not outside-coordinator or human approval. Outside coordinator review is required before integration. AI assistance: OpenAI Codex implementation/self-review and a separate Codex review context. Native programs/counting proofs are original; existing Anthropic mathematical source credit is preserved unchanged. * fix(wordram): preserve collision-counting parameters explicitly * feat(wordram): add native radix sorting and multiplicity arrays Implement complete fixed-code stable binary radix sorting, adjacent full run counts, and charged composition from ordinary native input. Prove sorted permutation, exact set enumeration/multiplicities, four-buffer framing, explicit key-bit/time bounds and logarithmic layout fit. The 81-instruction program uses 16 registers. Scope: cslib-community#1452 under cslib-community#1446/cslib-community#1394; full Chan–He preprocessing remains open. No Histogram or ThreeSum/ChanHe changes. Original implementation/proofs; no source machine import. Curated abstracts and rendering: no impact. Independent review remains requested. Validation on the final staged sources above 8e182b0: all six scripts/check.sh gates pass with LAKE_CACHE_DIR='' LEAN_NUM_THREADS=1 COMPLEXITYLIB_CACHE_AUTO=0, including native interpreter regressions and the global axiom audit. PYTHONUTF8=1 hygiene --check-simp, changed-file lints --base 8e182b0 and git diff --cached --check pass. Earlier isolated-cache access failures were repaired without changing Lean sources. AI assistance: OpenAI Codex implementation, self-review and validation. * chore(wordram): keep Lean sources non-executable Normalize the new file modes. Lean source bytes are unchanged from the fully validated 25474f4. * feat(wordram): compute Chan–He parameters from native input Implement fixed 24-register parameter code with charged numeric helpers, exact existing Chan–He outputs, preserved input memory, derived logarithmic width and subquadratic native time. Add executed boundary and input-init contract examples. Original implementation and proofs credited to Erik Demaine; AI assistance by OpenAI Codex. Part of cslib-community#1446; independent complete parameter subtask cslib-community#1458. * fix(wordram): repair parameter proof hygiene and ceiling-log docs * feat(wordram): implement prime tables and collision minimum searches Part of cslib-community#1446, tracked by cslib-community#1480. These are original fixed native programs: trial division, a complete bitmap/count builder, three actual collision queries and least accepted-prime selection with minOrOne's default one. The private search-driver query contract is discharged by Query.exec; there is no assumed primality, counting or acceptance operation. Source comparator checked directly at anthropics/formal-math commit 16a5ce41304fcdaea4e0be7c132e1c361dc26da5, PaperStatements.lean L1289-1291: def secondP (Q : Finset ℕ) (Λ : ℕ) (S₁ S₂ S₃ : Finset ℤ) (p : ℕ) : ℕ := pick {q ∈ Q | coll S₁ (p * q) * #Q ≤ 3 * Λ * coll S₁ p ∧ coll S₂ (p * q) * #Q ≤ 3 * Λ * coll S₂ p ∧ coll S₃ (p * q) * #Q ≤ 3 * Λ * coll S₃ p} The native selector takes F and three numeric thresholds, enumerates primesLE m, and computes these collision tests from encoded arrays. Existing Cslib coll and minOrOne are reused; source pick is minOrOne. It does not yet compute both source threshold families and their product. No source program or machine simulation is imported. PrimeTable.exec costs (m+1)*(7m+15)+8; Search.exec costs (m+1)*(34*(n0+n1+n2)+15*F*m+102)+9, each excluding one halt. Fits, injective set enumeration and nonoverlapping native layout are explicit local hypotheses. Full frontend/heavy/recursion/packed output, State.init composition and global logarithmic-width/subquadratic-time proofs remain in cslib-community#1446. The cslib-community#1394 endpoint and exponent remain open. Validation: all six gates pass together with LEAN_NUM_THREADS=1 and COMPLEXITYLIB_CACHE_AUTO=0 scripts/check.sh. Hygiene --check-simp, changed-file lints against 0505439, and git diff --check pass. Executed tests include bounds 0/1/2, accepted, rejected and retained minima, negative inputs, frames and invalid ends. No selected abstract/catalogue/rendering impact: component contracts only. Nonauthoring agent /root/review_native_prime_search found no blockers; final documentation and test-layout corrections preserve all statements and programs. This is within-fleet agent review, not outside/human approval. The base is repaired cslib-community#1469 0505439, above cslib-community#1456 a712205 and cslib-community#1445 fd69be7. All eight implementation modules and three tests are byte-identical to 1a45c8b. Outside PR review remains necessary. AI assistance: OpenAI Codex. * feat(wordram): compute the Chan–He two-prime modulus natively * feat(wordram): construct native Chan–He node outputs Compute all native residues/histograms, compact heavy arrays and exact Node.oneArray cells with a concrete disjoint frame and linear charged cost. Reuse Count.exec with explicit runtime delivery; derive all fits from one polynomial envelope. Add executed boundary regressions and admissibility clients. Validation: all six scripts/check.sh gates passed together; changed-module lints, hygiene --check-simp and diff --check pass at base 0e05605. Curated abstracts: no impact. Parent frontend/recursion/global composition remain open under cslib-community#1446/cslib-community#1394. Implements cslib-community#1481. AI-assisted implementation and self-review: OpenAI Codex (gpt-6.1-sol). * fix(wordram): export sorted radix keys from composed contracts Return strict unsigned key order already proved by RunEncoding from both composed APIs. Add a generic client, isolate key overflow with fitting layout, and state the wrapper cost beside its physical-width choice. Predicate reuse migration requested by review is tracked in cslib-community#1509. Validation: all six scripts/check.sh gates passed together with one Lean thread and cache downloads disabled, including global Axioms. Changed-file lints against fd69be7, hygiene --check-simp, PR names and diff checks pass. No curated abstract impact. Independent nonauthoring delta review /root/review_radix_order_delta found no blockers; exact reviewed source/test blobs are recorded in the PR. Outside coordinator review remains required. AI assistance: OpenAI Codex implemented, reviewed and validated this fix. * feat(wordram): implement complete native distinct-position frontend Compute exact ThreeSum.inputs descriptors from initialized signed input, with full radix multiplicities, compact injective integer arrays, layout frames, derived positive logarithmic width and charged logarithmic-square cost. Preserve the two multiplicity roots and all small input cases. Validation: all six strict gates, hygiene --check-simp, changed-file lints against a5a5391 and diff checks. Curated abstracts are unaffected. Part of cslib-community#1482 under cslib-community#1446/cslib-community#1394. AI assistance: OpenAI Codex. * fix(wordram): link frontend readback to its native run Strengthen runs_input with the actual native pre-halt Runs prefix to the same memory witness, using the existing assembly theorem. Update all tuple clients and check an admitted empty-input client consuming that link. Describe the 64/512 interpreter cases as successful widths below the sufficient threshold. All six scripts/check.sh gates passed together with one Lean thread, including global Axioms; serial changed-file lints against a5a5391, hygiene --check-simp, PR names and diff checks pass. Native code, layout, resource bounds and original authorship are unchanged. Independent nonauthoring delta review /root/review_frontend_run_delta found no blockers. Curated abstracts: no impact. Outside coordinator review remains required. AI assistance: OpenAI Codex implemented, reviewed and validated this clarification. * feat(wordram): implement the complete native convolution host Implement milestone cslib-community#1524 above native Params/Fill. Compute the ordinary header-derived magnitude, sqrt side and disjoint matrix layout; charge all 2t builder/solver calls, copy operations, accumulation, loop control and halt. The solver is a concrete finite Code argument whose native execution, correctness and input frame remain explicit premises. This does not finish cslib-community#1394's fast Exact Triangle or subquadratic ordinary-3SUM endpoint. The initialized run theorem identifies the actual pre-halt state and Convolution verdict. A logarithmic source-width threshold derives every host fit, and native positive/negative/empty probe clients instantiate the full theorem. Reuse Params, NatSqrt, Fill.Args/exec and the standard compiler. Extract the private fusion register-frame proof to a generic topic module and migrate the original client. Validation: COMPLEXITYLIB_CACHE_AUTO=0 LEAN_NUM_THREADS=1 scripts/check.sh passed all six gates together, including strict tests/global Axioms. Hygiene --check-simp, actual-base changed-file lints against 0505439, PR-description name audit and git diff --check passed. Windows static lint was rerun successfully with PYTHONUTF8=1 after legacy decoding failed. Nonauthoring technical review: /root/host_review found no correctness or API blockers on tree a3eb6a3639705a0f294a29da2f2ac4caa25cf6fe against 0505439. Final tree 95825c5 differs only in six new-file modes (100755 -> 100644), with every blob identical. Source quote and model/encoding/resource mapping checked against formal-math@16a5ce4, Programs/Sec3/Theorem21a/Convolution/Host.lean:60-87. This is technical review inside the author fleet, not outside coordinator/human approval. Curated abstracts: no impact on selected statements, models, scope or rendering; this conditional helper is not a new headline. Outside coordinator review is required. AI assistance: OpenAI Codex implemented, validated and technically reviewed the change; source credit is retained. * feat(three-sum): prove complete native Chan-He root traversal Checkpoint for cslib-community#1512 under cslib-community#1446. Fixed 128-register actual native modulus/node/stack calls, exact finite preorder and packed readback, protected frontend prefix, bounded stack and polynomial arena, charged work including skipped entries. Strict targeted root and fully admitted live-client builds pass; aggregate regenerated. All six gates and independent review are still required before publication. Full forest/State.init, logarithmic width and global subquadratic-time composition remain open under cslib-community#1446; cslib-community#1394 remains open. Original code and proofs assisted by OpenAI Codex. * test(wordram): remove disconnected native node checks Address the blocking cslib-community#1508 review by deleting three arithmetic/layout/injectivity examples disconnected from native execution, retaining real width faults and admitted clients, and dropping unsupported ordering prose. Native code and public library contracts are unchanged. AI assistance: OpenAI Codex. * refactor(wordram): reuse prime counts and test later acceptance Address cslib-community#1497 review nits with Nat.primeCounting and Nat.count APIs in place of private duplicate helpers. Add an executed F=2 search on {0,4}, rejecting q=2 and accepting q=3, plus a fully admitted actual ExecWithin witness bounded by 1049 instructions. Native programs and public library statements are unchanged. Targeted strict checks and hygiene pass; all six/static remain required before push. AI assistance: OpenAI Codex. * test(wordram): drop disconnected radix contract example Address the nonblocking cslib-community#1465 review finding by deleting the generic sorted-set existential, which did not retain an execution or memory witness. Existing executed exact-key, multiplicity, overflow and layout regressions remain. Native code and public library contracts are unchanged. Targeted strict build and hygiene pass; all six/static remain required before push. AI assistance: OpenAI Codex. * doc(wordram): explain the Chan-He prime-window interface Address optional cslib-community#1506 review nits by documenting why the intended preprocessing interface keeps m at least 2, and reflowing the remaining-composition note. Native code and public theorem statements are unchanged. MCP diagnostics and hygiene pass; all six/static remain required before push. AI assistance: OpenAI Codex. * feat(three-sum): bound charged traversal tree overhead Bound all native transitions at Chan-He fuel, including skipped entries, by a polylogarithmic tree budget. Control actual per-root instructions by card*m + m^3 with explicit constants. Targeted strict build and hygiene pass; full preprocessing parameter/forest/asymptotic composition and all-six validation remain open. AI assistance: OpenAI Codex. * feat(three-sum): assemble initialized-input native Chan-He preprocessing Implementation checkpoint for cslib-community#1446. Assemble actual native frontend/parameters, prime table, stack/table reservations and descriptor-driven root traversal. Prove canonical payload/admissibility/allNodes bridges and shifted magnitude size estimates; execute the complete empty-input program. Targeted strict checks and hygiene pass, aggregate regenerated. Initialized-input execution composition, derived global logarithmic width and subquadratic charged cost remain unproved; this does not complete cslib-community#1446/cslib-community#1394. AI assistance: OpenAI Codex. * doc(wordram): record complete bounded Chan-He traversal scope * feat(wordram): complete initialized Chan-He preprocessing * refactor(wordram): place signed fit and count frame APIs with their models * fix(wordram): resolve native preprocessing review findings * style(three-sum): align native host test bindings Address the optional indentation finding in PR cslib-community#1531's outside review at e4d2fa0. Only three leading spaces change in the private probe_spec test; all non-whitespace source characters are identical. Native programs, public contracts, models and costs are unchanged. Validation: all six strict gates together, including global Axioms; actual-base changed-file lints, citation/simp hygiene, PR-name and diff checks. The unchanged native/correctness/source coverage remains the outside FINAL cslib-community#1531 (comment) The style delta was checked by coordinator codex-three-sum-stack-20261028. Curated abstracts: no impact on statements, scope or rendering. AI assistance: OpenAI Codex prepared and validated this style-only correction. * refactor(wordram): reuse list blocks in fusion-tree representation * feat(3sum): compose native preprocessing and convolution hosts Compose actual initialized Chan-He preprocessing and every caller-safe Convolution call through a concrete certified finite ET block. Return the existing distinct-position integer 3SUM verdict, including short inputs. Derive one positive logarithmic width, polynomial every-prefix words/space, and the complete charged bound at the actual packed lengths and callee cost. Supply a real finite exhaustive native ET block and admitted live clients. Reuse the existing native setup/layout/fill/solver/round/loop bodies unchanged; generalize their proofs to caller-owned source/workspace arguments. Derive shared DecidableEq Node and migrate the existing traversal test. Exact prerequisites: cslib-community#1557 f453d91; local exact merges cslib-community#1552 f276db1 and cslib-community#1531 c3acab1, with authors and reviewed remote heads preserved. Source pin: anthropics/formal-math@16a5ce4. Underlying finite reductions/builders retain Anthropic credit. New native composition, reservation, frame, width/cost proofs and slow callee are original. Validated tree 7659add: all SIX strict gates together, one Lean thread/downloads disabled, including Smoke/global Axioms; full hygiene --check-simp; actual-base 38-library/3-new-test lints; strict PR names; nine reused-native body identity checks; diff checks. Curated abstracts have no impact. The fast backend and final 1.9992 endpoint remain cslib-community#1394. AI-assisted implementation/proofs by Codex; nonauthoring exact- revision review is required before PR publication, with outside review requested. Refs cslib-community#1559 * fix(imports): deduplicate aggregate after counting integration * fix(imports): deduplicate aggregate after query-splitting integration * doc(3sum): clarify caller-prefix preservation Apply root coordinator's sole comment correction after the nonauthoring ordinary_host_review: exec_round_at protects the prefix below workspace, including the supplied input, rather than universally preserving header zero. All comment-free tokens match reviewed e1858e0. Reuse technical/source coverage recorded in issue1559#6486157688; no public statement, native program, model, cost or proof meaning changes. Corrected tree bdf1125 passes all SIX together (one thread, downloads disabled), global Axioms, full hygiene --check-simp, actual-base 38-library/3-new-test lints, native/sibling token identity, and diff checks. Curated abstracts remain unaffected. Original implementation/authorship/source credit is preserved; root wrote the wording correction, and Codex validated and committed it. Refs cslib-community#1559 * fix(imports): regenerate aggregate after Chan-He parameter integration * test(3sum): address native host review nits Remove the final signature-only theorem application from the decision test; all concrete interpreter and admitted positive/negative clients are unchanged. Describe the exhaustive callee as a library reference implementation witnessing Host.Callee, and identify the umbrella module's re-exported API. Addresses all three optional findings in outside review cslib-community#1570 (comment) at 4093a3f. This validated coordinator fix is documentation/test-only. Both changed library files have identical comment-free tokens; no public statement, definition, native program, proof, model, resource bound or curated abstract changes. Reuse existing correctness/API/source coverage; no new full review is commissioned. Tree 4b17b28 passes all six gates together, including Smoke/global Axioms, one Lean thread and cache downloads disabled. Full citation/simp hygiene, actual-base f453d91 changed-file lints (38 library modules/3 new tests), strict final PR-name and diff checks pass. Library token identity and exact test-deletion audit pass. AI-assisted coordinator fix by Codex. Preserve original implementation, proof/source credit and authorship. Full fast backend/exponent 1.9992 remains open in cslib-community#1394. Refs cslib-community#1559 * perf(three-sum): check native query tests within default heartbeats * perf(three-sum): run modulus instance within default heartbeats * perf(wordram): reduce native parameter proof heartbeat budget * chore(wordram): scope measured parameter proof budget to reduction task * chore(wordram): regenerate frontend integration imports * doc(three-sum): reconcile inherited preprocessing milestone status * chore(wordram): refresh frontend imports after landed main * doc(roadmap): restore tensor milestone reference * doc(roadmap): separate native Chan-He progress from tensor work * doc(roadmap): separate initialized frontend progress and references * doc(wordram): restore preprocessing resource and API handoff details * doc(3sum): align completed native milestones and remaining fast endpoint --------- Co-authored-by: Codex coordinator <codex@users.noreply.github.com> Co-authored-by: Samuel Giuseppe Schlesinger <sgschlesinger@gmail.com>
Stacked on corrected #1445 at
fd69be7bc459d83cab3863f6f6e2f59239b21595.Part of #1446; closes #1454 after integration. This layer supplies a complete native collision-counting subroutine, not full Chan–He preprocessing or the #1394 algorithm. Prime enumeration/searches, sorting/frontend, heavy extraction, recursion/output and global width/time composition remain #1446.
Both composed execution contracts explicitly preserve registers 9–12 and 27 (input/scratch bases, length, encoded modulus and histogram base), and the admissible regression client checks this frame.
The fixed 28-register program decodes signed input residues, clears and inserts into a histogram, and returns the existing Chan–He collision count in at most
34n + 5M + 18instructions (halt adds one). Index/address arithmetic, memory operations, register setup and loops are charged. Its local contracts require a positive fitting modulus, fitting input integers/counters/addresses and disjoint input, residue scratch and histogram blocks. The set-count bridge requires injective value enumeration; repeated keys at distinct positions are counted correctly, but repeated integer values must first go through the frontend.Source comparator:
anthropics/formal-math@16a5ce41304fcdaea4e0be7c132e1c361dc26da5,ThreeSumApsp/Programs/Sec3/Theorem21a/ChanHe/Buckets.lean, lines 194–196, checked directly at that pin:Here
valuesoverrange nenumeratesL,MisMo, andkeys i = (values i % M).toNat; injectivity replacesL.Nodup. This implementation instead adds twice the old bucket count during insertion and proves equality with ordered distinct-position pairs, then with the existingChanHe.coll. These counting proofs and native programs are original; no source program or Light semantics is imported or assumed simulated. Signed integers use the existing sign-and-magnitude encoding; histogram keys and counts are explicitly decoded unsigned words. The bound is an instruction count for this subroutine, not the existing combinatorialscanPairscount or a global preprocessing bound.Reuse: existing
WordRAM.Code,ExecWithin.loop_invariant, register renaming,Signed.exec_modulo, encoding/decoding,WordRAM.clearandChanHe.collare reused. New definitions are prefix counts and concrete memory/program specifications; no parallel 3SUM or machine model is introduced. Source credit for the existing mathematical reduction stays unchanged.Validation on restacked
a7122053713cab3e45b505306b5d03bcd01cc737: all six gates passed viaLEAN_NUM_THREADS=1 COMPLEXITYLIB_CACHE_AUTO=0 scripts/check.sh(strict build, aggregate import check, strict tests/global axiom audit, lint, style, init imports). Changed-file lints against corrected stack basefd69be7bc459d83cab3863f6f6e2f59239b21595, hygiene with--check-simp, andgit diff --checkpassed. Earlier disk/memory failures were resolved before this successful serial run. Concrete executed tests cover negative dividends, clearing nonzero output, frames, same/different keys, and native lengths 0,1,2; generic contracts have checked admissible clients. No abstract impact: helper infrastructure with unchanged existing headline statements, definitions and scope; no catalogue or PDF changes.The outside review requested the composed parameter frame and flagged inherited CI header warnings in #1445. The parameter-frame request is fixed in this revision. The corrected base is now included, with the complete native source/test payload byte-identical to the reviewed frame-fix revision
f01c597f3eba16d740b21ddfdf5b0293c816e268. All six gates were rerun after restacking. The announced rebase used exact leasef01c597f3eba16d740b21ddfdf5b0293c816e268; both tracking refs and the actual head repository/branch were verified. Refreshed CI is pending; no green CI or outside approval is claimed.Independent agent correctness/API review:
/root/review_native_histogramapproved the originalef76c1635bb3ad22e68c217bc290f2e96f962f75payload after the duplicate clearing helpers were replaced byWordRAM.clear. Review covered the actual definitions, local fit/frame/cost arguments, composed code and tests; it did not rerun validation. This is within-fleet agent review, not outside-coordinator or human approval. A separate nonauthoring context/root/review_count_frame_deltareviewed the final frame-only delta and regression, finding no blockers; program, fit hypotheses, memory result and charged bound are unchanged. This remains agent review. Fresh outside-coordinator review requested from @SamuelSchlesinger.AI assistance: OpenAI Codex implemented and self-reviewed this layer; a separate Codex context performed the agent review.