From 857a826e162cf9d4ccaa20e02bee6a3389e67bb0 Mon Sep 17 00:00:00 2001 From: Ali Romman <226877337+aliromman@users.noreply.github.com> Date: Wed, 18 Nov 2026 16:57:01 -0500 Subject: [PATCH] Build an owned canonical row with literal address generation --- .../.gitattributes | 1 + .../owned-canonical-row-producer/CREDITS.md | 50 ++++ .../owned-canonical-row-producer/PROOF.md | 217 ++++++++++++++ .../owned-canonical-row-producer/README.md | 62 ++++ .../owned-canonical-row-producer/RESULT.json | 100 +++++++ .../SOURCE-PINS.json | 146 ++++++++++ .../owned-canonical-row-producer/SOURCES.json | 18 ++ .../owned-canonical-row-producer/TASK.json | 89 ++++++ .../VALIDATION.md | 37 +++ .../owned-canonical-row-producer/VERIFY.json | 32 +++ .../interpreters.py | 72 +++++ .../owned-canonical-row-producer/program.py | 73 +++++ .../retained/pr4100/NOTICE.md | 38 +++ .../retained/pr4100/check_batched_crt.py | 265 +++++++++++++++++ .../retained/pr7593/LICENSE | 201 +++++++++++++ .../retained/pr7593/NOTICE.md | 21 ++ .../retained/pr7593/PROOF.md | 268 ++++++++++++++++++ .../retained/pr7593/README.md | 61 ++++ .../retained/pr7593/hardware.py | 85 ++++++ .../retained/pr7593/switch.py | 225 +++++++++++++++ .../retained/pr7734/CREDITS.md | 30 ++ .../retained/pr7734/PROOF.md | 158 +++++++++++ .../retained/pr7734/query.py | 50 ++++ .../retained/pr7735/CREDITS.md | 33 +++ .../retained/pr7735/PROOF.md | 265 +++++++++++++++++ .../retained/pr7735/README.md | 79 ++++++ .../retained/pr7735/SOURCE-PINS.json | 90 ++++++ .../retained/pr7735/program.py | 219 ++++++++++++++ .../retained/pr7740/PROOF.md | 186 ++++++++++++ .../owned-canonical-row-producer/sources.py | 19 ++ .../owned-canonical-row-producer/verify.py | 171 +++++++++++ 31 files changed, 3361 insertions(+) create mode 100644 research/owned-canonical-row-producer/.gitattributes create mode 100644 research/owned-canonical-row-producer/CREDITS.md create mode 100644 research/owned-canonical-row-producer/PROOF.md create mode 100644 research/owned-canonical-row-producer/README.md create mode 100644 research/owned-canonical-row-producer/RESULT.json create mode 100644 research/owned-canonical-row-producer/SOURCE-PINS.json create mode 100644 research/owned-canonical-row-producer/SOURCES.json create mode 100644 research/owned-canonical-row-producer/TASK.json create mode 100644 research/owned-canonical-row-producer/VALIDATION.md create mode 100644 research/owned-canonical-row-producer/VERIFY.json create mode 100644 research/owned-canonical-row-producer/interpreters.py create mode 100644 research/owned-canonical-row-producer/program.py create mode 100644 research/owned-canonical-row-producer/retained/pr4100/NOTICE.md create mode 100644 research/owned-canonical-row-producer/retained/pr4100/check_batched_crt.py create mode 100644 research/owned-canonical-row-producer/retained/pr7593/LICENSE create mode 100644 research/owned-canonical-row-producer/retained/pr7593/NOTICE.md create mode 100644 research/owned-canonical-row-producer/retained/pr7593/PROOF.md create mode 100644 research/owned-canonical-row-producer/retained/pr7593/README.md create mode 100644 research/owned-canonical-row-producer/retained/pr7593/hardware.py create mode 100644 research/owned-canonical-row-producer/retained/pr7593/switch.py create mode 100644 research/owned-canonical-row-producer/retained/pr7734/CREDITS.md create mode 100644 research/owned-canonical-row-producer/retained/pr7734/PROOF.md create mode 100644 research/owned-canonical-row-producer/retained/pr7734/query.py create mode 100644 research/owned-canonical-row-producer/retained/pr7735/CREDITS.md create mode 100644 research/owned-canonical-row-producer/retained/pr7735/PROOF.md create mode 100644 research/owned-canonical-row-producer/retained/pr7735/README.md create mode 100644 research/owned-canonical-row-producer/retained/pr7735/SOURCE-PINS.json create mode 100644 research/owned-canonical-row-producer/retained/pr7735/program.py create mode 100644 research/owned-canonical-row-producer/retained/pr7740/PROOF.md create mode 100644 research/owned-canonical-row-producer/sources.py create mode 100644 research/owned-canonical-row-producer/verify.py diff --git a/research/owned-canonical-row-producer/.gitattributes b/research/owned-canonical-row-producer/.gitattributes new file mode 100644 index 0000000000..130a3ecaa2 --- /dev/null +++ b/research/owned-canonical-row-producer/.gitattributes @@ -0,0 +1 @@ +retained/** -text whitespace=cr-at-eol diff --git a/research/owned-canonical-row-producer/CREDITS.md b/research/owned-canonical-row-producer/CREDITS.md new file mode 100644 index 0000000000..5fc1b94e38 --- /dev/null +++ b/research/owned-canonical-row-producer/CREDITS.md @@ -0,0 +1,50 @@ +# Credit and exact sources + +Ali Romman supplied the new row controller, complete ownership and cost proof, +two-path row verification and package, with substantial OpenAI Codex assistance +in research, implementation, verification and writing. Apache-2.0. + +The consumed point service is Ali Romman's +[PR #7735](https://github.com/CrocSwap/integer-mult-bounds/pull/7735), head +`460eb0c026649b28ab3b00f45de136599d0570fa`. Its +[program](https://github.com/aliromman/integer-mult-bounds/blob/460eb0c026649b28ab3b00f45de136599d0570fa/research/linear-tape-rotation-switch/program.py), +[proof](https://github.com/aliromman/integer-mult-bounds/blob/460eb0c026649b28ab3b00f45de136599d0570fa/research/linear-tape-rotation-switch/PROOF.md), +loader, source pins and credits are retained unchanged. The graph constructor +is called directly. Every source instruction is preserved under relocation; +its two halts become jumps into the controller. + +Jerry Chen supplied the builder, physical ABI, Tape operations and point +cleanup in [PR #7593](https://github.com/CrocSwap/integer-mult-bounds/pull/7593), +head `56335a406469fad85e88ff72820d506d8bea6f63`. His +[notice](https://github.com/CubeJerry/integer-mult-bounds/blob/56335a406469fad85e88ff72820d506d8bea6f63/research/literal-canonical-rotation-switch/NOTICE.md), +source files and license are retained. The dense row interpreter calls the +unchanged Tape operations; it does not alter the source fourteen-owner CPU. + +Nick Petalas supplied the endpoint and child formulas in +[PR #7504](https://github.com/CrocSwap/integer-mult-bounds/pull/7504). The +[source proof](https://github.com/petalas/integer-mult-bounds/blob/7efb9a84277ec31abe2a934aeef8c8a70548aa5b/research/canonical-rotation-switch-query/PROOF.md) +is the mathematical predecessor. Ali Romman's closed descent in +[PR #7734](https://github.com/CrocSwap/integer-mult-bounds/pull/7734), head +`57bb6efed1be1dda9eb1a0f622ec2773bc8b0047`, supplies the retained wider oracle +and the point-service formula. + +Cinna Davis supplied the canonical compiler and padded rotation in +[PR #4100](https://github.com/CrocSwap/integer-mult-bounds/pull/4100), head +`337d04939571a637aeab54a0f58f54fde811663a`. The unchanged +[compiler](https://github.com/CrocSwap/integer-mult-bounds/blob/337d04939571a637aeab54a0f58f54fde811663a/research/unconditional-batched-crt/check_batched_crt.py) +and original notice supply the independent finite canonical-table oracle. + +Ali Romman's [PR #7740](https://github.com/CrocSwap/integer-mult-bounds/pull/7740), +head `913d61fd9bd5d3d65a11c04f1baf50fc24ceb858`, supplies the retained +[three-rectangle proof](https://github.com/aliromman/integer-mult-bounds/blob/913d61fd9bd5d3d65a11c04f1baf50fc24ceb858/research/rotation-row-rectangles/PROOF.md) +and the physical row-producer question. Its sharper arithmetic stream is +related work, not an algorithm called by this row graph. + +JoyboyBrian's [PR #5092](https://github.com/CrocSwap/integer-mult-bounds/pull/5092) +supplies a complete generic all-layer producer and fixed key-service join. +Its [contract](https://github.com/JoyboyBrian/integer-mult-bounds/blob/af3030a82d22cb1d897d891eb872e927dc322db3/research/crt-encoded-benes-rom-producer/README.md) +credits ToikY's arena lowering and the retained CRT lineage. It is related +work with a different workload, not an imported or replayed dependency. + +All eighteen retained files have exact byte pins. The base manifest records +canonical provenance only; no unmerged dependency ancestry is asserted. diff --git a/research/owned-canonical-row-producer/PROOF.md b/research/owned-canonical-row-producer/PROOF.md new file mode 100644 index 0000000000..c7242465e8 --- /dev/null +++ b/research/owned-canonical-row-producer/PROOF.md @@ -0,0 +1,217 @@ +# A literal owned canonical row producer + +## 1. Result + +Put `N=2^h`. One fixed fifteen-tape graph reads the four supplied descriptors +`h,s,a,j` and returns all `N` bits of the canonical padded-rotation row in +current-wire order. It preserves the borrowed inputs, clears every private +body and temporary guard, and returns every head. Its successful bounds are + +```text +T <= 1280 N (h+4), +K_after <= K_entry + N + 20(h+4). +``` + +Each read, write, unit move, jump and halt costs one transition. `K` counts +historical visited cells. Erasing a cell does not release its history. +The graph has 3,397 instruction locations, independent of the input values. +Its compact sorted-JSON digest is +`1e0115c00b85d77ad78fb6c6202e442b79e82d338b63d8b7171e368d694c2383`. + +This is a complete local producer with an owned output. It is not a new +kappa, a complete CRT caller or a discharge of any framework assumption. +The output-linear arithmetic stream in PR7740 has a sharper work bound; +this graph does not claim that bound in literal transitions. See +`CREDITS.md` for source links and `SOURCE-PINS.json` for all exact bytes. + +## 2. Entry and return boundary + +Use the fixed alphabet `0,1,B,L,E`, represented by `0,1,2,3,4`. Put `W=h+1`. +All fifteen tape owners are distinct. Every head starts at its own origin. +Origins can differ. The caller supplies these roles: + +| Tape | Entry body and boundary | +| --- | --- | +| 0 | Positive canonical LSB-first binary `h`, then blank; permanent left marker | +| 1..3 | Exactly `W` LSB-first bits for `s,a,j`, then blank; permanent left markers | +| 4 | Blank address window through relative position `h+2`; blank left guard | +| 5 | Blank point-output window through relative position `h+2`; blank left guard | +| 6..13 | Blank point-private windows through relative position `h+2`; blank left guards | +| 14 | Blank output cells `0..N`, with a permanent left marker | + +The legal numeric domain is `h>=1`, `1<=s<=N`, `0<=a=2` and `h+4>=5`, this is +less than `1280N(h+4)`. The bounds come from the literal loops, not measured +fixture timings. A numeric-domain rejection makes only the first point +call and has no output-return scan, so it also fits this envelope. + +## 6. Historical backing + +The original fourteen point roles visit at most `13h+49` cells in total. +The wrapper's address construction, countdown, increments and clearing stay +inside the same role intervals. Its bit role stays at positions `-1..1`. +The new row tape visits positions `-1..N`, which add `N+2` cells. Thus the +union of every visited interval has size at most + +```text +N + 13h + 51 < N + 20(h+4). +``` + +Every call uses the same owner and origin for every private role. The bill +is a union of visited cells, not a sum of repeated per-call allocations. +Adding this complete union to entry history is a conservative bound even +when some supplied cells already have backing. Clearing does not reduce +that union. Descriptor transport and relocation corridors are caller costs. + +## 7. Evidence and scope + +The dense instruction path calls the retained source Tape operations. A +separate sparse path keeps its own cells, heads and dispatch. They share the +emitted graph and the fixture boundary; they are not independent human or +formal-kernel reviews. They agree on the complete returned state, instruction +count, head positions, write counts and historical intervals for: + +- All 213 rows and 1,566 bits in the 49 complete canonical networks through + height three, checked against the unchanged PR4100 compiler. +- All seventeen historical `(h,s,j)=(5,17,6)` rows, with 544 output bits. +- Six complete larger rows through height twelve, including the sharp + three-rectangle example and a 4,096-bit row. The retained closed query + supplies these wider expected values. + +The historical rows take 1,360,554 transitions in total; the maximum row +cost is 80,716. These are exact service counts, not wall-clock timings or a +matched full-caller comparison. Four invalid numeric domains reject before +output in both interpreters. Wrong output, missing tail and private-retirement +mutations fail. Both adapters reject aliased owners. Every embedded source +instruction and all eighteen retained files are checked exactly. + +The arithmetic row theorem has an output-linear stream, whose direct tape +lowering remains open. This contribution instead gives a complete `O(Nh)` +physical service. The generic PR5092 producer generates all layers and joins +a key service; its workload and input encoding differ, so no speedup over +that complete construction is asserted here. Actual CRT descriptor production, +conversion, payload routing, transport, output consumption and disposal still +need a complete caller bill. All five framework assumptions and the selected +frontier remain unchanged. Historical full suites, selected cold replay, +Lean and Docker were not run. diff --git a/research/owned-canonical-row-producer/README.md b/research/owned-canonical-row-producer/README.md new file mode 100644 index 0000000000..6df8430c17 --- /dev/null +++ b/research/owned-canonical-row-producer/README.md @@ -0,0 +1,62 @@ +# An owned canonical row producer + +One fixed 3,397-location, fifteen-tape program emits a complete canonical +padded-rotation row from four borrowed descriptors. It constructs every wire +address on tape, preserves inputs, clears private bodies and guards, and +returns every head. For `N=2^h`, the complete bounds are +`T<=1280N(h+4)` and `K_after<=K_entry+N+20(h+4)`. + +Read [PROOF.md](PROOF.md), [program.py](program.py), [RESULT.json](RESULT.json), +[SOURCE-PINS.json](SOURCE-PINS.json) and [CREDITS.md](CREDITS.md). The unchanged +PR7735 point graph is embedded with relocated control targets and return +jumps. No host loop supplies query addresses. The output remains owned. +There is no new kappa or complete CRT caller claim. + +## Reproduce + +Use Python 3.12 and its standard library: + +```sh +python3.12 -B scripts/research_package.py --package research/owned-canonical-row-producer +``` + +Both registered commands print: + +```text +PASS_OWNED_CANONICAL_ROW_PRODUCER 15 tapes; complete owned rows and returns +``` + +Two instruction paths compare all bits, complete returned states, head +positions, write counts and historical intervals for 213 complete small +rows, seventeen historical rows and six larger rows through 4,096 bits. +They also check all 3,237 retained source instructions, four numeric-domain +rejections, three semantic/retirement controls and two alias rejections. +The all-height result follows from the written invariant and loop counts, +not the finite range. See [VALIDATION.md](VALIDATION.md). + +## Scope and remaining costs + +The caller supplies correctly encoded descriptors, distinct owners, blank +windows and framing. The producer returns one owned row. Current-state CRT +descriptor production, conversion, payload use, transport and output disposal +remain caller obligations. The output-linear arithmetic stream in PR7740 +has no direct physical lowering here. The complete generic PR5092 producer +has a different workload, so no matched speedup over it is claimed. All five +framework assumptions and the selected frontier remain unchanged. + +## Open next questions + +1. Can the three-rectangle stream reach output-linear literal transitions? + Start with the sharp `(6,53,25,7)` row and lower its phase/run countdowns. + Descriptor preparation and complete ownership returns must be charged. +2. Can an actual CRT consumer use this exact row owner without a host rewrite? + Start with its current-wire query order and descriptor encoding. Bind the + real producer, transport, payload use and row disposal before pricing a + complete workload against retained ROM reuse. + +Prepared by Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. +The retained notices preserve Jerry Chen, Nick Petalas, Cinna Davis and the +full predecessor lineage. Separate interpretation is not independent human +or formal-kernel acceptance. + +[Canonical claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19719352). diff --git a/research/owned-canonical-row-producer/RESULT.json b/research/owned-canonical-row-producer/RESULT.json new file mode 100644 index 0000000000..3ade30732b --- /dev/null +++ b/research/owned-canonical-row-producer/RESULT.json @@ -0,0 +1,100 @@ +{ + "alias_rejections": 2, + "canonical_bits_per_interpreter": 1566, + "complete_networks": 49, + "complete_rows_per_interpreter": 213, + "graph_sha256": "1e0115c00b85d77ad78fb6c6202e442b79e82d338b63d8b7171e368d694c2383", + "historical_bits": 544, + "historical_bits_sha256": "bc0ab563e6d8fdfa24ee89b50dbe3f9a3a6f23681f491e883c6b5aeef07d4104", + "historical_max_transitions": 80716, + "historical_rows": 17, + "historical_span_bound": "2^h+20*(h+4)", + "historical_transitions": 1360554, + "instructions": 3397, + "larger_complete_rows": [ + { + "args": [ + 6, + 53, + 25, + 7 + ], + "bits": 64, + "bits_sha256": "512564c36c1ac8b48f5db0df55b16e12e0def35d2bcc42ef5cea9a9a401072aa", + "span": 184, + "steps": 182537 + }, + { + "args": [ + 7, + 127, + 1, + 0 + ], + "bits": 128, + "bits_sha256": "bb3b5004d9f1336a9b31b338653c581948876ac926f95e05152521e8b736ec76", + "span": 259, + "steps": 403873 + }, + { + "args": [ + 8, + 255, + 127, + 8 + ], + "bits": 256, + "bits_sha256": "94fc8074643e280b0950cabe70f196afc0740d24d65fb9f6d6756bc436d953d0", + "span": 400, + "steps": 874158 + }, + { + "args": [ + 9, + 511, + 255, + 16 + ], + "bits": 512, + "bits_sha256": "e227696796514192b43f554e412af0f75009d2ec8f5a8d8f184ee8ff8acf4f3c", + "span": 667, + "steps": 2115954 + }, + { + "args": [ + 10, + 1024, + 512, + 9 + ], + "bits": 1024, + "bits_sha256": "5a648d8015900d89664e00e125df179636301a2d8fa191c1aa2bd9358ea53a69", + "span": 1190, + "steps": 4003217 + }, + { + "args": [ + 12, + 4095, + 2047, + 12 + ], + "bits": 4096, + "bits_sha256": "236c145b2174fe58ad3bcadeaa568305d6b51f19c38d60530ef4bd18483c6869", + "span": 4284, + "steps": 18998051 + } + ], + "numeric_domain_rejections_per_interpreter": 4, + "retained_point_instructions": 3237, + "semantic_and_retirement_controls": [ + "wrong_output_bit", + "missing_row_tail", + "failed_private_retirement" + ], + "small_max_transitions": 15616, + "small_trace_sha256": "308db5f0c4c67619798b07c52178a090206bc64ae44fb76a62b266237db86761", + "small_transitions": 2792115, + "tapes": 15, + "transition_bound": "1280*2^h*(h+4)" +} diff --git a/research/owned-canonical-row-producer/SOURCE-PINS.json b/research/owned-canonical-row-producer/SOURCE-PINS.json new file mode 100644 index 0000000000..245d62a9f3 --- /dev/null +++ b/research/owned-canonical-row-producer/SOURCE-PINS.json @@ -0,0 +1,146 @@ +[ + { + "path": "retained/pr7593/switch.py", + "source_repository": "CubeJerry/integer-mult-bounds", + "source_commit": "56335a406469fad85e88ff72820d506d8bea6f63", + "source_path": "research/literal-canonical-rotation-switch/switch.py", + "git_blob": "18a09d34011beb106f03d82588bffba099d4fb55", + "sha256": "89fe721a2920943dbc58eefe7f855ac1573e653e8af3b029c9c2ef838fdeac40" + }, + { + "path": "retained/pr7593/hardware.py", + "source_repository": "CubeJerry/integer-mult-bounds", + "source_commit": "56335a406469fad85e88ff72820d506d8bea6f63", + "source_path": "research/literal-canonical-rotation-switch/hardware.py", + "git_blob": "a8c259b6c944dcdef5eb3f2b6de6994e33d667ac", + "sha256": "624de343edff608e6f9344546ea86d0d9cef32694d2f1ab01e07f1efaf172423" + }, + { + "path": "retained/pr7593/PROOF.md", + "source_repository": "CubeJerry/integer-mult-bounds", + "source_commit": "56335a406469fad85e88ff72820d506d8bea6f63", + "source_path": "research/literal-canonical-rotation-switch/PROOF.md", + "git_blob": "b886214a59155cde081f8a4b7bdc38d49d7b5bab", + "sha256": "1bd3150bdb075ba259dc9b7932800c8897e9b14d2198e8d001a7b212bad5f7b0" + }, + { + "path": "retained/pr7593/README.md", + "source_repository": "CubeJerry/integer-mult-bounds", + "source_commit": "56335a406469fad85e88ff72820d506d8bea6f63", + "source_path": "research/literal-canonical-rotation-switch/README.md", + "git_blob": "ac7cb615b88c8fc134fdb80274cba8e6879c1bba", + "sha256": "b5420164cbb580a3908f5f66fa32ea3f20fc75dc011c40460879d789706afa51" + }, + { + "path": "retained/pr7593/NOTICE.md", + "source_repository": "CubeJerry/integer-mult-bounds", + "source_commit": "56335a406469fad85e88ff72820d506d8bea6f63", + "source_path": "research/literal-canonical-rotation-switch/NOTICE.md", + "git_blob": "86f6b001dc097a54521eb53877ad0bcd056a8f3d", + "sha256": "34bcdb8b901543204546621cdad33347cbada2c0e1ef1a473f3af551070fc600" + }, + { + "path": "retained/pr7593/LICENSE", + "source_repository": "CubeJerry/integer-mult-bounds", + "source_commit": "56335a406469fad85e88ff72820d506d8bea6f63", + "source_path": "research/literal-canonical-rotation-switch/LICENSE", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" + }, + { + "path": "retained/pr7734/query.py", + "source_repository": "aliromman/integer-mult-bounds", + "source_commit": "57bb6efed1be1dda9eb1a0f622ec2773bc8b0047", + "source_path": "research/rotation-switch-closed-descent/query.py", + "git_blob": "5d5aa278a67f9a69c5d080a2781b68d5c0d953ef", + "sha256": "cee90bb9255113d0180f69d68ba8b4f45f8a3f104c33029ce7bcb247f285cea2" + }, + { + "path": "retained/pr7734/PROOF.md", + "source_repository": "aliromman/integer-mult-bounds", + "source_commit": "57bb6efed1be1dda9eb1a0f622ec2773bc8b0047", + "source_path": "research/rotation-switch-closed-descent/PROOF.md", + "git_blob": "65f3702b100b57e1bc178dbbc9478732c783fc37", + "sha256": "8103406c30f14631289fab4d6227da1c691851eac01ee4ed2991722d233e28f7" + }, + { + "path": "retained/pr7734/CREDITS.md", + "source_repository": "aliromman/integer-mult-bounds", + "source_commit": "57bb6efed1be1dda9eb1a0f622ec2773bc8b0047", + "source_path": "research/rotation-switch-closed-descent/CREDITS.md", + "git_blob": "939b2827ff073a68e8505656c401df6cccd21f75", + "sha256": "7fda78a59b54ab7ecb2ff9dee9a161cc6a7d20a779a29cc5bfd664dd7b4cecb2" + }, + { + "path": "retained/pr4100/check_batched_crt.py", + "source_repository": "CrocSwap/integer-mult-bounds", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "source_path": "research/unconditional-batched-crt/check_batched_crt.py", + "git_blob": "1cf78abccd5e06beecc3ed21ba55f7c03b65fdbc", + "sha256": "681e2e3d71fa74c8b9b326f3860104fd9d89590a222e26ae6ee718d1fd40ff2e" + }, + { + "path": "retained/pr4100/NOTICE.md", + "source_repository": "CrocSwap/integer-mult-bounds", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "source_path": "research/unconditional-batched-crt/NOTICE.md", + "git_blob": "886a8fdee275f01b459cbd68ae2815dc9269502f", + "sha256": "924109837e71c52392191710d49c9deb42780878d1094f0b01e8690dbe799461" + }, + { + "path": "sources.py", + "source_repository": "aliromman/integer-mult-bounds", + "source_commit": "460eb0c026649b28ab3b00f45de136599d0570fa", + "source_path": "research/linear-tape-rotation-switch/sources.py", + "git_blob": "aecd53a5325ce2ac3e652cfbc6c4a537177b7d74", + "sha256": "7345c644d4ce53af392b491a2d6d515feb45a87b3600ba7d36701f7fffe7da16" + }, + { + "path": "retained/pr7735/program.py", + "source_repository": "aliromman/integer-mult-bounds", + "source_commit": "460eb0c026649b28ab3b00f45de136599d0570fa", + "source_path": "research/linear-tape-rotation-switch/program.py", + "git_blob": "fe6438c7e22208bbb703ee9edaeee2c2df476347", + "sha256": "d88e8ae20cb781b758fef6ac4f09a837d788b5910f0205141d33069bfa758d76" + }, + { + "path": "retained/pr7735/PROOF.md", + "source_repository": "aliromman/integer-mult-bounds", + "source_commit": "460eb0c026649b28ab3b00f45de136599d0570fa", + "source_path": "research/linear-tape-rotation-switch/PROOF.md", + "git_blob": "f17652c50b093db3b4a26e76667cac32f54b9b94", + "sha256": "93f573bf54ac8aacfd4ef7105114f4663887379835440f669cfe9e4938584781" + }, + { + "path": "retained/pr7735/CREDITS.md", + "source_repository": "aliromman/integer-mult-bounds", + "source_commit": "460eb0c026649b28ab3b00f45de136599d0570fa", + "source_path": "research/linear-tape-rotation-switch/CREDITS.md", + "git_blob": "18d278e96724c66781039eb8184f007f4b2c1e43", + "sha256": "52b8fbe081eb9801e4d461ed75f52fd4172c21d34bde871a91a4b3cb2e378aa0" + }, + { + "path": "retained/pr7735/SOURCE-PINS.json", + "source_repository": "aliromman/integer-mult-bounds", + "source_commit": "460eb0c026649b28ab3b00f45de136599d0570fa", + "source_path": "research/linear-tape-rotation-switch/SOURCE-PINS.json", + "git_blob": "a17a375a6aa7c57e9354115784f6e5915b05313e", + "sha256": "485d235d979876541e09a7ce6bcbf4fc87df6ab7653cdc91f97ec7e5801af031" + }, + { + "path": "retained/pr7735/README.md", + "source_repository": "aliromman/integer-mult-bounds", + "source_commit": "460eb0c026649b28ab3b00f45de136599d0570fa", + "source_path": "research/linear-tape-rotation-switch/README.md", + "git_blob": "7f31c45f02ddbfbd26c0c9108a4b49ad1cec55ce", + "sha256": "46b0d8e0c17c2fc66deae93ad5347b1add601529d3f0065f3fb78266d808cbd4" + }, + { + "path": "retained/pr7740/PROOF.md", + "source_repository": "aliromman/integer-mult-bounds", + "source_commit": "913d61fd9bd5d3d65a11c04f1baf50fc24ceb858", + "source_path": "research/rotation-row-rectangles/PROOF.md", + "git_blob": "144b3000039f8a76e3d322188f266061539da0c7", + "sha256": "547ab7fad160a12d5fa11a35b32a5b9e8d729ee21fe52655053b9afbb9fc5fd3" + } +] diff --git a/research/owned-canonical-row-producer/SOURCES.json b/research/owned-canonical-row-producer/SOURCES.json new file mode 100644 index 0000000000..5335fa97d9 --- /dev/null +++ b/research/owned-canonical-row-producer/SOURCES.json @@ -0,0 +1,18 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + } + ] +} diff --git a/research/owned-canonical-row-producer/TASK.json b/research/owned-canonical-row-producer/TASK.json new file mode 100644 index 0000000000..7f7c644ccc --- /dev/null +++ b/research/owned-canonical-row-producer/TASK.json @@ -0,0 +1,89 @@ +{ + "schema_version": 1, + "task_id": "uniform-transfer-audit", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "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": "changed", + "actual_scope": "Fixed fifteen-tape owned whole-row producer from the unchanged PR7735 point graph, with literal address generation, output, cleanup, head return and complete transition/history bounds", + "scope_change_reason": "Close the physical row ownership boundary left by PR7740; a local compiler service, not all five framework assumptions.", + "bottleneck_link": "Supply a complete encoded row service whose addresses and output costs are paid before a later actual CRT consumer join.", + "budget_minutes": 60, + "stop_rule": "Finish the literal graph, universal bill, exact source composition and two-path row checks; stop before full CRT integration or output-linear tape lowering.", + "outcome": "completed", + "evidence": "PROOF.md, program.py, interpreters.py, verify.py, RESULT.json and SOURCE-PINS.json", + "author": "Ali Romman", + "ai_assistance": "Substantial OpenAI Codex assistance in research, implementation, verification and writing.", + "open_questions": [ + { + "question": "Can the three-rectangle stream reach output-linear literal transitions?", + "why_it_matters": "The arithmetic stream has a sharper bound than point composition.", + "first_step": "Lower the phase and run countdowns for the sharp height-six row, including preparation and returns.", + "blocked_by": "No literal descriptor/phase producer is supplied." + }, + { + "question": "Can an actual CRT consumer use this exact row owner without a host rewrite?", + "why_it_matters": "A supplied service is not a complete workload.", + "first_step": "Bind current-wire query order, descriptors, transport, payload use and output disposal.", + "blocked_by": "No actual CRT producer/consumer join is supplied." + } + ] +} diff --git a/research/owned-canonical-row-producer/VALIDATION.md b/research/owned-canonical-row-producer/VALIDATION.md new file mode 100644 index 0000000000..0ee5b714c9 --- /dev/null +++ b/research/owned-canonical-row-producer/VALIDATION.md @@ -0,0 +1,37 @@ +# Validation record + +Author checks used CPython 3.12.16 on macOS arm64 with the standard library. +The normal and optimized registered commands passed, with warnings treated +as errors. Syntax and indentation checks passed for the three new modules. +No test relies on Python assertions for its scientific checks. + +```sh +python3.12 -B scripts/research_package.py --package research/owned-canonical-row-producer +``` + +Expected final line: + +```text +PASS_REGISTERED_RESEARCH_PACKAGE research/owned-canonical-row-producer outcome=completed +``` + +`RESULT.json` records the fixed graph digest and exact transition/history +counts. Both instruction paths check complete owner states and head returns. +The canonical compiler checks all small rows; the closed formula checks the +larger rows. These mathematical oracles share predecessor definitions but +do not drive the physical program. All eighteen retained source files and +all 3,237 embedded point instructions are checked exactly. + +Release checks use the committed package and source history, an exported +archive, and both registered commands in a read-only directory without Git +or tools on PATH. The PR and canonical Discussion record report the actual +release and hosted-CI outcomes. Export integrity and source hashes do not +establish the mathematical theorem by themselves. + +No full historical scientific suite, selected cold replay, Lean or Docker +was run. The two instruction paths share the same emitted graph and fixture +boundary. No independent human or formal-kernel acceptance is claimed. +The program operates on supplied descriptors and blank owner windows; +actual CRT descriptor production, transport, payload use and output disposal +are not part of its local transition count. No fragile source patch, runtime +callback or host-generated query address is used. diff --git a/research/owned-canonical-row-producer/VERIFY.json b/research/owned-canonical-row-producer/VERIFY.json new file mode 100644 index 0000000000..537a9ed44c --- /dev/null +++ b/research/owned-canonical-row-producer/VERIFY.json @@ -0,0 +1,32 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Exact point graph relocation, two literal instruction paths, complete canonical and larger rows, owner/head/history returns, numeric rejection and semantic/retirement/alias controls" + }, + { + "argv": [ + "{python}", + "-W", + "error", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Exact point graph relocation, two literal instruction paths, complete canonical and larger rows, owner/head/history returns, numeric rejection and semantic/retirement/alias controls" + } + ] +} diff --git a/research/owned-canonical-row-producer/interpreters.py b/research/owned-canonical-row-producer/interpreters.py new file mode 100644 index 0000000000..3dc6f46cae --- /dev/null +++ b/research/owned-canonical-row-producer/interpreters.py @@ -0,0 +1,72 @@ +"""Two literal instruction paths for fifteen disjoint tape owners. + +Prepared by Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. +The dense path uses Jerry Chen's Tape operations. The sparse path does not. +""" + + +def check_owners(tapes): + if len(tapes) != 15 or len({id(tape) for tape in tapes}) != 15: + raise ValueError('fifteen distinct owners required') + + +def dense(code, tapes, limit): + check_owners(tapes) + pc = 0 + for steps in range(1, limit + 1): + ins = code[pc] + if ins[0] == 'R': + pc = ins[2][tapes[ins[1]].read()] + elif ins[0] == 'W': + tapes[ins[1]].write(ins[2]); pc += 1 + elif ins[0] == 'M': + tapes[ins[1]].move(ins[2]); pc += 1 + elif ins[0] == 'J': + pc = ins[1] + elif ins[0] == 'H': + return dict(outcome=ins[1], steps=steps, + cells=[t.cells[:] for t in tapes], heads=[t.head for t in tapes], + low=[t.low for t in tapes], high=[t.high for t in tapes], + writes=[t.writes for t in tapes]) + else: + raise ValueError('unknown dense instruction') + raise TimeoutError('dense instruction limit') + + +def sparse(code, tapes, limit): + check_owners(tapes) + heads = [t.origin for t in tapes] + low, high, writes = heads[:], heads[:], [0] * 15 + sizes = [len(t.cells) for t in tapes] + cells = {(owner, position): value for owner, tape in enumerate(tapes) + for position, value in enumerate(tape.cells) if value != 2} + pc = 0 + for steps in range(1, limit + 1): + op, *args = code[pc] + if op == 'H': + return dict(outcome=args[0], steps=steps, heads=heads, low=low, high=high, + writes=writes, cells=[[cells.get((i, j), 2) for j in range(sizes[i])] + for i in range(15)]) + if op == 'J': + pc = args[0]; continue + owner, operand = args + position = heads[owner] + if op == 'R': + pc = operand[cells.get((owner, position), 2)] + elif op == 'W': + writes[owner] += 1 + if operand == 2: + cells.pop((owner, position), None) + else: + cells[owner, position] = operand + pc += 1 + elif op == 'M': + if operand not in (-1, 1): + raise ValueError('nonunit sparse move') + heads[owner] += operand; position = heads[owner]; pc += 1 + else: + raise ValueError('unknown sparse instruction') + if not 0 <= position < sizes[owner]: + raise ValueError('sparse window exceeded') + low[owner] = min(low[owner], position); high[owner] = max(high[owner], position) + raise TimeoutError('sparse instruction limit') diff --git a/research/owned-canonical-row-producer/program.py b/research/owned-canonical-row-producer/program.py new file mode 100644 index 0000000000..efd62ab02d --- /dev/null +++ b/research/owned-canonical-row-producer/program.py @@ -0,0 +1,73 @@ +"""Emit a fixed whole-row graph with a literal address counter. + +Prepared by Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. +Jerry Chen supplied the builder. The point graph is retained without edits. +""" + +from sources import load + +point = load('retained_linear_point', 'retained/pr7735/program.py') +B, L, E = point.B, point.L, point.E +H, S, A, J, ADDRESS, BIT = range(6) +COUNT, ROW = 6, 14 + + +def clear_body(b, tape): + loop, erase, done = [b.fresh() for _ in range(3)] + b.mark(loop); b.read(tape, {0: erase, 1: erase, E: erase, B: done}) + b.mark(erase); b.op('W', tape, B); b.op('M', tape, 1); b.jump(loop) + b.mark(done); b.rewind(tape) + b.op('M', tape, -1); b.op('W', tape, B); b.op('M', tape, 1) + + +def compile_row(): + b = point.Builder() + for tape in (ADDRESS, BIT, COUNT): + b.op('M', tape, -1); b.op('W', tape, L); b.op('M', tape, 1) + last0, last1, put0, put1, copied = [b.fresh() for _ in range(5)] + b.read(H, {0: put0, 1: put1}) + for bit, label, after in ((0, put0, last0), (1, put1, last1)): + b.mark(label); b.op('W', COUNT, bit); b.op('M', COUNT, 1) + b.op('M', H, 1); b.jump(after) + b.mark(last0); b.read(H, {0: put0, 1: put1}) + b.mark(last1); b.read(H, {0: put0, 1: put1, B: copied}) + b.mark(copied); b.op('W', COUNT, E); b.rewind(COUNT); b.rewind(H) + b.op('W', ADDRESS, 0); b.op('M', ADDRESS, 1) + loop, append, ready = [b.fresh() for _ in range(3)] + b.mark(loop); b.read(COUNT, {0: append, 1: append, E: ready}) + b.mark(append); b.op('W', ADDRESS, 0); b.op('M', ADDRESS, 1) + b.compact_decrement(COUNT); b.jump(loop) + b.mark(ready); b.rewind(ADDRESS) + clear_body(b, COUNT) + b.mark('row_query') + code, _ = point.compile_query() + for pc, ins in enumerate(code): + b.mark('point_' + str(pc)) + if ins[0] == 'R': + b.op('R', ins[1], {symbol: 'point_' + str(target) for symbol, target in ins[2].items()}) + elif ins[0] == 'J': + b.jump('point_' + str(ins[1])) + elif ins[0] == 'H': + b.jump('row_return' if ins[1] == 'DONE' else 'row_reject') + else: + b.op(*ins) + b.mark('row_return') + zero, one = b.fresh(), b.fresh() + b.read(BIT, {0: zero, 1: one}) + for bit, label in ((0, zero), (1, one)): + b.mark(label); blank = b.fresh(); b.read(ROW, {B: blank}); b.mark(blank) + b.op('W', ROW, bit); b.op('M', ROW, 1); b.op('W', BIT, B) + b.jump('increment') + b.mark('increment') + carry, stop_carry, more = [b.fresh() for _ in range(3)] + b.read(ADDRESS, {0: stop_carry, 1: carry}) + b.mark(carry); b.op('W', ADDRESS, 0); b.op('M', ADDRESS, 1); b.jump('increment') + b.mark(stop_carry); b.op('W', ADDRESS, 1); b.op('M', ADDRESS, 1) + b.read(ADDRESS, {0: more, 1: more, B: 'row_done'}) + b.mark(more); b.rewind(ADDRESS); b.jump('row_query') + b.mark('row_done'); b.rewind(ADDRESS) + clear_body(b, ADDRESS); clear_body(b, BIT); b.rewind(ROW); b.op('H', 'DONE') + b.mark('row_reject') + clear_body(b, ADDRESS); clear_body(b, BIT); b.op('H', 'REJECT') + b.mark('reject'); b.op('H', 'REJECT') + return b.finish(), dict(b.labels) diff --git a/research/owned-canonical-row-producer/retained/pr4100/NOTICE.md b/research/owned-canonical-row-producer/retained/pr4100/NOTICE.md new file mode 100644 index 0000000000..886a8fdee2 --- /dev/null +++ b/research/owned-canonical-row-producer/retained/pr4100/NOTICE.md @@ -0,0 +1,38 @@ +# Attribution and source boundaries + +New construction and audit: Cinna Davis, with substantial OpenAI Codex +assistance. Apache-2.0. No independent human or new formal-kernel review +is claimed. SOURCES.json and EXPORTED-SOURCES.json retain exact identities. +Source-specific notices are unchanged. + +- Douglas Colkitt and OpenAI's framework: stream algorithms, compact controls, + ordinary interchange, row-volume and tape contracts. +- Jose Manuel (jmbarrancoml), selected recursive/physical BIT and complex + closure packages: class-indexed callers, ring descriptors, fixed-state + compilation, common-grid precision and source integration. +- DreamingOfClouds, eumemic, Dugongue, Rohan Arun, alephnan and the retained + PR589/PR1627 lineage: the finite BIT word and chronological hosting. +- commdata2338, Ross Richardson and source527 contributors: normal forms, + fallback covariance, weighted leaves and recursive parking. +- PR2915's selected fast-primitive work: replacing both the weighted leaf + and the reached owner-header sites with a completed previous stage. +- Vlado Vojdanovski, PR1673 and its credited contributors: capped Gaussian + cells, finite LDU, shallow Toeplitz circuits, tensor compilation, support + routing, sparse layouts and conditioning audits. +- Chafik Boukhalfa, PR1758/1786: shifted Gaussian accretivity, per-visit + union scheduling, fine prime intervals and separate setup precision. +- PR4088 and its NOTICE retain the mixed-provider lineage, including Rohan + Arun, David Ganz/Dugongue, Nick Petalas, Ross Richardson, dataisfire, + Erwan Secousses, Sagar Thakrar, roger-sato, Marius-Paul Dumitrean and the + native compiler/geometry contributors. +- Tekalign, Ali Romman, Charles Bethin and the native source notices: + exact native replay and sparse Clifford-state evaluation. +- Tim Trudgian: the explicit unconditional prime-counting estimate. +- David Harvey and Joris van der Hoeven: the established O(N log N) + multiplier used on the shorter numerical records. + +This package contributes batched nonlinear CRT and its enlarged-guard cost; +independent full-ring normal-form and fallback derivations; the retuned BIT +assembly; the mixed-provider free-algebra lift with external spectators; +conservative position-dependent halos; cached chirps; and the proposed outer +composition. The predecessor words, identities and compilers retain their credit. diff --git a/research/owned-canonical-row-producer/retained/pr4100/check_batched_crt.py b/research/owned-canonical-row-producer/retained/pr4100/check_batched_crt.py new file mode 100644 index 0000000000..1cf78abccd --- /dev/null +++ b/research/owned-canonical-row-producer/retained/pr4100/check_batched_crt.py @@ -0,0 +1,265 @@ +"""Exact finite controls for the draft; not a machine-cost certificate.""" +import itertools +import json +import math + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def benes(permutation): + """Return (bit, switch table) layers on precisely len(permutation) wires.""" + size = len(permutation) + need(size >= 2 and size & (size - 1) == 0, "dyadic network size") + need(sorted(permutation) == list(range(size)), "permutation") + if size == 2: + return [(0, (permutation[0],) * 2)] + inverse = [0] * size + for x, y in enumerate(permutation): + inverse[y] = x + color = [-1] * size + for initial in range(size): + if color[initial] >= 0: + continue + color[initial] = 0 + stack = [initial] + while stack: + x = stack.pop() + for other in (x ^ 1, inverse[permutation[x] ^ 1]): + if color[other] < 0: + color[other] = color[x] ^ 1 + stack.append(other) + need(color[other] == color[x] ^ 1, "even cycle coloring") + first = tuple(color[x] ^ (x & 1) for x in range(size)) + last = tuple(color[inverse[y]] ^ (y & 1) for y in range(size)) + children = [] + for c in (0, 1): + child = [None] * (size // 2) + for x in range(size): + if color[x] == c: + child[x // 2] = permutation[x] // 2 + children.append(benes(child)) + result = [(0, first)] + for left, right in zip(*children): + need(left[0] == right[0], "common network schedule") + table = tuple((left, right)[x & 1][1][x // 2] for x in range(size)) + result.append((left[0] + 1, table)) + result.append((0, last)) + return result + + +def run_network(layers, value): + for bit, table in layers: + value ^= table[value] << bit + return value + + +def rotation(size, modulus, offset): + return tuple((x + offset) % modulus if x < modulus else x for x in range(size)) + + +def decode_group(values, moduli): + """Recover the integer from locally scaled CRT residues.""" + product = math.prod(moduli) + answer = 0 + prefix = 1 + for value, modulus in zip(values, moduli): + complement = product // modulus + residue = value * prefix % modulus + answer += residue * complement * pow(complement, -1, modulus) + prefix *= modulus + return answer % product + + +def balanced(values, moduli, reverse=False, compiled=False): + count = len(moduli) + need(count > 0 and count & (count - 1) == 0, "power-of-two axis count") + state = list(values) + levels = list(range(1, count.bit_length())) + for level in reversed(levels) if reverse else levels: + width = 1 << level + half = width // 2 + for start in range(0, count, width): + middle = start + half + valid = all(state[i] < moduli[i] for i in range(start, middle)) + lower = decode_group(state[start:middle], moduli[start:middle]) if valid else 0 + prefix = math.prod(moduli[start:middle]) + for i in range(middle, start + width): + offset = lower * pow(prefix, -1, moduli[i]) % moduli[i] + if reverse: + offset = -offset % moduli[i] + if compiled: + size = 1 << (moduli[i] - 1).bit_length() + state[i] = run_network(benes(rotation(size, moduli[i], offset)), state[i]) + elif state[i] < moduli[i]: + state[i] = (state[i] + offset) % moduli[i] + prefix *= moduli[i] + return tuple(state) + + +def direct(values, moduli): + prefix = 1 + integer = 0 + prefixes = [] + for value, modulus in zip(values, moduli): + prefixes.append(prefix) + integer += value * prefix + prefix *= modulus + return tuple(integer * pow(prefix, -1, modulus) % modulus + for prefix, modulus in zip(prefixes, moduli)) + + +def primitive_f(u, t, y, bits, positions, ybits, control_bits): + radix = 1 << bits + control_mask = (1 << control_bits) - 1 + ymask = (1 << ybits) - 1 + z = [(u >> (bits * i)) & 1 for i in range(len(positions))] + digits = [(t >> (bits * i)) & (radix - 1) for i in range(len(positions))] + y = (y + sum(2 * bit * digit * (1 << pos) + for bit, digit, pos in zip(z, digits, positions))) & ymask + t = (t + sum(((y >> pos) & 1) << (bits * i) + for i, pos in enumerate(positions))) & control_mask + digits = [(t >> (bits * i)) & (radix - 1) for i in range(len(positions))] + y = (y + sum(bit * (1 - 2 * digit) * (1 << pos) + for bit, digit, pos in zip(z, digits, positions))) & ymask + t = (t - sum((((y >> pos) & 1) ^ z[i]) << (bits * i) + for i, pos in enumerate(positions))) & control_mask + return u, t, y + + +def compact(u, t, y, source, bits=2, positions=(0,), ybits=6, control_bits=2): + need(control_bits >= bits * len(positions), "control field capacity") + mask = (1 << control_bits) - 1 + u, t, y = primitive_f(u, t, y, bits, positions, ybits, control_bits) + u = (u + sum(value << (bits * i) for i, value in enumerate(source(y)))) & mask + u, t, y = primitive_f(u, t, y, bits, positions, ybits, control_bits) + u = (u - sum(value << (bits * i) for i, value in enumerate(source(y)))) & mask + return u, t, y + + +def good(u, t, y, bits=2, positions=(0,), guard=6): + radix = 1 << bits + return all(((u >> (bits * i)) & (radix - 1)) != radix - 1 + and ((t >> (bits * i)) & (radix - 1)) != radix - 1 + and 2 * radix <= ((y >> (pos + 1)) & ((1 << (guard - 1)) - 1)) + < (1 << (guard - 1)) - 2 * radix + for i, pos in enumerate(positions)) + + +def linear_guard(u, t, y, bits=2, positions=(0,), guard=6, + control_bits=2, ybits=6): + """Bit-by-bit guard predicate; source functions are never evaluated.""" + steps = 0 + accepted = True + for word in (u, t): + for digit in range(len(positions)): + all_ones = True + for bit in range(bits): + all_ones = all_ones and bool((word >> (digit * bits + bit)) & 1) + steps += 1 + accepted = accepted and not all_ones + for pos in positions: + lower = 2 * (1 << bits) + upper = (1 << (guard - 1)) - lower + comparison = [0, 0] + for bit in range(guard - 2, -1, -1): + value = (y >> (pos + 1 + bit)) & 1 + for index, bound in enumerate((lower, upper)): + if comparison[index] == 0: + comparison[index] = value - ((bound >> bit) & 1) + steps += 2 + accepted = accepted and comparison[0] >= 0 and comparison[1] < 0 + need(steps <= 2 * control_bits + 2 * ybits, "linear tested-bit budget") + return accepted + + +def check(): + network_count = address_count = 0 + for bits in range(1, 7): + size = 1 << bits + for modulus in range(max(2, size // 2), size): + for offset in range(modulus): + permutation = rotation(size, modulus, offset) + layers = benes(permutation) + need(len(layers) == 2 * bits - 1, "network depth") + for bit, table in layers: + need(all(table[x] == table[x ^ (1 << bit)] for x in range(size)), + "switch control omits its target bit") + need(tuple(run_network(layers, x) for x in range(size)) == permutation, + "all-column modular rotation") + network_count += 1 + address_count += size + crt_addresses = valid_addresses = 0 + for moduli in ((3,), (3, 5), (3, 5, 7, 11)): + sizes = [1 << (s - 1).bit_length() for s in moduli] + seen = set() + for source in itertools.product(*(range(size) for size in sizes)): + target = balanced(source, moduli) + need(target not in seen, "padded CRT injection") + seen.add(target) + need(balanced(target, moduli, reverse=True) == source, "padded CRT inverse") + valid = all(x < s for x, s in zip(source, moduli)) + need(valid == all(x < s for x, s in zip(target, moduli)), "padding invariance") + if valid: + need(target == direct(source, moduli), "scaled CRT endpoint") + valid_addresses += 1 + need(balanced(source, moduli, compiled=True) == target, "compiled CRT endpoint") + crt_addresses += 1 + compact_cases = good_cases = repair_cases = 0 + functions = [lambda y: (0,), lambda y: (1,), lambda y: ((y >> 2) & 1,), + lambda y: ((y >> 1).bit_count() & 1,), + lambda y: ((((y >> 1) & 1) & ((y >> 4) & 1)),)] + for source_function, control_bits in itertools.product(functions, (2, 4)): + actual = {} + ideal = {} + for u, t, y in itertools.product(range(1 << control_bits), + range(1 << control_bits), range(64)): + start = (u, t, y) + end = compact(*start, source_function, control_bits=control_bits) + wanted = (u, t, y ^ source_function(y)[0]) + need(end not in actual, "actual gadget bijection") + need(wanted not in ideal, "ideal switch bijection") + actual[end] = start + ideal[wanted] = start + is_good = good(*start) + need(linear_guard(*start, control_bits=control_bits) == is_good, + "linear guard agrees with interval predicate") + need(good(*end) == is_good and good(*wanted) == is_good, "good/bad invariance") + if is_good: + need(end == wanted, "compact endpoint on good addresses") + good_cases += 1 + compact_cases += 1 + # Each arbitrary dirty input column follows S, then T S^-1 on bad holes. + for end, start in actual.items(): + u, t, y = start + repaired = (u, t, y ^ source_function(y)[0]) if not good(*end) else end + need(ideal[repaired] == start, "sparse correction column") + repair_cases += not good(*end) + multi_cases = 0 + def source_pair(y): + return (y >> 3) & 1, (y & ~65).bit_count() & 1 + for u, t in ((0, 0), (0, 15), (5, 5), (10, 10), (15, 0), (15, 15)): + for y in range(1 << 12): + start = (u, t, y) + end = compact(*start, source_pair, positions=(0, 6), ybits=12, control_bits=4) + f0, f1 = source_pair(y) + wanted = (u, t, y ^ f0 ^ (f1 << 6)) + is_good = good(*start, positions=(0, 6)) + need(linear_guard(*start, positions=(0, 6), control_bits=4, ybits=12) == is_good, + "two-target linear guard") + need(good(*end, positions=(0, 6)) == is_good, "two-target guard invariance") + if is_good: + need(end == wanted, "two-target compact endpoint") + multi_cases += 1 + return dict(status="PASS_FINITE_BATCHED_CRT_CONTROLS", network_count=network_count, + network_addresses=address_count, crt_addresses=crt_addresses, + valid_crt_addresses=valid_addresses, compact_addresses=compact_cases, + good_addresses=good_cases, repaired_bad_addresses=repair_cases, + two_target_addresses=multi_cases, linear_guard_verified=True, + machine_cost_verified=False, multiplication_kappa_claimed=False) + + +if __name__ == "__main__": + print(json.dumps(check(), sort_keys=True, indent=2)) diff --git a/research/owned-canonical-row-producer/retained/pr7593/LICENSE b/research/owned-canonical-row-producer/retained/pr7593/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/owned-canonical-row-producer/retained/pr7593/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/owned-canonical-row-producer/retained/pr7593/NOTICE.md b/research/owned-canonical-row-producer/retained/pr7593/NOTICE.md new file mode 100644 index 0000000000..86f6b001dc --- /dev/null +++ b/research/owned-canonical-row-producer/retained/pr7593/NOTICE.md @@ -0,0 +1,21 @@ +# Attribution and scope + +Prepared for Jerry Chen / @CubeJerry with substantial OpenAI assistance. +Apache-2.0. No independent human or formal-kernel acceptance is claimed. + +Nick Petalas, CrocSwap/integer-mult-bounds#7504 at +4eece58f5cebdb70a92d65447974f1c02383f60b, supplied the direct canonical +padded-rotation predicate, endpoint formulas and exact child closure. +His unmodified proof, source manifest and evaluator are retained. These +mathematical results and arithmetic complexity are credited prior work. + +Cinna Davis / 1337isnot1337 #4100 supplied the original deterministic Beneš +compiler and padded rotation. Its canonical check_batched_crt.py and NOTICE +remain unmodified. ToikY #4192 supplied generic arena lowering; JoyboyBrian +#5092/#5496 and successors supplied the encoded ROM/current-row context. +#7388's live CRT caller and #7390's sort fusion remain separate work. + +The new contribution is the2096-location,14-tape graph, its format/domain +validation, owned-Boolean/cleanup/guard contracts, complete scan costs and +historical-backing bound. No predecessor formula is claimed anew. No full +caller or selected assumption is discharged and no new kappa is claimed. diff --git a/research/owned-canonical-row-producer/retained/pr7593/PROOF.md b/research/owned-canonical-row-producer/retained/pr7593/PROOF.md new file mode 100644 index 0000000000..b886214a59 --- /dev/null +++ b/research/owned-canonical-row-producer/retained/pr7593/PROOF.md @@ -0,0 +1,268 @@ +# A literal canonical padded-rotation switch predicate + +## 1. Claim, source and credited arithmetic + +Canonical base: e54523517d0f03e58352e647c403a5af3e525a57. Nick Petalas's +[#7504](https://github.com/CrocSwap/integer-mult-bounds/pull/7504), exact head +4eece58f5cebdb70a92d65447974f1c02383f60b, proves the arithmetic formulas and +child closure for Cinna Davis's #4100 canonical Beneš compiler. Its proof +and evaluator are retained byte-for-byte. The canonical compiler SHA256 is +681e2e3d71fa74c8b9b326f3860104fd9d89590a222e26ae6ee718d1fd40ff2e. +Those formulas and their canonical orientation are credited prior results. + +For h>=1, N=2^h, 1<=s<=N, 0<=a0, s<=2^h, aS rejects. The credited child theorem +proves A<=S. Since this branch has prior A>0, S>=2 and the child modulus is +positive. J decreases once, R twice and X is halved. The invariant now holds +at eta-1 and the requested canonical bit is unchanged. At most h loop +entrances occur. This induction proves all-height correctness independently +of finite fixtures. No recursion stack or whole permutation is produced. + +The caller still owes the current-wire payload update between queries. +This predicate does not silently advance x or convert original-token labels. + +## 5. Complete instruction and historical-backing bounds + +Every R/W/M/J/H costs one; labels have no action. For at most W-bit records, +direct counts of the emitted loops give these safe complete bounds: + +| Macro | Instructions including returns | +| --- | ---: | +| Rewind from relative position <=W+1 |3W+6| +| Zero test including destination jump |6W+5| +| Increment/decrement |7W+5| +| Zero a number |7W+4| +| Copy a number and return both heads |11W+7| +| Right shift |9W+2| +| Left shift |7W+5| +| Compare and branch |11W+10| + +For example comparison uses two reads, two moves and one jump per bit, +then two frontier reads, two full rewinds and its destination jump. Right +shift has six transitions per following-bit transfer, plus its first move, +high zero and return. These counts include scanning erased spans to return. + +The canonical height has ell<=h=1<>i)&1 for i in range(width)] + +def fixture(h,s,a,j,x,overrides=None): + if h<0: raise ValueError('fixture h domain') + width=h+1 + bodies=[bits(h,max(1,h.bit_length())),bits(s,width),bits(a,width),bits(j,width),bits(x,width)] + if overrides: + for key,value in overrides.items(): bodies[key]=list(value) + tapes=[Tape(body,origin=3+i%4) for i,body in enumerate(bodies)] + tapes.append(Tape((),origin=4,capacity=1)) + # Capacity includes current blank frontier and guard retirement. + tapes.extend(Tape((),origin=3+i%5,private=True,capacity=max(h+2,len(bodies[0])+1)) for i in range(8)) + return tapes + +def check_return(tapes,before,outcome,expected=None): + if any(t.head!=t.origin for t in tapes): raise ValueError('head return') + for t,old in zip(tapes[:5],before[:5]): + if t.cells!=old or t.writes: raise ValueError('borrowed descriptor changed') + if outcome=='DONE': + old=list(before[5]);old[tapes[5].origin]=expected + if tapes[5].cells!=old or tapes[5].writes!=1: raise ValueError('owned Boolean output') + elif outcome=='REJECT': + if tapes[5].cells!=before[5] or tapes[5].writes: raise ValueError('rejected output modified') + else: raise ValueError('unknown outcome') + for t,old in zip(tapes[6:],before[6:]): + if t.cells!=old: raise ValueError('private capacity or exterior not restored') + if t.guard_writes!=[L,B]: raise ValueError('private guard lifetime') + if any(t.low=1`, `N=2^h`, `1<=s<=N`, and `0<=a0` as a nonidentity +child gives a wrong central switch already at `(h,s,a,j,x)=(2,2,1,1,1)`. + +## 3. Collapse any number of child steps + +The child branches of a table query are the low bits of its current wire: +`c_i=(x>>i) mod 2`. For any depth `0<=d>d`. After exactly `d` +interior descents, the requested row is an endpoint of height `H`. +The query uses the pair in Section 3 once. If either length is zero, +return zero. If `H=1`, both positive integer lengths must be one; return +one. Otherwise set `S=A_d+B_d` and `A=A_d`. + +For the first endpoint, when `j=d`, return + +```text +[S and A are odd] [floor(y/2)=floor(S/2)]. +``` + +For the last endpoint, return + +```text +[A is odd] [y=2`, `s=2^h-1`, `j=2h-2`, and `x=0`. With an `h`-bit offset field, +the all-zero offset returns zero. Changing any one offset bit `k` with +`1<=k=3`, +fix `x=a=2^(h-1)`, the same odd `s` and last row. The baseline answer is +zero. Changing any offset bit `1<=k> depth, + (modulus - offset + mask - tail) >> depth) + + +def endpoint(left, right, address, height, last): + """Evaluate the endpoint, including every identity child.""" + if left == 0 or right == 0: + return 0 + if height == 1: + return 1 + modulus = left + right + if not last: + return int((modulus & left & 1) and address // 2 == modulus // 2) + if modulus % 2 == 0: + return int(left % 2 == 1 and address < modulus) + if left % 2 == 0: + return int(address < left) + return int(left - 1 <= address <= modulus) + + +def switch_bit(height, modulus, offset, layer, address): + """Return the source's current-wire table bit with O(height) bit work.""" + require(all(type(v) is int for v in (height, modulus, offset, layer, address)), + "integer parameters") + require(1 <= height <= MAX_HEIGHT, "height outside the executable limit") + require(1 <= modulus <= 1 << height, "modulus outside the address domain") + require(0 <= offset < modulus, "offset outside the canonical interval") + require(0 <= layer < 2 * height - 1, "layer outside the network") + require(0 <= address < 1 << height, "address outside the network") + depth = min(layer, 2 * height - 2 - layer) + left, right = interval_pair(modulus, offset, depth, address) + return endpoint(left, right, address >> depth, height - depth, layer != depth) diff --git a/research/owned-canonical-row-producer/retained/pr7735/CREDITS.md b/research/owned-canonical-row-producer/retained/pr7735/CREDITS.md new file mode 100644 index 0000000000..18d278e967 --- /dev/null +++ b/research/owned-canonical-row-producer/retained/pr7735/CREDITS.md @@ -0,0 +1,33 @@ +# Credit and source boundaries + +Prepared by Ali Romman with substantial OpenAI Codex assistance in research, +implementation, verification and writing. New work is Apache-2.0. + +- Jerry Chen supplied the physical ABI, builder primitives, primary hardware + and quadratic graph in [PR #7593](https://github.com/CrocSwap/integer-mult-bounds/pull/7593). + The [program source](https://github.com/CubeJerry/integer-mult-bounds/blob/56335a406469fad85e88ff72820d506d8bea6f63/research/literal-canonical-rotation-switch/switch.py), + [hardware](https://github.com/CubeJerry/integer-mult-bounds/blob/56335a406469fad85e88ff72820d506d8bea6f63/research/literal-canonical-rotation-switch/hardware.py) + and [proof](https://github.com/CubeJerry/integer-mult-bounds/blob/56335a406469fad85e88ff72820d506d8bea6f63/research/literal-canonical-rotation-switch/PROOF.md) + are retained unchanged. Initialization in the new emitter adapts this + source. Its Builder and cleanup are called without mutation. The old + complete graph is replayed on the same 544 service fixtures. +- Ali Romman's [PR #7734](https://github.com/CrocSwap/integer-mult-bounds/pull/7734) + supplied the [closed descent proof](https://github.com/aliromman/integer-mult-bounds/blob/57bb6efed1be1dda9eb1a0f622ec2773bc8b0047/research/rotation-switch-closed-descent/PROOF.md) + and [arithmetic oracle](https://github.com/aliromman/integer-mult-bounds/blob/57bb6efed1be1dda9eb1a0f622ec2773bc8b0047/research/rotation-switch-closed-descent/query.py). + Nick Petalas's [PR #7504](https://github.com/CrocSwap/integer-mult-bounds/pull/7504) + supplied the endpoint and child formulas. These are predecessor results. +- Cinna Davis's [PR #4100](https://github.com/CrocSwap/integer-mult-bounds/pull/4100) + supplied the [canonical network compiler](https://github.com/CrocSwap/integer-mult-bounds/blob/337d04939571a637aeab54a0f58f54fde811663a/research/unconditional-batched-crt/check_batched_crt.py). + Its unchanged finite function supplies expected table bits. Its full + unconditional claim is not an accepted premise here. + +The new contribution is the physical closed-descent program, canonical +countdown and carry-scan lowering, linear complete service bill, and +separate sparse instruction interpretation. No predecessor formula or +physical ABI is claimed anew. Shared code and mathematical premises are +explicit; separate interpretation is not independent human acceptance. + +`SOURCE-PINS.json` records eleven retained files. The source notices and +license are unchanged, including ToikY, JoyboyBrian, Douglas Colkitt and +their predecessor lineages. `SOURCES.json` binds only base provenance. +No unmerged ancestry or full historical replay is asserted. diff --git a/research/owned-canonical-row-producer/retained/pr7735/PROOF.md b/research/owned-canonical-row-producer/retained/pr7735/PROOF.md new file mode 100644 index 0000000000..f17652c50b --- /dev/null +++ b/research/owned-canonical-row-producer/retained/pr7735/PROOF.md @@ -0,0 +1,265 @@ +# A linear-transition physical switch query + +## 1. Result and dependencies + +One fixed graph with 3,237 instruction locations and fourteen tapes computes +the canonical padded-rotation switch at every legal `(h,s,a,j,x)`. On the +unchanged PR7593 entry contract it returns one owned Boolean, preserves five +borrowed descriptors, clears eight private bodies and their temporary guards, +and returns every head. Its successful bounds are + +```text +T <= 1024(h+4), +K_after <= K_entry + 16(h+4). +``` + +`T` counts every read, write, unit move, jump and halt. `K` counts historical +visited cells; clearing does not release history. The new time bound is +linear in `h`. The earlier graph's published bound is `1024(h+3)^2`. +This comparison concerns the supplied query service. It is not a full CRT +caller bound, a measured runtime speedup, a new kappa, or a selected-frontier +change. The word "linear" includes validation, preparation and cleanup. + +Jerry Chen's PR7593 supplies the physical ABI, unchanged builder primitives, +primary interpreter and cleanup routine. Nick Petalas supplies the endpoint +and child formulas through PR7504. Ali Romman's PR7734 supplies the closed +descent and bit-probe lower bound. Cinna Davis's PR4100 compiler defines the +finite canonical-table oracle. See `CREDITS.md` and `SOURCE-PINS.json`. + +The new graph digest, with the retained compact sorted-JSON convention, is +`530e83add1f22dcbb2b207e7ede64b2cecc44cce71db5fb26706ce18b842f92c`. +The optional mutation argument emits separate control graphs. It is never +a runtime input. No input integer reaches a generated instruction operand. + +## 2. Entry and return contract + +The fixed alphabet is `0,1,B,L,E`, encoded by `0,1,2,3,4`. `B` is blank, +`L` is the left marker and `E` is a private end marker. Put `W=h+1`. + +| Tapes | Entry state | +| --- | --- | +| 0 | Borrowed positive canonical LSB-first binary `h`, then blank | +| 1..4 | Borrowed `s,a,j,x`, each exactly `W` LSB-first bits, then blank | +| 5 | Owned output body and its next cell blank | +| 6..13 | Disjoint private windows, blank through relative position `h+2` | + +Every head starts at its own first body cell. Origins can differ. Tapes 0..5 +have a permanent `L` immediately before the body. That cell is initially +blank on tapes 6..13; the graph installs and later erases their guards. +The supplied windows and distinct owners are preconditions. No row-label +count is treated as free physical storage. Opaque exteriors are not used. +Input bodies have no interior `L` markers. + +The legal numeric domain is `h>=1`, `1<=s<=2^h`, `0<=a empty zero`. + +The graph uses at most `12(k+1)` transitions for this operation. A sequence +from `n` to zero costs less than `24n`, because + +```text +sum_(v=1)^n (v2(v)+1) + = n + sum_(r>=1) floor(n/2^r) < 2n. +``` + +This bound includes head returns. It does not charge a full-width zero scan +at every step. `compact` converts a supplied padded private word to this +representation: scan to its end, erase high zero digits, put the new end +after the highest one, and return. Zero receives an end at the origin. +Every cell removed from the representation is cleared. + +The graph copies and validates `h`, then uses the canonical countdown to +produce `W` unary guide cells. This takes linear work even though the height +is supplied in binary. The guide initializes six `W`-bit numeric records +and validates/copies the four padded descriptors. The retained binary +primitives compute `R=2h-2`, create `2^h` by setting the high temporary bit, +and perform all domain comparisons. The borrowed originals remain intact. + +## 4. A single pair of carry scans + +After validation, the graph computes `b=s-a` and `r=2h-2-j`. A comparison +between `j` and `r` selects one of three fixed control branches: + +```text +jr: last endpoint, d=r. +``` + +The chosen `d` is compacted on the private `J` tape. There is no runtime +recursive call or child-descent loop. The two data scans have this invariant: + +- Before low-digit step `i=2` bits. The wire head already selects the suffix +`y=x>>d`; copy it to a spare private record. Form `S=A_d+B_d` with one +equal-width addition. These are literal scans, not variable shifts or +unit-cost integer operations. + +The earlier full-width data beyond a shortened end remain allocated until +cleanup. They have no role in arithmetic. They contain only digits or old +end markers, with no blank gap before the original frontier. Cleanup thus +erases them as well. Compacted counters are different: their shortened +tails are already blank. This establishes the cleanup precondition in both +cases; it does not discard hidden storage. + +## 5. Canonical answer and restoration + +PR7734 proves that the pair in Section 4 is the exact unreduced interval +pair after `d` source child steps. If either quotient is zero, the whole +child is identity. The graph tests both and returns zero. At the center, +both positive quotients must be one, so the one-row switch is one. + +Otherwise the first-endpoint graph returns + +```text +[S and A_d are odd] [floor(y/2)=floor(S/2)]. +``` + +The last-endpoint graph returns + +```text +[A_d is odd] [y=1`, `N=2^h`, `1<=s<=N`, `0<=a=D-u], +B = floor((s-a+D-1-t)/D) = q + [t=D-u`, the +possible pairs are `(p,q+1)`, `(p+1,q+1)`, and `(p+1,q)`; their qualifying +parities are `(odd,odd)`, `(even,odd)`, and `(even,even)`. Again, at most +one strip qualifies. Equal cuts and zero lengths only remove strips. + +At the center, `H=1`. The condition that both lengths are positive is + +```text +max(0,D-a) <= t < min(D,s-a). +``` + +It is one interval, possibly empty. The quotient interval is `[0,2)`. +Thus the center also needs at most one rectangle. For `h=1`, this is the +only row. + +## 4. The three-rectangle bound is sharp + +Take `(h,s,a,j)=(6,53,25,7)`, so `d=3` and `D=8`. Direct substitution gives + +| Remainder interval | Quotient interval | +|---|---| +| `[0,4)` | `[2,8)` | +| `[4,7)` | `[0,6)` | +| `[7,8)` | `[0,4)` | + +The one entries at `(t,y)=(0,6),(4,4),(7,0)` form a three-point fooling +set. A Cartesian rectangle that contains two points must contain both +cross points. For the three pairs, respectively, `(4,6)`, `(0,0)`, and +`(7,4)` are zero entries. Thus no all-one rectangle contains two witness +points. Every exact rectangle cover has at least three members. This +argument even allows arbitrary Cartesian subsets, not only intervals. + +The descriptor contains `4*6+3*6+1*4=46` active wire bits. The row has +23 active switches, since each switch has two paired wires. In general, +the active-bit count is the sum of the three rectangle areas, and the +active-switch count is half this sum. These are counts for the canonical +row. They are not minima over all routing networks or swap factorizations. + +## 5. Emit the row without a full-width query at each wire + +The output order is increasing `y`, then increasing `t`. Sort all quotient +endpoints together with `0` and `2^H`. At most seven nonempty phases result. +Within one phase the pattern over `t` is fixed. Sort all remainder endpoints +together with `0,D`. There are at most seven runs, including zero runs. +Evaluate the constant bit of each run once per phase. + +For a phase of `R` quotient values, repeat its run pattern `R` times. +Use canonical least-significant-bit-first countdowns for `R` and each run +length `L`. Zero is the empty list. A decrement of `n>0` visits +`v_2(n)+1` bits; if it clears the highest bit, remove that bit. Across a +complete countdown from `n` to zero, the exact number of visits is + +```text +sum_(k=1)^n (v_2(k)+1) = 2n-popcount(n) < 2n, n>0. +``` + +Return scans to the low end add only a constant factor. Empty-list tests +do not scan a fixed-width zero field. Retain one binary template for each +run length. Reset the inner counter by copying this template. For positive +`L`, its binary length is at most `L`. Thus all inner resets in one block +copy at most `D` bits. Across the whole row they copy at most `N` bits. + +There are `2^H<=N` outer decrements. Inner counters have exactly `N` +decrements. The sum of their bit visits is less than `4N`. Outer resets +copy at most `7(h+1)` bits. The at most seven phases, each with at most +seven run templates and one outer template, use at most `56(h+1)` template +bits in total. Phase preparation and interval comparisons cost `O(h)`. +Loop control is constant per run, block or output bit; each nonempty run +emits at least one bit. Total work is therefore `O(N+h)=O(N)`. + +Only a constant number of binary counters, templates and endpoints are +live. They need `O(h)` bits. The lower bound is `N` output writes for an +explicit `N`-bit row. This proves the stated `Theta(N)` bound. It is not +a lower bound for a compressed row or for a consumer that skips outputs. + +`row.py` supplies the descriptor and stream control. Its statistics count +counter visits, template bits, copies and outputs. Python object management +and statistics updates are not a literal machine-transition measurement. +The proof describes the bit algorithm; it does not assert that Python's +runtime has that bound under an arbitrary interpreter cost model. + +## 6. Verification and remaining boundary + +The finite oracle is the unchanged PR4100 deterministic compiler. The +verifier checks every row for every legal modulus and offset at heights +one through six: 2,793 networks, 28,797 rows and 1,633,182 wire entries. +It also compares the retained PR7734 point query, all streamed bits, +rectangle areas, switch pairing, first/center caps and the work inequalities. +The table digest agrees with the predecessor census. + +An additional 280 descriptors, with 4,937 boundary and random point checks, +reach height 65,536 without materializing large rows. There are 131,328 +individual countdown checks, fourteen input rejection checks, three +rectangle mutation controls and a coordinate-order mutation control. +The executable height cap bounds descriptor input size; the written proof +has no height cap. Wide tests are finite evidence, not its proof. + +A literal row producer still needs an ABI, scratch ownership, output +placement, head return and complete transition and historical-space bills. +Comparison with stored ROM requires the actual query/reuse workload and +transport, current-state offsets, payload use and retirement charges. +None is supplied by this descriptor theorem. All five selected framework +assumptions remain. No new kappa or full multiplication theorem is claimed. diff --git a/research/owned-canonical-row-producer/sources.py b/research/owned-canonical-row-producer/sources.py new file mode 100644 index 0000000000..aecd53a532 --- /dev/null +++ b/research/owned-canonical-row-producer/sources.py @@ -0,0 +1,19 @@ +"""Load only named, byte-pinned predecessor modules. Apache-2.0.""" + +import hashlib +import importlib.util +import json +from pathlib import Path + +PACKAGE = Path(__file__).resolve().parent + + +def load(name, relative): + pins = {row["path"]: row for row in json.loads((PACKAGE / "SOURCE-PINS.json").read_text())} + path = PACKAGE / relative + if hashlib.sha256(path.read_bytes()).hexdigest() != pins[relative]["sha256"]: + raise ValueError("retained module hash") + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module diff --git a/research/owned-canonical-row-producer/verify.py b/research/owned-canonical-row-producer/verify.py new file mode 100644 index 0000000000..d11c3fd419 --- /dev/null +++ b/research/owned-canonical-row-producer/verify.py @@ -0,0 +1,171 @@ +"""Check complete physical rows, owner returns and literal source composition. + +Prepared by Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. +""" + +import argparse +import hashlib +import json +from pathlib import Path + +from interpreters import dense, sparse +from program import compile_row, point +from sources import load + +PACKAGE = Path(__file__).resolve().parent + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def graph_check(code, labels): + for ins in code: + kind = ins[0] + need(kind in ('R', 'W', 'M', 'J', 'H'), 'literal opcode') + if kind in ('R', 'W', 'M'): + need(type(ins[1]) is int and 0 <= ins[1] < 15, 'literal owner') + if kind == 'R': + need(set(ins[2]) == set(range(5)), 'read alphabet') + need(all(type(v) is int and 0 <= v < len(code) for v in ins[2].values()), 'read targets') + elif kind == 'W': + need(ins[1] >= 4 and type(ins[2]) is int and 0 <= ins[2] < 5, 'write boundary') + elif kind == 'M': + need(type(ins[2]) is int and ins[2] in (-1, 1), 'unit move') + elif kind == 'J': + need(type(ins[1]) is int and 0 <= ins[1] < len(code), 'jump target') + else: + need(ins[1] in ('DONE', 'REJECT'), 'outcome') + retained, _ = point.compile_query() + need(len(retained) == 3237 and point.source.digest(retained) == + '530e83add1f22dcbb2b207e7ede64b2cecc44cce71db5fb26706ce18b842f92c', 'point graph pin') + for pc, ins in enumerate(retained): + expected = ins + if ins[0] == 'R': + expected = ('R', ins[1], {s: labels['point_' + str(t)] for s, t in ins[2].items()}) + elif ins[0] == 'J': + expected = ('J', labels['point_' + str(ins[1])]) + elif ins[0] == 'H': + expected = ('J', labels['row_return' if ins[1] == 'DONE' else 'row_reject']) + need(code[labels['point_' + str(pc)]] == expected, 'source instruction changed') + return len(retained) + + +def fixture(hw, args): + h, s, a, j = args + bodies = [hw.bits(h, h.bit_length())] + [hw.bits(v, h+1) for v in (s, a, j)] + tapes = [hw.Tape(body, origin=3+i%4) for i, body in enumerate(bodies)] + tapes.extend(hw.Tape((), origin=3+i%5, private=True, capacity=h+2) for i in range(10)) + tapes.append(hw.Tape((), origin=7, capacity=1 << h)) + return tapes + + +def execute(hw, code, args, expected, outcome='DONE'): + h = args[0]; n = 1 << h + tapes = fixture(hw, args); before = [t.cells[:] for t in tapes] + limit = 1280 * n * (h+4) + independent = sparse(code, tapes, limit) + result = dense(code, tapes, limit) + need(result == independent, 'instruction path disagreement') + need(result['outcome'] == outcome, 'wrong outcome') + need(result['heads'] == [t.origin for t in tapes], 'head return') + for i, tape in enumerate(tapes): + wanted = before[i][:] + if i == 14 and outcome == 'DONE': + wanted[tape.origin:tape.origin+n] = expected + need(result['cells'][i] == wanted, 'returned owner state') + need(result['low'][i] >= tape.origin-1, 'opaque left access') + need(not any(result['writes'][:4]), 'borrowed write') + need(result['writes'][14] == (n if outcome == 'DONE' else 0), 'output lifetime') + for i in range(4, 14): + expected_guards = [3, 2] * (n if i >= 6 and outcome == 'DONE' else 1) + if i == 6: + expected_guards = [3, 2] + expected_guards + need(tapes[i].guard_writes == expected_guards, 'private guard lifetime') + need(not any(t.guard_writes for t in tapes[:4] + tapes[14:]), 'permanent guard write') + span = sum(high-low+1 for low, high in zip(result['low'], result['high'])) + need(span <= n+20*(h+4), 'historical span bound') + return result['steps'], span + + +def calculate(): + for row in json.loads((PACKAGE/'SOURCE-PINS.json').read_text()): + need(hashlib.sha256((PACKAGE/row['path']).read_bytes()).hexdigest() == row['sha256'], 'source hash') + hw = load('row_source_hardware', 'retained/pr7593/hardware.py') + canonical = load('row_canonical_network', 'retained/pr4100/check_batched_crt.py') + query = load('row_closed_query', 'retained/pr7734/query.py') + code, labels = compile_row(); retained_count = graph_check(code, labels) + result = dict(instructions=len(code), graph_sha256=point.source.digest(code), tapes=15, + retained_point_instructions=retained_count, transition_bound='1280*2^h*(h+4)', + historical_span_bound='2^h+20*(h+4)') + trace = hashlib.sha256(); networks = rows = entries = total = peak = 0 + for h in range(1, 4): + for s in range(1, (1 << h)+1): + for a in range(s): + network = canonical.benes(canonical.rotation(1 << h, s, a)); networks += 1 + for j, (_, row) in enumerate(network): + args = (h, s, a, j); steps, span = execute(hw, code, args, row) + need([query.switch_bit(h, s, a, j, x) for x in range(1 << h)] == list(row), 'point oracle') + trace.update(json.dumps([args, row, steps, span]).encode()) + rows += 1; entries += len(row); total += steps; peak = max(peak, steps) + result.update(complete_networks=networks, complete_rows_per_interpreter=rows, + canonical_bits_per_interpreter=entries, small_transitions=total, + small_max_transitions=peak, small_trace_sha256=trace.hexdigest()) + row_bits = []; row_total = 0; row_peak = 0 + for a in range(17): + args = (5, 17, a, 6); row = canonical.benes(canonical.rotation(32, 17, a))[6][1] + steps, _ = execute(hw, code, args, row); row_total += steps; row_peak = max(row_peak, steps) + row_bits.extend(row) + result.update(historical_rows=17, historical_bits=544, historical_transitions=row_total, + historical_max_transitions=row_peak, historical_bits_sha256=hashlib.sha256(bytes(row_bits)).hexdigest()) + larger = [] + for h, s, a, j in [(6, 53, 25, 7), (7, 127, 1, 0), (8, 255, 127, 8), + (9, 511, 255, 16), (10, 1024, 512, 9), (12, 4095, 2047, 12)]: + row = [query.switch_bit(h, s, a, j, x) for x in range(1 << h)] + steps, span = execute(hw, code, (h, s, a, j), row) + larger.append(dict(args=[h, s, a, j], bits=len(row), steps=steps, span=span, + bits_sha256=hashlib.sha256(bytes(row)).hexdigest())) + result['larger_complete_rows'] = larger + invalid = [(2, 0, 0, 0), (2, 5, 0, 0), (2, 3, 3, 0), (2, 3, 0, 3)] + for args in invalid: + execute(hw, code, args, [], outcome='REJECT') + mutations = [] + bad = list(code); pos = next(i for i, ins in enumerate(code) if ins == ('W', 14, 0)) + bad[pos] = ('W', 14, 1); mutations.append(('wrong_output_bit', bad)) + bad = list(code); bad[labels['row_return']] = ('J', labels['row_done']); mutations.append(('missing_row_tail', bad)) + bad = list(code) + pos = next(i for i in range(labels['row_done'], labels['row_reject']) if code[i] == ('W', 4, 2)) + bad[pos] = ('W', 4, 0); mutations.append(('failed_private_retirement', bad)) + args = (3, 7, 3, 2); expected = canonical.benes(canonical.rotation(8, 7, 3))[2][1] + for name, changed in mutations: + try: + execute(hw, tuple(changed), args, expected) + except ValueError as exc: + need(str(exc) in ('returned owner state', 'head return'), 'wrong mutation failure') + else: + raise ValueError('mutation survived: '+name) + for interpreter in (dense, sparse): + tapes = fixture(hw, args); tapes[7] = tapes[6] + try: + interpreter(code, tapes, 10000) + except ValueError as exc: + need(str(exc) == 'fifteen distinct owners required', 'wrong alias failure') + else: + raise ValueError('aliased owners accepted') + result.update(numeric_domain_rejections_per_interpreter=len(invalid), semantic_and_retirement_controls=[x[0] for x in mutations], alias_rejections=2) + return result + + +def main(): + parser = argparse.ArgumentParser(description=__doc__); parser.add_argument('--write-result', action='store_true') + args = parser.parse_args(); result = calculate() + if args.write_result: + (PACKAGE/'RESULT.json').write_text(json.dumps(result, indent=2, sort_keys=True)+'\n') + else: + need(result == json.loads((PACKAGE/'RESULT.json').read_text()), 'result mismatch') + print('PASS_OWNED_CANONICAL_ROW_PRODUCER 15 tapes; complete owned rows and returns') + + +if __name__ == '__main__': + main()