From 28b0d1c94cb5de5acd4649dae29388cbcd499dd4 Mon Sep 17 00:00:00 2001 From: Jerry Jiaheng Chen <80299683+CubeJerry@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:15:53 +1100 Subject: [PATCH] Implement arbitrary fixed native offsets with one reversal and restored HOME return --- .../CHECKSUMS.sha256 | 54 ++ .../FREEZE.json | 281 +++++++++ .../PR-DESCRIPTION.md | 51 ++ .../PR-TITLE.txt | 1 + .../README.md | 78 +++ .../SOURCES.json | 83 +++ .../TASK.json | 93 +++ .../VALIDATION.json | 15 + .../VERIFY.json | 72 +++ .../implementation/CHECKPOINT.md | 24 + .../implementation/ENVIRONMENT.json | 9 + .../implementation/FREEZE.json | 215 +++++++ .../implementation/NOTICE.md | 33 + .../implementation/OVERLAP.md | 35 ++ .../implementation/PR-DESCRIPTION.md | 40 ++ .../implementation/PROOF.md | 228 +++++++ .../implementation/README.md | 59 ++ .../implementation/RESULT.json | 249 ++++++++ .../implementation/SOURCE-BINDING.json | 138 +++++ .../implementation/SOURCES.json | 182 ++++++ .../implementation/adapter.py | 117 ++++ .../implementation/affine.py | 101 ++++ .../implementation/bind_sources.py | 55 ++ .../implementation/machine.py | 129 ++++ .../reference/rank2/FREEZE.json | 179 ++++++ .../implementation/reference/rank2/PROOF.md | 316 ++++++++++ .../reference/rank2/RECIPE.json | 490 +++++++++++++++ .../reference/rank2/SOURCES.json | 232 +++++++ .../implementation/reference/rank2/machine.py | 129 ++++ .../implementation/reference/rank2/rank2.py | 200 +++++++ .../reference/rank2/reference/home/NOTICE.md | 35 ++ .../rank2/reference/home/parent_adapter.py | 131 ++++ .../rank2/reference/home/tape_graph.py | 281 +++++++++ .../reference/rank2/reference/leaf/NOTICE.md | 34 ++ .../leaf/inputs/controller_reference.py | 112 ++++ .../reference/rank2/reference/leaf/leaf.py | 564 ++++++++++++++++++ .../rank2/reference/linear/NOTICE.md | 36 ++ .../linear/inputs/controller_reference.py | 112 ++++ .../rank2/reference/linear/linear.py | 435 ++++++++++++++ .../reference/rank2/reference/phase/NOTICE | 11 + .../phase/inputs/controller_reference.py | 112 ++++ .../reference/rank2/reference/phase/phase.py | 335 +++++++++++ .../rank2/reference/source/clifford_exact.py | 149 +++++ .../rank2/reference/source/native_verify.py | 277 +++++++++ .../reference/translation/NOTICE.md | 20 + .../reference/translation/PROOF.md | 377 ++++++++++++ .../reference/inputs/controller_reference.py | 112 ++++ .../translation/reference/reverse.py | 207 +++++++ .../reference/translation/translate.py | 221 +++++++ .../implementation/verify.py | 219 +++++++ .../review/independent/RESULT.json | 79 +++ .../review/independent/REVIEW.md | 94 +++ .../review/independent/independent_check.py | 317 ++++++++++ .../review/root/RESULT.json | 49 ++ .../review/root/ROOT-REVIEW.md | 87 +++ .../review/root/check_affine_root.py | 110 ++++ 56 files changed, 8404 insertions(+) create mode 100644 research/literal-fixed-mask-native-translation/CHECKSUMS.sha256 create mode 100644 research/literal-fixed-mask-native-translation/FREEZE.json create mode 100644 research/literal-fixed-mask-native-translation/PR-DESCRIPTION.md create mode 100644 research/literal-fixed-mask-native-translation/PR-TITLE.txt create mode 100644 research/literal-fixed-mask-native-translation/README.md create mode 100644 research/literal-fixed-mask-native-translation/SOURCES.json create mode 100644 research/literal-fixed-mask-native-translation/TASK.json create mode 100644 research/literal-fixed-mask-native-translation/VALIDATION.json create mode 100644 research/literal-fixed-mask-native-translation/VERIFY.json create mode 100644 research/literal-fixed-mask-native-translation/implementation/CHECKPOINT.md create mode 100644 research/literal-fixed-mask-native-translation/implementation/ENVIRONMENT.json create mode 100644 research/literal-fixed-mask-native-translation/implementation/FREEZE.json create mode 100644 research/literal-fixed-mask-native-translation/implementation/NOTICE.md create mode 100644 research/literal-fixed-mask-native-translation/implementation/OVERLAP.md create mode 100644 research/literal-fixed-mask-native-translation/implementation/PR-DESCRIPTION.md create mode 100644 research/literal-fixed-mask-native-translation/implementation/PROOF.md create mode 100644 research/literal-fixed-mask-native-translation/implementation/README.md create mode 100644 research/literal-fixed-mask-native-translation/implementation/RESULT.json create mode 100644 research/literal-fixed-mask-native-translation/implementation/SOURCE-BINDING.json create mode 100644 research/literal-fixed-mask-native-translation/implementation/SOURCES.json create mode 100644 research/literal-fixed-mask-native-translation/implementation/adapter.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/affine.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/bind_sources.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/machine.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/FREEZE.json create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/PROOF.md create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/RECIPE.json create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/SOURCES.json create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/machine.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/rank2.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/home/NOTICE.md create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/home/parent_adapter.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/home/tape_graph.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/leaf/NOTICE.md create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/leaf/inputs/controller_reference.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/leaf/leaf.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/linear/NOTICE.md create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/linear/inputs/controller_reference.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/linear/linear.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/phase/NOTICE create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/phase/inputs/controller_reference.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/phase/phase.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/source/clifford_exact.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/source/native_verify.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/translation/NOTICE.md create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/translation/PROOF.md create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/translation/reference/inputs/controller_reference.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/translation/reference/reverse.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/reference/translation/translate.py create mode 100644 research/literal-fixed-mask-native-translation/implementation/verify.py create mode 100644 research/literal-fixed-mask-native-translation/review/independent/RESULT.json create mode 100644 research/literal-fixed-mask-native-translation/review/independent/REVIEW.md create mode 100644 research/literal-fixed-mask-native-translation/review/independent/independent_check.py create mode 100644 research/literal-fixed-mask-native-translation/review/root/RESULT.json create mode 100644 research/literal-fixed-mask-native-translation/review/root/ROOT-REVIEW.md create mode 100644 research/literal-fixed-mask-native-translation/review/root/check_affine_root.py diff --git a/research/literal-fixed-mask-native-translation/CHECKSUMS.sha256 b/research/literal-fixed-mask-native-translation/CHECKSUMS.sha256 new file mode 100644 index 0000000000..08f7761980 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/CHECKSUMS.sha256 @@ -0,0 +1,54 @@ +3d92cd4f38e2910c2a40945dadd19d33255419e3b50f6fbf3cff3672287d3bd4 PR-DESCRIPTION.md +61a357aa8da9dedb7caa76a6322be13337063d6c20255f0a82418fe799487815 PR-TITLE.txt +cf9426344fd2c4ea3a2cb4e1baff46069507b5cc8e788a1ebe8bd525519969fe README.md +306572d68a19f86677de0838d18a788b08de80f4aceb2cc8753ce3bc399f495f SOURCES.json +bc4ce6477195368369afb5ba8b2fdd9de5ab20da76ef1c9ca33baeb84bc4f75d TASK.json +4b84b694ae0c6b5e59ce3dee701ad3e9af937e071d0a794d89a285afff707ed3 VALIDATION.json +9cdf88df33fad24b57ea5c173c34323b9716ff51d3d138fd36eabb42070ded96 VERIFY.json +f54a3c992381a400dfacf5c7d92e9913e38ec9f42231e2f7f33d286af66a268e implementation/CHECKPOINT.md +f126bace428d01e7e07ce3455a62a8cd4e706c340b27befcc82098aa613f4e92 implementation/ENVIRONMENT.json +de2753cb42a012e07aa7ace263bedce5c4be8506ae30ab768af9e165a6edd6e0 implementation/FREEZE.json +d562b9cb72403d6edf8007e5065fa5e62f23fc5e27ef412e1c29d7b0dcd91edd implementation/NOTICE.md +a6a30afc20b2f55eb278abafb8761f8570d093971028c639909a9660eff4f121 implementation/OVERLAP.md +c4a5e2b37bad44ca24319fea6f9ae31b01fa4c5b351eeea5072d8c8b1d3c78bd implementation/PR-DESCRIPTION.md +f43040c6331dc29ecf3f435e980cc71f00a60e421f50f4e843192a23e733bd44 implementation/PROOF.md +fda143cc8e0b10eac00c7153c96005271fd31c422d4290777f1de94b6b304fd1 implementation/README.md +da72e73f0d140e9460e080553dc00c20d9c5fbcec88c9fa174b44a3406989423 implementation/RESULT.json +413d614973ad96a1adf98b70188e8db909931a6838cc87636472452a57abe909 implementation/SOURCE-BINDING.json +abbbd21565ff67a5268d30c034ad33f2143c8b2699bbcccc68569a326ff020b6 implementation/SOURCES.json +3ba85d9c49371841def2dc173b2d53fb271779382cb3eb4248bd93425c3fb46c implementation/adapter.py +9387d4caa6ea6ad9e232f4a2a07112fa1a681d34af19e5aae64d1d8adc5ebd2c implementation/affine.py +e765f1d8451682e11c03f73080841ff207b5f1c8710eae24211ebbbd182c4f2a implementation/bind_sources.py +ffe2677bb5b82932873cb08b05f890a1218070215ebe670a0b05079518e8baee implementation/machine.py +072dfea997d4db796d492eaf746e0bd99630964741b88862d0f10f5fc1e00275 implementation/reference/rank2/FREEZE.json +93e1ad8a92c3624df064e4f39119ccbb5c96391ea8dd5f7af58edc7ca9638352 implementation/reference/rank2/PROOF.md +b1386ad613213a01f736bc2e7fc7de5a25d2c700c3d577dfb396a266278ae702 implementation/reference/rank2/RECIPE.json +659ff7da20d16ece71aabbe240986e884fcaa6f53b5b0f082151e541e0534641 implementation/reference/rank2/SOURCES.json +ffe2677bb5b82932873cb08b05f890a1218070215ebe670a0b05079518e8baee implementation/reference/rank2/machine.py +3ca027f80b6cb973fa064612b8fb18b1306498e064a01e97ff7f9b6aa40b301a implementation/reference/rank2/rank2.py +b51b8fd0773a1bbe988c8a98d951dc34b175bf56bac772ef65997f1df7ed3842 implementation/reference/rank2/reference/home/NOTICE.md +04462e141548c6a86c500d40b4aee8c446c539bd9269098d7516fa13400ef099 implementation/reference/rank2/reference/home/parent_adapter.py +7d3cee3e79ba5fe410e1a6b5f4cf6a2fbe5e274f838b798cd8860344ff258b54 implementation/reference/rank2/reference/home/tape_graph.py +773921ac301cf7e37de97ed8a0066e6bbb69ec1150cc2b5f74a12cb20103f3cf implementation/reference/rank2/reference/leaf/NOTICE.md +e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73 implementation/reference/rank2/reference/leaf/inputs/controller_reference.py +bb46c1a55f1119957a52cd61f2cd957f3f7ad1e9b818c54a852bde09a0773744 implementation/reference/rank2/reference/leaf/leaf.py +2ac2051c0fbedfd9d11348493456bf479dbdd3104a4e106c8bf36251a72b6a50 implementation/reference/rank2/reference/linear/NOTICE.md +e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73 implementation/reference/rank2/reference/linear/inputs/controller_reference.py +d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33 implementation/reference/rank2/reference/linear/linear.py +5654eeb7fdc1acd6a6d246ef87b1155812efdcd0949f54be78e048fe905fbae0 implementation/reference/rank2/reference/phase/NOTICE +e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73 implementation/reference/rank2/reference/phase/inputs/controller_reference.py +2be149aa1be504509bb480f85396f0be302082d638e81422f747daee5a3c1ce7 implementation/reference/rank2/reference/phase/phase.py +2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962 implementation/reference/rank2/reference/source/clifford_exact.py +3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38 implementation/reference/rank2/reference/source/native_verify.py +24f5e9957fcd8f6cfdc021ff5bc91bf89e50587997e2a2cb18053949c0e0d205 implementation/reference/translation/NOTICE.md +6b76d348203aed15cbc30d104c59571111ccf6cb7bb4592936e9170f736b68e0 implementation/reference/translation/PROOF.md +e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73 implementation/reference/translation/reference/inputs/controller_reference.py +4b516d85baf3303db809bc1174394009b1fc71a8f7d17fb6c729ec8bb6aba245 implementation/reference/translation/reference/reverse.py +e2750fef8c2b9c8019d67285df3ca0d04340cd241782c7845665b7de621ca3bd implementation/reference/translation/translate.py +61bb8438cc82064e2aa54a88a4e5675b2f7e04751e7781749ec03398588a2126 implementation/verify.py +78d09fabe35c1d6b91ff6194553f0dfb07ac46d11f671518fbe86981f40e4122 review/independent/RESULT.json +067a30a7bd923aa45de9d08de9cadf891a201e1c76a04bd0b8049a05e311d26a review/independent/REVIEW.md +c199871df12c5d3fa84f8070b251da03446be532b44aa530d681cbf07def179e review/independent/independent_check.py +837e17f98737a4b700aa710f3fefc831082b0a63e1b1780bc12f0b6be1acd350 review/root/RESULT.json +f0913f8a52847947a358b4e42a41c088df56f54836bef3b5e1ff680f3075192d review/root/ROOT-REVIEW.md +6d14795a3d802c45d31ac46c5b7aad35a64472f9d8db624d0f9e502cf7d6a721 review/root/check_affine_root.py diff --git a/research/literal-fixed-mask-native-translation/FREEZE.json b/research/literal-fixed-mask-native-translation/FREEZE.json new file mode 100644 index 0000000000..b8e10fc63b --- /dev/null +++ b/research/literal-fixed-mask-native-translation/FREEZE.json @@ -0,0 +1,281 @@ +{ + "schema": "publication-candidate-freeze/1", + "status": "FROZEN", + "canonical_main": "e54523517d0f03e58352e647c403a5af3e525a57", + "author_freeze_sha256": "de2753cb42a012e07aa7ace263bedce5c4be8506ae30ab768af9e165a6edd6e0", + "scope": "Fixed-mask translation only; supplied Gamma6/HOME entry; no source monomial/MOVE/caller/nonleaf/assumption/kappa admission", + "files": [ + { + "path": "PR-DESCRIPTION.md", + "bytes": 2744, + "sha256": "3d92cd4f38e2910c2a40945dadd19d33255419e3b50f6fbf3cff3672287d3bd4" + }, + { + "path": "PR-TITLE.txt", + "bytes": 102, + "sha256": "61a357aa8da9dedb7caa76a6322be13337063d6c20255f0a82418fe799487815" + }, + { + "path": "README.md", + "bytes": 4205, + "sha256": "cf9426344fd2c4ea3a2cb4e1baff46069507b5cc8e788a1ebe8bd525519969fe" + }, + { + "path": "SOURCES.json", + "bytes": 3123, + "sha256": "306572d68a19f86677de0838d18a788b08de80f4aceb2cc8753ce3bc399f495f" + }, + { + "path": "TASK.json", + "bytes": 7224, + "sha256": "bc4ce6477195368369afb5ba8b2fdd9de5ab20da76ef1c9ca33baeb84bc4f75d" + }, + { + "path": "VALIDATION.json", + "bytes": 834, + "sha256": "4b84b694ae0c6b5e59ce3dee701ad3e9af937e071d0a794d89a285afff707ed3" + }, + { + "path": "VERIFY.json", + "bytes": 2001, + "sha256": "9cdf88df33fad24b57ea5c173c34323b9716ff51d3d138fd36eabb42070ded96" + }, + { + "path": "implementation/CHECKPOINT.md", + "bytes": 2090, + "sha256": "f54a3c992381a400dfacf5c7d92e9913e38ec9f42231e2f7f33d286af66a268e" + }, + { + "path": "implementation/ENVIRONMENT.json", + "bytes": 524, + "sha256": "f126bace428d01e7e07ce3455a62a8cd4e706c340b27befcc82098aa613f4e92" + }, + { + "path": "implementation/FREEZE.json", + "bytes": 7062, + "sha256": "de2753cb42a012e07aa7ace263bedce5c4be8506ae30ab768af9e165a6edd6e0" + }, + { + "path": "implementation/NOTICE.md", + "bytes": 1918, + "sha256": "d562b9cb72403d6edf8007e5065fa5e62f23fc5e27ef412e1c29d7b0dcd91edd" + }, + { + "path": "implementation/OVERLAP.md", + "bytes": 2281, + "sha256": "a6a30afc20b2f55eb278abafb8761f8570d093971028c639909a9660eff4f121" + }, + { + "path": "implementation/PR-DESCRIPTION.md", + "bytes": 2572, + "sha256": "c4a5e2b37bad44ca24319fea6f9ae31b01fa4c5b351eeea5072d8c8b1d3c78bd" + }, + { + "path": "implementation/PROOF.md", + "bytes": 12681, + "sha256": "f43040c6331dc29ecf3f435e980cc71f00a60e421f50f4e843192a23e733bd44" + }, + { + "path": "implementation/README.md", + "bytes": 3467, + "sha256": "fda143cc8e0b10eac00c7153c96005271fd31c422d4290777f1de94b6b304fd1" + }, + { + "path": "implementation/RESULT.json", + "bytes": 5806, + "sha256": "da72e73f0d140e9460e080553dc00c20d9c5fbcec88c9fa174b44a3406989423" + }, + { + "path": "implementation/SOURCE-BINDING.json", + "bytes": 3690, + "sha256": "413d614973ad96a1adf98b70188e8db909931a6838cc87636472452a57abe909" + }, + { + "path": "implementation/SOURCES.json", + "bytes": 7336, + "sha256": "abbbd21565ff67a5268d30c034ad33f2143c8b2699bbcccc68569a326ff020b6" + }, + { + "path": "implementation/adapter.py", + "bytes": 4903, + "sha256": "3ba85d9c49371841def2dc173b2d53fb271779382cb3eb4248bd93425c3fb46c" + }, + { + "path": "implementation/affine.py", + "bytes": 3859, + "sha256": "9387d4caa6ea6ad9e232f4a2a07112fa1a681d34af19e5aae64d1d8adc5ebd2c" + }, + { + "path": "implementation/bind_sources.py", + "bytes": 2580, + "sha256": "e765f1d8451682e11c03f73080841ff207b5f1c8710eae24211ebbbd182c4f2a" + }, + { + "path": "implementation/machine.py", + "bytes": 6041, + "sha256": "ffe2677bb5b82932873cb08b05f890a1218070215ebe670a0b05079518e8baee" + }, + { + "path": "implementation/reference/rank2/FREEZE.json", + "bytes": 5633, + "sha256": "072dfea997d4db796d492eaf746e0bd99630964741b88862d0f10f5fc1e00275" + }, + { + "path": "implementation/reference/rank2/PROOF.md", + "bytes": 16634, + "sha256": "93e1ad8a92c3624df064e4f39119ccbb5c96391ea8dd5f7af58edc7ca9638352" + }, + { + "path": "implementation/reference/rank2/RECIPE.json", + "bytes": 4468, + "sha256": "b1386ad613213a01f736bc2e7fc7de5a25d2c700c3d577dfb396a266278ae702" + }, + { + "path": "implementation/reference/rank2/SOURCES.json", + "bytes": 10337, + "sha256": "659ff7da20d16ece71aabbe240986e884fcaa6f53b5b0f082151e541e0534641" + }, + { + "path": "implementation/reference/rank2/machine.py", + "bytes": 6041, + "sha256": "ffe2677bb5b82932873cb08b05f890a1218070215ebe670a0b05079518e8baee" + }, + { + "path": "implementation/reference/rank2/rank2.py", + "bytes": 8253, + "sha256": "3ca027f80b6cb973fa064612b8fb18b1306498e064a01e97ff7f9b6aa40b301a" + }, + { + "path": "implementation/reference/rank2/reference/home/NOTICE.md", + "bytes": 2093, + "sha256": "b51b8fd0773a1bbe988c8a98d951dc34b175bf56bac772ef65997f1df7ed3842" + }, + { + "path": "implementation/reference/rank2/reference/home/parent_adapter.py", + "bytes": 5353, + "sha256": "04462e141548c6a86c500d40b4aee8c446c539bd9269098d7516fa13400ef099" + }, + { + "path": "implementation/reference/rank2/reference/home/tape_graph.py", + "bytes": 12069, + "sha256": "7d3cee3e79ba5fe410e1a6b5f4cf6a2fbe5e274f838b798cd8860344ff258b54" + }, + { + "path": "implementation/reference/rank2/reference/leaf/NOTICE.md", + "bytes": 1900, + "sha256": "773921ac301cf7e37de97ed8a0066e6bbb69ec1150cc2b5f74a12cb20103f3cf" + }, + { + "path": "implementation/reference/rank2/reference/leaf/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73" + }, + { + "path": "implementation/reference/rank2/reference/leaf/leaf.py", + "bytes": 17526, + "sha256": "bb46c1a55f1119957a52cd61f2cd957f3f7ad1e9b818c54a852bde09a0773744" + }, + { + "path": "implementation/reference/rank2/reference/linear/NOTICE.md", + "bytes": 2180, + "sha256": "2ac2051c0fbedfd9d11348493456bf479dbdd3104a4e106c8bf36251a72b6a50" + }, + { + "path": "implementation/reference/rank2/reference/linear/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73" + }, + { + "path": "implementation/reference/rank2/reference/linear/linear.py", + "bytes": 13102, + "sha256": "d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33" + }, + { + "path": "implementation/reference/rank2/reference/phase/NOTICE", + "bytes": 808, + "sha256": "5654eeb7fdc1acd6a6d246ef87b1155812efdcd0949f54be78e048fe905fbae0" + }, + { + "path": "implementation/reference/rank2/reference/phase/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73" + }, + { + "path": "implementation/reference/rank2/reference/phase/phase.py", + "bytes": 11734, + "sha256": "2be149aa1be504509bb480f85396f0be302082d638e81422f747daee5a3c1ce7" + }, + { + "path": "implementation/reference/rank2/reference/source/clifford_exact.py", + "bytes": 6824, + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + { + "path": "implementation/reference/rank2/reference/source/native_verify.py", + "bytes": 12323, + "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38" + }, + { + "path": "implementation/reference/translation/NOTICE.md", + "bytes": 1201, + "sha256": "24f5e9957fcd8f6cfdc021ff5bc91bf89e50587997e2a2cb18053949c0e0d205" + }, + { + "path": "implementation/reference/translation/PROOF.md", + "bytes": 19690, + "sha256": "6b76d348203aed15cbc30d104c59571111ccf6cb7bb4592936e9170f736b68e0" + }, + { + "path": "implementation/reference/translation/reference/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73" + }, + { + "path": "implementation/reference/translation/reference/reverse.py", + "bytes": 6649, + "sha256": "4b516d85baf3303db809bc1174394009b1fc71a8f7d17fb6c729ec8bb6aba245" + }, + { + "path": "implementation/reference/translation/translate.py", + "bytes": 7703, + "sha256": "e2750fef8c2b9c8019d67285df3ca0d04340cd241782c7845665b7de621ca3bd" + }, + { + "path": "implementation/verify.py", + "bytes": 11085, + "sha256": "61bb8438cc82064e2aa54a88a4e5675b2f7e04751e7781749ec03398588a2126" + }, + { + "path": "review/independent/RESULT.json", + "bytes": 2920, + "sha256": "78d09fabe35c1d6b91ff6194553f0dfb07ac46d11f671518fbe86981f40e4122" + }, + { + "path": "review/independent/REVIEW.md", + "bytes": 10061, + "sha256": "067a30a7bd923aa45de9d08de9cadf891a201e1c76a04bd0b8049a05e311d26a" + }, + { + "path": "review/independent/independent_check.py", + "bytes": 13800, + "sha256": "c199871df12c5d3fa84f8070b251da03446be532b44aa530d681cbf07def179e" + }, + { + "path": "review/root/RESULT.json", + "bytes": 1505, + "sha256": "837e17f98737a4b700aa710f3fefc831082b0a63e1b1780bc12f0b6be1acd350" + }, + { + "path": "review/root/ROOT-REVIEW.md", + "bytes": 4859, + "sha256": "f0913f8a52847947a358b4e42a41c088df56f54836bef3b5e1ff680f3075192d" + }, + { + "path": "review/root/check_affine_root.py", + "bytes": 6970, + "sha256": "6d14795a3d802c45d31ac46c5b7aad35a64472f9d8db624d0f9e502cf7d6a721" + } + ], + "checksums_file_sha256": "ac13903d2e79a989264303307b51c3540315fa15d0e28f7ebcea89e080df0951", + "verification": "Five registered commands passed; every emitted JSON receipt exactly matches its frozen author/independent/root result. See VALIDATION.json. Scientific bytes unchanged from the registered replay." +} diff --git a/research/literal-fixed-mask-native-translation/PR-DESCRIPTION.md b/research/literal-fixed-mask-native-translation/PR-DESCRIPTION.md new file mode 100644 index 0000000000..0d4364360c --- /dev/null +++ b/research/literal-fixed-mask-native-translation/PR-DESCRIPTION.md @@ -0,0 +1,51 @@ +## Result and why it matters + +Implement every fixed nine-bit native offset in the existing Gamma6/HOME ABI, +for arbitrary positive encoded column count and complete external factors. +A fixed `G e0=b` conjugates one retained first-slot reversal; at most20 CNOTs +suffice. Every component bit and spectator is preserved. This fills the +arbitrary-offset physical composition boundary needed by selected monomials. + +## Exact scope, novelty and costs + +The 31-tape core has `T<=2^20(fV+E+1)` and historical increment +`256(V+E+1)`, where `V=2PScw2^(9f)`. The35-tape HOME wrapper adds +`128(F+1)` time and64(F+1) history for F=E+V. Setup, typed entry, origins, +production and B1 bank transport remain separately paid. Success restores +heads/private fields and preserves the original owner/exteriors. Failure +cleanup is unclaimed. The sixth Gamma cutoff is preserved, not enforced by +this permutation. Pure record movement imposes no signed-range restriction. + +#7428 already supplies first-slot translation/reversal and opaque-tail parsing; +#7430 supplies fixed CNOT movement. The earlier selected rank-one literal join +already has offset1/phase1. This adds arbitrary fixed-mask composition, not +new algebra or the first offset-bearing MOVE. All retained source/notice bytes +are pinned. Canonical base: e54523517d0f03e58352e647c403a5af3e525a57. + +## Verification and reproduction + +Author checks cover all512 masks,15 emitted templates, five complete parser +probes through4097-bit cutoff syntax, dense offset511/far-slot264 packets, +identity, reuse and two actual wrong-map graph mutants. Root uses a separate +sparse CPU and direct address-XOR oracle: a fresh mask292 packet executes +22,467,224 transitions, with24,848 late HOME writes and all35heads/private +fields/exteriors restored. Independent exact-matrix review imports no author code and checks all261,632 +nonzero-mask/one-column cases plus three complete f=2 address spaces. Its +record-block sanity check is not a tape replay. All finite checks corroborate +the written all-f proof. + +```sh +python3 -B scripts/research_package.py --package research/literal-fixed-mask-native-translation +``` + +The registered commands, expected receipts and environment are in VERIFY.json. +The actual source-specific phase/G/X join, caller/header/view production, +packing, allocation and faster nonleaf tariff remain open. No selected +assumption is discharged and no new kappa or unconditional theorem is claimed. + +## Credit + +Prepared for @CubeJerry with substantial OpenAI ChatGPT/Codex assistance. +Predecessor authors and unchanged source notices are retained. The construction, +independent algebra role and separate root physical execution are disclosed; +this is not blind/human review or formal-kernel verification. diff --git a/research/literal-fixed-mask-native-translation/PR-TITLE.txt b/research/literal-fixed-mask-native-translation/PR-TITLE.txt new file mode 100644 index 0000000000..0fe639ae5f --- /dev/null +++ b/research/literal-fixed-mask-native-translation/PR-TITLE.txt @@ -0,0 +1 @@ +Implement arbitrary fixed native address offsets with one reversal and a restored literal HOME return diff --git a/research/literal-fixed-mask-native-translation/README.md b/research/literal-fixed-mask-native-translation/README.md new file mode 100644 index 0000000000..488f1f4875 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/README.md @@ -0,0 +1,78 @@ +# Literal fixed-mask native translation + +For each construction-time mask `b` in `F2^9`, this package implements the +address map `a_i -> a_i XOR (b_i (2^f-1))` on every encoded column of a complete +native packet. It preserves every coefficient/component bit, all outer and +spectator axes, the common grid, header and original supplied owner. The mask +is fixed programme data, not an encoded runtime argument. Pure permutation +needs no arithmetic range promise and permits minimum signed bit patterns. + +## Construction and complete local bill + +A fixed binary map `G` with `G e0=b` gives chronological `G^-1, X0, G`. +The unchanged #7428 first-slot reversal is used once; at most twenty retained +CNOT operations implement both conjugators. The old parser already permits +opaque data immediately after its five Gamma fields; the sixth cutoff field +is preserved without being enforced by this permutation. Zero mask is the +original-owner identity transaction. + +For `V=2PScw2^(9f)`, six-Gamma length `E` and `F=E+V`, the 31-tape core has +`T <= 2^20(fV+E+1)` and historical increment at most `256(V+E+1)`. +The 35-tape HOME wrapper adds `128(F+1)` time and `64(F+1)` history. +Fixed setup/origins, typed reservation, supplied packet production and general +B1 whole-bank transport remain separately paid. Successful calls restore every +head/private body and preserve opaque exteriors. Failure/interruption cleanup +is not claimed. This is a direct leaf bound; the selected nonleaf tariff and +all five framework assumptions remain open. + +## Evidence + +The unchanged original source is under `implementation/`. The author verifier +checks all512 masks, fifteen emitted templates, unused cutoff syntax through +4097 bits, dense offset511 and far-slot264 packets, identity, reuse and actual +wrong-conjugation/omitted-gate controls. Source authentication rejects a changed +retained byte. Normal and optimized Python produce the same scientific receipt. + +The separate root sparse CPU uses a direct address-XOR oracle, independent of +the emitted conjugator and the author's CPU. Its fresh mask292 packet retains +P=S=c=2, width3 and a130-bit cutoff;22,467,224 transitions produce24,848 late +HOME writes with all35 heads/private fields/exteriors restored. Finite packets +corroborate the universal proof and do not execute every positive f. + +Independent exact GF(2) matrix review imports no author code. It verifies all +261,632 nonzero-mask/one-column cases, three complete f=2 address spaces and +selected f=3 lifts. Its direct record-block sanity check is explicitly not a +literal tape replay; the universal lift is proved column by column in the review. + +## Reproduce + +`VERIFY.json` registers author normal/optimized checks, the separate +root physical check and independent exact-matrix review. Run from the repository +root with Python3.12 and the standard library: + +```sh +python3 -B scripts/research_package.py --package research/literal-fixed-mask-native-translation +``` + +See `implementation/PROOF.md`, the role-specific reviews and receipts, and +`PR-DESCRIPTION.md` for exact promises, evidence and publication text. + +## Novelty and credit + +#7428 already implements first-slot translation and its opaque-tail theorem; +#7430 provides fixed binary routing. The earlier selected rank-one join already +includes offset1 and nonzero constant phase. This result adds the arbitrary +fixed-mask literal composition and paid successful Gamma6/HOME lifecycle, not +new affine algebra, the first nonzero-offset MOVE or a faster tariff. Prior +source modules/notices are unchanged. Prepared for @CubeJerry with substantial +OpenAI ChatGPT/Codex assistance; review roles are disclosed and are not blind, +human peer review or formal proof-kernel checks. No new kappa. + +## Open next questions + +- Join one authenticated selected monomial's phase, binary map and offset with + exact column-dependent constant phase and original-grid promises. +- Bind actual source views, header/owner production, address packing and return + to the primitive, retaining all previous backing and complete B1 costs. +- Find and price a different nonleaf movement mechanism before claiming the + selected accelerated tariff or any complete multiplication improvement. diff --git a/research/literal-fixed-mask-native-translation/SOURCES.json b/research/literal-fixed-mask-native-translation/SOURCES.json new file mode 100644 index 0000000000..d86caf6e71 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/SOURCES.json @@ -0,0 +1,83 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1" + }, + { + "path": "docs/research/pr-intake-evidence/pr7000-application/PROOF-REVIEW.md", + "usage": "provenance", + "git_blob": "3dd1af2285e597676725e85ad4f65e7ad326d695", + "sha256": "4501502c2ceb9759b20372435fe4beb51082c5a5e2910c1fd5dbe6edca415055" + } + ], + "external_primary_provenance": "implementation/SOURCES.json and SOURCE-BINDING.json pin the unchanged #7428 first-slot translation/reversal, #7430 CNOT service, prior literal rank-two module and HOME sources. Their notices and exact proof copies remain bundled. implementation/FREEZE.json authenticates the original author package.", + "author_freeze_sha256": "de2753cb42a012e07aa7ace263bedce5c4be8506ae30ab768af9e165a6edd6e0", + "local_scientific_artifacts": [ + { + "path": "implementation/FREEZE.json", + "bytes": 7062, + "sha256": "de2753cb42a012e07aa7ace263bedce5c4be8506ae30ab768af9e165a6edd6e0" + }, + { + "path": "implementation/PROOF.md", + "bytes": 12681, + "sha256": "f43040c6331dc29ecf3f435e980cc71f00a60e421f50f4e843192a23e733bd44" + }, + { + "path": "implementation/affine.py", + "bytes": 3859, + "sha256": "9387d4caa6ea6ad9e232f4a2a07112fa1a681d34af19e5aae64d1d8adc5ebd2c" + }, + { + "path": "implementation/RESULT.json", + "bytes": 5806, + "sha256": "da72e73f0d140e9460e080553dc00c20d9c5fbcec88c9fa174b44a3406989423" + }, + { + "path": "implementation/SOURCE-BINDING.json", + "bytes": 3690, + "sha256": "413d614973ad96a1adf98b70188e8db909931a6838cc87636472452a57abe909" + }, + { + "path": "review/independent/REVIEW.md", + "bytes": 10061, + "sha256": "067a30a7bd923aa45de9d08de9cadf891a201e1c76a04bd0b8049a05e311d26a" + }, + { + "path": "review/independent/independent_check.py", + "bytes": 13800, + "sha256": "c199871df12c5d3fa84f8070b251da03446be532b44aa530d681cbf07def179e" + }, + { + "path": "review/independent/RESULT.json", + "bytes": 2920, + "sha256": "78d09fabe35c1d6b91ff6194553f0dfb07ac46d11f671518fbe86981f40e4122" + }, + { + "path": "review/root/ROOT-REVIEW.md", + "bytes": 4859, + "sha256": "f0913f8a52847947a358b4e42a41c088df56f54836bef3b5e1ff680f3075192d" + }, + { + "path": "review/root/check_affine_root.py", + "bytes": 6970, + "sha256": "6d14795a3d802c45d31ac46c5b7aad35a64472f9d8db624d0f9e502cf7d6a721" + }, + { + "path": "review/root/RESULT.json", + "bytes": 1505, + "sha256": "837e17f98737a4b700aa710f3fefc831082b0a63e1b1780bc12f0b6be1acd350" + } + ] +} diff --git a/research/literal-fixed-mask-native-translation/TASK.json b/research/literal-fixed-mask-native-translation/TASK.json new file mode 100644 index 0000000000..fd055fc4c9 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/TASK.json @@ -0,0 +1,93 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "task_id": "uniform-transfer-audit", + "original_card": { + "id": "uniform-transfer-audit", + "question": "Can one of the selected record's five inherited assumptions be proved at its actual caller?", + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md" + ], + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "acceptance_gate": "Identify the proposition and what would change downstream; do not equate a finite replay with a universal proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "first_experiment": "Choose one assumption ID (native_all_columns, owned_erasure, compiler, precision_tape, analytic_recovery), one quantified implication and exact dependency closure. Check current handoffs, including #5625 row reentry and #5707 root-prefix lowering, without treating their partial scope as the whole theorem. Prove or falsify that implication with a caller-bound argument; stop at the chosen obligation. Finite tests or root digits do not discharge an all-size statement.", + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "overlap_terms": [ + "native_all_columns", + "owned_erasure", + "compiler", + "precision_tape", + "analytic_recovery" + ], + "existing_checks": [ + { + "scope": "PR #4100: proposed unconditional construction and finite checks, without independent acceptance.", + "evidence": "research/unconditional-batched-crt/README.md", + "remaining": "Independent proof audit of one caller-bound all-size implication; all other premises remain explicit.", + "status": "author-checked", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "scope_status": "refined", + "scope_change_reason": "Narrow the inherited-assumption card to a fixed nine-bit arbitrary native offset in the existing physical Gamma6/HOME ABI. Its entry is supplied and the result does not prove an inherited assumption at the actual selected caller.", + "actual_scope": "For every construction-time mask b in F2^9, a fixed literal core translates every encoded column by b on complete nine-slot packets, preserves raw component bits and all spectators, returns its same supplied owner, and pays full local time and historical backing.", + "bottleneck_link": "Nonzero affine offsets occur in selected monomial recipes; this physical fixed-mask interface can surround a future source-bound C join. It supplies neither the source-specific recipe nor the actual owner/header producer, faster tariff or caller.", + "stop_rule": "Stop after the universal fixed-mask composition proof, retained-source authentication, bounded literal all-offset controls and independent physical/address checks. Do not infer complete monomial/MOVE/caller or selected assumption admission.", + "evidence": "implementation/PROOF.md; implementation/FREEZE.json; implementation/SOURCE-BINDING.json; implementation/RESULT.json; review/root/ROOT-REVIEW.md and RESULT.json; review/independent/REVIEW.md, independent_check.py and RESULT.json; VERIFY.json registered commands.", + "author": "@CubeJerry", + "ai_assistance": "Prepared for @CubeJerry with substantial OpenAI ChatGPT/Codex assistance. Construction, exact algebra cross-review and a separate root sparse CPU/address oracle are disclosed; these roles share the proposed mechanism and are not blind or human peer review or formal-kernel verification.", + "outcome": "completed", + "open_questions": [ + { + "question": "Can one authenticated selected multi-bit-offset monomial recipe compose its absolute phase, binary map and this offset in the correct chronology with complete paid lifecycle?", + "why_it_matters": "The offset is only one factor of a selected MOVE; source chronology and scalar phases must be retained.", + "first_step": "Pin one selected monomial ket recipe and prove phase then G then X_b, including constant phase proportional to f, on the complete packet.", + "blocked_by": "The present result deliberately starts with a fixed offset and supplied packet, not a complete source recipe." + }, + { + "question": "Can the actual caller provide and restore a DATA view and header satisfying the physical native interface?", + "why_it_matters": "Uniform semantics at a supplied primitive boundary do not create the view, reserve an owner or pay whole-bank delivery.", + "first_step": "Bind a source-root occurrence to its exact P,S,c,f,width and address packing, with paid head restoration and historical storage.", + "blocked_by": "Actual source acquisition, packing, allocation, B1 delivery and receiver remain separate." + }, + { + "question": "Can a different physical implementation satisfy the selected faster nonleaf monomial tariff?", + "why_it_matters": "The present service costs O_b(fV+E), and serial CNOT motion has a source-specific nonleaf tariff obstruction.", + "first_step": "Write an optimistic full call bill for a genuinely different nonleaf movement mechanism before a new construction.", + "blocked_by": "No accelerated supplier or complete asymptotic recurrence is established here." + } + ] +} diff --git a/research/literal-fixed-mask-native-translation/VALIDATION.json b/research/literal-fixed-mask-native-translation/VALIDATION.json new file mode 100644 index 0000000000..3aaf7ed8ed --- /dev/null +++ b/research/literal-fixed-mask-native-translation/VALIDATION.json @@ -0,0 +1,15 @@ +{ + "schema": "publication-validation/1", + "canonical_base": "e54523517d0f03e58352e647c403a5af3e525a57", + "utc": "2026-11-13 14:15 UTC", + "environment": "3.12.14 (main, Aug 25 2026, 14:00:49) [Clang 22.1.3 ]", + "metadata_and_source_pins": "PASS_PACKAGE_METADATA_AND_PINS", + "registered_replay": "PASS_REGISTERED_RESEARCH_PACKAGE research/literal-fixed-mask-native-translation outcome=completed", + "commands_executed": 5, + "all_five_output_receipts_exactly_match": true, + "author_normal_optimized": true, + "independent_matrix_normal_optimized": true, + "root_separate_sparse_cpu": true, + "registered_log_sha256": "c50973ff81459d6ead353cfe491853c4efcbb21b9c8104c65d7bac7f4656c92e", + "scope": "Local registered execution and disclosed proof review; not human, blind, formal-kernel, caller or complete multiplier admission." +} diff --git a/research/literal-fixed-mask-native-translation/VERIFY.json b/research/literal-fixed-mask-native-translation/VERIFY.json new file mode 100644 index 0000000000..96d277cf00 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/VERIFY.json @@ -0,0 +1,72 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "-W", + "error", + "{package}/implementation/verify.py" + ], + "timeout_seconds": 240, + "checks": "Author exact source/graph/payload/retirement/cost controls; all masks and fifteen tables, unused cutoff, actual wrong-map graph mutants." + }, + { + "argv": [ + "{python}", + "-O", + "-B", + "-W", + "error", + "{package}/implementation/verify.py" + ], + "timeout_seconds": 240, + "checks": "Author replay under optimized Python; exact receipt and source checks remain active." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "-W", + "error", + "{package}/review/independent/independent_check.py", + "{package}/implementation" + ], + "timeout_seconds": 120, + "checks": "Independent GF(2) row-matrix and packed-address checks, source/freeze authentication; no author imports or tape-execution claim." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "-W", + "error", + "{package}/review/independent/independent_check.py", + "{package}/implementation" + ], + "timeout_seconds": 120, + "checks": "The same independent matrix/address checks under optimized Python; explicit require checks remain active." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "-W", + "error", + "{package}/review/root/check_affine_root.py", + "{package}/implementation" + ], + "timeout_seconds": 300, + "checks": "Separate sparse graph CPU and direct XOR-address oracle execute fresh mask292 f1 packet with external P/S/c multiplicities, signed raw extrema, a130bitcutoff, allheads/private/exterior restoration and complete stated bill." + } + ] +} diff --git a/research/literal-fixed-mask-native-translation/implementation/CHECKPOINT.md b/research/literal-fixed-mask-native-translation/implementation/CHECKPOINT.md new file mode 100644 index 0000000000..b357d3ad31 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/CHECKPOINT.md @@ -0,0 +1,24 @@ +Wave14 started13:31 UTC; deadline14:20 UTC. + +#7428 already proves first-slot X translation with opaque arbitrary data after fiveGamma codes. Unchanged trailing cutoff Gamma6 is therefore admitted directly; code consumes E5 bytes, visits its endpoint, trace-returns without reading cutoff. No new reversal or parser is needed. New scoped gap is fixed arbitrary nine-coordinate offset composition in same Gamma6/HOME ABI. Let h=popcount(b), t=popcount(b without bit0). Compose h existing translations and2t 3-CNOT swap words on original9f geometry, one outer transaction. Complete sum h4096(V+E+1)+2t[3072f(V+1)+8192(V+E+1)]+31V+27 fits2^22(fV+E+1). History32h+128t+8<=1320 times(V+E+1), reserve2048; HOME adds128(F+1) time64(F+1) history, B1 separately. No generic MOVE/caller/nonleaf-rate claim. + +In-scope simplification13:38 UTC, suggested by parent: use fixed G e0=b +and chronological G^-1,X0,G. This supersedes the initial per-coordinate +schedule above. One reversal and at most20 total CNOTs suffice; complete +core sum <=61471fV+20480E+20507, reserve2^20(fV+E+1). History168F envelope, +reserve256(V+E+1); HOME adds64(F+1), total320(F+1). + +Author normal replay passed13:42 UTC in21.198 seconds. Full-offset511 and +mixed far-slot264 packets, identity and same-owner reuse pass; wrong-order +and omitted-conjugator actual graphs separate. All512 masks/261632 nonzero +mask-address pairs,15 emitted tables and5 complete Gamma6 parser probes pass. +Optimized replay/source binding and final manifest remain before freeze. + +Completion13:50 UTC: normal21.198s and optimized21.743s receipts agree; +source binding passes26 retained pins and20 original Git blobs. Source/graph +hashes are in SOURCE-BINDING.json and FREEZE.json. Full511 HOME run takes +13648484 transitions/10252 final writes; mixed264 takes28973166/37004. +All35 heads/private/exteriors return. No known defect remains. Parent +independent numerical/source review is pending. The prior positive join and +all earlier frozen packages remain untouched. Generated execution logs are +excluded from the delivered source manifest explicitly. diff --git a/research/literal-fixed-mask-native-translation/implementation/ENVIRONMENT.json b/research/literal-fixed-mask-native-translation/implementation/ENVIRONMENT.json new file mode 100644 index 0000000000..001ca251df --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/ENVIRONMENT.json @@ -0,0 +1,9 @@ +{ + "python": "3.12.14 (main, Aug 25 2026, 14:00:49) [Clang 22.1.3 ]", + "platform": "Linux-6.18.57-x86_64-with-glibc2.41", + "normal_runtime": "elapsed_seconds 21.198", + "optimized_runtime": "elapsed_seconds 21.743", + "normal_optimized_receipts": "identical", + "cache": "fresh required-absent bytecode prefixes before retained imports; no bytecode writes", + "independent_review": "parent independent numerical/source review pending; parent suggested conjugator; author verified exact integer algebra and full Graphs" +} diff --git a/research/literal-fixed-mask-native-translation/implementation/FREEZE.json b/research/literal-fixed-mask-native-translation/implementation/FREEZE.json new file mode 100644 index 0000000000..6a159ddbe8 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/FREEZE.json @@ -0,0 +1,215 @@ +{ + "status": "FROZEN", + "utc": "2026-11-13 13:50 UTC", + "canonical_main": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "CHECKPOINT.md", + "bytes": 2090, + "sha256": "f54a3c992381a400dfacf5c7d92e9913e38ec9f42231e2f7f33d286af66a268e" + }, + { + "path": "ENVIRONMENT.json", + "bytes": 524, + "sha256": "f126bace428d01e7e07ce3455a62a8cd4e706c340b27befcc82098aa613f4e92" + }, + { + "path": "NOTICE.md", + "bytes": 1918, + "sha256": "d562b9cb72403d6edf8007e5065fa5e62f23fc5e27ef412e1c29d7b0dcd91edd" + }, + { + "path": "OVERLAP.md", + "bytes": 2281, + "sha256": "a6a30afc20b2f55eb278abafb8761f8570d093971028c639909a9660eff4f121" + }, + { + "path": "PR-DESCRIPTION.md", + "bytes": 2572, + "sha256": "c4a5e2b37bad44ca24319fea6f9ae31b01fa4c5b351eeea5072d8c8b1d3c78bd" + }, + { + "path": "PROOF.md", + "bytes": 12681, + "sha256": "f43040c6331dc29ecf3f435e980cc71f00a60e421f50f4e843192a23e733bd44" + }, + { + "path": "README.md", + "bytes": 3467, + "sha256": "fda143cc8e0b10eac00c7153c96005271fd31c422d4290777f1de94b6b304fd1" + }, + { + "path": "RESULT.json", + "bytes": 5806, + "sha256": "da72e73f0d140e9460e080553dc00c20d9c5fbcec88c9fa174b44a3406989423" + }, + { + "path": "SOURCE-BINDING.json", + "bytes": 3690, + "sha256": "413d614973ad96a1adf98b70188e8db909931a6838cc87636472452a57abe909" + }, + { + "path": "SOURCES.json", + "bytes": 7336, + "sha256": "abbbd21565ff67a5268d30c034ad33f2143c8b2699bbcccc68569a326ff020b6" + }, + { + "path": "adapter.py", + "bytes": 4903, + "sha256": "3ba85d9c49371841def2dc173b2d53fb271779382cb3eb4248bd93425c3fb46c" + }, + { + "path": "affine.py", + "bytes": 3859, + "sha256": "9387d4caa6ea6ad9e232f4a2a07112fa1a681d34af19e5aae64d1d8adc5ebd2c" + }, + { + "path": "bind_sources.py", + "bytes": 2580, + "sha256": "e765f1d8451682e11c03f73080841ff207b5f1c8710eae24211ebbbd182c4f2a" + }, + { + "path": "machine.py", + "bytes": 6041, + "sha256": "ffe2677bb5b82932873cb08b05f890a1218070215ebe670a0b05079518e8baee" + }, + { + "path": "reference/rank2/FREEZE.json", + "bytes": 5633, + "sha256": "072dfea997d4db796d492eaf746e0bd99630964741b88862d0f10f5fc1e00275" + }, + { + "path": "reference/rank2/PROOF.md", + "bytes": 16634, + "sha256": "93e1ad8a92c3624df064e4f39119ccbb5c96391ea8dd5f7af58edc7ca9638352" + }, + { + "path": "reference/rank2/RECIPE.json", + "bytes": 4468, + "sha256": "b1386ad613213a01f736bc2e7fc7de5a25d2c700c3d577dfb396a266278ae702" + }, + { + "path": "reference/rank2/SOURCES.json", + "bytes": 10337, + "sha256": "659ff7da20d16ece71aabbe240986e884fcaa6f53b5b0f082151e541e0534641" + }, + { + "path": "reference/rank2/machine.py", + "bytes": 6041, + "sha256": "ffe2677bb5b82932873cb08b05f890a1218070215ebe670a0b05079518e8baee" + }, + { + "path": "reference/rank2/rank2.py", + "bytes": 8253, + "sha256": "3ca027f80b6cb973fa064612b8fb18b1306498e064a01e97ff7f9b6aa40b301a" + }, + { + "path": "reference/rank2/reference/home/NOTICE.md", + "bytes": 2093, + "sha256": "b51b8fd0773a1bbe988c8a98d951dc34b175bf56bac772ef65997f1df7ed3842" + }, + { + "path": "reference/rank2/reference/home/parent_adapter.py", + "bytes": 5353, + "sha256": "04462e141548c6a86c500d40b4aee8c446c539bd9269098d7516fa13400ef099" + }, + { + "path": "reference/rank2/reference/home/tape_graph.py", + "bytes": 12069, + "sha256": "7d3cee3e79ba5fe410e1a6b5f4cf6a2fbe5e274f838b798cd8860344ff258b54" + }, + { + "path": "reference/rank2/reference/leaf/NOTICE.md", + "bytes": 1900, + "sha256": "773921ac301cf7e37de97ed8a0066e6bbb69ec1150cc2b5f74a12cb20103f3cf" + }, + { + "path": "reference/rank2/reference/leaf/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73" + }, + { + "path": "reference/rank2/reference/leaf/leaf.py", + "bytes": 17526, + "sha256": "bb46c1a55f1119957a52cd61f2cd957f3f7ad1e9b818c54a852bde09a0773744" + }, + { + "path": "reference/rank2/reference/linear/NOTICE.md", + "bytes": 2180, + "sha256": "2ac2051c0fbedfd9d11348493456bf479dbdd3104a4e106c8bf36251a72b6a50" + }, + { + "path": "reference/rank2/reference/linear/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73" + }, + { + "path": "reference/rank2/reference/linear/linear.py", + "bytes": 13102, + "sha256": "d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33" + }, + { + "path": "reference/rank2/reference/phase/NOTICE", + "bytes": 808, + "sha256": "5654eeb7fdc1acd6a6d246ef87b1155812efdcd0949f54be78e048fe905fbae0" + }, + { + "path": "reference/rank2/reference/phase/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73" + }, + { + "path": "reference/rank2/reference/phase/phase.py", + "bytes": 11734, + "sha256": "2be149aa1be504509bb480f85396f0be302082d638e81422f747daee5a3c1ce7" + }, + { + "path": "reference/rank2/reference/source/clifford_exact.py", + "bytes": 6824, + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + { + "path": "reference/rank2/reference/source/native_verify.py", + "bytes": 12323, + "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38" + }, + { + "path": "reference/translation/NOTICE.md", + "bytes": 1201, + "sha256": "24f5e9957fcd8f6cfdc021ff5bc91bf89e50587997e2a2cb18053949c0e0d205" + }, + { + "path": "reference/translation/PROOF.md", + "bytes": 19690, + "sha256": "6b76d348203aed15cbc30d104c59571111ccf6cb7bb4592936e9170f736b68e0" + }, + { + "path": "reference/translation/reference/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73" + }, + { + "path": "reference/translation/reference/reverse.py", + "bytes": 6649, + "sha256": "4b516d85baf3303db809bc1174394009b1fc71a8f7d17fb6c729ec8bb6aba245" + }, + { + "path": "reference/translation/translate.py", + "bytes": 7703, + "sha256": "e2750fef8c2b9c8019d67285df3ca0d04340cd241782c7845665b7de621ca3bd" + }, + { + "path": "verify.py", + "bytes": 11085, + "sha256": "61bb8438cc82064e2aa54a88a4e5675b2f7e04751e7781749ec03398588a2126" + } + ], + "excluded_generated_paths": [ + "binding.log", + "normal.log", + "optimized.log" + ], + "known_defects": [], + "independent_review": "parent independent numerical/source review pending", + "scope": "fixed arbitrary nine-bit address offset in literal Gamma6/HOME ABI; no source monomial/MOVE/caller/nonleaf admission" +} diff --git a/research/literal-fixed-mask-native-translation/implementation/NOTICE.md b/research/literal-fixed-mask-native-translation/implementation/NOTICE.md new file mode 100644 index 0000000000..ff4f5c7562 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/NOTICE.md @@ -0,0 +1,33 @@ +# Credit and source retention + +Prepared for CubeJerry with substantial OpenAI assistance. Apache-2.0, +following the retained research sources. This is AI-assisted mathematics, +implementation and author testing, not independent human or proof-kernel +admission. Parent independently suggested the fixed CNOT conjugator as an +in-scope simplification; this worker proved, implemented and checked it. + +The retained first-slot translation is #7428, +1dbdaa414cfe4a4a0f015e88a04b52e146566786, including its exact proof and all +source notices. Its complete-record reversal comes from #7427, +7662d01d827c95d90032579c168cae78aa531f2f. Descriptor/Gamma and classical +two-stack/unary-binary lineages credited there are retained. The original +first-slot source application is post-G offset1, not packed fastest bit0. + +The generic fixed CNOT body is #7430, +39b40c465f7636a4bb6d70af28595fe8f70f4f3f. Its fixed-word emitter, relocation +and original-owner transaction are retained from the frozen literal rank2 +package (FREEZE SHA256 +072dfea997d4db796d492eaf746e0bd99630964741b88862d0f10f5fc1e00275). +That source module loads unchanged phase/leaf dependencies even though this +translation executes neither Gaussian arithmetic nor a positive C child. +B's HOME dispatcher b4fcc9d64971fdabd0b1d82cfb749d8aac920437 and bridge +13c29e2df66ba46402d4da5f1d2489ebf333e5fe supply the unchanged split/return +pattern and dense graph interpreter. + +Credit prior physical Gaussian monomial, serial/current-coded monomial, +native affine phase-tag, original-owner runtime-affine and selected all-f +source proofs. This package claims their local lifecycle composition in +the stated ABI, not their algebra or first general affine capability. +All immutable files, Git blobs and SHA256 hashes are pinned by SOURCES.json +and its nested original manifests. No predecessor or earlier frozen package +was modified and no worker remote publication was performed. diff --git a/research/literal-fixed-mask-native-translation/implementation/OVERLAP.md b/research/literal-fixed-mask-native-translation/implementation/OVERLAP.md new file mode 100644 index 0000000000..75c49bedfe --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/OVERLAP.md @@ -0,0 +1,35 @@ +# Prior scope and bounded overlap gate + +Context: canonical e54523517d0f03e58352e647c403a5af3e525a57, inspected +2026-11-13 about13:31–13:35 UTC. The exact #7428 head is +1dbdaa414cfe4a4a0f015e88a04b52e146566786. It already supplies the complete +25-tape first-slot translation, actual descriptors, same-owner commit, +arbitrary opaque header tail, cleanup and O(V+E5) bill. The reversal and +Gamma/unary-to-binary algorithms remain credited unchanged. Gamma6 acceptance +is a direct instance of its opaque-tail theorem, not a new parser result. + +Canonical `research/physical-gaussian-monomial/README.md` supplies encoded +Count controls and a source-relative physical Compact inventory for generic +affine/phase operations. It does not export this fixed local Gamma6/HOME +lifecycle table. `research/current-serial-monomial-leaf/README.md` explicitly +states only the descriptor iterator is literal; numerical control remains +structured source. It leaves complete numerical lifecycle export open. +Canonical `native-affine-phase-tags` supplies affine phase-tag identities, +not a physical tariff/dirty-restoration theorem. `inplace-runtime-affine` +implements a different two-coordinate modular shear with supplied descriptors, +and leaves native/ROW/caller interfaces open. Their broader operations and +same-owner lineage receive credit; no first general affine theorem is claimed. + +The new scope is one fixed table for every construction-time nine-bit offset +in this exact Gamma6/HOME format, using an immutable first-slot translation, +a fixed G e0=b CNOT conjugator and the paid original-owner transaction. It +requires no numerical supplier or runtime offset/descriptor producer beyond +the supplied packet. It does not implement the complete source monomial. + +The latest15 public open PR metadata records, #7500 and the returned update +page, had no matching arbitrary-offset Gamma6 lifecycle package. A targeted +literal+translation PR search returned103 results, only the first30 metadata +items inspected. This is bounded reconnaissance, not exhaustive literature +priority. #7477 improves failure retirement in reversal banks; this package +retains the source-pinned #7428 successful-return contract and claims no +failure cleanup. The source/caller/selected-rate boundaries remain separate. diff --git a/research/literal-fixed-mask-native-translation/implementation/PR-DESCRIPTION.md b/research/literal-fixed-mask-native-translation/implementation/PR-DESCRIPTION.md new file mode 100644 index 0000000000..7e96766608 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/PR-DESCRIPTION.md @@ -0,0 +1,40 @@ +Title: Emit arbitrary fixed native offsets with literal Gamma6/HOME return + +The current literal translation flips only output/native slot0. Reuse that +complete descriptor/reversal pass unchanged and conjugate it by a fixed CNOT +word G with G e0=b for each nine-bit offset b. Chronological G^{-1},X0,G +implements the complete all-column address XOR with one reversal and at most +20 CNOTs. The original9f geometry, every component bit and the complete +six-Gamma header remain unchanged. One outer transaction commits on the +same original owner only after all factors return and private work retires. + +#7428 already proves first-slot translation, including opaque data after +its fifth Gamma code; accepting the trailing cutoff is that existing theorem's +direct instance. Earlier physical/serial Gaussian-monomial work already +supplies broader algebra/operations in other ABIs. The new contribution is +the arbitrary fixed-offset31-tape lifecycle table and35-tape owned HOME +return in this exact packed format. There is no new reversal, tensor identity, +runtime matrix loader, generic source MOVE or kappa claim. + +Complete successful core time is bounded by2^20(fV+E+1), with incremental +historical backing256(V+E+1). HOME adds128(F+1) time and64(F+1) backing; +general bank routing, fixed program/setup and typed owned producers/placement +remain separate charges. Pure bit permutation needs no arithmetic headroom. +The selected faster nonleaf monomial tariff is not inherited. + +Normal/optimized author checks authenticate exact retained sources, test +all512 conjugators on all512 native addresses and inspect15 literal templates. +Five full first-slot parser probes preserve cutoff syntax through4097 bits, +with HEADER reads exactly inside the five-field prefix and equal runtime. +Full f1 HOME runs cover all-nine-bit offset511 with minimum signed component, +mixed far slots3/8 with outer/spectator/coefficient multiplicities, identity +and same-owner history reuse. Direct address-XOR oracles separate actually +executed omitted-conjugator and wrong-order graphs. All35 heads/private +bodies/guards/exteriors restore on success, with public writes delayed until +complete primitive return. Independent parent replay remains separately +labelled pending; large-f DATA execution is not claimed here. + +Remaining obligations are the actual source monomial binary/phase/offset +composition, typed source/owner and grid producers, complete caller and +nonleaf charging. This primitive does not implement every selected MOVE, +admit a recursive caller or discharge a foundational assumption. diff --git a/research/literal-fixed-mask-native-translation/implementation/PROOF.md b/research/literal-fixed-mask-native-translation/implementation/PROOF.md new file mode 100644 index 0000000000..0131b44215 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/PROOF.md @@ -0,0 +1,228 @@ +# Literal arbitrary fixed native offset in the Gamma6/HOME ABI + +## 1. Prior scope and quantified statement + +Canonical context is e54523517d0f03e58352e647c403a5af3e525a57. PR #7428 at +1dbdaa414cfe4a4a0f015e88a04b52e146566786 already implements the first-slot +translation X0, including actual descriptor production, complete-record +reversal, same-owner return and successful cleanup. Its25-tape translation +and retained13-tape reversal are unchanged here. The original proof is +retained as reference/translation/PROOF.md, exact Git blob +5c6325471aaed465737491870443f063c821b7a0. No new reversal, numeral conversion, +translation algebra, physical Gaussian-monomial theorem or faster tariff is +claimed. The new object is the fixed arbitrary-offset literal composition +and owned Gamma6/HOME return. + +Fix a construction-time integer b in0..511, representing a vector of F2^9. +It is not an encoded runtime parameter. Supply positive f,c,P,S,w,cutoff in +six canonical Gamma codes on HEADER. Let E5 count the first five codes and +E=E6 count all six. DATA is the complete lexicographic array +`[P] x [2^f]^9 x [S]`, with c complete Gaussian coefficient records per +address, real then imaginary, each component w raw MSB-first bits. Thus +`V=2PScw2^(9f)`, `F=E+V`. This permutation works at every positive w; +there is no arithmetic or signed-headroom requirement. Any common quantum +or interpretation of those component bits remains unchanged. + +The complete V-bit body ends in a blank. Owners are distinct; heads start +at their supplied origins, required private windows/guards are blank, and +opaque exteriors/earlier history remain charged. Supply the usual Gamma6 +owned HOME entry after typed reservation when using that layer. No source +owner selector, input producer, new ownership credit or full caller is +inferred from this entry contract. + +**Theorem.** For each fixed b the emitted31-tape four-symbol program sends +every source address `(a0,...,a8)` to + +`(ai XOR [bi*(2^f-1)])_(i=0..8)`. + +It copies each complete coefficient/component bit without alteration and +preserves P/S spectators, header/cutoff, width, owner identity, opaque +exteriors and quantum. Every head returns and every private body/guard +retires on success. One outer transaction installs the complete result on +the original DATA owner only after all factors return. No failure cleanup, +interruption/retry or general malformed-input theorem is asserted. + +With fixed program/origins supplied, complete successful bounds are + +`T_core <= 2^20(fV+E+1)`, +`K_final <= K_entry+256(V+E+1)`. + +The35-tape Gamma6/HOME adapter adds128(F+1) time and64(F+1) historical +backing, giving320(F+1) total increment, and returns exactly F bits to the +same supplied HOME. General B1 bank delivery/return is separately charged +at O(R_bank K_bank(F+1)). Fixed program/table construction, authentication +and origin provisioning have a fixed Setup_b charge if not already supplied. +No encoded size is decoded into a host runtime loop or graph generator. + +## 2. Why the unchanged five-field parser accepts Gamma6 + +This compatibility is already an instance of #7428's explicit opaque-tail +theorem: its section2 permits opaque data immediately after the fifth code. +The code provides a direct refinement. `compile_translation` calls Gamma +exactly five times for f,c,P,S,w, then immediately `trace_return(HEADER)`. +Each header step advances exactly one bit while extending HTRACE. Therefore +all HEADER reads lie at offsets0..E5-1. The final step visits offset E5, +which may be the first cutoff bit, but does not read or write it. + +The trace return branches only on its private trace and moves HEADER back +one cell for each consumed bit. It reads/writes no trailing header cell. +All later descriptor production uses the captured unary guides. The +retained reversal receives PDESC/RDESC/BDESC/DATA and private roles, never +HEADER. Final producer cleanup likewise has no HEADER operation. Hence the +sixth Gamma field is unchanged, regardless of its represented value or +length; HEADER returns to its original origin. The unchanged CNOT word +parser also reads just these first five fields and trace-returns, as in +the frozen Gamma6 rank2/positive joins. + +The original translation bill is4096(V+E5+1) with32(V+E5+1) private backing. +Replacing E5 by the larger E is a valid bound. The HOME splitter additionally +reads and copies the complete sixth code using a guide for its bit length, +not a unary expansion of the numerical cutoff. Its O(F+1) work remains paid. +This permutation has no positive-child cutoff branch and does not assert +rho*f<=cutoff. The sixth field is preserved format, not a newly enforced +leaf admission condition. + +## 3. Fixed conjugator and exact all-column action + +For b=0 no component runs; the outer original-owner transaction is the +identity. For b nonzero let p be its least supported coordinate. Construct +a fixed chronological CNOT word G: + +- If p>0, first exchange slots0 and p using `(0<-0 xor p), + (p<-p xor0),(0<-0 xor p)`. +- For every other supported coordinate j, append `(j<-j xor p)`. + +The slot exchange sends e0 to ep. All following gates leave its p bit1 +and set exactly the other supported coordinates. Thus G e0=b. If p=0, +the initial exchange is absent. Every CNOT is an involution, so reversing +the word gives G^{-1}. If b0=1 the word has popcount(b)-1<=8 gates; if +b0=0 it has3+popcount(b)-1<=10. No minimality claim is made. + +Chronologically execute G^{-1}, X0, G. For one nine-bit column x this gives + +`G(G^{-1}x XOR e0) = x XOR G e0 = x XOR b`. + +The retained generic CNOT body applies its fixed slot pair to all matching +f columns in the unchanged nine-slot geometry. The retained X0 complements +every one of slot0's f bits. Therefore the same identity holds separately +on each actual column. Equivalently, every supported full slot is XORed +with2^f-1. All other native bits and complete P/S/coefficient/component +factors remain spectators. There is no address-space enlargement or +changed f header. + +Every component is a pure permutation of complete records and has scalar +phase exactly1. The construction changes no sign, Gaussian component, bit +order within a record or grid. It accepts the most-negative signed bit +pattern because it never negates an arithmetic value. In the source ket +convention `|x> -> i^q(x)|G_source x XOR b>`, this X_b is applied after the +source binary map; its coordinate bit i denotes output packed slot i. +This observation fixes the intended offset convention but does not bind a +complete source monomial or MOVE. + +## 4. Literal relocation, owner return and helper reuse + +The old first-slot translation remains the same1878-location graph. The +two fixed CNOT words use immutable rank2 `compile_word` and unchanged +generic `cnot_columns`. Word generation is an offline function of b; no +runtime branch reads b, chooses p, loads a matrix or computes a jump. +For b=1 the word is empty and both CNOT modules are omitted. Otherwise one +reverse word, one X0 body and one forward word execute, at most20 CNOTs. + +The outer transaction clones original DATA once to WORK and restores its +head with TRACE. Immutable `insert` maps component HEADER0 to original +HEADER, component DATA1 to WORK, and private t>=2 to t+2. Fixed PC labels +are relocated and successful halt becomes a one-step continuation goto. +Thus every runtime operation is read/write/unit move/goto/halt. The largest +component port is26 from the CNOT module, mapping to28;31 ports are retained +for compatibility with the shared native cohort. Unused ports stay blank. + +Each completed component preserves HEADER, returns its public factor DATA +to origin and clears private bodies/guards. Therefore the same private +owners can be reused by the next component. Module commits affect only +WORK. After all components succeed, one V-bit final copy commits on original +DATA, erases WORK and records/restores both heads. WORK/TRACE guards then +retire. No component can write original DATA through its relocated ports. +Structural checks confirm this before the final commit for15 mask templates. + +HOME uses the retained six-code split/return with native origins at +B-relative2, blank guard1 and permanent^ at0. Core ports map injectively +to3..33; GUIDE is34. On success unchanged header and transformed body are +repacked, all split copies erase, and all35 heads return to their B origins. +B1 scatters only after primitive return, to the same immutable HOME. This +is a supplied owned operand; the parked productive fixture is unchanged. + +## 5. Complete successful invoice and retained history + +Use the credited complete translation bound +`T_X<=4096(V+E5+1)<=4096(V+E+1)` and generic fixed-word bound +`T_G(k)<=1024 k f(V+1)+8192(V+E+1)`, including all descriptor acquisition, +full body/bit copying, actual arithmetic-free record routing, returns and +retirement. Let k<=10 be this b's fixed conjugator length. The complete +nonzero-offset sum, allowing two word envelopes even when k0, is + +`4096(V+E+1)+2048k f(V+1)+16384(V+E+1)+31V+27`. + +With f(V+1)<=2fV and V<=fV this is bounded by + +`(4096k+20511)fV+20480E+20507` +`<=61471fV+20480E+20507<=2^20(fV+E+1)`. + +The zero-offset transaction costs31V+27 and also fits. The full cutoff +syntax is charged by E and the HOME overhead. There are no unpaid supplied +reversal descriptors: X0 physically produces P,2^f and2Scw2^(8f), including +unary expansion, linear-time unary/binary conversion, complete record +reversal and descriptor retirement. No helper, outer copy or return is an +oracle callback or an unpriced recursive child. + +Incremental private visited backing is at most32(V+E+1) for X0, +64(V+E+1) per fixed binary word and8(V+E+1) for WORK/TRACE. Summing rather +than refunding completed factors gives168(V+E+1)<256(V+E+1). The identity +uses only the outer increment. HOME adds64(F+1), giving the stated320(F+1) +envelope. Fixed setup/program storage and B1 full-bank delivery remain +separate charges. K_entry retains every older visited region and opaque +owner allocation. Shorter successful calls reuse erased current bodies +without refunding previous maxima. Changed origins require actual interval +unions and paid transport corridors. + +This is a direct O_b(fV+E) routine. It does not inherit the faster selected +nonleaf monomial tariff, establish amortization in a full recurrence, bind +the source recipe/owner, or supply a producer of the Gamma6 ABI. + +## 6. Evidence and exact limitations + +The algebra checker independently evaluates every nonzero b on all512 +addresses:261632 conjugation/inverse pairs, all512 masks including identity, +and an actual maximum conjugator length10. It does not compile512 large +graphs for code-coverage credit. Fifteen emitted mask templates, including +every single coordinate, identity, full511 and maximum-word510, pass port, +PC, unit-move and no-early-original-write checks. + +Five complete retained-X0 runs use five-field prefix length11 and Gamma6 +cutoffs with bit lengths1,2,64,513,4097. A read observer records HEADER +read offsets exactly0..10 and head maximum11 in every run; no HEADER write +occurs. All five take exactly681487 steps, return the expected complete +8192-bit raw permutation and restore all25 heads/private bodies/exteriors. +These observers never affect execution control. + +The full-offset511 packet uses all512 addresses with distinct10-bit real +labels and imaginary labels including the minimum signed value. Its10240 +DATA bits return against direct address-XOR oracle in13648484 transitions, +with10252 final HOME writes only after complete primitive return. A mixed +far-slot b264 packet exercises slots3 and8 plus two outer rows, three +spectators and two Gaussian coefficients. It returns36864 DATA bits in +28973166 transitions with37004 final HOME writes. Identity and smaller +same-owner reuse also pass; earlier guide history remains charged. All35 +heads/private bodies/guards/exteriors restore on successful complete runs. + +Actual graph mutants remove the last conjugator gate (returning offset255 +instead of511), or reorder the block as G^{-1},G,X0 (returning offset1). +Both complete cleanly but fail the correct XOR oracle. A changed retained +translation source byte rejects at authentication. Normal and optimized +author replays compare exact receipts. These are finite evidence; the +all-size result uses the preceding invariants and inherited helper proofs. + +No full large-f DATA execution is claimed here; the original first-slot +predecessor already includes a complete f2 fixture, credited as inherited +evidence. No generic source monomial dispatcher, all-MOVE implementation, +full owned lifetime, caller admission, selected rate, assumption discharge +or new kappa follows from this isolated bit-permutation interface. diff --git a/research/literal-fixed-mask-native-translation/implementation/README.md b/research/literal-fixed-mask-native-translation/implementation/README.md new file mode 100644 index 0000000000..7971d4119d --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/README.md @@ -0,0 +1,59 @@ +# Literal arbitrary fixed affine offset on complete native packets + +For every fixed nine-bit offset b, this package emits a complete same-owner +Gamma6/HOME translation on `[P] x [2^f]^9 x [S]` at every positive encoded +geometry. Slot i is XORed with2^f-1 exactly when bit i of b is set. Every +component bit, coefficient, spectator, header/cutoff and common grid is +preserved. The operation is a pure address permutation, including at minimum +signed component values; there is no arithmetic headroom promise. + +The existing #7428 first-slot translation is retained unchanged. Its theorem +already permits an opaque tail after the first five Gamma codes, so the +trailing sixth cutoff is accepted without a new parser. A fixed conjugator +G with G e0=b gives the chronological composition G^{-1},X0,G: one reversal +and at most20 literal CNOTs. For b=0 the outer transaction is the identity. +Offset/pivot/word generation occurs offline and never inspects runtime +geometry. The construction does not supply a runtime matrix/offset loader. + +The core uses31 tapes and has complete successful bounds + +`T_core<=2^20(fV+E+1)`, `K_final<=K_entry+256(V+E+1)`. + +Here `V=2PScw2^(9f)` and E includes all six Gamma codes. The35-tape HOME +layer adds128(F+1) time and64(F+1) backing, where F=E+V. General B1 bank +access, fixed setup/program storage and owned input production/placement +remain separately paid. All heads/private bodies/guards retire on success; +failure cleanup and interruption/retry are unclaimed. + +Reproduce with only the Python standard library; numerical runs take about +21 seconds each: + +```sh +python -B /workspace/scratch/92c9920affc2/worker-a/research/generic-affine-native-translation/verify.py +python -O -B /workspace/scratch/92c9920affc2/worker-a/research/generic-affine-native-translation/verify.py +python -B /workspace/scratch/92c9920affc2/worker-a/research/generic-affine-native-translation/bind_sources.py +``` + +The verifier checks all512 offset conjugators on all512 native addresses, +15 literal templates, five complete parser-boundary probes through4097-bit +cutoff syntax, and full dense f1 HOME executions for full offset511, mixed +far slots3/8, identity and same-owner reuse. Direct address-XOR oracles do +not simulate the emitted conjugators. Actual omission and conjugation-order +mutants return the predicted wrong maps. All35 heads/private/exteriors and +public-before-commit safety are checked. Fresh absent bytecode-cache prefixes +isolate source replay; exact pins and graph hashes are in SOURCES.json and +SOURCE-BINDING.json. `--write` refreshes the corresponding receipt. + +This closes one literal affine-offset interface. Earlier physical Gaussian +monomial and current serial/coded monomial work already covers broader +semantic operations in other source/Count ABIs; their algebra is not new +here. No generic source monomial dispatcher, complete MOVE, actual caller, +nonleaf tariff, global assumption discharge or kappa change is claimed. + +Open next questions are exact source-specific composition with binary and +complete linear/quadratic/global phase passes, numerical/source orientation +and owned producers, then caller/rate admission. C's independent census +confirms offsets are post-G output-coordinate masks and that every support +size1..9 occurs; this package neither duplicates that census nor infers +all-MOVE implementation from its offset domain. Earlier frozen packages +remain unchanged. The proof and exact limitations are in PROOF.md. diff --git a/research/literal-fixed-mask-native-translation/implementation/RESULT.json b/research/literal-fixed-mask-native-translation/implementation/RESULT.json new file mode 100644 index 0000000000..6959be0b1f --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/RESULT.json @@ -0,0 +1,249 @@ +{ + "algebra": { + "masks": 512, + "max_CNOTs_per_word": 10, + "nonzero_mask_address_pairs": 261632 + }, + "controls": [ + "omitted conjugator target", + "wrong conjugation order", + "actual retained-source corruption", + "no early original-owner write", + "cutoff parser extent" + ], + "core_tapes": 31, + "executed_mutants": [ + { + "actual_offset": 255, + "mutation": "omit_last_conjugator_gate", + "steps": 12404582 + }, + { + "actual_offset": 1, + "mutation": "wrong_conjugation_order", + "steps": 13648484 + } + ], + "full_offset": { + "E": 12, + "F": 10252, + "HOME_writes": 10252, + "V": 10240, + "core_return_steps": 13566388, + "offset": 511, + "output_sha256": "9c426b3d6a5063d87ccf058dfb2966670dec8db3e3cef6907dc00a6abd9d1f89", + "shape": [ + 1, + 1, + 1, + 1, + 10, + 1 + ], + "steps": 13648484, + "visited_increment": 169090 + }, + "identity": { + "E": 8, + "F": 2056, + "HOME_writes": 2056, + "V": 2048, + "core_return_steps": 80058, + "offset": 0, + "output_sha256": "91a006761793de4b1d9854700d2566dee5b828b80f6c58dd111b66821e8c2fb7", + "shape": [ + 1, + 1, + 1, + 1, + 2, + 1 + ], + "steps": 96586, + "visited_increment": 8271 + }, + "marker": "PASS_LITERAL_GENERIC_AFFINE_HOME", + "mixed_far_offset": { + "E": 140, + "F": 37004, + "HOME_writes": 37004, + "V": 36864, + "core_return_steps": 28677054, + "offset": 264, + "output_sha256": "ddd0884c8c548927cd1e8d35307f5e159932252bca8b409ea7cc096f075eceaa", + "shape": [ + 1, + 2, + 2, + 3, + 3, + 9223372036854775808 + ], + "steps": 28973166, + "visited_increment": 478521 + }, + "parser_probes": [ + { + "E5": 11, + "E6": 12, + "cutoff_bits": 1, + "header_head_max": 11, + "header_read_max": 10, + "steps": 681487 + }, + { + "E5": 11, + "E6": 14, + "cutoff_bits": 2, + "header_head_max": 11, + "header_read_max": 10, + "steps": 681487 + }, + { + "E5": 11, + "E6": 138, + "cutoff_bits": 64, + "header_head_max": 11, + "header_read_max": 10, + "steps": 681487 + }, + { + "E5": 11, + "E6": 1036, + "cutoff_bits": 513, + "header_head_max": 11, + "header_read_max": 10, + "steps": 681487 + }, + { + "E5": 11, + "E6": 8204, + "cutoff_bits": 4097, + "header_head_max": 11, + "header_read_max": 10, + "steps": 681487 + } + ], + "same_owner_reuse": { + "F": 2570, + "retained_guide_high": 30779, + "shape": [ + 1, + 1, + 1, + 1, + 2, + 231584178474632390847141970017375815706539969331281128078915168015826259279872 + ], + "steps": 2831353 + }, + "scope": "fixed-offset address permutation only; no source-MOVE/caller/monomial dispatcher/nonleaf admission", + "tables": [ + { + "CNOT_word_length": 0, + "commit": 31, + "locations": 65, + "offset": 0, + "sha256": "e2dbdab7f3aad4b875d757b28c04797c8bd2b90f916683abb17d60f78cc50ba8" + }, + { + "CNOT_word_length": 0, + "commit": 1909, + "locations": 1943, + "offset": 1, + "sha256": "b17ca072a1d1fa11140e952f98d513b71a0610afb494f298a1201b3d46f659f4" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 2, + "sha256": "1409d8c17b2e4feef4e4c0a65c413cd37336155d1d45b6a476f989aab1198903" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 4, + "sha256": "9deaaa9b634d49e555262c843f914d032e3ccc3d8b203a49b4a5420b9cdcd524" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 8, + "sha256": "c7f54b1f3f6c660b86fcd4afc75b6b27cab8d23d3a3a381e3a1a5062eb592bea" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 16, + "sha256": "6485ef9b185ab61d97fa6c43c197816537ef2c2af5fbb59fc1cf4862549652fd" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 32, + "sha256": "7bc8de28232d99b2bea8f637eb74bcb2df8b44c1dfa0af3f8b8ff59392fc8f34" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 64, + "sha256": "bf38c5fb0827aad8d3ee6c46e6f057d4044607c8626b9975ac44d338d1310bd0" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 128, + "sha256": "a9378489d83ec8a6c95030cd6a077d317b23c4684207bae7b37fb9b0e7fbcfce" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 256, + "sha256": "1c30af17c0055e9a29d7afd82c7205ef764c52244cb1060e94a0576345c77b98" + }, + { + "CNOT_word_length": 1, + "commit": 7251, + "locations": 7285, + "offset": 3, + "sha256": "581646d95f614c1d48860e57b0d0264bacd37a7a68a57447b11a2463e6cac96f" + }, + { + "CNOT_word_length": 1, + "commit": 7251, + "locations": 7285, + "offset": 17, + "sha256": "c66bbbd9366fe03c40620c7d7d326d07549d8f9a6a034406546f9d644910aa42" + }, + { + "CNOT_word_length": 4, + "commit": 14511, + "locations": 14545, + "offset": 264, + "sha256": "e1c3b6f6b6047d67c1f8eaae5d656cad9bad2f0a9cec4b40bc3bc82dbc0a2c42" + }, + { + "CNOT_word_length": 10, + "commit": 29031, + "locations": 29065, + "offset": 510, + "sha256": "4a566abab2cd35ad29e672bb973532b9a60faa5102213455a98e7c304a162b40" + }, + { + "CNOT_word_length": 8, + "commit": 24191, + "locations": 24225, + "offset": 511, + "sha256": "03660b3587683a09379316f6b923d6b1e12faa088872453525860296922d2180" + } + ], + "tapes": 35 +} diff --git a/research/literal-fixed-mask-native-translation/implementation/SOURCE-BINDING.json b/research/literal-fixed-mask-native-translation/implementation/SOURCE-BINDING.json new file mode 100644 index 0000000000..3b3fbeca8d --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/SOURCE-BINDING.json @@ -0,0 +1,138 @@ +{ + "status": "PASS", + "retained_pins": 26, + "original_git_blobs": 20, + "core_templates": [ + { + "CNOT_word_length": 0, + "commit": 31, + "locations": 65, + "offset": 0, + "sha256": "e2dbdab7f3aad4b875d757b28c04797c8bd2b90f916683abb17d60f78cc50ba8" + }, + { + "CNOT_word_length": 0, + "commit": 1909, + "locations": 1943, + "offset": 1, + "sha256": "b17ca072a1d1fa11140e952f98d513b71a0610afb494f298a1201b3d46f659f4" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 2, + "sha256": "1409d8c17b2e4feef4e4c0a65c413cd37336155d1d45b6a476f989aab1198903" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 4, + "sha256": "9deaaa9b634d49e555262c843f914d032e3ccc3d8b203a49b4a5420b9cdcd524" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 8, + "sha256": "c7f54b1f3f6c660b86fcd4afc75b6b27cab8d23d3a3a381e3a1a5062eb592bea" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 16, + "sha256": "6485ef9b185ab61d97fa6c43c197816537ef2c2af5fbb59fc1cf4862549652fd" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 32, + "sha256": "7bc8de28232d99b2bea8f637eb74bcb2df8b44c1dfa0af3f8b8ff59392fc8f34" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 64, + "sha256": "bf38c5fb0827aad8d3ee6c46e6f057d4044607c8626b9975ac44d338d1310bd0" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 128, + "sha256": "a9378489d83ec8a6c95030cd6a077d317b23c4684207bae7b37fb9b0e7fbcfce" + }, + { + "CNOT_word_length": 3, + "commit": 12091, + "locations": 12125, + "offset": 256, + "sha256": "1c30af17c0055e9a29d7afd82c7205ef764c52244cb1060e94a0576345c77b98" + }, + { + "CNOT_word_length": 1, + "commit": 7251, + "locations": 7285, + "offset": 3, + "sha256": "581646d95f614c1d48860e57b0d0264bacd37a7a68a57447b11a2463e6cac96f" + }, + { + "CNOT_word_length": 1, + "commit": 7251, + "locations": 7285, + "offset": 17, + "sha256": "c66bbbd9366fe03c40620c7d7d326d07549d8f9a6a034406546f9d644910aa42" + }, + { + "CNOT_word_length": 4, + "commit": 14511, + "locations": 14545, + "offset": 264, + "sha256": "e1c3b6f6b6047d67c1f8eaae5d656cad9bad2f0a9cec4b40bc3bc82dbc0a2c42" + }, + { + "CNOT_word_length": 10, + "commit": 29031, + "locations": 29065, + "offset": 510, + "sha256": "4a566abab2cd35ad29e672bb973532b9a60faa5102213455a98e7c304a162b40" + }, + { + "CNOT_word_length": 8, + "commit": 24191, + "locations": 24225, + "offset": 511, + "sha256": "03660b3587683a09379316f6b923d6b1e12faa088872453525860296922d2180" + } + ], + "HOME_graphs": [ + { + "offset": 0, + "states": 242, + "json_bytes": 17022, + "sha256": "78336f60a8c0a9f4d6e2d17b691c0a2642498db76df9c6ec892c0a9fc4bd6de8" + }, + { + "offset": 264, + "states": 14722, + "json_bytes": 981180, + "sha256": "215d911f83df35ede59c7a75ee2ee6977c6bbcf7a663ac92f6a3292492ac83a7" + }, + { + "offset": 510, + "states": 29242, + "json_bytes": 1975523, + "sha256": "869b6cf4d876ab07311698be7165e04f219354b0df90fa15f0c471efc2b23717" + }, + { + "offset": 511, + "states": 24402, + "json_bytes": 1644051, + "sha256": "c1b78c510299ba98b63e1c573623966a689d2226b0fa5bbaed1ab42275f9e746" + } + ] +} diff --git a/research/literal-fixed-mask-native-translation/implementation/SOURCES.json b/research/literal-fixed-mask-native-translation/implementation/SOURCES.json new file mode 100644 index 0000000000..425edf16d6 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/SOURCES.json @@ -0,0 +1,182 @@ +{ + "canonical_main": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "local": "reference/rank2/rank2.py", + "bytes": 8253, + "sha256": "3ca027f80b6cb973fa064612b8fb18b1306498e064a01e97ff7f9b6aa40b301a", + "parent_local": "rank2.py" + }, + { + "local": "reference/rank2/SOURCES.json", + "bytes": 10337, + "sha256": "659ff7da20d16ece71aabbe240986e884fcaa6f53b5b0f082151e541e0534641", + "parent_local": "SOURCES.json" + }, + { + "local": "reference/rank2/RECIPE.json", + "bytes": 4468, + "sha256": "b1386ad613213a01f736bc2e7fc7de5a25d2c700c3d577dfb396a266278ae702", + "parent_local": "RECIPE.json" + }, + { + "local": "reference/rank2/reference/linear/linear.py", + "bytes": 13102, + "sha256": "d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33", + "parent_local": "reference/linear/linear.py" + }, + { + "local": "reference/rank2/reference/linear/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73", + "parent_local": "reference/linear/inputs/controller_reference.py" + }, + { + "local": "reference/rank2/reference/linear/NOTICE.md", + "bytes": 2180, + "sha256": "2ac2051c0fbedfd9d11348493456bf479dbdd3104a4e106c8bf36251a72b6a50", + "parent_local": "reference/linear/NOTICE.md" + }, + { + "local": "reference/rank2/reference/phase/phase.py", + "bytes": 11734, + "sha256": "2be149aa1be504509bb480f85396f0be302082d638e81422f747daee5a3c1ce7", + "parent_local": "reference/phase/phase.py" + }, + { + "local": "reference/rank2/reference/phase/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73", + "parent_local": "reference/phase/inputs/controller_reference.py" + }, + { + "local": "reference/rank2/reference/phase/NOTICE", + "bytes": 808, + "sha256": "5654eeb7fdc1acd6a6d246ef87b1155812efdcd0949f54be78e048fe905fbae0", + "parent_local": "reference/phase/NOTICE" + }, + { + "local": "reference/rank2/reference/leaf/leaf.py", + "bytes": 17526, + "sha256": "bb46c1a55f1119957a52cd61f2cd957f3f7ad1e9b818c54a852bde09a0773744", + "parent_local": "reference/leaf/leaf.py" + }, + { + "local": "reference/rank2/reference/leaf/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73", + "parent_local": "reference/leaf/inputs/controller_reference.py" + }, + { + "local": "reference/rank2/reference/leaf/NOTICE.md", + "bytes": 1900, + "sha256": "773921ac301cf7e37de97ed8a0066e6bbb69ec1150cc2b5f74a12cb20103f3cf", + "parent_local": "reference/leaf/NOTICE.md" + }, + { + "local": "reference/rank2/reference/source/clifford_exact.py", + "bytes": 6824, + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962", + "parent_local": "reference/source/clifford_exact.py" + }, + { + "local": "reference/rank2/reference/source/native_verify.py", + "bytes": 12323, + "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38", + "parent_local": "reference/source/native_verify.py" + }, + { + "local": "reference/rank2/reference/home/tape_graph.py", + "bytes": 12069, + "sha256": "7d3cee3e79ba5fe410e1a6b5f4cf6a2fbe5e274f838b798cd8860344ff258b54", + "parent_local": "reference/home/tape_graph.py" + }, + { + "local": "reference/rank2/machine.py", + "bytes": 6041, + "sha256": "ffe2677bb5b82932873cb08b05f890a1218070215ebe670a0b05079518e8baee", + "parent_local": "machine.py" + }, + { + "local": "reference/rank2/reference/home/parent_adapter.py", + "bytes": 5353, + "sha256": "04462e141548c6a86c500d40b4aee8c446c539bd9269098d7516fa13400ef099", + "parent_local": "reference/home/parent_adapter.py" + }, + { + "local": "reference/rank2/reference/home/NOTICE.md", + "bytes": 2093, + "sha256": "b51b8fd0773a1bbe988c8a98d951dc34b175bf56bac772ef65997f1df7ed3842", + "parent_local": "reference/home/NOTICE.md" + }, + { + "local": "machine.py", + "bytes": 6041, + "sha256": "ffe2677bb5b82932873cb08b05f890a1218070215ebe670a0b05079518e8baee", + "parent_local": "machine.py" + }, + { + "local": "reference/rank2/PROOF.md", + "bytes": 16634, + "sha256": "93e1ad8a92c3624df064e4f39119ccbb5c96391ea8dd5f7af58edc7ca9638352", + "parent_local": "PROOF.md", + "role": "frozen parent proof/manifest" + }, + { + "local": "reference/rank2/FREEZE.json", + "bytes": 5633, + "sha256": "072dfea997d4db796d492eaf746e0bd99630964741b88862d0f10f5fc1e00275", + "parent_local": "FREEZE.json", + "role": "frozen parent proof/manifest" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "1dbdaa414cfe4a4a0f015e88a04b52e146566786", + "path": "research/native-translation-descriptor/translate.py", + "local": "reference/translation/translate.py", + "bytes": 7703, + "sha256": "e2750fef8c2b9c8019d67285df3ca0d04340cd241782c7845665b7de621ca3bd", + "blob": "5e1149f8ab45e0d5b4ecd963674ff8659d7f014b" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "1dbdaa414cfe4a4a0f015e88a04b52e146566786", + "path": "research/native-translation-descriptor/reference/reverse.py", + "local": "reference/translation/reference/reverse.py", + "bytes": 6649, + "sha256": "4b516d85baf3303db809bc1174394009b1fc71a8f7d17fb6c729ec8bb6aba245", + "blob": "60fce51dd8c3336e2bcf2873df254190e2203e14" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "1dbdaa414cfe4a4a0f015e88a04b52e146566786", + "path": "research/native-translation-descriptor/reference/inputs/controller_reference.py", + "local": "reference/translation/reference/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73", + "blob": "3ab6d0361f35038ffcdf0cf81a157f7a17b40e72" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "1dbdaa414cfe4a4a0f015e88a04b52e146566786", + "path": "research/native-translation-descriptor/NOTICE.md", + "local": "reference/translation/NOTICE.md", + "bytes": 1201, + "sha256": "24f5e9957fcd8f6cfdc021ff5bc91bf89e50587997e2a2cb18053949c0e0d205", + "blob": "903e332da2844843fbb1ad716b6d470f175e8de9" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "1dbdaa414cfe4a4a0f015e88a04b52e146566786", + "path": "research/native-translation-descriptor/PROOF.md", + "local": "reference/translation/PROOF.md", + "bytes": 19690, + "sha256": "6b76d348203aed15cbc30d104c59571111ccf6cb7bb4592936e9170f736b68e0", + "blob": "5c6325471aaed465737491870443f063c821b7a0" + } + ], + "parent_rank2_freeze_sha256": "072dfea997d4db796d492eaf746e0bd99630964741b88862d0f10f5fc1e00275", + "translation_head": "1dbdaa414cfe4a4a0f015e88a04b52e146566786", + "translation_proof_blob": "5c6325471aaed465737491870443f063c821b7a0", + "translation_proof_path": "research/native-translation-descriptor/PROOF.md" +} diff --git a/research/literal-fixed-mask-native-translation/implementation/adapter.py b/research/literal-fixed-mask-native-translation/implementation/adapter.py new file mode 100644 index 0000000000..7351ffa5c4 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/adapter.py @@ -0,0 +1,117 @@ +"""Paid Gamma6/HOME adapter for fixed-offset affine translation. + +Derived from the frozen rank2 adapter; Apache-2.0; Codex-assisted. +""" +from functools import cache +from hashlib import sha256 +import importlib.util +from pathlib import Path +import sys +import json + +HERE=Path(__file__).resolve().parent +sys.dont_write_bytecode=True +sys.pycache_prefix=str(HERE/'_unwritten_bytecode_cache') +if Path(sys.pycache_prefix).exists(): + raise ValueError('bytecode isolation path must remain absent') +import affine as C +B1=HERE/'reference/rank2/reference/home/tape_graph.py' +D=C.load('affine_home_dispatch', B1) +CORE_BASE,GUIDE,TAPES=3,34,35 + + +@cache +def core(offset,mutation=None): + code,alphabet,_=C.compile_translation(offset,mutation) + if alphabet!=('_','0','1','|'): + raise ValueError('changed fixed alphabet') + return code + + +def steps(g,tape,count,target): + for _ in range(abs(count)): + target=g.jump(target,((tape,1 if count>0 else -1),)) + return target + + +def copy_out(g,source,target,after): + state=g.state('repack') + g.add(state,after,tests=((source,'_'),)) + for bit in '01': + g.add(state,state,tests=((source,bit),),writes=((target,bit),(source,'_')), + moves=((source,1),(target,1))) + return state + + +def embed(g,code,after,offset): + labels=[g.state('AFFINE_B'+str(offset)) for _ in code] + for pc,(op,*args) in enumerate(code): + state=labels[pc];g.rules.setdefault(state,[]) + nxt=labels[pc+1] if pc+1>slot)&1) + return tuple(word) + + +def components(offset,mutation=None): + offset=fixed_offset(offset) + if offset==0: + return [] + word=conjugator(offset) + if mutation=='omit_last_conjugator_gate' and word: + word=word[:-1] + flip=('X0_',T.compile_translation()) + if not word: + return [flip] + before=('G_inverse_',P.compile_word(tuple(reversed(word)))) + after=('G_',P.compile_word(word)) + return [before,after,flip] if mutation=='wrong_conjugation_order' else [before,flip,after] + + +def compile_translation(offset,mutation=None): + """One complete original-owner transaction for a fixed offset, even zero.""" + factors,a=components(offset,mutation),Builder() + for tape in (WORK,TRACE): + a.op('move',tape,-1);a.op('write',tape,MARK);a.op('move',tape,1) + a.mark('clone') + a.op('read',DATA,{'0':'clone0',ONE:'clone1',BLANK:'cloned'}) + for bit in BITS: + a.mark('clone'+bit) + a.op('write',WORK,bit);a.op('move',WORK,1);a.op('move',DATA,1) + a.op('write',TRACE,ONE);a.op('move',TRACE,1);a.op('goto','clone') + a.mark('cloned');P.return_source(a);a.rewind(WORK,BITS) + entries={} + for index,(name,(code,alphabet)) in enumerate(factors): + entries[name]=len(a.code) + after=factors[index+1][0]+'0' if index+1budget:raise ValueError('finite execution budget') + return state + + def _general(self,state,rules): + tapes=state.tapes;heads=state.heads;lows=state.lows;highs=state.highs;writes=state.writes + found=None + for rule in rules: + if all(tapes[t][heads[t]]==symbol for t,symbol in rule[0]): + if found is not None:raise ValueError('nondeterministic emitted table') + found=rule + if found is None:raise Rejected('literal scanned-symbol rejection') + for t,value in found[1]: + if heads[t]==state.origins[t] and value!=SYMBOLS['^']: + raise MonitorViolation('attempted permanent B origin marker overwrite') + tapes[t][heads[t]]=value;writes[t]+=1 + for t,delta in found[2]: + if delta not in (-1,0,1):raise ValueError('nonunit emitted move') + heads[t]+=delta + if not 0<=heads[t]=2, the exact six positive canonical +Gamma codes `(f,r,P,S,w,cutoff)`, and the complete lexicographic packed array + +`[P] x [2^f]^9 x [S]`, `V=2PSr2^(9f)w`, `F=E+V`. + +E counts every header bit, including a potentially enormous cutoff code. +At each address there are r Gaussian coefficients, real then imaginary, +each signed w-bit MSB-first. Their common caller quantum Delta is unchanged. +r is coefficient multiplicity. The native rank two changes neither r nor +the nine f-bit slots. The direct entry condition is **2f<=cutoff**. + +Require the right and left phase rotations to fit signed w bits, and every +output of each of the actual2f central C axes to be Gaussian-integral on +the same grid and fit signed w bits. Final fit alone does not supply these +prefix conditions. All complete spectators and coefficient fields remain. +The native local boundary supplies distinct owners, heads at their origins, +blank required private windows/guards and preserved opaque exteriors, as in +the retained factors. Existing historical backing remains charged. + +**Theorem.** One fixed115776-location,31-tape four-symbol local program +returns `U^(tensor f)` on the original DATA owner, restores HEADER, all heads, +private bodies/guards and opaque exteriors, under these promises. It checks +2f against the actual cutoff. A valid-format cutoff or numerical rejection +precedes every original DATA write; failure cleanup/retry is unclaimed. +Its complete successful direct bounds are + +`T_core<=2^24(fV+E+1)`, +`K_final<=K_entry+1024(V+E+1)`. + +The supplied packed HOME adapter emits115953 states on35 fixed tapes. It +returns the identical Gamma6 header and transformed DATA to the same owned +HOME1526, with + +`T_HOME<=128(F+1)+2^24(fV+E+1)`, +`K_final<=K_entry+1088(F+1)`. + +B1's general full-bank gathering/return is separately charged at its +`O(R K(F+1))` invoice. The test graph uses an already-reserved typed owned +entry. It constructs neither INIT1526 nor a complete enclosing caller. + +## 2. Exact nontrivial factors and all-column geometry + +The complete matrices, alpha/Q fields and80 retained records are in +RECIPE.json. In the source convention a monomial sends +`|x> -> i^q(x) |Gx>`; both offsets and constant phases are zero. The rows are + +``` +G_R=(258,11,321,66,4,328,16,32,128), +G_L=(6,11,16,34,64,128,3,256,1). +``` + +Its right phase is + +`q_R=x0+2x1+x3+2x6` +` +2(x0x1+x0x3+x0x6+x0x8+x1x3+x1x6+x1x8+x3x6+x3x8) mod4`. + +Its left phase is `q_L=2x0+3x1 mod4`. Q's diagonal is already encoded in +alpha and is not added twice. The left36 records consist of five S records +and31 CNOTs. The right44 consist of six S, nine CZ and29 CNOTs. The literal +phase compiler handles each complete phase in one body pass, retaining the +actual simultaneous residue and signed range guards. It does not serially +negate an intermediate component just to realize that record list. + +For columns x_j the phase is `sum_j q(x_j)` (the constant term is zero). +Each binary row addition acts on the matching bit j in its two complete +f-bit slots. The retained CNOT routine derives every prefix/middle/suffix +length from the original header and executes all f columns. Fixed word +order is preserved. The generic fixed-word emitter in rank2.py changes +only which fixed source CNOTs call that unchanged routine. Its proof applies +to any distinct fixed slot pair in0..8; no runtime matrix loader is used. + +Let S01 exchange slots0 and1 through the fixed CNOT word +`(0<-0 xor1),(1<-1 xor0),(0<-0 xor1)`. It is an exact permutation with no +phase. The chronological factor list is + +| Order | Literal component | +|---:|---| +|1|Rank-aware entry guard, original header retained| +|2|Right complete phase| +|3|Right29-CNOT binary map| +|4|Unchanged positive first-slot C leaf on all f axes| +|5|S01, three CNOTs on every column| +|6|Unchanged positive first-slot C leaf again| +|7|S01 again| +|8|Left complete phase| +|9|Left31-CNOT binary map| + +Because S01 C0 S01=C1 and the two disjoint C blocks commute, the central +time sequence C0,S01,C0,S01 is exactly `C0 C1`. This retains all9f address +bits and implements the desired positive `C^(tensor2f)` on the first two +slots. Setting the existing leaf header's f to2f would instead change its +hard-coded nine-slot volume to2^(18f); that is not this construction. + +The independent source engine checks the exact interleaved central circuit, +including its phase, against C0 C1. Tensoring this fixed product proves the +all-f result, including arbitrary full spectators and r coefficients. No +tensor power is distributed over a sum or scalar ADD. + +## 3. Literal rank-aware entry and complete transaction + +The new guard uses the retained Gamma/unary/binary comparison routines on +their same29 ports. It decodes f and captures its canonical binary digits +and length. It appends one physical zero to the captured binary word and +one mark to its length. These are exactly the digits/length of2f. The +original unary F guide and public header are unchanged. It decodes the other +four bounded integers, reads cutoff only in binary, compares length then +lexicographic digits, and returns/clears its complete work. It never loops +over the numerical cutoff. Thus f<=cutoff<2f rejects even though both +unchanged single-slot leaves would individually accept. + +The whole core clones original DATA once onto WORK and uses TRACE to return +the original head. Every factor's public DATA port is WORK, its HEADER port +is original HEADER, and private port t>=2 maps to t+2. WORK and TRACE are +distinct from all reused module-private owners. The maximum module port28 +maps to30, so ports0..30 suffice. Each retained instruction's port and PC +are relocated; its successful halt is a one-step goto continuation. No +runtime callback, scalar oracle, size-specialized table or free return +implements a component. + +Every completed factor returns all its heads and clears its private work. +Consequently the same27 module-private tapes can be reused by the next +factor. An intermediate public commit of a retained module changes only +WORK. The original DATA receives no write until all nine components have +returned. The single final V-bit copy installs the complete result on the +same original owner, records its return trace, erases WORK and disposes +WORK/TRACE guards. No owner is replaced, relabelled or given productive credit. + +Rejection may leave private data/heads dirty. The core has no original-DATA +WRITE before its final commit location115742. The HOME adapter similarly +keeps all core activity private and scatters only after complete successful +return. This proves original public preservation on the stated finite +cutoff/numerical failures, including failure in the second C pass after a +completed first C and swap. It does not prove interruption rollback or retry. + +## 4. Exact numerical domain and sufficient reserve + +The retained leaf uses actual w+2-bit signed temporary numerators and exact +parity/range guards. Its four real rows have three plus signs and one minus, +so their actual values lie within the proved w+2 range for signed w-bit +inputs. Each retained phase rejects a requested negation of the unique +most-negative component. Copying or swapping that component without +negation is permitted. These concrete conditions, not an abstract fused +Gaussian primitive, are the numerical premises in section1. + +A useful sufficient caller condition is: all original components are +divisible by2^f, bounded in absolute value by M, and + +`2^f M <= 2^(w-1)-1`. + +The credited denominator/component-norm facts for a j-axis C prefix give +denominator dividing2^ceil(j/2) and component maximum norm2^ceil(j/2). +For j<=2f, both exponents are at most f. R preserves divisibility and +component magnitude, so every actual central prefix is integral and +symmetric-range bounded; permutations and L's unit phase remain safe. +This is a sufficient reserve, not a necessary domain or new norm theorem. + +No scale, width converter or rounding is installed. The original common +quantum, w and all header bits return unchanged. The selected application +review's common grid p+D and width p+h+2D+3 provide a conditional semantic +route, but this module does not emit its actual parameter/header producer +or assert that it supplies the sufficient divisibility condition above. +A caller may instead prove the precise correlated-prefix premises. + +## 5. Complete time and historical backing + +Every local read, write, unit move, goto and halt costs one step. All scans, +descriptor production, source copies, arithmetic, component seeks, history +returns and retirement below are included. Source helper prices are exact: +rewind3n+3, unary clear7n+4, unary copy +`(6+5t+z)n+5e+7`, doubling47n+18. Gamma prefix values sum to less than the +decoded value. Set Z=f+r+P+S+w<=5V. + +For the rank guard, five conversions including their trace/capture work +fit256(E+Z+1), the appended binary/length marks fit32(E+1), binary cutoff +decoding and the length/lexicographic comparison fit128(E+1), and all +remaining guide/guard returns and erasure fit128(E+Z+1). These follow by +the displayed helper prices and constant-depth prefix/tail loops; every +extra retained binary track is at most E+1. The larger envelope +`1024(E+Z+1)<=6144(V+E+1)` therefore covers the guard. Reserve +`65536(V+E+1)` to simplify the aggregate. + +The unchanged per-CNOT geometry/pass/retirement proof gives a bound for any +fixed k-gate nine-slot word: + +`T_G(k)<=1024 k f(V+1)+8192(V+E+1)`. + +The per-gate price does not depend on the old selected19/27-word counts. +The new four words have k=29,3,3,31, for a total66 CNOTs. Their shapes, +geometry construction, complete clone/commit and cleanup are all paid. +The other credited complete bounds are + +* two first-slot leaves: each65536(fV+E+1); +* each m=9 phase: at most65536(E+65V+1); +* outer whole-call transaction: exactly31V+27. + +Their sum, with f(V+1)<=2fV and V<=fV, is at most + +`8884255 fV +360448 E +360475 <=2^24(fV+E+1)`. + +This counts both active C blocks and every helper; no separately unpaid +recursive child is hidden in the bill. It is a direct-leaf rate. At a fixed +admitted active-axis cutoff q,2f<=q makes it O_q(F+1). Encoded cutoff value +and E are not made constants by that statement. No faster nonleaf tariff, +global kappa or complete selected dispatcher follows. + +For historical backing, the guard visits at most6V+7E+57 additional cells: +five decoded unary guides, DOUBLE, header trace/length, binary words and +lengths, all guard/end cells and public header positions. This is below +64(V+E+1). Each fixed binary word and each C leaf has credited complete +increment64(V+E+1), independent of its fixed word length. Each phase fits +256(V+E+1). The outer WORK/TRACE transaction adds8(V+E+1). Adding rather +than refunding successive increments gives + +`(64+4*64+2*64+2*256+8)(V+E+1)=968(V+E+1)<1024(V+E+1)`. + +K_entry includes every owner's complete earlier/opaque backing. At fixed +origins shorter successful calls scan only current live bodies and reuse +already blank tails, while earlier visited maxima remain. Changed origins +require actual interval unions and separately paid corridors; erasure or +new virtual names do not refund backing. + +## 6. Supplied owned HOME and following scalar contacts + +The retained B1 adapter copies/splits exactly six Gamma codes and complete +DATA onto private native HEADER/DATA. Its native origins are B-relative2, +leaving guard cell1 blank and preserving permanent B origin marker^ at0. +Core ports map injectively to3..33 and the header-length guide uses34. +Thus35 fixed tapes suffice. A larger consumer may reuse these after return; +the rank2 service does not allocate one tape per column or coefficient. + +On successful core return, it copies HEADER then DATA back to the complete +operand, erases copies and restores all heads/guards to B origins. The +unchanged scan/count proof gives adapter time128(F+1) and increment64(F+1). +B1 scatters exactly F bits to the same immutable HOME. Its general +full-bank delivery/return remains O(R K(F+1)); one local adapter is not an +unpriced complete source caller. The test's two homes contain one parked +productive input and the supplied live owned1526 packet. Entry is +graph.execution_start, after reservation, and productive_count=1 is fixture +bookkeeping. Owned1526 receives no productive credit or typed INIT here. + +Because the operation returns the exact original header, w/grid, geometry +and F, the existing signed HOME ADD can consume1526 after this return if +receiver1515 is supplied in frame470 with the identical header/common grid. +Frame/grid equality is a typed premise, not inferred from header bits. +That ADD preserves source1526 and costs4096(F+1), with increment8(F+2). +The four exterior SUBs at28041/28129/28135/28139 require matching frame601 +packets beforehand. Their coefficients stay-1 for every f; they are not +tensor-powered scalar signs. The ADD at28159 stays+1. + +For just these five arithmetic contacts and one MOVE, a conservative +standalone primitive bill is + +`20608(F+1)+2^24(fV+E+1)`, + +plus actual B1 delivery/reservation and all source/receiver production. +This is a boundary compatibility/ledger, not a six-event execution or the +full9582-event interval. INIT28037, receiver INIT28153, subsequent-1/4 SCALE, +dirty CLEAR37618, all intervening events and their producers remain separate. +No zero-at-CLEAR or free release theorem is asserted. + +## 7. Evidence, overlap and limits + +The full actual m=9,f=1 dense Gaussian packet returns on its owned HOME in +25854536 transitions, with5132 HOME writes only after complete primitive +return. A smaller nonzero packet reuses the same owners in20881778 steps +and retains the larger previous guide history. A wrong full-graph constant +phase returns exactly i times the expected image, so the oracle separates +the actual absolute phase. All35 heads, bodies/guards and opaque exteriors +return on successful cases. The forward oracle uses the original two frame +circuits and complete numerator accumulation, not the emitted factor word. + +The cutoff rejection f=1,cutoff=1 takes118370 transitions with no HOME write. +A source-constructed numerical case completes first C plus slot swap after +12601857 steps, has its complete intermediate WORK checked, then rejects +the second C at12803606 steps, again with no HOME write. Its failure cleanup +is deliberately unclaimed. Twenty-six guard-only header cases reach f129 +and4097-bit cutoff syntax at distinct signed origins; those are not full +f2/f129 DATA executions. Actual changed retained bytes, wrong source phase, +inverse quotient and a one-C substitute are rejected/separated. + +Source-complete positive rank-two leaves and their rank-scaled23-value +descriptor/cutoff already exist in #6978. Its protected whole MOVE retains +the two monomial/ordinary-provider premises and explicitly leaves their +supplier-free/literal join open. The present object is this actual owned +601→470 fixed-table join and unchanged Gamma6/HOME packet, not new C tensor +algebra, new rank-two factorization or first rank-two leaf. The prior selected +rank1 join, phase/G/leaf tables and HOME adapter retain their credit. Related +rank-two clean scalar conjugators/Pauli fusion macros do not supply these +complete stream tables. Bounded searches and exact pins are in OVERLAP.md. + +No endpoint scaling, full lifetime, format producer, arbitrary malformed +packet guarantee, rejection reuse, materialized uniform source word or +nonleaf supplier is supplied. All five selected assumptions and +kappa=.00363005817 remain. This is an AI-authored proof and finite replay, +not human or formal-kernel acceptance. diff --git a/research/literal-fixed-mask-native-translation/implementation/reference/rank2/RECIPE.json b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/RECIPE.json new file mode 100644 index 0000000000..04f5dc8367 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/RECIPE.json @@ -0,0 +1,490 @@ +{ + "source_event_index": 28141, + "source_event": [ + "MOVE", + 1526, + 601, + 470, + true + ], + "frames": { + "601": [ + 137 + ], + "470": [ + 75, + 137, + 265 + ] + }, + "retained_event": 19592, + "retained_role": 1421, + "rank": 2, + "left": { + "linear_Z4": [ + 2, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "matrix_rows": [ + 6, + 11, + 16, + 34, + 64, + 128, + 3, + 256, + 1 + ], + "offset": 0, + "phase": 0, + "quadratic_rows": [ + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + "right": { + "linear_Z4": [ + 1, + 2, + 0, + 1, + 0, + 0, + 2, + 0, + 0 + ], + "matrix_rows": [ + 258, + 11, + 321, + 66, + 4, + 328, + 16, + 32, + 128 + ], + "offset": 0, + "phase": 0, + "quadratic_rows": [ + 331, + 329, + 0, + 331, + 0, + 0, + 11, + 0, + 11 + ] + }, + "left_records": [ + [ + "S", + 0 + ], + [ + "S", + 0 + ], + [ + "S", + 1 + ], + [ + "S", + 1 + ], + [ + "S", + 1 + ], + [ + "XROW", + 7, + 8 + ], + [ + "XROW", + 8, + 7 + ], + [ + "XROW", + 7, + 8 + ], + [ + "XROW", + 2, + 5 + ], + [ + "XROW", + 1, + 5 + ], + [ + "XROW", + 0, + 5 + ], + [ + "XROW", + 5, + 8 + ], + [ + "XROW", + 8, + 5 + ], + [ + "XROW", + 5, + 8 + ], + [ + "XROW", + 4, + 6 + ], + [ + "XROW", + 6, + 4 + ], + [ + "XROW", + 4, + 6 + ], + [ + "XROW", + 8, + 3 + ], + [ + "XROW", + 0, + 3 + ], + [ + "XROW", + 3, + 6 + ], + [ + "XROW", + 6, + 3 + ], + [ + "XROW", + 3, + 6 + ], + [ + "XROW", + 8, + 2 + ], + [ + "XROW", + 1, + 2 + ], + [ + "XROW", + 0, + 2 + ], + [ + "XROW", + 2, + 3 + ], + [ + "XROW", + 3, + 2 + ], + [ + "XROW", + 2, + 3 + ], + [ + "XROW", + 8, + 1 + ], + [ + "XROW", + 3, + 1 + ], + [ + "XROW", + 0, + 1 + ], + [ + "XROW", + 8, + 0 + ], + [ + "XROW", + 6, + 0 + ], + [ + "XROW", + 0, + 1 + ], + [ + "XROW", + 1, + 0 + ], + [ + "XROW", + 0, + 1 + ] + ], + "right_records": [ + [ + "S", + 0 + ], + [ + "S", + 1 + ], + [ + "S", + 1 + ], + [ + "S", + 3 + ], + [ + "S", + 6 + ], + [ + "S", + 6 + ], + [ + "CZ", + 0, + 1 + ], + [ + "CZ", + 0, + 3 + ], + [ + "CZ", + 0, + 6 + ], + [ + "CZ", + 0, + 8 + ], + [ + "CZ", + 1, + 3 + ], + [ + "CZ", + 1, + 6 + ], + [ + "CZ", + 1, + 8 + ], + [ + "CZ", + 3, + 6 + ], + [ + "CZ", + 3, + 8 + ], + [ + "XROW", + 6, + 8 + ], + [ + "XROW", + 3, + 8 + ], + [ + "XROW", + 1, + 8 + ], + [ + "XROW", + 7, + 8 + ], + [ + "XROW", + 8, + 7 + ], + [ + "XROW", + 7, + 8 + ], + [ + "XROW", + 3, + 6 + ], + [ + "XROW", + 0, + 6 + ], + [ + "XROW", + 5, + 7 + ], + [ + "XROW", + 7, + 5 + ], + [ + "XROW", + 5, + 7 + ], + [ + "XROW", + 4, + 6 + ], + [ + "XROW", + 6, + 4 + ], + [ + "XROW", + 4, + 6 + ], + [ + "XROW", + 5, + 3 + ], + [ + "XROW", + 0, + 3 + ], + [ + "XROW", + 3, + 4 + ], + [ + "XROW", + 4, + 3 + ], + [ + "XROW", + 3, + 4 + ], + [ + "XROW", + 2, + 4 + ], + [ + "XROW", + 4, + 2 + ], + [ + "XROW", + 2, + 4 + ], + [ + "XROW", + 3, + 1 + ], + [ + "XROW", + 2, + 1 + ], + [ + "XROW", + 0, + 1 + ], + [ + "XROW", + 2, + 0 + ], + [ + "XROW", + 0, + 1 + ], + [ + "XROW", + 1, + 0 + ], + [ + "XROW", + 0, + 1 + ] + ] +} diff --git a/research/literal-fixed-mask-native-translation/implementation/reference/rank2/SOURCES.json b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/SOURCES.json new file mode 100644 index 0000000000..0ea6091131 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/SOURCES.json @@ -0,0 +1,232 @@ +{ + "schema": "literal-rank2-source-pins/1", + "canonical_main": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "39b40c465f7636a4bb6d70af28595fe8f70f4f3f", + "path": "research/literal-selected-linear-maps/linear.py", + "local": "reference/linear/linear.py", + "bytes": 13102, + "sha256": "d56704082b82e37d4a360b8aad7e0af63499f4160c6bbcfd338804453c46fa33", + "blob": "6aad40a6c47ed4415917c86fabbd5227a3819a41" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "39b40c465f7636a4bb6d70af28595fe8f70f4f3f", + "path": "research/literal-selected-linear-maps/inputs/controller_reference.py", + "local": "reference/linear/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73", + "blob": "3ab6d0361f35038ffcdf0cf81a157f7a17b40e72" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "39b40c465f7636a4bb6d70af28595fe8f70f4f3f", + "path": "research/literal-selected-linear-maps/NOTICE.md", + "local": "reference/linear/NOTICE.md", + "bytes": 2180, + "sha256": "2ac2051c0fbedfd9d11348493456bf479dbdd3104a4e106c8bf36251a72b6a50", + "blob": "3a3030f23df347c1e45ddf92d2083f89ed16cc67" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "172f4535ce8dcff79f626410af845f757c1563be", + "path": "research/literal-native-quadratic-phase/phase.py", + "local": "reference/phase/phase.py", + "bytes": 11734, + "sha256": "2be149aa1be504509bb480f85396f0be302082d638e81422f747daee5a3c1ce7", + "blob": "d48978145821fc4a62d534bef2bef9449bda883a" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "172f4535ce8dcff79f626410af845f757c1563be", + "path": "research/literal-native-quadratic-phase/inputs/controller_reference.py", + "local": "reference/phase/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73", + "blob": "3ab6d0361f35038ffcdf0cf81a157f7a17b40e72" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "172f4535ce8dcff79f626410af845f757c1563be", + "path": "research/literal-native-quadratic-phase/NOTICE", + "local": "reference/phase/NOTICE", + "bytes": 808, + "sha256": "5654eeb7fdc1acd6a6d246ef87b1155812efdcd0949f54be78e048fe905fbae0", + "blob": "7a1f1da9c59d40b1e72905fee5344a8db9ca4353" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "1a555e469b89af70d309bc966f8f813ac11dc887", + "path": "research/literal-positive-c-leaf/leaf.py", + "local": "reference/leaf/leaf.py", + "bytes": 17526, + "sha256": "bb46c1a55f1119957a52cd61f2cd957f3f7ad1e9b818c54a852bde09a0773744", + "blob": "bdcc80cbd8b64c601e6d69b7d25ece444b8b1ae2" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "1a555e469b89af70d309bc966f8f813ac11dc887", + "path": "research/literal-positive-c-leaf/inputs/controller_reference.py", + "local": "reference/leaf/inputs/controller_reference.py", + "bytes": 5938, + "sha256": "e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73", + "blob": "3ab6d0361f35038ffcdf0cf81a157f7a17b40e72" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "1a555e469b89af70d309bc966f8f813ac11dc887", + "path": "research/literal-positive-c-leaf/NOTICE.md", + "local": "reference/leaf/NOTICE.md", + "bytes": 1900, + "sha256": "773921ac301cf7e37de97ed8a0066e6bbb69ec1150cc2b5f74a12cb20103f3cf", + "blob": "71c5f6dae2c799ce5d76c544e98d1ee7c52ef76c" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "172f4535ce8dcff79f626410af845f757c1563be", + "path": "research/literal-native-quadratic-phase/reference/clifford_exact.py", + "local": "reference/source/clifford_exact.py", + "bytes": 6824, + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962", + "blob": "166841a037f069249f6f7f6dedb89248812f59e2" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "172f4535ce8dcff79f626410af845f757c1563be", + "path": "research/literal-native-quadratic-phase/reference/native_verify.py", + "local": "reference/source/native_verify.py", + "bytes": 12323, + "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38", + "blob": "2c209dfa9cfade3bc20ac5fc9d876b433a147f8c" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "b4fcc9d64971fdabd0b1d82cfb749d8aac920437", + "path": "research/compiler-permanent-home-dispatch/tape_graph.py", + "local": "reference/home/tape_graph.py", + "bytes": 12069, + "sha256": "7d3cee3e79ba5fe410e1a6b5f4cf6a2fbe5e274f838b798cd8860344ff258b54", + "blob": "f307133f2b0bba2e5969825cb814503d819322e7" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "13c29e2df66ba46402d4da5f1d2489ebf333e5fe", + "path": "research/source-bound-move-home-primitive/machine.py", + "local": "machine.py", + "bytes": 6041, + "sha256": "ffe2677bb5b82932873cb08b05f890a1218070215ebe670a0b05079518e8baee", + "blob": "fcd4ac01f03a4689fe9fa45d4ca5ea95950103da" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "13c29e2df66ba46402d4da5f1d2489ebf333e5fe", + "path": "research/source-bound-move-home-primitive/adapter.py", + "local": "reference/home/parent_adapter.py", + "bytes": 5353, + "sha256": "04462e141548c6a86c500d40b4aee8c446c539bd9269098d7516fa13400ef099", + "blob": "10606f87dcfa0781bcae900d95cb86925961d453" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "13c29e2df66ba46402d4da5f1d2489ebf333e5fe", + "path": "research/source-bound-move-home-primitive/NOTICE.md", + "local": "reference/home/NOTICE.md", + "bytes": 2093, + "sha256": "b51b8fd0773a1bbe988c8a98d951dc34b175bf56bac772ef65997f1df7ed3842", + "blob": "db83fd95e175c90a2f9e51545b4be4557fbb919e" + } + ], + "generated": [ + { + "local": "RECIPE.json", + "sha256": "b1386ad613213a01f736bc2e7fc7de5a25d2c700c3d577dfb396a266278ae702" + } + ], + "upstream_artifacts": [ + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "172f4535ce8dcff79f626410af845f757c1563be", + "path": "research/literal-native-quadratic-phase/reference/selected-native.json.gz", + "bytes": 350722, + "sha256": "2b94953dc14a122e3ef089633f05b58ec689ec5156feb7c784ed3e137dc01883", + "blob": "74563a7867d9d762b6588f65362369668841bb3e", + "canonical_sha256": "91429a6b96729292a8764836e00c87a6f7cd3b76f05159033f4867f69a98d097" + } + ], + "proof_inputs": [ + { + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/owned-ascent-contract/RECIPES.json", + "bytes": 126616, + "sha256": "d6753d91211e7c919519835b1e3da04bb165674ab3c93cd74e4768ca0c7e444f", + "blob": "bde1249d259e8633c9a5eb6afceae12bfb3cd351", + "role": "exact retained36/44 record recipe and older identity" + }, + { + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/owned-ascent-contract/PROOF.md", + "bytes": 17222, + "sha256": "6479ac35c78a773adde421fdb1127472554c7687f038c4516d5ae8a962f4120d", + "blob": "32ff104fa88f7968ac5f66f804f28565bfcd84aa", + "role": "owned quotient/lifetime and dirty-return scope" + }, + { + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/owned-ascent-contract/verify.py", + "bytes": 12434, + "sha256": "748bcd3a4d78002ff065c67872650bf9bfae8f0ab87fef8af2bfda4d4a31d2e6", + "blob": "b3683d81a1b4b6f7468cf3cb52f6144375d3377f", + "role": "ownership flag source semantics" + }, + { + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "docs/research/pr-intake-evidence/pr7000-application/PROOF-REVIEW.md", + "bytes": 25533, + "sha256": "4501502c2ceb9759b20372435fe4beb51082c5a5e2910c1fd5dbe6edca415055", + "blob": "3dd1af2285e597676725e85ad4f65e7ad326d695", + "role": "current exact common grid, full factor and exterior scalar contract" + }, + { + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "path": "research/current-coded-all-source-leaf/PROOF.md", + "bytes": 20312, + "sha256": "2943afc32745929374e8e55daff82b5fa78baa8a557d82b231d04b936c63c10d", + "blob": "5d619cfc2d3b7bc51e6fcc8e7a46ecd1e313e23d", + "role": "prior source-complete rank-two coded child and open supplier-free/literal join" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "39b40c465f7636a4bb6d70af28595fe8f70f4f3f", + "path": "research/literal-selected-linear-maps/PROOF.md", + "bytes": 17153, + "sha256": "217b6bbe9271aa5d5c0f0999a231d7386c7ba3fc432a88e3796d70ca283eb322", + "blob": "38f9adc04e3fb87d43dd92cfd3bd667a65d04238", + "role": "generic fixed CNOT geometry, per-gate cost and backing" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "172f4535ce8dcff79f626410af845f757c1563be", + "path": "research/literal-native-quadratic-phase/PROOF.md", + "bytes": 17878, + "sha256": "55f0a575f618bf467d0e25a25802053455d701cee1f23fb8811a671a1bd59ff3", + "blob": "46a43bf214d828aa972db66ad35e41b9cd07a964", + "role": "generic fixed m9 phase and complete cost/backing" + }, + { + "repository": "CubeJerry/integer-mult-bounds", + "commit": "1a555e469b89af70d309bc966f8f813ac11dc887", + "path": "research/literal-positive-c-leaf/PROOF.md", + "bytes": 16608, + "sha256": "c99157c3c43ae490b858cdbce04d85f3661ca5d9752770506d18ec4876c4ed6c", + "blob": "a8ae6684d55e3a1aaa7f2aa432f15ae9db580b11", + "role": "first-slot C exact numerator/prefix/cutoff/cost/backing" + } + ] +} diff --git a/research/literal-fixed-mask-native-translation/implementation/reference/rank2/machine.py b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/machine.py new file mode 100644 index 0000000000..fcd4ac01f0 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/machine.py @@ -0,0 +1,129 @@ +"""Dense interpreter of literal Graphs; observers never drive control. Apache-2.0.""" +from dataclasses import dataclass +SYMBOLS={s:i for i,s in enumerate('_01^|$')} + + +class Rejected(ValueError):pass +class MonitorViolation(ValueError):pass + + +@dataclass +class State: + tapes:list + heads:list + origins:list + lows:list + highs:list + entry_lows:list + entry_highs:list + writes:list + steps:int=0 + + def clone(self): + return State([bytearray(t) for t in self.tapes],self.heads.copy(),self.origins.copy(), + self.lows.copy(),self.highs.copy(),self.entry_lows.copy(),self.entry_highs.copy(), + self.writes.copy(),self.steps) + + +def initial(payloads,tape_count,*,old_history=0): + if len(payloads)!=2 or len(payloads[0])!=len(payloads[1]) or not payloads[0]: + raise ValueError('two complete same-F source homes') + f=len(payloads[0]);capacity=16*(f+128)+256 + origins=[17+(t%7) for t in range(tape_count)] + text='^'+'|'.join(payloads)+'|$' + tapes=[bytearray(capacity) for _ in range(tape_count)] + for tape,o in zip(tapes,origins): + tape[o]=SYMBOLS['^'];tape[o-3:o]=bytes([2,1,4]);tape[-3:]=bytes([1,4,2]) + o=origins[0];tapes[0][o:o+len(text)]=bytes(SYMBOLS[s] for s in text) + lows=origins.copy();highs=origins.copy();highs[0]=o+len(text)-1 + if old_history:highs[-1]=origins[-1]+old_history + return State(tapes,origins.copy(),origins,lows.copy(),highs.copy(),lows,highs,[0]*tape_count) + + +class Program: + def __init__(self,graph): + names=list(graph.rules);self.labels={name:i for i,name in enumerate(names)} + self.labels['HALT']=-1;self.start=self.labels[graph.start];self.rows=[] + for name in names: + rules=[(tuple((t,SYMBOLS[s]) for t,s in r.tests), + tuple((t,SYMBOLS[s]) for t,s in r.writes),r.moves, + self.labels[r.target]) for r in graph.rules[name]] + if rules and all(len(r[0])==1 and not r[1] and not r[2] for r in rules) and len({r[0][0][0] for r in rules})==1: + branch=[-2]*6 + for r in rules:branch[r[0][0][1]]=r[3] + self.rows.append((0,rules[0][0][0][0],branch)) + elif len(rules)==1 and not rules[0][0]: + _,writes,moves,nxt=rules[0] + if len(writes)==1 and not moves:self.rows.append((1,writes[0][0],(writes[0][1],nxt))) + elif len(moves)==1 and not writes:self.rows.append((2,moves[0][0],(moves[0][1],nxt))) + elif not moves and not writes:self.rows.append((3,nxt,None)) + else:self.rows.append((4,rules,None)) + else:self.rows.append((4,rules,None)) + + def run(self,state,*,start=None,stop=None,budget=100000000): + pc=self.start if start is None else self.labels[start] + stop_pc=None if stop is None else self.labels[stop] + rows=self.rows;tapes=state.tapes;heads=state.heads + lows=state.lows;highs=state.highs;writes=state.writes + while pc!=-1 and pc!=stop_pc: + op,t,arg=rows[pc] + if op==0: + pc=arg[tapes[t][heads[t]]] + if pc==-2:raise Rejected('literal scanned-symbol rejection') + elif op==1: + value,pc=arg + if heads[t]==state.origins[t] and value!=3: + raise MonitorViolation('attempted permanent B origin marker overwrite') + tapes[t][heads[t]]=value;writes[t]+=1 + elif op==2: + delta,pc=arg + if delta not in (-1,0,1):raise ValueError('nonunit emitted move') + heads[t]+=delta + if not 0<=heads[t]budget:raise ValueError('finite execution budget') + return state + + def _general(self,state,rules): + tapes=state.tapes;heads=state.heads;lows=state.lows;highs=state.highs;writes=state.writes + found=None + for rule in rules: + if all(tapes[t][heads[t]]==symbol for t,symbol in rule[0]): + if found is not None:raise ValueError('nondeterministic emitted table') + found=rule + if found is None:raise Rejected('literal scanned-symbol rejection') + for t,value in found[1]: + if heads[t]==state.origins[t] and value!=SYMBOLS['^']: + raise MonitorViolation('attempted permanent B origin marker overwrite') + tapes[t][heads[t]]=value;writes[t]+=1 + for t,delta in found[2]: + if delta not in (-1,0,1):raise ValueError('nonunit emitted move') + heads[t]+=delta + if not 0<=heads[t]0 else -1),)) + return target + + +def copy_out(g,source,target,after): + state=g.state('repack') + g.add(state,after,tests=((source,'_'),)) + for bit in '01': + g.add(state,state,tests=((source,bit),),writes=((target,bit),(source,'_')), + moves=((source,1),(target,1))) + return state + + +def embed(g,code,after): + labels=[g.state('MOVE24472') for _ in code] + for pc,(op,*args) in enumerate(code): + state=labels[pc];g.rules.setdefault(state,[]) + nxt=labels[pc+1] if pc+1= len(self.cells): + self.cells.extend('_' for _ in range(self.head+1-len(self.cells))) + self.cells[self.head] = value + self.peak = max(self.peak, len(self.cells)) + + def move(self, delta): + if delta not in (-1,0,1): + raise ValueError('one physical transition moves at most one cell') + if self.head+delta < 0: + raise ValueError('head crossed permanent origin') + self.head += delta + self.visited.add(self.head) + self.peak = max(self.peak,self.head+1) + + def contents(self): + return ''.join(self.cells) + + +@dataclass(frozen=True) +class Rule: + tests: tuple + writes: tuple + moves: tuple + target: str + + +class Graph: + def __init__(self): + self.rules = {} + self.serial = 0 + self.start = None + self.execution_start = None + self.checkpoints = {} + + def state(self, stem): + result = f'{stem}.{self.serial}' + self.serial += 1 + return result + + def add(self, state, target, tests=(), writes=(), moves=()): + self.rules.setdefault(state, []).append(Rule(tuple(tests), tuple(writes), + tuple(moves), target)) + + def jump(self, target, moves=()): + state = self.state('jump') + self.add(state, target, moves=moves) + return state + + def rewind(self, tape, target, erase=False): + state = self.state('erase' if erase else 'rewind') + self.add(state, target, tests=((tape, '^'),)) + for symbol in ALPHABET.replace('^', ''): + self.add(state, state, tests=((tape, symbol),), + writes=((tape, '_'),) if erase else (), moves=((tape, -1),)) + return state + + def validate(self): + # Exact symbolic determinism: two patterns overlap iff every shared + # tested tape has the same symbol. No wildcard expansion is needed. + for state, rules in self.rules.items(): + for i, a in enumerate(rules): + if a.target not in self.rules and a.target != 'HALT': + raise ValueError('undefined graph continuation') + for b in rules[:i]: + left, right = dict(a.tests), dict(b.tests) + if all(left[t] == right[t] for t in left.keys() & right.keys()): + raise ValueError('nondeterministic graph state '+state) + + def run(self, tapes, limit=10000000, checkpoint=None, start=None): + state, steps = self.start if start is None else start, 0 + while state != 'HALT': + if checkpoint and state in self.checkpoints: + checkpoint(self.checkpoints[state], tapes) + if steps >= limit: + raise ValueError('literal graph execution capacity') + matches = [r for r in self.rules[state] + if all(tapes[t].read() == value for t, value in r.tests)] + if len(matches) != 1: + raise ValueError('malformed tape or nondeterministic transition '+state) + rule, = matches + for tape, value in rule.writes: + tapes[tape].write(value) + for tape, delta in rule.moves: + tapes[tape].move(delta) + state, steps = rule.target, steps+1 + if checkpoint and 'HALT' in self.checkpoints: + checkpoint(self.checkpoints['HALT'], tapes) + return steps + + +def service(graph, name, arity, target): + """Four small supplied primitive graphs used ONLY by finite fixtures. + + Real scientific scalar/route/leaf graphs are still premises of the theorem. + Tapes 1,2 are operands; tape 3 is retained private primitive scratch. + """ + if name == 'REV': + if arity != 1: + raise ValueError('unary reversal') + cleanup = graph.rewind(3, target, erase=True) + back_operand = graph.rewind(1, cleanup) + copy = graph.state('reverse-install') + graph.add(copy, back_operand, tests=((3, '|'),), writes=((1, '|'),)) + for bit in '01': + graph.add(copy, copy, tests=((3, bit),), writes=((1, bit),), + moves=((1, 1), (3, 1))) + install = graph.jump(copy, ((1, 1), (3, 1))) + rewind_scratch = graph.rewind(3, install) + reverse = graph.state('reverse-copy') + graph.add(reverse, rewind_scratch, tests=((1, '^'),), writes=((3, '|'),)) + for bit in '01': + graph.add(reverse, reverse, tests=((1, bit),), writes=((3, bit),), + moves=((1, -1), (3, 1))) + begin_reverse = graph.jump(reverse, ((1, -1), (3, 1))) + seek = graph.state('reverse-seek') + graph.add(seek, begin_reverse, tests=((1, '|'),)) + for bit in '01': + graph.add(seek, seek, tests=((1, bit),), moves=((1, 1),)) + return graph.jump(seek, ((1, 1),)) + if name == 'FIRST': + if arity != 1: + raise ValueError('unary leaf fixture') + at = graph.state('first-bit') + for bit in '01': + graph.add(at, target, tests=((1, bit),), writes=((1, str(1-int(bit))),), + moves=((1, -1),)) + return graph.jump(at, ((1, 1),)) + if name not in ('ZERO', 'NOT', 'XOR') or arity != (2 if name == 'XOR' else 1): + raise ValueError('missing supplied primitive graph') + cleanup = target + for tape in range(arity, 0, -1): + cleanup = graph.rewind(tape, cleanup) + loop = graph.state('primitive-'+name) + graph.add(loop, cleanup, tests=tuple((t, '|') for t in range(1, arity+1))) + if name == 'XOR': + for a in '01': + for b in '01': + graph.add(loop, loop, tests=((1, a), (2, b)), + writes=((2, str(int(a)^int(b))),), moves=((1, 1), (2, 1))) + else: + for bit in '01': + graph.add(loop, loop, tests=((1, bit),), + writes=((1, '0' if name == 'ZERO' else str(1-int(bit))),), + moves=((1, 1),)) + return graph.jump(loop, tuple((t, 1) for t in range(1, arity+1))) + + +def scan(graph, homes, selected, gather, target): + """Unroll finite home order; scan arbitrary F only by field delimiters.""" + next_state = graph.rewind(0, target) + for home in range(homes-1, -1, -1): + work = selected.get(home) + after = next_state + loop = graph.state('gather' if gather else 'return') + if work: + graph.add(loop, after, tests=((0, '|'),) if gather else ((0, '|'), (work, '|')), + writes=((work, '|'),) if gather else (), moves=((0, 1),)) + else: + graph.add(loop, after, tests=((0, '|'),), moves=((0, 1),)) + for bit in '01': + if not work: + graph.add(loop, loop, tests=((0, bit),), moves=((0, 1),)) + elif gather: + graph.add(loop, loop, tests=((0, bit),), writes=((work, bit),), + moves=((0, 1), (work, 1))) + else: + for output in '01': + graph.add(loop, loop, tests=((0, bit), (work, output)), + writes=((0, output),), moves=((0, 1), (work, 1))) + next_state = graph.jump(loop, ((work, 1),)) if work else loop + return graph.jump(next_state, ((0, 1),)) + + +def reserve(graph, extra_homes, target): + """Append full zero homes by copying first-field extent, without F arithmetic.""" + if not extra_homes: + return target + return_home = graph.rewind(0, target) + finish = graph.state('reserve-finish') + graph.add(finish, return_home, writes=((0, '$'),)) + next_state = graph.rewind(3, finish, erase=True) + for position in range(extra_homes-1,-1,-1): + loop = graph.state('reserve-zero-home') + graph.add(loop, loop, tests=((3, '0'),), writes=((0, '0'),), moves=((0, 1),(3, 1))) + graph.add(loop, next_state, tests=((3, '|'),), writes=((0, '|'),), moves=((0, 1),)) + begin = graph.jump(loop, ((3, 1),)) + next_state = graph.rewind(3, begin) if position else begin + seek = graph.state('reserve-seek-end') + graph.add(seek, next_state, tests=((0, '$'),)) + for symbol in '^01|': + graph.add(seek, seek, tests=((0, symbol),), moves=((0, 1),)) + rewind_template = graph.rewind(3, seek) + rewind_home = graph.rewind(0, rewind_template) + copy = graph.state('reserve-copy-extent') + for bit in '01': + graph.add(copy, copy, tests=((0, bit),), writes=((3, '0'),), moves=((0, 1),(3, 1))) + graph.add(copy, rewind_home, tests=((0, '|'),), writes=((3, '|'),)) + return graph.jump(copy, ((0, 1),(3, 1))) + + +def compile_graph(events, owners, primitive=service, productive_count=None): + """Return a real transition graph on four tapes for the fixture family. + + General theorem: replace primitive by supplied finite graphs using m + scratch tapes; tape count is 1+b+m, independently of Q,K,F. + """ + graph, next_state = Graph(), 'HALT' + home_index = {owner: i for i, owner in enumerate(owners)} + if len(home_index) != len(owners): + raise ValueError('permanent home owner identities must be distinct') + for index in range(len(events)-1, -1, -1): + event = events[index] + if not event.service: + continue + graph.checkpoints[next_state] = index + if not 1 <= len(event.owners) <= 2 or len(set(event.owners)) != len(event.owners): + raise ValueError('bounded distinct physical operands') + selected = {home_index[owner]: i+1 for i, owner in enumerate(event.owners)} + cleanup = next_state + for tape in range(len(event.owners), 0, -1): + cleanup = graph.rewind(tape, cleanup, erase=True) + scatter = scan(graph, len(owners), selected, False, cleanup) + invoke = primitive(graph, event.service, len(event.owners), scatter) + origin = invoke + for tape in range(len(event.owners), 0, -1): + origin = graph.rewind(tape, origin) + next_state = scan(graph, len(owners), selected, True, origin) + graph.execution_start = next_state + productive_count = len(owners) if productive_count is None else productive_count + if not 1 <= productive_count <= len(owners): + raise ValueError('positive productive count within permanent bank') + graph.start = reserve(graph,len(owners)-productive_count,next_state) + graph.validate() + return graph + + +def initial_tapes(payloads, home_count, preformatted=False): + if not payloads or len({len(x) for x in payloads}) != 1 or not payloads[0]: + raise ValueError('positive common full field format') + if len(payloads) > home_count or any(set(x)-set('01') for x in payloads): + raise ValueError('binary productive bank in declared homes') + # Only productive fields are supplied. New private extents are prepared + # by the literal reserve graph. Optional preformatting is for fault tests. + fields = list(payloads) + if preformatted: + fields += ['0'*len(payloads[0])]*(home_count-len(payloads)) + return [Tape('^'+'|'.join(fields)+'|$'), Tape(), Tape(), Tape()] + + +def decoded(tapes, home_count): + raw = tapes[0].contents() + if raw[0] != '^' or not raw.endswith('|$'): + raise ValueError('home boundaries changed') + fields = tuple(raw[1:-2].split('|')) + if len(fields) != home_count: + raise ValueError('permanent home count changed') + return fields diff --git a/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/leaf/NOTICE.md b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/leaf/NOTICE.md new file mode 100644 index 0000000000..71c5f6dae2 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/leaf/NOTICE.md @@ -0,0 +1,34 @@ +# Attribution and license + +Prepared for Jerry Chen / @CubeJerry with substantial OpenAI assistance. +New material is Apache-2.0; copied predecessors retain their original notices. + +Jose Manuel (jmbarrancoml), CrocSwap/integer-mult-bounds#3091, supplies the +Gaussian C numerator rows, exact carry/parity/signed-fit argument, physical +complete-axis strategy and direct tensor tariff. Credit its #3055/#3087 +physical lineage, Alejandro Zarzuelo Urdiales's #45 Gaussian tensor reserve +and norm results, James Chang's #1869 ripple arithmetic, AAAmirinu's #2327 +prefix audit, and Nick Petalas's #2772/#3089 prefix/capacity work. + +@CubeJerry's #6967 current-coded leaf supplies the earlier source/format/ +lifecycle binding and explicitly leaves literal numerical export open. +#6978, #6986 and #6989 provide distinct all-source, cutoff-transport and +rounded wrappers. Their stronger failure-retirement and old coded interfaces +are not silently inherited by this packed component. + +The actual #7000 source, Clifford compiler and retained independent Gaussian +verifier are credited to DreamingOfClouds, Ali Romman, Cinna Davis, zxv, +unpaidmoon, icekylinx, CubeJerry and the earlier authors named by the retained +sources. The construction, lowering and matrix identities are not claimed anew. + +The packed ABI is published at +`172f4535ce8dcff79f626410af845f757c1563be`. Unary/Gamma/trace patterns follow +literal-layer-phase at `8b549ca6557ccbb3017b104b27ea35051f990416`, which credits +literal-layer-egress at `51ab0539059214fcfa044938c36a0b6017232be5`. The exact +Builder/Machine originates in #7349, head +`9dfe6747b8553fd11b408f2b045c5954ef1e6eaa`. + +The parent's dense execution/oracle and literal_layer_boundary's independent +source/Gaussian/universal-cost review are separately attributed in REVIEW.md. +Their artifacts are unchanged. Independent AI work is not human approval or +formal proof-kernel acceptance. diff --git a/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/leaf/inputs/controller_reference.py b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/leaf/inputs/controller_reference.py new file mode 100644 index 0000000000..3ab6d0361f --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/leaf/inputs/controller_reference.py @@ -0,0 +1,112 @@ +"""Finite three-tape online rank-recursion control; Apache-2.0. +Only PC and local symbols affect execution. Metrics/event logs are observers. +""" +from dataclasses import dataclass, field +BLANK, ONE, MARK = '_', '1', '|' +WIDTH, CHILD, STACK = range(3) + +class Builder: + def __init__(self): self.code, self.labels, self.serial = [], {}, 0 + def mark(self,n): + if n in self.labels: raise ValueError('duplicate label') + self.labels[n]=len(self.code) + def op(self,*x): self.code.append(x) + def rewind(self,t,symbols): + self.serial+=1; loop=f'rw{self.serial}'; done=loop+'done' + self.op('move',t,-1); self.mark(loop) + self.op('read',t,{s:loop+'step' for s in symbols}|{MARK:done}) + self.mark(loop+'step'); self.op('move',t,-1); self.op('goto',loop) + self.mark(done); self.op('move',t,1) + def finish(self,alphabet): + result=[] + for op,*a in self.code: + if op=='goto': a[0]=self.labels[a[0]] + elif op=='read': a[1]={s:self.labels[n] for s,n in a[1].items()} + result.append((op,*a)) + return tuple(result),tuple(alphabet) + +def compile_controller(m,ranks): + """Parameters are compile-time constants, absent from run-time state.""" + if type(m) is not int or m<2 or not ranks: raise ValueError('bad fixed profile') + if any(type(r) is not int or not 1<=r=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-fixed-mask-native-translation/implementation/reference/rank2/reference/leaf/leaf.py b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/leaf/leaf.py new file mode 100644 index 0000000000..bdcc80cbd8 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/leaf/leaf.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-fixed-mask-native-translation/implementation/reference/rank2/reference/linear/NOTICE.md b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/linear/NOTICE.md new file mode 100644 index 0000000000..3a3030f23d --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/linear/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-fixed-mask-native-translation/implementation/reference/rank2/reference/linear/inputs/controller_reference.py b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/linear/inputs/controller_reference.py new file mode 100644 index 0000000000..3ab6d0361f --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/linear/inputs/controller_reference.py @@ -0,0 +1,112 @@ +"""Finite three-tape online rank-recursion control; Apache-2.0. +Only PC and local symbols affect execution. Metrics/event logs are observers. +""" +from dataclasses import dataclass, field +BLANK, ONE, MARK = '_', '1', '|' +WIDTH, CHILD, STACK = range(3) + +class Builder: + def __init__(self): self.code, self.labels, self.serial = [], {}, 0 + def mark(self,n): + if n in self.labels: raise ValueError('duplicate label') + self.labels[n]=len(self.code) + def op(self,*x): self.code.append(x) + def rewind(self,t,symbols): + self.serial+=1; loop=f'rw{self.serial}'; done=loop+'done' + self.op('move',t,-1); self.mark(loop) + self.op('read',t,{s:loop+'step' for s in symbols}|{MARK:done}) + self.mark(loop+'step'); self.op('move',t,-1); self.op('goto',loop) + self.mark(done); self.op('move',t,1) + def finish(self,alphabet): + result=[] + for op,*a in self.code: + if op=='goto': a[0]=self.labels[a[0]] + elif op=='read': a[1]={s:self.labels[n] for s,n in a[1].items()} + result.append((op,*a)) + return tuple(result),tuple(alphabet) + +def compile_controller(m,ranks): + """Parameters are compile-time constants, absent from run-time state.""" + if type(m) is not int or m<2 or not ranks: raise ValueError('bad fixed profile') + if any(type(r) is not int or not 1<=r=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-fixed-mask-native-translation/implementation/reference/rank2/reference/linear/linear.py b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/linear/linear.py new file mode 100644 index 0000000000..6aad40a6c4 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/linear/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-fixed-mask-native-translation/implementation/reference/rank2/reference/phase/NOTICE b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/phase/NOTICE new file mode 100644 index 0000000000..7a1f1da9c5 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/phase/NOTICE @@ -0,0 +1,11 @@ +Prepared for Jerry Chen / CubeJerry with substantial OpenAI assistance. +Apache-2.0. New contribution: literal local lowering, scoped proof and package. +Ali Romman/#5375 supplies the incremental phase and repeated constant. +The retained reference files preserve original source text. +#7000 and its native/Gaussian lineage supply the selected source and engines; +credit DreamingOfClouds, Ali Romman, Cinna Davis, zxv, unpaidmoon, icekylinx, +CubeJerry and earlier authors named by the retained source. +C2 literal-layer-phase supplies Gamma and signed staging/return. B1 literal- +layer-egress supplies owner staging, and #7349 the retained literal machine. +Exact original/copy source pins are in SOURCES.json. No predecessor identity, +compiler, source construction or general monomial theorem is claimed as new. diff --git a/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/phase/inputs/controller_reference.py b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/phase/inputs/controller_reference.py new file mode 100644 index 0000000000..3ab6d0361f --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/phase/inputs/controller_reference.py @@ -0,0 +1,112 @@ +"""Finite three-tape online rank-recursion control; Apache-2.0. +Only PC and local symbols affect execution. Metrics/event logs are observers. +""" +from dataclasses import dataclass, field +BLANK, ONE, MARK = '_', '1', '|' +WIDTH, CHILD, STACK = range(3) + +class Builder: + def __init__(self): self.code, self.labels, self.serial = [], {}, 0 + def mark(self,n): + if n in self.labels: raise ValueError('duplicate label') + self.labels[n]=len(self.code) + def op(self,*x): self.code.append(x) + def rewind(self,t,symbols): + self.serial+=1; loop=f'rw{self.serial}'; done=loop+'done' + self.op('move',t,-1); self.mark(loop) + self.op('read',t,{s:loop+'step' for s in symbols}|{MARK:done}) + self.mark(loop+'step'); self.op('move',t,-1); self.op('goto',loop) + self.mark(done); self.op('move',t,1) + def finish(self,alphabet): + result=[] + for op,*a in self.code: + if op=='goto': a[0]=self.labels[a[0]] + elif op=='read': a[1]={s:self.labels[n] for s,n in a[1].items()} + result.append((op,*a)) + return tuple(result),tuple(alphabet) + +def compile_controller(m,ranks): + """Parameters are compile-time constants, absent from run-time state.""" + if type(m) is not int or m<2 or not ranks: raise ValueError('bad fixed profile') + if any(type(r) is not int or not 1<=r=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-fixed-mask-native-translation/implementation/reference/rank2/reference/phase/phase.py b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/phase/phase.py new file mode 100644 index 0000000000..d489781458 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/phase/phase.py @@ -0,0 +1,335 @@ +"""Literal selected native quadratic phase, with complete owner commit. + +Prepared for Jerry Chen / CubeJerry with substantial OpenAI assistance. +Apache-2.0. The multi-counter phase algorithm is credited to #5375. Header, +signed staging and return helpers are retained from the frozen C2 phase. +Only fixed-table read/write/unit-move/goto/halt instructions execute. +""" +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, OUTPUT, HTRACE, LENGTH, DOUBLE, COLUMNS, COEFF, OUTER, + SPECTATOR, WIDTH, REAL, IMAG, DTRACE) = range(14) +COUNTERS = tuple(range(14, 23)) +PRIVATE = tuple(range(2, 23)) +BITS = ('0', ONE) +SELECTED_LINEAR = (3, 3, 3, 3, 0, 3, 3, 2, 0) +SELECTED_ROWS = (111, 111, 111, 111, 0, 111, 111, 0, 0) +SELECTED_CONSTANT = 1 + + +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 load_component(a, target): + k = fresh(a, 'load') + a.mark(k) + a.op('read', WIDTH, {ONE: k+'bit', BLANK: k+'done'}) + a.mark(k+'bit') + a.op('read', DATA, {str(b): k+str(b) for b in (0, 1)}) + for b in (0, 1): + a.mark(k+str(b)) + a.op('write', target, str(b)) + a.op('move', target, 1) + a.op('move', DATA, 1) + a.op('write', DTRACE, ONE) + a.op('move', DTRACE, 1) + a.op('move', WIDTH, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(WIDTH, (ONE,)) + a.rewind(target, BITS) + + +def negate(a, tape): + """Exact w-bit integer negation; reject the unrepresentable minimum.""" + k = fresh(a, 'neg') + a.mark(k+'seek') + a.op('read', tape, {'0': k+'step', ONE: k+'step', BLANK: k+'last'}) + a.mark(k+'step') + a.op('move', tape, 1) + a.op('goto', k+'seek') + a.mark(k+'last') + a.op('move', tape, -1) + a.op('goto', k+'c1x0y0') + for carry in (0, 1): + for old_sign in (0, 1): + for new_sign in (0, 1): + name = k+f'c{carry}x{old_sign}y{new_sign}' + a.mark(name) + a.op('read', tape, {str(b): name+'b'+str(b) for b in (0, 1)} | + {MARK: 'reject' if old_sign and new_sign else k+'done'}) + for bit in (0, 1): + total = 1-bit+carry + digit, nxt = total % 2, total//2 + a.mark(name+'b'+str(bit)) + a.op('write', tape, str(digit)) + a.op('move', tape, -1) + a.op('goto', k+f'c{nxt}x{bit}y{digit}') + a.mark(k+'done') + a.op('move', tape, 1) + + +def stage_component(a, tape): + k = fresh(a, 'stage') + a.mark(k) + a.op('read', tape, {str(b): k+str(b) for b in (0, 1)} | {BLANK: k+'done'}) + for b in (0, 1): + a.mark(k+str(b)) + a.op('write', OUTPUT, str(b)) + a.op('move', OUTPUT, 1) + a.op('write', tape, BLANK) + a.op('move', tape, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(tape, (BLANK,)) + + +def initialize(a, counters, constant): + """Generate f zero bits on each counter and retain constant*f mod 4.""" + a.op('goto', 'initialize0') + for mode in range(4): + name = 'initialize'+str(mode) + a.mark(name) + a.op('read', COLUMNS, {ONE: name+'bit', BLANK: name+'done'}) + a.mark(name+'bit') + for tape in counters: + a.op('write', tape, '0') + a.op('move', tape, 1) + a.op('move', COLUMNS, 1) + a.op('goto', 'initialize'+str((mode+constant) % 4)) + a.mark(name+'done') + a.rewind(COLUMNS, (ONE,)) + for tape in counters: + a.rewind(tape, BITS) + a.op('goto', 'record'+str(mode)) + + +def advance(a, counters, linear, rows): + """Fixed finite lowering of the credited synchronized counter updater.""" + m = len(counters) + for i in range(m): + neighbors = tuple(j for j in range(m) if j != i and + (rows[min(i, j)] >> max(i, j)) & 1) + for mode in range(4): + name = f'advance{i}q{mode}' + a.mark(name) + a.op('read', counters[i], {str(b): name+'b'+str(b) for b in (0, 1)} | + {BLANK: name+'overflow'}) + for bit in (0, 1): + stem = name+'b'+str(bit) + a.mark(stem) + nxt = (mode+(1-2*bit)*linear[i]) % 4 + a.op('goto', stem+f'n0q{nxt}') + for k, j in enumerate(neighbors): + for value in range(4): + label = stem+f'n{k}q{value}' + a.mark(label) + a.op('read', counters[j], { + str(b): stem+f'n{k+1}q{(value+2*b) % 4}' + for b in (0, 1)}) + for value in range(4): + a.mark(stem+f'n{len(neighbors)}q{value}') + a.op('write', counters[i], str(1-bit)) + for tape in counters: + a.op('move', tape, 1) + a.op('goto', f'advance{i}q{value}' if bit else + 'advanced'+str(value)) + a.mark(name+'overflow') + for tape in counters: + target = fresh(a, 'all_end') + a.op('read', tape, {BLANK: target}) + a.mark(target) + for tape in counters: + a.rewind(tape, BITS) + if i: + a.op('goto', f'advance{i-1}q{mode}') + else: + a.op('move', OUTER, 1) + a.op('read', OUTER, {ONE: 'record'+str(mode), BLANK: 'finish'}) + for mode in range(4): + a.mark('advanced'+str(mode)) + for tape in counters: + a.rewind(tape, BITS) + a.op('goto', 'record'+str(mode)) + + +def compile_phase(linear=SELECTED_LINEAR, rows=SELECTED_ROWS, + constant=SELECTED_CONSTANT): + """Recipe is finite construction-time data; no runtime size is an argument.""" + m = len(linear) + if not 1 <= m <= len(COUNTERS) or len(rows) != m: + raise ValueError('fixed recipe dimension') + if type(constant) is not int or not 0 <= constant < 4: + raise ValueError('fixed constant phase') + if any(type(x) is not int or not 0 <= x < 4 for x in linear): + raise ValueError('fixed linear phase') + if any(type(x) is not int or not 0 <= x < 1 << m for x in rows): + raise ValueError('fixed quadratic rows') + if any(((rows[i] >> j) ^ (rows[j] >> i)) & 1 + for i in range(m) for j in range(m)): + raise ValueError('symmetric source quadratic matrix') + if any((linear[i] ^ (rows[i] >> i)) & 1 for i in range(m)): + raise ValueError('source diagonal parity') + counters = COUNTERS[:m] + a = Builder() + for tape in PRIVATE: + a.op('move', tape, -1) + a.op('write', tape, MARK) + a.op('move', tape, 1) + # Supplied local ABI: Gamma(f), Gamma(r), Gamma(P), Gamma(S), Gamma(w). + for target in (COLUMNS, COEFF, OUTER, SPECTATOR, WIDTH): + gamma(a, target) + trace_return(a, HEADER, HTRACE) + initialize(a, counters, constant) + for mode in range(4): + a.mark('record'+str(mode)) + a.op('read', SPECTATOR, {ONE: 'coefficient'+str(mode), BLANK: 'record_end'+str(mode)}) + a.mark('coefficient'+str(mode)) + a.op('read', COEFF, {ONE: 'payload'+str(mode), BLANK: 'coefficient_end'+str(mode)}) + a.mark('payload'+str(mode)) + load_component(a, REAL) + load_component(a, IMAG) + if mode in (2, 3): + negate(a, REAL) + if mode in (1, 2): + negate(a, IMAG) + order = (IMAG, REAL) if mode % 2 else (REAL, IMAG) + for tape in order: + stage_component(a, tape) + a.op('move', COEFF, 1) + a.op('goto', 'coefficient'+str(mode)) + a.mark('coefficient_end'+str(mode)) + a.rewind(COEFF, (ONE,)) + a.op('move', SPECTATOR, 1) + a.op('goto', 'record'+str(mode)) + a.mark('record_end'+str(mode)) + a.rewind(SPECTATOR, (ONE,)) + a.op('goto', f'advance{m-1}q{mode}') + advance(a, counters, linear, rows) + a.mark('finish') + a.op('read', DATA, {BLANK: 'verified', '0': 'reject', ONE: 'reject'}) + a.mark('verified') + trace_return(a, DATA, DTRACE) + a.rewind(OUTPUT, BITS) + a.mark('commit') + a.op('read', OUTPUT, {str(b): 'commit'+str(b) for b in (0, 1)} | {BLANK: 'committed'}) + for bit in ('0', ONE): + a.mark('commit'+bit) + a.op('write', DATA, bit) + a.op('write', OUTPUT, BLANK) + a.op('move', OUTPUT, 1) + a.op('move', DATA, 1) + a.op('write', DTRACE, ONE) + a.op('move', DTRACE, 1) + a.op('goto', 'commit') + a.mark('committed') + trace_return(a, DATA, DTRACE) + a.rewind(OUTPUT, (BLANK,)) + a.rewind(OUTER, (ONE,)) + for tape in (COLUMNS, OUTER, COEFF, SPECTATOR, WIDTH): + clear(a, tape) + for tape in counters: + clear(a, tape, 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-fixed-mask-native-translation/implementation/reference/rank2/reference/source/clifford_exact.py b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/source/clifford_exact.py new file mode 100644 index 0000000000..166841a037 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/rank2/reference/source/clifford_exact.py @@ -0,0 +1,149 @@ +"""Small exact Gaussian-dyadic Clifford compiler, independent of gx internals. +Paulis use i^p X^x Z^z. State vectors use integer Gaussian numerators / 2^d. +The tableau is supplemented by a literal circuit, so global phases are kept. +""" +from dataclasses import dataclass + +def parity(x):return x.bit_count()&1 +def rank(rows): + p={} + for x in rows: + while x: + b=x.bit_length()-1 + if b not in p:p[b]=x;break + x^=p[b] + return len(p) +def transpose(rows,n):return tuple(sum(((rows[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<> 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-fixed-mask-native-translation/implementation/reference/translation/NOTICE.md b/research/literal-fixed-mask-native-translation/implementation/reference/translation/NOTICE.md new file mode 100644 index 0000000000..903e332da2 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/translation/NOTICE.md @@ -0,0 +1,20 @@ +# Credit and assistance + +Prepared for Jerry Chen / @CubeJerry with substantial OpenAI assistance. +New work is Apache-2.0. Exact retained sources preserve their original notices. + +The selected #7000 source, its application and predecessor native/Clifford +contributors supply the actual event and operator decomposition. The published +literal-native-quadratic-phase package supplies the exact current recipe +binding and five-Gamma/raw packed ABI. The published literal-row-reversal +package supplies the unchanged literal record-reversal graph, classical +two-stack implementation and exact cost/history theorem. The phase lineage +supplies the retained Gamma/unary helpers, and #7349 supplies the finite +machine grammar and builder. The earlier serial monomial descriptor iterator +is a distinct predecessor, not a solved numerical join on this ABI. + +This package contributes literal collapsed-descriptor production and the +actual fixed-graph join for one source-bound post-matrix translation. It does +not claim the source recipe, tensor translation identity, reversal algorithm, +or classical unary/binary conversion as new. Independent AI review, where +recorded, is not human or formal-kernel acceptance. diff --git a/research/literal-fixed-mask-native-translation/implementation/reference/translation/PROOF.md b/research/literal-fixed-mask-native-translation/implementation/reference/translation/PROOF.md new file mode 100644 index 0000000000..5c6325471a --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/translation/PROOF.md @@ -0,0 +1,377 @@ +# A literal descriptor join for one selected native translation + +**Scoped enabling lemma; no new kappa.** Prepared for Jerry Chen / @CubeJerry +with substantial OpenAI assistance. Canonical base: +`e54523517d0f03e58352e647c403a5af3e525a57`. + +## 1. Actual source factor and exact boundary + +The selected native word is +`research/shared-wire-split-composition/data/final.json.gz`, compressed SHA256 +`2b94953dc14a122e3ef089633f05b58ec689ec5156feb7c784ed3e137dc01883`. +Its zero-based event 24472 is `["MOVE",415,3,99,false]`. The exact lowering of +the frame-3 to frame-99 operator has rank 1. Its right monomial has affine +offset **1**, with matrix rows +`(239,129,130,132,136,16,160,192,256)`. + +The retained Clifford constructor produces `diag; perm(G); xgate(offset); +global_phase`. Rows of G are indexed by output bits: the image integer is +`sum_i parity(G_i & x)*2^i`, then XOR offset. Therefore offset 1 flips +**output coordinate 0 after G**. It does not identify bit zero with the +fastest packed coordinate. The complete authenticated recipe is retained in +`RECIPE.json`; `bind_source.py` recomputes it and checks the post-matrix +translation with the separate retained signed-Pauli/Gaussian evaluator. + +The supplied entry ABI is exactly the five-Gamma/raw packed ABI of +[literal-native-quadratic-phase](https://github.com/CubeJerry/integer-mult-bounds/tree/172f4535ce8dcff79f626410af845f757c1563be/research/literal-native-quadratic-phase). +Its coordinate tuple is `a=(a_0,...,a_8)` with a_0 the slow coordinate, a_8 +the fast coordinate, and each `a_i` an f-bit nonnegative integer. For each +tensor column j, native coordinate bit i is `(a_i >> j)&1`. + +Consequently the source's lifted X_1 acts by + +`(a_0,a_1,...,a_8) -> (a_0 XOR (2^f-1),a_1,...,a_8)`. + +This package implements that translation alone at the stated post-matrix +boundary. It does not implement G, the source quadratic phase, the central +rank-one child, or the whole MOVE. In particular the existing phase pass +cannot simply be followed by this translation while omitting G. + +## 2. The joined literal theorem + +Supply positive integers `f,r,P,S,w` as five consecutive canonical Elias +Gamma codes on HEADER. Gamma(n) consists of `ell(n)-1` zeroes followed by +the ell(n) ordinary binary digits of n. Let E be their total bit length. +DATA is the complete lexicographic array + +`[P] x [2^f]^9 x [S]`, + +with r Gaussian coefficients per array entry and 2w raw bits per coefficient, +real component then imaginary component, each MSB first. The word contains +exactly + +`V = 2*P*2^(9f)*S*r*w` + +bits and then a physical blank. The payload may be arbitrary; no arithmetic +or signed headroom is needed for this permutation. HEADER can have opaque +data immediately after its fifth code. DATA can have opaque data after the +blank endpoint. All such exteriors remain unchanged. + +The fixed ports are HEADER=0, DATA=1, three private binary descriptors at +2,3,4, the nine retained reversal work roles at 5,...,13, and eleven producer +roles at 14,...,24. Thus there are **25 tapes**, of which 23 are private. +Each head begins at its own arbitrary origin, possibly negative. On private +roles, the guard at origin minus one and the active windows in Section 7 are +blank. This is an explicit allocation/blankness premise, not something two +local probes certify. Opaque cells outside those windows are preserved. + +**Theorem.** `compile_translation()` emits one fixed 1,878-location graph, +alphabet `{blank,0,1,|}`, using only scanned-symbol branches, one-cell writes, +unit moves, fixed jumps and halt. It has no runtime shape, integer, coordinate +array, source callback, multiplication service or graph-generation argument. +On every legal packet it applies the source translation above, commits to +the same DATA owner and exact original field, restores HEADER and every head, +and erases all private bodies and guards. + +For every successful call its complete local instruction count obeys + +`T <= 4096*(V+E+1)`, + +and its private historical backing obeys + +`K_final <= K0 + 32*(V+E+1)`. + +K0 is actual previous private backing, including currently blank retained +cells. No erasure reduces it. Both bounds are O(V) on this complete ABI. + +Missing DATA bits, an extra immediate DATA bit, or a malformed finite header +encountered by the literal parser cause rejection before any DATA write. +General malformed-input termination, failure cleanup, interrupted-call +recovery and later reuse after failure are not claimed. The normal runtime +graph contains no verifier step budget. + +## 3. Producing the correct collapsed lengths + +Collapse the complete packet as `[P'] x [R] x [B]`, taking + +`P'=P`, `R=2^f`, `B=2*S*r*w*2^(8f)`. + +The remaining eight coordinates, all spectator copies, r coefficients and +both complete w-bit components are in the B-bit suffix record. This includes +every real/imaginary bit; reversing B-bit records must preserve their internal +order. The identity `P' R B = V` is exact. + +The producer obtains these encodings from the actual HEADER as follows. + +1. The retained Gamma pattern creates unary guides of lengths f,r,P,S,w. + LENGTH counts prefix zeroes. Each tail digit b changes an existing unary + prefix v to `2v+b` using DOUBLE and physical scans. HTRACE records every + HEADER step and returns HEADER to its entry origin with erasure. +2. RDESC receives one `1`, then exactly f zeroes while scanning the F guide. + This is the canonical MSB-first encoding of `2^f`; it does not construct + an uncharged host power or require a supplied binary R. +3. Three literal nested scans over S, r and w append two unary marks per + innermost visit. PRODUCT therefore has exactly `B0=2Srw` marks. +4. For every mark of F, the fixed program executes eight unary doublings of + PRODUCT. Induction on the scanned F prefix gives the final length + `B=B0*2^(8f)`. Each doubling physically copies, clears, restores and + erases its scratch. Eight is a fixed property of this source geometry; + the number of iterations over f is discovered by local scans. +5. The routine in Section 4 consumes OUTER=P and PRODUCT=B and emits their + canonical binary words on PDESC and BDESC. RDESC is already canonical. + +At the reversal join all 25 heads are at their original origins. DATA has +not been written or moved. The three generated descriptor words are +canonical, positive, terminated by physical blanks, and on distinct owners. +The reversal's nine private windows are untouched and blank. Producer guards +at descriptor origin minus one are opaque exterior symbols to the reversal; +that routine neither reads nor changes them. + +## 4. A charged unary-to-binary bridge + +The descriptor routine `unary_binary` takes one positive unary run of length +n, a blank quotient role HALF, a blank DIGITS stack, and a blank destination. +Their roles and guards are distinct. Two fixed control copies alternate +which of the source/HALF roles holds the current positive quotient. This +does not allocate a changing family of tapes. + +While scanning the current run, a parity control bit toggles on every mark. +Every second mark appends one mark to the other role; all current marks are +erased. Thus at the scan end the other role has floor(n/2) marks and the +parity is n mod 2. The routine restores both unary heads and appends the +parity as one bit to DIGITS. A local read of the quotient distinguishes a +positive next iteration from termination. At termination both unary roles +are blank and restored. + +The resulting DIGITS word contains the remainders of repeated exact division +by two, least significant first. Its last bit is 1 because the last positive +quotient is 1. Popping DIGITS backward into the destination therefore writes +the canonical MSB-first binary representation, with no leading zero and no +external length. The pop erases DIGITS; guarded rewind restores destination +and all scratch heads. + +This is the classical division-by-two conversion with an explicit local +implementation and complete charge, not a claimed new numeral algorithm. +Here its linear cost matters: materializing unary B is affordable because +B is a complete suffix volume, and binary production must not add a hidden +quadratic rescan. + +For an iteration with current value n_i and quotient q_i=floor(n_i/2), the +literal instruction count is `7n_i+5q_i+10`. This includes the parity scan, +all writes, both rewinds, digit append and next-iteration test. If +`ell=ell(n)` and `s=popcount(n)`, then + +`sum_i n_i=2n-s`, `sum_i q_i=n-s`. + +The initial jump and final digit reversal/rewind add `9ell+7`. Hence the +routine's exact cost, excluding its caller's guard installation/removal, is + +`19n - 12s + 19ell + 7 <= 38n+7`. + +The current unary run never exceeds n, HALF never exceeds floor(n/2), and +DIGITS/destination never exceed ell(n). These are all-size loop invariants. +The finite encoder tests independently check the exact census; they are not +used as a universal interpolation argument. + +## 5. Actual reversal invocation and successful retirement + +The invoked graph is the exact +[literal-row-reversal](https://github.com/CubeJerry/integer-mult-bounds/tree/7662d01d827c95d90032579c168cae78aa531f2f/research/literal-row-reversal) +program, source SHA256 +`4b516d85baf3303db809bc1174394009b1fc71a8f7d17fb6c729ec8bb6aba245`. +Its 524 instructions are included in the joined graph with a fixed tape and +label relabeling. The single successful halt becomes a fixed jump to the +descriptor-retirement epilogue, of the same one-instruction cost. No runtime +call, decoded size, computed target or interpreter callback is inserted. +The verifier checks every instruction of this embedded subgraph against the +retained graph, including its rejection branch. + +The predecessor theorem maps each `[P] x [R] x [B]` packet to +`A'(p,a,b)=A(p,R-1-a,b)`, preserving the internal order of each complete +B-bit suffix record. For R=2^f, `R-1-a=a XOR (R-1)`. Combined with Section 3, +this is exactly the source tensor X_1 and preserves all other coordinates, +Gaussian coefficients and individual component bits. + +The predecessor stages its entire output, checks exact DATA cardinality, +then installs only on the same DATA owner. It restores descriptor heads and +its nine private roles before jumping to the epilogue. The epilogue erases +all generated descriptor bodies and remaining unary parameter bodies, then +all fourteen producer guards. Each clearing scan stops at its current blank +frontier and rewinds to its local guard. At halt every private body and guard +is blank and all heads have returned to their entry origins. + +If the header parser or the reversal rejects, the producer has made no DATA +write and the reversal has not started commit. Public values are therefore +preserved, but private work and heads can remain dirty. The proof requires +successful cleanup before a subsequent clean call. + +## 6. Exact complete instruction bill and linear envelope + +Each local instruction, including a read, write, unit move, jump or halt, +costs one. Let `s(n)=popcount(n)`, `ell(n)=floor(log2(n))+1`, and set + +`E'=ell(P)+ell(R)+ell(B)`. + +Define two exact helper counts: + +`g(n)=47n-30s(n)+33ell(n)-42`, + +`h(n)=19n-12s(n)+19ell(n)+7`. + +The first is Gamma decoding before the shared HEADER return and guards; +the second is Section 4's complete unary-to-binary conversion. To verify +the first directly, each leading zero uses seven instructions. A binary +prefix update from v by b uses `47v+17b+18` instructions in its three unary +copy/clear helpers, plus eight in the Gamma wrapper. The strict prefix sum +is `n-s(n)`. Counting the leading one and terminal LENGTH read gives g(n). +The proof uses finite control states and local scans throughout. + +The exact predecessor reversal count is + +`C(P,R,B)=53V+23PR+71P+54R+54B+28E'` + +` -30(s(P)+s(R)+s(B))-8`. + +The entire joined program has the following additive census: + +| Executed region | Exact instruction count | +|---|---| +| Install fourteen producer guards | `42` | +| Decode the five Gamma values | `g(f)+g(r)+g(P)+g(S)+g(w)` | +| Return HEADER and erase its trace | `5E+3` | +| Produce RDESC and restore F/RDESC | `11f+12` | +| Produce B0 by complete nested scans | `16Srw+10Sr+10S+7` | +| Execute eight doublings per F mark | `47(B-B0)+150f+4` | +| Produce PDESC and BDESC | `h(P)+h(B)` | +| Complete retained reversal | `C(P,R,B)` | +| Erase producer bodies/guards and halt | `7(E'+f+r+S+w)+99` | + +For the doubling row, a zero-bit update costs `47v+18`; there are 8f such +updates and their previous values sum to B-B0. Scanning and returning F +adds `6f+4`. For the last row, OUTER and PRODUCT have been consumed and all +temporary guides are blank; the only remaining body lengths are the three +descriptors and f,r,S,w. Clearing a body of length n costs `7n+4`, including +its return. Fourteen guard removals and the final halt give the constant 99. + +This census includes source acquisition, every unary expansion, record load, +copy, two-stack reversal, full output stage, DATA returns, complete commit, +descriptor returns, setup and erasure. It is independent of payload bits and +absolute origins. The graph is built once at a fixed finite setup cost before +the numerical inputs vary; the displayed bill is for each execution of that +fixed graph. No input-dependent compilation is hidden. + +For a convenient envelope, put `Sigma=f+r+P+S+w`. Gamma acquisition plus +HEADER return is at most `256(E+Sigma+1)`. RDESC costs at most `32(f+1)`; +the nested product at most `18B0+7`; the doubling stage at most +`47B+286f+4`; the two encoders at most `38(P+B)+14`; and the reversal at +most `256(V+E'+1)`. The exact epilogue is as above. Since every parameter, +B and B0 is at most V, Sigma<=5V. Moreover `E'<=log2(V)+3<=V`, as V>=1024. +These bounds sum to less than `4096(V+E+1)`. + +Finally `E<=2log2(frPSw)+5<=2log2(V)+5`, so E is O(log V) and the complete +execution is O(V). A unary parameter unrelated to the packet volume would +not justify this argument. Here the exact complete-array product pays every +expanded guide, including the large suffix B. + +## 7. Private backing, exteriors and repeated calls + +Every private role has a guard at relative position -1. The table below +gives its largest possible body/end position; hence its visited interval is +contained in `[-1,cap]`. Define `M=max(P,B)` and `L=ell(M)`. + +| Producer role | Cap | +|---|---| +| PDESC, RDESC, BDESC | `ell(P)`, `f+1`, `ell(B)` respectively | +| HTRACE, LENGTH | `E` each | +| DOUBLE | `M` | +| F, COEFF, OUTER, SPECTATOR, WIDTH | `f,r,P,S,w` respectively | +| PRODUCT | `B` | +| HALF | `floor(M/2)` | +| DIGITS | `L` | + +B dominates f,r,S,w because `B=2Srw*2^(8f)` and all parameters are positive. +Thus DOUBLE never needs more than max(P,B), whether during Gamma acquisition +or suffix doubling. The encoder alternates source/HALF, and its quotient +can never exceed half its initial source length. Its digit stack is bounded +by L. These caps include all intermediate formats, not just final contents. + +The predecessor's nine reversal roles retain their proved windows: OUTPUT +and DTRACE cap V; prefix and row guides cap P and R; suffix guide and record +scratch cap B; doubling scratch caps max(P,R,B); descriptor trace caps the +largest descriptor length; and group scratch caps RB. Its private history +increment is at most `8V+E'+18`. + +Adding the fourteen producer intervals gives the explicit union bound + +`K_final <= K0 + 8V + 2E' + 2E + M + Sigma + B + floor(M/2) + L + 46`. + +This is below `K0+32(V+E+1)`. Public heads visit exactly HEADER's consumed +interval `[0,E]` and DATA's complete interval `[0,V]`; their input backing +and endpoints are separately part of the supplied public field storage. +All opaque exteriors are preserved by the guard/frontier invariants. + +Erasure leaves previous backing allocated. After successful reuse at fixed +origins, retain the per-role maximum cap reached and combine it with actual +initial history; do not replace that sum by equality with a maximum of +per-call sums. A coarse valid sequence bound is +`K_initial+32(V_max+E_max+1)`. A shorter call scans only its current bodies, +so its exact current-shape instruction bill is unaffected by old blank +capacity. If caller origins change, keep the per-role absolute unions and +pay caller transport corridors; there is no bound on arbitrary relocated +histories by current V alone. + +## 8. Evidence, novelty and remaining obligations + +The complete author receipt contains nine successful runs, totaling 702,464 +payload bits and 57,517,967 local transitions. This includes a full selected +nine-coordinate f=2 packet: 262,144 Gaussian coefficients and 524,288 bits. +It is complete coverage of that fixture, not a higher-width prefix. All +104 standalone encoder cases, through n=1024, satisfy the exact encoder +census. Whole-packet expected outputs use a separate source-coordinate XOR +formula at coefficient addresses, not the reversal algorithm. + +The checker inspects the actual three produced descriptor words before the +retained subgraph starts, verifies every embedded predecessor instruction, +and checks exact HEADER/DATA read, write and movement counts, all origins, +private retirement and opaque exteriors. The same physical Tape objects are +kept across a longer/shorter/regrowing chain. The shorter call has the exact +same instruction count as its fresh counterpart, with old history retained. + +Controls omit the real/imaginary factor, interchange collapsed prefix/suffix +descriptors while preserving total volume, and omit descriptor retirement. +The wrong-axis control runs past the descriptor check and fails the source +coordinate output oracle. Separate malformed-header, short-DATA and extra-DATA +cases reject with unchanged public contents. Source binding changes offset 1 +to bit 8 and requires the independent full-kernel comparison to reject it. +Independent review and its exact receipt are recorded separately when ready. + +The predecessor row-reversal theorem already proves the complete-record map, +its translation corollary and cost. Its caller supplied collapsed binary +lengths. The serial monomial predecessor already provides literal descriptor +iteration for a different view ABI, while its numerical service remains +structured control. This contribution is the actual runtime descriptor +producer and fixed-graph composition on the current supplied five-Gamma ABI, +with source-specific axis/order binding and complete costs. It does not +claim a new reversal, tensor identity, numeral-conversion method or faster +monomial tariff. + +The five-Gamma/raw entry packet is still supplied. Production of this ABI +from the selected caller, its actual physical owner selector, conversion from +other component encodings, the source matrix G, remaining monomial factors, +recursive children, global stock and analytic recovery remain separate. +In particular the source owner number 415 binds which native operation +contains the factor; it does not identify the physical DATA tape of a full +selected compiler invocation. The theorem's same-owner statement begins at +its explicit DATA entry owner. + +All five selected assumptions remain retained: `native_all_columns`, +`owned_erasure`, `compiler`, `precision_tape`, and `analytic_recovery`. +The complete selected kappa remains 0.00363005817. This is one removed local +descriptor-production premise, not an unconditional multiplication theorem. + +Credit the selected #7000 source and its retained Clifford/native contributors; +the exact source-binding and packed ABI in the published B3 package; the +published C3 literal-row-reversal program and its classical two-stack lineage; +the prior literal phase's Gamma/unary helpers; and #7349's literal machine. +The retained references preserve their notices. Independent AI review does +not constitute human or proof-kernel acceptance. diff --git a/research/literal-fixed-mask-native-translation/implementation/reference/translation/reference/inputs/controller_reference.py b/research/literal-fixed-mask-native-translation/implementation/reference/translation/reference/inputs/controller_reference.py new file mode 100644 index 0000000000..3ab6d0361f --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/translation/reference/inputs/controller_reference.py @@ -0,0 +1,112 @@ +"""Finite three-tape online rank-recursion control; Apache-2.0. +Only PC and local symbols affect execution. Metrics/event logs are observers. +""" +from dataclasses import dataclass, field +BLANK, ONE, MARK = '_', '1', '|' +WIDTH, CHILD, STACK = range(3) + +class Builder: + def __init__(self): self.code, self.labels, self.serial = [], {}, 0 + def mark(self,n): + if n in self.labels: raise ValueError('duplicate label') + self.labels[n]=len(self.code) + def op(self,*x): self.code.append(x) + def rewind(self,t,symbols): + self.serial+=1; loop=f'rw{self.serial}'; done=loop+'done' + self.op('move',t,-1); self.mark(loop) + self.op('read',t,{s:loop+'step' for s in symbols}|{MARK:done}) + self.mark(loop+'step'); self.op('move',t,-1); self.op('goto',loop) + self.mark(done); self.op('move',t,1) + def finish(self,alphabet): + result=[] + for op,*a in self.code: + if op=='goto': a[0]=self.labels[a[0]] + elif op=='read': a[1]={s:self.labels[n] for s,n in a[1].items()} + result.append((op,*a)) + return tuple(result),tuple(alphabet) + +def compile_controller(m,ranks): + """Parameters are compile-time constants, absent from run-time state.""" + if type(m) is not int or m<2 or not ranks: raise ValueError('bad fixed profile') + if any(type(r) is not int or not 1<=r=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-fixed-mask-native-translation/implementation/reference/translation/reference/reverse.py b/research/literal-fixed-mask-native-translation/implementation/reference/translation/reference/reverse.py new file mode 100644 index 0000000000..60fce51dd8 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/translation/reference/reverse.py @@ -0,0 +1,207 @@ +"""Literal complete-record reversal from three encoded binary descriptors. + +Prepared for Jerry Chen / CubeJerry with substantial OpenAI assistance. +Apache-2.0. The two-stack algorithm is classical and already in 02-streams; +the unary/trace helper patterns come from the credited literal S_D package. +This zero-argument compiler emits one fixed local-symbol instruction graph. +""" +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 + +(PDESC, RDESC, BDESC, DATA, OUTPUT, PTR, RTR, BTR, DOUBLE, + HTRACE, GROUP, RECORD, DTRACE) = range(13) +PRIVATE = tuple(range(4, 13)) +BITS = ('0', ONE) + + +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 descriptor_step(a, descriptor): + a.op('write', HTRACE, ONE) + a.op('move', HTRACE, 1) + a.op('move', descriptor, 1) + + +def binary_descriptor(a, descriptor, target): + """A positive canonical MSB-first binary word to a unary guide.""" + k = fresh(a, 'binary') + a.op('read', descriptor, {ONE: k+'first'}) + a.mark(k+'first') + a.op('write', target, ONE) + descriptor_step(a, descriptor) + a.mark(k+'digit') + a.op('read', descriptor, {str(b): k+str(b) for b in (0, 1)} | + {BLANK: k+'done'}) + for bit in (0, 1): + a.mark(k+str(bit)) + unary_copy(a, target, DOUBLE, repeat=2, extra=bit) + clear(a, target) + unary_copy(a, DOUBLE, target, erase=True) + descriptor_step(a, descriptor) + a.op('goto', k+'digit') + a.mark(k+'done') + trace_return(a, descriptor, HTRACE) + + +def compile_reverse(): + """Compile once; no descriptor, shape, payload or origin argument.""" + a = Builder() + for tape in PRIVATE: + a.op('move', tape, -1) + a.op('write', tape, MARK) + a.op('move', tape, 1) + for descriptor, target in ((PDESC, PTR), (RDESC, RTR), (BDESC, BTR)): + binary_descriptor(a, descriptor, target) + a.mark('prefix') + a.op('read', PTR, {ONE: 'load_record', BLANK: 'finish'}) + a.mark('load_record') + a.op('read', RTR, {ONE: 'load_bit', BLANK: 'group_loaded'}) + a.mark('load_bit') + a.op('read', BTR, {ONE: 'read_bit', BLANK: 'record_loaded'}) + a.mark('read_bit') + a.op('read', DATA, {str(b): 'load'+str(b) for b in (0, 1)}) + for bit in ('0', ONE): + a.mark('load'+bit) + a.op('write', GROUP, bit) + a.op('move', GROUP, 1) + a.op('move', DATA, 1) + a.op('write', DTRACE, ONE) + a.op('move', DTRACE, 1) + a.op('move', BTR, 1) + a.op('goto', 'load_bit') + a.mark('record_loaded') + a.rewind(BTR, (ONE,)) + a.op('move', RTR, 1) + a.op('goto', 'load_record') + a.mark('group_loaded') + a.rewind(RTR, (ONE,)) + a.op('move', GROUP, -1) + a.mark('pop_record') + a.op('read', RTR, {ONE: 'pop_bit', BLANK: 'group_popped'}) + a.mark('pop_bit') + a.op('read', BTR, {ONE: 'pop_read', BLANK: 'record_popped'}) + a.mark('pop_read') + a.op('read', GROUP, {str(b): 'pop'+str(b) for b in (0, 1)}) + for bit in ('0', ONE): + a.mark('pop'+bit) + a.op('write', RECORD, bit) + a.op('move', RECORD, 1) + a.op('write', GROUP, BLANK) + a.op('move', GROUP, -1) + a.op('move', BTR, 1) + a.op('goto', 'pop_bit') + a.mark('record_popped') + a.rewind(BTR, (ONE,)) + a.op('move', RECORD, -1) + a.mark('emit_record') + a.op('read', RECORD, {str(b): 'emit'+str(b) for b in (0, 1)} | + {MARK: 'record_emitted'}) + for bit in ('0', ONE): + a.mark('emit'+bit) + a.op('write', OUTPUT, bit) + a.op('move', OUTPUT, 1) + a.op('write', RECORD, BLANK) + a.op('move', RECORD, -1) + a.op('goto', 'emit_record') + a.mark('record_emitted') + a.op('move', RECORD, 1) + a.op('move', RTR, 1) + a.op('goto', 'pop_record') + a.mark('group_popped') + a.op('read', GROUP, {MARK: 'prefix_done'}) + a.mark('prefix_done') + a.op('move', GROUP, 1) + a.rewind(RTR, (ONE,)) + a.op('move', PTR, 1) + a.op('goto', 'prefix') + a.mark('finish') + # Exact cardinality is derived from descriptor guides before DATA writes. + a.op('read', DATA, {BLANK: 'verified', '0': 'reject', ONE: 'reject'}) + a.mark('verified') + trace_return(a, DATA, DTRACE) + a.rewind(OUTPUT, BITS) + a.mark('commit') + a.op('read', OUTPUT, {str(b): 'commit'+str(b) for b in (0, 1)} | + {BLANK: 'committed'}) + for bit in ('0', ONE): + a.mark('commit'+bit) + a.op('write', DATA, bit) + a.op('write', OUTPUT, BLANK) + a.op('move', OUTPUT, 1) + a.op('move', DATA, 1) + a.op('write', DTRACE, ONE) + a.op('move', DTRACE, 1) + a.op('goto', 'commit') + a.mark('committed') + trace_return(a, DATA, DTRACE) + a.rewind(OUTPUT, (BLANK,)) + a.rewind(PTR, (ONE,)) + for tape in (PTR, RTR, BTR): + clear(a, tape) + 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', DATA, {}) + return a.finish((BLANK, '0', ONE, MARK)) + diff --git a/research/literal-fixed-mask-native-translation/implementation/reference/translation/translate.py b/research/literal-fixed-mask-native-translation/implementation/reference/translation/translate.py new file mode 100644 index 0000000000..5e1149f8ab --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/reference/translation/translate.py @@ -0,0 +1,221 @@ +"""Literal descriptor production and selected post-matrix X_1 translation. + +Prepared for Jerry Chen / CubeJerry with substantial OpenAI assistance. +Apache-2.0. Gamma/unary patterns are credited to the retained native phase; +the complete-record permutation is the unchanged retained row-reversal graph. +All integer arithmetic below is fixed-table construction, never runtime work. +""" +from pathlib import Path +import hashlib +import importlib.util +import sys + +HERE = Path(__file__).resolve().parent +PINS = { + 'reference/reverse.py': '4b516d85baf3303db809bc1174394009b1fc71a8f7d17fb6c729ec8bb6aba245', + 'reference/inputs/controller_reference.py': 'e664a748e6b6797d4b60f60a7a7dd68b59a5608acf56b9c5d8b466f363755f73', +} +for path, expected in PINS.items(): + if hashlib.sha256((HERE / path).read_bytes()).hexdigest() != expected: + raise ValueError('frozen source bytes: ' + path) +spec = importlib.util.spec_from_file_location('translation_retained_reverse', HERE / 'reference/reverse.py') +REV = importlib.util.module_from_spec(spec) +sys.modules[spec.name] = REV +spec.loader.exec_module(REV) +Builder, BLANK, ONE, MARK = REV.Builder, REV.BLANK, REV.ONE, REV.MARK +clear, unary_copy, trace_return, fresh = REV.clear, REV.unary_copy, REV.trace_return, REV.fresh +BITS = ('0', ONE) + +HEADER, DATA, PDESC, RDESC, BDESC = range(5) +# The retained reversal's nine private ports become 5,...,13. +HTRACE, LENGTH, DOUBLE, F, COEFF, OUTER, SPECTATOR, WIDTH, PRODUCT, HALF, DIGITS = range(14, 25) +PRODUCER_PRIVATE = (PDESC, RDESC, BDESC) + tuple(range(14, 25)) +ALL_PRIVATE = tuple(range(2, 25)) +REVERSE_PORTS = (PDESC, RDESC, BDESC, DATA) + tuple(range(5, 14)) + + +def header_step(a): + a.op('write', HTRACE, ONE) + a.op('move', HTRACE, 1) + a.op('move', HEADER, 1) + + +def gamma(a, target): + """Retained five-Gamma decoding pattern on this fixed private inventory.""" + 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 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) + header_step(a) + a.op('move', LENGTH, -1) + a.op('goto', k+'tail') + a.mark(k+'done') + a.op('move', LENGTH, 1) + + +def power_descriptor(a): + """Write the canonical descriptor 1 followed by f zeroes, not unary 2^f.""" + a.op('write', RDESC, ONE) + a.op('move', RDESC, 1) + k = fresh(a, 'power') + a.mark(k) + a.op('read', F, {ONE: k+'bit', BLANK: k+'done'}) + a.mark(k+'bit') + a.op('write', RDESC, '0') + a.op('move', RDESC, 1) + a.op('move', F, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(F, (ONE,)) + a.rewind(RDESC, BITS) + + +def product_guide(a): + """Generate exactly 2*S*r*w unary marks by actual nested local scans.""" + k = fresh(a, 'product') + a.mark(k+'s') + a.op('read', SPECTATOR, {ONE: k+'r', BLANK: k+'done'}) + a.mark(k+'r') + a.op('read', COEFF, {ONE: k+'w', BLANK: k+'r_done'}) + a.mark(k+'w') + a.op('read', WIDTH, {ONE: k+'bit', BLANK: k+'w_done'}) + a.mark(k+'bit') + for _ in range(2): + a.op('write', PRODUCT, ONE) + a.op('move', PRODUCT, 1) + a.op('move', WIDTH, 1) + a.op('goto', k+'w') + a.mark(k+'w_done') + a.rewind(WIDTH, (ONE,)) + a.op('move', COEFF, 1) + a.op('goto', k+'r') + a.mark(k+'r_done') + a.rewind(COEFF, (ONE,)) + a.op('move', SPECTATOR, 1) + a.op('goto', k+'s') + a.mark(k+'done') + a.rewind(SPECTATOR, (ONE,)) + a.rewind(PRODUCT, (ONE,)) + + +def suffix_power(a): + """Multiply the PRODUCT guide by 2^(8f), in eight fixed doublings per mark.""" + k = fresh(a, 'suffix') + a.mark(k) + a.op('read', F, {ONE: k+'bit', BLANK: k+'done'}) + a.mark(k+'bit') + for _ in range(8): + unary_copy(a, PRODUCT, DOUBLE, repeat=2) + clear(a, PRODUCT) + unary_copy(a, DOUBLE, PRODUCT, erase=True) + a.op('move', F, 1) + a.op('goto', k) + a.mark(k+'done') + a.rewind(F, (ONE,)) + + +def unary_binary(a, source, destination): + """Consume positive unary n; emit canonical MSB-first binary n in O(n). + + source, HALF, DIGITS and destination are distinct guarded physical roles. + Every parity, quotient and termination choice is a local scanned branch. + """ + k = fresh(a, 'encode') + a.op('goto', k+'p0q0') + for phase, (current, quotient) in enumerate(((source, HALF), (HALF, source))): + for parity in (0, 1): + name = k+f'p{phase}q{parity}' + a.mark(name) + a.op('read', current, {ONE: name+'bit', BLANK: name+'done'}) + a.mark(name+'bit') + a.op('write', current, BLANK) + if parity: + a.op('write', quotient, ONE) + a.op('move', quotient, 1) + a.op('move', current, 1) + a.op('goto', k+f'p{phase}q{1-parity}') + a.mark(name+'done') + a.rewind(current, (BLANK,)) + a.rewind(quotient, (ONE,)) + a.op('write', DIGITS, str(parity)) + a.op('move', DIGITS, 1) + a.op('read', quotient, {ONE: k+f'p{1-phase}q0', BLANK: k+'emit_start'}) + a.mark(k+'emit_start') + a.op('move', DIGITS, -1) + a.mark(k+'emit') + a.op('read', DIGITS, {str(b): k+'emit'+str(b) for b in (0, 1)} | {MARK: k+'done'}) + for bit in (0, 1): + a.mark(k+'emit'+str(bit)) + a.op('write', destination, str(bit)) + a.op('move', destination, 1) + a.op('write', DIGITS, BLANK) + a.op('move', DIGITS, -1) + a.op('goto', k+'emit') + a.mark(k+'done') + a.op('move', DIGITS, 1) + a.rewind(destination, BITS) + + +def retained_reversal(a, after): + """Construction-only relabeling; every retained runtime instruction remains local.""" + code, alphabet = REV.compile_reverse() + if alphabet != (BLANK, '0', ONE, MARK): + raise ValueError('retained alphabet') + for pc, instruction in enumerate(code): + a.mark('reverse_'+str(pc)) + op, *args = instruction + if op == 'read': + a.op(op, REVERSE_PORTS[args[0]], {s: 'reverse_'+str(dst) for s, dst in args[1].items()}) + elif op in ('write', 'move'): + a.op(op, REVERSE_PORTS[args[0]], args[1]) + elif op == 'goto': + a.op(op, 'reverse_'+str(args[0])) + elif op == 'halt': + a.op('goto', after) + else: + raise ValueError('nonlocal retained opcode') + + +def compile_translation(): + """One fixed 25-tape program; no runtime integer or recipe argument.""" + a = Builder() + for tape in PRODUCER_PRIVATE: + a.op('move', tape, -1) + a.op('write', tape, MARK) + a.op('move', tape, 1) + for target in (F, COEFF, OUTER, SPECTATOR, WIDTH): + gamma(a, target) + trace_return(a, HEADER, HTRACE) + power_descriptor(a) + product_guide(a) + suffix_power(a) + unary_binary(a, OUTER, PDESC) + unary_binary(a, PRODUCT, BDESC) + retained_reversal(a, 'retire_descriptors') + a.mark('retire_descriptors') + for tape in PRODUCER_PRIVATE: + clear(a, tape, BITS) + for tape in PRODUCER_PRIVATE: + a.op('move', tape, -1) + a.op('write', tape, BLANK) + a.op('move', tape, 1) + a.op('halt') + return a.finish((BLANK, '0', ONE, MARK)) diff --git a/research/literal-fixed-mask-native-translation/implementation/verify.py b/research/literal-fixed-mask-native-translation/implementation/verify.py new file mode 100644 index 0000000000..c3e15066c7 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/implementation/verify.py @@ -0,0 +1,219 @@ +"""Exact algebra, parser-boundary and complete literal HOME replay.""" +from pathlib import Path +import atexit +from hashlib import sha256 +import json +import random +import shutil +import subprocess +import sys +import tempfile +import time + +HERE=Path(__file__).resolve().parent +_cache=tempfile.TemporaryDirectory(prefix='affine-verify-') +atexit.register(_cache.cleanup) +sys.dont_write_bytecode=True +sys.pycache_prefix=str(Path(_cache.name)/'required-absent') +import adapter as A +import affine as C +from machine import Program,initial,fields,check_retired + + +def need(ok,message): + if not ok:raise ValueError(message) + + +def gamma(n): + if n<1:raise ValueError('positive Gamma value') + bits=bin(n)[2:] + return '0'*(len(bits)-1)+bits + + +def header(shape): + return ''.join(gamma(n) for n in shape) + + +def packed_mask(offset,f): + return sum(((1<>slot)&1) + + +def xor_image(data,shape,offset): + """Natural full-address XOR oracle, no slot swaps or CNOT simulation.""" + f,c,p,s,w,_=shape + count=1<<(9*f);record=2*c*s*w;mask=packed_mask(offset,f) + need(len(data)==p*count*record,'oracle full tensor length') + return ''.join(data[(outer*count+(address^mask))*record: + (outer*count+(address^mask)+1)*record] + for outer in range(p) for address in range(count)) + + +def word_image(x,word): + for target,control in word: + x^=((x>>control)&1)<=y for x,y in zip(state.highs,old_highs)),'old backing refunded') + reuse={'shape':small_shape,'F':len(small_bits),'steps':state.steps-old_steps, + 'retained_guide_high':state.highs[-1]} + mixed_shape=(1,2,2,3,3,1<<63) + mixed_data=''.join(str(rng.randrange(2)) for _ in range(2*2*2*3*3*512)) + mixed,*_=run_packet(264,mixed_shape,mixed_data,7428264) + identity,*_=run_packet(0,(1,1,1,1,2,1),small_data,7428000) + controls=[] + for mutation,expected_offset in (('omit_last_conjugator_gate',255),('wrong_conjugation_order',1)): + graph,_=A.compile_home(511,mutation=mutation) + s=initial((parked,bits),A.TAPES);Program(graph).run(s) + expected=header(shape)+xor_image(data,shape,expected_offset) + need(fields(s)==(parked,expected) and expected!=header(shape)+xor_image(data,shape,511), + 'actual conjugation omission/order mutant') + check_retired(s);controls.append({'mutation':mutation,'actual_offset':expected_offset,'steps':s.steps}) + source_corruption() + return {'marker':'PASS_LITERAL_GENERIC_AFFINE_HOME','algebra':exact,'parser_probes':probes, + 'core_tapes':C.TAPES,'tapes':A.TAPES,'tables':tables,'full_offset':full, + 'mixed_far_offset':mixed,'identity':identity,'same_owner_reuse':reuse, + 'executed_mutants':controls,'controls':['omitted conjugator target','wrong conjugation order', + 'actual retained-source corruption','no early original-owner write','cutoff parser extent'], + 'scope':'fixed-offset address permutation only; no source-MOVE/caller/monomial dispatcher/nonleaf admission'} + + +if __name__=='__main__': + start=time.monotonic();result=run() + if '--write' in sys.argv:(HERE/'RESULT.json').write_text(json.dumps(result,indent=2,sort_keys=True)+'\n') + elif (HERE/'RESULT.json').exists(): + need(json.loads((HERE/'RESULT.json').read_text())==json.loads(json.dumps(result)),'receipt drift') + print(json.dumps(result,sort_keys=True));print('elapsed_seconds',round(time.monotonic()-start,3)) diff --git a/research/literal-fixed-mask-native-translation/review/independent/RESULT.json b/research/literal-fixed-mask-native-translation/review/independent/RESULT.json new file mode 100644 index 0000000000..b31624ef09 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/review/independent/RESULT.json @@ -0,0 +1,79 @@ +{ + "checks": [ + "G e0 equals each nonzero fixed coordinate mask", + "reverse word is the GF(2) inverse", + "G after X0 after G^-1 equals XOR by b for every one-column address", + "bit0-absent maximum word and slow/fast packed slot ordering", + "P/S/coefficient/Re-Im/width record-index representation sanity only" + ], + "complete_packet_block": { + "P": 2, + "S": 2, + "addresses_per_outer_row": 262144, + "all_S_coefficient_component_width_cells_represented": true, + "coefficients": 2, + "description": "Direct address-index block-copy sanity only; no emitted tape graph is executed.", + "f": 2, + "independent_whole_packet_routing_check": false, + "offset": 510, + "outer_rows_preserved_by_direct_index_formula": true, + "record_block_bytes_per_address": 24, + "row_major_representation_sanity_cells": 12582912, + "width": 3 + }, + "f3_lift_controls": { + "all_masks": 512, + "checks": 2048, + "deterministic_column_vectors_per_mask": 4, + "f": 3 + }, + "full_f2_address_space": { + "f": 2, + "masks": { + "264": 262144, + "510": 262144, + "511": 262144 + }, + "slot_order": "slot 0 is the most-significant f-bit chunk; slot 8 is the least-significant chunk", + "total_complete_addresses": 786432 + }, + "limits": [ + "The checker proves the finite GF(2) identities and their per-column lift; it does not execute the tape graph.", + "The direct f=2 record-block slice calculation is only a row-major representation sanity check, not an independent whole-packet routing result.", + "The source proof and inherited #7428/#7430 guarantees remain responsible for the universal literal routing and tariff.", + "No selected full MOVE, phase, caller, or nonleaf admission is proved by this translation-only review." + ], + "one_column": { + "conjugation_address_checks": 261632, + "length_histogram": { + "0": 2, + "1": 8, + "10": 1, + "2": 28, + "3": 64, + "4": 98, + "5": 112, + "6": 98, + "7": 64, + "8": 29, + "9": 8 + }, + "masks": 512, + "maximum_word": { + "length": 10, + "mask": 510 + }, + "nonzero_matrix_checks": 511 + }, + "source": { + "affine_py_sha256": "9387d4caa6ea6ad9e232f4a2a07112fa1a681d34af19e5aae64d1d8adc5ebd2c", + "author_freeze_sha256": "de2753cb42a012e07aa7ace263bedce5c4be8506ae30ab768af9e165a6edd6e0", + "canonical_main": "e54523517d0f03e58352e647c403a5af3e525a57", + "generic_cnot_head_7430": "39b40c465f7636a4bb6d70af28595fe8f70f4f3f", + "generic_cnot_linear_blob": "6aad40a6c47ed4415917c86fabbd5227a3819a41", + "method": "Separate GF(2) row-matrix products and direct packed-address enumeration; no author imports.", + "proof_sha256": "f43040c6331dc29ecf3f435e980cc71f00a60e421f50f4e843192a23e733bd44", + "translation_head_7428": "1dbdaa414cfe4a4a0f015e88a04b52e146566786" + }, + "status": "PASS_INDEPENDENT_FIXED_MASK_GF2_REVIEW" +} diff --git a/research/literal-fixed-mask-native-translation/review/independent/REVIEW.md b/research/literal-fixed-mask-native-translation/review/independent/REVIEW.md new file mode 100644 index 0000000000..757df834fe --- /dev/null +++ b/research/literal-fixed-mask-native-translation/review/independent/REVIEW.md @@ -0,0 +1,94 @@ +# Independent cross-review: fixed affine mask translation + +## Decision and pinned scope + +**Pass for the stated fixed-mask translation theorem and its direct-leaf invoice.** I found no mismatch in the conjugator direction, coordinate ordering, full-column extension, or complete bounds. This is a read-only review of the frozen package; it does not admit a source MOVE, a selected caller, or any wider assumption. + +Canonical base: `e54523517d0f03e58352e647c403a5af3e525a57`. + +| Item | Exact pin | +|---|---| +| A freeze manifest SHA-256 | `de2753cb42a012e07aa7ace263bedce5c4be8506ae30ab768af9e165a6edd6e0` | +| `PROOF.md` SHA-256 | `f43040c6331dc29ecf3f435e980cc71f00a60e421f50f4e843192a23e733bd44` | +| `affine.py` SHA-256 | `9387d4caa6ea6ad9e232f4a2a07112fa1a681d34af19e5aae64d1d8adc5ebd2c` | +| #7428 first-slot translation head | `1dbdaa414cfe4a4a0f015e88a04b52e146566786` | +| #7428 retained proof Git blob | `5c6325471aaed465737491870443f063c821b7a0` | +| #7430 fixed CNOT source head | `39b40c465f7636a4bb6d70af28595fe8f70f4f3f` | +| #7430 linear module Git blob | `6aad40a6c47ed4415917c86fabbd5227a3819a41` | + +`independent_check.py` authenticates the full A freeze inventory, its proof/source hashes, and the #7428/#7430 source pins before running. It imports no author module or oracle. + +## Conjugator and bit order + +The fixed offset `b` uses its low nine-bit mask convention: bit `i` means output coordinate slot `i`. For `b != 0`, let `p` be its least set coordinate. The fixed chronological CNOT word first swaps slots 0 and `p` when `p>0`, then applies `j <- j xor p` for each other set bit `j`. The initial swap sends `e_0` to `e_p`; the later gates set exactly the other supported bits without changing `p`. Thus the word matrix satisfies `G e_0=b`. Reversing the word gives `G^{-1}` because each CNOT is an involution. + +The literal factor order is `G^{-1}`, then `X_0`, then `G`. In function-composition notation it maps + +`x -> G(G^{-1}x xor e_0) = x xor G e_0 = x xor b`. + +This direction is correct. Reordering it to `G^{-1},G,X_0` would leave only `X_0`; the package's executed order mutant is an appropriate negative control. Offset zero is a separate identity transaction with no CNOT or reversal. Offset one has an empty conjugator and is exactly the retained first-slot operation. + +The apparent endianness hazard is resolved by keeping the two representations distinct. The nine-bit `b` numbers native slots from 0 through 8, with slot 0 the slow/outer coordinate. The flattened address integer stores slot 0 as its most-significant `f`-bit chunk and slot 8 as its least-significant chunk. Consequently the packed address mask is + +`sum(((1<1`. + +I checked the retained CNOT table against its pair-block geometry. In `linear.py`, the variables named `high` and `low` are set to `min(target,control)` and `max(target,control)`. For each prefix and each middle assignment, row-major pair blocks are `00,01,10,11` for those two coordinate slots; `PREFIX`, `MIDDLE`, and `BLOCK` account for the earlier coordinates, intervening coordinates, and complete suffix/record. The source tables `(0,1,3,2)` when the control is the first slot and `(0,3,2,1)` when it is the second implement the corresponding target-xor-control truth tables. I found no reversed target/control or slow/fast-slot error. The three CNOT swap word is also an exact SWAP on the two selected bits. + +## All columns and complete spectators + +For every column `j`, write the nine native address bits as `x^(j) in F_2^9`. The unchanged #7430 CNOT body applies each fixed gate to the same bit `j` in both complete `f`-bit slots; the #7428 reversal implements `X_0` on every column because `2^f-1-a_0 = a_0 xor (2^f-1)`. The one-column identity above therefore gives `x^(j) -> x^(j) xor b` independently for every `j`, for every positive `f`. + +In packed row-major form, each supported slot's entire `f`-bit chunk is XORed with `2^f-1`. The transformation acts only on the address axis. The `P` outer row, `S` spectator, `c` Gaussian coefficient records, real/imaginary components, and all `w` raw bits remain within the same complete address record. Every signed pattern, including the minimum signed value, is valid because the program moves complete bit records and performs no arithmetic, sign change, scale conversion, or rounding. + +The independent checker forms 9-by-9 GF(2) row matrices directly and verifies: + +- every nonzero mask `b` has `G e_0=b` and the reversed CNOT word is a two-sided inverse; +- `G X_0 G^{-1}` in the stated chronology equals XOR by `b` for all 512 one-column addresses: 511 masks times 512 addresses, or 261,632 exact cases; +- for `f=2`, all 262,144 packed addresses each pass for offsets 264, 510 and 511, covering separated far slots, a bit-0-absent maximum word, and the full mask; +- for `f=3`, four deterministic full-width coordinate vectors pass for every mask; the universal lift itself follows column by column from the exact matrix identity; +- a direct row-major address-index sanity with `f=2`, `P=S=c=2`, and `w=3` represents 12,582,912 opaque component cells and checks the placement formula for outer rows and S/coefficient/component/width blocks. This is a representation sanity check, not an independent whole-packet routing check or an execution of the emitted tape graph. + +The finite identities corroborate the written universal column-lift proof; they do not extend that proof to physical graph execution at `f>1`. + +The fixed word length is `popcount(b)-1` when bit 0 is set and `popcount(b)+2` when bit 0 is absent and `b` is nonzero. The maximum is 10 at `b=510`; it has bit 0 clear and support on slots 1 through 8. The bound is correct, and no claim that 10 is a shortest possible implementation is needed. + +## Header tail and cutoff + +The core X0 translation and fixed CNOT word each consume only the first five Gamma fields `f,c,P,S,w`. The X0 parser returns its header by following its own trace and does not read the next symbol; #7428 already proves the first-slot routine accepts an opaque tail immediately after those five codes. The fixed CNOT routine has the same five-field parser. The HOME adapter is a separate boundary: it copies and returns all six Gamma fields, including the cutoff, without converting the cutoff value into a runtime loop count. Its scans are over the encoded header length `E`. + +The retained author observer probes are consistent with this exact boundary. With `E5=11`, cutoff code lengths corresponding to 1, 2, 64, 513 and 4097 represented bits all have identical `681,487` core steps, read offsets only 0 through 10, and maximum header head offset 11. These are source/observer fixtures, not a new cutoff theorem. The core has no cutoff rejection branch because this is a pure address permutation; it preserves the sixth field. The complete bill charges the whole `E6` header. + +## Costs and lifecycle + +Using the retained complete bounds `T_X <= 4096(V+E5+1)` for X0 and `T_G(k) <= 1024 k f(V+1)+8192(V+E+1)` for a fixed CNOT word, plus the outer `31V+27` transaction, the two conjugator words and X0 sum to + +`4096(V+E+1) + 2048k f(V+1) + 16384(V+E+1) + 31V+27`. + +For `k<=10`, `f(V+1)<=2fV` and `V<=fV`, this is at most + +`61471 fV + 20480 E + 20507 <= 2^20(fV+E+1)`. + +At fixed origins, X0, each complete fixed CNOT word, and the outer WORK/TRACE transaction contribute at most `32+64+64+8=168` times `(V+E+1)` visited backing, below the stated core envelope `256(V+E+1)`. Retired cells are not refunded; `K_entry` retains older history. The HOME adapter separately adds at most `128(F+1)` transitions and `64(F+1)` backing, so the combined incremental history bound is `320(F+1)`. B1 full-bank delivery/return, `Setup_b`, fixed program storage, origin provisioning, typed reservation, and caller placement remain separate charges. + +I found no hidden count depending on the numerical cutoff, no additional runtime mask dispatch, and no missing CNOT gate in the stated word expansion. These are direct fixed-mask leaf bounds, not the selected nonleaf monomial tariff. + +## Novelty boundary and open interfaces + +#7428 already supplies the complete first-slot translation, descriptor production, same-owner return, opaque-tail behavior, and its invoice. #7430 already supplies the generic fixed nine-slot CNOT body and fixed-word emitter. The scoped contribution here is their literal composition into an arbitrary construction-time fixed `b` offset in the Gamma6/HOME lifecycle, with the explicit two-word/one-translation invoice. This is a narrow physical interface composition, not new XOR algebra or a first general affine theorem. + +The selected rank-one event `24472` (`MOVE 415,3,99,false`) has a right factor with `offset=1` and constant phase `1` in the authenticated recipe at `publication/native-endpoint/research/literal-selected-move-join/reference/RECIPE.json` (SHA-256 `96fadb44c3316be93c6c02f50cd2c841a9541d67b98fd94fc47b73fa64dd404c`). This fixed-mask service covers that offset action alone. It does not supply the nonzero `i^1` constant phase or any complete source monomial/MOVE join. + +The theorem begins with a supplied owned Gamma6 packet and the stated blankness/origin promises. It does not supply failure cleanup or retry, an actual source producer, a full selected caller, a nonleaf supplier, an inherited-assumption discharge, or a new `kappa`. + +## Replay + +From the repository root: + +```sh +python3 -I -B worker-c/research/generic-affine-translation-review/independent_check.py worker-a/research/generic-affine-native-translation --write +python3 -O -I -B worker-c/research/generic-affine-translation-review/independent_check.py worker-a/research/generic-affine-native-translation +``` + +Both modes produce the same `RESULT.json`; `--write` writes only under this review directory. The checker uses explicit `require` checks, does not import the author package, and authenticates the frozen source bytes before its algebraic calculations. diff --git a/research/literal-fixed-mask-native-translation/review/independent/independent_check.py b/research/literal-fixed-mask-native-translation/review/independent/independent_check.py new file mode 100644 index 0000000000..0b7a19d61e --- /dev/null +++ b/research/literal-fixed-mask-native-translation/review/independent/independent_check.py @@ -0,0 +1,317 @@ +#!/usr/bin/env python3 +"""Independent GF(2) and packed-address review of the frozen fixed-mask join. + +No imports from the author package. The only package reads are for exact +source/freeze authentication. All checks remain active under python -O. +""" +from __future__ import annotations +import argparse +import hashlib +import json +from pathlib import Path + +EXPECTED_FREEZE = "de2753cb42a012e07aa7ace263bedce5c4be8506ae30ab768af9e165a6edd6e0" +EXPECTED_PROOF = "f43040c6331dc29ecf3f435e980cc71f00a60e421f50f4e843192a23e733bd44" +EXPECTED_AFFINE = "9387d4caa6ea6ad9e232f4a2a07112fa1a681d34af19e5aae64d1d8adc5ebd2c" +N = 9 +IDENTITY = tuple(1 << i for i in range(N)) + + +def require(ok: bool, why: str) -> None: + if not ok: + raise ValueError(why) + + +def sha(raw: bytes) -> str: + return hashlib.sha256(raw).hexdigest() + + +def authenticate(package: Path) -> dict: + freeze_raw = (package / "FREEZE.json").read_bytes() + require(sha(freeze_raw) == EXPECTED_FREEZE, "affine package freeze drift") + freeze = json.loads(freeze_raw) + require(freeze["status"] == "FROZEN", "author package is not frozen") + require(freeze["canonical_main"] == "e54523517d0f03e58352e647c403a5af3e525a57", + "canonical base drift") + files = {row["path"]: row for row in freeze["files"]} + require("PROOF.md" in files and "affine.py" in files and "SOURCES.json" in files, + "freeze lacks review targets") + for rel, row in files.items(): + raw = (package / rel).read_bytes() + require(len(raw) == row["bytes"] and sha(raw) == row["sha256"], + "frozen byte drift: " + rel) + require(files["PROOF.md"]["sha256"] == EXPECTED_PROOF, "proof pin mismatch") + require(files["affine.py"]["sha256"] == EXPECTED_AFFINE, "affine implementation pin mismatch") + listed = set(files) + excluded = set(freeze.get("excluded_generated_paths", [])) + actual = {p.relative_to(package).as_posix() for p in package.rglob("*") if p.is_file()} + actual.discard("FREEZE.json") + require(actual - listed <= excluded, "unfrozen package files found") + require(listed <= actual, "frozen package file missing") + sources = json.loads((package / "SOURCES.json").read_text()) + require(sources["canonical_main"] == freeze["canonical_main"], "source inventory base drift") + require(sources["translation_head"] == "1dbdaa414cfe4a4a0f015e88a04b52e146566786", + "#7428 translation source head drift") + require(sources["translation_proof_blob"] == "5c6325471aaed465737491870443f063c821b7a0", + "#7428 proof Git blob drift") + require(sources["parent_rank2_freeze_sha256"] == + "072dfea997d4db796d492eaf746e0bd99630964741b88862d0f10f5fc1e00275", + "rank2 parent source drift") + rank2_sources = json.loads((package / "reference/rank2/SOURCES.json").read_text()) + cnot_rows = [row for row in rank2_sources["files"] + if row.get("path") == "research/literal-selected-linear-maps/linear.py" + and row.get("commit") == "39b40c465f7636a4bb6d70af28595fe8f70f4f3f"] + require(len(cnot_rows) == 1 and cnot_rows[0].get("blob") == + "6aad40a6c47ed4415917c86fabbd5227a3819a41", + "#7430 generic CNOT source pin drift") + return freeze + + +def gate_matrix(target: int, control: int) -> tuple[int, ...]: + rows = list(IDENTITY) + rows[target] ^= 1 << control + return tuple(rows) + + +def matmul(a: tuple[int, ...], b: tuple[int, ...]) -> tuple[int, ...]: + """GF(2) row-matrix product, rows stored as integer bit masks.""" + out = [] + for row in a: + product = 0 + for j in range(N): + if (row >> j) & 1: + product ^= b[j] + out.append(product) + return tuple(out) + + +def apply_matrix(matrix: tuple[int, ...], vector: int) -> int: + image = 0 + for i, row in enumerate(matrix): + if (row & vector).bit_count() & 1: + image |= 1 << i + return image + + +def word_matrix(word: tuple[tuple[int, int], ...]) -> tuple[int, ...]: + result = IDENTITY + for target, control in word: + result = matmul(gate_matrix(target, control), result) + return result + + +def conjugator(mask: int) -> tuple[tuple[int, int], ...]: + """Independent construction: send e_0 to the fixed output mask.""" + if mask == 0: + return () + pivot = (mask & -mask).bit_length() - 1 + word: list[tuple[int, int]] = [] + if pivot: + word.extend(((0, pivot), (pivot, 0), (0, pivot))) + for slot in range(N): + if slot != pivot and ((mask >> slot) & 1): + word.append((slot, pivot)) + return tuple(word) + + +def one_column_algebra() -> dict: + length_histogram: dict[str, int] = {} + matrix_cases = 0 + relation_cases = 0 + worst = (-1, -1) + for mask in range(1 << N): + word = conjugator(mask) + k = len(word) + length_histogram[str(k)] = length_histogram.get(str(k), 0) + 1 + expected_k = 0 if mask == 0 else (mask.bit_count() - 1 if (mask & 1) else mask.bit_count() + 2) + require(k == expected_k, "fixed word-length formula mismatch") + require(all(0 <= t < N and 0 <= c < N and t != c for t, c in word), + "invalid fixed CNOT pair") + if k > worst[1]: + worst = (mask, k) + if mask == 0: + require(not word, "zero mask must emit identity word") + continue + inverse = tuple(reversed(word)) + G = word_matrix(word) + Ginv = word_matrix(inverse) + require(matmul(G, Ginv) == IDENTITY and matmul(Ginv, G) == IDENTITY, + "reversed CNOT word is not the matrix inverse") + require(apply_matrix(G, 1) == mask, "G e0 does not equal fixed mask") + matrix_cases += 1 + for x in range(1 << N): + # Chronology: G^{-1}; X_0; G. + y = apply_matrix(G, apply_matrix(Ginv, x) ^ 1) + require(y == (x ^ mask), + f"GF(2) conjugation mismatch mask={mask} x={x} got={y}") + relation_cases += 1 + require(worst == (510, 10), "maximum fixed word should be mask 510, length 10") + require(length_histogram.get("10") == 1, "unexpected count of length-ten masks") + return {"masks": 512, "nonzero_matrix_checks": matrix_cases, + "conjugation_address_checks": relation_cases, + "maximum_word": {"mask": worst[0], "length": worst[1]}, + "length_histogram": dict(sorted(length_histogram.items(), key=lambda kv: int(kv[0])))} + + +def packed_mask(mask: int, f: int) -> int: + full = (1 << f) - 1 + return sum(full << ((8 - slot) * f) + for slot in range(N) if (mask >> slot) & 1) + + +def address_chunks(address: int, f: int) -> list[int]: + full = (1 << f) - 1 + return [(address >> ((8 - slot) * f)) & full for slot in range(N)] + + +def pack_chunks(values: list[int], f: int) -> int: + return sum(value << ((8 - slot) * f) for slot, value in enumerate(values)) + + +def apply_word_to_fbit_slots(values: list[int], word: tuple[tuple[int, int], ...]) -> None: + for target, control in word: + values[target] ^= values[control] + + +def f2_full_address_checks() -> dict: + f = 2 + address_count = 1 << (N * f) + full = (1 << f) - 1 + cases: dict[str, int] = {} + for mask in (264, 510, 511): + word = conjugator(mask) + inverse = tuple(reversed(word)) + packed = packed_mask(mask, f) + for address in range(address_count): + values = address_chunks(address, f) + apply_word_to_fbit_slots(values, inverse) + values[0] ^= full + apply_word_to_fbit_slots(values, word) + expected_values = [value ^ (full if ((mask >> i) & 1) else 0) + for i, value in enumerate(address_chunks(address, f))] + require(values == expected_values, + f"f=2 tuple mismatch mask={mask} address={address}") + require(pack_chunks(values, f) == (address ^ packed), + f"f=2 packed mask/order mismatch mask={mask} address={address}") + cases[str(mask)] = address_count + return {"f": f, "masks": cases, "total_complete_addresses": sum(cases.values()), + "slot_order": "slot 0 is the most-significant f-bit chunk; slot 8 is the least-significant chunk"} + + +def full_packet_block_check() -> dict: + """Check one whole row-major packet, with all named spectators present.""" + f, P, S, coeffs, w, mask = 2, 2, 2, 2, 3, 510 + addresses = 1 << (N * f) + per_address = S * coeffs * 2 * w + volume = P * addresses * per_address + packed = packed_mask(mask, f) + # Bytes are opaque component labels. Treat each address's S/coefficient/ + # Re-Im/width cells as one complete record block and move it unchanged. + data = bytearray((i * 73 + i // 257 + 19) & 255 for i in range(volume)) + output = bytearray(volume) + for outer in range(P): + row = outer * addresses * per_address + for address in range(addresses): + src = row + (address ^ packed) * per_address + dst = row + address * per_address + output[dst:dst + per_address] = data[src:src + per_address] + # A separate direct address-index expectation checks every retained byte. + for outer in range(P): + row = outer * addresses * per_address + for address in range(addresses): + src = row + (address ^ packed) * per_address + dst = row + address * per_address + require(output[dst:dst + per_address] == data[src:src + per_address], + "complete packet record/spectator permutation mismatch") + require(len(output) == volume == 2 * P * S * coeffs * w * addresses, + "complete packet volume mismatch") + return {"offset": mask, "f": f, "P": P, "S": S, "coefficients": coeffs, + "width": w, "addresses_per_outer_row": addresses, + "record_block_bytes_per_address": per_address, + "row_major_representation_sanity_cells": volume, + "outer_rows_preserved_by_direct_index_formula": True, + "all_S_coefficient_component_width_cells_represented": True, + "independent_whole_packet_routing_check": False, + "description": "Direct address-index block-copy sanity only; no emitted tape graph is executed."} + + +def f3_column_lift_checks() -> dict: + f = 3 + full = (1 << f) - 1 + checked = 0 + vectors = [ + [0] * 9, + [full] * 9, + [((i * 5 + 3) & full) for i in range(9)], + [((i * 3 + 1) & full) for i in range(9)], + ] + for mask in range(512): + word = conjugator(mask) + inverse = tuple(reversed(word)) + for original in vectors: + values = original.copy() + if mask: + apply_word_to_fbit_slots(values, inverse) + values[0] ^= full + apply_word_to_fbit_slots(values, word) + expected = [v ^ (full if ((mask >> i) & 1) else 0) + for i, v in enumerate(original)] if mask else original + require(values == expected, f"f=3 column lift mismatch mask={mask}") + checked += 1 + return {"f": f, "all_masks": 512, "deterministic_column_vectors_per_mask": len(vectors), + "checks": checked} + + +def run(package: Path) -> dict: + freeze = authenticate(package) + algebra = one_column_algebra() + f2 = f2_full_address_checks() + packet = full_packet_block_check() + f3 = f3_column_lift_checks() + return { + "status": "PASS_INDEPENDENT_FIXED_MASK_GF2_REVIEW", + "source": { + "canonical_main": freeze["canonical_main"], + "author_freeze_sha256": EXPECTED_FREEZE, + "proof_sha256": EXPECTED_PROOF, + "affine_py_sha256": EXPECTED_AFFINE, + "translation_head_7428": "1dbdaa414cfe4a4a0f015e88a04b52e146566786", + "generic_cnot_head_7430": "39b40c465f7636a4bb6d70af28595fe8f70f4f3f", + "generic_cnot_linear_blob": "6aad40a6c47ed4415917c86fabbd5227a3819a41", + "method": "Separate GF(2) row-matrix products and direct packed-address enumeration; no author imports." + }, + "one_column": algebra, + "full_f2_address_space": f2, + "f3_lift_controls": f3, + "complete_packet_block": packet, + "checks": [ + "G e0 equals each nonzero fixed coordinate mask", + "reverse word is the GF(2) inverse", + "G after X0 after G^-1 equals XOR by b for every one-column address", + "bit0-absent maximum word and slow/fast packed slot ordering", + "P/S/coefficient/Re-Im/width record-index representation sanity only" + ], + "limits": [ + "The checker proves the finite GF(2) identities and their per-column lift; it does not execute the tape graph.", + "The direct f=2 record-block slice calculation is only a row-major representation sanity check, not an independent whole-packet routing result.", + "The source proof and inherited #7428/#7430 guarantees remain responsible for the universal literal routing and tariff.", + "No selected full MOVE, phase, caller, or nonleaf admission is proved by this translation-only review." + ] + } + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument("package", nargs="?", type=Path, + default=Path("worker-a/research/generic-affine-native-translation")) + parser.add_argument("--write", action="store_true", help="write RESULT.json beside this checker") + args = parser.parse_args() + result = run(args.package.resolve()) + rendered = json.dumps(result, indent=2, sort_keys=True) + "\n" + if args.write: + (Path(__file__).resolve().parent / "RESULT.json").write_text(rendered) + print(rendered, end="") + + +if __name__ == "__main__": + main() diff --git a/research/literal-fixed-mask-native-translation/review/root/RESULT.json b/research/literal-fixed-mask-native-translation/review/root/RESULT.json new file mode 100644 index 0000000000..053f5350a1 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/review/root/RESULT.json @@ -0,0 +1,49 @@ +{ + "E": 272, + "F": 24848, + "V": 24576, + "controls": [ + "host mask used without slot-endian conversion changes expected output", + "omitted far-slot offset changes expected output" + ], + "core_instructions": 16965, + "core_sha256": "ef2e7a5123d2b1ecbc3e1b31294edd58c5bba66aa4e14a3acc497cfc66d7bbde", + "input_sha256": "cdddfa87ffee2bfe4cbb83e9ce6c65350b0b6bc98d361f1c0fe20c82f36c5704", + "offset": 292, + "oracle": "Independent direct address XOR on complete P/native/S/coefficient/component records; no emitted conjugator or author oracle imported", + "output_sha256": "6738e2455ddeb09d5255f0793b2973729b31dd6ba6621295e2f7f4ecc7b4010d", + "physical_stream_xor": 73, + "receipt": { + "HOME_writes": 24848, + "checkpoints": { + "AFFINE_B292.71": { + "home_writes": 0, + "steps": 199011 + }, + "jump.5": { + "home_writes": 0, + "steps": 22342974 + }, + "jump.70": { + "home_writes": 0, + "steps": 22268360 + } + }, + "early_HOME_writes": 0, + "entry_head_history": 149737, + "final_head_history": 471436, + "steps": 22467224 + }, + "scope": "One full f1 shifted-origin call with external multiplicities, minimum signed bit patterns and a130-bit unused cutoff; all-f theorem and complete cost proof remain separate.", + "shape": { + "coefficients": 2, + "cutoff_bit_length": 130, + "f": 1, + "outer": 2, + "spectators": 2, + "width": 3 + }, + "states": 17142, + "status": "PASS_ROOT_AFFINE_HOME", + "tapes": 35 +} diff --git a/research/literal-fixed-mask-native-translation/review/root/ROOT-REVIEW.md b/research/literal-fixed-mask-native-translation/review/root/ROOT-REVIEW.md new file mode 100644 index 0000000000..39e8030c7c --- /dev/null +++ b/research/literal-fixed-mask-native-translation/review/root/ROOT-REVIEW.md @@ -0,0 +1,87 @@ +# Root review of the arbitrary fixed affine translation + +Canonical base: `e54523517d0f03e58352e647c403a5af3e525a57`. +Author freeze: `de2753cb42a012e07aa7ace263bedce5c4be8506ae30ab768af9e165a6edd6e0`. + +## Claim reviewed and result + +For each construction-time nine-bit mask b, the fixed literal core translates +each of the f native columns by b, with all P/S/coefficient/component factors +preserved. Gamma6/HOME has an explicitly supplied valid entry; this is not a +source-bound complete MOVE or selected caller admission. I found no defect in +the frozen proof, local invoice or successful lifecycle under those premises. +This review is performed by the same AI research programme, is not blind or +human peer review, and is not a formal-kernel proof. + +## Universal obligations checked directly + +The fixed CNOT word G maps e0 to b. For a mask whose lowest set coordinate p is +nonzero, the three-CNOT exchange sends e0 to ep; every remaining supported +coordinate then receives that p bit. Reversing the word gives its inverse. +The chronological composition G^-1, X0, G is therefore x -> x XOR b on each +column. The same word acts independently on all f columns; the unchanged X0 +complements all f bits of its first slot. No numerical precision or range +premise is needed for this complete-record permutation. In particular minimum +signed component bit patterns are allowed. Mask coordinates refer to native +slots, not the integer bit order of a lexicographic stream address. + +The two CNOT words have at most ten gates each, including the exchange when +bit zero is absent. The retained X0 reads exactly five Gamma codes and returns +HEADER using its private trace before examining the trailing sixth field. +Its trace can visit the first cutoff position but does not read or write it. +The current operation enforces no central-C cutoff: it preserves that field +for a later service. A valid positive canonical Gamma6 entry is still supplied. + +Each embedded factor modifies WORK, not original DATA; private ports are +injective and disjoint from the outer WORK/TRACE. Retained successful return +and retirement allow their fixed port cohort to be reused. Only the final +outer commit installs original DATA; HOME scatters only after primitive return. +Malformed input, interruption and rejected-call private cleanup are unclaimed. + +The sum of the retained full X0 bound, two fixed-word bounds, and the outer +transaction is at most + +`(4096k+20511)fV + 20480E + 20507`, with `k<=10`. + +This is at most `2^20(fV+E+1)`. Incremental history sums to at most +`(32+64+64+8)(V+E+1)=168(V+E+1)`, fitting the stated core reserve256. +HOME adds128(F+1) time and64(F+1) history, giving320(F+1) total history. +Prior backing, fixed Setup_b/origins/reservation and B1 whole-bank movement +remain separately charged. This is a direct O_b(fV+E) leaf routine, not the +selected accelerated monomial tariff. + +## Separate physical execution + +`check_affine_root.py` uses a sparse unit-step graph interpreter written in +this root review line. It imports the emitted adapter graph, not the author's +CPU or numerical/address oracle. Every embedded instruction is compared to the +actual core instruction table. Its mathematical oracle directly XORs complete +lexicographic address blocks; it does not construct or apply G. + +The fresh mask292 uses slots2,5,8; its physical MSB-stream XOR is73. The fixture +has f=1, P=S=c=2, width3 and a130-bit cutoff. Its V=24576 bits include all512 +native addresses, distinct external factors and minimum signed raw patterns. +The expected output differs both from a host-endian mask error and from +omitting the far supported slot. These are oracle-discrimination controls; +the author's separate verifier supplies actual graph-mutant executions. + +The interpreter executes22,467,224 transitions through17,142 graph states. +It checks all24,848 final HOME writes occur after primitive return, with zero +earlier HOME writes. All35 heads, private fields, opaque exteriors and a +parked productive owner are restored/preserved. The recorded visited interval +sum increases from149,737 to471,436; an old guide extent remains included. +The complete stated time/history bounds hold for this fixture. The frozen +JSON receipt contains input/output, core and shape hashes. + +Run from the package with the explicit implementation directory: + +```sh +python3 -I -B -W error review/root/check_affine_root.py implementation +``` + +The author separately covers identity, all-slot511, a different far-slot264, +large unused cutoff syntax, same-owner reuse and two actual faulty graphs. +This root physical run has f=1; it is not universal numerical execution or a +complete f>1 native packet. The all-f result relies on the written invariants +and credited unchanged CNOT/X0 helper proofs. No inherited assumption, whole +selected lifetime, complete multiplication bound or new kappa is established. diff --git a/research/literal-fixed-mask-native-translation/review/root/check_affine_root.py b/research/literal-fixed-mask-native-translation/review/root/check_affine_root.py new file mode 100644 index 0000000000..c2a5aa18c6 --- /dev/null +++ b/research/literal-fixed-mask-native-translation/review/root/check_affine_root.py @@ -0,0 +1,110 @@ +"""Independent sparse Graph CPU and direct XOR-address oracle for arbitrary fixed affine translation.""" +from pathlib import Path +from fractions import Fraction +import hashlib,json,sys,time +P=Path(sys.argv[1]).resolve() if len(sys.argv)>1 else Path(__file__).with_name('source').resolve() +sys.path.insert(0,str(P)) +import adapter as a +def require(ok,why): + if not ok:raise ValueError(why) +def word(x,w):return format(x%(1<>slot)&1)<<(8-slot) for slot in range(9)) + blocks={} + for p in range(outer): + for address in range(512): + bits=[] + for spectator in range(spectators): + for coefficient in range(coefficients): + for component in range(2): + value=((address^(address>>3)^(address>>6))+3*p+5*spectator+2*coefficient+3*component)% (1<