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
1 change: 1 addition & 0 deletions research/directory-producer-invoice/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source/** -text whitespace=blank-at-eol,blank-at-eof,space-before-tab,cr-at-eol
250 changes: 250 additions & 0 deletions research/directory-producer-invoice/PROOF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
# One shared radix traversal in the source-pinned directory producer

ToikY, with substantial OpenAI Codex assistance. Apache-2.0.

## Result and predecessor boundary

PR2590 (ywz65), `research/source-directory-setup-cost`, already proves the
unchanged producer's cubic radix reconstruction and complete volume-linear
asymptotic. Its explicit next question asks whether one encoded exponent
traversal can be shared across the fixed matrix coordinates. This package
answers that question for the producer component: replace its repeated
`high_power` traversal by one shared traversal, preserve its exact result and
complete record-tape behavior, and save a specified number of Word reads,
writes and unit moves. No new asymptotic order is claimed.

The source closure is six byte-authenticated files retained at canonical main
`20ecf2891d80b5acf18d980b2164fb44ea7faa90`, under
`research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/`.
The `directory.py` SHA256 is
`4270e370b2bfe38ef73aadcd97d1b3496b56bd582115d74331eb9e5ceb90bec7`;
the six original executable files remain unchanged. The experiment rebinds only the
producer module's `high_power` callback after constructing an already valid
Context. Context construction, including its separate `high_count`, and
Context close are outside the measured component and remain unchanged.

The new claim is the shared traversal, its exact complete producer-action
delta and a separately derived complete read/write/move invoice. The earlier
division write law, output-volume theorem and directory/reserve lifetime
results retain their original credit. This is no full selected caller,
source-stock construction, physical tape compiler, recursive tariff or kappa
result.

## Valid input contract and replacement

Write `d` for the fixed vocabulary dimension, `M=d^2`, `modulus=q^w`,
`c=q^(w-1)`, `H=c^M`, with `q>=2`, `w>=1`. A valid source Ring uses
`L=bit_length(modulus)+1` numerical bits. `B>=1` is the number of physical old
prefix positions; `h>=0` is the number of fields in each prefix. The supplied
old-field count is an `I`-bit Word, while the old-prefix count is a canonical
variable-length Count. The supplied old-directory/count/field and used Context
heads enter at 1; unrelated protected spectators retain their own heads.

Every old field has one valid finite `Q`-bit source code, followed by `M`
valid `L`-bit words with values strictly below `c`, then its record delimiter.
There are no extra or missing input symbols. One serialized field therefore
has

```
F = Q + 2 + M(L+1)
```

symbols. Equal old prefixes remain distinct physical positions. Successful
production emits, in source order, every old prefix followed by every
lexicographically ordered high field. Its output extent and count are

```
U = B H (h+1) F, returned_count = B H.
```

The source `counts.high_power` performs `M` complete `radix_power` traversals.
Each traversal yields `w` times; `digit_suffix` skips the first yield and
multiplies its Count by `q` on every other yield. The replacement is:

```
first = True
for _ in radix_power(ring,q):
if first:
first = False
else:
for _ in range(d*d):
value.multiply_small(q)
```

Both programs apply the same ordered sequence of exactly `M(w-1)`
multiplications by the same fixed `q`. Thus they have exactly the same Count
intermediate values, bit widths, symbol operations and final value `BH`.
The replacement decodes no runtime exponent: the existing encoded traversal
controls the outer loop and the inner `d*d` bound is fixed finite vocabulary
data. At `w=1` it still performs one full validating traversal; skipping every
traversal would omit source validation.

The radix generator and Count multiplication operate on disjoint Word and
record-Tape objects. Retaining its divisor/power across multiple Count
multiplications requires no additional Word. On success it frees those Word
roles and restores the same protected heads. Consequently every later
instruction of `produce`, its supplied arguments and its old-prefix/output
state is identical. No change to `old_prefix`, Odometer, cleanup, count
comparison, code validation or source serialization is needed.

This theorem concerns successful valid inputs. It does not add a new
exception-path rollback contract to the inherited source, or establish that
every arbitrary malformed numerical record is leak-free on rejection.

## Exact radix invoice

All vectors below have order `(reads,writes,unit_moves)` and use the source's
fixed-alphabet Word/Tape meters. They include zero initialization and erasure
where stated. Python allocation, instrumentation, audit-only integer decoding
and a physical fixed-tape implementation are outside this meter.

For a full-width division with quotient popcount `s`, the exact Word invoice is

```
D_L(s) = (15L^2+44L+33 + (12L+15)s,
3L^2+ 8L+ 4 + ( 3L+ 2)s,
14L^2+50L+44 + (12L+20)s).
```

PR2590 owns the middle, write-count identity. The other lanes are derived from
the same frozen methods. Each of the `L` division iterations performs a shift,
erases its former remainder, compares full words, writes one quotient bit and
moves both scan heads. A subtraction occurs exactly for the `s` one bits of
the quotient. Every `shift_add_bit` includes its `L+1` loop-condition reads;
finite literal loading also includes its extent-check reads. Counting these
reads is necessary for the complete invoice.

Useful exact vectors, for words starting at head 1, are

| Operation | `(reads,writes,unit_moves)` |
|---|---|
| Arena zero | `(4L+5,L+1,4L+6)` |
| Arena free | `(2L+3,L+1,2L+4)` |
| Arena copy | `(8L+9,2L+1,8L+12)` |
| Nonaliased comparison | `(5L+6,0,4L+8)` |
| Word zero test | `(2L+3,0,2L+4)` |
| Literal `q`, `b=bit_length(q)` | zero-vector plus `(2b+1,b,2b+2)` |

Let `A_L`, `E_L`, `C_L`, `P_L`, `Z_L` respectively denote the last table's
literal, free, copy, comparison and zero-test vectors. One full radix
traversal has exact cost

```
R(q,w,L) = A_L + C_L + (w+2)P_L
+ sum_(j=0..w-1) D_L(popcount(q^j))
+ 2w Z_L + (2w+2)E_L.
```

The two extra comparisons validate the final one; the final two erasures
dispose of divisor and power. The unchanged source performs `M` such
traversals, and the replacement performs one. All other Word operations and
every record/index operation agree. The exact complete producer saving is
therefore

```
Delta_record = Delta_index = (0,0,0),
Delta_residue = (M-1) R(q,w,L).
```

It is zero for `d=1` and strictly positive in all three lanes for `d>1`.
This saving is independent of `B`, `h`, old field values and the Count size;
those affect identical retained work. The asymptotic cubic dependence on
`w` remains when `d` is fixed, as already proved in PR2590.

## Complete retained work, rather than only output writes

`independent.py` derives the entire original and replacement invoices, not
only their delta. It imports no primary or predecessor executable and binds
the six source byte strings before comparing the measured receipt. Its
separate lanes include all supplied Tape and Word meter changes as well as
source-created scratch objects.

The exact Odometer counts per old prefix are

```
I_c = sum_(j=1..M) c^j, A_c = sum_(j=0..M-1) c^j,
T_c = A_c (c-popcount(c)).
```

Here `I_c` counts digit increments, `A_c` counts carry/reset paths and `T_c`
counts one-bit ripple visits. At `c=1`, both sums equal `M`, rather than using
a singular geometric-quotient expression. Each reset scans the entire `L`
bits. The last advance, which marks the Odometer finished, is included.

For `K>=1`, put `t=K-popcount(K)` and `e=bit_length(K)-1`. All emission Count
increments from 0 to K cost

```
(2t+5K, t+K+e, 2t+4K+2e).
```

The complete Counter countdown from K to 0 costs

```
(2t+5K+1, t+K+2e+3, 2t+4K+2e+4).
```

The different final-zero and growing-right-delimiter paths explain the
different constants. Constructors, old padded-field-count input scans,
normalization, Count equality and final erasure are additional explicit
terms; they are not folded into a zero-cost loop bound. Count multiplication
from bit width `k` to `k'` costs `(2k+k'+2,k'+1,2k'+2)`.

For completeness, a saved old prefix has `n=hF` symbols. Its construction,
return rewind, all H copies and final clear cost

```
(4n+4+H(3n+3), 2n, 4n+6+H(2n+4))
```

on its own record Tape. The output Tape, including its final rewind, costs
`(2U+1,U,2U+2)`. Its borrowed old-input Tape costs
`(2BhF+BhML+3,0,2BhF+4)`. This includes all validation reads, initial and
final rewinds. One old numerical word's allocation, decoding, range check,
saved serialization and erasure costs `(16L+19,3L+2,14L+24)`.
These terms, all Odometer Word operations, all count operations and the
unchanged `high_power` or replacement term are summed in the checker.

The source creates exactly `5+2B` record Tape objects during production.
No physical Tape-object reuse is inferred merely because a logical role is
dead. The already known additional numerical live-word peak is
`max(M,6)`: Odometer owns M, exponent reconstruction needs at most six and
old-prefix decoding owns one at a time. Those phases are disjoint. The shared
version does not change this peak. This is reuse/confirmation of the existing
directory lifetime analysis, not a new reserve theorem or proof that the
physical caller can host all objects simultaneously.

## Finite evidence and limits

The measured component starts with a valid Context. Both variants run against
the same source fixtures, with runtime `Word.inspect` forbidden. The primary
observer includes all preexisting borrowed record tapes, all new record tapes,
residue-arena/template actions and the index-word arena. The independent
checker reproduces every action lane from formulas and independently creates
the complete expected output bytes by base-c address expansion.

Seven paired fixtures include three distinct empty-prefix positions,
nonempty histories of lengths one and two, radices 2/3/5, a binary long-carry
case, a nine-digit binary Odometer, a nontrivial `d=2,c=3` high cube and the
actual `d=64,c=1` boundary. The latter runs the unchanged dimension-64 producer code, but is
not a full nontrivial high-cube or selected source-stock execution. Bounded
small Odometers independently corroborate unique ordered enumeration, full
carry/reset counts and ripple sums. These checks do not replace the symbolic
loop argument above.

At `d=64,q=3,w=1,L=3`, one radix traversal costs `(523,95,556)`.
The replacement saves exactly `(2141685,389025,2276820)` residue Word actions.
In the recorded `B=1,h=1,Q=6507,I=4` fixture, its residue Word invoice changes
from `(2793472,483328,2916352)` to `(651787,94303,639532)`.
Record Tape `(310027,91612,274870)` and index Word `(15,0,12)` costs agree.
The complete output bytes/count, protected words, heads and scratch erasure
also agree. No elapsed-time or bit-machine saving is inferred from these
source-meter numbers.

Credit Jose Manuel/PR2569 for the producer, ywz65/PR2590 and PR2566 for setup
and primitive cost analysis, and the retained stream/cardinality/selected
caller and storage-reserve lineage. Original source notices and all frozen
bytes remain intact. Adoption into a shared producer, a complete caller
invoice, physical Tape layout/allocation, full Pi/source-stock admission,
recursive/supplier/outer obligations and frontier changes are outside this
package. No independent human or formal-kernel acceptance is claimed.
117 changes: 117 additions & 0 deletions research/directory-producer-invoice/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Share one encoded radix traversal in directory setup

The retained `directory.produce` computes its returned count by reconstructing
the same modulus radix once per matrix coordinate. This package supplies one
local replacement, `high_power_shared`, that traverses the encoded radix once
and repeats the identical count multiplication at each yield. The unchanged
producer is executed with either binding; frozen/shared runtime bytes are not
edited or installed.

Let d be dimension, M=d², modulus=q^w, c=q^(w−1), H=c^M, and B>0 the physical
old-prefix count. Both versions perform exactly M(w−1) ordered multiplications
by q on the returned Count and produce B H. The candidate removes exactly
M−1 complete radix traversals. For a one-traversal source Word invoice
rho=(reads,writes,unit moves), its exact saving is `(M−1)rho`.
Record/Count/Counter Tape actions, old-field index Word actions, output bytes,
lexicographic order and multiplicity are unchanged.

The actual dimension64/cap1 fixture uses the retained Q=6507 code width and
executes the complete producer. Source residue Word actions fall from
`(2793472,483328,2916352)` to `(651787,94303,639532)`:
exact saving `(2141685,389025,2276820) = 4095*(523,95,556)`.
Record Tape actions remain `(310027,91612,274870)` and index Word actions
remain `(15,0,12)`. This is an action count, not a wall-clock speed claim.
The fixture uses a projected valid finite vocabulary; it does not reconstruct
the full selected source catalogue or admit its low-code/GL specifications.

## Contract and prior work

The interval starts with an already-live valid Context and canonical valid
input tapes/Words, positive B, enough arena capacity and no concurrent mutation.
Context preparation/teardown, input/vocabulary compilation and disposal of the
returned directory/Count remain explicit caller charges outside the interval.
No numerical decoding of runtime Words is used. The independent integer model
is external mathematical verification, not runtime control.

`source/CALLER.py:207` retains the actual `Machine.residual_begin` call to this
producer. The candidate is opt-in research code; the shared caller remains
unchanged. Python controller/object/allocation costs, literal physical tape
lowering, backing/slot metadata, source admission and full caller composition
remain separate. Successful valid-input restoration is the contract; inherited
malformed-input paths do not provide general exception rollback.

[PR2590](https://github.com/CrocSwap/integer-mult-bounds/pull/2590), by ywz65,
already proves repeated radix reconstruction is cubic in w and the complete
producer is Theta_q(D), including counters and physical duplicate prefixes.
Its explicit shared-traversal question motivates this replacement. Its output
formula `D=B H(h+1)[Q+2+M(L+1)]`, the separate directory-storage allowance,
and Ross Richardson's exact successful numerical peak `max(M,6)` are credited
prior results. The peak remains unchanged here; at d=64 it is 4096 above
all entry residents. This is not a new asymptotic theorem or peak discovery.

The source Word radix term falls from M traversals to one. With fixed dimension
it retains the cubic width order; no claim removes that order. All M(w−1)
Count multiplications remain charged. `PROOF.md` and `independent.py` give the
complete exact invoice and phase boundaries, rather than treating output size
or a numerical peak as a whole physical caller bill.

## Evidence and reproduction

```sh
python3.12 -B scripts/research_package.py --package research/directory-producer-invoice
python3.12 -I -B research/directory-producer-invoice/verify.py
python3.12 -I -B research/directory-producer-invoice/independent.py
python3.12 -I -B research/directory-producer-invoice/test_verify.py
```

Six runtime modules and the caller/notice exports are authenticated by exact
SHA256 and Git blobs before execution. The primary meters every created and
borrowed Tape plus residue/index arena traffic, compares actual original and
candidate runs, and checks output/order, count, heads, protected state and
successful cleanup. The separate formula checker imports neither primary nor
retained executable modules. Controls target wrong yield/multiplication,
undercounted radix work, multiplicity, source authentication and typed receipts.
Normal and optimized replay must pass; default replay is read-only.

Bounded complete high cubes use small dimensions/caps. The dimension64 fixture
has cap1; no multi-lift dimension64 directory, huge-prime payload, complete GL64
source, full selected cold replay, human review or formal-kernel acceptance is
claimed. The written source argument covers valid arbitrary parameters under
its contract; finite tests corroborate it.

## Scope and coordination

Canonical base `20ecf2891d80b5acf18d980b2164fb44ea7faa90`, priority6. The changed
`selected-stock-envelope` card is retained exactly in `TASK.json`. The named
baseline was attempted but a sparse omitted selected-package ASSEMBLY blocks
its inventory check; this package supplies its own complete local runtime slice.
It does not derive the selected complex m73 reserve coefficient.

The canonical investigation is the claim/update on
[PR4011](https://github.com/CrocSwap/integer-mult-bounds/pull/4011#issuecomment-6264214824).
`TASK.json` records the full724-open-PR-body entry scan, latest100-body delta,
retained predecessor reassessment, live handoff checks and coverage limits.
No novelty guarantee follows from the bounded text search.

## Open next questions

See structured questions in `TASK.json`. First review this exact success
contract and bind the candidate to the complete caller with a physical control
and allocator tariff. Context, child_extents/read_prefix, geometry, coefficients,
dispatch and the other Pi phases remain charged obligations. Then join all
simultaneously live parent/child, dirty, Count, template and backing categories
at original widths before claiming reserve or recursive supplier admission.
There is no selected-frontier or kappa change.

## Credit

Jose Manuel/jmbarrancoml supplies the physical caller, encoded runtime and
canonical directory lineage; David Arias/PR2753 and Nick Petalas supply retained
caller/controller/record components. Their complete original notice is retained
unchanged in `source/NOTICE.md`. ywz65/PR2566 and PR2590 supply primitive/setup
analysis, the cubic correction and explicit optimization question; ywz65's
directory-storage package and Ross Richardson's numerical-phase audit supply
the credited storage/peak facts. Chris R/Clear1nsight PR3983/4011 supplies the
adjacent preparation/admission bill and named directory/context obligations.
New adapter, exact invoice, proof and packaging by ToikY with substantial
OpenAI Codex assistance and separate AI math/test contexts. Apache-2.0.
Loading