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
19 changes: 18 additions & 1 deletion docs/ci-verification.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
# CI verification

## Current selected-family replay: #6030
## Current selected-family replay: #7000 with #7001

The [selected record](../certificates/selected-result.json) binds conditional
κ = 0.00363005817 to the [application review](research/pr-intake-evidence/pr7000-application/PROOF-REVIEW.md),
[validation receipts](research/pr-intake-evidence/pr7000-application/VALIDATION.json),
and [explicit source closure](../certificates/frontier7000-source.json).
`make frontier7000-verify` follows that exact-source selected replay. The review
reuses eleven authenticated preceding executions and records seven fresh serial
application, scalar and complete native-catalogue executions. The earlier
monolithic timeout is retained separately and is not completed coverage.
Consult the receipts for exact commands, source heads and limits.

The five inherited framework assumptions remain. No complete uniform word,
literal multiplier execution, independent human proof or formal-kernel proof
is asserted. Routine research submissions do not need to rerun this
selected-family replay. The sections below preserve historical checkpoints.

## Historical selected-family replay: #6030

The [historical checkpoint](../certificates/checkpoints/frontier6030.json) binds conditional
κ = 0.003125804 to the [proof review](research/pr-intake-evidence/pr6030-audit/PROOF-REVIEW.md),
[validation receipts](research/pr-intake-evidence/pr6030-audit/VALIDATION.json),
and [explicit source closure](../certificates/frontier6030-source.json).
Expand Down
238 changes: 238 additions & 0 deletions research/canonical-rotation-switch-query/PROOF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
# Direct canonical switch queries for padded rotations

This scoped written proof gives a new arithmetic construction of the precise
deterministic tables in Cinna Davis's #4100 `check_batched_crt.py:benes`.
The source is pinned at canonical main
`e54523517d0f03e58352e647c403a5af3e525a57` in SOURCES.json. Its generic
permutation-routing theorem is a cited premise. No predecessor replay is a
deliverable of this package. This contribution was produced by Nick Petalas.

## 1. Domain and result

Let `N=2^h`, `h>=1`, `1<=s<=N`, and `0<=a<s`. Write

```
P(x) = (x+a) mod s for 0<=x<s,
P(x) = x for s<=x<N.
```

There are `2h-1` canonical switch rows, numbered from zero. A row at index
`j` flips axis `min(j,2h-2-j)` when its table bit at the *current wire*
address is one. This is a table query, not a query indexed by the original
input token's address.

For `h>1`, the first row is

```
F(x) = [s and a are odd] [floor(x/2)=floor(s/2)]. (1)
```

The last row is

```
L(x) = [a is odd] [x<s] if s is even;
L(x) = [x<a] if s is odd, a even;
L(x) = [a-1 <= x <= s] if s and a are odd. (2)
```

Brackets denote the indicator of a condition. For branch `c` in `{0,1}`,
put

```
s_c = floor(s/2) + [s odd and c=(a mod 2)],
b_c = floor(a/2) + c(a mod 2),
a_c = b_c mod s_c. (3)
```

The child on that branch is exactly the padded rotation with parameters
`(N/2,s_c,a_c)`. An empty child is identity and needs no modular division.
In every nonempty child `0<=b_c<=s_c`, so reduction in (3) is just replacing
`b_c=s_c` by zero. Thus no general integer division is necessary.

For an interior row `0<j<2h-2`, its bit is the child's bit at

```
(h,s,a,j,x) -> (h-1,s_(x mod 2),a_(x mod 2),j-1,floor(x/2)). (4)
```

At `h=1`, the only row has constant bit `a`. If `a=0`, the entire network
is identity. Equations (1)-(4) compute one canonical bit by at most `h`
iterations, with `O(h^2)` elementary bit operations and `O(h)` working bits.
These are bounds for bounded-integer arithmetic, not a physical tape bill.

## 2. Canonical component colors

The source colors the graph with the two perfect matchings

```
A(x)=x xor 1, B(x)=P^{-1}(P(x) xor 1).
```

It starts each uncolored component at its least vertex with color zero.
For an even-cycle component, fixing that first color uniquely determines
all colors. DFS neighbor order therefore does not affect the result. The
source's endpoint rows are

```
F(x)=color(x) xor (x mod 2),
L(y)=color(P^{-1}(y)) xor (y mod 2). (5)
```

