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/runtime-paired-ddg-arithmetic/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
retained/** -text whitespace=cr-at-eol
51 changes: 51 additions & 0 deletions research/runtime-paired-ddg-arithmetic/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Sources and attribution

Ali Romman supplied the runtime-parameter construction, shared residue
arithmetic, full gate bill and complete checks, with substantial OpenAI
Codex assistance in research, implementation, verification and writing.
New code and prose are Apache-2.0.

Nick Petalas supplied the fixed-pair arithmetic circuit and explicit
runtime-parameter question in
[PR #7746](https://github.com/CrocSwap/integer-mult-bounds/pull/7746), head
`71fdb2cf1ec973b5402c4d3c2466864014a1ccda`. Its
[circuit](https://github.com/petalas/integer-mult-bounds/blob/71fdb2cf1ec973b5402c4d3c2466864014a1ccda/research/paired-ddg-arithmetic-step/circuit.py)
supplies the unchanged Boolean primitives and modular addition. Its
[proof](https://github.com/petalas/integer-mult-bounds/blob/71fdb2cf1ec973b5402c4d3c2466864014a1ccda/research/paired-ddg-arithmetic-step/PROOF.md)
supplies the shared phase and compute-copy-swap-uncompute method. The new
subclass changes only the wire layout and allocation bound; no source
global or function is replaced. All seven source package files are retained,
and the original fixed-pair verifier runs unchanged.

zxv, with substantial OpenAI Codex assistance, supplied the complete paired
decision graphs, probability law and expected-bit optimum in
[PR #6072](https://github.com/CrocSwap/integer-mult-bounds/pull/6072), head
`9011bf83e85ecd0443c789cf03259442f750877d`. Its
[constructor](https://github.com/zxv/integer-mult-bounds/blob/9011bf83e85ecd0443c789cf03259442f750877d/research/paired-residue-sampler/verify.py)
and [proof](https://github.com/zxv/integer-mult-bounds/blob/9011bf83e85ecd0443c789cf03259442f750877d/research/paired-residue-sampler/README.md)
are retained. The unchanged constructor runs for all 144 pairs. The original
full probability/mean catalogue entry point was not run. Its classical DDG,
JoyboyBrian inverse and Nick Petalas stochastic-prefix credit remains intact.

JoyboyBrian, with substantial OpenAI Codex assistance, supplied the inverse
and counter-based lifecycle context in
[PR #6102](https://github.com/CrocSwap/integer-mult-bounds/pull/6102), head
`0422af13625c2e7e8ece28bdd74364a61764c64a`. Its
[proof](https://github.com/JoyboyBrian/integer-mult-bounds/blob/0422af13625c2e7e8ece28bdd74364a61764c64a/research/paired-ddg-reversal/PROOF.md)
and README are retained. Its complete suite was not run and its physical
counter obligations are not discharged by a circuit step.

Related work, not executable input: Nick Petalas's
[PR #7187](https://github.com/CrocSwap/integer-mult-bounds/pull/7187), head
`5504be187271a90a3a46e497ed2d5b4196c5df8a`, gives the
[resident table bank](https://github.com/petalas/integer-mult-bounds/blob/5504be187271a90a3a46e497ed2d5b4196c5df8a/research/signed-swap-residue-bank/PROOF.md)
under an output-relabelling contract. It was read for overlap. His
[PR #6127](https://github.com/CrocSwap/integer-mult-bounds/pull/6127) supplies
a different owned-delimiter boundary for the fixed pair. This package does
not claim those earlier table or tape results and does not transfer their
tariffs to the new circuit.

All eleven retained files have Git-blob and SHA-256 pins and keep their
original notices. The base manifest records provenance only; no unmerged
source ancestry is asserted. Separate finite checks do not constitute
independent human or formal-kernel acceptance.
155 changes: 155 additions & 0 deletions research/runtime-paired-ddg-arithmetic/PROOF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# A reversible draw for runtime residue parameters

## Contract and result

The caller supplies read-only parameters a,b with 1 <= a,b <= 12 before
the first coin is read. They remain fixed through the draw. The packet has
an eight-bit phase theta, a two-bit live-node index or output label, and one
stopping flag. A separate resident coin is read-only. On entry, the packet
is a reachable unfinished state of zxv's denominator-13 graph, and all
2,146 work bits are zero.

One fixed circuit maps this packet to the source graph's next packet,
preserves the two parameters and coin, and returns every work bit to zero.
Its gate list is independent of a,b and the phase. Its reverse maps every
valid result back to the exact input with zero workspace.

| Resource per draw | Count |
| --- | ---: |
| X gates | 864 |
| CNOT gates | 10,054 |
| Toffoli gates | 3,104 |
| Total gates | 14,022 |
| Temporary Boolean wires | 2,135 |
| Clean packet backing bits | 11 |
| Total clean work bits | 2,146 |
| Live packet bits | 11 |
| Read-only parameter bits | 8 |
| Resident coin bits | 1 |

The total circuit has 2,166 wires. Parameter arithmetic, packet copying,
swapping and uncomputation are included. Loading the caller's parameters,
physical wire access, random-tape movement and stopping storage are not
included. This is a gate-level construction, not a tape tariff or speedup.
It is larger than the fixed-pair circuit and serves a larger input domain.

## Shared phase and parameter arithmetic

The ordered outcome weights are

```text
(w00, w01, w10, w11) = ((13-a)(13-b), (13-a)b, a(13-b), ab).
```

At depth k, keep theta = 2^k mod 169. For any weight w, its next binary
probability digit is one exactly when `(w*theta mod169) >= 85`. This follows
by subtracting twice the floor at depth k from the floor at depth k+1.

All arithmetic below is modulo 169. Generate theta, 2theta, 4theta and
8theta by modular doubling. The four runtime bits of a select these values;
three modular additions give `a*theta`. Do the same for b, using the same
four phase multiples. Generate four multiples of `a*theta` and `b*theta`.
The bits of b applied to the former give `rho = ab*theta`. Two additions
give each of `alpha = 13a*theta` and `beta = 13b*theta` from coefficients 1,4,8.
The four required residues are

```text
rho-alpha-beta, beta-rho, alpha-rho, rho.
```

Thus all four probability digits come from the shared phase and the two
runtime parameters. No weight, phase-digit or transition table is stored.
Every modular result is reduced before the next operation. The threshold
test is the top bit of the nine-bit sum r+171 for 0 <= r <= 168.

The source modular adder is retained unchanged. For the new subtraction,
compute delta = left-right modulo 512 in nine bits. Its mathematical
range is [-168,168], so the top bit is set exactly when the difference is
negative. In that case, select delta+169 modulo 512; otherwise select
delta. The resulting low eight bits represent the reduced difference in
[0,168]. The verifier checks all 169 squared operand pairs and reverses
the whole subtraction computation, including its temporary wires.

## Ordered forward and inverse maps

Let d0,d1,d2,d3 be the four digits. Set c_i to the sum of the digits before
label i, and D to their total. For node j and coin u, form m = 2j+u. The
source returns label i exactly when d_i=1 and m=c_i. These conditions are
mutually exclusive. If no leaf condition holds, the next live index is
m-D. The next phase is 2theta mod169. The two output bits and stopping
flag are built from the four leaf conditions; no output relabelling occurs.

For the inverse, recover the old phase from the new one:

```text
theta = (theta_new + 169*(theta_new mod2))/2.
```

Recompute the four digits using the same retained parameters. For a live
output j', recover m=j'+D. For a terminal output i, recover m=c_i. Then
the old node is floor(m/2) and its stopping flag is zero. On the valid
domain, m mod2 is the resident coin. The verifier checks every such edge,
including the closing edge of the 156-phase period.

Each Boolean computation uses X, CNOT and Toffoli on clean temporary
wires. Compute the next packet, XOR it into the clean backing packet, and
reverse the computation. Swap the two packets with three CNOT gates per
bit. Compute the inverse packet and XOR it out of the backing, then
reverse that computation. Since the forward and inverse formulas agree
on the reachable domain, the backing and temporary wires are zero on exit.
Both computations reuse the same temporary region after clearing it.

The unchanged source Boolean primitives use a configurable allocation
cursor through an ordinary subclass. The subclass supplies the new wire
layout and a finite compile-time allocation bound. It changes no retained
function or module global. A gate list is emitted once; Python allocation
is part of generation and is not a runtime circuit operation.

## Complete finite evidence and all-depth consequence

The reference path calls the unchanged graph constructor for every one of
the 144 parameter pairs. Independently, it computes binary digits from
integer floors at all 156 phases and reconstructs each live-node transition.
The two descriptions agree on all 624 transitions per pair, or 89,856 in
total. The phase does not repeat before the closing edge, and the live count
returns to one. Every claimed input packet and both coin values are covered.

A bit-lane gate interpreter executes all these inputs together and compares
every wire, including both parameters, the coin and all zero work bits.
It also runs the reverse gate list on every reference output. A separate
scalar bit-state interpreter checks both directions on 288 root and final
phase cases, two per parameter pair. Four controls detect a wrong stopping
flag, changed parameter, dirty work bit and exchanged output order.

The fixed-pair source verifier runs unchanged. The new arithmetic also
checks all 28,561 modular subtraction inputs and their uncomputation.
The result certificate records the gate hash, exact bill and a complete
transition digest for each pair. The verifier reconstructs these data.

Start at phase one, node zero and stopping flag zero. Each executed gate
step equals the source transition on its reachable input. Induction therefore
preserves the output and first stopping depth on every ordered coin path,
including paths that pass through any number of phase wraps. The predecessor
product law and expected-bit optimum transfer under its fixed nonadaptive
parameter and independent fair-coin assumptions. They are predecessor results,
not new probability theorems in this package.

## Resource and conclusion limits

The circuit removes per-parameter transition data from the runtime service.
The fixed gate description and its physical execution still cost resources.
No total-ROM minimum or byte saving over a compressed circuit description is
claimed. The resident-table bank in PR7187 changes the coin-to-label contract;
its payload count is not a physical runtime baseline for this circuit.

Stopping time remains unbounded. The caller must provide and retain the two
parameters throughout any later cleanup. This package does not install the
circuit in either the counter protocol of PR6102 or the owned-delimiter
protocol of PR6127. Their tape boundaries are distinct. Random-tape access,
output retention, stopping storage, a reached nonadaptive caller and the full
native invoice remain open for this arithmetic service. Restoring coins does
not make them independent of a retained output. Parameters outside 1..12 and
unreachable packets are outside the clean-workspace contract.

No new kappa, selected assumption discharge, independent human review or
formal-kernel acceptance is claimed. All five framework assumptions remain.
54 changes: 54 additions & 0 deletions research/runtime-paired-ddg-arithmetic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# One arithmetic circuit for all runtime residue pairs

One fixed reversible circuit implements a draw for all **144** nonzero
denominator-13 residue pairs supplied at runtime. It uses **14,022 gates**
and **2,146 clean work bits**, including parameter arithmetic and cleanup.
Both parameters and the coin remain unchanged. The original ordered
coin-to-label function and first stopping depth are preserved.

Read [the contract and proof](PROOF.md), [the circuit generator](parametric.py),
[the exact bill and pair certificates](RESULT.json), [the checker](verify.py),
[source pins](SOURCE-PINS.json) and [source credit](CREDITS.md).

The circuit computes four weight residues from one phase and two four-bit
parameters. It replaces transition-data lookup with arithmetic. This is a
larger input domain and a larger circuit than the fixed-pair predecessor;
no physical speedup or total-code-size saving is claimed.

Python 3.12, standard library only:

```sh
python3.12 -B scripts/research_package.py --package research/runtime-paired-ddg-arithmetic
```

Both registered commands print:

```text
PASS_RUNTIME_PAIRED_DDG_ARITHMETIC
144 runtime pairs; 89856 complete forward/inverse transitions
864 X; 10054 CNOT; 3104 Toffoli; 14022 gates
2135 temporary bits + 11 clean backing bits = 2146 clean work bits
```

All 89,856 reachable edges agree with the unchanged source constructor
and a separate integer-floor description. Every output and work wire is
checked in both directions. A scalar interpreter checks 288 cases in both
directions. All 28,561 subtraction inputs, four fault controls and the
unchanged fixed-pair verifier pass. No historical full catalogue, native,
selected cold, Lean or Docker replay is claimed.

No new kappa follows. Stopping time remains unbounded. Physical tape
movement, parameter loading, output retention, stopping storage, conditional
freshness and a reached nonadaptive caller remain separate obligations.
The selected frontier and all five framework assumptions remain unchanged.

## Open next questions

- Install this fixed circuit in a stated tape layout and charge access to
all wires, parameters and consumed coins for a terminating path. Compare
the counter and owned-delimiter boundaries before selecting one.
- Can a smaller exact circuit retain the same runtime input and ordered
output contract? Start with the complete transition certificate and
count preparation, inverse computation and cleanup together.

Prepared by Ali Romman with substantial OpenAI Codex assistance. Apache-2.0.
Loading
Loading