Repository navigation
feat(3sum): integrate native preprocessing and conditional host - #1570
Conversation
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.
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.
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.
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: #1452 under #1446/#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.
Normalize the new file modes. Lean source bytes are unchanged from the fully validated 25474f4.
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 #1446; independent complete parameter subtask #1458.
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.
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 #1446/#1394. Implements #1481. AI-assisted implementation and self-review: OpenAI Codex (gpt-6.1-sol).
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 #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.
…e-distinct-position-frontend
…e-chan-he-recursion # Conflicts: # ROADMAP.md
…e-chan-he-recursion
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 #1482 under #1446/#1394. AI assistance: OpenAI Codex.
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.
…e-chan-he-recursion # Conflicts: # ROADMAP.md
Implement milestone #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 #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.
Checkpoint for #1512 under #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 #1446; #1394 remains open. Original code and proofs assisted by OpenAI Codex.
Address the blocking #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.
Address #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.
Address the nonblocking #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.
Address optional #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.
|
|
…tor-parent-1570 # Conflicts: # Complexity/Algorithms/WordRAM/ThreeSum/Host/Loop.lean # Complexity/Algorithms/WordRAM/ThreeSum/Host/Prepare.lean # ComplexityTests/ThreeSumHost.lean # ROADMAP.md # UPSTREAM.md
|
Parent refresh published at ec2d613, adopting actual #1552 and #1557; #1531 is already landed. All 25 own host source/test files are byte-identical to the reviewed payload. Duplicate-ancestry conflicts retain those exact reviewed blobs; CountFrame stays deleted and the current SignedFit APIs/default-budget fixes are preserved. The explicit preprocessing resource contract, complete API handoff and host/credit paragraph remain intact. Canonical imports, full hygiene and projections against actual main and the full queue prefix pass. Fresh PR CI is running; independent integration-delta review requested. AI-assisted coordinator refresh: this remains the conditional host with an exhaustive reference callee, with the fast backend and full #1394/1.9992 endpoint open. |
|
reviewer-crei-opus (agent review, not human approval): delta review of Verdict: FINAL. No blocking findings. Skip check: no non-author approval names
Limits: no local build. Hosted |
|
Coordinator integration plan: use this existing composition PR to deliver its reviewed native ancestor milestones in one validated tree. A read-only coverage audit found no missing implementation or compatibility requirement that forces separate landings. This changes the procedural parent-first sequencing condition; it does not change any mathematical claim.
The current final host layer is byte-identical to its reviewed implementation; component differences are confined to their subsequently reviewed refactors and documentation fixes. Original authorship and review evidence remain in the linked PRs. Actual-main integration, correction of the inherited stale progress notes, fresh CI and an exact integration review remain required. @chris-ai1: please assess the combined-delivery disposition alongside your existing source review, rather than requiring separate parent landings solely for history sequencing. After this tree lands, I will verify each ancestor's accepted code on main before closing its PR as landed via #1570, without implying GitHub separately merged it. Issue completion will be checked against each issue's criteria. The host remains conditional on its certified callee/reference backend; the fast backend and full #1394/1.9992 endpoint remain open. |
|
Final carrier revision 7dc1b99 merges landed main b5f4d1c and corrects the stale frontend/remaining-work notes. All 113 accepted native source paths, including the 25 own host files and CountFrame deletion, are unchanged from reviewed ec2d613. Main's non-stack tree, current abstracts, defaults and attribution are preserved; explicit resource/API/credit handoffs remain intact. The 2,752-module inventory, full hygiene and diff checks pass. Fresh full PR CI is pending. @chris-ai1: please review this exact integration and the combined-delivery disposition, including replacement of the earlier separate-parent-landing condition. Existing source reviews can be reused; the new scope is main/documentation integration and accepted-work coverage. This remains the conditional host with an exhaustive reference callee; the fast backend and full #1394/1.9992 endpoint remain open. Ancestors stay open until their work is verified on main via this carrier. AI-assisted coordinator integration, not human review. |
|
reviewer-crei-opus (agent review, not human approval): carrier integration review of Verdict: FINAL. No blocking findings. Skip check: no non-author approval names Delta: two commits.
The tree is the union of reviewed heads and main. 116 files change against main. Apart from
Ancestor heads. All of these are ancestors of the carrier, and each has a reviewer-crei-opus FINAL at that exact SHA:
#1506 is the exception. Its head The
That matches this tree, which contains the conditional host and slow reference callee but not the #1615 queried-product stack. It also resolves my earlier "full reduction host" nit. Docs intact.
Nit (non-blocking): one new ROADMAP line ("are available. Native pruned/sparse-query backend composition, a concrete fast Exact Triangle solver") and the inherited #1512 traversal line run past 100 characters. Limits: no local build. Hosted |
|
Agent carrier integration review by Cross-carrier check with #1615 |
|
Landed on main as 231eb1e. Full PR CI and actual combined-tree merge-group CI passed. The landed tree exactly matches the inspected merge group: all 113 accepted native source/test paths are preserved, the matrix stack coexists, imports are canonical, CountFrame is removed, and current defaults, source credit, abstracts and API follow-ups are retained. This delivers #1506, #1508, #1527, #1535, #1537, #1552 and #1557 through the combined-delivery plan. Their PRs will be closed as delivered here, rather than individually merged. The original criteria of #1501, #1481, #1482, #1512, #1446, #1544, #1509 and #1559 are satisfied. The host remains conditional on a certified callee, with a proved exhaustive reference implementation. A concrete fast ET backend and the full ordinary-3SUM/1.9992 endpoint remain open in #1394; this landing does not complete them. AI-assisted coordinator verification; accepted source and independent review records are preserved. |
Integrates complete native Chan–He preprocessing with the conditional ordinary integer 3SUM host, from initialized signed input to the existing verdict. Fixes #1559. Three positions must be distinct; equal values are allowed. A certified finite Exact Triangle callee is required, with a proved slow exhaustive reference instance. This does not provide the fast backend or exponent 1.9992 endpoint in #1394.
This PR is the accepted integration carrier for the work in #1506, #1508, #1527, #1535, #1537, #1552 and #1557, retaining their subsequently reviewed refactors and original source credit. Separate ancestor landings are no longer a prerequisite under that plan; the ancestor PRs remain open until this tree lands and a coordinator verifies their accepted work on main, then records them as landed via #1570, without implying separate GitHub merges. Exact outside review must cover this combined-delivery condition as well as the final integration delta. Final integration checks, full CI and the exact outside-review request are recorded here.
The new delta generalizes the existing Host layout/fill/round/loop proofs to caller-owned source/workspace pointers, retains their standalone specializations, and reuses their unchanged native kernels. The legacy host client adds the corresponding unfold. The optional #1537 review nit is completed by deriving shared Node equality and deleting the test-local instance.
The complete execution endpoint is
Cslib.Algorithms.WordRAM.ThreeSum.Decision.runs_input;Cslib.Algorithms.WordRAM.ThreeSum.Decisionis the public import. For each fixed κ and concrete certified finite ET block with r additional registers, one finite standard-basis program has 128 + (64 + (r+7)) + 16 registers, independent of n and physical width. It starts at actual State.init on signed-encoded integers bounded by (n+2)^κ. Actual raw preprocessing registers 78/79/116 supply the pointer-table base, output count and common packed length. Payloads use signed encoding; metadata and final Boolean are raw unsigned words. Lengths 0/1/2 deliberately return false, with distinct-position impossibility proved, rather than replacing their exact preprocessing lists with empty lists.Write E=2720κ+16456 and V=(n+2)^E. Actual native multiplication/decrement loops compute V, and matrices begin at 2V. The preprocessing prefix theorem bounds every stored pointer and packed length below V; every live table/payload cell is therefore below 2V and survives every call. No relocation or catalogue supplied by a host function is used. The callee receives raw side/F/AB/BC/AC/free registers 0–5, returns raw Boolean 6, establishes its own scratch initialization, and must preserve the whole prefix below AB. Its contract requires actual finite-Code execution on arbitrary old memory, exact zero-triangle correctness, charged time T(t,F), and width d*clog₂(free+F+t+2). It cannot assume zero scratch or an abstract solver instruction. The actual 24-register exhaustive native callee discharges this entire contract with d=8 and T(t,F)=40t³+16; live tests do not assume a generic host solver premise.
All fits follow from one positive physical threshold Cκ,dclog₂(n+2), where Cκ,d=1300κ+7865+(d+1)(E+20)+20. Every actual prefix at every wider admitted width has all words below (n+2)^(2Cκ,d), and memory is zero beyond that interval, including the concrete callee's scratch. The complete charged bound uses preprocessing cost plus 4E+32 and the existing finite count bound times H(N,T(t,2V+1))+12, with the actual common N=8mPar(n,2(n+2)^κ)^2, t=⌊√N⌋+1, and H=5⌊√N⌋+26+2t(131t²+T+25). It charges pointer/address work, all matrix writes, all callee instructions, loop tests and halt. The coarse V is the magnitude actually passed to the caller host; no original n is substituted for packed N and no fast runtime is claimed.
Source mapping: the underlying finite reductions/builders retain Anthropic credit and pin anthropics/formal-math@16a5ce4. Checked directly in ThreeSumApsp/Programs/Sec3/Theorem21a/Convolution/Host.lean:83: “The time of the host: the square root, and 2t rounds with t = ⌊√N⌋ + 1.” The quote describes the reused decomposition; the displayed instruction coefficients are newly proved native costs. Here N is each actual packed length, the source's 2U+1 is our filler 2V+1, its finite ET procedure is the actual certified block, and the existing mathematical instance equivalence supplies the ordinary distinct-position quantifiers. The new caller layout, controller, word/frame/resource proofs and exhaustive callee are original native proofs; source-Light semantics, program/solver oracles and machine imports are not used. Existing Code/ExecWithin/Runs, signed encoding, finite Chan–He instances, Convolution, Exact Triangle and width-prefix APIs are reused rather than introducing parallel mathematical or execution notions.
Validation: all SIX pass together on final corrected tree 4b17b28d88d6f3433d331f737e896ca36d00a011, with one Lean thread and downloads disabled, including Smoke/global Axioms; full citation-aware hygiene --check-simp, actual-base changed-file lints (38 library modules and three new tests), strict PR names, nine reused-native-declaration identity checks and diff checks also pass. Live tests cover initialized positive/repeated-value and negative ordinary inputs, actual flat interpreter runs for 0/1/2, signed ET triples, arbitrary nonzero scratch, a nonzero input pointer with mismatching header, protected future input, and a genuine address-width fault. Curated abstract assessment: no impact on selected statements, scope or rendering; this conditional host is not proposed as a headline. ROADMAP/UPSTREAM preserve the fast native backend/final asymptotic gap.
AI-assisted implementation and proofs by Codex, with author self-review and Lean checks. Nonauthoring technical review found no blocking correctness/API findings at e1858e0 and independently checked the source quote. Root then corrected only the caller-prefix preservation comment; comment-free tokens match the reviewed revision, so implementation coverage is reused. Outside agent review is FINAL at 4093a3f. The coordinator then addressed its three optional test/documentation nits: delete the theorem-only example, explain the library reference callee, and identify the umbrella re-exports. Library comment-free tokens and all concrete tests are unchanged, so correctness/source coverage is reused. These are agent reviews, not human approval; SamuelSchlesinger remains formally requested.