Call `A` pairs with coincident `B` edges doubled pairs. Every doubled pair
whose least endpoint is even has colors equal to address parity.
Write `s=2m+epsilon`, `a=2b+delta`.

If `s` and `a` are both even, all components are doubled pairs. If `s` is
even and `a` is odd, the active interval `[0,s-1]` forms one alternating
cycle: its `B` edges are `(1,2),(3,4),...,(s-3,s-2),(s-1,0)`.
All remaining components are doubled pairs. Both cases give
`color(x)=x mod 2` everywhere. The size-two cycle may itself be doubled.

Suppose `s` is odd and `a` is even. The component containing the first
padded vertex `s` is the interval `[s-a-1,s]`. Its edges alternate along
successive vertices, with one closing `B` edge between the interval's
endpoints. Its least vertex `s-a-1` is even. Every other component is a
doubled pair. Again `color(x)=x mod 2` everywhere. For `a=0` the named
interval is just the doubled pair `(s-1,s)`.

Finally suppose `s` and `a` are odd. Put `t=s-a`, which is even and at
least two. The exceptional component has vertices

```
0,1,...,t-1, s, s-1.
```

There are alternating consecutive edges on `[0,t-1]`, the `B` edges
`(t-1,s)` and `(s-1,0)`, and the `A` edge `(s-1,s)`.
Starting at zero gives parity colors on `[0,t-1]`, color zero at `s`,
and color one at `s-1`. All other components are doubled pairs. Hence

```
color(x) = (x mod 2) xor [x in {s-1,s}]. (6)
```

These descriptions follow directly by substituting the rotation and its
inverse into `B`; they list all edges because each vertex has one `A`
neighbor and one `B` neighbor. In particular they also identify each
component's least vertex and settle the source's orientation convention.
Substitution in the first equation of (5) proves (1).

## 3. The last row

For `y<s`, the inverse is `y-a` when `y>=a`, and `y+s-a` when `y<a`.
For `y>=s` the inverse is `y`.

When `s` is even, the active inverse changes parity exactly when `a` is
odd, giving the first line of (2). When `s` is odd and `a` even, precisely
`y<a` changes parity, giving the second line. When both are odd, the
inverse changes parity on `[a,s-1]`. The two exceptional colors in (6)
occur at inverse addresses `s-1` and `s`, corresponding to `y=a-1` and
`y=s`. Neither is in `[a,s-1]`; adding both gives `[a-1,s]` and proves
the third line. The first padded wire can have a nonzero switch even
though the completed permutation fixes every padded wire.

## 4. Child closure

The source defines child `c` at index `floor(x/2)` to have value
`floor(P(x)/2)` for the unique `x` of color `c` in that input pair.
The parity cases give the following complete table. A zero modulus is
the empty identity child.

| s | a | child 0 modulus, offset | child 1 modulus, offset |
| --- | --- | --- | --- |
| 2m | 2b | m, b mod m | m, b mod m |
| 2m | 2b+1 | m, b mod m | m, (b+1) mod m |
| 2m+1 | 2b | m+1, b mod (m+1) | m, b mod m |
| 2m+1 | 2b+1 | m, b mod m | m+1, (b+1) mod (m+1) |

For the first three rows, colors are parity, so substituting `x=2z+c`
into the two branches of `P` gives the displayed rotation. At any input
pair entirely beyond the active range, `P` fixes both addresses and the
child fixes its index.

For the last row, child zero uses `x=2z` for `z<m`, and uses the padded
`x=s` at `z=m`; child one uses `x=2z+1` for `z<m`, and uses `x=s-1` at
`z=m`. For child zero, the active values are

```
z+b when z<m-b,
z+b-m when m-b<=z<m;
```

the index `m` is fixed. Thus its modulus is `m` and its offset is `b`.
For child one the values are

```
z+b+1 when z<m-b,
z+b-m when m-b<=z<m,
b when z=m.
```

This is the rotation modulo `m+1` by `b+1`. All larger indices are fixed.
The table is exactly (3), including its padding behavior. Induction on
`h`, using the source's interleaving of the two child tables, proves (4)
and equality of every directly computed bit to its canonical source bit.

## 5. Arithmetic cost and scope

