Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions research/rotation-switch-closed-descent/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
retained/** -text whitespace=cr-at-eol
30 changes: 30 additions & 0 deletions research/rotation-switch-closed-descent/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Credit and exact sources

Prepared by Ali Romman with substantial OpenAI Codex assistance in research,
implementation, verification and writing. New work is Apache-2.0.

- Nick Petalas supplied the canonical endpoint formulas and child recurrence
in [PR #7504](https://github.com/CrocSwap/integer-mult-bounds/pull/7504).
The [source proof](https://github.com/petalas/integer-mult-bounds/blob/7efb9a84277ec31abe2a934aeef8c8a70548aa5b/research/canonical-rotation-switch-query/PROOF.md)
and [query](https://github.com/petalas/integer-mult-bounds/blob/7efb9a84277ec31abe2a934aeef8c8a70548aa5b/research/canonical-rotation-switch-query/rotation_query.py)
are retained unchanged. The source README retains its related-work credit.
- Cinna Davis supplied the deterministic compiler in
[PR #4100](https://github.com/CrocSwap/integer-mult-bounds/pull/4100).
The [canonical source](https://github.com/CrocSwap/integer-mult-bounds/blob/337d04939571a637aeab54a0f58f54fde811663a/research/unconditional-batched-crt/check_batched_crt.py)
is called unchanged for finite table comparisons. Its NOTICE is retained.
The full unconditional construction is not an accepted premise here.
- Jerry Chen supplied the fourteen-tape implementation in
[PR #7593](https://github.com/CrocSwap/integer-mult-bounds/pull/7593),
head `56335a406469fad85e88ff72820d506d8bea6f63`. It is related physical
work, not a consumed executable or a claimed automatic speedup.

The new contribution is the two-length closed descent, direct query and
matching bit-probe lower bound. The endpoint formulas retain their source
credit. The canonical compiler is a separate finite oracle; the recurrence
comparison shares the mathematical predecessor. Neither is an independent
human review.

`SOURCE-PINS.json` binds six retained files byte for byte. `SOURCES.json`
binds the base catalogue and selected record as provenance. No unmerged
source ancestry is asserted. The base license is retained. All predecessor
authors named in the retained notices keep their credit.
158 changes: 158 additions & 0 deletions research/rotation-switch-closed-descent/PROOF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# A closed formula for canonical rotation switch queries

This proof changes the arithmetic query in Nick Petalas's
[PR #7504](https://github.com/CrocSwap/integer-mult-bounds/pull/7504).
Its endpoint formulas and child-closure theorem are cited premises, retained
with exact bytes in `retained/pr7504/PROOF.md`. The new result is a closed
descent formula, a linear bit-cost query, and a matching worst-case lower
bound. No new kappa or complete compiler follows.

## 1. Contract

Let `h>=1`, `N=2^h`, `1<=s<=N`, and `0<=a<s`. The permutation sends
`x` to `(x+a) mod s` on `0<=x<s` and fixes every padded address. Use the
deterministic component orientation in Cinna Davis's PR4100 canonical
Beneš compiler. A query supplies row `0<=j<2h-1` and its **current wire**
`0<=x<N`. It asks for the Boolean switch bit, not the final destination
of the input token.

All arithmetic inputs have at most `h+1` bits, except the height and row,
which need `O(log(h+1))` bits. The bit-cost statement charges addition,
comparison, Boolean operations and shifts by their binary implementation.
It assumes no precomputed row table or advice about the query inputs.
It does not specify tape roles, ownership, or restoration.

## 2. Replace offset reduction by two interval lengths

Write `A=a` and `B=s-a`. At a nonidentity node, both are positive. For
child branch `c` in `{0,1}`, define the unreduced lengths

```text
A' = floor((A+c)/2),
B' = floor((B+1-c)/2).
```

The source's four parity cases give `s'=A'+B'` and raw offset `A'`.
This can also be checked by writing `A=2u+alpha`, `B=2v+beta`, with
`alpha,beta` in `{0,1}`. If both new lengths are positive, the source
offset reduction does nothing. If `A'=0`, the child is identity. If
`B'=0`, its raw offset equals its modulus, so the source reduces it to
zero and the child is also identity. If both vanish, it is empty identity.

Thus the pair need not reproduce the source's normalized modulus after
identity is reached. It must only preserve the fact that all later bits
are zero. It does: either zero component stays zero under every subsequent
update. This distinction is necessary. Treating `A'=s'>0` as a nonidentity
child gives a wrong central switch already at `(h,s,a,j,x)=(2,2,1,1,1)`.

## 3. Collapse any number of child steps

The child branches of a table query are the low bits of its current wire:
`c_i=(x>>i) mod 2`. For any depth `0<=d<h`, put

```text
M = 2^d-1, t = x mod 2^d,
A_d = floor((a+t)/2^d),
B_d = floor((s-a+M-t)/2^d).
```

These are exactly the unreduced interval lengths after `d` child steps.
For the first length, repeated halving gives

```text
A_d = floor((a + sum_(i=0)^(d-1) c_i 2^i)/2^d).
```

To prove the step from `d` to `d+1`, use
`floor((floor(z/2^d)+c)/2)=floor((z+c*2^d)/2^(d+1))` for integer `z,c`.
The second length has digit `1-c_i`, whose weighted sum is `M-t`.
The initial case `d=0` gives `(a,s-a)`. This proves both formulas by
induction. Section 2 proves that a zero component correctly represents
every later identity node.

## 4. One endpoint query

Set `d=min(j,2h-2-j)`, `H=h-d`, and `y=x>>d`. After exactly `d`
interior descents, the requested row is an endpoint of height `H`.
The query uses the pair in Section 3 once. If either length is zero,
return zero. If `H=1`, both positive integer lengths must be one; return
one. Otherwise set `S=A_d+B_d` and `A=A_d`.

For the first endpoint, when `j=d`, return

```text
[S and A are odd] [floor(y/2)=floor(S/2)].
```

For the last endpoint, return

```text
[A is odd] [y<S] if S is even;
[y<A] if S is odd and A is even;
[A-1<=y<=S] if S and A are odd.
```

These are precisely the retained endpoint formulas. In particular, the
last case can switch the first padded wire. Section 3, identity absorption,
and the source's child theorem prove equality to the canonical switch
table for every legal height and query. No network or row is constructed.

## 5. Linear work and optimal order of growth

The query has a fixed number of additions, subtractions, comparisons,
Boolean operations and shifts on at most `h+2` bits. It has no descent
loop. The depth and reflected row need `O(log(h+1))` bit work. All remaining
operations have `O(h)` binary work and need `O(h)` temporary bits.

Variable shift lengths do not require a multiplication or division. A
binary counter can emit the required unary prefix using repeated decrement.
Across `d` decrements, the total number of visited trailing-zero bits is
`O(d+log(d+1))`. A return to the counter's low end changes only the constant.
Copy the remaining field in one pass. The mask and prefix restriction use
the same bounded scans. Since `d<h`, this also gives a sequential bit
implementation with `O(h)` work. It is an arithmetic implementation
argument, not a supplied physical tape program or an owned-work contract.

The order of growth cannot improve for exact standalone bit queries. Fix
`h>=2`, `s=2^h-1`, `j=2h-2`, and `x=0`. With an `h`-bit offset field,
the all-zero offset returns zero. Changing any one offset bit `k` with
`1<=k<h` to one gives a legal even offset `2^k`, and the last-endpoint
formula returns one. An exact deterministic algorithm must inspect all
`h-1` such bits on the zero input. Otherwise an unread bit gives an
indistinguishable input with a different answer. This is a bit-probe lower
bound even if every other descriptor is free.

The lower bound does not rely on a long encoding of zero. For `h>=3`,
fix `x=a=2^(h-1)`, the same odd `s` and last row. The baseline answer is
zero. Changing any offset bit `1<=k<h-1` from zero to one gives answer
one while retaining an `h`-bit positive offset. Thus minimal binary
encodings also require `h-2` probes on this input. The worst-case cost is
therefore `Theta(h)` in either encoding. No claim is made about randomized
error, amortized repeated queries, supplied advice, or word-RAM unit cost.

## 6. Verification and boundary

The verifier compares every entry of all 2,793 networks at heights one
through six against the unchanged canonical graph compiler and the
unchanged source recurrence: 1,633,182 entries per comparison. It also
routes all 152,526 addresses, checks 892,854 descent states, and compares
420 wide queries through height 4096. Six explicit cases reach height
65536. Five changed formulas produce wrong source bits; twelve malformed
domains reject before any identity shortcut. The receipt records exact
witnesses and the 544-bit historical row digest.

The full-height theorem is the induction above, not an extrapolation from
these checks. The executable caps height at 65536 to bound allocation.
The lower-bound fixtures test the stated bit sensitivities. They do not
simulate every possible query algorithm.

Nick Petalas supplied the endpoint and child identities. Cinna Davis's
compiler supplies the separate finite oracle. Both retained executables
are shared comparison dependencies. Their complete historical verification
suites are not invoked. Jerry Chen's PR7593 supplies a literal physical
implementation of the earlier quadratic recurrence; its program and cost
are not replaced here. CRT offset production, descriptor serialization,
owned predicate return, clearing, head restoration, payload consumption,
and complete caller pricing remain open. All five selected framework
assumptions remain. This is author checking with substantial OpenAI Codex
assistance, not independent human or formal-kernel acceptance.
78 changes: 78 additions & 0 deletions research/rotation-switch-closed-descent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Optimal linear-bit canonical rotation queries

The exact canonical padded-rotation switch can be queried in `Theta(h)`
worst-case bit work and `O(h)` temporary bits. A closed formula replaces
the repeated child descent of PR7504. It returns the same current-wire
predicate without a permutation, network, row ROM, or recursion stack.
This is an arithmetic construction and scoped proof. **No new kappa** follows.

For row `j`, let `d=min(j,2h-2-j)`, `M=2^d-1`, and `t=x mod 2^d`.
The two child interval lengths are

```text
A = floor((a+t)/2^d),
B = floor((s-a+M-t)/2^d).
```

Either zero length means identity. Otherwise a single retained endpoint
formula at height `h-d` and wire `x>>d` gives the answer. This uses a fixed
number of linear binary operations. A family of inputs needs at least
`h-1` offset-bit probes with padded fields, or `h-2` with minimal positive
encodings, so the worst-case order of growth is sharp.

Read [PROOF.md](PROOF.md), [query.py](query.py), [RESULT.json](RESULT.json),
[SOURCE-PINS.json](SOURCE-PINS.json) and [CREDITS.md](CREDITS.md). The proof
covers every positive height. The executable has a height limit of 65536.

## Evidence and reproduction

Use Python 3.12 and the standard library:

```sh
python3.12 -B scripts/research_package.py --package research/rotation-switch-closed-descent
```

Both registered commands print:

```text
PASS_ROTATION_SWITCH_CLOSED_DESCENT optimal O(h) bit query
```

The verifier checks all 1,633,182 switch entries in 2,793 networks against
the retained canonical compiler and source recurrence. It routes 152,526
addresses and checks 892,854 descent states. Further checks cover 420 wide
source queries, the 544-bit historical row, explicit height-65536 cases,
bit sensitivities, twelve invalid domains and five wrong-formula controls.
The retained sources are authenticated before use. No historical research
entry point is executed. The finite checks corroborate the written proof.

## Scope

This changes an arithmetic query. Jerry Chen's PR7593 already supplies a
fourteen-tape implementation of the earlier recurrence; its literal program
and quadratic bound remain separate. This package supplies no physical
instruction count, caller runtime measurement, or supplier admission.
All five selected framework assumptions remain. Historical suites, physical
caller replay, selected cold replay, Lean and Docker were not run.

## Open next questions

- Lower the closed formula to a literal fixed-tape program. Preserve the
borrowed descriptors, return one owned bit, and price clearing and head
returns. Start with the existing `(h,s,j)=(5,17,6)` boundary. The present
arithmetic proof does not provide that owned-work contract.
- Compose the query with actual current-state CRT offsets and compare a
complete workload against retained row-ROM reuse. Start with the existing
exceptional-key producer. Offset production, descriptor conversion and
payload consumption remain required costs.

`TASK.json` records the changed audit-card scope and these questions. The
base is canonical main `e54523517d0f03e58352e647c403a5af3e525a57`, priority
revision 8. Selected bindings pass; the catalogue assessment is older than
the selected record. The selected frontier is unchanged.

Prepared by Ali Romman with substantial OpenAI Codex assistance. Nick
Petalas supplied the endpoint and child formulas; Cinna Davis supplied the
canonical compiler; Jerry Chen supplied related physical lowering. See the
retained notices and credit file. This is source-aware author checking,
not independent human or formal-kernel acceptance. Apache-2.0.
73 changes: 73 additions & 0 deletions research/rotation-switch-closed-descent/RESULT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"canonical_entries": 1633182,
"descent_states": 892854,
"domain_rejections": 12,
"h5_s17_layer6_entries": 544,
"h5_s17_layer6_sha256": "bc0ab563e6d8fdfa24ee89b50dbe3f9a3a6f23681f491e883c6b5aeef07d4104",
"minimal_encoding_sensitivity_checks": 4237,
"networks": 2793,
"one_bit_sensitivity_checks": 4242,
"queries_beyond_source_cap": 6,
"recursive_entries": 1633182,
"routed_addresses": 152526,
"scope": "O(h) arithmetic bit query; no physical caller or new kappa",
"semantic_mutants": {
"lost carry": {
"expected": 1,
"mutant": 0,
"query": [
2,
3,
1,
1,
1
]
},
"lost identity": {
"expected": 0,
"mutant": 1,
"query": [
2,
2,
1,
1,
1
]
},
"unshifted wire": {
"expected": 1,
"mutant": 0,
"query": [
3,
3,
1,
3,
3
]
},
"wrong complement": {
"expected": 0,
"mutant": 1,
"query": [
2,
2,
1,
1,
1
]
},
"wrong path": {
"expected": 1,
"mutant": 0,
"query": [
2,
3,
1,
1,
1
]
}
},
"table_sha256": "a03bef31f1c4d89ada71e74120ba6cf3ce329153abcb6b38860242d7d95f1863",
"wide_recursive_queries": 420
}
50 changes: 50 additions & 0 deletions research/rotation-switch-closed-descent/SOURCE-PINS.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[
{
"path": "retained/pr7504/rotation_query.py",
"source_repository": "petalas/integer-mult-bounds",
"source_commit": "7efb9a84277ec31abe2a934aeef8c8a70548aa5b",
"source_path": "research/canonical-rotation-switch-query/rotation_query.py",
"git_blob": "d9501b0425b432ff9d2a49b0a4514d7ff9914969",
"sha256": "f38e6a92be46a620d1a8faca9b013fcb44e55dfad329735a30ceb64a413f5cc2"
},
{
"path": "retained/pr7504/PROOF.md",
"source_repository": "petalas/integer-mult-bounds",
"source_commit": "7efb9a84277ec31abe2a934aeef8c8a70548aa5b",
"source_path": "research/canonical-rotation-switch-query/PROOF.md",
"git_blob": "80a8295201d5aea4e37016075ed8df10eca44656",
"sha256": "cd886b0ed8a49153babd2a49887da0abf819902461268bf48f0a1cb6d427bdb1"
},
{
"path": "retained/pr7504/README.md",
"source_repository": "petalas/integer-mult-bounds",
"source_commit": "7efb9a84277ec31abe2a934aeef8c8a70548aa5b",
"source_path": "research/canonical-rotation-switch-query/README.md",
"git_blob": "f17282a6377a5e7d9acc56a25704a3c59eac1eba",
"sha256": "4fb7c3dcd2421f26833810b789e47e9ff2c2c719cd435a110c657da711f12969"
},
{
"path": "retained/pr4100/check_batched_crt.py",
"source_repository": "CrocSwap/integer-mult-bounds",
"source_commit": "337d04939571a637aeab54a0f58f54fde811663a",
"source_path": "research/unconditional-batched-crt/check_batched_crt.py",
"git_blob": "1cf78abccd5e06beecc3ed21ba55f7c03b65fdbc",
"sha256": "681e2e3d71fa74c8b9b326f3860104fd9d89590a222e26ae6ee718d1fd40ff2e"
},
{
"path": "retained/pr4100/NOTICE.md",
"source_repository": "CrocSwap/integer-mult-bounds",
"source_commit": "337d04939571a637aeab54a0f58f54fde811663a",
"source_path": "research/unconditional-batched-crt/NOTICE.md",
"git_blob": "886a8fdee275f01b459cbd68ae2815dc9269502f",
"sha256": "924109837e71c52392191710d49c9deb42780878d1094f0b01e8690dbe799461"
},
{
"path": "retained/base/LICENSE",
"source_repository": "CrocSwap/integer-mult-bounds",
"source_commit": "e54523517d0f03e58352e647c403a5af3e525a57",
"source_path": "LICENSE",
"git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64",
"sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4"
}
]
Loading
Loading