Skip to content
Merged
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
181 changes: 181 additions & 0 deletions research/unsigned-connector-residue-count/PROOF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# Exact counts of optimal unsigned one-source words

## Model and statement

Let R be a nonzero unital ring of exact finite characteristic m >= 2. Let
X, Z and Y be left R-modules, and let B: X -> Z and A: Z -> Y be arbitrary
compatible R-linear maps. The three distinct data roles x, z and y may be
arbitrarily dirty. The only paid calls are

```text
B: z += Bx
A: y += Az
```

Calls are complete, source-preserving additive implementations, with their own
private state restored and their heads returned. Every call includes its full
implementation price. No inverse, sign change, scalar multiplier, frame change,
copy, direct AB call, source mutation, or additional connector is free. The
word is independent of input contents, and y is observed only after completion.
Correctness is universal in the maps and modules. Additional relations in a
particular choice of maps can permit shorter specialized words.

For c in {1,...,m-1}, the target is y += c ABx with x and z unchanged. The
minimum length is 2m. Write N_m(c) for the number of distinct literal words
attaining this minimum. Define N_m(0) as an auxiliary count over **balanced**
words with exactly m A events and m B events. It is not the optimum-word
count for the zero target, whose optimum is the empty word.

Let mu be the Mobius function and define the integer Ramanujan sum

```text
R_d(c) = sum_{e | gcd(d,c)} e mu(d/e).
```

Then, for every m >= 2 and every 0 <= c < m,

```text
N_m(c) = (1/m) sum_{d | m} R_d(c) binom(2m/d, m/d). (1)
```

For nonzero c this is the complete optimal-word count. The complete number of
restored length-2m words for the zero target is N_m(0)+2, adding A^(2m) and
B^(2m). The number for each other target is unchanged.

If p is prime, (1) reduces to

```text
N_p(0) = [binom(2p,p) + 2(p-1)]/p,
N_p(c) = [binom(2p,p) - 2]/p, 1 <= c < p. (2)
```

The nonzero target coefficients have equal optimal-word counts **if and only
if m is prime**. For any m, N_m(c) depends only on gcd(m,c); in particular all
unit coefficients have the same count. Reversing a word changes c to -c and
gives an unsigned inverse of the same length.

This is a scoped proof in the complete-call interface. The finite verifier is
corroboration of the proof, not its all-characteristic justification.

## 1. Dirty-state reduction and optimal length

For a word w, let a and b be its A and B counts. Let I(w) be the number of
ordered event pairs in which B occurs before A. Straight-line substitution
gives the exact action

```text
x_final = x,
z_final = z + b Bx,
y_final = y + a Az + I(w) ABx.
```

No commutation of A and B is used. Their order is AB because B writes z and
A reads z. Universal correctness forces b = 0 mod m to restore z and a = 0
mod m to cancel arbitrary connector dirt. To see necessity, take X=Y=Z=R,
use identity maps, and vary x and z independently. Exact characteristic m
means k*1_R=0 exactly when m divides k.

For nonzero c, both operators must occur. Thus a,b >= m and the total length
is at least 2m. The literal word

```text
B^c A B^(m-c) A^(m-1)
```

has a=b=m and I(w)=c mod m. It attains the bound. Every length-2m word for
nonzero c must therefore have a=b=m, and it realizes c exactly when I(w)=c
mod m. This also gives the minimum fixed-price bill m(c_A+c_B) for any positive
complete-call prices c_A,c_B. The count theorem, rather than this elementary
minimum-length extension of the F3 argument, is the contribution here.

For a balanced word, reversing the event order exchanges before and after in
all m^2 B/A pairs. Hence I(reverse(w))=m^2-I(w)=-I(w) mod m. This proves the
inverse statement without granting a free signed call.

## 2. The coefficient is a subset-position statistic

Choose the m positions of A in {0,...,2m-1}, written s_1<...<s_m. Before the
jth A, there are s_j earlier events and j-1 of them are A. Consequently

```text
I(w) = sum_j [s_j-(j-1)] = sum_j s_j - m(m-1)/2. (3)
```

Each m-element position subset determines exactly one balanced word. In
particular sum_c N_m(c)=binom(2m,m). The shift in (3) cannot be dropped in
even characteristic.

## 3. Exact root-of-unity transform

Fix a divisor d of m, and a primitive complex dth root zeta. Complex roots
are only a finite counting device; they impose no assumption on R. By (3),
with t=m(m-1)/2,

```text
sum_w zeta^I(w)
= zeta^(-t) [u^m] product_{s=0}^{2m-1} (1 + u zeta^s)
= zeta^(-t) [u^m] [1-(-u)^d]^(2m/d)
= zeta^(-t) (-1)^((d+1)m/d) binom(2m/d,m/d). (4)
```

The product identity follows because each dth root occurs 2m/d times and
product_{s=0}^{d-1}(1+u zeta^s)=1-(-u)^d.