Keep four records for `s,a,x,j` and a record for the current height. At
most the initial `h+1` bits are needed by any of `s,a,x`; the row and
height records need `O(log(h+1))` bits. Each descent requires parity
tests, halving, a constant number of comparisons, additions and
subtractions, and the equality reduction in (3). Scanning their binary
records implements each operation in `O(h+1)` bit operations. Height
decreases at every descent, so total work is `O(h^2)` and working storage
is `O(h)`. No recursion stack, permutation, component graph or row ROM is
part of the new evaluator. The Python implementation bounds `h<=4096`;
the written recurrence and proof apply to every positive `h`.

This is not a shortest-switch circuit or a claim that physical repeated
queries are always cheaper than a retained ROM. It gives the exact same
Boolean table predicate, a useful prerequisite for replacing the whole-ROM
producer in the current-state key boundary. Producing the current CRT
offset, serializing descriptors, returning an owned predicate, disposing
of work, physical tape access, malformed-stream recovery and a complete
caller bill remain separate. No supplier admission, new kappa, or complete
multiplication theorem follows.

## 6. Verification and bounded-resource implementation

The verifier compares the new evaluator with the pinned canonical
definition for every modulus and offset at heights one through five. It
also extracts the two actual child permutations and checks (3), then
routes every address using only the new point queries. These are finite
checks of the new construction, not a re-execution of #4100's research
verification or a substitute for the proof above. It hashes the 544
bit-bytes at `h=5,s=17,j=6`, the key's table geometry, without importing a
predecessor receipt. Domain, semantic and large-width checks are explicit
exceptions and remain active under Python optimization.

Power of Ten inspection: all new functions fit within 60 physical lines;
the evaluator has one loop bounded by 4096 and no recursion. Verification
heights are bounded by five and each network has at most 32 addresses and
nine rows. The imported canonical comparison function recursively
constructs only these small networks, with depth at most five. This is a
rule-1 deviation for an immutable source oracle; the new evaluator and
new verification loops are iterative. Replacing that oracle would remove
the exact-source comparison this package needs. Follow-up: retain the
depth cap whenever increasing finite coverage.

Python's managed runtime allocates integers and small containers during
execution, a rule-3 deviation. The public height cap bounds the live
evaluator integers by 4097 bits and the fixed census bounds its live
network storage. The inherited comparison oracle allocates at most five
levels with 32 wires at the top. No asynchronous work, open file resource,
dynamic code generation or newly shared mutable state is introduced.
The sole import through a file loader has a fixed SHA256-authenticated
target and is a rule-9 deviation for the comparison oracle, not a dynamic
production dispatch. Normal and optimized warning-strict runs, source
authentication and the finite rejection controls are the compensating
checks. Follow-up: changing that target requires a new source pin and
review of this proof's orientation convention.

No project Python linter or installed `ruff`, `mypy` or `pyright` was
available. Warning-strict normal and optimized execution, AST parsing,
registered package metadata/source checks and committed-byte checks are
the available diagnostics. The two warning-strict commands are registered
in VERIFY.json for recurring CI replay; no shared diagnostic configuration
is changed.
132 changes: 132 additions & 0 deletions research/canonical-rotation-switch-query/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Direct canonical Beneš bits for padded modular rotations

One switch bit of the canonical network for `x -> (x+a) mod s` on
`x<s<=2^h`, fixing the padded addresses, can be computed in `O(h^2)` bit
operations and `O(h)` working bits. No permutation, component graph or
whole row ROM is constructed by the new evaluator.

This is a scoped written proof and arithmetic construction, with finite
exact corroboration. It computes precisely Cinna Davis's #4100 canonical
tables, including the deterministic component orientations. No new kappa,
physical tape tariff or supplier admission is claimed.

## Result

For `h>1`, the first row is zero except for the pair `{s-1,s}` when both
`s` and `a` are odd. The last row has the following one-bit predicate at
the current wire address `x`.

| Parameters | Last-row bit |
| --- | --- |
| s even | `[a odd] [x<s]` |
| s odd, a even | `[x<a]` |
| s odd, a odd | `[a-1<=x<=s]` |

For child branch `c` in `{0,1}`, the canonical child is itself a padded
rotation with

```
s_c = floor(s/2) + [s odd and c=(a mod 2)]
a_c = (floor(a/2) + c(a mod 2)) mod s_c.
```

An empty child is identity. The only possible reduction is equality with
`s_c`, which is replaced by zero. An interior point query follows branch
`x mod 2`, halves `x`, and reduces both height and row index by one. The
base row at height one has constant bit `a`. Thus at most `h` iterations
suffice. [PROOF.md](PROOF.md) proves the formulas by identifying the
source's colored matching components and its exact child permutations.

