Skip to content

feat(arithmetic): add casting-out residues and delayed mod-17 reduction - #273

Merged
RobinLinus merged 3 commits into
solving-bitcoin:mainfrom
brenorb:claude/seeded-primitive-8
Nov 9, 2026
Merged

RobinLinus merged 3 commits into
solving-bitcoin:mainfrom
brenorb:claude/seeded-primitive-8

Conversation

@brenorb

@brenorb brenorb commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds u4::mod15 (base-16 integer residue modulo 15, running and delayed-ladder schedules), u4::mod17::u4_nibbles_to_mod17_delayed (same residue as the existing fold, reduced once at the end), and u32::mersenne_residue (u32_mod255, u32_mod65535).
  • Existing u4_nibbles_to_mod17 and its tests are unchanged; the delayed schedule is additive.
  • Records the knowledge page, three catalog records, comparison, NR-095 (per-step normalization dominated beyond three nibbles) and OP-051 (residue-check consumer frontier).

Evidence

  • 64 nibbles: mod 15 running 1,214 vs ladder 833 script bytes (-31%); mod 17 running 1,342 vs delayed 894 (-33%); at the 997 limit mod 17 falls 20,926 -> 13,066 (-38%). Peaks are unchanged (n+3); the running form wins only below four nibbles. u32 byte-sum residues: 87 (mod 255) and 115 (mod 65,535) bytes vs 100 for mod 65,537. Sizes pinned by tests.
  • Tests: exhaustive 1-3 digit vectors for mod-15 schedules and the delayed mod-17; seeded vectors up to 128 nibbles against conventional base-16 evaluation; all 4,096 byte-boundary combinations (with a rejected off-by-one residue) for mod 255; all 64 lane-boundary pairs plus 300 random words for mod 65,535; non-canonical and out-of-range limbs at every position; preserved main/alt state; generation bounds; exact stack frontier for the mod-15 schedules.
  • The mod-15 and mod-255/65,535 residues are digit/limb sums and cannot see transpositions; the page says so. Evidence locally-reproduced; execution unclassified. No Bitcoin Core validation or deployability claim.
  • Note: NR/OP numbering follows PRs 266-272 (NR-088..094, OP-044..050); PR 265 uses NR-087/OP-043.

Test plan

  • CARGO_PROFILE_DEV_OPT_LEVEL=1 CARGO_PROFILE_TEST_OPT_LEVEL=1 cargo test --locked -- --skip fields:: (all suites pass)
  • python3 tools/kb.py validate

🤖 Generated with Claude Code

Table-free modulo-15 residue of a canonical u4 vector (running and ladder
schedules), a delayed-reduction modulo-17 schedule, and u32 residues
modulo 255 and 65,535. Keeping the sum exact and reducing once saves 31%
(mod 15) and 33% (mod 17) at 64 nibbles, 38% at 997, with the same peak.
Evidence locally-reproduced; execution unclassified.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T07:56:54.780302Z c45c797 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c45c797a60

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread knowledge/primitives/u4-mod15.md Resolved
Comment thread src/arithmetic/u4/mod15.rs Resolved
Comment thread knowledge/primitives/u4-mod15.md Resolved

Copy link
Copy Markdown
Contributor

Review of c45c797a60cf: leaving this PR open pending the following changes.

The reproduction instructions pass two positional test filters to Cargo; that command fails before running tests. Split the mod15/mod17 commands. More importantly for the claimed locally-reproduced comparison, the published 997-nibble mod17 result (13,066 bytes) is not pinned by the new size/metric tests, which stop at 128/32. Add that boundary measurement, and explicitly document the caller's required residue comparison and terminal clean-stack step.

The current CI is green; these are contract, boundary, or evidence gaps that those checks do not cover.

brenorb commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, @RobinLinus! The reproduction commands now use separate Cargo filters, and tests pin both 997-nibble fragment sizes. I documented the terminal residue check and clean-stack obligation, and aligned the recorded metrics with execution of the exact policy-compiled fragments under the stated profile. Focused tests, metrics and knowledge validation pass on the merged base; CI is running and the full non-field suite is queued.

@RobinLinus
RobinLinus merged commit 26e9c8c into solving-bitcoin:main Nov 9, 2026
3 checks passed
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.

2 participants