The phase and sign in (4) cancel. If d is odd, d divides t because d divides
m and 2 is invertible modulo d. Thus zeta^(-t)=1, and d+1 is even. If d is
even, m is even, zeta^(d/2)=-1 and

```text
zeta^(-t) = (-1)^((m/d)(m-1)) = (-1)^(m/d).
```

Since d+1 is odd, the other sign is also (-1)^(m/d). Therefore

```text
sum_w zeta^I(w) = binom(2m/d,m/d). (5)
```

This includes d=1, which gives the total number of balanced words.

## 4. Fourier inversion gives the divisor formula

Let omega be a primitive mth root. The elementary finite geometric sum gives

```text
1_{I=c mod m} = (1/m) sum_{k=0}^{m-1} omega^(k(I-c)).
```

Sum over balanced words and use (5). Group k by the exact order d of omega^k.
The resulting sum of primitive dth roots to the power -c is R_d(c).
For completeness its integer form follows from inclusion-exclusion. If

```text
S_d(c) = sum_{zeta primitive of order d} zeta^(-c),
```

then sum_{e|d} S_e(c) is the sum of all dth roots to the power -c. This is d
if d divides c and zero otherwise. Mobius inversion yields

```text
S_d(c) = sum_{e|d} mu(d/e) e 1_{e|c}
= sum_{e|gcd(d,c)} e mu(d/e) = R_d(c).
```

This proves (1). No census or numerical complex arithmetic is needed.

## 5. Exactly the primes have uniform nonzero counts

When m=p is prime, its divisors are 1,p. R_p(0)=p-1 and R_p(c)=-1 for
nonzero c, while binom(2,1)=2. This proves (2).

Conversely suppose all N_m(c) for c!=0 were a common value b. Their Fourier
transform at any nontrivial mth root would then be N_m(0)-b, because the sum
of the nontrivial powers of that root over the residues is -1. It would be
independent of the root's order. If m is composite, choose a proper prime
divisor p of m. Equation (5) at order m gives 2; at order p it gives
binom(2m/p,m/p)>2 since m/p>=2. Both roots are nontrivial, a contradiction.
Thus uniformity holds exactly for prime m.

Finally gcd(m,c) determines gcd(d,c) for every divisor d of m, so (1) proves
the asserted gcd dependence. This gives N_m(c)=N_m(-c) as also witnessed by
word reversal.
114 changes: 114 additions & 0 deletions research/unsigned-connector-residue-count/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Exact counts of shortest unsigned connector words

This scoped proof gives a closed formula for the number of optimal schedules
at a one-source dirty-connector boundary, over every finite characteristic.
It also proves that the nonzero coefficient counts are equal exactly in prime
characteristic. The contribution was produced by Nick Petalas.

Let the only complete calls be `B: z += Bx` and `A: y += Az`, with arbitrary
dirty data, immutable source x and generic compatible linear maps over a
nonzero unital ring of exact characteristic m. For a nonzero integer residue
c modulo m, require `y += c ABx`, with x and z unchanged.

Every optimal word has m calls of each operator, hence length 2m. The new
result counts these words, rather than improving this elementary call floor:

```text
N_m(c) = (1/m) sum_{d | m} R_d(c) binom(2m/d, m/d),
R_d(c) = sum_{e | gcd(d,c)} e mu(d/e).
```

Here mu is the Mobius function and R is the integer Ramanujan sum. In prime
characteristic p every nonzero c has `(binom(2p,p)-2)/p` optimal words. Composite
characteristics have unequal nonzero counts. For example, the counts for c=1,2,3
at m=4 are 16,18,16. All residues with the same gcd(m,c) have equal counts.
Reversing any balanced word gives its same-length unsigned inverse.

[PROOF.md](PROOF.md) gives the complete all-characteristic proof from the
dirty-state action, a subset-position statistic and exact finite Fourier
inversion. It uses no finite census as a universal premise. N_m(0) is an
auxiliary **balanced-word** count; the zero target has empty optimal word.
The full zero-target length-2m count adds the two pure words to N_m(0).

## Evidence and reproduction

From the repository root, with CPython 3.12 and its standard library:

```sh
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -W error -B research/unsigned-connector-residue-count/verify.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/unsigned-connector-residue-count
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/unsigned-connector-residue-count --check-source-history
```

Any CPython 3.12 path can replace the local interpreter path. The verifier prints
a generated JSON receipt with every package/input SHA256, followed by
`PASS_UNSIGNED_CONNECTOR_RESIDUE_COUNT moduli=31 residues=527`. It writes no
files. Both ordinary and optimized Python commands are registered.

The exact finite checks cover:

