From 39b40c465f7636a4bb6d70af28595fe8f70f4f3f Mon Sep 17 00:00:00 2001 From: Jerry Jiaheng Chen <80299683+CubeJerry@users.noreply.github.com> Date: Thu, 12 Nov 2026 12:32:36 +0800 Subject: [PATCH] Implement both selected Gaussian linear maps as fixed tape programs with every column and complete owner return Prepared for @CubeJerry with substantial OpenAI assistance. Independent source, universal proof, inverse-address oracle, separate local interpreter, exact complete cost and history checks. No new kappa; all global assumptions retained. --- .../BIG-RESULT-OPTIMIZED.json | 158 +++++ .../BIG-RESULT.json | 158 +++++ .../COST-RESULT-OPTIMIZED.json | 6 + .../COST-RESULT.json | 6 + .../ENVIRONMENT.json | 18 + .../MATRICES.json | 222 +++++++ .../literal-selected-linear-maps/NOTICE.md | 36 ++ .../literal-selected-linear-maps/OVERLAP.md | 94 +++ .../PR-DESCRIPTION.md | 84 +++ .../literal-selected-linear-maps/PR-TITLE.txt | 1 + .../literal-selected-linear-maps/PROOF.md | 308 ++++++++++ .../literal-selected-linear-maps/README.md | 75 +++ .../RESULT-OPTIMIZED.json | 396 ++++++++++++ .../literal-selected-linear-maps/RESULT.json | 396 ++++++++++++ .../REUSE-RESULT-OPTIMIZED.json | 47 ++ .../REUSE-RESULT.json | 47 ++ .../SOURCE-GATE-OPTIMIZED.json | 91 +++ .../SOURCE-GATE.json | 91 +++ .../literal-selected-linear-maps/SOURCES.json | 131 ++++ .../literal-selected-linear-maps/TASK.json | 42 ++ .../VERIFICATION.md | 86 +++ .../literal-selected-linear-maps/VERIFY.json | 115 ++++ .../literal-selected-linear-maps/check.py | 146 +++++ .../literal-selected-linear-maps/check_big.py | 111 ++++ .../check_cost.py | 59 ++ .../check_reuse.py | 43 ++ .../independent/RESULT-OPTIMIZED.json | 1 + .../independent/RESULT.json | 1 + .../independent/REVIEW.md | 103 ++++ .../independent/SOURCE-BINDINGS.json | 89 +++ .../independent/dense_check.py | 213 +++++++ .../independent/literal_dense_runner.cpp | 88 +++ .../inputs/controller_reference.py | 112 ++++ .../literal-selected-linear-maps/linear.py | 435 ++++++++++++++ .../reference/C4-table-cpu.cpp | 90 +++ .../reference/clifford_exact.py | 149 +++++ .../controlled-block-shear--README.md | 28 + .../current-serial-monomial-leaf--PROOF.md | 160 +++++ .../fixed-tape-affine-shear--PROOF.md | 199 ++++++ .../fixed-tape-ordered-shear--PROOF.md | 267 +++++++++ .../reference/leaf-patterns.py | 564 ++++++++++++++++++ .../literal-elementary-interchange--PROOF.md | 157 +++++ .../reference/native_verify.py | 277 +++++++++ .../reference/packed-phase-PROOF.md | 336 +++++++++++ .../reference/phase-patterns.py | 343 +++++++++++ .../reference/selected-native-catalogue.py | 97 +++ .../reference/selected-native.json.gz | Bin 0 -> 350722 bytes .../source_gate.py | 42 ++ .../table_cpu.cpp | 90 +++ 49 files changed, 6808 insertions(+) create mode 100644 research/literal-selected-linear-maps/BIG-RESULT-OPTIMIZED.json create mode 100644 research/literal-selected-linear-maps/BIG-RESULT.json create mode 100644 research/literal-selected-linear-maps/COST-RESULT-OPTIMIZED.json create mode 100644 research/literal-selected-linear-maps/COST-RESULT.json create mode 100644 research/literal-selected-linear-maps/ENVIRONMENT.json create mode 100644 research/literal-selected-linear-maps/MATRICES.json create mode 100644 research/literal-selected-linear-maps/NOTICE.md create mode 100644 research/literal-selected-linear-maps/OVERLAP.md create mode 100644 research/literal-selected-linear-maps/PR-DESCRIPTION.md create mode 100644 research/literal-selected-linear-maps/PR-TITLE.txt create mode 100644 research/literal-selected-linear-maps/PROOF.md create mode 100644 research/literal-selected-linear-maps/README.md create mode 100644 research/literal-selected-linear-maps/RESULT-OPTIMIZED.json create mode 100644 research/literal-selected-linear-maps/RESULT.json create mode 100644 research/literal-selected-linear-maps/REUSE-RESULT-OPTIMIZED.json create mode 100644 research/literal-selected-linear-maps/REUSE-RESULT.json create mode 100644 research/literal-selected-linear-maps/SOURCE-GATE-OPTIMIZED.json create mode 100644 research/literal-selected-linear-maps/SOURCE-GATE.json create mode 100644 research/literal-selected-linear-maps/SOURCES.json create mode 100644 research/literal-selected-linear-maps/TASK.json create mode 100644 research/literal-selected-linear-maps/VERIFICATION.md create mode 100644 research/literal-selected-linear-maps/VERIFY.json create mode 100644 research/literal-selected-linear-maps/check.py create mode 100644 research/literal-selected-linear-maps/check_big.py create mode 100644 research/literal-selected-linear-maps/check_cost.py create mode 100644 research/literal-selected-linear-maps/check_reuse.py create mode 100644 research/literal-selected-linear-maps/independent/RESULT-OPTIMIZED.json create mode 100644 research/literal-selected-linear-maps/independent/RESULT.json create mode 100644 research/literal-selected-linear-maps/independent/REVIEW.md create mode 100644 research/literal-selected-linear-maps/independent/SOURCE-BINDINGS.json create mode 100644 research/literal-selected-linear-maps/independent/dense_check.py create mode 100644 research/literal-selected-linear-maps/independent/literal_dense_runner.cpp create mode 100644 research/literal-selected-linear-maps/inputs/controller_reference.py create mode 100644 research/literal-selected-linear-maps/linear.py create mode 100644 research/literal-selected-linear-maps/reference/C4-table-cpu.cpp create mode 100644 research/literal-selected-linear-maps/reference/clifford_exact.py create mode 100644 research/literal-selected-linear-maps/reference/controlled-block-shear--README.md create mode 100644 research/literal-selected-linear-maps/reference/current-serial-monomial-leaf--PROOF.md create mode 100644 research/literal-selected-linear-maps/reference/fixed-tape-affine-shear--PROOF.md create mode 100644 research/literal-selected-linear-maps/reference/fixed-tape-ordered-shear--PROOF.md create mode 100644 research/literal-selected-linear-maps/reference/leaf-patterns.py create mode 100644 research/literal-selected-linear-maps/reference/literal-elementary-interchange--PROOF.md create mode 100644 research/literal-selected-linear-maps/reference/native_verify.py create mode 100644 research/literal-selected-linear-maps/reference/packed-phase-PROOF.md create mode 100644 research/literal-selected-linear-maps/reference/phase-patterns.py create mode 100644 research/literal-selected-linear-maps/reference/selected-native-catalogue.py create mode 100644 research/literal-selected-linear-maps/reference/selected-native.json.gz create mode 100644 research/literal-selected-linear-maps/source_gate.py create mode 100644 research/literal-selected-linear-maps/table_cpu.cpp diff --git a/research/literal-selected-linear-maps/BIG-RESULT-OPTIMIZED.json b/research/literal-selected-linear-maps/BIG-RESULT-OPTIMIZED.json new file mode 100644 index 0000000000..37e1c8d064 --- /dev/null +++ b/research/literal-selected-linear-maps/BIG-RESULT-OPTIMIZED.json @@ -0,0 +1,158 @@ +{ + "compiler_flags": [ + "-std=c++17", + "-O2" + ], + "controls": [ + "all gates retain only the first column; complete lifecycle still succeeds", + "change one-bits in the final public commit", + "reverse control and target at every compiled gate" + ], + "interpreter_sha256": "0474e20f8af34ebbdb6a0d5ff48473d1f69ae6c971ef31e51a4a15f32f5dee02", + "records": { + "commit_bits": { + "accepted": true, + "data_writes": 1024, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 1024, + "output_sha256": "35ae5091b37e8f0f306833ef57a635f9dc06738d7f4e563a610eec2adb26fe28", + "private_blank": true, + "private_history": 8766, + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "steps": 1386351 + }, + "first_column_only": { + "accepted": true, + "data_writes": 524288, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 524288, + "output_sha256": "e97cabd15fd4dfb60aa55e20a784a9961d82e93a7382ab64dae452a319ee652b", + "private_blank": true, + "private_history": 3342402, + "shape": [ + 2, + 1, + 1, + 1, + 1 + ], + "steps": 642688745 + }, + "left_f1": { + "accepted": true, + "data_writes": 1024, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 1024, + "output_sha256": "6a128ea56b5f94f4dd3afbdc50dfba539b289424ccb63ddd5964efe675855f7b", + "private_blank": true, + "private_history": 8766, + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "steps": 1936566 + }, + "left_f2": { + "accepted": true, + "data_writes": 524288, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 524288, + "output_sha256": "951d44352e7b10734c7ff1bd412b815232575b939aed8f9fc47f9e5c277924d6", + "private_blank": true, + "private_history": 4030530, + "shape": [ + 2, + 1, + 1, + 1, + 1 + ], + "steps": 1726632151 + }, + "right_f1": { + "accepted": true, + "data_writes": 1024, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 1024, + "output_sha256": "84489c67321c36ad71002fa004daefd191908e20dff3020ac3375ee827fc1dc1", + "private_blank": true, + "private_history": 8766, + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "steps": 1386351 + }, + "right_f2": { + "accepted": true, + "data_writes": 524288, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 524288, + "output_sha256": "d4e5c1bd2226e312b5122ac5e344e4a91a22e373f4074661738ad3a5e0ba0c26", + "private_blank": true, + "private_history": 4030530, + "shape": [ + 2, + 1, + 1, + 1, + 1 + ], + "steps": 1230072483 + }, + "wrong_control_direction": { + "accepted": true, + "data_writes": 1024, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 1024, + "output_sha256": "70fb17ef173be022e3644fd9dee793e958cb987d5f6a0771ff836eff9c057626", + "private_blank": true, + "private_history": 8766, + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "steps": 1386351 + } + }, + "scope": "Both actual fixed m=9 maps, complete 262144-address f=2 fields; no reduced dimension or address sampling.", + "seed": 2026111205, + "source_sha256": "d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33", + "status": "PASS_ACTUAL_BOTH_SELECTED_LINEAR_F2" +} diff --git a/research/literal-selected-linear-maps/BIG-RESULT.json b/research/literal-selected-linear-maps/BIG-RESULT.json new file mode 100644 index 0000000000..37e1c8d064 --- /dev/null +++ b/research/literal-selected-linear-maps/BIG-RESULT.json @@ -0,0 +1,158 @@ +{ + "compiler_flags": [ + "-std=c++17", + "-O2" + ], + "controls": [ + "all gates retain only the first column; complete lifecycle still succeeds", + "change one-bits in the final public commit", + "reverse control and target at every compiled gate" + ], + "interpreter_sha256": "0474e20f8af34ebbdb6a0d5ff48473d1f69ae6c971ef31e51a4a15f32f5dee02", + "records": { + "commit_bits": { + "accepted": true, + "data_writes": 1024, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 1024, + "output_sha256": "35ae5091b37e8f0f306833ef57a635f9dc06738d7f4e563a610eec2adb26fe28", + "private_blank": true, + "private_history": 8766, + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "steps": 1386351 + }, + "first_column_only": { + "accepted": true, + "data_writes": 524288, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 524288, + "output_sha256": "e97cabd15fd4dfb60aa55e20a784a9961d82e93a7382ab64dae452a319ee652b", + "private_blank": true, + "private_history": 3342402, + "shape": [ + 2, + 1, + 1, + 1, + 1 + ], + "steps": 642688745 + }, + "left_f1": { + "accepted": true, + "data_writes": 1024, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 1024, + "output_sha256": "6a128ea56b5f94f4dd3afbdc50dfba539b289424ccb63ddd5964efe675855f7b", + "private_blank": true, + "private_history": 8766, + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "steps": 1936566 + }, + "left_f2": { + "accepted": true, + "data_writes": 524288, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 524288, + "output_sha256": "951d44352e7b10734c7ff1bd412b815232575b939aed8f9fc47f9e5c277924d6", + "private_blank": true, + "private_history": 4030530, + "shape": [ + 2, + 1, + 1, + 1, + 1 + ], + "steps": 1726632151 + }, + "right_f1": { + "accepted": true, + "data_writes": 1024, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 1024, + "output_sha256": "84489c67321c36ad71002fa004daefd191908e20dff3020ac3375ee827fc1dc1", + "private_blank": true, + "private_history": 8766, + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "steps": 1386351 + }, + "right_f2": { + "accepted": true, + "data_writes": 524288, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 524288, + "output_sha256": "d4e5c1bd2226e312b5122ac5e344e4a91a22e373f4074661738ad3a5e0ba0c26", + "private_blank": true, + "private_history": 4030530, + "shape": [ + 2, + 1, + 1, + 1, + 1 + ], + "steps": 1230072483 + }, + "wrong_control_direction": { + "accepted": true, + "data_writes": 1024, + "exteriors_preserved": true, + "header_preserved": true, + "header_writes": 0, + "heads_returned": true, + "input_bits": 1024, + "output_sha256": "70fb17ef173be022e3644fd9dee793e958cb987d5f6a0771ff836eff9c057626", + "private_blank": true, + "private_history": 8766, + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "steps": 1386351 + } + }, + "scope": "Both actual fixed m=9 maps, complete 262144-address f=2 fields; no reduced dimension or address sampling.", + "seed": 2026111205, + "source_sha256": "d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33", + "status": "PASS_ACTUAL_BOTH_SELECTED_LINEAR_F2" +} diff --git a/research/literal-selected-linear-maps/COST-RESULT-OPTIMIZED.json b/research/literal-selected-linear-maps/COST-RESULT-OPTIMIZED.json new file mode 100644 index 0000000000..22136773c5 --- /dev/null +++ b/research/literal-selected-linear-maps/COST-RESULT-OPTIMIZED.json @@ -0,0 +1,6 @@ +{ + "abstract_shapes_checked": 56, + "physical_receipts_matched": 14, + "scope": "Exact helper-derived formula matches full physical traces; large shapes check arithmetic inequalities only, not payload execution.", + "status": "PASS_EXACT_SELECTED_LINEAR_COST" +} diff --git a/research/literal-selected-linear-maps/COST-RESULT.json b/research/literal-selected-linear-maps/COST-RESULT.json new file mode 100644 index 0000000000..22136773c5 --- /dev/null +++ b/research/literal-selected-linear-maps/COST-RESULT.json @@ -0,0 +1,6 @@ +{ + "abstract_shapes_checked": 56, + "physical_receipts_matched": 14, + "scope": "Exact helper-derived formula matches full physical traces; large shapes check arithmetic inequalities only, not payload execution.", + "status": "PASS_EXACT_SELECTED_LINEAR_COST" +} diff --git a/research/literal-selected-linear-maps/ENVIRONMENT.json b/research/literal-selected-linear-maps/ENVIRONMENT.json new file mode 100644 index 0000000000..7dd3e5f4ee --- /dev/null +++ b/research/literal-selected-linear-maps/ENVIRONMENT.json @@ -0,0 +1,18 @@ +{ + "author_compiler_flags": [ + "-std=c++17", + "-O2" + ], + "compiler": "c++ (Debian 14.2.0-19) 14.2.0", + "independent_compiler_flags": [ + "-std=c++17", + "-O2", + "-Wall", + "-Wextra", + "-pedantic" + ], + "platform": "Linux-6.18.57-x86_64-with-glibc2.41", + "python": "3.12.14 (main, Aug 25 2026, 14:00:49) [Clang 22.1.3 ]", + "review_status": "independent root acceptance retained", + "source_base": "e54523517d0f03e58352e647c403a5af3e525a57" +} diff --git a/research/literal-selected-linear-maps/MATRICES.json b/research/literal-selected-linear-maps/MATRICES.json new file mode 100644 index 0000000000..0ddf8babc9 --- /dev/null +++ b/research/literal-selected-linear-maps/MATRICES.json @@ -0,0 +1,222 @@ +{ + "left": { + "gate_count": 27, + "locations": 34131, + "matrix_rows": [ + 3, + 5, + 9, + 17, + 32, + 65, + 129, + 1, + 256 + ], + "table_sha256": "5f1a916d1a4c39195522754c44b8facd2fbe237161943440fa6aa25c3b287496", + "word": [ + [ + 7, + 0 + ], + [ + 6, + 0 + ], + [ + 4, + 0 + ], + [ + 3, + 0 + ], + [ + 2, + 0 + ], + [ + 1, + 0 + ], + [ + 1, + 0 + ], + [ + 0, + 1 + ], + [ + 1, + 0 + ], + [ + 2, + 1 + ], + [ + 1, + 2 + ], + [ + 2, + 1 + ], + [ + 3, + 2 + ], + [ + 2, + 3 + ], + [ + 3, + 2 + ], + [ + 4, + 3 + ], + [ + 3, + 4 + ], + [ + 4, + 3 + ], + [ + 5, + 4 + ], + [ + 4, + 5 + ], + [ + 5, + 4 + ], + [ + 6, + 5 + ], + [ + 5, + 6 + ], + [ + 6, + 5 + ], + [ + 7, + 6 + ], + [ + 6, + 7 + ], + [ + 7, + 6 + ] + ] + }, + "right": { + "gate_count": 19, + "locations": 24451, + "matrix_rows": [ + 239, + 129, + 130, + 132, + 136, + 16, + 160, + 192, + 256 + ], + "table_sha256": "40c12281a92857287c13fd55d551ab3e574392656a174812e07625764eb7ae6c", + "word": [ + [ + 5, + 7 + ], + [ + 3, + 7 + ], + [ + 2, + 7 + ], + [ + 1, + 7 + ], + [ + 0, + 7 + ], + [ + 7, + 6 + ], + [ + 5, + 6 + ], + [ + 6, + 5 + ], + [ + 3, + 5 + ], + [ + 4, + 5 + ], + [ + 5, + 4 + ], + [ + 4, + 5 + ], + [ + 4, + 3 + ], + [ + 2, + 3 + ], + [ + 3, + 2 + ], + [ + 1, + 2 + ], + [ + 2, + 1 + ], + [ + 0, + 1 + ], + [ + 1, + 0 + ] + ] + } +} diff --git a/research/literal-selected-linear-maps/NOTICE.md b/research/literal-selected-linear-maps/NOTICE.md new file mode 100644 index 0000000000..3a3030f23d --- /dev/null +++ b/research/literal-selected-linear-maps/NOTICE.md @@ -0,0 +1,36 @@ +# Attribution and scope + +New construction, source binding, uniform complete-cost proof, author checks +and packaging were prepared for Jerry Chen (@CubeJerry), with substantial +OpenAI assistance. Independent receipts identify the separate executing +reviewer and distinct methods. No human or proof-kernel verification of the +multiplication theorem is claimed. New work is Apache-2.0. + +Credit Matarener's #3825 controlled reversal and #3834's finite identity +check; David Arias's #2776/fixed-tape-ordered-shear split/merge, unary conversion +and local return method; the fixed-tape-affine-shear runtime-coefficient +extension and its credited Charles Bethin unit-carry predecessor; JoyboyBrian's +#5188 complete literal interchange and binary-alphabet successor; Jose Manuel's +physical Gaussian monomial and #3087/#4172 lineage; the selected monomial +record lift; and #6992's current serial-column implication and conditional +bill. These algebraic and routing methods are not new claims here. + +The #7000 selected native/compiler/application-review authors supply the +actual word, exact Clifford lowering, signed Gaussian interpreter and phase +conventions. Their retained source notices are unchanged. + +The published controller `9dfe6747b8553fd11b408f2b045c5954ef1e6eaa` supplies +Builder/Machine/Tape. The literal layer phase +`8b549ca6557ccbb3017b104b27ea35051f990416`, selected quadratic phase +`172f4535ce8dcff79f626410af845f757c1563be`, and positive C leaf +`1a555e469b89af70d309bc966f8f813ac11dc887` supply the shared packed interface +and reusable local acquisition/copy/return patterns. Exact reference copies +and source pins are retained. The new `fresh` adds a label delimiter to avoid +decimal label collisions in the larger compile-time word. + +C4's dense author-test interpreter is retained as a source reference. This +package changes its fixed inventory from 29 to 27 and raises only its external +watchdog. That reuse is not presented as independently written review. Root's +independent interpreter/oracle were written separately and are retained +unchanged. No invented PR number is used for newly published fork branches; +they are identified by exact commits until a PR exists. diff --git a/research/literal-selected-linear-maps/OVERLAP.md b/research/literal-selected-linear-maps/OVERLAP.md new file mode 100644 index 0000000000..21b2b673ef --- /dev/null +++ b/research/literal-selected-linear-maps/OVERLAP.md @@ -0,0 +1,94 @@ +# Wave 5 B5 scope and optimistic-budget gate + +Status: proceed to one narrowly scoped literal implementation, not a new kappa. +Canonical main was checked live and remains +`e54523517d0f03e58352e647c403a5af3e525a57`. + +The selected #7000 MOVE24472 recipe has two fixed nine-by-nine matrices: +right `[239,129,130,132,136,16,160,192,256]` and +left `[3,5,9,17,32,65,129,1,256]`. Both act independently on every one of f +columns. Target only those raw address permutations on the published +five-Gamma(f,r,P,S,w) packed ABI. Constant/linear/quadratic phases, the XOR +offset, positive C leaf, full MOVE, old codec/strided packing and global +admission remain separate. Both high-control and low-control directions are +required. All raw coefficient bits, including arbitrary signed endpoints, +are merely moved and require no numerical headroom restriction. + +## Overlap gate + +- #3834 `controlled-block-shear` checks the controlled-reversal/XOR identity + through dimension 16; it supplies no complete tape schedule or uniform + encoded cost. Its credited predecessor is #3825. +- #5188 `literal-elementary-interchange` supplies a complete fixed local + all-H block interchange on separate binary descriptors, with a complete + `2^20(H+1)(V+1)(L+1)^2` bill. Its binary-alphabet successor is also read. + This is a substantial predecessor, but not the two source matrices on the + shared Gamma ABI at O(fV+E). +- #6992 `current-serial-monomial-leaf` already proves the all-column serial + identity and repeated direct-leaf bill. Only its descriptor iterator is a + literal graph; its numeric/movement provider remains structured source. + O(fV) additionally uses its explicit R1>=A1^6 and metadata absorption + hypotheses. Those algebraic and serialization results are credited, not + re-proved as novel here. +- `fixed-tape-ordered-shear` (canonical last package change + 7de16285a02ebb45cf46e7501baa7eafa78335e3) and + `fixed-tape-affine-shear` already give literal O(V) ordered modular-addition + kernels with separate supplied LSB descriptors and protected output. + At Q=2 a unit shear is a CNOT in one direction. At Q=2^f, modular addition + is not independent bitwise XOR. These results leave reversed-field routing, + full caller descriptor generation and selected owner installation outside + their exact scope. They supply the split/merge and unary-clock methods. +- `physical-gaussian-monomial` explicitly does not expand its full structured + provider to a complete transition table; `selected-monomial-tape-lift` + supplies the record list under inherited compact-movement propositions. +- Live targeted open-PR searches are retained in OPEN-OVERLAP.json. No exact + encoded two-matrix packed join was located in this bounded search; this is + not an exhaustive archival absence theorem. Root owns active allocation. + +The proposed novelty is the source-bound, literal, all-column join with actual +header-derived geometry and same-owner lifecycle, without long-record +absorption conditions. No new CNOT, GF(2) elimination, or tensor identity is +claimed. + +## Optimistic complete bill + +Use fixed CNOT decompositions obtained by exact row elimination (forward +order gives 19 gates for the right matrix; reverse pivot order gives 27 for +the left). Fixed gate count is independent of f, payload and address size. +Validate the exact matrix products and every one of 512 source addresses. + +For one gate between logical coordinates h=1, h=2 on the packed Gaussian ABI, AM<=V/8, A<=V/8 and B<=V/4. Thus a +complete pass plus a possible update costs less than `128(V+1)`. + +For completeness, the initial geometry of a fixed h,l gate costs exactly + +`124A0+124M+47B0 -36P -24RSw +28RS+10R +180f+44`. + +The three generated extents, all intermediate doubles and all loop resets +are included. Its positive terms are bounded by `512(V+1)` using +A0,M<=V/8, B0<=V/4, RS<=B0/2 and f<=V. Final per-gate guide return/clear is +`3f+7(A_final+M+B_final)+15`, bounded by `32(V+1)`. Therefore every one of +at most 27 fixed gates, including all its f actual passes, has the safe bound +`1024 f (V+1)`. This deliberately loose allowance absorbs fixed jumps and +all gate boundaries. + +The first-five Gamma conversions cost O(f+r+P+S+w+E), since strict binary +prefix values sum to less than each decoded value. Each value is <=V. The +VOLUME preparation, whole source clone/return, final public commit/return, +all remaining guide erasures and guard initialization/disposal together +cost less than `8192(V+E+1)` by the same unary prices. For example VOLUME +construction is +`47V+28P+40PR+40PRS-24PRSw+168f+83`, the complete clone is `20V+11`, and +commit itself is `16V+7`, before the fixed selection/retirement instructions. +These explicit helper formulas keep repeated control work in the bill. + +Combining the 27-gate bound with the overhead, and V>=1024f for positive +f,r,P,S,w, yields the uniform complete bound + +`T <= 65536 (fV+E+1)`. + +The right program has fewer fixed gates, but no improved asymptotic claim is +attached to that constant. Program construction is input independent. Actual +entry production/transport, old-codec conversion, arbitrary strided packing, +phases, offsets, the C leaf and any complete caller remain additional work. +This is an O(fV+E) direct-leaf tariff, not an O(V) unrestricted-f affine rate +or a faster nonleaf recurrence. + +## 7. Historical backing and repeated use + +Each private role visits an interval starting at its own relative -1 guard. +MODE has cap 1. HTRACE and LENGTH each have cap E. Every other private role +has cap at most V, including blank endpoints: two whole banks, DTRACE, +VOLUME/AUX/DOUBLE, five input guides, three gate guides, four half streams and +four chunk streams. Temporary pre-halving guides are <=V/2 and every chunk +is <=V/4. No role count or origin depends on the header values. + +There are 22 volume-bounded roles, two header-bounded roles and MODE, so the +sum of new private intervals is at most `22V+2E+51`. Including both public +tapes adds at most `V+E+2`, giving `23V+3E+53`. Both are bounded by +`64(V+E+1)`. If K0 is the actual corresponding pre-entry historical backing, +the full history at any time is at most `K0+64(V+E+1)`. + +Erasure does not reduce history. Repeated calls at fixed origins retain the +union of each individual role's intervals, or its per-role maximum span, +then sum over roles. A later smaller clean call scans only its new finite +bodies and keeps its own current-shape time bill; it does not scan an old +blank capacity. Changed origins require their actual absolute interval +unions and paid transport corridors. Supplied source/opaque storage remains +in K0; it is never reclassified as free by a new wrapper object. + +## 8. Evidence, limitations and Open next questions + +The author direct oracle computes each output coordinate by XOR of the +selected original coordinates according to the actual matrix rows. It does +not execute the CNOT word to obtain expected payloads. All 512 one-column +matrix addresses are checked. Complete physical f=1 fields exercise r, P, S +and w variation, translated origins, arbitrary bits, header/exterior/head +preservation and malformed-cardinality rejection. + +A separate dense C++ interpreter executes both actual fixed m=9 graphs on +all 262,144 addresses of a complete f=2 field. Both direct-matrix outputs and +all lifecycle checks pass. It cross-checks f=1 step counts against the pinned +reference interpreter. Changing every gate to process only the first column +still produces a complete, cleanly retired field but fails the f=2 oracle. +Reversing all control directions and corrupting final commit bits are also +detected. No reduced dimension, sampled address set or short prefix is +substituted for these full f=2 runs. Reusable-history evidence and independent +root/peer evidence are retained separately. Finite executions corroborate the +universal loop, algebra and cost proof; they do not replace it. + +The next concrete composition is the exact retained MOVE24472: bind both +phase recipes and right offset around these G maps and the positive all-f C +leaf, then prove numerical admission, layout, public failure semantics and +the entire bill. The five/six-code packed interface permits a literal join, +but this package does not execute it. A general source caller still needs a +paid bridge from its old coded/strided representation, actual occurrence +emission and owner lifecycle. Faster nonleaf suppliers, recursion cutoff and +precision admission, and the remaining foundational assumptions stay open. +No selected certificate or accepted complete multiplication bound changes. diff --git a/research/literal-selected-linear-maps/README.md b/research/literal-selected-linear-maps/README.md new file mode 100644 index 0000000000..587e5d5899 --- /dev/null +++ b/research/literal-selected-linear-maps/README.md @@ -0,0 +1,75 @@ +# Literal selected linear maps on the packed all-column field + +**No new kappa. Independently reviewed scoped enabling lemma.** Both fixed +GF(2) linear maps around current #7000 MOVE24472's positive C factor are +implemented by local tape programs on the five-Gamma header `f,r,P,S,w`. +The complete packed array is `[P] x [2^f]^9 x [S]`, with r Gaussian w-bit pairs +per address. Every positive f and arbitrary raw payload are covered. + +The right program has 19 fixed CNOTs and 24,451 locations; the left has 27 and +34,131. Both use 27 tapes, four symbols, and only local read/write, unit move, +goto and halt. The actual f loop, both control directions, all header-derived +geometry, copying, private staging, same-owner commit and erasure are paid. +The proved complete bound is `65536(fV+E+1)` instructions and actual entry +history plus `64(V+E+1)` newly visited cells. No long-record absorption or +supplied stride/transpose premise is used. + +DATA is preserved until the full permutation is staged. Success restores +HEADER, all heads, private bodies/guards and opaque exteriors. A following +sixth Gamma code remains opaque and unchanged. Detected malformed cardinality +or symbols preserve public DATA/HEADER; failure private cleanup/retry is not +claimed. This is only the two linear factors, not phases, offset, C, full MOVE, +old-codec/strided packing, native caller or complete multiplier. + +## Source, novelty and review + +Base: `e54523517d0f03e58352e647c403a5af3e525a57`. SOURCE-GATE.json recomputes +actual event 24472 `["MOVE",415,3,99,false]` and the complete retained recipe. +SOURCES.json pins fourteen files by repository/commit/path/blob/bytes/hash. +MATRICES.json retains the exact matrix rows, CNOT words and graph hashes. +PROOF.md gives the universal algebra, geometry, lifecycle, complete cost and +historical-backing argument. + +#3834, #5188, #6992, the selected monomial record lift and literal ordered/ +affine shear packages are substantive predecessors. Their identities, +elimination and split/merge methods are credited, not claimed new. The new +result is the actual selected, both-direction, all-column literal join on +the shared packed ABI with its complete uniform direct-leaf bill. See +OVERLAP.md and NOTICE.md. + +Root independently accepted the frozen science after source/whole-proof +review, a separately written C++ CPU, inverse-address oracle and complete +exact cost census. All fourteen exact Git commit:path bindings pass. Its +fourteen complete actual m9 packets, four malformed controls, persistent +reuse and three mutants cover 3,076,553,809 transitions. See independent/. +This is independent agent review, not human or proof-kernel acceptance. + +## Reproduce + +From this directory, with CPython 3.12+ and C++17 `c++` for dense runs: + +```sh +python -I -W error -B source_gate.py +python -I -W error -B check.py +python -I -W error -B check_big.py +python -I -W error -B check_reuse.py +python -I -W error -B check_cost.py +python -I -W error -B independent/dense_check.py linear.py +``` + +Normal and `-O` commands are recorded in the standalone VERIFY.json manifest. Both actual complete +f=2 arrays have 262,144 addresses and 524,288 bits; right and left take exactly +1,230,072,483 and 1,726,632,151 literal steps. Their outputs match direct matrix +addresses. No reduced dimension or sampled prefix substitutes for these runs. +The author cost check compares a helper-derived exact formula with the saved +complete trace receipts; the execution checks produce those traces. Expected +markers and coverage are in VERIFICATION.md. + +## Open next questions + +Compose the exact source MOVE's right phase, right G, right offset, positive +all-column C, left phase and left G, with whole-call staging and numerical +admission. Then supply the paid old-format/strided bridge, actual occurrence +emission, owner transport and global cutoff/precision premises. Faster +nonleaf work is separate from this O(fV+E) direct-leaf result. All five global +foundational assumptions and the selected complete bound remain unchanged. diff --git a/research/literal-selected-linear-maps/RESULT-OPTIMIZED.json b/research/literal-selected-linear-maps/RESULT-OPTIMIZED.json new file mode 100644 index 0000000000..ddf5d84aee --- /dev/null +++ b/research/literal-selected-linear-maps/RESULT-OPTIMIZED.json @@ -0,0 +1,396 @@ +{ + "cases": [ + { + "kind": "complete m9 f1", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "right", + "steps": 1386351 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 2, + 1, + 1, + 2 + ], + "side": "right", + "steps": 5214915 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 1, + 2, + 1, + 1 + ], + "side": "right", + "steps": 2693395 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 1, + 1, + 2, + 1 + ], + "side": "right", + "steps": 2662876 + }, + { + "kind": "opaque sixth Gamma code", + "opaque_bits": 4100, + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "right", + "steps": 1386351 + }, + { + "kind": "short payload", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "right", + "steps": 57815 + }, + { + "kind": "extra payload", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "right", + "steps": 60899 + }, + { + "kind": "bad header", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "right", + "steps": 76 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "left", + "steps": 1936566 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 2, + 1, + 1, + 2 + ], + "side": "left", + "steps": 7349674 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 1, + 2, + 1, + 1 + ], + "side": "left", + "steps": 3739168 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 1, + 1, + 2, + 1 + ], + "side": "left", + "steps": 3741395 + }, + { + "kind": "opaque sixth Gamma code", + "opaque_bits": 4100, + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "left", + "steps": 1936566 + }, + { + "kind": "short payload", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "left", + "steps": 57815 + }, + { + "kind": "extra payload", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "left", + "steps": 60899 + }, + { + "kind": "bad header", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "left", + "steps": 76 + } + ], + "gate_counts": { + "left": 27, + "right": 19 + }, + "scope": "Complete actual m9 f1 packets; full f2 and graph mutants are separate receipts.", + "seed": 2026111205, + "source_sha256": "d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33", + "status": "PASS_LITERAL_SELECTED_LINEAR_BASE", + "words": { + "left": [ + [ + 7, + 0 + ], + [ + 6, + 0 + ], + [ + 4, + 0 + ], + [ + 3, + 0 + ], + [ + 2, + 0 + ], + [ + 1, + 0 + ], + [ + 1, + 0 + ], + [ + 0, + 1 + ], + [ + 1, + 0 + ], + [ + 2, + 1 + ], + [ + 1, + 2 + ], + [ + 2, + 1 + ], + [ + 3, + 2 + ], + [ + 2, + 3 + ], + [ + 3, + 2 + ], + [ + 4, + 3 + ], + [ + 3, + 4 + ], + [ + 4, + 3 + ], + [ + 5, + 4 + ], + [ + 4, + 5 + ], + [ + 5, + 4 + ], + [ + 6, + 5 + ], + [ + 5, + 6 + ], + [ + 6, + 5 + ], + [ + 7, + 6 + ], + [ + 6, + 7 + ], + [ + 7, + 6 + ] + ], + "right": [ + [ + 5, + 7 + ], + [ + 3, + 7 + ], + [ + 2, + 7 + ], + [ + 1, + 7 + ], + [ + 0, + 7 + ], + [ + 7, + 6 + ], + [ + 5, + 6 + ], + [ + 6, + 5 + ], + [ + 3, + 5 + ], + [ + 4, + 5 + ], + [ + 5, + 4 + ], + [ + 4, + 5 + ], + [ + 4, + 3 + ], + [ + 2, + 3 + ], + [ + 3, + 2 + ], + [ + 1, + 2 + ], + [ + 2, + 1 + ], + [ + 0, + 1 + ], + [ + 1, + 0 + ] + ] + } +} diff --git a/research/literal-selected-linear-maps/RESULT.json b/research/literal-selected-linear-maps/RESULT.json new file mode 100644 index 0000000000..ddf5d84aee --- /dev/null +++ b/research/literal-selected-linear-maps/RESULT.json @@ -0,0 +1,396 @@ +{ + "cases": [ + { + "kind": "complete m9 f1", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "right", + "steps": 1386351 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 2, + 1, + 1, + 2 + ], + "side": "right", + "steps": 5214915 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 1, + 2, + 1, + 1 + ], + "side": "right", + "steps": 2693395 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 1, + 1, + 2, + 1 + ], + "side": "right", + "steps": 2662876 + }, + { + "kind": "opaque sixth Gamma code", + "opaque_bits": 4100, + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "right", + "steps": 1386351 + }, + { + "kind": "short payload", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "right", + "steps": 57815 + }, + { + "kind": "extra payload", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "right", + "steps": 60899 + }, + { + "kind": "bad header", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "right", + "steps": 76 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "left", + "steps": 1936566 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 2, + 1, + 1, + 2 + ], + "side": "left", + "steps": 7349674 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 1, + 2, + 1, + 1 + ], + "side": "left", + "steps": 3739168 + }, + { + "kind": "complete m9 f1", + "shape": [ + 1, + 1, + 1, + 2, + 1 + ], + "side": "left", + "steps": 3741395 + }, + { + "kind": "opaque sixth Gamma code", + "opaque_bits": 4100, + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "left", + "steps": 1936566 + }, + { + "kind": "short payload", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "left", + "steps": 57815 + }, + { + "kind": "extra payload", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "left", + "steps": 60899 + }, + { + "kind": "bad header", + "shape": [ + 1, + 1, + 1, + 1, + 1 + ], + "side": "left", + "steps": 76 + } + ], + "gate_counts": { + "left": 27, + "right": 19 + }, + "scope": "Complete actual m9 f1 packets; full f2 and graph mutants are separate receipts.", + "seed": 2026111205, + "source_sha256": "d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33", + "status": "PASS_LITERAL_SELECTED_LINEAR_BASE", + "words": { + "left": [ + [ + 7, + 0 + ], + [ + 6, + 0 + ], + [ + 4, + 0 + ], + [ + 3, + 0 + ], + [ + 2, + 0 + ], + [ + 1, + 0 + ], + [ + 1, + 0 + ], + [ + 0, + 1 + ], + [ + 1, + 0 + ], + [ + 2, + 1 + ], + [ + 1, + 2 + ], + [ + 2, + 1 + ], + [ + 3, + 2 + ], + [ + 2, + 3 + ], + [ + 3, + 2 + ], + [ + 4, + 3 + ], + [ + 3, + 4 + ], + [ + 4, + 3 + ], + [ + 5, + 4 + ], + [ + 4, + 5 + ], + [ + 5, + 4 + ], + [ + 6, + 5 + ], + [ + 5, + 6 + ], + [ + 6, + 5 + ], + [ + 7, + 6 + ], + [ + 6, + 7 + ], + [ + 7, + 6 + ] + ], + "right": [ + [ + 5, + 7 + ], + [ + 3, + 7 + ], + [ + 2, + 7 + ], + [ + 1, + 7 + ], + [ + 0, + 7 + ], + [ + 7, + 6 + ], + [ + 5, + 6 + ], + [ + 6, + 5 + ], + [ + 3, + 5 + ], + [ + 4, + 5 + ], + [ + 5, + 4 + ], + [ + 4, + 5 + ], + [ + 4, + 3 + ], + [ + 2, + 3 + ], + [ + 3, + 2 + ], + [ + 1, + 2 + ], + [ + 2, + 1 + ], + [ + 0, + 1 + ], + [ + 1, + 0 + ] + ] + } +} diff --git a/research/literal-selected-linear-maps/REUSE-RESULT-OPTIMIZED.json b/research/literal-selected-linear-maps/REUSE-RESULT-OPTIMIZED.json new file mode 100644 index 0000000000..bb18c13cc0 --- /dev/null +++ b/research/literal-selected-linear-maps/REUSE-RESULT-OPTIMIZED.json @@ -0,0 +1,47 @@ +{ + "records": [ + { + "large_shape": [ + 1, + 2, + 2, + 1, + 1 + ], + "large_steps": 5190814, + "retained_total_history": 31699, + "side": "right", + "small_and_fresh_steps": 1386351, + "small_shape": [ + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "large_shape": [ + 1, + 2, + 2, + 1, + 1 + ], + "large_steps": 7240107, + "retained_total_history": 31699, + "side": "left", + "small_and_fresh_steps": 1936566, + "small_shape": [ + 1, + 1, + 1, + 1, + 1 + ] + } + ], + "scope": "Same actual tape objects and intervals; old public payload/descriptor tails retained as opaque exterior. No failure-time retry claim.", + "seed": 2026111206, + "status": "PASS_SELECTED_LINEAR_SAME_OWNER_REUSE" +} diff --git a/research/literal-selected-linear-maps/REUSE-RESULT.json b/research/literal-selected-linear-maps/REUSE-RESULT.json new file mode 100644 index 0000000000..bb18c13cc0 --- /dev/null +++ b/research/literal-selected-linear-maps/REUSE-RESULT.json @@ -0,0 +1,47 @@ +{ + "records": [ + { + "large_shape": [ + 1, + 2, + 2, + 1, + 1 + ], + "large_steps": 5190814, + "retained_total_history": 31699, + "side": "right", + "small_and_fresh_steps": 1386351, + "small_shape": [ + 1, + 1, + 1, + 1, + 1 + ] + }, + { + "large_shape": [ + 1, + 2, + 2, + 1, + 1 + ], + "large_steps": 7240107, + "retained_total_history": 31699, + "side": "left", + "small_and_fresh_steps": 1936566, + "small_shape": [ + 1, + 1, + 1, + 1, + 1 + ] + } + ], + "scope": "Same actual tape objects and intervals; old public payload/descriptor tails retained as opaque exterior. No failure-time retry claim.", + "seed": 2026111206, + "status": "PASS_SELECTED_LINEAR_SAME_OWNER_REUSE" +} diff --git a/research/literal-selected-linear-maps/SOURCE-GATE-OPTIMIZED.json b/research/literal-selected-linear-maps/SOURCE-GATE-OPTIMIZED.json new file mode 100644 index 0000000000..f99d0926be --- /dev/null +++ b/research/literal-selected-linear-maps/SOURCE-GATE-OPTIMIZED.json @@ -0,0 +1,91 @@ +{ + "canonical_base": "e54523517d0f03e58352e647c403a5af3e525a57", + "complete_recipe": { + "left": { + "linear_Z4": [ + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "matrix_rows": [ + 3, + 5, + 9, + 17, + 32, + 65, + 129, + 1, + 256 + ], + "offset": 0, + "phase": 0, + "quadratic_rows": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + "rank": 1, + "right": { + "linear_Z4": [ + 3, + 3, + 3, + 3, + 0, + 3, + 3, + 2, + 0 + ], + "matrix_rows": [ + 239, + 129, + 130, + 132, + 136, + 16, + 160, + 192, + 256 + ], + "offset": 1, + "phase": 1, + "quadratic_rows": [ + 111, + 111, + 111, + 111, + 0, + 111, + 111, + 0, + 0 + ] + } + }, + "event": [ + "MOVE", + 415, + 3, + 99, + false + ], + "event_index": 24472, + "scope": "Actual source recipe recomputed and checked; exported programs implement only its two linear address factors.", + "source_files": 14, + "status": "PASS_SELECTED_LINEAR_SOURCE_GATE" +} diff --git a/research/literal-selected-linear-maps/SOURCE-GATE.json b/research/literal-selected-linear-maps/SOURCE-GATE.json new file mode 100644 index 0000000000..f99d0926be --- /dev/null +++ b/research/literal-selected-linear-maps/SOURCE-GATE.json @@ -0,0 +1,91 @@ +{ + "canonical_base": "e54523517d0f03e58352e647c403a5af3e525a57", + "complete_recipe": { + "left": { + "linear_Z4": [ + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "matrix_rows": [ + 3, + 5, + 9, + 17, + 32, + 65, + 129, + 1, + 256 + ], + "offset": 0, + "phase": 0, + "quadratic_rows": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + "rank": 1, + "right": { + "linear_Z4": [ + 3, + 3, + 3, + 3, + 0, + 3, + 3, + 2, + 0 + ], + "matrix_rows": [ + 239, + 129, + 130, + 132, + 136, + 16, + 160, + 192, + 256 + ], + "offset": 1, + "phase": 1, + "quadratic_rows": [ + 111, + 111, + 111, + 111, + 0, + 111, + 111, + 0, + 0 + ] + } + }, + "event": [ + "MOVE", + 415, + 3, + 99, + false + ], + "event_index": 24472, + "scope": "Actual source recipe recomputed and checked; exported programs implement only its two linear address factors.", + "source_files": 14, + "status": "PASS_SELECTED_LINEAR_SOURCE_GATE" +} diff --git a/research/literal-selected-linear-maps/SOURCES.json b/research/literal-selected-linear-maps/SOURCES.json new file mode 100644 index 0000000000..77c4d7b21c --- /dev/null +++ b/research/literal-selected-linear-maps/SOURCES.json @@ -0,0 +1,131 @@ +{ + "base": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "bytes": 6824, + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "local": "reference/clifford_exact.py", + "path": "research/shared-wire-split-composition/frozen/clifford_exact.py", + "repository": "CrocSwap/integer-mult-bounds", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + { + "blob": "2c209dfa9cfade3bc20ac5fc9d876b433a147f8c", + "bytes": 12323, + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "local": "reference/native_verify.py", + "path": "research/shared-wire-split-composition/frozen/native_verify.py", + "repository": "CrocSwap/integer-mult-bounds", + "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38" + }, + { + "blob": "74563a7867d9d762b6588f65362369668841bb3e", + "bytes": 350722, + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "local": "reference/selected-native.json.gz", + "path": "research/shared-wire-split-composition/data/final.json.gz", + "repository": "CrocSwap/integer-mult-bounds", + "sha256": "2b94953dc14a122e3ef089633f05b58ec689ec5156feb7c784ed3e137dc01883" + }, + { + "blob": "98b35c89c8bd52637633aa78d506244bca8ec9e1", + "bytes": 5071, + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "local": "reference/selected-native-catalogue.py", + "path": "docs/research/pr-intake-evidence/pr7000-application/check_native_catalogue.py", + "repository": "CrocSwap/integer-mult-bounds", + "sha256": "6120e1ea1e07eeba757694d209437a38f121b0a377cc466889a30fa52c561472" + }, + { + "blob": "3ab6d0361f35038ffcdf0cf81a157f7a17b40e72", + "bytes": 5938, + "commit": "9dfe6747b8553fd11b408f2b045c5954ef1e6eaa", + "local": "inputs/controller_reference.py", + "path": "research/selected-rank-control/controller_reference.py", + "repository": "CubeJerry/integer-mult-bounds", + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73" + }, + { + "blob": "c6e87695340a12d76d8f4fc8fb9ae069d3ec6a47", + "bytes": 11572, + "commit": "8b549ca6557ccbb3017b104b27ea35051f990416", + "local": "reference/phase-patterns.py", + "path": "research/literal-layer-phase/phase.py", + "repository": "CubeJerry/integer-mult-bounds", + "sha256": "9a360817b80e869398927f38a4f110de0b5a1f9620eeb23b19e166f112b83f23" + }, + { + "blob": "46a43bf214d828aa972db66ad35e41b9cd07a964", + "bytes": 17878, + "commit": "172f4535ce8dcff79f626410af845f757c1563be", + "local": "reference/packed-phase-PROOF.md", + "path": "research/literal-native-quadratic-phase/PROOF.md", + "repository": "CubeJerry/integer-mult-bounds", + "sha256": "55f0a575f618bf467d0e25a25802053455d701cee1f23fb8811a671a1bd59ff3" + }, + { + "blob": "bdcc80cbd8b64c601e6d69b7d25ece444b8b1ae2", + "bytes": 17526, + "commit": "1a555e469b89af70d309bc966f8f813ac11dc887", + "local": "reference/leaf-patterns.py", + "path": "research/literal-positive-c-leaf/leaf.py", + "repository": "CubeJerry/integer-mult-bounds", + "sha256": "bb46c1a55f1119957a52cd61f2cd957f3f7ad1e9b818c54a852bde09a0773744" + }, + { + "blob": "1e3a9c427f0397bfb121bd77c1bd7e4af6ca501d", + "bytes": 3922, + "commit": "1a555e469b89af70d309bc966f8f813ac11dc887", + "local": "reference/C4-table-cpu.cpp", + "path": "research/literal-positive-c-leaf/table_cpu.cpp", + "repository": "CubeJerry/integer-mult-bounds", + "sha256": "b6180d3b12f7bb9142c146c57a0e868a74d3d7e3653c7264fb890c57f85cc08b" + }, + { + "blob": "b1619fd6894da807817d2e701fccfe5d946cc7f8", + "bytes": 1160, + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "local": "reference/controlled-block-shear--README.md", + "path": "research/controlled-block-shear/README.md", + "repository": "CrocSwap/integer-mult-bounds", + "sha256": "e130c19279ce45bc91dad31ef061e6098c0052ab9ac4e9fb11d1c612414e9a90" + }, + { + "blob": "d4e14bba3fe10e0f269b0891b0e196b723b651cf", + "bytes": 9310, + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "local": "reference/literal-elementary-interchange--PROOF.md", + "path": "research/literal-elementary-interchange/PROOF.md", + "repository": "CrocSwap/integer-mult-bounds", + "sha256": "507684173bde7865161d641bbffc6862c1e825407c42efa70747c763dadd03af" + }, + { + "blob": "f6097b18553ede9b6ec3d4168cac79448d82eb4b", + "bytes": 9185, + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "local": "reference/current-serial-monomial-leaf--PROOF.md", + "path": "research/current-serial-monomial-leaf/PROOF.md", + "repository": "CrocSwap/integer-mult-bounds", + "sha256": "9d9887da91617030174d1c7eb5e76492ac05974c78bb06e77412e5a6e34463a0" + }, + { + "blob": "967eaeb4a17263194a6932b409a2637e133ad238", + "bytes": 13987, + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "local": "reference/fixed-tape-ordered-shear--PROOF.md", + "path": "research/fixed-tape-ordered-shear/PROOF.md", + "repository": "CrocSwap/integer-mult-bounds", + "sha256": "2b5df8f57a9d36a8281e8267f1a9fefbccb4c5e5e044bdd73e911aa55acbfe24" + }, + { + "blob": "3b2e34e6ee633c99e9a812cbbf1c2dbd8b646a96", + "bytes": 11173, + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "local": "reference/fixed-tape-affine-shear--PROOF.md", + "path": "research/fixed-tape-affine-shear/PROOF.md", + "repository": "CrocSwap/integer-mult-bounds", + "sha256": "4437de82c86f6e90e9652875e86f0c88ef39ef950a301594fb0c29e1284f6ae4" + } + ] +} diff --git a/research/literal-selected-linear-maps/TASK.json b/research/literal-selected-linear-maps/TASK.json new file mode 100644 index 0000000000..6024ccf5d4 --- /dev/null +++ b/research/literal-selected-linear-maps/TASK.json @@ -0,0 +1,42 @@ +{ + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "claim": "Both actual MOVE24472 binary linear factors on the supplied packed five-Gamma ABI, all positive f columns, literal O(fV+E), complete same-owner return and historical accounting.", + "kappa_status": "No new kappa; complete accepted bound remains conditional.", + "method": "Fixed CNOT decompositions and generated unary geometry; direct matrix-XOR oracle; independent inverse-address oracle and separately written dense local CPU.", + "nonclaims": [ + "Full MOVE or source caller", + "Old-codec/strided interface", + "Numerical/cutoff admission", + "Faster nonleaf tariff", + "Global assumption removal", + "New kappa" + ], + "open_next_questions": [ + "Compose actual source phases, G maps, offset and positive C with joined numerical/lifecycle cost.", + "Provide paid actual caller old-format/strided packing and owner/occurrence interfaces.", + "Establish global precision/cutoff and remaining full-theorem assumptions." + ], + "outcome": "completed", + "overlap": [ + "controlled-block-shear", + "literal-elementary-interchange", + "binary-elementary-interchange", + "fixed-tape-ordered-shear", + "fixed-tape-affine-shear", + "current-serial-monomial-leaf", + "physical-gaussian-monomial", + "selected-monomial-tape-lift" + ], + "program_sha256": "d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33", + "proof_sha256": "217b6bbe9271aa5d5c0f0999a231d7386c7ba3fc432a88e3796d70ca283eb322", + "review_status": "Author normal/optimized complete physical checks and separate root source/universal/cost/dense review accepted.", + "schema": "standalone-task-provenance-v1", + "stopping_rule": "Stop for exact prior literal join, unaffordable geometry/complete tariff, or source mismatch; freeze after source, proof, cost, all-column and endpoint checks.", + "track_seeds": [ + 50, + 60, + 75 + ], + "wave": 5, + "worker": "literal_layer_boundary" +} diff --git a/research/literal-selected-linear-maps/VERIFICATION.md b/research/literal-selected-linear-maps/VERIFICATION.md new file mode 100644 index 0000000000..3e4e66d305 --- /dev/null +++ b/research/literal-selected-linear-maps/VERIFICATION.md @@ -0,0 +1,86 @@ +# Verification receipt guide + +Science frozen and independently accepted: + +- linear.py SHA256 `d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33`. +- PROOF.md SHA256 `217b6bbe9271aa5d5c0f0999a231d7386c7ba3fc432a88e3796d70ca283eb322`. +- Right table+alphabet `40c12281a92857287c13fd55d551ab3e574392656a174812e07625764eb7ae6c`. +- Left table+alphabet `5f1a916d1a4c39195522754c44b8facd2fbe237161943440fa6aa25c3b287496`. + +## Author evidence + +`source_gate.py` prints PASS_SELECTED_LINEAR_SOURCE_GATE. It checks fourteen +retained source byte/Git-blob pins, recomputes the actual current native recipe +and compares both source matrix row lists. This portable check is distinct +from root's actual commit:path authentication below. + +`check.py` prints PASS_LITERAL_SELECTED_LINEAR_BASE. It checks all 512 scalar +matrix addresses, ten complete actual m9,f1 successful packets and six +malformed controls. Success shapes vary r/P/S/w. Two packets append an opaque +sixth Gamma code with a 2,049-bit represented cutoff, plus trailing symbols; +only the first-five prefix is parsed. Inputs include translated/negative +origins, arbitrary raw bits and protected exteriors. + +`check_big.py` prints PASS_ACTUAL_BOTH_SELECTED_LINEAR_F2. Its second author +interpreter is C4's dense CPU adapted to 27 tapes; that reuse is disclosed. +It executes both actual m9,f2 arrays in full, with 262,144 addresses and +524,288 bits each. Direct matrix-coordinate XOR provides the oracle. The +right and left costs are 1,230,072,483 and 1,726,632,151 instructions, and f1 +counts match the reference CPU. Three altered programs fail the oracle: +first-column-only (despite complete clean retirement), reversed controls, +and changed final-commit bits. + +`check_reuse.py` prints PASS_SELECTED_LINEAR_SAME_OWNER_REUSE. Each fixed map +runs on a longer then shorter field on the same actual objects, preserving +old history and opaque public tails. The smaller call has the same price as +a fresh small call. No failure-time retry is inferred. + +`check_cost.py` prints PASS_EXACT_SELECTED_LINEAR_COST. The independently +summed helper/geometry/full-work formula agrees with fourteen complete +physical receipts. Fifty-six larger parameter checks are exact arithmetic +only: no huge payload execution is claimed. The universal inequalities are +proved in PROOF.md rather than inferred from these finite points. + +Normal and optimized author executions produced byte-identical scientific +receipts for all five scripts. The C++ compiler flags for the author runner +are `-std=c++17 -O2`; external timeouts/watchdogs are verification controls, +not part of the unbounded tape-program semantics. + +## Separate root review + +The unchanged files in independent/ are a separate root agent's work: +REVIEW.md, dense_check.py, literal_dense_runner.cpp, RESULT.json, +RESULT-OPTIMIZED.json and SOURCE-BINDINGS.json. Their copies match the originals +byte-for-byte. The review covers the complete source, universal proof, +physical lifecycle, inherited premises and complete cost/history bill. + +The root CPU was written separately from the author CPU. The expected map is +computed by inversion of the nine-bit truth table at each OUTPUT column and +reconstruction of its source address; it does not execute the CNOT word. +Fourteen complete actual m9 packets, including both full f2 fields, four +malformed controls, two grow/shrink/regrow sequences and three program mutants +are checked. The ordinary eighteen packets total 3,076,553,809 transitions. +The exact full instruction formula and DATA's V+1 reads, V writes and 4V +moves are checked. Normal/optimized receipts agree. SOURCE-BINDINGS.json +records all fourteen actual Git commit:path/blob/byte bindings, not just a +self-declared local checksum comparison. + +Portable review commands, from the package directory: + +```sh +python -I -W error -B independent/dense_check.py linear.py +python -I -W error -O -B independent/dense_check.py linear.py +``` + +Both require a C++17 compiler named `c++` and compile the independent runner +in a temporary directory. VERIFY.json records explicit normal/optimized +commands and their timeouts as a standalone replay manifest. TASK/SOURCES +use standalone provenance; no compatibility with canonical +research_package.py, hosted CI acceptance or a new shared workflow is claimed. + +## Practical limits + +Finite traces are implementation evidence. Universal conclusions rest on +the reviewed algebra/loop/cost invariants. No complete MOVE, old-codec bridge, +free strided layout, numerical/C admission, source caller, faster nonleaf +rate or foundational assumption is supplied. No new kappa is claimed. diff --git a/research/literal-selected-linear-maps/VERIFY.json b/research/literal-selected-linear-maps/VERIFY.json new file mode 100644 index 0000000000..20dd7296a7 --- /dev/null +++ b/research/literal-selected-linear-maps/VERIFY.json @@ -0,0 +1,115 @@ +{ + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/source_gate.py" + ], + "checks": "Fourteen retained source pins and actual selected MOVE recipe", + "timeout_seconds": 60 + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-O", + "-B", + "{package}/source_gate.py" + ], + "checks": "Source binding under optimized Python", + "timeout_seconds": 60 + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/check.py" + ], + "checks": "Complete m9 f1 fields, coefficient/spectator extents, opaque sixth code, malformed controls", + "timeout_seconds": 180 + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-O", + "-B", + "{package}/check.py" + ], + "checks": "Same complete physical checks under optimized Python", + "timeout_seconds": 180 + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/check_big.py" + ], + "checks": "Both actual complete m9 f2 matrices, direct address oracle, three executable mutations", + "timeout_seconds": 180 + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/check_reuse.py" + ], + "checks": "Actual persistent owners, opaque tails and long-to-short historical backing", + "timeout_seconds": 180 + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/independent/dense_check.py", + "{package}/linear.py" + ], + "checks": "Independent inverse-address oracle, separate CPU, exact complete census, malformed/reuse and three mutants", + "timeout_seconds": 180 + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-O", + "-B", + "{package}/independent/dense_check.py", + "{package}/linear.py" + ], + "checks": "Same independent checks under optimized Python", + "timeout_seconds": 180 + } + ], + "inputs": [], + "python": "3.12", + "registration_scope": "Standalone explicit commands. TASK/SOURCES retain standalone provenance; this is not a claim of canonical research_package.py schema or hosted CI admission.", + "requirements": [], + "schema": "standalone-replay-v1", + "schema_version": 1, + "status": "ready", + "system_requirements": [ + "C++17 compiler available as c++ for author and independent dense replays" + ] +} diff --git a/research/literal-selected-linear-maps/check.py b/research/literal-selected-linear-maps/check.py new file mode 100644 index 0000000000..17ca3c2bfb --- /dev/null +++ b/research/literal-selected-linear-maps/check.py @@ -0,0 +1,146 @@ +"""Author checks against direct selected-matrix XOR addresses, not gate words.""" +from pathlib import Path +import hashlib +import json +import random +import sys + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import linear as m + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +def gamma(n): + bits = bin(n)[2:] + return '0'*(len(bits)-1)+bits + + +def header(shape): + return ''.join(gamma(n) for n in shape) + + +def extent(shape): + f, r, p, s, w = shape + return 2*w*p*s*r*(1 << (9*f)) + + +def oracle(payload, shape, rows): + f, r, p, s, w = shape + q, row_count, block = 1 << f, 1 << (9*f), 2*w*r*s + require(len(payload) == p*row_count*block, 'oracle complete field') + out = ['?']*len(payload) + for source in range(row_count): + coordinates = [(source >> ((8-i)*f)) & (q-1) for i in range(9)] + destination = 0 + for row in rows: + value = 0 + for i in range(9): + if (row >> i) & 1: + value ^= coordinates[i] + destination = destination*q+value + for outer in range(p): + a, b = (outer*row_count+source)*block, (outer*row_count+destination)*block + out[b:b+block] = payload[a:a+block] + require('?' not in out, 'oracle matrix permutation') + return ''.join(out) + + +def caps(shape): + v, e = extent(shape), len(header(shape)) + result = [v]*27 + result[m.HEADER] = result[m.HTRACE] = result[m.LENGTH] = e + result[m.MODE] = 1 + return result + + +def packet(shape, payload): + origins = tuple(7*i-71 for i in range(27)) + tapes = [] + for i, (origin, cap) in enumerate(zip(origins, caps(shape))): + cells = {origin-3:'1', origin-2:'|', origin+cap+1:'0', origin+cap+2:'|'} + if i < 2: + cells[origin-1] = '1' + tapes.append(m.Tape(cells, origin)) + for i, text in ((m.HEADER, header(shape)), (m.DATA, payload)): + tapes[i].cells.update({origins[i]+j: bit for j, bit in enumerate(text)}) + return tapes, origins + + +def execute(side, shape, payload, *, code=None, accept=True, edit=None): + code = m.compile_linear(side)[0] if code is None else code + tapes, origins = packet(shape, payload) + if edit: + edit(tapes, origins) + before = [dict(t.cells) for t in tapes] + owners = tuple(map(id, tapes)) + cpu = m.Machine(code, tapes) + try: + cpu.run(2_000_000_000) + rejected = False + except ValueError as exc: + require(str(exc) == 'invalid scanned symbol', 'unexpected machine failure: '+str(exc)) + rejected = True + require(rejected != accept, 'acceptance mismatch') + require(tuple(map(id, tapes)) == owners, 'owner identity') + require(tapes[0].cells == before[0], 'header bytes') + if accept: + output = oracle(payload, shape, m.MATRICES[side]) + require(tapes[1].cells == before[1] | {origins[1]+j: b for j,b in enumerate(output)}, 'direct address oracle or public exterior') + require(all(t.head == u for t,u in zip(tapes, origins)), 'head restoration') + require(all(t.cells == before[i] for i,t in enumerate(tapes) if i != 1), 'private/exterior restoration') + v, e, f = extent(shape), len(header(shape)), shape[0] + require(cpu.steps <= 65536*(f*v+e+1), 'complete time envelope') + require(sum(t.high-t.low+1 for t in tapes[2:]) <= 64*(v+e+1), 'private history envelope') + for i,(t,o,cap) in enumerate(zip(tapes,origins,caps(shape))): + require(t.low >= o-int(i>=2) and t.high <= o+cap, 'role visit cap') + else: + require(tapes[1].cells == before[1], 'failed call changed public data') + return cpu.steps + + +def main(): + rng = random.Random(2026111205) + results = [] + words = {} + for side, rows in m.MATRICES.items(): + word = m.cnot_word(rows) + words[side] = word + for x in range(512): + y = x + for target, control in word: + y ^= ((y >> control) & 1) << target + expected = sum(((row & x).bit_count() % 2) << i for i,row in enumerate(rows)) + require(y == expected, 'fixed GF(2) decomposition') + code, alphabet = m.compile_linear(side) + require(set(alphabet) == {'_','0','1','|'}, 'fixed alphabet') + require(all(i[0] in ('read','write','move','goto','halt') for i in code), 'literal instruction language') + for shape in ((1,1,1,1,1), (1,2,1,1,2), (1,1,2,1,1), (1,1,1,2,1)): + payload = ''.join(str(rng.randrange(2)) for _ in range(extent(shape))) + steps = execute(side, shape, payload, code=code) + results.append({'side':side,'shape':shape,'steps':steps,'kind':'complete m9 f1'}) + shape=(1,1,1,1,1) + payload='01'*(extent(shape)//2) + opaque=gamma((1 << 2048)+12345)+'|10' + def opaque_tail(tapes, origins): + start=origins[0]+len(header(shape)) + tapes[0].cells.update({start+j:b for j,b in enumerate(opaque)}) + steps=execute(side,shape,payload,code=code,edit=opaque_tail) + results.append({'side':side,'shape':shape,'steps':steps,'kind':'opaque sixth Gamma code','opaque_bits':len(opaque)}) + for kind,edit in ( + ('short payload', lambda t,u:t[1].cells.pop(u[1]+extent(shape)-1)), + ('extra payload', lambda t,u:t[1].cells.__setitem__(u[1]+extent(shape),'1')), + ('bad header', lambda t,u:t[0].cells.__setitem__(u[0],'|'))): + steps=execute(side,shape,payload,code=code,accept=False,edit=edit) + results.append({'side':side,'shape':shape,'steps':steps,'kind':kind}) + print(json.dumps({'status':'PASS_LITERAL_SELECTED_LINEAR_BASE','source_sha256':hashlib.sha256((HERE/'linear.py').read_bytes()).hexdigest(), + 'gate_counts':{s:len(w) for s,w in words.items()},'words':words,'seed':2026111205,'cases':results, + 'scope':'Complete actual m9 f1 packets; full f2 and graph mutants are separate receipts.'},indent=2,sort_keys=True)) + + +if __name__ == '__main__': + main() diff --git a/research/literal-selected-linear-maps/check_big.py b/research/literal-selected-linear-maps/check_big.py new file mode 100644 index 0000000000..efd8486b54 --- /dev/null +++ b/research/literal-selected-linear-maps/check_big.py @@ -0,0 +1,111 @@ +"""Complete actual f=2 matrices on a dense interpreter of the emitted graph. + +The C4 test interpreter is retained with its fixed inventory changed 29->27 +and a larger external watchdog. This is author cross-interpreter evidence, +not root's independently implemented review. +""" +from pathlib import Path +import hashlib +import json +import random +import subprocess +import sys +import tempfile +import time + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import check as c + + +def table_text(code): + symbols = {'_':0,'0':1,'1':2,'|':3} + rows = [str(len(code))] + for op,*a in code: + tape = value = 0 + branches = [-1]*4 + if op == 'read': + tag,tape = 0,a[0] + for s,pc in a[1].items():branches[symbols[s]]=pc + elif op == 'write':tag,tape,value=1,a[0],symbols[a[1]] + elif op == 'move':tag,tape,value=2,a[0],a[1] + elif op == 'goto':tag,value=3,a[0] + elif op == 'halt':tag=4 + else:raise ValueError('unrecognized literal instruction') + rows.append(' '.join(map(str,(tag,tape,value,*branches)))) + return '\n'.join(rows)+'\n' + + +def invoke(tmp, executable, shape, payload, code): + program,packet,output=(tmp/n for n in ('program.txt','packet.txt','output.txt')) + program.write_text(table_text(code)) + origins=[64+2*i for i in range(27)] + packet.write_text(' '.join(map(str,origins))+'\n'+' '.join(map(str,c.caps(shape)))+'\n'+c.header(shape)+'\n'+payload+'\n') + start=time.monotonic() + run=subprocess.run([str(executable),str(program),str(packet),str(output)],capture_output=True,text=True,check=True,timeout=180) + result=json.loads(run.stdout); out=output.read_text() + c.require(result['accepted'],'dense literal rejection') + c.require(all(result[x] for x in ('heads_returned','private_blank','header_preserved','exteriors_preserved')),'dense lifecycle boundary') + c.require(result['data_writes']==len(payload) and result['header_writes']==0,'dense public write census') + c.require(result['steps'] <= 65536*(shape[0]*len(payload)+len(c.header(shape))+1),'dense time envelope') + c.require(result['private_history'] <= 64*(len(payload)+len(c.header(shape))+1),'dense history envelope') + result.update({'shape':list(shape),'input_bits':len(payload),'output_sha256':hashlib.sha256(out.encode()).hexdigest()}) + return out,result,time.monotonic()-start + + +def capture(side): + old=c.m.Builder; builder=old();c.m.Builder=lambda:builder + try:code,alphabet=c.m.compile_linear(side) + finally:c.m.Builder=old + return code,alphabet,builder.labels + + +def main(): + rng=random.Random(2026111205) + small_shape=(1,1,1,1,1);big_shape=(2,1,1,1,1) + small=''.join(str(rng.randrange(2)) for _ in range(c.extent(small_shape))) + big=''.join(str(rng.randrange(2)) for _ in range(c.extent(big_shape))) + records={}; controls=[]; timings={} + with tempfile.TemporaryDirectory(prefix='literal-linear-full-') as folder: + tmp=Path(folder);exe=tmp/'table_cpu' + subprocess.run(['c++','-std=c++17','-O2',str(HERE/'table_cpu.cpp'),'-o',str(exe)],check=True,capture_output=True,text=True,timeout=60) + for side in ('right','left'): + code,alphabet,labels=capture(side) + out,receipt,elapsed=invoke(tmp,exe,small_shape,small,code) + c.require(out==c.oracle(small,small_shape,c.m.MATRICES[side]),'dense f1 direct matrix') + c.require(receipt['steps']==c.execute(side,small_shape,small,code=code),'two literal interpreters count differently') + records[side+'_f1']=receipt;timings[side+'_f1']=elapsed + expected=c.oracle(big,big_shape,c.m.MATRICES[side]) + out,receipt,elapsed=invoke(tmp,exe,big_shape,big,code) + c.require(out==expected,'actual complete f2 direct matrix') + records[side+'_f2']=receipt;timings[side+'_f2']=elapsed + print('completed actual '+side+' f2',file=sys.stderr,flush=True) + if side=='right': + broken=list(code) + for label,pc in labels.items(): + if label.endswith('next_column'): + broken[pc]=('goto',labels[label[:-len('next_column')]+'finished']) + wrong,receipt,elapsed=invoke(tmp,exe,big_shape,big,tuple(broken)) + c.require(wrong!=expected,'first-column-only mutant escaped') + records['first_column_only']=receipt;timings['first_column_only']=elapsed + controls.append('all gates retain only the first column; complete lifecycle still succeeds') + wrong_commit=tuple(('write',c.m.DATA,'0') if i==('write',c.m.DATA,'1') else i for i in code) + wrong,receipt,elapsed=invoke(tmp,exe,small_shape,small,wrong_commit) + c.require(wrong!=c.oracle(small,small_shape,c.m.MATRICES[side]),'commit mutant escaped') + records['commit_bits']=receipt;timings['commit_bits']=elapsed + controls.append('change one-bits in the final public commit') + old=c.m.cnot_columns + c.m.cnot_columns=lambda a,target,control:old(a,control,target) + try:wrong_direction=c.m.compile_linear('right')[0] + finally:c.m.cnot_columns=old + wrong,receipt,elapsed=invoke(tmp,exe,small_shape,small,wrong_direction) + c.require(wrong!=c.oracle(small,small_shape,c.m.MATRICES['right']),'reversed CNOT-direction mutant escaped') + records['wrong_control_direction']=receipt;timings['wrong_control_direction']=elapsed + controls.append('reverse control and target at every compiled gate') + print(json.dumps({'status':'PASS_ACTUAL_BOTH_SELECTED_LINEAR_F2','source_sha256':hashlib.sha256((HERE/'linear.py').read_bytes()).hexdigest(), + 'interpreter_sha256':hashlib.sha256((HERE/'table_cpu.cpp').read_bytes()).hexdigest(),'compiler_flags':['-std=c++17','-O2'], + 'seed':2026111205,'records':records,'controls':controls,'scope':'Both actual fixed m=9 maps, complete 262144-address f=2 fields; no reduced dimension or address sampling.'},indent=2,sort_keys=True)) + print('Elapsed seconds (observations only): '+json.dumps({k:round(v,3) for k,v in timings.items()},sort_keys=True),file=sys.stderr) + + +if __name__=='__main__':main() diff --git a/research/literal-selected-linear-maps/check_cost.py b/research/literal-selected-linear-maps/check_cost.py new file mode 100644 index 0000000000..a8d5cdd55f --- /dev/null +++ b/research/literal-selected-linear-maps/check_cost.py @@ -0,0 +1,59 @@ +"""Exact termwise instruction census; no observed timing fits.""" +from pathlib import Path +import json +import sys + +HERE=Path(__file__).resolve().parent +sys.path.insert(0,str(HERE)) +import linear as m + + +def gamma_cost(n): + return 47*n-30*n.bit_count()+33*n.bit_length()-42 + + +def price(side,shape): + f,r,p,s,w=shape + v=2*w*r*p*s*(1 << (9*f)) + e=sum(2*n.bit_length()-1 for n in shape) + volume=47*v+28*p+40*p*r+40*p*r*s-24*p*r*s*w+168*f+83 + cost=75+sum(gamma_cost(n) for n in shape)+5*e+3+volume+20*v+11+1 + for target,control in m.cnot_word(m.MATRICES[side]): + high,low=min(target,control),max(target,control) + a=p*(1 << ((high+1)*f-1));mid=1 << ((low-high)*f-1);b=2*w*r*s*(1 << ((8-low)*f)) + cost+=124*a+124*mid+47*b-36*p-24*r*s*w+28*r*s+10*r+180*f+44 + for j in range(f): + cost+=58*v+78*a*mid+48*a+16 + if j+1bound:raise ValueError('complete envelope') + abstract=0 + for f in (1,2,3,4,8,31,128): + for shape in ((f,1,1,1,1),(f,2,3,5,7),(f,1,1 << 257,1,1),(f,1 << 129,1,1,1 << 63)): + for side in m.MATRICES: + exact,bound=price(side,shape) + if exact>bound:raise ValueError('adversarial parameter price') + abstract+=1 + print(json.dumps({'status':'PASS_EXACT_SELECTED_LINEAR_COST','physical_receipts_matched':len(records),'abstract_shapes_checked':abstract, + 'scope':'Exact helper-derived formula matches full physical traces; large shapes check arithmetic inequalities only, not payload execution.'},indent=2,sort_keys=True)) + + +if __name__=='__main__':main() diff --git a/research/literal-selected-linear-maps/check_reuse.py b/research/literal-selected-linear-maps/check_reuse.py new file mode 100644 index 0000000000..6592374435 --- /dev/null +++ b/research/literal-selected-linear-maps/check_reuse.py @@ -0,0 +1,43 @@ +"""Long-to-short calls on the same physical owners, retaining opaque tails.""" +from pathlib import Path +import json +import random +import sys + +HERE=Path(__file__).resolve().parent +sys.path.insert(0,str(HERE)) +import check as c + + +def main(): + rng=random.Random(2026111206); records=[] + for side in ('right','left'): + large=(1,2,2,1,1);small=(1,1,1,1,1) + old=''.join(str(rng.randrange(2)) for _ in range(c.extent(large))) + new=''.join(str(rng.randrange(2)) for _ in range(c.extent(small))) + tapes,origins=c.packet(large,old);owners=tuple(map(id,tapes)) + code=c.m.compile_linear(side)[0] + first=c.m.Machine(code,tapes).run(2_000_000_000) + c.require(all(t.head==u for t,u in zip(tapes,origins)),'large call return') + initial_history=[(t.low,t.high) for t in tapes] + # Caller prepares the next public prefix. Old tails remain opaque; + # neither owned tapes nor history observers are reset/recreated. + for t,text in ((c.m.HEADER,c.header(small)),(c.m.DATA,new)): + tapes[t].cells.update({origins[t]+j:b for j,b in enumerate(text)}) + tapes[c.m.DATA].cells.pop(origins[c.m.DATA]+len(new),None) + before=[dict(t.cells) for t in tapes] + second=c.m.Machine(code,tapes).run(2_000_000_000) + expected=c.oracle(new,small,c.m.MATRICES[side]) + c.require(tapes[1].cells==before[1]|{origins[1]+j:b for j,b in enumerate(expected)},'reused field/opaque tail') + c.require(all(t.cells==before[i] for i,t in enumerate(tapes) if i!=1),'reused private/header/exterior') + c.require(all(t.head==u for t,u in zip(tapes,origins)),'reused head return') + c.require(tuple(map(id,tapes))==owners,'same owner identities') + c.require([(t.low,t.high) for t in tapes]==initial_history,'history was reset or unexpectedly expanded') + fresh=c.execute(side,small,new,code=code) + c.require(second.steps==fresh,'current time depends on old erased capacity') + records.append({'side':side,'large_shape':large,'small_shape':small,'large_steps':first.steps,'small_and_fresh_steps':second.steps,'retained_total_history':sum(b-a+1 for a,b in initial_history)}) + print(json.dumps({'status':'PASS_SELECTED_LINEAR_SAME_OWNER_REUSE','seed':2026111206,'records':records, + 'scope':'Same actual tape objects and intervals; old public payload/descriptor tails retained as opaque exterior. No failure-time retry claim.'},indent=2,sort_keys=True)) + + +if __name__=='__main__':main() diff --git a/research/literal-selected-linear-maps/independent/RESULT-OPTIMIZED.json b/research/literal-selected-linear-maps/independent/RESULT-OPTIMIZED.json new file mode 100644 index 0000000000..adefdadd1e --- /dev/null +++ b/research/literal-selected-linear-maps/independent/RESULT-OPTIMIZED.json @@ -0,0 +1 @@ +{"cases": [{"entry_history": 25, "history": 8766, "kind": "complete actual m9", "shape": [1, 1, 1, 1, 1], "side": "right", "steps": 1386351}, {"entry_history": 8766, "history": 42572, "kind": "complete actual m9", "shape": [1, 1, 1, 1, 5], "side": "right", "steps": 6490047}, {"entry_history": 42572, "history": 42574, "kind": "complete actual m9", "shape": [1, 2, 1, 2, 1], "side": "right", "steps": 5216059}, {"entry_history": 42574, "history": 4030543, "kind": "complete actual m9", "shape": [2, 1, 1, 1, 1], "side": "right", "steps": 1230072483}, {"entry_history": 25, "history": 81876, "kind": "complete actual m9", "shape": [1, 2, 2, 1, 3], "side": "right", "steps": 15176695}, {"entry_history": 81876, "history": 81876, "kind": "complete actual m9", "shape": [1, 1, 1, 1, 1], "side": "right", "steps": 1386351}, {"entry_history": 81876, "history": 109021, "kind": "complete actual m9", "shape": [1, 1, 2, 2, 4], "side": "right", "steps": 20169432}, {"entry_history": 25, "history": 8766, "kind": "complete actual m9", "shape": [1, 1, 1, 1, 1], "side": "left", "steps": 1936566}, {"entry_history": 8766, "history": 42572, "kind": "complete actual m9", "shape": [1, 1, 1, 1, 5], "side": "left", "steps": 9152582}, {"entry_history": 42572, "history": 42574, "kind": "complete actual m9", "shape": [1, 2, 1, 2, 1], "side": "left", "steps": 7351266}, {"entry_history": 42574, "history": 4030543, "kind": "complete actual m9", "shape": [2, 1, 1, 1, 1], "side": "left", "steps": 1726632151}, {"entry_history": 25, "history": 81876, "kind": "complete actual m9", "shape": [1, 2, 2, 1, 3], "side": "left", "steps": 21238852}, {"entry_history": 81876, "history": 81876, "kind": "complete actual m9", "shape": [1, 1, 1, 1, 1], "side": "left", "steps": 1936566}, {"entry_history": 81876, "history": 109021, "kind": "complete actual m9", "shape": [1, 1, 2, 2, 4], "side": "left", "steps": 28237941}, {"entry_history": 25, "history": 4155, "kind": "short", "shape": [1, 1, 1, 1, 1], "side": "right", "steps": 57815}, {"entry_history": 25, "history": 4157, "kind": "extra", "shape": [1, 1, 1, 1, 1], "side": "right", "steps": 60899}, {"entry_history": 25, "history": 50, "kind": "header", "shape": [1, 1, 1, 1, 1], "side": "right", "steps": 76}, {"entry_history": 25, "history": 2791, "kind": "symbol", "shape": [1, 1, 1, 1, 1], "side": "right", "steps": 51677}], "complete_actual_f2_sides": 2, "exact_helper_census": true, "interpreter_sha256": "6d1002aa7d1f00a5a5e906eb42c4a6e7d680f710eb3cb616a07090db667c68df", "mutations": ["corrupted original-owner commit", "correct function with incorrect complete cost", "clean first-column-only native map"], "program_sha256": "d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33", "seed": 982713, "source_matrices": "actual MOVE24472 right and left", "status": "PASS_INDEPENDENT_SELECTED_LINEAR"} diff --git a/research/literal-selected-linear-maps/independent/RESULT.json b/research/literal-selected-linear-maps/independent/RESULT.json new file mode 100644 index 0000000000..adefdadd1e --- /dev/null +++ b/research/literal-selected-linear-maps/independent/RESULT.json @@ -0,0 +1 @@ +{"cases": [{"entry_history": 25, "history": 8766, "kind": "complete actual m9", "shape": [1, 1, 1, 1, 1], "side": "right", "steps": 1386351}, {"entry_history": 8766, "history": 42572, "kind": "complete actual m9", "shape": [1, 1, 1, 1, 5], "side": "right", "steps": 6490047}, {"entry_history": 42572, "history": 42574, "kind": "complete actual m9", "shape": [1, 2, 1, 2, 1], "side": "right", "steps": 5216059}, {"entry_history": 42574, "history": 4030543, "kind": "complete actual m9", "shape": [2, 1, 1, 1, 1], "side": "right", "steps": 1230072483}, {"entry_history": 25, "history": 81876, "kind": "complete actual m9", "shape": [1, 2, 2, 1, 3], "side": "right", "steps": 15176695}, {"entry_history": 81876, "history": 81876, "kind": "complete actual m9", "shape": [1, 1, 1, 1, 1], "side": "right", "steps": 1386351}, {"entry_history": 81876, "history": 109021, "kind": "complete actual m9", "shape": [1, 1, 2, 2, 4], "side": "right", "steps": 20169432}, {"entry_history": 25, "history": 8766, "kind": "complete actual m9", "shape": [1, 1, 1, 1, 1], "side": "left", "steps": 1936566}, {"entry_history": 8766, "history": 42572, "kind": "complete actual m9", "shape": [1, 1, 1, 1, 5], "side": "left", "steps": 9152582}, {"entry_history": 42572, "history": 42574, "kind": "complete actual m9", "shape": [1, 2, 1, 2, 1], "side": "left", "steps": 7351266}, {"entry_history": 42574, "history": 4030543, "kind": "complete actual m9", "shape": [2, 1, 1, 1, 1], "side": "left", "steps": 1726632151}, {"entry_history": 25, "history": 81876, "kind": "complete actual m9", "shape": [1, 2, 2, 1, 3], "side": "left", "steps": 21238852}, {"entry_history": 81876, "history": 81876, "kind": "complete actual m9", "shape": [1, 1, 1, 1, 1], "side": "left", "steps": 1936566}, {"entry_history": 81876, "history": 109021, "kind": "complete actual m9", "shape": [1, 1, 2, 2, 4], "side": "left", "steps": 28237941}, {"entry_history": 25, "history": 4155, "kind": "short", "shape": [1, 1, 1, 1, 1], "side": "right", "steps": 57815}, {"entry_history": 25, "history": 4157, "kind": "extra", "shape": [1, 1, 1, 1, 1], "side": "right", "steps": 60899}, {"entry_history": 25, "history": 50, "kind": "header", "shape": [1, 1, 1, 1, 1], "side": "right", "steps": 76}, {"entry_history": 25, "history": 2791, "kind": "symbol", "shape": [1, 1, 1, 1, 1], "side": "right", "steps": 51677}], "complete_actual_f2_sides": 2, "exact_helper_census": true, "interpreter_sha256": "6d1002aa7d1f00a5a5e906eb42c4a6e7d680f710eb3cb616a07090db667c68df", "mutations": ["corrupted original-owner commit", "correct function with incorrect complete cost", "clean first-column-only native map"], "program_sha256": "d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33", "seed": 982713, "source_matrices": "actual MOVE24472 right and left", "status": "PASS_INDEPENDENT_SELECTED_LINEAR"} diff --git a/research/literal-selected-linear-maps/independent/REVIEW.md b/research/literal-selected-linear-maps/independent/REVIEW.md new file mode 100644 index 0000000000..9ee37739c4 --- /dev/null +++ b/research/literal-selected-linear-maps/independent/REVIEW.md @@ -0,0 +1,103 @@ +# Independent review of the two selected literal linear maps + +**Disposition: accepted for the stated packed two-matrix enabling lemma.** +Prepared for Jerry Chen / @CubeJerry with substantial OpenAI assistance. +This is separate root review of another agent's work, not human or proof-kernel +acceptance. No complete multiplication bound or global assumption is discharged. + +## Frozen scope and source authentication + +Reviewed `linear.py` SHA256 +`d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33` +and `PROOF.md` SHA256 +`217b6bbe9271aa5d5c0f0999a231d7386c7ba3fc432a88e3796d70ca283eb322`. +The source is canonical `e54523517d0f03e58352e647c403a5af3e525a57`, +actual MOVE24472 `["MOVE",415,3,99,false]`, frames `[]` and `[239]`. +The exact right and left binary matrices are independently fixed in the +review checker. Their addresses use native coordinate i as bit i, while the +packed field places coordinate zero first. This distinction is substantive. + +All fourteen `SOURCES.json` entries were separately authenticated against +their actual `commit:path` through Git: tree entry/blob, complete bytes, +length and SHA256. `SOURCE-BINDINGS.json` retains the receipt. This is stronger +than testing a locally declared checksum against itself. The original frame +lowering and accepted recipe evidence establish the source matrices; this +review does not claim a new proof of the retained Clifford compiler. + +## Universal obligations reviewed + +I read the complete graph generator and proof. Reversed row-elimination +operations give the claimed matrix in temporal order. Each fixed gate acts +on all f columns, and operations on different columns commute. Both physical +directions use the correct four-chunk permutation. The generated geometry +`[A] x [2] x [M] x [2] x [B]` satisfies `4AMB=V`, with the specified +coordinate order, spectators, Gaussian components and individual bits. +No coefficient-length absorption or supplied-stride premise is used. + +The split/chunk/merge invariant preserves full bit records. Alternating +whole-field banks avoid overwriting unread input. Every public DATA read and +return occurs before the sole final commit. The first-five Gamma header, +its opaque trailing symbols, all private guards and bodies, and successful +head positions have matching entry and return contracts. Blank distinct +private owners are explicit premises, and named rejection preserves public +data without promising failure cleanup or retry. + +Historical backing is a sum of the intervals of actual roles. In particular, +a smaller reused call retains its earlier larger allocation. The stated +`K_entry+64(V+E+1)` bound and per-role maximum rule handle this correctly; +replacing this with `64(V_current+E_current+1)` would be false on shrinking +calls. External entry supply is not part of the component's runtime theorem. + +## Independent full cost census + +Before reading the author's cost proof I derived the following counts from +the emitted loops: rewind `3n+3`, clear `7n+4`, unary copy `11n+7`, doubling +`47n+18`, even halving `15n+14`, and unary product `11nm+10n+7`. +The complete column count is + +`58V + 78AM + 48A + 16`. + +Its next-column update costs `47B+15A+33`, and final guide retirement costs +`3f+15+7(A_last+M+B_last)`. The independent checker sums all header parsing, +volume/geometry preparation, source cloning, every gate and column, final +commit, guide cleanup and guard operations. It agrees exactly with complete +executions, not only their asymptotic order. Algebraic expansion also agrees +with the author's initial-geometry and VOLUME formulas. + +The proof's inequalities follow from positive encoded fields, B>=2, +AM,A<=V/8 and V>=1024f. Summing at most 27 fixed gate bills and the explicit +overhead gives the claimed `65536(fV+E+1)` envelope. These are direct-leaf +costs; they do not establish an O(V) arbitrary-f affine service. + +## Independent execution and failure detection + +The companion `dense_check.py` and `literal_dense_runner.cpp` were written +separately from the author interpreter, test oracle and compiled runner. +Expected outputs are obtained by inverting the complete nine-bit source +matrix truth table, extracting each OUTPUT bit column, and reconstructing +its source address. They are not computed by executing the CNOT word. + +The check executes fourteen complete actual m9 packets, including both full +f2 fields, variation of r/P/S/w, and two fixed-inventory grow/shrink/regrow +sequences. It also exercises four malformed inputs. Total counted transitions +across those eighteen packets are 3,076,553,809. The full f2 counts are +1,230,072,483 for the right map and 1,726,632,151 for the left. Whole output, +all private and opaque cells, heads, retained history, exact complete cost, +and DATA's `[V+1 reads, V writes, 4V moves]` census are checked. + +Three program mutations are detected: corrupted original-owner commit, +a numerically correct extra instruction that violates the exact cost, and +processing only the first column of every gate. Normal and optimized Python +produce identical structured receipts. Both commands compile the separate +C++17 interpreter in a temporary directory; a compiler named `c++` is required. + +``` +python -I -W error -B independent/dense_check.py linear.py +python -I -W error -O -B independent/dense_check.py linear.py +``` + +Finite execution supports, but does not replace, the universal induction and +cost proof. The phases, translation, positive C, old coded/strided layout +bridge, source caller and global precision/cutoff/ownership admission remain +outside this package. A complete MOVE must compose their actual interfaces +and preserve public data through any later arithmetic failure. diff --git a/research/literal-selected-linear-maps/independent/SOURCE-BINDINGS.json b/research/literal-selected-linear-maps/independent/SOURCE-BINDINGS.json new file mode 100644 index 0000000000..badcefa150 --- /dev/null +++ b/research/literal-selected-linear-maps/independent/SOURCE-BINDINGS.json @@ -0,0 +1,89 @@ +{ + "status": "PASS_EXACT_GIT_SOURCE_BINDINGS", + "sources": [ + { + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/shared-wire-split-composition/frozen/clifford_exact.py", + "blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + { + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/shared-wire-split-composition/frozen/native_verify.py", + "blob": "2c209dfa9cfade3bc20ac5fc9d876b433a147f8c", + "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38" + }, + { + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/shared-wire-split-composition/data/final.json.gz", + "blob": "74563a7867d9d762b6588f65362369668841bb3e", + "sha256": "2b94953dc14a122e3ef089633f05b58ec689ec5156feb7c784ed3e137dc01883" + }, + { + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "docs/research/pr-intake-evidence/pr7000-application/check_native_catalogue.py", + "blob": "98b35c89c8bd52637633aa78d506244bca8ec9e1", + "sha256": "6120e1ea1e07eeba757694d209437a38f121b0a377cc466889a30fa52c561472" + }, + { + "commit": "9dfe6747b8553fd11b408f2b045c5954ef1e6eaa", + "path": "research/selected-rank-control/controller_reference.py", + "blob": "3ab6d0361f35038ffcdf0cf81a157f7a17b40e72", + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73" + }, + { + "commit": "8b549ca6557ccbb3017b104b27ea35051f990416", + "path": "research/literal-layer-phase/phase.py", + "blob": "c6e87695340a12d76d8f4fc8fb9ae069d3ec6a47", + "sha256": "9a360817b80e869398927f38a4f110de0b5a1f9620eeb23b19e166f112b83f23" + }, + { + "commit": "172f4535ce8dcff79f626410af845f757c1563be", + "path": "research/literal-native-quadratic-phase/PROOF.md", + "blob": "46a43bf214d828aa972db66ad35e41b9cd07a964", + "sha256": "55f0a575f618bf467d0e25a25802053455d701cee1f23fb8811a671a1bd59ff3" + }, + { + "commit": "1a555e469b89af70d309bc966f8f813ac11dc887", + "path": "research/literal-positive-c-leaf/leaf.py", + "blob": "bdcc80cbd8b64c601e6d69b7d25ece444b8b1ae2", + "sha256": "bb46c1a55f1119957a52cd61f2cd957f3f7ad1e9b818c54a852bde09a0773744" + }, + { + "commit": "1a555e469b89af70d309bc966f8f813ac11dc887", + "path": "research/literal-positive-c-leaf/table_cpu.cpp", + "blob": "1e3a9c427f0397bfb121bd77c1bd7e4af6ca501d", + "sha256": "b6180d3b12f7bb9142c146c57a0e868a74d3d7e3653c7264fb890c57f85cc08b" + }, + { + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/controlled-block-shear/README.md", + "blob": "b1619fd6894da807817d2e701fccfe5d946cc7f8", + "sha256": "e130c19279ce45bc91dad31ef061e6098c0052ab9ac4e9fb11d1c612414e9a90" + }, + { + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/literal-elementary-interchange/PROOF.md", + "blob": "d4e14bba3fe10e0f269b0891b0e196b723b651cf", + "sha256": "507684173bde7865161d641bbffc6862c1e825407c42efa70747c763dadd03af" + }, + { + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/current-serial-monomial-leaf/PROOF.md", + "blob": "f6097b18553ede9b6ec3d4168cac79448d82eb4b", + "sha256": "9d9887da91617030174d1c7eb5e76492ac05974c78bb06e77412e5a6e34463a0" + }, + { + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/fixed-tape-ordered-shear/PROOF.md", + "blob": "967eaeb4a17263194a6932b409a2637e133ad238", + "sha256": "2b5df8f57a9d36a8281e8267f1a9fefbccb4c5e5e044bdd73e911aa55acbfe24" + }, + { + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/fixed-tape-affine-shear/PROOF.md", + "blob": "3b2e34e6ee633c99e9a812cbbf1c2dbd8b646a96", + "sha256": "4437de82c86f6e90e9652875e86f0c88ef39ef950a301594fb0c29e1284f6ae4" + } + ] +} diff --git a/research/literal-selected-linear-maps/independent/dense_check.py b/research/literal-selected-linear-maps/independent/dense_check.py new file mode 100644 index 0000000000..284b23e30b --- /dev/null +++ b/research/literal-selected-linear-maps/independent/dense_check.py @@ -0,0 +1,213 @@ +"""Independent inverse-address oracle, literal CPU and complete cost census. + +Prepared for CubeJerry with OpenAI assistance. Apache-2.0. +The author interpreter, test oracle and runtime metrics are not used. +The companion literal_dense_runner.cpp is a separate instruction interpreter. +""" +from pathlib import Path +import hashlib +import importlib.util +import json +import random +import subprocess +import sys +import tempfile + +MATRICES = { + 'right': (239,129,130,132,136,16,160,192,256), + 'left': (3,5,9,17,32,65,129,1,256), +} +SYMBOLS = '_01|' + +def need(ok, message): + if not ok: + raise AssertionError(message) + +def gamma(n): + b=format(n,'b') + return '0'*(len(b)-1)+b + +def gcost(n): + return 47*n-30*n.bit_count()+33*n.bit_length()-42 + +def cclear(n): + return 7*n+4 + +def ccopy(n): + return 11*n+7 + +def cproduct(n,m): + return 11*n*m+10*n+7 + +def cmultiply(n,m): + return 23*n*m+17*n+18 + +def cdouble(n): + return 47*n+18 + +def chalve(n): + need(n%2==0,'even generated guide') + return 15*n+14 + +def cdoublings(n,k,f): + return 47*(n*(1<<(k*f))-n)+18*k*f+6*f+4 + +def cvolume(shape): + f,r,p,s,w=shape + total=ccopy(p); n=p + for factor in (r,s,w): + total+=cmultiply(n,factor); n*=factor + total+=cdoublings(n,9,f); n<<=9*f + total+=cdouble(n) + return total + +def geometry(shape,target,control): + f,r,p,s,w=shape; h,l=sorted((target,control)) + a=p<<(h+1)*f + cost=ccopy(p)+cdoublings(p,h+1,f)+chalve(a); a//=2 + m=1<<((l-h)*f) + cost+=1+cdoublings(1,l-h,f)+chalve(m);m//=2 + cost+=cproduct(r,s)+cmultiply(r*s,w)+cdouble(r*s*w) + b=2*r*s*w + cost+=cdoublings(b,8-l,f);b<<=(8-l)*f + return a,m,b,cost + +def gate_cost(shape,target,control): + f,r,p,s,w=shape;v=2*w*p*s*r*(1<<(9*f)) + a,m,b,total=geometry(shape,target,control) + for j in range(f): + need(4*a*m*b==v,'complete column geometry') + # Direct census of prefix loading, four chunks, output merge, + # whole-array rewind, mode update and the column test. + total+=58*v+78*a*m+48*a+16 + if j+1>((8-i)*f+j))&1)<>i)&1)<<((8-i)*f+j) + need(source>((8-i)*f))&q)<1< +#include +#include +#include +#include +#include +#include +#include + +struct Instruction { int op, tape, value; std::array branch; }; +int symbol(char c) { + const std::string alphabet="_01|"; + auto p=alphabet.find(c); + if(p==std::string::npos) throw std::runtime_error("bad input symbol"); + return static_cast(p); +} +int main(int argc,char **argv) { + try { + if(argc!=2) throw std::runtime_error("one encoded test file required"); + std::ifstream in(argv[1]); + int n,nt,cases; std::int64_t capacity; + in>>n>>nt>>capacity>>cases; + if(!in || n<1 || nt<2 || capacity<128 || cases<1) throw std::runtime_error("bad dimensions"); + std::vector code(n); + for(auto &a:code) { + in>>a.op>>a.tape>>a.value; + for(auto &d:a.branch) in>>d; + if(!in || a.op<0 || a.op>4) throw std::runtime_error("bad instruction"); + if(a.op<3 && (a.tape<0 || a.tape>=nt)) throw std::runtime_error("bad tape"); + if(a.op==0) for(int d:a.branch) if(d < -1 || d>=n) throw std::runtime_error("bad local edge"); + if(a.op==1 && (a.value<0 || a.value>3)) throw std::runtime_error("bad write"); + if(a.op==2 && a.value!=1 && a.value!=-1) throw std::runtime_error("nonunit move"); + if(a.op==3 && (a.value<0 || a.value>=n)) throw std::runtime_error("bad fixed goto"); + } + std::vector> row(nt,std::vector(capacity,0)); + std::vector origin(nt),head(nt),low(nt),high(nt); + for(int t=0;t{2,1,3,2}[k]; row[t][capacity-5+k]=std::array{1,2,3,1}[k]; } + } + for(int c=0;c>header>>payload>>expected; + if(!in || head!=origin) throw std::runtime_error("bad clean entry"); + bool expected_halt=expected!="REJECT"; + std::array fields={header,payload}; + for(int t=0;t<2;t++) { + auto &s=fields[t]; if(s=="EMPTY")s.clear(); + if(origin[t]+s.size()+8>=static_cast(capacity)) throw std::runtime_error("observer capacity"); + std::fill(row[t].begin()+origin[t],row[t].end()-6,0); + for(std::size_t j=0;j{1,2,3,1}[k]; + } + auto before=row; + std::vector> counts(nt,{0,0,0}); + std::uint64_t steps=0; int pc=0; bool halt=false; + while(pc>=0 && steps<10000000000ULL) { + if(pc>=n)throw std::runtime_error("escaped graph"); + const auto &a=code[pc++];++steps; + if(a.op==0) { ++counts[a.tape][0]; pc=a.branch[row[a.tape][head[a.tape]]]; } + else if(a.op==1) { ++counts[a.tape][1]; row[a.tape][head[a.tape]]=a.value; } + else if(a.op==2) { + ++counts[a.tape][2]; auto &h=head[a.tape]; h+=a.value; + if(h<0 || h>=capacity)throw std::runtime_error("observer capacity exceeded"); + low[a.tape]=std::min(low[a.tape],h);high[a.tape]=std::max(high[a.tape],h); + } else if(a.op==3) pc=a.value; + else { halt=true;break; } + } + if(steps>=10000000000ULL)throw std::runtime_error("bounded observer budget"); + bool public_unchanged=row[0]==before[0] && row[1]==before[1]; + bool result=true; + if(expected_halt) { + if(expected.size()!=fields[1].size())throw std::runtime_error("wrong expected extent"); + for(std::size_t j=0;j=budget: raise ValueError('finite verifier budget') + self.step() + return self + +def initial_tapes(width,origins=(0,0,0),ancestor=('0','1','t0','_','|','0')): + if width<1: raise ValueError('positive width') + u,c,p=origins + return [Tape({u-1:MARK,**{u+i:ONE for i in range(width)}},u),Tape({c-1:MARK},c), + Tape({p-1:MARK,**{p-2-i:s for i,s in enumerate(ancestor) if s!=BLANK}},p)] diff --git a/research/literal-selected-linear-maps/linear.py b/research/literal-selected-linear-maps/linear.py new file mode 100644 index 0000000000..6aad40a6c4 --- /dev/null +++ b/research/literal-selected-linear-maps/linear.py @@ -0,0 +1,435 @@ +"""Literal selected nine-coordinate linear maps on a packed Gaussian field. + +Prepared for Jerry Chen / CubeJerry with substantial OpenAI assistance. +Apache-2.0. Split/merge, unary clocks and CNOT decomposition are credited +predecessor methods; this is their exact encoded all-column selected join. +""" +from pathlib import Path +import hashlib +import sys + +HERE = Path(__file__).resolve().parent +MACHINE = HERE/'inputs/controller_reference.py' +EXPECTED_MACHINE = 'e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73' +if hashlib.sha256(MACHINE.read_bytes()).hexdigest() != EXPECTED_MACHINE: + raise ValueError('frozen local machine source drift') +sys.path.insert(0, str(MACHINE.parent)) +from controller_reference import Builder, Machine, Tape, BLANK, ONE, MARK + +(HEADER, DATA, A, B, MODE, HTRACE, LENGTH, DOUBLE, F, R, P, S, WIDTH, + VOLUME, AUX, PREFIX, MIDDLE, BLOCK, LEFT, RIGHT, LOUT, ROUT, + Q0, Q1, Q2, Q3, DTRACE) = range(27) +PRIVATE = tuple(range(2, 27)) +BITS = ('0', ONE) +CHUNKS = (Q0, Q1, Q2, Q3) +MATRICES = { + 'right': (239,129,130,132,136,16,160,192,256), + 'left': (3,5,9,17,32,65,129,1,256), +} +DIMENSION = 9 + + +def cnot_word(rows): + """Fixed-data Gaussian elimination; no input header is consulted.""" + if len(rows) != DIMENSION or any(type(x) is not int or not 0 <= x < 1 << DIMENSION for x in rows): + raise ValueError('fixed nine-coordinate matrix') + choices = [] + for order in (range(DIMENSION), range(DIMENSION-1, -1, -1)): + a, eliminated, word = list(rows), set(), [] + def add(target, control): + a[target] ^= a[control] + word.append((target, control)) + for j in order: + if not (a[j] >> j) & 1: + candidates = [i for i in range(DIMENSION) if i not in eliminated and (a[i] >> j) & 1] + if not candidates: + raise ValueError('singular fixed matrix') + k = candidates[0] + add(j, k); add(k, j); add(j, k) + for i in range(DIMENSION): + if i != j and (a[i] >> j) & 1: + add(i, j) + eliminated.add(j) + if a != [1 << i for i in range(DIMENSION)]: + raise ValueError('fixed elimination invariant') + choices.append(tuple(reversed(word))) + return min(choices, key=lambda x: (len(x), x)) + + +def fresh(a, stem): + a.serial += 1 + return stem + str(a.serial) + '_' + + + +def clear(a, tape, symbols=(ONE,)): + k = fresh(a, 'clear') + a.mark(k) + a.op('read', tape, {s: k+'bit' for s in symbols} | {BLANK: k+'done'}) + a.mark(k+'bit') + a.op('write', tape, BLANK) + a.op('move', tape, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(tape, (BLANK,)) + + + +def unary_copy(a, source, target, *, repeat=1, extra=0, erase=False): + k = fresh(a, 'copy') + a.mark(k) + a.op('read', source, {ONE: k+'bit', BLANK: k+'done'}) + a.mark(k+'bit') + for _ in range(repeat): + a.op('write', target, ONE) + a.op('move', target, 1) + if erase: + a.op('write', source, BLANK) + a.op('move', source, 1) + a.op('goto', k) + a.mark(k+'done') + for _ in range(extra): + a.op('write', target, ONE) + a.op('move', target, 1) + a.rewind(source, (BLANK,) if erase else (ONE,)) + a.rewind(target, (ONE,)) + + + +def header_step(a): + a.op('write', HTRACE, ONE) + a.op('move', HTRACE, 1) + a.op('move', HEADER, 1) + + + +def gamma(a, target): + """Actual positive Gamma code to unary, using only literal operations.""" + k = fresh(a, 'gamma') + a.mark(k+'prefix') + a.op('read', HEADER, {'0': k+'zero', ONE: k+'one'}) + a.mark(k+'zero') + a.op('write', LENGTH, ONE) + a.op('move', LENGTH, 1) + header_step(a) + a.op('goto', k+'prefix') + a.mark(k+'one') + header_step(a) + a.op('write', target, ONE) + a.op('move', LENGTH, -1) + a.mark(k+'tail') + a.op('read', LENGTH, {ONE: k+'tailbit', MARK: k+'done'}) + a.mark(k+'tailbit') + a.op('write', LENGTH, BLANK) + a.op('read', HEADER, {str(b): k+'digit'+str(b) for b in (0, 1)}) + for b in (0, 1): + a.mark(k+'digit'+str(b)) + unary_copy(a, target, DOUBLE, repeat=2, extra=b) + clear(a, target) + unary_copy(a, DOUBLE, target, erase=True) + header_step(a) + a.op('move', LENGTH, -1) + a.op('goto', k+'tail') + a.mark(k+'done') + a.op('move', LENGTH, 1) + + + +def trace_return(a, tape, trace): + k = fresh(a, 'return') + a.op('move', trace, -1) + a.mark(k) + a.op('read', trace, {ONE: k+'bit', MARK: k+'done'}) + a.mark(k+'bit') + a.op('write', trace, BLANK) + a.op('move', trace, -1) + a.op('move', tape, -1) + a.op('goto', k) + a.mark(k+'done') + a.op('move', trace, 1) + + + +def double(a, tape): + unary_copy(a, tape, DOUBLE, repeat=2) + clear(a, tape) + unary_copy(a, DOUBLE, tape, erase=True) + + + +def halve(a, tape): + k = fresh(a, 'halve') + a.mark(k) + a.op('read', tape, {ONE: k+'first', BLANK: k+'done'}) + a.mark(k+'first') + a.op('write', tape, BLANK) + a.op('move', tape, 1) + a.op('read', tape, {ONE: k+'second', BLANK: 'reject'}) + a.mark(k+'second') + a.op('write', tape, BLANK) + a.op('move', tape, 1) + a.op('write', DOUBLE, ONE) + a.op('move', DOUBLE, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(tape, (BLANK,)) + a.rewind(DOUBLE, (ONE,)) + unary_copy(a, DOUBLE, tape, erase=True) + + + +def product(a, left, right, target): + k = fresh(a, 'product') + a.mark(k+'outer') + a.op('read', left, {ONE: k+'inner', BLANK: k+'done'}) + a.mark(k+'inner') + a.op('read', right, {ONE: k+'bit', BLANK: k+'row'}) + a.mark(k+'bit') + a.op('write', target, ONE) + a.op('move', target, 1) + a.op('move', right, 1) + a.op('goto', k+'inner') + a.mark(k+'row') + a.rewind(right, (ONE,)) + a.op('move', left, 1) + a.op('goto', k+'outer') + a.mark(k+'done') + a.rewind(left, (ONE,)) + a.rewind(target, (ONE,)) + + + +def emit_stream(a, source, target): + k = fresh(a, 'stream') + a.mark(k) + a.op('read', source, {str(b): k+str(b) for b in (0, 1)} | {BLANK: k+'done'}) + for bit in ('0', ONE): + a.mark(k+bit) + a.op('write', target, bit) + a.op('move', target, 1) + a.op('write', source, BLANK) + a.op('move', source, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(source, (BLANK,)) + + + +def commit(a, source): + k = fresh(a, 'commit') + a.mark(k) + a.op('read', source, {str(b): k+str(b) for b in (0, 1)} | {BLANK: k+'done'}) + for bit in ('0', ONE): + a.mark(k+bit) + a.op('write', DATA, bit) + a.op('write', source, BLANK) + a.op('move', source, 1) + a.op('move', DATA, 1) + a.op('write', DTRACE, ONE) + a.op('move', DTRACE, 1) + a.op('goto', k) + a.mark(k+'done') + trace_return(a, DATA, DTRACE) + a.rewind(source, (BLANK,)) + + + +def multiply_guide(a, target, factor): + product(a, target, factor, AUX) + clear(a, target) + unary_copy(a, AUX, target, erase=True) + + +def column_doublings(a, target, times): + """times is fixed construction data; the actual F loop survives.""" + k = fresh(a, 'column_double') + a.mark(k) + a.op('read', F, {ONE: k+'more', BLANK: k+'done'}) + a.mark(k+'more') + for _ in range(times): + double(a, target) + a.op('move', F, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(F, (ONE,)) + + +def volume(a): + unary_copy(a, P, VOLUME) + for factor in (R, S, WIDTH): + multiply_guide(a, VOLUME, factor) + column_doublings(a, VOLUME, DIMENSION) + double(a, VOLUME) + + +def geometry(a, high, low): + # At j=0: A=P*2^((high+1)f-1), M=2^((low-high)f-1), + # B=2wrS*2^((8-low)f). Temporary doubles are also paid. + unary_copy(a, P, PREFIX) + column_doublings(a, PREFIX, high+1) + halve(a, PREFIX) + a.op('write', MIDDLE, ONE) + column_doublings(a, MIDDLE, low-high) + halve(a, MIDDLE) + product(a, R, S, BLOCK) + multiply_guide(a, BLOCK, WIDTH) + double(a, BLOCK) + column_doublings(a, BLOCK, DIMENSION-1-low) + + +def clone(a): + k = fresh(a, 'clone') + a.mark(k) + a.op('read', VOLUME, {ONE: k+'read', BLANK: k+'done'}) + a.mark(k+'read') + a.op('read', DATA, {str(b): k+str(b) for b in (0, 1)}) + for bit in BITS: + a.mark(k+bit) + a.op('write', A, bit) + a.op('move', A, 1) + a.op('move', DATA, 1) + a.op('write', DTRACE, ONE) + a.op('move', DTRACE, 1) + a.op('move', VOLUME, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(VOLUME, (ONE,)) + a.op('read', DATA, {BLANK: k+'valid'}) + a.mark(k+'valid') + trace_return(a, DATA, DTRACE) + a.rewind(A, BITS) + + +def copy_block(a, source, target, *, return_target=False): + k = fresh(a, 'block_copy') + a.mark(k) + a.op('read', BLOCK, {ONE: k+'read', BLANK: k+'done'}) + a.mark(k+'read') + a.op('read', source, {str(b): k+str(b) for b in (0, 1)}) + for bit in BITS: + a.mark(k+bit) + a.op('write', target, bit) + a.op('move', target, 1) + a.op('write', source, BLANK) + a.op('move', source, 1) + a.op('move', BLOCK, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(BLOCK, (ONE,)) + if return_target: + a.rewind(target, BITS) + + +def load_half(a, source, target): + k = fresh(a, 'half') + a.mark(k) + a.op('read', MIDDLE, {ONE: k+'two', BLANK: k+'done'}) + a.mark(k+'two') + for _ in range(2): + copy_block(a, source, target) + a.op('move', MIDDLE, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(MIDDLE, (ONE,)) + a.rewind(target, BITS) + + +def cnot_columns(a, target, control): + """All encoded F columns of one fixed CNOT, both physical directions.""" + high, low = min(target, control), max(target, control) + permutation = (0, 1, 3, 2) if control == high else (0, 3, 2, 1) + geometry(a, high, low) + k = fresh(a, 'cnot') + a.mark(k+'prefix') + a.op('read', PREFIX, {ONE: k+'load_select', BLANK: k+'end'}) + a.mark(k+'load_select') + a.op('read', MODE, {'0': k+'loadA', ONE: k+'loadB'}) + for source, label in ((A, 'A'), (B, 'B')): + a.mark(k+'load'+label) + load_half(a, source, LEFT) + load_half(a, source, RIGHT) + a.op('goto', k+'middle') + a.mark(k+'middle') + a.op('read', MIDDLE, {ONE: k+'chunks', BLANK: k+'middle_done'}) + a.mark(k+'chunks') + for source, chunk in ((LEFT, Q0), (LEFT, Q1), (RIGHT, Q2), (RIGHT, Q3)): + copy_block(a, source, chunk, return_target=True) + for i, index in enumerate(permutation): + emit_stream(a, CHUNKS[index], LOUT if i < 2 else ROUT) + a.op('move', MIDDLE, 1) + a.op('goto', k+'middle') + a.mark(k+'middle_done') + a.rewind(MIDDLE, (ONE,)) + for tape in (LEFT, RIGHT): + a.rewind(tape, (BLANK,)) + for tape in (LOUT, ROUT): + a.rewind(tape, BITS) + a.op('read', MODE, {'0': k+'mergeB', ONE: k+'mergeA'}) + for label, destination in (('mergeB', B), ('mergeA', A)): + a.mark(k+label) + emit_stream(a, LOUT, destination) + emit_stream(a, ROUT, destination) + a.op('goto', k+'prefix_done') + a.mark(k+'prefix_done') + a.op('move', PREFIX, 1) + a.op('goto', k+'prefix') + a.mark(k+'end') + a.op('read', MODE, {'0': k+'endA', ONE: k+'endB'}) + for mode, source, destination in ((0, A, B), (1, B, A)): + label = k+'end'+('A' if mode == 0 else 'B') + a.mark(label) + a.op('read', source, {BLANK: label+'valid'}) + a.mark(label+'valid') + a.rewind(source, (BLANK,)) + a.rewind(destination, BITS) + a.op('write', MODE, str(1-mode)) + a.op('goto', k+'column_done') + a.mark(k+'column_done') + a.rewind(PREFIX, (ONE,)) + a.op('move', F, 1) + a.op('read', F, {ONE: k+'next_column', BLANK: k+'finished'}) + a.mark(k+'next_column') + double(a, BLOCK) + halve(a, PREFIX) + a.op('goto', k+'prefix') + a.mark(k+'finished') + a.rewind(F, (ONE,)) + for tape in (PREFIX, MIDDLE, BLOCK): + clear(a, tape) + + +def compile_linear(side): + """side is fixed construction data: exactly 'left' or 'right'.""" + if side not in MATRICES: + raise ValueError('one of the two selected fixed linear maps is required') + word = cnot_word(MATRICES[side]) + a = Builder() + for tape in PRIVATE: + a.op('move', tape, -1) + a.op('write', tape, MARK) + a.op('move', tape, 1) + for target in (F, R, P, S, WIDTH): + gamma(a, target) + trace_return(a, HEADER, HTRACE) + volume(a) + clone(a) + a.op('write', MODE, '0') + for target, control in word: + cnot_columns(a, target, control) + a.op('read', MODE, {'0': 'commitA', ONE: 'commitB'}) + for label, source in (('commitA', A), ('commitB', B)): + a.mark(label) + commit(a, source) + a.op('goto', 'retire') + a.mark('retire') + for tape in (F, R, P, S, WIDTH, VOLUME): + clear(a, tape) + clear(a, MODE, BITS) + for tape in PRIVATE: + a.op('move', tape, -1) + a.op('write', tape, BLANK) + a.op('move', tape, 1) + a.op('halt') + a.mark('reject') + a.op('read', HEADER, {}) + return a.finish((BLANK, '0', ONE, MARK)) diff --git a/research/literal-selected-linear-maps/reference/C4-table-cpu.cpp b/research/literal-selected-linear-maps/reference/C4-table-cpu.cpp new file mode 100644 index 0000000000..1e3a9c427f --- /dev/null +++ b/research/literal-selected-linear-maps/reference/C4-table-cpu.cpp @@ -0,0 +1,90 @@ +// Dense interpreter for the literal table; observer fields never feed control. +// Prepared for Jerry Chen / CubeJerry with substantial OpenAI assistance. +// Apache-2.0. This is test infrastructure, not the mathematical tape program. +#include +#include +#include +#include +#include +#include +#include +#include + +struct Instruction { int op, tape, value; std::array next; }; +int symbol(char c) { + if(c=='_') return 0; if(c=='0') return 1; + if(c=='1') return 2; if(c=='|') return 3; + throw std::runtime_error("fixture symbol"); +} + +int main(int argc,char**argv) { + try { + if(argc!=4) throw std::runtime_error("table, packet, output required"); + std::ifstream table(argv[1]), packet(argv[2]); + int count; table>>count; + std::vector code(count); + for(auto &i:code) table>>i.op>>i.tape>>i.value>>i.next[0]>>i.next[1]>>i.next[2]>>i.next[3]; + if(!table) throw std::runtime_error("table parse"); + std::array origin,head,cap,low,high; + std::array,29> row; + std::array writes{}; + for(auto &n:origin) packet>>n; + for(auto &n:cap) packet>>n; + std::string header,data; packet>>header>>data; + if(!packet) throw std::runtime_error("packet parse"); + for(int t=0;t<29;++t) { + head[t]=low[t]=high[t]=origin[t]; + row[t].assign(origin[t]+cap[t]+3,0); + row[t][origin[t]-3]=2; row[t][origin[t]-2]=3; + if(t<2) row[t][origin[t]-1]=2; + row[t][origin[t]+cap[t]+1]=1; row[t][origin[t]+cap[t]+2]=3; + } + for(size_t j=0;j=count) throw std::runtime_error("pc range"); + if(++steps>4000000000ULL) throw std::runtime_error("test instruction cap"); + const auto &i=code[pc++]; + switch(i.op) { + case 0: pc=i.next[row[i.tape][head[i.tape]]]; if(pc<0) rejected=true; break; + case 1: row[i.tape][head[i.tape]]=i.value; ++writes[i.tape]; break; + case 2: + head[i.tape]+=i.value; + low[i.tape]=std::min(low[i.tape],head[i.tape]); + high[i.tape]=std::max(high[i.tape],head[i.tape]); + if(head[i.tape]=2) || + head[i.tape]>origin[i.tape]+cap[i.tape]) throw std::runtime_error("proved visit cap escaped"); + break; + case 3: pc=i.value; break; + case 4: accepted=true; break; + default: throw std::runtime_error("opcode"); + } + } + bool returned=true,clean=true,exterior=true; + uint64_t history=0; + for(int t=0;t<29;++t) { + returned=returned && head[t]==origin[t]; + exterior=exterior && row[t][origin[t]-3]==2 && row[t][origin[t]-2]==3; + if(t<2) exterior=exterior && row[t][origin[t]-1]==2; + exterior=exterior && row[t][origin[t]+cap[t]+1]==1 && row[t][origin[t]+cap[t]+2]==3; + if(t>=2) { + history+=high[t]-low[t]+1; + for(int j=origin[t]-1;j<=origin[t]+cap[t];++j) clean=clean && row[t][j]==0; + } + } + std::ofstream output(argv[3],std::ios::binary); + const char*alphabet="_01|"; + for(size_t j=0;j>i)&1)<>j&1);a[j],a[k]=a[k],a[j] + for i in range(n): + if i!=j and a[i]>>j&1:a[i]^=a[j] + assert [r&((1<>n for r in a) +def basis_extend(cols,n): + out=[] + for x in list(cols)+[1<len(out):out.append(x) + assert len(out)==n + return tuple(out) +def nullspace(rows,n): + a=list(rows);p=[];k=0 + for j in range(n): + t=next((i for i in range(k,len(a)) if a[i]>>j&1),None) + if t is None:continue + a[t],a[k]=a[k],a[t] + for i in range(len(a)): + if i!=k and a[i]>>j&1:a[i]^=a[k] + p.append(j);k+=1 + return tuple((1<>j)&1)<>i&1:out=pmul(out,T[i]) + for i in range(n): + if z>>i&1:out=pmul(out,T[n+i]) + return out +def compose(A,B):return tuple(apply(A,p) for p in B) +def inverse(T): + n=len(T)//2;cols=[x|(z<>n;u,v,p=apply(T,(x,z,0));assert (u,v)==identity(n)[j][:2];out.append((x,z,(-p)%4)) + return tuple(out) +def qvalue(Q,alpha,x,n): + return (sum(alpha[i] for i in range(n) if x>>i&1)+2*sum(parity((Q[i]>>(i+1))&(x>>(i+1))) for i in range(n) if x>>i&1))%4 +def mul_i(a,p): + x,y=a;p%=4 + return [(x,y),(-y,x),(-x,-y),(y,-x)][p] +@dataclass +class Op: + n:int + tab:tuple + circuit:list + def then(self,b): + assert self.n==b.n + return Op(self.n,compose(b.tab,self.tab),self.circuit+b.circuit) + def adjoint(self): + circ=[] + for e in reversed(self.circuit): + if e[0]=='P':circ.append(('P',inv(e[1],self.n))) + elif e[0]=='D':circ.append(('D',e[1],tuple((-x)%4 for x in e[2]))) + elif e[0]=='C':circ.append(('C',e[1],-e[2])) + elif e[0]=='phase':circ.append(('phase',(-e[1])%4)) + else:circ.append(e) + return Op(self.n,inverse(self.tab),circ) + def zero_state(self,basis=0): + N=1<>i)&1 for i in range(n)) + assert all(alpha[i]%2==(Q[i]>>i)&1 for i in range(n)) + return Op(n,tuple([(1<>i&1 else 0,1<>i&1 else 0) for i in range(n)]),[('C',q,sgn)]) +def xgate(n,b):return Op(n,tuple([(1<>i)&1)) for i in range(n)]),[('X',b)]) +def fourier(n,axes=None): + out=ident(n) + for i in range(n) if axes is None else axes:out=out.then(cgate(n,1<len(selected):picks.append(j);selected.append(x) + assert len(picks)==r and all(x>>r==0 for x in Bcols) + Br=transpose(selected,r);Bi=inv(Br,r);Dr=transpose([Dcols[j]&((1<=2, its exact record delimiters and common quantum, supplied +local LEFT markers and aligned origins, and actually disjoint public, context +and private segments. Current private prefixes start physically blank; previous +erased backing remains allocated. These are caller premises, not inferred +from object identity or a short fixture. + +Let a valid parent monomial descriptor have fixed recipe rank m, positive f,K, +0<=rho=A1^6 and (E+1)^4+Q=O(V), this is F_template+O_m(fV). +The larger displayed bill remains if either absorption condition fails. + +This can match a direct PAID-leaf budget when a separate global cutoff admits +the complete source construction, including rf<=cutoff for a rank-r leaf. +No such cutoff, compiled stock/precision substitution, new supplier rate or +assembled kappa is established here. + +## 4. Strict numerical-domain distinction and rejection + +Phases act as signed permutations of the real/imaginary components. Strict +symmetric component headroom is invariant under every such phase and address +permutation, proving all intermediate representability in the sufficient +domain. The unchanged common grid needs no extra arithmetic rounding. + +The original combined-phase admission does not suffice. For a constant-phase-2 +monomial with f=2, the tensor phase is +1, so a most-negative h-bit component +can pass the batched phase. The first serialized column multiplies it by -1, +which cannot fit. Thus the two acceptance domains are provably different. +For the actual selected right recipe, whose constant is1, f=4 and an input +supported on the all-zero selected bits similarly has combined phase +1; +serial quarter rotations can expose an unrepresentable intermediate negation. +This caveat was found by the separate native worker's adversarial review. + +Each retained one-column call preserves its input on its named arithmetic +rejection. Earlier completed columns can nevertheless have changed the serial +field. SerialProvider therefore has no whole-job rollback guarantee. A full +protected stage, such as the separately published atomic MOVE wrapper, must +pay transfer/commit/retirement to obtain that property. No interruption or +malformed-success rollback is claimed. + +Global native source correctness, the full compiler placement, ownership, +precision and analytic multiplication assumptions remain. Finite witnesses +do not discharge those universal premises, and no accepted certificate changes. diff --git a/research/literal-selected-linear-maps/reference/fixed-tape-affine-shear--PROOF.md b/research/literal-selected-linear-maps/reference/fixed-tape-affine-shear--PROOF.md new file mode 100644 index 0000000000..3b2e34e6ee --- /dev/null +++ b/research/literal-selected-linear-maps/reference/fixed-tape-affine-shear--PROOF.md @@ -0,0 +1,199 @@ +# Literal runtime affine shear and its source half-coefficient leaf + +This is an algorithmic proof for the supplied finite programs. It is not a +proof-kernel result, a native operator proof or a complete supplier admission. +The split/merge idea and the local machine/counter/copy macros are David Arias's +PR2776. Charles Bethin's unit-carry kernel is the closest fixed-carry successor. +The new feature is an arbitrary **runtime** coefficient and offset, with their +complete conversion, wrap, reset and cleanup costs. + +## Contract and fixed machine + +For every positive integer `P,Q,G,S` and `0<=c,C (p,x,g, y +/- (c*x+C) mod Q, z). +``` + +The total cost, including descriptor conversion, all carries, rewinds and +cleanup, is at most `1024V` transitions and `64V` visited tape cells. The space +bill includes visited cells subsequently cleared; it is not a final live-space +count. Invalid inputs need not be cleaned up on rejection. This is a valid-input +contract; inspecting one initial cell does not certify an otherwise unbounded +scratch tape is empty. + +## Split invariant and termination + +PR2776's retained binary-to-unary macro preserves its canonical input and +returns its work tape blank. Convert seven values: `P,Q,G,S,Q,c+1,C+1`. +The second Q copy is a genuine independent x-traversal counter. Remove one +unary mark from each last counter, and compare each with the Q counter to +reject `c>=Q` or `C>=Q`. These comparisons are literal finite loops. + +At a boundary the two split tapes have lengths `(L,R)=(Q-r,r)` with `0<=r r+1 mod Q`. The transient `(0,Q)` is reset before any payload. +Initialization advances by C. At the start of the x-th group, therefore, + +``` +r = C + c*x mod Q, (L,R) = (Q-r,r). +``` + +For every gap g, gather the first L source records into A and the remaining R +into B; a record has S opaque bits. Advance the split by exactly c mark transfers +and advance the **separate** Q counter once. This works for zero and nonunit c: +traversal does not depend on the order or period of the offsets. After Q groups, +`C+cQ = C mod Q`, so no prefix reset or reconstructed coefficient is needed. +The same invariant applies to each next prefix and to the emission pass. + +Forward emission consumes B's next R records, then A's next L. This moves each +source y to y+r modulo Q. Inverse compilation reverses the two gather segments +and the two emission segments: it gathers R then L and emits L then R, giving +`y-r`. Both are permutations for **every** c; c need not be a unit because x is +preserved. Every copied bucket cell is consumed exactly once. Rewinds preserve +source and descriptors. The retained eraser clears each private region back +through its temporary LEFT origin marker and returns that head to its origin. + +All loops use finite positive unary counters or finite segments. Each x iteration +finishes c transfers; each wrap finishes Q transfers; P,Q,G,S are finite. This +proves termination and all endpoints for every permitted shape and payload. +Finite coefficient grids corroborate this argument; they do not replace it. + +## Complete uniform transition ledger + +The retained positive conversion takes +`24n - 7 popcount(n) + 15 bit_length(n) + 12 <= 44n` transitions. +A rewind from a right marker after h symbols costs `3h+3`; scanning/deleting one +unary suffix marker uses the actual local instructions in the retained source. +The following conservative blocks are upper bounds obtained by summing those +instructions. Every extent monomial displayed is at most V. + +| Executed block | Transition bound | +|---|---:| +| Initialize output and eleven private marked tapes | `36 <= 36V` | +| Seven conversions | `44(P+G+S+2Q+c+C+2) <= 308V` | +| Decode c+1,C+1 by one-mark removal | `6c+6C+22 <= 22Q <= 22V` | +| Two strict coefficient/Q comparisons, including rewinds | `11c+11C+22 <= 22Q <= 22V` | +| Initialize the split and advance C (no wrap) | `14C+3Q+6 <= 17Q <= 17V` | +| Two payload/traversal phases, excluding coefficient advancement | `23V+20PQ^2G+28PQG+20PQ+20P+8 <= 119V` | +| All coefficient advancements and cyclic resets in both phases | `2P[Q(17c+4)+c(10Q+3)] <= 54PQ^2 <= 54V` | +| Finish gather and rewind both buckets | `3V+9 <= 12V` | +| Finish output, source/output rewinds and all eleven complete erasures | `<=111V` | +| Final halt | `1 <= V` | + +Their sum is at most `802V`, below the stated `1024V` allowance. + +For the phase row, one record copy costs at most `(11+consume)S+4`, and a segment +of length l costs at most `(11+consume)Sl+10l+4`, including its length rewind. +The two segment lengths sum to Q regardless of gcd(c,Q). Summing the actual +P/x/G loop branches and unit moves gives the displayed two-phase polynomial. +No uniform distribution of offsets is used in this bound. + +For the advancement row, a coefficient rewind costs at most `3c+3`; c ordinary +transfers plus loop tests cost at most `14c+1`. Each cyclic reset adds at most +`10Q+3`. Across all Q x-groups at one prefix there are exactly c resets, since +the total advance is cQ starting at C=1`, the complete high fields have common extent `Q=q^e`, and + +``` +2 * ((Q+1)/2) = Q+1 = 1 mod Q. +``` + +Thus the runtime multiplier is c=(Q+1)/2. The negative half leaf is the inverse +program. This grows with e; treating the rational factor as a fixed number of +unit shears would be an invalid uniform-time argument. + +The complete linked half program includes a **literal** preparer on the same +nineteen-tape bank. It checks that Q's low bit is one and at least one further +bit exists, copies the remaining bits into an owned blank coefficient tape, +then performs a ripple increment beginning at its second bit. The copied +integer is floor(Q/2); the result is `floor(Q/2)+2=(Q+3)/2=c+1`. The final +high-bit check enforces canonical encoding. It returns Q and both input heads. +After the generic kernel, a literal scan erases every coefficient bit and its +markers, returning its tape to its original blank origin. These tables are +retained in TABLE.json.gz together with the generic programs; linking adjusts +only finite state destinations, not runtime addresses. + +Preparation costs at most `40 bit_length(Q)+80 <= 67Q` for Q>=3. Complete owned +descriptor erasure costs at most `8 bit_length(Q)+8 <= 11Q`. Their tape cells +already lie within the generic space ledger. The linked half call therefore +costs less than `880V`, still within `1024V` and `64V`, including preparation and +cleanup. General c,C are supplied descriptors; preparing arbitrary rational +coefficients from a caller is not made free by this half-specific construction. +The offset descriptor is C+1=1 for this actual source leaf and is preserved. + +For an actual complete source packet, group every coordinate before source0 as +P, those between source0 and target3 as G, and those after target3 as S. Their +extents may be enormous; the proof quantifies over them. No sorting, random +access, hidden high-coordinate lookup or ordinary interchange is used. This +binds the later-target half leaf on the complete-high-fiber interface. The +finite executed fixtures compress these spectator dimensions and do not +materialize the full source high matrix or prove the whole native invocation. +Other later-target +/-1 and +/-1/2 slots have the same interface; no claim about +reversed-field slots or unit_scale is implied. + +## Remaining obligations and decision + +This closes one physically priced ordered-affine primitive with a source-bound +half descriptor. It does not construct PR4989's complete low-type cache, native +canonical call, raw-body call, completed ordinary swap, ROW padding or the full +compiled matcher. Installation in the whole recursive owner bank, matched +physical tape allocation, reserve/precision/threshold constants and the P3 +recurrence remain open. Output/source separation is explicit; replacing the +source owner by the output or erasing that original source needs the caller's +paid ownership protocol. No selected frontier or multiplication exponent is +changed. Continue only after one of those separate contracts is selected and +its complete allowance is stated; another small coefficient fixture is not a +new contribution. diff --git a/research/literal-selected-linear-maps/reference/fixed-tape-ordered-shear--PROOF.md b/research/literal-selected-linear-maps/reference/fixed-tape-ordered-shear--PROOF.md new file mode 100644 index 0000000000..967eaeb4a1 --- /dev/null +++ b/research/literal-selected-linear-maps/reference/fixed-tape-ordered-shear--PROOF.md @@ -0,0 +1,267 @@ +# A literal fixed-tape ordered shear at every extent + +## Statement and exact boundary + +For each direction `s ∈ {−1,+1}`, one fixed finite-control machine accepts four +positive canonical LSB-first binary integers `P,Q,G,S` and an arbitrary Boolean +stream in lexicographic `(p,x,g,y,z)` order, with + +``` +0 <= p < P, 0 <= x,y < Q, 0 <= g < G, 0 <= z < S. +V = P Q² G S. +``` + +It returns an owned output stream whose bit originally at `(p,x,g,y,z)` is at +`(p,x,g,(y+s*x) mod Q,z)`. The source and four binary descriptors are unchanged. +All temporary payload, unary counters and conversion work are erased, including +their installed markers. Every input head returns to its first encoded cell; +every scratch head returns to its original blank origin. The output starts +blank at its origin and finishes marked, with its head at its first bit. +Additional tapes are untouched. The program and physical tape count are +independent of `P,Q,G,S`, including arbitrarily long spectator dimensions `P,G,S`. +No ordinary-swap oracle, variable-size machine state or precomputed operation +trace is provided to the running controller. + +This is a physical implementation of one already-known ordered-affine operation. +It is not a new algebraic routing lemma. In the exact selected source +`research/selected-bit-stream-routes/qadic_streams.py`, this is `add_high` with +`c=s`, zero carry, `before=P`, `middle=G`, `suffix=S`, `high=Q` and +`reversed_fields=False`. For `Q=1`, both functions are the identity on values; +the new machine still returns an independently owned output. The ordinary +interchange oracle in that predecessor is not invoked in this specialization. + +The source's `rotate_fibers` explains the split/merge method; its README states +that the payload meter omits Python arithmetic, erasure and some head returns. +The contribution here is the literal finite controller and its complete +physical accounting. Generic ordered-affine routing, fixed arithmetic and +fixed-tape stream arguments retain their upstream authorship. The source +identities and review boundary are pinned in SOURCES.json. + +## Machine model and finite compilation + +`machine.py` defines the finite instruction forms: branch on one scanned symbol, +write one symbol at one head, move one head by ±1, jump to a fixed instruction, +halt, and reject. Only fixed tape numbers and finite instruction labels appear +in the compiled program. A branch has one destination for each listed alphabet +symbol and a fixed default. No instruction reads an integer head index, stream +length, simulation counter, Python list, callback or arithmetic expression. + +Each instruction is directly one transition of a conventional multitape +machine: unused heads stay still, unchanged symbols are copied through, and a +branch's observed symbol determines the next finite state. A jump is a stay +transition. There is no RAM simulation or `log V` overhead. The interpreter's +integer coordinates, sparse maps, step limit and resource statistics describe +the external simulation; the program has no instruction that observes them. +The separate dense interpreter reads the serialized table and implements the +same local transitions without importing the producer. + +The assembler runs before the input exists. It resolves a finite set of labels +and expands fixed macros. `build_program(inverse=False)` and +`build_program(inverse=True)` each produce **531 instructions on fourteen +tapes**, over the fixed seven-symbol alphabet +`BLANK, LEFT, RIGHT, ZERO, ONE, UNIT, MARK`. The last symbol is reserved and not +used on a valid execution. The only assembler parameter is this Boolean choice; +it does not accept runtime dimensions. TABLE.json contains the entire compiled +programs and is compared exactly to regeneration. Table size is independent of +the largest fixture or any theorem parameter. + +Input descriptors and payload are supplied as standard marked strings, with +heads at their first cell. This is the input encoding, not free computation of +unary counts or a routing trace. Scratch tapes begin blank at the specified +origin. The machine installs and removes its own work markers. Valid-input +correctness assumes the declared payload has exactly V bits; incomplete streams, +noncanonical descriptors and occupied work cells are rejection controls, not +proof that the machine recognizes every malformed global input before writing. + +## Binary descriptor preparation + +The finite setup macro copies each canonical positive binary descriptor to a +single reusable work tape. A finite state remembers the last input bit and +requires that it is one at the right delimiter; this rejects zero, an empty +word and a redundant high zero. The original input is then rewound unchanged. + +The work copy is decremented in place, with one unary mark appended per positive +countdown value. A borrow scans low zeroes, turns them into ones, and clears the +first one. When that one was the most significant bit, the right delimiter +moves left. At a power of two, the remaining low bits are all one; consequently +the representation stays canonical. At one, the final delimiter is erased and +the macro ends. A full zero test is never performed per iteration. + +Let `L=bit_length(N)` and `pop(N)` be the number of ones. Across `N` decrements, + +``` +sum_{k=1}^N v2(k) = N − pop(N). +``` + +For the emitted instruction schedule the exact cost, excluding caller marker +installation and the final halt, is + +``` +c(N) = 24N − 7 pop(N) + 15L + 12 <= 44N. (1) +``` + +To derive it, the initial copy and two rewinds cost `12L+10`; borrow/decrement +paths cost `7 sum v2(k)+14N+3(L−1)`; final cleanup and unary rewind add `3N+5`. +The resulting unary word has N marks followed by a right delimiter, and the +conversion work is empty. These are counts of the actual emitted branch, +write, move and jump instructions, not fitted timing coefficients. Finite +counter tests independently exercise power-of-two shrink boundaries and the +exact formula. + +Thus preparing all four extents costs at most +`44(P+Q+G+S) <= 176V`: indeed `L<=N` and `pop(N)>=1` give +`c(N)<=39N+5<=44N`. This estimate holds for all positive extents, including +huge `P`, `G` or `S`. No spectator logarithm is multiplied into each payload +bit. The unary input expansion consumes space linear in V and is part of the +construction, not an assumed external descriptor service. + +## Ordered split and merge + +For fixed `(p,x,g)`, the target fibre consists of Q consecutive blocks of S +bits. In the forward direction, append its first `Q−x` blocks to A and its +last x blocks to B. Do this for every prefix in its original order. Rewind +A and B. For each identical prefix, emit x blocks from B and then `Q−x` +blocks from A. Each piece keeps its internal bit order. + +An old target coordinate `y=Q−x` appears at `y+x−Q`. Both are `(y+x) mod Q`. Each bucket holds +its successive prefix pieces in precisely the order used to consume them; +there is no random access or cross-prefix mixing. This argument holds for +arbitrary bit values, not merely for the tested payloads. + +The inverse splits after x blocks and emits the second piece first. Its +output coordinate is `(y−x) mod Q`. Therefore the two machines are mutual +inverses on stream values. The source-preserving ownership convention means +that a caller must release an unwanted copy; that release is a separately +linear scan, not a claim that duplicated source storage disappears for free. + +Two unary tracks encode the lengths `L=Q−x` and `R=x`. Their heads are at their +right delimiters between fibres. Initially they contain Q and zero marks. +After all G fibres for one x, the controller deletes one mark from L and adds +one to R, using their current end positions. It detects the final x iteration +by the LEFT marker immediately before the new, empty L delimiter. It then +transfers the Q marks back from R to L, restoring `(Q,0)` for the next p. +Every old delimiter beyond the new end is erased during these transfers. +Thus no numeric x value or comparison of head positions is needed. + +P, G and S are separate unary loops. Their positions and limits are physical +tape data. The L/R tracks control the two pieces in both complete phases; +empty halves at x=0 and Q=1 take the same delimiter branches. There is no +division or host-language runtime counter. + +Loop induction gives the prefix invariant: before each fibre, source and +bucket heads identify its next unconsumed piece, the P/G positions and L/R +lengths encode the current prefix, and all unary delimiters are intact. Before +each record, the S track is rewound; the inner loop then copies exactly S bits +and stops at its right delimiter. The L/R and G delimiter branches advance the +next enclosing position. The finite reset paths reestablish this invariant +for the next fibre and, after the final prefix, leave every bucket consumed. + +## Full physical cost and workspace + +All instructions, including branches and fixed jumps, are charged. A rewind +from relative head position h costs exactly `3h` transitions. A record copy +with an S-track initially at its right delimiter costs +`(11+consume)S+4`, where `consume` is zero during gathering and one during +emission. The very first record instead starts with the S head at one, saving +exactly `3S`. The remaining length-loop overhead for a segment of l records is +`6l+4`. These facts follow directly by counting the emitted instruction paths; +both bit values have paths of equal length. + +The two complete phases have this exact ledger: + +| Part | Transitions, summed over both phases | +| --- | ---: | +| Record copies and S rewinds | `23V + 8P Q²G − 3S` | +| L/R segment-loop overhead | `12P Q²G + 16PQG` | +| G rewinds and G-loop overhead | `12PQG + 8PQ − 3G` | +| P rewinds and P delimiter tests | `5P + 8` | +| L/R unit transfers, resets and enclosing advances | `42PQ + 10P` | + +Their sum is + +``` +23V + 20P Q²G + 28PQG + 50PQ + 15P − 3S − 3G + 8. +``` + +Marker installation, initial L traversal, full-source and bucket checks, +bucket rewinds, output termination, final source/output rewinds, scratch +erasure and halt cost a further +`13V + 4(P+G+S) + 7Q + 96`. Adding the four conversions gives the exact +all-input running time, in either direction: + +``` +T = c(P)+c(Q)+c(G)+c(S) + 36V + 20P Q²G + 28PQG + + 50PQ + 19P + 7Q + G + S + 104 + <= 442V. (2) +``` + +Every positive monomial and extent in (2) is at most V, as is one. Equation +(1) bounds the conversion sum by `176V`. Summing the displayed coefficients +therefore proves (2), with equality at `P=Q=G=S=1`, where the machine takes +442 transitions. This is an exact instruction-count argument, not an +empirical extrapolation. In particular, an arbitrarily large P or G does not +create a `log P` or `log G` charge per payload bit. + +For space, count every cell between the origin and the furthest visited +position on each physical tape, even after its contents are erased. Put +`ell_N=bit_length(N)`. The fourteen tapes have these full-execution spans: + +| Tapes | Total visited span | +| --- | ---: | +| Preserved source and owned output | `2V+4` | +| A and B split streams | `V+4` | +| Unary P, G and S | `P+G+S+6` | +| Unary L and R | `2Q+4` | +| Reused binary conversion work | `max ell_N+2` | +| Four preserved binary descriptors | `sum ell_N+8` | + +Thus the total is exactly + +``` +3V + P+G+S+2Q + max ell_N + sum ell_N + 28 <= 41V. (3) +``` + +No head visits a position below its own origin. The elementary inequalities +`ell_N<=N<=V` prove the last bound; equality again holds at the smallest +instance. The same bound covers every execution prefix, including blanked +but still visited bucket regions. Fourteen heads and the fixed finite control +are constant additional machine resources. Translating any tape's origin +changes neither (2) nor (3). + +The source remains owned by the caller; the output is a distinct owned stream. +Gathering stores at most V bucket bits. Emission erases each consumed bit +immediately after writing it, so the total number of nonblank payload cells +on source, output and buckets is at most `2V+1`, including that single-copy +transition. This sharper observation is not substituted for the visited-span +bound. The final cleanup visits every unary/split tail through its origin, +erases its marker and leaves its head at that origin. The conversion tape was +already empty except for its marker and is cleaned in the same manner. Source +and descriptor markers remain unchanged; the marked output is rewound to its +first bit. No data-dependent collection of tapes, parked stack or allocator +is part of this operation. + +## What remains open + +This theorem discharges physical unit ordered shears, including arbitrary +spectator sizes, a source-preserving inverse, setup and scratch cleanup. It +leaves nonzero/data-dependent carries, rational scaling, reversed-field +interchange, complete selected owner routing, recursive role allocation, +ordinary leaf/bootstrap substitution and the stronger H2 time recurrence +outside its scope. It does not change any child histogram, selected κ, +precision assumption, complex supplier or analytic transfer theorem. + +A fixed integer multiple of the unit shear follows by finitely many passes, +with its coefficient-dependent constant and intermediate copies charged. +This observation does not make a runtime-sized coefficient or rational +denominator free. No complete such caller is supplied here. + +The all-size claims above rest on the algorithmic loop and step-count proofs. +The independently interpreted finite executions, source comparisons and +mutation controls provide implementation evidence, not a proof-assistant +verification of that induction or of the multiplication theorem. + +Credit: the upstream ordered-affine stream lemma and Jose Manuel's selected +stream reduction supply the method and interface. The fixed controller and +checks are new work for David Arias with substantial OpenAI Codex assistance. +New work is Apache-2.0. diff --git a/research/literal-selected-linear-maps/reference/leaf-patterns.py b/research/literal-selected-linear-maps/reference/leaf-patterns.py new file mode 100644 index 0000000000..bdcc80cbd8 --- /dev/null +++ b/research/literal-selected-linear-maps/reference/leaf-patterns.py @@ -0,0 +1,564 @@ +"""Literal positive rank-one Gaussian C tensor leaf on a packed m=9 field. + +Prepared for Jerry Chen / CubeJerry with substantial OpenAI assistance. +Apache-2.0. C arithmetic and tensor algebra are credited #3091 predecessors. +Only fixed local instructions execute; encoded inputs do not specialize code. +""" +from pathlib import Path +import hashlib +import sys + +HERE = Path(__file__).resolve().parent +MACHINE = HERE / 'inputs' / 'controller_reference.py' +EXPECTED_MACHINE = 'e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73' +if hashlib.sha256(MACHINE.read_bytes()).hexdigest() != EXPECTED_MACHINE: + raise ValueError('frozen literal machine source drift') +sys.path.insert(0, str(MACHINE.parent)) +from controller_reference import Builder, Machine, Tape, BLANK, ONE, MARK + +(HEADER, DATA, A, B, MODE, HTRACE, LENGTH, DOUBLE, F, R, P, S, WIDTH, + FBIN, FLEN, TBIN, TLEN, PREFIX, SUFFIX, LEFT, RIGHT, LOUT, ROUT, + AR, AI, BR, BI, NUM, DTRACE) = range(29) +PRIVATE = tuple(range(2, 29)) +BITS = ('0', ONE) +INPUTS = (AR, AI, BR, BI) +ROWS = ((1, -1, 1, 1), (1, 1, -1, 1), + (1, 1, 1, -1), (-1, 1, 1, 1)) +NATIVE_DIMENSION = 9 + + +def fresh(a, stem): + a.serial += 1 + return stem + str(a.serial) + + +def clear(a, tape, symbols=(ONE,)): + k = fresh(a, 'clear') + a.mark(k) + a.op('read', tape, {s: k+'bit' for s in symbols} | {BLANK: k+'done'}) + a.mark(k+'bit') + a.op('write', tape, BLANK) + a.op('move', tape, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(tape, (BLANK,)) + + +def unary_copy(a, source, target, *, repeat=1, extra=0, erase=False): + k = fresh(a, 'copy') + a.mark(k) + a.op('read', source, {ONE: k+'bit', BLANK: k+'done'}) + a.mark(k+'bit') + for _ in range(repeat): + a.op('write', target, ONE) + a.op('move', target, 1) + if erase: + a.op('write', source, BLANK) + a.op('move', source, 1) + a.op('goto', k) + a.mark(k+'done') + for _ in range(extra): + a.op('write', target, ONE) + a.op('move', target, 1) + a.rewind(source, (BLANK,) if erase else (ONE,)) + a.rewind(target, (ONE,)) + + +def trace_return(a, tape, trace): + k = fresh(a, 'return') + a.op('move', trace, -1) + a.mark(k) + a.op('read', trace, {ONE: k+'bit', MARK: k+'done'}) + a.mark(k+'bit') + a.op('write', trace, BLANK) + a.op('move', trace, -1) + a.op('move', tape, -1) + a.op('goto', k) + a.mark(k+'done') + a.op('move', trace, 1) + + +def header_step(a): + a.op('write', HTRACE, ONE) + a.op('move', HTRACE, 1) + a.op('move', HEADER, 1) + + +def gamma(a, target, capture=None): + """Unary decode for parameters bounded by the actual field volume.""" + k = fresh(a, 'gamma') + a.mark(k+'prefix') + a.op('read', HEADER, {'0': k+'zero', ONE: k+'one'}) + a.mark(k+'zero') + a.op('write', LENGTH, ONE) + a.op('move', LENGTH, 1) + header_step(a) + a.op('goto', k+'prefix') + a.mark(k+'one') + header_step(a) + a.op('write', target, ONE) + if capture: + for tape, bit in ((capture[0], ONE), (capture[1], ONE)): + a.op('write', tape, bit) + a.op('move', tape, 1) + a.op('move', LENGTH, -1) + a.mark(k+'tail') + a.op('read', LENGTH, {ONE: k+'tailbit', MARK: k+'done'}) + a.mark(k+'tailbit') + a.op('write', LENGTH, BLANK) + a.op('read', HEADER, {str(b): k+'digit'+str(b) for b in (0, 1)}) + for bit in (0, 1): + a.mark(k+'digit'+str(bit)) + unary_copy(a, target, DOUBLE, repeat=2, extra=bit) + clear(a, target) + unary_copy(a, DOUBLE, target, erase=True) + if capture: + for tape, symbol in ((capture[0], str(bit)), (capture[1], ONE)): + a.op('write', tape, symbol) + a.op('move', tape, 1) + header_step(a) + a.op('move', LENGTH, -1) + a.op('goto', k+'tail') + a.mark(k+'done') + a.op('move', LENGTH, 1) + if capture: + a.rewind(capture[0], BITS) + a.rewind(capture[1], (ONE,)) + + +def gamma_binary(a): + """Keep cutoff in binary: its represented value can exceed V arbitrarily.""" + k = fresh(a, 'threshold') + a.mark(k+'prefix') + a.op('read', HEADER, {'0': k+'zero', ONE: k+'one'}) + a.mark(k+'zero') + a.op('write', LENGTH, ONE) + a.op('move', LENGTH, 1) + header_step(a) + a.op('goto', k+'prefix') + a.mark(k+'one') + a.op('write', TBIN, ONE) + a.op('move', TBIN, 1) + a.op('write', TLEN, ONE) + a.op('move', TLEN, 1) + header_step(a) + a.op('move', LENGTH, -1) + a.mark(k+'tail') + a.op('read', LENGTH, {ONE: k+'read', MARK: k+'done'}) + a.mark(k+'read') + a.op('write', LENGTH, BLANK) + a.op('read', HEADER, {str(b): k+str(b) for b in (0, 1)}) + for bit in ('0', ONE): + a.mark(k+bit) + a.op('write', TBIN, bit) + a.op('move', TBIN, 1) + a.op('write', TLEN, ONE) + a.op('move', TLEN, 1) + header_step(a) + a.op('move', LENGTH, -1) + a.op('goto', k+'tail') + a.mark(k+'done') + a.op('move', LENGTH, 1) + a.rewind(TBIN, BITS) + a.rewind(TLEN, (ONE,)) + + +def cutoff_guard(a): + k = fresh(a, 'compare') + a.mark(k+'length') + a.op('read', FLEN, {ONE: k+'fmore', BLANK: k+'fend'}) + a.mark(k+'fmore') + a.op('read', TLEN, {ONE: k+'step', BLANK: 'reject'}) + a.mark(k+'step') + a.op('move', FLEN, 1) + a.op('move', TLEN, 1) + a.op('goto', k+'length') + a.mark(k+'fend') + a.op('read', TLEN, {ONE: k+'done', BLANK: k+'equal_length'}) + a.mark(k+'equal_length') + a.rewind(FLEN, (ONE,)) + a.rewind(TLEN, (ONE,)) + a.mark(k+'lex') + a.op('read', FBIN, {'0': k+'f0', ONE: k+'f1', BLANK: k+'equal'}) + a.mark(k+'f0') + a.op('read', TBIN, {'0': k+'same', ONE: k+'done'}) + a.mark(k+'f1') + a.op('read', TBIN, {'0': 'reject', ONE: k+'same'}) + a.mark(k+'same') + a.op('move', FBIN, 1) + a.op('move', TBIN, 1) + a.op('goto', k+'lex') + a.mark(k+'equal') + a.op('read', TBIN, {BLANK: k+'done'}) + a.mark(k+'done') + for tape, symbols in ((FLEN, (ONE,)), (TLEN, (ONE,)), (FBIN, BITS), (TBIN, BITS)): + a.rewind(tape, symbols) + clear(a, tape, symbols) + + +def double(a, tape): + unary_copy(a, tape, DOUBLE, repeat=2) + clear(a, tape) + unary_copy(a, DOUBLE, tape, erase=True) + + +def halve(a, tape): + k = fresh(a, 'halve') + a.mark(k) + a.op('read', tape, {ONE: k+'first', BLANK: k+'done'}) + a.mark(k+'first') + a.op('write', tape, BLANK) + a.op('move', tape, 1) + a.op('read', tape, {ONE: k+'second', BLANK: 'reject'}) + a.mark(k+'second') + a.op('write', tape, BLANK) + a.op('move', tape, 1) + a.op('write', DOUBLE, ONE) + a.op('move', DOUBLE, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(tape, (BLANK,)) + a.rewind(DOUBLE, (ONE,)) + unary_copy(a, DOUBLE, tape, erase=True) + + +def product(a, left, right, target): + k = fresh(a, 'product') + a.mark(k+'outer') + a.op('read', left, {ONE: k+'inner', BLANK: k+'done'}) + a.mark(k+'inner') + a.op('read', right, {ONE: k+'bit', BLANK: k+'row'}) + a.mark(k+'bit') + a.op('write', target, ONE) + a.op('move', target, 1) + a.op('move', right, 1) + a.op('goto', k+'inner') + a.mark(k+'row') + a.rewind(right, (ONE,)) + a.op('move', left, 1) + a.op('goto', k+'outer') + a.mark(k+'done') + a.rewind(left, (ONE,)) + a.rewind(target, (ONE,)) + + +def geometry(a): + product(a, S, R, SUFFIX) + unary_copy(a, P, PREFIX) + k = fresh(a, 'geometry') + a.mark(k+'suffix') + a.op('read', F, {ONE: k+'block', BLANK: k+'suffix_done'}) + a.mark(k+'block') + for _ in range(NATIVE_DIMENSION-1): + double(a, SUFFIX) + a.op('move', F, 1) + a.op('goto', k+'suffix') + a.mark(k+'suffix_done') + a.rewind(F, (ONE,)) + a.op('move', F, 1) + a.mark(k+'prefix') + a.op('read', F, {ONE: k+'more', BLANK: k+'done'}) + a.mark(k+'more') + double(a, PREFIX) + a.op('move', F, 1) + a.op('goto', k+'prefix') + a.mark(k+'done') + a.rewind(F, (ONE,)) + for tape in (P, R, S): + clear(a, tape) + + +def copy_width(a, source, target, *, rewind_target=False): + k = fresh(a, 'widthcopy') + a.mark(k) + a.op('read', WIDTH, {ONE: k+'read', BLANK: k+'done'}) + a.mark(k+'read') + a.op('read', source, {str(b): k+str(b) for b in (0, 1)}) + for bit in ('0', ONE): + a.mark(k+bit) + a.op('write', target, bit) + a.op('move', target, 1) + a.op('write', source, BLANK) + a.op('move', source, 1) + a.op('move', WIDTH, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(WIDTH, (ONE,)) + if rewind_target: + a.rewind(target, BITS) + + +def load_suffix(a, source, target): + k = fresh(a, 'suffix') + a.mark(k) + a.op('read', SUFFIX, {ONE: k+'pair', BLANK: k+'done'}) + a.mark(k+'pair') + for _ in range(2): + copy_width(a, source, target) + a.op('move', SUFFIX, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(SUFFIX, (ONE,)) + a.rewind(target, BITS) + + +def emit_stream(a, source, target): + k = fresh(a, 'stream') + a.mark(k) + a.op('read', source, {str(b): k+str(b) for b in (0, 1)} | {BLANK: k+'done'}) + for bit in ('0', ONE): + a.mark(k+bit) + a.op('write', target, bit) + a.op('move', target, 1) + a.op('write', source, BLANK) + a.op('move', source, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(source, (BLANK,)) + + +def tuple_branch(a, label, emit, prefix=()): + """Compile the fixed sixteen branches of a four-symbol read.""" + name = label+''.join(map(str, prefix)) + a.mark(name) + if len(prefix) == 4: + emit(prefix) + else: + a.op('read', INPUTS[len(prefix)], {str(b): name+str(b) for b in (0, 1)}) + for bit in (0, 1): + tuple_branch(a, label, emit, prefix+(bit,)) + + +def c_component(a, signs, output): + """Exact four-input numerator, two sign extensions, halving and fit.""" + k = fresh(a, 'C') + a.mark(k+'seek') + a.op('read', WIDTH, {ONE: k+'seekbit', BLANK: k+'seekend'}) + a.mark(k+'seekbit') + for tape in INPUTS: + a.op('move', tape, 1) + a.op('move', WIDTH, 1) + a.op('goto', k+'seek') + a.mark(k+'seekend') + a.rewind(WIDTH, (ONE,)) + for tape in INPUTS: + a.op('move', tape, -1) + a.op('goto', k+'digit0') + for carry in (-1, 0, 1, 2): + label = k+'digit'+str(carry) + a.mark(label) + a.op('read', WIDTH, {ONE: label+'read', BLANK: k+'extend'+str(carry)}) + def digit(bits, carry=carry): + total = carry+sum(s*b for s, b in zip(signs, bits)) + a.op('write', NUM, str(total % 2)) + a.op('move', NUM, 1) + for tape in INPUTS: + a.op('move', tape, -1) + a.op('move', WIDTH, 1) + a.op('goto', k+'digit'+str(total//2)) + tuple_branch(a, label+'read', digit) + a.mark(k+'extend'+str(carry)) + for tape in INPUTS: + a.op('move', tape, 1) + a.rewind(WIDTH, (ONE,)) + a.op('goto', k+'sign1c'+str(carry)) + for stage in (1, 2): + for carry in (-1, 0, 1, 2): + def extension(bits, carry=carry, stage=stage): + total = carry+sum(s*b for s, b in zip(signs, bits)) + a.op('write', NUM, str(total % 2)) + a.op('move', NUM, 1) + a.op('goto', k+'sign2c'+str(total//2) if stage == 1 else k+'check') + tuple_branch(a, k+'sign'+str(stage)+'c'+str(carry), extension) + a.mark(k+'check') + a.rewind(NUM, BITS) + a.op('read', NUM, {'0': k+'even', ONE: 'reject'}) + a.mark(k+'even') + a.op('write', NUM, BLANK) + a.op('move', NUM, 1) + a.mark(k+'highseek') + a.op('read', NUM, {'0': k+'highstep', ONE: k+'highstep', BLANK: k+'highend'}) + a.mark(k+'highstep') + a.op('move', NUM, 1) + a.op('goto', k+'highseek') + a.mark(k+'highend') + a.op('move', NUM, -1) + a.op('read', NUM, {str(b): k+'top'+str(b) for b in (0, 1)}) + for bit in ('0', ONE): + a.mark(k+'top'+bit) + a.op('write', NUM, BLANK) + a.op('move', NUM, -1) + a.op('read', NUM, {bit: k+'emit'}) + a.mark(k+'emit') + a.op('read', WIDTH, {ONE: k+'emitread', BLANK: k+'done'}) + a.mark(k+'emitread') + a.op('read', NUM, {str(b): k+'emit'+str(b) for b in (0, 1)}) + for bit in ('0', ONE): + a.mark(k+'emit'+bit) + a.op('write', output, bit) + a.op('move', output, 1) + a.op('write', NUM, BLANK) + a.op('move', NUM, -1) + a.op('move', WIDTH, 1) + a.op('goto', k+'emit') + a.mark(k+'done') + a.rewind(WIDTH, (ONE,)) + + +def clone_source(a): + """Clone exactly the generated volume; reject short/excess cardinality.""" + k = fresh(a, 'clone') + a.mark(k+'prefix') + a.op('read', PREFIX, {ONE: k+'blocks', BLANK: k+'done'}) + a.mark(k+'blocks') + for side in range(2): + name = k+'side'+str(side) + a.mark(name) + a.op('read', SUFFIX, {ONE: name+'coefficient', BLANK: name+'done'}) + a.mark(name+'coefficient') + for component in range(2): + field = name+'field'+str(component) + a.mark(field) + a.op('read', WIDTH, {ONE: field+'read', BLANK: field+'done'}) + a.mark(field+'read') + a.op('read', DATA, {str(b): field+str(b) for b in (0, 1)}) + for bit in ('0', ONE): + a.mark(field+bit) + a.op('write', A, bit) + a.op('move', A, 1) + a.op('move', DATA, 1) + a.op('write', DTRACE, ONE) + a.op('move', DTRACE, 1) + a.op('move', WIDTH, 1) + a.op('goto', field) + a.mark(field+'done') + a.rewind(WIDTH, (ONE,)) + a.op('move', SUFFIX, 1) + a.op('goto', name) + a.mark(name+'done') + a.rewind(SUFFIX, (ONE,)) + a.op('move', PREFIX, 1) + a.op('goto', k+'prefix') + a.mark(k+'done') + a.rewind(PREFIX, (ONE,)) + a.op('read', DATA, {BLANK: k+'verified'}) + a.mark(k+'verified') + trace_return(a, DATA, DTRACE) + a.rewind(A, BITS) + + +def commit(a, source): + k = fresh(a, 'commit') + a.mark(k) + a.op('read', source, {str(b): k+str(b) for b in (0, 1)} | {BLANK: k+'done'}) + for bit in ('0', ONE): + a.mark(k+bit) + a.op('write', DATA, bit) + a.op('write', source, BLANK) + a.op('move', source, 1) + a.op('move', DATA, 1) + a.op('write', DTRACE, ONE) + a.op('move', DTRACE, 1) + a.op('goto', k) + a.mark(k+'done') + trace_return(a, DATA, DTRACE) + a.rewind(source, (BLANK,)) + + +def compile_leaf(): + a = Builder() + for tape in PRIVATE: + a.op('move', tape, -1) + a.op('write', tape, MARK) + a.op('move', tape, 1) + gamma(a, F, (FBIN, FLEN)) + for tape in (R, P, S, WIDTH): + gamma(a, tape) + gamma_binary(a) + trace_return(a, HEADER, HTRACE) + cutoff_guard(a) + for i in range(2): + a.op('read', WIDTH, {ONE: 'width'+str(i)}) + a.mark('width'+str(i)) + a.op('move', WIDTH, 1) + a.rewind(WIDTH, (ONE,)) + geometry(a) + clone_source(a) + a.op('write', MODE, '0') + a.mark('prefix') + a.op('read', PREFIX, {ONE: 'load_select', BLANK: 'axis_end'}) + a.mark('load_select') + a.op('read', MODE, {'0': 'loadA', ONE: 'loadB'}) + for mode, source in enumerate((A, B)): + a.mark('load'+('A' if mode == 0 else 'B')) + load_suffix(a, source, LEFT) + load_suffix(a, source, RIGHT) + a.op('goto', 'pairs') + a.mark('pairs') + a.op('read', SUFFIX, {ONE: 'pair', BLANK: 'pairs_done'}) + a.mark('pair') + for source, target in ((LEFT, AR), (LEFT, AI), (RIGHT, BR), (RIGHT, BI)): + copy_width(a, source, target, rewind_target=True) + for signs, output in zip(ROWS, (LOUT, LOUT, ROUT, ROUT)): + c_component(a, signs, output) + for tape in INPUTS: + clear(a, tape, BITS) + a.op('move', SUFFIX, 1) + a.op('goto', 'pairs') + a.mark('pairs_done') + a.rewind(SUFFIX, (ONE,)) + for tape in (LEFT, RIGHT): + a.rewind(tape, (BLANK,)) + for tape in (LOUT, ROUT): + a.rewind(tape, BITS) + a.op('read', MODE, {'0': 'mergeB', ONE: 'mergeA'}) + for name, target in (('mergeB', B), ('mergeA', A)): + a.mark(name) + emit_stream(a, LOUT, target) + emit_stream(a, ROUT, target) + a.op('goto', 'prefix_done') + a.mark('prefix_done') + a.op('move', PREFIX, 1) + a.op('goto', 'prefix') + a.mark('axis_end') + a.op('read', MODE, {'0': 'endA', ONE: 'endB'}) + for mode, source, target in ((0, A, B), (1, B, A)): + name = 'end'+('A' if mode == 0 else 'B') + a.mark(name) + a.op('read', source, {BLANK: name+'valid'}) + a.mark(name+'valid') + a.rewind(source, (BLANK,)) + a.rewind(target, BITS) + a.op('write', MODE, str(1-mode)) + a.op('goto', 'axis_done') + a.mark('axis_done') + a.rewind(PREFIX, (ONE,)) + a.op('move', F, 1) + a.op('read', F, {ONE: 'next_axis', BLANK: 'finish'}) + a.mark('next_axis') + double(a, SUFFIX) + halve(a, PREFIX) + a.op('goto', 'prefix') + a.mark('finish') + a.op('read', MODE, {'0': 'commitA', ONE: 'commitB'}) + for name, source in (('commitA', A), ('commitB', B)): + a.mark(name) + commit(a, source) + a.op('goto', 'retire') + a.mark('retire') + a.rewind(F, (ONE,)) + for tape in (F, WIDTH, PREFIX, SUFFIX): + clear(a, tape) + clear(a, MODE, BITS) + for tape in PRIVATE: + a.op('move', tape, -1) + a.op('write', tape, BLANK) + a.op('move', tape, 1) + a.op('halt') + a.mark('reject') + a.op('read', HEADER, {}) + return a.finish((BLANK, '0', ONE, MARK)) + + + + diff --git a/research/literal-selected-linear-maps/reference/literal-elementary-interchange--PROOF.md b/research/literal-selected-linear-maps/reference/literal-elementary-interchange--PROOF.md new file mode 100644 index 0000000000..d4e14bba3f --- /dev/null +++ b/research/literal-selected-linear-maps/reference/literal-elementary-interchange--PROOF.md @@ -0,0 +1,157 @@ +# Complete local-symbol elementary interchange + +JoyboyBrian, with substantial OpenAI Codex assistance. Apache-2.0. + +## Domain and endpoint + +Let H>=0 and A,G,S>=1 be arbitrary integers and V=A*4^H*G*S. +Five disjoint borrowed tapes contain SOURCE's V opaque binary cells and the +canonical little-endian words H,A,G,S. Each has LEFT at position0 and head1; +numbers have RIGHT after their most significant bit (zero is 0 RIGHT), and all +bodies have blank tails. Fifteen disjoint private tapes are initially entirely +blank with head0. External tapes are disjoint from every private tape. Input +initialization is supplied, not free production of these tapes. A caller with +preexisting erased backing may use it; its capacity is not credited as zero. + +For every such input, init then run halts returned. SOURCE and all four words +are byte-for-byte unchanged, heads1. OUTPUT is a distinct owned V-bit body +with head1. Every other private tape has only its LEFT marker and blank body, +head1. At indices (a,x,g,y,s), with x,y in [0,2^H), output is the source bit at +(a,y,g,x,s). After the caller consumes OUTPUT by the included consume entry, +run may repeat on these same roles with any new admitted borrowed tapes. close +then erases all15 owned markers and returns all private heads1. No malformed +input rejection rollback or external alias detection is promised. + +## What the executable is + +program.assemble executes once offline. Its result has4589 instructions and +five entries; this word is independent of H,A,G,S and payload bits. Assembly +helpers, lambdas and Python loops do not survive into the machine. The only +instructions are test(role,symbol,yes,no), write(role,symbol), move(role,+/-1), +jump(pc), and halt(status). Role names and five symbols0,1,LEFT,RIGHT,BLANK are +finite constants. test performs exactly one local read. No arithmetic, +copy, counter, permutation, method call or allocator opcode exists. The PC +encodes finite carries and route choices. Host integers for heads/PC/censuses +are simulator configuration and observers, never decoded tape operands. +The all-width theorem concerns unbounded program semantics. execute's finite +max_steps is an observer watchdog and may abort a larger admitted instance. + +This is a five-symbol multitape program over binary payloads, not a supplied +implementation over a two-symbol tape alphabet. A separate fixed-block binary +alphabet translation remains open. The result does replace the entire source +callee's host control, including arithmetic and scratch selection. + +## Primitive invariants + +rewind moves left until the owned/borrowed LEFT marker, then right once. clear +first rewinds, overwrites each body symbol up to the first BLANK, then rewinds. +It preserves retained backing. copy(source,target,end) traverses only binary +body symbols, checks each destination cell blank, writes the same bit, and +returns both heads. For a number it appends RIGHT; for a payload it leaves the +blank tail. Its target must be empty. All uses satisfy this premise. + +zero branches true precisely on 0 RIGHT and restores head1 on both branches. +All number words used with it remain canonical. normalize scans to RIGHT, +replaces high zero cells by RIGHT while erasing the previous delimiter; if the +word becomes empty, it writes 0 RIGHT. dec is called only on a positive number: +it changes low zeros to ones up to the first one, changes that one to zero, +then normalizes. This is subtraction of one, including powers of two and one. + +double shifts the little-endian bit stream by one place. Two PC states carry +the old preceding bit, starting at0. At RIGHT a carry1 becomes the new high bit +and a new RIGHT is written. Every use is positive, hence the resulting word +is canonical. half requires the low bit0, then copies each next bit one cell +left and moves the delimiter left, erasing its former cell. Every use divides +an even positive value, so its high bit remains1 and its result is positive. + +counted(number,counter,body) clones the number to an empty dedicated counter, +tests zero, executes body and dec until zero, then clears it. Its source is +preserved. Bodies never alias their enclosing counter. The three nested +counter roles OUTER,BETWEEN,BITS are distinct; all sequential invocations +reuse them only after clear. No depth or role inventory depends on values. + +## Complete digit pass and all-width induction + +PRE,GAP,TAIL have values P,M,T. digit reads order (p,a,m,b,t), a,b in{0,1}, +into four separate queues Qab in order(p,m,t), each of length P*M*T. Each read +and append is performed by counted loops and literal instructions. The second +traversal reads Qba in order(p,a,m,b,t); consequently it swaps those two binary +digits while retaining spectators. It checks source and each queue end, +restores source head, clears queues, and returns the new body head1. Total +volume is4PMT; opaque bits never determine a route or numerical counter. + +SCAN starts at H. It decrements once before each potential doubling, and stops +if zero. Thus GAP=G*2^max(H-1,0), TAIL=S*2^max(H-1,0), PRE=A. REMAIN starts atH. +The first pass uses SOURCE and B0. Subsequent passes alternate B0/B1; each +clears the consumed owned buffer before reuse. Before pass i>0, PRE doubles +and TAIL halves. Therefore at pass i=0,...,H-1: + + PRE=A*2^i, GAP=G*2^(H-1), TAIL=S*2^(H-1-i). + +TAIL is even precisely whenever the next half is taken. Each pass has volume +4*PRE*GAP*TAIL=V. This is exactly the retained atom_swap/digit_swap digit +schedule specialized to q=2, or PR5162 Elementary.run's encoded-H schedule. +The retained source proof's index induction exchanges the two H-bit blocks +in H adjacent digit-pair passes; no new source ordering or padding is assumed. +The program duplicates three finite pass bodies for SOURCE/B0/B1, not H +bodies. H=0 takes the SOURCE return branch and copies to a distinct OUTPUT. +At H>0 the selected owned buffer is copied to OUTPUT and cleared. PRE,GAP, +TAIL,REMAIN are then cleared. This proves the endpoint and repeat-call +invariant. init and close explicitly create and remove all15 markers. + +PREDECESSOR.json pins the exact PR5162 export and all cited source members. +The original vendor notices are inside that unchanged archive. Verification +authenticates it before reading the source. It is evidence for the written +refinement, not a hidden runtime source executor. + +## Complete price and capacity boundary + +Let L=H+bitlen(H)+bitlen(A)+bitlen(G)+bitlen(S)+8, with bitlen(0)=1. +Every numerical body in the proof has length at most L. For example GAP and +TAIL add at most H-1 bits and PRE at most H-1. Each rewind/clear/copy, +normalization/decrement, double/half of a number uses fewer than128(L+1) +literal instructions, by summing the displayed tests, moves, writes and +jumps per scanned cell, including origin/delimiter branches. + +A digit pass traverses2V payload bits. There are at most2V suffix countdown +iterations; enclosing outer/between iterations and counter constructions +are at most8(V+1), since A,G,S and the intermediate extents are positive. +Payload transfer contributes fewer than16(V+1) instructions. Queue clearing +and source/queue returns together traverse fewer than8(V+1) cells. Charging +all these, including countdown setup/normalization/clear, gives the safe +bound4096(V+1)(L+1) instructions per digit pass. Descriptor setup and SCAN +cost at most1024(H+1)(L+1)^2. Updating PRE/TAIL is at most256(L+1) per pass. +Final output transport, clearing the final buffer, caller consume (or paid source installation) and owned +marker disposal cost at most128(V+L+1). These inequalities are conservative +termwise loop bounds, not inferred from elapsed time or finite fixtures. + +In particular the complete init/run/consume/close session is bounded by + + T <= 2^20 * (H+1) * (V+1) * (L+1)^2. + +The finite admission checker independently excludes control-only cycles. +For this word, at most two jumps occur between cell instructions or halt; +thus T<=3(C+k), where C counts actual reads+writes+unit moves and k +is the number of executed entries in the session (k=1 for one execute call). +Tests are paid reads even when merely checking a precondition. +Successful output computation is priced with caller consumption/disposal, +not only the routing core. Reusing a live initialized owner omits only its +already-paid init and eventual close; all per-call costs remain. + +Fifteen private roles is an exact inventory, not a bound on total retained +backing under arbitrary histories. clear does not shrink arrays; total +backing-space grants remain a separate obligation. Simulator allocation and +wall time are not the local-symbol model's instruction price. + +## Actual caller and limits + +The actual PR5162 raw u/back descriptor is H2,A1,G1024,S12, V196608. +The verifier executes the same whole literal callee, compares every output +bit with the independent address permutation and also executes a paid +copy-back to the original source port before disposal in the caller probe. +That extra caller transport is separately metered. No raw12-shear replay, +ROM producer, repair, current selected/native supplier, all-size CRT/full E, +precision, outer multiplication or improved kappa is asserted here. + +Finite single-column and adversarial controls corroborate this written proof; +they do not prove its quantified claims or confer human/kernel acceptance. diff --git a/research/literal-selected-linear-maps/reference/native_verify.py b/research/literal-selected-linear-maps/reference/native_verify.py new file mode 100644 index 0000000000..2c209dfa9c --- /dev/null +++ b/research/literal-selected-linear-maps/reference/native_verify.py @@ -0,0 +1,277 @@ +"""Check native operators with exact Gaussian dyadic arithmetic. + +The interpreter is adapted from the independent campaign native review. +It does not import the source-code producer or the Clifford compiler. +Research used OpenAI Codex under the user's direction. +""" + +from functools import lru_cache + + +def require(condition, label): + if not condition: + raise ValueError(label) + + +def parity(value): + return value.bit_count() % 2 + + +def mul(matrix, vector): + return sum(parity(row & vector) << i for i, row in enumerate(matrix)) + + +def transpose(matrix): + return tuple(sum(((row >> j) & 1) << i for i, row in enumerate(matrix)) for j in range(len(matrix))) + + +def inverse(matrix): + n = len(matrix) + rows = [row | (1 << (n+i)) for i, row in enumerate(matrix)] + for j in range(n): + pivot = next((i for i in range(j, n) if rows[i] >> j & 1), None) + require(pivot is not None, 'singular binary chart') + rows[j], rows[pivot] = rows[pivot], rows[j] + for i in range(n): + if i != j and rows[i] >> j & 1: + rows[i] ^= rows[j] + require([row & ((1 << n)-1) for row in rows] == [1 << i for i in range(n)], 'binary inverse') + return tuple(row >> n for row in rows) + + +def extend(vectors, n): + columns, pivots = [], {} + for value in tuple(vectors) + tuple(1 << i for i in range(n)): + reduced = value + while reduced: + j = reduced.bit_length()-1 + if j not in pivots: + pivots[j] = reduced + columns.append(value) + break + reduced ^= pivots[j] + require(len(columns) == n, 'frame basis extension') + return tuple(columns) + + +def adjoint(circuit): + out = [] + for gate in reversed(circuit): + if gate[0] == 'P': + out.append(('P', inverse(gate[1]))) + elif gate[0] == 'D': + out.append(('D', gate[1], tuple(-a % 4 for a in gate[2]))) + elif gate[0] == 'C': + out.append(('C', gate[1], -gate[2])) + elif gate[0] == 'phase': + out.append(('phase', -gate[1] % 4)) + else: + require(gate[0] == 'X', 'adjoint gate type') + out.append(gate) + return tuple(out) + + +def fourier(rank): + return tuple(('C', 1 << i, 1) for i in range(rank)) + + +def frame(vectors, n): + rank = len(vectors) + if rank == 0: + return () + if rank == n: + return fourier(n) + matrix = transpose(extend(vectors, n)) + columns = transpose(inverse(matrix)) + quadratic = tuple((1 << i) ^ sum(parity(a & b) << j for j, b in enumerate(columns)) for i, a in enumerate(columns)) + diagonal = tuple((row >> i) & 1 for i, row in enumerate(quadratic)) + chart = (('P', matrix), ('D', quadratic, diagonal)) + return adjoint(chart) + fourier(rank) + chart + + +def monomial(record): + matrix = tuple(record['matrix_rows']) + quadratic = tuple(record['quadratic_rows']) + linear = tuple(record['linear_Z4']) + require(transpose(quadratic) == quadratic, 'quadratic symmetry') + require(len(matrix) == len(quadratic) == len(linear) == 9, 'monomial dimension') + require(all(a % 2 == (quadratic[i] >> i) & 1 for i, a in enumerate(linear)), 'diagonal parity') + inverse(matrix) + return (('D', quadratic, linear), ('P', matrix), ('X', record['offset']), ('phase', record['phase'])) + + +def recipe(record): + rank = record['rank'] + require(isinstance(rank, int) and 0 <= rank <= 9, 'child rank') + if rank == 0: + require(record['right'] is None, 'rank zero right factor') + return monomial(record['left']) + return monomial(record['right']) + fourier(rank) + monomial(record['left']) + + +def tableau(circuit, n=9): + rows = [(1 << i, 0, 0) for i in range(n)] + [(0, 1 << i, 0) for i in range(n)] + for gate in circuit: + tag = gate[0] + out = [] + inverse_transpose = transpose(inverse(gate[1])) if tag == 'P' else None + for x, z, phase in rows: + if tag == 'P': + x, z = mul(gate[1], x), mul(inverse_transpose, z) + elif tag == 'X': + phase += 2 * parity(z & gate[1]) + elif tag == 'C': + if parity(z & gate[1]): + x ^= gate[1] + phase += 3 * gate[2] + elif tag == 'D': + quadratic, linear = gate[1:] + phase += sum(linear[i] for i in range(n) if x >> i & 1) + phase += 2 * sum(parity((quadratic[i] >> (i+1)) & (x >> (i+1))) for i in range(n) if x >> i & 1) + z ^= mul(quadratic, x) + else: + require(tag == 'phase', 'tableau gate type') + out.append((x, z, phase % 4)) + rows = out + return tuple(rows) + + +@lru_cache(maxsize=512) +def action(gate): + if gate[0] == 'P': + return tuple(mul(gate[1], x) for x in range(512)) + require(gate[0] == 'D', 'state action type') + quadratic, linear = gate[1:] + return tuple((sum(linear[i] for i in range(9) if x >> i & 1) + + 2 * sum(parity((quadratic[i] >> (i+1)) & (x >> (i+1))) for i in range(9) if x >> i & 1)) % 4 for x in range(512)) + + +def rotate(pair, power): + a, b = pair + return ((a, b), (-b, a), (-a, -b), (b, -a))[power % 4] + + +def state(circuit, basis=0): + value, denominator = {basis: (1, 0)}, 0 + for gate in circuit: + tag = gate[0] + result = {} + if tag == "C": + direction, sign = gate[1:] + for address, (a, b) in value.items(): + for target, pair in ((address, (a - sign*b, b + sign*a)), + (address ^ direction, (a + sign*b, b - sign*a))): + old = result.get(target, (0, 0)) + result[target] = (old[0] + pair[0], old[1] + pair[1]) + denominator += 1 + else: + for address, pair in value.items(): + if tag == "P": + target = mul(gate[1], address) + elif tag == "X": + target = address ^ gate[1] + else: + target = address + if tag == "D": + pair = rotate(pair, action(gate)[address]) + else: + require(tag == "phase", "Unknown Gaussian state gate") + pair = rotate(pair, gate[1]) + require(target not in result, "A monomial address map is not injective") + result[target] = pair + value = {address: pair for address, pair in result.items() if pair != (0, 0)} + while denominator and all((a | b) % 2 == 0 for a, b in value.values()): + denominator -= 1 + value = {address: (a//2, b//2) for address, (a, b) in value.items()} + return value, denominator + + +def equal(actual, expected, label): + require(tableau(actual) == tableau(expected), label + ": signed Pauli action") + require(state(actual) == state(expected), label + ": exact global phase") + + +def verify(data, certificate): + word = data["word"] + original, clean = data["programs"], data["clean_programs"] + source_recipes = data["recipes"] + residuals = data["residuals"]["recipes"] + native_tags = {"climb", "adapter", "residual_adapter"} + for orientation in ("forward", "backward"): + native = [event for event in clean[orientation] if event[0] in native_tags] + require(native == [event for event in original[orientation] if event[0] in native_tags], + "A retained native event changed") + require(len(native) == 5056, "The retained native event count changed") + frames = [frame(tuple(vectors), 9) for vectors in word["frames"]] + used = {(event[3], event[4]) for program in clean.values() + for event in program if event[0] == "climb"} + children = {(record["old"], record["new"]): record for record in source_recipes["children"]} + require(len(children) == len(source_recipes["children"]) and used <= set(children), + "The retained child recipe coverage is incomplete") + for old, new in sorted(used): + record = children[old, new] + require(record["rank"] == len(word["frames"][new]) - len(word["frames"][old]), + "A retained child has the wrong rank") + equal(recipe(record), adjoint(frames[old]) + frames[new], "Retained child") + endpoints = {(record["role"], record["port"]): record + for record in source_recipes["endpoint_adapters"]} + require(len(endpoints) == len(source_recipes["endpoint_adapters"]) + and set(endpoints) == {(role, p) for role in ("source", "target") for p in range(112)}, + "The endpoint adapter coverage is incomplete") + for (role, port), record in endpoints.items(): + direction = word["ports"][port] + conventional = (("C", direction, 1),) if role == "source" else ( + ("C", direction, -1),) + fourier(9) + index = word["start"][port] if role == "source" else word["final"][112 + port] + require(record["frame"] == index and record["rank"] == 0, "An endpoint frame changed") + equal(recipe(record), adjoint(conventional) + frames[index], "Endpoint adapter") + used_residuals = set() + for program in clean.values(): + for event in program: + if event[0] != "residual_adapter": + continue + _, position, register, entry, *tail = event + terminal = tail[0] if tail else 1 + key = str(entry) if terminal == 1 else str(entry) + ":" + str(terminal) + require(key in residuals and position in ("pre", "post"), "A residual binding changed") + require(entry == word["start"][register] and terminal == word["final"][register], + "A residual endpoint changed") + used_residuals.add(key) + for key in sorted(used_residuals): + record = residuals[key] + equal(recipe(record), adjoint(frames[record["frame"]]) + frames[record.get("terminal", 1)], + "Residual adapter") + records = certificate["input_recipes"] + ports = certificate["compensation_ports"] + require([record["port"] for record in records] == ports and len(records) == 8, + "The eight input recipes changed") + columns = 0 + for item in records: + port, label = item["port"], item["label"] + require(label == word["ports"][port] and item["canonical_start_frame_id"] == word["start"][port], + "An input recipe has the wrong supplier label") + record = item["recipe"] + require(record["rank"] == 1, "An input copy has the wrong child rank") + for side in ("left", "right"): + factor = record[side] + require(factor["quadratic_rows"] == [0] * 9 and factor["linear_Z4"] == [0] * 9 + and factor["offset"] == factor["phase"] == 0, + "An input factor is not an address permutation") + actual, expected = recipe(record), (("C", label, 1),) + equal(actual, expected, "Positive inherited input line") + for basis in range(512): + require(state(actual, basis) == state(expected, basis), "A complete input Gaussian column differs") + columns += 1 + negative = monomial(record["right"]) + (("C", 1, -1),) + monomial(record["left"]) + require(tableau(negative) != tableau(expected) or state(negative) != state(expected), + "An inverse input child was not detected") + phased = actual + (("phase", 1),) + require(tableau(phased) == tableau(actual) and state(phased) != state(expected), + "An input phase-only error was not detected") + return {"status": "PASS_EXACT_INPUT_NATIVE_FRAMES", "retained_native_events_per_orientation": 5056, + "retained_child_recipes": len(used), "endpoint_adapter_recipes": len(endpoints), + "residual_adapter_recipes": len(used_residuals), "new_input_recipes": len(records), + "new_exact_gaussian_columns": columns, "inverse_input_child_controls": len(records), + "phase_only_controls": len(records), "address_permutation_factors": 2 * len(records), + "method": "Independent signed Pauli and exact Gaussian interpretation; no compiler import", + "scope": "Positive inherited input frames before every retained adapter. No recursive hosting claim."} diff --git a/research/literal-selected-linear-maps/reference/packed-phase-PROOF.md b/research/literal-selected-linear-maps/reference/packed-phase-PROOF.md new file mode 100644 index 0000000000..46a43bf214 --- /dev/null +++ b/research/literal-selected-linear-maps/reference/packed-phase-PROOF.md @@ -0,0 +1,336 @@ +# A literal quadratic phase for a current selected native recipe + +**Scoped enabling lemma; no new kappa.** Prepared for Jerry Chen / @CubeJerry +with substantial OpenAI assistance. Canonical base: +`e54523517d0f03e58352e647c403a5af3e525a57`. + +## 1. Exact claim, source and novelty + +Fix the nine-coordinate right monomial in the lowering of the actual retained +#7000 native `MOVE` at zero-based program index **24472**: +`["MOVE",415,3,99,false]`. Its before/after frames are 3 and 99 and its +proper-width central child has rank 1. The source is +`research/shared-wire-split-composition/data/final.json.gz`, compressed SHA256 +`2b94953dc14a122e3ef089633f05b58ec689ec5156feb7c784ed3e137dc01883`, +with canonical uncompressed JSON SHA256 +`91429a6b96729292a8764836e00c87a6f7cd3b76f05159033f4867f69a98d097`. +This is a current selected source event, not the historical event8814 fixture. + +`RECIPE.json` retains the whole exact lowering, including both monomial +recipes. The right factor has constant phase 1, linear coefficients +`(3,3,3,3,0,3,3,2,0)`, and symmetric quadratic row masks +`(111,111,111,111,0,111,111,0,0)`. Diagonal entries are already included in +the linear coefficients; only strictly upper matrix entries contribute +quadratic terms. With `J={0,1,2,3,5,6}`, its input-coordinate phase is + +\[ +q(x)=1+3\sum_{i\in J}x_i+2x_7+ + 2\sum_{i