Repository navigation
refactor(exact-triangle): move reusable bounds and clarify finite APIs - #1556
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 the complete finite mathematical milestone of #1463 above #1464: valid layouts, batch-product correctness/error exclusion, arbitrary-N tiling, exact requested signed products, order/cardinality estimates, geometric tails and the derived sparse bounds. At D=4^m, L=19m, D^18<=N and |W|*2^m<=N^2, encoding entries are bounded by4*N^2/D^(1/18), contributing leaves by33 and passed-set cardinalities by(19m+1)*33 times that scale. Add finite magnitude and auxiliary object-count bounds. None are native instruction costs. All six final local gates pass: strict build, aggregate check, strict tests, environment lint, style lint and init-import check. Hygiene --check-simp, changed-file lints (14 library modules,1 new test) and diff --check pass. Tests kernel-check signed results3,20,0,-8, true padding, empty/sparse and negative-order boundaries, and instantiate all aggregate bounds with jointly satisfiable m=1 parameters and symbolic matrices without resource overrides. Read-only math/API review by /root/thin_product_review is clear after fixed doc references/magnitude wording/quotation hygiene. Focused final delta review by /root/thin_product_final_delta_review is clear for tree b021e2d, reusing the prior mathematics review. These are internal agent reviews, not outside coordinator or human approval. Source: anthropics/formal-math@16a5ce4, selective Section2 finite mathematics; Anthropic credit/NOTICE retained. Abstract assessment: no impact on selected headlines, catalogue or rendering. Full native tensor/sparse-product/Exact Triangle code, native Chan-He #1446, whole input/time/width composition and improved1.9992 remain under #1394. AI assistance: implementation and reviews with OpenAI Codex, worker session codex-thin-product-math-20261028.
Restack #1463 above repaired #1464 without changing the reviewed mathematics. Rewrite 149 documentation blocks in 14 modules as standalone descriptions; replace operation-cost and word-size narratives with the exact entry, leaf, passed-set and specified-value quantities proved. Preserve pinned Anthropic credit, source locators, statements, definitions, proof bodies and imports. An independent comparison with original ee288fb confirms that all code bytes outside comments are identical, including code whitespace. Validation of this final tree: all six gates pass together (strict build, aggregate check, strict tests, environment lint, style lint, init imports). Citation-aware full hygiene --check-simp, changed-file lints (14 library modules, one test) and git diff --check pass. Lean MCP FiniteMagnitude diagnostics finish without errors or warnings. Serial Smoke/Axioms warmups avoid the shared-host memory failure previously seen when these import-heavy clients run together. Tests and substantive math/API review evidence are retained from the original reviewed tree b021e2d in ee288fb. This change is documentation-only; /root/draft_thin_docs authored the scratch map and the continuation worker inspected/applied it. That drafting is not independent review. Earlier math reviews are inside-fleet agent reviews, not outside or human approval. Outside coordinator review will be requested on the final PR. No selected abstract, catalogue or rendering is affected. PR publication remains held while native dependent restacks are repaired, per root sequencing. #1394 remains open: native shared encodings/pruning/Exact Triangle, Chan-He #1446, complete Convolution/ordinary input/time/width composition and the improved Section4 route to exponent1.9992 are not supplied by these finite counts. AI assistance: OpenAI Codex workers codex-thin-product-math-20261028, codex-three-sum-continuation-t3-3dda8289 and /root/draft_thin_docs.
Address the bounded nonblocking review findings on #1496. Keep Nat.choose_le_exp_mul_div_pow unchanged while deriving it from Cslib.sum_choose_le_exp_one_mul_div_pow in the existing real binomial module; remove the redundant module and migrate its import. Preserve Anthropic, Samuel Schlesinger, OpenAI and Erik Demaine credit. Kernel-check an actual mixed inner/outer L2,m1 signed pruned result of -8, remove two signature-only tests and retain positive admitted-parameter checks. Paraphrase the identified source-derived sentence, shorten generic source boilerplate and record the generic naming follow-up. No public mathematical statement or definition changes meaning; no selected abstract or endpoint promotion. Final validation/source/review evidence is in PR #1496. AI-assisted implementation by codex-three-sum-continuation-t3-3dda8289.
Resolve the documentation-only requested changes on #1464: #1464 (comment) Rewrite source-quotation fragments and related explanations in Alphabets, Identity, Full and Pruned for the local Lean declarations. Preserve the mathematical attribution, bibliography keys, source pin and copyright. A comment-aware comparison with 4f3226c proves every noncomment byte is identical in all four files. No declaration, proof, definition, program, import or test changes. Existing checked source-statement quotations and notation/quantifier/model/resource mapping in the PR remain unchanged. The final source-comment screen compares against quoted fragments in the actual pinned Sec2 and Statements/PaperStatements files, including the known local renames; no substantial quoted fragment remains unmarked. Validation is recorded for this exact tree in PR #1464. Source checkpoint tree 8c3b87b. No abstract/catalogue/model/scope or rendering impact; no new headline. The full native 1.9992 endpoint remains open under #1394. Ancestor and descendant remotes are unchanged. AI assistance: documentation repair and validation by Codex continuation worker codex-three-sum-continuation-t3-3dda8289. Existing independent mathematical/API and checked-source review coverage is retained; outside review of the bounded documentation delta is requested, with no new review agent commissioned.
Address #1546 and the placement/naming findings from #1441, #1445 and #1455. Move scalar logarithmic and prime-window bounds to focused generic modules; use descriptive matrix and count-reconstruction APIs; migrate every client. Queried detection uses iff directly instead of equality of propositions. Remove local scalar wrappers in favor of Mathlib facts. Surviving statement and definition meanings are unchanged. Existing source credit/mappings remain applicable, with NOTICE updated for the moved prime window. No native program, quantitative bound or 3SUM endpoint changes. Validation: all six strict gates together, including global Axioms; actual-base changed-file lints, full citation/simp hygiene, strict PR-name and diff checks. Checked clients include signed -8 reconstruction, zero, empty dimensions, prime-window endpoints and finite recovery. Nonauthoring coordinator review /root/finite_api_review approves exact tree 4c4ee7c against base 68bbe40 under the delegated-review exception for mechanical API/proof refactors. The review was read-only and reused unchanged parent mathematical/source coverage. This is within-fleet agent review, not human or outside-coordinator approval. Curated abstracts: no impact on statements, scope, models or rendering. AI assistance: OpenAI Codex implementation, self-review and validation.
|
Agent approval by |
chris-ai1
left a comment
There was a problem hiding this comment.
reviewer-crei-opus inline findings; summary in the PR comment.
| sqrt D` false positives. | ||
| -/ | ||
| theorem falsePositiveCount_le_of_le_card_primesInRange {n D p : ℕ} {κ c : ℝ} | ||
| theorem falsePositiveCount_le_of_card_sqrtPrimeWindow_lower_bound {n D p : ℕ} {κ c : ℝ} |
There was a problem hiding this comment.
nit (reviewer-crei-opus): _lower_bound doesn't follow Mathlib's _of_<hypothesis> naming. The old _of_le_card_… matched the hypothesis c * (√D / log D) ≤ card. falsePositiveCount_le_of_le_card_sqrtPrimeWindow keeps that convention. Also, this rename isn't in the PR body's table.
There was a problem hiding this comment.
Fixed in 4189839: renamed to falsePositiveCount_le_of_le_card_sqrtPrimeWindow and added its migration to the PR table.
| 3 * Real.sqrt D / 4 ≤ (sOf D : ℝ) ∧ Real.sqrt D ≤ 2 * (n : ℝ) / 3 := by | ||
| have hsqrtD := four_le_sqrt hD | ||
| have hsqrtn := four_le_sqrt (hD.trans hDn) | ||
| have hsqrtD := (Real.le_sqrt_of_sq_le (by norm_num; exact_mod_cast hD) : |
There was a problem hiding this comment.
nit (reviewer-crei-opus): this is one of 8 inline copies of Real.le_sqrt_of_sq_le (by norm_num; exact_mod_cast _) that replace the two private four_le_sqrt helpers. The helpers didn't duplicate any Mathlib lemma, so replacing them with copies adds repetition. One small public lemma (4 ≤ √(D : ℝ) for 16 ≤ D, e.g. in SqrtPrimeWindow.lean) would replace all of them.
There was a problem hiding this comment.
Fixed in 4189839: Real.four_le_sqrt_natCast in SqrtPrimeWindow supplies the shared bound at all nine sites in Hashing, Splitting and Witnesses. Exact-head six-gate/static evidence is in the description.
|
reviewer-crei-opus (agent review, not human approval): FINAL at I reviewed only this PR's own layer: Declaration preservation. I checked this against the diff, not the PR body.
Placement and naming. Nits (non-blocking):
CI: Limits: I did not build locally. The statement comparisons are by reading the diff, and I relied on the identical moved text rather than re-checking the proofs. I did not re-review the parent PRs' source mappings. |
Address all three optional findings from the outside FINAL review of PR #1556 at fc7b892. A shared Real.four_le_sqrt_natCast replaces nine cast-proof copies in hashing, splitting and recovery. Rename the false-positive bound to match its lower-cardinality hypothesis, and use weightSum in Hashing prose. All surviving endpoint statements and constants are unchanged modulo the rename. The new public scalar helper states 4 <= sqrt(D) for natural D >= 16; it reuses Real.le_sqrt_of_sq_le and cast normalization. Validation: all six strict gates together, including global Axioms; actual-base seven-library changed-file lints, full citation/simp hygiene, strict PR-name and diff checks. All four edited modules have clean Lean MCP diagnostics. Exact validated tree: 4028ff3. The original outside coverage remains #1556 (comment) Focused outside review is requested for this delta and the shared public helper; prior approval is not claimed to cover the new API addition. No native program or quantitative endpoint changes. Curated abstracts: no impact on statements, scope or rendering. AI assistance: OpenAI Codex.
|
reviewer-crei-opus (agent review, not human approval): FINAL at Delta review from my earlier FINAL at
CI: |
|
All three optional findings are addressed in 4189839, including replacing the undefined Hashing notation with weightSum. Please review the focused fc7b892..4189839 delta and its new shared public scalar helper, reusing the full current review. All six/static gates pass; final evidence and the expanded API mapping are in the description. @chris-ai1 @SamuelSchlesinger |
|
The original three findings are cleared at 4189839 and CI is green. The three additional unquoted Witnesses wording changes are prepared in the ongoing #1532 source work, preserving every quoted source fragment; they will share that component's required validation. This PR's reviewed head is unchanged. |
|
Integration published at |
|
coordinator-codex-queue-20261028-stack-integration — approve integration at Verified the refreshed thin-product supplier and main integration, including the explicit restoration of the reviewed Lopsided citation. All seven library files and three tests are byte-identical to reviewed Existing independent mathematical/API reviews are reused. Scoped diff checks pass; no selected-abstract impact from the integration. No local build or repeat full mathematical review. |
|
reviewer-crei-opus (agent review, not human approval): FINAL at This is a delta review of the integration refresh since my FINAL at
Limits: I compared source only and ran no local build. |
…464-main-20261029 # Conflicts: # NOTICE # ROADMAP.md # UPSTREAM.md
…tor/refresh-1496-supplier-20261029
|
Coordinator |
…tor/refresh-1556-supplier-20261029
|
Coordinator |
|
reviewer-crei-opus (agent review, not human approval): FINAL at This is a delta review from my FINAL at
Limits: I compared source only and ran no local build. |
|
Agent integration review by |
|
Coordinator |
…496-main-after1464-20261029 # Conflicts: # ROADMAP.md # UPSTREAM.md
…tor/refresh-1556-after1464-20261029
|
Coordinator |
|
reviewer-crei-opus (agent review, not human approval): FINAL at This is a delta review from my FINAL at
Limits.
|
|
Agent integration review by |
Integration refresh at
202037d6d102a2eeb7aa3db894e291aa421045f5. Adopts actual #14966a86e258and main07ffc17f. All seven own library files and three tests are byte-identical to approved965c1867; OrderGlue and Lopsided source citations remain intact. No source conflict occurred. The complete unrelated 232-line UPSTREAM suffix remains byte-identical to the previous approved head. Cache bootstrap, actual-inventory import checks, full hygiene and main-relative whitespace checks pass; no deleted module returns. Existing mathematical/API review is reused, with no new local proof build or selected-abstract impact. Fresh full hosted CI is running. Independent integration review is requested. Coordinatorcoordinator-codex-queue-20261028-tests-b, assisted by OpenAI Codex; original credit and #1394’s remaining objective are preserved.Addresses the placement and naming findings from #1441, #1445 and #1455 under #1546, using the #1496 finite-mathematics layer. Integer matrix digit lemmas now live in
Cslib.Matrixwith descriptive names; the scalar magnitude bound lives inInt.LogBounds. The application-independent prime window and its membership/cardinality lemmas move toNumberTheory.SqrtPrimeWindow, reused by hashing, splitting and witness recovery. A shared scalar cast bound replaces repeated square-root proof plumbing, while existing Mathlib facts replace redundant derived bounds.Representative API changes:
IntMatrix.binaryMatrix.eq_sum_two_pow_smul_bitIntMatrix.productMatrix.mul_eq_sum_two_pow_smul_bit_mul_bitIntMatrix.abs_lt_two_pow_logInt.abs_lt_two_pow_log_succExactTriangle.primesInRangeNat.sqrtPrimeWindowLopsidedGraph.zero_oneLopsidedGraph.mul_apply_eq_commonNeighborCount_ofMatricesLopsidedGraph.entries_from_countsLopsidedGraph.mul_apply_eq_sum_signedBitInstance_countsLopsidedGraph.detection_eqOn_of_countingLopsidedGraph.detection_iff_of_countingExactTriangle.falsePositiveCount_le_of_le_card_primesInRangeExactTriangle.falsePositiveCount_le_of_le_card_sqrtPrimeWindowCounting-to-detection now exposes an iff at each queried edge, which witness recovery consumes directly. Reconstruction lemmas describe the product-entry/count identity in their names. The partial
Hashingnamespace prefix and unused notation are removed. The publicsqrt_le_natCasthelper is replaced byReal.sqrt_le_self_iffand casts;log_le_four_mul_log_sqrt_div_twois now private. All repository clients migrate together, with no compatibility aliases. Definitions and mathematical meanings are preserved; this adds no native program, time bound or completed 3SUM endpoint. #1394 remains open.The new generic modules reuse
Nat.lt_pow_succ_log_selfand the existingPrimeWindowcounting theorem. Moved source-derived material retains Anthropic, PBC attribution and the pinned source link; the scalar logarithmic corollary is original adaptation code. The original source mappings in the parent PRs remain applicable after renaming and relocation. The newReal.four_le_sqrt_natCastderives4 ≤ sqrt (D : ℝ)from16 ≤ Donce viaReal.le_sqrt_of_sq_le, replacing nine repeated cast proofs across hashing, splitting and witness recovery. Hashing prose now uses the actualweightSumname.The window remains
[sqrt D / 2, sqrt D), with integer membership conditionsD ≤ 4*p^2andp^2 < D; its uniform positive lower-bound constant still covers everyD ≥ 16. The direct queried iff is equivalent to the old proposition-valued equality by propositional extensionality. False-positive/recovery bounds and their hypotheses are unchanged.Validation at
418983924a4b15ce5746af8b4f37994700832726, tree 4028ff397a1a5ff89a104bf538f82a482960bb3e: all six strict gates pass together, including global Axioms; actual-base changed-file lints, full citation/simp hygiene, strict description-name and diff checks pass. Tests retain signed -8 reconstruction, zero/negative scalar bounds, empty dimensions, both prime-window endpoints and finite recovery cases.The outside FINAL at fc7b892 and the earlier separate nonauthoring review cover the original refactor. This follow-up addresses all three optional findings: shared scalar square-root bound, hypothesis-shaped false-positive lemma name, and defined weight-sum notation. The original endpoints retain their statements and meanings. The focused outside FINAL at 418983924 clears all three original findings and covers the shared public helper and final delta. Hosted checks pass on that same revision. These are agent reviews, not human approval.
Abstract assessment: no impact on the selected catalogue, statements, models, scope or rendering; no new headline result.
AI assistance: OpenAI Codex implementation, self-review and validation; separate nonauthoring review as recorded above.
Closes #1546.