- All 527 residue counts at m=2,...,32, comparing the formula with a separate
chronological dynamic program.
- All 250,950 balanced position subsets at m=2,...,10, plus literal dirty
coefficient execution of all 17,574 balanced words at m=2,...,8.
- All 21,840 unrestricted length-2m words at m=2,...,7, finding 4,716 restored
words. This includes the two pure zero-target words in each characteristic.
- 496 explicit nonzero-coefficient witnesses, 3,968 noncommuting two-coordinate
dirty-input cases and 3,968 inverse roundtrips, through m=32.
- Eight controls for a missing position shift, a prime-only formula misused in
composite characteristic, omitted source/readout cancellation, the wrong
target coefficient, reversed AB order, a clean-only shortcut, and invalid
executable-domain inputs.

The finite program restricts m to 2 through 32. The largest dynamic-programming
table has 34,848 integer slots. Subset enumeration visits at most binom(20,10)
objects per characteristic; literal words have at most 64 events. Functions
have no recursion, all scientific contracts use explicit exceptions, and
`-W error` diagnostics run in both registered modes. Python allocates dynamic
objects within those fixed finite bounds; fixed-memory execution is not claimed.

The card's first working control prints
`PASS_UNIVERSAL_CONNECTOR_BOUNDARY pairings=945 max_coverage=31 queries=74 leaves=182`.
The selected binding baseline also passes. These are orientation checks, not
part of the new counting proof or a cold replay of the selected construction.

## Attribution and scope

Ross Richardson's [#943/#934 lineage](../universal-connector-boundary/README.md)
supplies the complete-call dirty-connector interface and prefix viewpoint.
Riquelme Soares's [#4189](https://github.com/CrocSwap/integer-mult-bounds/pull/4189),
head `5fb3936dfc8082f438f21c72dd6ca49ff4366ae7`, supplies the unsigned F3
one-source problem, the mod-three count floor and its six optimal words.
Equation (2) of the new proof recovers that six-word count as its p=3 case.
The general count uses classical subset generating functions, finite Fourier
inversion and Ramanujan sums; no novelty is claimed for those tools themselves.
Concurrent [#4231](https://github.com/CrocSwap/integer-mult-bounds/pull/4231),
head `8a956cbc80dc55697fd3e214812ce567b5eca48f`, classifies the unsigned five-source
optimum by characteristic and also gives the one-source 2m call floor. That
floor is shared context; the new result here is its complete word-count law.
No pending executable or archived source is imported.

The `connector-alphabet-change` card is explicitly changed to this scheduling
side question. The characteristic-two coefficient premise changes; the
operations stay unsigned. This does not add a new connector operation or find
a selected-supplier saving. The neighboring five-source and signed-ring tasks
remain separate. Exact base and input pins are in [SOURCES.json](SOURCES.json).

All calls must include their complete implementation prices. Admission,
coefficient preparation, instruction storage, dispatch and word-dependent
physical routing remain additional. No concrete supplier caller, native/tape
implementation, precision analysis, outer multiplication theorem, formal-kernel
proof or new kappa is supplied. Independent human and formal proof-kernel review
are unclaimed. Apache-2.0.

## Open next questions

The structured questions in [TASK.json](TASK.json) give first steps and blockers.

1. Can these marginal coefficient spectra constrain simultaneous demands in a
multi-source unsigned connector? A joint readout-position argument is needed;
multiplying independent marginal counts would discard their correlations.
2. Can a concrete recursive caller choose among its minimum-length words to
reduce fully charged routing? Start with one pinned caller and compare two
schedules including all accesses and head returns. This package supplies no
physical price for that choice.
38 changes: 38 additions & 0 deletions research/unsigned-connector-residue-count/SOURCES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"schema_version": 1,
"base_commit": "12fa8c5c844be21bfefb38a19503fbd867a11244",
"files": [
{
"path": "certificates/selected-result.json",
"usage": "provenance",
"git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81",
"sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129"
},
{
"path": "docs/research/agent-task-catalog.json",
"usage": "provenance",
"git_blob": "64bfc5af6709ed9811171e0a2108f05e1219cb65",
"sha256": "352a6184713b8843d96fd2c2071eb7aeaa655906b7c51d45ad444912666c8a96"
},
{
"path": "research/universal-connector-boundary/README.md",
"usage": "input",
"git_blob": "d277f7c5830b1f2bc42e1ff41ab86e7d7564929f",
"sha256": "23415f7829ab8d80a783142f10f7d31abbce84579362769984680af3df954476"
}
],
"context_only": [
{
"url": "https://github.com/CrocSwap/integer-mult-bounds/pull/4189",
"head_commit": "5fb3936dfc8082f438f21c72dd6ca49ff4366ae7",
"credit": "Riquelme Soares",
"role": "Unsigned F3 one-source problem and six optimal words; no executable dependency."
},
{
"url": "https://github.com/CrocSwap/integer-mult-bounds/pull/4231",
"head_commit": "8a956cbc80dc55697fd3e214812ce567b5eca48f",
"credit": "Nick Petalas",
"role": "Concurrent five-source characteristic classification and shared one-source 2m call floor; no executable dependency."
}
]
}
Loading