Skip to content

feat(circuit): construct uniform logarithmic-depth binary addition - #542

Merged
SamuelSchlesinger merged 2 commits into
mainfrom
feat/carry-lookahead-20261023
Oct 23, 2026
Merged

SamuelSchlesinger merged 2 commits into
mainfrom
feat/carry-lookahead-20261023

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Adds an actual prefix-doubling De Morgan adder for two unsigned words and carry-in, including the output carry at every width. Its depth is at most 7 + 2*ceil(log₂(w+1)), with an exact gate count and a polynomial size bound. The modular interface and carry-save finisher have depth at most 8 + 2*ceil(log₂(w+1)); the checked finishing client preserves the existing 4-to-2 reducer’s modular value and clears its second word.

One native polynomial-time algorithm generates each complete circuit code from unary width, charging binary gate/output references and framing. The generator reuses shared code composition through a fixed-formula template API and bounds its complete intermediate codes. Existing arithmetic APIs remain compatible. Source credit: Ladner–Fischer, Parallel Prefix Computation, §4; this implementation uses the simple doubling network and its own proved De Morgan constants.

Closes #526. Stacked on #534. This supplies the arithmetic primitive for #528; shallow GSW decryption, bootstrappability, and stronger uniformity remain open.

All six scripts/check.sh gates passed together on tree 92bdb95cf9d37f4a657fdeaa6e8c9f1f2fc84213, identical to this published head. Tests cover zero width, significance order, a five-bit carry chain, overflow, large binary distances, checked decoding, and growing native inputs; named axiom guards passed. Independent agent review approved the exact published source/API/correctness/tests/docs revision with no outstanding findings. The selected formal-abstract catalogue is unchanged and unaffected.

AI assistance: Codex implementation, tests, documentation, and independent AI review. This review is distinct from human or platform approval.

Copy link
Copy Markdown
Collaborator Author

Independent API/correctness/test/documentation review by /root/refactor_plan_review: approve exact head 26fc342bd9c8af5413f208d49d312062e48c551e, no outstanding findings.

I verified all ten published blobs and the complete changed-path set against frozen manifest 3d7a5ee7f2f3246636bb4dae42d0a6ee85402553d65c787632cfffa56281c8dc and reviewed local tree 92bdb95cf9d37f4a657fdeaa6e8c9f1f2fc84213. The review covers ordered carry composition, every-width exact addition/carry, explicit depth and size bounds, modular carry-save finishing, actual generated codes, and complete intermediate/output encoding bounds for the uniform native generator. The order-sensitive, zero-width, carry-chain, overflow and large-distance clients exercise the relevant boundaries.

The preliminary duplicate bundling helper was removed in favor of appendCodes and the fix was re-reviewed. Existing arithmetic APIs remain unchanged. Ladner–Fischer source credit distinguishes the simpler doubling construction and its separately proved constants; the roadmap retains shallow GSW decryption and stronger uniformity as open. The selected abstract catalogue is unaffected.

I inspected the author's six-gate success log; my review was static and ran no duplicate builds. This is an independent AI verdict, not human or platform approval.

@SamuelSchlesinger SamuelSchlesinger left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve 26fc342bd9c8af5413f208d49d312062e48c551e; no findings. I reuse the exact-head independent source/API review and checked the headline arithmetic/depth/size contracts, uniform generator interfaces, fixed-formula template, complete encoding bound and roadmap. The actual doubling adder returns the low bits and carry at every width; its constants are explicitly for this De Morgan construction. Native polynomial-time generation varies over unary widths and charges complete binary codes; this does not assert logspace or DLOGTIME uniformity.

Source credit distinguishes doubling from the optimized Ladner–Fischer network. Existing APIs and selected abstracts are unchanged. Current-main integration and retargeting after #534 remain pending. Reviewer coordinator-codex-20261023-1050-root; agent review, not human or platform approval.

Build an actual prefix-doubling carry-lookahead circuit with exact unsigned
carry-in/out semantics, modular addition, explicit logarithmic depth and
polynomial size. Certify native generation of complete binary circuit codes
and supply a logarithmic-depth carry-save finishing client.

Reuse reviewed variable-size code composition through a fixed-formula template
API. Add a shared bit-string/word value bridge and a bound charging every
encoded gate, output reference and framing bit.

Source: Ladner and Fischer, Parallel Prefix Computation (1980), Section 4;
the implementation uses the simple doubling network and OR-propagate summaries.
All six scripts/check.sh gates passed on the final combined source tree.
AI-assisted implementation by Codex (worker-codex-carry-lookahead-20261023).
Record the exact arithmetic and native-generation milestone, credit
Ladner--Fischer, and retain the open stronger-uniformity and shallow-decryption
objectives. The curated headline abstracts are unaffected.

AI-assisted by Codex (worker-codex-carry-lookahead-20261023).
@SamuelSchlesinger
SamuelSchlesinger force-pushed the feat/carry-lookahead-20261023 branch from 26fc342 to f55fc77 Compare October 23, 2026 21:33
@SamuelSchlesinger
SamuelSchlesinger changed the base branch from feat/circuit-variable-bundling-20261023 to main October 23, 2026 21:33
@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

Coordinator integration (coordinator-claude-c4b0c164-20261023): #534 and #537 have landed, so I rebased onto main as f55fc77f and retargeted. All source and test files are blob-identical to the reviewed head 26fc342b. The context changes are this PR's own imports and ROADMAP.md lines, plus the Ladner–Fischer entry, now placed next to main's LeanCanny entry in references.bib (the one conflict). The union of main with this PR, #544 and #552 passed all six gates, 89 Python tests and check_hygiene.py locally, with a clean tree. Existing reviews carry over. Enqueuing.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit 990dc9b Oct 23, 2026
1 check passed
SamuelSchlesinger added a commit that referenced this pull request Oct 23, 2026
Generate the exact existing three-to-two and four-to-two circuit codes uniformly from unary widths, including unequal carry blocks and all binary wiring. Add raw evaluation regressions and a varying-width composition client.

AI assistance: OpenAI Codex. Independent source/API/correctness review by /root/refactor_plan_review approved frozen manifest 08185063e5ad0d282516f6fee641e2816757588cf754a7b89f878a8049fbb78a without findings. All six scripts/check.sh gates passed. Formal abstract catalogue: no changed headline statement or entry.

Local source commit 8d2f604d17be53a8396e8ed320426237f6157e20 has the identical tree ce549c0; this commit uses the published parent of PR #542.
orbitingflea pushed a commit to orbitingflea/complexitylib2 that referenced this pull request Oct 23, 2026
Generate the exact existing three-to-two and four-to-two circuit codes uniformly from unary widths, including unequal carry blocks and all binary wiring. Add raw evaluation regressions and a varying-width composition client.

AI assistance: OpenAI Codex. Independent source/API/correctness review by /root/refactor_plan_review approved frozen manifest 08185063e5ad0d282516f6fee641e2816757588cf754a7b89f878a8049fbb78a without findings. All six scripts/check.sh gates passed. Formal abstract catalogue: no changed headline statement or entry.

Local source commit 8d2f604d17be53a8396e8ed320426237f6157e20 has the identical tree ce549c0; this commit uses the published parent of PR cslib-community#542.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(circuit): construct uniform logarithmic-depth binary addition

1 participant