diff --git a/research/reversible-signed-half-kernel/PREDECESSOR.json b/research/reversible-signed-half-kernel/PREDECESSOR.json new file mode 100644 index 0000000000..198fde4b91 --- /dev/null +++ b/research/reversible-signed-half-kernel/PREDECESSOR.json @@ -0,0 +1,9 @@ +{ + "head": "2711ca28367c5bbbb54ce9601928e885d87ca165", + "pr": "https://github.com/CrocSwap/integer-mult-bounds/pull/6066", + "source_path": "research/reversible-stochastic-shears/README.md", + "retained_path": "predecessor/PR6066-README.md", + "sha256": "bb6cee79d80fad16278141d1f0a42f348ec291eba288ee00668cdd59d5aab3d7", + "author": "https://github.com/zxv", + "license": "Apache-2.0" +} diff --git a/research/reversible-signed-half-kernel/PROOF.md b/research/reversible-signed-half-kernel/PROOF.md new file mode 100644 index 0000000000..93ebbe2a1e --- /dev/null +++ b/research/reversible-signed-half-kernel/PROOF.md @@ -0,0 +1,69 @@ +# A charged two-tape implementation of one signed stochastic half + +This addresses the physical half-SCALE question of [PR6066](https://github.com/CrocSwap/integer-mult-bounds/pull/6066). It lowers one macro with a resident coin and explicitly available clean working bits. It does not supply the full scalar caller, random-bit delivery, a native MOVE or a new kappa. + +## Contract, width and scratch + +Let W>=2. A W-bit two's-complement register holds arbitrary x in [-2^(W-1),2^(W-1)-1]. A resident read-only coin u is 0 or 1, and a parity cell r and W working cells start zero. The sign s in {-1,1} is a compiled parameter. The endpoint is + + (x, u, r=0, work=0^W) -> (S(s*x,2,u), u, (s*x) mod 2, 0^W), + +where S(n,2,u)=floor(n/2)+1[u < n mod 2]. Reversing the gate program restores x and clears r and every working cell. The coin cell is never written, even temporarily. + +Data positions 0..W-1 hold the little-endian signed value; positions W, W+1 and W+2 hold r,u,t; positions W+3..2W+1 hold W-1 carry bits. Thus the data extent is exactly 2W+2 binary cells. Of these, W are clean working cells (t and carries), one is the retained residue, one is the resident coin and W contain the dirty input. No extra arithmetic guard bit is needed on this declared input range. + +The interpreter has two Boolean control accumulators plus a fixed set of at most eight modes. The separate read-only program tape and its preparation are counted below. Clean workspace availability and placement of the resident coin are input obligations, not free consequences of a dirty caller. + +## Exact reversible gate word + +Extract the low bit with CNOT(x0,r), CNOT(r,x0). This records r=x mod 2 and clears x0. Swap neighboring bits from low to high, then copy the old sign bit into the vacated highest position. The value register now holds q=floor(x/2). This uses exactly 3W CNOTs and no arithmetic shift instruction. + +For positive sign, increment q when r(1-u)=1. For negative sign, increment q when ru=1 and then negate it in two's complement. The identities are + + S(x,2,u) = q+r(1-u), + S(-x,2,u) = -q-ru. + +The increment's control t is prepared and cleared reversibly. For r(1-u), use CNOT(r,t) then Toffoli(r,u,t), and reverse them after the increment; the coin is only a control. For ru, use one Toffoli before and after. The negative case complements every value bit and performs a controlled increment with t temporarily set to one. + +A controlled ripple increment first computes carries c_(j+1)=c_j*x_j with c0=t. It XORs c_j into x_j and then clears the carries in descending order using + + c_(j+1) = c_j * (1-x'_j). + +The negative bit control is two X gates around a Toffoli. Every carry and t returns zero. All gate operands are distinct. The increment has 2(W-1) Toffolis, W CNOTs and 2(W-1) X gates. + +All arithmetic has its signed meaning without overflow. The intermediate q lies between -2^(W-2) and 2^(W-2)-1; q plus its controlled increment lies between -2^(W-2) and 2^(W-2). Its negation fits in W bits. The gate word is a permutation even away from these reached states, but only the specified clean-work endpoint is given the stochastic-half interpretation. + +The exact gate counts are: + +| Sign | X | CNOT | Toffoli | +|---|---:|---:|---:| +| + | 2W-2 | 4W+2 | 2W | +| - | 5W-2 | 5W | 4W-2 | + +A zero-residue isolated implementation cannot restore x: for example S(0,2,1)=S(1,2,1). The one retained bit is necessary for this isolated map. Existing side information can change that contract, as the inferred sites in [PR6091](https://github.com/CrocSwap/integer-mult-bounds/pull/6091) illustrate. The W clean working cells are not claimed optimal. + +## Explicit fixed-tape lowering + +The tape alphabet has seven instruction symbols L,R,A,B,X,C,T, plus two boundary markers. L and R move the binary data head by one cell. A and B XOR the current data bit into the corresponding one-bit finite-control accumulator. X flips the current data bit; C flips it controlled by accumulator A; T flips it controlled by both A and B. Each action is reversible; L and R are inverse to each other. The program head moves one instruction at a time. There is no addressed data access in this interpreter. + +Each Boolean gate expands into literal unary head walks. An X visits its target and returns. A CNOT visits control/target/control/home, with operations A,C,A. A Toffoli visits first control/second control/target/second control/first control/home, with operations A,B,T,B,A. Every macro returns the data head and both control accumulators to zero. The compiler emits every walk symbol, including long gaps between operands. + +Let L be the emitted instruction-word length. A forward call executes L payload instructions and rewinds its read-only program head; an inverse call first sweeps to the end and executes the inverted instructions backwards. With the two marker transitions included, **each direction costs 2L+2 interpreter steps**, and both heads return to their entry positions. The program occupies L+2 fixed-alphabet cells. The inverse uses the same tape; it needs no second stored word. All input-dependent information is in the declared value, residue and resident coin, not in an unreturned head position or control register. + +If D=2W+1 is the largest data address, then the three gate macros have lengths at most 2D+1, 4D+3 and 6D+5, respectively. Hence, with the exact counts above, + + L <= N_X(2D+1)+N_C(4D+3)+N_T(6D+5) = O(W^2). + +This is a deliberately elementary implementation. Preparing its explicit unary program takes O(W^2 log W) charged setup time with O(log W) counter space; the output program itself has O(W^2) cells. It can be reused at the same width/sign. It does not establish a faster physical tariff, and the program storage is not excluded from the resource ledger. + +## Source binding and verification + +The frozen historical PR5599 prefix used by PR6066 contains 18 positive and 66 negative half SCALEs. Its first examples are zero-based event 52 at role345 and event89 at role259. Both use the coefficient signs implemented here. The module does not replace the whole 9,589-event source program or assume its other macros are free. + +The verifier compares the Boolean gate interpreter with an independent integer divmod formula for every signed input, both coins and both signs at W=2..8 (2,032 cases). A separate literal tape-head interpreter executes 324 full forward/inverse round trips, including larger widths through 128 and signed endpoints. It checks all scratch, read-only coin cells, returned heads, program motion, gate counts and exact program hashes. The written ripple/sign proof supplies the all-width quantifier. Wrong sign and unsupported width controls are included; normal and optimized checks remain active. + +## Remaining composition obligations + +A complete caller still needs the resident coin fetched and returned, allocation of these clean cells, an integer-grid width that contains actual caller values, every other scalar macro, data-layout movement between registers, inferred-residue sites, native MOVE error propagation and the total paid bill. The O(W^2) unary program should not be inserted into a faster budget without those charges. No supplier, selected change, independent human review or proof-kernel acceptance is claimed. + +Prepared by [zxv](https://github.com/zxv) with substantial OpenAI Codex assistance. Credit [Nick Petalas](https://github.com/petalas)'s [PR6026](https://github.com/CrocSwap/integer-mult-bounds/pull/6026), [Ali Romman](https://github.com/aliromman)'s [PR5599](https://github.com/CrocSwap/integer-mult-bounds/pull/5599), PR6066's stochastic ABI and retained predecessors. Ripple carries and reversible gate decompositions are classical. The contribution is their explicit signed stochastic-half/tape contract and complete local invoice. Apache-2.0. diff --git a/research/reversible-signed-half-kernel/README.md b/research/reversible-signed-half-kernel/README.md new file mode 100644 index 0000000000..af078792d7 --- /dev/null +++ b/research/reversible-signed-half-kernel/README.md @@ -0,0 +1,26 @@ +# PR6066's signed halves have an explicit reversible tape kernel + +One signed stochastic half from [PR6066](https://github.com/CrocSwap/integer-mult-bounds/pull/6066) now has an explicit binary gate word and two-tape program, with exact dirty-input restoration and residue cleanup. It works for every W>=2 signed bits, either sign and either resident coin, without a further arithmetic guard bit. The coin is never written. + +The kernel uses one retained parity bit, W clean working cells and a read-only unary program of O(W^2) symbols. Its literal data-head walks and program-head return are charged. A direction takes 2L+2 interpreter steps for emitted word length L; exact gate counts and per-width program hashes are in RESULT.json. The retained bit is necessary for the isolated half; working scratch is not claimed minimal. + +## Significance for researchers + +This completes the specific single-macro lowering requested by PR6066. Its physical tariff is concrete and includes program storage and head motion. It does not make the complete stochastic prefix or supplier free: resident coin delivery, other scalar macros, caller widths and native transitions still need their own bills. [PR6091](https://github.com/CrocSwap/integer-mult-bounds/pull/6091)'s inferred residue sites have extra side information and need a compatible composition. + +## Reproduce + +```sh +python3.12 -B scripts/research_package.py --package research/reversible-signed-half-kernel +python3.12 -B scripts/check_research_commit.py --package research/reversible-signed-half-kernel +``` + +Normal and optimized standard-library checks exhaust 2,032 signed gate cases through eight bits, execute 324 literal tape round trips and check larger guards through 128 bits. They compare separate integer, gate and tape interpreters, including signed endpoints, exact scratch/coin/head restoration, invoices and rejection controls. PROOF.md establishes the all-width identities and tape model; finite tests do not replace them. + +## Open next questions + +Install the kernel at one actual reached half site with paid resident-coin delivery, clean-work allocation and the caller's exact finite guard. Then lower the rounded ADD and other SCALE macros and total their physical bill. An optimized tape layout or asymptotically faster increment program is a separate comparison against this explicit baseline. + +## Scope and credit + +Only one local signed half is implemented. The historical PR5599 prefix is authenticated to bind its two coefficient signs and 84 sites, not replayed as a complete physical program. No native/selected cold replay, complete sampler/caller, improved kappa or total resource optimum is claimed. Prepared by [zxv](https://github.com/zxv) with substantial OpenAI Codex assistance; credit [Nick Petalas](https://github.com/petalas), [Ali Romman](https://github.com/aliromman), PR6066 and their retained source lineage. The pending predecessor statement is retained verbatim with its exact hash. Apache-2.0; no independent human or proof-kernel review. diff --git a/research/reversible-signed-half-kernel/RESULT.json b/research/reversible-signed-half-kernel/RESULT.json new file mode 100644 index 0000000000..e44828e286 --- /dev/null +++ b/research/reversible-signed-half-kernel/RESULT.json @@ -0,0 +1,416 @@ +{ + "exhaustive_signed_gate_cases": 2032, + "invoices": [ + { + "clean_work_bits": 2, + "data_cells": 6, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 10, + "T": 6, + "X": 8 + }, + "kernel_steps": 594, + "program_cells": 298, + "program_sha256": "585f1007f996421c23a9cfa41df26100c81cc1e0f4a05f61ed9b2c9056aa8e0a", + "program_symbols": 296, + "retained_parity_bits": 1, + "sign": -1, + "width": 2 + }, + { + "clean_work_bits": 2, + "data_cells": 6, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 10, + "T": 4, + "X": 2 + }, + "kernel_steps": 386, + "program_cells": 194, + "program_sha256": "c25fae11105dd1bb0d782ab5cc6db776568e66a6c72113e6f33ce24473b9de3e", + "program_symbols": 192, + "retained_parity_bits": 1, + "sign": 1, + "width": 2 + }, + { + "clean_work_bits": 3, + "data_cells": 8, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 15, + "T": 10, + "X": 13 + }, + "kernel_steps": 1206, + "program_cells": 604, + "program_sha256": "af6f60808330e42ab09575c83ca25b7d2204ef7313daf6add440e0fa638c9fbc", + "program_symbols": 602, + "retained_parity_bits": 1, + "sign": -1, + "width": 3 + }, + { + "clean_work_bits": 3, + "data_cells": 8, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 14, + "T": 6, + "X": 4 + }, + "kernel_steps": 726, + "program_cells": 364, + "program_sha256": "f3730af778dde16f7038e3b19f735b5ba01f6220a41794b1f401c911a60a3382", + "program_symbols": 362, + "retained_parity_bits": 1, + "sign": 1, + "width": 3 + }, + { + "clean_work_bits": 4, + "data_cells": 10, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 20, + "T": 14, + "X": 18 + }, + "kernel_steps": 2002, + "program_cells": 1002, + "program_sha256": "7ddade899561acc5121b1a93ca19f4266c034661505d24be51c5d6e367d0b82f", + "program_symbols": 1000, + "retained_parity_bits": 1, + "sign": -1, + "width": 4 + }, + { + "clean_work_bits": 4, + "data_cells": 10, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 18, + "T": 8, + "X": 6 + }, + "kernel_steps": 1162, + "program_cells": 582, + "program_sha256": "83e7ce31724e6bee669aae02ca34c484ad0a69acea91f86886dc4a49ab09bf97", + "program_symbols": 580, + "retained_parity_bits": 1, + "sign": 1, + "width": 4 + }, + { + "clean_work_bits": 5, + "data_cells": 12, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 25, + "T": 18, + "X": 23 + }, + "kernel_steps": 2982, + "program_cells": 1492, + "program_sha256": "95efec372abf94ba0db59414de472ffd6a0eba9b4d0fffa29b4e823fe66a74c9", + "program_symbols": 1490, + "retained_parity_bits": 1, + "sign": -1, + "width": 5 + }, + { + "clean_work_bits": 5, + "data_cells": 12, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 22, + "T": 10, + "X": 8 + }, + "kernel_steps": 1694, + "program_cells": 848, + "program_sha256": "d5195e8438cbdc683e33fbfb2d8c94e3cce07eba46d6a65a3e7f1637268c2adc", + "program_symbols": 846, + "retained_parity_bits": 1, + "sign": 1, + "width": 5 + }, + { + "clean_work_bits": 6, + "data_cells": 14, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 30, + "T": 22, + "X": 28 + }, + "kernel_steps": 4146, + "program_cells": 2074, + "program_sha256": "c3fc3c708ce7b0bcd1f8480022f73b047b6a77f8f985141727fb5f639b6706b7", + "program_symbols": 2072, + "retained_parity_bits": 1, + "sign": -1, + "width": 6 + }, + { + "clean_work_bits": 6, + "data_cells": 14, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 26, + "T": 12, + "X": 10 + }, + "kernel_steps": 2322, + "program_cells": 1162, + "program_sha256": "dfc571db686f09e19521dd3e81086c8ae54fb7d1cf506c778cb14a896f5c8159", + "program_symbols": 1160, + "retained_parity_bits": 1, + "sign": 1, + "width": 6 + }, + { + "clean_work_bits": 7, + "data_cells": 16, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 35, + "T": 26, + "X": 33 + }, + "kernel_steps": 5494, + "program_cells": 2748, + "program_sha256": "04bc2f0205bca115c123cee8795a745f20537a82da3adee9caffaaa3ceeb2ef0", + "program_symbols": 2746, + "retained_parity_bits": 1, + "sign": -1, + "width": 7 + }, + { + "clean_work_bits": 7, + "data_cells": 16, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 30, + "T": 14, + "X": 12 + }, + "kernel_steps": 3046, + "program_cells": 1524, + "program_sha256": "9e4cbc2b9ee500ae54bed591531fee2c8cbe583d23aa1cd2d22970dc95eaa99e", + "program_symbols": 1522, + "retained_parity_bits": 1, + "sign": 1, + "width": 7 + }, + { + "clean_work_bits": 8, + "data_cells": 18, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 40, + "T": 30, + "X": 38 + }, + "kernel_steps": 7026, + "program_cells": 3514, + "program_sha256": "189e2a4a14f6f9ec5423a6445ffbc3d6f956a8f6d9af886a01e7a55e4af67ab5", + "program_symbols": 3512, + "retained_parity_bits": 1, + "sign": -1, + "width": 8 + }, + { + "clean_work_bits": 8, + "data_cells": 18, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 34, + "T": 16, + "X": 14 + }, + "kernel_steps": 3866, + "program_cells": 1934, + "program_sha256": "a8dd33403ca4021dedf4d4fd9fb10f0c5b76f3b6476f4ef7003da0b8eefccede", + "program_symbols": 1932, + "retained_parity_bits": 1, + "sign": 1, + "width": 8 + }, + { + "clean_work_bits": 16, + "data_cells": 34, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 80, + "T": 62, + "X": 78 + }, + "kernel_steps": 25906, + "program_cells": 12954, + "program_sha256": "77b2f329acd565b3e531670624b908dfeaf6753097ff221db465524c69f57ace", + "program_symbols": 12952, + "retained_parity_bits": 1, + "sign": -1, + "width": 16 + }, + { + "clean_work_bits": 16, + "data_cells": 34, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 66, + "T": 32, + "X": 30 + }, + "kernel_steps": 13882, + "program_cells": 6942, + "program_sha256": "deb2cfdf41d6bea2ed25c150d290c7e96944e6e445f7d2c109f317173f08a3e0", + "program_symbols": 6940, + "retained_parity_bits": 1, + "sign": 1, + "width": 16 + }, + { + "clean_work_bits": 32, + "data_cells": 66, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 160, + "T": 126, + "X": 158 + }, + "kernel_steps": 98994, + "program_cells": 49498, + "program_sha256": "e1b66351f3cffdabe90960ffb6a50ca81b2cc09262a37e23d2ae77d337ea0190", + "program_symbols": 49496, + "retained_parity_bits": 1, + "sign": -1, + "width": 32 + }, + { + "clean_work_bits": 32, + "data_cells": 66, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 130, + "T": 64, + "X": 62 + }, + "kernel_steps": 52346, + "program_cells": 26174, + "program_sha256": "c379a5eb88f913a1753cdca7f564261c3dd67a2ae0faeebe154df7191cea7184", + "program_symbols": 26172, + "retained_parity_bits": 1, + "sign": 1, + "width": 32 + }, + { + "clean_work_bits": 64, + "data_cells": 130, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 320, + "T": 254, + "X": 318 + }, + "kernel_steps": 386482, + "program_cells": 193242, + "program_sha256": "b55d05bcd82bc9d50d9ce1dcae79096e8f39d156dea839fb3fbdda9eea89006d", + "program_symbols": 193240, + "retained_parity_bits": 1, + "sign": -1, + "width": 64 + }, + { + "clean_work_bits": 64, + "data_cells": 130, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 258, + "T": 128, + "X": 126 + }, + "kernel_steps": 203002, + "program_cells": 101502, + "program_sha256": "c81bad75592eba127cf12fb18d429ef42c848ff69729b9fbed8174b25330fa1d", + "program_symbols": 101500, + "retained_parity_bits": 1, + "sign": 1, + "width": 64 + }, + { + "clean_work_bits": 128, + "data_cells": 258, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 640, + "T": 510, + "X": 638 + }, + "kernel_steps": 1526706, + "program_cells": 763354, + "program_sha256": "6340b75ffab6a201fd42bd477527539807155f1a49f95ab15246a51c2192ad0b", + "program_symbols": 763352, + "retained_parity_bits": 1, + "sign": -1, + "width": 128 + }, + { + "clean_work_bits": 128, + "data_cells": 258, + "finite_control_accumulator_bits": 2, + "fixed_interpreter_modes_at_most": 8, + "gates": { + "C": 514, + "T": 256, + "X": 254 + }, + "kernel_steps": 799226, + "program_cells": 399614, + "program_sha256": "404e06dc31ef4bd8d7b56133811c084059bd3106c649134bb768b72e855e5a1e", + "program_symbols": 399612, + "retained_parity_bits": 1, + "sign": 1, + "width": 128 + } + ], + "large_guard_cases": 96, + "literal_tape_round_trips": 324, + "scope": "One local signed-half kernel with resident read-only coin and clean work. Complete caller/random-tape delivery and other scalar macros remain open; no new kappa.", + "source_first_negative": [ + 89, + 259, + "-1/2" + ], + "source_first_positive": [ + 52, + 345, + "1/2" + ], + "source_half_sites": 84, + "status": "PASS_REVERSIBLE_SIGNED_HALF_TAPE" +} diff --git a/research/reversible-signed-half-kernel/SOURCES.json b/research/reversible-signed-half-kernel/SOURCES.json new file mode 100644 index 0000000000..34b0d2454b --- /dev/null +++ b/research/reversible-signed-half-kernel/SOURCES.json @@ -0,0 +1,24 @@ +{ + "schema_version": 1, + "base_commit": "721c03822c421b7f7fcbb2598993b947c4d88419", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a", + "sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/p104-helper-subspace-splits/WORD.json.gz", + "usage": "input", + "git_blob": "e325091e3051afe37a2d9c82f85afe9028510edb", + "sha256": "bbb072bced5824a8d9094c49be2fc51fbfdd05fb2b7dab8106e1275053075099" + } + ] +} diff --git a/research/reversible-signed-half-kernel/TASK.json b/research/reversible-signed-half-kernel/TASK.json new file mode 100644 index 0000000000..90ce732d11 --- /dev/null +++ b/research/reversible-signed-half-kernel/TASK.json @@ -0,0 +1,89 @@ +{ + "schema_version": 1, + "task_id": "uniform-transfer-audit", + "priority_revision": 8, + "base_commit": "721c03822c421b7f7fcbb2598993b947c4d88419", + "original_card": { + "id": "uniform-transfer-audit", + "question": "Can one of the selected record's five inherited assumptions be proved at its actual caller?", + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md" + ], + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "acceptance_gate": "Identify the proposition and what would change downstream; do not equate a finite replay with a universal proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "first_experiment": "Choose one assumption ID (native_all_columns, owned_erasure, compiler, precision_tape, analytic_recovery), one quantified implication and exact dependency closure. Check current handoffs, including #5625 row reentry and #5707 root-prefix lowering, without treating their partial scope as the whole theorem. Prove or falsify that implication with a caller-bound argument; stop at the chosen obligation. Finite tests or root digits do not discharge an all-size statement.", + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "overlap_terms": [ + "native_all_columns", + "owned_erasure", + "compiler", + "precision_tape", + "analytic_recovery" + ], + "existing_checks": [ + { + "scope": "PR #4100: proposed unconditional construction and finite checks, without independent acceptance.", + "evidence": "research/unconditional-batched-crt/README.md", + "remaining": "Independent proof audit of one caller-bound all-size implication; all other premises remain explicit.", + "status": "author-checked", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "scope_status": "refined", + "actual_scope": "Lower one PR6066 signed stochastic half to an explicit reversible Boolean and fixed-tape program with complete local width, scratch, program storage and motion invoice.", + "scope_change_reason": "Explicit follow-up starts with recent zxv PRs; PR6066 asks for this particular physical macro.", + "bottleneck_link": "Removes one unpriced logical scalar primitive while leaving complete native/caller costs explicit.", + "budget_minutes": 30, + "stop_rule": "Stop after the all-width single-kernel proof and independent integer/gate/tape checks. Do not infer a full prefix or supplier tariff.", + "outcome": "completed", + "evidence": "PROOF.md; kernel.py; RESULT.json: exhaustive signed inputs, literal head programs, width/guard and source binding.", + "author": "zxv", + "ai_assistance": "Substantial OpenAI Codex assistance; no subagents or independent human/formal review.", + "open_questions": [ + { + "question": "Can this kernel be installed at an actual reached half site?", + "why_it_matters": "Binds local resources to the physical source caller.", + "first_step": "Export resident coin delivery, clean-work availability, scalar layout and the exact value/guard range.", + "blocked_by": "No complete caller installation or native transition is provided." + }, + { + "question": "Can the remaining rounded scalar macros and inferred-parity sites be priced?", + "why_it_matters": "One lowered macro does not establish the whole prefix cost.", + "first_step": "Add one rounded ADD and then total every actual source operation and tape movement.", + "blocked_by": "Full arithmetic/random-tape/native bill remains open." + } + ] +} diff --git a/research/reversible-signed-half-kernel/VERIFY.json b/research/reversible-signed-half-kernel/VERIFY.json new file mode 100644 index 0000000000..09d43e800a --- /dev/null +++ b/research/reversible-signed-half-kernel/VERIFY.json @@ -0,0 +1,32 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/p104-helper-subspace-splits/WORD.json.gz" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Independent integer/gate/literal-tape semantics, exact invoices, all-width guard controls" + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Same checks under optimization" + } + ] +} diff --git a/research/reversible-signed-half-kernel/kernel.py b/research/reversible-signed-half-kernel/kernel.py new file mode 100644 index 0000000000..e0b2279b09 --- /dev/null +++ b/research/reversible-signed-half-kernel/kernel.py @@ -0,0 +1,131 @@ +"""A finite binary-tape signed stochastic half. zxv + OpenAI Codex. Apache-2.0.""" +from collections import Counter + + +def need(ok,message): + if not ok: + raise ValueError(message) + + +def compile_gates(width,sign): + need(type(width) is int and width >= 2 and sign in (-1,1), 'kernel domain') + r,u,t = width,width+1,width+2 + carry = [t]+list(range(width+3,2*width+2)) + gates = [] + def x(a): gates.append(('X',a)) + def c(a,b): gates.append(('C',a,b)) + def tof(a,b,d): gates.append(('T',a,b,d)) + def swap(a,b): c(a,b);c(b,a);c(a,b) + def increment(): + for j in range(width-1): + tof(carry[j],j,carry[j+1]) + for j in range(width): + c(carry[j],j) + for j in range(width-2,-1,-1): + x(j);tof(carry[j],j,carry[j+1]);x(j) + c(0,r);c(r,0) + for j in range(width-1): + swap(j,j+1) + c(width-2,width-1) + if sign == 1: + c(r,t);tof(r,u,t) + increment() + tof(r,u,t);c(r,t) + else: + tof(r,u,t) + increment() + tof(r,u,t) + for j in range(width): x(j) + x(t);increment();x(t) + counts = Counter(g[0] for g in gates) + want = ({'X':2*width-2,'C':4*width+2,'T':2*width} if sign == 1 else + {'X':5*width-2,'C':5*width,'T':4*width-2}) + need(dict(counts) == want, 'exact gate invoice') + need(all(len(set(g[1:])) == len(g)-1 and max(g[1:]) < 2*width+2 for g in gates), + 'distinct bounded gate operands') + need(all(g[-1] != u for g in gates), 'coin cell is never written') + return gates + + +def execute_gates(initial,gates,inverse=False): + cells = list(initial) + for gate in reversed(gates) if inverse else gates: + op,*a = gate + if op == 'X': cells[a[0]] ^= 1 + elif op == 'C': cells[a[1]] ^= cells[a[0]] + else: cells[a[2]] ^= cells[a[0]] & cells[a[1]] + return cells + + +def compile_tape(gates): + """Unary head walks: no indexed data access exists in the tape program.""" + out = [] + head = 0 + def visit(position,op): + nonlocal head + out.append(('R'*(position-head)) if position >= head else ('L'*(head-position))) + out.append(op) + head = position + for g in gates: + op,*a = g + if op == 'X': + visit(a[0],'X') + elif op == 'C': + visit(a[0],'A');visit(a[1],'C');visit(a[0],'A') + else: + visit(a[0],'A');visit(a[1],'B');visit(a[2],'T') + visit(a[1],'B');visit(a[0],'A') + visit(0,'') + need(head == 0, 'all gate macros return the data head') + return ''.join(out) + + +def execute_tape(initial,code,inverse=False): + cells = list(initial) + head = a = b = 0 + moves = work = pc = 0 + writes = set() + if inverse: + while pc < len(code): + pc += 1;work += 1 + while (pc > 0 if inverse else pc < len(code)): + if inverse: + pc -= 1 + op = {'L':'R','R':'L'}.get(code[pc],code[pc]) + else: + op = code[pc];pc += 1 + work += 1 + if op in ('L','R'): + head += 1 if op == 'R' else -1 + moves += 1 + need(0 <= head < len(cells), 'data head inside declared extent') + elif op == 'A': a ^= cells[head] + elif op == 'B': b ^= cells[head] + elif op == 'X': cells[head] ^= 1;writes.add(head) + elif op == 'C': cells[head] ^= a;writes.add(head) + elif op == 'T': cells[head] ^= a & b;writes.add(head) + else: raise ValueError('invalid finite instruction') + if not inverse: + while pc: + pc -= 1;work += 1 + need(head == pc == a == b == 0, 'both heads and finite control return') + need(work == 2*len(code), 'payload execution plus program-head return invoice') + return cells,dict(steps=work+2,boundary_marker_steps=2,data_head_moves=moves, + written_cells=sorted(writes)) + + +def encode(x,width,u): + need(-(1 << (width-1)) <= x < 1 << (width-1) and u in (0,1), 'signed input/coin') + cells = [(x >> j) & 1 for j in range(width)]+[0]*(width+2) + cells[width+1] = u + return cells + + +def decode(cells,width): + value = sum(cells[j] << j for j in range(width)) + return value-(1 << width) if cells[width-1] else value + + +def expected(x,sign,u): + q,r = divmod(sign*x,2) + return q+int(u < r),r diff --git a/research/reversible-signed-half-kernel/predecessor/PR6066-README.md b/research/reversible-signed-half-kernel/predecessor/PR6066-README.md new file mode 100644 index 0000000000..829b3ebf4b --- /dev/null +++ b/research/reversible-signed-half-kernel/predecessor/PR6066-README.md @@ -0,0 +1,203 @@ +# Stochastic scalar prefixes can restore dirty inputs with a parity log + +A grid-valued stochastic ADD is an exactly invertible shear when its inverse +uses the complemented coin. A rounded signed halving instead needs one parity +bit; keeping that bit suffices, and recomputing it during reversal clears it. +Together these give a compute–accumulate–uncompute interface for the exact +9,589-event scalar prefix studied by +[Nick Petalas](https://github.com/petalas)'s +[PR #6026](https://github.com/CrocSwap/integer-mult-bounds/pull/6026). + +The source has 84 signed halvings. The protocol uses **84 clean residue bits +and 11,713 read-only random bits per real stream sample**, restores all 748 +arbitrary dirty working values, returns the residue log to zero, and leaves +the random tape unchanged. Its forward arithmetic law is exactly the source's +fresh stochastic rounding law. Thus its source-relative forward error bound +is retained under the source's assumptions; that concentration result is cited, +not independently replayed or strengthened here. + +This is a logical scalar-grid ABI, not a native rounded supplier, physically +reversible bit-level implementation, complete caller invoice or new κ. Physical +random-bit preparation/access, guard widths, integer arithmetic, temporary +cleanup and the later native MOVE remain payable and unimplemented. + +## Exact stochastic rounding and an inverse shear + +Normalize the grid spacing to one. For an integer numerator $n$, dyadic +denominator $d=2^q$, and a fixed coin integer $0\leq U