At the handoff's `h=5,s=17,j=6` geometry this supplies any of the 544
offset/address bits without constructing that whole ROM. It does not yet
provide a literal physical predicate-return service.

## Evidence and scope

The verifier checks all 713 networks with `1<=h<=5`, every modulus
`1<=s<=2^h` and every offset `0<=a<s`. All 168,862 directly computed switch
entries equal the pinned canonical definition. It extracts and checks 710
root decompositions, and independently checks 19,406 routed endpoints
using the new point queries. Twelve invalid-domain cases and six semantic
controls pass. Twenty large-width queries, including full-depth paths
through `h=4096`, need no exponentially sized reference network.

The finite counts describe the new evaluator's checks. The generic source
compiler is an oracle, not a predecessor scientific result audited here.
The universal claim rests on the written proof, not extrapolation.
`--receipt` writes a generated report bound to all seven package-file
SHA256 hashes and the live canonical source hash. No receipt is hand-written.

The public implementation caps `h` at 4096 to bound managed-runtime
allocation. The recurrence and proof have no such mathematical cap.
PROOF.md records the bounded Python-allocation and immutable-oracle
recursion/loader deviations from Power of Ten. The production evaluator
itself is iterative and uses no imported scientific implementation.

## Reproduce

From the repository root, using CPython 3.12 and the standard library:

```sh
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -W error -B research/canonical-rotation-switch-query/verify.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -W error -O -B research/canonical-rotation-switch-query/verify.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/canonical-rotation-switch-query
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/canonical-rotation-switch-query --check-source-history
```

Another CPython 3.12 executable may replace the local path. Direct verification
ends with `PASS_CANONICAL_ROTATION_SWITCH_QUERY`. Add
`--receipt /absolute/path/outside/checkout.json` to produce the hash-bound
report. Each registered command is bounded to 120 seconds. All generated
output belongs outside the checkout.

## Provenance and overlap

Scientific base is canonical main
`e54523517d0f03e58352e647c403a5af3e525a57`, priority revision 8. The
`uniform-transfer-audit` card explicitly changes scope to this original
construction. JoyboyBrian's [Discussion #4709 handoff](https://github.com/CrocSwap/integer-mult-bounds/discussions/4709)
identifies the whole-ROM versus one-predicate bottleneck. The
[advance claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19591481)
states the exact source-compatible question.

[SOURCES.json](SOURCES.json) pins the canonical definition and its unchanged
notice as live inputs, and the catalogue, selected record and predecessor
context as provenance.
Live PR/Discussion checks, merged-PR searches and main-tree README searches
found no same-scope result within that coverage. The cached overlap helper
had incomplete sparse local coverage and older remote coverage; it was
supplemented by live reads and main-tree searches. This is not a guarantee
against unpublished or differently worded work.

Nick Petalas's #4876 prices optimal active swaps for full dyadic cycles.
Its tariff construction and proof are not used here. This result concerns
pointwise evaluation of a fixed deterministic compiler for arbitrary padded
moduli. It does not settle optimal padded-cycle swap counts.

## Open next questions

1. Lower the point evaluator to a literal fixed tape program returning one
caller-owned predicate. Begin with encoded `h,s,a,j,x` and the `h=5,s=17,
j=6` boundary. Charge comparisons, scans, initialization, erasure and all
head returns. The arithmetic proof does not supply that physical bill.
2. Join it to the exceptional key's current-state CRT offset producer.
Begin with the complete `(0,1,4)` key and stale-second-offset control from
Discussion #4709. Descriptor conversion, borrowed-state restoration and
uninterrupted ownership remain obligations. A supplied offset is not
free CRT reconstruction.

Structured first steps and blockers are in [TASK.json](TASK.json).

## Credit

This contribution was produced by Nick Petalas. Cinna Davis /
1337isnot1337 supplies the deterministic Beneš compiler and padded rotation
in #4100. ToikY's #4192 supplies the generic arena lowering; JoyboyBrian's
#5092 and #5496 supply the encoded producer and current-row query context.
Their results and retained predecessor lineage are cited premises. The
source-specific [notice](../unconditional-batched-crt/NOTICE.md) is unchanged.
Parity coloring and binary integer arithmetic are standard ingredients;
the formulas, padded-rotation closure and direct canonical evaluator are
the result contributed here. Independent human and formal proof-kernel
review are unclaimed. Apache-2.0.
Loading