diff --git a/research/r437-preparation-composition/.gitattributes b/research/r437-preparation-composition/.gitattributes new file mode 100644 index 0000000000..fa1385d99a --- /dev/null +++ b/research/r437-preparation-composition/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/research/r437-preparation-composition/POOLED-SOURCES.json b/research/r437-preparation-composition/POOLED-SOURCES.json new file mode 100644 index 0000000000..439c24dc2c --- /dev/null +++ b/research/r437-preparation-composition/POOLED-SOURCES.json @@ -0,0 +1,618 @@ +[ + { + "path": "certificates/selected-result.json", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "research/community-hyperplane599-audit/pr589/bit589/v9/hosted/GLOBAL-TEMPLATE.json.gz", + "sha256": "0357b7cfbd7c29b4983982baf153c8a9f1e1e412690cd7fa9fc3d23d7963b20f" + }, + { + "path": "research/community-hyperplane599-audit/pr589/bit589/v9/nine/GEOMETRY.json", + "sha256": "0058c491d839142aa99ef86a5ec697ce99857632228531512ea3fa74fb24d734" + }, + { + "path": "research/e8-bit-p111-tuned/tune/EXPECTED.json", + "sha256": "b9f0e5ca038abe837b0007c8fe006f366a6f02009244ac57705a8a200e2301f4" + }, + { + "path": "research/e8-bit-p111-tuned/tune/bitE8mut-p111-tuned.json.gz", + "sha256": "e3e301e62bc2b41dbf1ceac0acf3d35824ebeab1848c5a2142d4577b109da52f" + }, + { + "path": "research/physical-compiler-correspondence/README.md", + "sha256": "bb04d8a05f0fbda2df0dc653118524ecaace3d22dd924179574fc115524df901" + }, + { + "path": "research/physical-compiler-correspondence/owners.py", + "sha256": "220918b53e45c5992471bb2fd0a95e62f410679048f3517504c851077ee94845" + }, + { + "path": "research/pr589-five-helper-hosting/PROOF.md", + "sha256": "59cae781bfbe1a01ed9e66a8efeeb5a2b995e5ecdf908586b23ecc39f2b8d647" + }, + { + "path": "research/pr589-five-helper-hosting/verify.py", + "sha256": "cf90e19ae9991b0698be03d395a8cc29061ecb307eb7fea19adfb2d23c25a367" + }, + { + "path": "research/r437-pooled-native-interface/.gitattributes", + "sha256": "a3c414970082c100e8f9cec6d96b7d5eec4c31660d670b50d46f2d8ac53a3b76" + }, + { + "path": "research/r437-pooled-native-interface/PROOF.md", + "sha256": "695c3416094ee374a6b5d5152c80ce29f18358eda21e3afb7b58c2264a6d879c" + }, + { + "path": "research/r437-pooled-native-interface/README.md", + "sha256": "be6c7a6fae80047631d926e83c73a217037cfdccdc38a5e6d0f4c38865f1ca14" + }, + { + "path": "research/r437-pooled-native-interface/RESULT.json", + "sha256": "27a20d575cb90c16a186a621d553e167f2bb6fd4e19541fe8d8dfc0208451658" + }, + { + "path": "research/r437-pooled-native-interface/SOURCES.json", + "sha256": "219bcca3f47aa555cc7c9e126ccbee3509fe7e4fe29b4968b4357ae9c1f0a006" + }, + { + "path": "research/r437-pooled-native-interface/TASK.json", + "sha256": "f8348e1128757b7e42650100f24c690f368c230f7c72c3613617a1105fba2fc7" + }, + { + "path": "research/r437-pooled-native-interface/VALIDATION.md", + "sha256": "b3b4978ca4540ea1d6083f6ba77b957750afeed222e2048f046ee62b5f31a590" + }, + { + "path": "research/r437-pooled-native-interface/VERIFY.json", + "sha256": "c23da87b8d9cb87b651b987a71fbf76811b182be474f42dc5273c7d13e4bab2b" + }, + { + "path": "research/r437-pooled-native-interface/adapter.py", + "sha256": "c1c054e5a2c650cfc267117b32896073e6735b93c5fbfb1defe6e379c4afab9e" + }, + { + "path": "research/r437-pooled-native-interface/check_interface.py", + "sha256": "b4f5fab63a262e36b5d585ad9ed6bb9436ecb8183eae233b27c8da9c448128d4" + }, + { + "path": "research/r437-pooled-native-interface/check_transport.py", + "sha256": "c1351777d8886754a172ed3f6e90586be5c664a93b66eda5e87fa9580f104ab7" + }, + { + "path": "research/r437-pooled-native-interface/inputs/EXPECTED.json", + "sha256": "67d06bcb90d2307a11975d6b25107a695be477f168f2dc289b8484ba0b7e2de0" + }, + { + "path": "research/r437-pooled-native-interface/inputs/catalogue.py", + "sha256": "83ea88f82d4a83c5f889774bfe3519b7ebaa24b6a0e2a969dafff012107a89bf" + }, + { + "path": "research/r437-pooled-native-interface/inputs/geometry.json.gz", + "sha256": "edcaebb35d313f403b2db45a2cf808617f921c83cf7a11dd5d74356570ede1a8" + }, + { + "path": "research/r437-pooled-native-interface/inputs/moves.json", + "sha256": "0a58b239795d213743b5654c59a3e4622a0ddd4a53d8dba3fa30dedef4558dff" + }, + { + "path": "research/r437-pooled-native-interface/inputs/template.json.gz", + "sha256": "6e03c76f5a4227394ea57e901eb7e93f4d1ee411ccfecd483fd44ea043550494" + }, + { + "path": "research/r437-pooled-native-interface/inputs/word.json.gz", + "sha256": "e432182d5b62c8bbefeb871fce30317234d707e5e18d4295e65ac21f7fd8365e" + }, + { + "path": "research/r437-pooled-native-interface/pooled_compiler.py", + "sha256": "fa1c589e5809ba8223eaf070cfb299bf55d843889d360b4d089824eb675e177c" + }, + { + "path": "research/r437-pooled-native-interface/replica_catalogue.py", + "sha256": "d093a5a5421596d82c6c6e9fbc7fbf3f313c803a7ba423d666b98344b1912ff3" + }, + { + "path": "research/r437-pooled-native-interface/verify.py", + "sha256": "dcbe8cdfee38ce0beff30c48a07a07009f4f054fd11454a80e834188547c2ffd" + }, + { + "path": "research/recursive-parking-boundary/README.md", + "sha256": "491aa208391ee4c2936510b1a5c5c018dd5509d9a0e88687c72ab8406cd77b18" + }, + { + "path": "research/selected-bit-local-ring-sweeps/PROOF.md", + "sha256": "846c59440cc99e28bae93ad2af99525bc769de29368080071b8427141215b4f7" + }, + { + "path": "research/selected-bit-physical-caller/PROOF.md", + "sha256": "e5a827e93fe313ba9bf4a2e300bae01b58b28004aa8a8ee119cf6d950edd9f93" + }, + { + "path": "research/selected-bit-physical-caller/README.md", + "sha256": "989ad891ce3f866c920a25e0cdd661815f982c4c854370f8c00668eaa15d770c" + }, + { + "path": "research/selected-bit-physical-caller/RESULT.json", + "sha256": "de6216b9f89f22b9602867776a7fc951ec558c852e6abd4624151e95d868af56" + }, + { + "path": "research/selected-bit-physical-caller/SNAPSHOTS.json", + "sha256": "c7b3485bdae5ddf43166cd6626bd512816e179617a4234c36584f6c57c34744a" + }, + { + "path": "research/selected-bit-physical-caller/SOURCES.json", + "sha256": "94e1f55094bbd122e4ee73413650fa24072c392d53d257041cd5d38a2269e4fd" + }, + { + "path": "research/selected-bit-physical-caller/TASK.json", + "sha256": "84319cb2f8c7c121927123e8c3271c3ec4ec93fc9be362dcfdf7ee4366cd1a74" + }, + { + "path": "research/selected-bit-physical-caller/VALIDATION.md", + "sha256": "c38eaa31a9cf3489356f2e2a675e2bc6194fa41796589edc9cbd8578b5d71c0f" + }, + { + "path": "research/selected-bit-physical-caller/VERIFY.json", + "sha256": "5bb3cf67018f35de5b825c9bb4b7a6590296da85f492ba3dbff7a6ce9bdebf8e" + }, + { + "path": "research/selected-bit-physical-caller/continuation_checks.py", + "sha256": "c6ef8fa86a7099af0eb6763a3f5bd43f8f94e1e176cfba38c0077b3e0f5fda48" + }, + { + "path": "research/selected-bit-physical-caller/frame_checks.py", + "sha256": "ced41d9244afcb5275ad5c46dc0f60265afc1e6422d29b277364e945825c4dd8" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/EVIDENCE.json", + "sha256": "77b7cbefa2ca30acf2f77e23d14808ccd27848e9c76e4c5e68a045ef7891a07f" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/PREDECESSOR.json", + "sha256": "e3127475913d62dbdf1b45d9283d2db2e9b689e0f81a703189150c1e5be2bca0" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/PROOF.md", + "sha256": "552fa306d5cc228f4d8d8553f8ac5fc6a738ef2b66a2cb765ba0638cd229794d" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/README.md", + "sha256": "6ce41fd7e6dfbe5faecc25bd36561f0a65b6ebca6fc69d3fb72569424a405045" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/RESULT.json", + "sha256": "4919655bae2e5cff051e8f2d240a8e4ebb03392a9da2fb5328daa9248fb7e88b" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/SOURCES.json", + "sha256": "7c78f539078e1bc3d893b78b5ee24cb22dc090d3763fe554e861b6c3d3e7eaf7" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/TASK.json", + "sha256": "ac7d4b38da31b373e665929027fc04afb66c3e9aedaea3296e3783637912d0e8" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/VALIDATION.md", + "sha256": "ac0f2fab0ca810ce0202d31480daa8329cba0897ab015520a2bfd4b689c4086b" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/VERIFY.json", + "sha256": "6ad0e07f68458afedece927550655b5bc5cd9861a70044fcd95bb10a2179f0a6" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/bootstrap.py", + "sha256": "eef1c418e8edbdf317d159683e30beaecd971c77cf41d6b09708576405e2141e" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/check_layout.py", + "sha256": "454b1587d1ed5ccaea19b621a67e2ceba999d7ede61188125faa41c4dd2ab2b1" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/check_nested_model.py", + "sha256": "b1941b882b0659722c3c41994c82f020c1f7ab320dc28c43c2758029ef8a48b7" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/check_recursion.py", + "sha256": "dde82badf043e553bc635a34295e2b5505d84d6dfbaf96e0cfccb8a8c3dbb158" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/check_runtime.py", + "sha256": "9fcf0c9a3c84a17446fafe8da50b63db296ba9465d48ddb6fdeac8742dfc98b1" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/check_sign.py", + "sha256": "ee4fd34acd49962a18d268aefeb20aa3c2673a10e7a43eee3e51a9bd3cf9106a" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/check_sources.py", + "sha256": "1c49984ae6ee7f8a44cde16b51e486f0b3ba4ee5c973389ac8d58a82d0a0aa3b" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/consumer.py", + "sha256": "2f2a8604c23fb2c81f24320c71ed0142118d98dde3be6086adad28e89954a777" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/control_checks.py", + "sha256": "c09d33327932b4ffbb8acb26c8a6bb621bcca542157d22f1edf72679a9359981" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/driver.py", + "sha256": "ceaf8f75de9810a05ebf8f65780b6f8bd7599a5768401d5e4386182afe615cdf" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/evidence/NOTICE.md", + "sha256": "fd7c42e89878cda6df86dde8720ece34625a337cf5edd795a421e2d3b42919e9" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/evidence/pr2688-NOTICE.md", + "sha256": "c899fccf7bd32397f0ddd85e4af35a166cefb3e3ae3407ec40edc3ab2051b617" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/evidence/pr2688-PROOF.md", + "sha256": "fa9bec0952468e4acb760a88d45d5be216325650e1a4080cf590e07b90c9f533" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/evidence/pr2708-README.md", + "sha256": "5906f6b7b2c8eea90e441476c4cbd60fe2ef981b690c63357bcfe67e3104aeef" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/evidence/pr2731-README.md", + "sha256": "19683df4394de299cbd7e1cce39bf9434ad260b1a37006587cf9aed84c9c0a03" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/layout.py", + "sha256": "3beef6534b02c3b011b741f957a7d9fb05a9ac0bba1fed53b2c71834e4ea6bc1" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/linear_sign.py", + "sha256": "73e895fc701a4145cbe89d60f5775128354e7f08d0a45eacf22f423913f54e67" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/node.py", + "sha256": "0bd4f640cafb5c8f070c161d86445910f77578a672bf5886936ed89e7f6bd21b" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/packet_engine.py", + "sha256": "c80fc3aa9092f91cc309b2fb2dbc3618bf96bdb9b8498503993ea161f0ae2134" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/peel.py", + "sha256": "8b20888f74b4cd814a97b42ec72528fbfb6d2e936c5022df726f0785d0d01a2e" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/NOTICE.md", + "sha256": "c446b32b8a621844fb2fbe654810c8122035bdd43fed2132f1137d98cb6f9943" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/PROOF.md", + "sha256": "88754d57bae35a2089d9de221ff32ba802b7a56b810f96271f3ea36985edfb14" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/README.md", + "sha256": "15631eb826b2d8d54fbee18fb6f70ee035e172d524c2a209b6c467c3f0204f64" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/RESULT.json", + "sha256": "0d94c5e9150f3fbd603526c67ea33168d3ba45e158aaf722e848bf5c316a37a8" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/SOURCES.json", + "sha256": "1b02a5c607a5967948988c3beaf37d9975d650ad501a99fcf74c135dc1f05fdd" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/TASK.json", + "sha256": "a4cd54d4b09ad12a90a5feeb39a127f0f0d5a2a04f9f88554c5fc3ee0cfe77f4" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/VERIFY.json", + "sha256": "e1dd0ee5f267ffa515bb345054ff8637cfedb0079b0d2da29b90b7848264926e" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/cardinal_counts.py", + "sha256": "59ddeac102a0cc51fa49b15aae6aeb68cd68ed217fa974ce916372a177d2ec8f" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/catalogue.py", + "sha256": "83ea88f82d4a83c5f889774bfe3519b7ebaa24b6a0e2a969dafff012107a89bf" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/check_headers.py", + "sha256": "a41dab0c487c341eb32b34a03af74454e15e9e61e7386a1ca426d83f3b68b1ca" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/check_layout.py", + "sha256": "8f776a21dc0e31f9738d822cfda38db92f1e3672afb880d4246ec5e084a50a41" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/check_runtime.py", + "sha256": "5357e4ff255f17c4209aaf71a3413a4148475f11180c4f829e8f0ebacd2877cb" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/check_sources.py", + "sha256": "6463c2724e04a313181b78e90a17cd62ee42465754902cca3e9a65c6140a15a1" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/consumer.py", + "sha256": "b28ec97b0873ff2be25aff4bdde268247ffcec0d21279d0ada196de19a0bdc66" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/control.py", + "sha256": "d3a93e54bb7d333b73917586407d11674d38b5c3fda4fbdc436fb5293ae7786a" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/control_checks.py", + "sha256": "5ea6ded8c2508fbb00d93655affdfe7907ffb60916389e0736249c003a7a5148" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/driver.py", + "sha256": "ee9e42fe95ab28fdd5e927c2d46fd480305aaad610eb2ca7ae514a5d22d9f0ac" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/fresh_rows.py", + "sha256": "e4ae08fbd658add630eb7754ebe0cbcb42c6f39cf4128f9cb92e27fcf5213a7d" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/layout.py", + "sha256": "7534b0166805f2ae8d11495c811d2bd272cea89c89b6bb5251fd411c89245a20" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/model.py", + "sha256": "c937ae8e46162f88fc1cd7646d3b22c99273029ad0f0e3131f46ddec230676cb" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/node.py", + "sha256": "b88fc9ac0b22d939311ff4f7aff788e8c87a64fd5e866498e59bd27940ee3f28" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/packet_engine.py", + "sha256": "ce7f132a6a69c802406f07c4a2119ef921e8978520ff58d5eeaeedb982c257f2" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/peel.py", + "sha256": "3de018e68601566c364c7568b110f60c1bf34941b846cdffb94401bb799f85e3" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/topology.py", + "sha256": "384d456ddba76de137a63b50019d5bba2e9f6daa4177c91643e0565d4cf1d44b" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/binding.py", + "sha256": "20169a8af6ed2b34069fd353a2bc1c42335ab686c58de8479baef33dd3fb493b" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/bitstream.py", + "sha256": "f78bac9641007dbd8824984edcac057274fe016ce78bd9cb512d0c0913274783" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/cardinality.py", + "sha256": "505d5e560c5a507e6184edcc19a87cf1fed243eb34a5cb21fbe1e4fe017e7f22" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/check_support.py", + "sha256": "d9977e87ddc5acdb836b8e4a4e3942da17a05b04ce67c04547d17b986b518964" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/children.py", + "sha256": "a78866939631214c1d1659203b2b5fc062e3c6255e9f11f975c310046b010bd6" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/controller.py", + "sha256": "fa09146991f6c04e6f4b6eb9bf0c8e103e70e90a0e402ff3d69814e6aac8ff8c" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/counts.py", + "sha256": "00b476dbda0e8cc99886bf794439e1cb9e775f435f599a3557e99321fe084069" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/directory.py", + "sha256": "4270e370b2bfe38ef73aadcd97d1b3496b56bd582115d74331eb9e5ceb90bec7" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/episode.py", + "sha256": "38f79cb2a370548471063952d5f7c74bd795a2a8496fdcf3ce0996d79e3adaff" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/forms.py", + "sha256": "1fdf9d31b7eb107c396e33f94dad61c9d3f2c709cae61178268a44ca80dbc0b4" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/low_codes.py", + "sha256": "f657e17f6088c840e3f7783e662257630f6d2c1e71c217721ffbca4d6ac93e87" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/matrices.py", + "sha256": "00b687434039b54529ee092e34f9435cfcd66e0816eb3bd2a6688c73f4e01459" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/numeric.py", + "sha256": "7327b05c4ec3e0f6d9c352cc7de85bfd4ebe940482553e77c59a773a8c09c514" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/oracle.py", + "sha256": "7bd18089e32ce48085b5e3a75159f6a82cdb2649ec682c53db05e399d97aef67" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/packet.py", + "sha256": "970e7fe0719e3dfe122b248941e6f21cd90d7dd62089fa6acbd0e5412ce083a5" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/plan.py", + "sha256": "d9c8dc93762db4d3a449814aa51e2211460648694469854d89cb48cb04188cf3" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/records.py", + "sha256": "0c9c4b23e998597fb877bb1a29da69ac869b68262abe635b162b4dba9c69b372" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/residual.py", + "sha256": "8fd24747cae498dfb2ba333e7f8a68d7315ae4c2d7530d8ca145aab95ede21df" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/routes.py", + "sha256": "ed7dc3679451696ab1dd841146b215c9515a3eec5e4ff3763f33c315f1696ada" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/selection.py", + "sha256": "bc8e371fb1fa0b41fb05ef0b34d0f4c317b2396f9833d91f44f95c2b54b4052b" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/sources.py", + "sha256": "f102edc7816d742bd89db8097254c19b843d0ef5cf6758ad42e93bcc0b214c62" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/stream.py", + "sha256": "c7dc7da5b00f27016982ada4c0416f8328568b00df16d97012f33d4b372d79b5" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/stream_runner.py", + "sha256": "751c5023ca0e477369e448583961ace6a76db2723bb6c26f81203def539f1249" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/trace.py", + "sha256": "c71ba11d793dde2ac6e4cdcf468482872975c34589bf1167f2a460cb8a74e984" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/words.py", + "sha256": "5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/predecessor/verify.py", + "sha256": "cd83797d1f420f7e5de61c1a693110b4ee0c80bac0adae4699599046b7f76f8a" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/recursive_call.py", + "sha256": "157deaa5972557893d43494a81151483bdc46373448ec677cb6a738c9b7e6f1e" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/scheduler.py", + "sha256": "0d96f7fbd6f90416167c5a52c0e3de942d1a0cae3d2968831932a9576701699f" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/stream_runner.py", + "sha256": "b255feaf6cc6e40413ae73fe302bf8f290bf4dd89f4128b23a91cc9860601801" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/trace.py", + "sha256": "3a664224c558244f606b603cad816d75e94a17c9b2620a06a1530e893dfceac2" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2753/verify.py", + "sha256": "65126e788eeea10e830fc583cf4afe0bfc4d67495cbf8ac21de3507dbe624d56" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/NOTICE.md", + "sha256": "8640d1b52fd21e5b20e8109ce9c4957ca1e19a95e26a1c80d019a6e6f4d5f178" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/PROOF.md", + "sha256": "fc9e7dcc5b385b6e508d6a6e9524b93059fa3e9fd5fcfb5eedbd85b3a54ba55e" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/README.md", + "sha256": "6550a466bfafff2ca11740e931ed9fce062eb488f23e74edff7e4bbae8282bb1" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/RESULT.json", + "sha256": "4406fec9515bb4206c75b681f046b5441319cf1ed39a13b9b0134696b1c192a7" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/SOURCES.json", + "sha256": "a6476b786632c2cbffabbe27eece790e378996c8b03eb17a01f1094f20fc4cdf" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/TASK.json", + "sha256": "964d3a4fbfb53fd58936840328ac4b770b324c9e78f722861b1db04663110626" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/VERIFY.json", + "sha256": "f9e252e8ab255b49c3b18d4db76cc09ebd9fb61d599305e0aca8bf295189028d" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/checks.py", + "sha256": "98ffbd58881aa138b8dbae4d5722855ece2a5fdf7585e53978069ae9b064eb09" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/codec.py", + "sha256": "5b9fda8136f7e60bece54e3fcc74f4ea0bec7145fa60e1ae3a4d252741b81fd3" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/vendor/parking_machine.py", + "sha256": "68134779debfb795468a1aaecbc2b9d321d7d4e451313ce7dc8fa7092561df4c" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/vendor/pr2753_recursive_call.py", + "sha256": "157deaa5972557893d43494a81151483bdc46373448ec677cb6a738c9b7e6f1e" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/vendor/words.py", + "sha256": "5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9" + }, + { + "path": "research/selected-bit-physical-caller/inputs/pr2769/verify.py", + "sha256": "37f9e51e6c038a2493b4550e3cf0bd52621b6c20e115f0886406fc9909a82120" + }, + { + "path": "research/selected-bit-physical-caller/loader.py", + "sha256": "4d8647f520b2967a0ca7dcadeb39d6ebabbce44df4193f609fef22911d0ae67b" + }, + { + "path": "research/selected-bit-physical-caller/macro_binding.py", + "sha256": "9ef31765d03d2c54fad9296f2ff0707a190ce169e44de4f0f45214e3c410c01a" + }, + { + "path": "research/selected-bit-physical-caller/macro_checks.py", + "sha256": "0631b4d6b547a76d8ea4babd3465908b9efaa058503f8330140bcc8eb22a51cb" + }, + { + "path": "research/selected-bit-physical-caller/macro_code.py", + "sha256": "f626b018124747a5f17c1603bea36cd74c00a69a0647fd7b10e9c4e2964caea8" + }, + { + "path": "research/selected-bit-physical-caller/macro_controls.py", + "sha256": "a5343faffadfdd9ea0e52d4c7c4ef24ba5e8d2dee86c8af27c094ad78944b845" + }, + { + "path": "research/selected-bit-physical-caller/macro_local_checks.py", + "sha256": "a9be60378d1282184632066b87cb044a8510b6623acf0df4dbf2f1bcd35cb830" + }, + { + "path": "research/selected-bit-physical-caller/macro_machine.py", + "sha256": "7bc6e42072a09a08ac961e05c3da01cde012d740d4b4c605f298d994f2ad7c5a" + }, + { + "path": "research/selected-bit-physical-caller/macro_selected_checks.py", + "sha256": "080e147837a4983a73e598af0cc97333e2cfb1d328f5190c9d4447a8bdbb4668" + }, + { + "path": "research/selected-bit-physical-caller/nested_bank_checks.py", + "sha256": "4c225e7d91c767b4cedcf9f9b5222875be948bf8b4ef03cedc4f46f1d570e9bb" + }, + { + "path": "research/selected-bit-physical-caller/numerical_frame.py", + "sha256": "3fd62eda5d0b48bf31ea244708a77afdc6d16cf4fc9439d140ef422a38c7406c" + }, + { + "path": "research/selected-bit-physical-caller/residual_blocks.py", + "sha256": "ab7f3df8906decd2efecfb138eac1456c106bb520b2598761f699f80680d8331" + }, + { + "path": "research/selected-bit-physical-caller/role_parking.py", + "sha256": "1884a3c260d81d5efbc0c33d86a810d6728e55e5764cfcd423f858cc685470f3" + }, + { + "path": "research/selected-bit-physical-caller/scratch_pool.py", + "sha256": "41f1eb93652b7174c3b02f95f70e1a9ce2e2aed0a729e725167c8f226e65d8db" + }, + { + "path": "research/selected-bit-physical-caller/verify.py", + "sha256": "bfba14c842ea4d97bf160588abc061553d3e4eab66cd5f32b903e1a67e661aec" + }, + { + "path": "research/selected-bit-recursive-closure/PROOF.md", + "sha256": "74cc8de20f21acb5123fe2d20996fe0925ea6e51b3dec633bd5221fb719b3344" + }, + { + "path": "upstream/build/sections/02-streams.tex", + "sha256": "606c80db61cad13aa0c3b6060dc4b88dbbe7ac60cdd831aa93f28d908fd09dab" + } +] diff --git a/research/r437-preparation-composition/PREDECESSORS.json b/research/r437-preparation-composition/PREDECESSORS.json new file mode 100644 index 0000000000..7b48c3de7c --- /dev/null +++ b/research/r437-preparation-composition/PREDECESSORS.json @@ -0,0 +1,52 @@ +{ + "pins": { + "4025": "84bd28ef6da3a3473d14a48088f30ba82d414450", + "4011": "fc1426353de3389409a27e5b9bc146a95edf811c", + "4010": "92daee4bf12255efe4ae0102eeb5f72794bf9c57" + }, + "files": { + "forward_fields.py": { + "sha256": "4b6cb4b8a20c920c32dbad7b8e99a728d75681b0b4cdc876f4bd60730302a83b", + "git_blob": "45dcf2467f2167293fada94ba93d6e9d367de18b" + }, + "predecessor4025/source/CALLER.py": { + "sha256": "7bc6e42072a09a08ac961e05c3da01cde012d740d4b4c605f298d994f2ad7c5a", + "git_blob": "5a032e8923f7f8b22bb98f3e39b804beb9906c16" + }, + "predecessor4025/source/NOTICE.md": { + "sha256": "c446b32b8a621844fb2fbe654810c8122035bdd43fed2132f1137d98cb6f9943", + "git_blob": "ef9f81510db86eaf2f0a7191d85e92a6db30ddc0" + }, + "predecessor4025/source/cardinality.py": { + "sha256": "505d5e560c5a507e6184edcc19a87cf1fed243eb34a5cb21fbe1e4fe017e7f22", + "git_blob": "b8ba857e32c5903408e1e61ff916300848b4a208" + }, + "predecessor4025/source/counts.py": { + "sha256": "00b476dbda0e8cc99886bf794439e1cb9e775f435f599a3557e99321fe084069", + "git_blob": "81b48940ce222290a40d4fb349ce827f4788469d" + }, + "predecessor4025/source/directory.py": { + "sha256": "4270e370b2bfe38ef73aadcd97d1b3496b56bd582115d74331eb9e5ceb90bec7", + "git_blob": "c74cacf5ce809c0561d374f137a52df0992b4226" + }, + "predecessor4025/source/records.py": { + "sha256": "0c9c4b23e998597fb877bb1a29da69ac869b68262abe635b162b4dba9c69b372", + "git_blob": "4f00467a0ff580954ad2fd0c7380240c753ddef3" + }, + "predecessor4025/source/stream.py": { + "sha256": "c7dc7da5b00f27016982ada4c0416f8328568b00df16d97012f33d4b372d79b5", + "git_blob": "5e5a4bb0f98971447043e25d4dd6991bfc070389" + }, + "predecessor4025/source/words.py": { + "sha256": "5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9", + "git_blob": "8d4ba37e2778acb35b34e0719df2caf138fbeb50" + }, + "predecessor4025/verify.py": { + "sha256": "b2c72707bebb9ecdba2b89675830439393e6e13c76f68dad20d42d6ef70e539a", + "git_blob": "614e57282c0edfe39f1afe45d140cf338210e62a" + } + }, + "historical_pooled_archive_sha256": "d178f0be069810017113bdb824f6985bd9cfdd7b8a8ab2411c48c02f7a57eb30", + "pooled_manifest_sha256": "95635c15a09cdac656e91b3a13ad2bf481ef4ffdcf67c7dd3c27b8400b2751ef", + "transport": "Byte-identical materialized vendor directory; historical archive retained locally outside published package." +} diff --git a/research/r437-preparation-composition/PROOF.md b/research/r437-preparation-composition/PROOF.md new file mode 100644 index 0000000000..7dff562203 --- /dev/null +++ b/research/r437-preparation-composition/PROOF.md @@ -0,0 +1,105 @@ +# Preparation composition and phase contract + +This is a source-action theorem for successful valid inputs. It is not the +complete Pi term, a physical allocator tariff, or an exponent improvement. + +## Interval + +Borrow a canonical Program, old raw-directory tape, positive old-prefix Count, +encoded history depth, modulus and Ring. Their complete bytes, heads and live +numerical ownership are protected. Actively used Program/directory/Count tapes, +modulus, Ring operands, encoded depth and arena templates enter at their canonical +head1 positions; the runtime rewinds these inputs and does not promise restoration +of arbitrary active-input entry heads. Unused spectator Words may enter at other +valid heads (the fixtures use head2), and those heads are preserved. +Specifications are independently compiled +from the pinned pooled R437 catalogue. Create Context; create frame control +Words; produce the full next directory and prefix Count; read its first prefix, +run SelectedBinding.validate_residual, clear the prefix; read the first prefix +again, run SelectedBinding.child_program, clear the prefix; then clear both +returned tapes, close the returned Count and Context and release frame controls. +This is precisely the preparation sequence used by residual_begin and +prepare_child at these named component boundaries, with geometry, child_extents, +fixed handoff copies and payload roles explicitly factored out. It does not +execute the entire Machine methods or establish literal top-level reachability. + +The Context constructor and final disposer are included. Input construction, +source/low-vocabulary compilation, Ring construction, old Program/directory +construction and later child consumption are outside this interval, and retain +separate charges. The frozen low specification is real; the admitted history is +a generic legal fallback history, not a projected good-class assertion. + +## Two radix families + +For dimension d, M=d², modulus q^w, both Context.high_count and directory.produce +invoke high_power. The original implementation repeats digit_suffix M times; +ToikY's #4025 adapter validates radix_power once and repeats the same ordered +M(w-1) Count multiplications by q. Its mathematical count is unchanged. Both +implementations exhaust the radix validator even when w=1. A complete traversal +has source-residue invoice rho; the saving is (M-1)rho per high_power. + +This package applies the identical credited adapter at **both** original +bindings, including counts.high_power reached by Context.high_count. Therefore +the full interval saves exactly 2(M-1)rho source-residue actions. Count and record +actions, cardinality, output bytes/order and physical duplicate prefix +multiplicity are unchanged. It introduces no tape, numerical Word or extra +simultaneously live storage. Context still creates and later closes its high +Count and cap, and the producer retains its M-digit odometer. No Context charge +is silently borrowed from an already-live fixture. + +## Chronological admission composition + +The #4011 adapter changes only monotone Program/Fields admission. Both validation +and child creation construct one Callback over the same history and first +prefix. Each checks exactly the same chronological predicates and finishes with +the original random-access Program restored. The child extension's later access +and output copy are unchanged. Hence there are exactly two admission savings. + +Let n=h+1, r=2I+L+5, c=Q+2I+90, F=Q+2+4096(L+1). For one admission, the removed +Program reads and moves are + + 3r n + (3c-1)h n/2, n(2r+2+ch). + +The removed Fields reads and moves are + + (3F-1)n(n+1)/2 - 3nF + 3nQ + 6n, + F n(n-1) + n(2Q+6). + +Writes are unchanged. Twice their sum is the complete interval's record saving. +The source index-Word saving is separately metered; it is not inferred from +record actions. The adapter preserves residue actions and adds no live tape or +Word. Its AST guards fail on unreviewed admission shapes. + +## Composition argument + +Directory production returns byte-identical canonical prefixes under either +radix implementation; therefore both original and cursor Callback receive the +same bytes. Cursor admission returns the same accepted state and preserves +borrowed fields; therefore the subsequent extension and disposal are identical. +The two changes affect disjoint source-action lanes (residue versus record/index) +and restore the same protected boundary state. Sequential composition gives the +sum of savings without a cross term. The verifier executes all four combinations +and checks this equality in every action lane, and checks that phase invoices +partition the entire measured interval. It also checks identical created-tape +inventory, numerical peak and slot count; this is source runtime storage, not a +full physical backing/metadata tariff. + +## Actual finite source boundary + +The pinned #4010 replica catalogue independently resolves native IDLE896352, +rank14, and old common COPY1603, rank7, at low identity over q=3. Both low source +specifications are compiled by the actual Specifications path; the current +source is fallback. Its actual compiled plan begins with a UNIT child. Q=6512 +includes the five-bit pooled source-code widening. At h=2 the old history uses +the distinct COPY and IDLE source codes, and every field belongs to its actual +compiled context. Roots are 2048*64^h, root unit2; admitted current width2048 +extends to32. The tests cover h=0/B=1 and h=2/B=2, including duplicate physical +prefixes. They are complete dimension64 high cubes only at cap1 (modulus3); +no nontrivial 3^4096 cube is executed. + +The universal source-code composition proof assumes every old/current context +is admitted, enough capacity, positive cardinalities and no concurrent mutation. +Malformed-input general rollback, selected source reachability, physical gather, +transport, geometry, coefficient evaluation, full CALL/RETURN, stock and kappa +remain separate obligations. This package cannot promote the low-level saving +to a complete recurrence. diff --git a/research/r437-preparation-composition/README.md b/research/r437-preparation-composition/README.md new file mode 100644 index 0000000000..ee2d04215e --- /dev/null +++ b/research/r437-preparation-composition/README.md @@ -0,0 +1,88 @@ +# Compose two preparation improvements on actual pooled R437 sources + +This package joins ToikY's #4025 shared radix traversal with #4011 chronological +Callback admission and independently compiles #4010's actual pooled source +contexts. It measures a complete named interval: Context construction, full +next-directory production, both first-prefix read/validate and read/child-program +phases, and disposal of every owned result and Context. + +The new composition applies radix sharing to Context.high_count as well as the +directory producer. Both variants exhaust validation and retain every ordered +Count multiplication. The interval saves **8190 validated radix traversals** +worth **4,283,370 reads, 778,050 writes and 4,553,640 moves** of source residue +Words in each dimension64/cap1 case. No tape or numerical word is added. +The chronological adapter separately saves two complete admissions; the four +original/candidate combinations prove exact additive savings without cross terms. + +| Actual-source fixture | Original total source actions | Composed total | Reduction | +|---|---:|---:|---:| +| h=0, one old physical prefix | 11,709,798 | 2,023,876 | 82.716% | +| h=2, two duplicate old physical prefixes | 21,090,379 | 10,356,737 | 50.894% | + +Totals sum separately recorded record-Tape, residue-Word and index-Word reads, +writes and unit moves. They are source-operation counts, not wall-clock or a +physical bit-machine tariff. RESULT.json preserves all lanes and phase invoices. +At h=2 the record lane alone drops 7,331,381 to 6,247,715 actions, and numerical +peak remains 4097 additional residue Words and 16 index Words (including Context +and frame controls). Created tapes and backing slots agree in all four modes. + +The current source is **native IDLE896352, rank14, Q=6512**; the old history also +uses **common COPY1603, rank7**. Actual Specifications compilation checks the low +identity contexts over q=3. The IDLE is fallback, and its actual plan starts with +a UNIT child. Legal generic histories reach current width2048 and produce a +width32 child. Active inputs enter at canonical head1; unused spectators also test head2. +Every borrowed byte/head, spectator Word, input Count and numeric +ownership set is restored after complete disposal. The first prefix is cleared +and reread between validation and extension, matching the real caller boundaries. + +These are complete dimension64 high cubes at cap1 (modulus3). They do not execute +a nontrivial 3^4096 cube. Source compilation is real; top-level selected-history +reachability and a full physical CALL/RETURN are not established. Geometry, +child_extents, transport/gather/scatter, handoff copies, coefficient evaluations, +control/allocator tariffs, original-width stock and remaining Pi terms stay +explicit. There is no new kappa or selected-frontier change. + +## Evidence and reproduction + +Run `python3 -B scripts/research_package.py --package research/r437-preparation-composition`. +The package is self-contained: its authenticated 154-file materialized pooled export preserves +all frozen notices and complete loader inventory; exact #4025 sources and the +#4011 adapter are retained with original hashes. PREDECESSORS.json and +POOLED-SOURCES.json bind bytes and upstream heads. Shared/frozen files are never +edited. The checker independently compiles both source specifications, then runs +four modes for each fixture. An independent serializer checks every returned child byte and its width32 extent. The independent invoice checker imports no runtime. +Eleven controls include two actual same-output losing compositions: leaving +Context unoptimized and silently skipping validation. Checks remain active under +optimized Python. This is AI-assisted reviewable source evidence, not independent +human acceptance or formal kernel verification. + +## Open next questions + +PROOF.md states the success contract and exact formulas. Input/low-vocabulary +compilation and construction of the borrowed Ring/old history are separate entry +charges. Successful valid-input cleanup is proved; general malformed-input +rollback is not promised. TASK.json records scope, overlap and structured next +questions. The next useful join prices geometry/child extents and fixed handoff +copies on this same pooled context, including arbitrary dirty acquisition before +the residual; it must not reuse an unpooled rank26 fixture as rank14 evidence. + +## Credit + +ToikY/#4025 supplies high_power_shared, complete producer metering and the exact +validated radix invoice. ywz65/#2590 supplied the prior cubic repeated-setup +analysis and explicitly requested shared traversal; ywz65/#2566 supplies primitive +analysis. Ross Richardson's numerical peak audit retains its credit. Chris R / +Clear1nsight #4011 supplies the forward admission adapter and source invoices; +#4010 supplies actual replica-indexed pooled source compilation. Jose Manuel / +jmbarrancoml supplies the physical caller and encoded runtime; David Arias/#2753, +Nick Petalas and the retained controller/record lineage retain their notices. +The R437/OQ4, pooling and chart work retains ai-nanachi/#3647, zxv/#3690, +Ali Romman/#1043, Sagar Thakrar/#3700, #3936/#3950/#3967, #3958/#3959/#3995, +and the authors credited by those packages. New composition, lifecycle boundary, +exact joined invoice and controls: Chris R / Clear1nsight with substantial OpenAI +Codex assistance and a separate AI review. Apache-2.0. + +Publication uses the154 unchanged upstream source files under vendor/, with exact +file/directory inventory, SHA256 and no-link checks before execution. Missing, +extra, linked and corrupted inputs reject. The original compressed archive was +retained as local evidence outside this package; transport changed, science did not. diff --git a/research/r437-preparation-composition/RESULT.json b/research/r437-preparation-composition/RESULT.json new file mode 100644 index 0000000000..2ff963ad94 --- /dev/null +++ b/research/r437-preparation-composition/RESULT.json @@ -0,0 +1,1203 @@ +{ + "cases": [ + { + "saved": { + "index": { + "moves": 2432, + "reads": 2360, + "writes": 584 + }, + "record": { + "moves": 26200, + "reads": 39286, + "writes": 0 + }, + "residue": { + "moves": 4553640, + "reads": 4283370, + "writes": 778050 + } + }, + "variants": [ + { + "B": 1, + "I": 13, + "L": 3, + "Q": 6512, + "additional_index_peak": 13, + "additional_residue_peak": 4097, + "child_kind": "unit", + "child_width": 32, + "created_record_tapes": 22, + "cursor": false, + "directory_sha256": "d5df5271cbc88c7dc31822a7a0a5000ebfe226ec3584140aa59dfa7149a30480", + "h": 0, + "new_index_slots": 13, + "new_residue_slots": 4097, + "output_sha256": "1eaf19380bf78f4098abbbd4e19641cc47ccd9a992790547333cc7a71dba1424", + "parent_width": 2048, + "phases": { + "context_create": { + "index": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "record": { + "moves": 30, + "reads": 28, + "writes": 6 + }, + "residue": { + "moves": 2278372, + "reads": 2143140, + "writes": 389295 + } + }, + "directory_produce": { + "index": { + "moves": 30, + "reads": 42, + "writes": 0 + }, + "record": { + "moves": 45984, + "reads": 45940, + "writes": 22965 + }, + "residue": { + "moves": 2646016, + "reads": 2519040, + "writes": 438272 + } + }, + "dispose_context_and_outputs": { + "index": { + "moves": 60, + "reads": 58, + "writes": 28 + }, + "record": { + "moves": 59144, + "reads": 59140, + "writes": 29564 + }, + "residue": { + "moves": 10, + "reads": 9, + "writes": 4 + } + }, + "frame_controls": { + "index": { + "moves": 146, + "reads": 142, + "writes": 41 + }, + "record": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "residue": { + "moves": 0, + "reads": 0, + "writes": 0 + } + }, + "read_child_clear": { + "index": { + "moves": 6264, + "reads": 6355, + "writes": 1372 + }, + "record": { + "moves": 209840, + "reads": 255656, + "writes": 52502 + }, + "residue": { + "moves": 2430, + "reads": 2295, + "writes": 413 + } + }, + "read_validate_clear": { + "index": { + "moves": 2468, + "reads": 2461, + "writes": 578 + }, + "record": { + "moves": 196442, + "reads": 242260, + "writes": 45840 + }, + "residue": { + "moves": 2420, + "reads": 2283, + "writes": 413 + } + } + }, + "protected_state_restored": true, + "shared": false, + "source_good": false, + "source_rank": 14, + "source_request": 896352, + "total": { + "index": { + "moves": 8968, + "reads": 9058, + "writes": 2019 + }, + "record": { + "moves": 511440, + "reads": 603024, + "writes": 150877 + }, + "residue": { + "moves": 4929248, + "reads": 4666767, + "writes": 828397 + } + } + }, + { + "B": 1, + "I": 13, + "L": 3, + "Q": 6512, + "additional_index_peak": 13, + "additional_residue_peak": 4097, + "child_kind": "unit", + "child_width": 32, + "created_record_tapes": 22, + "cursor": true, + "directory_sha256": "d5df5271cbc88c7dc31822a7a0a5000ebfe226ec3584140aa59dfa7149a30480", + "h": 0, + "new_index_slots": 13, + "new_residue_slots": 4097, + "output_sha256": "1eaf19380bf78f4098abbbd4e19641cc47ccd9a992790547333cc7a71dba1424", + "parent_width": 2048, + "phases": { + "context_create": { + "index": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "record": { + "moves": 30, + "reads": 28, + "writes": 6 + }, + "residue": { + "moves": 2278372, + "reads": 2143140, + "writes": 389295 + } + }, + "directory_produce": { + "index": { + "moves": 30, + "reads": 42, + "writes": 0 + }, + "record": { + "moves": 45984, + "reads": 45940, + "writes": 22965 + }, + "residue": { + "moves": 2646016, + "reads": 2519040, + "writes": 438272 + } + }, + "dispose_context_and_outputs": { + "index": { + "moves": 60, + "reads": 58, + "writes": 28 + }, + "record": { + "moves": 59144, + "reads": 59140, + "writes": 29564 + }, + "residue": { + "moves": 10, + "reads": 9, + "writes": 4 + } + }, + "frame_controls": { + "index": { + "moves": 146, + "reads": 142, + "writes": 41 + }, + "record": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "residue": { + "moves": 0, + "reads": 0, + "writes": 0 + } + }, + "read_child_clear": { + "index": { + "moves": 5048, + "reads": 5175, + "writes": 1080 + }, + "record": { + "moves": 196740, + "reads": 236013, + "writes": 52502 + }, + "residue": { + "moves": 2430, + "reads": 2295, + "writes": 413 + } + }, + "read_validate_clear": { + "index": { + "moves": 1252, + "reads": 1281, + "writes": 286 + }, + "record": { + "moves": 183342, + "reads": 222617, + "writes": 45840 + }, + "residue": { + "moves": 2420, + "reads": 2283, + "writes": 413 + } + } + }, + "protected_state_restored": true, + "shared": false, + "source_good": false, + "source_rank": 14, + "source_request": 896352, + "total": { + "index": { + "moves": 6536, + "reads": 6698, + "writes": 1435 + }, + "record": { + "moves": 485240, + "reads": 563738, + "writes": 150877 + }, + "residue": { + "moves": 4929248, + "reads": 4666767, + "writes": 828397 + } + } + }, + { + "B": 1, + "I": 13, + "L": 3, + "Q": 6512, + "additional_index_peak": 13, + "additional_residue_peak": 4097, + "child_kind": "unit", + "child_width": 32, + "created_record_tapes": 22, + "cursor": false, + "directory_sha256": "d5df5271cbc88c7dc31822a7a0a5000ebfe226ec3584140aa59dfa7149a30480", + "h": 0, + "new_index_slots": 13, + "new_residue_slots": 4097, + "output_sha256": "1eaf19380bf78f4098abbbd4e19641cc47ccd9a992790547333cc7a71dba1424", + "parent_width": 2048, + "phases": { + "context_create": { + "index": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "record": { + "moves": 30, + "reads": 28, + "writes": 6 + }, + "residue": { + "moves": 1552, + "reads": 1455, + "writes": 270 + } + }, + "directory_produce": { + "index": { + "moves": 30, + "reads": 42, + "writes": 0 + }, + "record": { + "moves": 45984, + "reads": 45940, + "writes": 22965 + }, + "residue": { + "moves": 369196, + "reads": 377355, + "writes": 49247 + } + }, + "dispose_context_and_outputs": { + "index": { + "moves": 60, + "reads": 58, + "writes": 28 + }, + "record": { + "moves": 59144, + "reads": 59140, + "writes": 29564 + }, + "residue": { + "moves": 10, + "reads": 9, + "writes": 4 + } + }, + "frame_controls": { + "index": { + "moves": 146, + "reads": 142, + "writes": 41 + }, + "record": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "residue": { + "moves": 0, + "reads": 0, + "writes": 0 + } + }, + "read_child_clear": { + "index": { + "moves": 6264, + "reads": 6355, + "writes": 1372 + }, + "record": { + "moves": 209840, + "reads": 255656, + "writes": 52502 + }, + "residue": { + "moves": 2430, + "reads": 2295, + "writes": 413 + } + }, + "read_validate_clear": { + "index": { + "moves": 2468, + "reads": 2461, + "writes": 578 + }, + "record": { + "moves": 196442, + "reads": 242260, + "writes": 45840 + }, + "residue": { + "moves": 2420, + "reads": 2283, + "writes": 413 + } + } + }, + "protected_state_restored": true, + "shared": true, + "source_good": false, + "source_rank": 14, + "source_request": 896352, + "total": { + "index": { + "moves": 8968, + "reads": 9058, + "writes": 2019 + }, + "record": { + "moves": 511440, + "reads": 603024, + "writes": 150877 + }, + "residue": { + "moves": 375608, + "reads": 383397, + "writes": 50347 + } + } + }, + { + "B": 1, + "I": 13, + "L": 3, + "Q": 6512, + "additional_index_peak": 13, + "additional_residue_peak": 4097, + "child_kind": "unit", + "child_width": 32, + "created_record_tapes": 22, + "cursor": true, + "directory_sha256": "d5df5271cbc88c7dc31822a7a0a5000ebfe226ec3584140aa59dfa7149a30480", + "h": 0, + "new_index_slots": 13, + "new_residue_slots": 4097, + "output_sha256": "1eaf19380bf78f4098abbbd4e19641cc47ccd9a992790547333cc7a71dba1424", + "parent_width": 2048, + "phases": { + "context_create": { + "index": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "record": { + "moves": 30, + "reads": 28, + "writes": 6 + }, + "residue": { + "moves": 1552, + "reads": 1455, + "writes": 270 + } + }, + "directory_produce": { + "index": { + "moves": 30, + "reads": 42, + "writes": 0 + }, + "record": { + "moves": 45984, + "reads": 45940, + "writes": 22965 + }, + "residue": { + "moves": 369196, + "reads": 377355, + "writes": 49247 + } + }, + "dispose_context_and_outputs": { + "index": { + "moves": 60, + "reads": 58, + "writes": 28 + }, + "record": { + "moves": 59144, + "reads": 59140, + "writes": 29564 + }, + "residue": { + "moves": 10, + "reads": 9, + "writes": 4 + } + }, + "frame_controls": { + "index": { + "moves": 146, + "reads": 142, + "writes": 41 + }, + "record": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "residue": { + "moves": 0, + "reads": 0, + "writes": 0 + } + }, + "read_child_clear": { + "index": { + "moves": 5048, + "reads": 5175, + "writes": 1080 + }, + "record": { + "moves": 196740, + "reads": 236013, + "writes": 52502 + }, + "residue": { + "moves": 2430, + "reads": 2295, + "writes": 413 + } + }, + "read_validate_clear": { + "index": { + "moves": 1252, + "reads": 1281, + "writes": 286 + }, + "record": { + "moves": 183342, + "reads": 222617, + "writes": 45840 + }, + "residue": { + "moves": 2420, + "reads": 2283, + "writes": 413 + } + } + }, + "protected_state_restored": true, + "shared": true, + "source_good": false, + "source_rank": 14, + "source_request": 896352, + "total": { + "index": { + "moves": 6536, + "reads": 6698, + "writes": 1435 + }, + "record": { + "moves": 485240, + "reads": 563738, + "writes": 150877 + }, + "residue": { + "moves": 375608, + "reads": 383397, + "writes": 50347 + } + } + } + ] + }, + { + "saved": { + "index": { + "moves": 15752, + "reads": 15496, + "writes": 3668 + }, + "record": { + "moves": 433488, + "reads": 650178, + "writes": 0 + }, + "residue": { + "moves": 4553640, + "reads": 4283370, + "writes": 778050 + } + }, + "variants": [ + { + "B": 2, + "I": 25, + "L": 3, + "Q": 6512, + "additional_index_peak": 16, + "additional_residue_peak": 4097, + "child_kind": "unit", + "child_width": 32, + "created_record_tapes": 24, + "cursor": false, + "directory_sha256": "c52a539d9e7c063d20f9c1759545f51146b21373fb7580cc7fabfa8244f6d7b3", + "h": 2, + "new_index_slots": 16, + "new_residue_slots": 4097, + "output_sha256": "3b66b89a28829d78171ce2dbb6e15ddaa33bf6de53d96a58698f283e0e328422", + "parent_width": 2048, + "phases": { + "context_create": { + "index": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "record": { + "moves": 30, + "reads": 28, + "writes": 6 + }, + "residue": { + "moves": 2278372, + "reads": 2143140, + "writes": 389295 + } + }, + "directory_produce": { + "index": { + "moves": 108, + "reads": 156, + "writes": 0 + }, + "record": { + "moves": 1007922, + "reads": 1148549, + "writes": 320769 + }, + "residue": { + "moves": 4096000, + "reads": 3993600, + "writes": 667648 + } + }, + "dispose_context_and_outputs": { + "index": { + "moves": 108, + "reads": 106, + "writes": 52 + }, + "record": { + "moves": 314830, + "reads": 314826, + "writes": 157407 + }, + "residue": { + "moves": 10, + "reads": 9, + "writes": 4 + } + }, + "frame_controls": { + "index": { + "moves": 244, + "reads": 240, + "writes": 66 + }, + "record": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "residue": { + "moves": 0, + "reads": 0, + "writes": 0 + } + }, + "read_child_clear": { + "index": { + "moves": 45644, + "reads": 47189, + "writes": 9806 + }, + "record": { + "moves": 859926, + "reads": 1099512, + "writes": 157485 + }, + "residue": { + "moves": 2430, + "reads": 2295, + "writes": 413 + } + }, + "read_validate_clear": { + "index": { + "moves": 34264, + "reads": 35291, + "writes": 7392 + }, + "record": { + "moves": 793168, + "reads": 1019452, + "writes": 137471 + }, + "residue": { + "moves": 2420, + "reads": 2283, + "writes": 413 + } + } + }, + "protected_state_restored": true, + "shared": false, + "source_good": false, + "source_rank": 14, + "source_request": 896352, + "total": { + "index": { + "moves": 80368, + "reads": 82982, + "writes": 17316 + }, + "record": { + "moves": 2975876, + "reads": 3582367, + "writes": 773138 + }, + "residue": { + "moves": 6379232, + "reads": 6141327, + "writes": 1057773 + } + } + }, + { + "B": 2, + "I": 25, + "L": 3, + "Q": 6512, + "additional_index_peak": 16, + "additional_residue_peak": 4097, + "child_kind": "unit", + "child_width": 32, + "created_record_tapes": 24, + "cursor": true, + "directory_sha256": "c52a539d9e7c063d20f9c1759545f51146b21373fb7580cc7fabfa8244f6d7b3", + "h": 2, + "new_index_slots": 16, + "new_residue_slots": 4097, + "output_sha256": "3b66b89a28829d78171ce2dbb6e15ddaa33bf6de53d96a58698f283e0e328422", + "parent_width": 2048, + "phases": { + "context_create": { + "index": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "record": { + "moves": 30, + "reads": 28, + "writes": 6 + }, + "residue": { + "moves": 2278372, + "reads": 2143140, + "writes": 389295 + } + }, + "directory_produce": { + "index": { + "moves": 108, + "reads": 156, + "writes": 0 + }, + "record": { + "moves": 1007922, + "reads": 1148549, + "writes": 320769 + }, + "residue": { + "moves": 4096000, + "reads": 3993600, + "writes": 667648 + } + }, + "dispose_context_and_outputs": { + "index": { + "moves": 108, + "reads": 106, + "writes": 52 + }, + "record": { + "moves": 314830, + "reads": 314826, + "writes": 157407 + }, + "residue": { + "moves": 10, + "reads": 9, + "writes": 4 + } + }, + "frame_controls": { + "index": { + "moves": 244, + "reads": 240, + "writes": 66 + }, + "record": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "residue": { + "moves": 0, + "reads": 0, + "writes": 0 + } + }, + "read_child_clear": { + "index": { + "moves": 37768, + "reads": 39441, + "writes": 7972 + }, + "record": { + "moves": 643182, + "reads": 774423, + "writes": 157485 + }, + "residue": { + "moves": 2430, + "reads": 2295, + "writes": 413 + } + }, + "read_validate_clear": { + "index": { + "moves": 26388, + "reads": 27543, + "writes": 5558 + }, + "record": { + "moves": 576424, + "reads": 694363, + "writes": 137471 + }, + "residue": { + "moves": 2420, + "reads": 2283, + "writes": 413 + } + } + }, + "protected_state_restored": true, + "shared": false, + "source_good": false, + "source_rank": 14, + "source_request": 896352, + "total": { + "index": { + "moves": 64616, + "reads": 67486, + "writes": 13648 + }, + "record": { + "moves": 2542388, + "reads": 2932189, + "writes": 773138 + }, + "residue": { + "moves": 6379232, + "reads": 6141327, + "writes": 1057773 + } + } + }, + { + "B": 2, + "I": 25, + "L": 3, + "Q": 6512, + "additional_index_peak": 16, + "additional_residue_peak": 4097, + "child_kind": "unit", + "child_width": 32, + "created_record_tapes": 24, + "cursor": false, + "directory_sha256": "c52a539d9e7c063d20f9c1759545f51146b21373fb7580cc7fabfa8244f6d7b3", + "h": 2, + "new_index_slots": 16, + "new_residue_slots": 4097, + "output_sha256": "3b66b89a28829d78171ce2dbb6e15ddaa33bf6de53d96a58698f283e0e328422", + "parent_width": 2048, + "phases": { + "context_create": { + "index": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "record": { + "moves": 30, + "reads": 28, + "writes": 6 + }, + "residue": { + "moves": 1552, + "reads": 1455, + "writes": 270 + } + }, + "directory_produce": { + "index": { + "moves": 108, + "reads": 156, + "writes": 0 + }, + "record": { + "moves": 1007922, + "reads": 1148549, + "writes": 320769 + }, + "residue": { + "moves": 1819180, + "reads": 1851915, + "writes": 278623 + } + }, + "dispose_context_and_outputs": { + "index": { + "moves": 108, + "reads": 106, + "writes": 52 + }, + "record": { + "moves": 314830, + "reads": 314826, + "writes": 157407 + }, + "residue": { + "moves": 10, + "reads": 9, + "writes": 4 + } + }, + "frame_controls": { + "index": { + "moves": 244, + "reads": 240, + "writes": 66 + }, + "record": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "residue": { + "moves": 0, + "reads": 0, + "writes": 0 + } + }, + "read_child_clear": { + "index": { + "moves": 45644, + "reads": 47189, + "writes": 9806 + }, + "record": { + "moves": 859926, + "reads": 1099512, + "writes": 157485 + }, + "residue": { + "moves": 2430, + "reads": 2295, + "writes": 413 + } + }, + "read_validate_clear": { + "index": { + "moves": 34264, + "reads": 35291, + "writes": 7392 + }, + "record": { + "moves": 793168, + "reads": 1019452, + "writes": 137471 + }, + "residue": { + "moves": 2420, + "reads": 2283, + "writes": 413 + } + } + }, + "protected_state_restored": true, + "shared": true, + "source_good": false, + "source_rank": 14, + "source_request": 896352, + "total": { + "index": { + "moves": 80368, + "reads": 82982, + "writes": 17316 + }, + "record": { + "moves": 2975876, + "reads": 3582367, + "writes": 773138 + }, + "residue": { + "moves": 1825592, + "reads": 1857957, + "writes": 279723 + } + } + }, + { + "B": 2, + "I": 25, + "L": 3, + "Q": 6512, + "additional_index_peak": 16, + "additional_residue_peak": 4097, + "child_kind": "unit", + "child_width": 32, + "created_record_tapes": 24, + "cursor": true, + "directory_sha256": "c52a539d9e7c063d20f9c1759545f51146b21373fb7580cc7fabfa8244f6d7b3", + "h": 2, + "new_index_slots": 16, + "new_residue_slots": 4097, + "output_sha256": "3b66b89a28829d78171ce2dbb6e15ddaa33bf6de53d96a58698f283e0e328422", + "parent_width": 2048, + "phases": { + "context_create": { + "index": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "record": { + "moves": 30, + "reads": 28, + "writes": 6 + }, + "residue": { + "moves": 1552, + "reads": 1455, + "writes": 270 + } + }, + "directory_produce": { + "index": { + "moves": 108, + "reads": 156, + "writes": 0 + }, + "record": { + "moves": 1007922, + "reads": 1148549, + "writes": 320769 + }, + "residue": { + "moves": 1819180, + "reads": 1851915, + "writes": 278623 + } + }, + "dispose_context_and_outputs": { + "index": { + "moves": 108, + "reads": 106, + "writes": 52 + }, + "record": { + "moves": 314830, + "reads": 314826, + "writes": 157407 + }, + "residue": { + "moves": 10, + "reads": 9, + "writes": 4 + } + }, + "frame_controls": { + "index": { + "moves": 244, + "reads": 240, + "writes": 66 + }, + "record": { + "moves": 0, + "reads": 0, + "writes": 0 + }, + "residue": { + "moves": 0, + "reads": 0, + "writes": 0 + } + }, + "read_child_clear": { + "index": { + "moves": 37768, + "reads": 39441, + "writes": 7972 + }, + "record": { + "moves": 643182, + "reads": 774423, + "writes": 157485 + }, + "residue": { + "moves": 2430, + "reads": 2295, + "writes": 413 + } + }, + "read_validate_clear": { + "index": { + "moves": 26388, + "reads": 27543, + "writes": 5558 + }, + "record": { + "moves": 576424, + "reads": 694363, + "writes": 137471 + }, + "residue": { + "moves": 2420, + "reads": 2283, + "writes": 413 + } + } + }, + "protected_state_restored": true, + "shared": true, + "source_good": false, + "source_rank": 14, + "source_request": 896352, + "total": { + "index": { + "moves": 64616, + "reads": 67486, + "writes": 13648 + }, + "record": { + "moves": 2542388, + "reads": 2932189, + "writes": 773138 + }, + "residue": { + "moves": 1825592, + "reads": 1857957, + "writes": 279723 + } + } + } + ] + } + ], + "full_Pi_closed": false, + "physical_payload_executed": false, + "selected_kappa_changed": false, + "source_identity": "84cc5d15252e334b9bed24c50d6826fd3d765710857e5db04889fc76d62aed1e", + "status": "PASS_ACTUAL_POOLED_PREPARATION_COMPOSITION" +} diff --git a/research/r437-preparation-composition/REVIEW.md b/research/r437-preparation-composition/REVIEW.md new file mode 100644 index 0000000000..9570263100 --- /dev/null +++ b/research/r437-preparation-composition/REVIEW.md @@ -0,0 +1,41 @@ +# Separate read-only AI review + +Reviewed 2026-10-19 against the package working bytes before publication, canonical +base20ecf2891d80b5acf18d980b2164fb44ea7faa90. This is a separate AI review, not +independent human acceptance or formal-kernel verification. + +The reviewer checked the proof, complete lifecycle partition, actual pooled +source compilation and the four-way additive-saving claim. Optimized primary +replay, independent invoice and all seven controls passed; metadata and pins +passed. All ten retained #4025/#4011 files match blobs in their pinned commit +trees, and all154 pooled export files byte-match #4010 head +92daee4bf12255efe4ae0102eeb5f72794bf9c57. + +The reviewer confirmed the additional independent returned-Program serializer +matches root/unit/depth and every UNIT metadata/parent-child record and requires +final width32. It is observational and does not change the action invoice. + +One contract clarification was requested and incorporated: actively used inputs +and arena templates must enter at canonical head1, because the retained runtime +rewinds them. Arbitrary entry-head restoration is only tested/promised for unused +spectators (fixtures use head2). PROOF.md and README.md state this explicitly. + +No blocking proof/source issue was identified within the named interval. Actual +compiled contexts, legal generic histories and cap1 finite execution remain +separate from literal selected reachability, full geometry/physical caller and +remaining Pi/stock obligations. + +## Publication-only transport review + +At12:18UTC the large archive transport was replaced by154 materialized regular +source files with identical bytes. The original archive remains local evidence +outside the publication. A separate read-only review compared every source +against that archive and confirmed the scientific receipt unchanged. Exact +file/directory inventory, no-link checks and all source hashes precede execution. + +All three optimized commands passed in a178-file package-only Git-free export; +all hashes stayed unchanged. The latest11-control suite additionally passed +from a separate readonly444-file/555-directory export, again unchanged. Temporary +mutation fixtures are writable private copies, never the published inputs. +No packaging blocker was identified. Official committed-ref export and hosted +CI remain separate publication gates. diff --git a/research/r437-preparation-composition/SOURCES.json b/research/r437-preparation-composition/SOURCES.json new file mode 100644 index 0000000000..0839f4876a --- /dev/null +++ b/research/r437-preparation-composition/SOURCES.json @@ -0,0 +1,18 @@ +{ + "schema_version": 1, + "base_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "67f085acd86acd7d4e03922d9cf4b26bca66fed5", + "sha256": "47b42433f5a85809a3aadd29c2c339da2c6ed728e4f7762df6b88bccb7874cf0" + } + ] +} diff --git a/research/r437-preparation-composition/TASK.json b/research/r437-preparation-composition/TASK.json new file mode 100644 index 0000000000..553e385d2b --- /dev/null +++ b/research/r437-preparation-composition/TASK.json @@ -0,0 +1,99 @@ +{ + "schema_version": 1, + "task_id": "selected-stock-envelope", + "priority_revision": 6, + "base_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "original_card": { + "id": "selected-stock-envelope", + "question": "What explicit uniform stock envelope does the actual selected stopped producer supply at one bootstrap stage?", + "starting_points": [ + "research/selected-bootstrap-stock-audit/README.md", + "research/bootstrap-cutoff-time-space-split/README.md", + "certificates/selected-result.json", + "docs/research/community-efficient1000-review.md", + "research/stock-margin-chain/README.md" + ], + "methods": [ + "Derive a source-bound reserve recurrence at the actual selected atom widths, separating parent stock from completed inner borrowing.", + "Find an exact missing implication or counterexample to a proposed selected-stage stock envelope." + ], + "acceptance_gate": "Bind every coefficient and depth factor to the selected producer and state the width domain. Compare a proved envelope with the sufficient cutoff guard; a large numerical headroom or a historical m=120 coefficient is not a selected m=73 proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read #2972 stock-margin chain and the selected stock audit. The new source archive reports the remaining cutoff comparisons, but leaves every actual stock coefficient unresolved; it is not an independently validated reserve envelope.", + "scope": "Source-bound orientation only. Read the named package and review before relying on its local evidence; this command is not its replay or supplier admission." + }, + "first_experiment": "Choose one actual selected producer/stage and derive its parent reserve and depth coefficient from source. Check whether newer handoffs already cover that exact obligation. Stop with the missing implementation lemma if it cannot be bounded; do not rerun #2972 cutoff/headroom arithmetic as a new contribution.", + "bottleneck_link": "This reduces a concrete inherited implementation obligation without confusing unchanged kappa arithmetic with a completed theorem.", + "allowed_variations": [ + "One stage or one explicit reserve/depth implication.", + "An independently checked same-domain proof repair, retaining all remaining assumptions." + ], + "scope_change_triggers": [ + "Importing the historical 57604 or 252 allowance without a selected-producer binding.", + "Calling a conditional fit lemma a full outer-proof adoption.", + "Replacing an actual selected stock coefficient with cutoff comparisons or a conditional fit inequality." + ], + "overlap_terms": [ + "selected stock", + "stock envelope", + "bootstrap cutoff", + "1956", + "1965", + "1990", + "2972", + "stock-margin-chain", + "actual_stock_coefficient" + ], + "existing_checks": [ + { + "scope": "Retained stock audit identifies missing actual selected-stage coefficients; later cutoff-chain arithmetic does not supply them.", + "evidence": "docs/research/research-family-status.md#revision-6-handoffs-source-archives-awaiting-independent-validation", + "remaining": "Derive one actual reserve/depth coefficient from the selected producer.", + "status": "reviewed", + "source_commit": "836b19bfa309ceafbc8ee32a15e8c4b10dde7e11", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Source-bound composition of Context construction/close, directory production, first-prefix validation and child-program preparation, with all owned output disposal. Actual pooled native IDLE896352 and old COPY1603 context; no complete physical caller or selected-source history reachability claim.", + "scope_change_reason": "Explicit donor/parent assignment joins independently published preparation improvements and actual pooled source compilation; this is a complete named preparation interval, not the original selected m73 reserve coefficient.", + "bottleneck_link": "Close a source-bound preparation interval while retaining the remaining complete Pi and physical stock obligations.", + "outcome": "partial", + "evidence": "PROOF.md, RESULT.json, four-way actual-source lifecycle replay, no-import invoice and seven scientific controls and four materialized-source inventory controls.", + "author": "Chris R / Clear1nsight with substantial OpenAI Codex assistance", + "coordination": { + "entry": "2026-10-19T10:48:00Z", + "canonical_main": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "priority_revision": 6, + "overlap": "Parent checked live handoffs, 733 open PR bodies at 10:46 UTC and latest R437 search. ToikY4025 handoff released09:58; reuse credited. Broader Discussion/closed/code coverage partial.", + "predecessors": { + "4025": "84bd28ef6da3a3473d14a48088f30ba82d414450", + "4011": "fc1426353de3389409a27e5b9bc146a95edf811c", + "4010": "92daee4bf12255efe4ae0102eeb5f72794bf9c57" + } + }, + "time_budget_minutes": 60, + "stop_rule": "Stop at a verified complete named preparation interval and exact joined saving; do not infer full Pi, physical reserve or selected-history reachability.", + "ai_assistance": "Substantial OpenAI Codex assistance for analysis, implementation and separate read-only AI review; no independent human acceptance.", + "open_questions": [ + { + "question": "Bind the preparation interval to complete residual_begin/prepare_child including geometry, child_extents and physical handoff.", + "why_it_matters": "The remaining Pi costs and original-width simultaneous lifetimes decide recursive feasibility.", + "first_step": "Use actual pooled IDLE896352 at Q6512 and include preceding arbitrary dirty acquisition; preserve the independently compiled low contexts.", + "blocked_by": "No full physical execution or geometry/transport tariff is supplied here." + }, + { + "question": "Lower the exact composed source saving to a fixed physical-control/allocator tariff.", + "why_it_matters": "Source actions and numerical peaks do not by themselves price a physical bit machine.", + "first_step": "Retain every Context/prefix/Count lifetime and price fixed control, slots and backing at original widths.", + "blocked_by": "Full stock coefficient and machine-control implementation remain open." + } + ] +} diff --git a/research/r437-preparation-composition/VALIDATION.json b/research/r437-preparation-composition/VALIDATION.json new file mode 100644 index 0000000000..afc5065b99 --- /dev/null +++ b/research/r437-preparation-composition/VALIDATION.json @@ -0,0 +1,22 @@ +{ + "canonical_main": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "priority_revision": 6, + "python": "CPython3.12.3", + "normal_registered_three_commands": "PASS", + "optimized_three_commands": "PASS", + "final_observer_serializer_primary": "PASS", + "independent_AI_review": "scoped pass after canonical-head-entry clarification; exact predecessor Git blobs and all154 retained source payloads compared", + "full_Pi_closed": false, + "physical_payload_executed": false, + "publication_and_hosted_CI": "reported separately at exact published head", + "publication_transport": { + "format": "178 regular package files including154 byte-identical vendor source files; archive transport removed", + "normal_registered_three_commands": "PASS", + "controls": "11 PASS including missing/extra/link/corruption", + "scientific_receipt_unchanged": true, + "retained_archive": "local publication-evidence/pooled-source.tar.gz outside published package", + "minimal_Git_free_replay": "PASS all3 optimized commands from178-file package-only export; hashes unchanged. Latest11 controls additionally PASS from readonly444/555 export with hashes unchanged.", + "verify_sha256": "98b38dd6ae9a657e34966bf683e0a732b7cbf2728cb108a86157ad8692ee7ad7", + "test_sha256": "cdd1caaaa01980419a4c212a04961f8122f78371fb74698ffb8c5a9a1cfe7aef" + } +} diff --git a/research/r437-preparation-composition/VERIFY.json b/research/r437-preparation-composition/VERIFY.json new file mode 100644 index 0000000000..3b839256f0 --- /dev/null +++ b/research/r437-preparation-composition/VERIFY.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 300, + "checks": "Authenticate retained exports, independently compile actual pooled contexts, run four-way lifecycle/action equality and protected-state restoration." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/independent.py" + ], + "timeout_seconds": 300, + "checks": "Derive exact additive record/radix invoices without importing runtime." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/test_verify.py" + ], + "timeout_seconds": 300, + "checks": "Losing same-output composition controls, guarded admission AST and scope/invoice mutations." + } + ] +} diff --git a/research/r437-preparation-composition/forward_fields.py b/research/r437-preparation-composition/forward_fields.py new file mode 100644 index 0000000000..45dcf2467f --- /dev/null +++ b/research/r437-preparation-composition/forward_fields.py @@ -0,0 +1,97 @@ +"""Package-local monotone field validator for Callback admission only. + +Not a replacement for arbitrary Fields.read/check_code. Its caller must issue +one next() for each chronological history step, then the current field unless +leaf=True, followed by finish(). The unchanged encoded Callback loop does this. +""" +import ast +from hashlib import sha256 + +def adapted_callback(base, records): + class ForwardFields: + def __init__(self, fields): + self.fields=fields + fields.tape.rewind() + def next(self, code): + tape=self.fields.tape + observed=records.read_finite(tape,self.fields.code_bits) + records.need(observed==code,'original global raw-field code') + while tape.read()!=records.RECORD_END: + records.need(tape.read()!=records.BLANK,'record exists at global slot') + tape.step(1) + tape.step(1) + def finish(self): + tape=self.fields.tape + complete=tape.read()==records.BLANK + tape.rewind() + records.need(complete,'exact frozen/current field prefix') + class ForwardCallback(base): pass + return ForwardCallback,ForwardFields + +def install(base,records,path,namespace): + tree=ast.parse(path.read_text()) + cls=next(x for x in tree.body if isinstance(x,ast.ClassDef) and x.name=='Callback') + method=next(x for x in cls.body if isinstance(x,ast.FunctionDef) and x.name=='_validate_program') + records.need(sha256(ast.dump(method).encode()).hexdigest()=='182c3b095d95d7ccf98d6f5e881aa58f0619621fc17b8e77030cdc4c086967b6','exact reviewed admission AST') + class Rewrite(ast.NodeTransformer): + def __init__(self):self.checks=self.ends=self.program_seeks=0 + def visit_Expr(self,node): + if isinstance(node.value,ast.Call) and isinstance(node.value.func,ast.Name) and node.value.func.id=='seek_record': + records.need(ast.unparse(node.value)=='seek_record(self.program.tape, after)','exact terminal program seek') + self.program_seeks+=1 + return ast.Pass() + return self.generic_visit(node) + def visit_Call(self,node): + if isinstance(node.func,ast.Attribute) and ast.dump(node.func.value)==ast.dump(ast.parse('self.fields',mode='eval').body): + if node.func.attr=='check_code': + records.need(len(node.args)==2 and not node.keywords,'exact check_code shape') + self.checks+=1 + return ast.Call(ast.Attribute(ast.Name('cursor',ast.Load()),'next',ast.Load()),[node.args[1]],[]) + if node.func.attr=='end': + records.need(len(node.args)==1 and not node.keywords,'exact end shape') + self.ends+=1 + return ast.Call(ast.Attribute(ast.Name('cursor',ast.Load()),'finish',ast.Load()),[],[]) + raise ValueError('unreviewed field use in admission') + return self.generic_visit(node) + edit=Rewrite();method=edit.visit(method) + records.need((edit.checks,edit.ends,edit.program_seeks)==(2,2,1),'exact monotone admission sites') + method.body.insert(0,ast.parse('cursor = ForwardFields(self.fields)').body[0]) + cls,cursor=adapted_callback(base,records) + env=dict(namespace,ForwardFields=cursor) + exec(compile(ast.fix_missing_locations(ast.Module([method],type_ignores=[])),str(path),'exec'),env) + forward_program=program_cursor(records,path.with_name('records.py')) + admitted=env['_validate_program'] + def validate(self): + original=self.program + self.program=forward_program(original) + try:admitted(self) + finally:self.program=original + cls._validate_program=validate + return cls + + +def program_cursor(records,path): + tree=ast.parse(path.read_text()) + cls=next(x for x in tree.body if isinstance(x,ast.ClassDef) and x.name=='Program') + methods=[] + for name in ('root','step'): + method=next(x for x in cls.body if isinstance(x,ast.FunctionDef) and x.name==name) + records.need(sha256(ast.dump(method).encode()).hexdigest()==PROGRAM_AST[name],'exact reviewed Program AST') + records.need(ast.unparse(method.body[-2])=='self.tape.rewind()','terminal Program rewind') + method.body[-2]=ast.parse('self.tape.step(1)').body[0] + if name=='step': + records.need(ast.unparse(method.body[1])=='seek_record(self.tape, level)','initial Program seek') + method.body.pop(1) + methods.append(method) + env=dict(vars(records)) + exec(compile(ast.fix_missing_locations(ast.Module(methods,type_ignores=[])),str(path),'exec'),env) + class ForwardProgram: + def __init__(self,program): + self.tape=program.tape + self.code_bits=program.code_bits + self.index_arena=program.index_arena + self.residue_arena=program.residue_arena + ForwardProgram.root=env['root'];ForwardProgram.step=env['step'] + return ForwardProgram + +PROGRAM_AST={'root': 'f1ce38c0bab29ef74f2f0d60373d08cfae69cbbd6b1539914d10ea4001909c02', 'step': 'a1358d976440865d1dff2c410874b89426949c3123350dd132e8eb9a7867af39'} diff --git a/research/r437-preparation-composition/independent.py b/research/r437-preparation-composition/independent.py new file mode 100644 index 0000000000..83fcd9d882 --- /dev/null +++ b/research/r437-preparation-composition/independent.py @@ -0,0 +1,28 @@ +"""No runtime imports: derive exact compositional invoice from frozen receipt.""" +import json +from pathlib import Path +HERE=Path(__file__).resolve().parent + +def need(x,m): + if not x:raise ValueError(m) +def run(data): + for row in data['cases']: + a,b,c,d=row['variants'];h=a['h'];n=h+1;I=a['I'];L=a['L'];Q=a['Q'] + r=2*I+L+5;k=Q+2*I+90;F=Q+2+4096*(L+1) + program_reads=3*r*n+(3*k-1)*h*n//2 + program_moves=n*(2*r+2+k*h) + fields_reads=(3*F-1)*n*(n+1)//2-3*n*F+3*n*Q+6*n + fields_moves=F*n*(n-1)+n*(2*Q+6) + expected={'reads':2*(program_reads+fields_reads),'writes':0,'moves':2*(program_moves+fields_moves)} + need(row['saved']['record']==expected,'twice complete Callback admission record saving') + need(row['saved']['residue']=={k:8190*v for k,v in zip(('reads','writes','moves'),(523,95,556))},'two radix families source-word saving') + need(a['created_record_tapes']==d['created_record_tapes'],'no additional tapes') + need(a['additional_residue_peak']==d['additional_residue_peak'],'no additional residue peak') + need(a['additional_index_peak']==d['additional_index_peak'],'no additional index peak') + for x in row['variants']: + need(x['protected_state_restored'] is True,'successful cleanup') + need(x['Q']==6512 and x['source_request']==896352 and x['source_rank']==14,'actual pooled identity') + return True +if __name__=='__main__': + data=json.loads((HERE/'RESULT.json').read_text());run(data) + print('PASS_INDEPENDENT_PREPARATION_INVOICE') diff --git a/research/r437-preparation-composition/predecessor4025/source/CALLER.py b/research/r437-preparation-composition/predecessor4025/source/CALLER.py new file mode 100644 index 0000000000..5a032e8923 --- /dev/null +++ b/research/r437-preparation-composition/predecessor4025/source/CALLER.py @@ -0,0 +1,453 @@ +"""One active frame, fixed stream roles and an encoded parent continuation.""" +from contextlib import contextmanager + +import loader +codec = loader.activate() +from cardinal_counts import Count, positive +from cardinality import multiply_atom_power +from directory import Context, append_tape, produce +from driver import xor_family +from episode import xor_packet +import fresh_rows +from layout import Layout +from macro_binding import view +from numeric import Geometry +from packet import read_prefix +import packet_engine +import peel +from plan import Request +from records import Program, Tape +from recursive_call import copy_word +from residual_blocks import events as block_events +from role_parking import FiniteFields, RoleParking, transfer +from routes import copy_rows, route_packet +from scratch_pool import Lease, ScratchPool +from selection import gather, scatter +from stream import Counter +from trace import child +from words import BLANK, LEFT, Ring, Unsigned, need + + +NAMES = ("source", "peeled", "old_directory", "program", "old_count", "rows", + "before", "gap", "suffix", "unused", "leading", "fibre", "highs", + "family_rows", "directory", "prefixes", "current", "copy_source", "idle", "swap", "header") +CAPSULE = ("source", "old_directory", "program", "old_count", "rows", "before", "gap", "suffix") + + +class Machine: + def __init__(self, binding, topology, programs, arena, indices, observe=None): + self.binding, self.topology, self.programs = binding, topology, tuple(programs) + self.arena, self.indices = arena, indices + staged = max(program.staged_roles for program in programs) + labels = (*NAMES, *(("family", i) for i in range(topology.families)), + *(("stage", i) for i in range(staged))) + self.roles = {label: Tape() for label in labels} + self.handoff = {label: Tape() for label in CAPSULE} + self.output = Tape() + self.pool = ScratchPool(binding.codes.q ** 2 + 128) + self.numerical = codec.BankParking(arena, indices) + self.streams = RoleParking(self.numerical, self.roles.values()) + self.header = FiniteFields((2, len(programs), max(len(p.operations) for p in programs), + arena.capacity, arena.capacity, arena.capacity, + indices.capacity, indices.capacity)) + self.context = self.program = self.size = self.depth = None + self.geometry_state = None + self.pc = self.mode = 0 + self.root = True + self.closed = False + self.observe = observe # Checker-only; the controller never reads its result. + self.counts = dict(macros=0, residuals=0, calls=0, returns=0) # Observers only. + + def tape(self, label): + return self.roles[label] + + def count(self, label): + result = object.__new__(Count) + result.tape = self.tape(label) + return result + + def commit(self, result, label): + target = self.tape(label) + if result is target: + return + target.clear() + append_tape(result, target) + target.rewind() + if isinstance(result, Lease): + result.clear() + + def save_count(self, value, label): + self.commit(value.tape, label) + value.close() + + def new_context(self, modulus, size, depth): + ring = Ring(modulus) + context = Context(ring, self.binding.codes) + self.save_count(context.highs, "highs") + context.highs = self.count("highs") + self.context, self.size, self.depth = context, size, depth + self.program = view(Program, self, self.tape("program")) + + def restore_context(self, labels): + modulus, one, cap, size, depth = labels + ring = object.__new__(Ring) + ring.arena, ring.raw = self.arena, Unsigned(self.arena) + ring.modulus, ring.one = self.arena.words[modulus], self.arena.words[one] + context = object.__new__(Context) + context.ring, context.arena, context.raw = ring, self.arena, ring.raw + context.codes = self.binding.codes + context.q, context.dimension = context.codes.q, context.codes.dimension + context.cap, context.highs = self.arena.words[cap], self.count("highs") + self.context = context + self.size, self.depth = self.indices.words[size], self.indices.words[depth] + self.program = view(Program, self, self.tape("program")) + + def boundary(self): + self.pool.empty() + for tape in self.roles.values(): + tape.step(-1) + need(tape.read() == LEFT, "completed canonical head stands after LEFT") + tape.step(1) + ring = self.context.ring + expected_indices = {self.size.slot, self.depth.slot} + if self.geometry_state is not None: + _definition, page, layout, fields, columns = self.geometry_state + expected_indices.update(word.slot for word in + (columns, page.one, page.two, page.leaf_cutoff, fields, + layout.core, layout.extra, layout.total)) + need(self.arena.live == {ring.modulus.slot, ring.one.slot, self.context.cap.slot} and + self.indices.live == expected_indices, + "only declared persistent and active geometry words at a completed macro") + + @contextmanager + def geometry(self, definition): + if self.geometry_state is not None: + owner, page, layout, fields, _columns = self.geometry_state + need(owner is definition, "one active residual geometry") + yield page, layout, fields + return + divisor = self.indices.literal(self.context.dimension) + columns, remainder = Unsigned(self.indices).divmod(self.size, divisor) + self.indices.free_many(divisor, remainder) + page = Geometry(definition.plan, self.indices, columns, self.depth, definition.code, self.program) + if self.binding.cutoff != 64: + self.indices.free(page.leaf_cutoff) + page.leaf_cutoff = self.indices.literal(self.binding.cutoff) + layout = Layout(page, self.size, self.context.ring, self.context.q, + self.count("leading"), self.count("gap"), self.count("suffix")) + fields = page.plus(self.depth, page.one) + self.geometry_state = definition, page, layout, fields, columns + yield page, layout, fields + + def close_geometry(self): + if self.geometry_state is None: + return + _definition, page, layout, fields, columns = self.geometry_state + self.geometry_state = None + self.indices.free(fields) + layout.close() + page.close() + self.indices.free(columns) + + def node(self): + divisor = self.indices.literal(self.context.dimension) + columns, remainder = Unsigned(self.indices).divmod(self.size, divisor) + valid = not columns.zero() + self.indices.free_many(divisor, columns, remainder) + need(valid, "complete internal node width") + for label in ("old_count", "rows", "before", "gap", "suffix"): + self.count(label).normalize() + positive(self.count(label)) + # Preserve source ingress validation before the first payload operation. + first = read_prefix(self.tape("old_directory"), self.depth) + self.tape("old_directory").rewind() + zero = self.indices.zero() + incoming = self.binding.incoming(self) + try: + value = incoming.coefficient(first, Request("incoming", zero)) + self.arena.free(value) + finally: + first.clear() + self.indices.free(zero) + unused = fresh_rows.quotient(self.count("rows"), self.context, self.topology.families) + self.save_count(unused, "unused") + stock = Count(self.count("unused")) + try: + need(stock.divide_small(self.binding.stock_multiple) == 0, "compatible fresh stock factor") + finally: + stock.close() + self.save_count(Count.product(self.count("unused"), self.count("before")), "leading") + fibre = Count.product(self.count("leading"), self.count("gap")) + total = Unsigned(self.indices).times_small(self.size, 2) + multiply_atom_power(fibre, total, self.context.ring, self.context.q) + self.indices.free(total) + complete = Count.product(fibre, self.count("suffix")) + fibre.close() + self.save_count(complete, "fibre") + peeled = peel.run(self.tape("source"), self.context, self.indices, self.size, self.depth, + self.program, self.tape("old_directory"), self.count("old_count"), + self.count("rows"), self.count("before"), self.count("gap"), + self.count("suffix"), incoming) + self.commit(peeled, "peeled") + self.save_count(fresh_rows.family_rows(self.context), "family_rows") + source = self.tape("peeled") + outer = Counter(self.count("old_count")) + try: + while not outer.finished: + for family in range(self.topology.families): + copy_rows(source, self.tape(("family", family)), self.count("family_rows"), self.count("fibre")) + outer.decrement() + need(source.read() == BLANK, "complete canonical fresh-row split") + finally: + outer.close() + source.rewind() + for family in range(self.topology.families): + self.tape(("family", family)).rewind() + + def residual_begin(self, role, definition): + self.binding.check_stock(self) + directory, prefixes = produce(self.tape("old_directory"), self.depth, self.count("old_count"), + definition.code, self.context) + self.commit(directory, "directory") + self.save_count(prefixes, "prefixes") + with self.geometry(definition) as (_page, _layout, fields): + first = read_prefix(self.tape("directory"), fields) + self.tape("directory").rewind() + try: + self.binding.validate_residual(self, definition, first) + finally: + first.clear() + self.commit(self.tape(role), "current") + self.counts["residuals"] += 1 + if self.observe is not None: + self.observe(self, "residual_begin", definition, role) + + def prepare_child(self, definition, event, layout, fields): + need(event.parent_identity is self.program and + event.source_code == definition.code == layout.geometry.source_code, + "recursive gate belongs to the current program and source") + raw = Unsigned(self.indices) + need(raw.compare(event.width, self.size) < 0, "strict child contraction") + extents = layout.child_extents(event.first, event.second, event.width, before=self.count("before")) + first = read_prefix(self.tape("directory"), fields) + self.tape("directory").rewind() + program = None + try: + program = self.binding.child_program(self, definition, event, first) + inputs = (self.tape("current"), self.tape("directory"), program, + self.tape("prefixes"), self.tape("unused"), *(extent.tape for extent in extents)) + for label, source in zip(CAPSULE, inputs): + target = self.handoff[label] + need(target.read() == BLANK, "empty fixed child handoff port") + append_tape(source, target) + target.rewind() + return (self.arena.copy(self.context.ring.modulus), + self.indices.copy(event.width), self.indices.copy(event.depth)) + finally: + if program is not None: + program.clear() + first.clear() + for extent in extents: + extent.close() + + def block(self, definition, block): + grants = None + with self.geometry(definition) as (page, layout, fields): + if block[0] == "axis": + axis = block[1] + trace = child(page, page.raw.times_small(page.columns, axis), + page.raw.times_small(page.columns, 3 - axis), + self.indices.copy(page.columns), "good") + else: + trace = block_events(page, block) + try: + first = next(trace, None) + if first is not None and first.kind == "enter" and page.raw.compare(first.width, page.leaf_cutoff) >= 0: + grants = self.prepare_child(definition, first, layout, fields) + else: + def complete_events(): + if first is not None: + yield first + yield from trace + result = packet_engine.run(self.tape("current"), complete_events(), layout, + self.tape("directory"), self.count("prefixes"), fields, + lambda prefix, request: self.binding.coefficient(self, definition, prefix, request)) + self.commit(result, "current") + finally: + trace.close() + if grants is not None: + self.close_geometry() + self.call(grants) + return True + return False + + def call(self, grants): + self.pool.empty() + need(self.geometry_state is None, "close derived geometry before the recursive cut") + ring = self.context.ring + self.header.write(self.tape("header"), (int(self.root), self.mode, self.pc + 1, + ring.modulus.slot, ring.one.slot, self.context.cap.slot, + self.size.slot, self.depth.slot)) + self.streams.park() + modulus, size, depth = grants + self.numerical.park(({modulus.slot}, {size.slot, depth.slot})) + for label in CAPSULE: + transfer(self.handoff[label], self.tape(label)) + self.new_context(modulus, size, depth) + self.root, self.mode, self.pc = False, self.binding.child_mode, 0 + self.counts["calls"] += 1 + + def close_frame(self): + self.close_geometry() + ring = self.context.ring + self.context.close() + ring.close() + self.arena.free(ring.modulus) + self.indices.free_many(self.size, self.depth) + for tape in self.roles.values(): + tape.clear() + self.pool.empty() + need(not self.arena.live and not self.indices.live, "child numerical cleanup before restoration") + + def returned(self): + families = {i: self.tape(("family", i)) for i in range(self.topology.families)} + result = fresh_rows.merge(families, self.context, self.topology.families, + self.count("old_count"), self.count("fibre")) + need(self.output.read() == BLANK, "empty protected return port") + append_tape(result, self.output) + self.output.rewind() + result.clear() + return self.complete_return() + + def complete_return(self): + """Return the already completed protected output through one frame.""" + self.close_frame() + if self.root: + return True + self.numerical.restore() + self.streams.restore() + root, self.mode, self.pc, *labels = self.header.read(self.tape("header")) + self.root = bool(root) + self.tape("header").clear() + self.restore_context(labels) + transfer(self.output, self.tape("current")) + self.counts["returns"] += 1 + return False + + def dispatch(self, operation): + kind, *args = operation + context, old_count, fibre = self.context, self.count("old_count"), self.count("fibre") + if kind == "node": + self.node() + elif kind == "residual_begin": + self.residual_begin(*args) + elif kind == "block": + if self.block(*args): + return "jump" + elif kind == "residual_end": + self.close_geometry() + transfer(self.tape("current"), self.tape(args[0])) + self.tape("directory").clear() + self.tape("prefixes").clear() + if self.observe is not None: + self.observe(self, "residual_end", args[1], args[0]) + elif kind == "gather_route": + role, family, low, route = args + selected = gather(self.tape(("family", family)), context, old_count, low, fibre) + try: + self.commit(route_packet(selected, route, context, old_count, fibre), role) + finally: + selected.clear() + elif kind == "route_scatter": + role, family, low, route = args + result = route_packet(self.tape(role), route, context, old_count, fibre) + try: + changed = scatter(self.tape(("family", family)), result, context, old_count, low, fibre) + self.commit(changed, ("family", family)) + finally: + result.clear() + elif kind == "gather": + role, family, low = args + self.commit(gather(self.tape(("family", family)), context, old_count, low, fibre), role) + elif kind == "scatter": + role, family, low = args + self.commit(scatter(self.tape(("family", family)), self.tape(role), context, old_count, low, fibre), ("family", family)) + elif kind == "xor": + target, source = args + self.commit(xor_packet(self.tape(source), self.tape(target), context, old_count, fibre), target) + elif kind == "family_xor": + target, source = args + self.commit(xor_family(self.tape(("family", source)), self.tape(("family", target)), + old_count, self.count("family_rows"), fibre), ("family", target)) + elif kind == "exchange": + first, second = (("family", index) for index in args) + transfer(self.tape(first), self.tape("swap")) + transfer(self.tape(second), self.tape(first)) + transfer(self.tape("swap"), self.tape(second)) + elif kind == "copy": + self.commit(self.tape(args[0]), args[1]) + if self.observe is not None: + self.observe(self, "copy_source", *args) + elif kind == "move": + transfer(self.tape(args[0]), self.tape(args[1])) + elif kind == "clear": + self.tape(args[0]).clear() + elif kind == "checkpoint": + if self.observe is not None: + self.observe(self, *args) + else: + need(kind == "return", "closed finite macro alphabet") + return "done" if self.returned() else "jump" + return "next" + + def load_root(self, source, directory, program, modulus, size, depth, old_count, rows, before, gap, suffix, mode=0): + need(not self.arena.live and not self.indices.live, "empty supplied working banks") + inputs = (source, directory, program, old_count.tape, rows.tape, before.tape, gap.tape, suffix.tape) + owned = (*self.roles.values(), *self.handoff.values(), self.output, *self.pool.tapes) + need(all(input_tape is not work_tape for input_tape in inputs for work_tape in owned), + "borrowed root input ports are outside the reusable working bank") + for label, tape in zip(CAPSULE, inputs): + self.commit(tape, label) + self.new_context(copy_word(modulus, self.arena), copy_word(size, self.indices), copy_word(depth, self.indices)) + self.mode, self.pc, self.root = mode, 0, True + + def run(self, source, directory, program, modulus, size, depth, old_count, rows, before, gap, suffix, mode=0): + need(not self.closed, "one owned root invocation per machine initialization") + with self.pool.install(): + self.load_root(source, directory, program, modulus, size, depth, old_count, rows, before, gap, suffix, mode) + while True: + self.boundary() + operation = self.programs[self.mode].operations[self.pc] + action = self.dispatch(operation) + self.counts["macros"] += 1 + if action == "done": + break + if action == "next": + self.pc += 1 + self.pool.empty() + need(self.numerical.machine.tapes == [{}, {0: "^"}], "complete physical stack return") + self.erase_work() + return self.output + + def erase_work(self): + """Erase permanent owned markers/templates at the final root return.""" + need(not self.arena.live and not self.indices.live and not self.pool.live, + "root cleanup follows complete frame and scratch cleanup") + def marker(tape): + tape.step(-1) + need(tape.read() == LEFT, "owned work marker at the known origin") + tape.write(BLANK) + tape.step(1) + for tape in (*self.roles.values(), *self.handoff.values(), *self.pool.tapes): + need(tape.read() == BLANK, "empty body before owned marker erasure") + marker(tape) + for arena in (self.arena, self.indices): + for word in arena.words: + marker(word) + arena.template.erase() + marker(arena.template) + self.numerical._empty_port() + self.numerical._move(1, -1) + self.numerical._write(1, "_") + self.numerical._move(1, 1) + self.closed = True diff --git a/research/r437-preparation-composition/predecessor4025/source/NOTICE.md b/research/r437-preparation-composition/predecessor4025/source/NOTICE.md new file mode 100644 index 0000000000..ef9f81510d --- /dev/null +++ b/research/r437-preparation-composition/predecessor4025/source/NOTICE.md @@ -0,0 +1,49 @@ +# Attribution + +Jose Manuel (`jmbarrancoml`) prepared the full first-range caller, gap/peel +integration, source catalogue binding and checks with substantial OpenAI Codex +assistance. New work uses Apache-2.0. We claim no independent human review +or new formal-kernel verification of this package. + +We credit OpenAI's retained framework and Douglas Colkitt for the stream, +interchange and tape contracts. The selected word/hosting lineage includes +DreamingOfClouds' PR589 tuning on eumemic's PR555 word, Dugongue's PR541/548, +rohanarun's PR542, eumemic's PR490 whole-owner argument and alephnan's PR1627 +literal reader and chronological hosting proof. + +The source527 contributors supplied the normal forms and weighted leaf +factorization. commdata2338 supplied PR2160's selected good form, PR2188's +mixed descriptor grammar, PR1379's parking boundary and PR2332's selected +table/global-slot binding. Ross Richardson supplied PR2159's full-ring fallback +topology and covariance. Jose Manuel's PR2157/2171/2195/2207/2234 and +PR2310/2364/2405/2449/2501/2569 supply the selected chart, controlled stream, +generated grammar, canonical-prefix, completed residual and source-route +predecessors. PR2195 supplies the ring/GL hosting lift and terminal gauge +calculation recalled in our proof. We do not claim new versions of those +algebraic identities. + +We retain 25 files from PR2569 at +`0b116cb34f27a4b064f0d8dd65549ea5705cf9c0`, including its 16 unchanged PR2501 +runtime/compiler dependencies. SOURCES.json lists their original paths, +Git blobs and SHA256 hashes. We retain their bytes and source comments. +We adapt PR2234's provider enumeration in catalogue.py and preserve its +ordered request digest. Our test-only model and observers adapt predecessor +finite expectation and origin-column patterns. The oracle module serves +fixed-q source compilation and finite expectations; we do not use it to +decode runtime high fields or execute payload permutations. + +We credit ywz65's PR2475 for conditional whole-call staging and PR2545 for its +separate buffer-residency completion. Ross Richardson's PR2519 gives a +separate one-buffer R439 adapter and relative-chart packet identity. We do +not adopt those numerical workspace constants. commdata2338's PR2386/2399 +sharpen request counts and completed leaf/header substitution. + +We credit ywz65's completed PR2566 audit of AtomSwap/Sign cost and ownership, +and PR2590 for the cubic radix-reconstruction term in directory setup. We +use PR2569's corrected proof at +`898ff36fe2cd05f733de6b26c88a4c4741b06237`; its runtime bytes match our earlier +pin. We preserve the canonical-input hypothesis and charge returned directory +and Count disposal outside the audited producer interval. + +We leave larger recursive return, numerical reserve admission and full +multiplication transfer open. We retain the selected frontier. diff --git a/research/r437-preparation-composition/predecessor4025/source/cardinality.py b/research/r437-preparation-composition/predecessor4025/source/cardinality.py new file mode 100644 index 0000000000..b8ba857e32 --- /dev/null +++ b/research/r437-preparation-composition/predecessor4025/source/cardinality.py @@ -0,0 +1,136 @@ +"""Canonical unbounded binary cardinalities on one sequential tape each.""" +from records import Tape +from stream import Counter +from words import BLANK, LEFT, ONE, RIGHT, ZERO, need + + +class Natural: + def __init__(self, source=None): + self.tape = Tape() + if source is None: + self.tape.append(ONE) + else: + source.rewind() + while source.read() != RIGHT: + bit = source.read() + need(bit in (ZERO, ONE), "binary cardinality input") + self.tape.append(bit) + source.step(1) + source.rewind() + self.tape.append(RIGHT) + self.normalize() + + def read(self): + return self.tape.read() + + def step(self, direction): + self.tape.step(direction) + + def rewind(self): + self.tape.rewind() + + def msb(self): + self.rewind() + while self.read() != RIGHT: + self.step(1) + self.step(-1) + + def normalize(self): + self.rewind() + while self.read() != RIGHT: + self.step(1) + self.step(-1) + while self.read() == ZERO: + self.tape.write(RIGHT) + self.step(1) + self.tape.write(BLANK) + self.step(-1) + self.step(-1) + if self.read() == LEFT: + self.step(1) + self.tape.write(ZERO) + self.step(1) + self.tape.write(RIGHT) + self.rewind() + + def multiply_small(self, constant): + """The multiplier and bounded carry belong to fixed finite control.""" + need(constant >= 2, "fixed cardinality multiplier") + carry = 0 + while self.read() != RIGHT: + total = constant*self.read()+carry + self.tape.write(total & 1) + carry = total >> 1 + self.step(1) + while carry: + self.tape.write(carry & 1) + carry >>= 1 + self.step(1) + self.tape.write(RIGHT) + self.rewind() + + def divide_small(self, constant): + self.msb() + remainder = 0 + while self.read() != LEFT: + remainder = 2*remainder+self.read() + if remainder >= constant: + self.tape.write(ONE) + remainder -= constant + else: + self.tape.write(ZERO) + self.step(-1) + self.step(1) + self.normalize() + return remainder + + def marginal(self): + """Copy with one high zero bit for the retained ADD input contract.""" + result = Natural(self) + result.msb() + result.step(1) + result.tape.write(ZERO) + result.step(1) + result.tape.write(RIGHT) + result.rewind() + return result + + def close(self): + self.tape.clear() + + +def radix_power(ring, q): + """Yield once per radix-q digit of M=q^w, without decoding w.""" + arena = ring.arena + divisor, power = arena.literal(q), arena.copy(ring.modulus) + try: + while ring.raw.compare(power, ring.one) > 0: + quotient, remainder = ring.raw.divmod(power, divisor) + need(remainder.zero() and not quotient.zero(), "cardinality prime-power context") + arena.free_many(power, remainder) + power = quotient + yield + need(ring.raw.compare(power, ring.one) == 0, "complete radix exponent") + finally: + arena.free_many(divisor, power) + + +def multiply_atom_power(value, exponent, ring, q): + count = Counter(exponent) + try: + while not count.finished: + for _ in radix_power(ring, q): + value.multiply_small(q) + count.decrement() + finally: + count.close() + + +def digit_suffix(value, ring, q): + """Multiply by q^(w-1), preserving an arbitrary spectator factor.""" + first = True + for _ in radix_power(ring, q): + if first: + first = False + else: + value.multiply_small(q) diff --git a/research/r437-preparation-composition/predecessor4025/source/counts.py b/research/r437-preparation-composition/predecessor4025/source/counts.py new file mode 100644 index 0000000000..81b48940ce --- /dev/null +++ b/research/r437-preparation-composition/predecessor4025/source/counts.py @@ -0,0 +1,57 @@ +"""Unbounded cardinalities; only compiled finite constants enter host control.""" +from cardinality import Natural, digit_suffix +from records import Tape +from words import ONE, RIGHT, ZERO, need + + +class Count(Natural): + @classmethod + def literal(cls, value): + """Compile a fixed cardinality, never decode a runtime operand.""" + need(isinstance(value, int) and value >= 0, "compiled cardinality") + tape = Tape() + for bit in range(max(1, value.bit_length())): + tape.append((value >> bit) & 1) + tape.append(RIGHT) + tape.rewind() + result = cls(tape) + tape.clear() + return result + + def increment(self): + self.rewind() + while self.read() == ONE: + self.tape.write(ZERO) + self.step(1) + if self.read() == RIGHT: + self.tape.write(ONE) + self.step(1) + self.tape.write(RIGHT) + else: + need(self.read() == ZERO, "canonical count digit") + self.tape.write(ONE) + self.rewind() + + def equals(self, other): + self.rewind() + other.rewind() + same = True + while self.read() != RIGHT and other.read() != RIGHT: + same = same and self.read() == other.read() + self.step(1) + other.step(1) + same = same and self.read() == other.read() == RIGHT + self.rewind() + other.rewind() + return same + + +def high_power(value, ring, q, dimension): + for _ in range(dimension*dimension): + digit_suffix(value, ring, q) + + +def high_count(ring, q, dimension): + result = Count.literal(1) + high_power(result, ring, q, dimension) + return result diff --git a/research/r437-preparation-composition/predecessor4025/source/directory.py b/research/r437-preparation-composition/predecessor4025/source/directory.py new file mode 100644 index 0000000000..c74cacf5ce --- /dev/null +++ b/research/r437-preparation-composition/predecessor4025/source/directory.py @@ -0,0 +1,126 @@ +"""Produce all high fields while preserving physical old-prefix multiplicity.""" +from cardinality import radix_power +from counts import Count, high_count, high_power +from records import RECORD_END, Tape, append_finite, append_word, read_finite, read_word +from stream import Counter +from words import BLANK, RIGHT, ZERO, need + + +class Context: + def __init__(self, ring, vocabulary): + self.ring, self.arena, self.raw = ring, ring.arena, ring.raw + self.codes = vocabulary + self.q, self.dimension = vocabulary.q, vocabulary.dimension + for _ in radix_power(ring, self.q): + pass + divisor = self.arena.literal(self.q) + self.cap, remainder = self.raw.divmod(ring.modulus, divisor) + need(remainder.zero() and not self.cap.zero(), "positive high-field radix") + self.arena.free_many(divisor, remainder) + self.highs = high_count(ring, self.q, self.dimension) + + def close(self): + self.arena.free(self.cap) + self.highs.close() + + +class Odometer: + def __init__(self, context): + self.context = context + self.digits = [[context.arena.zero() for _ in range(context.dimension)] + for _ in range(context.dimension)] + self.finished = False + + def advance(self): + need(not self.finished, "live high odometer") + context = self.context + for row in reversed(self.digits): + for digit in reversed(row): + context.raw.increment_in_place(digit) + if context.raw.compare(digit, context.cap) < 0: + return + need(context.raw.compare(digit, context.cap) == 0, "high digit carry") + while digit.read() != RIGHT: + digit.write(ZERO) + digit.step(1) + digit.rewind() + self.finished = True + + def close(self): + for row in self.digits: + self.context.arena.free_many(*row) + + +def append_tape(source, destination): + source.rewind() + while source.read() != BLANK: + destination.append(source.read()) + source.step(1) + source.rewind() + + +def old_prefix(source, field_count, context): + """Retain one serialized prefix; decode at most one old numerical word.""" + output, remaining = Tape(), Counter(field_count) + try: + while not remaining.finished: + code = read_finite(source, context.codes.bits) + need(code < context.codes.limit, "old compiled source code") + append_finite(output, code, context.codes.bits) + for _ in range(context.dimension*context.dimension): + word = read_word(source, context.arena) + try: + need(context.raw.compare(word, context.cap) < 0, "old high digit range") + append_word(output, word) + finally: + context.arena.free(word) + need(source.read() == RECORD_END, "old field boundary") + source.step(1) + output.append(RECORD_END) + remaining.decrement() + output.rewind() + return output + except ValueError: + output.clear() + raise + finally: + remaining.close() + + +def produce(old, old_fields, old_count, code, context): + need(0 <= code < context.codes.limit, "new compiled source code") + expected, emitted = Count(old_count), Count.literal(0) + high_power(expected, context.ring, context.q, context.dimension) + outer, output = Counter(old_count), Tape() + old.rewind() + try: + need(not outer.finished, "nonempty old physical prefix domain") + while not outer.finished: + saved = old_prefix(old, old_fields, context) + high = Odometer(context) + try: + while not high.finished: + append_tape(saved, output) + append_finite(output, code, context.codes.bits) + for row in high.digits: + for digit in row: + append_word(output, digit) + output.append(RECORD_END) + emitted.increment() + high.advance() + finally: + saved.clear() + high.close() + outer.decrement() + need(old.read() == BLANK and emitted.equals(expected), "complete canonical raw directory") + old.rewind() + output.rewind() + return output, expected + except ValueError: + output.clear() + expected.close() + old.rewind() + raise + finally: + emitted.close() + outer.close() diff --git a/research/r437-preparation-composition/predecessor4025/source/records.py b/research/r437-preparation-composition/predecessor4025/source/records.py new file mode 100644 index 0000000000..4f00467a0f --- /dev/null +++ b/research/r437-preparation-composition/predecessor4025/source/records.py @@ -0,0 +1,271 @@ +"""Sequential binary program/field records and typed continuation stacks. + +Runtime numerical words copy between tapes. Only tags, source codes, ranks +and row labels enter fixed finite control. Fixture encoding is separate. +""" +from words import BLANK, LEFT, ONE, RIGHT, ZERO, Meter, Unsigned, need + +WORD_END, RECORD_END = 5, 6 +ROOT, STEP, VALUE, CONSTANT, MULTIPLY, PAIR, RETURN = range(7, 14) +FINITE_BITS = 16 # Fixed vocabulary width for this compiled source instance. + + +class Tape: + def __init__(self): + self.cells = bytearray([LEFT]) + self.head = 1 + self.meter = Meter() + + def read(self): + self.meter.reads += 1 + return self.cells[self.head] if self.head < len(self.cells) else BLANK + + def write(self, symbol): + need(ZERO <= symbol <= RETURN, "fixed record alphabet") + self.meter.writes += 1 + if self.head >= len(self.cells): + self.cells.extend([BLANK]*(self.head+1-len(self.cells))) + self.cells[self.head] = symbol + + def step(self, direction): + need(direction in (-1, 1), "unit record-head move") + self.head += direction + need(self.head >= 0, "local record boundary") + self.meter.moves += 1 + + def append(self, symbol): + need(self.read() == BLANK, "append at record blank") + self.write(symbol) + self.step(1) + + def rewind(self): + self.step(-1) + while self.read() != LEFT: + self.step(-1) + self.step(1) + + def clear(self): + self.rewind() + while self.read() != BLANK: + self.write(BLANK) + self.step(1) + self.rewind() + + +def append_word(tape, word): + word.rewind() + while word.read() != RIGHT: + tape.append(word.read()) + word.step(1) + tape.append(WORD_END) + word.rewind() + + +def read_word(tape, arena): + out = arena.zero() + while tape.read() != WORD_END: + bit = tape.read() + need(bit in (ZERO, ONE) and out.read() != RIGHT, "encoded word extent") + out.write(bit) + out.step(1) + tape.step(1) + need(out.read() == RIGHT, "complete encoded word") + tape.step(1) + out.rewind() + return out + + +def append_finite(tape, value, bits=FINITE_BITS): + """Compile-time finite source/operation tag encoding.""" + need(0 <= value < 1 << bits, "compiled finite vocabulary") + for bit in range(bits): + tape.append((value >> bit) & 1) + tape.append(WORD_END) + + +def read_finite(tape, bits=FINITE_BITS): + # The accumulator ranges over a fixed finite set, independent of e/w/h. + state = 0 + for bit in range(bits): + value = tape.read() + need(value in (ZERO, ONE), "finite label bit") + state |= value << bit + tape.step(1) + need(tape.read() == WORD_END, "finite label delimiter") + tape.step(1) + return state + + +def seek_record(tape, index): + machine, arena = Unsigned(index.arena), index.arena + remaining, one = arena.copy(index), arena.literal(1) + tape.rewind() + while not remaining.zero(): + while tape.read() != RECORD_END: + need(tape.read() != BLANK, "record exists at global slot") + tape.step(1) + tape.step(1) + after = machine.subtract_exact(remaining, one) + arena.free(remaining) + remaining = after + arena.free_many(remaining, one) + + +class Stack: + def __init__(self, index_arena, residue_arena): + self.index_arena, self.residue_arena = index_arena, residue_arena + self.tape, self.reverse = Tape(), Tape() + + def empty(self): + self.tape.step(-1) + result = self.tape.read() == LEFT + self.tape.step(1) + return result + + def push(self, tag, *words): + need(tag in (VALUE, CONSTANT, MULTIPLY, PAIR, RETURN), "continuation kind") + need(len(words) == (2 if tag == VALUE else 1), "continuation arity") + self.tape.append(tag) + for word in words: + append_word(self.tape, word) + self.tape.append(RECORD_END) + + def pop(self): + need(not self.empty(), "nonempty continuation stack") + tape, reverse = self.tape, self.reverse + tape.step(-1) + need(tape.read() == RECORD_END, "continuation top delimiter") + tape.write(BLANK) + tape.step(-1) + while tape.read() not in (LEFT, RECORD_END): + reverse.append(tape.read()) + tape.write(BLANK) + tape.step(-1) + tape.step(1) + reverse.step(-1) + tag = reverse.read() + need(tag in (VALUE, CONSTANT, MULTIPLY, PAIR, RETURN), "encoded continuation kind") + reverse.write(BLANK) + reverse.step(-1) + arenas = (self.index_arena, self.index_arena) if tag == VALUE else (self.residue_arena,) + words = [] + for arena in arenas: + out = arena.zero() + while reverse.read() != WORD_END: + bit = reverse.read() + need(bit in (ZERO, ONE) and out.read() != RIGHT, "continuation binary word") + out.write(bit) + out.step(1) + reverse.write(BLANK) + reverse.step(-1) + need(out.read() == RIGHT, "complete continuation operand") + reverse.write(BLANK) + reverse.step(-1) + out.rewind() + words.append(out) + need(reverse.read() == LEFT, "complete continuation record") + reverse.step(1) + return tag, tuple(words) + + +class Program: + """Encoded root and admitted chronological steps; numerical fields are words.""" + def __init__(self, index_arena, residue_arena, code_bits=FINITE_BITS): + self.index_arena, self.residue_arena = index_arena, residue_arena + self.code_bits = code_bits + self.tape = Tape() + + def root(self): + self.tape.rewind() + need(self.tape.read() == ROOT, "root record") + self.tape.step(1) + size = read_word(self.tape, self.index_arena) + unit = read_word(self.tape, self.residue_arena) + depth = read_word(self.tape, self.index_arena) + need(self.tape.read() == RECORD_END, "root record end") + self.tape.rewind() + return size, unit, depth + + def step(self, level): + need(not level.zero(), "positive step level") + seek_record(self.tape, level) + need(self.tape.read() == STEP, "step record") + self.tape.step(1) + metadata = tuple(read_finite(self.tape, self.code_bits if field == 1 else FINITE_BITS) + for field in range(6)) + parent = read_word(self.tape, self.index_arena) + child = read_word(self.tape, self.index_arena) + need(self.tape.read() == RECORD_END, "step record end") + self.tape.rewind() + return metadata, parent, child + + @classmethod + def fixture(cls, index_arena, residue_arena, root_size, root_unit, events, code_bits=FINITE_BITS): + """Fixture-only serialization; runtime computes and validates extents.""" + out = cls(index_arena, residue_arena, code_bits) + out.tape.append(ROOT) + for arena, value in ((index_arena, root_size), (residue_arena, root_unit), (index_arena, len(events))): + word = arena.input(value) + append_word(out.tape, word) + arena.free(word) + out.tape.append(RECORD_END) + size = root_size + for kind, code, rank, field, reverse, half in events: + f = size//64 + child = rank*f if kind == 0 else f//2 if half else f + out.tape.append(STEP) + for field_index, label in enumerate((kind, code, rank, field, int(reverse), int(half))): + append_finite(out.tape, label, code_bits if field_index == 1 else FINITE_BITS) + for value in (size, child): + word = index_arena.input(value) + append_word(out.tape, word) + index_arena.free(word) + out.tape.append(RECORD_END) + size = child + out.tape.rewind() + return out + + +class Fields: + def __init__(self, index_arena, residue_arena, code_bits=FINITE_BITS): + self.index_arena, self.residue_arena = index_arena, residue_arena + self.code_bits = code_bits + self.tape = Tape() + + def check_code(self, slot, code): + seek_record(self.tape, slot) + observed = read_finite(self.tape, self.code_bits) + self.tape.rewind() + need(observed == code, "original global raw-field code") + + def end(self, after): + seek_record(self.tape, after) + complete = self.tape.read() == BLANK + self.tape.rewind() + need(complete, "exact frozen/current field prefix") + + def read(self, slot, code, depth): + need(Unsigned(self.index_arena).compare(slot, depth) < 0, "frozen field excludes current/future slot") + seek_record(self.tape, slot) + observed = read_finite(self.tape, self.code_bits) + need(observed == code, "exact encoded raw-field specification") + out = [[read_word(self.tape, self.residue_arena) for _ in range(64)] for _ in range(64)] + need(self.tape.read() == RECORD_END, "complete 64-dimensional raw high field") + self.tape.rewind() + return out + + @classmethod + def fixture(cls, index_arena, residue_arena, fields, code_bits=FINITE_BITS): + """Load canonical raw-field fixture data before measured execution.""" + out = cls(index_arena, residue_arena, code_bits) + for code, high in fields: + append_finite(out.tape, code, code_bits) + need(len(high) == 64 and all(len(row) == 64 for row in high), "field fixture shape") + for row in high: + for value in row: + word = residue_arena.input(value) + append_word(out.tape, word) + residue_arena.free(word) + out.tape.append(RECORD_END) + out.tape.rewind() + return out diff --git a/research/r437-preparation-composition/predecessor4025/source/stream.py b/research/r437-preparation-composition/predecessor4025/source/stream.py new file mode 100644 index 0000000000..5e5a4bb0f9 --- /dev/null +++ b/research/r437-preparation-composition/predecessor4025/source/stream.py @@ -0,0 +1,163 @@ +"""Binary-counted complete-fibre ADD using an encoded coefficient callback. + +Each arbitrary spectator extent has its own canonical word length. None +enters the coefficient context. Payload bits remain opaque to the arithmetic. +""" +from records import Tape +from words import BLANK, LEFT, ONE, RIGHT, ZERO, need + + +class Counter: + """Canonical variable-length countdown with amortized ripple movement.""" + def __init__(self, word): + self.tape = Tape() + word.rewind() + while word.read() != RIGHT: + self.tape.append(word.read()) + word.step(1) + word.rewind() + self.tape.append(RIGHT) + self.tape.step(-1) + self.tape.step(-1) + while self.tape.read() == ZERO: + self.tape.write(RIGHT) + self.tape.step(1) + self.tape.write(BLANK) + self.tape.step(-1) + self.tape.step(-1) + self.finished = self.tape.read() == LEFT + if self.finished: + self.tape.step(1) + self.tape.write(ZERO) + self.tape.step(1) + self.tape.write(RIGHT) + self.tape.rewind() + + def decrement(self): + need(not self.finished, "positive countdown") + tape = self.tape + while tape.read() == ZERO: + tape.write(ONE) + tape.step(1) + need(tape.read() == ONE, "canonical positive counter") + tape.write(ZERO) + tape.step(1) + if tape.read() == RIGHT: + tape.write(BLANK) + tape.step(-1) + tape.step(-1) + if tape.read() == LEFT: + tape.step(1) + tape.write(ZERO) + tape.step(1) + tape.write(RIGHT) + self.finished = True + else: + tape.step(1) + tape.write(RIGHT) + tape.rewind() + + def close(self): + self.tape.clear() + + +def positive_extent(word): + """Reject padding inherited from a different, larger spectator extent.""" + word.msb() + margin = word.read() + word.step(-1) + significant = word.read() + word.rewind() + need(margin == ZERO and significant == ONE, "separately canonical positive spectator extent") + + +def one_bit_suffix(word): + """Recognize the fixed encodings of one, without decoding a cardinality.""" + word.rewind() + if word.read() != ONE: + return False + word.step(1) + if word.read() == ZERO: + word.step(1) + result = word.read() == RIGHT + word.rewind() + return result + + +def copy_blocks(source, target, count, suffix, observe): + blocks = Counter(count) + single = one_bit_suffix(suffix) + while not blocks.finished: + if single: + bit = source.read() + need(bit in (ZERO, ONE), "opaque payload bit") + target.append(bit) + source.step(1) + else: + bits = Counter(suffix) + while not bits.finished: + bit = source.read() + need(bit in (ZERO, ONE), "opaque payload bit") + target.append(bit) + source.step(1) + bits.decrement() + bits.close() + observe(bits) + blocks.decrement() + blocks.close() + observe(blocks) + + +def add_pass(source, ring, before, middle, suffix, prepare_coefficient, payload_factory=Tape): + for extent in (before, middle, suffix): + positive_extent(extent) + left, right, out = payload_factory(), payload_factory(), payload_factory() + totals = {"reads": 0, "writes": 0, "moves": 0} + def observe(counter): + # External meter only; no count controls execution. + for key in totals: + totals[key] += getattr(counter.tape.meter, key) + def traverse(merge): + coefficient = prepare_coefficient() + need(ring.raw.compare(coefficient, ring.modulus) < 0, "canonical encoded coefficient") + outer = Counter(before) + while not outer.finished: + x = ring.arena.zero() + sources = Counter(ring.modulus) + while not sources.finished: + offset = ring.multiply(coefficient, x) + leading = ring.raw.subtract_exact(ring.modulus, offset) + mid = Counter(middle) + while not mid.finished: + if merge: + copy_blocks(right, out, offset, suffix, observe) + copy_blocks(left, out, leading, suffix, observe) + else: + copy_blocks(source, left, leading, suffix, observe) + copy_blocks(source, right, offset, suffix, observe) + mid.decrement() + mid.close() + observe(mid) + ring.arena.free_many(offset, leading) + sources.decrement() + if not sources.finished: + ring.raw.increment_in_place(x) + sources.close() + observe(sources) + ring.arena.free(x) + outer.decrement() + outer.close() + observe(outer) + ring.arena.free(coefficient) + traverse(False) + need(source.read() == BLANK, "complete input extent") + source.rewind() + left.rewind() + right.rewind() + traverse(True) + need(left.read() == right.read() == BLANK, "complete split consumption") + left.clear() + right.clear() + out.rewind() + return out, {"counters": totals, "left": left.meter.record(), "right": right.meter.record(), + "output": out.meter.record()} diff --git a/research/r437-preparation-composition/predecessor4025/source/words.py b/research/r437-preparation-composition/predecessor4025/source/words.py new file mode 100644 index 0000000000..8d4ba37e27 --- /dev/null +++ b/research/r437-preparation-composition/predecessor4025/source/words.py @@ -0,0 +1,415 @@ +"""Binary word tapes; unbounded numerical values stay in tape cells. + +Only zero/one carry states and fixed register/operation tags enter Python +control. Fixture loading/inspection methods are outside measured execution. +The arena bounds the tape inventory by a compile-time register capacity. +""" +ZERO, ONE, LEFT, RIGHT, BLANK = range(5) + + +def need(test, message): + if not test: + raise ValueError(message) + + +class Meter: + __slots__ = ("reads", "writes", "moves", "peak_live", "allocations") + + def __init__(self): + self.reads = self.writes = self.moves = self.peak_live = self.allocations = 0 + + def record(self): + return {name: getattr(self, name) for name in self.__slots__} + + +class Word: + __slots__ = ("arena", "slot", "cells", "head") + + def __init__(self, arena, slot): + self.arena, self.slot = arena, slot + self.cells = bytearray([LEFT] + [BLANK]*(arena.bits+1)) + self.head = 1 + + def read(self): + self.arena.meter.reads += 1 + return self.cells[self.head] + + def write(self, symbol): + need(symbol in (ZERO, ONE, RIGHT, BLANK), "word tape alphabet") + self.arena.meter.writes += 1 + self.cells[self.head] = symbol + + def step(self, direction): + need(direction in (-1, 1), "unit word-head movement") + self.head += direction + need(0 <= self.head < len(self.cells), "local word boundary") + self.arena.meter.moves += 1 + + def rewind(self): + self.step(-1) + while self.read() != LEFT: + self.step(-1) + self.step(1) + + def msb(self): + self.rewind() + while self.read() != RIGHT: + self.step(1) + self.step(-1) + + def zero(self): + self.rewind() + nonzero = False + while True: + bit = self.read() + if bit == RIGHT: + break + need(bit in (ZERO, ONE), "complete binary word") + nonzero = nonzero or bit == ONE + self.step(1) + self.rewind() + return not nonzero + + def erase(self): + self.rewind() + while self.read() != RIGHT: + self.write(BLANK) + self.step(1) + self.write(BLANK) + self.rewind() + + def inspect(self): + """Checker-only decoding; arithmetic code must not call this.""" + need(self.head == 1 and self.cells[-1] == RIGHT, "inspect a restored word") + return sum(bit << i for i, bit in enumerate(self.cells[1:-1])) + + +class Arena: + def __init__(self, bits, capacity=65536): + need(bits >= 2 and capacity > 0, "fixed word context") + self.bits, self.capacity = bits, capacity + self.meter = Meter() + self.words, self.available, self.live = [], [], set() + self.template = Word(self, -1) + self.template.cells[1:-1] = bytes([ZERO])*bits + self.template.cells[-1] = RIGHT + + def zero(self): + if self.available: + slot = self.available.pop() + out = self.words[slot] + else: + slot = len(self.words) + need(slot < self.capacity, "fixed register inventory") + out = Word(self, slot) + self.words.append(out) + need(slot not in self.live, "fresh numerical register") + self.live.add(slot) + self.meter.allocations += 1 + self.meter.peak_live = max(self.meter.peak_live, len(self.live)) + source = self.template + source.rewind() + while source.read() != RIGHT: + need(out.read() == BLANK, "erased register before reuse") + out.write(ZERO) + out.step(1) + source.step(1) + need(out.read() == BLANK, "erased right delimiter cell") + out.write(RIGHT) + out.rewind() + source.rewind() + return out + + def literal(self, value): + """Compile-time literal only; never decode a runtime word here.""" + need(isinstance(value, int) and value >= 0, "unsigned literal") + out = self.zero() + for bit in tuple((value >> i) & 1 for i in range(value.bit_length())): + need(out.read() != RIGHT, "literal fits the fixed word") + out.write(bit) + out.step(1) + out.rewind() + return out + + def input(self, value): + """Fixture-only loading of an encoded input word.""" + return self.literal(value) + + def copy(self, source): + need(source.arena is self, "one word extent") + out = self.zero() + source.rewind() + while source.read() != RIGHT: + out.write(source.read()) + source.step(1) + out.step(1) + out.rewind() + source.rewind() + return out + + def free(self, word): + need(word.arena is self and word.slot in self.live, "owned numerical register") + word.erase() + self.live.remove(word.slot) + self.available.append(word.slot) + + def free_many(self, *words): + for word in words: + self.free(word) + + def rollback(self, protected): + """Erase owned temporary roles on a rejecting path; capacity is fixed.""" + for slot in tuple(self.live): + if slot not in protected: + self.free(self.words[slot]) + for slot in protected: + self.words[slot].rewind() + + +class Unsigned: + def __init__(self, arena): + self.arena = arena + + def compare(self, a, b): + need(a.arena is b.arena is self.arena, "comparison word context") + if a is b: + return 0 + a.rewind() + b.rewind() + state = 0 + while a.read() != RIGHT: + x, y = a.read(), b.read() + need(x in (ZERO, ONE) and y in (ZERO, ONE), "comparison binary digits") + if x != y: + state = 1 if x == ONE else -1 + a.step(1) + b.step(1) + need(b.read() == RIGHT, "equal comparison extents") + a.rewind() + b.rewind() + return state + + def add(self, a, b): + out = self.arena.zero() + a.rewind() + b.rewind() + carry = 0 + while a.read() != RIGHT: + x, y = a.read(), b.read() + total = x+y+carry # Four finite carry states, not word arithmetic. + out.write(total & 1) + carry = total >> 1 + a.step(1) + if b is not a: + b.step(1) + out.step(1) + need(b.read() == RIGHT, "equal addition extents") + a.rewind() + b.rewind() + out.rewind() + return out, carry + + def subtract(self, a, b): + out = self.arena.zero() + a.rewind() + b.rewind() + borrow = 0 + while a.read() != RIGHT: + x, y = a.read(), b.read() + digit = x-y-borrow # One finite borrow bit. + out.write(digit & 1) + borrow = int(digit < 0) + a.step(1) + if b is not a: + b.step(1) + out.step(1) + need(b.read() == RIGHT, "equal subtraction extents") + a.rewind() + b.rewind() + out.rewind() + return out, borrow + + def subtract_exact(self, a, b): + out, borrow = self.subtract(a, b) + need(not borrow, "unsigned subtraction precondition") + return out + + def shift_add_bit(self, a, bit): + need(bit in (ZERO, ONE), "one incoming bit") + out = self.arena.zero() + a.rewind() + carry = bit + while a.read() != RIGHT: + previous = a.read() + out.write(carry) + carry = previous + a.step(1) + out.step(1) + a.rewind() + out.rewind() + need(not carry, "reserved high-bit margin") + return out + + def divmod(self, numerator, denominator): + need(not denominator.zero(), "nonzero binary divisor") + # A zero high bit leaves room for 2*remainder+bit. + denominator.msb() + margin = denominator.read() + denominator.rewind() + need(margin == ZERO, "binary divisor has the high-bit margin") + scan = self.arena.copy(numerator) + quotient, remainder = self.arena.zero(), self.arena.zero() + scan.msb() + quotient.msb() + while scan.read() != LEFT: + shifted = self.shift_add_bit(remainder, scan.read()) + self.arena.free(remainder) + if self.compare(shifted, denominator) >= 0: + remainder = self.subtract_exact(shifted, denominator) + self.arena.free(shifted) + quotient.write(ONE) + else: + remainder = shifted + quotient.write(ZERO) + scan.step(-1) + quotient.step(-1) + scan.step(1) + quotient.step(1) + self.arena.free(scan) + return quotient, remainder + + def times_small(self, a, constant): + """Multiply by a fixed finite matrix/rank label; preserve the word margin.""" + need(0 <= constant <= 128, "finite index multiplier") + result = self.arena.zero() + for bit in tuple((constant >> i) & 1 for i in range(constant.bit_length()-1, -1, -1)): + doubled, carry = self.add(result, result) + need(not carry, "index multiplication margin") + self.arena.free(result) + if bit: + result, carry = self.add(doubled, a) + need(not carry, "index multiplication extent") + self.arena.free(doubled) + else: + result = doubled + return result + + def increment_in_place(self, word): + """Ripple increment for a bounded address counter; restore its head.""" + word.rewind() + while word.read() == ONE: + word.write(ZERO) + word.step(1) + need(word.read() == ZERO, "ripple increment has space") + word.write(ONE) + word.rewind() + + +class Ring: + """Canonical residues modulo an encoded M>1 with one leading zero bit.""" + def __init__(self, modulus): + self.modulus, self.arena = modulus, modulus.arena + self.raw = Unsigned(self.arena) + self.one = self.arena.literal(1) + try: + need(self.raw.compare(modulus, self.one) > 0, "modulus exceeds one") + modulus.msb() + margin = modulus.read() + modulus.step(-1) + significant = modulus.read() + modulus.rewind() + need(margin == ZERO and significant == ONE, "canonical modulus word with one high-bit margin") + except ValueError: + self.arena.free(self.one) + raise + + def close(self): + self.arena.free(self.one) + + def add(self, a, b): + total, carry = self.raw.add(a, b) + need(not carry, "canonical modular addition margin") + if self.raw.compare(total, self.modulus) >= 0: + out = self.raw.subtract_exact(total, self.modulus) + self.arena.free(total) + return out + return total + + def subtract(self, a, b): + if self.raw.compare(a, b) >= 0: + return self.raw.subtract_exact(a, b) + larger, carry = self.raw.add(a, self.modulus) + need(not carry, "canonical modular subtraction margin") + out = self.raw.subtract_exact(larger, b) + self.arena.free(larger) + return out + + def negate(self, a): + zero = self.arena.zero() + out = self.subtract(zero, a) + self.arena.free(zero) + return out + + def multiply(self, a, b): + if a.zero() or b.zero(): + return self.arena.zero() + if self.raw.compare(a, self.one) == 0: + return self.arena.copy(b) + if self.raw.compare(b, self.one) == 0: + return self.arena.copy(a) + scan = self.arena.copy(b) + result = self.arena.zero() + scan.msb() + while scan.read() != LEFT: + doubled = self.add(result, result) + self.arena.free(result) + if scan.read() == ONE: + result = self.add(doubled, a) + self.arena.free(doubled) + else: + result = doubled + scan.step(-1) + scan.step(1) + self.arena.free(scan) + return result + + def inverse(self, a): + """Euclid, with Bezout coefficients reduced modulo M; None for nonunits.""" + r0, r1 = self.arena.copy(self.modulus), self.arena.copy(a) + t0, t1 = self.arena.zero(), self.arena.copy(self.one) + while not r1.zero(): + quotient, r2 = self.raw.divmod(r0, r1) + if self.raw.compare(quotient, self.modulus) >= 0: + reduced = self.raw.subtract_exact(quotient, self.modulus) + self.arena.free(quotient) + quotient = reduced + product = self.multiply(quotient, t1) + t2 = self.subtract(t0, product) + self.arena.free_many(quotient, product, r0, t0) + r0, r1, t0, t1 = r1, r2, t1, t2 + unit = self.raw.compare(r0, self.one) == 0 + self.arena.free_many(r0, r1, t1) + if unit: + return t0 + self.arena.free(t0) + return None + + def literal(self, constant): + """Compile a fixed signed integer through binary modular operations.""" + negative = constant < 0 + magnitude = abs(constant) + result = self.arena.zero() + instructions = tuple((magnitude >> i) & 1 for i in range(magnitude.bit_length()-1, -1, -1)) + for bit in instructions: + doubled = self.add(result, result) + self.arena.free(result) + if bit: + result = self.add(doubled, self.one) + self.arena.free(doubled) + else: + result = doubled + if negative: + out = self.negate(result) + self.arena.free(result) + result = out + return result diff --git a/research/r437-preparation-composition/predecessor4025/verify.py b/research/r437-preparation-composition/predecessor4025/verify.py new file mode 100644 index 0000000000..614e57282c --- /dev/null +++ b/research/r437-preparation-composition/predecessor4025/verify.py @@ -0,0 +1,285 @@ +#!/usr/bin/env python3 +"""Meter the frozen directory producer, including all Count/Counter tape work. + +Apache-2.0. ToikY with substantial OpenAI Codex assistance. The six canonical +source files implement the object under review; no source bytes are changed. +Setup supplies an already valid Context. No full source/specification/stock +admission or physical finite-state tariff is inferred from this component. +""" +from __future__ import annotations +from contextlib import contextmanager +import hashlib +import itertools +import json +from pathlib import Path +import sys +import types + +HERE=Path(__file__).resolve().parent +PINS={ + 'CALLER.py':('7bc6e42072a09a08ac961e05c3da01cde012d740d4b4c605f298d994f2ad7c5a','5a032e8923f7f8b22bb98f3e39b804beb9906c16'), + 'NOTICE.md':('c446b32b8a621844fb2fbe654810c8122035bdd43fed2132f1137d98cb6f9943','ef9f81510db86eaf2f0a7191d85e92a6db30ddc0'), + 'cardinality.py':('505d5e560c5a507e6184edcc19a87cf1fed243eb34a5cb21fbe1e4fe017e7f22','b8ba857e32c5903408e1e61ff916300848b4a208'), + 'counts.py':('00b476dbda0e8cc99886bf794439e1cb9e775f435f599a3557e99321fe084069','81b48940ce222290a40d4fb349ce827f4788469d'), + 'directory.py':('4270e370b2bfe38ef73aadcd97d1b3496b56bd582115d74331eb9e5ceb90bec7','c74cacf5ce809c0561d374f137a52df0992b4226'), + 'records.py':('0c9c4b23e998597fb877bb1a29da69ac869b68262abe635b162b4dba9c69b372','4f00467a0ff580954ad2fd0c7380240c753ddef3'), + 'stream.py':('c7dc7da5b00f27016982ada4c0416f8328568b00df16d97012f33d4b372d79b5','5e5a4bb0f98971447043e25d4dd6991bfc070389'), + 'words.py':('5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9','8d4ba37e2778acb35b34e0719df2caf138fbeb50'), +} +CASES=( + {'name':'small_h0','d':1,'q':3,'w':2,'B':3,'h':0,'Q':4,'I':3}, + {'name':'small_h1','d':2,'q':3,'w':2,'B':2,'h':1,'Q':4,'I':3}, + {'name':'small_h2','d':2,'q':3,'w':2,'B':1,'h':2,'Q':5,'I':4}, + {'name':'binary_long_carry','d':1,'q':2,'w':4,'B':3,'h':0,'Q':3,'I':3}, + {'name':'binary_nine_digits','d':3,'q':2,'w':2,'B':1,'h':1,'Q':3,'I':3}, + {'name':'radix5_history2','d':1,'q':5,'w':2,'B':2,'h':2,'Q':4,'I':4}, + {'name':'dimension64_cap1','d':64,'q':3,'w':1,'B':1,'h':1,'Q':6507,'I':4}, +) + + +def need(condition,message): + if not condition:raise ValueError(message) + + +def canonical(value):return json.dumps(value,sort_keys=True,separators=(',',':')) + +def digest(raw):return hashlib.sha256(raw).hexdigest() + +def no_duplicate_keys(pairs): + result={} + for key,value in pairs: + need(key not in result,'duplicate receipt key: '+key) + result[key]=value + return result + +def load_receipt(path=None): + return json.loads((HERE/'RESULT.json' if path is None else Path(path)).read_text(),object_pairs_hook=no_duplicate_keys) + + +def authenticate(): + for name,(sha,blob) in PINS.items(): + path=HERE/'source'/name + need(not path.is_symlink(),'source symlink: '+name) + raw=path.read_bytes() + need(digest(raw)==sha,'source bytes: '+name) + need(hashlib.sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest()==blob, + 'source Git blob: '+name) + + +@contextmanager +def sources(): + authenticate() + names=('words','records','stream','cardinality','counts','directory') + saved={name:sys.modules.get(name) for name in names} + modules={} + try: + for name in names: + module=types.ModuleType(name);module.__file__=str(HERE/'source'/(name+'.py')) + sys.modules[name]=module + exec(compile((HERE/'source'/(name+'.py')).read_bytes(),module.__file__,'exec'),module.__dict__) + modules[name]=module + yield types.SimpleNamespace(**modules) + finally: + for name,value in saved.items(): + if value is None:sys.modules.pop(name,None) + else:sys.modules[name]=value + + +def actions(meter):return {key:getattr(meter,key) for key in ('reads','writes','moves')} + +def difference(after,before):return {key:after[key]-before[key] for key in after} + +def sum_actions(rows):return {key:sum(row[key] for row in rows) for key in ('reads','writes','moves')} + + +def field_bytes(code,digits,Q,L): + return bytes([(code>>i)&1 for i in range(Q)]+[5]+ + [bit for value in digits for bit in [(value>>i)&1 for i in range(L)]+[5]]+[6]) + + +def decode_count(value): + raw=bytes(value.tape.cells) + end=raw.index(3,1) + return sum(bit<<(i-1) for i,bit in enumerate(raw[1:end],1)) + + +def high_power_shared(value,ring,q,dimension,radix_power): + first=True + for _ in radix_power(ring,q): + if first: + first=False + else: + for _ in range(dimension*dimension): + value.multiply_small(q) + + +def run_case(config,candidate=False,alter_old=None,alter_code=None): + need(isinstance(config,dict),'case schema') + need(type(candidate) is bool,'candidate mode') + d,q,w,B,h,Q,I=(config[k] for k in ('d','q','w','B','h','Q','I')) + need(all(type(x) is int for x in (d,q,w,B,h,Q,I)) and + d>0 and q>=2 and w>=1 and B>=1 and h>=0 and Q>=2 and I>=max(2,h.bit_length()+1),'case domain') + M=d*d;modulus=q**w;c=q**(w-1);H=c**M;L=modulus.bit_length()+1 + need(H<=10000,'bounded fixture output enumeration; no full nontrivial GL64 lift') + F=Q+2+M*(L+1) + with sources() as S: + registry=[] + original_init=S.records.Tape.__init__;original_step=S.records.Tape.step + def tape_init(tape): + original_init(tape);tape.audit_max_head=1;registry.append(tape) + def tape_step(tape,direction): + original_step(tape,direction);tape.audit_max_head=max(tape.audit_max_head,tape.head) + S.records.Tape.__init__=tape_init;S.records.Tape.step=tape_step + arena=S.words.Arena(L,capacity=M+64);indices=S.words.Arena(I,capacity=16) + ring=S.words.Ring(arena.literal(modulus)) + vocabulary=types.SimpleNamespace(q=q,dimension=d,bits=Q,limit=1<=0 to b has axes 8+7a,...,7+7b. +This follows directly from the data levels: source levels are P_q at -1 and +I_8+E_a at a>=0; target levels are 0 at -1 and I_8-P_q+E_a at a>=0. +Here E_a is the first a exterior seven-blocks. The difference is the same +for both members. The source rho_s interchanges q-perpendicular directions +with exterior block s; its displayed block matrix gives these boundary +identities in both call orientations. + +For a descriptor (child, offset, 8), let S be the corresponding eight entries +in that ordered pending list. Define pi_S by mapping local axes 0,...,7 to +the ordered entries of S, then mapping the remaining axes to the unused +ambient axes in increasing order. Put sigma_S=A_q pi_S. This is an explicit +orthogonal matrix; it maps the full local residual projector to precisely S. + +For the common invocation d the helper owner is + + (F, g), g = d sigma_S^-1. + +For data use g=d rho_s,q and sigma=rho_s,q^-1. Consequently g sigma=d +for every role. The private temporary uses a separate reserved family and +class d. Within a call, different data roles have different families; hosted +families belong to inactive pairs; the private family is outside the live +data stock. Helpers sharing F have different actual pi_S, not merely different +text descriptors. The verifier checks the slot supports and their disjointness +even when one call uses several idle children of that same family. + +If two such helpers had the same physical class, canceling d and the common +A_q would give pi_S=pi_T. Applying them to a basis vector distinguishes them +over every K. Thus all 661 dirty roles and the private role have injective +physical owners at each fixed d. This does not assert disjointness across d. + +For stage 2, replica 0, pair 0, the helpers 232,...,236 in family 666 use child +4 and supports 1..8, 9..16, 17..24, 25..32, 33..40. The pending support is +1..42, leaving 41,42. The checker conjugates all five full local swaps by +their actual permutations and checks completion on all 128 address basis +columns. The five distinct streams can carry correlated values without aliasing. + +## 3. Whole-call simulation and the rank-seven issue + +Work at a fixed common invocation d. Pull each owned physical row back by +bar(d), obtaining a common-address row f_i. Give it a bookkeeping gauge +Gamma_i and decoded row c_i=f_i composed with Gamma_i. A gauge is a bijection, +not a data reset. At stage s use the partial swap on the frame projector plus +E_s; for a reflected call use I_8-P_frame plus E_s. + +MOVE from Gamma_a to Gamma_b changes the payload to +f_i composed with Gamma_a composed with Gamma_b^-1, so its decoded value is +unchanged. ADD between equal frames changes the decoded destination by the +decoded source. Fresh COPY uses the same transport into the private row, and +therefore copies its decoded value. If temporary and source decoded rows are +equal, bijectivity gives + + f_temp = f_source composed with Gamma_source composed with Gamma_temp^-1. + +This is precisely the physical ERASE guard. Zero decoded payload is equivalent +to zero physical payload, so no dirty private value is silently discarded. +Induction over the literal events proves simultaneous execution correctness. +Injective physical owners ensure each event leaves all other streams unchanged. +The equation g sigma=d means a chart-routed ADD is exactly a common native +address ADD, rather than an additional unpriced data-dependent routing rule. + +This is the generic simulation argument of PR540's FramedReplay and +OwnerTransport, instantiated here with PR589's word and owner construction. +The checker reconstructs every record directly from the pinned word and checks +equality with both template programs and their hashes. It propagates all 661 +input columns simultaneously, including dirty helper columns. MOVE labels, +common ADD frames, clean COPY destinations, centre immutability, every ERASE +guard, and the final private zero are checked in that same chronological run. +The final decoded map is x'=x, h'=h, y'=y+x, for both orientations in their +local role ordering. This identity of Boolean-linear maps also holds after +substituting arbitrary correlated input functions. + +PR540's concrete rank-eight COPY lemma cannot be reused unchanged. PR589 copies +sources 472,...,480 from frames 510,...,518 to frame 0. These frames have rank +seven. In the forward call, Gamma_510 Gamma_0^-1 = D_P510 on the local block; +the common E_s factor cancels. In the reflected call the relative map is +D_(I-P510) D_I = D_P510, again rank seven. The same calculation supplies +each matching ERASE transport. All nine frame pairs are checked exactly in +both orientations. The receipt includes distinguishing basis columns against +both a full rank-eight swap and a different rank-seven projector. + +For a helper, the difference between its entry and exit gauges is the full +local eight-dimensional swap in either orientation. Returning to the native +physical stream (F,g) turns this into D on g A_q S. Data output formulas use +only that call's input data, because no helper column remains in decoded data +outputs. They agree exactly with the unhosted call using the same data owners, +regardless of the distinct and evolving bank/helper contents in the comparison. + +## 4. Cover sweeps and chronological composition + +Apply the complete-call result before commuting anything. For a fixed helper +slot, d -> d sigma^-1 is a bijection of the full group G. Thus its cover sweep +applies its residual once to every class of its host family. Different d's +may revisit a stream through other slots. They use its **current** contents. +Since the complete-call result held for arbitrary dirty functions, this is +legal without a fresh-input or independence assumption. Active data families +are disjoint from hosted families throughout that sweep. Residuals on disjoint +axes commute within each fixed (family,g) stream. + +The checker independently walks the actual nine-stage schedule. Each local +stage enters its required level; every bridge has equal levels; idle children +have the actual source level; all pairs reach level eight before exchange. +For every host slot its stage lies after the last local/bridge touch of that +pair and strictly before its nominated idle child. Across those positions, +complete calls and bridges on other pairs have no endpoint dependence on this +family. Any intervening idle/host operations on this family use disjoint axes, +checked in the same fixed A_q chart. Consequently its residual can move to +its nominated child after complete calls have been reduced to their endpoints. + +For each (family,g,child), the moved residuals occupy disjoint subsets of the +pending projector, and the remainder is exactly the complement. The partial +swap product identity in section 1 therefore reconstructs the original idle +child. Repeat for every child. All data, inactive streams and the private zero +are retained throughout; no prior bank output or hosted output is reinitialized. +This proves the retained-data equality in the stated exact stream model. + +The count check yields the unchanged formal profile +{1:381024, 2:400416, 3:22752, 4:26880, 5:29376, 6:17376, 7:26784, 42:288}, +rank mass 1808352 and deficit 10272. These are recursive rank counts. They do +not establish a new routing invoice or justify changing the selected result. + +## Remaining obligations + +The Python certificates and this written induction have not been ported into +PR540's Lean source provider. Its proof of the older PR442 call is not a formal +proof of this newer call. A finite-group operator proof also does not implement +the all-size injective compiler, child algorithms, common grid, restored work, +tape, precision, row, exceptional-class or analytic transfer contracts. Full +native supplier replay and finite invoice admission are separate checks. + +Predecessors: DaysSky (PR442 hosting); Zhihao Chen, chafreaky and eumemic +(compressed geometry and retained supplier chain); DreamingOfClouds/eumemic +(PR545/555/589 punctured and tuned words); cheesegrader (PR540 formal framework); +commdata2338 (PR1307 ambient-axis census and PR1421 projector ledger); +1337isnot1337/CinnaDavis (PR1351/1371 physical-family operator checks). +Prepared with substantial OpenAI Codex assistance, Apache-2.0. diff --git a/research/r437-preparation-composition/vendor/research/pr589-five-helper-hosting/verify.py b/research/r437-preparation-composition/vendor/research/pr589-five-helper-hosting/verify.py new file mode 100644 index 0000000000..dbc71f56bb --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/pr589-five-helper-hosting/verify.py @@ -0,0 +1,414 @@ +#!/usr/bin/env python3 +"""Exact certificates for PROOF.md; not a Lean or all-size multiplication proof. + +Standard library only. No producer or predecessor verifier is imported. +Prepared with substantial OpenAI Codex assistance; Apache-2.0. +""" +import argparse +import copy +import gzip +import hashlib +import json +import struct +from collections import Counter, defaultdict +from fractions import Fraction as Q +from functools import lru_cache +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +WORD = 'research/e8-bit-p111-tuned/tune/bitE8mut-p111-tuned.json.gz' +HOST = 'research/community-hyperplane599-audit/pr589/bit589/v9/hosted/GLOBAL-TEMPLATE.json.gz' +GEO = 'research/community-hyperplane599-audit/pr589/bit589/v9/nine/GEOMETRY.json' + + +class Reject(Exception): + pass + + +def need(condition, message): + if not condition: + raise Reject(message) + + +def read(path): + raw = (ROOT / path).read_bytes() + return json.loads(gzip.decompress(raw) if str(path).endswith('.gz') else raw) + + +def ident(n): + return tuple(tuple(Q(i == j) for j in range(n)) for i in range(n)) + + +def trans(a): + return tuple(zip(*a)) + + +def mul(a, b): + bt = trans(b) + return tuple(tuple(sum((x*y for x,y in zip(row,col) if x and y), Q(0)) + for col in bt) for row in a) + + +def sub(a, b): + return tuple(tuple(x-y for x,y in zip(r,s)) for r,s in zip(a,b)) + + +def projection(rows, n=8): + """Rational Gram-Schmidt, followed by the sum of line projectors.""" + basis = [] + for row in rows: + u = tuple(map(Q, row)) + for b, norm in basis: + c = sum(x*y for x,y in zip(u,b)) / norm + u = tuple(x-c*y for x,y in zip(u,b)) + norm = sum(x*x for x in u) + if norm: + basis.append((u,norm)) + p = tuple(tuple(sum((b[i]*b[j]/norm for b,norm in basis), Q(0)) + for j in range(n)) for i in range(n)) + need(mul(p,p) == p and trans(p) == p, 'non-orthogonal frame projector') + return p, len(basis) + + +def dyadic(a): + return all(x.denominator & (x.denominator-1) == 0 for row in a for x in row) + + +def swap(p): + """D_P(x,y) = ((I-P)x+Py, Px+(I-P)y).""" + c = sub(ident(len(p)), p) + return tuple(c[i]+p[i] for i in range(len(p))) + tuple(p[i]+c[i] for i in range(len(p))) + + +@lru_cache(None) +def certify_transport(p, q, down): + low, high = (q,p) if down else (p,q) + need(mul(low,high)==low and mul(high,low)==low, 'non-nested transport') + residual = sub(high,low) + need(mul(swap(p),swap(q)) == swap(residual), 'wrong address transport') + need(mul(residual,residual)==residual, 'non-projector residual') + + +def literal_programs(w, dims): + """Reconstruct six-integer records from gates, then both orientations.""" + n = 2*w['v']+w['R']; cur = w['start'][:]; rec = [] + def move(r,f): + if cur[r] != f: + rec.append([0,r,cur[r],f,dims[f]-dims[cur[r]],0]); cur[r] = f + def gates(seq,phase): + for f,d,srcs in seq: + for r in [d]+srcs: + move(r,f) + rec.extend([1,d,s,1,f,phase] for s in srcs) + gates(w['D'],1); gates(w['A'],2) + for k,r in enumerate(w['ret']): + f = cur[r]; rec.append([2,r,n,f,0,dims[f]]) + for j,row in enumerate(w['scatter']): + if k in row: + rec.append([1,w['v']+j,n,1,0,3]) + rec.append([3,r,n,f,0,0]) + gates(w['B'],4); gates(w['C'],5) + for r in range(n): + move(r,w['final'][r]) + out = {} + for rev in (False,True): + events = [] + for op,x,y,c,f,z in (reversed(rec) if rev else rec): + if op == 0: + events.append([0,x,c if rev else y,y if rev else c,f,int(rev)]) + elif op == 1: + events.append([1,x,y,-c if rev else c,f,int(rev)]) + elif op == (3 if rev else 2): + events.append([2,x,y,c,f,abs(dims[c]-dims[f]),int(rev)]) + else: + events.append([3,x,y,c,f,z,int(rev)]) + out['reverse' if rev else 'forward'] = events + raw = b''.join(struct.pack('<6i',*r) for r in rec) + return out, hashlib.sha256(raw).hexdigest() + + +def local_replay(events, w, projectors, dims, rev=False): + n = 2*w['v']+w['R']; v = w['v'] + frames = (w['final'] if rev else w['start'])[:] + [-1] + values = [1 << r for r in range(n)] + [0] + centre = None; paid = Counter(); copies = [] + @lru_cache(None) + def transport(a,b,is_copy): + p,q = projectors[a],projectors[b] + if rev: + p,q = sub(ident(8),p),sub(ident(8),q) + # COPY can descend; MOVE must ascend. + down = ((dims[a] < dims[b]) if rev else (dims[a] > dims[b])) + certify_transport(p,q,is_copy and down) + return abs(dims[b]-dims[a]) + for pos,e in enumerate(events): + op,x = e[:2] + need(0 <= x < n, 'bad role') + if op == 0: + _,_,a,b,r,flag=e + need(flag==int(rev) and frames[x]==a, 'stale MOVE frame') + need(r==((dims[a]-dims[b]) if rev else (dims[b]-dims[a])) and r>=0, 'wrong MOVE rank') + need(transport(a,b,False)==r, 'MOVE transport rank') + frames[x]=b + if r: paid[r]+=1 + elif op == 1: + _,_,y,c,f,flag=e + need(0<=y<=n and x!=y and flag==int(rev), 'bad ADD') + need(frames[x]==frames[y]==f, 'ADD without common frame') + need(centre is not None or y!=n, 'read of closed temporary') + need(x!=centre, 'write to centre while copied') + if c & 1: values[x] ^= values[y] + elif op == 2: + _,_,y,a,b,r,flag=e + need(y==n and centre is None and values[n]==0 and frames[n]==-1, 'COPY into dirty temporary') + need(flag==int(rev) and frames[x]==a, 'stale COPY frame') + need(transport(a,b,True)==r==7, 'COPY must use actual rank seven') + values[n]=values[x]; frames[n]=b; centre=x; paid[r]+=1 + copies.append(dict(position=pos,source=x,old=a,new=b,rank=r)) + elif op == 3: + _,_,y,a,b,r,flag=e + need(flag==int(rev) and y==n and centre==x, 'unmatched ERASE') + need(frames[x]==a and frames[n]==b and values[n]==values[x], 'invalid ERASE guard') + need(r==(7 if rev else 0), 'wrong ERASE record') + need(transport(a,b,True)==7, 'ERASE transport') + values[n]=0; frames[n]=-1; centre=None + else: + raise Reject('unknown opcode') + expected=[(1<', 'exec'), module.__dict__) + value = module.Catalogue(3) + code = replacement(Path(topology.__file__).read_text(), '==661', '==659', 1) + topo = types.ModuleType('oq4_topology') + sys.modules[topo.__name__] = topo + exec(compile(code, '', 'exec'), topo.__dict__) + return value, topo.SelectedTopology(value) diff --git a/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/check_interface.py b/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/check_interface.py new file mode 100644 index 0000000000..d44bcf750f --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/check_interface.py @@ -0,0 +1,114 @@ +"""Source-level all-replica audit, no full-volume physical replay.""" +from collections import Counter, defaultdict +from functools import lru_cache +from hashlib import sha256 +import json +from pathlib import Path +import sys +import replica_catalogue as rc +import adapter +from check_transport import determinant,dyadic,dyadic_unit,reconstructed_chart,distinguishing_entry,canonical + +HERE=Path(__file__).resolve().parent +need=rc.need + +def run(): + cat,top=rc.load() + charts=set() + calls=[] + for stage in range(9): + for replica in range(32): + call=top.call(stage,replica); calls.append(call) + charts.update(owner.chart for owner in call.owners) + charts.update(request.chart for request in cat.requests.idles) + charts.update(request.chart for rows in cat.requests.prototypes for request in rows if request.kind=='COPY') + matrices={};dets=Counter();cdigest=sha256() + for chart in sorted(charts,key=lambda c:canonical(c.key)): + m=reconstructed_chart(chart,cat.geometry) + need(m==cat.chart_matrix(chart),'actual pooled chart agrees with independent reconstruction') + need(all(dyadic(x) for row in m for x in row),'dyadic entries') + det=determinant(m);need(dyadic_unit(det),'chart invertible at every odd prime') + matrices[chart]=m;dets[str(det)]+=1 + cdigest.update((canonical([chart.key,str(det)])+'\n').encode()) + @lru_cache(None) + def witness(a,b):return distinguishing_entry(matrices[a],matrices[b]) + pairs=0;wdigest=sha256();stage_pairs=Counter() + for call in calls: + groups=defaultdict(list) + for role,owner in enumerate(call.owners):groups[owner.family].append((role,owner.chart)) + for family,roles in sorted(groups.items()): + for index,(role,a) in enumerate(roles): + for other,b in roles[:index]: + entry=witness(a,b);pairs+=1;stage_pairs[call.stage]+=1 + wdigest.update((canonical([call.stage,call.replica,family,role,other,*entry])+'\n').encode()) + profile=Counter();kinds=Counter();digest=sha256();resolved=0 + for identifier,r in enumerate(cat.requests): + need(cat.requests.identifier(*r.key)==identifier,'full request key round trip') + if r.kind!='IDLE': + call=top.call(r.stage,r.replica) + need(call.requests[r.position]==identifier,'actual caller source identifier') + owner=call.owners[r.role] + need((r.family,r.chart)==(owner.family,owner.chart) if r.kind=='MOVE' + else r.family==28416 and r.source_chart==owner.chart,'typed owner/source chart') + else: + need(top.idle_family(identifier,r.replica)==r.family,'absolute idle family') + resolved+=1;profile[r.base.rank]+=1;kinds[r.kind]+=1 + digest.update((canonical(r.record())+'\n').encode()) + need(profile==cat.profile and resolved==903456,'complete physical profile') + idle_ids=[i for event in top.schedule if event['kind']=='idle' + for replica in range(32) for i in top.idle_identifiers(event['idx'],replica)] + need(len(idle_ids)==63936 and len(set(idle_ids))==63936,'exact once idle enumeration') + need(set(idle_ids)==set(range(cat.requests.starts[-1],len(cat.requests))),'full idle coverage') + controls=[] + def reject(name,action): + try:action() + except (ValueError,TypeError,KeyError,AttributeError):controls.append(name) + else:raise ValueError('accepted control '+name) + reject('replica omitted',lambda:cat.requests.identifier('MOVE',6,19236)) + reject('wrong idle replica',lambda:top.idle_family(idle_ids[0],(cat.requests[idle_ids[0]].replica+1)%32)) + reject('legacy idle consumer',lambda:top.idles) + reject('replica factorized profile',lambda:need(all(n%32==0 for n in profile.values()),'profile is not replica factorized')) + first=cat.requests.identifier('MOVE',6,1,19236) + zero=cat.requests.identifier('MOVE',6,0,19236) + a,b=cat.requests[first],cat.requests[zero] + need(a.role==b.role==643 and a.family==b.family==209 and a.chart!=b.chart,'actual first moved helper witness') + reject('same-family duplicate chart',lambda:distinguishing_entry(matrices[a.chart],matrices[a.chart])) + need(cat.codes.bits-cat.old_code_bits==5,'expanded source-code field is exactly five bits wider') + from catalogue import Specifications + from sources import identity + specs=Specifications(cat); low=tuple(tuple(map(int,row)) for row in identity(64)) + rank14=next(i for i in idle_ids if cat.requests[i].base.rank==14) + copy_id=next(i for i,r in enumerate(cat.requests.prototypes[0]) if r.kind=='COPY') + compiled=[] + for identifier,common in ((first,True),(first,False),(rank14,False),(copy_id,True)): + handle=rc.source_handle(cat,identifier,common,low) + spec=rc.resolve_handle(cat,specs,handle) + r=cat.requests[identifier] + need(spec.template.record[:2]==(rc.VERSION,r.replica),'compiled source retains replica identity') + need(spec.template.rank==r.base.rank,'actual source rank') + compiled.append({'request':identifier,'kind':r.kind,'replica':r.replica,'rank':r.base.rank, + 'common':common,'good':spec.good}) + reject('stale source codebook',lambda:rc.resolve_handle(cat,specs,rc.SourceHandle(rc.VERSION,adapter.REQUEST_DIGEST,handle.code))) + import copy + wrong_context=copy.copy(cat);wrong_context.q=5 + reject('different prime source codebook',lambda:rc.resolve_handle(cat,specs,rc.SourceHandle(rc.VERSION,rc.codebook_identity(wrong_context),handle.code))) + reject('mismatched Specifications context',lambda:rc.resolve_handle(cat,Specifications(wrong_context),handle)) + reject('untagged integer source',lambda:rc.resolve_handle(cat,specs,handle.code)) + reject('native COPY request',lambda:specs.bind(copy_id,False,low)) + return dict(status='PASS_POOLED_REPLICA_NATIVE_REQUEST_INTERFACE',request_count=resolved, + request_kinds=dict(sorted(kinds.items())),profile=dict(sorted(profile.items())), + rank_mass=sum(r*n for r,n in profile.items()),request_sha256=digest.hexdigest(), + chart_count=len(charts),determinants=dict(sorted(dets.items())),chart_sha256=cdigest.hexdigest(), + same_family_pairs=pairs,per_stage_pairs=dict(sorted(stage_pairs.items())), + witness_sha256=wdigest.hexdigest(),unique_chart_pair_witnesses=witness.cache_info().currsize, + old_q3_code_bits=cat.old_code_bits,new_q3_code_bits=cat.codes.bits,code_bits_delta=5, + first_moved_request=first,replica_zero_request=zero, + controls=controls,compiled_actual_sources=compiled,source_identity=cat.source_identity,ERASE_guards=len(cat.erase_guards),local_owner_gathers_per_low=189792,idle_owner_gathers_per_low=63936, + routes_per_low=379584,family_scans_per_low=507456, + full_physical_caller_executed=False,supplier_admitted=False) + +if __name__=='__main__': + value=run() + if '--write' in sys.argv:(HERE/'RESULT.json').write_text(json.dumps(value,sort_keys=True,indent=2)+'\n') + else:need(json.loads((HERE/'RESULT.json').read_bytes())==json.loads(json.dumps(value)),'exact frozen interface receipt') + print(json.dumps(value,sort_keys=True)) diff --git a/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/check_transport.py b/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/check_transport.py new file mode 100644 index 0000000000..5bd3c8a38a --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/check_transport.py @@ -0,0 +1,208 @@ +"""Independent dyadic chart and packet separation certificates for R437/OQ4. + +Chris R / Clear1nsight with substantial OpenAI Codex assistance. Apache-2.0. +The source catalogue is reused; exact determinant and separation checks are new. +""" +from collections import Counter, defaultdict +from fractions import Fraction as F +from hashlib import sha256 +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent + +def need(ok, message): + if not ok: + raise ValueError(message) + +def power_two(n): + return n > 0 and n & (n - 1) == 0 + +def dyadic(x): + return power_two(F(x).denominator) + +def dyadic_unit(x): + x = F(x) + return power_two(abs(x.numerator)) and power_two(x.denominator) + +def determinant(matrix): + """Exact elimination independent of predecessor chart/inverse routines.""" + a = [list(map(F, row)) for row in matrix] + n, result = len(a), F(1) + need(all(len(row) == n for row in a), 'square determinant') + for col in range(n): + pivot_row = next((i for i in range(col, n) if a[i][col]), None) + if pivot_row is None: + return F(0) + if pivot_row != col: + a[pivot_row], a[col] = a[col], a[pivot_row] + result = -result + pivot = a[col][col] + result *= pivot + for i in range(col + 1, n): + if not a[i][col]: + continue + factor = a[i][col] / pivot + for j in range(col + 1, n): + if a[col][j]: + a[i][j] -= factor * a[col][j] + a[i][col] = F(0) + return result + +def distinguishing_entry(a, b): + for i, (ra, rb) in enumerate(zip(a, b)): + for j, (x, y) in enumerate(zip(ra, rb)): + if dyadic_unit(x - y): + return i, j, str(x - y) + raise ValueError('no universally nonzero dyadic-unit chart witness') + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(',', ':')) + +def reconstructed_chart(chart, geometry): + """Sparse coordinate specification; no catalogue matrix/route functions.""" + entries = {(i, i): F(1) for i in range(64)} + if chart.kind == 'data' and chart.stage: + axes = tuple(range(8)) + tuple(range(8 + 7*(chart.stage-1), 8 + 7*chart.stage)) + rho = geometry['ports'][chart.port]['rho15'] + for i, a in enumerate(axes): + for j, b in enumerate(axes): + entries[a,b] = F(rho[i][j]) + elif chart.kind == 'family' or chart.kind == 'host' and chart.port >= 0: + port = geometry['ports'][chart.port] + for i in range(8): + entries[i,0] = F(port['q'][i], 2) + for j in range(1,8): + entries[i,j] = F(port['complement_columns'][i][j-1]) + else: + need(chart.kind in ('identity','host','data'), 'known chart label') + if chart.kind == 'host': + support, native = set(chart.axes), set(range(8)) + need(len(support) == 8, 'eight owner axes') + exchanges = dict() + for a,b in zip(sorted(native-support), sorted(support-native)): + exchanges[a], exchanges[b] = b,a + entries = {(i, exchanges.get(j,j)): x for (i,j),x in entries.items()} + return tuple(tuple(entries.get((i,j),F(0)) for j in range(64)) for i in range(64)) + +def source_certificate(): + import adapter + catalogue, topology = adapter.load() + charts = sorted(catalogue.charts, key=lambda x: canonical(x.key)) + chart_ids = {chart: i for i, chart in enumerate(charts)} + matrices, determinants, chart_rows = {}, Counter(), [] + for chart in charts: + matrix = reconstructed_chart(chart, catalogue.geometry) + need(matrix == catalogue.chart_matrix(chart), 'independent exact chart reconstruction') + need(all(dyadic(x) for row in matrix for x in row), 'dyadic chart entries') + det = determinant(matrix) + need(dyadic_unit(det), 'unit determinant at every odd modulus') + matrices[chart] = matrix + determinants[str(det)] += 1 + chart_rows.append([chart.key, str(det)]) + witnesses, difference_counts, stage_counts = [], Counter(), [] + for stage in range(9): + call = topology.call(stage,0) + groups = defaultdict(list) + for role,owner in enumerate(call.owners): + groups[owner.family].append((role,owner.chart)) + before = len(witnesses) + for family, roles in sorted(groups.items()): + for a, (role_a, chart_a) in enumerate(roles): + for role_b,chart_b in roles[:a]: + entry = distinguishing_entry(matrices[chart_a],matrices[chart_b]) + difference_counts[entry[2]] += 1 + witnesses.append([stage,family,role_a,role_b,chart_ids[chart_a],chart_ids[chart_b],*entry]) + stage_counts.append(len(witnesses)-before) + # Check the precise replica reduction, not only an aggregate histogram. + for replica in range(32): + other = topology.call(stage,replica) + need(len(other.owners)==len(call.owners)==659, 'current complete role inventory') + need(all(o.chart==b.chart and o.family==b.family+888*replica + for o,b in zip(other.owners,call.owners)), 'all actual replica owner labels') + # A source-specific carry control at actual native IDLE27776/chart98. + idle = catalogue.requests[27776] + need(idle.kind == 'IDLE' and idle.base.rank == 26 and idle.chart.port == 98, + 'actual rank26 native chart') + sigma = matrices[idle.chart] + carry_cases = [] + for q,w in ((3,2),(5,3),(7,4)): + modulus = q**w + reduced = tuple(tuple(x.numerator*pow(x.denominator,-1,modulus)%modulus + for x in row) for row in sigma) + low = tuple(tuple(x.numerator*pow(x.denominator,-1,q)%q + for x in row) for row in sigma) + # Raw native identity has zero high digits, but rational chart entries carry. + high = tuple(tuple((x-y)//q for x,y in zip(a,b)) for a,b in zip(reduced,low)) + need(all((x-y)%q == 0 and 0 <= h < q**(w-1) + for a,b,c in zip(reduced,low,high) for x,y,h in zip(a,b,c)), + 'complete canonical raw-to-high quotient') + nonzero = sum(x != 0 for row in high for x in row) + need(nonzero > 0, 'low-only chart retag loses actual native carry') + carry_cases.append({'q':q,'w':w,'nonzero_high_entries':nonzero, + 'raw_identity_high_zero':True}) + receipt = catalogue.receipt() + kinds = receipt['request_kinds'] + local_roles = 9*32*659 + idles = kinds['IDLE']*32 + counts = { + 'local_gathers_per_low_class':local_roles, + 'local_scatters_per_low_class':local_roles, + 'local_routes_per_low_class':2*local_roles, + 'idle_gathers_per_low_class':idles, + 'idle_scatters_per_low_class':idles, + 'all_family_scans_per_low_class':2*(local_roles+idles), + } + need(receipt['binding_sha256']==adapter.REQUEST_DIGEST,'current complete source binding') + need(len(charts)==1235 and len(witnesses)==5619,'frozen chart and pair inventory') + return { + 'status':'PASS_CURRENT_R437_UNIFORM_OWNER_SEPARATION', + 'request_binding_sha256':receipt['binding_sha256'], + 'chart_labels':len(charts),'determinants':dict(sorted(determinants.items())), + 'chart_certificate_sha256':sha256(canonical(chart_rows).encode()).hexdigest(), + 'canonical_same_family_pairs':len(witnesses),'replicated_same_family_pairs':32*len(witnesses), + 'per_stage_pairs':stage_counts,'witness_differences':dict(sorted(difference_counts.items())), + 'witness_sha256':sha256(canonical(witnesses).encode()).hexdigest(), + 'request_kinds':kinds,'complete_transport_counts':counts, + 'actual_native_carry_controls':carry_cases, + 'quantifier':'Every odd prime q, every w>=1, every invertible common low, every high lift; algebraic owner/route interface only.', + 'full_GL64_physical_execution':False,'supplier_admission':False, + } + +def finite_controls(): + identity = ((F(1),F(0)),(F(0),F(1))) + swap = ((F(0),F(1)),(F(1),F(0))) + need(determinant(identity)==1 and determinant(swap)==-1,'determinant positive controls') + rejected = [] + for label, action in [ + ('same_family_duplicate_chart',lambda:distinguishing_entry(identity,identity)), + ('odd_prime_determinant',lambda:need(dyadic_unit(determinant(((3,0),(0,1)))),'odd determinant rejected')), + ('odd_denominator',lambda:need(dyadic(F(1,3)),'odd denominator rejected')), + ('difference_vanishes_mod_3',lambda:distinguishing_entry(identity,((F(4),F(0)),(F(0),F(1))))), + ]: + try: action() + except ValueError: rejected.append(label) + else: raise ValueError('control accepted: '+label) + # Disjoint writes into the latest family compose; stale snapshots lose writes. + original = [0,1,1,0,0,1] + def scatter(state, index, values): + result = state[:];result[2*index:2*index+2] = values;return result + latest = scatter(scatter(original,0,[1,1]),2,[0,0]) + stale = scatter(original,2,[0,0]) + need(latest == [1,1,1,0,0,0] and stale != latest,'stale scatter semantic control') + rejected.append('stale_scatter_snapshot') + return rejected + +def main(): + result = source_certificate() + result['controls'] = finite_controls() + target = HERE/'RESULT.json' + if '--write' in sys.argv: + target.write_text(json.dumps(result,indent=2,sort_keys=True)+'\n') + else: + need(json.loads(target.read_text())==result,'frozen exact transport receipt') + print(json.dumps(result,sort_keys=True)) + +if __name__ == '__main__': + main() diff --git a/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/inputs/EXPECTED.json b/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/inputs/EXPECTED.json new file mode 100644 index 0000000000..bc2585e140 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/inputs/EXPECTED.json @@ -0,0 +1,34 @@ +{ + "word_gzip_sha256": "e432182d5b62c8bbefeb871fce30317234d707e5e18d4295e65ac21f7fd8365e", + "word_content_sha256": "da77deaf11368d016622348227657b98404b6afbc7e4f3d6fe9a246baae0dcce", + "records_sha256": "caeb2eb0e417992788c32c1f5812ada60b46d1dfdba9f4ac376299b2dede13cb", + "template_content_sha256": "c425a64739981b3ae3ed6b36d1a2f42c2d35e93f007649e89d4c677d8e158fe5", + "program_sha256": "a777373994bd84681d6c2be75251ba6a04a1521580910f23afe09bb50db632b2", + "profile": { + "1": 380160, + "2": 400864, + "3": 22176, + "4": 26592, + "5": 29376, + "6": 17376, + "7": 26496, + "26": 32, + "42": 384 + }, + "live": 28416, + "physical": 28425, + "rank_mass": 1808352, + "deficit": 10272, + "emitted_events": 7814016, + "hosted_residuals": 125856, + "BIT_c": "1736646042038446578551/1000000000000000000000000", + "BIT_c_decimal": "0.001736646042038446578551", + "next_grid": "217080755254805822319/125000000000000000000000", + "invoice": { + "prefix_bits": 177, + "charged_prefix": 192, + "two_level_bits": 393, + "charged_two_level": 512, + "ROW": 18355 + } +} diff --git a/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/inputs/catalogue.py b/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/inputs/catalogue.py new file mode 100644 index 0000000000..0efc0575a7 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/inputs/catalogue.py @@ -0,0 +1,268 @@ +"""Fixed selected request compilation, adapted from pinned PR2234 provider.py. + +Only q, rational labels and low classes enter these compilation routines. +Runtime precision, high matrices, widths and coefficients remain on tapes. +""" +from collections import Counter, defaultdict +from dataclasses import dataclass +from fractions import Fraction as F +from functools import cached_property, lru_cache +from hashlib import sha256 +import importlib.util +import json + +from binding import split_basis +from low_codes import LowCodes +import oracle +from plan import compile_plan +from sources import ROOT, Template, compile_specification, identity, product +from words import need + + +def canonical(value): + return json.dumps(value,sort_keys=True,separators=(",",":")) + + +@dataclass(frozen=True) +class Base: + kind: str + data: tuple + rank: int + + @cached_property + def key(self): + values=[[str(x) for x in row] for row in self.data] if self.kind=="local" else self.data + return sha256(canonical([self.kind,self.rank,values]).encode()).hexdigest() + + @lru_cache(None) + def matrix(self): + out=[[F(0)]*64 for _ in range(64)] + if self.kind=="local": + for i,row in enumerate(self.data):out[i][:8]=row + else: + need(self.kind=="idle" and len(set(self.data))==self.rank,"fixed idle base") + for i in self.data:out[i][i]=F(1) + return tuple(map(tuple,out)) + + @lru_cache(None) + def basis(self,q): + return split_basis(self.matrix(),self.rank,q) + + +@dataclass(frozen=True) +class Chart: + kind: str + port: int = -1 + stage: int = -1 + axes: tuple = () + + @property + def key(self):return (self.kind,self.port,self.stage,self.axes) + + +@dataclass(frozen=True) +class Request: + kind: str + stage: int + position: int + role: int + family: int + old_frame: int + new_frame: int + base: Base + chart: Chart + header_space: str + source_chart: object = None + + def record(self): + return [self.kind,self.stage,self.position,self.role,self.family, + self.old_frame,self.new_frame,self.base.key,self.base.rank, + self.chart.key,self.header_space,self.source_chart.key if self.source_chart else None] + + +class Catalogue: + dimension=64 + replicas=32 + families=28416 + private=661 + replica_stride=888 + + def __init__(self,q): + self.q=q + path=ROOT/"research/pr589-five-helper-hosting/verify.py" + spec=importlib.util.spec_from_file_location("retained_selected_node_source",path) + self.old=importlib.util.module_from_spec(spec);spec.loader.exec_module(self.old) + self.word,self.template,self.geometry=(self.old.read(p) for p in + (self.old.WORD,self.old.HOST,self.old.GEO)) + rows=[self.old.projection([self.word["lines"][i] for i in frame]) for frame in self.word["frames"]] + self.projectors=[p for p,_ in rows];self.dimensions=[r for _,r in rows] + self.idles={event["idx"]:event for event in self.template["schedule"] if event["kind"]=="idle"} + self.requests=[];self.bases={};self.charts=set();self.erase_guards=[] + self._bind() + self.codes=LowCodes(q,64,len(self.requests)) + self.identifiers={self.semantic_key(request):i for i,request in enumerate(self.requests)} + need(len(self.identifiers)==len(self.requests),"unique full catalogue request identifiers") + + @staticmethod + def semantic_key(request): + return (request.kind,request.stage,request.role if request.kind=="IDLE" else request.position) + + def base(self,a,b): + lo,hi=(a,b) if self.dimensions[a]<=self.dimensions[b] else (b,a) + value=Base("local",self.old.sub(self.projectors[hi],self.projectors[lo]), + self.dimensions[hi]-self.dimensions[lo]) + return self.bases.setdefault(value.key,value) + + def pending(self,child):return tuple(self.old.pending_axes(self.idles[child])) + + def owner_chart(self,call,role): + family,route=call["owners"][role] + if route[0]=="data":return Chart("data",route[2],route[1]) + need(route[0]=="hosted","selected owner route kind") + _,child,offset,width=route + axes=self.pending(child)[offset:offset+width] + need(len(axes)==8,"complete selected helper support") + return Chart("host",family%111 if min(axes)<8 else -1,axes=axes) + + @lru_cache(None) + def chart_matrix(self,chart): + out=identity(64) + if chart.kind=="identity":return tuple(map(tuple,out)) + if chart.kind=="data": + if chart.stage==0:return tuple(map(tuple,out)) + axes=list(range(8))+list(range(8+7*(chart.stage-1),8+7*chart.stage)) + rho=self.geometry["ports"][chart.port]["rho15"] + for i,a in enumerate(axes): + for j,b in enumerate(axes):out[a][b]=F(rho[i][j]) + return tuple(map(tuple,out)) + if chart.kind=="family" or (chart.kind=="host" and chart.port>=0): + port=self.geometry["ports"][chart.port] + for i in range(8):out[i][:8]=[F(port["q"][i],2)]+list(map(F,port["complement_columns"][i])) + if chart.kind=="host": + domain,support=set(range(8)),set(chart.axes);permutation=list(range(64)) + for a,b in zip(sorted(domain-support),sorted(support-domain)): + permutation[a],permutation[b]=b,a + need(set(permutation[:8])==support,"selected owner support completion") + out=[[row[permutation[j]] for j in range(64)] for row in out] + else:need(chart.kind=="family","known fixed chart") + return tuple(map(tuple,out)) + + def _append(self,request): + need(0', 'exec'), + {'t': template, 'need': need}) + + +def compile_owners(template, moves): + t = copy.deepcopy(template) + last, seen, windows = {}, [], {} + for position, event in enumerate(t['schedule']): + if event['kind'] == 'local_cover_sweep': + seen.append((position, event['stage'], event['pair'])) + last[event['pair']] = position + elif event['kind'] == 'bridge': + last[event['dst']] = last[event['src']] = position + elif event['kind'] == 'idle': + stages = [s for p, s, pair in seen + if last.get(event['pair'], -1) < p < position and pair != event['pair']] + if event['rank'] and stages: + windows[str(event['idx'])] = [event['pair'], event['rank'], sorted(stages)] + need(windows == t['hosting']['windows'], 'windows derived from literal chronology') + calls = {(c['stage'], c['replica']): c for c in t['calls']} + need(len(calls) == 288, 'complete stage-replica call domain') + changed = set() + for move in moves: + key = move['stage'], move['call_replica'], move['helper'] + need(key not in changed, 'duplicate moved logical owner') + changed.add(key) + call = calls[key[:2]] + old, new = move['old'], move['new'] + role = 222 + move['helper'] + need(call['owners'][role] == [old['family'], ['hosted', old['child'], old['offset'], 8]], + 'exact predecessor owner') + call['owners'][role] = [new['family'], ['hosted', new['child'], new['offset'], 8]] + occupancy = defaultdict(set) + count = 0 + for call in t['calls']: + for family, route in call['owners'][222:]: + need(route[0] == 'hosted', 'host-all domain') + _, child, offset, width = route + pair, capacity, stages = t['hosting']['windows'][str(child)] + need(call['stage'] in stages and pair != call['pair'], 'untouched destination window') + need(0 <= family < 28416 and (family % 888) // 222 == pair, + 'absolute destination family pair') + need(width == 8 and 0 <= offset and offset + width <= capacity, + 'whole residual within destination') + cells = set(range(offset, offset + width)) + need(not cells.intersection(occupancy[child, family]), 'disjoint absolute owner cells') + occupancy[child, family].update(cells) + count += 1 + need(count == 125856, 'each logical helper hosted exactly once') + profile = Counter() + for call in t['calls']: + for event in t['local_programs'][call['orientation']]: + if event[0] == 0 and event[4]: profile[event[4]] += 1 + elif event[0] == 2: profile[event[5]] += 1 + idle_records = [] + for event in t['schedule']: + if event['kind'] != 'idle' or not event['rank']: continue + child, pair, capacity = event['idx'], event['pair'], event['rank'] + for replica in range(32): + for cp in range(222): + family = replica * 888 + pair * 222 + cp + used = occupancy[child, family] + need(used == set(range(len(used))), 'compact occupied prefix') + rank = capacity - len(used) + if rank: + profile[rank] += 1 + idle_records.append([child, replica, cp, family, len(used), rank]) + need(sum(profile.values()) == 903456, 'all paid requests retained') + need(sum(r*n for r,n in profile.items()) == 1808352, 'rank mass retained') + return t, profile, idle_records + + +def retained_emit(template): + """Execute the unchanged final stream-emission block of pinned emit_k.py.""" + source = (HERE / 'inputs/emit_k.py').read_text() + start = source.index(' expanded=hashlib.sha256(); count=0; local=2*V+R\n') + end = source.index(" res['additional_interface']=", start) + code = '\n'.join(line[4:] for line in source[start:end].splitlines()) + scope = {'t': template, 'res': {}, 'hashlib': hashlib, 'json': json, + 'V': 111, 'R': 437, 'LIVE': 28416} + exec(compile(code, '', 'exec'), scope) + return scope['res'] + + +def independent_emit(template): + """Use the separately retained predecessor audit encoder without adaptation.""" + source = ast.parse((HERE / 'inputs/audit_hosted_k.py').read_text()) + function = next(n for n in source.body if isinstance(n, ast.FunctionDef) and n.name == 'digest') + scope = {'hashlib': hashlib, 'json': json, 'V': 111} + exec(compile(ast.fix_missing_locations(ast.Module(body=[function], type_ignores=[])), + '', 'exec'), scope) + return scope['digest'](template) + + +def changed_event_count(before, after): + count = 0 + for old, new in zip(before['calls'], after['calls']): + changed = {i for i,(a,b) in enumerate(zip(old['owners'],new['owners'])) if a != b} + for z in before['local_programs'][old['orientation']]: + count += z[1] in changed or (z[0] != 0 and z[2] in changed) + return count diff --git a/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/replica_catalogue.py b/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/replica_catalogue.py new file mode 100644 index 0000000000..1fa6ea58c5 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/replica_catalogue.py @@ -0,0 +1,208 @@ +"""Explicit replica-indexed request interface for the frozen pooled R437 source. + +Retains canonical Base/Chart/Template/LowCodes semantics. No physical execution +or supplier admission is implied. Apache-2.0; Chris R, OpenAI Codex assistance. +""" +from bisect import bisect_right +from collections import Counter +from collections.abc import Sequence +from dataclasses import dataclass, replace +from functools import lru_cache +from hashlib import sha256 +import json +from pathlib import Path +import sys + +import adapter +import pooled_compiler + +HERE = Path(__file__).resolve().parent +VERSION = 'pooled-replica-request-v1' +need = adapter.require + +@dataclass(frozen=True) +class ReplicaRequest: + replica: int + request: object + + def __getattr__(self, name): + return getattr(self.request, name) + + def record(self): + return [VERSION, self.replica] + self.request.record() + + @property + def key(self): + r = self.request + return (r.kind, r.stage, self.replica, r.role if r.kind == 'IDLE' else r.position) + +class Requests(Sequence): + """Full 903456-site vocabulary, constructed lazily without symmetry quotient.""" + def __init__(self, catalogue, prototypes, idle_records): + self.catalogue = catalogue + self.prototypes = [tuple(r for r in prototypes if r.kind != 'IDLE' and r.stage == s) + for s in range(9)] + self.positions = [{r.position: j for j, r in enumerate(rows)} for rows in self.prototypes] + self.starts = [0] + for rows in self.prototypes: + self.starts.append(self.starts[-1] + 32 * len(rows)) + self.idles = [] + self.idle_lookup = {} + module = sys.modules[type(catalogue).__module__] + for child, replica, cp, family, used, rank in idle_records: + event = catalogue.idles[child] + axes = catalogue.pending(child)[used:] + need(len(axes) == rank, 'literal pooled idle suffix') + base = module.Base('idle', axes, rank) + base = catalogue.bases.setdefault(base.key, base) + request = module.Request('IDLE', child, child, cp, family, + event['source_level'], event['target_level'], base, + module.Chart('family', cp % 111), 'owner') + wrapped = ReplicaRequest(replica, request) + self.idle_lookup[wrapped.key] = self.starts[-1] + len(self.idles) + self.idles.append(wrapped) + + def __len__(self): + return self.starts[-1] + len(self.idles) + + def __getitem__(self, index): + if not isinstance(index, int): + raise TypeError('request indices are explicit integers') + if index < 0: + index += len(self) + if not 0 <= index < len(self): + raise IndexError(index) + if index >= self.starts[-1]: + return self.idles[index - self.starts[-1]] + stage = bisect_right(self.starts, index) - 1 + replica, slot = divmod(index-self.starts[stage], len(self.prototypes[stage])) + old = self.prototypes[stage][slot] + call = self.catalogue.template['calls'][32*stage+replica] + chart = self.catalogue.owner_chart(call, old.role) + if old.kind == 'MOVE': + request = replace(old, family=call['owners'][old.role][0], chart=chart) + else: + request = replace(old, source_chart=chart) + return ReplicaRequest(replica, request) + + def identifier(self, kind, stage, replica, position): + need(0 <= replica < 32, 'physical caller replica') + if kind == 'IDLE': + return self.idle_lookup[kind, stage, replica, position] + slot = self.positions[stage][position] + need(self.prototypes[stage][slot].kind == kind, 'physical request kind') + return self.starts[stage] + replica*len(self.prototypes[stage]) + slot + +class ReplicaTopology: + """Changed interface: IDLE enumeration takes the replica explicitly. + + Deliberately exposes no legacy `idles` table. Existing compile_node requires + an explicit consumer adaptation; feeding it expanded IDLE IDs is unsafe. + """ + replicas, pairs, ports, families, stride = 32, 4, 111, 28416, 888 + + def __init__(self, catalogue, old_topology): + self.catalogue = catalogue + self.schedule = tuple(catalogue.template['schedule']) + self.old_topology = old_topology + self.idle_groups = {} + for index, request in enumerate(catalogue.requests.idles, catalogue.requests.starts[-1]): + self.idle_groups.setdefault((request.stage,request.replica), []).append(index) + + def idle_identifiers(self, child, replica): + need(0 <= replica < 32, 'physical idle replica') + return tuple(self.idle_groups.get((child,replica), ())) + + def idle_family(self, identifier, replica): + request = self.catalogue.requests[identifier] + need(request.kind == 'IDLE' and request.replica == replica, 'exact idle replica binding') + return request.family + + @lru_cache(None) + def call(self, stage, replica): + import topology + source = self.catalogue.template['calls'][32*stage+replica] + old = self.old_topology.call(stage,replica) + owners = tuple(topology.Owner(family, self.catalogue.owner_chart(source,role)) + for role,(family,route) in enumerate(source['owners'])) + identifiers = tuple(self.catalogue.requests.identifier('MOVE' if event[0] == 0 else 'COPY', + stage,replica,position) + if event[0] in (0,2) else None + for position,event in enumerate(old.events)) + need(len(owners) == 659, 'actual pooled role inventory') + return topology.Call(stage,replica,owners,old.start,old.end,old.events,identifiers,old.reverse) + + def matrix(self, chart): + return self.catalogue.chart_matrix(chart) + + def family(self, replica, pair, side, port): + return self.old_topology.family(replica,pair,side,port) + +def load(): + catalogue, old_topology = adapter.load() + proposal = json.loads((HERE/'inputs/moves.json').read_bytes()) + pooled, profile, idles = pooled_compiler.compile_owners(catalogue.template, proposal['moves']) + prototypes = catalogue.requests + old_bits = catalogue.codes.bits + # Preserve the literal unpooled topology as a recipe-only predecessor. + import copy + old_topology.catalogue = copy.copy(catalogue) + catalogue.template = pooled + catalogue.bases = dict(catalogue.bases) + catalogue.requests = Requests(catalogue, prototypes, idles) + catalogue.profile = profile + from low_codes import LowCodes + catalogue.codes = LowCodes(catalogue.q,64,len(catalogue.requests)) + # Reject the replica-blind public identifier entry point instead of retaining + # an accidentally usable old dictionary. Requests.identifier is the new API. + catalogue.identifiers = {} + catalogue.identifier = catalogue.requests.identifier + catalogue.semantic_key = lambda request: request.key + catalogue.erase_guards = tuple((stage,replica,*rest) for stage,*rest in catalogue.erase_guards for replica in range(32)) + catalogue.source_identity = codebook_identity(catalogue) + catalogue.old_code_bits = old_bits + catalogue.charts = {catalogue.owner_chart(call,role) for call in pooled['calls'] for role in range(659)} + catalogue.charts.update(r.chart for r in catalogue.requests.idles) + catalogue.charts.update(r.chart for r in prototypes if r.kind == 'COPY') + catalogue.receipt = lambda: receipt(catalogue) + return catalogue, ReplicaTopology(catalogue, old_topology) + + +@dataclass(frozen=True) +class SourceHandle: + schema: str + identity: str + code: int + + +def source_handle(catalogue, identifier, common, low): + return SourceHandle(VERSION, catalogue.source_identity, catalogue.codes.encode(identifier,common,low)) + + +def resolve_handle(catalogue, specifications, handle): + need(isinstance(handle,SourceHandle) and handle.schema == VERSION and + handle.identity == catalogue.source_identity, 'exact pooled source codebook identity') + need(getattr(specifications,'catalogue',None) is catalogue, 'exact Specifications codebook context') + return specifications[handle.code] + + +def receipt(catalogue): + from catalogue import canonical + digest = sha256() + kinds = Counter() + for request in catalogue.requests: + kinds[request.kind] += 1 + digest.update((canonical(request.record())+'\n').encode()) + return {'physical_requests': len(catalogue.requests), 'replicas': 32, + 'request_kinds': dict(kinds), 'rank_histogram': dict(catalogue.profile), + 'ERASE_guards': len(catalogue.erase_guards), 'binding_sha256': digest.hexdigest(), + 'source_identity': catalogue.source_identity, 'schema': VERSION} + + +def codebook_identity(catalogue): + import low_codes + fields = [VERSION, catalogue.q, catalogue.dimension, len(catalogue.requests), + catalogue.codes.bits, adapter.REQUEST_DIGEST, + sha256((HERE/'inputs/moves.json').read_bytes()).hexdigest(), + sha256(Path(low_codes.__file__).read_bytes()).hexdigest()] + return sha256(json.dumps(fields,separators=(',',':')).encode()).hexdigest() diff --git a/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/verify.py b/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/verify.py new file mode 100644 index 0000000000..4a470e1e99 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/r437-pooled-native-interface/verify.py @@ -0,0 +1,42 @@ +"""Read-only, source-authenticated replay; no foreign Git objects required.""" +from hashlib import sha1, sha256 +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +sys.path.insert(0,str(HERE)) +from check_transport import need +from check_interface import run + +def regular(path): + need(path.is_file(), 'regular source file: '+str(path)) + need(all(not part.is_symlink() for part in (path,*path.parents)), 'no source symlink') + +def authenticate(): + sources = json.loads((HERE/'SOURCES.json').read_text()) + need(sources['base_commit']=='20ecf2891d80b5acf18d980b2164fb44ea7faa90','canonical base') + for row in sources['files']: + if row['usage']!='input': + continue + path=ROOT/row['path']; regular(path); data=path.read_bytes() + need(sha256(data).hexdigest()==row['sha256'] and + sha1(b'blob '+str(len(data)).encode()+b'\0'+data).hexdigest()==row['git_blob'], + 'canonical source identity: '+row['path']) + expected=set() + for row in sources['retained']: + path=HERE/row['path']; regular(path);data=path.read_bytes();expected.add(row['path']) + need(len(data)==row['bytes'] and sha256(data).hexdigest()==row['sha256'] and + sha1(b'blob '+str(len(data)).encode()+b'\0'+data).hexdigest()==row['git_blob'], + 'retained source identity: '+row['path']) + observed={f.relative_to(HERE).as_posix() for f in (HERE/'inputs').rglob('*') if f.is_file()} + need(expected==observed|{'adapter.py','check_transport.py','pooled_compiler.py'},'complete retained source inventory') + need('--write' not in sys.argv,'registered verification is read-only') + +if __name__ == '__main__': + authenticate() + result=run() + need(json.loads((HERE/'RESULT.json').read_bytes())==json.loads(json.dumps(result)), 'exact frozen interface receipt') + print(json.dumps(result,sort_keys=True)) + print('PASS_POOLED_REPLICA_NATIVE_INTERFACE') diff --git a/research/r437-preparation-composition/vendor/research/recursive-parking-boundary/README.md b/research/r437-preparation-composition/vendor/research/recursive-parking-boundary/README.md new file mode 100644 index 0000000000..251f335eba --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/recursive-parking-boundary/README.md @@ -0,0 +1,281 @@ +# Recursive parking: a precise call-boundary contract + +**Scoped written proof and source-bound finite audit; no new kappa.** + +The retained tape package proves individual push/pop round trips and explicitly +leaves intervening children and scheduler composition open. This successor +supplies the finite controller for **one park/call/restore boundary**, including +active I/O movement and dispatch. For fixed `W >= 2`, role lengths `n_i`, total +logical volume `V = sum(n_i)`, and active role `a`, its exact wrapper charge is + +``` +5 V - n_a + 9 W - 2 transitions, excluding the child's execution. +``` + +For equal positive lengths `n_i = n`, the child receives exactly `n = V/W` +bits and the wrapper uses at most `14 V` transitions. This separates logical +volume from workspace and parked ancestor storage. It does not change a paid +supplier profile or discharge the complete fixed-tape multiplier. + +There is also an all-length counterexample to a weaker contract: preserving +all parked bytes **and the parking head at return** does not bound a child's +time uniformly in ancestor length. A fixed finite controller can scan the +entire ancestor and return unchanged. Restoration, trace locality, and a +uniform child-time bound are separate obligations. This is not a defect in the +upstream manuscript: it explicitly forbids ancestor scans. + +## Model and boundary hypotheses + +Use `W+3` bidirectional tapes: `W` roles, child I/O, parking, and one temporary. +The alphabet is exactly blank, separator, zero, one. One transition reads the +current symbols, writes at most one symbol per tape, and moves each head by +at most one cell. `W` and the active role are fixed when compiling the +controller; neither is an input-dependent tape allocation. + +A **marked stream** of length `n >= 0` has separator at position -1, its `n` +arbitrary bits at positions 0 through `n-1`, blank everywhere else, and head 0. +A **marked empty** tape has just that separator and head 0. It is not literally +all blank. The parking interface at top `h` has separator at `h-1`, arbitrary +finite contents strictly to its left, blank at and to the right of `h`, and +head `h`. No length or absolute position is readable by a transition. + +At wrapper entry, all roles are marked streams; I/O and temporary are marked +empty. Park all inactive roles in increasing index order, move the active +stream to I/O, call the child, move its result back, and pop the inactive roles +in decreasing index order. At child entry every role and the temporary are +marked empty, I/O contains exactly the original active stream, and the parking +top is + +``` +h_child = h + sum(i != a)(n_i + 1). +``` + +The **semantic child contract** is: starting at that interface, return the +specified length-preserving function `F` of the I/O bits, with I/O head 0 and +marker intact; return every reused role and temporary marked empty; restore +the entire parking tape and its exact head `h_child`. The specified `F` must +not depend on the parked ancestor. Other child tapes or a descriptor stack, +if supplied, need their own restoration and cost contracts. + +For the **whole nested trace** to avoid ancestors, additionally require that +the child visits no parking cell below `h_child-1` and writes no cell below +`h_child`. For a running-time conclusion additionally supply a child-time +bound uniform over the permitted ancestor contents and top position. +Locality alone does not imply a running-time bound: a child can also waste +arbitrary time without moving its parking head. + +## All-length proof + +The proof below is an induction on stream length and on the fixed phase list, +not an inference from the finite test range. [machine.py](machine.py) gives the +literal rules and [verify.py](verify.py) binds the inherited rules to source. + +### Three primitive facts + +1. **Push.** After `i` copy steps, the source head is `i`, its first `i` bits + are erased, and those bits occupy parking cells `[h,h+i)` in original order. + The next source bit advances both heads by one. At the first blank, write a + separator at `h+n`, advance parking to `h+n+1`, and start rewinding the erased + source. Its `n` blanks and left separator take `n+1` further transitions to + restore head 0. Total: `(n+1)+(n+1)=2n+2`. Parking never visits below `h`. + +2. **Pop.** From that parked record, two entry steps move onto and erase its + right separator. Transfer its `n` bits right-to-left into the temporary; + they appear there reversed. On reading the old separator at `h-1`, leave it + intact, return parking to `h`, and move temporary left. Reading temporary + right-to-left now writes the original bit order to the empty output, + erasing temporary as it goes. Its left separator returns its head to zero + and starts output rewind. Rewinding the output stops at its own separator + and returns head zero. The three loops each take `n+1` transitions, so the + total is `3n+5`. Parking stays in `[h-1,h+n+1]` and only writes `[h,h+n]`. + The original parking frame and marked-empty temporary are restored. + + These are the actual `TapeStackPush.instruction` and + `TapeStack.instruction` tables, not list append/reverse primitives. Their + existing Lean proofs retain credit. The bounds are also exact first-done + times on these interfaces: the copy and rewind phases cannot finish before + seeing their delimiters. Empty streams give two and five steps respectively. + +3. **Move.** On a source bit and destination blank, erase/copy and advance + both heads. At the first source/destination blank pair, move both left. + Rewind over source blanks and destination bits together; at the pair of + left separators, move both right and finish. This leaves the source marked + empty and destination equal to its old source, both heads at zero, in + `2n+2` steps. Both heads stay at or to the right of -1. The loop invariants + are the same copied/erased prefix invariant as push, with simultaneous + rewind. A malformed interface has a rejecting branch. + +The inherited Lean proofs establish the endpoint identities at the stated +iteration counts for facts 1 and 2, at every length. They do not separately +formalize first-done minimality or intermediate trace bounds. Those additional +claims use the phase and position arguments above. We have not rerun the +inherited Lean kernel. Fact 3 and the composition below are also written proofs +and executable controllers, not new Lean theorems. + +### Composition and cost + +Let `i_1,...,i_(W-1)` list the inactive roles. Induction on `j` shows that after +their first `j` pushes, precisely those roles are empty, their records are +stacked above the entry delimiter in that order, and all unpushed roles are +unchanged. Move preserves the active bits and empties the last role. Thus all +semantic child preconditions hold. Applying the child contract supplies its +output and exactly the interfaces needed by the reverse move and the pops. +Induction backwards through the parked records restores every inactive role +to its own original contents and head. The final active role holds `F(x_a)`; +I/O and temporary are empty and the parking frame is exactly its entry frame. +The bits of all roles were arbitrary throughout. + +For locality, each push starts at a top at least `h`, and the last pop stops +at the original delimiter `h-1`. Every intervening top is farther right. +Consequently the wrapper never visits below `h-1` or writes below `h`. +Applying the child's stronger locality contract gives the same conclusion +for the complete trace, and permits induction over any finite nesting depth. +No equality of role lengths is used in the restoration or locality proofs. + +`boundary_program(W,a)` is the explicit compile-time phase list. Its state is +a phase index and the current primitive state; tape selectors in each phase +are fixed constants. Each primitive's done state makes one stationary dispatch +transition to the next phase, and the child's done state makes one such return +transition. There are `2W+1` phases including the child. The inherited tables, +the move table, and these fixed dispatch edges therefore specialize to one +finite controller with no length tests, seek operations, or data-dependent +tape selectors. A child subroutine is composed through its entry/done states; +its own execution is accounted separately. + +Adding the costs gives + +``` +sum(i != a)(5 n_i + 7) + 2(2 n_a + 2) + (2 W + 1) + = 5 V - n_a + 9 W - 2. +``` + +For equal `n>=1`, this is `(5W-1)n+9W-2 <= (14W-3)n <= 14V`. +For `n=0` the exact cost is `9W-2`; a bound by `14V=0` is deliberately **not** +claimed. A fixed list of `s` child calls can join final dispatches directly +to the next boundary, giving at most `14sV` wrapper steps for positive equal +roles, plus the child costs and the separately priced parent operations. + +Marked interfaces are explicit preconditions. If a surrounding routine must +install and later remove all `W+2` work-tape markers, the inherited two-step +install/remove operations add `4(W+2)` steps, once per such lifecycle. The +existing parking delimiter belongs to the caller. The `14V` formula does not +silently include marker installation, descriptors, or row routing. + +### What this gives to a recurrence + +Assume separately that row splitting supplies equal complete role streams, +every child preserves length, the finite call plan has `s` children of width +`e/m`, and all remaining node work has a uniform `cV` bound. Then + +``` +T(V,e) <= s T(V/W,e/m) + (14s+c)V. +``` + +Dividing by logical `V` yields the `s/W` coefficient in the upstream normalized +recurrence. Temporary or parked storage is not substituted for `V`. An unequal +pair of role lengths `(1,2)` with active role zero instead sends one bit to its +child, whereas `V/W=3/2`: stack restoration alone cannot establish equal-volume +normalization. This corroborates, and does not replace, the manuscript's +complete-row hypothesis. + +## Endpoint-only counterexample and controls + +For `W=2`, two one-bit roles and active role zero, the wrapper costs 25 steps. +Give parking `L` contiguous ancestor bits below its original delimiter. Once +the inactive bit is parked, one fixed four-state child does this: step left, +scan left through nonblanks until a blank, scan right through nonblanks until +the blank at its entry top, and finish. It neither writes nor changes I/O. + +This child restores every bit, head, and work interface, yet takes exactly +`2L+9` transitions. Thus endpoint restoration alone cannot imply a uniform +bound depending only on the child's one-bit volume. The finite witnesses +`L=0,7,63` give 9,23,135 child steps and the same 25 wrapper steps. No selected +child is alleged to execute this scan. + +The thirteen receipt controls cover both source-table corruptions, parked-byte +and head mutations, role/temporary cleanup, I/O length/head changes, an +unchecked head drift that actually breaks restoration, wrong role pop order, +omitted dispatch cost, unequal-volume normalization, and the endpoint-preserving +ancestor scan. Contract guards and trace observations are **test instrumentation**, +not unpaid tape-machine validation routines. + +## Reproduction and finite coverage + +From the repository root, standard-library Python 3.12: + +```sh +python3 -B scripts/research_package.py --package research/recursive-parking-boundary --check-only +python3 -B scripts/research_package.py --package research/recursive-parking-boundary +``` + +Direct replay is `python3 -I -B research/recursive-parking-boundary/verify.py`. +Expected line: + +``` +PASS_RECURSIVE_PARKING_BOUNDARY: 396 source-table entries; 22308 equal-role boundaries; 4044 nested boundaries; 13 controls rejected +``` + +[RESULT.json](RESULT.json) is deterministic and compared in full. The receipt +records 12 push and 384 pop table rows checked against separate decision rules, +8,001 exhaustive primitive round trips (all payloads of lengths 0..6, all +ancestors of lengths 0..2 over four symbols, three translated stack origins), +22,308 equal-role boundaries, and 300 unequal-role cases. Equal-role domains +are all payloads and active roles for `(W,max n)=(2,5),(3,3),(4,2)`, with four +ancestor fixtures. Ninety nested fixtures exercise 4,044 inner boundaries on +the **same reused role, parking, I/O, and temporary tapes**, depths 0..4, +`W=2..4`, and ancestor lengths 0 or 257. + +Nested fixtures deliberately use abstract Python row split/merge shims outside +the measured boundary. They test the assumed recursive interfaces and do not +implement or price physical row routing. Six additional test groups cover +longer move payloads, extractor grammar rejection, a semantic table-corruption +witness, repeated changing active roles through `W=8`, identical local traces +under ancestor replacement/translation, and the unbounded scan counterexample. + +The extractor accepts only the literal syntax used by these two pinned tables; +it is not a Lean elaborator. Live input SHA256 pins are checked by direct replay; +the registered package checker also checks Git blobs and historical provenance. +Use `--write-result NEW_PATH` only for explicit regeneration; it refuses to +overwrite an existing file. Python timing and memory overhead are not machine +transition counts or integer-multiplication runtime measurements. + +## Limits and attribution + +The new result is the specified conditional boundary proof, explicit control +composition, independent table extraction/replay and boundary counterexample. +It is not a complete recursive scheduler, physical row/descriptor implementation, +selected call-plan binding, all-size supplier/compiler theorem, new Lean proof, +or a native/selected cold replay. Precision, tape layout of the mathematical +arrays, complete caller integration, analytic transfer, and independent human +review remain open. No selected certificate, frozen source, or supplier changes. + +The source package by [rfu08](https://github.com/rfu08), in the PR64 transfer +lineage, already supplies and proves the push/pop machines; it was introduced +on main at `2d970ab3ca0271cfb2b609dc9aae1b7073b7774d`. The upstream manuscript's +fixed-tape schedule and the ranked-pair transfer review already explain the +intended linear overhead. Those results retain their credit; this does not +claim a new stack algorithm. [PR861](https://github.com/CrocSwap/integer-mult-bounds/pull/861) +is nearby counter-cost work and explicitly excludes recursive scheduling; no +code or theorem from that pending PR is imported. + +Base: `bce54fb3f895cbe5cd4c0eb477c3afeed100190f`. Selected PR1094 +`0fc329d0bec93ca7cd288eaea1295172e8789810` is context only. There are no pending +PR dependencies. Exact Git-blob and SHA256 source pins are in +[SOURCES.json](SOURCES.json); assignment, scope, and coordination are recorded +in [TASK.json](TASK.json). New contributions use the repository's Apache-2.0 +license; all predecessor files and notices remain unchanged. + +Prepared for commdata2338 (@commdata2338), with substantial OpenAI Codex assistance. + +## Open next questions + +1. **Formal boundary composition and trace frame rule.** This would connect + the existing kernel-checked stack primitives to recursive handoffs. Start + by formalizing the marked-stream move and the quantified intermediate head + bounds, then induct over `boundary_program`. Blocker: the new composition + and trace statements have not been implemented or compiled in Lean. +2. **One physical complete-row split/merge caller.** The boundary only earns + `V/W` under equal complete rows. Start with a fixed `W=2` caller and explicit + row payload width, retaining every spectator and counting counter/reset + movement. Blocker: the current nested test uses abstract routing shims; + descriptor and dispatch-stack integration need their own uniform cost proof. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-local-ring-sweeps/PROOF.md b/research/r437-preparation-composition/vendor/research/selected-bit-local-ring-sweeps/PROOF.md new file mode 100644 index 0000000000..4330de85dd --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-local-ring-sweeps/PROOF.md @@ -0,0 +1,301 @@ +# Selected BIT calls on complete local-ring packets + +We prove an exact-stream integration statement for the selected PR589 word and +an explicit sufficient row layout. We assume completed address callees with +the spectator, restoration and work contracts below. We do not prove their +recursive implementation cost or admit a new exponent. + +## Domain and conclusion + +Fix an odd prime q, w >= 1, R = Z/q^w and m = 64. A payload is an arbitrary +Boolean function of two complete address blocks and complete spectators. +We compute payload XOR over F2; we use R only for addresses. At a given +recursive node, fix a diagonal unit matrix A whose entries depend on exposed +ancestor fields, but not on this node's family, cover coordinates or unused +descendant row field. We may fix each ancestor tuple separately in the proof. + +Use the pinned 288 call descriptors and both literal local programs, the +fixed data charts rho, and the helper completions in section 3. For each low +cover class, execute the whole local word on its complete high packet before +advancing to the next low class. Use fresh private work and the literal +transported-source ERASE guards. Assume that address callees act on the whole +specified packet, preserve its complete spectators, restore row coordinates +and close their work before returning. + +Under these hypotheses we obtain the selected local endpoints and chronological +hosting identity over GL64(R), on arbitrary correlated dirty payloads. After +the global bridges, idle remainders and terminal stream exchange, we obtain +the full weighted reversed interchange on each live family. We also give a +restricted-fibre XOR procedure and a compatible row divisor for these calls. +We retain their stated scan, route and workspace charges. + +We reuse alephnan's PR1627 literal replay and chronological proof. Eumemic +already gave a whole-owner GL local-ring argument in PR490. Our contribution +binds that domain to the selected literal word, distinguishes point owners +from complete-packet owners, supplies a selected live-row layout, and gives +physical restricted-fibre and wrong-geometry controls. We make no novelty +claim for generic conjugation or the common-label induction. + +## 1. Split projectors over R + +For a projector P on the head block and the fixed reversal C on the tail, +write + + D_C(P) = [[I-P, P C], [C P, I-C P C]]. + +We need P^2=P, without a symmetry requirement. Multiplication gives +D_C(P)^2=I. For nested projectors PQ=QP=P, multiplication gives +D_C(P) D_C(Q)=D_C(Q-P). For disjoint commuting projectors, it gives +D_C(P) D_C(Q)=D_C(P+Q). Conjugate by diag(A,I) to obtain the weighted maps. +For a variable g in GL64(R), conjugate P by g P g^-1. Use the inverse of g; +its transpose generally differs. + +PR1627 reconstructs the 636 rational frame projectors from the selected root +lines, and checks exact idempotence, nesting and dyadic final entries. These +identities hold in Z[1/2], so we specialize them to R. For a rank-r rational +idempotent, the characteristic polynomial equals T^(m-r)(T-1)^r in Z[1/2]. +After reduction modulo q, diagonalizability of an idempotent gives rank r. +We do not infer rank from the trace modulo q. + +Choose r independent columns of P and m-r independent columns of I-P modulo +q. Lift those same columns to R and concatenate them into T. The determinant +of T is a unit because its reduction is invertible. The equations +PT=T diag(I_r,0) then give P=T diag(I_r,0) T^-1. This proves split rank r +over R, including q dividing r. We apply the argument to frame projectors, +their nested differences and the ambient stage embeddings. + +For completeness, write P=B V with V B=I_r. Then + + D_C(P)-I = [-B; C B] [V, -V C]. + +The first factor has left inverse [-V,0], and the second has right inverse +[B;0]. Thus the address residual has split rank r. Unit conjugation preserves +this factorization and rank. + +We check 636 frames and 531 distinct residuals over Z/9, Z/25, Z/49 and +Z/27: 4,668 exact image/kernel bases, including 760 positive ranks divisible +by q. These finite checks audit the specialization argument; the argument +above covers arbitrary odd q and w. + +## 2. The selected local word and its rank-seven guards + +For the common invocation d, give each logical role the address label + + Gamma = Q_A Q_d D_C(P_frame + E_s) Q_d^-1 Q_A^-1, + Q_A = diag(A,I), Q_d = diag(d,C d C). + +For the reflected orientation replace the local P_frame by I_8-P_frame. +The exterior E_s occupies the first s seven-coordinate blocks. A MOVE from +label Gamma_a to Gamma_b uses Gamma_a Gamma_b^-1. An ADD between equal +labels performs XOR at the common address. COPY creates a private copy with +the relative transport. Equality of the decoded temporary and source implies + + f_temp = f_source composed with Gamma_source Gamma_temp^-1, + +which is the physical ERASE guard. Bijectivity equates zero decoded and zero +physical payload. Apply induction to the literal chronological events, using +the owner separation from section 3 to exclude indirect writes to a source. + +The imported PR1627 replay propagates all 661 initial Boolean columns through +both 27,234-event programs, checks centre immutability and the nine literal +COPY/ERASE episodes per orientation, and returns x'=x, y'=y+x, h'=h in local +role order. Arbitrary substitutions for those columns allow correlated +payloads. Each event acts separately at each high cover coordinate after +owner alignment, so the same induction applies to a complete high packet. + +The source copies frames 510 through 518 to frame 0. Their relative swap has +rank seven in both orientations; the common E_s cancels. We check weighted +transport for the actual frame pairs and twelve ambient 64-dimensional COPY +cases, including charts that mix local and exterior axes. We reuse PR1627's +literal guard checks rather than treating a rank number as an ERASE proof. + +## 3. Complete owner packets and chronological sweeps + +Let F_d0 = {d0 + q G : G in [q^(w-1)]^(64*64)} for a fixed invertible low +matrix d0. A matrix over R is invertible exactly when its reduction is. +For a fixed unit chart sigma, right multiplication is a bijection + + F_d0 sigma^-1 = F_(d0 sigma_bar^-1). + +The bijection includes the carries in the chosen low/high representation. +At one low invocation, two helpers in the same family therefore have +disjoint complete packets precisely when their owner low classes differ. + +For port p let A_p be the retained dyadic orthogonal family chart. For a +hosted support S of size eight, start from D={0,...,7}. Pair the sorted sets +D\S and S\D and exchange each pair of axes, obtaining pi_S. If S meets D, +set sigma_S=A_p pi_S; otherwise set sigma_S=pi_S. This is the support +completion used in PR2157. It has image A_p E_S on the local block, since +A_p is the identity on exterior axes. Its full basis order need not match +PR1627's completion: the full local endpoint depends on this image projector. + +Within a selected call, the supports of two helpers in the same family are +disjoint. Their images remain nonzero disjoint subspaces modulo each odd q, +because A_p is invertible there. Hence their chart reductions differ. Left +multiplication by d0 preserves that difference, proving complete-packet +separation. The 222 data families are distinct and outside the helper +families. The private family lies outside the live inventory. + +We check the prescribed images of 124 completion types and the supports of +181,056 same-family pairs across 288 calls. The selected word includes +11,072 same-family ADDs across these calls. For example, stage 0, replica 0, +event 19422 adds role 244 into role 243 in family 451, on supports 9..16 and +1..8. A whole-family XOR would act on more than the specified owned packet. + +Finish the whole word for a low class before the next class. Distinct low +invocations may reuse a physical packet through different roles. The local +endpoint theorem accepts its current arbitrary dirty value, so this reuse +does not require fresh or independent inputs. We reduce complete calls to +their endpoints before commuting any hosted residuals. + +For each fixed slot, d -> d sigma^-1 permutes the full GL64(R) cover. Thus +one full sweep places that slot's residual once on each physical class. +For a fixed family and physical g, the images g A_p E_S A_p^-1 g^-1 of +disjoint supports are commuting disjoint idempotents. PR1627 checks the +selected untouched intervals between a slot's host stage and its nominated +idle child. Its chronological argument therefore applies in these charts: +move the completed slot endpoints inside those intervals, then multiply +them with the exact remainder to recover each full idle child. + +We also replay the global eight-role Boolean schedule, including its eighteen +bridge shears and terminal pair exchange. It returns the identity on decoded +data. The terminal exchange moves frame labels with stream values. On an +original source family the entry projector is the port line P and the final +projector is I-P; on the other family the endpoints are 0 and I. Their +relative operators give the full F_A. We check the 111 weighted ambient +source endpoints and the 888 data-chart boundary cases over Z/9 and Z/25. +For f-atom blocks, tensor these identities with I_f and retain the specified +tail reversal convention. We do not charge a new full-tail pass for a +coordinate convention, or assert that an actual required pass would be free. + +## 4. Restricted-fibre XOR and its cost + +The stream model in `upstream/build/sections/02-streams.tex`, lines 24-26, +60-96 and 98-118, permits fixed selectors, split/merge passes and work +copies, with charges for scans, counters, rewinds and erasure. At fixed q +there are finitely many low classes. Use the following procedure for a +same-family ADD on two distinct owned low packets: + +1. Scan the family and copy the target and source packets to work streams. +2. Align both complete high fibres to d=g sigma and XOR them there. +3. Invert the target alignment. Scan the original family and replace only + its target packet, copying the other packets unchanged. +4. Erase the fresh work copies and reset their heads. + +Keep the original source intact. Its work copy needs no inverse route before +erasure. With packet volume V_f and whole-family volume V_F, charge + + C_select(q) V_F + T_target(V_f,w) + T_source(V_f,w) + + T_target_return(V_f,w) + C_XOR V_f. + +There are three route actions. An invocation over every low class multiplies +the finite q-dependent constant; it does not introduce a loop of scans over +the growing high-cardinality set. The fixed-route lowering in PR2157 can +implement each route under its completed ordinary-callee and preparation +contracts. Its cost must enter the selected numerical invoice before use in +an admitted bound. PR490 likewise retained a separate B_GL allowance. + +Our physical fixture executes this procedure on the full GL2(Z/9) family: +3,888 rows, three unused classes per row, seventeen payload bits per class. +It performs two full-family scans and two ordered high shifts on 198,288 +bits. The target and return charts are identity in this fixture; the source +chart is [[1,1],[0,1]]. It needs no ordinary callee. The independent oracle +uses full-ring matrix multiplication, and we compare the whole payload, +including the 47 unowned low-class packets. Omitting a carry changes the +payload. The meter counts payload reads, writes, head movement and erasure; +it does not measure Python controller arithmetic or certify all selected +64-dimensional routes. + +## 5. An explicit live-row layout compatible with the physical count + +The selected emitter counts W=28,416 live families and P=W+9=28,425 physical +slots. Its private COPY register starts at zero; the copied-centres lemma +uses a work stream with the same logical volume as its source. We must +allocate and charge that work separately. We cannot clear arbitrary input +rows merely by assigning them a private-slot label. + +Keep w fixed down the coarse recursion. Set N=|GL64(F_q)|, +H=q^(4096(w-1)), and + + M=lcm(W,P)=269241600, K=M N H, + D(n)=0 for n<64; D(n)=1+D(42 floor(n/64)) otherwise, + S(n,w)=K^D(n). + +At an internal node take a row count R_rows=t S(n,w). Decode its complete +range as + + [W] x [N] x [H] x [U], + U=R_rows/(W N H)=t * 9475 * K^(D(n)-1). + +All original rows carry live payload. Allocate the private and selector work +streams outside this coordinate split, with the complete packet shape of +their sources. A fixed family and low class has exact logical volume +V/(W N), since we retain all H high coordinates and all U unused rows. + +For a child of width r floor(n/64), 1<=r<=42, monotonicity of D gives +D_child<=D(n)-1. Fallback children of width at most floor(n/64) obey the +same inequality. Thus K^D_child divides U. For each fixed parent high +matrix, the child receives an identical complete fresh row range inside U; +parent high coordinates and inactive atoms become complete spectators. +After k active levels the unused count is t * 9475^k * K^(D(n)-k). +The compatibility factor remains complete unused stock. + +This induction requires routes to fix U and generated child descriptors +to read exposed ancestors rather than fresh child roles. It also requires +the child to restore its row field pointwise. At leaves we use the completed +ordinary contract, whose own workspace obligations remain separate. We +prove sufficient coarse row stock, not a full allocation of recursive work +tapes. The retained depth-first parking procedure in `04-swap.tex`, lines +222-242, is a starting point for that allocation and its scan bill. + +Since M/P=9472, S is also divisible by the P-based packet power. This is +an explicit alternative layout with an overreserve. We do not identify its +live rows with arbitrary P-slot input rows or claim that divisibility alone +discharges PR2084's physical interpretation premise. + +For the eligible prime domain q>2^80, M=S without divisibility, the outer wrapper may pad its row range to +ceil(R_rows/S) S<2 R_rows. It may remove that padding only after the completed +parent restores its full row coordinate. We have not supplied the outer +borrow, finite-cutoff or time admission here. + +The executable layout test enumerates a complete small model with W=2, +P=3, q=3 and GL1 high/low fields: 1,296 original rows, 324 rows in a selected +low packet, and unused count 108 containing the child divisor 36. We check +exact coverage and decoding, child independence from the parent high field, +and rejection of P as the live-volume denominator. This is a layout test, +not a small simulation of the full selected recursive algorithm. + +## 6. Controls and limits + +For the selected port-eight root r=(0,1,1,0,1,0,0,1), take g=I+3E_12 over +Z/9, with zero-based indices. The wrong transpose conjugate g P g^T agrees +with g P g^-1 modulo 3 but fails idempotence: entry (1,1) of its defect is 6. +The corresponding partial swap fails involution with defect 3 at (1,1). + +An orthogonal projection onto each transformed range does not repair this. +Let u=g r and v=g^-T r. The projectors uu^T/(u^T u) and I-vv^T/(v^T v) +have split ranks 1 and 7, agree with the correct pair modulo 3, and each +defines an involution. Their product still differs from the full swap: +head entries (1,4) and (4,1) have defects 6 and 3. We need the complementary +oblique projectors uv^T/4 and I-uv^T/4. + +For a separate weak-owner countermodel over GL2(Z/9), take sigma_0=I and +sigma_1=I+3E_01. The 81 owner pairs differ at each fixed d, but both image +packets are the same high fibre. The alias permutation has 27 three-cycles. +A simultaneous snapshot XOR has Boolean rank 54; the serial fixed-d XORs +have rank 81. On an all-one payload they leave zero and 27 ones respectively. +This refutes point-owner injection as a sufficient high-batching argument; +the selected low-separated completions pass the stronger condition. + +We leave completed weighted child implementations, their recursive scratch +allocation, bad-class integration, a selected finite routing invoice and +the outer analytic transfer as obligations. We prove neither an unconditional +integer-multiplication theorem nor a change to the selected kappa. We prepared +this written proof and executable certificate with substantial OpenAI Codex +assistance; no independent human or proof-assistant verification is claimed. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/PROOF.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/PROOF.md new file mode 100644 index 0000000000..548ecff3ef --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/PROOF.md @@ -0,0 +1,486 @@ +# A fixed-tape lowering of the selected BIT caller + +Jose Manuel (`jmbarrancoml`), with substantial OpenAI Codex assistance. + +I give a constructive source-level lowering of the p=1 caller in David Arias's +[PR2753](https://github.com/CrocSwap/integer-mult-bounds/pull/2753), at +`7dba5452a4071a856a0b11cebdcd2d3b6bcd7659`. I retain his endpoint, stock, +root-coupling and local-cost hypotheses. I replace depth-dependent logical tape +objects by permanent roles and a sequential parking stack. I use the numerical +codec from my [PR2769](https://github.com/CrocSwap/integer-mult-bounds/pull/2769), +at `d97f150d89e3f3eebdf625a468a445c9c0f1e6c9`, and ywz65's two-tape controller +from [PR2635](https://github.com/CrocSwap/integer-mult-bounds/pull/2635), at +`1662dda699d9ea57b3fb13a23873b087d765149f`. + +I implement the finite macroprogram and its dispatch loop, both checkpoint +codecs, the actual numerical Frame substitution and the residual return cursor. +I execute complete reduced-source programs through the fixed-role controller. +I do not materialize the selected GL64 word or supply one fully expanded +microtransition table. Readers must assess the source-level compilation argument +separately from the finite checks. Section 9 binds the implemented controller to +the construction below. + +## 1. Statement and retained hypotheses + +Fix the source-admissible prime q and the selected source vocabulary. Use the +complete input domain of PR2753, PROOF sections 1, 5 and 6: compatible fresh-row +stock, canonical programs and directories, minimal root word widths and the +specified root coupling. In particular the internal node has + +\[ +V=C R B G S A^{2n},\quad A=q^w,\quad R=WNHU,\quad W=28416, +\quad N=|GL_{64}(\mathbb F_q)|. +\] + +**Claim.** One can compile this caller to a multitape machine with a number of +tapes depending only on q and the pinned source. The machine computes the same +complete Boolean endpoint and preserves the same physical row/prefix ordinals. +It uses \(O_q(V_{\rm root})+F_q\) cells and preserves the baseline local toll +\(O_q(V(n+w))\). It uses no numerical-width, precision, tape-length or recursion- +depth value in finite control. Here \(F_q\) covers one-time source compilation. + +This claim concerns the p=1 baseline. I retain the stronger H2 route/leaf +contracts, the outer borrowing wrapper and the complex supplier as separate +obligations. I claim neither the historical sharp parking constant nor a new +multiplication exponent. I leave the selected result unchanged. + +The proof uses successful, well-bracketed execution on admitted inputs. A +caller may reject malformed input. The claim does not require transactional +recovery from interruption halfway through a parking-table command. + +## 2. Three kinds of state + +The source stores numerical values in fixed-width Word slots, arbitrary +cardinalities and sequential records on Tape objects, and source labels in +finite host objects. These require different encodings. + +* I keep two permanent Word banks of capacity \(2^{24}\), with the root residue + and index templates. I assign bank/slot labels to finite control. PR2753's + source inventory bounds simultaneous numerical use below \(2^{22}\); the + three fresh call grants fit the remaining capacity. +* I assign a fixed collection of canonical stream roles to the node input, + peeled input, W family packets, 661 ordinary local packets, the private + packet, the retained COPY input, residual input/current/output, programs, + directories and cardinalities. I add fixed capsule and return ports. None of + these roles changes its physical tape identity at a recursive call. +* I encode the program counter and finite source/slot labels in a fixed-width + control record. A finite source label may have an enormous q-dependent + alphabet; it still cannot contain n, w, h, a spectator value or a tape offset. + +For a convenient allocation, reserve W+1024 persistent stream roles. The named +roles above, three child extents, eight node cardinalities, context.highs, +driver row count, three borrowed root input tapes and eight handoff ports fit +this allowance with room to spare. +Inactive roles hold an empty body after their LEFT marker. I also reserve +\(q^2+128\) scratch roles as justified in section 5. The machine can therefore +use at most + +\[ +2\cdot2^{24}+W+q^2+1156 +\] + +tapes: the Word banks, two Word templates, persistent and scratch roles, and +the parking tape and its packet port. I count the protected output and handoff +ports among the W+1024 persistent roles; the reusable checkpoint set excludes +those ports. This is a conservative existence bound, not an optimized machine. + +I allocate the role inventory once. Clearing a role erases its body; clearing +does not release its identity. For borrowed Fields I construct a view of the +declared prefix role and omit the source's immediately overwritten empty Tape. +I retain a Stack's two roles until its Callback closes, even when a pop empties +them. These ownership rules avoid reliance on Python garbage collection. + +## 3. Compile the whole caller to a finite word of blocks + +All loops in `Driver.global_word` range over fixed source data: the global +schedule, replicas, ports, pairs, literal local events and GL64 low classes. +All source request labels and their good/fallback plans also range over fixed-q +sets. At compilation, unroll these loops in their source order. The resulting +word can be huge; its length contributes to \(F_q\), not to an input-dependent +oracle. Compile `LocalState.accept` and `finish` along each finite literal word, +preserving its version and private-COPY guards. + +Use the following block vocabulary. A label names fixed roles and source data; +encoded dimensions and cardinalities remain on their declared tapes. + +| Block | Action and successful return contract | +| --- | --- | +| NODE | Validate incoming weight; compute stock and extents; peel the remainder; split into canonical families. | +| GATHER_ROUTE | Gather the declared native low packet and route it to its fixed local role. Preserve the family. | +| RESIDUAL_BEGIN | Produce the current directory and prefix count, bind the fixed source plan, and initialize the residual current role from its source. | +| FORWARD/BACKWARD | Complete the plan's column adapter sweep in the source order, including reversed columns and commands on the backward sweep. | +| SWEEP | Complete one fallback ADD or linear-sign column sweep. | +| CHILD | Compute one good/main/half child boundary from encoded geometry; run the complete leaf or perform the call protocol in section 6. | +| RESIDUAL_END | Commit the complete residual result into its declared local/private/idle destination; clear residual work. | +| XOR/COPY/ERASE | Perform the corresponding literal operation on fixed roles, retaining the source's private-copy lifetime and guard. | +| ROUTE_SCATTER | Route a completed local role back and scatter into the latest contents of its family. | +| BRIDGE/EXCHANGE | Complete the two chronological bridge XORs, or exchange contents through one temporary role. | +| MERGE_RETURN | Merge the final families, place the owned result in the protected return port and clear the frame's roles. | + +NODE and MERGE_RETURN bracket the fixed global word. A local event emits the +source's residual blocks at the exact point where `Driver.local` calls them. +An idle event emits them between its gather and scatter. A COPY first copies +its source into the retained COPY role; after its residual returns, it places +the output in the private role and clears that retained copy. ERASE clears the +private role at the original guarded position. No low class or physical prefix +is deduplicated. + +For a good residual, emit FORWARD, CHILD(good), BACKWARD. For a fallback plan, +emit one SWEEP for each nonchild command. For each pair command emit the three +ordered CHILD candidates: half reset, main pair/unit, half reset. Each half +candidate checks the fixed same-bank condition and the encoded half width; +it does nothing when the source would omit that half. This preserves odd-column +central spectators and the source's f=1 case. + +`residual_blocks.Cursor` gives this part of the construction explicitly. Its +state consists of a finite command position and one of three stages. It advances +before the block, so its serialized state denotes the return continuation. +All variable column loops finish inside a FORWARD, BACKWARD or SWEEP block. +A below-cutoff leaf finishes inside CHILD. An internal CHILD has no suspended +column iteration. Thus a recursive cut needs only the next fixed instruction +label, the root/child flag and finite slot labels. The caller never retains a +Python generator or an input-dependent host iterator across that cut. + +The compiled node word applies to each generation. The child uses the same +word with new encoded size, program, directory and cardinalities. The fixed +CHILD label determines the pending destination and return action. Re-entering +at its successor cannot repeat a LocalState acceptance or a completed adapter. + +## 4. Canonical commits and semantic refinement + +When a completed primitive returns a new owned result, clear the old canonical +destination, transfer the result body into it and clear the result role. Preserve +the primitive's borrowed sources until it completes. `role_parking.transfer` +implements this destructive transfer with reads, writes and unit head moves. +Its work is \(O(L_{old}+L_{new})\); the source and destination return to LEFT. + +Use distinct canonical roles even when the logical caller returns its input +unchanged. Copying that input into the designated result role removes pointer- +identity cases from the recursive interface. Within an atomic macro, finite +role labels suffice for the source's bounded aliases. A completed exchange uses +three transfers through a fixed temporary role. A scatter replaces its family +before the next gather or scatter reads it. This last rule preserves the +latest-family chronology in the source, including earlier helper returns. + +Induct on completed blocks. NODE agrees with source peeling and row splitting. +Each nonrecursive block performs the same ordered source primitive operations +and then transfers their complete result without changing its contents. The +three-way residual expansion agrees with `trace.execute`, including reverse +adapter order and half-reset omission. Section 6 gives the recursive induction +step. MERGE_RETURN therefore produces the source's complete endpoint. The same +argument preserves borrowed inputs, source-program scope and physical prefix +multiplicity, since transfers copy symbols in order and no block identifies +equal prefix values. + +## 5. Fixed scratch roles inside atomic blocks + +Every source numerical array has fixed source dimensions and uses the permanent +Word banks. The only unbounded coefficient-evaluation nesting uses the existing +sequential pending/value Stack tapes. It does not allocate a matrix or Callback +per ancestor. I retain the source's preparation cost and encoded arithmetic. + +For stream scratch, the following counts include nested callees but exclude +canonical inputs and destinations. They give a conservative lexical allocation; +the global reserve \(q^2+128\) exceeds their maximum. + +| Source path in the frozen PR2753 export | Tape roles | +| --- | ---: | +| `predecessor/cardinal_counts.py`, `layout.child_extents` | 16 | +| `predecessor/fresh_rows.py` split/merge, excluding W canonical outputs | 8 | +| `predecessor/vendor/directory.py` context/produce | 12 | +| `predecessor/vendor/selection.py` gather/scatter | 10 | +| `predecessor/vendor/routes.py` complete owner route | 20 | +| `packet_engine.py`, `stream_runner.py`, `vendor/stream.py` complete ADD and coefficient | 32 | +| `vendor/bitstream.py` complete atom swap | \(q^2+24\) | +| `linear_sign.py` complete address sign | 16 | +| `recursive_call.py`, `vendor/children.py` descriptor preparation | 16 | + +For each row, allocate the named lexical temporaries once for that macro's +active call path, and reuse them only after their last borrower finishes. +The variable loops justify that reuse as follows. + +Count.product retains factor, scan and result, plus the one temporary copy in +Count.add; it closes that copy before the next multiplier bit. Directory +production clears its saved prefix before the next old-prefix ordinal. Routing +partition clears its key after each record and reuses two buckets; route_cube +alternates completed pass outputs. Fresh-row splitting assigns its W outputs +to permanent family roles and reuses its counters. + +Digit swap uses exactly q² bucket roles, one output and bounded outer/middle/bit +counters. Atom swap additionally retains three cardinalities and the previous +digit result. It clears the previous result before the next pass. The packet +interpreter reuses one prefix copy, one local fibre, one changed fibre and its +partial packet output. These lifetimes fit q²+24. Address sign uses the PR2753 +linear scanner, not the older w-pass sign. + +The largest control-tape overlap occurs in `children.coefficient`: two Callback +objects and one extended Program. Each Callback owns two Stacks, each with a +main and reverse tape. That accounts for eight stack roles and one descriptor +role. The evaluator processes arbitrary history by pushing records on these +fixed tapes. Prefix, packet and arithmetic-counter roles fit the ADD allowance +of 32. Matrix and scalar temporaries use Word slots, not further stream tapes. + +For lowered ownership, `Count.close` and `Counter.close` end their lexical +borrow. Callback.close/abort end all four Stack-role borrows. Borrowed Fields +create no placeholder role. Returned directories, cardinalities and descriptors +transfer to canonical destinations before their scratch scopes end. A Stack.pop +does not release its reverse role. No source variable loop retains a growing +collection of live Tape identities under these rules. + +Inside a nonrecursive macro the call nesting depth is bounded by the finite +source call graph, except for the already serialized callback evaluation. Assign +distinct scratch roles to simultaneously active lexical owners. Each operation +then acts on a fixed tape or chooses among finitely many role labels. Replace +the Tape simulator's cell-array access by the stated read/write/unit-move +instruction. The head position remains a physical head, not a control integer. +This supplies a finite-tape implementation for each block; it does not add a +constant-time random-access operation. + +The translation specializes the source's known callbacks and factories. It is +not a compiler for arbitrary Python callbacks. Replace known lambdas by their +explicit macro operands, omit observer/meter histories, and replace `.head==1` +guards by the quiescent-head invariant or a one-cell LEFT probe. Interpret +`.cells` only as the simulator representation of a tape. Initialize Word slots +by scanning the existing encoded root templates; do not read `.bits` into +control or construct new per-child templates. The original-program identity +guard becomes the declared current-frame program role and fixed source label. +Finite live/free slot maps remain finite control because capacity is fixed. + +## 6. Call, park and return + +Maintain the following cut invariant: canonical role bodies have no interior +BLANK or LEFT; heads stand immediately after LEFT; scratch roles are empty; +live Word slots have the unchanged root templates. Record the successor PC, +root flag and required finite Word-slot labels on the control role. + +Prepare the child's full input capsule before parking: copy the current packet, +current directory, extended source program, prefix count, unused stock and the +three projected extents into fixed handoff ports. Copy modulus, width and depth +into three fresh Word slots. These copies belong to the child. The descriptor +and projected spectator formulas are the unchanged PR2753 formulas; the capsule +contains the whole packet, not a representative prefix or visible subchunk. + +Park the canonical parent roles, including empty roles, in fixed order on an +outer PR2635 frame. For each body symbol write its four-bit code to the shared +packet port, clear the source symbol, then PUSH the record. Keep the role order +in finite control. `RoleParking.park` implements these steps. Open an inner +numerical frame on the same parking tape and call PR2769 PARK with the three +child grant slots. That codec parks the other live parent slots and preserves +their exact labels. The child now owns the empty reusable role bank and the +three grants. It adopts the handoff copies, clears the ports and starts at NODE. + +On child return, put its completed output in the protected return port. Clear +its canonical and scratch bodies, close its numerical work and grants, then +restore the inner numerical frame. Restore the outer stream frame in reverse +fixed role order and read the parent control record. The output port lies +outside both restore sets. Transfer its result into the parent current role +specified by the CHILD return label, clear the port and continue at the recorded +successor PC. The source's saved borrowed roles and Word aliases have their +original contents and identities. Restore source ownership before any parent +comparison, cleanup or coefficient evaluation resumes. + +Use a finite root flag in the current control state to distinguish final return +from a parent restoration. At a deeper call, save that flag with the parent and +set the child's flag to false. The machine needs no depth counter to find its +parent: the matched frame delimiters supply the stack discipline. + +At the final root return, copy or transfer the protected result to the declared +output tape, close owned numerical words and erase the two templates by scanning +to RIGHT. Erase LEFT on each owned role and the parking port marker after all +matched frames have closed. Reset those heads by the known marker position +before erasing it. Leave the borrowed root input tapes intact. This final work +costs the sum of the fixed templates and cleared role extents, hence O_q(V_root) +on the stated domain. Intermediate calls retain the templates for reuse; the +outermost cleanup does not assume their cells disappear with a host object. + +Induct on the finite decreasing-width call tree. The leaf blocks satisfy the +retained source contract. A completed child preserves the capsule's row and +spectator coordinates, while the parent remains unchanged on the parking tape. +The inverse codecs restore the complete parent; the protected result supplies +the one substitution expected at CHILD. The induction proves the compiled +caller's return contract. It also proves that parent frame delimiters cannot be +mistaken for child payload or partial records. + +`numerical_frame.py` separately substitutes this numerical protocol into the +actual source Frame call site. It copies all three grants before PARK and +restores before the parent engine resumes. Its failure handling closes children +while the parent remains parked. That executable integration retains the source +generator scheduler; the finite macroprogram above removes that separate layer. + +## 7. Movement and cell charges + +For r canonical role records containing L source symbols, the role codec sends +S=4L bits through PR2635. Its matched frame costs exactly +\(5S+7r+3\) table steps, in addition to the explicit encoding, erasure and port +work. Those additional scans cost \(O(L+r)\). All r roles, including empty ones, +pay their delimiter cost. The numerical codec has its PR2769 linear invoice in +parked word bits, record labels and fixed bank-capacity scans. A fixed bank scan +is q-dependent constant work, not a scan through ancestor frames. + +At each internal boundary, capsule copies, two checkpoints, restoration and +output commit cost \(O_q(V)\) under the retained local metadata envelope. There +are a fixed-q number of such boundaries at each node: a good request has one; +a fallback request has at most 49911, independently of f. Thus the total added +checkpoint work per node is \(O_q(V)\). + +Canonical result commits need a separate charge. Fixed global/local event +commits add \(O_q(V)\). Adapter-column commits add \(O_q(fV)\); digit-pass +commits add \(O_q(wV)\). Consequently the complete added local work is +\(O_q(V(n+w))\), which preserves the p=1 recurrence in PR2753. I make no +claim that every canonical commit belongs to an O(V) node toll. + +Let \(M_j=8V_j+32\Delta_j+E_j\) be the retained logical frame envelope. Canonical +ownership and the handoff ports add a fixed number of copies of already charged +complete packets, programs, directories or counts. Their total is at most a +q-dependent multiple of \(M_j\). Four-bit serialization adds another constant +factor. Scratch roles contain at most the retained block's live data; cleared +tails do not count as live symbols, but the machine may have visited them. + +For a visited-cell bound on reusable tapes, bound each tape's largest occupied +prefix by the sum of charged frame/block extents that could occupy it. The fixed +role count multiplies the largest relevant extent by a q-dependent constant. +Each role keeps a dense body and moves only within that prefix or its adjacent +delimiter cell. The parking tape holds exactly the active ancestor encodings; +the packet port holds at most one current record. This argument includes erased +but visited tape cells and permanent markers/templates. + +PR2753 proves \(M_j<(10+2^{-125})V_j\) on the stated domain and +\(V_j=V_{root}/(WN)^j\). Hence the physical reserve, including the complete +active parking stack, is + +\[ +O_q\!\left(\sum_j M_j\right)+F_q=O_q(V_{root})+F_q. +\] + +For padded widths or uncoupled histories retain the explicit M ledger and the +preparation costs; do not use this absorption. I do not carry over the sharp +logical coefficient 11 to the physical construction. + +## 8. Evidence and open boundary + +The checks compare 16362 trace events in 36 good/fallback cases after 180 +serialized cursor reconstructions. They cover f=1, odd f, both banks, threshold +63/64/65 and half threshold 127/128/129. A separate iterative fixture performs +1500 nested complete stream/numerical checkpoints with four permanent stream +roles and three allocated index slots. It retains its child result in a distinct +port through all restores. It uses an encoded countdown and no parent-object +stack. + +The actual selected Frame checks cover normal return, constructor failure after +PARK and a deeper child failure. The complete small q=2, dimension=2 model covers +9216 addresses, 12 internal calls and 156 residuals using one numerical bank +pair. It uses one family, cutoff 2 and root coordinate projectors; its children +execute all twelve conjugated GL2 good/fallback forms. That model retains the +logical payload scheduler. Neither it nor the +cursor fixture executes the complete selected macroprogram from section 3. + +Readers can review the fixed-role source compilation independently of those +finite controls. Section 9 adds complete small payload replays through the +generated controller. Stronger H2 primitives and the outer wrapper retain their +own mathematical contracts. I establish no new selected frontier or complete +integer multiplication theorem. + +## 9. Executable fixed-role controller + +I implement the finite source expansion in `macro_code.compile_node`. It follows +the retained schedule/replica/low/local order, authenticates LocalState during +compilation and emits explicit COPY, XOR, IDLE, bridge and exchange instructions. +It inlines each residual's finite block sequence. The compiler consumes only +fixed-q source labels and plans; input dimensions and high fields never enter +this pass. The complete selected expansion is effective but enormous. The +replays materialize complete reduced-source words, not a sampled GL64 word. + +`macro_machine.Machine` runs one dispatch loop. Its header contains the root flag, +program-mode label, successor PC and five Word-slot labels: modulus, one, cap, +size and depth. I retain a derived Geometry/Layout only within the active +residual. I close its eight index words before CALL, so no cached object or +generator survives child descent. After RETURN I rebuild constructor-free views +of the five restored words and derive geometry again only if another block needs +it. I never rerun directory production, an accepted literal event or node setup +on a parent return. + +The implementation uses W+s+21 reusable stream roles, where s is the largest +local owner count plus its private role. It adds eight handoff ports, one output +port and q²+128 scratch tapes. With the two numerical banks/templates and two +parking tapes, it uses at most + +\[ +2\cdot2^{24}+W+s+q^2+162 +\] + +working tapes. For s=662 this is below section 2's bound, including eleven +borrowed root input ports. The simulator creates Word backing objects lazily, +but each object has a slot in the fixed bank. Provisioning and clearing those +fixed slot markers adds q-dependent constant work; it does not allocate a bank +per child. I initialize word bodies by the existing template scans. + +`scratch_pool.ScratchPool` selects a free role from a fixed inventory. A lease +contains a finite slot label and an active bit. Clearing the owned scratch value +ends that lease. A later stale close does nothing, while a stale read rejects; +it cannot erase a newer borrower of the role. The source's lexical-lifetime +inventory in section 5 bounds the simultaneous leases and aliases. The simulator +may create many lease objects over time, but it retains no lease history and +none crosses CALL. Meter and allocation counters are checker observations. + +I specialize the authenticated source's Tape globals and default factories for +these leases. I add the four Stack-role releases at Callback.close and create +borrowed Fields views without allocating discarded placeholders. Stack.pop still +retains its reverse role. During execution I reject any new physical Tape or +Arena constructor call. This specialization implements the source rewrite in +section 5; it leaves the frozen files unchanged. Its Python namespace installation +is harness setup, not an input-dependent machine operation. + +At successful root return I erase working bodies, permanent LEFT markers, Word +templates and the parking-port marker. I keep only the declared output and +borrowed inputs. Boundary probes use scanned LEFT symbols, and the controller +checks the exact declared live numerical slots. I require borrowed root input +ports to lie outside the reusable working bank. + +`macro_binding.SelectedBinding` calls the retained selected coefficient and +descriptor routines. The selected junction replay checks a native rank-42 +descriptor, repeated frozen prefixes, the exact projected gap, encoded successor +PC and parent restoration. It also runs actual adapter and generated-child +coefficient evaluations for an identity projector, with independently expected +values 0 and 2. Its 23-bit controlled body and unused stock 11 test this junction; +they are not an admitted complete selected payload. + +The complete GL2(F2) controller replay executes 5859 macros from 483 descendant +and 63 root instructions, with 12 internal calls, 156 residuals and 9216 output +bits. It preserves the pinned logical replay's complete payload hash. The source +recursive Invocation constructor is disabled throughout the run. It uses 24 +canonical stream roles, eight handoff ports and at most 20 live scratch leases +from its 132-role pool. + +The complete GL2(F3) replay uses all 48 lows and four families, n=2, w=1, weights +(2,1) and external gap 2. It executes 25415 instructions on 31104 bits, including +192 MOVE, 96 COPY and 384 IDLE residuals. Independent projector formulas check +the private COPY data before its cancelling XORs; independent address formulas +check both intermediate sweeps and the final endpoint on all rows. I precompile +only this fixture's finite coordinate-zero coefficients, retaining source/view +and high-field checks. Production does not use that table. This fixture has no +internal child, while the GL2(F2) replay tests recursive control. + +Additional controls reject stale leases, exhaustion and forbidden allocation. +A complete 1458-bit nonzero remainder peel checks the unpeeled coordinates and +external gap. A 2430-bit modulus-9 atom swap checks reuse across two radix digits. +These tests support the source refinement and ownership annotations. They do not +replace the parametric proof, prove stronger H2 or exhaust the selected GL64 +source and arbitrary precision domain. + +I also corrected the parent-identity coverage gap that starship-s reported in +[Discussion2319](https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18960884). +The earlier deterministic signature omitted that identity. I reproduced its +acceptance of 214 corrupted candidate boundaries, including 42 invocations. +I now validate identity against `page.parent_identity` on both reference and +reconstructed paths before projection. Twelve controls cover None and foreign +parents for ENTER, INVOKE and RETURN on both paths. I serialize no object address. +The generated call gate separately rejects a missing parent, a different Program +view and a wrong source code before it prepares or parks a child. + +For simulator efficiency, a scratch lease delegates append, rewind and clear to +the same retained Tape methods. Those methods still perform their literal reads, +writes and unit moves. I update the observational lease meter from their actual +counter differences; no counter value selects computation or a head position. +An exact-traffic control compares leased and ordinary tapes on empty, singleton +and longer bodies. This removes repeated Python wrapper calls without introducing +a bulk-copy or constant-time rewind primitive. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/README.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/README.md new file mode 100644 index 0000000000..abd0edba96 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/README.md @@ -0,0 +1,90 @@ +# Selected BIT caller: fixed roles, parked banks and finite returns + +I implement fixed-role recursive control for the all-size p=1 caller in +[David Arias's PR2753](https://github.com/CrocSwap/integer-mult-bounds/pull/2753). +I compile its fixed source schedule to macroinstructions and execute them with +one active frame, permanent stream roles, two numerical banks and one parking +stack. I serialize the parent return label and state before child descent; +I retain no parent generator or per-child tape bank. Under the pinned caller's +input and root-coupling hypotheses, I prove an O_q(V_root)+F_q physical reserve +and retain its O_q(V(n+w)) local toll. See [PROOF.md](PROOF.md). + +The executable contribution includes: + +* A finite instruction emitter and dispatch loop, with canonical result commits, + protected child handoff/return ports and complete root workspace erasure. +* A fixed scratch pool with explicit leases, stale-access rejection and guards + against physical Tape or Arena allocation during execution. +* Complete generated-controller replays on 9216 recursive GL2(F2) addresses and + 31104 four-family GL2(F3) addresses. The latter checks 96 private COPY endpoints + before cancelling XORs and both intermediate family sweeps. +* Actual selected adapter/child coefficients and typed CALL/RETURN checks, plus + the earlier Frame integration, 1500 nested checkpoints and residual cursors. + +I execute the reduced source programs through the generated controller, with the +source recursive Invocation constructor disabled. Production uses the unchanged +selected coefficient implementation; the reduced fixtures use their declared +small grammars. I have not materialized the astronomical selected GL64 instruction +word or expanded the retained primitive blocks into one complete microtransition +table. I support the parametric claim with the source-level refinement proof; +finite replays do not establish a formal verification of the full theorem. + +I retain p=1, the stronger H2 primitive obligations and the outer borrowing +wrapper boundary. I make no exponent improvement or supplier-admission claim. +I leave the selected frontier unchanged. + +## Reproduce + +Use Python 3.12 and the standard library, from the repository root: + +```sh +python3.12 -B scripts/research_package.py --package research/selected-bit-physical-caller +``` + +The registered suites authenticate the complete frozen source inventory and +its transitive repository inputs before execution. They cover the generated +recursive and four-family controllers, selected-source junction and ownership +controls, and normal/optimized Frame and continuation checks. +See [VALIDATION.md](VALIDATION.md) for scope, commands and observations. + +## Attribution and overlap + +Jose Manuel (`jmbarrancoml`) contributed this lowering and integration, with +substantial OpenAI Codex assistance in mathematics, code and verification. I +claim no independent human or proof-assistant review. + +David Arias supplied the all-size logical caller, stock/endpoint induction, +linear-sign repair and complete logical reserve in PR2753. I reuse my numerical +codec from [PR2769](https://github.com/CrocSwap/integer-mult-bounds/pull/2769). +ywz65 supplied the finite two-tape parking controller in +[PR2635](https://github.com/CrocSwap/integer-mult-bounds/pull/2635). +[SNAPSHOTS.json](SNAPSHOTS.json) pins the 97 unchanged exported files and their +original Git paths. Those exports retain predecessor notices, including the +earlier routing, directory, residual-lifetime and selected-source work. + +I coordinated this scope in +[Discussion2319](https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18958887). +The numerical lifetime audits in PR2781/2796/2801, the ordered-shear machine in +PR2776 and the separately claimed outer wrapper address complementary boundaries. +I do not incorporate their pending claims as proof dependencies. + +I corrected the earlier continuation checker's parent-identity omission after +[starship-s's audit](https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18960884). +I now validate each boundary against its expected parent before deterministic +signature projection, test wrong parents on both comparison paths, and reject +wrong parent/source bindings at the generated controller's call gate. + +## Open next questions + +* Replace the retained O(wV) route/leaf routines with the required H2 primitives. + Price the actual source-bound coefficient and movement paths; the present + physical lowering retains the p=1 baseline. +* Join the physical reserve with the outer stock wrapper. Coordinate with its + active author and track all padding, restoration and preparation charges. +* Audit the compiler and primitive specialization independently. Start with + the opcode/source correspondence, lease-end annotations and CALL invariants; + a complete expanded transition table or proof-assistant refinement remains open. + +The structured scope, overlap checkpoint and next steps appear in +[TASK.json](TASK.json). This contribution follows the repository's Apache-2.0 +license and preserves the frozen sources' notices. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/RESULT.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/RESULT.json new file mode 100644 index 0000000000..44afaf8dca --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/RESULT.json @@ -0,0 +1,63 @@ +{ + "frame": { + "sha256": "bafe9397fdad657a89da48fd8147ccf45d5df8d8195b8877c1c117408539ed84", + "cases": ["normal", "constructor_failure", "child_failure"], + "scope": "Actual selected descriptor and Frame boundary with controlled 23-bit child bodies" + }, + "continuation": { + "sha256": "6d3cc8a9b5e5239138140a7769ddcd2f79cec9c66338982dff5ec404c5f139e9", + "trace_cases": 36, + "compared_events": 16362, + "serialized_return_cursors": 180, + "nested_frames": 1500, + "maximum_allocated_index_slots": 3, + "permanent_stream_roles": 4, + "wrong_parent_controls": 12, + "scope": "Residual event refinement and nested role/numerical checkpoint protocol, not a whole selected payload replay" + }, + "macro_nested": { + "sha256": "325eb10894bbada046a80e71a3e3ed6cad954e1617a51724049476e2e446976f", + "addresses": 9216, + "instructions": [483, 63], + "macros": 5859, + "internal_calls": 12, + "residuals": 156, + "peak_scratch_leases": 20, + "scratch_capacity": 132, + "payload_sha256": "c4b4abb3419284c0de9cf141c653e8bcdd3d79a2ae4096f43cab530f5caab1bd", + "scope": "Complete generated q2 recursive controller; fixed roles, serialized returns and root workspace erasure" + }, + "macro_local": { + "sha256": "720b91aee3dfc6fffdba80c4c99c3762cc51dd492cae50d0c7f2e924ddba2c4f", + "addresses": 31104, + "instructions": 25415, + "private_copy_oracles": 96, + "residuals": {"MOVE": 192, "COPY": 96, "IDLE": 384}, + "intermediate_sweeps": [0, 1], + "peak_scratch_leases": 25, + "scratch_capacity": 137, + "payload_sha256": "5035a339800d38d3c2436548e89fc08db368266d4d6065a2adaf491052975af4", + "scope": "Complete generated four-family q3/w1/n2/gap2 caller, including private COPY, XOR, IDLE, bridge and exchange" + }, + "macro_selected": { + "sha256": "716735096baccca2bffeb114c2e00cf83f6112a83c0d4aae0564e345e0251090", + "selected_coefficients": [0, 2], + "selected_child_width": 168, + "selected_successor_pc": 1, + "controlled_payload_bits": 23, + "rejected_gates": ["wrong_parent", "foreign_program", "wrong_source"], + "remainder_addresses": 1458, + "two_digit_addresses": 2430, + "scope": "Actual selected grammar/coefficient/CALL boundary plus ownership, nonzero peel and two-digit scratch-reuse controls" + }, + "nested": { + "sha256": "c6097f7da02444c18d777e77fc4f16caf01a4de79bc8060ad0c996e2cd6956d6", + "complete_addresses": 9216, + "internal_calls": 12, + "internal_returns": 12, + "residuals": 156, + "separate_child_arenas": 0, + "payload_sha256": "68477c468bd70d3488f9e1afbfa576aab2fa9db44949874ab873d64c22853b46", + "scope": "Complete q=2 dimension2 recursive model with shared numerical banks and the retained logical payload scheduler" + } +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/SNAPSHOTS.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/SNAPSHOTS.json new file mode 100644 index 0000000000..034836cfaa --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/SNAPSHOTS.json @@ -0,0 +1,683 @@ +{ + "files": [ + { + "path": "inputs/pr2753/EVIDENCE.json", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/EVIDENCE.json", + "sha256": "77b7cbefa2ca30acf2f77e23d14808ccd27848e9c76e4c5e68a045ef7891a07f", + "git_blob": "c2c347abc2b8c19bb642c4da1aad5b3e8383016f" + }, + { + "path": "inputs/pr2753/PREDECESSOR.json", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/PREDECESSOR.json", + "sha256": "e3127475913d62dbdf1b45d9283d2db2e9b689e0f81a703189150c1e5be2bca0", + "git_blob": "56d76c357b51f4fc6856923222bfca47f03334e7" + }, + { + "path": "inputs/pr2753/PROOF.md", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/PROOF.md", + "sha256": "552fa306d5cc228f4d8d8553f8ac5fc6a738ef2b66a2cb765ba0638cd229794d", + "git_blob": "1a08e57eac2a37764066d31baa3ecd3769759158" + }, + { + "path": "inputs/pr2753/README.md", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/README.md", + "sha256": "6ce41fd7e6dfbe5faecc25bd36561f0a65b6ebca6fc69d3fb72569424a405045", + "git_blob": "75461632856f94d6b48ae820cf5d0b2b232305c2" + }, + { + "path": "inputs/pr2753/RESULT.json", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/RESULT.json", + "sha256": "4919655bae2e5cff051e8f2d240a8e4ebb03392a9da2fb5328daa9248fb7e88b", + "git_blob": "75faec7844e18fc7c44543dbab87aba2ecf32b3e" + }, + { + "path": "inputs/pr2753/SOURCES.json", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/SOURCES.json", + "sha256": "7c78f539078e1bc3d893b78b5ee24cb22dc090d3763fe554e861b6c3d3e7eaf7", + "git_blob": "ff8c8e36176aa56e319d0f9e584167ac21d67f33" + }, + { + "path": "inputs/pr2753/TASK.json", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/TASK.json", + "sha256": "ac7d4b38da31b373e665929027fc04afb66c3e9aedaea3296e3783637912d0e8", + "git_blob": "d70ad317275d2a517ab1294ce48ecb1f83dfedbf" + }, + { + "path": "inputs/pr2753/VALIDATION.md", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/VALIDATION.md", + "sha256": "ac0f2fab0ca810ce0202d31480daa8329cba0897ab015520a2bfd4b689c4086b", + "git_blob": "d91680665a28c12c27c99336b55c3d5341dd0fe4" + }, + { + "path": "inputs/pr2753/VERIFY.json", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/VERIFY.json", + "sha256": "6ad0e07f68458afedece927550655b5bc5cd9861a70044fcd95bb10a2179f0a6", + "git_blob": "b6072f66c13a38b5d8dff3ca3bc5f3f3562f1b6e" + }, + { + "path": "inputs/pr2753/bootstrap.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/bootstrap.py", + "sha256": "eef1c418e8edbdf317d159683e30beaecd971c77cf41d6b09708576405e2141e", + "git_blob": "448c9b3a86eedb84220646ab27ff089a32ad5b9b" + }, + { + "path": "inputs/pr2753/check_layout.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/check_layout.py", + "sha256": "454b1587d1ed5ccaea19b621a67e2ceba999d7ede61188125faa41c4dd2ab2b1", + "git_blob": "be59d614d25961f891e1640bf85cf5e2f474a059" + }, + { + "path": "inputs/pr2753/check_nested_model.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/check_nested_model.py", + "sha256": "b1941b882b0659722c3c41994c82f020c1f7ab320dc28c43c2758029ef8a48b7", + "git_blob": "20fed6bd389cb53fc52d0ad8389e9e7704c90265" + }, + { + "path": "inputs/pr2753/check_recursion.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/check_recursion.py", + "sha256": "dde82badf043e553bc635a34295e2b5505d84d6dfbaf96e0cfccb8a8c3dbb158", + "git_blob": "8f36c88e196cf5afc0d6e227ba8568a10bb23c6a" + }, + { + "path": "inputs/pr2753/check_runtime.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/check_runtime.py", + "sha256": "9fcf0c9a3c84a17446fafe8da50b63db296ba9465d48ddb6fdeac8742dfc98b1", + "git_blob": "fe355a703475325bca4807b8ffedfa9f6edb74f5" + }, + { + "path": "inputs/pr2753/check_sign.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/check_sign.py", + "sha256": "ee4fd34acd49962a18d268aefeb20aa3c2673a10e7a43eee3e51a9bd3cf9106a", + "git_blob": "50669949a1325e8c49aa0ff714c40a50077b5eb8" + }, + { + "path": "inputs/pr2753/check_sources.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/check_sources.py", + "sha256": "1c49984ae6ee7f8a44cde16b51e486f0b3ba4ee5c973389ac8d58a82d0a0aa3b", + "git_blob": "5c09a13943070a3bb3c0da06fd19fbc6916d1743" + }, + { + "path": "inputs/pr2753/consumer.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/consumer.py", + "sha256": "2f2a8604c23fb2c81f24320c71ed0142118d98dde3be6086adad28e89954a777", + "git_blob": "a66d9276f829ce2c619871866816649d5f3687fd" + }, + { + "path": "inputs/pr2753/control_checks.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/control_checks.py", + "sha256": "c09d33327932b4ffbb8acb26c8a6bb621bcca542157d22f1edf72679a9359981", + "git_blob": "11daa0b2221c5870d19ba2eaf411a6bff3a0398d" + }, + { + "path": "inputs/pr2753/driver.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/driver.py", + "sha256": "ceaf8f75de9810a05ebf8f65780b6f8bd7599a5768401d5e4386182afe615cdf", + "git_blob": "5b7846a70aada53d87480b337e1c04217118771b" + }, + { + "path": "inputs/pr2753/evidence/NOTICE.md", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/evidence/NOTICE.md", + "sha256": "fd7c42e89878cda6df86dde8720ece34625a337cf5edd795a421e2d3b42919e9", + "git_blob": "d0318d43ed420e21dc52166a19de703aa87fbb3e" + }, + { + "path": "inputs/pr2753/evidence/pr2688-NOTICE.md", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/evidence/pr2688-NOTICE.md", + "sha256": "c899fccf7bd32397f0ddd85e4af35a166cefb3e3ae3407ec40edc3ab2051b617", + "git_blob": "f2b49cdef83a4a685fad32c01fba93e12cfcb5a8" + }, + { + "path": "inputs/pr2753/evidence/pr2688-PROOF.md", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/evidence/pr2688-PROOF.md", + "sha256": "fa9bec0952468e4acb760a88d45d5be216325650e1a4080cf590e07b90c9f533", + "git_blob": "1395e1941863e40ff6d62dd91c41de2cb56edae9" + }, + { + "path": "inputs/pr2753/evidence/pr2708-README.md", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/evidence/pr2708-README.md", + "sha256": "5906f6b7b2c8eea90e441476c4cbd60fe2ef981b690c63357bcfe67e3104aeef", + "git_blob": "79b8742f32b4ffb991f91ddd2d3c6be693084e6d" + }, + { + "path": "inputs/pr2753/evidence/pr2731-README.md", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/evidence/pr2731-README.md", + "sha256": "19683df4394de299cbd7e1cce39bf9434ad260b1a37006587cf9aed84c9c0a03", + "git_blob": "ac5b826f9c34e1faadc5d5a02d5d260823112078" + }, + { + "path": "inputs/pr2753/layout.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/layout.py", + "sha256": "3beef6534b02c3b011b741f957a7d9fb05a9ac0bba1fed53b2c71834e4ea6bc1", + "git_blob": "aa554b14fe0f6b308d9fba0a2afc92e5a28e20cb" + }, + { + "path": "inputs/pr2753/linear_sign.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/linear_sign.py", + "sha256": "73e895fc701a4145cbe89d60f5775128354e7f08d0a45eacf22f423913f54e67", + "git_blob": "6a6e5c02f299fad8c4f7ab724fc36e14a22ab13c" + }, + { + "path": "inputs/pr2753/node.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/node.py", + "sha256": "0bd4f640cafb5c8f070c161d86445910f77578a672bf5886936ed89e7f6bd21b", + "git_blob": "28c98a3573b458f7a055678d70b602b80e6e959e" + }, + { + "path": "inputs/pr2753/packet_engine.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/packet_engine.py", + "sha256": "c80fc3aa9092f91cc309b2fb2dbc3618bf96bdb9b8498503993ea161f0ae2134", + "git_blob": "72543f684f38fefeacc2ee66d81661f1a2439cf7" + }, + { + "path": "inputs/pr2753/peel.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/peel.py", + "sha256": "8b20888f74b4cd814a97b42ec72528fbfb6d2e936c5022df726f0785d0d01a2e", + "git_blob": "38502515afc928082c849cd2cda8578d33a5050a" + }, + { + "path": "inputs/pr2753/predecessor/NOTICE.md", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/NOTICE.md", + "sha256": "c446b32b8a621844fb2fbe654810c8122035bdd43fed2132f1137d98cb6f9943", + "git_blob": "ef9f81510db86eaf2f0a7191d85e92a6db30ddc0" + }, + { + "path": "inputs/pr2753/predecessor/PROOF.md", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/PROOF.md", + "sha256": "88754d57bae35a2089d9de221ff32ba802b7a56b810f96271f3ea36985edfb14", + "git_blob": "a4746d1786f41e45a36fdedf37966b80fbab3562" + }, + { + "path": "inputs/pr2753/predecessor/README.md", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/README.md", + "sha256": "15631eb826b2d8d54fbee18fb6f70ee035e172d524c2a209b6c467c3f0204f64", + "git_blob": "988ff622029aff49d7e99deb2468684d904bc852" + }, + { + "path": "inputs/pr2753/predecessor/RESULT.json", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/RESULT.json", + "sha256": "0d94c5e9150f3fbd603526c67ea33168d3ba45e158aaf722e848bf5c316a37a8", + "git_blob": "7b7dfe0eab22a7b511483f268b97a7c707fd8b90" + }, + { + "path": "inputs/pr2753/predecessor/SOURCES.json", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/SOURCES.json", + "sha256": "1b02a5c607a5967948988c3beaf37d9975d650ad501a99fcf74c135dc1f05fdd", + "git_blob": "4fef1a4d6c2d5e2620d3506d6032f9226870ed39" + }, + { + "path": "inputs/pr2753/predecessor/TASK.json", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/TASK.json", + "sha256": "a4cd54d4b09ad12a90a5feeb39a127f0f0d5a2a04f9f88554c5fc3ee0cfe77f4", + "git_blob": "eb2ce7cc00df816daf566f101d56a0330852c1d9" + }, + { + "path": "inputs/pr2753/predecessor/VERIFY.json", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/VERIFY.json", + "sha256": "e1dd0ee5f267ffa515bb345054ff8637cfedb0079b0d2da29b90b7848264926e", + "git_blob": "69c7ad75abe494be386f73a5d51359b9053cd9be" + }, + { + "path": "inputs/pr2753/predecessor/cardinal_counts.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/cardinal_counts.py", + "sha256": "59ddeac102a0cc51fa49b15aae6aeb68cd68ed217fa974ce916372a177d2ec8f", + "git_blob": "6a14feac45094ae9156e8c2c982d6727544f180e" + }, + { + "path": "inputs/pr2753/predecessor/catalogue.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/catalogue.py", + "sha256": "83ea88f82d4a83c5f889774bfe3519b7ebaa24b6a0e2a969dafff012107a89bf", + "git_blob": "0efc0575a7623ac41c094d2e8772beda5a9fdc29" + }, + { + "path": "inputs/pr2753/predecessor/check_headers.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/check_headers.py", + "sha256": "a41dab0c487c341eb32b34a03af74454e15e9e61e7386a1ca426d83f3b68b1ca", + "git_blob": "1c372b19e19b838a89c0e64daeda15ec6b49f079" + }, + { + "path": "inputs/pr2753/predecessor/check_layout.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/check_layout.py", + "sha256": "8f776a21dc0e31f9738d822cfda38db92f1e3672afb880d4246ec5e084a50a41", + "git_blob": "174d843716a684145f934cb55a612bca85aad725" + }, + { + "path": "inputs/pr2753/predecessor/check_runtime.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/check_runtime.py", + "sha256": "5357e4ff255f17c4209aaf71a3413a4148475f11180c4f829e8f0ebacd2877cb", + "git_blob": "5647693b3a5c1555b65e281c6609f98b92d45542" + }, + { + "path": "inputs/pr2753/predecessor/check_sources.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/check_sources.py", + "sha256": "6463c2724e04a313181b78e90a17cd62ee42465754902cca3e9a65c6140a15a1", + "git_blob": "9219cdf863d9f060d6e38a4f2f4760fd227af003" + }, + { + "path": "inputs/pr2753/predecessor/consumer.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/consumer.py", + "sha256": "b28ec97b0873ff2be25aff4bdde268247ffcec0d21279d0ada196de19a0bdc66", + "git_blob": "24b53521fce94d3349072cf47d70e62195f4d541" + }, + { + "path": "inputs/pr2753/predecessor/control.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/control.py", + "sha256": "d3a93e54bb7d333b73917586407d11674d38b5c3fda4fbdc436fb5293ae7786a", + "git_blob": "4f6ac09bffab43dbccc470bd0bde2ffbe969a8b2" + }, + { + "path": "inputs/pr2753/predecessor/control_checks.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/control_checks.py", + "sha256": "5ea6ded8c2508fbb00d93655affdfe7907ffb60916389e0736249c003a7a5148", + "git_blob": "712cfddc4caaad9e788d97b0e1e3f623172c43ed" + }, + { + "path": "inputs/pr2753/predecessor/driver.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/driver.py", + "sha256": "ee9e42fe95ab28fdd5e927c2d46fd480305aaad610eb2ca7ae514a5d22d9f0ac", + "git_blob": "0bdee4c9e348259b470a636a98e7657770f97fae" + }, + { + "path": "inputs/pr2753/predecessor/fresh_rows.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/fresh_rows.py", + "sha256": "e4ae08fbd658add630eb7754ebe0cbcb42c6f39cf4128f9cb92e27fcf5213a7d", + "git_blob": "aa3a327604308d3a5c7a27b65f5e631d430ab093" + }, + { + "path": "inputs/pr2753/predecessor/layout.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/layout.py", + "sha256": "7534b0166805f2ae8d11495c811d2bd272cea89c89b6bb5251fd411c89245a20", + "git_blob": "267d5ab98cd013ee82ba75e6d41609f1778af25f" + }, + { + "path": "inputs/pr2753/predecessor/model.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/model.py", + "sha256": "c937ae8e46162f88fc1cd7646d3b22c99273029ad0f0e3131f46ddec230676cb", + "git_blob": "9fb82fa57d29cdf8402f91534dffed8f586ced6c" + }, + { + "path": "inputs/pr2753/predecessor/node.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/node.py", + "sha256": "b88fc9ac0b22d939311ff4f7aff788e8c87a64fd5e866498e59bd27940ee3f28", + "git_blob": "13badda6f059da2132cbe325c071307e5191baa3" + }, + { + "path": "inputs/pr2753/predecessor/packet_engine.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/packet_engine.py", + "sha256": "ce7f132a6a69c802406f07c4a2119ef921e8978520ff58d5eeaeedb982c257f2", + "git_blob": "27a0dbf82e78252beede56ff86f5933c93eb55c1" + }, + { + "path": "inputs/pr2753/predecessor/peel.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/peel.py", + "sha256": "3de018e68601566c364c7568b110f60c1bf34941b846cdffb94401bb799f85e3", + "git_blob": "2ae1769a9726ab738d3981891d0b76beccac2d99" + }, + { + "path": "inputs/pr2753/predecessor/topology.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/topology.py", + "sha256": "384d456ddba76de137a63b50019d5bba2e9f6daa4177c91643e0565d4cf1d44b", + "git_blob": "39a2916c207d04be5efc44750d8606f5da0c2990" + }, + { + "path": "inputs/pr2753/predecessor/vendor/binding.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/binding.py", + "sha256": "20169a8af6ed2b34069fd353a2bc1c42335ab686c58de8479baef33dd3fb493b", + "git_blob": "21a5a21220a18ab62a19ac403a9944bc3a8665c8" + }, + { + "path": "inputs/pr2753/predecessor/vendor/bitstream.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/bitstream.py", + "sha256": "f78bac9641007dbd8824984edcac057274fe016ce78bd9cb512d0c0913274783", + "git_blob": "4d1fd4abb0f2aabe833e5cbc9efb51039739e7ca" + }, + { + "path": "inputs/pr2753/predecessor/vendor/cardinality.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/cardinality.py", + "sha256": "505d5e560c5a507e6184edcc19a87cf1fed243eb34a5cb21fbe1e4fe017e7f22", + "git_blob": "b8ba857e32c5903408e1e61ff916300848b4a208" + }, + { + "path": "inputs/pr2753/predecessor/vendor/check_support.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/check_support.py", + "sha256": "d9977e87ddc5acdb836b8e4a4e3942da17a05b04ce67c04547d17b986b518964", + "git_blob": "e1f961df9fa3a441fc5b600d1288a8d038eca51e" + }, + { + "path": "inputs/pr2753/predecessor/vendor/children.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/children.py", + "sha256": "a78866939631214c1d1659203b2b5fc062e3c6255e9f11f975c310046b010bd6", + "git_blob": "ce4935f838516e2b08d13bec767cb803786fbc6b" + }, + { + "path": "inputs/pr2753/predecessor/vendor/controller.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/controller.py", + "sha256": "fa09146991f6c04e6f4b6eb9bf0c8e103e70e90a0e402ff3d69814e6aac8ff8c", + "git_blob": "c631a9e77fbcccf0e8f448adc22978728aed7b60" + }, + { + "path": "inputs/pr2753/predecessor/vendor/counts.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/counts.py", + "sha256": "00b476dbda0e8cc99886bf794439e1cb9e775f435f599a3557e99321fe084069", + "git_blob": "81b48940ce222290a40d4fb349ce827f4788469d" + }, + { + "path": "inputs/pr2753/predecessor/vendor/directory.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/directory.py", + "sha256": "4270e370b2bfe38ef73aadcd97d1b3496b56bd582115d74331eb9e5ceb90bec7", + "git_blob": "c74cacf5ce809c0561d374f137a52df0992b4226" + }, + { + "path": "inputs/pr2753/predecessor/vendor/episode.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/episode.py", + "sha256": "38f79cb2a370548471063952d5f7c74bd795a2a8496fdcf3ce0996d79e3adaff", + "git_blob": "30d11ff4f333813855d36da3eb5a1ab0e154bafe" + }, + { + "path": "inputs/pr2753/predecessor/vendor/forms.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/forms.py", + "sha256": "1fdf9d31b7eb107c396e33f94dad61c9d3f2c709cae61178268a44ca80dbc0b4", + "git_blob": "6667c0b772a63f0059c7caffec63e0d919a92398" + }, + { + "path": "inputs/pr2753/predecessor/vendor/low_codes.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/low_codes.py", + "sha256": "f657e17f6088c840e3f7783e662257630f6d2c1e71c217721ffbca4d6ac93e87", + "git_blob": "737edfc4a10f4b7b3b97a7cef4b40864efd806e6" + }, + { + "path": "inputs/pr2753/predecessor/vendor/matrices.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/matrices.py", + "sha256": "00b687434039b54529ee092e34f9435cfcd66e0816eb3bd2a6688c73f4e01459", + "git_blob": "5d497353efbb9eeaaf4facd96ab40ffb0f3aa20d" + }, + { + "path": "inputs/pr2753/predecessor/vendor/numeric.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/numeric.py", + "sha256": "7327b05c4ec3e0f6d9c352cc7de85bfd4ebe940482553e77c59a773a8c09c514", + "git_blob": "6d4ebca8398008375b8f4762d1a9f1514e8c2611" + }, + { + "path": "inputs/pr2753/predecessor/vendor/oracle.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/oracle.py", + "sha256": "7bd18089e32ce48085b5e3a75159f6a82cdb2649ec682c53db05e399d97aef67", + "git_blob": "244f131466698a3ace10b657242fe1f65c07fd1f" + }, + { + "path": "inputs/pr2753/predecessor/vendor/packet.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/packet.py", + "sha256": "970e7fe0719e3dfe122b248941e6f21cd90d7dd62089fa6acbd0e5412ce083a5", + "git_blob": "ebc9b616514412b80c56d523776e6ba5d6766453" + }, + { + "path": "inputs/pr2753/predecessor/vendor/plan.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/plan.py", + "sha256": "d9c8dc93762db4d3a449814aa51e2211460648694469854d89cb48cb04188cf3", + "git_blob": "48255d5454308c07635fae4e7eb4873b0bd2a4f8" + }, + { + "path": "inputs/pr2753/predecessor/vendor/records.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/records.py", + "sha256": "0c9c4b23e998597fb877bb1a29da69ac869b68262abe635b162b4dba9c69b372", + "git_blob": "4f00467a0ff580954ad2fd0c7380240c753ddef3" + }, + { + "path": "inputs/pr2753/predecessor/vendor/residual.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/residual.py", + "sha256": "8fd24747cae498dfb2ba333e7f8a68d7315ae4c2d7530d8ca145aab95ede21df", + "git_blob": "3d070d2539a529f3b14ecb086a92a3db056229fe" + }, + { + "path": "inputs/pr2753/predecessor/vendor/routes.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/routes.py", + "sha256": "ed7dc3679451696ab1dd841146b215c9515a3eec5e4ff3763f33c315f1696ada", + "git_blob": "35531201dc349a811dfabc6f1f6e64697d665194" + }, + { + "path": "inputs/pr2753/predecessor/vendor/selection.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/selection.py", + "sha256": "bc8e371fb1fa0b41fb05ef0b34d0f4c317b2396f9833d91f44f95c2b54b4052b", + "git_blob": "2c28f1aaec104a75c4e6c170b3e6a60300ee6700" + }, + { + "path": "inputs/pr2753/predecessor/vendor/sources.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/sources.py", + "sha256": "f102edc7816d742bd89db8097254c19b843d0ef5cf6758ad42e93bcc0b214c62", + "git_blob": "16d5e7e6a28018f1e2d76d61efe2d54f6a6941d4" + }, + { + "path": "inputs/pr2753/predecessor/vendor/stream.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/stream.py", + "sha256": "c7dc7da5b00f27016982ada4c0416f8328568b00df16d97012f33d4b372d79b5", + "git_blob": "5e5a4bb0f98971447043e25d4dd6991bfc070389" + }, + { + "path": "inputs/pr2753/predecessor/vendor/stream_runner.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/stream_runner.py", + "sha256": "751c5023ca0e477369e448583961ace6a76db2723bb6c26f81203def539f1249", + "git_blob": "efff281d4c4be5c1378e31404fbcc634fe4ade59" + }, + { + "path": "inputs/pr2753/predecessor/vendor/trace.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/trace.py", + "sha256": "c71ba11d793dde2ac6e4cdcf468482872975c34589bf1167f2a460cb8a74e984", + "git_blob": "bb845a90f5bcf006e683e581e385936208f6a1f4" + }, + { + "path": "inputs/pr2753/predecessor/vendor/words.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/vendor/words.py", + "sha256": "5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9", + "git_blob": "8d4ba37e2778acb35b34e0719df2caf138fbeb50" + }, + { + "path": "inputs/pr2753/predecessor/verify.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/predecessor/verify.py", + "sha256": "cd83797d1f420f7e5de61c1a693110b4ee0c80bac0adae4699599046b7f76f8a", + "git_blob": "121acc1ff15ec85a8011e96eda2eb587608413b9" + }, + { + "path": "inputs/pr2753/recursive_call.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/recursive_call.py", + "sha256": "157deaa5972557893d43494a81151483bdc46373448ec677cb6a738c9b7e6f1e", + "git_blob": "6d33224145aa04f7fbaf7b6cda7c9c164311a402" + }, + { + "path": "inputs/pr2753/scheduler.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/scheduler.py", + "sha256": "0d96f7fbd6f90416167c5a52c0e3de942d1a0cae3d2968831932a9576701699f", + "git_blob": "60c2b6d065eba91dd5e0edb7a77fc087971eca3f" + }, + { + "path": "inputs/pr2753/stream_runner.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/stream_runner.py", + "sha256": "b255feaf6cc6e40413ae73fe302bf8f290bf4dd89f4128b23a91cc9860601801", + "git_blob": "6ba5df130bb4a0fcb06b6c630830ae3a6922921b" + }, + { + "path": "inputs/pr2753/trace.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/trace.py", + "sha256": "3a664224c558244f606b603cad816d75e94a17c9b2620a06a1530e893dfceac2", + "git_blob": "4b002201ce54cdecec9acf4e874b7f71cd75fe71" + }, + { + "path": "inputs/pr2753/verify.py", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/verify.py", + "sha256": "65126e788eeea10e830fc583cf4afe0bfc4d67495cbf8ac21de3507dbe624d56", + "git_blob": "96be8f5859a3f3799344d46dec1ee68170d96bfa" + }, + { + "path": "inputs/pr2769/NOTICE.md", + "commit": "d97f150d89e3f3eebdf625a468a445c9c0f1e6c9", + "source_path": "research/selected-bit-register-parking/NOTICE.md", + "sha256": "8640d1b52fd21e5b20e8109ce9c4957ca1e19a95e26a1c80d019a6e6f4d5f178", + "git_blob": "307c2da733f7f3a76e97c77e71072e811f40df02" + }, + { + "path": "inputs/pr2769/PROOF.md", + "commit": "d97f150d89e3f3eebdf625a468a445c9c0f1e6c9", + "source_path": "research/selected-bit-register-parking/PROOF.md", + "sha256": "fc9e7dcc5b385b6e508d6a6e9524b93059fa3e9fd5fcfb5eedbd85b3a54ba55e", + "git_blob": "7207ce7dec86694f01a3d9c049dcb87cc909e380" + }, + { + "path": "inputs/pr2769/README.md", + "commit": "d97f150d89e3f3eebdf625a468a445c9c0f1e6c9", + "source_path": "research/selected-bit-register-parking/README.md", + "sha256": "6550a466bfafff2ca11740e931ed9fce062eb488f23e74edff7e4bbae8282bb1", + "git_blob": "c96e0d6cec56a9a5579ae159456fc15767315bc3" + }, + { + "path": "inputs/pr2769/RESULT.json", + "commit": "d97f150d89e3f3eebdf625a468a445c9c0f1e6c9", + "source_path": "research/selected-bit-register-parking/RESULT.json", + "sha256": "4406fec9515bb4206c75b681f046b5441319cf1ed39a13b9b0134696b1c192a7", + "git_blob": "b2d1889d77019e06ac0326ac91b1322340cf3866" + }, + { + "path": "inputs/pr2769/SOURCES.json", + "commit": "d97f150d89e3f3eebdf625a468a445c9c0f1e6c9", + "source_path": "research/selected-bit-register-parking/SOURCES.json", + "sha256": "a6476b786632c2cbffabbe27eece790e378996c8b03eb17a01f1094f20fc4cdf", + "git_blob": "746393061c55f47412601e3d346e914762683e0c" + }, + { + "path": "inputs/pr2769/TASK.json", + "commit": "d97f150d89e3f3eebdf625a468a445c9c0f1e6c9", + "source_path": "research/selected-bit-register-parking/TASK.json", + "sha256": "964d3a4fbfb53fd58936840328ac4b770b324c9e78f722861b1db04663110626", + "git_blob": "216dc8f8bcb33fe32d0eaccdadb0fe0383d73848" + }, + { + "path": "inputs/pr2769/VERIFY.json", + "commit": "d97f150d89e3f3eebdf625a468a445c9c0f1e6c9", + "source_path": "research/selected-bit-register-parking/VERIFY.json", + "sha256": "f9e252e8ab255b49c3b18d4db76cc09ebd9fb61d599305e0aca8bf295189028d", + "git_blob": "6537be05745836106c753e1388ffc8b1bd23ce4c" + }, + { + "path": "inputs/pr2769/checks.py", + "commit": "d97f150d89e3f3eebdf625a468a445c9c0f1e6c9", + "source_path": "research/selected-bit-register-parking/checks.py", + "sha256": "98ffbd58881aa138b8dbae4d5722855ece2a5fdf7585e53978069ae9b064eb09", + "git_blob": "46630a7648b1c93530e9253872a19cce338929ff" + }, + { + "path": "inputs/pr2769/codec.py", + "commit": "d97f150d89e3f3eebdf625a468a445c9c0f1e6c9", + "source_path": "research/selected-bit-register-parking/codec.py", + "sha256": "5b9fda8136f7e60bece54e3fcc74f4ea0bec7145fa60e1ae3a4d252741b81fd3", + "git_blob": "9cd54d9417eb685dcd3f8293f01299ef9046ad31" + }, + { + "path": "inputs/pr2769/vendor/parking_machine.py", + "commit": "d97f150d89e3f3eebdf625a468a445c9c0f1e6c9", + "source_path": "research/selected-bit-register-parking/vendor/parking_machine.py", + "sha256": "68134779debfb795468a1aaecbc2b9d321d7d4e451313ce7dc8fa7092561df4c", + "git_blob": "cafd614a3b7bc87b019361fcdf890ed976f26d19" + }, + { + "path": "inputs/pr2769/vendor/pr2753_recursive_call.py", + "commit": "d97f150d89e3f3eebdf625a468a445c9c0f1e6c9", + "source_path": "research/selected-bit-register-parking/vendor/pr2753_recursive_call.py", + "sha256": "157deaa5972557893d43494a81151483bdc46373448ec677cb6a738c9b7e6f1e", + "git_blob": "6d33224145aa04f7fbaf7b6cda7c9c164311a402" + }, + { + "path": "inputs/pr2769/vendor/words.py", + "commit": "d97f150d89e3f3eebdf625a468a445c9c0f1e6c9", + "source_path": "research/selected-bit-register-parking/vendor/words.py", + "sha256": "5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9", + "git_blob": "8d4ba37e2778acb35b34e0719df2caf138fbeb50" + }, + { + "path": "inputs/pr2769/verify.py", + "commit": "d97f150d89e3f3eebdf625a468a445c9c0f1e6c9", + "source_path": "research/selected-bit-register-parking/verify.py", + "sha256": "37f9e51e6c038a2493b4550e3cf0bd52621b6c20e115f0886406fc9909a82120", + "git_blob": "6be4f94eda9c96f4e7265a294f63e39309dcb0c6" + } + ] +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/SOURCES.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/SOURCES.json new file mode 100644 index 0000000000..a27291a915 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/SOURCES.json @@ -0,0 +1,21 @@ +{ + "schema_version": 1, + "base_commit": "31452ecd309f32a97e2e84214719b21297a59018", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "889b95d936746df124872133ae1e7cc339adcb92", + "sha256": "7d185cd8c2af35988d638d969748ad7b670f902606444dbfc748e4402c340df6" + } + ], + "snapshot_manifest": "SNAPSHOTS.json", + "transitive_input_manifest": "inputs/pr2753/SOURCES.json", + "authentication": "loader.py authenticates all 97 snapshot files, then calls the pinned PR2753 verifier with the current repository root to authenticate its complete transitive inputs. For selected-result.json only, it accepts either the original exact record or the exact record at c719a5e0b3a6760a6fdf5d5af82d6ff2399329e5; the latter changes only the UTF-8 HPE verifier's proof-supplement hash. Both complete SHA256 and Git blob pins appear in loader.py. Frozen manifests remain unchanged." +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/TASK.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/TASK.json new file mode 100644 index 0000000000..28b8d5e1cb --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/TASK.json @@ -0,0 +1,74 @@ +{ + "schema_version": 1, + "task_id": "supplier-boundary-audit", + "priority_revision": 5, + "base_commit": "31452ecd309f32a97e2e84214719b21297a59018", + "selection_seed": "131b49a6b7aac7cc0c24c8bae642ffb8", + "original_card": { + "id": "supplier-boundary-audit", + "question": "Does one selected supplier obligation follow from its actual source-bound checks?", + "starting_points": ["certificates/selected-result.json", "research/owner-boundary-audit/README.md"], + "methods": [ + "Trace one hypothesis through the source, checker and complete caller.", + "Construct one semantically invalid but superficially well-formed fixture and test rejection." + ], + "acceptance_gate": "Pin the current sources and one obligation; the historical owner audit is an example, not evidence of a current bug.", + "first_step": { + "command": ["python3", "-B", "research/owner-boundary-audit/verify.py"], + "expected": "PASS_PR626_NEXT_TOUCH_BOUNDARY_AUDIT", + "inspect": "Identify why the timing-only omission passes but the full production controller still rejects it.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Choose one current supplier obligation and trace whether its acceptance depends on an independent check.", + "bottleneck_link": "Closing a current acceptance gap or proof obligation strengthens reliability even without changing kappa.", + "allowed_variations": ["Audit one named current condition using a new semantic counterexample."], + "scope_change_triggers": ["Reporting the historical timing-only diagnostic as a new current acceptance bug."], + "overlap_terms": ["owner boundary", "bridge omission", "hosting"] + }, + "scope_status": "changed", + "actual_scope": "Implement a finite-macrocode, fixed-role recursive controller for PR2753's p=1 caller; prove its source refinement and physical time/space bounds; execute complete reduced-source recursive and four-family payloads and the actual selected typed coefficient/call junction.", + "scope_change_reason": "The source-bound audit identifies physical caller lowering as an explicit remaining obligation. The user requests a central mathematical contribution; I address that obligation with a construction and scoped executable checks rather than an acceptance-counterexample audit.", + "bottleneck_link": "Replace depth-dependent logical frame tapes and parent generators with an executable fixed-role controller, charged parking and serialized return state while retaining the all-size caller's endpoint and baseline toll.", + "budget_minutes": 240, + "stop_rule": "Implement the complete finite instruction emitter and recursive dispatch, verify full small payloads and selected typed interfaces, and state the remaining selected GL64 materialization, stronger H2 and outer-transfer obligations.", + "outcome": "completed", + "evidence": "PROOF.md gives the whole-caller refinement and physical bounds. The generated controller passes complete 9216-bit recursive and 31104-bit four-family payloads, 96 independent private COPY oracles, both intermediate sweeps and full root workspace erasure. Selected checks exercise real adapter/child coefficients, descriptors and serialized returns. Constructor guards reject new Tape/Arena allocation during macros. Historical Frame and 1500-depth continuation controls remain registered. No complete selected GL64 payload or formal kernel claim.", + "author": "Jose Manuel (jmbarrancoml)", + "ai_assistance": "Substantial OpenAI Codex assistance, including mathematical and source-analysis subagents. No independent human or proof-assistant verification claimed.", + "discussion": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18958887", + "freshness": { + "canonical_main": "c719a5e0b3a6760a6fdf5d5af82d6ff2399329e5", + "upstream_checked_utc": "2026-10-16T02:44Z", + "overlap_checked_utc": "2026-10-16T02:49Z", + "coverage": "Submission supplement: all 582 open PRs, complete Discussion 2319 comment pagination, recent hub 1166 comments and targeted merged/open searches. Prior 23:55 full snapshot covered 707 open PRs, 1469 Discussion records and 1987 local records. No competing generated-controller completion or new PR2809 feedback appeared. The three source heads remain unchanged. Metadata coverage excludes arbitrary diffs and unpublished work. Guidance, priority 5 and selected parameters remain unchanged; one selected-record proof-supplement hash changed for an explicit UTF-8 verifier read, covered by exact compatibility pins in loader.py.", + "complementary_work": "Ross Richardson's count-tape grant audit at Discussion 2319 comment 18963164 excludes this generated controller. Petalas's logical outer wrapper PR2808 remains at b00b58e0db823643364f705b530faac254e7b05b; it retains physical and stronger H2 boundaries. PR2776/2829 provide ordered unit shear/carry components. These pending claims are not imported proof dependencies." + }, + "audit_correction": { + "author": "starship-s", + "url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18960884", + "audited_head": "38af8fb25f6adb5fa7da145cd9a03d41c39fd5d0", + "finding": "The deterministic continuation signature omitted parent identity and accepted 214 wrong-parent candidate boundaries, including 42 invocations. I reproduced the gap; it did not demonstrate a producer or proof defect.", + "correction": "Validate expected parent identity on both streams before signature projection; reject None and foreign parents for each boundary kind on both paths; guard the generated call's parent/source binding before capsule preparation.", + "timing_limit": "The auditor reported an old 300-second registered nested timeout and a separate 281.28-second pass on Linux/CPython3.12.13. I retain that limitation; the current generated-controller replay and its declared timeouts have no fresh Linux claim." + }, + "open_questions": [ + { + "question": "Independently audit the compiler and primitive specialization, or formalize their refinement.", + "why_it_matters": "The executable macrocontroller and source-level proof do not constitute a proof-assistant verification or a fully expanded selected transition table.", + "first_step": "Check the opcode/source correspondence, scratch lease-end annotations, five-word recursive cut and constructor-free parent restoration against the frozen source.", + "blocked_by": "Independent mathematical review and a formal refinement remain open." + }, + { + "question": "Supply the stronger H2 route and leaf primitives.", + "why_it_matters": "The physical lowering retains the p=1 baseline and does not establish an exponent improvement.", + "first_step": "Price the complete source-bound primitive, including generated coefficients, scans and restoration.", + "blocked_by": "The retained route and leaf routines still use O(wV) work." + }, + { + "question": "Compose the physical reserve with the outer stock wrapper.", + "why_it_matters": "Compatible stock capacity and a caller reserve do not establish the outer multiplication transfer.", + "first_step": "Coordinate with the outer-wrapper author and join its padding/restoration ledger to the physical caller contract.", + "blocked_by": "Separate outer-wrapper and supplier-transfer obligations." + } + ] +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/VALIDATION.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/VALIDATION.md new file mode 100644 index 0000000000..5b1a9221f3 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/VALIDATION.md @@ -0,0 +1,115 @@ +# Validation scope and controller replays + +I use Python 3.12.15 on macOS arm64. Each registered command authenticates the +97 frozen files and PR2753's transitive repository inputs before execution. +The verifier compares a SHA256 receipt over the complete canonical JSON result +of each suite, including event counts, restoration outcomes and operation meters. +I retain the expected receipts in RESULT.json. + +| Suite | Evidence | +| --- | --- | +| frame | Actual selected IDLE source 27825, widths 256→168→84, two repeated frozen-prefix records, exact projected extents, same Word objects/slots/bytes/heads after return. Controlled 23-bit bodies. | +| frame failures | Constructor failure after PARK and a deeper child failure; initiating error and parent state survive cleanup. | +| continuation | 36 good/fallback traces, 16362 compared events and 180 reconstructed return cursors. Width quotients 1,2,3,63,64,65,127,128,129. | +| role parking | 1500 nested frames, four permanent stream roles, three allocated index slots, 1501 protected output symbols. Exact composed table charge 1051500 steps. | +| controls | Nine complete-result transfers; short/out-of-range/overlong finite-control records and a dirty child role reject. | +| nested | Complete 9216-address GL2 payload, 12 shared-bank child calls/returns, 156 residuals, 12 root-stock and 144 child-stock checks. Independent address provenance oracle. | + +For the generated-controller implementation I add: + +| Suite | Evidence | +| --- | --- | +| macro_nested | Complete 9216-bit recursive GL2(F2) caller through 483/63 emitted instructions and 5859 macros; 12 serialized child calls/returns and 156 residuals. Same complete payload as the pinned logical replay. | +| macro_local | Complete 31104-bit, four-family GL2(F3) caller through 25415 instructions; 192 MOVE, 96 COPY, 384 IDLE, bridge and exchange. Independent projector checks for all 96 private COPY results before cancelling XORs, plus both intermediate sweeps. | +| macro_selected | Actual selected native rank-42 adapter/child coefficients 0/2, width 256→168, exact descriptor/gap, repeated prefixes, saved successor PC and parent restoration. Controlled 23-bit body and reduced role inventory. | +| ownership | Reject stale reads, pool exhaustion and new physical Tape/Arena construction; stale cleanup preserves a newer borrower. | +| primitive reuse | Complete 1458-bit nonzero remainder peel and 2430-bit two-digit modulus-9 swap, preserving their independent spectator coordinates. | + +I disable the source recursive Invocation constructor during both complete +controller replays. I also forbid physical Tape and Arena construction inside +the completed source blocks. The q2 run uses at most 20 scratch leases from 132 +fixed roles; the q3 run uses at most 25 from 137. Both erase the root's owned +markers/templates and leave no parent frames on the parking tape. + +The q2 fixture uses one family, cutoff 2 and root coordinate projectors; its +children execute all twelve conjugated GL2 good/fallback forms. The q3 fixture +uses n=2, w=1, weights (2,1), all 48 lows and external gap 2. I precompile its +finite coordinate-zero coefficient table and validate each runtime source/view +and zero high field. Production instead calls the retained selected coefficient +implementation, which the selected junction suite also exercises. + +I completed all seven registered commands with exit code 0 on 2026-10-16 under +Python 3.12.15/macOS arm64, after the parent-identity correction. The launcher +reported `PASS_REGISTERED_RESEARCH_PACKAGE`. The recursive controller took +104.67 seconds and the complete four-family controller took 321.60 seconds. +These timings describe the local simulator; I infer no asymptotic saving from +them. RESULT.json pins the complete JSON receipts, not wall-clock timings. + +I reproduced starship-s's [wrong-parent audit](https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18960884) +against the old checker: 86 ENTER, 42 INVOKE and 86 RETURN mutations retained its +positive digest. I corrected both comparison paths before signature projection. +The current controls reject None and foreign parents for each boundary kind on +both paths, and the generated selected gate rejects missing/foreign parents and +the wrong source code before capsule preparation. I keep object addresses out +of deterministic receipts. + +The auditor also reported a 300-second timeout in the old registered logical +nested suite, followed by a separate 281.28-second pass on Linux/CPython 3.12.13. +I preserve that portability limitation. The current controller delegates lease +loops to the same literal Tape methods to reduce simulator overhead; exact API +traffic controls cover that change. I have not run the current package on Linux. + +At the 02:44 UTC submission checkpoint I fetched canonical main +`c719a5e0b3a6760a6fdf5d5af82d6ff2399329e5`. The maintainer changed one entry +in selected-result.json after making the HPE Lean verifier read UTF-8 explicitly +in commit `2dfb25cd3c762a2b24ba732a28bb21e4d331687a`. I checked that exact +one-field difference; the selected parameters and our ten other runtime inputs +remain unchanged. The loader accepts either complete selected record by exact +SHA256 and Git blob, then passes an in-memory manifest to the frozen verifier. +I preserve the 97 exports and their original manifests byte for byte. Each +suite also rejects unrecognized parameter and proof-manifest mutations. +The first refreshed registered replay exceeded the 30-second continuation +limit; I then passed that suite alone in 48.08 seconds. An experimental budget +of 45/45/75/75/240/600/120 seconds passed both Frame and both continuation +commands, then timed out in macro_nested. I restored the original manifest +budget, under which I had completed the seven-suite run above. I claim no +complete registered pass after the submission refresh. The new authentication +and mutation controls passed normally and with assertions disabled; the +controller, primitives and payload oracles have no changes from the complete +pass at implementation commit `61f4d7ce`. These timeout observations concern +the local simulator and remain a reproducibility limitation. + +For the original proof/adapter submission I completed all five registered +commands with exit code 0 on 2026-10-15. The +launcher reported `PASS_REGISTERED_RESEARCH_PACKAGE`; the complete nested +payload took 150.31 seconds under Python 3.12.15. The frame and continuation +commands also passed with `-O`; their acceptance checks use explicit exceptions. +I ran the pinned GL2 oracle with ordinary Python. + +I then fast-forwarded the isolated branch to canonical main +`28f54620ff770dd051d5df35882bd84303d13c6f` and authenticated the complete source +inventory again. The registered runner, declared runtime inputs, guidance and +selected record had no changes. I did not repeat the unchanged payload suite +after that refresh. The source selection/provenance base remains +`31452ecd309f32a97e2e84214719b21297a59018`. + +The registered manifest now replaces the old logical `nested` replay with +`macro_nested`, which checks the same complete payload through the generated +controller and additionally enforces fixed allocation and root erasure. I retain +the historical suite, receipt and optional command: + +```sh +python3.12 -I -B research/selected-bit-physical-caller/verify.py --suite nested +``` + +The seven registered commands have a combined maximum of 1200 seconds. Frame and +continuation suites run normally and with `-O`; the complete generated fixtures +and selected/ownership controls use explicit `need` checks. I have not expanded +the whole selected controller to a microtransition table or executed its GL64 +payload. The source-level proof carries that parametric refinement obligation; +these reduced fixtures do not instantiate the selected stock multiple or prime. + +I ran the task card's historical owner-boundary positive control and the current +baseline binding check. Those checks establish orientation and source bindings; +they are not new mathematical results or the selected complete cold replay. +This package changes no selected construction file, parameter or certificate. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/VERIFY.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/VERIFY.json new file mode 100644 index 0000000000..6828097772 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/VERIFY.json @@ -0,0 +1,56 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "certificates/selected-result.json", + "research/community-hyperplane599-audit/pr589/bit589/v9/hosted/GLOBAL-TEMPLATE.json.gz", + "research/community-hyperplane599-audit/pr589/bit589/v9/nine/GEOMETRY.json", + "research/e8-bit-p111-tuned/tune/EXPECTED.json", + "research/e8-bit-p111-tuned/tune/bitE8mut-p111-tuned.json.gz", + "research/pr589-five-helper-hosting/PROOF.md", + "research/pr589-five-helper-hosting/verify.py", + "research/recursive-parking-boundary/README.md", + "research/selected-bit-local-ring-sweeps/PROOF.md", + "research/selected-bit-recursive-closure/PROOF.md", + "upstream/build/sections/02-streams.tex" + ], + "commands": [ + { + "argv": ["{python}", "-I", "-B", "{package}/verify.py", "--suite", "frame"], + "timeout_seconds": 60, + "checks": "Actual selected Frame with shared banks, exact parent restoration, constructor and deeper-child failure" + }, + { + "argv": ["{python}", "-I", "-B", "-O", "{package}/verify.py", "--suite", "frame"], + "timeout_seconds": 60, + "checks": "Same selected Frame obligations with Python assertions disabled" + }, + { + "argv": ["{python}", "-I", "-B", "{package}/verify.py", "--suite", "continuation"], + "timeout_seconds": 30, + "checks": "Finite residual cursor versus pinned events, 1500 nested stream/numerical checkpoints, protected output and exact parking-table invoice" + }, + { + "argv": ["{python}", "-I", "-B", "-O", "{package}/verify.py", "--suite", "continuation"], + "timeout_seconds": 30, + "checks": "Same continuation, canonical transfer and rejection controls with Python assertions disabled" + }, + { + "argv": ["{python}", "-I", "-B", "{package}/verify.py", "--suite", "macro_nested"], + "timeout_seconds": 300, + "checks": "Complete 9216-address GL2 recursive payload through generated fixed-role control; reject source recursive Invocations and new physical Tape/Arena allocation; erase root work" + }, + { + "argv": ["{python}", "-I", "-B", "{package}/verify.py", "--suite", "macro_local"], + "timeout_seconds": 600, + "checks": "Complete 31104-address four-family GL2(F3) caller, 96 independent private COPY endpoints, both intermediate sweeps, IDLE/bridge/exchange and root cleanup" + }, + { + "argv": ["{python}", "-I", "-B", "{package}/verify.py", "--suite", "macro_selected"], + "timeout_seconds": 120, + "checks": "Actual selected adapter/child coefficients and typed fixed-role CALL/RETURN; stale-lease and allocation rejection controls; nonzero peel and two-digit swap" + } + ] +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/continuation_checks.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/continuation_checks.py new file mode 100644 index 0000000000..f2be8aad16 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/continuation_checks.py @@ -0,0 +1,254 @@ +"""Independent event comparison and nested fixed-role checkpoint checks.""" +from hashlib import sha256 +from dataclasses import replace +from itertools import product +import json +from pathlib import Path +import sys + +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +import loader +codec = loader.activate() +from numeric import Geometry +from plan import Command, Plan, Reference +from records import Tape, append_word +from residual_blocks import Cursor, events +from role_parking import BODY, FiniteFields, RoleParking, transfer +from trace import execute +from words import Arena, BLANK, RIGHT, Unsigned, need + + +def snapshot(tape): + return bytes(tape.cells[1:]).rstrip(bytes([BLANK])) + + +def value(word): + if word is None: + return None + return bytes(word.cells[1:-1]) + + +def signature(event, page): + if event.kind in ("enter", "invoke", "return"): + need(event.parent_identity is page.parent_identity, + "trace boundary belongs to the expected parent") + request = event.request + return (event.kind, value(event.first), value(event.second), value(event.width), value(event.depth), + event.child_kind, event.field, event.reverse, event.source_code, event.half, + None if request is None else + (request.kind, value(request.coordinate), request.reference, request.reverse_adapter, + request.child_kind, request.field, request.reverse, request.negative_inverse, request.half)) + + +def collect(iterator, page): + try: + return [signature(event, page) for event in iterator] + finally: + iterator.close() + + +def cursor_checks(): + digest = sha256() + total = cases = checkpoints = 0 + plans = [Plan(64, rank, True, ( + Command("add", 1, 0, Reference("head", 0, 1, 0)), + Command("add", 65, 64, Reference("tail", 0, sign=-1)), + )) for rank in (1, 7, 42)] + plans.append(Plan(64, 1, False, ( + Command("child", 0, 1, Reference("pair")), + Command("add", 65, 0, Reference("shear", 0)), + Command("child", 64, 65, Reference("pair")), + Command("sign", 127, -1, Reference("fixed", sign=-1)), + Command("child", 0, 64, Reference("unit")), + ))) + for plan, width in product(plans, (1, 2, 3, 63, 64, 65, 127, 128, 129)): + arena = Arena(18, 128) + columns, depth = arena.input(width), arena.input(9) + page = Geometry(plan, arena, columns, depth, 23, object()) + retained = frozenset(arena.live) + tape = Tape() + try: + expected = collect(execute(page), page) + need(arena.live == retained, "source trace releases its numerical locals") + actual = [] + cursor = Cursor(plan) + while not cursor.done: + block = cursor.take() + # Serialize the return state BEFORE the block, then discard the + # cursor object. The resumed object receives no prior Python state. + cursor.save(tape) + del cursor + actual.extend(collect(events(page, block), page)) + cursor = Cursor.restore(plan, tape) + tape.clear() + need(arena.live == retained, "one block closes its encoded column and child geometry") + checkpoints += 1 + need(actual == expected, "same full event sequence after finite-cursor reconstruction") + digest.update(repr(actual).encode()) + total += len(actual) + cases += 1 + finally: + tape.clear() + page.close() + arena.free_many(columns, depth) + need(not arena.live, "closed cursor fixture bank") + return dict(cases=cases, compared_events=total, serialized_return_cursors=checkpoints, + digest=digest.hexdigest()) + + +def parent_controls(): + """Reject each wrong-parent boundary before deterministic projection. + + Credit starship-s's public audit of PR2809 head38af8fb, Discussion2319 + comment18960884. Test both independently supplied streams; object addresses + never enter the stable receipt. + """ + global execute, events + rejected = [] + for path in ("reference", "reconstructed"): + for kind in ("enter", "invoke", "return"): + for variant, identity in (("none", None), ("foreign", object())): + original = execute if path == "reference" else events + changed = [] + def wrong_parent(*args): + iterator = original(*args) + try: + for event in iterator: + if event.kind == kind: + changed.append(kind) + event = replace(event, parent_identity=identity) + yield event + finally: + iterator.close() + if path == "reference": + execute = wrong_parent + else: + events = wrong_parent + try: + try: + cursor_checks() + except ValueError as error: + need(str(error) == "trace boundary belongs to the expected parent" and changed, + "wrong-parent control reaches its intended boundary") + rejected.append(path + ":" + kind + ":" + variant) + else: + raise ValueError("wrong parent escaped the continuation checker") + finally: + if path == "reference": + execute = original + else: + events = original + return rejected + + +def nested_roles(depth=1500): + """One iterative control loop; encoded depth and no parent object stack.""" + residues, indices = Arena(3, 4), Arena(12, 8) + numerical = codec.BankParking(residues, indices) + roles = tuple(Tape() for _ in range(4)) + streams = RoleParking(numerical, roles) + schema = FiniteFields((2, indices.capacity)) + result = Tape() # Protected return port, outside the reusable role bank. + current, root = indices.input(depth), True + raw = Unsigned(indices) + entered = returned = 0 + while not current.zero(): + schema.write(roles[0], (int(root), current.slot)) + append_word(roles[1], current) + roles[1].rewind() + for symbol in BODY: + roles[2].append(symbol) + roles[2].rewind() + one = indices.literal(1) + following = raw.subtract_exact(current, one) + indices.free(one) + streams.park() + numerical.park((frozenset(), {following.slot})) + current, root = following, False + need(all(not snapshot(tape) and tape.head == 1 for tape in roles), + "same empty canonical role bank for the child") + entered += 1 + indices.free(current) + result.append(1) + while not root: + numerical.restore() + streams.restore() + root_label, slot = schema.read(roles[0]) + root = bool(root_label) + current = indices.words[slot] + need(slot in indices.live, "restored finite slot names a live parent word") + current.rewind() + while current.read() != RIGHT: + need(roles[1].read() == current.read(), "restored data role matches its numerical word") + roles[1].step(1) + current.step(1) + need(roles[1].read() == 5 and snapshot(roles[2]) == bytes(BODY) and + not snapshot(roles[3]), "nonempty and empty canonical roles restore in fixed order") + current.rewind() + indices.free(current) + for tape in roles: + tape.clear() + result.append(1) + returned += 1 + result.rewind() + need(entered == returned == depth and snapshot(result) == bytes([1]) * (depth + 1), + "protected child output survives all matched parent restorations") + need(not indices.live and not residues.live and numerical.machine.tapes[0] == {} and + numerical.machine.tapes[1] == {0: "^"}, "complete numerical, role and stack cleanup") + # Per level: four stream records (4*(4+13+12) bits), one numerical + # record (1+3+12 bits), and two matched frame pairs. + need(numerical.machine.counts["steps"] == depth * (5 * 132 + 7 * 5 + 3 * 2), + "exact composed PR2635 table invoice, including empty roles") + output = dict(frames=depth, maximum_index_slots=len(indices.words), stream_roles=len(roles), + protected_return_symbols=depth + 1, parking_charge=numerical.machine.counts, + codec_charge=numerical.codec_counts) + result.clear() + return output + + +def transfer_checks(): + for old, new in product((b"", bytes(BODY), bytes([0, 1]) * 32), repeat=2): + source, target = Tape(), Tape() + for symbol in new: + source.append(symbol) + for symbol in old: + target.append(symbol) + transfer(source, target) + need(not snapshot(source) and snapshot(target) == new and source.head == target.head == 1, + "owned result transfer replaces the complete canonical body") + rejected = 0 + for body in (b"", bytes([1, 1]), bytes([0, 1, 0])): + tape = Tape() + for symbol in body: + tape.append(symbol) + tape.rewind() + try: + FiniteFields((3,)).read(tape) + except ValueError: + rejected += 1 + need(rejected == 3, "reject short, out-of-range and overlong finite state") + numerical = codec.BankParking(Arena(3, 2), Arena(3, 2)) + role = Tape() + role.append(1) + role.rewind() + parking = RoleParking(numerical, (role,)) + parking.park() + role.append(0) + role.rewind() + try: + parking.restore() + except ValueError as error: + need(str(error) == "child clears canonical roles before return", "dirty-role failure cause") + else: + raise ValueError("dirty child role was overwritten on parent restoration") + role.clear() + parking.restore() + need(snapshot(role) == bytes([1]), "dirty-role rejection preserves the complete parked parent") + return dict(transfers=9, malformed_controls_rejected=rejected, dirty_role_rejected=True) + + +if __name__ == "__main__": + result = dict(cursor=cursor_checks(), roles=nested_roles(), transfer=transfer_checks(), parents=parent_controls()) + print(json.dumps(result, sort_keys=True, indent=2)) + print("PASS_FIXED_ROLE_CONTINUATIONS") diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/frame_checks.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/frame_checks.py new file mode 100644 index 0000000000..4b992ffcb0 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/frame_checks.py @@ -0,0 +1,232 @@ +"""Selected descriptor/Frame checks with explicit controlled child consumers.""" +from pathlib import Path +import sys +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import loader +loader.activate() + +from hashlib import sha256 +import json +from types import SimpleNamespace +from unittest.mock import patch +from cardinal_counts import Count +from catalogue import Catalogue, Specifications +from check_support import audit, bits, inspect_count, no_decode +from directory import Context, append_tape +from layout import Layout +import node +from numerical_frame import Session +from numeric import Geometry +import oracle +from packet import read_prefix +from records import Fields, Program, Tape +from recursive_call import child_call +from scheduler import complete +from trace import Event +from words import Arena, BLANK, Ring, need + + +def snapshot(arena): + return {slot: (arena.words[slot], bytes(arena.words[slot].cells)) for slot in arena.live} + + +def restored(arena, expected): + need(arena.live == set(expected), "same protected numerical roles after return") + for slot, (word, value) in expected.items(): + need(arena.words[slot] is word and bytes(word.cells) == value and word.head == 1, + "same parent Word alias, bits and head after return") + + +def selected_handoff(catalogue, mode="normal"): + specifications = Specifications(catalogue) + identifier = next(i for i, request in enumerate(catalogue.requests) + if request.kind == "IDLE" and request.base.rank == 42) + template = catalogue.template_for(identifier, False) + low = tuple(map(tuple, oracle.inverse(oracle.reduce_rational(template.preparation, 3), 3))) + spec = specifications.bind(identifier, False, low) + need(spec.good, "selected native rank-42 source class") + indices, arena = Arena(10), Arena(3) + modulus = arena.input(3) + ring = Ring(modulus) + context = Context(ring, catalogue.codes) + size, depth, fields = (indices.input(value) for value in (256, 0, 1)) + program = Program.fixture(indices, arena, 256, 2, (), catalogue.codes.bits) + root = node.SelectedNode(context, indices, program, size, depth, catalogue, specifications) + high = [[0]*64 for _ in range(64)] + field = Fields.fixture(indices, arena, [(spec.code, high)], catalogue.codes.bits) + directory = Tape() + for _ in range(2): + append_tape(field.tape, directory) + directory.rewind() + field.tape.clear() + counts = [Count.literal(value) for value in (2, 11, 2, 5, 3)] + prefixes, stock, before, gap, suffix = counts + source = Tape() + initial = bytes((index*7 ^ index//3) & 1 for index in range(23)) + for bit in initial: + source.append(bit) + source.rewind() + initial_program, initial_directory = bytes(program.tape.cells), bytes(directory.cells) + protected = snapshot(arena), snapshot(indices) + transitions, handoffs, returns, outputs = [], [], [], [] + labels = {} + observed_frames = [] + + def observe(kind, frame): + if kind == "enter": + level = inspect_count(frame.depth) + labels[id(frame)] = level + observed_frames.append(frame) + need(frame.arena is arena and frame.indices is indices, "same numerical banks in the real Frame") + transitions.append((kind, labels[id(frame)])) + + session = Session(arena, indices, observe=observe) + + def invoke(owner, current, old, count, field_count, unused, b, g, s): + f = inspect_count(owner.parent_size)//64 # Checker-only fixture construction. + columns = indices.input(f) + geometry = Geometry(SimpleNamespace(dimension=64), indices, columns, owner.depth, spec.code, owner.program) + leading = Count.product(unused, b) + layout = Layout(geometry, owner.parent_size, owner.context.ring, 3, leading, g, s) + operands = [indices.input(value) for value in (0, 86*f, 42*f, inspect_count(owner.depth)+1)] + event = Event("invoke", operands[0], operands[1], width=operands[2], depth=operands[3], + child_kind="good", source_code=spec.code, parent_identity=owner.program) + saved = snapshot(arena), snapshot(indices) + old_payload, old_fields = bytes(current.cells), bytes(old.cells) + try: + output = yield from child_call(owner, current, event, layout, old, count, field_count, unused, b) + restored(arena, saved[0]) + restored(indices, saved[1]) + need(bytes(current.cells) == old_payload and bytes(old.cells) == old_fields, + "real call preserves complete supplied source and frozen directory") + return output + finally: + layout.close() + geometry.close() + leading.close() + indices.free_many(columns, *operands) + + def controlled_run(self, current, old, count, unused, b, g, s, observe=None): + level, width = inspect_count(self.depth), inspect_count(self.parent_size) + need(self.indices is indices and self.context.arena is arena, "child executes in the shared banks") + need((level, width) in ((1, 168), (2, 84)), "actual selected generated child widths") + need(unused is stock and inspect_count(count) == 2 and inspect_count(unused) == 11, + "separate repeated-prefix count and unused stock") + need(tuple(inspect_count(x) for x in (b, g, s)) == (2, 5*3**(176 if level == 1 else 344), 3), + "actual ordered child gap survives both frames") + root_size, root_unit, root_depth = self.program.root() + need(tuple(inspect_count(x) for x in (root_size, root_unit, root_depth)) == (256, 2, level), + "child program retains original root and current generation") + indices.free_many(root_size, root_depth) + arena.free(root_unit) + old.rewind() + for _ in range(2): + saved = read_prefix(old, self.depth) + need(bits(saved) == bits(directory)[:len(bits(directory))//2]*level, + "ordered repeated physical prefixes remain independent") + saved.clear() + need(old.read() == BLANK, "exact old-prefix directory extent") + old.rewind() + handoffs.append({"depth": level, "width": width, "old_prefixes": 2, "fresh_rows": 11}) + if mode == "child_failure" and level == 2: + # A failed child leaves a valid local Word. Cleanup must remove it + # while the parent is still parked, then allow outer LIFO cleanup. + arena.input(2) + raise ValueError("injected deepest child failure") + if level == 1: + new_directory = Tape() + new_field = Fields.fixture(indices, arena, [(spec.code, high)], catalogue.codes.bits) + for _ in range(2): + prefix = read_prefix(old, self.depth) + append_tape(prefix, new_directory) + append_tape(new_field.tape, new_directory) + prefix.clear() + old.rewind() + new_directory.rewind() + new_field.tape.clear() + child_fields = indices.input(2) + extents = [Count(value) for value in (b, g, s)] + try: + transformed = yield from invoke(self.consumer, current, new_directory, count, + child_fields, unused, *extents) + output = Tape() + outputs.append(output) + transformed.rewind() + while transformed.read() in (0, 1): + output.append(1-transformed.read()) + transformed.step(1) + transformed.rewind() + transformed.clear() + output.rewind() + finally: + indices.free(child_fields) + new_directory.clear() + for value in extents: + value.close() + else: + output = Tape() + outputs.append(output) + for bit in reversed(bits(current)): + output.append(bit) + output.rewind() + returns.append(level) + return output + + original_node = node.SelectedNode + def constructor_failure(*args, **kwargs): + arena.input(2) + raise ValueError("injected child constructor failure") + error = None + output = None + try: + with patch.object(original_node, "run_generator", controlled_run), session.install(), no_decode(): + if mode == "constructor_failure": + with patch.object(node, "SelectedNode", constructor_failure): + output = complete(invoke(root.consumer, source, directory, prefixes, fields, stock, before, gap, suffix)) + else: + output = complete(invoke(root.consumer, source, directory, prefixes, fields, stock, before, gap, suffix)) + need(mode == "normal", "injected lifecycle failure must propagate") + need(bits(output) == bytes(1-bit for bit in reversed(initial)), "controlled nested endpoint") + need(returns == [2, 1] and transitions == [("enter", 1), ("enter", 2), ("return", 2), ("return", 1)], + "actual LIFO shared-frame return") + except ValueError as failure: + need(mode != "normal", "normal shared Frame failed: " + str(failure)) + error = str(failure) + expected = "injected child constructor failure" if mode == "constructor_failure" else "injected deepest child failure" + need(error == expected, "cleanup preserves the initiating failure") + finally: + restored(arena, protected[0]) + restored(indices, protected[1]) + need(bytes(source.cells)[1:] == initial and bytes(program.tape.cells) == initial_program and + bytes(directory.cells) == initial_directory, "root borrowed inputs preserved") + need(session.codec.machine.tapes == [{}, {0: "^"}] and session.codec.machine.heads == [0, 1], + "shared numerical parking stack is empty after the complete source call") + need(all(frame.closed for frame in observed_frames), "completed or aborted frames close") + for item in outputs: + item.clear() + if output is not None: + output.clear() + source.clear() + directory.clear() + program.tape.clear() + for value in counts: + value.close() + indices.free_many(size, depth, fields) + context.close() + ring.close() + arena.free(modulus) + audit(indices) + audit(arena) + return {"mode": mode, "source_request": identifier, "handoffs": handoffs, + "transitions": transitions, "return_order": returns, "failure": error, + "scope": "Actual selected descriptors, constructors and child_call; controlled 23-bit child bodies, not selected GL64 payload", + "table_charge": dict(session.codec.machine.counts)} + + +def run(): + catalogue = Catalogue(3) + return [selected_handoff(catalogue, mode) for mode in ("normal", "constructor_failure", "child_failure")] + + +if __name__ == "__main__": + print(json.dumps(run(), indent=2)) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/EVIDENCE.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/EVIDENCE.json new file mode 100644 index 0000000000..c2c347abc2 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/EVIDENCE.json @@ -0,0 +1,46 @@ +{ + "schema_version": 1, + "purpose": "Byte-exact predecessor proof evidence used by PROOF.md; no predecessor scientific result is claimed as new.", + "files": [ + { + "path": "evidence/pr2731-README.md", + "source_pr": "https://github.com/CrocSwap/integer-mult-bounds/pull/2731", + "author": "starship-s", + "commit": "46c0c3554608a1096816ad668c755d3b5b7a8c0b", + "source_path": "research/selected-residual-live-volume/README.md", + "git_blob": "ac5b826f9c34e1faadc5d5a02d5d260823112078", + "sha256": "19683df4394de299cbd7e1cce39bf9434ad260b1a37006587cf9aed84c9c0a03", + "usage": "residual and retained-role lifetime proof" + }, + { + "path": "evidence/pr2708-README.md", + "source_pr": "https://github.com/CrocSwap/integer-mult-bounds/pull/2708", + "author": "Nick Petalas (petalas)", + "commit": "2982489cc00a17bd1c7ee1e206e975eda9bcb64d", + "source_path": "research/selected-route-live-volume/README.md", + "git_blob": "79b8742f32b4ffb991f91ddd2d3c6be693084e6d", + "sha256": "5906f6b7b2c8eea90e441476c4cbd60fe2ef981b690c63357bcfe67e3104aeef", + "usage": "route and caller-phase lifetime proof" + }, + { + "path": "evidence/pr2688-PROOF.md", + "source_pr": "https://github.com/CrocSwap/integer-mult-bounds/pull/2688", + "author": "ywz65", + "commit": "1b9e1ed8793ffdde3c4b115641f0e644a9289923", + "source_path": "research/selected-directory-storage-reserve/PROOF.md", + "git_blob": "1395e1941863e40ff6d62dd91c41de2cb56edae9", + "sha256": "fa9bec0952468e4acb760a88d45d5be216325650e1a4080cf590e07b90c9f533", + "usage": "canonical-directory storage theorem" + }, + { + "path": "evidence/pr2688-NOTICE.md", + "source_pr": "https://github.com/CrocSwap/integer-mult-bounds/pull/2688", + "author": "ywz65", + "commit": "1b9e1ed8793ffdde3c4b115641f0e644a9289923", + "source_path": "research/selected-directory-storage-reserve/NOTICE.md", + "git_blob": "f2b49cdef83a4a685fad32c01fba93e12cfcb5a8", + "sha256": "c899fccf7bd32397f0ddd85e4af35a166cefb3e3ae3407ec40edc3ab2051b617", + "usage": "original source attribution" + } + ] +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/PREDECESSOR.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/PREDECESSOR.json new file mode 100644 index 0000000000..56d76c357b --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/PREDECESSOR.json @@ -0,0 +1,208 @@ +{ + "pr": "https://github.com/CrocSwap/integer-mult-bounds/pull/2697", + "head": "a53fdf4bcbe33c6732f0bec1badc8c023380f9d1", + "author": "Jose Manuel (jmbarrancoml)", + "path": "research/selected-bit-node", + "files": { + "NOTICE.md": { + "sha256": "c446b32b8a621844fb2fbe654810c8122035bdd43fed2132f1137d98cb6f9943", + "git_blob": "ef9f81510db86eaf2f0a7191d85e92a6db30ddc0" + }, + "PROOF.md": { + "sha256": "88754d57bae35a2089d9de221ff32ba802b7a56b810f96271f3ea36985edfb14", + "git_blob": "a4746d1786f41e45a36fdedf37966b80fbab3562" + }, + "README.md": { + "sha256": "15631eb826b2d8d54fbee18fb6f70ee035e172d524c2a209b6c467c3f0204f64", + "git_blob": "988ff622029aff49d7e99deb2468684d904bc852" + }, + "RESULT.json": { + "sha256": "0d94c5e9150f3fbd603526c67ea33168d3ba45e158aaf722e848bf5c316a37a8", + "git_blob": "7b7dfe0eab22a7b511483f268b97a7c707fd8b90" + }, + "SOURCES.json": { + "sha256": "1b02a5c607a5967948988c3beaf37d9975d650ad501a99fcf74c135dc1f05fdd", + "git_blob": "4fef1a4d6c2d5e2620d3506d6032f9226870ed39" + }, + "TASK.json": { + "sha256": "a4cd54d4b09ad12a90a5feeb39a127f0f0d5a2a04f9f88554c5fc3ee0cfe77f4", + "git_blob": "eb2ce7cc00df816daf566f101d56a0330852c1d9" + }, + "VERIFY.json": { + "sha256": "e1dd0ee5f267ffa515bb345054ff8637cfedb0079b0d2da29b90b7848264926e", + "git_blob": "69c7ad75abe494be386f73a5d51359b9053cd9be" + }, + "cardinal_counts.py": { + "sha256": "59ddeac102a0cc51fa49b15aae6aeb68cd68ed217fa974ce916372a177d2ec8f", + "git_blob": "6a14feac45094ae9156e8c2c982d6727544f180e" + }, + "catalogue.py": { + "sha256": "83ea88f82d4a83c5f889774bfe3519b7ebaa24b6a0e2a969dafff012107a89bf", + "git_blob": "0efc0575a7623ac41c094d2e8772beda5a9fdc29" + }, + "check_headers.py": { + "sha256": "a41dab0c487c341eb32b34a03af74454e15e9e61e7386a1ca426d83f3b68b1ca", + "git_blob": "1c372b19e19b838a89c0e64daeda15ec6b49f079" + }, + "check_layout.py": { + "sha256": "8f776a21dc0e31f9738d822cfda38db92f1e3672afb880d4246ec5e084a50a41", + "git_blob": "174d843716a684145f934cb55a612bca85aad725" + }, + "check_runtime.py": { + "sha256": "5357e4ff255f17c4209aaf71a3413a4148475f11180c4f829e8f0ebacd2877cb", + "git_blob": "5647693b3a5c1555b65e281c6609f98b92d45542" + }, + "check_sources.py": { + "sha256": "6463c2724e04a313181b78e90a17cd62ee42465754902cca3e9a65c6140a15a1", + "git_blob": "9219cdf863d9f060d6e38a4f2f4760fd227af003" + }, + "consumer.py": { + "sha256": "b28ec97b0873ff2be25aff4bdde268247ffcec0d21279d0ada196de19a0bdc66", + "git_blob": "24b53521fce94d3349072cf47d70e62195f4d541" + }, + "control.py": { + "sha256": "d3a93e54bb7d333b73917586407d11674d38b5c3fda4fbdc436fb5293ae7786a", + "git_blob": "4f6ac09bffab43dbccc470bd0bde2ffbe969a8b2" + }, + "control_checks.py": { + "sha256": "5ea6ded8c2508fbb00d93655affdfe7907ffb60916389e0736249c003a7a5148", + "git_blob": "712cfddc4caaad9e788d97b0e1e3f623172c43ed" + }, + "driver.py": { + "sha256": "ee9e42fe95ab28fdd5e927c2d46fd480305aaad610eb2ca7ae514a5d22d9f0ac", + "git_blob": "0bdee4c9e348259b470a636a98e7657770f97fae" + }, + "fresh_rows.py": { + "sha256": "e4ae08fbd658add630eb7754ebe0cbcb42c6f39cf4128f9cb92e27fcf5213a7d", + "git_blob": "aa3a327604308d3a5c7a27b65f5e631d430ab093" + }, + "layout.py": { + "sha256": "7534b0166805f2ae8d11495c811d2bd272cea89c89b6bb5251fd411c89245a20", + "git_blob": "267d5ab98cd013ee82ba75e6d41609f1778af25f" + }, + "model.py": { + "sha256": "c937ae8e46162f88fc1cd7646d3b22c99273029ad0f0e3131f46ddec230676cb", + "git_blob": "9fb82fa57d29cdf8402f91534dffed8f586ced6c" + }, + "node.py": { + "sha256": "b88fc9ac0b22d939311ff4f7aff788e8c87a64fd5e866498e59bd27940ee3f28", + "git_blob": "13badda6f059da2132cbe325c071307e5191baa3" + }, + "packet_engine.py": { + "sha256": "ce7f132a6a69c802406f07c4a2119ef921e8978520ff58d5eeaeedb982c257f2", + "git_blob": "27a0dbf82e78252beede56ff86f5933c93eb55c1" + }, + "peel.py": { + "sha256": "3de018e68601566c364c7568b110f60c1bf34941b846cdffb94401bb799f85e3", + "git_blob": "2ae1769a9726ab738d3981891d0b76beccac2d99" + }, + "topology.py": { + "sha256": "384d456ddba76de137a63b50019d5bba2e9f6daa4177c91643e0565d4cf1d44b", + "git_blob": "39a2916c207d04be5efc44750d8606f5da0c2990" + }, + "vendor/binding.py": { + "sha256": "20169a8af6ed2b34069fd353a2bc1c42335ab686c58de8479baef33dd3fb493b", + "git_blob": "21a5a21220a18ab62a19ac403a9944bc3a8665c8" + }, + "vendor/bitstream.py": { + "sha256": "f78bac9641007dbd8824984edcac057274fe016ce78bd9cb512d0c0913274783", + "git_blob": "4d1fd4abb0f2aabe833e5cbc9efb51039739e7ca" + }, + "vendor/cardinality.py": { + "sha256": "505d5e560c5a507e6184edcc19a87cf1fed243eb34a5cb21fbe1e4fe017e7f22", + "git_blob": "b8ba857e32c5903408e1e61ff916300848b4a208" + }, + "vendor/check_support.py": { + "sha256": "d9977e87ddc5acdb836b8e4a4e3942da17a05b04ce67c04547d17b986b518964", + "git_blob": "e1f961df9fa3a441fc5b600d1288a8d038eca51e" + }, + "vendor/children.py": { + "sha256": "a78866939631214c1d1659203b2b5fc062e3c6255e9f11f975c310046b010bd6", + "git_blob": "ce4935f838516e2b08d13bec767cb803786fbc6b" + }, + "vendor/controller.py": { + "sha256": "fa09146991f6c04e6f4b6eb9bf0c8e103e70e90a0e402ff3d69814e6aac8ff8c", + "git_blob": "c631a9e77fbcccf0e8f448adc22978728aed7b60" + }, + "vendor/counts.py": { + "sha256": "00b476dbda0e8cc99886bf794439e1cb9e775f435f599a3557e99321fe084069", + "git_blob": "81b48940ce222290a40d4fb349ce827f4788469d" + }, + "vendor/directory.py": { + "sha256": "4270e370b2bfe38ef73aadcd97d1b3496b56bd582115d74331eb9e5ceb90bec7", + "git_blob": "c74cacf5ce809c0561d374f137a52df0992b4226" + }, + "vendor/episode.py": { + "sha256": "38f79cb2a370548471063952d5f7c74bd795a2a8496fdcf3ce0996d79e3adaff", + "git_blob": "30d11ff4f333813855d36da3eb5a1ab0e154bafe" + }, + "vendor/forms.py": { + "sha256": "1fdf9d31b7eb107c396e33f94dad61c9d3f2c709cae61178268a44ca80dbc0b4", + "git_blob": "6667c0b772a63f0059c7caffec63e0d919a92398" + }, + "vendor/low_codes.py": { + "sha256": "f657e17f6088c840e3f7783e662257630f6d2c1e71c217721ffbca4d6ac93e87", + "git_blob": "737edfc4a10f4b7b3b97a7cef4b40864efd806e6" + }, + "vendor/matrices.py": { + "sha256": "00b687434039b54529ee092e34f9435cfcd66e0816eb3bd2a6688c73f4e01459", + "git_blob": "5d497353efbb9eeaaf4facd96ab40ffb0f3aa20d" + }, + "vendor/numeric.py": { + "sha256": "7327b05c4ec3e0f6d9c352cc7de85bfd4ebe940482553e77c59a773a8c09c514", + "git_blob": "6d4ebca8398008375b8f4762d1a9f1514e8c2611" + }, + "vendor/oracle.py": { + "sha256": "7bd18089e32ce48085b5e3a75159f6a82cdb2649ec682c53db05e399d97aef67", + "git_blob": "244f131466698a3ace10b657242fe1f65c07fd1f" + }, + "vendor/packet.py": { + "sha256": "970e7fe0719e3dfe122b248941e6f21cd90d7dd62089fa6acbd0e5412ce083a5", + "git_blob": "ebc9b616514412b80c56d523776e6ba5d6766453" + }, + "vendor/plan.py": { + "sha256": "d9c8dc93762db4d3a449814aa51e2211460648694469854d89cb48cb04188cf3", + "git_blob": "48255d5454308c07635fae4e7eb4873b0bd2a4f8" + }, + "vendor/records.py": { + "sha256": "0c9c4b23e998597fb877bb1a29da69ac869b68262abe635b162b4dba9c69b372", + "git_blob": "4f00467a0ff580954ad2fd0c7380240c753ddef3" + }, + "vendor/residual.py": { + "sha256": "8fd24747cae498dfb2ba333e7f8a68d7315ae4c2d7530d8ca145aab95ede21df", + "git_blob": "3d070d2539a529f3b14ecb086a92a3db056229fe" + }, + "vendor/routes.py": { + "sha256": "ed7dc3679451696ab1dd841146b215c9515a3eec5e4ff3763f33c315f1696ada", + "git_blob": "35531201dc349a811dfabc6f1f6e64697d665194" + }, + "vendor/selection.py": { + "sha256": "bc8e371fb1fa0b41fb05ef0b34d0f4c317b2396f9833d91f44f95c2b54b4052b", + "git_blob": "2c28f1aaec104a75c4e6c170b3e6a60300ee6700" + }, + "vendor/sources.py": { + "sha256": "f102edc7816d742bd89db8097254c19b843d0ef5cf6758ad42e93bcc0b214c62", + "git_blob": "16d5e7e6a28018f1e2d76d61efe2d54f6a6941d4" + }, + "vendor/stream.py": { + "sha256": "c7dc7da5b00f27016982ada4c0416f8328568b00df16d97012f33d4b372d79b5", + "git_blob": "5e5a4bb0f98971447043e25d4dd6991bfc070389" + }, + "vendor/stream_runner.py": { + "sha256": "751c5023ca0e477369e448583961ace6a76db2723bb6c26f81203def539f1249", + "git_blob": "efff281d4c4be5c1378e31404fbcc634fe4ade59" + }, + "vendor/trace.py": { + "sha256": "c71ba11d793dde2ac6e4cdcf468482872975c34589bf1167f2a460cb8a74e984", + "git_blob": "bb845a90f5bcf006e683e581e385936208f6a1f4" + }, + "vendor/words.py": { + "sha256": "5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9", + "git_blob": "8d4ba37e2778acb35b34e0719df2caf138fbeb50" + }, + "verify.py": { + "sha256": "cd83797d1f420f7e5de61c1a693110b4ee0c80bac0adae4699599046b7f76f8a", + "git_blob": "121acc1ff15ec85a8011e96eda2eb587608413b9" + } + } +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/PROOF.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/PROOF.md new file mode 100644 index 0000000000..1a08e57eac --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/PROOF.md @@ -0,0 +1,320 @@ +# Executable all-size selected BIT caller and complete logical reserve + +This package extends the selected first-range caller of [PR2697](https://github.com/CrocSwap/integer-mult-bounds/pull/2697), by Jose Manuel (`jmbarrancoml`), to every internal width n>=64. It implements the previously missing whole-packet recursive call and return, with an independent fresh-row coordinate, exact projected spectators and separate numerical frame banks. It also replaces the inherited digit-pass address sign by a linear-traffic sign, which is necessary when the fallback normal form is repeated over arbitrarily many columns. + +The result is a scoped construction and source-level proof. It supports the executable baseline p=1 and a complete logical live-symbol reserve under the stated root coupling. It does **not** establish the selected native H2 saving `a=384599/10^10`, a fixed-physical-tape compiler, the outer borrowing wrapper, the complex supplier, or a complete multiplication theorem. The selected frontier is unchanged. + +`predecessor/` preserves the PR2697 package at exact head `a53fdf4bcbe33c6732f0bec1badc8c023380f9d1`; [PREDECESSOR.json](PREDECESSOR.json) gives its author and byte pins. The selected finite operators, normal forms, chronological guards and generated-weight grammar remain attributed to that package and its [source notice](predecessor/NOTICE.md). The compatible stock comes from [PR2234](https://github.com/CrocSwap/integer-mult-bounds/pull/2234), `d047ef86fbc5b1614d3d8e2b8d3441413beab73f`, retained in [selected-bit-local-ring-sweeps](../selected-bit-local-ring-sweeps/PROOF.md). The earlier [written recursive closure](../selected-bit-recursive-closure/PROOF.md) supplies the paid profile and moment estimates; the present contribution implements and audits the missing all-size caller boundary. + +## 1. Complete input and endpoint contract + +Fix an odd prime q, precision w>=1, atom radix A=q^w, m=64, W=28416, P=28425, + + N = |GL_64(F_q)|, H = q^(4096(w-1)), + K = lcm(W,P) N H = 269241600 N H, + D(n) = 0 for n<64, + D(n) = 1+D(42 floor(n/64)) for n>=64. + +At a node of width n>=64, use fresh-row count R=t K^D(n), t>=1. The complete input order is + + [C physical frozen-prefix ordinals][R fresh rows] + [B][head A^n][G][tail A^n][S]. + +C,B,G,S are arbitrary positive complete extents. Frozen prefixes may repeat and carry arbitrary correlations in their Boolean payload; equal field values do not identify their physical ordinals. The incoming diagonal unit a_i is generated by the source-bound encoded program. It reads the frozen prefix and encoded coordinate i only. It cannot inspect fresh family/low/high/unused-row coordinates, body addresses or spectator values. + +The required address endpoint on each frozen prefix is + + head_i' = a_i tail_(n-1-i), + tail_(n-1-i)' = a_i^(-1) head_i, 0<=i=1 and delta=n-64f, 0<=delta<64. `peel.events` handles the delta pairs with original head coordinates 64f+i and absolute tail coordinates 2n-1-(64f+i), using the original frozen incoming coefficient at 64f+i. It appends no fictitious current field. The remaining logical core has 128f atoms and embedding + + phi(p)=p for p<64f, + phi(p)=p+2delta for p>=64f. + +Its middle spectator is the ordered product `[peeled head A^delta][G][peeled tail A^delta]`. This mixed-radix regrouping is injective, so preserving it restores each original coordinate rather than only its product size. + +For a child let a=phi(first), b=phi(second), c=width. The runtime checks c>0, a+c<=b, b+c<=2n, that each complete chunk lies in one original bank, and that mapping each final atom agrees with a+c-1 and b+c-1. These last checks rule out a chunk crossing the embedding discontinuity. + +The complete selected packet can then be read, without moving any payload, as + + [C H frozen prefixes][U][B'][A^c child head][G'][A^c child tail][S'], + +where + + B' = B*A^a * (G if a>=n else 1), + G' = A^(b-a-c) * (G if a0 | suffix | +| tail half-reset on k>=64 | kf | (k+1)f-d | d=floor(f/2)>0 | before | + +A half-reset retains the central A^(f-2d) spectator, including the middle atom for odd f. For f=1 it is omitted. In the good case B'=B, G'=G*A^((128-2r)f+2delta), S'=S. Every selected child satisfies the bank and contiguity checks. + +## 3. Program extension, ordinal preservation and completed return + +For c<64, `trace.child` keeps the completed eight-primitive weighted leaf. For c>=64 it yields ENTER, INVOKE, RETURN with the same encoded boundary. `packet_engine` checks the parent identity, source code, child kind, field, orientation, half flag, positions, width and depth, and permits exactly one INVOKE between matched boundaries. Primitive events are forbidden inside an unresolved internal child. + +On INVOKE, `recursive_call.child_call` constructs one source-bound child Request and calls the inherited `children.extend` once. It appends the parent source/rank/field/orientation/half and exact parent/child sizes. `Callback.step` verifies the exact rf, f or floor(f/2) formula and strict contraction. The new descriptor depends on the unchanged parent program and fixed low-class branch, never on a selected numerical high field. Reading the first directory prefix validates the encoded context; it does not choose the branch or replace the complete directory by that representative. + +The child receives the full current directory of C H physical prefixes, with h+1 frozen fields, and the whole selected packet. The call lies outside the prefix loop. No high-prefix value or repeated frozen prefix is deduplicated. The child's own `produce` appends its new field after those h+1 ancestors. Its incoming weight grammar has exactly the old fields and cannot read that new field. Ancestor field ordinals and their original source codes remain authenticated by the inherited callback. + +`Frame` creates separate residue/index arenas, copies encoded words and program symbols without runtime integer decoding, and constructs the child's `SelectedNode`. The scheduler uses an explicit generator stack, so Python call-stack depth does not impose an upper width limit. A single shared fixed-capacity arena would not suffice for arbitrarily many suspended parents. + +`node.selected_topology` retains one source topology on the shared fixed-q +Catalogue. The inherited recipe/call caches are therefore bounded by source +labels and low classes, rather than by the number of completed child invocations. +This sharing is necessary for the one-time compilation allowance F_q below. + +After the child returns an owned output, the engine clears its previous owned current packet and resumes the exact saved parent trace. The input source remains preserved. Family scatter always merges into the latest family state, including earlier returned roles. Private COPY retains the copied source for its literal lifetime; ERASE still checks the inherited chronological equality guard. The generated child preserves every spectator, including unused U, so it cannot invalidate those guards. + +## 4. Termination, compatible stock and endpoint induction + +Every child has positive c<=42f<=21n/32=2^80 and the root-coupled precision/history domain stated in section 6. The endpoint construction itself applies to odd source-admissible primes, but the displayed epsilon and imported moment gaps are not asserted for all odd primes. + +The inherited sign uses w digit passes. A fallback has signs in every column, so retaining that implementation would introduce an f*w local factor. `linear_sign.sign_address` repairs this concrete all-size issue. On `[before][A][suffix]`, copy the zero slice; move by charged unit head steps to the last nonzero suffix slice; copy each nonzero slice forward while visiting their starts in reverse order; then advance to the next outer row. This implements x->-x modulo A, preserves the source and resets both heads. Total source-head movements, including rewind, are at most 6V. Counter initialization and decrement remain explicit and have the inherited amortized linear scan charge. Thus all f signs cost O(fV). + +Adapter ADDs have O_q(V) complete-fibre cost after their numeric preparation is charged to the associated complete fibres. There are O_q(f) adapters. Peel has at most 63 pairs and costs O_q(wV). Owner routes and ordinary leaf atom swaps still use O_q(wV) implementations. The current code therefore has the **p=1 baseline**, not a general p=1-a<1 primitive contract. + +For completeness, the preparation absorption is an asymptotic source argument, not a measured finite invoice. Fixed-size ring arithmetic is polynomial in L,I,h. A pair expression branches at most twice per ancestor, giving at most 2^h times a fixed polynomial. Under the root coupling 2^(h+1)<=8e² and e<=w^(10000/17), this is a fixed polynomial in w. Its ratio to the complete target-fibre factor q^w has a finite supremum over w>=1. Old/current directory and frame setup costs have the same type of polynomial absorption. Spectator count initialization is charged to its scan; arbitrary spectator sizes stay in canonical count tapes. For independently chosen widths/history, retain those preparation terms explicitly. + +The source-bound paid profile is + + (H_1,H_2,H_3,H_4,H_5,H_6,H_7,H_42) + = (381024, 400416, 22752, 26880, 29376, 17376, 26784, 288). + +Here T(n,w) denotes a uniform normalized upper bound over admissible descendant +contexts with the original root e and its coupling retained. Atom precision w +is fixed for the entire recursion; it is not recomputed from a child's n. +The time unit is charged logical Tape reads, writes and unit head movements, +with the stated preparation absorption. It is neither Python wall-clock time +nor a bound for the still-unimplemented fixed-physical-tape lowering. + +A bad class has at most 3*(127+254+16256)=49911 main/half child calls. This is below the inherited 32*64² allowance. Their widths are at most f. For each paid request, the retained nonzero-minor argument bounds the bad fraction by 2*64^3/q: the minor union bound is conditioned on GL64, whose density is greater than one half. At the lower allowed boundary, 2*64^3*10^16 < 2^80, so the same epsilon=10^-16 is valid uniformly for every allowed prime. There is no union over all request labels. With F=32*64²*sum H_r=118606528512, the normalized stopped recurrence is + + T(n,w) <= Cw (0=64). + +C depends on fixed q and the pinned source, not original e, spectator values or a suspended parent's contents. The retained moment receipts give + + mu_1 = 2874298095721977/2890625000000000 <199/200, + mu_(1-c0) <9999/10000, c0=17/10000, + mu_t = [sum H_r(r/64)^t + epsilon F(1/64)^t]/W. + +Induction using the monotone proposed bound, not an assumed monotonicity of measured runtime, gives + + T(n,w) <=200Cn +10000Cn^(1-c0)w. + +This imports the existing moment evidence; it is not a new moment certificate. It supplies the baseline recurrence of the actual completed caller. Obtaining the selected H2 saving requires stronger implementations of every named route/leaf primitive, and their full numerical billing. Replacing only a leaf callback is insufficient. + +## 6. Complete reserve domain and statement + +The byte-exact proof exports are authenticated in [EVIDENCE.json](EVIDENCE.json), with author and source-path attribution in [evidence/NOTICE.md](evidence/NOTICE.md). The local storage inputs are [PR2731](https://github.com/CrocSwap/integer-mult-bounds/pull/2731), the [residual lifetime proof](evidence/pr2731-README.md) giving 3v+3r at `46c0c3554608a1096816ad668c755d3b5b7a8c0b`; [PR2708](https://github.com/CrocSwap/integer-mult-bounds/pull/2708), the [routing/key lifetime proof](evidence/pr2708-README.md) at `2982489cc00a17bd1c7ee1e206e975eda9bcb64d`; and [PR2688](https://github.com/CrocSwap/integer-mult-bounds/pull/2688), the [directory storage proof](evidence/pr2688-PROOF.md) at `1b9e1ed8793ffdde3c4b115641f0e644a9289923`. These sharp component results are predecessor work. The new reserve combines them with the all-size code's actual suspended-parent, numerical and control lifetimes. + +The space unit below is one live logical tape symbol, including LEFT/RIGHT/record delimiters. Cleared storage is reusable. This is not a Python heap bound. Observers that retain histories and external meter histories are checker instrumentation and are excluded. + +Put W=28416, N=|GL_64(F_q)|, H=q^(4096(w-1)), A=q^w, and + + K = 269241600 N H = lcm(28416, 28425) N H. + +Use distinct notation A for the atom radix; the constant 269241600 is the row-stock multiplier, not the atom radix. Let D(n)=0 for n<64 and D(n)=1+D(42 floor(n/64)) otherwise. A root with fresh-row count t K^D(e), t a positive integer, has sufficient stock on every branch. The algorithm invokes an internal child only for its actual width at least 64; smaller children use the completed eight-primitive leaf. + +Assume q is one fixed prime at least 2^80, the source-bound selected catalogue has 28278 requests, the residue and root-index words have their canonical minimal widths, and the generated history satisfies + + w = ceil(e^(17/10000)), n <= e, + 2^(h+1) <= 8e², 17(h+1) <= 20051w. + +The last inequality may instead be checked directly for the supplied initial history and every descendant. For a history generated from the original root, the global chronological level is never reset at a unit child and h+1<=D(e)<=2 log2(e) at every internal node. The inequality follows from max_(x>=1) log2(x)/x^(17/10000)=1/((17/10000)*exp(1)*log(2)); the rounded constant 20051/17 is conservative. Arbitrarily padded residue/index contexts or an unrelated large supplied history are outside this simplified constant bound; the explicit ledger below still charges their actual widths and lengths. + +For this reserve statement, supply root residue and index arenas of capacity 2^24, matching the child banks constructed by `Frame`. For the runtime inventory described below, all simultaneously live logical symbols, including borrowed input and suspended parents, are less than + + 11 V_root + F_q. + +F_q is the one-time finite source/compiler table storage for the fixed q and selected catalogue. It is independent of e,w,h and every runtime high residue. It can instead be part of the fixed machine description. If charged as work storage, the bound is `(11 + F_q/q²) V_root`, since V_root>=q². This is an explicit separation of compilation from execution, not an unpriced runtime numerical component. + +A uniform four-bit encoding suffices for the record alphabet, whose largest symbol is RETURN=13. Thus the corresponding encoded live contents occupy less than 44 V_root+4F_q bits. This is a storage encoding observation. Scheduling and scanning those contents on a fixed number of physical tapes, with a proved time bound, remains a separate compiler obligation. + +### Active packet volumes and suspended parents + +At one node write its input order as + + [C prefixes][R fresh rows][B][A^n head][G][A^n tail][S], + R = W N H U, + V = C R B G S A^(2n). + +After the fresh-row split, every selected low-class packet has exactly + + v = C H U B G S A^(2n) = V/(WN). + +`layout.child_extents` keeps U as the independent fresh-row factor. It moves each spectator interval into exactly one of B',G',S', including the old external gap once. The child's complete input is the same v-bit packet, not merely its two visible chunks. Its current directory is inherited with C H physical prefixes, and its old current field is frozen exactly once. Consequently, along the single active recursion chain, + + V_j = V_root/(WN)^j. + +This identity is the reason parent families may be retained: their costs form a geometric series. Charging every suspended parent as another V_root would be a different, weaker accounting. + +The row quotient is U=t*9475*K^(D-1) at a node whose supplied stock is t*K^D. Indeed 269241600/28416=9475. A shorter actual child uses fewer than D-1 levels and treats the remaining K power as a positive stock multiplier. No discarded or hidden U factor is allowed in this argument. + +The scheduler retains only one active chain. `recursive_call.Frame` gives each internal child separate residue and index arenas of capacity 2^24. The parent arena remains parked and counted. The parent clears the temporary extended program and temporary first prefix before yielding; `packet_engine` clears an obsolete current packet after each returned child; `node` clears peeled and family copies on return. These lifetime rules are necessary to the geometric accounting. `Frame.close` erases live numerical words and the program, but permanent arena templates and erased-slot LEFT markers are released with the logical frame bank; it does not implement a sequential physical blank-return procedure for them. + +### Local payload and routing-key allowance + +A deliberately coarse 8V allowance at a node covers its own payload and routing keys, including the copies it retains while a descendant is active. This is not a sharp first-range peak result. + +* Source, peeled source and all split families together occupy at most 3V. Merge occupies at most 4V. Peel's completed primitive pipeline is at most 6V: source/current/partial output plus at most three complete local-fibre copies; local fibres partition the complete current packet. +* The selected local call has 661 ordinary roles and at most one private role. PR2731 bounds a completed local residual by 3v+3r, borrowed input included, where r is one physical-prefix fibre. PR2708 bounds the route by 2v+3H(r+J) for w>1, with a smaller w=1 bound, and J=4096(L+1) for actual residue width L. Gather/scatter creates at most one additional native family copy Nv=V/W. +* With J<=r, every local phase is bounded by 3V+680v+V/W. The slack 680 includes all 662 role packets, the source/current/copy retained at an invocation, and the residual or route's active local copies. This quantity is below 4V even using N>=1 and W=28416. At an invocation no partially assembled primitive output exists: `packet_engine` yields before beginning the next prefix loop. +* A new child's own payload is charged in its own8v term. Retained parent references do not create a second physical copy; counting them twice would only increase this conservative allowance. + +Under the hypotheses J<=r follows from r>=A² and L<=bw+2, with b=ceil(log2q). Namely J<=4096(b+3)w<=q^(2w), using b+3<=q, w<=q^(w-1), and 4096<=q. Actual internal packets have a much larger A^(2n) factor, n>=64. + +Thus all payload and keys on the active chain cost at most + + 8 sum_j V_j <= 8 WN/(WN-1) V_root. + +### Explicit metadata ledger before absorption + +Let L be residue width, I root-index width, Q source-code width, and h the frozen history length at the node. Write ell(V)=1+floor(log2V). Canonical count tapes use at most ell(V)+4 symbols including a leading margin and delimiters. All cardinalities generated at an admissible internal node are at most V: this includes H, fresh-row quotients, prefix counts, projected spectator extents, powers of A and their intermediate nonnegative products. The required root stock ensures H<=V even for the deepest internal frame. + +A serialized field occupies exactly + + f = Q + 4096(L+1) + 2 + +symbols. A complete produced directory has + + Delta = 1 + C H (h+1) f + +symbols; the old directory and any one copied prefix are no larger. This includes physical multiplicities, source labels, word delimiters, record delimiters and LEFT. The root input directory is a supplied input of this exact canonical form, not free metadata. + +The exact program size at history length h is + + P_h = 2I + L + 6 + h(Q+2I+90). + +This follows directly from `records.Program`: a ROOT tag, two index words, one residue word and one record delimiter, then h STEP records with six finite fields (one Q-bit and five 16-bit), two index words, and a record delimiter; each encoded word carries WORD_END, and the whole tape carries LEFT. + +The following intentionally inflated ledger covers one frame: + + E(V,h,L,I,Q) = + (2^24+1)(L+I+4) two Word arenas and their templates + + 8 P_(h+1) original/extended/copied programs + + 16(h+3)(2I+L+8) pending/value stacks and pop reversals + + 2^20(ell(V)+4) Count/Counter tapes and saved continuations + + 2^32(Q+1) finite labels, form records, role bindings + + q² + 2^20. bucket and other LEFT markers + +In addition charge 32Delta for coexisting old/current directories and temporary raw-prefix/field copies. The current implementation needs far fewer than 32; this covers directory construction (old+output+saved prefix), one consumer directory and prefix, the child-extension prefix and an inherited borrowed directory, with slack. A child directory is charged to that child's associated complete packet; it is never charged against an isolated header or a single atom. + +Therefore a pre-absorption bound is + + F_q + sum_(active j) [8V_j + 32Delta_j + E(V_j,h_j,L,I,Q)]. + +This formula is also the appropriate form when widths are padded or a supplied history does not satisfy the root-coupled bounds. An arbitrary supplied byte string is not automatically a canonical Program or directory: successful execution checks exact depth, fields and prefix count. If a host separately retains unrelated input files or instrumentation, their actual sizes must be added. No reserve theorem can absorb an arbitrarily large unrelated supplied string into V. + +### Source inventory supporting the constants + +The arena capacity is a source bound, not an inference from a finite test. Every matrix is at most 128 by 256. At most64 such matrices, 2^19 other Word-vector entries, and 1024 scalar/index temporaries suffice: + + 64*(128*256) + 2^19 + 1024 < 2^22 < 2^24. + +`Matrices.prepare` retains the input high matrix with raw/common/projector intermediates, fewer than eight full matrices. `good_form` has at its late peak projector, left, right, li, ri, lp, a0, b, cross; its early a has been freed. Its row/column scalar lists total at most 4032 entries and at most 64 pivots. `fallback_form` retains a 128-square matrix, at most 16256 shear scalars, and 128 diagonal entries. A retained Page form may coexist with one ancestor matrix preparation by `Callback.weight`; there is no matrix per ancestor. `weight` uses explicit sequential pending/value stacks. Route decoration and directory odometers are separate phases and fit within the same inflated 64-matrix bound. Euclid/divmod/multiply loops free scalar temporaries on every iteration; fewer than 32 nested arithmetic temporaries are needed, covered by 1024. + +The callback evaluator has arity at most two and decreases the chronological level at every VALUE expansion. At most two pending records per level, one retained completed value per level, and a constant number of pop/reverse records exist. Allowing two Callback objects and both reverse tapes gives the stated 16(h+3)(2I+L+8) bound. The evaluator recomputes ancestor forms; it does not retain an exponentially large evaluation tree. + +The Count/Counter allowance 2^20 is deliberately much larger than the fixed source-call inventory. There are five node input-count copies, three derived stock/fibre counts, layout extent triples, context.highs, the driver's row count, directory expected/emitted/outer counters, and the bounded nested primitive counters. Count.product has factor/scan/result and one add copy. These loops process one entry at a time; they do not append a counter per processed row, prefix, digit, matrix entry or operation. The only unbounded nesting is the separately charged recursive frame chain or serialized callback stack. Saved generator continuations have a fixed number of references, labels and encoded word/tape positions per nonrecursive source activation; the same 2^20 allowance covers a conservative serialization. This is a storage inventory, not an implementation of such a continuation compiler. + +Finite fallback permutation snapshots have at most 16256 records of 128 labels. Two simultaneously relevant forms and all 661 role bindings, loop labels and trace metadata fit far below 2^32(Q+1). Fixed-q chart/source/low-class plan caches are instead in F_q: they are independent of input precision and must not silently be called runtime-free Python memory. The atom digit-swap has at most q² bucket LEFT markers; fresh families, role buffers, count tapes and stack tapes fit the additional 2^20 markers. Arena LEFT/RIGHT markers were already counted in arena cells. + +### Root-coupled absorption, with explicit inequalities + +For minimal widths and the selected vocabulary, + + L <= bw+2, I <=591w, h+1 <=1180w, Q <=4096b+16. + +The source-code bound uses 2*28278*N<2^16 q^4096, including both physical views. The index bound follows from the canonical root word I<=log2e+2 and w>=e^(17/10000); for x>=1, log2x/x^(17/10000)<=1/((17/10000)*exp(1)*log(2))<313, so591 is conservative. The displayed history bound is the retained checked root-coupled condition, rounded upward. + +Substituting these bounds into the ledger gives, with considerable slack, + + E <= 2^48(b+597)w² + 2^20(ell(V)+4) + q². + +Here 8P_(h+1) and the callback stacks are quadratic in w; the arena is linear in w; finite form labels are bounded by 2^45(b+1); and all constant LEFT markers are included. More explicitly, replacing L by (b+2)w and h+1 by 1180w, the non-count/non-q² part has nonnegative coefficients and degree at most two in w. It is at most (83066202501+17592241506793*b)w², which is less than 2^48(b+597)w² coefficientwise. Thus the displayed envelope is an exact conservative inequality, not a finite-size extrapolation. + +Every complete active packet has V>=q^(2w); internal frames in fact have V>=q^(128w). For integer w>=1, w²<=4^(w-1), and q²>=4. Also b+597<=q for q>=2^80. Therefore + + 2^48(b+597)w² / V <= 2^48/q <= 2^-32. + +For V>=16, ell(V)+4<=16 sqrt(V), so + + 2^20(ell(V)+4)/V <= 2^24/q^w <= 2^-56. + +Finally q²/V<=1. Hence E<2V. PR2688, with the same minimal vocabulary and history assumptions, gives Delta<2^-130 V for a complete associated packet, so 32Delta<2^-125V. It follows that + + 8V +32Delta +E < (10+2^-125)V, + +and summing the geometric series yields + + (10+2^-125) WN/(WN-1) V_root <11V_root. + +This proves the claimed full logical live-symbol reserve, including numerical words and suspended parents. It does not reuse the historical 14-field parking reserve or claim that the existing source has implemented that sharper physical layout. + +## 7. Explicit stock coefficient and capacity boundary + +Since N=64. Consequently + + k <= 2(4096w+1)log2e+1 <=8195w log2e. + +With w=ceil(e^(17/10000))<=2e^(17/10000), this also gives + + k <=16390 e^(17/10000) log2e. + +These deliberately rounded constants are derived from the new 269241600 row stock. A sharper coefficient can be obtained from log2(32/21), but no historical 6748 coefficient is assumed. Storage closure and stock feasibility do not price the actual numerical execution time; that remains governed by the actual callback and routing implementation rather than a free-operation model. + + +## 8. Evidence and remaining obligations + +The executable checks cover projected ordered coordinates, nonzero remainders, same-bank and cross-bank children, odd half-reset gaps, complete dispatch chronology, repeated frozen-prefix ordinals, independent unused stock, a small completed recursive execution, linear-sign endpoints and traffic, and scheduler depth beyond the native Python recursion limit. Explicit protocol mutations reject omitted or duplicate calls and changed return boundaries. The independent coordinate/origin oracle checks the correct treatment of U/B, all gap placements and whole-packet prefix ordinals; those positive oracle comparisons are not described as injected mutation tests. [VERIFY.json](VERIFY.json) defines the reproducible checks and their exact scope; finite controls support the parametric argument and do not enumerate the selected GL64 payload. + +The code still uses logical dynamically created frame/tape objects. The full live-content inequality is distinct from a proved lowering to a fixed number of physical tapes with charged cursor movements, record markers, frame-bank reuse and erasure. No claim that `Frame.close` physically blanks the arena templates is made. The inherited full-ring algebra and source bindings remain proof dependencies, and no proof-assistant or transition-table verification is supplied. + +The direct next step toward multiplication is to compile and price this now-complete caller in the intended fixed-tape interface, then replace the O(wV) route and leaf routines by implementations satisfying the selected H2 contracts, preserving this whole-call stock and metadata accounting. The ordinary outer borrowing/rounding wrapper, complex supplier and analytic transfer retain their own obligations. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/README.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/README.md new file mode 100644 index 0000000000..7546163285 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/README.md @@ -0,0 +1,76 @@ +# A completed recursive caller for the selected BIT construction + +This package removes the `64 <= n < 128` restriction from the executable caller in [Jose Manuel's PR2697](https://github.com/CrocSwap/integer-mult-bounds/pull/2697). An internal child now runs the same complete selected caller over its whole packet and returns to its suspended parent. Its unused row stock, frozen field directory, generated coefficient program and ordered spectators are passed explicitly. The caller terminates at the existing below-64 leaves. + +This closes a central implementation gap: the earlier executable only handled widths for which every child was already a leaf. The earlier recursive closure note supplied a mathematical recurrence with a completed callee premise; this package supplies that callee in the logical stream implementation and accounts for its nested storage. It also repairs an inherited sign operation whose per-column cost would otherwise grow with atom precision. + +**The multiplication exponent does not change.** The selected conditional value remains κ = 0.001672660197076918. The executable establishes the baseline `p=1` time recurrence under the stated source and root-coupling hypotheses. Its routing and leaf swaps still cost `O(wV)`; it does not establish the stronger selected H2 contracts, a compiler to a fixed number of physical tapes, or the outer multiplication transfer. It is a substantive step on the actual caller, not a new exponent certificate. + +## What is new + +- A decreasing-width dispatcher with explicit ENTER / INVOKE / RETURN boundaries, one complete child invocation across all current high-prefix ordinals, and an iterative scheduler that avoids a Python recursion-depth restriction. +- Exact child geometry across the original head/gap/tail layout, including same-bank children, odd half-resets and remainder peeling at widths above the previous range. +- Separate child stock `U` and spectator `B`. Their product is never used as a substitute for available fresh rows. Each child gets separate numerical arenas and its own serialized source-bound program. +- A sign implementation with linear complete-fibre traffic. In particular, the fixed two-slice retreat does not copy a padded residue counter once per atom. +- A full logical live-symbol ledger for payload, keys, directories, numerical banks, continuations and suspended parents. Under the explicit canonical root-coupling hypotheses in [PROOF.md](PROOF.md), the bound is `< 11 V_root + F_q`, where `F_q` is fixed-q source compilation storage. This is not a Python heap bound or a completed physical tape-space theorem. + +The stock is the compatible selected stock + +``` +K = lcm(28416,28425) |GL64(Fq)| q^(4096(w-1)) + = 269241600 |GL64(Fq)| q^(4096(w-1)). +D(n) = 0 if n < 64, otherwise 1 + D(42 floor(n/64)). +root rows = t K^D(n), t >= 1. +``` + +A child receives exactly `V/(28416 |GL64(Fq)|)` payload symbols. Thus retaining suspended parent states produces a geometric storage sum. The proof derives a sufficient row-capacity exponent `k <= 8195 w log2(e)` and retains the divisibility and outer-padding obligation; merely supplying `q^k` rows does not satisfy the executable contract. + +## Scope and source boundary + +The base is canonical main `7b39515117fe26e75d16c268877391f1bdaa5640`, priority revision 5. The selected result and its scientific inputs remain unchanged. [TASK.json](TASK.json) records the current-main and overlap checkpoints, the explicit user-directed scope refinement and next questions. + +A matching [recursive-boundary claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18957230) by jmbarrancoml appeared at 19:47 UTC, after this task started at 19:19:46 and checked overlap. This is an independent construction and joined logical-reserve argument; exclusive novelty is not claimed. Nick Petalas concurrently completed [PR2743](https://github.com/CrocSwap/integer-mult-bounds/pull/2743), the sharper first-range payload/key result. Our coarse payload allowance is not a claim to that result, and the finer first-range count-storage result [PR2749](https://github.com/CrocSwap/integer-mult-bounds/pull/2749), published during validation, remains separate. + +The runtime import graph actually uses the byte-for-byte [PR2697 export](predecessor/) at `a53fdf4bcbe33c6732f0bec1badc8c023380f9d1`; [PREDECESSOR.json](PREDECESSOR.json) authenticates all 50 files before executable imports. Candidate modules at this package root override only the changed components. No pending source is treated as admitted to the selected frontier. [SOURCES.json](SOURCES.json) pins every external live input, including the inherited profile/stock proofs. [EVIDENCE.json](EVIDENCE.json) authenticates the four retained component-proof/notice files before execution; their separate attribution is preserved. + +The constructor accepts internal widths `n >= 64`; below-64 cases are completed trace leaves, not new root `SelectedNode` entry points. The compatible all-size stock and canonical program/directory form are input hypotheses. The local divisibility guard alone does not certify adequate stock for an arbitrary entire tree. + +## Evidence and reproduction + +Use CPython 3.12, standard library only, from the repository root: + +```sh +python3.12 scripts/research_package.py --package research/selected-bit-recursive-caller +``` + +[VERIFY.json](VERIFY.json) declares the bounded commands. A particular suite can be replayed directly: + +```sh +python3.12 -B research/selected-bit-recursive-caller/verify.py --suite recursion +``` + +The suites have deliberately different claims: + +| Suite | Evidence | +| --- | --- | +| `source` | Full selected provider catalogue and 7,843,392 literal caller events; generated coefficients, global schedule, complete gapped endpoint, and two distinct sampled high fields. | +| `node` | Complete four-family GL2 Boolean-column model including MOVE, COPY, IDLE, bridge, exchange, exact source preservation and scratch cleanup. | +| `recursion` | Independent ordered-layout oracle; actual `peel.run` above the old range; selected descriptor/frame handoffs `256 -> 168 -> 84` with controlled tiny payload consumers; 1,501 scheduler frames; malformed-return, failed-construction and exception cleanup controls. | +| `nested` | Complete two-level physical execution on a separate dimension-2, q=2 toy with all six GL2 low classes. It uses a coordinate-projector root and full conjugated GL2 children, with actual node/driver/trace/layout and stream operations and test-only source/coefficient fixtures. It is not execution of the enormous selected GL64 payload. | +| `controls` | Sign endpoints and counter-cost regression, stale gather/scatter witnesses, bridge/exchange directions, invalid stock, omitted/changed source pins, and exact receipt mutations. | + +No finite model proves all widths. The parametric argument is in [PROOF.md](PROOF.md); the tests independently challenge its geometry, chronology, source binding and cleanup boundaries. The selected-frame check is explicitly a controlled callee fixture, and the q=2 toy is outside the selected odd-prime admission domain. + +Verification is read-only and compares complete typed receipts in [RESULT.json](RESULT.json), including their canonical SHA256 digests. Explicit generation uses `--emit-to NEW_FILE` and refuses to overwrite a file. Assertions are required for independent test code; direct optimized runs are rejected. [VALIDATION.md](VALIDATION.md) records the actual environment, commands and outcomes. + +## Open next questions + +1. **Can this logical caller be compiled to the required fixed tape inventory with the same charges?** The next concrete step is a serialized frame-bank/continuation layout with cursor movement, template cleanup and reuse charged on every return. The full live-content ledger is available; the existing Python tape objects are not that compiler. +2. **Can routing and ordinary leaf swaps satisfy the selected H2 primitive contracts?** Start with the actual `routes.py` and `bitstream.py` paths reached by this caller, preserving complete-prefix order and source ownership. Replacing only the recursive callback cannot remove their `O(wV)` charge. This is the immediate time bottleneck between the baseline recurrence and the stronger selected H2 saving. The baseline can already feed the inherited conditional ordinary-caller bootstrap, once its physical and outer-wrapper premises are supplied. +3. **Can the compatible reserve be supplied by the outer borrowing wrapper?** Implement the stated compatible-row padding and restoration, preserving the `U` coordinate and full metadata ledger. The capacity inequality alone does not establish the wrapper, and the complex supplier and analytic transfer remain separate obligations. + +## Attribution + +David Arias, with substantial OpenAI Codex assistance, including mathematical, implementation and independent-checking subagents. This is not independent human review or a proof-assistant verification. New work is under Apache-2.0. + +Jose Manuel (`jmbarrancoml`) supplied the executable first-range caller and its selected source chain. The complete retained [NOTICE](predecessor/NOTICE.md) credits the selected word, hosting, full-ring normal forms, coefficient grammar and packet contracts. We additionally credit starship-s's PR2731 residual storage, NickPetalas's PR2708 route/key storage and ywz65's PR2688 directory bound. Those component results are not claimed here as new. The earlier mathematical recursive closure and compatible-stock construction remain explicit proof dependencies. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/RESULT.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/RESULT.json new file mode 100644 index 0000000000..75faec7844 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/RESULT.json @@ -0,0 +1,893 @@ +{ + "controls": { + "full_result_sha256": "890b59b04df5cce330e6e7c5c228ec9268d454e5c4ab38d606496a5acd2f7bf3", + "result": { + "bridge_exchange": { + "bridge_columns": 15552, + "exchange_columns": 15552 + }, + "linear_sign": { + "addresses": 3120, + "cases": 36, + "control_scaling": { + "finite_assertion": "control reads+writes+moves <=512V in these five cases", + "measured_family": [ + { + "control_tape_steps": 1035, + "modulus": 3, + "volume": 3 + }, + { + "control_tape_steps": 3371, + "modulus": 9, + "volume": 9 + }, + { + "control_tape_steps": 9879, + "modulus": 27, + "volume": 27 + }, + { + "control_tape_steps": 29308, + "modulus": 81, + "volume": 81 + }, + { + "control_tape_steps": 87075, + "modulus": 243, + "volume": 243 + } + ], + "scope": "all Counter tapes, residue arena, and before/suffix tapes; source/output payload tapes excluded" + }, + "digest": "6ea234c0e8aabd48a6de8b8901bd52ade9705ac41ef53b169fe588ae8b8c5452", + "exact_source_moves": "(6M-8)BS+4", + "host_numeric_decode": false, + "malformed_input_controls": [ + "truncated_input", + "overlong_input", + "non_bit_input" + ], + "moduli": [ + 2, + 3, + 9, + 25 + ], + "residue_width_counter_setups": "3B; no per-slice padded numeral-two counter", + "source_move_bound": "6V", + "status": "PASS_LINEAR_SIGN_INDEPENDENT" + }, + "rejections_counts": { + "cardinality_cases": 20, + "maximum_product_bits": 822, + "rejections": [ + "self_XOR", + "write_private", + "write_copied_source", + "wrong_ERASE_source", + "wrong_ADD_frame", + "node_range_0", + "node_range_1", + "incomplete_stock_1", + "incomplete_stock_191", + "incomplete_stock_193", + "incomplete_stock_188", + "incomplete_high_stock", + "physical_inventory_denominator", + "selected_compatibility_stock" + ], + "runtime_modules": [ + "cardinal_counts.py", + "layout.py", + "packet_engine.py", + "consumer.py", + "peel.py", + "fresh_rows.py", + "control.py", + "driver.py", + "node.py", + "topology.py", + "linear_sign.py", + "recursive_call.py", + "scheduler.py" + ], + "selected_unused_factor": 9475 + }, + "stale_state": { + "stale_family_scatter": { + "correct": 1946, + "source": 1998, + "wrong": 1998 + }, + "stale_low_gather": { + "correct": 1947, + "source": 1962, + "wrong": 1962 + } + }, + "verifier_mutations": { + "before_executable_imports": true, + "rejected": [ + "omitted_source:certificates/selected-result.json", + "omitted_source:research/community-hyperplane599-audit/pr589/bit589/v9/hosted/GLOBAL-TEMPLATE.json.gz", + "omitted_source:research/community-hyperplane599-audit/pr589/bit589/v9/nine/GEOMETRY.json", + "omitted_source:research/e8-bit-p111-tuned/tune/EXPECTED.json", + "omitted_source:research/e8-bit-p111-tuned/tune/bitE8mut-p111-tuned.json.gz", + "omitted_source:research/pr589-five-helper-hosting/PROOF.md", + "omitted_source:research/pr589-five-helper-hosting/verify.py", + "omitted_source:research/recursive-parking-boundary/README.md", + "omitted_source:research/selected-bit-local-ring-sweeps/PROOF.md", + "omitted_source:research/selected-bit-recursive-closure/PROOF.md", + "omitted_source:upstream/build/sections/02-streams.tex", + "omitted_CI_input", + "omitted_executable_predecessor", + "omitted_proof_predecessor", + "wrong_live_hash", + "changed_executable_bytes", + "receipt_wrong_type", + "receipt_wrong_value", + "receipt_extra_field", + "receipt_wrong_digest" + ], + "verification_writes_receipts": false + } + } + }, + "nested": { + "full_result_sha256": "d5fea26cf0d2318fe5f8d8f9ebd1be817b715d0a23f524be73f8c432f3900780", + "result": { + "child_fresh_rows": 6, + "complete_addresses": 9216, + "counts": { + "child_stock_checks": 144, + "enter": 1452, + "internal_calls": 12, + "internal_returns": 12, + "residuals": 156, + "return": 1452, + "root_stock_checks": 12 + }, + "domain": "toy q=2, dimension=2, cutoff=2, one family; not selected GL64", + "leaf_unused_rows": 1, + "low_classes": 6, + "output_sha256": "68477c468bd70d3488f9e1afbfa576aab2fa9db44949874ab873d64c22853b46", + "root_normal_forms": "coordinate projectors", + "root_rows": 36, + "root_width": 4, + "tracked_work_erased": 3796717 + } + }, + "node": { + "full_result_sha256": "c3e6e32c0ad818cfed1b920d8dfa9f840f81ae64099e853ffe6b1c18be4f363e", + "result": { + "bank_atoms": 2, + "children": { + "enter": 5712, + "return": 5712 + }, + "dimension": 2, + "erased_tapes": 6406846, + "events": { + "bridge": 4, + "exchange": 2, + "global": 15, + "global_return": 15, + "literal": 864, + "residual": 672 + }, + "families": 4, + "first_sweep_checkpoints": [ + 0, + 1 + ], + "gap": 1, + "input_columns": 15552, + "low_classes": 48, + "payload_sha256": "0a0c46f6fa0b21feebadbdc446afaf66d3e3b37a9136bdc2c6c6338a631b615d", + "residuals": { + "COPY": 96, + "IDLE": 384, + "MOVE": 192 + }, + "width": 1 + } + }, + "recursion": { + "full_result_sha256": "6ab6832821d0ff9d3f71075c45894c2bbdbc6d16d7e47d8bac7e72a7e2ceed9e", + "result": { + "abort_cleanup": { + "child_failure_propagated": true, + "owned_parent_tapes_erased": 2, + "scope": "controlled primitive creates owned output before failing child; real packet engine and scheduler" + }, + "all_size_peel": { + "changed_scalar_rows": { + "128": { + "129": 5 + }, + "129": { + "128": 2 + } + }, + "columns": 2, + "dimension": 64, + "incoming_weights": { + "0": 1, + "128": 5, + "64": 2 + }, + "legacy_columns_one_rejected": true, + "modulus": 9, + "parent_width": 129, + "primitive_counts": { + "add": 3, + "atom_swap": 4, + "sign": 1 + }, + "queried_offsets": [ + 128, + 128, + 128 + ], + "remainder": 1, + "scope": "actual peel.run and incoming callback; independent scalar opcode interpreter; no dense payload" + }, + "construction_failure": { + "copied_program_erased": true, + "failed_fresh_banks_erased": 2, + "parent_program_unchanged": true + }, + "frame_handoff": { + "complete_selected_GL64_payload_executed": false, + "controlled_payload_bits": 23, + "depths": 2, + "handoffs": [ + { + "before": 2, + "depth": 1, + "gap": "5*3^176", + "prefixes": 2, + "stock": 11, + "suffix": 3, + "width": 168 + }, + { + "before": 2, + "depth": 2, + "gap": "5*3^344", + "prefixes": 2, + "stock": 11, + "suffix": 3, + "width": 84 + } + ], + "repeated_call_recipe_cache_growth": 0, + "return_order": [ + 2, + 1 + ], + "sampled_old_prefixes": 2, + "scope": "real selected constructors, Callback.extend, Frame and directory handoff; controlled child consumer only", + "selected_node_constructions": 5, + "shared_topology_instances": 1, + "source_rank": 42, + "source_request": 27825, + "widths": [ + 256, + 168, + 84 + ] + }, + "frame_mutations": [ + { + "check_kind": "independent preserved-input oracle", + "closed_frames": 2, + "mutation": "source_bit", + "rejection": "independent checker: frozen source bytes changed" + }, + { + "check_kind": "independent preserved-input oracle", + "closed_frames": 2, + "mutation": "directory_bit", + "rejection": "independent checker: frozen directory bytes changed" + }, + { + "check_kind": "runtime head contract", + "closed_frames": 2, + "mutation": "output_head", + "rejection": "completed recursive return restores caller heads" + } + ], + "layouts": { + "cases": 136, + "digest": "b25c5037bd2b008d4424b257327e89d43a9131964978a452dd27f5121ed5d4af", + "moduli": [ + 3, + 9 + ], + "rejected_overlapping_or_noncontiguous_chunks": 24, + "spectators": [ + 2, + 5, + 3 + ] + }, + "lifecycle": { + "normal_owned_return": true, + "rejected": [ + "missing_invoke", + "duplicate_invoke", + "missing_return", + "metadata_mutation", + "aliased_output", + "aliased_metadata_mutation", + "width_mutation" + ] + }, + "status": "PASS_RECURSIVE_JUNCTIONS", + "traces": [ + { + "boundaries": [ + [ + "unit", + 1, + true, + 0, + false + ], + [ + "pair", + 2, + false, + 0, + false + ], + [ + "unit", + 1, + true, + 0, + false + ] + ], + "events": { + "add": 12, + "atom_swap": 16, + "enter": 3, + "return": 3, + "sign": 4 + }, + "kind": "pair_head", + "parent_width": 128 + }, + { + "boundaries": [ + [ + "unit", + 1, + true, + 0, + false + ], + [ + "pair", + 2, + false, + 64, + true + ], + [ + "unit", + 1, + true, + 0, + false + ] + ], + "events": { + "add": 12, + "atom_swap": 16, + "enter": 3, + "return": 3, + "sign": 4 + }, + "kind": "pair_tail", + "parent_width": 128 + }, + { + "boundaries": [ + [ + "unit", + 2, + false, + 0, + false + ] + ], + "events": { + "add": 6, + "atom_swap": 8, + "enter": 1, + "return": 1, + "sign": 2 + }, + "kind": "unit_cross", + "parent_width": 128 + }, + { + "events": [ + "enter", + "invoke", + "return" + ], + "kind": "good", + "parent_width": 128, + "width": 84 + }, + { + "boundaries": [ + [ + "unit", + 32, + true, + 0, + false + ], + [ + "pair", + 64, + false, + 0, + false + ], + [ + "unit", + 32, + true, + 0, + false + ] + ], + "events": { + "add": 192, + "atom_swap": 256, + "enter": 3, + "invoke": 1, + "return": 3, + "sign": 64 + }, + "kind": "pair_head", + "parent_width": 4096 + }, + { + "boundaries": [ + [ + "unit", + 32, + true, + 0, + false + ], + [ + "pair", + 64, + false, + 64, + true + ], + [ + "unit", + 32, + true, + 0, + false + ] + ], + "events": { + "add": 192, + "atom_swap": 256, + "enter": 3, + "invoke": 1, + "return": 3, + "sign": 64 + }, + "kind": "pair_tail", + "parent_width": 4096 + }, + { + "boundaries": [ + [ + "unit", + 64, + false, + 0, + false + ] + ], + "events": { + "enter": 1, + "invoke": 1, + "return": 1 + }, + "kind": "unit_cross", + "parent_width": 4096 + }, + { + "events": [ + "enter", + "invoke", + "return" + ], + "kind": "good", + "parent_width": 4096, + "width": 2688 + }, + { + "boundaries": [ + [ + "unit", + 64, + true, + 0, + false + ], + [ + "pair", + 128, + false, + 0, + false + ], + [ + "unit", + 64, + true, + 0, + false + ] + ], + "events": { + "enter": 3, + "invoke": 3, + "return": 3 + }, + "kind": "pair_head", + "parent_width": 8192 + }, + { + "boundaries": [ + [ + "unit", + 64, + true, + 0, + false + ], + [ + "pair", + 128, + false, + 64, + true + ], + [ + "unit", + 64, + true, + 0, + false + ] + ], + "events": { + "enter": 3, + "invoke": 3, + "return": 3 + }, + "kind": "pair_tail", + "parent_width": 8192 + }, + { + "boundaries": [ + [ + "unit", + 128, + false, + 0, + false + ] + ], + "events": { + "enter": 1, + "invoke": 1, + "return": 1 + }, + "kind": "unit_cross", + "parent_width": 8192 + }, + { + "events": [ + "enter", + "invoke", + "return" + ], + "kind": "good", + "parent_width": 8192, + "width": 5376 + } + ], + "trampoline": { + "closed_after_failure": 1101, + "completed_frames": 1501, + "host_recursion_limit_unchanged": true + } + } + }, + "source": { + "full_result_sha256": "04143916807402150bb2a61a8da44720a951742bc54e4b667e66c7ad6bf54fd7", + "result": { + "gapped_endpoint": { + "bank_atoms": 3, + "before": 2, + "bits": 5832, + "children": { + "enter": 20, + "return": 20 + }, + "core_atoms": 2, + "erased_tapes": 1145684, + "gap": 2, + "marker": [ + 1234, + 2720 + ], + "payload_sha256": "134dda6cf3b1f7ed605ca940db6326b4a1d059a5e81165effa5c403e1983a78a", + "peel_pairs": 1, + "suffix": 2 + }, + "gapped_extents": { + "gap": 5, + "geometry_cases": 36, + "widths": [ + 64, + 65, + 95, + 127 + ] + }, + "generated_peel": { + "ancestor_rank": 5, + "columns": 130, + "frozen_fields": 1, + "head64_to_tail0": 8, + "parent_atoms": 65, + "peel_scalars": [ + 8, + 1, + 8 + ], + "root_atoms": 832, + "source_code_bits": 6507, + "tail0_to_head64": 8, + "wrong_offset_weight": 2 + }, + "global_scalar": { + "bridge_shears": 18, + "family_XOR_actions": 63936, + "global_events": 29, + "omission_controls": 18, + "terminal_family_pairs": 14208 + }, + "sampled_high_packet": { + "bits": 39366, + "children": { + "enter": 1, + "return": 1 + }, + "complete_high_cube": false, + "dimension": 2, + "erased_tapes": 464279, + "gap": 3, + "high_prefixes": 2, + "payload_sha256": "b7fa73bbb6e282d63e6ea9fac8a2443c6357d015d34c65ecf0e5829af68bfed8", + "width": 2 + }, + "selected_consumers": [ + { + "callbacks": [ + "adapter", + "child" + ], + "code_bits": 6507, + "common": true, + "full_payload_executed": false, + "kind": "MOVE", + "rank": 1, + "request": 0 + }, + { + "callbacks": [ + "adapter", + "child" + ], + "code_bits": 6507, + "common": false, + "full_payload_executed": false, + "kind": "IDLE", + "rank": 42, + "request": 27825 + } + ], + "selected_sources": { + "consumer_binding_sha256": "e59279f482edde48fb08773e32c429acb369eaf33a723034d083cc0577c714c6", + "literal_counts": { + "0": 838368, + "1": 6999840, + "2": 2592, + "3": 2592 + }, + "literal_events": 7843392, + "literal_source_sha256": "ea44aa047a2a9cf034de8b56b2166c49cf2dbdf9cd9ed6a20299a4f2b05ef09a", + "local_certificates": { + "forward": { + "copies": 9, + "profile": { + "1": 1323, + "2": 1342, + "3": 79, + "4": 44, + "5": 102, + "6": 11, + "7": 19 + }, + "records": 27234, + "symbolic_columns": 661 + }, + "reverse": { + "copies": 9, + "profile": { + "1": 1323, + "2": 1342, + "3": 79, + "4": 44, + "5": 102, + "6": 11, + "7": 19 + }, + "records": 27234, + "symbolic_columns": 661 + } + }, + "ownership": { + "calls": 288, + "distinct_slot_permutations": 14, + "first_five_helper": { + "ambient_axes": [ + [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + [ + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + [ + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24 + ], + [ + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32 + ], + [ + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40 + ] + ], + "children": [ + 4, + 4, + 4, + 4, + 4 + ], + "family": 666, + "pair": 0, + "replica": 0, + "roles": [ + 232, + 233, + 234, + 235, + 236 + ], + "stage": 2 + }, + "hosted_occurrences": 126432, + "idle_remainder_profile": { + "2": 13920, + "4": 14208, + "42": 288, + "6": 14208, + "7": 21312 + }, + "max_helpers_per_family": { + "0": 3, + "1": 3, + "2": 5, + "3": 5, + "4": 5, + "5": 5, + "6": 3, + "7": 5, + "8": 3 + } + }, + "provider": { + "base_labels": 541, + "binding_sha256": "f5a4fb124709adc4b56376a3146e3609e91c0f4d3ed1931a61785a5d99bf8ee7", + "canonical_ERASE_guards": 81, + "canonical_requests": 28278, + "chart_labels": 1235, + "full_paid_requests": 904896, + "rank_histogram": { + "1": 381024, + "2": 400416, + "3": 22752, + "4": 26880, + "42": 288, + "5": 29376, + "6": 17376, + "7": 26784 + }, + "replicas": 32, + "request_kinds": { + "COPY": 81, + "IDLE": 1998, + "MOVE": 26199 + } + }, + "split_basis_ranks": { + "1": 120, + "2": 182, + "3": 77, + "4": 41, + "42": 1, + "5": 85, + "6": 13, + "7": 22 + } + } + } + } +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/SOURCES.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/SOURCES.json new file mode 100644 index 0000000000..ff8c8e3617 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/SOURCES.json @@ -0,0 +1,84 @@ +{ + "schema_version": 1, + "base_commit": "7b39515117fe26e75d16c268877391f1bdaa5640", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "input", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "889b95d936746df124872133ae1e7cc339adcb92", + "sha256": "7d185cd8c2af35988d638d969748ad7b670f902606444dbfc748e4402c340df6" + }, + { + "path": "research/pr589-five-helper-hosting/verify.py", + "usage": "input", + "git_blob": "dbc71f56bb4205ebe378ada1f9f4ea88630d1d39", + "sha256": "cf90e19ae9991b0698be03d395a8cc29061ecb307eb7fea19adfb2d23c25a367" + }, + { + "path": "research/pr589-five-helper-hosting/PROOF.md", + "usage": "input", + "git_blob": "bbd3f12b9a32b3ad3cba85a2d5a1b3054214fa02", + "sha256": "59cae781bfbe1a01ed9e66a8efeeb5a2b995e5ecdf908586b23ecc39f2b8d647" + }, + { + "path": "research/e8-bit-p111-tuned/tune/bitE8mut-p111-tuned.json.gz", + "usage": "input", + "git_blob": "85a4499bf9e4911a705d50567a2c2ef6cf23739a", + "sha256": "e3e301e62bc2b41dbf1ceac0acf3d35824ebeab1848c5a2142d4577b109da52f" + }, + { + "path": "research/community-hyperplane599-audit/pr589/bit589/v9/hosted/GLOBAL-TEMPLATE.json.gz", + "usage": "input", + "git_blob": "9eafb8776cbf78c72124f833534469ddfa5e98ec", + "sha256": "0357b7cfbd7c29b4983982baf153c8a9f1e1e412690cd7fa9fc3d23d7963b20f" + }, + { + "path": "research/community-hyperplane599-audit/pr589/bit589/v9/nine/GEOMETRY.json", + "usage": "input", + "git_blob": "44006542202ca6037533a754f0bcd00549d7e088", + "sha256": "0058c491d839142aa99ef86a5ec697ce99857632228531512ea3fa74fb24d734" + }, + { + "path": "research/recursive-parking-boundary/README.md", + "usage": "input", + "git_blob": "251f335ebaccc11d69393ee7aeb5a2e84526d0bb", + "sha256": "491aa208391ee4c2936510b1a5c5c018dd5509d9a0e88687c72ab8406cd77b18" + }, + { + "path": "upstream/build/sections/02-streams.tex", + "usage": "input", + "git_blob": "088fceea1867abc76271d7efe7532b779fee9039", + "sha256": "606c80db61cad13aa0c3b6060dc4b88dbbe7ac60cdd831aa93f28d908fd09dab" + }, + { + "path": "research/e8-bit-p111-tuned/tune/EXPECTED.json", + "usage": "input", + "git_blob": "e293ddc557742637f9f679f083a1a282d87b1b13", + "sha256": "b9f0e5ca038abe837b0007c8fe006f366a6f02009244ac57705a8a200e2301f4" + }, + { + "path": "research/selected-bit-local-ring-sweeps/PROOF.md", + "usage": "input", + "git_blob": "4330de85dd9862ed15d84ab917887d249753df99", + "sha256": "846c59440cc99e28bae93ad2af99525bc769de29368080071b8427141215b4f7" + }, + { + "path": "research/selected-bit-recursive-closure/PROOF.md", + "usage": "input", + "git_blob": "6c410cab5713979214a45835091fbeb9ee9b8531", + "sha256": "74cc8de20f21acb5123fe2d20996fe0925ea6e51b3dec633bd5221fb719b3344" + } + ], + "predecessor": { + "manifest": "PREDECESSOR.json", + "head": "a53fdf4bcbe33c6732f0bec1badc8c023380f9d1", + "scope": "Exact executable source export; authenticate every file before import. See retained NOTICE and provenance chain." + }, + "proof_exports": "EVIDENCE.json" +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/TASK.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/TASK.json new file mode 100644 index 0000000000..d70ad31727 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/TASK.json @@ -0,0 +1,150 @@ +{ + "schema_version": 1, + "task_id": "selected-stock-envelope", + "priority_revision": 5, + "base_commit": "7b39515117fe26e75d16c268877391f1bdaa5640", + "original_card": { + "id": "selected-stock-envelope", + "question": "What explicit uniform stock envelope does the actual selected stopped producer supply at one bootstrap stage?", + "starting_points": [ + "research/selected-bootstrap-stock-audit/README.md", + "research/bootstrap-cutoff-time-space-split/README.md", + "certificates/selected-result.json", + "docs/research/community-efficient1000-review.md" + ], + "methods": [ + "Derive a source-bound reserve recurrence at the actual selected atom widths, separating parent stock from completed inner borrowing.", + "Find an exact missing implication or counterexample to a proposed selected-stage stock envelope." + ], + "acceptance_gate": "Bind every coefficient and depth factor to the selected producer and state the width domain. Compare a proved envelope with the sufficient cutoff guard; a large numerical headroom or a historical m=120 coefficient is not a selected m=73 proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read #1956/#1965/#1990 in the batch review and the stock-audit source boundary. Its actual selected coefficient remains uncomputed.", + "scope": "Source-bound orientation only. Read the named package and review before relying on its local evidence; this command is not its replay or supplier admission." + }, + "first_experiment": "Choose one of the fourteen recorded stages, pin its producer, and derive the parent reserve and depth coefficient. Stop with a precise source-level missing lemma if that coefficient cannot yet be bounded; do not rerun the already checked headroom arithmetic as a new result.", + "bottleneck_link": "This reduces a concrete inherited implementation obligation without confusing unchanged kappa arithmetic with a completed theorem.", + "allowed_variations": [ + "One stage or one explicit reserve/depth implication.", + "An independently checked same-domain proof repair, retaining all remaining assumptions." + ], + "scope_change_triggers": [ + "Importing the historical 57604 or 252 allowance without a selected-producer binding.", + "Calling a conditional fit lemma a full outer-proof adoption." + ], + "overlap_terms": [ + "selected stock", + "stock envelope", + "bootstrap cutoff", + "1956", + "1965", + "1990" + ] + }, + "scope_status": "refined", + "actual_scope": "Implement the selected BIT whole-packet caller at every internal width, with recursive child return, separate compatible stock, and a full logical live-symbol reserve. Establish the baseline p=1 recurrence; retain fixed-tape lowering, stronger H2 time and outer-transfer obligations.", + "scope_change_reason": "The explicit user asks for a central implementation bottleneck. PR2697 stops at 64 <= n < 128; larger recursive children and their storage are the concrete missing implication.", + "bottleneck_link": "Replace an assumed completed recursive callee by an executable decreasing-width caller. This addresses the all-size BIT producer used by ordinary multiplication, not a local tariff or hypothetical histogram.", + "budget_minutes": 120, + "stop_rule": "Complete the recursive width/field/stock induction, implement and check the changed stream boundaries, and state the exact remaining time/outer-transfer assumptions; no substitute peripheral result.", + "outcome": "completed", + "evidence": "Source-bound all-size implementation and endpoint/stock/reserve proof; exact selected catalogue and 7843392 literal events checked, complete first-range GL2 payload replay, recursive layout/descriptor/exception checks, and a separate full two-level physical toy. See RESULT.json and VALIDATION.md for exact executed suites and limitations.", + "author": "David Arias", + "ai_assistance": "Substantial OpenAI Codex assistance, including mathematical and implementation subagents; no independent human review.", + "open_questions": [ + { + "question": "Compile the logical recursive caller to the intended fixed number of physical tapes.", + "why_it_matters": "The full live-content reserve is not a physical tape compiler or a movement-time proof.", + "first_step": "Serialize frame banks and continuations, then price cursor movement, template erasure and reuse across one recursive return.", + "blocked_by": "No implementation of that physical lowering is included." + }, + { + "question": "Replace O(wV) owner routing and ordinary leaf swaps with implementations meeting selected H2.", + "why_it_matters": "The completed caller currently supports only p=1 and does not improve the multiplication exponent.", + "first_step": "Price and improve the actual native routes.py and bitstream.py paths while preserving the complete source-bound prefix packet.", + "blocked_by": "The stronger route and leaf primitive contracts are still open." + }, + { + "question": "Supply compatible K-power stock through the outer borrowing and padding wrapper.", + "why_it_matters": "A q-ary capacity bound alone does not give the required divisible fresh rows or their return.", + "first_step": "Implement padding to a compatible multiple, restore it and propagate the full metadata reserve through the wrapper.", + "blocked_by": "The wrapper, complex supplier and full analytic transfer are outside this package." + } + ], + "freshness": { + "started_utc": "2026-10-15T19:19:46Z", + "start_main": "7b39515117fe26e75d16c268877391f1bdaa5640", + "latest_main": "63a279f5790872996a13f0e9efdae35818171b48", + "checked_utc": "2026-10-15T20:13:28Z", + "priority_revision": 5, + "guidance_changed": false, + "selected_record_changed": false, + "live_inputs_changed": false, + "decision": "Continue the isolated all-size caller. Read newly integrated control-uniformity and body-stock audits and efficient1300 review: they retain the recursive payload-dispatch/physical-caller premises and do not close this implementation gap. Preserve exact scientific base and input pins.", + "intermediate_main": "7ef5f7150476fdf995b286b9cdbed262c631939c" + }, + "overlap": { + "initial_coverage": { + "open_prs": 752, + "discussion_records": 1368, + "complete_pagination": true, + "warnings": [] + }, + "final_coverage": { + "open_prs": 727, + "discussion_records": 1382, + "local_records": 1840, + "open_prs_fetched_at": "2026-10-15T19:56:29.123108+00:00", + "discussions_fetched_at": "2026-10-15T19:59:14.008528+00:00", + "complete_pagination": true, + "warnings": [] + }, + "terms": [ + "selected-bit-recursive", + "all-size", + "recursive caller", + "selected-bit-node", + "2319" + ], + "predecessor_head_rechecked": "a53fdf4bcbe33c6732f0bec1badc8c023380f9d1", + "new_related_result": { + "pr": 2743, + "head": "c1e8065671f4f1854c5508f4bb18b85851074547", + "scope": "Sharp first-range payload/key content only; it explicitly retains larger recursion and total metadata reserve. Credit Nick Petalas; our8V is a coarse allowance, not a competing sharp first-node result." + }, + "parallel_claim": { + "url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18957230", + "author": "jmbarrancoml", + "announced_utc": "2026-10-15T19:47:00Z", + "scope": "Larger-child whole-packet boundary, exact U/source fields, same-bank/gap layout and completed return.", + "decision": "This matching claim appeared after our19:19:46 start and initial overlap pass. Continue as an explicitly independent construction with the joined all-size logical reserve, sign repair and separate tests. Do not claim exclusive novelty or priority; the pending parallel implementation remains provisional." + }, + "finer_count_claim": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18957024", + "limitations": "Metadata searches are not novelty certificates. Cached full PR/discussion records were filtered and relevant current discussions read directly. No public coordination messages were posted under the donor restriction.", + "publication_check": { + "checked_utc": "2026-10-15T20:13:28Z", + "discussion_updated_at": "2026-10-15T20:02:17Z", + "recursive_claim_still_pending": true, + "new_finer_count_result": { + "pr": 2749, + "head": "a18ba3bbfb549af66488a890edcb4a3744de90a3", + "scope": "Completed first-range cardinality/countdown storage component; sharper than our coarse allowance. Not imported as a proof dependency. Larger recursion, numerical/control storage and total reserve remain open in that submission." + } + } + }, + "validation": { + "command": "python3.12 -B scripts/research_package.py --package research/selected-bit-recursive-caller", + "python": "3.12.15", + "platform": "macOS27.0.1 arm64", + "suites": 5, + "exit_code": 0, + "seconds": 520.413, + "read_only_package_files": 84, + "changed_paths": [] + } +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/VALIDATION.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/VALIDATION.md new file mode 100644 index 0000000000..d91680665a --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/VALIDATION.md @@ -0,0 +1,56 @@ +# Validation record + +Scientific base: canonical main `7b39515117fe26e75d16c268877391f1bdaa5640`. +Fresh main `63a279f5790872996a13f0e9efdae35818171b48` was checked before submission; +guidance, priority revision 5, selected record and every live scientific input +were unchanged. New integrated body-stock and control-uniformity results were +read; both retain the missing caller/physical premises addressed here. + +Environment: local macOS arm64, CPython 3.12.15, standard library only. +Initial development also used CPython 3.14.7. No Python timing is used as a +Turing-machine complexity measurement. + +Author-side checks already passed: + +- Complete selected source catalogue and 7,843,392 literal events. +- Complete first-range four-family GL2 model: 15,552 Boolean columns, 672 + residual calls and 5,712 matched leaf brackets; 344 seconds under 3.12.15. +- Complete recursive dimension-2 toy: 9,216 exact origins, twelve real internal + returns, 156 residual calls, all six GL2 child low classes and exact remaining + row stock 6/1. Root residuals are coordinate projectors; children use the full + conjugated good/fallback normal forms. Approximately 82–94 seconds. +- Source/receipt mutation controls, sign endpoint and counter traffic checks, + stale-state witnesses, bridge/exchange directions and stock rejection. +- Large-width ordered-layout, selected descriptor/frame, failed-constructor, + aborted-child and 1,501-frame scheduler tests. Selected Frame payloads are + controlled test consumers, not a full selected GL64 execution. + +The final registered read-only replay **passed all five suites** in 520.413 +seconds, with exit status 0: + +```sh +python3.12 -B scripts/research_package.py --package research/selected-bit-recursive-caller +``` + +It emitted `PASS_SELECTED_BIT_RECURSIVE_CALLER` for source, node, recursion, +nested and controls, followed by `PASS_REGISTERED_RESEARCH_PACKAGE`. +A separate before/after SHA256 inventory covered all 84 then-present package +files: no path or byte changed. The full-node suite took 333.388 seconds; the +nested suite took 82.41 seconds. Final edits after replay only record validation, +upstream freshness and the newly published parallel PR2749; executable files and +retained receipts are unchanged. + +Additional direct CLI controls rejected optimized execution and refused to +overwrite an existing receipt. Metadata/source pins and `git diff --check` +also passed. The shared-topology test constructs five selected nodes with one +source topology and verifies zero repeated recipe/call cache growth. + +The final direct Discussion2319 check found the matching 19:47 recursive claim +still pending and the narrower first-range count component published as PR2749 +at `a18ba3bbfb549af66488a890edcb4a3744de90a3`. Both are credited in TASK/README; +no public coordination post was made. +The selected cold replay is not required or claimed: no selected artifact, +frontier or predecessor bytes were changed. No fixed-tape compiler, full GL64 +payload execution, proof-assistant verification, human review or new κ is +claimed. The optional full-conjugated outer toy was abandoned as too slow and +is not part of the retained executable or evidence. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/VERIFY.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/VERIFY.json new file mode 100644 index 0000000000..b6072f66c1 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/VERIFY.json @@ -0,0 +1,76 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "certificates/selected-result.json", + "research/community-hyperplane599-audit/pr589/bit589/v9/hosted/GLOBAL-TEMPLATE.json.gz", + "research/community-hyperplane599-audit/pr589/bit589/v9/nine/GEOMETRY.json", + "research/e8-bit-p111-tuned/tune/EXPECTED.json", + "research/e8-bit-p111-tuned/tune/bitE8mut-p111-tuned.json.gz", + "research/pr589-five-helper-hosting/PROOF.md", + "research/pr589-five-helper-hosting/verify.py", + "research/recursive-parking-boundary/README.md", + "research/selected-bit-local-ring-sweeps/PROOF.md", + "research/selected-bit-recursive-closure/PROOF.md", + "upstream/build/sections/02-streams.tex" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--suite", + "source" + ], + "timeout_seconds": 180, + "checks": "Full selected catalogue, all literal global events, gapped and sampled high-field endpoint checks" + }, + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--suite", + "node" + ], + "timeout_seconds": 600, + "checks": "Complete GL2 first-range Boolean column replay including COPY, IDLE, bridge and exchange" + }, + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--suite", + "recursion" + ], + "timeout_seconds": 60, + "checks": "Independent child layouts, all-size peel, selected descriptor/frame handoff, deep scheduler and rejected-return controls" + }, + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--suite", + "nested" + ], + "timeout_seconds": 300, + "checks": "Complete two-level physical GL2 toy execution with independent address provenance" + }, + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--suite", + "controls" + ], + "timeout_seconds": 60, + "checks": "Linear sign cost and malformed inputs, stale-state witnesses, native bridge/exchange, source and receipt mutation controls" + } + ] +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/bootstrap.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/bootstrap.py new file mode 100644 index 0000000000..448c9b3a86 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/bootstrap.py @@ -0,0 +1,11 @@ +"""Resolve the exact exported predecessor, with candidate modules first.""" +from pathlib import Path +import sys +ROOT=Path(__file__).resolve().parent +for path in (ROOT/'predecessor'/'vendor', ROOT/'predecessor', ROOT): + path=str(path) + if path in sys.path: sys.path.remove(path) + sys.path.insert(0,path) + +import sources +sources.ROOT=ROOT.parents[1] diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/check_layout.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/check_layout.py new file mode 100644 index 0000000000..be59d614d2 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/check_layout.py @@ -0,0 +1,147 @@ +"""Independent gap, peel and generated-weight endpoint checks.""" +from hashlib import sha256 +from itertools import product +import sys +from time import monotonic + +from cardinal_counts import Count +from catalogue import Catalogue, Specifications +from check_runtime import Tracker, destination +from check_support import audit, bits, inspect_count, no_decode +from consumer import IncomingWeights +from directory import Context +from layout import Layout +import model +from numeric import Geometry +import oracle +import peel +from plan import Plan +from records import Fields, Program, Tape +from words import Arena, Ring, need + + +def extents(): + arena,indices=Arena(5),Arena(11) + mod=arena.input(9);ring=Ring(mod) + columns,depth=indices.input(1),indices.input(0) + before,gap,suffix=Count.literal(2),Count.literal(5),Count.literal(7) + checks=0 + for n in (64,65,95,127): + size=indices.input(n) + geometry=Geometry(Plan(64,1,True,()),indices,columns,depth,0,object()) + layout=Layout(geometry,size,ring,3,before,gap,suffix) + for a,b in ((0,1),(0,127),(63,64),(64,65),(126,127)): + first,second=indices.input(a),indices.input(b) + with no_decode():result=layout.extents(first,second) + x=a if a<64 else a+2*(n-64) + y=b if b<64 else b+2*(n-64) + expected=[2*9**x*(5 if x>=n else 1),9**(y-x-1)*(5 if x=n else 1),7*9**(2*n-1-x)*(5 if x=3 guard. + self.q,self.dimension,self.requests=2,2,2 + self.radices=(3,2) + self.size,self.limit,self.bits=6,24,5 + + +class Catalogue: + def __init__(self): + self.codes=ToyCodes() + self.requests=(Request("MOVE",0,0),Request("MOVE",1,0)) + + def low_classes(self): + for ordinal in range(6):yield self.codes.unrank(ordinal) + + +class Topology: + families=replicas=1 + schedule=({"kind":"local_cover_sweep","stage":0},) + + def __init__(self,catalogue):self.catalogue=catalogue + + def call(self,stage,replica): + need(stage==replica==0,"toy single selected sweep") + return Call(0,0,(Owner(0,I),),(0,),(2,), + ((0,0,0,1,1,0),(0,0,1,2,1,0)),(0,1),False) + + @staticmethod + def matrix(chart):return chart + + +class UnitIncoming: + """The only nonzero coefficient over F2 is one, for every frozen prefix.""" + def __init__(self,context):self.context=context + def weight(self,index):return self.context.arena.copy(self.context.ring.one) + def coefficient(self,prefix,request): + need(request.kind=="incoming","toy incoming request") + return self.weight(request.coordinate) + + +class Consumer: + recursive=True + + def __init__(self,context,indices,program,size,depth,catalogue,topology, + incoming,plans,tracker,counters,root_axes=False,root_level=False): + self.context,self.indices,self.program=context,indices,program + self.size,self.depth=size,depth + self.catalogue,self.topology,self.incoming=catalogue,topology,incoming + self.plans,self.tracker,self.counters=plans,tracker,counters + self.root_axes=root_axes + self.root_level=root_level + + def apply(self,source,identifier,common,low,old_directory,old_count, + before,gap,suffix,observe=None,child_stock=None,child_before=None): + need(common and identifier in (0,1),"toy bound MOVE source") + context,indices=self.context,self.indices + expected_stock=Count.literal(6 if self.root_level else 1) + try: + need(child_stock is not None and expected_stock.equals(child_stock), + "nested model exact independent unused stock") + self.counters["root_stock_checks" if self.root_level else "child_stock_checks"]+=1 + finally:expected_stock.close() + plan,constants=self.plans[(identifier,low)] + if self.root_axes:plan=Plan(2,1,True,()) + code=context.codes.encode(identifier,common,low) + directory,prefixes=produce(old_directory,self.depth,old_count,code,context) + divisor,one=indices.literal(2),indices.literal(1) + columns,remainder=Unsigned(indices).divmod(self.size,divisor) + indices.free_many(divisor,remainder) + geometry=Geometry(plan,indices,columns,self.depth,code,self.program) + # A checker-only scale reduction makes width two an actual internal + # call. Production Geometry's cutoff remains exactly64. + indices.free(geometry.leaf_cutoff) + geometry.leaf_cutoff=indices.literal(2) + fields=geometry.plus(self.depth,one);indices.free(one) + layout=Layout(geometry,self.size,context.ring,context.q,before,gap,suffix) + + def coefficient(prefix,request): + # At fixed q=2,w=1 all high fields are zero and all unit weights + # are one. These finite coefficients were compiled beforehand. + if request.kind=="child":return context.arena.copy(context.ring.one) + key=(request.reference,request.reverse_adapter) + return context.arena.literal(constants[key]) + + def invoke(current,event): + self.counters["internal_calls"]+=1 + need(child_stock is not None and child_before is not None,"toy separate unused stock") + extents=layout.child_extents(event.first,event.second,event.width,before=child_before) + child_program=object() + child=Consumer(context,indices,child_program,event.width,event.depth, + self.catalogue,self.topology,self.incoming,self.plans, + self.tracker,self.counters) + node=Node(context,indices,child_program,event.width,event.depth, + self.topology,child,self.incoming) + frozen=bytes(directory.cells) + try: + result=yield Invocation(node.run_generator(current,directory,prefixes, + child_stock,*extents)) + need(bytes(directory.cells)==frozen,"toy frozen parent directory preserved") + need(current.head==result.head==directory.head==1,"toy complete child heads") + self.counters["internal_returns"]+=1 + return result + finally: + for extent in extents:extent.close() + + def boundary(kind):self.counters[kind]+=1 + try: + self.counters["residuals"]+=1 + # Two direct coordinate-projector normal forms keep the outer + # fixture economical. Every real internal child still executes + # all 12 conjugated GL2 good/fallback normal forms unchanged. + if self.root_axes: + first=geometry.raw.times_small(columns,identifier) + second=geometry.raw.times_small(columns,3-identifier) + events=child_trace(geometry,first,second,indices.copy(columns),"good") + else:events=execute(geometry) + return (yield from packet_engine.run_generator(source,events,layout, + directory,prefixes,fields,coefficient,factory=self.tracker.payload, + observe=boundary,invoke=invoke)) + finally: + layout.close();geometry.close();indices.free_many(columns,fields) + directory.clear();prefixes.close();old_directory.rewind() + + +def compile_coefficients(catalogue,context,indices,incoming): + """Fixed 12-member toy source table; host decoding occurs only here.""" + plans={} + ring=context.ring + matrices=Matrices(ring) + for low in catalogue.low_classes(): + for identifier in (0,1): + prepared=oracle.multiply(low,oracle.reduce_rational(I if identifier==0 else S,2),2) + projector=oracle.multiply([[row[0]] for row in prepared], + oracle.inverse(prepared,2)[:1],2) + good=projector[0][0]!=0 + plan=compile_plan(projector,1,2,good) + encoded=matrices.constants(projector) + form=good_form(encoded,1,ring) if good else fallback_form(encoded,ring) + columns,depth=indices.literal(1),indices.literal(0) + page=Page(plan,form,ring,indices,columns,incoming.weight,depth,0,object()) + constants={} + for command in plan.commands: + if command.kind!="add":continue + for reverse in (False,True): + value=page.coefficient(command.reference,depth,reverse) + constants[(command.reference,reverse)]=value.inspect() + context.arena.free(value) + page.close();matrices.free(encoded);indices.free_many(columns,depth) + plans[(identifier,low)]=(plan,constants) + return plans + + +def run(): + start=monotonic() + catalogue=Catalogue();topology=Topology(catalogue) + arena,indices=Arena(3),Arena(8) + modulus=arena.input(2);ring=Ring(modulus);context=Context(ring,catalogue.codes) + incoming=UnitIncoming(context) + plans=compile_coefficients(catalogue,context,indices,incoming) + size,depth=indices.input(4),indices.input(0) + program=object();tracker=Tracker();counters=Counter() + consumer=Consumer(context,indices,program,size,depth,catalogue,topology, + incoming,plans,tracker,counters,root_axes=True,root_level=True) + node=Node(context,indices,program,size,depth,topology,consumer,incoming) + source=tracker.source(36*256,linear=False);original=bytes(source.cells) + old=Tape();old_count=Count.literal(1);rows=Count.literal(36) + before,gap,suffix=Count.literal(1),Count.literal(1),Count.literal(1) + with tracker.install(), no_decode(): + output=node.run(source,old,old_count,rows,before,gap,suffix) + try: + need(bytes(source.cells)==original,"nested model read-only source") + need(source.head==output.head==old.head==1,"nested model restored heads") + for address in range(36*256): + wanted=destination(address,4,2,(1,1,1,1)) + need(output.origins.get(wanted+1)==address,"nested model exact complete F endpoint") + need(len(output.origins)==36*256,"nested model exact output extent") + need(counters["internal_calls"]==counters["internal_returns"]>0, + "nested model actual internal returns") + need(counters["internal_calls"]==12 and counters["residuals"]==156 + and counters["root_stock_checks"]==12 and counters["child_stock_checks"]==144, + "complete two-level GL2 source and stock coverage") + need(counters["enter"]==counters["return"],"nested model all child brackets close") + need(tracker.live=={source,output},"nested model all tracked work erased") + record={"domain":"toy q=2, dimension=2, cutoff=2, one family; not selected GL64", + "root_normal_forms":"coordinate projectors", + "root_width":4,"root_rows":36,"complete_addresses":36*256, + "child_fresh_rows":6,"leaf_unused_rows":1, + "low_classes":6,"counts":dict(sorted(counters.items())), + "output_sha256":sha256(bytes(output.cells)).hexdigest(), + "tracked_work_erased":tracker.erased} + finally: + output.clear();source.clear();old.clear() + for value in (old_count,rows,before,gap,suffix):value.close() + indices.free_many(size,depth);context.close();ring.close();arena.free(modulus) + need(not indices.live and not arena.live,"nested model numerical restoration") + print("nested model completed in %.2fs"%(monotonic()-start),flush=True) + return record + + +if __name__=="__main__": + import json + print(json.dumps(run(),sort_keys=True)) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/check_recursion.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/check_recursion.py new file mode 100644 index 0000000000..8f36c88e19 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/check_recursion.py @@ -0,0 +1,544 @@ +"""Independent layout, lifecycle and real-frame junction checks. + +The frame test patches only SelectedNode.run_generator with a tiny controlled +consumer. It exercises the real descriptor/Frame/old-directory handoff and +return, not the unmaterialized complete selected GL64 payload or its endpoint. +""" +from collections import Counter +from dataclasses import replace +from hashlib import sha256 +import json +from pathlib import Path +import sys +from types import SimpleNamespace + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import bootstrap +from cardinal_counts import Count +from catalogue import Catalogue, Specifications +from check_support import audit, bits, inspect_count, no_decode +from directory import Context, append_tape +from layout import Layout +import node +from numeric import Geometry +import oracle +import model +from packet import read_prefix +import packet_engine +import peel +from records import Fields, Program, Tape +import recursive_call +from recursive_call import child_call +from scheduler import Invocation, complete +from trace import Event, child, pair_command +from words import Arena, BLANK, RIGHT, Ring + + +def expected_extents(n, dimension, modulus, first, second, width, before, gap, suffix): + core = dimension * (n // dimension) + def physical(i): + return i if i < core else i + 2 * (n - core) + a, b = physical(first), physical(second) + assert physical(first + width - 1) == a + width - 1 + assert physical(second + width - 1) == b + width - 1 + assert a + width <= n or a >= n + assert b + width <= n or b >= n + result = [before * modulus ** a, modulus ** (b - a - width), + suffix * modulus ** (2 * n - b - width)] + result[0 if a >= n else 2 if b + width <= n else 1] *= gap + return tuple(result) + + +def layout_case(n, dimension, modulus, chunk, invalid=False): + indices = Arena(max(9, (4 * n).bit_length() + 1)) + residues = Arena(modulus.bit_length() + 1) + m = residues.input(modulus); ring = Ring(m) + size, columns, zero = (indices.input(v) for v in (n, n // dimension, 0)) + geometry = Geometry(SimpleNamespace(dimension=dimension), indices, columns, zero, 0, zero) + before, gap, suffix = (Count.literal(v) for v in (2, 5, 3)) + layout = Layout(geometry, size, ring, 3, before, gap, suffix) + first, second, width = (indices.input(v) for v in chunk) + output = None + try: + try: + with no_decode(): + output = layout.child_extents(first, second, width, before=before) + except ValueError: + if invalid: + return None + raise + assert not invalid, 'invalid projected child accepted' + result = tuple(inspect_count(v) for v in output) + assert result == expected_extents(n, dimension, modulus, *chunk, 2, 5, 3) + assert result[0] * modulus ** (2 * chunk[2]) * result[1] * result[2] == 30 * modulus ** (2 * n) + return result + finally: + if output is not None: + for value in output: value.close() + layout.close(); geometry.close() + indices.free_many(size, columns, zero, first, second, width) + ring.close(); residues.free(m) + for value in (before, gap, suffix): value.close() + audit(indices); audit(residues) + + +def layouts(): + digest = sha256(); count = invalid = 0 + for dimension, sizes in ((2, (4, 5, 6, 7)), (64, (64, 65, 128, 129, 191, 192, 193, 257))): + for n in sizes: + f = n // dimension; rank = min(42, dimension - 1) + chunks = [(0, (2 * dimension - rank) * f, rank * f)] + chunks += [(i * f, k * f, f) for i, k in ((0, 1), (0, dimension), (dimension, 2 * dimension - 1))] + if f // 2: + chunks += [(k * f, (k + 1) * f - f // 2, f // 2) for k in (1, dimension + 1)] + for modulus in (3, 9): + for chunk in chunks: + result = layout_case(n, dimension, modulus, chunk) + digest.update(json.dumps([n, dimension, modulus, chunk, result]).encode()); count += 1 + core = dimension * f + for chunk in ((0, 1, 2), (core - 1, core + 2, 2)): + layout_case(n, dimension, 3, chunk, invalid=True); invalid += 1 + return {'cases':count, 'rejected_overlapping_or_noncontiguous_chunks':invalid, + 'moduli':[3,9], 'spectators':[2,5,3], 'digest':digest.hexdigest()} + + +def traces(): + result = [] + for n in (128, 4096, 8192): + indices = Arena((4 * n).bit_length() + 1) + columns, depth = indices.input(n // 64), indices.input(3) + program = object() + page = Geometry(SimpleNamespace(dimension=64), indices, columns, depth, 17, program) + for label, target, source in (('pair_head',0,1), ('pair_tail',64,65), ('unit_cross',0,64)): + kind = 'unit' if label == 'unit_cross' else 'pair' + command = SimpleNamespace(target=target, source=source, reference=SimpleNamespace(kind=kind)) + generator = pair_command(page, command) + counts = Counter(); boundaries = [] + with no_decode(): + for event in generator: + counts[event.kind] += 1 + if event.kind == 'enter': + boundaries.append([event.child_kind, inspect_count(event.width), event.half, + event.field, event.reverse]) + f = n // 64 + expected = 1 if target < 64 <= source else 3 + assert counts['enter'] == counts['return'] == expected + assert counts['invoke'] == (int(f >= 64) + (2 * int(f // 2 >= 64) if expected == 3 else 0)) + result.append({'parent_width':n, 'kind':label, 'events':dict(counts), 'boundaries':boundaries}) + generator = child(page, indices.zero(), indices.input(86 * (n // 64)), + indices.input(42 * (n // 64)), 'good') + with no_decode(): + kinds = [event.kind for event in generator] + assert kinds == ['enter', 'invoke', 'return'] + result.append({'parent_width':n, 'kind':'good', 'events':kinds, 'width':42*(n//64)}) + page.close(); indices.free_many(columns, depth); audit(indices) + return result + + +def trampoline(): + entered = []; returned = []; closed = [] + def descend(depth, fail=False): + entered.append(depth) + try: + if depth: + value = yield Invocation(descend(depth - 1, fail)) + else: + if fail: raise ValueError('deliberate deepest controlled failure') + value = 0 + returned.append(depth) + return value + 1 + finally: + closed.append(depth) + assert complete(descend(1500)) == 1501 + assert entered == list(range(1500, -1, -1)) + assert returned == closed == list(range(1501)) + entered.clear(); returned.clear(); closed.clear() + try: + complete(descend(1100, True)) + except ValueError as error: + assert str(error) == 'deliberate deepest controlled failure' + else: + raise AssertionError('deep child failure was swallowed') + assert closed == list(range(1101)) and not returned + def illegal(): + yield 'non-invocation suspension' + try: complete(illegal()) + except ValueError: pass + else: raise AssertionError('untyped suspension accepted') + return {'completed_frames':1501, 'closed_after_failure':1101, 'host_recursion_limit_unchanged':True} + + +def lifecycle(): + indices = Arena(10); columns, depth = indices.input(2), indices.zero() + program = object(); page = Geometry(SimpleNamespace(dimension=64), indices, columns, depth, 3, program) + layout = SimpleNamespace(geometry=page, fibre=lambda:Count.literal(1)) + one = Count.literal(1); fields = indices.zero(); directory = Tape() + source = Tape(); source.append(1); source.rewind() + words = [indices.input(v) for v in (0,172,84,1)] + base = Event('enter', words[0], words[1], width=words[2], depth=words[3], + child_kind='good', source_code=3, parent_identity=program) + invoke_count = [] + def consumer(current, event): + invoke_count.append(event.child_kind) + if mode == 'aliased_output': + if False: yield + return current + output = Tape(); append_tape(current, output); output.rewind() + if False: yield + return output + def events(mode): + yield base + if mode != 'missing_invoke': yield replace(base, kind='invoke') + if mode == 'duplicate_invoke': yield replace(base, kind='invoke') + if mode == 'width_mutation': + page.raw.increment_in_place(base.width) + if mode == 'aliased_metadata_mutation': + base.field = 1 + if mode != 'missing_return': + yield replace(base, kind='return', field=1 if mode == 'metadata_mutation' else base.field) + rejected = [] + for mode in ('normal','missing_invoke','duplicate_invoke','missing_return','metadata_mutation', + 'aliased_output','aliased_metadata_mutation','width_mutation'): + base.field = 0 + original = bytes(source.cells); output = None + try: + with no_decode(): + output = packet_engine.run(source,events(mode),layout,directory,one,fields,None,invoke=consumer) + assert mode == 'normal', 'malformed recursive lifetime accepted: ' + mode + assert bits(output) == bytes([1]) and output is not source + except ValueError: + assert mode != 'normal' + rejected.append(mode) + finally: + if output is not None and output is not source: output.clear() + assert bytes(source.cells) == original and source.head == directory.head == 1 + source.clear(); directory.clear(); one.close(); page.close() + indices.free_many(columns, depth, fields, *words); audit(indices) + return {'normal_owned_return':True, 'rejected':rejected} + + +def abort_cleanup(): + """A child exception must erase the parent's already-created output.""" + indices = Arena(10); columns, level = indices.input(1), indices.zero() + identity = object() + geometry = Geometry(SimpleNamespace(dimension=64),indices,columns,level,0,identity) + layout = SimpleNamespace(geometry=geometry,fibre=lambda:Count.literal(1)) + source = Tape(); source.append(1); source.rewind() + directory = Tape(); prefixes = Count.literal(1); fields = Count.literal(0) + operands = [indices.input(v) for v in (0,64,64,1)] + boundary = Event('enter',operands[0],operands[1],width=operands[2],depth=operands[3], + parent_identity=identity,child_kind='good') + created = [] + class Captured(Tape): + def __init__(self): + super().__init__(); created.append(self) + def events(): + yield Event('sign',operands[0]) + yield boundary + yield replace(boundary,kind='invoke') + yield replace(boundary,kind='return') + def fail(current,event): + if False: yield + raise ValueError('controlled failed child') + original_action = packet_engine.action + packet_engine.action = lambda local,event,layout,coefficient,factory:local + try: + try: + complete(packet_engine.run_generator(source,events(),layout,directory,prefixes,fields, + None,factory=Captured,invoke=fail)) + except ValueError as error: assert str(error) == 'controlled failed child' + else: raise AssertionError('child exception swallowed') + assert created and all(not bits(tape) and tape.head==1 for tape in created) + assert bits(source)==bytes([1]) and source.head==directory.head==1 + finally: + packet_engine.action=original_action + source.clear();directory.clear();prefixes.close();fields.close();geometry.close() + indices.free_many(columns,level,*operands) + audit(indices) + return {'child_failure_propagated':True,'owned_parent_tapes_erased':len(created), + 'scope':'controlled primitive creates owned output before failing child; real packet engine and scheduler'} + + +def construction_failure(): + """Failed construction cannot leave a frame that the caller cannot own.""" + indices,arena=Arena(10),Arena(3) + modulus=arena.input(3);ring=Ring(modulus) + context=Context(ring,SimpleNamespace(q=3,dimension=64,bits=2)) + program=Program.fixture(indices,arena,256,2,[],2) + width,depth=indices.input(168),indices.input(1) + parent=SimpleNamespace(context=context,indices=indices,specifications=SimpleNamespace(catalogue=object())) + event=SimpleNamespace(width=width,depth=depth) + banks=[];programs=[] + original_arena,original_program,original_node=recursive_call.Arena,recursive_call.Program,node.SelectedNode + def bank(*args,**kwargs): + result=original_arena(*args,**kwargs);banks.append(result);return result + def copied_program(*args,**kwargs): + result=original_program(*args,**kwargs);programs.append(result);return result + def reject_constructor(child_context,child_indices,*args): + child_context.arena.zero();child_indices.zero() + raise ValueError('injected child construction failure') + recursive_call.Arena,recursive_call.Program,node.SelectedNode=bank,copied_program,reject_constructor + saved=bytes(program.tape.cells) + try: + try: + with no_decode(): recursive_call.Frame(parent,program,event) + except ValueError as error: assert str(error)=='injected child construction failure' + else: raise AssertionError('constructor injection was not reached') + assert len(banks)==2 and len(programs)==1 + for value in banks:audit(value) + assert not bits(programs[0].tape) + assert bytes(program.tape.cells)==saved and program.tape.head==1 + finally: + recursive_call.Arena,recursive_call.Program,node.SelectedNode=original_arena,original_program,original_node + program.tape.clear();indices.free_many(width,depth);context.close();ring.close();arena.free(modulus) + audit(indices);audit(arena) + return {'failed_fresh_banks_erased':2,'copied_program_erased':True,'parent_program_unchanged':True} + + +def all_size_peel(): + """Lower actual peel.run to independent scalar rows, without dense bits.""" + indices,arena=Arena(10),Arena(5) + modulus=arena.input(9);ring=Ring(modulus) + context=SimpleNamespace(dimension=64,q=3,ring=ring,arena=arena) + size,depth=indices.input(129),indices.zero() + values=[1]*129;values[64]=2;values[128]=5 + incoming=model.Incoming(context,indices,values) + source,old=Tape(),Tape() + old_count,stock,before,gap,suffix=(Count.literal(v) for v in (1,7,2,5,3)) + original_run=packet_engine.run + def collect(force_legacy_columns): + rows=[{i:1} for i in range(258)] + coordinates=[];counts=Counter();positions=set() + def scalar(source_arg,events,layout,directory,prefixes,fields,coefficient,**kwargs): + assert source_arg is source and directory is old + assert inspect_count(layout.geometry.columns)==2 and not layout.embedded + assert [inspect_count(x) for x in (layout.before,layout.gap,layout.suffix)]==[14,5,3] + if force_legacy_columns: + replacement=indices.literal(1);column_word=layout.geometry.columns + while replacement.read()!=RIGHT: + column_word.write(replacement.read());column_word.step(1);replacement.step(1) + column_word.rewind();replacement.rewind();indices.free(replacement) + try: + for event in events: + first=inspect_count(event.first);positions.add(first);counts[event.kind]+=1 + if event.kind=='sign': + rows[first]={j:(-value)%9 for j,value in rows[first].items()} + else: + second=inspect_count(event.second);positions.add(second) + if event.kind=='atom_swap': rows[first],rows[second]=rows[second],rows[first] + else: + assert event.kind=='add' + coordinates.append(inspect_count(event.request.coordinate)) + value=coefficient(old,event.request);scalar_value=inspect_count(value);arena.free(value) + for j,entry in rows[second].items():rows[first][j]=(rows[first].get(j,0)+scalar_value*entry)%9 + rows[first]={j:value for j,value in rows[first].items() if value} + finally:events.close() + return source + packet_engine.run=scalar + with no_decode(): + assert peel.run(source,context,indices,size,depth,object(),old,old_count, + stock,before,gap,suffix,incoming) is source + return rows,coordinates,counts,positions + try: + actual,coordinates,counts,positions=collect(False) + expected=[{i:1} for i in range(258)];expected[128]={129:5};expected[129]={128:2} + assert actual==expected and coordinates==[128]*3 and positions=={128,129} + assert counts=={'atom_swap':4,'add':3,'sign':1} + legacy,legacy_coordinates,legacy_counts,_=collect(True) + assert legacy!=expected and legacy_coordinates[0]==64 and legacy_counts['sign']==65 + finally: + packet_engine.run=original_run + incoming.close();source.clear();old.clear() + for value in (old_count,stock,before,gap,suffix):value.close() + indices.free_many(size,depth);ring.close();arena.free(modulus) + audit(indices);audit(arena) + return {'parent_width':129,'dimension':64,'columns':2,'remainder':1,'modulus':9, + 'incoming_weights':{'0':1,'64':2,'128':5},'queried_offsets':coordinates, + 'changed_scalar_rows':{'128':{'129':5},'129':{'128':2}}, + 'primitive_counts':dict(counts),'legacy_columns_one_rejected':True, + 'scope':'actual peel.run and incoming callback; independent scalar opcode interpreter; no dense payload'} + + +def frame_handoff(catalogue=None, mutation=None): + catalogue = Catalogue(3) if catalogue is None else catalogue + specifications = Specifications(catalogue) + identifier = next(i for i,r in enumerate(catalogue.requests) if r.base.rank == 42) + template = catalogue.template_for(identifier, True) + low = tuple(map(tuple, oracle.inverse(oracle.reduce_rational(template.preparation, 3), 3))) + spec = specifications.bind(identifier, True, low) + assert spec.good and spec.template.rank == 42 + indices, arena = Arena(10), Arena(3) + modulus = arena.input(3); ring = Ring(modulus); context = Context(ring, catalogue.codes) + size, depth = indices.input(256), indices.zero() + program = Program.fixture(indices, arena, 256, 2, [], catalogue.codes.bits) + root_node=node.SelectedNode(context,indices,program,size,depth,catalogue,specifications) + parent=root_node.consumer + # Exercise repeated actual construction: these source caches must not + # acquire one new self key for every completed recursive frame. + common_topology=root_node.topology + common_call=common_topology.call(0,0) + cache_sizes=(type(common_topology).call.cache_info().currsize, + type(common_topology).recipe.cache_info().currsize) + extra_nodes=[node.SelectedNode(context,indices,program,size,depth,catalogue,specifications) + for _ in range(2)] + for repeated in extra_nodes: + assert repeated.topology is common_topology + assert repeated.topology.call(0,0) is common_call + zero_high = [[0] * 64 for _ in range(64)] + field = Fields.fixture(indices, arena, [(spec.code, zero_high)], catalogue.codes.bits) + directory = Tape(); append_tape(field.tape,directory); append_tape(field.tape,directory); directory.rewind() + field.tape.clear() + prefixes, stock, before, gap, suffix = (Count.literal(v) for v in (2,11,2,5,3)) + fields = indices.input(1) + source = Tape() + original_payload = bytes((i * 7 ^ i // 3) & 1 for i in range(23)) + for bit in original_payload: source.append(bit) + source.rewind() + original_program, original_directory = bytes(program.tape.cells), bytes(directory.cells) + frames = []; handoffs = []; returned = []; outputs = []; injected = [] + protected_indices, protected_residues = set(indices.live), set(arena.live) + original_run = node.SelectedNode.run_generator + + def controlled_run(self, current, old, count, unused, b, g, s, observe=None): + # Test instrumentation reads encoded values; production code stays + # under no_decode and never sees these Python integers. + level, width = inspect_count(self.depth), inspect_count(self.parent_size) + frames.append(self) + assert self.topology is common_topology + assert self.topology.call(0,0) is common_call + assert self.indices is not indices and self.context.arena is not arena + assert unused is stock and inspect_count(unused) == 11 and inspect_count(count) == 2 + assert level in (1,2) and width == {1:168,2:84}[level] + root_size, root_unit, root_depth = self.program.root() + assert (inspect_count(root_size),inspect_count(root_unit),inspect_count(root_depth)) == (256,2,level) + self.indices.free_many(root_size,root_depth); self.context.arena.free(root_unit) + slot = self.indices.input(level) + metadata, previous, generated = self.program.step(slot) + assert metadata == (0,spec.code,42,0,0,0) + assert (inspect_count(previous),inspect_count(generated)) == ({1:256,2:168}[level],width) + self.indices.free_many(slot,previous,generated) + # Every original physical prefix remains present in the same order. + old.rewind() + for _ in range(2): + saved = read_prefix(old,self.depth) + assert bits(saved) == bits(directory)[:len(bits(directory))//2] * level + saved.clear() + assert old.read() == BLANK # Exactly two complete physical prefixes. + old.rewind() + power = {1:176,2:344}[level] + assert tuple(inspect_count(x) for x in (b,g,s)) == (2,5*3**power,3) + handoffs.append({'depth':level,'width':width,'prefixes':2,'stock':11, + 'before':2,'gap':'5*3^'+str(power),'suffix':3}) + original = bytes(current.cells) + if level == 1: + new_directory = Tape(); old.rewind() + new_field = Fields.fixture(self.indices,self.context.arena,[(spec.code,zero_high)],catalogue.codes.bits) + for _ in range(2): + old_prefix = read_prefix(old,self.depth) + append_tape(old_prefix,new_directory); append_tape(new_field.tape,new_directory) + old_prefix.clear() + old.rewind(); new_directory.rewind(); new_field.tape.clear() + child_fields = self.indices.input(2) + cb,cg,cs = (Count(x) for x in (b,g,s)) + try: + transformed = yield from invoke(self.consumer,current,new_directory,count,child_fields,unused,cb,cg,cs) + output = Tape(); outputs.append(output) + transformed.rewind() + while transformed.read() in (0,1): + output.append(1-transformed.read()); transformed.step(1) + transformed.rewind(); transformed.clear(); output.rewind() + finally: + self.indices.free(child_fields); new_directory.clear() + for value in (cb,cg,cs):value.close() + else: + # Deliberately tiny controlled permutation, not selected BIT. + values = bits(current); output = Tape(); outputs.append(output) + for bit in reversed(values): output.append(bit) + output.rewind() + assert bytes(current.cells) == original and current.head == old.head == self.program.tape.head == 1 + if level == 2 and mutation is not None: + injected.append(mutation) + if mutation == 'source_bit': current.cells[1] ^= 1 + elif mutation == 'directory_bit': old.cells[1] ^= 1 + elif mutation == 'output_head': output.step(1) + else: raise AssertionError('unknown fixture mutation') + returned.append(level) + return output + + def invoke(owner,current,old,count,field_count,unused,b,g,s): + local_indices=owner.indices; n=inspect_count(owner.parent_size); f=n//64 + columns=local_indices.input(f) + geometry=Geometry(SimpleNamespace(dimension=64),local_indices,columns,owner.depth,spec.code,owner.program) + leading=Count.product(unused,b) + layout=Layout(geometry,owner.parent_size,owner.context.ring,3,leading,g,s) + operands=[local_indices.input(v) for v in (0,86*f,42*f,inspect_count(owner.depth)+1)] + event=Event('invoke',operands[0],operands[1],width=operands[2],depth=operands[3], + child_kind='good',source_code=spec.code,parent_identity=owner.program) + saved_source, saved_directory = bytes(current.cells), bytes(old.cells) + try: + result = yield from child_call(owner,current,event,layout,old,count,field_count,unused,b) + assert bytes(current.cells) == saved_source, 'independent checker: frozen source bytes changed' + assert bytes(old.cells) == saved_directory, 'independent checker: frozen directory bytes changed' + return result + finally: + layout.close();geometry.close();leading.close();local_indices.free_many(columns,*operands) + + node.SelectedNode.run_generator=controlled_run + rejection = None + try: + with no_decode(): + output=complete(invoke(parent,source,directory,prefixes,fields,stock,before,gap,suffix)) + assert bits(output) == bytes(1-bit for bit in reversed(original_payload)) + assert bytes(source.cells)[1:] == original_payload + assert bytes(directory.cells)==original_directory and bytes(program.tape.cells)==original_program + assert source.head==output.head==directory.head==program.tape.head==1 + assert returned == [2,1] + assert mutation is None, 'injected return corruption escaped the checker' + assert indices.live==protected_indices and arena.live==protected_residues + for frame in frames: + audit(frame.indices); audit(frame.context.arena) + assert not bits(frame.program.tape) + output.clear() + except (ValueError, AssertionError) as error: + if mutation is None or injected != [mutation]: raise + rejection = str(error) + expected = {'source_bit':'independent checker: frozen source bytes changed', + 'directory_bit':'independent checker: frozen directory bytes changed', + 'output_head':'completed recursive return restores caller heads'}[mutation] + assert rejection == expected + finally: + node.SelectedNode.run_generator=original_run + for output in outputs: output.clear() + source.clear();directory.clear();program.tape.clear() + for value in (prefixes,stock,before,gap,suffix):value.close() + indices.free_many(size,depth,fields);context.close();ring.close();arena.free(modulus) + audit(indices);audit(arena) + assert (type(common_topology).call.cache_info().currsize, + type(common_topology).recipe.cache_info().currsize)==cache_sizes + for frame in frames: + audit(frame.indices); audit(frame.context.arena) + assert not bits(frame.program.tape) + if mutation is not None: + return {'mutation':mutation,'rejection':rejection,'closed_frames':len(frames), + 'check_kind':'runtime head contract' if mutation=='output_head' else 'independent preserved-input oracle'} + return {'source_request':identifier,'source_rank':42,'depths':2,'widths':[256,168,84], + 'selected_node_constructions':3+len(frames),'shared_topology_instances':1, + 'repeated_call_recipe_cache_growth':0, + 'sampled_old_prefixes':2,'controlled_payload_bits':23, + 'handoffs':handoffs,'return_order':returned, + 'scope':'real selected constructors, Callback.extend, Frame and directory handoff; controlled child consumer only', + 'complete_selected_GL64_payload_executed':False} + + +def run(catalogue=None): + catalogue = Catalogue(3) if catalogue is None else catalogue + return {'status':'PASS_RECURSIVE_JUNCTIONS','layouts':layouts(),'traces':traces(), + 'trampoline':trampoline(),'lifecycle':lifecycle(),'frame_handoff':frame_handoff(catalogue), + 'abort_cleanup':abort_cleanup(),'construction_failure':construction_failure(), + 'all_size_peel':all_size_peel(), + 'frame_mutations':[frame_handoff(catalogue, mutation) + for mutation in ('source_bit','directory_bit','output_head')]} + + +if __name__ == '__main__': + print(json.dumps(run(),indent=2)) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/check_runtime.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/check_runtime.py new file mode 100644 index 0000000000..fe355a7034 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/check_runtime.py @@ -0,0 +1,181 @@ +"""Complete Boolean model with linear provenance attached by the checker.""" +from collections import Counter, deque +from contextlib import contextmanager +from hashlib import sha256 +import sys +from time import monotonic + +import bitstream +import cardinality +from cardinal_counts import Count +from check_support import audit, bits, no_decode +import counts +from directory import Context +import driver +import fresh_rows +import model +import linear_sign +import node +import packet +import packet_engine +from records import Tape +import stream +from words import Arena, BLANK, LEFT, ONE, Ring, ZERO, need + + +class Tracker: + def __init__(self): + self.last=None;self.recent=deque(maxlen=2);self.xor=False + self.live=set();self.erased=0;state=self + class Control(Tape): + def __init__(self): + super().__init__();state.live.add(self) + + def clear(self): + super().clear() + need(self.head==1 and not bits(self),"erased node control work") + if self in state.live:state.live.remove(self);state.erased+=1 + + class Payload(Tape): + def __init__(self): + super().__init__();self.origins={};state.live.add(self) + + def read(self): + value=super().read() + if self.head in self.origins: + state.last=self.origins[self.head];state.recent.append(state.last) + return value + + def write(self,value): + super().write(value) + if value==BLANK:self.origins.pop(self.head,None) + elif value in (ZERO,ONE): + if state.xor: + need(len(state.recent)==2,"two observed Boolean XOR operands") + self.origins[self.head]=state.recent[0]^state.recent[1] + elif state.last is not None:self.origins[self.head]=state.last + + def clear(self): + super().clear() + need(self.head==1 and not self.origins and not bits(self),"erased node payload work") + if self in state.live:state.live.remove(self);state.erased+=1 + self.payload,self.control=Payload,Control + + def source(self,length,linear=True): + tape=self.payload() + for i in range(length):tape.append(((i*13)^(i>>3)^(i>>7)^0x53)&1) + tape.origins={i+1:(1<= 2^80`, `1 <= m <= 64`, `w,n,C >= 1`, and `h >= 0` be integers. +There are `C` old physical positions, including repeated or empty tuples, +`h` frozen fields per position, and one new field. Fix one vocabulary of +`1 <= R0 <= 28278` requests, and use its same minimal code width for all +frozen and current fields. Define + +``` +N = product_(k=0)^(m-1) (q^m-q^k), +B = bitlength(2 R0 N-1), L = bitlength(q^w)+1, +H = q^(m²(w-1)), J = B + m²(L+1) + 2. +``` + +For a source-correct GL interpretation, q must additionally be an odd prime +and the predecessor's other source premises must hold. The storage inequality +itself only uses the stated integer inequalities, so it does not establish +primality or source correctness by checking a large integer fixture. + +The unchanged `append_finite` emits B bits and `WORD_END`; `append_word` +emits L bits and `WORD_END`; each field then emits `RECORD_END`. Thus J is +the exact field extent derived in PR2590. `directory.produce` emits every +old position and every high key exactly once. Counting the tape's initial +`LEFT` cell as well, the occupied directory extent is exactly + +``` +D = 1 + C H (h+1) J. +``` + +There is no allocated trailing blank cell in the retained `Tape.cells`. +This is a count of its fixed-alphabet symbols, not Python object overhead. + +Let each complete Boolean fibre have R bits and impose + +``` +R >= q^(2nw), 17(h+1) <= 20051 w. +``` + +The packet payload is `V = C H R` bits. In particular it includes the entire +body, unused stock and suffix spectators of the predecessor's complete-fibre +contract. R is not just the small slice modified by one local operation. +The depth inequality follows from PR2569's retained coupling +`w=ceil(e^(17/10000))`, `2^(h+1)<=8e²`: taking logarithms gives +`h+1 <= 3+(20000/17)log2(w) <= (20051/17)w`. It is a sufficient envelope, +not a claim that every pair satisfying it is realized by a caller. + +## Uniform numerical inequality + +Write `ell=bitlength(q)`, so ell>=81 and `2^(ell-1)<=q<2^ell`. +Since `2R0<2^16` and `N=81` and `8211<108*81`. Because +`CH(h+1)>=1`, the leading LEFT cell can be absorbed without dropping it: + +``` +D <= CH(h+1)(J+1) < 8300 CH(h+1)w ell. +``` + +For integers w>=1 and q>=3, `w<=q^(w-1)`: it holds at one and induction +uses `w+1<=q w`. Therefore + +``` +D/V < (8300*20051/17) ell * w²/q^(2nw) + <= (8300*20051/17) ell/q². +``` + +The sequence `ell/2^(2(ell-1))` decreases for positive integer ell, since +the ratio of successive terms is `(ell+1)/(4ell)<1`. Hence + +``` +ell/q² <= 81/2^160, +8300*20051*81 < 17*2^30, +D < 2^-130 V. +``` + +This proves the all-input statement. The strict constant is convenient and +not asserted optimal. No numerical logarithm, enormous high-cube materialization, +sampling assumption or empirical asymptotic fit is used in the proof. + +## Physical encoding and use in a caller ledger + +The retained record machine has symbols 0 through 13. A fixed four-bit +encoding therefore occupies exactly `4D` bits for this directory. Consequently + +``` +4D < 2^-128 V, 5D < 2^-127 V, 20D < 2^-125 V. +``` + +The last two inequalities bound the **directory term** `5D` in the +predecessor's parking formula, in symbol cells and in the four-bit encoding. +They do not include separately mentioned role markers or other caller state. +The smaller directory-only allowance is a constructive storage upper bound; +it is not a runtime bound or an admission of the old literal reserve constants. + +For any nonempty finite collection of simultaneously live directories satisfying the +same premises separately, summing gives `sum D_i < 2^-130 sum V_i`, with the +analogous encoded and parking bounds. In particular a live parent and returned +child directory must both be counted. There is no conclusion here that +`sum V_i` equals one current packet, is bounded by the root payload, or follows +the old `V+4v`/`5V+19v` expressions without a new caller occupancy argument. + +The caller must still supply those live volumes and lifetimes; route buckets, +odometer and cardinality tapes, control headers, child-private workspace, owned +and borrowed dirty buffers, and restoration state have separate bills. The +finite source executions below validate directory serialization, not those +global peak or numeric reserve obligations. No directory is free. + +## Boundaries and evidence + +The verifier executes the unchanged producer on complete small high cubes, +repeated/empty old tuples and the selected m=64/w=1 format. An independent +literal serializer checks every returned symbol, the exact J/D formulas, +the LEFT cell and physical multiplicities. Large-q checks use arithmetic +only; the source's fixed-q compiler is not executed at astronomical q. + +The countermodels keep the distinctions effective: tiny q, a header-only +fibre, unbounded frozen depth, or arbitrary padding of the supposedly minimal +code can defeat the numerical fraction. Dropping delimiters or the LEFT cell +understates actual serialized storage. These examples do not refute PR2569, +whose complete-body/root-coupling and fixed-format premises are retained. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/evidence/pr2708-README.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/evidence/pr2708-README.md new file mode 100644 index 0000000000..79b8742f32 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/evidence/pr2708-README.md @@ -0,0 +1,114 @@ +# Sharp live payload/key storage for the selected BIT owner route + +This closes one storage component of Jose Manuel's pending [PR2697](https://github.com/CrocSwap/integer-mult-bounds/pull/2697), pinned at `a53fdf4bcbe33c6732f0bec1badc8c023380f9d1`. Its complete first-node caller leaves route temporaries as `O_q(v)+O(V/W)` and total numerical reserve open. Here the unchanged `route_packet` has an exact live-content peak, including its borrowed input: + +```text +w > 1: 2v + 3H(R+J) +w = 1: 2v + 2HR + HJ +``` + +These are proved for the source routine's well-formed successful runs. Eight complete small fixtures attain the formulas when executing that same routine. This is a component certificate and a scoped caller corollary. It does not establish a total reserve, admit a supplier or change kappa. + +Coordination: [Discussion2319 claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18954841). Base main `b5ea56e0a5ac4552166253b1fa4be0753bb38c30`, priority revision 5. The selected record remains unchanged. + +## Contract and counted storage + +Let q be an odd prime, d the fixed matrix dimension, w a positive payload precision, and `cap=q^(w-1)`. Set + +```text +H = cap^(d*d) complete high matrices per old prefix +C >= 1 physical old-prefix count, repetitions retained +R >= 1 payload symbols in one high-matrix fibre +t = HR one complete high cube +v = CHR one packet +J = d*d*(ell+1) serialized route key +``` + +Here ell is the actual residue arena's fixed binary word length, including its supplied padding. Each of the d*d key words contributes ell binary symbols and one WORD_END delimiter. No minimal encoding assumption is needed. The compiled route must act bijectively on the complete high cube and satisfy the retained source context/word-margin contracts. Every factory invocation creates a fresh, distinct, initially empty tape. The input is exactly v contiguous binary payload symbols and is retained unchanged. + +The count is the number of simultaneously nonblank payload and embedded-key symbols on route tapes, excluding each tape's LEFT marker. Cleared symbols cease to contribute even if the Python bytearray remains allocated. Numerical arena words, counters, context, fixed compilation, tape markers, provenance dictionaries and other Python heap capacity are excluded. This is deliberately narrower than occupied tape volume or process memory. The source's exact abstract tape semantics and ordinary ownership discipline are premises. + +## Lifetime proof + +Write `K=H(R+J)=t+HJ` for one decorated cube. Its content has a fixed length independent of key values, bucket balance, route chart or input bits. + +In `partition`, the current decorated cube retains K symbols. During bucket filling, the two buckets have combined content at most K; the separate key scratch has at most J symbols and the following output is empty. Thus the total is at most `2K+J <= 3K`, since H and R are positive. During bucket concatenation the key scratch has been cleared, while the buckets, current input and growing following output contribute at most 3K. At the final appended output symbol they contribute exactly 3K. The buckets are only cleared in `partition`'s finally block. Clearing current occurs later in `route_cube`, after partition returns. + +During decoration, `route_cube` has at most K decorated symbols, plus numerical scratch excluded above. During key stripping it retains the decorated input and grows a pure output of size at most t, giving at most `K+t <= 3K`. A partition therefore determines its sharp internal peak when cap>1. There is at least one partition because d>=1, ell>=2 and cap>1. If cap=1 there are no partitions, H=1, and the sharp internal peak is K+t at completion of key stripping. + +For old prefix p, numbered 0 through C-1, `route_packet` retains its original v-symbol input, the already completed outer output of length pt, and a separate local cube of length t while `route_cube` runs. Consequently for cap>1 its peak is + +```text +v + pt + t + 3K <= 2v + 3K. +``` + +Equality occurs in the final partition of the final old prefix, before any bucket or current cleanup. The copy from the returned pure cube into the outer output has at most `v+pt+3t <= 2v+2t`, below that peak. For cap=1, replace 3K by K+t and obtain `2v+K+t = 2v+2t+HJ`, attained at the final prefix's key-stripping completion. The final result and borrowed source each have size v; all other counted content is cleared. + +This proves both universal equalities for the fixed routine, rather than a lower bound for every possible routing algorithm. Different disposal timing or a different route can change the result. + +## Consequence for the caller's gather/route/return/scatter phases + +In PR2697, let N be the number of low GL classes, W the number of family streams, `V=WNv`, and r the number of staged roles. Its stated selected values are W=28416 and r=661. Treat these as the caller's authenticated geometry; this package does not replay the full selected catalogue or node. + +When the last role is gathered and routed, r-1 completed packets remain alongside the route input. During inverse routing, all r staged packets remain, but one is already included in the route's borrowed-input charge. Thus both phases are bounded by + +```text +(r+1)v + 3H(R+J). +``` + +Scatter has a different overlap. All r staged packets and the returned packet of size v survive while `selection.scatter` builds a replacement whole family of size Nv. The old family is already counted among the W live families and is cleared only after scatter returns. Hence gather, routing, return and scatter, apart from the retained source/peeled/family streams, are bounded by + +```text +(r+1)v + max(Nv, 3H(R+J)). +``` + +`Node.run` retains at most 3V in protected input, peeled output and live family streams during those phases. Final merge can add a full V before cleanup. A joint bound for these phases and final merge is therefore + +```text +max(4V, 3V + 662v + max(Nv, 3H(R+J))). +``` + +This excludes literal local-word execution, COPY, residual/primitive interiors, peel interiors, directory production, counters and numerical/control storage. In particular COPY can briefly retain 661 roles, a cloned input and a returned private packet, 663v before residual-internal work. The displayed phase bound must not be applied to that interval. No historical `5V+19v` reserve or complete-node allocation is imported. + +## Replay and evidence + +Use Python 3.12 with only the standard library: + +```sh +python3.12 scripts/research_package.py --package research/selected-route-live-volume --check-only +python3.12 scripts/research_package.py --package research/selected-route-live-volume +python3.12 -I -O -B research/selected-route-live-volume/verify.py +``` + +`SNAPSHOTS.json` records exact PR2697 paths, Git blobs and SHA256 hashes. The verifier checks all 16 snapshots before importing any retained code. Twelve required runtime modules are retained byte-for-byte, together with the caller proof, driver, node and attribution notice. These runtime bytes came through PR2569; their inherited notices and dependencies are preserved. The new checker changes no source file or route operation. It supplies a measuring Tape factory and temporarily replaces only the route's private key-tape constructor. + +The eight fixtures use q=3 or 5, d=1 or 2, w=1 through 3, C=1 through 3 and R=1 through 5. Each exercises the complete declared high cube, up to 625 matrices. The 1,298 Boolean positions carry independent origin labels through actual copy operations. A separate integer modular-multiplication oracle checks every output origin and bit. Both partitioned and nonpartitioned cases attain the proof's exact peak. A direct scan of every retained measuring tape independently counts the first attained peak, and the exit census checks source preservation, head reset and cleared temporaries. + +Seventeen behavioral checks reject input/output-only budgets and premature current/bucket disposal budgets for all eight fixtures, then exercise a nonbinary payload failure with preserved borrowed input and erased owned payload buffers. Seven integrity groups cover a Git-free optimized replay, corrupt route/record/driver snapshots, a bool-for-integer receipt mutation, overwrite refusal and internal-output refusal. The receipt is checked with exact type-sensitive JSON comparison. To regenerate, use `--write-result` with a new path outside the package and compare it with RESULT.json. + +Validation passed on macOS arm64 with CPython 3.12.15 through the registered launcher and its seven integrity groups, and on CPython 3.14.8 with optimized assertions disabled and warnings treated as errors. The six repository replay-selection tests passed. Separate internal proof/source review also passed the optimized replay, integrity checks and exact source comparisons; no independent human review is claimed. + +The general theorem is the written lifetime proof. The tests are finite implementation evidence, including arbitrary Boolean origins on small cubes. They do not execute the enormous selected GL64 domain or prove the inherited native/compiler semantics. ValueError cleanup is checked for contiguous tapes without internal BLANK holes. Arbitrary exception cleanup and numerical scratch cleanup on malformed inputs are not claimed. + +## Verification design and deviations + +Build the Lever led to a retained-source replay and literal write counter instead of a hand-counted receipt. Prove It Works led to exact permutation/origin checks and an independent peak census on the actual route. No production code is changed. + +Power of Ten inspection covers the new verifier, tracker and integrity command. There is no recursion. New fixture execution is fixed at eight contexts with at most 625 high matrices, 3 prefixes and 5 fibre symbols. The receipt comparator stops after 20,000 nodes; integrity subprocesses have 90-second timeouts; registered commands have finite 120-second timeouts. New functions remain below 60 physical lines. Executable contracts remain enabled under -O. Syntax validation and warning-as-error replays are run; no separate static type checker or linter is installed. + +Rule 3, memory allocation: Python and the retained tape interpreter allocate during execution. Scope is this finite offline verifier. The fixed fixture list bounds all tapes, keys and origin dictionaries; the tracker retains cleared tapes for the independent census, so its own memory must never be used as the theorem's storage measure. Each successful fixture closes its arena and clears source/result. Follow-up if extending the domains is to calculate a new allocation cap before changing the fixed fixtures. + +Rules 8/9, instrumentation: the inherited factory interface and one temporary routes.Tape replacement provide two explicit measuring-constructor targets. The context manager restores the original target on every exit. This is checker-only instrumentation, with bounded targets and no dynamic code evaluation. Follow-up for production use would be an explicit upstream observer interface, outside this component's scope. + +Frozen predecessor code retains tape-terminated loops, dynamic Python allocation and methods exceeding one page. Rewriting them would destroy the byte-exact subject of this audit. Their execution is bounded here by the finite complete cubes, fixed word lengths and registered timeouts; no repository-wide Power of Ten compliance is asserted. + +## Open next questions + +1. What explicit reserve covers the residual and primitive interiors alongside this caller phase bound? Start with one PR2697 residual ENTER/RETURN, retaining its input, output and the 661 role buffers. Missing lifetime bounds for its directories, counts, coefficient pages and leaf work still block total reserve admission. +2. Can early bucket disposal or avoiding a local cube reduce this routine's peak without changing its complete-fibre semantics? First propose a changed literal ownership schedule and check it against the same origin and peak tests. This is an optimization opportunity, not needed to retain the present audit. A new route requires its own proof and source pin. + +## Credit and scope history + +Nick Petalas prepared this component audit. Jose Manuel/jmbarrancoml supplied PR2697's first-node caller and PR2569's source packets, routes and selected lineage. ywz65 supplied PR2590's cubic setup correction and PR2688's separate directory-storage component. The retained NOTICE.md credits the stream and tape framework, Douglas Colkitt, the selected hosting/word contributors and the source527/compiler lineage. Their construction and code are not claimed as new here. New work follows the repository's Apache-2.0 license. + +This follows the live total-live-volume handoff rather than the task picker's initial complex-mechanism suggestions. TASK.json declares a changed scope from the selected-stock-envelope card's complete stage recurrence to one actual pending caller component. PR2688 handles a different component. No family expansion, formal-kernel or independent human verification, full supplier replay, selected cold replay or new exponent is claimed. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/evidence/pr2731-README.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/evidence/pr2731-README.md new file mode 100644 index 0000000000..ac5b826f9c --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/evidence/pr2731-README.md @@ -0,0 +1,180 @@ +# Sharp payload storage for the selected BIT residual engine + +PR2697 leaves residual and primitive temporaries as an asymptotic term in its +first-node storage ledger. For its unchanged completed-leaf implementation, +**the sharp live payload bound, including the borrowed input, is `3v + 3R`**. +Here `R` is one complete prefix fibre and `v = P R` is the packet containing +`P >= 1` fibres. This closes one storage component, not the total caller reserve. + +The source is Jose Manuel/jmbarrancoml's [PR2697](https://github.com/CrocSwap/integer-mult-bounds/pull/2697) +at `a53fdf4bcbe33c6732f0bec1badc8c023380f9d1`. +[SNAPSHOTS.json](SNAPSHOTS.json) authenticates the 22 unchanged source exports. +The [Discussion2319 claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18955184) +takes the residual-lifetime handoff after Nick Petalas's +[PR2708 route bound](https://github.com/CrocSwap/integer-mult-bounds/pull/2708). +ywz65's [PR2688 directory bound](https://github.com/CrocSwap/integer-mult-bounds/pull/2688) +is another complementary component. Neither result is reproduced or claimed anew. + +## Contract and metric + +Count nonblank Boolean payload cells on distinct tapes. Reading a cell does not +erase it. Keep borrowed input cells in the count until the routine returns. +Exclude LEFT markers, prefix directories and fields, numerical/controller/count +tapes, and allocated Python backing capacity. Thus this is not a count of all +physical tape cells or host memory. + +Assume `q` is a fixed odd prime, `M = q^w`, `w >= 1`, `P >= 1`, and `R > 0`. +The input is a complete packet of equally sized fibres. Each fibre includes all +positive before/gap/suffix multiplicities and the full body domain supplied by +[Layout](vendor/layout.py). The trace is valid and completes successfully using +the pinned ADD, atom-swap and sign primitives and below-cutoff completed leaves. +Coefficient and observation callbacks allocate no payload tapes. Larger +recursive calls and arbitrary exception-path cleanup are outside this contract. + +## Lifetime proof + +### Primitive interiors + +The primitives preserve their borrowed source of `R` cells and return a new +`R`-cell output. Their bucket reads do not erase bucket content. + +* [ADD](vendor/vendor/stream.py) partitions the source into two buckets whose + combined size is `R`. Both buckets survive until the full output is written. + Its exact peak, including source, is `3R`. +* A single digit swap or complement has the same `3R` peak. In a + [multi-digit atom swap](vendor/vendor/bitstream.py), a later digit pass also + retains the original source while its current intermediate, buckets and next + output coexist. Its exact peak is `4R`. A one-digit atom swap needs `3R`. +* A sign first complements every digit, then calls `translate_one` before + clearing the complemented intermediate. During translation, the original + source, complemented current, translation buckets and complete output all + coexist. Its exact peak is `4R`, including when `w = 1`. + +All these counts are independent of the payload values. Empty bucket partitions +can change which bucket owns a cell, but not the combined bucket length. + +### Packet accumulation + +In [packet_engine.run](vendor/packet_engine.py), the first primitive uses the +borrowed input itself as `current`. After a primitive completes, `current` is a +new full packet. The original borrowed packet remains unchanged. The previous +owned `current` is cleared only after the next complete packet has been written. + +During the last fibre of a later primitive, the retained objects have sizes: + +| Object | Payload cells | +| --- | ---: | +| Original borrowed source | `v` | +| Distinct current packet | `v` | +| Previously completed fibres in the next output | `(P - 1)R` | +| Local source, intermediate, buckets and primitive output | at most `4R` | + +Their sum is `3v + 3R`. Earlier fibres have a smaller accumulated output. +After the primitive returns, copying its result to the packet output retains +only the local source and result, so that phase needs at most `3v + 2R`. +Cleanup and packet replacement cannot increase either bound. + +More precisely, numbering payload primitives from zero, their exact peaks are: + +| Primitive | First primitive | Any later primitive | +| --- | ---: | ---: | +| ADD or one-digit atom swap | `2v + 2R` | `3v + 2R` | +| Sign or multi-digit atom swap | `2v + 3R` | `3v + 3R` | + +An empty trace returns the source alias and has peak `v`. Entry/return records +allocate no payload. Every nonempty [completed leaf](vendor/vendor/trace.py) +contains a sign after earlier primitives. Consequently any trace containing +such a leaf attains `3v + 3R`; the result is not just an upper bound. + +This is a source-level lifetime proof for the stated contract. The finite checks +below corroborate the proof and instrument coverage; they do not replace it. + +## Retained-role corollary + +Let `K` distinct staged packets of size `v` remain live during a local call, +including any existing private packet. Count aliases by tape identity. +In [Driver.local](vendor/driver.py): + +* MOVE passes one of those packets as the engine's borrowed input. The staged + packets plus residual therefore need at most `(K + 2)v + 3R`. +* COPY first makes a distinct clone while all `K` staged packets remain live. + That clone is the engine's borrowed input. The bound is `(K + 3)v + 3R`. + The clone is cleared after return; the returned private packet remains until + its matching ERASE. + +For the source's 661 ordinary roles and at most one private role, both cases +are bounded by `664v + 3R`. This counts staged roles and the active residual +only. It does not include protected input, whole-family storage, directories, +routes, scatter output, peel/merge work, control tapes or markers. The corollary +is derived from source ownership and chronology; this checker does not execute +the full `Driver.local` schedule or certify its total reserve. + +## Reproduction and evidence + +From the repository root, with standard-library Python 3.12: + +```sh +python3.12 scripts/research_package.py --package research/selected-residual-live-volume --check-only +python3.12 scripts/research_package.py --package research/selected-residual-live-volume +python3.12 -B -O research/selected-residual-live-volume/verify.py +``` + +[verify.py](verify.py) authenticates sources before imports, instruments the +unchanged allocation/read/write paths, and checks a direct tape census against +the running meter. Instrumentation is restored in `finally`; it changes no +transform, cleanup order or allocation policy. Origin tags track every input +cell through actual copy operations. Expected address permutations use separate +ordinary modular arithmetic, and actual Boolean values are checked too. +Allocation-site classification is bound to the frozen source lines, not a +promise of compatibility with future versions. + +[RESULT.json](RESULT.json) records 17 fixtures and 231 primitive events. The +fixtures include an empty alias case, ADD/swap/sign over moduli 3 and 9 with +one and two prefixes, nontrivial spectators and gaps, an embedded layout, and +complete good/fallback traces with 1 and 19 child returns. The final fixture +rejects a missing child return. Positive fixtures cover 10,701 input cells with +individual origin tracking; these are complete small declared domains, not +selected GL64 execution or a complete high-header census. + +A sharp fixture has `P = 2`, `R = 972`, `v = 1944` and measured peak **8748**. +At that cut the census identifies both full packets, the partial next output, +local source, primitive intermediate, buckets and primitive output. Budgets +that omit the borrowed source or prematurely discard `current` give 6804; +omitting bucket/output overlap gives 7776. All are rejected by the actual census. +Source-byte mutation, incomplete manifests and borrowed-input mutation are also +rejected. Default replay compares the exact typed receipt and does not rewrite +it; `--write-result` refuses an existing result file. + +The registered replay and the standalone checker serve different provenance +roles. The runner validates historical catalogue provenance at the pinned Git +base. Standalone replay authenticates the frozen manifest and scientific source +exports plus the explicitly declared live selected-record input. Full Git +history is needed for the runner's historical provenance check, not for the +standalone scientific replay. + +## Open next questions + +Can the complete first-node caller fit a numerical reserve? Join this residual +component with the route and directory components at their actual overlapping +lifetimes, then include protected/family copies, count/controller tapes, markers +and disposal. A source-matched event ledger is the feasible first step, not +another independent maximum added blindly to all others. Larger recursive +returns remain a separate blocker. [TASK.json](TASK.json) records this handoff. + +Stop this contribution at the component result. It does not justify a larger +construction campaign by itself. No new supplier, kappa, selected-frontier +change, full selected cold replay, full GL64 execution, formal-kernel proof or +independent human review is claimed. The finite coefficient fixtures use small +explicit projectors rather than selected 64-dimensional callbacks. Numerical +storage, markers and arbitrary error-path cleanup remain unverified. + +## Credit + +Jose Manuel/jmbarrancoml supplies the unchanged PR2697 engine and first-node +caller. [vendor/NOTICE.md](vendor/NOTICE.md) retains its full stream, selected-word, +normal-form, controller, hosting and audit lineage. Nick Petalas supplies the +complementary route result and explicit residual-lifetime handoff; ywz65 supplies +the directory and earlier primitive/setup audits. + +New proof, checker and evidence prepared by starship-s with substantial Hermes +(`gpt-6-astra-900k`) and Codex (`gpt-6-astra`, max effort) assistance. Apache-2.0. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/layout.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/layout.py new file mode 100644 index 0000000000..aa554b14fe --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/layout.py @@ -0,0 +1,123 @@ +"""Binary two-bank layout with an independent complete intervening gap.""" +from cardinal_counts import Count, positive +from cardinality import multiply_atom_power +from words import need + + +class Layout: + def __init__(self,geometry,parent_size,ring,q,before,gap,suffix,embedded=True): + for value in (before,gap,suffix):positive(value) + self.geometry,self.ring,self.q=geometry,ring,q + self.before,self.gap,self.suffix=before,gap,suffix + self.parent_size,self.embedded=parent_size,embedded + self.core=geometry.raw.times_small(geometry.columns,geometry.plan.dimension) + remaining=geometry.raw.subtract_exact(parent_size,self.core) + self.extra=geometry.raw.times_small(remaining,2) + geometry.index.free(remaining) + self.total=geometry.raw.times_small(parent_size,2) + + def physical(self,position): + if not self.embedded or self.geometry.raw.compare(position,self.core)<0: + return self.geometry.index.copy(position) + return self.geometry.plus(position,self.extra) + + def extents(self,first,second=None): + g=self.geometry + a=self.physical(first) + b=self.physical(second) if second is not None else None + if b is not None:need(g.raw.compare(a,b)<0,"ordered physical body atoms") + last=a if b is None else b + pre,tail=Count(self.before),Count(self.suffix) + multiply_atom_power(pre,a,self.ring,self.q) + after=g.raw.subtract_exact(self.total,last) + count=g.raw.subtract_exact(after,g.one) + multiply_atom_power(tail,count,self.ring,self.q) + g.index.free_many(after,count) + if g.raw.compare(a,self.parent_size)>=0: + enlarged=Count.product(pre,self.gap);pre.close();pre=enlarged + if g.raw.compare(last,self.parent_size)<0: + enlarged=Count.product(tail,self.gap);tail.close();tail=enlarged + values=[pre] + if b is not None: + distance=g.raw.subtract_exact(b,a) + count=g.raw.subtract_exact(distance,g.one) + middle=Count.literal(1) + multiply_atom_power(middle,count,self.ring,self.q) + if g.raw.compare(a,self.parent_size)<0 and g.raw.compare(b,self.parent_size)>=0: + enlarged=Count.product(middle,self.gap);middle.close();middle=enlarged + values.append(middle) + g.index.free_many(distance,count,b) + values.append(tail);g.index.free(a) + result=[value.marginal() for value in values] + for value in values:value.close() + return result + + def fibre(self): + value=Count.product(self.before,self.gap) + multiply_atom_power(value,self.total,self.ring,self.q) + result=Count.product(value,self.suffix) + value.close() + return result + + def close(self): + self.geometry.index.free_many(self.core,self.extra,self.total) + + def child_extents(self, first, second, width, *, before): + """Return B', G', S' for two complete, disjoint child chunks. + + Source order is [U][B][head M^n][G][tail M^n][S]. U is returned + separately to the caller and must not be absorbed in `before`. + The projected order is [U][B'][chunk M^c][G'][chunk M^c][S']. + """ + positive(before) + g = self.geometry + need(not width.zero(), "positive recursive child width") + a, b = self.physical(first), self.physical(second) + a_end, b_end = g.plus(a, width), g.plus(b, width) + last_offset = g.raw.subtract_exact(width, g.one) + first_last = g.plus(first, last_offset) + second_last = g.plus(second, last_offset) + mapped_first_last = self.physical(first_last) + mapped_second_last = self.physical(second_last) + expected_first_last = g.raw.subtract_exact(a_end, g.one) + expected_second_last = g.raw.subtract_exact(b_end, g.one) + words = (a,b,a_end,b_end,last_offset,first_last,second_last, + mapped_first_last,mapped_second_last, + expected_first_last,expected_second_last) + values = [] + try: + need(g.raw.compare(a,b)<0 and g.raw.compare(a_end,b)<=0, + "ordered disjoint recursive child chunks") + need(g.raw.compare(b_end,self.total)<=0, + "recursive child lies in the complete body") + need(g.raw.compare(mapped_first_last,expected_first_last)==0 + and g.raw.compare(mapped_second_last,expected_second_last)==0, + "each recursive child chunk is physically contiguous") + for start,end in ((a,a_end),(b,b_end)): + need(g.raw.compare(start,self.parent_size)>=0 + or g.raw.compare(end,self.parent_size)<=0, + "recursive chunk does not cross the original gap") + + pre, middle, tail = Count(before), Count.literal(1), Count(self.suffix) + values = [pre,middle,tail] + multiply_atom_power(pre,a,self.ring,self.q) + between = g.raw.subtract_exact(b,a_end) + after = g.raw.subtract_exact(self.total,b_end) + try: + multiply_atom_power(middle,between,self.ring,self.q) + multiply_atom_power(tail,after,self.ring,self.q) + finally: + g.index.free_many(between,after) + + # Exactly one of these three complete spectator regions contains + # the parent's external gap; it is multiplied in exactly once. + gap_region = (0 if g.raw.compare(a,self.parent_size)>=0 else + 2 if g.raw.compare(b_end,self.parent_size)<=0 else 1) + enlarged = Count.product(values[gap_region],self.gap) + values[gap_region].close() + values[gap_region] = enlarged + return [value.marginal() for value in values] + finally: + for value in values: + value.close() + g.index.free_many(*words) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/linear_sign.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/linear_sign.py new file mode 100644 index 0000000000..6a6e5c02f2 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/linear_sign.py @@ -0,0 +1,82 @@ +"""Linear-traffic address negation on complete atom fibres. + +The source shape is [before][M][suffix], M = ring.modulus. No atom value +or spectator cardinality is decoded into host control. Each nonzero atom +slice is copied forwards, while slice starts are visited in reverse order. +""" +from bitstream import copy_bits +from records import Tape +from stream import Counter, positive_extent +from words import BLANK, need + + +def move_slices(source, count, suffix, direction): + """Move count complete slices by charged unit head movements.""" + blocks = Counter(count) + try: + while not blocks.finished: + bits = Counter(suffix) + try: + while not bits.finished: + source.step(direction) + bits.decrement() + finally: + bits.close() + blocks.decrement() + finally: + blocks.close() + + +def sign_address(source, ring, q, before, suffix): + """Pull back x -> -x mod M, preserving source and resetting both heads. + + q is retained for the old public signature; the permutation needs only + M >= 2. Source-head moves, including the final rewind, are at most 6V, + where V = before*M*suffix. Numerical counter setup has its usual + amortized binary-counting charge and is not hidden in this move bound. + """ + del q + positive_extent(before) + positive_extent(suffix) + two = ring.arena.literal(2) + leading = ring.raw.subtract_exact(ring.modulus, two) + nonzero = ring.raw.subtract_exact(ring.modulus, ring.one) + output = Tape() + outer = Counter(before) + try: + while not outer.finished: + # Preserve the zero slice, then reach the final nonzero slice. + copy_bits(source, output, suffix) + move_slices(source, leading, suffix, 1) + remaining = Counter(nonzero) + try: + while not remaining.finished: + copy_bits(source, output, suffix) + remaining.decrement() + if not remaining.finished: + # Two is finite control. Copying a padded residue word + # for this count once per atom would cost O(V log M) + # when suffix=1. + for _ in range(2): + backwards=Counter(suffix) + try: + while not backwards.finished: + source.step(-1) + backwards.decrement() + finally:backwards.close() + finally: + remaining.close() + # We finished just after slice 1; advance to the next outer row. + move_slices(source, leading, suffix, 1) + outer.decrement() + need(source.read() == BLANK, "complete linear sign input") + source.rewind() + output.rewind() + return output + except ValueError: + output.clear() + raise + finally: + source.rewind() + outer.close() + ring.arena.free_many(two, leading, nonzero) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/node.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/node.py new file mode 100644 index 0000000000..28c98a3573 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/node.py @@ -0,0 +1,88 @@ +"""Complete internal node: peel, fresh rows, recursive caller and return.""" +from cardinal_counts import Count, positive +from cardinality import multiply_atom_power +from consumer import Consumer, IncomingWeights +from driver import Driver +import fresh_rows +from packet import read_prefix +import peel +from plan import Request +from topology import SelectedTopology +from words import Unsigned, need +from scheduler import complete + + +def selected_topology(catalogue): + """One immutable source table per catalogue, shared by every frame. + + The retained topology's recipe/call caches include its identity in their + keys. Recreating that identity per child would retain source-table copies + after those children returned. Keep the single owner on the fixed-q + catalogue instead of introducing another global frame-keyed cache. + """ + result=getattr(catalogue,"_recursive_caller_topology",None) + if result is None: + result=SelectedTopology(catalogue) + catalogue._recursive_caller_topology=result + need(result.catalogue is catalogue,"selected topology belongs to its fixed source") + return result + + +class Node: + def __init__(self,context,indices,program,parent_size,depth,topology,consumer,incoming,stock_multiple=1): + self.context,self.indices,self.program=context,indices,program + self.parent_size,self.depth=parent_size,depth + self.topology,self.consumer,self.incoming=topology,consumer,incoming + self.stock_multiple=stock_multiple + raw=Unsigned(indices);dimension,one=indices.literal(context.dimension),indices.literal(1) + columns,remainder=raw.divmod(parent_size,dimension) + valid=not columns.zero() + indices.free_many(dimension,one,columns,remainder) + need(valid,"complete internal node width") + + def run(self,*args,**kwargs): + return complete(self.run_generator(*args,**kwargs)) + + def run_generator(self,source,old_directory,old_count,row_count,before,gap,suffix,observe=None): + old_count,row_count,before,gap,suffix=(Count(value) for value in (old_count,row_count,before,gap,suffix)) + for value in (old_count,row_count,before,gap,suffix):positive(value) + context,indices=self.context,self.indices + unused=leading=fibre=None;peeled=None;families={} + try: + old_directory.rewind();first=read_prefix(old_directory,self.depth);old_directory.rewind() + zero=indices.zero() + try: + value=self.incoming.coefficient(first,Request("incoming",zero)) + context.arena.free(value) + finally:first.clear();indices.free(zero) + unused=fresh_rows.quotient(row_count,context,self.topology.families) + stock=Count(unused) + try:need(stock.divide_small(self.stock_multiple)==0,"selected compatible unused stock factor") + finally:stock.close() + leading=Count.product(unused,before) + fibre=Count.product(leading,gap) + total=Unsigned(indices).times_small(self.parent_size,2) + multiply_atom_power(fibre,total,context.ring,context.q);indices.free(total) + following=Count.product(fibre,suffix);fibre.close();fibre=following + peeled=peel.run(source,context,indices,self.parent_size,self.depth,self.program, + old_directory,old_count,row_count,before,gap,suffix,self.incoming) + families=fresh_rows.split(peeled,context,self.topology.families,old_count,fibre) + driver=Driver(context,self.topology,self.consumer,old_directory,old_count,leading,gap,suffix,fibre,observe,child_stock=unused,child_before=before) + yield from driver.global_word(families) + return fresh_rows.merge(families,context,self.topology.families,old_count,fibre) + finally: + for tape in families.values():tape.clear() + if peeled is not None and peeled is not source:peeled.clear() + for value in (unused,leading,fibre,old_count,row_count,before,gap,suffix): + if value is not None:value.close() + source.rewind();old_directory.rewind() + + +class SelectedNode(Node): + def __init__(self,context,indices,program,parent_size,depth,catalogue,specifications): + need(context.dimension==64 and context.codes is catalogue.codes and + specifications.catalogue is catalogue,"one source-bound selected node") + topology=selected_topology(catalogue) + consumer=Consumer(context,indices,program,specifications,parent_size,depth) + incoming=IncomingWeights(context,indices,program,specifications,parent_size,depth) + super().__init__(context,indices,program,parent_size,depth,topology,consumer,incoming,9475) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/packet_engine.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/packet_engine.py new file mode 100644 index 0000000000..72543f684f --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/packet_engine.py @@ -0,0 +1,98 @@ +"""Shared trace on complete prefixes, with the caller's full two-bank layout.""" +from bitstream import copy_bits +from packet import read_prefix +from records import Tape +from stream import Counter +from stream_runner import action +from words import BLANK, need +from scheduler import Invocation, complete + + +def run_generator(source,events,layout,directory,prefix_count,field_count,coefficient,factory=Tape,observe=None,invoke=None): + fibre=layout.fibre() + current,active=source,None + boundary_words=[] + boundary_labels=None + returned=False + internal=invoked=False + try: + for event in events: + if event.kind=="enter": + need(active is None and event.parent_identity is layout.geometry.parent_identity, + "one whole-packet completed child") + active=event + boundary_labels=(event.child_kind,event.field,event.reverse,event.half, + event.source_code,event.parent_identity) + boundary_words=[layout.geometry.index.copy(getattr(event,name)) + for name in ("first","second","width","depth")] + internal=layout.geometry.raw.compare(event.width,layout.geometry.leaf_cutoff)>=0 + invoked=False + if observe is not None:observe("enter") + continue + if event.kind=="return": + need(active is not None and boundary_labels== + (event.child_kind,event.field,event.reverse,event.half, + event.source_code,event.parent_identity), + "same completed child returns") + for saved,name in zip(boundary_words,("first","second","width","depth")): + need(layout.geometry.raw.compare(saved,getattr(event,name))==0,"restored child geometry") + need(invoked==internal,"exactly one internal invocation before return") + layout.geometry.index.free_many(*boundary_words);boundary_words=[] + active=None + boundary_labels=None + if observe is not None:observe("return") + continue + if event.kind=="invoke": + need(active is not None and internal and not invoked and invoke is not None, + "exactly one bound recursive child consumer") + need(boundary_labels==(event.child_kind,event.field,event.reverse,event.half, + event.source_code,event.parent_identity), + "invoke matches entered child") + for saved,name in zip(boundary_words,("first","second","width","depth")): + need(layout.geometry.raw.compare(saved,getattr(event,name))==0, + "invoke has the entered child geometry") + following=yield Invocation(invoke(current,event)) + need(following is not current,"recursive child returns its owned output") + if current is not source:current.clear() + current=following + invoked=True + continue + need(active is None or not internal,"internal body is exclusively a whole-packet invocation") + output,prefixes=factory(),Counter(prefix_count) + directory.rewind() + try: + need(not prefixes.finished,"nonempty complete prefix packet") + while not prefixes.finished: + fields=read_prefix(directory,field_count) + local,changed=factory(),None + try: + copy_bits(current,local,fibre);local.rewind() + changed=action(local,event,layout,lambda request:coefficient(fields,request),factory) + copy_bits(changed,output,fibre) + need(changed.read()==BLANK,"complete changed prefix fibre") + finally: + if changed is not None and changed is not local:changed.clear() + local.clear();fields.clear() + prefixes.decrement() + need(current.read()==directory.read()==BLANK,"complete shared packet and directory") + current.rewind();directory.rewind() + if current is not source:current.clear() + output.rewind();current=output + except ValueError: + output.clear() + raise + finally:prefixes.close() + need(active is None,"complete child lifetime") + returned=True + return current + finally: + # A deeper failure closes suspended parents with GeneratorExit. Owned + # output must be erased on that path as well as ordinary ValueError. + if not returned and current is not source:current.clear() + fibre.close();directory.rewind();source.rewind() + if boundary_words:layout.geometry.index.free_many(*boundary_words) + events.close() + + +def run(*args,**kwargs): + return complete(run_generator(*args,**kwargs)) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/peel.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/peel.py new file mode 100644 index 0000000000..38502515af --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/peel.py @@ -0,0 +1,46 @@ +"""Peel the last n-m head atoms using original incoming weight offsets.""" +from cardinal_counts import Count +from layout import Layout +from numeric import Geometry +import packet_engine +from plan import Plan, Request +from trace import primitive +from words import Unsigned, need + + +def events(geometry,parent_size): + raw,index=geometry.raw,geometry.index + coordinate=raw.times_small(geometry.columns,geometry.plan.dimension) + total=raw.times_small(parent_size,2) + last=raw.subtract_exact(total,geometry.one) + index.free(total) + try: + while raw.compare(coordinate,parent_size)<0: + right=raw.subtract_exact(last,coordinate) + try: + for stage in range(8): + a,b=index.copy(coordinate),index.copy(right) + if stage in (0,2,4,6):yield from primitive("atom_swap",a,b,None,geometry) + elif stage==7: + index.free(a);yield from primitive("sign",b,None,None,geometry) + else: + request=Request("incoming",index.copy(coordinate),negative_inverse=stage==3) + yield from primitive("add",b,a,request,geometry) + finally:index.free(right) + raw.increment_in_place(coordinate) + finally:index.free_many(coordinate,last) + + +def run(source,context,indices,parent_size,depth,program,old_directory,old_count, + fresh_rows,before,gap,suffix,incoming): + divisor=indices.literal(context.dimension) + columns,remainder=Unsigned(indices).divmod(parent_size,divisor) + indices.free_many(divisor,remainder) + geometry=Geometry(Plan(context.dimension,1,True,()),indices,columns,depth,0,program) + leading=Count.product(fresh_rows,before) + layout=Layout(geometry,parent_size,context.ring,context.q,leading,gap,suffix,embedded=False) + try: + return packet_engine.run(source,events(geometry,parent_size),layout,old_directory, + old_count,depth,incoming.coefficient) + finally: + layout.close();leading.close();geometry.close();indices.free(columns) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/NOTICE.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/NOTICE.md new file mode 100644 index 0000000000..ef9f81510d --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/NOTICE.md @@ -0,0 +1,49 @@ +# Attribution + +Jose Manuel (`jmbarrancoml`) prepared the full first-range caller, gap/peel +integration, source catalogue binding and checks with substantial OpenAI Codex +assistance. New work uses Apache-2.0. We claim no independent human review +or new formal-kernel verification of this package. + +We credit OpenAI's retained framework and Douglas Colkitt for the stream, +interchange and tape contracts. The selected word/hosting lineage includes +DreamingOfClouds' PR589 tuning on eumemic's PR555 word, Dugongue's PR541/548, +rohanarun's PR542, eumemic's PR490 whole-owner argument and alephnan's PR1627 +literal reader and chronological hosting proof. + +The source527 contributors supplied the normal forms and weighted leaf +factorization. commdata2338 supplied PR2160's selected good form, PR2188's +mixed descriptor grammar, PR1379's parking boundary and PR2332's selected +table/global-slot binding. Ross Richardson supplied PR2159's full-ring fallback +topology and covariance. Jose Manuel's PR2157/2171/2195/2207/2234 and +PR2310/2364/2405/2449/2501/2569 supply the selected chart, controlled stream, +generated grammar, canonical-prefix, completed residual and source-route +predecessors. PR2195 supplies the ring/GL hosting lift and terminal gauge +calculation recalled in our proof. We do not claim new versions of those +algebraic identities. + +We retain 25 files from PR2569 at +`0b116cb34f27a4b064f0d8dd65549ea5705cf9c0`, including its 16 unchanged PR2501 +runtime/compiler dependencies. SOURCES.json lists their original paths, +Git blobs and SHA256 hashes. We retain their bytes and source comments. +We adapt PR2234's provider enumeration in catalogue.py and preserve its +ordered request digest. Our test-only model and observers adapt predecessor +finite expectation and origin-column patterns. The oracle module serves +fixed-q source compilation and finite expectations; we do not use it to +decode runtime high fields or execute payload permutations. + +We credit ywz65's PR2475 for conditional whole-call staging and PR2545 for its +separate buffer-residency completion. Ross Richardson's PR2519 gives a +separate one-buffer R439 adapter and relative-chart packet identity. We do +not adopt those numerical workspace constants. commdata2338's PR2386/2399 +sharpen request counts and completed leaf/header substitution. + +We credit ywz65's completed PR2566 audit of AtomSwap/Sign cost and ownership, +and PR2590 for the cubic radix-reconstruction term in directory setup. We +use PR2569's corrected proof at +`898ff36fe2cd05f733de6b26c88a4c4741b06237`; its runtime bytes match our earlier +pin. We preserve the canonical-input hypothesis and charge returned directory +and Count disposal outside the audited producer interval. + +We leave larger recursive return, numerical reserve admission and full +multiplication transfer open. We retain the selected frontier. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/PROOF.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/PROOF.md new file mode 100644 index 0000000000..a4746d1786 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/PROOF.md @@ -0,0 +1,351 @@ +# First internal selected BIT node + +Jose Manuel (`jmbarrancoml`), with substantial OpenAI Codex assistance. +We work in the retained stream model and use the pinned written predecessor +refinements. Maintainer admission and formal-kernel verification remain open. + +## Statement and input contract + +Fix an odd prime q, m=64, w>=1 and M=q^w. Put + + N=|GL_64(F_q)|, H=q^(4096(w-1)), W=28416, P=28425, + lcm(W,P)=269241600, lcm(W,P)/W=9475. + +Choose 64<=n<128 and delta=n-64. Supply a well-formed generated parent program +of final width n and depth h, using this package's complete fixed-q source +vocabulary from its creation. Supply its C>=1 physical frozen prefixes in +their original order, including repetitions. Each prefix contains exactly h +raw fields and determines incoming units A_0,...,A_(n-1) in Z/M. +The parent grammar reads these frozen fields only. In particular, the incoming +weights do not depend on the new family, current low/high header, unused row +coordinate, body address or external spectators. + +Supply fresh row cardinality K, a positive multiple of 269241600*N*H, and +positive cardinalities B,G,S. Use canonical unbounded binary cardinalities +and index/residue words with the retained margin/encoding contracts. Set +U=K/(W*N*H), so 9475 divides U. Use the following physical input order: + + [old prefix][K fresh rows][B][H_n][G][D_n][S]. + +We interpret fresh rows lexicographically as +`[family][low GL class][raw high matrix][U]`. We use the incoming ordinal +without identifying or discarding repeated frozen prefixes. A caller may +supply arbitrary dirty, correlated payload bits. The original input, parent +program and frozen directory remain read-only; the node owns fresh output, +staging, private and arithmetic work. + +**Refinement proposition.** Under the source identities and primitive +refinements pinned in SOURCES.json, we construct a finite stream program for +this node whose output, at each frozen prefix, has address permutation + + H_i' = A_i D_(n-1-i), + D_(n-1-i)' = A_i^-1 H_i (0<=i (A^-1 H,C0 D)`. In the original coordinates we obtain + + v=P(C0 D-A^-1 H), + T_A(P)(H,D)=(H+A v,D-C0 v). + +For an idempotent P, direct multiplication gives `T_A(P)^2=I`. For nested +idempotents P,Q with PQ=QP=P, we obtain +`T_A(P) T_A(Q)=T_A(Q-P)`; for PQ=QP=0 we obtain `T_A(P+Q)`. +These are polynomial matrix identities over a commutative ring. We require +neither a field nor symmetry after conjugation. The selected rational base +projectors and owner charts have dyadic entries, so their authenticated +identities specialize to Z/M for odd q. For each raw invertible header g, +simultaneous conjugation by g preserves nesting and disjointness. We use +the source's same fixed charts and support identities in that conjugation. + +Reduction modulo q identifies invertible raw matrices with the disjoint +union of N low classes, each with H high matrices. Right multiplication by +an invertible owner chart sigma permutes this full set; at a fixed common +low it permutes the complete matching high fibres. The route refinement +implements that permutation. Distinct source charts remain distinct modulo q +by their disjoint nonzero support columns, so the within-invocation ownership +argument also survives this extension. + +The local symbolic-column proof uses XOR on Boolean functions and these +address permutations. Its cancellation, dirty-helper independence and +transported-source identities therefore hold on the finite address set over +Z/M. The hosting chronology only uses those complete-call identities and +the disjoint-projector products above. This gives the ring/GL version of +the retained argument, with the same frozen A throughout a physical prefix. + +## Source catalogue and caller geometry + +We adapt PR2234's provider enumeration, preserving its ordered record digest +`f5a4fb124709adc4b56376a3146e3609e91c0f4d3ed1931a61785a5d99bf8ee7`. +We enumerate 28278 canonical requests: 26199 MOVE, 81 COPY and 1998 IDLE. +With 32 replicas we obtain 904896 paid requests. We retain 541 base labels, +1235 chart labels and 81 canonical transported ERASE guards. We bind each +MOVE/COPY to its literal position, stage, role, source family and chart. +For COPY we reserve canonical family 28416 as private metadata; we use the +call's actual owner family for the payload source. + +We compile the fixed vocabulary from (q,request,view,low). At q=3 we need 6507 +bits per code. Authors of older two-request fixtures used 6494 bits; we do not reinterpret +those encoded programs. Low-class enumeration, rational matrix compilation +and specification caches depend only on q and fixed source labels. Runtime +precision, raw high fields, parent widths and incoming coefficients remain +on tapes. Lazy fixed-q compilation implements a finite table, with no claim +of a small practical table. + +For local calls we gather a native owner header g and route d=g sigma into +common coordinates. We then compile the base projector with chart I and +preparation B0. The actual projector is d P0 d^-1. We do not apply sigma +again. For native idle requests we retain the actual family chart A_port and +preparation A_port B0. Those requests require the native view. The source +checker binds both views to the actual coefficient/serialized-child consumer; +the proofs use the inherited source and normal-form refinements. + +We obtain paid ranks at most 42. Since floor(n/64)=1, we use child width equal +to the rank in the good branch, and width one in the fallback branch. +We expand them through PR2501's completed leaves. We introduce no opaque +recursive callee in this range. + +## Original-offset peel and independent gap + +Before decoding fresh rows, we apply the weighted exchange on each pair + + (head coordinate 64+i, tail coordinate delta-1-i), 0<=i=n else1), + middle = M^(b-a-1) * (G if a=0 +we use K_s on X and K_s-P_t on Y. Thus level 8 has gauges I_64 and I_64-P_t. +Conjugate these by the native raw g and apply T_A. After the terminal family +exchange, the original X label has final gauge T_A(I-gP_tg^-1), while the +original Y label has T_A(I). The source scalar identity restores their +decoded values. Relative to the initial gauges, the physical endpoints are + + X: T_A(I-gP_tg^-1) T_A(gP_tg^-1)=T_A(I)=F_A, + Y: T_A(I) T_A(0)=F_A. + +We use PR2195's explicit gauge convention here. Applying another body +exchange after the family exchange would change this endpoint. + +More explicitly, decode a physical function by `c_i=f_i compose Gamma_i`. +MOVE and idle preserve c_i; an aligned ADD performs decoded XOR. The complete +scalar schedule returns c_i, hence +`f_i_out=f_i_in compose Gamma_i_in compose inverse(Gamma_i_out)`. +The complementary factors in the X calculation commute, so either displayed +order gives F_A. We carry the frame label with each exchanged family value. + +## Complete charge and ownership ledger + +Let v=C H R be one staged packet volume, with +`R=UBGS M^(2n)` and V=W N v. Let I be the supplied index-word extent and D +the serialized current directory size. Before using root coupling, retain + + D=O_q(CH(h+1)(w+1)), + T_directory_setup=O_q(w^3+w log(C+1)), + T_route=O_q(Jv+CH(poly(w)+J^2)), J=O_q(w). + +We use ywz65's PR2590 correction for the cubic setup term. Each fresh radix +traversal performs w full-width unsigned divisions. For canonical counts, +`w^2<=q^w<=qH` and `log2(C+1)<=C` absorb setup into D. We charge the output +directory/Count disposal separately. If an h countdown uses padded index +extent I, retain its scans until the root coupling gives I=O(w). + +For arbitrary B,G,S,U we form products through binary doubling/addition. +Their setup costs a fixed polynomial in the bit lengths of those factors +and the index/residue words. Positive complete multiplicities absorb the +cardinality terms; the factor `M^(2n)` absorbs fixed precision polynomials. +For fresh-row division we count 4096(w-1) small divisions, their actual quotient +lengths and the cubic radix reconstruction. We count the context's initial +H production even though the API receives a context. Its immutable q-only +compilation and source parsing contribute a finite q-dependent constant. + +Under the retained generated-root coupling + + w=ceil(e^(17/10000)), n<=e, 2^(h+1)<=8e^2, + +we have h=O(log w), I=O(log e)=O(w), and D=O_q(v). The inherited coefficient +allowance `O_q(e^3 w^3)` per source site is at most a fixed polynomial in w +(the retained coarse bound is w^1800). For n>=64 the complete body fibre +`q^(2nw)` absorbs that polynomial. This also pays repeated prefix reads, +normal-form preparation and restored program scans. For unrelated arbitrary +h or padded index words we claim the unabsorbed ledger, not this bound. + +| Component | Complete charge and status | +| --- | --- | +| Retained ADD, atom swap, sign and leaf expansion | Written primitive bounds, with independent PR2566 audit: ADD O_q(v), swaps/signs O_q(wv), including preparation, count reads, suffix and cleanup. The first-range traces have fixed-q many events. | +| Original-offset peel | At most 63 weighted pairs on volume V; we count coefficient work and all 8 primitives per pair, giving O_q((n+w)V) in this bounded range. | +| Fresh-row split/merge, clones, native XOR and final family return | A fixed-q number of complete sequential passes, plus the binary setup above. We count both temporary output and disposal of the replaced stream. | +| Owner gather/route/inverse/scatter and directories | A fixed-q number of charged routes and full family scans, including decoration, keys, directory production and erasure. Hence O_q(wV) under coupling. | +| Local staging and live storage | We retain the protected input, peeled output when present, all W live families, 661 role packets, one private packet, transient primitive/scatter outputs, directories and arithmetic words. We bound their sum by C_q V under coupling. | +| Completed children and return | All children fit the completed below64 leaves. We count their full bodies, metadata preparation, reset and erasure, with no unpaid recursive call. | +| Larger recursion and numerical reserve | Unknown for this implementation. We do not reuse the older V+4v or 5V+19v parking constants. | + +The numbers of stages, replicas, local events, low classes and finite labels +depend only on q and the fixed source. Summing these complete charges gives +`C_q V(n+w)` time and `C_q V` occupied work for this first-range node. We +include the potentially huge fixed-q compiler in C_q. We do not present these +constants as practical or as numerical reserve admission. The implementation +retains the original input and erases replaced owned streams; adding the +protected input only changes this displayed constant. + +For this per-role implementation we use the following exact invocation counts: + +| Operation | Count | +| --- | --- | +| Local MOVE / COPY residuals |838368N /2592N | +| Native idle residuals |63936N | +| Local XORs |6999840N | +| Local gather and local scatter |190368N each | +| Idle gather and idle scatter |63936N each | +| Owner/common routes |380736N | +| Whole-family bridge XORs |63936 | +| Terminal handle exchanges |14208 | + +We therefore pay for 508608N full-family gather/scatter scans. PR2475's +coalesced scan count does not apply to this implementation. Before absorption, +we bound source/peeled/family/merged copies by 4V, staged/private work by +662v, route/residual/scatter temporaries by O_q(v)+O(V/W), and retain D plus +the old directory, numerical pages and canonical counters. This inventory +accounts for temporary copies as well as live logical data. + +## Evidence boundaries and further obligations + +We authenticate the entire selected catalogue, literal controller and hosting +sources. We probe actual selected common/native coefficient junctions and +check 130 address columns for a generated width 65 remainder whose last weight +differs from weight 0. We execute complete Boolean endpoints in a separate +four-family GL2 model and in a gapped three-atom model, using actual source +routes, bit primitives and expanded leaves. We check linear origins for +arbitrary dirty input columns, including COPY and ADD. We separately execute +two distinct high fields at w=2; that test samples the high cube. + +We leave full GL64 Boolean payload execution open. The mathematical claim +uses the stated source/primitive refinements; the finite executions check +specific implementation implications. Larger recursive parking, a numerical +reserve inequality, complex-side transfer and formal compilation remain +separate obligations. We leave the selected exponent unchanged. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/README.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/README.md new file mode 100644 index 0000000000..988ff62202 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/README.md @@ -0,0 +1,81 @@ +# Complete selected BIT node for 64 <= n < 128 + +We construct the first internal selected BIT node from actual source packets +and completed below64 leaves. We include the original-weight remainder peel, +fresh-row decoding, the complete local/idle/bridge/exchange caller, an +independent external gap and return to the original row order. + +In [PROOF.md](PROOF.md) we prove the scoped stream refinement under the pinned +predecessor contracts: arbitrary dirty payloads return with weighted reversal +F_A, unchanged row/spectator coordinates and cleared owned work. Under the +retained root coupling we construct a complete `C_q V(n+w)` time bound. +We leave numerical reserve admission, larger recursion and full transfer open. +We claim no new exponent or formal-kernel verification. + +The caller completes the handoff from +[PR2569](https://github.com/CrocSwap/integer-mult-bounds/pull/2569) and the +conditional whole-call staging interface in +[PR2475](https://github.com/CrocSwap/integer-mult-bounds/pull/2475). +We preserve PR2234's full 28278-request vocabulary, the selected logical +denominator W=28416 and compatible unused-row factor 9475. We use a common +view after local routing and the native family chart for idle requests. + +Within a local invocation we scatter repeated-family roles into the latest +family state. We finish one common low before gathering the next. Both +requirements matter: repeated faulty sweeps can cancel at the final endpoint, +so we check the first sweep and retain separate lost-update witnesses. + +## Evidence and reproduction + +We retain exact receipts in [RESULT.json](RESULT.json), source pins in +[SOURCES.json](SOURCES.json) and registered commands in [VERIFY.json](VERIFY.json). +Run from repository root with standard-library Python 3.12 and full Git history: + +```sh +python3.12 scripts/research_package.py --package research/selected-bit-node --check-only +python3.12 scripts/research_package.py --package research/selected-bit-node +``` + +| Evidence | Scope | +| --- | --- | +| Selected catalogue and 7843392 literal events |28278 canonical requests, 904896 replicated paid requests, 288 local calls, 541 split bases and retained chronological ownership certificates. | +| Actual selected consumer probes | Common MOVE and native IDLE coefficient/child junctions; no full GL64 payload execution. | +| Selected generated width 65 peel |130 address columns; original A64=8 versus A0=2, unchanged frozen fields/program and no new field. | +| Complete four-family GL2 node |31104 independent Boolean input columns, 672 residuals, 5712 completed child entries/returns, COPY/ERASE and first-sweep checkpoints. | +| Complete gapped peel and core |43740 Boolean bits with gap 5 and nontrivial before/suffix factors; all origins and marker 39125→43689. | +| Two high fields at width 2 |39366 Boolean bits through one shared child interval; sampled high cube. | +| Controls under Python `-O` | Lost updates, reversed Y bridge, family-only exchange, 16 frame/range/stock rejections and cardinality products through 822 bits. | + +We use the actual stream operations in the complete small models. We use +independent address formulas and Boolean origin columns only as expectations. +Finite execution does not replace the quantified proof or constitute full +selected GL64 payload execution. A slower machine may exceed the bounded +generic replay budget; each command declares its limit. + +## Open next questions + +We record the revision 5 expansion decision in [TASK.json](TASK.json) and the +[existing claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18951991). +Before expanding to a larger child, identify its complete live parent state, +including 661 staged roles and directories, and derive its parking/return bill. +That would connect this first-range node to all-size recursion; recursive +workspace and numerical reserve admission remain the blockers. + +For numerical admission, derive simultaneous live volumes for this caller +before substituting them into a reserve inequality. The old four-buffer +constants do not cover this implementation. At the final overlap checkpoint, +ywz65's pending [PR2688](https://github.com/CrocSwap/integer-mult-bounds/pull/2688) +supplies a directory-only allowance under its large-q premises. Check that +component before deriving the remaining caller/routing/child budget. +For formal compilation, begin +with the latest-family scatter and chronological low-sweep invariants in an +operational stream model. TASK.json gives the first steps and blockers. + +## Credit + +Jose Manuel (`jmbarrancoml`) prepared this contribution with substantial OpenAI +Codex assistance. New work uses Apache-2.0. We retain 25 predecessor files +byte-for-byte and record their origins in SOURCES.json. We credit ywz65's +primitive audit PR2566 and cubic directory-setup correction PR2590, along +with the selected source, grammar and caller contributors in +[NOTICE.md](NOTICE.md). The pending packages retain their separate review status. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/RESULT.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/RESULT.json new file mode 100644 index 0000000000..7b7dfe0eab --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/RESULT.json @@ -0,0 +1,61 @@ +{ + "environment":{"python":"CPython 3.12.13","platform":"Darwin 25.5.0 arm64","dependencies":"standard library","scope":"Local author checks; full selected source/control census and complete small Boolean models, with selected coefficient probes and sampled high fields. No full GL64 payload execution."}, + "source":{ + "full_result_sha256":"0f9a58f98d24c7cdacb62952fba6b935bcf7391f7dad7442edfd640af5ea663e", + "result":{ + "gapped_endpoint":{"bank_atoms":3,"before":6,"bits":43740,"children":{"enter":20,"return":20},"core_atoms":2,"erased_tapes":9177171,"gap":5,"marker":[39125,43689],"payload_sha256":"6a09c7134287cc0149ab28e2d15c5ba728ef464c562f3ad0db8f0608f01322d5","peel_pairs":1,"suffix":2}, + "gapped_extents":{"gap":5,"geometry_cases":36,"widths":[64,65,95,127]}, + "generated_peel":{"ancestor_rank":5,"columns":130,"frozen_fields":1,"head64_to_tail0":8,"parent_atoms":65,"peel_scalars":[8,1,8],"root_atoms":832,"source_code_bits":6507,"tail0_to_head64":8,"wrong_offset_weight":2}, + "global_scalar":{"bridge_shears":18,"family_XOR_actions":63936,"global_events":29,"omission_controls":18,"terminal_family_pairs":14208}, + "sampled_high_packet":{"bits":39366,"children":{"enter":1,"return":1},"complete_high_cube":false,"dimension":2,"erased_tapes":372459,"gap":3,"high_prefixes":2,"payload_sha256":"b7fa73bbb6e282d63e6ea9fac8a2443c6357d015d34c65ecf0e5829af68bfed8","width":2}, + "selected_consumers":[ + {"callbacks":["adapter","child"],"code_bits":6507,"common":true,"full_payload_executed":false,"kind":"MOVE","rank":1,"request":0}, + {"callbacks":["adapter","child"],"code_bits":6507,"common":false,"full_payload_executed":false,"kind":"IDLE","rank":42,"request":27825} + ], + "selected_sources":{ + "consumer_binding_sha256":"e59279f482edde48fb08773e32c429acb369eaf33a723034d083cc0577c714c6", + "literal_counts":{"0":838368,"1":6999840,"2":2592,"3":2592}, + "literal_events":7843392, + "literal_source_sha256":"ea44aa047a2a9cf034de8b56b2166c49cf2dbdf9cd9ed6a20299a4f2b05ef09a", + "local_certificates":{ + "forward":{"copies":9,"profile":{"1":1323,"2":1342,"3":79,"4":44,"5":102,"6":11,"7":19},"records":27234,"symbolic_columns":661}, + "reverse":{"copies":9,"profile":{"1":1323,"2":1342,"3":79,"4":44,"5":102,"6":11,"7":19},"records":27234,"symbolic_columns":661} + }, + "ownership":{ + "calls":288,"distinct_slot_permutations":14, + "first_five_helper":{"ambient_axes":[[1,2,3,4,5,6,7,8],[9,10,11,12,13,14,15,16],[17,18,19,20,21,22,23,24],[25,26,27,28,29,30,31,32],[33,34,35,36,37,38,39,40]],"children":[4,4,4,4,4],"family":666,"pair":0,"replica":0,"roles":[232,233,234,235,236],"stage":2}, + "hosted_occurrences":126432,"idle_remainder_profile":{"2":13920,"4":14208,"6":14208,"7":21312,"42":288}, + "max_helpers_per_family":{"0":3,"1":3,"2":5,"3":5,"4":5,"5":5,"6":3,"7":5,"8":3} + }, + "provider":{ + "base_labels":541,"binding_sha256":"f5a4fb124709adc4b56376a3146e3609e91c0f4d3ed1931a61785a5d99bf8ee7","canonical_ERASE_guards":81, + "canonical_requests":28278,"chart_labels":1235,"full_paid_requests":904896, + "rank_histogram":{"1":381024,"2":400416,"3":22752,"4":26880,"5":29376,"6":17376,"7":26784,"42":288}, + "replicas":32,"request_kinds":{"COPY":81,"IDLE":1998,"MOVE":26199} + }, + "split_basis_ranks":{"1":120,"2":182,"3":77,"4":41,"5":85,"6":13,"7":22,"42":1} + } + } + }, + "node":{ + "full_result_sha256":"8fc9ebd9c9e43aa95343a9590c70bf548467a7d5b67267e2a92a2215bd707452", + "result":{ + "dimension":2,"width":1,"bank_atoms":2,"families":4,"low_classes":48,"gap":2,"input_columns":31104,"first_sweep_checkpoints":[0,1], + "residuals":{"MOVE":192,"COPY":96,"IDLE":384},"children":{"enter":5712,"return":5712}, + "events":{"bridge":4,"exchange":2,"global":15,"global_return":15,"literal":864,"residual":672}, + "erased_tapes":10012294,"payload_sha256":"5035a339800d38d3c2436548e89fc08db368266d4d6065a2adaf491052975af4" + } + }, + "controls":{ + "full_result_sha256":"bf0e719ad640a1df6f9543dace731e1585fd36e392e745c0485c57744da95c83", + "result":{ + "bridge_exchange":{"bridge_columns":15552,"exchange_columns":15552}, + "rejections_counts":{ + "cardinality_cases":20,"maximum_product_bits":822, + "rejections":["self_XOR","write_private","write_copied_source","wrong_ERASE_source","wrong_ADD_frame","node_range_0","node_range_1","node_range_4","node_range_5","incomplete_stock_1","incomplete_stock_191","incomplete_stock_193","incomplete_stock_188","incomplete_high_stock","physical_inventory_denominator","selected_compatibility_stock"], + "runtime_modules":["cardinal_counts.py","layout.py","packet_engine.py","consumer.py","peel.py","fresh_rows.py","control.py","driver.py","node.py","topology.py"],"selected_unused_factor":9475 + }, + "stale_state":{"stale_family_scatter":{"correct":1946,"source":1998,"wrong":1998},"stale_low_gather":{"correct":1947,"source":1962,"wrong":1962}} + } + } +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/SOURCES.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/SOURCES.json new file mode 100644 index 0000000000..4fef1a4d6c --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/SOURCES.json @@ -0,0 +1,58 @@ +{ + "schema_version":1, + "base_commit":"b4560d9e7216f72b73c5aa940ac099c05e33ccf9", + "files":[ + {"path":"certificates/selected-result.json","usage":"provenance","git_blob":"ae6a99f28aa468649eb66a361e764d769363bf11","sha256":"10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32"}, + {"path":"docs/research/agent-task-catalog.json","usage":"provenance","git_blob":"889b95d936746df124872133ae1e7cc339adcb92","sha256":"7d185cd8c2af35988d638d969748ad7b670f902606444dbfc748e4402c340df6"}, + {"path":"research/pr589-five-helper-hosting/verify.py","usage":"input","git_blob":"dbc71f56bb4205ebe378ada1f9f4ea88630d1d39","sha256":"cf90e19ae9991b0698be03d395a8cc29061ecb307eb7fea19adfb2d23c25a367"}, + {"path":"research/pr589-five-helper-hosting/PROOF.md","usage":"input","git_blob":"bbd3f12b9a32b3ad3cba85a2d5a1b3054214fa02","sha256":"59cae781bfbe1a01ed9e66a8efeeb5a2b995e5ecdf908586b23ecc39f2b8d647"}, + {"path":"research/e8-bit-p111-tuned/tune/bitE8mut-p111-tuned.json.gz","usage":"input","git_blob":"85a4499bf9e4911a705d50567a2c2ef6cf23739a","sha256":"e3e301e62bc2b41dbf1ceac0acf3d35824ebeab1848c5a2142d4577b109da52f"}, + {"path":"research/community-hyperplane599-audit/pr589/bit589/v9/hosted/GLOBAL-TEMPLATE.json.gz","usage":"input","git_blob":"9eafb8776cbf78c72124f833534469ddfa5e98ec","sha256":"0357b7cfbd7c29b4983982baf153c8a9f1e1e412690cd7fa9fc3d23d7963b20f"}, + {"path":"research/community-hyperplane599-audit/pr589/bit589/v9/nine/GEOMETRY.json","usage":"input","git_blob":"44006542202ca6037533a754f0bcd00549d7e088","sha256":"0058c491d839142aa99ef86a5ec697ce99857632228531512ea3fa74fb24d734"}, + {"path":"research/recursive-parking-boundary/README.md","usage":"input","git_blob":"251f335ebaccc11d69393ee7aeb5a2e84526d0bb","sha256":"491aa208391ee4c2936510b1a5c5c018dd5509d9a0e88687c72ab8406cd77b18"}, + {"path":"upstream/build/sections/02-streams.tex","usage":"input","git_blob":"088fceea1867abc76271d7efe7532b779fee9039","sha256":"606c80db61cad13aa0c3b6060dc4b88dbbe7ac60cdd831aa93f28d908fd09dab"}, + {"path":"research/e8-bit-p111-tuned/tune/EXPECTED.json","usage":"input","git_blob":"e293ddc557742637f9f679f083a1a282d87b1b13","sha256":"b9f0e5ca038abe837b0007c8fe006f366a6f02009244ac57705a8a200e2301f4"} + ], + "vendor_source":{"pr":2569,"commit":"0b116cb34f27a4b064f0d8dd65549ea5705cf9c0","unchanged":true,"proof_correction":"898ff36fe2cd05f733de6b26c88a4c4741b06237"}, + "vendor_files":[ + {"name":"binding.py","source_path":"research/selected-source-packets/binding.py","git_blob":"21a5a21220a18ab62a19ac403a9944bc3a8665c8","sha256":"20169a8af6ed2b34069fd353a2bc1c42335ab686c58de8479baef33dd3fb493b"}, + {"name":"bitstream.py","source_path":"research/selected-source-packets/vendor/bitstream.py","git_blob":"4d1fd4abb0f2aabe833e5cbc9efb51039739e7ca","sha256":"f78bac9641007dbd8824984edcac057274fe016ce78bd9cb512d0c0913274783"}, + {"name":"cardinality.py","source_path":"research/selected-source-packets/vendor/cardinality.py","git_blob":"b8ba857e32c5903408e1e61ff916300848b4a208","sha256":"505d5e560c5a507e6184edcc19a87cf1fed243eb34a5cb21fbe1e4fe017e7f22"}, + {"name":"check_support.py","source_path":"research/selected-source-packets/check_support.py","git_blob":"e1f961df9fa3a441fc5b600d1288a8d038eca51e","sha256":"d9977e87ddc5acdb836b8e4a4e3942da17a05b04ce67c04547d17b986b518964"}, + {"name":"children.py","source_path":"research/selected-source-packets/vendor/children.py","git_blob":"ce4935f838516e2b08d13bec767cb803786fbc6b","sha256":"a78866939631214c1d1659203b2b5fc062e3c6255e9f11f975c310046b010bd6"}, + {"name":"controller.py","source_path":"research/selected-source-packets/vendor/controller.py","git_blob":"c631a9e77fbcccf0e8f448adc22978728aed7b60","sha256":"fa09146991f6c04e6f4b6eb9bf0c8e103e70e90a0e402ff3d69814e6aac8ff8c"}, + {"name":"counts.py","source_path":"research/selected-source-packets/counts.py","git_blob":"81b48940ce222290a40d4fb349ce827f4788469d","sha256":"00b476dbda0e8cc99886bf794439e1cb9e775f435f599a3557e99321fe084069"}, + {"name":"directory.py","source_path":"research/selected-source-packets/directory.py","git_blob":"c74cacf5ce809c0561d374f137a52df0992b4226","sha256":"4270e370b2bfe38ef73aadcd97d1b3496b56bd582115d74331eb9e5ceb90bec7"}, + {"name":"episode.py","source_path":"research/selected-source-packets/episode.py","git_blob":"30d11ff4f333813855d36da3eb5a1ab0e154bafe","sha256":"38f79cb2a370548471063952d5f7c74bd795a2a8496fdcf3ce0996d79e3adaff"}, + {"name":"forms.py","source_path":"research/selected-source-packets/vendor/forms.py","git_blob":"6667c0b772a63f0059c7caffec63e0d919a92398","sha256":"1fdf9d31b7eb107c396e33f94dad61c9d3f2c709cae61178268a44ca80dbc0b4"}, + {"name":"low_codes.py","source_path":"research/selected-source-packets/low_codes.py","git_blob":"737edfc4a10f4b7b3b97a7cef4b40864efd806e6","sha256":"f657e17f6088c840e3f7783e662257630f6d2c1e71c217721ffbca4d6ac93e87"}, + {"name":"matrices.py","source_path":"research/selected-source-packets/vendor/matrices.py","git_blob":"5d497353efbb9eeaaf4facd96ab40ffb0f3aa20d","sha256":"00b687434039b54529ee092e34f9435cfcd66e0816eb3bd2a6688c73f4e01459"}, + {"name":"numeric.py","source_path":"research/selected-source-packets/vendor/numeric.py","git_blob":"6d4ebca8398008375b8f4762d1a9f1514e8c2611","sha256":"7327b05c4ec3e0f6d9c352cc7de85bfd4ebe940482553e77c59a773a8c09c514"}, + {"name":"oracle.py","source_path":"research/selected-source-packets/vendor/oracle.py","git_blob":"244f131466698a3ace10b657242fe1f65c07fd1f","sha256":"7bd18089e32ce48085b5e3a75159f6a82cdb2649ec682c53db05e399d97aef67"}, + {"name":"packet.py","source_path":"research/selected-source-packets/vendor/packet.py","git_blob":"ebc9b616514412b80c56d523776e6ba5d6766453","sha256":"970e7fe0719e3dfe122b248941e6f21cd90d7dd62089fa6acbd0e5412ce083a5"}, + {"name":"plan.py","source_path":"research/selected-source-packets/vendor/plan.py","git_blob":"48255d5454308c07635fae4e7eb4873b0bd2a4f8","sha256":"d9c8dc93762db4d3a449814aa51e2211460648694469854d89cb48cb04188cf3"}, + {"name":"records.py","source_path":"research/selected-source-packets/vendor/records.py","git_blob":"4f00467a0ff580954ad2fd0c7380240c753ddef3","sha256":"0c9c4b23e998597fb877bb1a29da69ac869b68262abe635b162b4dba9c69b372"}, + {"name":"residual.py","source_path":"research/selected-source-packets/residual.py","git_blob":"3d070d2539a529f3b14ecb086a92a3db056229fe","sha256":"8fd24747cae498dfb2ba333e7f8a68d7315ae4c2d7530d8ca145aab95ede21df"}, + {"name":"routes.py","source_path":"research/selected-source-packets/routes.py","git_blob":"35531201dc349a811dfabc6f1f6e64697d665194","sha256":"ed7dc3679451696ab1dd841146b215c9515a3eec5e4ff3763f33c315f1696ada"}, + {"name":"selection.py","source_path":"research/selected-source-packets/selection.py","git_blob":"2c28f1aaec104a75c4e6c170b3e6a60300ee6700","sha256":"bc8e371fb1fa0b41fb05ef0b34d0f4c317b2396f9833d91f44f95c2b54b4052b"}, + {"name":"sources.py","source_path":"research/selected-source-packets/vendor/sources.py","git_blob":"16d5e7e6a28018f1e2d76d61efe2d54f6a6941d4","sha256":"f102edc7816d742bd89db8097254c19b843d0ef5cf6758ad42e93bcc0b214c62"}, + {"name":"stream.py","source_path":"research/selected-source-packets/vendor/stream.py","git_blob":"5e5a4bb0f98971447043e25d4dd6991bfc070389","sha256":"c7dc7da5b00f27016982ada4c0416f8328568b00df16d97012f33d4b372d79b5"}, + {"name":"stream_runner.py","source_path":"research/selected-source-packets/vendor/stream_runner.py","git_blob":"efff281d4c4be5c1378e31404fbcc634fe4ade59","sha256":"751c5023ca0e477369e448583961ace6a76db2723bb6c26f81203def539f1249"}, + {"name":"trace.py","source_path":"research/selected-source-packets/vendor/trace.py","git_blob":"bb845a90f5bcf006e683e581e385936208f6a1f4","sha256":"c71ba11d793dde2ac6e4cdcf468482872975c34589bf1167f2a460cb8a74e984"}, + {"name":"words.py","source_path":"research/selected-source-packets/vendor/words.py","git_blob":"8d4ba37e2778acb35b34e0719df2caf138fbeb50","sha256":"5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9"} + ], + "proof_dependencies":[ + {"pr":2195,"head":"3a1cf78a1ba6322129e42d80c50d21765524d612","path":"research/selected-bit-local-ring-sweeps/PROOF.md","git_blob":"4330de85dd9862ed15d84ab917887d249753df99","sha256":"846c59440cc99e28bae93ad2af99525bc769de29368080071b8427141215b4f7","role":"Ring/GL hosting lift, frozen weighted common frames and explicit terminal endpoint gauges."}, + {"pr":2234,"head":"d047ef86fbc5b1614d3d8e2b8d3441413beab73f","role":"Original full provider catalogue and selected caller/reserve interface; catalogue.py adapts its enumeration."}, + {"pr":2310,"head":"a5258f548bfb6da71c3b72733fbbd2fb4995c929","role":"Generated grammar, coefficient and root-coupled control allowance."}, + {"pr":2332,"head":"0ee2ca645f3b04e1e4df1e1055b6f9aab09eaa95","role":"Selected source table and original global field slots."}, + {"pr":2475,"head":"4d536232f392d7df44e716f6d6099f459e4d9035","role":"Conditional whole-call staging and transported private lifetime."}, + {"pr":2501,"head":"52a995b9d7f3e008c252770a5f47fde67a7cb37a","role":"Completed selected residual and below64 leaves; retained dependencies through PR2569."}, + {"pr":2519,"head":"fe9ca26c8df754ccadbb3df89c721dad3b497b48","role":"Separate one-buffer R439 adapter and relative-chart identity."}, + {"pr":2545,"head":"8b82afa62da2647a0022775bdc2e19f7f4b3ac6e","role":"Separate whole-call buffer-residency completion; no adoption of its numerical allocation."}, + {"pr":2566,"head":"bfe8317a38f03a5693470e873b29101f3f7a55e4","role":"ywz65 complete primitive cost and ownership audit."}, + {"pr":2569,"head":"898ff36fe2cd05f733de6b26c88a4c4741b06237","role":"Source-directory and route refinement with corrected setup bill; runtime bytes unchanged from pinned0b116cb3."}, + {"pr":2590,"head":"8803e0ced7d5cc8a6db1b11157742f70981f4f42","role":"ywz65 cubic cardinality setup correction and canonical-input directory bound; charge returned-output disposal separately."} + ], + "scope":"Authenticate live main inputs and25 unchanged predecessor files before source imports. Pending mathematical dependencies remain subject to review." +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/TASK.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/TASK.json new file mode 100644 index 0000000000..eb2ce7cc00 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/TASK.json @@ -0,0 +1,48 @@ +{ + "schema_version":1, + "task_id":"uniform-transfer-audit", + "priority_revision":5, + "base_commit":"b4560d9e7216f72b73c5aa940ac099c05e33ccf9", + "original_card":{ + "id":"uniform-transfer-audit", + "question":"Can one exact all-size/compiler, precision, hosting or restoration implication be proved or falsified?", + "starting_points":["certificates/selected-result.json","docs/audit.md"], + "methods":["Prove one missing implication with explicit quantified hypotheses.","Find an exact counterexample at the claimed interface boundary."], + "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_baseline.py"],"expected":"PASS_RESEARCH_BASELINE_BINDINGS_ONLY","inspect":"Read the selected review scope and choose one exact all-size or precision implication.","scope":"Positive control / source-bound orientation only; this is not a new construction or full cold replay."}, + "first_experiment":"Write its quantified inputs and conclusion; find a missing hypothesis or construct a minimal exact adversarial instance.", + "bottleneck_link":"Finite supplier improvements are useful only under the retained transfer obligations.", + "allowed_variations":["Choose one tape, precision, hosting or restoration lemma."], + "scope_change_triggers":["Replacing a quantified obligation with another finite smoke test."], + "overlap_terms":["uniform transfer","all-size","precision"] + }, + "scope_status":"refined", + "actual_scope":"Complete the selected BIT node for 64<=n<128 from actual source packets and completed below64 leaves, including original-offset peel, arbitrary external gap, complete local/idle/bridge/exchange caller, row return and scratch disposal.", + "scope_change_reason":"PR2569 leaves the complete selected caller open after constructing its source boundary. We take that concrete handoff and close the first internal width range. The written refinement quantifies over precision and dirty payloads; finite checks exercise separate source and implementation implications.", + "bottleneck_link":"A selected residual with produced source fields still needs a caller that preserves owner chronology, fresh-row multiplicities, spectators and transported private work. This node supplies that missing first-range composition. Larger recursive admission remains open.", + "budget_minutes":240, + "stop_rule":"Complete this bounded node and its charged proof, or publish a failed endpoint/source/return obligation. Reassess the family expansion gate before implementing larger recursive children.", + "outcome":"completed", + "evidence":"PROOF.md states the quantified first-range refinement and complete asymptotic ledger. RESULT.json separates full selected source/literal checks, actual selected coefficient probes, complete small Boolean nodes, sampled high fields and mutation controls.", + "author":"Jose Manuel (jmbarrancoml)", + "ai_assistance":"Substantial OpenAI Codex assistance in mathematical analysis, source investigation, implementation, checking and writing. We claim neither independent human review nor new formal-kernel verification.", + "discussion":"https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18951991", + "freshness":{"canonical_main":"b5ea56e0a5ac4552166253b1fa4be0753bb38c30","upstream_checked_utc":"2026-10-15T17:40:10Z","overlap_checked_utc":"2026-10-15T17:28:53Z","coverage":"782 open PRs, 1320 Discussion/comment/reply records and 1690 local records; complete pagination, all 1908 matches saved and no warnings. Supplemental live reads through 17:40:10UTC confirmed unchanged main and PR2688, no new comments in2319/2304 and no competing new node PR. PR2688 supplies a complementary directory-only reserve component. Searches exclude arbitrary code diffs and do not establish novelty.","compatibility":"We fast-forwarded the task branch to this canonical main. Priority remains5; source pins and selected frontier remain unchanged. TASK/SOURCES retain b4560d9e as exact historical provenance. The navigation correction concerns R439 semantic-D evidence."}, + "concurrent_work":[ + {"pr":2688,"author":"ywz65","head":"1b9e1ed8793ffdde3c4b115641f0e644a9289923","relation":"Pending directory-only numerical storage allowance under large-q/root-depth/body/minimal-code premises. It excludes total caller lifetimes, routing/controller/count tapes and child workspace; we retain those total reserve obligations."} + ], + "expansion_gate":{ + "decision":"Continue this first-node acceptance-gap repair; reassess before larger recursion.", + "record":"https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18951991", + "evidence_status":"Selected finite construction is reviewed conditional evidence. New source/residual dependencies and this package remain pending author-checked constructions; PR2566 and PR2590 provide separate independent cost audits. At the final checkpoint PR2688 adds a pending directory-only allowance without changing the total caller reserve obligation.", + "boundary":"Read-only incoming generated program/frozen fields and complete fresh rows; arbitrary dirty payload. Return F_A in original row/spectator order and erase owned work. See PROOF.md for quantified hypotheses and read sets.", + "cost_ledger":"Retained primitive/source bounds plus a constructive complete first-node C_q V(n+w) upper bound under root coupling. Total numerical reserve constants, larger recursive parking and full transfer remain unknown.", + "decision_value":"Close the full first-node consumer without deferring peel, routes or cleanup. Pending QQ16/P104 profile changes have separate endpoint/retention/hosting budgets; local node completion does not admit a new supplier.", + "bounded_test":"Full source census, complete generic Boolean execution, actual selected generated peel and source junctions, with lost-update/stock/frame controls. Stop on a failed implication or complete this package." + }, + "open_questions":[ + {"question":"Can a larger selected child use this node while its parent directories and staged roles remain live?","why_it_matters":"The first-range node closes the below64 callee chain; all-size recursion needs nested row production and a charged parent return.","first_step":"At a new expansion gate, fix one smallest above-range parent and list the live payload, 661-role staging, directories and program at each child entry and return.","blocked_by":"Recursive parking/return construction and numerical reserve admission."}, + {"question":"Can a numerical workspace constant admit this complete caller?","why_it_matters":"Our asymptotic bound counts 661 staged roles and directories; older four-buffer constants do not apply unchanged.","first_step":"Check PR2688's directory-only component, derive the remaining simultaneous live volumes including output disposal, then substitute the total into the selected reserve inequality.","blocked_by":"A complete live-volume certificate and the applicable pending reserve contract."}, + {"question":"Can a formal stream-machine compiler check this node refinement?","why_it_matters":"Written proofs and finite Boolean executions do not establish formal-kernel acceptance.","first_step":"Formalize the latest-family scatter and chronological low-sweep invariants over the pinned stream primitives.","blocked_by":"Operational compiler model and formalized predecessor refinements."} + ] +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/VERIFY.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/VERIFY.json new file mode 100644 index 0000000000..69c7ad75ab --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/VERIFY.json @@ -0,0 +1,21 @@ +{ + "schema_version":1, + "status":"ready", + "python":"3.12", + "requirements":[], + "inputs":[ + "research/pr589-five-helper-hosting/verify.py", + "research/pr589-five-helper-hosting/PROOF.md", + "research/e8-bit-p111-tuned/tune/bitE8mut-p111-tuned.json.gz", + "research/community-hyperplane599-audit/pr589/bit589/v9/hosted/GLOBAL-TEMPLATE.json.gz", + "research/community-hyperplane599-audit/pr589/bit589/v9/nine/GEOMETRY.json", + "research/e8-bit-p111-tuned/tune/EXPECTED.json", + "research/recursive-parking-boundary/README.md", + "upstream/build/sections/02-streams.tex" + ], + "commands":[ + {"argv":["{python}","-I","-B","{package}/verify.py","--suite","source"],"timeout_seconds":400,"checks":"Authenticate inputs and full selected source/literal bindings; check actual consumer junctions and generated peel; execute complete gapped Boolean endpoint and sampled multi-high packet."}, + {"argv":["{python}","-I","-B","{package}/verify.py","--suite","node"],"timeout_seconds":600,"checks":"Execute complete four-family GL2 node on31104 independent Boolean columns, with intermediate alias-sweep endpoints, actual leaves, private lifetimes and cleanup."}, + {"argv":["{python}","-I","-O","-B","{package}/verify.py","--suite","controls"],"timeout_seconds":200,"checks":"With assertions disabled, witness both stale-state failures, reversed Y bridge and family exchange; reject frame/range/stock faults and check arbitrary-width cardinalities."} + ] +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/cardinal_counts.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/cardinal_counts.py new file mode 100644 index 0000000000..6a14feac45 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/cardinal_counts.py @@ -0,0 +1,55 @@ +"""Separate unbounded tapes for products of arbitrary spectator cardinalities.""" +from counts import Count as RetainedCount +from words import LEFT, ONE, RIGHT, ZERO, need + + +class Count(RetainedCount): + def zero(self): + self.rewind() + result=self.read()==ZERO + self.step(1) + result=result and self.read()==RIGHT + self.rewind() + return result + + def add(self,other): + source=Count(other) + self.rewind();source.rewind() + carry=0;left_done=False + try: + while True: + if not left_done and self.read()==RIGHT:left_done=True + right_done=source.read()==RIGHT + if left_done and right_done and not carry:break + a=ZERO if left_done else self.read() + b=ZERO if right_done else source.read() + need(a in (ZERO,ONE) and b in (ZERO,ONE),"binary cardinality sum") + total=a+b+carry + self.tape.write(total&1);carry=total>>1 + self.step(1) + if not right_done:source.step(1) + self.tape.write(RIGHT) + self.normalize() + finally:source.close() + + @classmethod + def product(cls,left,right): + factor,scan,result=cls(left),cls(right),cls.literal(0) + scan.msb() + try: + while scan.read()!=LEFT: + result.multiply_small(2) + if scan.read()==ONE:result.add(factor) + else:need(scan.read()==ZERO,"binary multiplier digit") + scan.step(-1) + scan.step(1) + return result + except ValueError: + result.close() + raise + finally: + factor.close();scan.close() + + +def positive(value): + need(isinstance(value,Count) and not value.zero(),"independent positive cardinality tape") diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/catalogue.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/catalogue.py new file mode 100644 index 0000000000..0efc0575a7 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/catalogue.py @@ -0,0 +1,268 @@ +"""Fixed selected request compilation, adapted from pinned PR2234 provider.py. + +Only q, rational labels and low classes enter these compilation routines. +Runtime precision, high matrices, widths and coefficients remain on tapes. +""" +from collections import Counter, defaultdict +from dataclasses import dataclass +from fractions import Fraction as F +from functools import cached_property, lru_cache +from hashlib import sha256 +import importlib.util +import json + +from binding import split_basis +from low_codes import LowCodes +import oracle +from plan import compile_plan +from sources import ROOT, Template, compile_specification, identity, product +from words import need + + +def canonical(value): + return json.dumps(value,sort_keys=True,separators=(",",":")) + + +@dataclass(frozen=True) +class Base: + kind: str + data: tuple + rank: int + + @cached_property + def key(self): + values=[[str(x) for x in row] for row in self.data] if self.kind=="local" else self.data + return sha256(canonical([self.kind,self.rank,values]).encode()).hexdigest() + + @lru_cache(None) + def matrix(self): + out=[[F(0)]*64 for _ in range(64)] + if self.kind=="local": + for i,row in enumerate(self.data):out[i][:8]=row + else: + need(self.kind=="idle" and len(set(self.data))==self.rank,"fixed idle base") + for i in self.data:out[i][i]=F(1) + return tuple(map(tuple,out)) + + @lru_cache(None) + def basis(self,q): + return split_basis(self.matrix(),self.rank,q) + + +@dataclass(frozen=True) +class Chart: + kind: str + port: int = -1 + stage: int = -1 + axes: tuple = () + + @property + def key(self):return (self.kind,self.port,self.stage,self.axes) + + +@dataclass(frozen=True) +class Request: + kind: str + stage: int + position: int + role: int + family: int + old_frame: int + new_frame: int + base: Base + chart: Chart + header_space: str + source_chart: object = None + + def record(self): + return [self.kind,self.stage,self.position,self.role,self.family, + self.old_frame,self.new_frame,self.base.key,self.base.rank, + self.chart.key,self.header_space,self.source_chart.key if self.source_chart else None] + + +class Catalogue: + dimension=64 + replicas=32 + families=28416 + private=661 + replica_stride=888 + + def __init__(self,q): + self.q=q + path=ROOT/"research/pr589-five-helper-hosting/verify.py" + spec=importlib.util.spec_from_file_location("retained_selected_node_source",path) + self.old=importlib.util.module_from_spec(spec);spec.loader.exec_module(self.old) + self.word,self.template,self.geometry=(self.old.read(p) for p in + (self.old.WORD,self.old.HOST,self.old.GEO)) + rows=[self.old.projection([self.word["lines"][i] for i in frame]) for frame in self.word["frames"]] + self.projectors=[p for p,_ in rows];self.dimensions=[r for _,r in rows] + self.idles={event["idx"]:event for event in self.template["schedule"] if event["kind"]=="idle"} + self.requests=[];self.bases={};self.charts=set();self.erase_guards=[] + self._bind() + self.codes=LowCodes(q,64,len(self.requests)) + self.identifiers={self.semantic_key(request):i for i,request in enumerate(self.requests)} + need(len(self.identifiers)==len(self.requests),"unique full catalogue request identifiers") + + @staticmethod + def semantic_key(request): + return (request.kind,request.stage,request.role if request.kind=="IDLE" else request.position) + + def base(self,a,b): + lo,hi=(a,b) if self.dimensions[a]<=self.dimensions[b] else (b,a) + value=Base("local",self.old.sub(self.projectors[hi],self.projectors[lo]), + self.dimensions[hi]-self.dimensions[lo]) + return self.bases.setdefault(value.key,value) + + def pending(self,child):return tuple(self.old.pending_axes(self.idles[child])) + + def owner_chart(self,call,role): + family,route=call["owners"][role] + if route[0]=="data":return Chart("data",route[2],route[1]) + need(route[0]=="hosted","selected owner route kind") + _,child,offset,width=route + axes=self.pending(child)[offset:offset+width] + need(len(axes)==8,"complete selected helper support") + return Chart("host",family%111 if min(axes)<8 else -1,axes=axes) + + @lru_cache(None) + def chart_matrix(self,chart): + out=identity(64) + if chart.kind=="identity":return tuple(map(tuple,out)) + if chart.kind=="data": + if chart.stage==0:return tuple(map(tuple,out)) + axes=list(range(8))+list(range(8+7*(chart.stage-1),8+7*chart.stage)) + rho=self.geometry["ports"][chart.port]["rho15"] + for i,a in enumerate(axes): + for j,b in enumerate(axes):out[a][b]=F(rho[i][j]) + return tuple(map(tuple,out)) + if chart.kind=="family" or (chart.kind=="host" and chart.port>=0): + port=self.geometry["ports"][chart.port] + for i in range(8):out[i][:8]=[F(port["q"][i],2)]+list(map(F,port["complement_columns"][i])) + if chart.kind=="host": + domain,support=set(range(8)),set(chart.axes);permutation=list(range(64)) + for a,b in zip(sorted(domain-support),sorted(support-domain)): + permutation[a],permutation[b]=b,a + need(set(permutation[:8])==support,"selected owner support completion") + out=[[row[permutation[j]] for j in range(64)] for row in out] + else:need(chart.kind=="family","known fixed chart") + return tuple(map(tuple,out)) + + def _append(self,request): + need(0=n else 1),9**(y-x-1)*(5 if x=n else 1),7*9**(2*n-1-x)*(5 if x>3)^(i>>7)^0x53)&1) + tape.origins={i+1:(1<=0: + enlarged=Count.product(pre,self.gap);pre.close();pre=enlarged + if g.raw.compare(last,self.parent_size)<0: + enlarged=Count.product(tail,self.gap);tail.close();tail=enlarged + values=[pre] + if b is not None: + distance=g.raw.subtract_exact(b,a) + count=g.raw.subtract_exact(distance,g.one) + middle=Count.literal(1) + multiply_atom_power(middle,count,self.ring,self.q) + if g.raw.compare(a,self.parent_size)<0 and g.raw.compare(b,self.parent_size)>=0: + enlarged=Count.product(middle,self.gap);middle.close();middle=enlarged + values.append(middle) + g.index.free_many(distance,count,b) + values.append(tail);g.index.free(a) + result=[value.marginal() for value in values] + for value in values:value.close() + return result + + def fibre(self): + value=Count.product(self.before,self.gap) + multiply_atom_power(value,self.total,self.ring,self.q) + result=Count.product(value,self.suffix) + value.close() + return result + + def close(self): + self.geometry.index.free_many(self.core,self.extra,self.total) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/model.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/model.py new file mode 100644 index 0000000000..9fb82fa57d --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/model.py @@ -0,0 +1,172 @@ +"""Complete small caller fixture; production streams execute its residuals. + +The selected source/grammar checks are separate. This model has two-dimensional +projectors and four live families, not a sampled selected GL64 payload. +""" +from collections import Counter +from dataclasses import dataclass +from fractions import Fraction as F + +from cardinal_counts import Count +from directory import produce +from forms import fallback_form, good_form +from layout import Layout +from low_codes import LowCodes +from matrices import Matrices +from numeric import Geometry, Page +import oracle +import packet_engine +from plan import compile_plan +from records import BLANK, RECORD_END, Tape, append_word, read_finite, read_word, seek_record +from topology import Call, Owner +from trace import execute +from words import need + +I=((F(1),F(0)),(F(0),F(1))) +S=((F(0),F(1)),(F(1),F(0))) +A=((F(1),F(1)),(F(0),F(1))) + + +@dataclass(frozen=True) +class Request: + kind: str + base: int + family: int + chart: tuple = I + + +class Catalogue: + q=3 + dimension=2 + + def __init__(self): + self.requests=[] + for _stage in range(2): + self.requests.extend((Request("MOVE",0,0),Request("COPY",0,4),Request("MOVE",0,0,S))) + for family in range(4): + self.requests.extend((Request("IDLE",0,family,A),Request("IDLE",1,family,A))) + self.codes=LowCodes(3,2,len(self.requests)) + + def low_classes(self): + for ordinal in range(self.codes.size):yield self.codes.unrank(ordinal) + + +class Topology: + replicas=1 + pairs=2 + ports=1 + families=4 + stride=4 + + def __init__(self,catalogue): + self.catalogue=catalogue + self.idles={i:(6+i,) for i in range(8)} + self.schedule=tuple( + [{"kind":"local_cover_sweep","stage":0},{"kind":"local_cover_sweep","stage":1}] + +[{"kind":"idle","idx":i} for i in range(8)] + +[{"kind":"bridge","dst":0,"src":1,"coefficient":c} for c in (1,-1)] + +[{"kind":"local_cover_sweep","stage":i} for i in (2,3)] + +[{"kind":"exchange"}]) + + def call(self,stage,replica): + need(replica==0,"model replica") + if stage<2: + events=((0,0,0,1,1,0),(2,0,3,1,0,1,0),(1,2,3,1,0,0), + (1,2,3,1,0,0),(3,0,3,1,0,0,0),(0,1,0,1,1,0)) + requests=(3*stage,3*stage+1,None,None,None,3*stage+2) + return Call(stage,0,(Owner(0,I),Owner(0,S),Owner(1,I)),(0,0,0),(1,1,0),events,requests,False) + pair=stage-2 + return Call(stage,0,(Owner(2*pair,I),Owner(2*pair+1,I)),(0,0),(0,0), + ((1,1,0,1,0,0),(1,0,1,1,0,0),(1,1,0,1,0,0)),(None,None,None),False) + + @staticmethod + def matrix(chart):return chart + + def idle_family(self,identifier,replica): + need(replica==0,"model native replica") + return self.catalogue.requests[identifier].family + + @staticmethod + def family(replica,pair,side,port): + need(replica==port==0,"model family coordinates") + return 2*pair+side + + +class Incoming: + def __init__(self,context,indices,values): + self.context,self.indices=context,indices + self.tape=Tape() + for value in values: + word=context.arena.input(value) + append_word(self.tape,word);self.tape.append(RECORD_END) + context.arena.free(word) + self.tape.rewind() + + def weight(self,coordinate): + seek_record(self.tape,coordinate) + value=read_word(self.tape,self.context.arena) + need(self.tape.read()==RECORD_END,"complete encoded fixture weight") + self.tape.rewind() + return value + + def coefficient(self,prefix,request): + need(prefix.read()==BLANK and request.kind=="incoming","model frozen-only root context") + value=self.weight(request.coordinate) + if request.negative_inverse: + inverse=self.context.ring.inverse(value) + need(inverse is not None,"fixture unit weight") + opposite=self.context.ring.negate(inverse) + self.context.arena.free_many(value,inverse);value=opposite + return value + + def close(self):self.tape.clear() + + +class Consumer: + def __init__(self,context,indices,program,parent_size,depth,catalogue,incoming): + self.context,self.indices,self.program=context,indices,program + self.parent_size,self.depth,self.catalogue,self.incoming=parent_size,depth,catalogue,incoming + self.calls=Counter();self.children=Counter() + + def apply(self,source,identifier,common,low,old_directory,old_count,before,gap,suffix,observe=None): + context,indices,arena=self.context,self.indices,self.context.arena + request=self.catalogue.requests[identifier] + need(common==(request.kind!="IDLE"),"model current source view") + self.calls[request.kind]+=1 + basis=I if request.base==0 else S + chart=I if common else request.chart + preparation=tuple(tuple(sum(chart[i][k]*basis[k][j] for k in range(2)) for j in range(2)) for i in range(2)) + low_header=oracle.multiply(low,oracle.reduce_rational(preparation,context.q),context.q) + p=oracle.multiply([[row[0]] for row in low_header],oracle.inverse(low_header,context.q)[:1],context.q) + good=p[0][0]!=0 + plan=compile_plan(p,1,context.q,good) + code=context.codes.encode(identifier,common,low) + directory,prefixes=produce(old_directory,self.depth,old_count,code,context) + columns,one=indices.literal(1),indices.literal(1) + geometry=Geometry(plan,indices,columns,self.depth,code,self.program) + fields,carry=geometry.raw.add(self.depth,one);indices.free(one) + need(not carry,"model current field count") + layout=Layout(geometry,self.parent_size,context.ring,context.q,before,gap,suffix) + def coefficient(prefix,reference): + seek_record(prefix,self.depth) + need(read_finite(prefix,context.codes.bits)==code,"model produced request/view field") + high=[[read_word(prefix,arena) for _ in range(2)] for _ in range(2)] + need(prefix.read()==RECORD_END,"model raw high record") + prefix.step(1);need(prefix.read()==BLANK,"model current field is last");prefix.rewind() + matrices=Matrices(context.ring) + header=matrices.raw_header(low,high,context.q) + prepared=matrices.constants(preparation) + full=matrices.multiply(header,prepared) + projector=matrices.projector(full,1) + form=good_form(projector,1,context.ring) if good else fallback_form(projector,context.ring) + page=Page(plan,form,context.ring,indices,columns,self.incoming.weight,self.depth,code,self.program) + value=page.evaluate(reference);page.close() + for matrix in (high,header,prepared,full,projector):matrices.free(matrix) + return value + def boundary(kind): + self.children[kind]+=1 + if observe is not None:observe(kind) + try:return packet_engine.run(source,execute(geometry),layout,directory,prefixes,fields,coefficient,observe=boundary) + finally: + layout.close();geometry.close();indices.free_many(columns,fields) + directory.clear();prefixes.close() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/node.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/node.py new file mode 100644 index 0000000000..13badda6f0 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/node.py @@ -0,0 +1,68 @@ +"""One complete first-range node: peel, fresh rows, global caller and return.""" +from cardinal_counts import Count, positive +from cardinality import multiply_atom_power +from consumer import Consumer, IncomingWeights +from driver import Driver +import fresh_rows +from packet import read_prefix +import peel +from plan import Request +from topology import SelectedTopology +from words import Unsigned, need + + +class Node: + def __init__(self,context,indices,program,parent_size,depth,topology,consumer,incoming,stock_multiple=1): + self.context,self.indices,self.program=context,indices,program + self.parent_size,self.depth=parent_size,depth + self.topology,self.consumer,self.incoming=topology,consumer,incoming + self.stock_multiple=stock_multiple + raw=Unsigned(indices);dimension,one=indices.literal(context.dimension),indices.literal(1) + columns,remainder=raw.divmod(parent_size,dimension) + valid=raw.compare(columns,one)==0 + indices.free_many(dimension,one,columns,remainder) + need(valid,"complete node first internal range") + + def run(self,source,old_directory,old_count,row_count,before,gap,suffix,observe=None): + old_count,row_count,before,gap,suffix=(Count(value) for value in (old_count,row_count,before,gap,suffix)) + for value in (old_count,row_count,before,gap,suffix):positive(value) + context,indices=self.context,self.indices + unused=leading=fibre=None;peeled=None;families={} + try: + old_directory.rewind();first=read_prefix(old_directory,self.depth);old_directory.rewind() + zero=indices.zero() + try: + value=self.incoming.coefficient(first,Request("incoming",zero)) + context.arena.free(value) + finally:first.clear();indices.free(zero) + unused=fresh_rows.quotient(row_count,context,self.topology.families) + stock=Count(unused) + try:need(stock.divide_small(self.stock_multiple)==0,"selected compatible unused stock factor") + finally:stock.close() + leading=Count.product(unused,before) + fibre=Count.product(leading,gap) + total=Unsigned(indices).times_small(self.parent_size,2) + multiply_atom_power(fibre,total,context.ring,context.q);indices.free(total) + following=Count.product(fibre,suffix);fibre.close();fibre=following + peeled=peel.run(source,context,indices,self.parent_size,self.depth,self.program, + old_directory,old_count,row_count,before,gap,suffix,self.incoming) + families=fresh_rows.split(peeled,context,self.topology.families,old_count,fibre) + driver=Driver(context,self.topology,self.consumer,old_directory,old_count,leading,gap,suffix,fibre,observe) + driver.global_word(families) + return fresh_rows.merge(families,context,self.topology.families,old_count,fibre) + finally: + for tape in families.values():tape.clear() + if peeled is not None and peeled is not source:peeled.clear() + for value in (unused,leading,fibre,old_count,row_count,before,gap,suffix): + if value is not None:value.close() + source.rewind();old_directory.rewind() + + +class SelectedNode(Node): + def __init__(self,context,indices,program,parent_size,depth,catalogue,specifications): + need(context.dimension==64 and context.codes is catalogue.codes and + specifications.catalogue is catalogue,"one source-bound selected node") + topology=SelectedTopology(catalogue) + consumer=Consumer(context,indices,program,specifications,parent_size,depth) + incoming=IncomingWeights(context,indices,program,specifications,parent_size,depth) + super().__init__(context,indices,program,parent_size,depth,topology,consumer,incoming,9475) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/packet_engine.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/packet_engine.py new file mode 100644 index 0000000000..27a0dbf82e --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/packet_engine.py @@ -0,0 +1,63 @@ +"""Shared trace on complete prefixes, with the caller's full two-bank layout.""" +from bitstream import copy_bits +from packet import read_prefix +from records import Tape +from stream import Counter +from stream_runner import action +from words import BLANK, need + + +def run(source,events,layout,directory,prefix_count,field_count,coefficient,factory=Tape,observe=None): + fibre=layout.fibre() + current,active=source,None + try: + for event in events: + if event.kind=="enter": + need(active is None and event.parent_identity is layout.geometry.parent_identity, + "one whole-packet completed child") + active=event + if observe is not None:observe("enter") + continue + if event.kind=="return": + need(active is not None and active.parent_identity is event.parent_identity and + (active.child_kind,active.field,active.reverse,active.half,active.source_code)== + (event.child_kind,event.field,event.reverse,event.half,event.source_code), + "same completed child returns") + for a,b in ((active.first,event.first),(active.second,event.second), + (active.width,event.width),(active.depth,event.depth)): + need(layout.geometry.raw.compare(a,b)==0,"restored child geometry") + active=None + if observe is not None:observe("return") + continue + output,prefixes=factory(),Counter(prefix_count) + directory.rewind() + try: + need(not prefixes.finished,"nonempty complete prefix packet") + while not prefixes.finished: + fields=read_prefix(directory,field_count) + local,changed=factory(),None + try: + copy_bits(current,local,fibre);local.rewind() + changed=action(local,event,layout,lambda request:coefficient(fields,request),factory) + copy_bits(changed,output,fibre) + need(changed.read()==BLANK,"complete changed prefix fibre") + finally: + if changed is not None and changed is not local:changed.clear() + local.clear();fields.clear() + prefixes.decrement() + need(current.read()==directory.read()==BLANK,"complete shared packet and directory") + current.rewind();directory.rewind() + if current is not source:current.clear() + output.rewind();current=output + except ValueError: + output.clear() + raise + finally:prefixes.close() + need(active is None,"complete child lifetime") + return current + except ValueError: + if current is not source:current.clear() + raise + finally: + fibre.close();directory.rewind();source.rewind() + events.close() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/peel.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/peel.py new file mode 100644 index 0000000000..2ae1769a97 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/peel.py @@ -0,0 +1,44 @@ +"""Peel the last n-m head atoms using original incoming weight offsets.""" +from cardinal_counts import Count +from layout import Layout +from numeric import Geometry +import packet_engine +from plan import Plan, Request +from trace import primitive +from words import need + + +def events(geometry,parent_size): + raw,index=geometry.raw,geometry.index + coordinate=raw.times_small(geometry.columns,geometry.plan.dimension) + total=raw.times_small(parent_size,2) + last=raw.subtract_exact(total,geometry.one) + index.free(total) + try: + while raw.compare(coordinate,parent_size)<0: + right=raw.subtract_exact(last,coordinate) + try: + for stage in range(8): + a,b=index.copy(coordinate),index.copy(right) + if stage in (0,2,4,6):yield from primitive("atom_swap",a,b,None,geometry) + elif stage==7: + index.free(a);yield from primitive("sign",b,None,None,geometry) + else: + request=Request("incoming",index.copy(coordinate),negative_inverse=stage==3) + yield from primitive("add",b,a,request,geometry) + finally:index.free(right) + raw.increment_in_place(coordinate) + finally:index.free_many(coordinate,last) + + +def run(source,context,indices,parent_size,depth,program,old_directory,old_count, + fresh_rows,before,gap,suffix,incoming): + columns=indices.literal(1) + geometry=Geometry(Plan(context.dimension,1,True,()),indices,columns,depth,0,program) + leading=Count.product(fresh_rows,before) + layout=Layout(geometry,parent_size,context.ring,context.q,leading,gap,suffix,embedded=False) + try: + return packet_engine.run(source,events(geometry,parent_size),layout,old_directory, + old_count,depth,incoming.coefficient) + finally: + layout.close();leading.close();geometry.close();indices.free(columns) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/topology.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/topology.py new file mode 100644 index 0000000000..39a2916c20 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/topology.py @@ -0,0 +1,91 @@ +"""Fixed chronological selected calls, owners and global frame boundaries.""" +from dataclasses import dataclass +from functools import lru_cache +from hashlib import sha256 + +from catalogue import canonical +from words import need + + +@dataclass(frozen=True) +class Owner: + family: int + chart: object + + +@dataclass(frozen=True) +class Call: + stage: int + replica: int + owners: tuple + start: tuple + end: tuple + events: tuple + requests: tuple + reverse: bool + + +class SelectedTopology: + replicas=32 + pairs=4 + ports=111 + families=28416 + stride=888 + + def __init__(self,catalogue): + self.catalogue=catalogue + self.schedule=tuple(catalogue.template["schedule"]) + self.idles={i:tuple(j for j,r in enumerate(catalogue.requests) if r.kind=="IDLE" and r.stage==i) + for i in range(10)} + expected="Each recipe phase: replicas then all cover classes; finish every local invocation before the next." + need(catalogue.template["loop_order"]==expected,"source-selected loop order") + self._validate_global() + + def _validate_global(self): + levels=[-1]*4 + for position,event in enumerate(self.schedule): + kind=event["kind"] + if kind=="local_cover_sweep": + need(levels[event["pair"]]==event["stage"]-1,"local call enters its data level") + levels[event["pair"]]=event["stage"] + elif kind=="idle": + need(levels[event["pair"]]==event["source_level"],"idle enters its native level") + levels[event["pair"]]=event["target_level"] + need(bool(self.idles[event["idx"]])==(event["rank"]>0),"zero idle source boundary") + elif kind=="bridge": + need(event["coefficient"] in (-1,1) and event["dst"]!=event["src"] and + levels[event["dst"]]==levels[event["src"]],"native bridge frame alignment") + else: + need(kind=="exchange" and position==len(self.schedule)-1 and levels==[8]*4, + "terminal exchange frame boundary") + + @lru_cache(None) + def recipe(self,stage): + source=self.catalogue.template["calls"][32*stage] + reverse=source["orientation"]=="reverse" + events=tuple(map(tuple,self.catalogue.template["local_programs"][source["orientation"]])) + identifiers=tuple(self.catalogue.identifier("MOVE" if event[0]==0 else "COPY",stage,position) + if event[0] in (0,2) else None for position,event in enumerate(events)) + word=self.catalogue.word + start=tuple(word["final"] if reverse else word["start"]) + end=tuple(word["start"] if reverse else word["final"]) + return events,identifiers,start,end,reverse + + @lru_cache(None) + def call(self,stage,replica): + source=self.catalogue.template["calls"][32*stage+replica] + events,identifiers,start,end,reverse=self.recipe(stage) + owners=tuple(Owner(family,self.catalogue.owner_chart(source,role)) + for role,(family,_route) in enumerate(source["owners"])) + need(len(owners)==len(start)==len(end)==661,"complete selected staged roles") + return Call(stage,replica,owners,start,end,events,identifiers,reverse) + + def matrix(self,chart):return self.catalogue.chart_matrix(chart) + + def idle_family(self,request_id,replica): + request=self.catalogue.requests[request_id] + need(request.kind=="IDLE","native idle family") + return request.family+self.stride*replica + + def family(self,replica,pair,side,port): + return self.stride*replica+(2*pair+side)*self.ports+port diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/binding.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/binding.py new file mode 100644 index 0000000000..21a5a21220 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/binding.py @@ -0,0 +1,102 @@ +"""Fixed selected labels and explicit owner-to-common numerical specifications.""" +from dataclasses import dataclass, replace +from fractions import Fraction as F +from hashlib import sha256 +import importlib.util +import json + +from routes import compile_route +from sources import ROOT, Template, compile_specification, identity, independent_columns, product +from words import need + + +def split_basis(base, rank, q): + size = len(base) + complement = [[F(i == j)-base[i][j] for j in range(size)] for i in range(size)] + image, kernel = independent_columns(base, q), independent_columns(complement, q) + need((len(image), len(kernel)) == (rank, size-rank), "source projector rank") + basis = [[base[i][j] for j in image]+[complement[i][j] for j in kernel] for i in range(size)] + projected = [[basis[i][j] if j < rank else F(0) for j in range(size)] for i in range(size)] + need(product(base, basis) == projected and len(independent_columns(basis, q)) == size, + "fixed source split basis") + return tuple(map(tuple, basis)) + + +def common_template(template): + basis = split_basis(template.base, template.rank, template.q) + need(tuple(map(tuple, product(template.chart, basis))) == template.preparation, + "original owner preparation provenance") + return replace(template, chart=tuple(map(tuple, identity(len(template.base)))), preparation=basis, + record=template.record+("common-after-owner-route",)) + + +def owner_common(template, owner_low, request, vocabulary): + route = compile_route(owner_low, template.chart, vocabulary) + owner_code = vocabulary.encode(request, False, route.low) + common_code = vocabulary.encode(request, True, route.target_low) + owner = compile_specification(owner_code, template, route.low) + common = compile_specification(common_code, common_template(template), route.target_low) + need(owner.good == common.good, "same physical low projector branch") + return owner, common, route + + +@dataclass(frozen=True) +class Episode: + source: int + targets: tuple + private: int + records: tuple + sha256: str + source_family: int + target_families: tuple + chart: tuple + template: object + request: int = 1 + + +def selected_episode(q=3): + path = ROOT / "research/pr589-five-helper-hosting/verify.py" + spec = importlib.util.spec_from_file_location("selected_source_packet_labels", path) + old = importlib.util.module_from_spec(spec) + spec.loader.exec_module(old) + word, host = old.read(old.WORD), old.read(old.HOST) + call = host["calls"][0] + need(call["orientation"] == "forward", "selected episode orientation") + records = host["local_programs"]["forward"][21881:21938] + digest = sha256(json.dumps(records, separators=(",", ":")).encode()).hexdigest() + need(digest == "e622fdcb880ed9e39962929f64272937cc4ccdd6bafd7def1dc1d7a68512b35e", + "selected literal COPY511 episode") + need(records[0] == [2,473,661,511,0,7,0] and records[-1] == [3,473,661,511,0,0,0], + "exact transported COPY and ERASE") + targets = tuple(record[1] for record in records[1:-1]) + need(len(targets) == len(set(targets)) == 55 and + all(record == [1, target, 661, 1, 0, 0] and target not in (473,661) + for target, record in zip(targets, records[1:-1])), "immutable COPY source and private value") + family, route = call["owners"][473] + need(family == 527 and route == ["hosted",2,16,8], "selected COPY source owner") + idle = next(event for event in host["schedule"] if event["kind"] == "idle" and event["idx"] == 2) + support = old.pending_axes(idle)[16:24] + need(support == list(range(17,25)), "selected source support") + permutation = list(range(64)) + for i, j in enumerate(support): + permutation[i], permutation[j] = j, i + chart = tuple(tuple(F(permutation[j] == i) for j in range(64)) for i in range(64)) + target_families = tuple(call["owners"][target][0] for target in targets) + need(target_families == targets and family not in target_families and + all(call["owners"][target][1] == ["data",0,target % 111] for target in targets), + "disjoint stage-zero target families") + local, rank = old.projection([word["lines"][i] for i in word["frames"][511]]) + need(rank == 7, "selected COPY511 rank") + key = sha256(json.dumps(["local", rank, [[str(x) for x in row] for row in local]], + sort_keys=True, separators=(",", ":")).encode()).hexdigest() + need(key == "f256295f6139080a4b55eeb08cd459385c08060fbee5b1cf318379d6ee9b5cbf", + "selected COPY511 projector label") + base = [[F(0) for _ in range(64)] for _ in range(64)] + for i in range(8): + base[i][:8] = local[i] + basis = split_basis(base, rank, q) + record = ("COPY",0,21881,473,28416,511,0,key,7,"common",tuple(support),-1) + template = Template(q, rank, record, tuple(map(tuple, base)), + tuple(map(tuple, identity(64))), basis) + return Episode(473, targets, 661, tuple(map(tuple, records)), digest, family, + target_families, chart, template) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/bitstream.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/bitstream.py new file mode 100644 index 0000000000..4d1fd4abb0 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/bitstream.py @@ -0,0 +1,160 @@ +"""Complete atom swaps and address signs, using fixed-radix digit passes.""" +from cardinality import Natural, digit_suffix, radix_power +from records import Tape +from stream import Counter, copy_blocks, one_bit_suffix, positive_extent +from words import BLANK, ONE, ZERO, need + + +def unobserved(_counter): + pass + + +def copy_bits(source, target, length): + if one_bit_suffix(length): + bit = source.read() + need(bit in (ZERO, ONE), "opaque single payload bit") + target.append(bit) + source.step(1) + return + count = Counter(length) + while not count.finished: + bit = source.read() + need(bit in (ZERO, ONE), "opaque stream bit") + target.append(bit) + source.step(1) + count.decrement() + count.close() + + +def digit_swap(source, q, before, middle, suffix): + buckets = [[Tape() for _ in range(q)] for _ in range(q)] + outer = Counter(before) + while not outer.finished: + for a in range(q): + between = Counter(middle) + while not between.finished: + for b in range(q): + copy_bits(source, buckets[a][b], suffix) + between.decrement() + between.close() + outer.decrement() + outer.close() + need(source.read() == BLANK, "complete digit-swap input") + source.rewind() + for row in buckets: + for tape in row: + tape.rewind() + out, outer = Tape(), Counter(before) + while not outer.finished: + for a in range(q): + between = Counter(middle) + while not between.finished: + for b in range(q): + copy_bits(buckets[b][a], out, suffix) + between.decrement() + between.close() + outer.decrement() + outer.close() + for row in buckets: + for tape in row: + need(tape.read() == BLANK, "complete transposed digit bucket") + tape.clear() + out.rewind() + return out + + +def digit_complement(source, q, before, suffix): + buckets, outer = [Tape() for _ in range(q)], Counter(before) + while not outer.finished: + for digit in range(q): + copy_bits(source, buckets[digit], suffix) + outer.decrement() + outer.close() + need(source.read() == BLANK, "complete digit-complement input") + source.rewind() + for tape in buckets: + tape.rewind() + out, outer = Tape(), Counter(before) + while not outer.finished: + for digit in range(q): + copy_bits(buckets[q-1-digit], out, suffix) + outer.decrement() + outer.close() + for tape in buckets: + need(tape.read() == BLANK, "complete complemented digit bucket") + tape.clear() + out.rewind() + return out + + +def atom_swap(source, ring, q, before, middle, suffix): + for value in (before, middle, suffix): + positive_extent(value) + pre, gap, tail = Natural(before), Natural(middle), Natural(suffix) + digit_suffix(gap, ring, q) + digit_suffix(tail, ring, q) + current, first = source, True + try: + for _ in radix_power(ring, q): + if not first: + pre.multiply_small(q) + need(tail.divide_small(q) == 0, "exact next digit suffix") + following = digit_swap(current, q, pre, gap, tail) + if current is not source: + current.clear() + current, first = following, False + return current + finally: + pre.close() + gap.close() + tail.close() + + +def translate_one(source, ring, before, suffix): + leading = ring.raw.subtract_exact(ring.modulus, ring.one) + left, right, output = Tape(), Tape(), Tape() + outer = Counter(before) + while not outer.finished: + copy_blocks(source, left, leading, suffix, unobserved) + copy_blocks(source, right, ring.one, suffix, unobserved) + outer.decrement() + outer.close() + need(source.read() == BLANK, "complete translation input") + source.rewind() + left.rewind() + right.rewind() + outer = Counter(before) + while not outer.finished: + copy_blocks(right, output, ring.one, suffix, unobserved) + copy_blocks(left, output, leading, suffix, unobserved) + outer.decrement() + outer.close() + need(left.read() == right.read() == BLANK, "complete translation buckets") + left.clear() + right.clear() + ring.arena.free(leading) + output.rewind() + return output + + +def sign_address(source, ring, q, before, suffix): + for value in (before, suffix): + positive_extent(value) + pre, tail = Natural(before), Natural(suffix) + digit_suffix(tail, ring, q) + current, first = source, True + try: + for _ in radix_power(ring, q): + if not first: + pre.multiply_small(q) + need(tail.divide_small(q) == 0, "exact complemented suffix") + following = digit_complement(current, q, pre, tail) + if current is not source: + current.clear() + current, first = following, False + result = translate_one(current, ring, before, suffix) + current.clear() + return result + finally: + pre.close() + tail.close() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/cardinality.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/cardinality.py new file mode 100644 index 0000000000..b8ba857e32 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/cardinality.py @@ -0,0 +1,136 @@ +"""Canonical unbounded binary cardinalities on one sequential tape each.""" +from records import Tape +from stream import Counter +from words import BLANK, LEFT, ONE, RIGHT, ZERO, need + + +class Natural: + def __init__(self, source=None): + self.tape = Tape() + if source is None: + self.tape.append(ONE) + else: + source.rewind() + while source.read() != RIGHT: + bit = source.read() + need(bit in (ZERO, ONE), "binary cardinality input") + self.tape.append(bit) + source.step(1) + source.rewind() + self.tape.append(RIGHT) + self.normalize() + + def read(self): + return self.tape.read() + + def step(self, direction): + self.tape.step(direction) + + def rewind(self): + self.tape.rewind() + + def msb(self): + self.rewind() + while self.read() != RIGHT: + self.step(1) + self.step(-1) + + def normalize(self): + self.rewind() + while self.read() != RIGHT: + self.step(1) + self.step(-1) + while self.read() == ZERO: + self.tape.write(RIGHT) + self.step(1) + self.tape.write(BLANK) + self.step(-1) + self.step(-1) + if self.read() == LEFT: + self.step(1) + self.tape.write(ZERO) + self.step(1) + self.tape.write(RIGHT) + self.rewind() + + def multiply_small(self, constant): + """The multiplier and bounded carry belong to fixed finite control.""" + need(constant >= 2, "fixed cardinality multiplier") + carry = 0 + while self.read() != RIGHT: + total = constant*self.read()+carry + self.tape.write(total & 1) + carry = total >> 1 + self.step(1) + while carry: + self.tape.write(carry & 1) + carry >>= 1 + self.step(1) + self.tape.write(RIGHT) + self.rewind() + + def divide_small(self, constant): + self.msb() + remainder = 0 + while self.read() != LEFT: + remainder = 2*remainder+self.read() + if remainder >= constant: + self.tape.write(ONE) + remainder -= constant + else: + self.tape.write(ZERO) + self.step(-1) + self.step(1) + self.normalize() + return remainder + + def marginal(self): + """Copy with one high zero bit for the retained ADD input contract.""" + result = Natural(self) + result.msb() + result.step(1) + result.tape.write(ZERO) + result.step(1) + result.tape.write(RIGHT) + result.rewind() + return result + + def close(self): + self.tape.clear() + + +def radix_power(ring, q): + """Yield once per radix-q digit of M=q^w, without decoding w.""" + arena = ring.arena + divisor, power = arena.literal(q), arena.copy(ring.modulus) + try: + while ring.raw.compare(power, ring.one) > 0: + quotient, remainder = ring.raw.divmod(power, divisor) + need(remainder.zero() and not quotient.zero(), "cardinality prime-power context") + arena.free_many(power, remainder) + power = quotient + yield + need(ring.raw.compare(power, ring.one) == 0, "complete radix exponent") + finally: + arena.free_many(divisor, power) + + +def multiply_atom_power(value, exponent, ring, q): + count = Counter(exponent) + try: + while not count.finished: + for _ in radix_power(ring, q): + value.multiply_small(q) + count.decrement() + finally: + count.close() + + +def digit_suffix(value, ring, q): + """Multiply by q^(w-1), preserving an arbitrary spectator factor.""" + first = True + for _ in radix_power(ring, q): + if first: + first = False + else: + value.multiply_small(q) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/check_support.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/check_support.py new file mode 100644 index 0000000000..e1f961df9f --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/check_support.py @@ -0,0 +1,111 @@ +"""Checker-only native observations and source-bit provenance.""" +from contextlib import contextmanager +from records import Tape +from words import BLANK, LEFT, ONE, RIGHT, ZERO, Word, need + + +@contextmanager +def no_decode(): + previous = Word.inspect + def reject(_word): + raise ValueError("runtime numerical decoding") + Word.inspect = reject + try: + yield + finally: + Word.inspect = previous + + +def inspect_count(value): + value.rewind() + result, bit = 0, 0 + while value.read() != RIGHT: + result |= value.read() << bit + bit += 1 + value.step(1) + value.rewind() + return result + + +def bits(tape): + end = len(tape.cells) + while end > 1 and tape.cells[end-1] == BLANK: + end -= 1 + return bytes(tape.cells[1:end]) + + +def audit(arena, live=()): + need(arena.live == {word.slot for word in live}, "exact numerical ownership") + need(arena.template.head == 1, "restored numerical template") + for word in arena.words: + need(word.head == 1, "restored numerical head") + if word.slot not in arena.live: + need(word.cells[0] == LEFT and all(x == BLANK for x in word.cells[1:]), "erased numeric work") + + +def payload(length, seed=0): + tape = Tape() + for i in range(length): + tape.append(((i*7+seed*11) ^ (i >> 3) ^ (i >> 7)) & 1) + tape.rewind() + return tape + + +class Origins: + def __init__(self): + self.last, self.live, self.erased = None, set(), 0 + audit_state = self + class Control(Tape): + def __init__(self): + super().__init__() + audit_state.live.add(self) + + def clear(self): + super().clear() + need(self.head == 1 and not bits(self), "erased encoded control work") + if self in audit_state.live: + audit_state.live.remove(self) + audit_state.erased += 1 + class Tagged(Tape): + def __init__(self): + super().__init__() + self.origins = {} + audit_state.live.add(self) + + def read(self): + value = super().read() + if self.head in self.origins: + audit_state.last = self.origins[self.head] + return value + + def write(self, value): + super().write(value) + if value == BLANK: + self.origins.pop(self.head, None) + elif value in (ZERO, ONE) and audit_state.last is not None: + self.origins[self.head] = audit_state.last + + def clear(self): + super().clear() + need(self.head == 1 and not self.origins and not bits(self), "erased route scratch") + if self in audit_state.live: + audit_state.live.remove(self) + audit_state.erased += 1 + self.factory = Tagged + self.control_factory = Control + + def source(self, length): + tape = self.factory() + for i in range(length): + tape.append(((i*13) ^ (i >> 2)) & 1) + tape.origins = {i+1:i for i in range(length)} + tape.rewind() + return tape + + +def reject(function, message): + try: + function() + except ValueError: + return message + raise ValueError("missing rejection: "+message) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/children.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/children.py new file mode 100644 index 0000000000..ce4935f838 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/children.py @@ -0,0 +1,84 @@ +"""Serialized child extensions on the same raw-prefix field band.""" +from controller import Callback +from records import BLANK, FINITE_BITS, RECORD_END, ROOT, STEP, Program, append_finite, append_word +from words import need + + +def extend(incoming, request): + parent = incoming.program + index, residue = incoming.index, incoming.residue + need(request.child_kind in ("good", "pair", "unit"), "serialized child kind") + kind = {"good": 0, "pair": 1, "unit": 2}[request.child_kind] + specification = incoming.specifications[incoming.current_code] + rank = specification.template.rank + f, remainder = incoming.raw.divmod(incoming.final_size, incoming.sixty_four) + index.free(remainder) + if kind == 0: + size = incoming.raw.times_small(f, rank) + elif request.half: + need(kind == 2, "only orientation unit children halve") + size, remainder = incoming.raw.divmod(f, incoming.two_index) + index.free(remainder) + else: + size = index.copy(f) + index.free(f) + need(not size.zero() and incoming.raw.compare(request.coordinate, size) < 0, + "requested completed-child coordinate") + new_depth = incoming.plus(incoming.depth, incoming.one_index) + out = Program(index, residue, parent.code_bits) + out.tape.append(ROOT) + for word in (incoming.root_size, incoming.root_unit, new_depth): + append_word(out.tape, word) + out.tape.append(RECORD_END) + parent.tape.rewind() + while parent.tape.read() != RECORD_END: + parent.tape.step(1) + parent.tape.step(1) + while parent.tape.read() != BLANK: + out.tape.append(parent.tape.read()) + parent.tape.step(1) + parent.tape.rewind() + out.tape.append(STEP) + metadata = (kind, incoming.current_code, rank, request.field, int(request.reverse), int(request.half)) + for position, value in enumerate(metadata): + append_finite(out.tape, value, parent.code_bits if position == 1 else FINITE_BITS) + append_word(out.tape, incoming.final_size) + append_word(out.tape, size) + out.tape.append(RECORD_END) + out.tape.rewind() + index.free_many(size, new_depth) + return out + + +def coefficient(ring, index, program, fields, specifications, current_code, request): + """Evaluate an actual appended leaf program; no fresh current field exists.""" + parent, leaf, extended = None, None, None + protected_residues, protected_indices = frozenset(ring.arena.live), frozenset(index.live) + try: + parent = Callback(ring, index, program, fields, specifications, current_code, allow_fallback=True) + extended = extend(parent, request) + leaf = Callback(ring, index, extended, fields, specifications, current_code, + allow_fallback=True, leaf=True) + value = leaf.weight(request.coordinate) + if request.negative_inverse: + inverse = ring.inverse(value) + need(inverse is not None, "serialized child weight unit") + opposite = ring.negate(inverse) + ring.arena.free_many(value, inverse) + value = opposite + leaf.close() + parent.close() + extended.tape.clear() + return value + except ValueError: + if leaf is not None: + leaf.abort() + if parent is not None: + parent.abort() + if extended is not None: + extended.tape.clear() + ring.arena.rollback(protected_residues) + index.rollback(protected_indices) + program.tape.rewind() + fields.tape.rewind() + raise diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/controller.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/controller.py new file mode 100644 index 0000000000..c631a9e77f --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/controller.py @@ -0,0 +1,305 @@ +"""Encoded selected coefficient/offset callback, including descriptor indices. + +Runtime residues, extents, coordinates and generation levels remain words. +Only finite operation/source/rank/row labels enter native control. The loop +refines the retained PR2310/2332 grammar and PR2405 raw-prefix interface. +""" +from matrices import Matrices +from records import BLANK, CONSTANT, MULTIPLY, PAIR, RETURN, VALUE, Stack, seek_record +from words import LEFT, ONE, RIGHT, ZERO, Unsigned, need + +GOOD_KIND, PAIR_KIND, UNIT_KIND = range(3) + + +def finite_word(word, limit): + """Decode only a provably finite row/pivot label, not a variable index.""" + need(0 < limit <= 128, "finite row-label range") + word.msb() + state = 0 + while word.read() != LEFT: + bit = word.read() + need(bit in (ZERO, ONE), "finite-selector bit") + state = (state << 1) | bit + need(state < limit, "finite-selector extent") + word.step(-1) + word.step(1) + return state + + +class Callback: + def __init__(self, ring, index_arena, program, fields, specifications, current_code, + allow_fallback=False, leaf=False): + self.ring, self.residue = ring, ring.arena + self.index, self.raw = index_arena, Unsigned(index_arena) + self.program, self.fields, self.specifications = program, fields, specifications + self.current_code = current_code + self.leaf = leaf + self.protected_residues, self.protected_indices = frozenset(self.residue.live), frozenset(self.index.live) + need(current_code in specifications and (allow_fallback or specifications[current_code].good), + "selected good current site") + need(program.code_bits == fields.code_bits and + all(code == spec.code and 0 <= code < 1 << program.code_bits for code, spec in specifications.items()), + "one compiled source-code vocabulary") + self.q = specifications[current_code].template.q + need(all(spec.template.q == self.q for spec in specifications.values()), "one fixed source prime") + self.index.template.rewind() + large_enough = True + for _ in range(8): + if self.index.template.read() == RIGHT: + large_enough = False + break + self.index.template.step(1) + self.index.template.rewind() + need(large_enough, "internal-site index context has eight bits") + self.one_index, self.sixty_four = self.index.literal(1), self.index.literal(64) + self.two_index = self.index.literal(2) + self.matrices = Matrices(ring) + self.pending, self.values = Stack(index_arena, self.residue), Stack(index_arena, self.residue) + self.prepared_codes = set() # Bounded finite-vocabulary checker observation. + try: + self._prime_power_context() + self._validate_program() + except ValueError: + self.abort() + raise + + def plus(self, a, b): + value, carry = self.raw.add(a, b) + need(not carry, "binary index margin") + return value + + def _prime_power_context(self): + qword = self.residue.literal(self.q) # Fixed machine prime, not a runtime residue. + self.high_cap, remainder = self.ring.raw.divmod(self.ring.modulus, qword) + need(remainder.zero() and not self.high_cap.zero(), "positive prime-power field cap") + self.residue.free(remainder) + test = self.residue.copy(self.high_cap) + while self.ring.raw.compare(test, self.ring.one) > 0: + quotient, remainder = self.ring.raw.divmod(test, qword) + need(remainder.zero(), "modulus is a power of the fixed prime") + self.residue.free_many(test, remainder) + test = quotient + need(self.ring.raw.compare(test, self.ring.one) == 0, "complete prime-power reduction") + self.residue.free_many(test, qword) + + def step(self, level): + metadata, parent, child = self.program.step(level) + kind, code, rank, field, reverse, half = metadata + need(kind in (GOOD_KIND, PAIR_KIND, UNIT_KIND) and code in self.specifications, + "selected finite step/source") + spec = self.specifications[code] + need(rank == spec.template.rank and 1 <= rank <= 42, "actual selected rank") + need((kind == GOOD_KIND) == spec.good, "actual low-class branch") + need(reverse in (0, 1) and half in (0, 1), "finite step flags") + need(kind == UNIT_KIND or not half, "halving only at unit reset") + need((kind == PAIR_KIND and field < 127 and reverse == (field >= 64)) or + (kind != PAIR_KIND and field == 0 and reverse == 0), "physical pair field and reversal") + f, remainder = self.raw.divmod(parent, self.sixty_four) + self.index.free(remainder) + need(not f.zero(), "internal parent extent") + if kind == GOOD_KIND: + expected = self.raw.times_small(f, rank) + elif half: + expected, remainder = self.raw.divmod(f, self.two_index) + self.index.free(remainder) + else: + expected = self.index.copy(f) + need(not child.zero() and self.raw.compare(child, expected) == 0 and self.raw.compare(child, parent) < 0, + "exact proper generated child extent") + self.index.free(expected) + return metadata, parent, child, f + + def _validate_program(self): + self.root_size, self.root_unit, self.depth = self.program.root() + self.root_size.msb() + top = self.root_size.read() + self.root_size.step(-1) + significant = self.root_size.read() + self.root_size.rewind() + need(top == ZERO and significant == ONE, "canonical root-index word extent") + need(self.raw.compare(self.root_size, self.sixty_four) >= 0, "selected internal root") + need(self.ring.raw.compare(self.root_unit, self.ring.modulus) < 0, "canonical root unit") + inv = self.ring.inverse(self.root_unit) + need(inv is not None, "root coefficient unit") + self.residue.free(inv) + current, count = self.index.copy(self.root_size), self.index.zero() + while self.raw.compare(count, self.depth) < 0: + level = self.plus(count, self.one_index) + metadata, parent, child, f = self.step(level) + need(self.raw.compare(parent, current) == 0, "chronological program extents") + self.fields.check_code(count, metadata[1]) + self.index.free_many(parent, f, current, count) + current, count = child, level + self.index.free(count) + self.final_size = current + after = self.plus(self.depth, self.one_index) + seek_record(self.program.tape, after) + need(self.program.tape.read() == BLANK, "exact program depth") + self.program.tape.rewind() + if self.leaf: + self.fields.end(self.depth) + else: + self.fields.check_code(self.depth, self.current_code) + self.fields.end(after) + self.index.free(after) + + def prepare(self, slot, code, scope): + high = self.fields.read(slot, code, scope) + for row in high: + for digit in row: + need(self.ring.raw.compare(digit, self.high_cap) < 0, "canonical high digit") + spec = self.specifications[code] + p = self.matrices.prepare(spec.low, high, self.q, spec.template.preparation, spec.template.rank) + self.matrices.free(high) + # Only the checker consumes this finite source-code trace. + self.prepared_codes.add(code) + return p + + def weight(self, index): + need(self.raw.compare(index, self.final_size) < 0, "requested generated coordinate") + need(self.pending.empty() and self.values.empty(), "empty binary continuation roles") + self.pending.push(VALUE, self.depth, index) + while not self.pending.empty(): + tag, operands = self.pending.pop() + if tag == CONSTANT: + coefficient, = operands + self.values.push(RETURN, coefficient) + self.residue.free(coefficient) + elif tag == MULTIPLY: + coefficient, = operands + value_tag, values = self.values.pop() + need(value_tag == RETURN, "value-stack tag") + value, = values + result = self.ring.multiply(value, coefficient) + self.values.push(RETURN, result) + self.residue.free_many(coefficient, value, result) + elif tag == PAIR: + coefficient, = operands + den_tag, den_values = self.values.pop() + num_tag, num_values = self.values.pop() + need(den_tag == num_tag == RETURN, "ordered pair value tags") + denominator, = den_values + numerator, = num_values + inv = self.ring.inverse(denominator) + need(inv is not None, "generated pair denominator unit") + product = self.ring.multiply(coefficient, numerator) + result = self.ring.multiply(product, inv) + self.values.push(RETURN, result) + self.residue.free_many(coefficient, denominator, numerator, inv, product, result) + else: + need(tag == VALUE, "pending value request") + level, coordinate = operands + if level.zero(): + need(self.raw.compare(coordinate, self.root_size) < 0, "root coordinate extent") + self.values.push(RETURN, self.root_unit) + self.index.free_many(level, coordinate) + continue + metadata, parent, child, f = self.step(level) + kind, code, rank, field, reverse, _half = metadata + need(self.raw.compare(coordinate, child) < 0, "recursive coordinate extent") + if kind == UNIT_KIND: + self.values.push(RETURN, self.ring.one) + else: + slot = self.raw.subtract_exact(level, self.one_index) + p = self.prepare(slot, code, self.depth) + if kind == GOOD_KIND: + pivots = self.matrices.good_pivots(p, rank) + self.matrices.free(p) + quotient, remainder = self.raw.divmod(coordinate, f) + pivot = finite_word(quotient, rank) + self.pending.push(MULTIPLY, pivots[pivot]) + self.pending.push(VALUE, slot, coordinate) + self.residue.free_many(*pivots) + self.index.free_many(quotient, remainder) + else: + diagonal, permutation = self.matrices.fallback(p) + self.matrices.free(p) + self.pending.push(PAIR, diagonal[field]) + if reverse: + last = self.raw.subtract_exact(f, self.one_index) + column = self.raw.subtract_exact(last, coordinate) + self.index.free(last) + else: + column = self.index.copy(coordinate) + for row in (field, permutation[field]): + if row < 64: + first = self.raw.times_small(f, row) + position = self.plus(first, column) + self.pending.push(VALUE, slot, position) + self.index.free_many(first, position) + else: + self.pending.push(CONSTANT, self.ring.one) + self.residue.free_many(*diagonal) + self.index.free(column) + self.index.free(slot) + self.index.free_many(level, coordinate, parent, child, f) + tag, values = self.values.pop() + need(tag == RETURN and self.pending.empty() and self.values.empty(), "closed generated evaluation") + result, = values + return result + + def coefficient(self, target_row, column, inverse=False): + need(not self.leaf, "internal coefficient requires a current field") + need(0 < target_row < 64 and isinstance(target_row, int), "fixed head target row") + f, remainder = self.raw.divmod(self.final_size, self.sixty_four) + self.index.free(remainder) + need(not f.zero() and self.raw.compare(column, f) < 0, "current selected column") + scope = self.plus(self.depth, self.one_index) + p = self.prepare(self.depth, self.current_code, scope) + self.index.free(scope) + pinv = self.ring.inverse(p[0][0]) + need(pinv is not None, "selected good head pivot") + ratio = self.ring.multiply(p[target_row][0], pinv) + ell = self.ring.negate(ratio) + self.residue.free_many(pinv, ratio) + self.matrices.free(p) + base = self.raw.times_small(f, target_row) + index = self.plus(base, column) + self.index.free_many(base, f) + numerator, denominator = self.weight(index), self.weight(column) + self.index.free(index) + ainv = self.ring.inverse(denominator) + need(ainv is not None, "incoming head coefficient unit") + product = self.ring.multiply(ell, numerator) + coefficient = self.ring.multiply(product, ainv) + self.residue.free_many(ell, numerator, denominator, ainv, product) + if inverse: + opposite = self.ring.negate(coefficient) + self.residue.free(coefficient) + coefficient = opposite + return coefficient + + def offset(self, target_row, column, source, inverse=False): + need(self.ring.raw.compare(source, self.ring.modulus) < 0, "canonical source atom") + coefficient = self.coefficient(target_row, column, inverse) + result = self.ring.multiply(coefficient, source) + self.residue.free(coefficient) + return result + + def close(self): + need(self.pending.empty() and self.values.empty(), "closed continuation interface") + self.index.free_many(self.root_size, self.depth, self.final_size, + self.one_index, self.sixty_four, self.two_index) + self.residue.free_many(self.root_unit, self.high_cap) + + def abort(self): + self.residue.rollback(self.protected_residues) + self.index.rollback(self.protected_indices) + self.program.tape.rewind() + self.fields.tape.rewind() + for stack in (self.pending, self.values): + stack.tape.clear() + stack.reverse.clear() + + +def selected_offset(ring, index_arena, program, fields, specifications, current_code, + target_row, column, source, inverse=False): + callback = Callback(ring, index_arena, program, fields, specifications, current_code) + try: + result = callback.offset(target_row, column, source, inverse) + prepared = tuple(sorted(callback.prepared_codes)) + callback.close() + return result, prepared + except ValueError: + callback.abort() + raise diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/counts.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/counts.py new file mode 100644 index 0000000000..81b48940ce --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/counts.py @@ -0,0 +1,57 @@ +"""Unbounded cardinalities; only compiled finite constants enter host control.""" +from cardinality import Natural, digit_suffix +from records import Tape +from words import ONE, RIGHT, ZERO, need + + +class Count(Natural): + @classmethod + def literal(cls, value): + """Compile a fixed cardinality, never decode a runtime operand.""" + need(isinstance(value, int) and value >= 0, "compiled cardinality") + tape = Tape() + for bit in range(max(1, value.bit_length())): + tape.append((value >> bit) & 1) + tape.append(RIGHT) + tape.rewind() + result = cls(tape) + tape.clear() + return result + + def increment(self): + self.rewind() + while self.read() == ONE: + self.tape.write(ZERO) + self.step(1) + if self.read() == RIGHT: + self.tape.write(ONE) + self.step(1) + self.tape.write(RIGHT) + else: + need(self.read() == ZERO, "canonical count digit") + self.tape.write(ONE) + self.rewind() + + def equals(self, other): + self.rewind() + other.rewind() + same = True + while self.read() != RIGHT and other.read() != RIGHT: + same = same and self.read() == other.read() + self.step(1) + other.step(1) + same = same and self.read() == other.read() == RIGHT + self.rewind() + other.rewind() + return same + + +def high_power(value, ring, q, dimension): + for _ in range(dimension*dimension): + digit_suffix(value, ring, q) + + +def high_count(ring, q, dimension): + result = Count.literal(1) + high_power(result, ring, q, dimension) + return result diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/directory.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/directory.py new file mode 100644 index 0000000000..c74cacf5ce --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/directory.py @@ -0,0 +1,126 @@ +"""Produce all high fields while preserving physical old-prefix multiplicity.""" +from cardinality import radix_power +from counts import Count, high_count, high_power +from records import RECORD_END, Tape, append_finite, append_word, read_finite, read_word +from stream import Counter +from words import BLANK, RIGHT, ZERO, need + + +class Context: + def __init__(self, ring, vocabulary): + self.ring, self.arena, self.raw = ring, ring.arena, ring.raw + self.codes = vocabulary + self.q, self.dimension = vocabulary.q, vocabulary.dimension + for _ in radix_power(ring, self.q): + pass + divisor = self.arena.literal(self.q) + self.cap, remainder = self.raw.divmod(ring.modulus, divisor) + need(remainder.zero() and not self.cap.zero(), "positive high-field radix") + self.arena.free_many(divisor, remainder) + self.highs = high_count(ring, self.q, self.dimension) + + def close(self): + self.arena.free(self.cap) + self.highs.close() + + +class Odometer: + def __init__(self, context): + self.context = context + self.digits = [[context.arena.zero() for _ in range(context.dimension)] + for _ in range(context.dimension)] + self.finished = False + + def advance(self): + need(not self.finished, "live high odometer") + context = self.context + for row in reversed(self.digits): + for digit in reversed(row): + context.raw.increment_in_place(digit) + if context.raw.compare(digit, context.cap) < 0: + return + need(context.raw.compare(digit, context.cap) == 0, "high digit carry") + while digit.read() != RIGHT: + digit.write(ZERO) + digit.step(1) + digit.rewind() + self.finished = True + + def close(self): + for row in self.digits: + self.context.arena.free_many(*row) + + +def append_tape(source, destination): + source.rewind() + while source.read() != BLANK: + destination.append(source.read()) + source.step(1) + source.rewind() + + +def old_prefix(source, field_count, context): + """Retain one serialized prefix; decode at most one old numerical word.""" + output, remaining = Tape(), Counter(field_count) + try: + while not remaining.finished: + code = read_finite(source, context.codes.bits) + need(code < context.codes.limit, "old compiled source code") + append_finite(output, code, context.codes.bits) + for _ in range(context.dimension*context.dimension): + word = read_word(source, context.arena) + try: + need(context.raw.compare(word, context.cap) < 0, "old high digit range") + append_word(output, word) + finally: + context.arena.free(word) + need(source.read() == RECORD_END, "old field boundary") + source.step(1) + output.append(RECORD_END) + remaining.decrement() + output.rewind() + return output + except ValueError: + output.clear() + raise + finally: + remaining.close() + + +def produce(old, old_fields, old_count, code, context): + need(0 <= code < context.codes.limit, "new compiled source code") + expected, emitted = Count(old_count), Count.literal(0) + high_power(expected, context.ring, context.q, context.dimension) + outer, output = Counter(old_count), Tape() + old.rewind() + try: + need(not outer.finished, "nonempty old physical prefix domain") + while not outer.finished: + saved = old_prefix(old, old_fields, context) + high = Odometer(context) + try: + while not high.finished: + append_tape(saved, output) + append_finite(output, code, context.codes.bits) + for row in high.digits: + for digit in row: + append_word(output, digit) + output.append(RECORD_END) + emitted.increment() + high.advance() + finally: + saved.clear() + high.close() + outer.decrement() + need(old.read() == BLANK and emitted.equals(expected), "complete canonical raw directory") + old.rewind() + output.rewind() + return output, expected + except ValueError: + output.clear() + expected.close() + old.rewind() + raise + finally: + emitted.close() + outer.close() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/episode.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/episode.py new file mode 100644 index 0000000000..30d11ff4f3 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/episode.py @@ -0,0 +1,124 @@ +"""Transported COPY/XOR/ERASE on staged complete packets and physical families.""" +from counts import Count +from directory import produce +from records import Tape +from routes import copy_rows, route_packet +from selection import gather, scatter +from stream import Counter +from words import BLANK, ONE, ZERO, need + + +def xor_packet(source, target, context, old_count, fibre, factory=Tape): + output, outer = factory(), Counter(old_count) + source.rewind() + target.rewind() + try: + while not outer.finished: + highs = Counter(context.highs) + while not highs.finished: + bits = Counter(fibre) + while not bits.finished: + left, right = source.read(), target.read() + need(left in (ZERO, ONE) and right in (ZERO, ONE), "aligned Boolean operands") + output.append(left ^ right) + source.step(1) + target.step(1) + bits.decrement() + bits.close() + highs.decrement() + highs.close() + outer.decrement() + need(source.read() == target.read() == BLANK, "complete aligned XOR") + output.rewind() + return output + except ValueError: + output.clear() + raise + finally: + outer.close() + source.rewind() + target.rewind() + + +def staged(source, targets, episode, context, old_count, fibre, residual, factory=Tape): + """Call the concrete residual once, then retain its transported ERASE guard.""" + need(tuple(targets) == episode.targets and len({id(tape) for tape in targets.values()}) == len(targets) + and all(tape is not source for tape in targets.values()), "distinct staged live roles") + need(len(episode.records) == len(episode.targets)+2 and + episode.records[0][:3] == (2,episode.source,episode.private) and + episode.records[-1][:3] == (3,episode.source,episode.private) and + episode.records[0][3:5] == episode.records[-1][3:5] and + all(record[0] == 1 and record[1] == target and record[2] == episode.private + and record[3] in (-1,1) and target != episode.source + for target, record in zip(episode.targets, episode.records[1:-1])), + "closed source-preserving COPY interval") + initial, outer = factory(), Counter(old_count) + source.rewind() + while not outer.finished: + copy_rows(source, initial, context.highs, fibre) + outer.decrement() + outer.close() + need(source.read() == BLANK, "complete staged COPY source") + source.rewind() + initial.rewind() + private, result = None, {} + try: + private = residual(initial) + need(private is not initial and private is not source and + all(private is not value for value in targets.values()), "owned transported private result") + for target in episode.targets: + result[target] = xor_packet(private, targets[target], context, old_count, fibre, factory) + # Only reads of private and source occur after the completed transport. + # The authenticated literal word therefore supplies the transported + # equality guard; comparison with untransported source would be wrong. + need(source.head == private.head == 1, "transported source lifetime closes at ERASE") + return result + except ValueError: + for value in result.values(): + value.clear() + raise + finally: + if private is not None and private is not initial and private is not source: + private.clear() + initial.clear() + + +def physical(families, episode, source_route, common_code, context, old_directory, + old_fields, old_count, fibre, residual, factory=Tape): + """Gather, route, produce fields, execute, scatter and erase local work. + + residual(source, directory, prefix_count) must execute the completed + common-view residual and preserve its inputs. The verifier supplies the + actual PR2501 packet interpreter, including its leaf expansion. + """ + request, common, low = context.codes.decode(common_code) + need(common and request == episode.request and low == source_route.target_low + and source_route.chart == episode.chart, "current common-view source binding") + source = gather(families[episode.source_family], context, old_count, source_route.low, fibre, factory) + common_source = directory = prefixes = changed = None + targets, result = {}, {} + try: + common_source = route_packet(source, source_route, context, old_count, fibre, factory) + for role, family in zip(episode.targets, episode.target_families): + targets[role] = gather(families[family], context, old_count, low, fibre, factory) + directory, prefixes = produce(old_directory, old_fields, old_count, common_code, context) + changed = staged(common_source, targets, episode, context, old_count, fibre, + lambda value: residual(value, directory, prefixes), factory) + for role, family in zip(episode.targets, episode.target_families): + result[family] = scatter(families[family], changed[role], context, old_count, low, fibre, factory) + return result + except ValueError: + for value in result.values(): + value.clear() + raise + finally: + source.clear() + if common_source is not None: + common_source.clear() + for collection in (targets, changed or {}): + for value in collection.values(): + value.clear() + if directory is not None: + directory.clear() + if prefixes is not None: + prefixes.close() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/forms.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/forms.py new file mode 100644 index 0000000000..6667c0b772 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/forms.py @@ -0,0 +1,182 @@ +"""Complete selected adapter preparations with binary scalar operands. + +The fixed matrix and reduction indices are finite control. All coefficients +remain Word objects. Algebra follows source527 and PR2159/2160/2188/2234. +""" +from dataclasses import dataclass + +from matrices import Matrices +from words import need + + +@dataclass +class GoodForm: + dimension: int + rank: int + pivots: tuple + rows: tuple + columns: tuple + cross: list + + def close(self, ring): + ring.arena.free_many(*self.pivots) + for _, _, value in self.rows + self.columns: + ring.arena.free(value) + Matrices(ring).free(self.cross) + + +@dataclass +class Reduction: + kind: str + target: int + source: int + scalar: object + permutation: tuple + + +@dataclass +class FallbackForm: + dimension: int + diagonal: tuple + permutation: tuple + reductions: tuple + negative_sign: bool + + def close(self, ring): + ring.arena.free_many(*self.diagonal) + for reduction in self.reductions: + if reduction.scalar is not None: + ring.arena.free(reduction.scalar) + + +def row_add(matrix, target, source, coefficient, ring): + if coefficient.zero(): + return + for j in range(len(matrix[0])): + product = ring.multiply(coefficient, matrix[source][j]) + result = ring.add(matrix[target][j], product) + ring.arena.free_many(matrix[target][j], product) + matrix[target][j] = result + + +def column_add(matrix, target, source, coefficient, ring): + if coefficient.zero(): + return + for row in matrix: + product = ring.multiply(coefficient, row[source]) + result = ring.add(row[target], product) + ring.arena.free_many(row[target], product) + row[target] = result + + +def negative_product(a, b, ring): + value = ring.multiply(a, b) + result = ring.negate(value) + ring.arena.free(value) + return result + + +def good_form(projector, rank, ring): + """Keep chronological row/column scalars and the full cross block.""" + m = len(projector) + need(1 <= rank < m <= 64, "fixed good preparation dimension") + matrices, arena = Matrices(ring), ring.arena + a = [[arena.copy(value) for value in reversed(row)] for row in projector] + left, right = matrices.identity(m), matrices.identity(m) + pivots, rows, columns = [], [], [] + for k in range(rank): + column = m-1-k + pivot = arena.copy(a[k][column]) + inverse = ring.inverse(pivot) + need(inverse is not None, "complete good class") + pivots.append(pivot) + for i in range(k+1, m): + coefficient = negative_product(a[i][column], inverse, ring) + rows.append((i, k, coefficient)) + row_add(a, i, k, coefficient, ring) + row_add(left, i, k, coefficient, ring) + for j in range(column): + coefficient = negative_product(a[k][j], inverse, ring) + columns.append((column, j, coefficient)) + column_add(a, j, column, coefficient, ring) + column_add(right, j, column, coefficient, ring) + arena.free(inverse) + for i in range(m): + for j in range(m): + need(ring.raw.compare(a[i][j], pivots[i]) == 0 if i < rank and j == m-1-i + else a[i][j].zero(), "complete northeast diagonal endpoint") + matrices.free(a) + li, ri = matrices.inverse(left), matrices.inverse(right) + lp = matrices.multiply(left, projector) + a0 = matrices.multiply(lp[:rank], li) + b = matrices.multiply(ri, [row[:rank] for row in reversed(li)]) + for matrix in (a0, b): + for row in matrix: + for j, value in enumerate(row): + row[j] = ring.negate(value) + arena.free(value) + cross = matrices.zero(m, m) + for k, pivot in enumerate(pivots): + inverse = ring.inverse(pivot) + need(inverse is not None, "good pivot remains a unit") + for i in range(m): + value = ring.negate(b[i][k]) + if i == m-1-k: + adjusted = ring.subtract(value, inverse) + arena.free(value) + value = adjusted + arena.free(cross[i][k]) + cross[i][k] = value + for j in range(rank, m): + value = ring.multiply(inverse, a0[k][j]) + arena.free(cross[m-1-k][j]) + cross[m-1-k][j] = value + arena.free(inverse) + for matrix in (left, right, li, ri, lp, a0, b): + matrices.free(matrix) + return GoodForm(m, rank, tuple(pivots), tuple(rows), tuple(columns), cross) + + +def fallback_form(projector, ring): + """Retain each shear's original pair and pre-operation permutation.""" + matrices, arena = Matrices(ring), ring.arena + rows = matrices.residual(projector) + size = len(rows) + permutation, reductions = list(range(size)), [] + for j in range(size): + inverse = None + for pivot in range(j, size): + inverse = ring.inverse(rows[pivot][j]) + if inverse is not None: + break + need(inverse is not None, "complete fallback unit pivot") + if pivot != j: + reductions.append(Reduction("swap", j, pivot, None, tuple(permutation))) + rows[j], rows[pivot] = rows[pivot], rows[j] + permutation[j], permutation[pivot] = permutation[pivot], permutation[j] + for i in range(size): + if i == j: + continue + coefficient = negative_product(rows[i][j], inverse, ring) + reductions.append(Reduction("shear", i, j, coefficient, tuple(permutation))) + row_add(rows, i, j, coefficient, ring) + arena.free(inverse) + diagonal = [] + determinant = arena.copy(ring.one) + for i in range(size): + for j in range(size): + if i == j: + diagonal.append(rows[i][j]) + value = ring.multiply(determinant, rows[i][j]) + arena.free(determinant) + determinant = value + else: + need(rows[i][j].zero(), "complete fallback diagonal endpoint") + arena.free(rows[i][j]) + negative_one = ring.negate(ring.one) + positive = ring.raw.compare(determinant, ring.one) == 0 + negative = ring.raw.compare(determinant, negative_one) == 0 + need(positive or negative, "fallback terminal determinant sign") + arena.free_many(determinant, negative_one) + return FallbackForm(len(projector), tuple(diagonal), tuple(permutation), + tuple(reductions), not positive) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/low_codes.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/low_codes.py new file mode 100644 index 0000000000..737edfc4a1 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/low_codes.py @@ -0,0 +1,109 @@ +"""Fixed-q compilation of lexicographic GL codes, independent of input width.""" +from math import prod +from words import need + + +class Constraints: + def __init__(self, rows, q): + self.rows, self.q = rows, q + self.basis, self.inconsistent = [], False + + def next(self, column): + coefficients = [row[column] for row in self.rows] + rhs = 0 + for pivot, row, value in self.basis: + factor = coefficients[pivot] + coefficients = [(a-factor*b) % self.q for a, b in zip(coefficients, row)] + rhs = (rhs+factor*value) % self.q + pivot = next((i for i, x in enumerate(coefficients) if x), None) + return coefficients, rhs, pivot + + def excluded(self, reduced, value): + if self.inconsistent: + return 0 + _row, rhs, pivot = reduced + if pivot is not None: + return self.q**(len(self.rows)-len(self.basis)-1) + return self.q**(len(self.rows)-len(self.basis)) if value == rhs else 0 + + def choose(self, reduced, value): + if self.inconsistent: + return + row, rhs, pivot = reduced + if pivot is None: + self.inconsistent = value != rhs + return + inverse = pow(row[pivot], -1, self.q) + normalized = tuple(x*inverse % self.q for x in row) + self.basis.append((pivot, normalized, (value-rhs)*inverse % self.q)) + self.basis.sort(key=lambda item: item[0]) + + +class LowCodes: + def __init__(self, q, dimension, requests=1): + need(q >= 3 and all(q % p for p in range(2, q)) and + 1 <= dimension <= 64 and requests > 0, "fixed prime and source vocabulary") + self.q, self.dimension, self.requests = q, dimension, requests + self.radices = tuple(q**dimension-q**k for k in range(dimension)) + self.size = prod(self.radices) + self.limit = 2*requests*self.size + self.bits = max(1, (self.limit-1).bit_length()) + + def vector_rank(self, rows, vector): + constraints, rank = Constraints(rows, self.q), 0 + for column, value in enumerate(vector): + reduced = constraints.next(column) + total = self.q**(self.dimension-column-1) + for smaller in range(value): + rank += total-constraints.excluded(reduced, smaller) + constraints.choose(reduced, value) + need(constraints.inconsistent, "independent low row") + return rank + + def vector_unrank(self, rows, rank): + constraints, vector = Constraints(rows, self.q), [] + for column in range(self.dimension): + reduced = constraints.next(column) + total = self.q**(self.dimension-column-1) + for value in range(self.q): + count = total-constraints.excluded(reduced, value) + if rank < count: + vector.append(value) + constraints.choose(reduced, value) + break + rank -= count + else: + raise ValueError("low-row rank range") + need(rank == 0 and constraints.inconsistent, "complete independent low row") + return tuple(vector) + + def rank(self, matrix): + need(len(matrix) == self.dimension and + all(len(row) == self.dimension and all(isinstance(x, int) and 0 <= x < self.q + for x in row) for row in matrix), + "fixed low matrix shape and residues") + rank, previous = 0, [] + for row, radix in zip(matrix, self.radices): + rank = rank*radix+self.vector_rank(previous, row) + previous.append(tuple(row)) + return rank + + def unrank(self, rank): + need(isinstance(rank, int) and 0 <= rank < self.size, "GL low ordinal") + digits = [] + for radix in reversed(self.radices): + rank, digit = divmod(rank, radix) + digits.append(digit) + rows = [] + for digit in reversed(digits): + rows.append(self.vector_unrank(rows, digit)) + return tuple(rows) + + def encode(self, request, common, matrix): + need(0 <= request < self.requests and common in (False, True), "fixed request/view tag") + return (2*request+int(common))*self.size+self.rank(matrix) + + def decode(self, code): + need(isinstance(code, int) and 0 <= code < self.limit, "complete compiled source code") + tag, ordinal = divmod(code, self.size) + return tag//2, bool(tag & 1), self.unrank(ordinal) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/matrices.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/matrices.py new file mode 100644 index 0000000000..5d497353ef --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/matrices.py @@ -0,0 +1,217 @@ +"""Fixed-dimensional preparations whose entries are binary word tapes. + +Matrix positions and row permutations range over the fixed 64/128-dimensional +control alphabet. Runtime entries never become Python integers. The algebra +adapts the retained source527/PR2160/2159/2234 normal forms. +""" +from words import need + + +class Matrices: + def __init__(self, ring): + self.ring, self.arena = ring, ring.arena + + def zero(self, rows, columns): + need(0 < rows <= 128 and 0 < columns <= 256, "fixed matrix dimensions") + return [[self.arena.zero() for _ in range(columns)] for _ in range(rows)] + + def free(self, matrix): + for row in matrix: + for value in row: + self.arena.free(value) + + def copy(self, matrix): + return [[self.arena.copy(value) for value in row] for row in matrix] + + def identity(self, size): + out = self.zero(size, size) + for i in range(size): + self.arena.free(out[i][i]) + out[i][i] = self.arena.copy(self.ring.one) + return out + + def constants(self, matrix): + """Compile a fixed rational source matrix; inverses use the word machine.""" + palette = {} + for row in matrix: + for constant in row: + if constant in palette: + continue + numerator = self.ring.literal(constant.numerator) + denominator = self.ring.literal(constant.denominator) + inv = self.ring.inverse(denominator) + need(inv is not None, "source denominator is a unit") + palette[constant] = self.ring.multiply(numerator, inv) + self.arena.free_many(numerator, denominator, inv) + out = [[self.arena.copy(palette[constant]) for constant in row] for row in matrix] + for value in palette.values(): + self.arena.free(value) + return out + + def multiply(self, a, b): + rows, inner, columns = len(a), len(b), len(b[0]) + need(all(len(row) == inner for row in a) and all(len(row) == columns for row in b), + "matrix product shape") + out = self.zero(rows, columns) + for i in range(rows): + for k in range(inner): + if a[i][k].zero(): + continue + for j in range(columns): + if b[k][j].zero(): + continue + product = self.ring.multiply(a[i][k], b[k][j]) + total = self.ring.add(out[i][j], product) + self.arena.free_many(out[i][j], product) + out[i][j] = total + return out + + def inverse(self, matrix): + size = len(matrix) + need(size <= 128 and all(len(row) == size for row in matrix), "fixed square matrix") + identity = self.identity(size) + rows = [[self.arena.copy(value) for value in row] + unit + for row, unit in zip(matrix, identity)] + for j in range(size): + pinv = None + for pivot in range(j, size): + pinv = self.ring.inverse(rows[pivot][j]) + if pinv is not None: + break + need(pinv is not None, "matrix unit pivot") + rows[j], rows[pivot] = rows[pivot], rows[j] + for k in range(2*size): + value = self.ring.multiply(pinv, rows[j][k]) + self.arena.free(rows[j][k]) + rows[j][k] = value + self.arena.free(pinv) + for i in range(size): + if i == j or rows[i][j].zero(): + continue + coefficient = self.arena.copy(rows[i][j]) + for k in range(2*size): + product = self.ring.multiply(coefficient, rows[j][k]) + value = self.ring.subtract(rows[i][k], product) + self.arena.free_many(rows[i][k], product) + rows[i][k] = value + self.arena.free(coefficient) + for i in range(size): + for j in range(size): + need(self.ring.raw.compare(rows[i][j], self.ring.one) == 0 if i == j else rows[i][j].zero(), + "binary matrix inverse endpoint") + self.arena.free(rows[i][j]) + return [row[size:] for row in rows] + + def projector(self, header, rank): + need(0 < rank < len(header), "proper projector rank") + inv = self.inverse(header) + out = self.multiply([row[:rank] for row in header], inv[:rank]) + self.free(inv) + return out + + def good_pivots(self, projector, rank): + rows = self.copy(projector) + size, pivots = len(rows), [] + for k in range(rank): + inv = self.ring.inverse(rows[k][k]) + need(inv is not None, "binary nongeneric good class") + pivots.append(self.arena.copy(rows[k][k])) + for i in range(k+1, size): + if rows[i][k].zero(): + continue + coefficient = self.ring.multiply(rows[i][k], inv) + for j in range(size): + product = self.ring.multiply(coefficient, rows[k][j]) + value = self.ring.subtract(rows[i][j], product) + self.arena.free_many(rows[i][j], product) + rows[i][j] = value + self.arena.free(coefficient) + self.arena.free(inv) + # Rank-r split projectors with these pivots have zero residual block. + for i in range(rank, size): + for j in range(rank, size): + need(rows[i][j].zero(), "binary full-ring Schur block") + self.free(rows) + return pivots + + def residual(self, p): + size = len(p) + need(size <= 64, "selected residual dimension") + out = self.zero(2*size, 2*size) + for i in range(size): + for j in range(size): + if i == j: + complement = self.ring.subtract(self.ring.one, p[i][j]) + else: + complement = self.ring.negate(p[i][j]) + for row, column, value in ( + (i, j, complement), + (2*size-1-i, 2*size-1-j, self.arena.copy(complement)), + (i, 2*size-1-j, self.arena.copy(p[i][j])), + (2*size-1-i, j, self.arena.copy(p[i][j])), + ): + self.arena.free(out[row][column]) + out[row][column] = value + return out + + def fallback(self, projector): + rows = self.residual(projector) + size = len(rows) + permutation = list(range(size)) # Fixed finite row-label control. + for j in range(size): + inv = None + for pivot in range(j, size): + inv = self.ring.inverse(rows[pivot][j]) + if inv is not None: + break + need(inv is not None, "binary fallback unit pivot") + rows[j], rows[pivot] = rows[pivot], rows[j] + permutation[j], permutation[pivot] = permutation[pivot], permutation[j] + for i in range(size): + if i == j or rows[i][j].zero(): + continue + coefficient = self.ring.multiply(rows[i][j], inv) + for k in range(size): + product = self.ring.multiply(coefficient, rows[j][k]) + value = self.ring.subtract(rows[i][k], product) + self.arena.free_many(rows[i][k], product) + rows[i][k] = value + self.arena.free(coefficient) + self.arena.free(inv) + diagonal = [] + for i in range(size): + for j in range(size): + if i == j: + diagonal.append(rows[i][j]) + else: + need(rows[i][j].zero(), "binary fallback diagonal endpoint") + self.arena.free(rows[i][j]) + return diagonal, tuple(permutation) + + def raw_header(self, low, high, q): + """Compile-time low class plus encoded runtime high digits.""" + qword = self.ring.literal(q) + constants = {constant for row in low for constant in row} + palette = {constant: self.ring.literal(constant) for constant in constants} + out = [] + for lo, hi in zip(low, high): + row = [] + for constant, digit in zip(lo, hi): + term = self.ring.multiply(qword, digit) + row.append(self.ring.add(term, palette[constant])) + self.arena.free(term) + out.append(row) + self.arena.free(qword) + for value in palette.values(): + self.arena.free(value) + return out + + def prepare(self, low, high, q, fixed_preparation, rank): + raw = self.raw_header(low, high, q) + basis_chart = self.constants(fixed_preparation) + header = self.multiply(raw, basis_chart) + self.free(raw) + self.free(basis_chart) + p = self.projector(header, rank) + self.free(header) + return p diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/numeric.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/numeric.py new file mode 100644 index 0000000000..6d4ebca839 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/numeric.py @@ -0,0 +1,189 @@ +"""One numeric page for one exact raw prefix; never a packet-wide constant.""" +from controller import Callback, finite_word +from forms import fallback_form, good_form +from matrices import Matrices +from words import Unsigned, need + + +class Geometry: + def __init__(self, plan, index_arena, columns, depth, source_code, parent_identity): + self.plan = plan + self.index, self.raw = index_arena, Unsigned(index_arena) + self.columns = columns + self.depth, self.source_code, self.parent_identity = depth, source_code, parent_identity + self.one, self.two = self.index.literal(1), self.index.literal(2) + self.leaf_cutoff = self.index.literal(64) + need(not columns.zero(), "positive residual columns") + + def plus(self, a, b): + out, carry = self.raw.add(a, b) + need(not carry, "residual address margin") + return out + + def point(self, field, column): + base = self.raw.times_small(self.columns, field) + if field < self.plan.dimension: + result = self.plus(base, column) + else: + last = self.raw.subtract_exact(self.columns, self.one) + reverse = self.raw.subtract_exact(last, column) + result = self.plus(base, reverse) + self.index.free_many(last, reverse) + self.index.free(base) + return result + + def close(self): + self.index.free_many(self.one, self.two, self.leaf_cutoff) + + +class Page(Geometry): + def __init__(self, plan, form, ring, index_arena, columns, weight, + depth, source_code, parent_identity): + super().__init__(plan, index_arena, columns, depth, source_code, parent_identity) + self.form, self.ring, self.weight = form, ring, weight + if plan.good: + need((form.dimension, form.rank) == (plan.dimension, plan.rank), "good plan binding") + else: + signature = tuple((r.kind, r.target, r.source, r.permutation) for r in form.reductions) + need(signature == plan.reductions and form.permutation == plan.permutation + and form.negative_sign == plan.negative_sign, "full/low fallback itinerary binding") + + def bank(self, row, column): + if row >= self.plan.dimension: + return self.ring.arena.copy(self.ring.one) + base = self.raw.times_small(self.columns, row) + position = self.plus(base, column) + result = self.weight(position) + self.index.free_many(base, position) + return result + + def ratio(self, scalar, numerator, denominator): + ring, arena = self.ring, self.ring.arena + inverse = ring.inverse(denominator) + need(inverse is not None, "generated adapter denominator unit") + product = ring.multiply(scalar, numerator) + result = ring.multiply(product, inverse) + arena.free_many(numerator, denominator, inverse, product) + return result + + def coefficient(self, reference, column, reverse=False): + ring, arena, form = self.ring, self.ring.arena, self.form + if reference.kind == "head": + scalar = form.rows[reference.index][2] + elif reference.kind == "tail": + scalar = form.columns[reference.index][2] + elif reference.kind == "cross": + scalar = form.cross[reference.first][reference.second] + else: + need(reference.kind == "shear", "adapter coefficient reference") + reduction = form.reductions[reference.index] + need((reduction.target, reduction.source, reduction.permutation) == + (reference.first, reference.second, reference.permutation), "original shear reference") + scalar = reduction.scalar + if scalar.zero(): + result = arena.zero() + elif reference.kind == "tail": + result = arena.copy(scalar) + else: + if reference.kind == "head": + numerator, denominator = self.bank(reference.first, column), self.bank(reference.second, column) + elif reference.kind == "cross": + numerator, denominator = arena.copy(ring.one), self.bank(reference.second, column) + else: + numerator = self.bank(reference.permutation[reference.first], column) + denominator = self.bank(reference.permutation[reference.second], column) + result = self.ratio(scalar, numerator, denominator) + if (reference.sign < 0) != reverse: + opposite = ring.negate(result) + arena.free(result) + result = opposite + return result + + def child_weight(self, kind, field, reverse, index): + ring, arena = self.ring, self.ring.arena + if kind == "unit": + return arena.copy(ring.one) + if kind == "good": + quotient, remainder = self.raw.divmod(index, self.columns) + k = finite_word(quotient, self.plan.rank) + parent = self.weight(index) + result = ring.multiply(parent, self.form.pivots[k]) + arena.free(parent) + self.index.free_many(quotient, remainder) + return result + need(kind == "pair" and 0 <= field < 2*self.plan.dimension-1, "pair child field") + if self.form.permutation[field] == field: + return arena.copy(self.form.diagonal[field]) + if reverse: + last = self.raw.subtract_exact(self.columns, self.one) + column = self.raw.subtract_exact(last, index) + self.index.free(last) + else: + column = self.index.copy(index) + numerator = self.bank(self.form.permutation[field], column) + denominator = self.bank(field, column) + result = self.ratio(self.form.diagonal[field], numerator, denominator) + self.index.free(column) + return result + + def close(self): + self.form.close(self.ring) + super().close() + + def evaluate(self, request): + if request.kind == "adapter": + return self.coefficient(request.reference, request.coordinate, request.reverse_adapter) + need(request.kind == "child", "symbolic coefficient request") + value = self.child_weight(request.child_kind, request.field, request.reverse, request.coordinate) + if request.negative_inverse: + inverse = self.ring.inverse(value) + need(inverse is not None, "completed leaf weight unit") + result = self.ring.negate(inverse) + self.ring.arena.free_many(value, inverse) + return result + return value + + +def selected_page(plan, ring, index_arena, program, fields, specifications, current_code): + """Caller closes the returned page and incoming frame at the same prefix.""" + incoming = Callback(ring, index_arena, program, fields, specifications, current_code, + allow_fallback=True) + columns, remainder = incoming.raw.divmod(incoming.final_size, incoming.sixty_four) + index_arena.free(remainder) + scope = incoming.plus(incoming.depth, incoming.one_index) + projector = incoming.prepare(incoming.depth, current_code, scope) + index_arena.free(scope) + need(plan.good == specifications[current_code].good, "fixed selected branch") + form = good_form(projector, plan.rank, ring) if plan.good else fallback_form(projector, ring) + Matrices(ring).free(projector) + page = Page(plan, form, ring, index_arena, columns, incoming.weight, + incoming.depth, current_code, program) + return page, incoming + + +def selected_coefficient(plan, ring, index_arena, program, fields, specifications, + current_code, request): + """Closed per-prefix callback for a symbolic trace event, on each pass.""" + need(current_code in specifications and plan.dimension == 64 and + plan.rank == specifications[current_code].template.rank and + plan.good == specifications[current_code].good, "selected trace/source binding") + if request.kind == "child": + from children import coefficient + return coefficient(ring, index_arena, program, fields, specifications, current_code, request) + protected_residues, protected_indices = frozenset(ring.arena.live), frozenset(index_arena.live) + incoming = None + try: + page, incoming = selected_page(plan, ring, index_arena, program, fields, specifications, current_code) + result = page.evaluate(request) + page.close() + index_arena.free(page.columns) + incoming.close() + return result + except ValueError: + if incoming is not None: + incoming.abort() + ring.arena.rollback(protected_residues) + index_arena.rollback(protected_indices) + program.tape.rewind() + fields.tape.rewind() + raise diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/oracle.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/oracle.py new file mode 100644 index 0000000000..244f131466 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/oracle.py @@ -0,0 +1,94 @@ +"""Host arithmetic for fixture construction and expected values only.""" +from math import gcd + +from words import need + + +def eye(n): + return [[int(i == j) for j in range(n)] for i in range(n)] + + +def multiply(a, b, modulus): + out = [[0]*len(b[0]) for _ in a] + for i, row in enumerate(a): + for k, x in enumerate(row): + if x: + for j, y in enumerate(b[k]): + if y: + out[i][j] = (out[i][j]+x*y) % modulus + return out + + +def inverse(a, modulus): + n = len(a) + rows = [list(row)+unit for row, unit in zip(a, eye(n))] + for j in range(n): + k = next((i for i in range(j, n) if gcd(rows[i][j], modulus) == 1), None) + need(k is not None, "oracle unit pivot") + rows[j], rows[k] = rows[k], rows[j] + inv = pow(rows[j][j], -1, modulus) + rows[j] = [x*inv % modulus for x in rows[j]] + for i in range(n): + if i != j and rows[i][j]: + c = rows[i][j] + rows[i] = [(x-c*y) % modulus for x, y in zip(rows[i], rows[j])] + return [row[n:] for row in rows] + + +def reduce_rational(a, modulus): + return [[x.numerator*pow(x.denominator, -1, modulus) % modulus for x in row] for row in a] + + +def fixture(template, width, high=1, bad=False, unit_low=False, row=None): + q, modulus = template.q, template.q**width + row = template.rank if row is None else row + h = eye(64) + if bad: + h[0][0], h[0][row], h[row][0], h[row][row] = q, q-1, 1, 1+q*high + elif unit_low: + h[0][0], h[0][row], h[row][0], h[row][row] = 1+q*high, 1, 1, 2 + else: + h[0][row], h[row][0], h[row][row] = 1, q*high, 1+q*high + raw = multiply(h, inverse(reduce_rational(template.preparation, modulus), modulus), modulus) + low = tuple(tuple(x % q for x in row) for row in raw) + digits = tuple(tuple(x//q for x in row) for row in raw) + return low, digits + + +def projector(template, low, high, width): + q, modulus = template.q, template.q**width + raw = [[a+q*b for a, b in zip(lo, hi)] for lo, hi in zip(low, high)] + common = multiply(raw, reduce_rational(template.chart, modulus), modulus) + return multiply(multiply(common, reduce_rational(template.base, modulus), modulus), + inverse(common, modulus), modulus) + + +def good_pivots(p, rank, modulus): + rows, pivots = [list(row) for row in p], [] + for k in range(rank): + inv = pow(rows[k][k], -1, modulus) + pivots.append(rows[k][k]) + for i in range(k+1, len(rows)): + coefficient = rows[i][k]*inv % modulus + rows[i] = [(x-coefficient*y) % modulus for x, y in zip(rows[i], rows[k])] + return pivots + + +def fallback(p, modulus): + n = len(p) + rows = [[0]*(2*n) for _ in range(2*n)] + for i in range(n): + for j in range(n): + rows[i][j] = rows[2*n-1-i][2*n-1-j] = (int(i == j)-p[i][j]) % modulus + rows[i][2*n-1-j] = rows[2*n-1-i][j] = p[i][j] + permutation = list(range(2*n)) + for j in range(2*n): + pivot = next(i for i in range(j, 2*n) if gcd(rows[i][j], modulus) == 1) + rows[j], rows[pivot] = rows[pivot], rows[j] + permutation[j], permutation[pivot] = permutation[pivot], permutation[j] + inv = pow(rows[j][j], -1, modulus) + for i in range(2*n): + if i != j and rows[i][j]: + coefficient = rows[i][j]*inv % modulus + rows[i] = [(x-coefficient*y) % modulus for x, y in zip(rows[i], rows[j])] + return [rows[i][i] for i in range(2*n)], tuple(permutation) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/packet.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/packet.py new file mode 100644 index 0000000000..ebc9b61651 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/packet.py @@ -0,0 +1,97 @@ +"""One shared trace across a sequential directory of complete raw prefixes. + +Each primitive traverses the whole packet before the next trace event. Child +entry/return occur once for the packet, never once per sampled high header. +""" +from bitstream import copy_bits +from cardinality import Natural, multiply_atom_power +from records import RECORD_END, Tape +from stream import Counter, positive_extent +from stream_runner import Layout, action +from trace import execute +from words import BLANK, need + + +def read_prefix(directory, field_count): + out, remaining = Tape(), Counter(field_count) + while not remaining.finished: + while directory.read() != RECORD_END: + symbol = directory.read() + need(symbol != BLANK, "complete raw-prefix directory") + out.append(symbol) + directory.step(1) + out.append(RECORD_END) + directory.step(1) + remaining.decrement() + remaining.close() + out.rewind() + return out + + +def copy_prefix(source, output, before, body): + count = Counter(before) + while not count.finished: + copy_bits(source, output, body) + count.decrement() + count.close() + + +def run(source, geometry, parent_size, ring, q, before, suffix, prefix_count, + field_count, directory, coefficient, payload_factory=Tape, boundary_observer=None): + positive_extent(prefix_count) + expected_fields = geometry.plus(geometry.depth, geometry.one) + matches = geometry.raw.compare(field_count, expected_fields) == 0 + geometry.index.free(expected_fields) + need(matches, "original frozen/current field count") + layout = Layout(geometry, parent_size, ring, q, before, suffix) + body = Natural(suffix) + multiply_atom_power(body, layout.total, ring, q) + current, active = source, None + try: + for event in execute(geometry): + if event.kind == "enter": + need(active is None and event.parent_identity is geometry.parent_identity, + "one whole-packet child invocation") + active = event + if boundary_observer is not None: + boundary_observer(event.kind) + continue + if event.kind == "return": + need(active is not None and active.parent_identity is event.parent_identity and + (active.child_kind, active.field, active.reverse, active.half, active.source_code) == + (event.child_kind, event.field, event.reverse, event.half, event.source_code), + "whole-packet symbolic return") + for a, b in ((active.first, event.first), (active.second, event.second), + (active.width, event.width), (active.depth, event.depth)): + need(geometry.raw.compare(a, b) == 0, "whole-packet encoded child return") + active = None + if boundary_observer is not None: + boundary_observer(event.kind) + continue + output, prefixes = payload_factory(), Counter(prefix_count) + directory.rewind() + while not prefixes.finished: + fields = read_prefix(directory, field_count) + local = payload_factory() + copy_prefix(current, local, before, body) + local.rewind() + changed = action(local, event, layout, lambda request: coefficient(fields, request), payload_factory) + copy_prefix(changed, output, before, body) + need(changed.read() == BLANK, "complete returned prefix fibre") + changed.clear() + local.clear() + fields.clear() + prefixes.decrement() + prefixes.close() + need(current.read() == directory.read() == BLANK, "complete shared high packet") + current.rewind() + directory.rewind() + if current is not source: + current.clear() + output.rewind() + current = output + need(active is None, "whole-packet child return") + return current + finally: + layout.close() + body.close() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/plan.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/plan.py new file mode 100644 index 0000000000..48255d5454 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/plan.py @@ -0,0 +1,112 @@ +"""Compile fixed-low symbolic itineraries, without width or high fields.""" +from dataclasses import dataclass +from math import prod + +from words import need + + +@dataclass(frozen=True) +class Reference: + kind: str + index: int = 0 + first: int = 0 + second: int = 0 + permutation: tuple = () + sign: int = 1 + + +@dataclass(frozen=True) +class Command: + kind: str + target: int + source: int + reference: Reference + + +@dataclass +class Request: + kind: str + coordinate: object + reference: object = None + reverse_adapter: bool = False + child_kind: str = "" + field: int = 0 + reverse: bool = False + negative_inverse: bool = False + half: bool = False + + +@dataclass(frozen=True) +class Plan: + dimension: int + rank: int + good: bool + commands: tuple + reductions: tuple = () + permutation: tuple = () + negative_sign: bool = False + + +def compile_plan(low_projector, rank, q, good): + """Host arithmetic here depends only on the fixed prime/low vocabulary.""" + m = len(low_projector) + need(1 <= rank < m <= 64, "compiled residual dimension") + if good: + commands = [] + index = 0 + for k in range(rank): + for i in range(k+1, m): + commands.append(Command("add", i, k, Reference("head", index, i, k))) + index += 1 + index = 0 + for k in range(rank): + column = m-1-k + for source in range(column): + commands.append(Command("add", m+column, m+source, + Reference("tail", index, sign=-1))) + index += 1 + for i in range(m): + for k in range(m): + commands.append(Command("add", m+i, k, Reference("cross", i*m+k, i, k))) + return Plan(m, rank, True, tuple(commands)) + size = 2*m + rows = [[0]*size for _ in range(size)] + for i in range(m): + for j in range(m): + rows[i][j] = rows[size-1-i][size-1-j] = (int(i == j)-low_projector[i][j]) % q + rows[i][size-1-j] = rows[size-1-i][j] = low_projector[i][j] % q + permutation, reductions = list(range(size)), [] + for j in range(size): + pivot = next(i for i in range(j, size) if rows[i][j] % q) + if pivot != j: + reductions.append(("swap", j, pivot, tuple(permutation))) + rows[j], rows[pivot] = rows[pivot], rows[j] + permutation[j], permutation[pivot] = permutation[pivot], permutation[j] + inverse = pow(rows[j][j], -1, q) + for i in range(size): + if i != j: + coefficient = -rows[i][j]*inverse % q + reductions.append(("shear", i, j, tuple(permutation))) + rows[i] = [(x+coefficient*y) % q for x, y in zip(rows[i], rows[j])] + sign = prod(rows[i][i] for i in range(size)) % q + need(sign in (1, q-1), "compiled terminal sign") + commands = [] + unit = Reference("unit") + for i in range(size-1): + commands.append(Command("child", i, size-1, unit)) + commands.append(Command("child", i, size-1, Reference("pair", i, i, size-1, + tuple(permutation)))) + if sign != 1: + commands.append(Command("sign", size-1, -1, Reference("fixed", sign=-1))) + for index in range(len(reductions)-1, -1, -1): + kind, i, k, snapshot = reductions[index] + if kind == "swap": + commands.append(Command("child", i, k, unit)) + else: + reference = Reference("shear", index, i, k, snapshot, -1) + if i > k: + commands.append(Command("add", i, k, reference)) + else: + commands.extend((Command("child", i, k, unit), Command("add", k, i, reference), + Command("child", i, k, unit))) + return Plan(m, rank, False, tuple(commands), tuple(reductions), tuple(permutation), sign != 1) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/records.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/records.py new file mode 100644 index 0000000000..4f00467a0f --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/records.py @@ -0,0 +1,271 @@ +"""Sequential binary program/field records and typed continuation stacks. + +Runtime numerical words copy between tapes. Only tags, source codes, ranks +and row labels enter fixed finite control. Fixture encoding is separate. +""" +from words import BLANK, LEFT, ONE, RIGHT, ZERO, Meter, Unsigned, need + +WORD_END, RECORD_END = 5, 6 +ROOT, STEP, VALUE, CONSTANT, MULTIPLY, PAIR, RETURN = range(7, 14) +FINITE_BITS = 16 # Fixed vocabulary width for this compiled source instance. + + +class Tape: + def __init__(self): + self.cells = bytearray([LEFT]) + self.head = 1 + self.meter = Meter() + + def read(self): + self.meter.reads += 1 + return self.cells[self.head] if self.head < len(self.cells) else BLANK + + def write(self, symbol): + need(ZERO <= symbol <= RETURN, "fixed record alphabet") + self.meter.writes += 1 + if self.head >= len(self.cells): + self.cells.extend([BLANK]*(self.head+1-len(self.cells))) + self.cells[self.head] = symbol + + def step(self, direction): + need(direction in (-1, 1), "unit record-head move") + self.head += direction + need(self.head >= 0, "local record boundary") + self.meter.moves += 1 + + def append(self, symbol): + need(self.read() == BLANK, "append at record blank") + self.write(symbol) + self.step(1) + + def rewind(self): + self.step(-1) + while self.read() != LEFT: + self.step(-1) + self.step(1) + + def clear(self): + self.rewind() + while self.read() != BLANK: + self.write(BLANK) + self.step(1) + self.rewind() + + +def append_word(tape, word): + word.rewind() + while word.read() != RIGHT: + tape.append(word.read()) + word.step(1) + tape.append(WORD_END) + word.rewind() + + +def read_word(tape, arena): + out = arena.zero() + while tape.read() != WORD_END: + bit = tape.read() + need(bit in (ZERO, ONE) and out.read() != RIGHT, "encoded word extent") + out.write(bit) + out.step(1) + tape.step(1) + need(out.read() == RIGHT, "complete encoded word") + tape.step(1) + out.rewind() + return out + + +def append_finite(tape, value, bits=FINITE_BITS): + """Compile-time finite source/operation tag encoding.""" + need(0 <= value < 1 << bits, "compiled finite vocabulary") + for bit in range(bits): + tape.append((value >> bit) & 1) + tape.append(WORD_END) + + +def read_finite(tape, bits=FINITE_BITS): + # The accumulator ranges over a fixed finite set, independent of e/w/h. + state = 0 + for bit in range(bits): + value = tape.read() + need(value in (ZERO, ONE), "finite label bit") + state |= value << bit + tape.step(1) + need(tape.read() == WORD_END, "finite label delimiter") + tape.step(1) + return state + + +def seek_record(tape, index): + machine, arena = Unsigned(index.arena), index.arena + remaining, one = arena.copy(index), arena.literal(1) + tape.rewind() + while not remaining.zero(): + while tape.read() != RECORD_END: + need(tape.read() != BLANK, "record exists at global slot") + tape.step(1) + tape.step(1) + after = machine.subtract_exact(remaining, one) + arena.free(remaining) + remaining = after + arena.free_many(remaining, one) + + +class Stack: + def __init__(self, index_arena, residue_arena): + self.index_arena, self.residue_arena = index_arena, residue_arena + self.tape, self.reverse = Tape(), Tape() + + def empty(self): + self.tape.step(-1) + result = self.tape.read() == LEFT + self.tape.step(1) + return result + + def push(self, tag, *words): + need(tag in (VALUE, CONSTANT, MULTIPLY, PAIR, RETURN), "continuation kind") + need(len(words) == (2 if tag == VALUE else 1), "continuation arity") + self.tape.append(tag) + for word in words: + append_word(self.tape, word) + self.tape.append(RECORD_END) + + def pop(self): + need(not self.empty(), "nonempty continuation stack") + tape, reverse = self.tape, self.reverse + tape.step(-1) + need(tape.read() == RECORD_END, "continuation top delimiter") + tape.write(BLANK) + tape.step(-1) + while tape.read() not in (LEFT, RECORD_END): + reverse.append(tape.read()) + tape.write(BLANK) + tape.step(-1) + tape.step(1) + reverse.step(-1) + tag = reverse.read() + need(tag in (VALUE, CONSTANT, MULTIPLY, PAIR, RETURN), "encoded continuation kind") + reverse.write(BLANK) + reverse.step(-1) + arenas = (self.index_arena, self.index_arena) if tag == VALUE else (self.residue_arena,) + words = [] + for arena in arenas: + out = arena.zero() + while reverse.read() != WORD_END: + bit = reverse.read() + need(bit in (ZERO, ONE) and out.read() != RIGHT, "continuation binary word") + out.write(bit) + out.step(1) + reverse.write(BLANK) + reverse.step(-1) + need(out.read() == RIGHT, "complete continuation operand") + reverse.write(BLANK) + reverse.step(-1) + out.rewind() + words.append(out) + need(reverse.read() == LEFT, "complete continuation record") + reverse.step(1) + return tag, tuple(words) + + +class Program: + """Encoded root and admitted chronological steps; numerical fields are words.""" + def __init__(self, index_arena, residue_arena, code_bits=FINITE_BITS): + self.index_arena, self.residue_arena = index_arena, residue_arena + self.code_bits = code_bits + self.tape = Tape() + + def root(self): + self.tape.rewind() + need(self.tape.read() == ROOT, "root record") + self.tape.step(1) + size = read_word(self.tape, self.index_arena) + unit = read_word(self.tape, self.residue_arena) + depth = read_word(self.tape, self.index_arena) + need(self.tape.read() == RECORD_END, "root record end") + self.tape.rewind() + return size, unit, depth + + def step(self, level): + need(not level.zero(), "positive step level") + seek_record(self.tape, level) + need(self.tape.read() == STEP, "step record") + self.tape.step(1) + metadata = tuple(read_finite(self.tape, self.code_bits if field == 1 else FINITE_BITS) + for field in range(6)) + parent = read_word(self.tape, self.index_arena) + child = read_word(self.tape, self.index_arena) + need(self.tape.read() == RECORD_END, "step record end") + self.tape.rewind() + return metadata, parent, child + + @classmethod + def fixture(cls, index_arena, residue_arena, root_size, root_unit, events, code_bits=FINITE_BITS): + """Fixture-only serialization; runtime computes and validates extents.""" + out = cls(index_arena, residue_arena, code_bits) + out.tape.append(ROOT) + for arena, value in ((index_arena, root_size), (residue_arena, root_unit), (index_arena, len(events))): + word = arena.input(value) + append_word(out.tape, word) + arena.free(word) + out.tape.append(RECORD_END) + size = root_size + for kind, code, rank, field, reverse, half in events: + f = size//64 + child = rank*f if kind == 0 else f//2 if half else f + out.tape.append(STEP) + for field_index, label in enumerate((kind, code, rank, field, int(reverse), int(half))): + append_finite(out.tape, label, code_bits if field_index == 1 else FINITE_BITS) + for value in (size, child): + word = index_arena.input(value) + append_word(out.tape, word) + index_arena.free(word) + out.tape.append(RECORD_END) + size = child + out.tape.rewind() + return out + + +class Fields: + def __init__(self, index_arena, residue_arena, code_bits=FINITE_BITS): + self.index_arena, self.residue_arena = index_arena, residue_arena + self.code_bits = code_bits + self.tape = Tape() + + def check_code(self, slot, code): + seek_record(self.tape, slot) + observed = read_finite(self.tape, self.code_bits) + self.tape.rewind() + need(observed == code, "original global raw-field code") + + def end(self, after): + seek_record(self.tape, after) + complete = self.tape.read() == BLANK + self.tape.rewind() + need(complete, "exact frozen/current field prefix") + + def read(self, slot, code, depth): + need(Unsigned(self.index_arena).compare(slot, depth) < 0, "frozen field excludes current/future slot") + seek_record(self.tape, slot) + observed = read_finite(self.tape, self.code_bits) + need(observed == code, "exact encoded raw-field specification") + out = [[read_word(self.tape, self.residue_arena) for _ in range(64)] for _ in range(64)] + need(self.tape.read() == RECORD_END, "complete 64-dimensional raw high field") + self.tape.rewind() + return out + + @classmethod + def fixture(cls, index_arena, residue_arena, fields, code_bits=FINITE_BITS): + """Load canonical raw-field fixture data before measured execution.""" + out = cls(index_arena, residue_arena, code_bits) + for code, high in fields: + append_finite(out.tape, code, code_bits) + need(len(high) == 64 and all(len(row) == 64 for row in high), "field fixture shape") + for row in high: + for value in row: + word = residue_arena.input(value) + append_word(out.tape, word) + residue_arena.free(word) + out.tape.append(RECORD_END) + out.tape.rewind() + return out diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/residual.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/residual.py new file mode 100644 index 0000000000..3d070d2539 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/residual.py @@ -0,0 +1,93 @@ +"""Concrete selected residual consumer for newly produced common directories.""" +from controller import Callback +from numeric import Geometry, selected_coefficient +import packet +from plan import compile_plan +from records import Fields, Tape +from words import Unsigned, need + + +class SelectedResidual: + def __init__(self, context, indices, program, specifications, code, parent_size, depth, + before, suffix): + # Only fixed source/low data enters this compilation step. + import oracle + spec = specifications[code] + _request, common, low = context.codes.decode(code) + need(context.dimension == 64 and common and low == spec.low and + spec.template.chart == tuple(map(tuple, oracle.eye(64))) and + program.code_bits == context.codes.bits, "selected common-view residual consumer") + q = context.q + prepared = oracle.multiply(low,oracle.reduce_rational(spec.template.preparation,q),q) + projector = oracle.multiply([row[:spec.template.rank] for row in prepared], + oracle.inverse(prepared,q)[:spec.template.rank],q) + self.plan = compile_plan(projector,spec.template.rank,q,spec.good) + self.context,self.indices,self.program = context,indices,program + self.specifications,self.code = specifications,code + self.parent_size,self.depth,self.before,self.suffix = parent_size,depth,before,suffix + + def __call__(self, source, directory, prefix_count): + context, indices = self.context,self.indices + raw = Unsigned(indices) + divisor,one = indices.literal(64),indices.literal(1) + columns,remainder = raw.divmod(self.parent_size,divisor) + indices.free_many(divisor,remainder) + field_count,carry = raw.add(self.depth,one) + indices.free(one) + need(not carry, "current source field extent") + geometry = Geometry(self.plan,indices,columns,self.depth,self.code,self.program) + padded_count = prefix_count.marginal() + try: + directory.rewind() + first = packet.read_prefix(directory,field_count) + directory.rewind() + fields = Fields(indices,context.arena,context.codes.bits) + fields.tape = first + frame = Callback(context.ring,indices,self.program,fields,self.specifications,self.code, + allow_fallback=True) + valid = raw.compare(frame.final_size,self.parent_size) == 0 and raw.compare(frame.depth,self.depth) == 0 + frame.close() + first.clear() + need(valid, "shared trace agrees with the encoded parent frame") + def coefficient(prefix, request): + current = Fields(indices,context.arena,context.codes.bits) + current.tape = prefix + return selected_coefficient(self.plan,context.ring,indices,self.program,current, + self.specifications,self.code,request) + return packet.run(source,geometry,self.parent_size,context.ring,context.q, + self.before,self.suffix,padded_count,field_count,directory,coefficient) + finally: + geometry.close() + indices.free_many(columns,field_count) + padded_count.close() + directory.rewind() + + +class SelectedCopy511: + """Bind the authenticated physical interval to its concrete selected callee.""" + def __init__(self, context, indices, program, specifications, common_low, + parent_size, depth, before, suffix): + import oracle + from binding import selected_episode + from routes import compile_route, inverse_rational + from sources import compile_specification + self.episode = selected_episode(context.q) + inverse = oracle.reduce_rational(inverse_rational(self.episode.chart),context.q) + native_low = oracle.multiply(common_low,inverse,context.q) + self.route = compile_route(native_low,self.episode.chart,context.codes) + self.code = context.codes.encode(self.episode.request,True,common_low) + spec = compile_specification(self.code,self.episode.template,common_low) + need(self.code not in specifications or specifications[self.code] == spec, + "one frozen/current source-code interpretation") + vocabulary = dict(specifications) + vocabulary[self.code] = spec + self.residual = SelectedResidual(context,indices,program,vocabulary,self.code, + parent_size,depth,before,suffix) + self.context,self.indices,self.depth = context,indices,depth + + def __call__(self, families, old_directory, old_fields, old_count, fibre): + from episode import physical + need(Unsigned(self.indices).compare(old_fields,self.depth) == 0, + "physical old fields agree with the generated parent depth") + return physical(families,self.episode,self.route,self.code,self.context,old_directory, + old_fields,old_count,fibre,self.residual) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/routes.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/routes.py new file mode 100644 index 0000000000..35531201dc --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/routes.py @@ -0,0 +1,249 @@ +"""Owner/common high-cube routes by binary keys and sequential stable passes.""" +from dataclasses import dataclass +from fractions import Fraction + +from bitstream import copy_bits +from counts import Count +from directory import Odometer, append_tape +from matrices import Matrices +from records import WORD_END, Tape, append_word, read_word +from stream import Counter +from words import BLANK, ONE, RIGHT, ZERO, need + + +@dataclass(frozen=True) +class Route: + q: int + dimension: int + low: tuple + target_low: tuple + chart: tuple + + +def compile_route(low, chart, vocabulary): + """Compile fixed labels only; no input modulus or high digit is available.""" + import oracle + q, dimension = vocabulary.q, vocabulary.dimension + vocabulary.rank(low) + need(len(chart) == dimension and all(len(row) == dimension for row in chart), "fixed chart shape") + chart = tuple(tuple(Fraction(x) for x in row) for row in chart) + reduced = oracle.reduce_rational(chart, q) + oracle.inverse(reduced, q) + target = tuple(map(tuple, oracle.multiply(low, reduced, q))) + vocabulary.rank(target) + return Route(q, dimension, tuple(map(tuple, low)), target, chart) + + +def inverse_rational(matrix): + """Fixed source compilation; fractions never enter measured payload loops.""" + size = len(matrix) + rows = [[Fraction(x) for x in row]+[Fraction(i == j) for j in range(size)] + for i, row in enumerate(matrix)] + for column in range(size): + pivot = next((i for i in range(column, size) if rows[i][column]), None) + need(pivot is not None, "invertible fixed rational chart") + rows[column], rows[pivot] = rows[pivot], rows[column] + scale = rows[column][column] + rows[column] = [x/scale for x in rows[column]] + for i in range(size): + if i != column: + factor = rows[i][column] + rows[i] = [x-factor*y for x, y in zip(rows[i], rows[column])] + return tuple(tuple(row[size:]) for row in rows) + + +def high_key(high, route, chart, context): + matrices, arena = Matrices(context.ring), context.arena + raw = matrices.raw_header(route.low, high, context.q) + common = matrices.multiply(raw, chart) + matrices.free(raw) + divisor = arena.literal(context.q) + keys = [] + try: + for i in range(context.dimension): + row = [] + keys.append(row) + for j in range(context.dimension): + low = arena.literal(route.target_low[i][j]) + difference = context.raw.subtract_exact(common[i][j], low) + quotient, remainder = context.raw.divmod(difference, divisor) + arena.free_many(low, difference) + valid = remainder.zero() and context.raw.compare(quotient, context.cap) < 0 + arena.free(remainder) + row.append(quotient) + need(valid, "exact routed low class and high carry") + return keys + except ValueError: + matrices.free(keys) + raise + finally: + matrices.free(common) + arena.free(divisor) + + +def copy_key(source, output, context, selected=None, cursor=None): + bit = ZERO + template = context.arena.template + for coordinate in range(context.dimension*context.dimension): + template.rewind() + if coordinate == selected: + cursor.rewind() + while template.read() != RIGHT: + value = source.read() + need(value in (ZERO, ONE), "complete binary route key") + if coordinate == selected: + if cursor.read() == ONE: + bit = value + cursor.step(1) + output.append(value) + source.step(1) + template.step(1) + need(source.read() == WORD_END, "route key word extent") + output.append(WORD_END) + source.step(1) + template.rewind() + if coordinate == selected: + cursor.rewind() + return bit + + +def copy_rows(source, output, count, fibre): + remaining = Counter(count) + try: + while not remaining.finished: + copy_bits(source, output, fibre) + remaining.decrement() + finally: + remaining.close() + + +def partition(source, coordinate, cursor, context, fibre, factory): + buckets = (factory(), factory()) + counts = (Count.literal(0), Count.literal(0)) + records = Counter(context.highs) + output = factory() + try: + while not records.finished: + key = Tape() + try: + bit = copy_key(source, key, context, coordinate, cursor) + append_tape(key, buckets[bit]) + copy_bits(source, buckets[bit], fibre) + counts[bit].increment() + finally: + key.clear() + records.decrement() + need(source.read() == BLANK, "complete route partition") + source.rewind() + for bucket, count in zip(buckets, counts): + bucket.rewind() + remaining = Counter(count) + while not remaining.finished: + copy_key(bucket, output, context) + copy_bits(bucket, output, fibre) + remaining.decrement() + remaining.close() + need(bucket.read() == BLANK, "complete stable route bucket") + output.rewind() + return output + except ValueError: + output.clear() + raise + finally: + records.close() + for bucket, count in zip(buckets, counts): + bucket.clear() + count.close() + + +def route_cube(source, route, context, fibre, factory=Tape): + need((route.q, route.dimension) == (context.q, context.dimension), "route/context binding") + matrices, arena = Matrices(context.ring), context.arena + chart = matrices.constants(route.chart) + high, decorated = Odometer(context), factory() + source.rewind() + current, output = decorated, None + try: + while not high.finished: + key = high_key(high.digits, route, chart, context) + for row in key: + for digit in row: + append_word(decorated, digit) + matrices.free(key) + copy_bits(source, decorated, fibre) + high.advance() + need(source.read() == BLANK, "complete source high cube") + source.rewind() + decorated.rewind() + if context.raw.compare(context.cap, context.ring.one) > 0: + for coordinate in reversed(range(context.dimension*context.dimension)): + cursor = arena.copy(context.ring.one) + try: + while True: + following = partition(current, coordinate, cursor, context, fibre, factory) + current.clear() + current = following + cursor.msb() + final = cursor.read() == ONE + cursor.rewind() + if final: + break + shifted = context.raw.shift_add_bit(cursor, ZERO) + arena.free(cursor) + cursor = shifted + finally: + arena.free(cursor) + high.close() + high = Odometer(context) + output = factory() + while not high.finished: + for row in high.digits: + for expected in row: + actual = read_word(current, arena) + valid = context.raw.compare(actual, expected) == 0 + arena.free(actual) + need(valid, "complete bijective routed high order") + copy_bits(current, output, fibre) + high.advance() + need(current.read() == BLANK, "complete routed key removal") + output.rewind() + return output + except ValueError: + if output is not None: + output.clear() + raise + finally: + current.clear() + high.close() + matrices.free(chart) + source.rewind() + + +def route_packet(source, route, context, old_count, fibre, factory=Tape): + outer, output = Counter(old_count), factory() + source.rewind() + try: + need(not outer.finished, "positive route prefix count") + while not outer.finished: + local = factory() + try: + copy_rows(source, local, context.highs, fibre) + local.rewind() + changed = route_cube(local, route, context, fibre, factory) + try: + copy_rows(changed, output, context.highs, fibre) + need(changed.read() == BLANK, "closed routed prefix") + finally: + changed.clear() + finally: + local.clear() + outer.decrement() + need(source.read() == BLANK, "complete old-prefix route") + output.rewind() + return output + except ValueError: + output.clear() + raise + finally: + outer.close() + source.rewind() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/selection.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/selection.py new file mode 100644 index 0000000000..2c28f1aaec --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/selection.py @@ -0,0 +1,71 @@ +"""Gather/scatter one low class at its original positions in a complete family.""" +from bitstream import copy_bits +from counts import Count, high_power +from records import Tape +from routes import copy_rows +from stream import Counter +from words import BLANK, ONE, ZERO, need + + +def discard_rows(source, count, fibre): + rows = Counter(count) + try: + while not rows.finished: + bits = Counter(fibre) + while not bits.finished: + need(source.read() in (ZERO, ONE), "complete skipped payload") + source.step(1) + bits.decrement() + bits.close() + rows.decrement() + finally: + rows.close() + + +def packet_operation(source, context, old_count, low, fibre, replacement=None, factory=Tape): + # The ordinal and vocabulary cardinality belong to fixed-q compilation. + ordinal = context.codes.rank(low) + before = Count.literal(ordinal) + after = Count.literal(context.codes.size-ordinal-1) + high_power(before, context.ring, context.q, context.dimension) + high_power(after, context.ring, context.q, context.dimension) + outer, output = Counter(old_count), factory() + source.rewind() + if replacement is not None: + replacement.rewind() + try: + need(not outer.finished, "positive physical old-prefix count") + while not outer.finished: + if replacement is None: + discard_rows(source, before, fibre) + copy_rows(source, output, context.highs, fibre) + discard_rows(source, after, fibre) + else: + copy_rows(source, output, before, fibre) + discard_rows(source, context.highs, fibre) + copy_rows(replacement, output, context.highs, fibre) + copy_rows(source, output, after, fibre) + outer.decrement() + need(source.read() == BLANK, "complete selected family") + if replacement is not None: + need(replacement.read() == BLANK, "complete packet replacement") + output.rewind() + return output + except ValueError: + output.clear() + raise + finally: + before.close() + after.close() + outer.close() + source.rewind() + if replacement is not None: + replacement.rewind() + + +def gather(source, context, old_count, low, fibre, factory=Tape): + return packet_operation(source, context, old_count, low, fibre, factory=factory) + + +def scatter(source, replacement, context, old_count, low, fibre, factory=Tape): + return packet_operation(source, context, old_count, low, fibre, replacement, factory) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/sources.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/sources.py new file mode 100644 index 0000000000..16d5e7e6a2 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/sources.py @@ -0,0 +1,148 @@ +"""Compile fixed selected rational labels and low classes. + +This stage depends on q and the fixed selected catalogue, never on the input +width or high digits. Runtime inverses and coefficients come from words.py. +The selection/chart conventions adapt PR2234 and PR2405 with attribution. +""" +from dataclasses import dataclass +from fractions import Fraction as F +from hashlib import sha256 +import importlib.util +import json +from pathlib import Path + +from words import need + + +ROOT = Path(__file__).resolve().parents[3] + + +def identity(n): + return [[F(i == j) for j in range(n)] for i in range(n)] + + +def product(a, b): + out = [[F(0) for _ in b[0]] for _ in a] + for i, row in enumerate(a): + for k, x in enumerate(row): + if x: + for j, y in enumerate(b[k]): + if y: + out[i][j] += x*y + return out + + +def independent_columns(matrix, q): + # q is fixed when compiling the finite source vocabulary. + rows = [[x.numerator*pow(x.denominator, -1, q) % q for x in row] for row in matrix] + rank, chosen = 0, [] + for j in range(len(matrix[0])): + pivot = next((i for i in range(rank, len(rows)) if rows[i][j]), None) + if pivot is None: + continue + rows[rank], rows[pivot] = rows[pivot], rows[rank] + inv = pow(rows[rank][j], -1, q) + rows[rank] = [x*inv % q for x in rows[rank]] + for i in range(len(rows)): + if i != rank and rows[i][j]: + c = rows[i][j] + rows[i] = [(x-c*y) % q for x, y in zip(rows[i], rows[rank])] + chosen.append(j) + rank += 1 + if rank == len(rows): + break + return chosen + + +@dataclass(frozen=True) +class Template: + q: int + rank: int + record: tuple + base: tuple + chart: tuple + preparation: tuple + + +@dataclass(frozen=True) +class Specification: + code: int + template: Template + low: tuple + good: bool + + +def compile_specification(code, template, low): + """Compile the finite low-class branch, with no width/high input.""" + import oracle + q = template.q + need(len(low) == 64 and all(len(row) == 64 and all(0 <= x < q for x in row) for row in low), + "fixed raw low class") + h = oracle.multiply(low, oracle.reduce_rational(template.preparation, q), q) + inv = oracle.inverse(h, q) + p = oracle.multiply([row[:template.rank] for row in h], inv[:template.rank], q) + try: + oracle.good_pivots(p, template.rank, q) + good = True + except ValueError: + good = False + return Specification(code, template, tuple(map(tuple, low)), good) + + +def compile_templates(q=3): + path = ROOT / "research/pr589-five-helper-hosting/verify.py" + spec = importlib.util.spec_from_file_location("retained_binary_control_source", path) + old = importlib.util.module_from_spec(spec) + spec.loader.exec_module(old) + word, host, geometry = (old.read(p) for p in (old.WORD, old.HOST, old.GEO)) + call = host["calls"][0] + program = host["local_programs"][call["orientation"]] + idles = {event["idx"]: event for event in host["schedule"] if event["kind"] == "idle"} + templates = [] + for position, op, role, key in ( + (21816, 2, 472, "c097fc120eea0e30ceaae6f2f6bad489ec86945dfecb852fb50c2d46d64185cd"), + (18085, 0, 222, "5a7dce9c52ac8c9c23fa89766439abfc412b5242b444945289a83828ffa9ae6d"), + ): + event = program[position] + need(event[:2] == [op, role], "exact selected literal") + a, b, rank = event[3:6] if op == 2 else event[2:5] + pa, ra = old.projection([word["lines"][i] for i in word["frames"][a]]) + pb, rb = old.projection([word["lines"][i] for i in word["frames"][b]]) + lo, hi = (pa, pb) if ra <= rb else (pb, pa) + local = old.sub(hi, lo) + observed = sha256(json.dumps(["local", rank, [[str(x) for x in row] for row in local]], + sort_keys=True, separators=(",", ":")).encode()).hexdigest() + need(observed == key and abs(ra-rb) == rank, "selected projector identity") + base = [[F(0) for _ in range(64)] for _ in range(64)] + for i in range(8): + base[i][:8] = local[i] + family, route = call["owners"][role] + need(route[0] == "hosted", "selected hosted source") + _, child, offset, width = route + axes = old.pending_axes(idles[child])[offset:offset+width] + port = family % 111 if min(axes) < 8 else -1 + chart = identity(64) + if op != 2: + if port >= 0: + entry = geometry["ports"][port] + for i in range(8): + chart[i][:8] = [F(entry["q"][i], 2)] + list(map(F, entry["complement_columns"][i])) + pi = list(range(64)) + for i, j in zip(sorted(set(range(8))-set(axes)), sorted(set(axes)-set(range(8)))): + pi[i], pi[j] = j, i + chart = [[row[pi[j]] for j in range(64)] for row in chart] + complement = [[F(i == j)-base[i][j] for j in range(64)] for i in range(64)] + image, kernel = independent_columns(base, q), independent_columns(complement, q) + need((len(image), len(kernel)) == (rank, 64-rank), "fixed low-field split basis") + basis = [[base[i][j] for j in image] + [complement[i][j] for j in kernel] for i in range(64)] + # PB=BE over the rationals, before any input-width modulus exists. + projected_basis = [[basis[i][j] if j < rank else F(0) for j in range(64)] for i in range(64)] + need(product(base, basis) == projected_basis and len(independent_columns(basis, q)) == 64, + "rational split basis with unit determinant modulo fixed q") + preparation = product(chart, basis) + record = ("COPY" if op == 2 else "MOVE", 0, position, role, + host["live"] if op == 2 else family, a, b, key, rank, + "common" if op == 2 else "owner", tuple(axes), port) + templates.append(Template(q, rank, record, tuple(map(tuple, base)), tuple(map(tuple, chart)), + tuple(map(tuple, preparation)))) + return tuple(templates) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/stream.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/stream.py new file mode 100644 index 0000000000..5e5a4bb0f9 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/stream.py @@ -0,0 +1,163 @@ +"""Binary-counted complete-fibre ADD using an encoded coefficient callback. + +Each arbitrary spectator extent has its own canonical word length. None +enters the coefficient context. Payload bits remain opaque to the arithmetic. +""" +from records import Tape +from words import BLANK, LEFT, ONE, RIGHT, ZERO, need + + +class Counter: + """Canonical variable-length countdown with amortized ripple movement.""" + def __init__(self, word): + self.tape = Tape() + word.rewind() + while word.read() != RIGHT: + self.tape.append(word.read()) + word.step(1) + word.rewind() + self.tape.append(RIGHT) + self.tape.step(-1) + self.tape.step(-1) + while self.tape.read() == ZERO: + self.tape.write(RIGHT) + self.tape.step(1) + self.tape.write(BLANK) + self.tape.step(-1) + self.tape.step(-1) + self.finished = self.tape.read() == LEFT + if self.finished: + self.tape.step(1) + self.tape.write(ZERO) + self.tape.step(1) + self.tape.write(RIGHT) + self.tape.rewind() + + def decrement(self): + need(not self.finished, "positive countdown") + tape = self.tape + while tape.read() == ZERO: + tape.write(ONE) + tape.step(1) + need(tape.read() == ONE, "canonical positive counter") + tape.write(ZERO) + tape.step(1) + if tape.read() == RIGHT: + tape.write(BLANK) + tape.step(-1) + tape.step(-1) + if tape.read() == LEFT: + tape.step(1) + tape.write(ZERO) + tape.step(1) + tape.write(RIGHT) + self.finished = True + else: + tape.step(1) + tape.write(RIGHT) + tape.rewind() + + def close(self): + self.tape.clear() + + +def positive_extent(word): + """Reject padding inherited from a different, larger spectator extent.""" + word.msb() + margin = word.read() + word.step(-1) + significant = word.read() + word.rewind() + need(margin == ZERO and significant == ONE, "separately canonical positive spectator extent") + + +def one_bit_suffix(word): + """Recognize the fixed encodings of one, without decoding a cardinality.""" + word.rewind() + if word.read() != ONE: + return False + word.step(1) + if word.read() == ZERO: + word.step(1) + result = word.read() == RIGHT + word.rewind() + return result + + +def copy_blocks(source, target, count, suffix, observe): + blocks = Counter(count) + single = one_bit_suffix(suffix) + while not blocks.finished: + if single: + bit = source.read() + need(bit in (ZERO, ONE), "opaque payload bit") + target.append(bit) + source.step(1) + else: + bits = Counter(suffix) + while not bits.finished: + bit = source.read() + need(bit in (ZERO, ONE), "opaque payload bit") + target.append(bit) + source.step(1) + bits.decrement() + bits.close() + observe(bits) + blocks.decrement() + blocks.close() + observe(blocks) + + +def add_pass(source, ring, before, middle, suffix, prepare_coefficient, payload_factory=Tape): + for extent in (before, middle, suffix): + positive_extent(extent) + left, right, out = payload_factory(), payload_factory(), payload_factory() + totals = {"reads": 0, "writes": 0, "moves": 0} + def observe(counter): + # External meter only; no count controls execution. + for key in totals: + totals[key] += getattr(counter.tape.meter, key) + def traverse(merge): + coefficient = prepare_coefficient() + need(ring.raw.compare(coefficient, ring.modulus) < 0, "canonical encoded coefficient") + outer = Counter(before) + while not outer.finished: + x = ring.arena.zero() + sources = Counter(ring.modulus) + while not sources.finished: + offset = ring.multiply(coefficient, x) + leading = ring.raw.subtract_exact(ring.modulus, offset) + mid = Counter(middle) + while not mid.finished: + if merge: + copy_blocks(right, out, offset, suffix, observe) + copy_blocks(left, out, leading, suffix, observe) + else: + copy_blocks(source, left, leading, suffix, observe) + copy_blocks(source, right, offset, suffix, observe) + mid.decrement() + mid.close() + observe(mid) + ring.arena.free_many(offset, leading) + sources.decrement() + if not sources.finished: + ring.raw.increment_in_place(x) + sources.close() + observe(sources) + ring.arena.free(x) + outer.decrement() + outer.close() + observe(outer) + ring.arena.free(coefficient) + traverse(False) + need(source.read() == BLANK, "complete input extent") + source.rewind() + left.rewind() + right.rewind() + traverse(True) + need(left.read() == right.read() == BLANK, "complete split consumption") + left.clear() + right.clear() + out.rewind() + return out, {"counters": totals, "left": left.meter.record(), "right": right.meter.record(), + "output": out.meter.record()} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/stream_runner.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/stream_runner.py new file mode 100644 index 0000000000..efff281d4c --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/stream_runner.py @@ -0,0 +1,112 @@ +"""Interpret the shared trace on a complete Boolean fibre for one prefix. + +Coefficient requests remain symbolic until a pass reads its exact raw prefix. +All physical atom positions and spectator cardinalities remain binary. +""" +from bitstream import atom_swap, sign_address +from cardinality import Natural, multiply_atom_power +from stream import add_pass, positive_extent +from trace import execute +from words import need + + +class Layout: + def __init__(self, geometry, parent_size, ring, q, before, suffix): + positive_extent(before) + positive_extent(suffix) + self.geometry, self.ring, self.q = geometry, ring, q + self.before, self.suffix = before, suffix + self.core = geometry.raw.times_small(geometry.columns, geometry.plan.dimension) + unused = geometry.raw.subtract_exact(parent_size, self.core) + self.extra = geometry.raw.times_small(unused, 2) + geometry.index.free(unused) + self.total = geometry.raw.times_small(parent_size, 2) + + def physical(self, position): + if self.geometry.raw.compare(position, self.core) < 0: + return self.geometry.index.copy(position) + return self.geometry.plus(position, self.extra) + + def extents(self, first, second=None): + g = self.geometry + a = self.physical(first) + b = self.physical(second) if second is not None else None + if b is not None: + need(g.raw.compare(a, b) < 0, "ordered stream atoms") + pre, tail = Natural(self.before), Natural(self.suffix) + multiply_atom_power(pre, a, self.ring, self.q) + after = g.raw.subtract_exact(self.total, a if b is None else b) + count = g.raw.subtract_exact(after, g.one) + multiply_atom_power(tail, count, self.ring, self.q) + g.index.free_many(after, count) + values = [pre] + if b is not None: + distance = g.raw.subtract_exact(b, a) + gap = g.raw.subtract_exact(distance, g.one) + middle = Natural() + multiply_atom_power(middle, gap, self.ring, self.q) + values.append(middle) + g.index.free_many(distance, gap, b) + values.append(tail) + g.index.free(a) + result = [value.marginal() for value in values] + for value in values: + value.close() + return result + + def close(self): + self.geometry.index.free_many(self.core, self.extra, self.total) + + +def action(source, event, layout, coefficient, payload_factory=None): + """One full primitive pass; split and merge each request a coefficient.""" + if event.kind == "add": + extents = layout.extents(event.second, event.first) + elif event.kind == "atom_swap": + extents = layout.extents(event.first, event.second) + else: + need(event.kind == "sign", "stream primitive tag") + extents = layout.extents(event.first) + try: + if event.kind == "add": + kwargs = {} if payload_factory is None else {"payload_factory": payload_factory} + output, _traffic = add_pass(source, layout.ring, *extents, + lambda: coefficient(event.request), **kwargs) + return output + if event.kind == "atom_swap": + return atom_swap(source, layout.ring, layout.q, *extents) + return sign_address(source, layout.ring, layout.q, *extents) + finally: + for extent in extents: + extent.close() + + +def run(source, geometry, parent_size, ring, q, before, suffix, coefficient, + payload_factory=None): + layout = Layout(geometry, parent_size, ring, q, before, suffix) + current, active = source, None + try: + for event in execute(geometry): + if event.kind == "enter": + need(active is None and event.parent_identity is geometry.parent_identity, + "one complete child invocation") + active = event + continue + if event.kind == "return": + need(active is not None and active.parent_identity is event.parent_identity + and active.source_code == event.source_code and active.child_kind == event.child_kind + and active.half == event.half, + "same symbolic child return") + for a, b in ((active.first, event.first), (active.second, event.second), + (active.width, event.width), (active.depth, event.depth)): + need(geometry.raw.compare(a, b) == 0, "restored encoded child context") + active = None + continue + following = action(current, event, layout, coefficient, payload_factory) + if current is not source: + current.clear() + current = following + need(active is None, "closed stream child invocation") + return current + finally: + layout.close() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/trace.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/trace.py new file mode 100644 index 0000000000..bb845a90f5 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/trace.py @@ -0,0 +1,167 @@ +"""One encoded-index trace for algebra observation and stream interpretation. + +The iterator lends each emitted word until the next iteration. A child +extension always refers to the unchanged parent program and current raw slot. +""" +from dataclasses import dataclass, replace + +from plan import Request +from words import need + + +@dataclass +class Event: + kind: str + first: object + second: object = None + request: object = None + width: object = None + depth: object = None + child_kind: str = "" + field: int = 0 + reverse: bool = False + source_code: int = 0 + parent_identity: object = None + half: bool = False + + +def columns(page, reverse=False): + j = page.raw.subtract_exact(page.columns, page.one) if reverse else page.index.zero() + try: + while page.raw.compare(j, page.columns) < 0: + yield j + if reverse: + if j.zero(): + break + previous = page.raw.subtract_exact(j, page.one) + page.index.free(j) + j = previous + else: + page.raw.increment_in_place(j) + finally: + page.index.free(j) + + +def primitive(kind, first, second, request, page): + try: + yield Event(kind, first, second, request) + finally: + page.index.free(first) + if second is not None: + page.index.free(second) + if request is not None: + page.index.free(request.coordinate) + + +def leaf(page, first, second, width, kind, field=0, reverse=False, half=False): + need(not width.zero() and page.raw.compare(width, page.leaf_cutoff) < 0, + "completed leaf child below selected cutoff") + depth = page.plus(page.depth, page.one) + boundary = Event("enter", first, second, width=width, depth=depth, + child_kind=kind, field=field, reverse=reverse, + source_code=page.source_code, parent_identity=page.parent_identity, half=half) + try: + yield boundary + i = page.index.zero() + try: + while page.raw.compare(i, width) < 0: + left = page.plus(first, i) + last = page.raw.subtract_exact(width, page.one) + tail = page.raw.subtract_exact(last, i) + right = page.plus(second, tail) + page.index.free_many(last, tail) + try: + # A weighted leaf uses only complete atom swaps, later + # ADDs and one sign. No weighted-swap oracle appears. + for stage in range(8): + a, b = page.index.copy(left), page.index.copy(right) + if stage in (0, 2, 4, 6): + yield from primitive("atom_swap", a, b, None, page) + elif stage == 7: + page.index.free(a) + yield from primitive("sign", b, None, None, page) + else: + request = Request("child", page.index.copy(i), child_kind=kind, + field=field, reverse=reverse, negative_inverse=stage == 3, half=half) + yield from primitive("add", b, a, request, page) + finally: + page.index.free_many(left, right) + page.raw.increment_in_place(i) + finally: + page.index.free(i) + yield replace(boundary, kind="return") + finally: + page.index.free(depth) + + +def child(page, first, second, width, kind, field=0, reverse=False, half=False): + try: + need(page.raw.compare(first, second) < 0, "ordered child chunks") + end = page.plus(first, width) + need(page.raw.compare(end, second) <= 0, "disjoint child chunks") + page.index.free(end) + yield from leaf(page, first, second, width, kind, field, reverse, half) + finally: + page.index.free_many(first, second, width) + + +def pair_command(page, command): + i, k, m = command.target, command.source, page.plan.dimension + need(i < k, "ordered fallback child fields") + same = (i < m) == (k < m) + half, remainder = page.raw.divmod(page.columns, page.two) + page.index.free(remainder) + try: + for stage in range(3): + if stage != 1: + if not same or half.zero(): + continue + first = page.raw.times_small(page.columns, k) + after = page.raw.times_small(page.columns, k+1) + second = page.raw.subtract_exact(after, half) + page.index.free(after) + yield from child(page, first, second, page.index.copy(half), "unit", half=True) + else: + first = page.raw.times_small(page.columns, i) + second = page.raw.times_small(page.columns, k) + kind = command.reference.kind + need(kind in ("unit", "pair"), "selected fallback child kind") + yield from child(page, first, second, page.index.copy(page.columns), + kind, i if kind == "pair" else 0, + i >= m if kind == "pair" else False) + finally: + page.index.free(half) + + +def adapters(page, reverse=False): + # Recreate the finite command iterator for each encoded column. + for j in columns(page, reverse): + commands = reversed(page.plan.commands) if reverse else page.plan.commands + for command in commands: + target, source = page.point(command.target, j), page.point(command.source, j) + request = Request("adapter", page.index.copy(j), command.reference, reverse) + yield from primitive("add", target, source, request, page) + + +def execute(page): + """Expand one complete residual whose children lie below the cutoff.""" + if page.plan.good: + yield from adapters(page) + first = page.index.zero() + second = page.raw.times_small(page.columns, 2*page.plan.dimension-page.plan.rank) + width = page.raw.times_small(page.columns, page.plan.rank) + yield from child(page, first, second, width, "good") + yield from adapters(page, True) + else: + for command in page.plan.commands: + if command.kind == "child": + yield from pair_command(page, command) + else: + for j in columns(page): + target = page.point(command.target, j) + if command.kind == "sign": + yield from primitive("sign", target, None, None, page) + else: + source = page.point(command.source, j) + request = Request("adapter", page.index.copy(j), command.reference) + yield from primitive("add", target, source, request, page) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/words.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/words.py new file mode 100644 index 0000000000..8d4ba37e27 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/vendor/words.py @@ -0,0 +1,415 @@ +"""Binary word tapes; unbounded numerical values stay in tape cells. + +Only zero/one carry states and fixed register/operation tags enter Python +control. Fixture loading/inspection methods are outside measured execution. +The arena bounds the tape inventory by a compile-time register capacity. +""" +ZERO, ONE, LEFT, RIGHT, BLANK = range(5) + + +def need(test, message): + if not test: + raise ValueError(message) + + +class Meter: + __slots__ = ("reads", "writes", "moves", "peak_live", "allocations") + + def __init__(self): + self.reads = self.writes = self.moves = self.peak_live = self.allocations = 0 + + def record(self): + return {name: getattr(self, name) for name in self.__slots__} + + +class Word: + __slots__ = ("arena", "slot", "cells", "head") + + def __init__(self, arena, slot): + self.arena, self.slot = arena, slot + self.cells = bytearray([LEFT] + [BLANK]*(arena.bits+1)) + self.head = 1 + + def read(self): + self.arena.meter.reads += 1 + return self.cells[self.head] + + def write(self, symbol): + need(symbol in (ZERO, ONE, RIGHT, BLANK), "word tape alphabet") + self.arena.meter.writes += 1 + self.cells[self.head] = symbol + + def step(self, direction): + need(direction in (-1, 1), "unit word-head movement") + self.head += direction + need(0 <= self.head < len(self.cells), "local word boundary") + self.arena.meter.moves += 1 + + def rewind(self): + self.step(-1) + while self.read() != LEFT: + self.step(-1) + self.step(1) + + def msb(self): + self.rewind() + while self.read() != RIGHT: + self.step(1) + self.step(-1) + + def zero(self): + self.rewind() + nonzero = False + while True: + bit = self.read() + if bit == RIGHT: + break + need(bit in (ZERO, ONE), "complete binary word") + nonzero = nonzero or bit == ONE + self.step(1) + self.rewind() + return not nonzero + + def erase(self): + self.rewind() + while self.read() != RIGHT: + self.write(BLANK) + self.step(1) + self.write(BLANK) + self.rewind() + + def inspect(self): + """Checker-only decoding; arithmetic code must not call this.""" + need(self.head == 1 and self.cells[-1] == RIGHT, "inspect a restored word") + return sum(bit << i for i, bit in enumerate(self.cells[1:-1])) + + +class Arena: + def __init__(self, bits, capacity=65536): + need(bits >= 2 and capacity > 0, "fixed word context") + self.bits, self.capacity = bits, capacity + self.meter = Meter() + self.words, self.available, self.live = [], [], set() + self.template = Word(self, -1) + self.template.cells[1:-1] = bytes([ZERO])*bits + self.template.cells[-1] = RIGHT + + def zero(self): + if self.available: + slot = self.available.pop() + out = self.words[slot] + else: + slot = len(self.words) + need(slot < self.capacity, "fixed register inventory") + out = Word(self, slot) + self.words.append(out) + need(slot not in self.live, "fresh numerical register") + self.live.add(slot) + self.meter.allocations += 1 + self.meter.peak_live = max(self.meter.peak_live, len(self.live)) + source = self.template + source.rewind() + while source.read() != RIGHT: + need(out.read() == BLANK, "erased register before reuse") + out.write(ZERO) + out.step(1) + source.step(1) + need(out.read() == BLANK, "erased right delimiter cell") + out.write(RIGHT) + out.rewind() + source.rewind() + return out + + def literal(self, value): + """Compile-time literal only; never decode a runtime word here.""" + need(isinstance(value, int) and value >= 0, "unsigned literal") + out = self.zero() + for bit in tuple((value >> i) & 1 for i in range(value.bit_length())): + need(out.read() != RIGHT, "literal fits the fixed word") + out.write(bit) + out.step(1) + out.rewind() + return out + + def input(self, value): + """Fixture-only loading of an encoded input word.""" + return self.literal(value) + + def copy(self, source): + need(source.arena is self, "one word extent") + out = self.zero() + source.rewind() + while source.read() != RIGHT: + out.write(source.read()) + source.step(1) + out.step(1) + out.rewind() + source.rewind() + return out + + def free(self, word): + need(word.arena is self and word.slot in self.live, "owned numerical register") + word.erase() + self.live.remove(word.slot) + self.available.append(word.slot) + + def free_many(self, *words): + for word in words: + self.free(word) + + def rollback(self, protected): + """Erase owned temporary roles on a rejecting path; capacity is fixed.""" + for slot in tuple(self.live): + if slot not in protected: + self.free(self.words[slot]) + for slot in protected: + self.words[slot].rewind() + + +class Unsigned: + def __init__(self, arena): + self.arena = arena + + def compare(self, a, b): + need(a.arena is b.arena is self.arena, "comparison word context") + if a is b: + return 0 + a.rewind() + b.rewind() + state = 0 + while a.read() != RIGHT: + x, y = a.read(), b.read() + need(x in (ZERO, ONE) and y in (ZERO, ONE), "comparison binary digits") + if x != y: + state = 1 if x == ONE else -1 + a.step(1) + b.step(1) + need(b.read() == RIGHT, "equal comparison extents") + a.rewind() + b.rewind() + return state + + def add(self, a, b): + out = self.arena.zero() + a.rewind() + b.rewind() + carry = 0 + while a.read() != RIGHT: + x, y = a.read(), b.read() + total = x+y+carry # Four finite carry states, not word arithmetic. + out.write(total & 1) + carry = total >> 1 + a.step(1) + if b is not a: + b.step(1) + out.step(1) + need(b.read() == RIGHT, "equal addition extents") + a.rewind() + b.rewind() + out.rewind() + return out, carry + + def subtract(self, a, b): + out = self.arena.zero() + a.rewind() + b.rewind() + borrow = 0 + while a.read() != RIGHT: + x, y = a.read(), b.read() + digit = x-y-borrow # One finite borrow bit. + out.write(digit & 1) + borrow = int(digit < 0) + a.step(1) + if b is not a: + b.step(1) + out.step(1) + need(b.read() == RIGHT, "equal subtraction extents") + a.rewind() + b.rewind() + out.rewind() + return out, borrow + + def subtract_exact(self, a, b): + out, borrow = self.subtract(a, b) + need(not borrow, "unsigned subtraction precondition") + return out + + def shift_add_bit(self, a, bit): + need(bit in (ZERO, ONE), "one incoming bit") + out = self.arena.zero() + a.rewind() + carry = bit + while a.read() != RIGHT: + previous = a.read() + out.write(carry) + carry = previous + a.step(1) + out.step(1) + a.rewind() + out.rewind() + need(not carry, "reserved high-bit margin") + return out + + def divmod(self, numerator, denominator): + need(not denominator.zero(), "nonzero binary divisor") + # A zero high bit leaves room for 2*remainder+bit. + denominator.msb() + margin = denominator.read() + denominator.rewind() + need(margin == ZERO, "binary divisor has the high-bit margin") + scan = self.arena.copy(numerator) + quotient, remainder = self.arena.zero(), self.arena.zero() + scan.msb() + quotient.msb() + while scan.read() != LEFT: + shifted = self.shift_add_bit(remainder, scan.read()) + self.arena.free(remainder) + if self.compare(shifted, denominator) >= 0: + remainder = self.subtract_exact(shifted, denominator) + self.arena.free(shifted) + quotient.write(ONE) + else: + remainder = shifted + quotient.write(ZERO) + scan.step(-1) + quotient.step(-1) + scan.step(1) + quotient.step(1) + self.arena.free(scan) + return quotient, remainder + + def times_small(self, a, constant): + """Multiply by a fixed finite matrix/rank label; preserve the word margin.""" + need(0 <= constant <= 128, "finite index multiplier") + result = self.arena.zero() + for bit in tuple((constant >> i) & 1 for i in range(constant.bit_length()-1, -1, -1)): + doubled, carry = self.add(result, result) + need(not carry, "index multiplication margin") + self.arena.free(result) + if bit: + result, carry = self.add(doubled, a) + need(not carry, "index multiplication extent") + self.arena.free(doubled) + else: + result = doubled + return result + + def increment_in_place(self, word): + """Ripple increment for a bounded address counter; restore its head.""" + word.rewind() + while word.read() == ONE: + word.write(ZERO) + word.step(1) + need(word.read() == ZERO, "ripple increment has space") + word.write(ONE) + word.rewind() + + +class Ring: + """Canonical residues modulo an encoded M>1 with one leading zero bit.""" + def __init__(self, modulus): + self.modulus, self.arena = modulus, modulus.arena + self.raw = Unsigned(self.arena) + self.one = self.arena.literal(1) + try: + need(self.raw.compare(modulus, self.one) > 0, "modulus exceeds one") + modulus.msb() + margin = modulus.read() + modulus.step(-1) + significant = modulus.read() + modulus.rewind() + need(margin == ZERO and significant == ONE, "canonical modulus word with one high-bit margin") + except ValueError: + self.arena.free(self.one) + raise + + def close(self): + self.arena.free(self.one) + + def add(self, a, b): + total, carry = self.raw.add(a, b) + need(not carry, "canonical modular addition margin") + if self.raw.compare(total, self.modulus) >= 0: + out = self.raw.subtract_exact(total, self.modulus) + self.arena.free(total) + return out + return total + + def subtract(self, a, b): + if self.raw.compare(a, b) >= 0: + return self.raw.subtract_exact(a, b) + larger, carry = self.raw.add(a, self.modulus) + need(not carry, "canonical modular subtraction margin") + out = self.raw.subtract_exact(larger, b) + self.arena.free(larger) + return out + + def negate(self, a): + zero = self.arena.zero() + out = self.subtract(zero, a) + self.arena.free(zero) + return out + + def multiply(self, a, b): + if a.zero() or b.zero(): + return self.arena.zero() + if self.raw.compare(a, self.one) == 0: + return self.arena.copy(b) + if self.raw.compare(b, self.one) == 0: + return self.arena.copy(a) + scan = self.arena.copy(b) + result = self.arena.zero() + scan.msb() + while scan.read() != LEFT: + doubled = self.add(result, result) + self.arena.free(result) + if scan.read() == ONE: + result = self.add(doubled, a) + self.arena.free(doubled) + else: + result = doubled + scan.step(-1) + scan.step(1) + self.arena.free(scan) + return result + + def inverse(self, a): + """Euclid, with Bezout coefficients reduced modulo M; None for nonunits.""" + r0, r1 = self.arena.copy(self.modulus), self.arena.copy(a) + t0, t1 = self.arena.zero(), self.arena.copy(self.one) + while not r1.zero(): + quotient, r2 = self.raw.divmod(r0, r1) + if self.raw.compare(quotient, self.modulus) >= 0: + reduced = self.raw.subtract_exact(quotient, self.modulus) + self.arena.free(quotient) + quotient = reduced + product = self.multiply(quotient, t1) + t2 = self.subtract(t0, product) + self.arena.free_many(quotient, product, r0, t0) + r0, r1, t0, t1 = r1, r2, t1, t2 + unit = self.raw.compare(r0, self.one) == 0 + self.arena.free_many(r0, r1, t1) + if unit: + return t0 + self.arena.free(t0) + return None + + def literal(self, constant): + """Compile a fixed signed integer through binary modular operations.""" + negative = constant < 0 + magnitude = abs(constant) + result = self.arena.zero() + instructions = tuple((magnitude >> i) & 1 for i in range(magnitude.bit_length()-1, -1, -1)) + for bit in instructions: + doubled = self.add(result, result) + self.arena.free(result) + if bit: + result = self.add(doubled, self.one) + self.arena.free(doubled) + else: + result = doubled + if negative: + out = self.negate(result) + self.arena.free(result) + result = out + return result diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/verify.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/verify.py new file mode 100644 index 0000000000..121acc1ff1 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/predecessor/verify.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +"""Authenticate inputs, replay bounded evidence and compare exact receipts.""" +import argparse +from hashlib import sha256 +import json +from pathlib import Path +import sys + +HERE=Path(__file__).resolve().parent +ROOT=HERE.parents[1] +sys.path[:0]=[str(HERE),str(HERE/"vendor")] + + +def canonical(value): + # Normalize integer dictionary keys before ordering the serialized receipt. + return json.dumps(json.loads(json.dumps(value)),sort_keys=True,separators=(",",":")) + + +def main(): + parser=argparse.ArgumentParser() + parser.add_argument("--suite",choices=("source","node","controls"),required=True) + parser.add_argument("--emit",action="store_true") + args=parser.parse_args() + sources=json.loads((HERE/"SOURCES.json").read_text()) + for item in sources["files"]: + if item["usage"]=="input" and sha256((ROOT/item["path"]).read_bytes()).hexdigest()!=item["sha256"]: + raise ValueError("pinned main input changed: "+item["path"]) + for item in sources["vendor_files"]: + if sha256((HERE/"vendor"/item["name"]).read_bytes()).hexdigest()!=item["sha256"]: + raise ValueError("unchanged predecessor source changed: "+item["name"]) + if args.suite=="source": + from catalogue import Catalogue + from check_sources import catalogue_checks, consumer_probes, global_scalar + from check_layout import extents, selected_peel, complete_gapped + from check_headers import sampled_packet + catalogue=Catalogue(3) + result={"selected_sources":catalogue_checks(catalogue), + "selected_consumers":consumer_probes(catalogue), + "global_scalar":global_scalar(catalogue),"gapped_extents":extents(), + "generated_peel":selected_peel(catalogue),"gapped_endpoint":complete_gapped(), + "sampled_high_packet":sampled_packet()} + elif args.suite=="node": + from check_runtime import complete_node + result=complete_node() + else: + from control_checks import stale_controls, bridge_and_exchange, rejections_and_counts + result={"stale_state":stale_controls(),"bridge_exchange":bridge_and_exchange(), + "rejections_counts":rejections_and_counts()} + observed={"full_result_sha256":sha256(canonical(result).encode()).hexdigest(),"result":result} + if not args.emit: + expected=json.loads((HERE/"RESULT.json").read_text())[args.suite] + if canonical(observed)!=canonical(expected): + print(json.dumps(observed,sort_keys=True,indent=2)) + raise ValueError("retained exact receipt differs: "+args.suite) + print("PASS_SELECTED_BIT_NODE "+args.suite) + print(json.dumps(observed,sort_keys=True,indent=2)) + + +if __name__=="__main__": + main() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/recursive_call.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/recursive_call.py new file mode 100644 index 0000000000..6d33224145 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/recursive_call.py @@ -0,0 +1,110 @@ +"""Complete generated child on one packet, with separately charged frame work. + +The parent's frozen fields are the child's old directory. The unused U +coordinate alone supplies fresh rows; address spectators are never borrowed. +""" +from cardinal_counts import Count +from children import extend +from controller import Callback +from directory import Context, append_tape +from packet import read_prefix +from plan import Request +from records import Fields, Program +from words import Arena, RIGHT, Ring, Unsigned, need + +REGISTER_CAPACITY=1 << 24 + + +def copy_word(source,arena): + """Copy an encoded value to a separate frame bank without decoding it.""" + out=arena.zero() + source.rewind() + try: + while source.read()!=RIGHT: + need(out.read()!=RIGHT,"equal frame word extents") + out.write(source.read());source.step(1);out.step(1) + need(out.read()==RIGHT,"complete frame word copy") + out.rewind();return out + except ValueError: + arena.free(out);raise + finally:source.rewind() + + +class Frame: + def __init__(self,parent,program,event): + # bits describes the existing physical word template, not a decoded + # width, residue or address. Both frames have identical templates. + self.arena=Arena(parent.context.arena.bits,REGISTER_CAPACITY) + self.indices=Arena(parent.indices.bits,REGISTER_CAPACITY) + self.modulus=self.ring=self.context=self.program=self.size=self.depth=self.node=None + try: + self.modulus=copy_word(parent.context.ring.modulus,self.arena) + self.ring=Ring(self.modulus) + self.context=Context(self.ring,parent.context.codes) + self.program=Program(self.indices,self.arena,program.code_bits) + append_tape(program.tape,self.program.tape);self.program.tape.rewind() + self.size=copy_word(event.width,self.indices) + self.depth=copy_word(event.depth,self.indices) + from node import SelectedNode + self.node=SelectedNode(self.context,self.indices,self.program,self.size,self.depth, + parent.specifications.catalogue,parent.specifications) + except BaseException: + # The caller cannot close a constructor that never returned. + # These are fresh, separate banks, so every remaining word belongs + # to this failed frame, including partial child initialization. + if self.program is not None:self.program.tape.clear() + if self.context is not None:self.context.close() + if self.ring is not None:self.ring.close() + self.indices.rollback(frozenset()) + self.arena.rollback(frozenset()) + raise + + def close(self): + self.program.tape.clear() + self.indices.free_many(self.size,self.depth) + self.context.close();self.ring.close();self.arena.free(self.modulus) + need(not self.indices.live and not self.arena.live,"recursive frame numerical restoration") + + +def child_call(parent,source,event,layout,directory,prefixes,fields,stock,before): + need(stock is not None and before is not None,"independent child row-stock and spectators") + context,indices=parent.context,parent.indices + need(event.parent_identity is parent.program and event.source_code==layout.geometry.source_code, + "recursive call belongs to the frozen parent") + raw=Unsigned(indices) + need(raw.compare(event.width,parent.parent_size)<0,"strict recursive contraction") + extents=layout.child_extents(event.first,event.second,event.width,before=before) + extended=frame=callback=result=None + returned=False + first=None + try: + directory.rewind();first=read_prefix(directory,fields);directory.rewind() + prefix=Fields(indices,context.arena,context.codes.bits);prefix.tape=first + callback=Callback(context.ring,indices,parent.program,prefix,parent.specifications, + event.source_code,allow_fallback=True) + zero=indices.zero() + try: + request=Request("child",zero,child_kind=event.child_kind,field=event.field, + reverse=event.reverse,half=event.half) + extended=extend(callback,request) + finally:indices.free(zero) + callback.close();callback=None + # Descriptor depends only on ancestor program and the finite branch; + # the representative high prefix is not used to pick children. + frame=Frame(parent,extended,event) + extended.tape.clear();extended=None + first.clear();first=None + from scheduler import Invocation + result=yield Invocation(frame.node.run_generator(source,directory,prefixes,stock,*extents)) + need(source.head==result.head==directory.head==parent.program.tape.head==1, + "completed recursive return restores caller heads") + returned=True + return result + finally: + if result is not None and result is not source and not returned:result.clear() + if callback is not None:callback.abort() + if frame is not None:frame.close() + if extended is not None:extended.tape.clear() + if first is not None:first.clear() + for extent in extents:extent.close() + directory.rewind();source.rewind();parent.program.tape.rewind() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/scheduler.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/scheduler.py new file mode 100644 index 0000000000..60c2b6d065 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/scheduler.py @@ -0,0 +1,28 @@ +"""Iterative evaluator: child depth does not consume the Python call stack.""" +from dataclasses import dataclass +from types import GeneratorType +from words import need + +@dataclass +class Invocation: + body: object + +def complete(body): + need(isinstance(body,GeneratorType),"a suspended stream program") + stack=[body] + value=None + try: + while stack: + try: + request=stack[-1].send(value) + except StopIteration as done: + stack.pop() + value=done.value + continue + need(isinstance(request,Invocation) and isinstance(request.body,GeneratorType), + "only a complete child invocation may suspend the caller") + stack.append(request.body) + value=None + return value + finally: + for pending in reversed(stack): pending.close() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/stream_runner.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/stream_runner.py new file mode 100644 index 0000000000..6ba5df130b --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/stream_runner.py @@ -0,0 +1,113 @@ +"""Interpret the shared trace on a complete Boolean fibre for one prefix. + +Coefficient requests remain symbolic until a pass reads its exact raw prefix. +All physical atom positions and spectator cardinalities remain binary. +""" +from bitstream import atom_swap +from linear_sign import sign_address +from cardinality import Natural, multiply_atom_power +from stream import add_pass, positive_extent +from trace import execute +from words import need + + +class Layout: + def __init__(self, geometry, parent_size, ring, q, before, suffix): + positive_extent(before) + positive_extent(suffix) + self.geometry, self.ring, self.q = geometry, ring, q + self.before, self.suffix = before, suffix + self.core = geometry.raw.times_small(geometry.columns, geometry.plan.dimension) + unused = geometry.raw.subtract_exact(parent_size, self.core) + self.extra = geometry.raw.times_small(unused, 2) + geometry.index.free(unused) + self.total = geometry.raw.times_small(parent_size, 2) + + def physical(self, position): + if self.geometry.raw.compare(position, self.core) < 0: + return self.geometry.index.copy(position) + return self.geometry.plus(position, self.extra) + + def extents(self, first, second=None): + g = self.geometry + a = self.physical(first) + b = self.physical(second) if second is not None else None + if b is not None: + need(g.raw.compare(a, b) < 0, "ordered stream atoms") + pre, tail = Natural(self.before), Natural(self.suffix) + multiply_atom_power(pre, a, self.ring, self.q) + after = g.raw.subtract_exact(self.total, a if b is None else b) + count = g.raw.subtract_exact(after, g.one) + multiply_atom_power(tail, count, self.ring, self.q) + g.index.free_many(after, count) + values = [pre] + if b is not None: + distance = g.raw.subtract_exact(b, a) + gap = g.raw.subtract_exact(distance, g.one) + middle = Natural() + multiply_atom_power(middle, gap, self.ring, self.q) + values.append(middle) + g.index.free_many(distance, gap, b) + values.append(tail) + g.index.free(a) + result = [value.marginal() for value in values] + for value in values: + value.close() + return result + + def close(self): + self.geometry.index.free_many(self.core, self.extra, self.total) + + +def action(source, event, layout, coefficient, payload_factory=None): + """One full primitive pass; split and merge each request a coefficient.""" + if event.kind == "add": + extents = layout.extents(event.second, event.first) + elif event.kind == "atom_swap": + extents = layout.extents(event.first, event.second) + else: + need(event.kind == "sign", "stream primitive tag") + extents = layout.extents(event.first) + try: + if event.kind == "add": + kwargs = {} if payload_factory is None else {"payload_factory": payload_factory} + output, _traffic = add_pass(source, layout.ring, *extents, + lambda: coefficient(event.request), **kwargs) + return output + if event.kind == "atom_swap": + return atom_swap(source, layout.ring, layout.q, *extents) + return sign_address(source, layout.ring, layout.q, *extents) + finally: + for extent in extents: + extent.close() + + +def run(source, geometry, parent_size, ring, q, before, suffix, coefficient, + payload_factory=None): + layout = Layout(geometry, parent_size, ring, q, before, suffix) + current, active = source, None + try: + for event in execute(geometry): + if event.kind == "enter": + need(active is None and event.parent_identity is geometry.parent_identity, + "one complete child invocation") + active = event + continue + if event.kind == "return": + need(active is not None and active.parent_identity is event.parent_identity + and active.source_code == event.source_code and active.child_kind == event.child_kind + and active.half == event.half, + "same symbolic child return") + for a, b in ((active.first, event.first), (active.second, event.second), + (active.width, event.width), (active.depth, event.depth)): + need(geometry.raw.compare(a, b) == 0, "restored encoded child context") + active = None + continue + following = action(current, event, layout, coefficient, payload_factory) + if current is not source: + current.clear() + current = following + need(active is None, "closed stream child invocation") + return current + finally: + layout.close() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/trace.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/trace.py new file mode 100644 index 0000000000..4b002201ce --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/trace.py @@ -0,0 +1,184 @@ +"""One encoded-index trace for algebra observation and stream interpretation. + +The iterator lends each emitted word until the next iteration. A child +extension always refers to the unchanged parent program and current raw slot. +""" +from dataclasses import dataclass, replace + +from plan import Request +from words import need + + +@dataclass +class Event: + kind: str + first: object + second: object = None + request: object = None + width: object = None + depth: object = None + child_kind: str = "" + field: int = 0 + reverse: bool = False + source_code: int = 0 + parent_identity: object = None + half: bool = False + + +def columns(page, reverse=False): + j = page.raw.subtract_exact(page.columns, page.one) if reverse else page.index.zero() + try: + while page.raw.compare(j, page.columns) < 0: + yield j + if reverse: + if j.zero(): + break + previous = page.raw.subtract_exact(j, page.one) + page.index.free(j) + j = previous + else: + page.raw.increment_in_place(j) + finally: + page.index.free(j) + + +def primitive(kind, first, second, request, page): + try: + yield Event(kind, first, second, request) + finally: + page.index.free(first) + if second is not None: + page.index.free(second) + if request is not None: + page.index.free(request.coordinate) + + +def leaf(page, first, second, width, kind, field=0, reverse=False, half=False): + need(not width.zero() and page.raw.compare(width, page.leaf_cutoff) < 0, + "completed leaf child below selected cutoff") + depth = page.plus(page.depth, page.one) + boundary = Event("enter", first, second, width=width, depth=depth, + child_kind=kind, field=field, reverse=reverse, + source_code=page.source_code, parent_identity=page.parent_identity, half=half) + try: + yield boundary + i = page.index.zero() + try: + while page.raw.compare(i, width) < 0: + left = page.plus(first, i) + last = page.raw.subtract_exact(width, page.one) + tail = page.raw.subtract_exact(last, i) + right = page.plus(second, tail) + page.index.free_many(last, tail) + try: + # A weighted leaf uses only complete atom swaps, later + # ADDs and one sign. No weighted-swap oracle appears. + for stage in range(8): + a, b = page.index.copy(left), page.index.copy(right) + if stage in (0, 2, 4, 6): + yield from primitive("atom_swap", a, b, None, page) + elif stage == 7: + page.index.free(a) + yield from primitive("sign", b, None, None, page) + else: + request = Request("child", page.index.copy(i), child_kind=kind, + field=field, reverse=reverse, negative_inverse=stage == 3, half=half) + yield from primitive("add", b, a, request, page) + finally: + page.index.free_many(left, right) + page.raw.increment_in_place(i) + finally: + page.index.free(i) + yield replace(boundary, kind="return") + finally: + page.index.free(depth) + + +def child(page, first, second, width, kind, field=0, reverse=False, half=False): + try: + need(page.raw.compare(first, second) < 0, "ordered child chunks") + end = page.plus(first, width) + need(page.raw.compare(end, second) <= 0, "disjoint child chunks") + page.index.free(end) + need(not width.zero(), "positive complete child invocation") + if page.raw.compare(width, page.leaf_cutoff) < 0: + yield from leaf(page, first, second, width, kind, field, reverse, half) + else: + # Borrow the same encoded boundary until the caller resumes this + # generator after one whole-packet recursive return. Never loop + # over exposed high-prefix values to invoke separate children. + depth = page.plus(page.depth, page.one) + boundary = Event("enter", first, second, width=width, depth=depth, + child_kind=kind, field=field, reverse=reverse, + source_code=page.source_code, + parent_identity=page.parent_identity, half=half) + try: + yield boundary + yield replace(boundary, kind="invoke") + yield replace(boundary, kind="return") + finally: + page.index.free(depth) + finally: + page.index.free_many(first, second, width) + + +def pair_command(page, command): + i, k, m = command.target, command.source, page.plan.dimension + need(i < k, "ordered fallback child fields") + same = (i < m) == (k < m) + half, remainder = page.raw.divmod(page.columns, page.two) + page.index.free(remainder) + try: + for stage in range(3): + if stage != 1: + if not same or half.zero(): + continue + first = page.raw.times_small(page.columns, k) + after = page.raw.times_small(page.columns, k+1) + second = page.raw.subtract_exact(after, half) + page.index.free(after) + yield from child(page, first, second, page.index.copy(half), "unit", half=True) + else: + first = page.raw.times_small(page.columns, i) + second = page.raw.times_small(page.columns, k) + kind = command.reference.kind + need(kind in ("unit", "pair"), "selected fallback child kind") + yield from child(page, first, second, page.index.copy(page.columns), + kind, i if kind == "pair" else 0, + i >= m if kind == "pair" else False) + finally: + page.index.free(half) + + +def adapters(page, reverse=False): + # Recreate the finite command iterator for each encoded column. + for j in columns(page, reverse): + commands = reversed(page.plan.commands) if reverse else page.plan.commands + for command in commands: + target, source = page.point(command.target, j), page.point(command.source, j) + request = Request("adapter", page.index.copy(j), command.reference, reverse) + yield from primitive("add", target, source, request, page) + + +def execute(page): + """Expand a residual and yield opaque complete internal child calls.""" + if page.plan.good: + yield from adapters(page) + first = page.index.zero() + second = page.raw.times_small(page.columns, 2*page.plan.dimension-page.plan.rank) + width = page.raw.times_small(page.columns, page.plan.rank) + yield from child(page, first, second, width, "good") + yield from adapters(page, True) + else: + for command in page.plan.commands: + if command.kind == "child": + yield from pair_command(page, command) + else: + for j in columns(page): + target = page.point(command.target, j) + if command.kind == "sign": + yield from primitive("sign", target, None, None, page) + else: + source = page.point(command.source, j) + request = Request("adapter", page.index.copy(j), command.reference) + yield from primitive("add", target, source, request, page) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/verify.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/verify.py new file mode 100644 index 0000000000..96be8f5859 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2753/verify.py @@ -0,0 +1,188 @@ +#!/usr/bin/env python3 +"""Read-only replay, authenticating all external runtime/proof inputs first.""" +import argparse +from copy import deepcopy +from hashlib import sha1, sha256 +import json +from pathlib import Path +import shutil +import sys +from tempfile import TemporaryDirectory + +HERE=Path(__file__).resolve().parent +ROOT=HERE.parents[1] +LIVE_INPUTS=( + 'certificates/selected-result.json', + 'research/community-hyperplane599-audit/pr589/bit589/v9/hosted/GLOBAL-TEMPLATE.json.gz', + 'research/community-hyperplane599-audit/pr589/bit589/v9/nine/GEOMETRY.json', + 'research/e8-bit-p111-tuned/tune/EXPECTED.json', + 'research/e8-bit-p111-tuned/tune/bitE8mut-p111-tuned.json.gz', + 'research/pr589-five-helper-hosting/PROOF.md', + 'research/pr589-five-helper-hosting/verify.py', + 'research/recursive-parking-boundary/README.md', + 'research/selected-bit-local-ring-sweeps/PROOF.md', + 'research/selected-bit-recursive-closure/PROOF.md', + 'upstream/build/sections/02-streams.tex', +) +FROZEN_FILES=( + 'NOTICE.md','PROOF.md','README.md','RESULT.json','SOURCES.json','TASK.json','VERIFY.json', + 'cardinal_counts.py','catalogue.py','check_headers.py','check_layout.py','check_runtime.py', + 'check_sources.py','consumer.py','control.py','control_checks.py','driver.py','fresh_rows.py', + 'layout.py','model.py','node.py','packet_engine.py','peel.py','topology.py', + 'vendor/binding.py','vendor/bitstream.py','vendor/cardinality.py','vendor/check_support.py', + 'vendor/children.py','vendor/controller.py','vendor/counts.py','vendor/directory.py', + 'vendor/episode.py','vendor/forms.py','vendor/low_codes.py','vendor/matrices.py', + 'vendor/numeric.py','vendor/oracle.py','vendor/packet.py','vendor/plan.py','vendor/records.py', + 'vendor/residual.py','vendor/routes.py','vendor/selection.py','vendor/sources.py', + 'vendor/stream.py','vendor/stream_runner.py','vendor/trace.py','vendor/words.py','verify.py', +) +SUITES=('source','node','recursion','nested','controls') +EVIDENCE_FILES={ + 'evidence/pr2731-README.md':'46c0c3554608a1096816ad668c755d3b5b7a8c0b', + 'evidence/pr2708-README.md':'2982489cc00a17bd1c7ee1e206e975eda9bcb64d', + 'evidence/pr2688-PROOF.md':'1b9e1ed8793ffdde3c4b115641f0e644a9289923', + 'evidence/pr2688-NOTICE.md':'1b9e1ed8793ffdde3c4b115641f0e644a9289923', +} + + +def need(condition,message): + if not condition:raise ValueError(message) + + +def canonical(value): + # Preserve JSON scalar types; 1.0 and true must not stand in for integer 1. + return json.dumps(json.loads(json.dumps(value)),sort_keys=True,separators=(',',':'),allow_nan=False) + + +def payload(path): + need(path.is_file() and not path.is_symlink(),'regular pinned file: '+str(path)) + return path.read_bytes() + + +def authenticate(sources=None,predecessor=None,manifest=None,here=HERE,root=ROOT,evidence=None): + sources=json.loads((here/'SOURCES.json').read_text()) if sources is None else sources + predecessor=json.loads((here/'PREDECESSOR.json').read_text()) if predecessor is None else predecessor + manifest=json.loads((here/'VERIFY.json').read_text()) if manifest is None else manifest + evidence=json.loads((here/'EVIDENCE.json').read_text()) if evidence is None else evidence + live=[item for item in sources['files'] if item['usage']=='input'] + need(sorted(item['path'] for item in live)==list(LIVE_INPUTS),'exact live source inventory') + need(sorted(manifest['inputs'])==list(LIVE_INPUTS),'exact replay invalidation inventory') + need(predecessor['head']=='a53fdf4bcbe33c6732f0bec1badc8c023380f9d1','exact executable predecessor') + need(sorted(predecessor['files'])==sorted(FROZEN_FILES),'exact predecessor source inventory') + physical=sorted(str(path.relative_to(here/'predecessor')) + for path in (here/'predecessor').rglob('*') if path.is_file() + and '__pycache__' not in path.parts) + need(physical==sorted(FROZEN_FILES),'no omitted or extra predecessor files') + need(sorted(row['path'] for row in evidence['files'])==sorted(EVIDENCE_FILES), + 'exact predecessor proof inventory') + for row in evidence['files']: + need(row['commit']==EVIDENCE_FILES[row['path']],'exact predecessor proof commit') + for name,item,path in [(item['path'],item,root/item['path']) for item in live]+[ + (name,item,here/'predecessor'/name) for name,item in predecessor['files'].items()]+[ + (item['path'],item,here/item['path']) for item in evidence['files']]: + data=payload(path) + need(sha256(data).hexdigest()==item['sha256'],'pinned bytes changed: '+name) + blob=sha1(b'blob '+str(len(data)).encode()+b'\0'+data).hexdigest() + need(blob==item['git_blob'],'pinned Git blob changed: '+name) + return {'live_inputs':len(live),'frozen_files':len(FROZEN_FILES), + 'frozen_proofs':len(EVIDENCE_FILES),'predecessor_head':predecessor['head']} + + +def receipt(result): + return {'full_result_sha256':sha256(canonical(result).encode()).hexdigest(),'result':result} + + +def compare(observed,expected): + need(canonical(observed)==canonical(expected),'retained exact receipt differs') + + +def verifier_controls(): + sources=json.loads((HERE/'SOURCES.json').read_text()) + frozen=json.loads((HERE/'PREDECESSOR.json').read_text()) + manifest=json.loads((HERE/'VERIFY.json').read_text()) + rejected=[] + def reject(label,action): + try:action() + except ValueError:rejected.append(label) + else:raise ValueError('negative control accepted: '+label) + for name in LIVE_INPUTS: + changed=deepcopy(sources) + changed['files']=[row for row in changed['files'] if row['path']!=name] + reject('omitted_source:'+name,lambda:authenticate(sources=changed)) + changed=deepcopy(manifest);changed['inputs'].pop() + reject('omitted_CI_input',lambda:authenticate(manifest=changed)) + changed=deepcopy(frozen);del changed['files']['vendor/controller.py'] + reject('omitted_executable_predecessor',lambda:authenticate(predecessor=changed)) + changed=json.loads((HERE/'EVIDENCE.json').read_text());changed['files'].pop() + reject('omitted_proof_predecessor',lambda:authenticate(evidence=changed)) + changed=deepcopy(sources) + next(row for row in changed['files'] if row['usage']=='input')['sha256']='0'*64 + reject('wrong_live_hash',lambda:authenticate(sources=changed)) + with TemporaryDirectory(prefix='recursive-caller-source-control-') as temporary: + location=Path(temporary) + shutil.copytree(HERE/'predecessor',location/'predecessor',ignore=shutil.ignore_patterns('__pycache__')) + shutil.copytree(HERE/'evidence',location/'evidence') + shutil.copyfile(HERE/'EVIDENCE.json',location/'EVIDENCE.json') + path=location/'predecessor'/'vendor'/'controller.py' + path.write_bytes(path.read_bytes()+b'\n# deliberate changed executable source\n') + reject('changed_executable_bytes',lambda:authenticate(sources,frozen,manifest,location)) + base=receipt({'integer':1,'flag':True}) + for label,value in [('receipt_wrong_type',{'integer':1.0,'flag':True}), + ('receipt_wrong_value',{'integer':2,'flag':True}), + ('receipt_extra_field',{'integer':1,'flag':True,'extra':0})]: + reject(label,lambda:compare(receipt(value),base)) + changed=deepcopy(base);changed['full_result_sha256']='0'*64 + reject('receipt_wrong_digest',lambda:compare(changed,base)) + return {'rejected':rejected,'before_executable_imports':True,'verification_writes_receipts':False} + + +def evaluate(suite): + import bootstrap + if suite=='source': + from catalogue import Catalogue + from check_sources import catalogue_checks,consumer_probes,global_scalar + from check_layout import extents,selected_peel,complete_gapped + from check_headers import sampled_packet + catalogue=Catalogue(3) + return {'selected_sources':catalogue_checks(catalogue), + 'selected_consumers':consumer_probes(catalogue), + 'global_scalar':global_scalar(catalogue),'gapped_extents':extents(), + 'generated_peel':selected_peel(catalogue),'gapped_endpoint':complete_gapped(), + 'sampled_high_packet':sampled_packet()} + if suite=='node': + from check_runtime import complete_node + return complete_node(gap_size=1) + if suite=='recursion': + from check_recursion import run + return run() + if suite=='nested': + from check_nested_model import run + return run() + from check_sign import run + from control_checks import stale_controls,bridge_and_exchange,rejections_and_counts + return {'linear_sign':run(),'stale_state':stale_controls(), + 'bridge_exchange':bridge_and_exchange(),'rejections_counts':rejections_and_counts(), + 'verifier_mutations':verifier_controls()} + + +def main(): + parser=argparse.ArgumentParser(description=__doc__) + parser.add_argument('--suite',required=True,choices=SUITES) + parser.add_argument('--emit-to',type=Path,help='Explicit generation to a NEW file; never overwrite a retained receipt') + args=parser.parse_args() + need(not sys.flags.optimize,'assertion-based independent checkers require optimization disabled') + if args.emit_to is not None:need(not args.emit_to.exists(),'refuse to overwrite an existing receipt') + authentication=authenticate() + observed=receipt(evaluate(args.suite)) + if args.emit_to is not None: + with args.emit_to.open('x') as handle:json.dump(observed,handle,indent=2,sort_keys=True);handle.write('\n') + print('GENERATED_RECURSIVE_CALLER '+args.suite+' '+str(args.emit_to)) + else: + retained=json.loads((HERE/'RESULT.json').read_text()) + need(sorted(retained)==sorted(SUITES),'exact retained suite inventory') + compare(observed,retained[args.suite]) + print('PASS_SELECTED_BIT_RECURSIVE_CALLER '+args.suite+' '+observed['full_result_sha256']) + return authentication + + +if __name__=='__main__':main() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/NOTICE.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/NOTICE.md new file mode 100644 index 0000000000..307c2da733 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/NOTICE.md @@ -0,0 +1,30 @@ +# Attribution + +Jose Manuel (`jmbarrancoml`) wrote the numerical-bank codec, its composition +proof, exact sequential invoice and tests with substantial OpenAI Codex +assistance. Apache-2.0. We claim no independent human or formal-kernel review. + +We retain these source files without byte changes: + +- `vendor/words.py`: Jose Manuel's PR2697, commit + `a53fdf4bcbe33c6732f0bec1badc8c023380f9d1`, originally + `research/selected-bit-node/vendor/words.py`. The retained selected + coefficient/stream lineage includes PR2332/2364/2405/2449/2501/2569, + the PR2234 recursive specification, and the source527/PR589 construction. +- `vendor/parking_machine.py`: ywz65's PR2635, commit + `1662dda699d9ea57b3fb13a23873b087d765149f`, originally + `research/finite-parking-frames/machine.py`. ywz65 supplied the two-tape + finite table, matched-frame proof and exact table invoice with OpenAI + Codex assistance. Its PR2574/2534/2483/2250/2287 lineage retains credit. +- `vendor/pr2753_recursive_call.py`: David Arias's PR2753, commit + `7dba5452a4071a856a0b11cebdcd2d3b6bcd7659`, originally + `research/selected-bit-recursive-caller/recursive_call.py`. We retain it + as reference text only. David Arias supplied the concurrent all-size + logical caller, iterative scheduler and joined logical reserve with + substantial OpenAI Codex assistance. + +The source creators retain their original credit. This contribution does +not claim a new generic stack construction or first logical recursive caller. +The new boundary is the literal bank/slot/word serialization into the existing +parking table, same-slot restoration, fixed physical inventory and complete +sequential-operation invoice. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/PROOF.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/PROOF.md new file mode 100644 index 0000000000..7207ce7dec --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/PROOF.md @@ -0,0 +1,199 @@ +# Physical parking for fixed numerical banks + +We connect the selected BIT Word interface to ywz65's finite two-tape parking +controller. We use one shared parking tape and one packet port through a +well-bracketed sequence of arbitrarily nested calls. We restore parent values +into their original register objects, so suspended aliases remain valid. + +David Arias's concurrent PR2753 supplies the all-size logical caller. In its +`recursive_call.Frame`, he creates separate numerical arenas for each child +and leaves physical bank reuse open. We contribute this numerical interface; +we retain payload and controller serialization as separate obligations. + +## Contract + +Fix two arenas with capacities C_0,C_1 and word widths b_0,b_1. Each capacity +belongs to the fixed machine description. Each slot has one physical tape, +and each arena has one template tape. Throughout the nested run, keep the +widths and capacities fixed. The retained `words.py` gives each live word +b binary cells followed by RIGHT, with LEFT at position zero. Enter with +word and template heads immediately after LEFT. + +Let ell_j=max(1,ceil(log2 C_j)). For a live slot i in bank j, we encode + + [one bank bit][ell_j little-endian slot bits][b_j word bits]. + +The record has s_i=1+ell_j+b_j bits. We omit the numerical RIGHT delimiter; +we use the packet port's `$` terminator and validate it against the destination +template during restoration. The bank bit selects one of two fixed extents. + +The caller may grant a declared subset of live slots to its child. For +example, it can first copy modulus, width and depth into three fresh slots, +then grant those copies. We park the remaining parent slots. The child must +clear its grants and numerical work before restoration. We promise to restore +the parked slots, not values that the caller explicitly transfers to the child. + +The caller issues trusted, well-bracketed PARK/RESTORE operations. We do not +authenticate an arbitrary callee's authority to close an ancestor frame. +We require well-formed words and the retained finite register-allocation +contract. We permit a different free-list order after return; we preserve +live slots, values, object aliases and heads. Allocation histories and meter +counters are observations, not restored data. + +## Construction + +`BankParking.park` checks the empty packet port and issues BEGIN. It visits +both fixed slot inventories in order. For each live ungranted slot, it: + +1. Writes the bank label, slot label and word bits to the packet port. +2. Writes `$` and rewinds the word and port with unit head moves. +3. Executes the retained PUSH table, then erases/releases the source word. + +The port is empty after each PUSH. At return, only the declared grants remain +live in the numerical banks. We allocate no checkpoint tape for an ancestor. + +`restore` first requires empty banks and an empty port. It probes the previous +parking cell and returns the parking head to its top. At a record it executes +POP, decodes the bank and slot, and selects that exact erased slot. It then +initializes the slot through the retained `Arena.zero`, copies the word bits, +and requires `$` exactly when the numerical head reaches RIGHT. It clears +the consumed port, then rewinds both heads. At F it executes END. + +We select the original `arena.words[slot]` object. Allocating a different +object and assigning it the old slot number would not restore aliases. +The finite free-slot map may choose a new order, but a suspended reference +to any live parent Word returns to the same object, tape, value and head. + +## Correctness and nesting + +For one word, serialization preserves each bit in its original order. The +bank and slot labels identify its physical destination. PR2635's PUSH/POP +proof supplies exact packet order and consumed-record erasure. The validated +template extent prevents silent truncation or padding. Erasing the source +after PUSH makes that slot available to the child without discarding its +saved parent value. + +After any prefix of a PARK operation, we have saved exactly the visited +ungranted slots, released those slots, and left the remaining slots unchanged. +Each saved record has a unique bank/slot pair. After the child clears its +banks, reverse POP restores each saved slot once. At F we have restored the +parent's entire parked live set and removed its checkpoint records. + +We induct over a well-bracketed command sequence. BEGIN places the child's +frame above the parent's saved records. Matching restore stops at the child's +F marker, so it neither reads nor writes the older checkpoint below that +frame. After the child returns and clears its own live slots, the parent's +restore has the same premises. This proves arbitrary finite nesting, including +empty frames, unequal bank widths, sparse slot sets and retained child grants. +The finite tests below do not establish this induction by extrapolation. + +The physical inventory is + + C_0 + C_1 numerical slot tapes + + 2 template tapes + 1 parking tape + 1 packet-port tape. + +It is independent of nesting depth. Slot labels, liveness and free-slot +selection range over fixed finite sets and may live in finite control. +The codec branches on finite labels or scanned symbols; it does not decode +word values or use a host depth counter. Simulator coordinates and meters +record execution without selecting its control path. An implementation that +stores its free list on a separate tape must add that tape and its scans. + +## Complete sequential operation invoice + +Count source/target Word operations, codec operations and the retained +parking-table operations. Exclude child computation and the caller's initial +preparation of any granted copies. Let r count parked word records, let +L=sum_i b_i, and let S=sum_i s_i. A word counts again each time a caller parks +it. For d matched frame pairs, the exact tape-operation counts are + + reads = 14S + 10L + 32r + 15d, + writes = 6S + 3L + 8r + 2d, + unit moves = 12S + 10L + 30r + 12d. + +These are counts in the retained sequential read/write/move API, not Python +wall-clock measurements or a count of a fully expanded multi-tape transition +table. Fixed finite-control bookkeeping adds O(C_0+C_1+r) per frame. Thus the +complete operation has O(S+(C_0+C_1)d) cost, with fixed-capacity control. + +We derive the counts from the literal scans. For one b-bit word at its left +boundary, the retained routines have these costs: + +| Routine | Reads | Writes | Unit moves | +| --- | ---: | ---: | ---: | +| Word.erase / Arena.free | 2b+3 | b+1 | 2b+4 | +| Arena.zero into the same erased slot | 4b+5 | b+1 | 4b+6 | + +The zero-initialization row includes both the word and template rewinds. +For one s-bit record, the added scans have these costs: + +| Part | Reads | Writes | Unit moves | +| --- | ---: | ---: | ---: | +| Supply record and erase source | 2s+4b+8 | s+b+2 | 2s+4b+10 | +| Decode, initialize and consume returned record | 2s+6b+9 | s+2b+2 | 2s+6b+10 | +| Retained PUSH plus POP | 10s+14 | 4s+4 | 8s+8 | + +For each frame, BEGIN/END, four empty-port checks and r+1 boundary probes +add r+15 reads, two writes and 2r+12 moves. Summing gives the displayed +formulas. We also check PR2635's separate exact table invoice: + + steps = 5S + 7r + 3d, + reads = 10S + 14r + 6d, + writes = 4S + 4r + 2d, + moves = 8S + 8r + 2d. + +The checker reports an auxiliary action total: the three complete API counts +plus one per fixed-inventory slot test and one per parking-command dispatch. +With C=C_0+C_1, this total equals + + 32S + 23L + 72r + (C+31)d. + +This definition does not silently include unmetered child arithmetic or grant +copy preparation. The caller must charge those operations where it performs +them. Reusing a fixed bank does not make coefficient evaluation free. + +## Space and source binding + +At a completed parking boundary the stack contains one F per open frame and +one R plus s_i bits per stored record. The packet port uses at most +max_i(s_i)+2 cells, including its markers. A conservative bound for the full +numeric slot/template spans is + + (C_0+1)(b_0+2) + (C_1+1)(b_1+2). + +We count these spans even for erased slots. Add the current parking stack +and packet-port span to obtain the component's storage bound. Opaque caller +contents below the granted stack origin remain preserved and separately +owned. We claim no new total caller reserve. + +We retain byte-exact sources in `vendor/`. `words.py` comes from Jose Manuel's +PR2697 at `a53fdf4bcbe33c6732f0bec1badc8c023380f9d1`. +`parking_machine.py` comes from ywz65's PR2635 at +`1662dda699d9ea57b3fb13a23873b087d765149f`. The copied PR2753 +`recursive_call.py`, at `7dba5452a4071a856a0b11cebdcd2d3b6bcd7659`, is a +reference-only application boundary; we never import or replay that caller +in this package. + +At that boundary, a caller can copy modulus/size/depth into fresh slots of the +shared banks, grant those copies, park the other parent words, and build its +child context in the available slots. It must close that context and grants +before RESTORE. Our grant fixture checks this transfer with distinct encoded +extents. Wiring the complete iterative caller to this interface, and +serializing its payload, directory and generator continuation, remain open. +We leave Petalas's arithmetic-scratch and continuation-content audits separate. + +## Verification scope + +The checker authenticates source bytes before imports. It covers all 64 pairs +of three-bit words, sparse and empty inventories, translated parking/port +origins, arbitrary opaque ancestors, 602-bit words, child input grants and +1,501 nested frames. It compares aliases, complete word bytes, heads, live +slots, cleared storage and the exact operation formulas. + +Controls distinguish correct values in the wrong slot from proper restoration; +reject live child work and changed widths/inventories; and expose physical +bit corruption or uncleared checkpoint cells. We retain the trusted-command +and successful-word-format premises. We claim no general interruption rollback, +hostile-code isolation, full fixed-tape caller, new exponent or formal-kernel +verification. Jose Manuel (`jmbarrancoml`) prepared this work with substantial +OpenAI Codex assistance. The source notices and Apache-2.0 license remain in force. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/README.md b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/README.md new file mode 100644 index 0000000000..c96e0d6cec --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/README.md @@ -0,0 +1,82 @@ +# Reuse fixed numerical banks across recursive calls + +I connect the selected BIT numerical registers to a fixed parking tape and +packet port. After a child reuses the banks, I restore the parent's values +into the same register objects and reset their heads. The codec supports +arbitrary finite nesting without allocating a checkpoint tape per ancestor. + +This supplies one physical component left open by David Arias's concurrent +[PR2753](https://github.com/CrocSwap/integer-mult-bounds/pull/2753). He constructs +the all-size logical caller with separate dynamic numerical arenas. I retain +his logical result and contribute the numerical-bank serialization/reuse +boundary. Full caller integration and payload/controller serialization remain +open; I leave the selected exponent unchanged. + +For C numerical slots, the component uses **C+4 physical tapes**, including +two templates, the parking tape and the packet port. I prove an exact +sequential read/write/move invoice, including slot labels, word initialization +and erasure, delimiters, boundary probes and rewinds. See [PROOF.md](PROOF.md). +The caller may pass separately owned input grants in the shared banks, then +must close them before restoring its parent. + +## Reproduce + +Use Python 3.12 and its standard library: + +```sh +python3.12 scripts/research_package.py --package research/selected-bit-register-parking +``` + +The verifier checks source hashes before imports and compares the complete +typed [receipt](RESULT.json). The tests cover: + +- All 64 pairs of three-bit words, including zero and all-one values. +- Sparse slots, empty frames, translated heads, opaque ancestors, 602-bit + words and slot labels wider than their stored words. +- **1,501 nested frames**, 3,750 parked records and exact restoration while + using at most three allocated slots in each bank. +- Modulus/width/depth grants and failures involving slot aliases, child + cleanup, widths, capacities, corrupted bits and uncleared checkpoints. + +For direct replay, run: + +```sh +python3.12 -I -O -B research/selected-bit-register-parking/verify.py +``` + +The `--emit` option prints a new receipt without writing package files. +I distinguish the written +all-depth induction from these finite examples. I claim no independent human +or proof-assistant verification. + +## Sources and coordination + +I reuse ywz65's [PR2635](https://github.com/CrocSwap/integer-mult-bounds/pull/2635) +parking controller and my [PR2697](https://github.com/CrocSwap/integer-mult-bounds/pull/2697) +Word interface without changing their bytes. [SOURCES.json](SOURCES.json) +records exact commits, paths and hashes. I preserve David Arias's PR2753 +Frame source as a reference; this verifier does not execute his full caller. + +I narrowed my concurrent logical-caller investigation after PR2753 appeared. +The [canonical claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18957230) +records that decision and the original scope. Nick Petalas's numerical +scratch and continuation-content audits in [PR2759](https://github.com/CrocSwap/integer-mult-bounds/pull/2759) +and [PR2758](https://github.com/CrocSwap/integer-mult-bounds/pull/2758) remain complementary. Their counts +and the existing payload/directory reserves are not new results of this codec. + +Jose Manuel (`jmbarrancoml`), with substantial OpenAI Codex assistance in the +construction, proof, implementation and checks. Apache-2.0; predecessor +attribution appears in [NOTICE.md](NOTICE.md). + +## Open next questions + +- Can the complete PR2753 caller use the shared banks at its Frame boundary? + Bind its child input grants and context cleanup, then check the actual + internal return. The remaining work is caller integration, not another + generic stack test. +- Can the caller serialize its payload, directories and continuation with + the same fixed-tape discipline? Preserve role aliases and charge the + transfers. This codec only handles numerical banks. +- Can the joined physical ledger fit the intended supplier contract? Combine + actual codec charges with the existing component reserves and outer stock + wrapper. No total reserve or exponent admission follows here. diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/RESULT.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/RESULT.json new file mode 100644 index 0000000000..b2d1889d77 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/RESULT.json @@ -0,0 +1,212 @@ +{ + "result": { + "controls": [ + "grant references an inactive slot", + "callee leaves a live numerical slot", + "unmatched restore at the blank root", + "correct value restored into the wrong slot alias", + "physical parking bit mutation changes parent state", + "parent values return but checkpoint cells remain occupied", + "word template extent changes across a parked frame", + "bank inventory changes across a parked frame" + ], + "finite_table_entries": 490, + "flat": { + "all_three_bit_pairs": 64, + "maximum_observed_actions": 737, + "records": 128 + }, + "granted_arguments": { + "frames": 1, + "observed": { + "actions": 2583, + "moves": 1018, + "reads": 1123, + "writes": 416 + }, + "parking": { + "moves": 410, + "reads": 528, + "steps": 264, + "writes": 206 + }, + "record_bits": 48, + "records": 3, + "upper_bounds": { + "actions": 5344, + "moves": 1744, + "reads": 1744, + "writes": 704 + }, + "word_bits": 34 + }, + "integrity_controls": [ + "pinned source mutation: vendor/words.py", + "pinned source mutation: vendor/parking_machine.py", + "pinned source mutation: vendor/pr2753_recursive_call.py", + "missing source entry", + "duplicate source entry" + ], + "nested": [ + { + "allocated_slots": [ + 0, + 0 + ], + "bill": { + "frames": 1, + "observed": { + "actions": 47, + "moves": 12, + "reads": 15, + "writes": 2 + }, + "parking": { + "moves": 2, + "reads": 6, + "steps": 3, + "writes": 2 + }, + "record_bits": 0, + "records": 0, + "upper_bounds": { + "actions": 320, + "moves": 80, + "reads": 80, + "writes": 72 + }, + "word_bits": 0 + }, + "capacities": [ + 7, + 9 + ], + "depth": 1, + "translated": false, + "word_widths": [ + 9, + 602 + ] + }, + { + "allocated_slots": [ + 3, + 3 + ], + "bill": { + "frames": 17, + "observed": { + "actions": 681539, + "moves": 272404, + "reads": 297335, + "writes": 111414 + }, + "parking": { + "moves": 99554, + "reads": 124662, + "steps": 62331, + "writes": 49794 + }, + "record_bits": 12400, + "records": 40, + "upper_bounds": { + "actions": 1200960, + "moves": 399760, + "reads": 399760, + "writes": 150664 + }, + "word_bits": 12220 + }, + "capacities": [ + 7, + 9 + ], + "depth": 17, + "translated": true, + "word_widths": [ + 9, + 602 + ] + }, + { + "allocated_slots": [ + 3, + 3 + ], + "bill": { + "frames": 1501, + "observed": { + "actions": 2943047, + "moves": 1158012, + "reads": 1278765, + "writes": 471752 + }, + "parking": { + "moves": 468002, + "reads": 605256, + "steps": 302628, + "writes": 235502 + }, + "record_bits": 54375, + "records": 3750, + "upper_bounds": { + "actions": 6180320, + "moves": 2010080, + "reads": 2010080, + "writes": 820572 + }, + "word_bits": 37500 + }, + "capacities": [ + 7, + 9 + ], + "depth": 1501, + "translated": false, + "word_widths": [ + 9, + 11 + ] + } + ], + "wide_slot_labels": { + "bill": { + "frames": 1, + "observed": { + "actions": 1636, + "moves": 410, + "reads": 465, + "writes": 177 + }, + "parking": { + "moves": 210, + "reads": 274, + "steps": 137, + "writes": 106 + }, + "record_bits": 24, + "records": 2, + "upper_bounds": { + "actions": 11872, + "moves": 3176, + "reads": 3176, + "writes": 2640 + }, + "word_bits": 5 + }, + "slot_bits": [ + 10, + 7 + ], + "slots": [ + 512, + 64 + ], + "word_bits": [ + 2, + 3 + ] + } + }, + "sha256": "c6855d4252b0af7debbe2b0050651ec269f0e060a72fd4a678080334a1b3b34b" +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/SOURCES.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/SOURCES.json new file mode 100644 index 0000000000..746393061c --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/SOURCES.json @@ -0,0 +1,49 @@ +{ + "schema_version": 1, + "base_commit": "936fac15b1b1b59dc5285c713a77f9f3c07b2906", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "889b95d936746df124872133ae1e7cc339adcb92", + "sha256": "7d185cd8c2af35988d638d969748ad7b670f902606444dbfc748e4402c340df6" + } + ], + "snapshots": [ + { + "path": "vendor/words.py", + "source_commit": "a53fdf4bcbe33c6732f0bec1badc8c023380f9d1", + "source_path": "research/selected-bit-node/vendor/words.py", + "git_blob": "8d4ba37e2778acb35b34e0719df2caf138fbeb50", + "sha256": "5c37f57708ba3131bdcb03139f9dbc29886bee44569c09cbba51b68f75acd7f9" + }, + { + "path": "vendor/parking_machine.py", + "source_commit": "1662dda699d9ea57b3fb13a23873b087d765149f", + "source_path": "research/finite-parking-frames/machine.py", + "git_blob": "cafd614a3b7bc87b019361fcdf890ed976f26d19", + "sha256": "68134779debfb795468a1aaecbc2b9d321d7d4e451313ce7dc8fa7092561df4c" + }, + { + "path": "vendor/pr2753_recursive_call.py", + "usage": "reference-only; never imported", + "source_commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "source_path": "research/selected-bit-recursive-caller/recursive_call.py", + "git_blob": "6d33224145aa04f7fbaf7b6cda7c9c164311a402", + "sha256": "157deaa5972557893d43494a81151483bdc46373448ec677cb6a738c9b7e6f1e" + } + ], + "application": { + "pr": 2753, + "author": "David Arias (DavidAriasC)", + "commit": "7dba5452a4071a856a0b11cebdcd2d3b6bcd7659", + "path": "research/selected-bit-recursive-caller/recursive_call.py", + "scope": "Physical numerical-bank replacement boundary. Full caller integration remains open." + } +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/TASK.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/TASK.json new file mode 100644 index 0000000000..216dc8f8bc --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/TASK.json @@ -0,0 +1,86 @@ +{ + "schema_version": 1, + "task_id": "centre-path-sharing", + "priority_revision": 5, + "base_commit": "936fac15b1b1b59dc5285c713a77f9f3c07b2906", + "original_card": { + "id": "centre-path-sharing", + "question": "Can the 64-per-call centre path (eight rank-8 COPY/ERASE totals through the private temporary) be shared across calls or shrunk?", + "starting_points": [ + "docs/research/research-family-status.md", + "research/complex-local-word-ceiling/README.md", + "research/split-centres-global/proofs/PR386-BIT-GEOMETRY.txt", + "certificates/selected-result.json" + ], + "methods": [ + "Derive a fully charged favorable relaxation for sharing one centre path across k calls, including restoration, hosting and precision.", + "Prove a lower bound on copied information per call for the selected decoder contract." + ], + "acceptance_gate": "Show the changed centre charge and copy profile per call with every added restoration or hosting cost charged, and its ceiling via ceiling.ceiling(centre=...). A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "first_step": { + "command": [ + "python3", + "-B", + "research/complex-local-word-ceiling/verify.py" + ], + "expected": "PASS_COMPLEX_LOCAL_WORD_CEILING", + "inspect": "Read the selected word's per-call local profile, its packing ceiling and the lever table; run levers.py for the ideal budget of the lever you target.", + "scope": "Positive control and planning budget only; this is not a new construction or full cold replay." + }, + "first_experiment": "Write the per-call centre charge and copy children for sharing across k = 2 calls, charge the sharing overhead, and screen it; stop this route if even the ideal sharing gains under 10%. Ideal budgets: free 2.80x, shared by two 1.90x (levers.py).", + "bottleneck_link": "The centre path consumes 64 of about 99.6 unpaid coordinates per call, i.e. about 64% of the raw deficit.", + "allowed_variations": [ + "One sharing pattern across a fixed number of calls.", + "One reduced copied-total contract for the existing decoder.", + "If the coverage law, template or guard changes, derive an applicable fully charged replacement bound instead of applying the incumbent ceiling outside its scope." + ], + "scope_change_triggers": [ + "Removing copies without a replacement contract for the decoder's copied totals.", + "Continuing a partial cost improvement while leaving the same unpriced consumer, restoration or central-readout obligation unresolved; refresh the family expansion decision first. Local product-retiming evidence has a narrow scope and is not a ban on changed graphs or contracts." + ], + "overlap_terms": [ + "centre path", + "copied totals", + "private temporary", + "shared centre", + "batching" + ] + }, + "scope_status": "changed", + "actual_scope": "Physical two-tape serialization and same-slot restoration of two fixed numerical banks across arbitrary finite nesting; source-bound to PR2697 Word slots and PR2635 parking, with PR2753's Frame as the application boundary.", + "scope_change_reason": "I compared centre covariance with fully charged consumers, then took the explicit recursive-caller handoff. After David Arias published the concurrent logical caller PR2753, I narrowed this contribution to its open physical numerical-bank reuse boundary and preserved my parallel logical draft outside the repository.", + "bottleneck_link": "A complete logical caller still needs physical bank reuse and charged restoration. This codec closes its numerical-bank component while retaining payload/controller integration and total supplier admission.", + "budget_minutes": 120, + "stop_rule": "Publish the quantified bank codec with exact source pins, complete operation accounting and meaningful failure controls; do not describe it as a complete caller or exponent improvement.", + "outcome": "partial", + "evidence": "PROOF.md gives all-depth correctness, fixed physical tape count and exact API invoices. RESULT.json covers complete small words, 1501 nested frames, same-slot aliases, 602-bit words, copied child grants and source/semantic controls.", + "author": "Jose Manuel (jmbarrancoml)", + "ai_assistance": "Substantial OpenAI Codex assistance in mathematics, code, checks and writing. No independent human or proof-assistant verification claimed.", + "discussion": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2319#discussioncomment-18957230", + "freshness": { + "canonical_main": "8e22a9d9f621c72ab5b299061c2be4c7f638fd3c", + "upstream_checked_utc": "2026-10-15T20:56Z", + "overlap_checked_utc": "2026-10-15T20:33:03Z", + "coverage": "705 open PRs, 1393 Discussion/comment/reply records and 1897 local records; complete remote pagination and no warnings. PR2753 directly overlaps the logical caller, so I narrowed to physical numerical-bank parking. Petalas's arithmetic and continuation-content audits remain complementary. Metadata searches do not prove novelty. A targeted 20:55 UTC supplement checked Discussion2319 and new PRs through2767; it found no competing physical numerical-bank codec. PR2753 and PR2635 retain their pinned heads. PR2758/2759 are completed complementary storage audits; the current evaluator-lifetime claim explicitly separates this codec. Canonical-main guidance and the selected record remain unchanged." + }, + "open_questions": [ + { + "question": "Can the complete PR2753 caller use these shared banks at its Frame boundary?", + "why_it_matters": "The codec closes numerical serialization, but the complete caller still creates separate dynamic arenas.", + "first_step": "Bind copied modulus/width/depth grants and child context cleanup to one actual internal return.", + "blocked_by": "Source-bound complete caller integration." + }, + { + "question": "Can the caller serialize its payload, directories and continuation on fixed tapes?", + "why_it_matters": "Numerical bank reuse alone does not establish a fixed-tape supplier.", + "first_step": "Assign finite physical role handles, preserve aliases and price controller/record transfers at the same suspension point.", + "blocked_by": "The remaining physical caller refinement." + }, + { + "question": "Can the joined physical ledger meet the intended supplier contract?", + "why_it_matters": "Component space bounds and exact codec charges do not imply total numerical reserve or exponent admission.", + "first_step": "Combine actual codec charges with the current payload/directory/count results and outer stock wrapper.", + "blocked_by": "Full caller integration and transfer obligations." + } + ] +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/VERIFY.json b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/VERIFY.json new file mode 100644 index 0000000000..6537be0574 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/VERIFY.json @@ -0,0 +1,30 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Authenticate source snapshots, check complete word/slot/alias restoration, arbitrary-depth model instances, exact full API invoices and semantic/integrity controls." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Repeat the entire typed receipt and rejection controls with Python assertions disabled." + } + ] +} diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/checks.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/checks.py new file mode 100644 index 0000000000..46630a7648 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/checks.py @@ -0,0 +1,317 @@ +"""Independent endpoint, nesting and charge observations for the bank codec.""" +from itertools import product +from copy import deepcopy +from pathlib import Path +from unittest.mock import patch +import json + +from codec import BankParking +from parking_machine import Machine, certify, TABLE +from words import Arena, BLANK, LEFT, RIGHT, need + + +def word_bytes(arena): + return {slot: (arena.words[slot], bytes(arena.words[slot].cells), arena.words[slot].head) + for slot in arena.live} + + +def check_words(arena, expected): + need(arena.live == set(expected), "exact parent live-slot inventory") + for slot, (identity, data, head) in expected.items(): + word = arena.words[slot] + need(word is identity and bytes(word.cells) == data and word.head == head == 1, + "exact parent alias, word bits and head") + need(arena.template.head == 1, "restored numerical template head") + for word in arena.words: + if word.slot not in arena.live: + need(word.head == 1 and word.cells[0] == LEFT and + all(bit == BLANK for bit in word.cells[1:]), "erased inactive physical word slot") + + +def observation(codec): + return {"parking": dict(codec.machine.counts), "codec": dict(codec.codec_counts), + "words": [{k: getattr(arena.meter, k) for k in ("reads", "writes", "moves")} + for arena in codec.arenas]} + + +def difference(after, before): + out = {"parking": {}, "codec": {}, "words": []} + for kind in ("parking", "codec"): + out[kind] = {key: after[kind][key]-before[kind][key] for key in after[kind]} + for a, b in zip(after["words"], before["words"]): + out["words"].append({key: a[key]-b[key] for key in a}) + return out + + +def combine(parts): + keys = ("reads", "writes", "moves") + totals = {key: 0 for key in keys} + parking = {key: 0 for key in ("steps", *keys)} + finite = 0 + for part in parts: + for key in keys: + totals[key] += part["parking"][key]+part["codec"][key]+sum(row[key] for row in part["words"]) + for key in parking: + parking[key] += part["parking"][key] + finite += part["codec"]["slot_tests"]+part["codec"]["commands"] + totals["actions"] = sum(totals.values())+finite + return totals, parking + + +def measure(codec, action, parts): + before = observation(codec) + action() + parts.append(difference(observation(codec), before)) + + +def verify_bill(codec, parts, total_bits, word_bits, records, frames): + totals, parking = combine(parts) + expected = {"steps": 5*total_bits+7*records+3*frames, + "reads": 10*total_bits+14*records+6*frames, + "writes": 4*total_bits+4*records+2*frames, + "moves": 8*total_bits+8*records+2*frames} + need(parking == expected, "exact predecessor parking charge") + capacity = sum(codec.capacities) + exact = {"reads": 14*total_bits+10*word_bits+32*records+15*frames, + "writes": 6*total_bits+3*word_bits+8*records+2*frames, + "moves": 12*total_bits+10*word_bits+30*records+12*frames, + "actions": 32*total_bits+23*word_bits+72*records+(capacity+31)*frames} + need(totals == exact, "exact complete sequential API invoice") + bounds = {"reads": 32*total_bits+40*records+(4*capacity+16)*frames, + "writes": 12*total_bits+16*records+(4*capacity+8)*frames, + "moves": 32*total_bits+40*records+(4*capacity+16)*frames, + "actions": 96*total_bits+128*records+(16*capacity+64)*frames} + need(all(totals[key] <= bounds[key] for key in totals), "complete codec, Word and table charge") + return {"record_bits": total_bits, "word_bits": word_bits, "records": records, "frames": frames, + "observed": totals, "upper_bounds": bounds, "parking": parking} + + +def clear_banks(arenas): + for arena in arenas: + for slot in tuple(arena.live): + arena.free(arena.words[slot]) + + +def flat_cases(): + cases, total_records = 0, 0 + maximum_actions = 0 + for a, b in product(range(8), range(8)): + arenas = (Arena(3, 3), Arena(3, 5)) + left, right = arenas[0].input(a), arenas[1].input(b) + state = tuple(word_bytes(arena) for arena in arenas) + codec = BankParking(*arenas) + parts = [] + measure(codec, codec.park, parts) + need(all(not arena.live for arena in arenas), "parent banks released") + # Reuse the same objects with different values while the parent waits. + x, y = arenas[0].input(a ^ 7), arenas[1].input(b ^ 3) + need(x is left and y is right, "child reuses the original physical slots") + clear_banks(arenas) + measure(codec, codec.restore, parts) + for arena, expected in zip(arenas, state): + check_words(arena, expected) + need(codec.machine.tapes == [{}, {0: "^"}] and codec.machine.heads == [0, 1], + "complete parking and port cleanup") + bill = verify_bill(codec, parts, (1+2+3)+(1+3+3), 6, 2, 1) + maximum_actions = max(maximum_actions, bill["observed"]["actions"]) + clear_banks(arenas) + cases += 1 + total_records += 2 + return {"all_three_bit_pairs": cases, "records": total_records, + "maximum_observed_actions": maximum_actions} + + +def nested_case(depth, widths=(9, 602), capacities=(7, 9), translated=False): + arenas = tuple(Arena(width, capacity) for width, capacity in zip(widths, capacities)) + machine = Machine(parking={-7: "1", -6: "R", -5: "0"}, + packet={30: "^"}, heads=(11, 31)) if translated else Machine(packet={0: "^"}, heads=(0, 1)) + initial_tapes, initial_heads = deepcopy(machine.tapes), list(machine.heads) + codec = BankParking(*arenas, machine=machine) + expected_stack, parts = [], [] # Checker history, never read by the codec. + total_bits = word_bits = records = 0 + for level in range(depth): + for bank, arena in enumerate(arenas): + # Empty frames, different inventories, holes and high-valued words. + for index in range(level % 4): + arena.input((1 << (widths[bank]-2)) + (level+index) % 64) + if level % 4 == 3: + arena.free(arena.words[1]) + state = tuple(word_bytes(arena) for arena in arenas) + expected_stack.append(state) + for bank, values in enumerate(state): + records += len(values) + total_bits += len(values)*(1+codec.slot_bits[bank]+widths[bank]) + word_bits += len(values)*widths[bank] + measure(codec, codec.park, parts) + need(all(not arena.live for arena in arenas), "numerical banks empty after each suspension") + for state in reversed(expected_stack): + measure(codec, codec.restore, parts) + for arena, values in zip(arenas, state): + check_words(arena, values) + clear_banks(arenas) # The returned child closes before its parent resumes. + need(machine.tapes == initial_tapes and machine.heads == initial_heads, + "nested opaque ancestors and translated heads preserved") + bill = verify_bill(codec, parts, total_bits, word_bits, records, depth) + need(all(len(arena.words) <= capacity for arena, capacity in zip(arenas, capacities)), + "depth does not enlarge the physical bank inventory") + return {"depth": depth, "word_widths": widths, "capacities": capacities, + "allocated_slots": [len(arena.words) for arena in arenas], "translated": translated, "bill": bill} + + +def granted_arguments(): + arenas = (Arena(10, 8), Arena(12, 10)) + modulus, size, depth = arenas[0].input(729), arenas[1].input(256), arenas[1].input(3) + parent = tuple(word_bytes(arena) for arena in arenas) + # These copies model the modulus/size/depth grants at PR2753's Frame site. + child_modulus = arenas[0].copy(modulus) + child_size, child_depth = arenas[1].copy(size), arenas[1].copy(depth) + granted = ({child_modulus.slot}, {child_size.slot, child_depth.slot}) + codec = BankParking(*arenas) + parts = [] + measure(codec, lambda: codec.park(granted), parts) + need((child_modulus.inspect(), child_size.inspect(), child_depth.inspect()) == (729, 256, 3), + "separate child input grants survive parent suspension") + need(arenas[0].live == granted[0] and arenas[1].live == granted[1], "only granted child inputs remain") + clear_banks(arenas) + measure(codec, codec.restore, parts) + for arena, state in zip(arenas, parent): + check_words(arena, state) + bill = verify_bill(codec, parts, (1+3+10)+2*(1+4+12), 34, 3, 1) + clear_banks(arenas) + return bill + + +def wide_slot_labels(): + arenas = (Arena(2, 513), Arena(3, 65)) + for arena, value in zip(arenas, (3, 5)): + for _ in range(arena.capacity): + arena.input(value) + for word in arena.words[:-1]: + arena.free(word) + parent = tuple(word_bytes(arena) for arena in arenas) + codec = BankParking(*arenas) + parts = [] + measure(codec, codec.park, parts) + measure(codec, codec.restore, parts) + for arena, expected in zip(arenas, parent): + check_words(arena, expected) + bill = verify_bill(codec, parts, (1+10+2)+(1+7+3), 5, 2, 1) + clear_banks(arenas) + return {"slots": [512, 64], "slot_bits": codec.slot_bits, + "word_bits": [2, 3], "bill": bill} + + +def rejected(function, message): + try: + function() + except (ValueError, KeyError): + return message + raise ValueError("missing failure control: " + message) + + +def controls(): + arenas = (Arena(5, 4), Arena(7, 4)) + codec = BankParking(*arenas) + result = [rejected(lambda: codec.park(({0}, set())), "grant references an inactive slot")] + word = arenas[0].input(19) + original = word_bytes(arenas[0]) + codec.park() + leak = arenas[0].input(3) + result.append(rejected(codec.restore, "callee leaves a live numerical slot")) + arenas[0].free(leak) + codec.restore() + check_words(arenas[0], original) + clear_banks(arenas) + result.append(rejected(codec.restore, "unmatched restore at the blank root")) + + local = (Arena(5, 4), Arena(7, 4)) + local[0].input(17) + spare = local[0].input(3) + local[0].free(spare) + state = word_bytes(local[0]) + redirected = BankParking(*local) + redirected.park() + redirected.machine.tapes[0][3] = "1" # Slot0 becomes valid, erased slot1. + def wrong_slot(): + redirected.restore() + need(sorted(word.inspect() for word in local[0].words if word.slot in local[0].live) == [17], + "weak value-multiset check still passes") + check_words(local[0], state) + result.append(rejected(wrong_slot, "correct value restored into the wrong slot alias")) + + # Inject a table fault: POP returns each parked one bit as zero. + for source_value in (31,): + local = (Arena(5, 4), Arena(7, 4)) + local[0].input(source_value) + state = word_bytes(local[0]) + table = dict(TABLE) + nxt, _writes, moves = table["pop_copy", "1", "_"] + table["pop_copy", "1", "_"] = (nxt, ("_", "0"), moves) + changed = BankParking(*local, machine=Machine(packet={0: "^"}, heads=(0, 1), table=table)) + changed.park() + def wrong_restore(): + changed.restore() + check_words(local[0], state) + result.append(rejected(wrong_restore, "physical parking bit mutation changes parent state")) + + local = (Arena(5, 4), Arena(7, 4)) + local[0].input(17) + table = dict(TABLE) + for bit in ("0", "1"): + nxt, _writes, moves = table["pop_copy", bit, "_"] + table["pop_copy", bit, "_"] = (nxt, (None, bit), moves) + uncleared = BankParking(*local, machine=Machine(packet={0: "^"}, heads=(0, 1), table=table)) + uncleared.park() + def lost_clear(): + uncleared.restore() + need(uncleared.machine.tapes == [{}, {0: "^"}], "erase the consumed physical checkpoint") + result.append(rejected(lost_clear, "parent values return but checkpoint cells remain occupied")) + + local = (Arena(5, 4), Arena(7, 4)) + saved_word = local[0].input(17) + changed = BankParking(*local) + changed.park() + # A changed template extent must not silently truncate or pad a word. + local[0].template.cells[-2] = RIGHT + result.append(rejected(changed.restore, "word template extent changes across a parked frame")) + need(saved_word.slot == 0, "control retains its original role identity") + local = (Arena(5, 4), Arena(7, 4)) + fixed = BankParking(*local) + fixed.park() + local[0].capacity = 5 + result.append(rejected(fixed.restore, "bank inventory changes across a parked frame")) + return result + + +def run(): + return {"finite_table_entries": certify(TABLE), "flat": flat_cases(), + "nested": [nested_case(1), nested_case(17, translated=True), nested_case(1501, widths=(9, 11))], + "granted_arguments": granted_arguments(), "wide_slot_labels": wide_slot_labels(), + "controls": controls(), + "integrity_controls": integrity_controls()} + + +def integrity_controls(): + import verify + originals = Path.read_bytes, Path.read_text + manifest = json.loads((verify.HERE / "SOURCES.json").read_text()) + result = [] + for entry in manifest["snapshots"]: + target = verify.HERE / entry["path"] + def changed_bytes(path, _target=target): + data = originals[0](path) + return data+b"\n" if path == _target else data + with patch.object(Path, "read_bytes", changed_bytes): + result.append(rejected(verify.authenticate, "pinned source mutation: " + entry["path"])) + target = verify.HERE / "SOURCES.json" + for duplicate in (False, True): + changed = deepcopy(manifest) + if duplicate: + changed["snapshots"].append(changed["snapshots"][0]) + else: + changed["snapshots"].pop() + def changed_text(path, *args, _changed=changed, **kwargs): + return json.dumps(_changed) if path == target else originals[1](path, *args, **kwargs) + with patch.object(Path, "read_text", changed_text): + result.append(rejected(verify.authenticate, "duplicate source entry" if duplicate else "missing source entry")) + return result diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/codec.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/codec.py new file mode 100644 index 0000000000..9cd54d9417 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/codec.py @@ -0,0 +1,151 @@ +"""Two fixed tapes park and restore two finite numerical register banks. + +Word values and parking depth stay on tapes. Bank/slot labels and the live +maps range over fixed finite inventories. Counters below are observations. +""" +from parking_machine import HALTS, Machine +from words import LEFT, ONE, RIGHT, ZERO, need + + +class BankParking: + def __init__(self, residue_arena, index_arena, machine=None): + self.arenas = (residue_arena, index_arena) + need(residue_arena is not index_arena, "two distinct fixed numerical banks") + self.capacities = tuple(arena.capacity for arena in self.arenas) + self.slot_bits = tuple(max(1, (capacity-1).bit_length()) for capacity in self.capacities) + self.machine = Machine(packet={0: "^"}, heads=(0, 1)) if machine is None else machine + self.codec_counts = dict(reads=0, writes=0, moves=0, slot_tests=0, commands=0) + + def _read(self, tape): + self.codec_counts["reads"] += 1 + return self.machine.tapes[tape].get(self.machine.heads[tape], "_") + + def _write(self, tape, symbol): + self.codec_counts["writes"] += 1 + position = self.machine.heads[tape] + if symbol == "_": + self.machine.tapes[tape].pop(position, None) + else: + self.machine.tapes[tape][position] = symbol + + def _move(self, tape, direction): + need(direction in (-1, 1), "unit codec head movement") + self.codec_counts["moves"] += 1 + self.machine.heads[tape] += direction + + def _command(self, command): + need(self.machine.state == "done", "parking controller is at a completed boundary") + self.codec_counts["commands"] += 1 + self.machine.state = command + while self.machine.state not in HALTS: + self.machine.step() + need(self.machine.state == "done", "matched parking command completes") + + def _empty_port(self): + need(self._read(1) == "_", "empty packet port before bank operation") + self._move(1, -1) + try: + need(self._read(1) == "^", "packet port starts after its left marker") + finally: + self._move(1, 1) + + def _put_bit(self, bit): + need(bit in (ZERO, ONE) and self._read(1) == "_", "append a bit to an empty port cell") + self._write(1, "1" if bit else "0") + self._move(1, 1) + + def _take_bit(self): + symbol = self._read(1) + need(symbol in ("0", "1"), "complete binary register record") + self._write(1, "_") + self._move(1, 1) + return int(symbol == "1") + + def _rewind_port(self): + self._move(1, -1) + while self._read(1) != "^": + self._move(1, -1) + self._move(1, 1) + + def _supply(self, bank, slot, word): + self._put_bit(bank) + for bit in range(self.slot_bits[bank]): + self._put_bit((slot >> bit) & 1) + word.rewind() + while True: + bit = word.read() + if bit == RIGHT: + break + need(bit in (ZERO, ONE), "live numerical word has a complete binary extent") + self._put_bit(bit) + word.step(1) + word.rewind() + need(self._read(1) == "_", "empty packet terminator cell") + self._write(1, "$") + self._rewind_port() + + def park(self, keep=(frozenset(), frozenset())): + """Park all parent slots except separately owned child input grants. + + A caller can copy modulus/width/depth into fresh slots and grant those + copies to the child. It must close the grants before restore(). + """ + need(len(keep) == 2 and all(arena.capacity == capacity + for arena, capacity in zip(self.arenas, self.capacities)), "fixed bank inventory") + for bank, arena in enumerate(self.arenas): + need(all(type(slot) is int and slot in arena.live for slot in keep[bank]), + "child grants are live fixed slot labels") + self._empty_port() + self._command("begin") + for bank, arena in enumerate(self.arenas): + for slot in range(self.capacities[bank]): + self.codec_counts["slot_tests"] += 1 + if slot in arena.live and slot not in keep[bank]: + word = arena.words[slot] + need(word.slot == slot and word.arena is arena, "stable physical numerical role") + self._supply(bank, slot, word) + self._command("push") + arena.free(word) + need(arena.live == set(keep[bank]), "only declared child grants remain in the bank") + self._empty_port() + + def _restore_word(self): + bank = self._take_bit() + slot = 0 + for bit in range(self.slot_bits[bank]): + slot |= self._take_bit() << bit + arena = self.arenas[bank] + need(slot < self.capacities[bank] and slot < len(arena.words) and + slot not in arena.live and slot in arena.available, "original parent slot is free") + # The allocator's finite free map may change order. The original + # Word object/slot must survive; relabelling another object is invalid. + arena.available.remove(slot) + arena.available.append(slot) + word = arena.zero() + need(word is arena.words[slot] and word.slot == slot, "restore the original slot object") + while word.read() != RIGHT: + word.write(self._take_bit()) + word.step(1) + need(self._read(1) == "$", "stored numerical word matches the fixed template extent") + self._write(1, "_") + self._rewind_port() + word.rewind() + + def restore(self): + """Restore the latest owned frame in a well-bracketed command stream.""" + need(all(arena.capacity == capacity for arena, capacity in zip(self.arenas, self.capacities)), + "restore uses the same fixed numerical bank inventory") + need(all(not arena.live for arena in self.arenas), + "child clears its grants and numerical work before parent restoration") + self._empty_port() + while True: + self._move(0, -1) + symbol = self._read(0) + self._move(0, 1) + if symbol == "F": + self._command("end") + self._empty_port() + return + need(symbol in ("0", "1", "R"), "owned frame or matched register record") + self._command("pop") + self._restore_word() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/vendor/parking_machine.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/vendor/parking_machine.py new file mode 100644 index 0000000000..cafd614a3b --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/vendor/parking_machine.py @@ -0,0 +1,108 @@ +"""Two-tape parking controller. Apache-2.0; ywz65 with OpenAI Codex. + +Only (finite state, two scanned symbols) selects a transition. Coordinates, +step limits and counters belong to the simulator, not the controller. +""" +from itertools import product + +ALPHABET = tuple('_01^$FR') +STATES = ('begin', 'end', 'end_check', 'push', 'push_copy', 'push_rewind', + 'pop', 'pop_measure', 'pop_return', 'pop_copy') +HALTS = ('done', 'reject') + +def transition_table(): + table = {(s, a, b): ('reject', (None, None), (0, 0)) + for s, a, b in product(STATES, ALPHABET, ALPHABET)} + def put(s, a, b, nxt, writes=(None, None), moves=(0, 0)): + table[s, a, b] = nxt, writes, moves + for b in ALPHABET: + put('begin', '_', b, 'done', ('F', None), (1, 0)) + put('end', '_', b, 'end_check', moves=(-1, 0)) + for a in ALPHABET: + put('end_check', a, b, 'reject', moves=(1, 0)) + put('end_check', 'F', b, 'done', ('_', None)) + for b in '01$': + put('push', '_', b, 'push_copy', ('R', None), (1, 0)) + for b in '01': + put('push_copy', '_', b, 'push_copy', (b, '_'), (1, 1)) + put('push_copy', '_', '$', 'push_rewind', (None, '_'), (0, -1)) + put('push_rewind', '_', '_', 'push_rewind', moves=(0, -1)) + put('push_rewind', '_', '^', 'done', moves=(0, 1)) + put('pop', '_', '_', 'pop_measure', moves=(-1, 0)) + for a in '01': + put('pop_measure', a, '_', 'pop_measure', moves=(-1, 1)) + put('pop_return', a, '_', 'pop_return', moves=(1, 0)) + put('pop_copy', a, '_', 'pop_copy', ('_', a), (-1, -1)) + put('pop_measure', 'R', '_', 'pop_return', moves=(1, 0)) + put('pop_measure', 'F', '_', 'reject', moves=(1, 0)) + put('pop_return', '_', '_', 'pop_copy', (None, '$'), (-1, -1)) + put('pop_copy', 'R', '^', 'done', ('_', None), (0, 1)) + return table + +TABLE = transition_table() + +def need(ok, message): + if not ok: + raise ValueError(message) + +def certify(table): + need(set(table) == set(product(STATES, ALPHABET, ALPHABET)), 'complete finite table') + for key, (nxt, writes, moves) in table.items(): + need(nxt in STATES + HALTS, 'finite next state') + need(len(writes) == len(moves) == 2, 'exactly two tapes') + need(all(x is None or x in ALPHABET for x in writes), 'finite writes') + need(all(type(x) is int and x in (-1, 0, 1) for x in moves), 'unit head moves') + return len(table) + +class Machine: + def __init__(self, parking=None, packet=None, heads=(0, 0), table=None): + self.tapes = [dict(parking or {}), dict(packet or {})] + self.heads = list(heads) + self.table = TABLE if table is None else table + self.state = 'done' + self.counts = dict(steps=0, reads=0, writes=0, moves=0) + self.visited = [set(), set()] + self.transitions = set() + + def step(self): + pair = tuple(t.get(h, '_') for t, h in zip(self.tapes, self.heads)) + key = (self.state, *pair) + nxt, writes, moves = self.table[key] + self.transitions.add(key) + self.counts['steps'] += 1 + self.counts['reads'] += 2 + for k in (0, 1): + h = self.heads[k] + self.visited[k].add(h) + if writes[k] is not None: + self.counts['writes'] += 1 + if writes[k] == '_': + self.tapes[k].pop(h, None) + else: + self.tapes[k][h] = writes[k] + self.heads[k] += moves[k] + self.counts['moves'] += abs(moves[k]) + self.state = nxt + + def run(self, entry, limit=1000000): + need(entry in ('begin', 'end', 'push', 'pop'), 'public entry') + before = dict(self.counts) + self.state = entry + for _ in range(limit): + self.step() + if self.state in HALTS: + return {k: self.counts[k] - before[k] for k in before} + raise ValueError('test execution budget; not a controller counter') + +def tariff(operation, n=0): + if operation == 'begin': + steps, writes, moves = 1, 1, 1 + elif operation == 'end': + steps, writes, moves = 2, 1, 1 + elif operation == 'push': + steps, writes, moves = 2*n+3, 2*n+2, 3*n+3 + elif operation == 'pop': + steps, writes, moves = 3*n+4, 2*n+2, 5*n+5 + else: + raise ValueError(operation) + return dict(steps=steps, reads=2*steps, writes=writes, moves=moves) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/vendor/pr2753_recursive_call.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/vendor/pr2753_recursive_call.py new file mode 100644 index 0000000000..6d33224145 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/vendor/pr2753_recursive_call.py @@ -0,0 +1,110 @@ +"""Complete generated child on one packet, with separately charged frame work. + +The parent's frozen fields are the child's old directory. The unused U +coordinate alone supplies fresh rows; address spectators are never borrowed. +""" +from cardinal_counts import Count +from children import extend +from controller import Callback +from directory import Context, append_tape +from packet import read_prefix +from plan import Request +from records import Fields, Program +from words import Arena, RIGHT, Ring, Unsigned, need + +REGISTER_CAPACITY=1 << 24 + + +def copy_word(source,arena): + """Copy an encoded value to a separate frame bank without decoding it.""" + out=arena.zero() + source.rewind() + try: + while source.read()!=RIGHT: + need(out.read()!=RIGHT,"equal frame word extents") + out.write(source.read());source.step(1);out.step(1) + need(out.read()==RIGHT,"complete frame word copy") + out.rewind();return out + except ValueError: + arena.free(out);raise + finally:source.rewind() + + +class Frame: + def __init__(self,parent,program,event): + # bits describes the existing physical word template, not a decoded + # width, residue or address. Both frames have identical templates. + self.arena=Arena(parent.context.arena.bits,REGISTER_CAPACITY) + self.indices=Arena(parent.indices.bits,REGISTER_CAPACITY) + self.modulus=self.ring=self.context=self.program=self.size=self.depth=self.node=None + try: + self.modulus=copy_word(parent.context.ring.modulus,self.arena) + self.ring=Ring(self.modulus) + self.context=Context(self.ring,parent.context.codes) + self.program=Program(self.indices,self.arena,program.code_bits) + append_tape(program.tape,self.program.tape);self.program.tape.rewind() + self.size=copy_word(event.width,self.indices) + self.depth=copy_word(event.depth,self.indices) + from node import SelectedNode + self.node=SelectedNode(self.context,self.indices,self.program,self.size,self.depth, + parent.specifications.catalogue,parent.specifications) + except BaseException: + # The caller cannot close a constructor that never returned. + # These are fresh, separate banks, so every remaining word belongs + # to this failed frame, including partial child initialization. + if self.program is not None:self.program.tape.clear() + if self.context is not None:self.context.close() + if self.ring is not None:self.ring.close() + self.indices.rollback(frozenset()) + self.arena.rollback(frozenset()) + raise + + def close(self): + self.program.tape.clear() + self.indices.free_many(self.size,self.depth) + self.context.close();self.ring.close();self.arena.free(self.modulus) + need(not self.indices.live and not self.arena.live,"recursive frame numerical restoration") + + +def child_call(parent,source,event,layout,directory,prefixes,fields,stock,before): + need(stock is not None and before is not None,"independent child row-stock and spectators") + context,indices=parent.context,parent.indices + need(event.parent_identity is parent.program and event.source_code==layout.geometry.source_code, + "recursive call belongs to the frozen parent") + raw=Unsigned(indices) + need(raw.compare(event.width,parent.parent_size)<0,"strict recursive contraction") + extents=layout.child_extents(event.first,event.second,event.width,before=before) + extended=frame=callback=result=None + returned=False + first=None + try: + directory.rewind();first=read_prefix(directory,fields);directory.rewind() + prefix=Fields(indices,context.arena,context.codes.bits);prefix.tape=first + callback=Callback(context.ring,indices,parent.program,prefix,parent.specifications, + event.source_code,allow_fallback=True) + zero=indices.zero() + try: + request=Request("child",zero,child_kind=event.child_kind,field=event.field, + reverse=event.reverse,half=event.half) + extended=extend(callback,request) + finally:indices.free(zero) + callback.close();callback=None + # Descriptor depends only on ancestor program and the finite branch; + # the representative high prefix is not used to pick children. + frame=Frame(parent,extended,event) + extended.tape.clear();extended=None + first.clear();first=None + from scheduler import Invocation + result=yield Invocation(frame.node.run_generator(source,directory,prefixes,stock,*extents)) + need(source.head==result.head==directory.head==parent.program.tape.head==1, + "completed recursive return restores caller heads") + returned=True + return result + finally: + if result is not None and result is not source and not returned:result.clear() + if callback is not None:callback.abort() + if frame is not None:frame.close() + if extended is not None:extended.tape.clear() + if first is not None:first.clear() + for extent in extents:extent.close() + directory.rewind();source.rewind();parent.program.tape.rewind() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/vendor/words.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/vendor/words.py new file mode 100644 index 0000000000..8d4ba37e27 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/vendor/words.py @@ -0,0 +1,415 @@ +"""Binary word tapes; unbounded numerical values stay in tape cells. + +Only zero/one carry states and fixed register/operation tags enter Python +control. Fixture loading/inspection methods are outside measured execution. +The arena bounds the tape inventory by a compile-time register capacity. +""" +ZERO, ONE, LEFT, RIGHT, BLANK = range(5) + + +def need(test, message): + if not test: + raise ValueError(message) + + +class Meter: + __slots__ = ("reads", "writes", "moves", "peak_live", "allocations") + + def __init__(self): + self.reads = self.writes = self.moves = self.peak_live = self.allocations = 0 + + def record(self): + return {name: getattr(self, name) for name in self.__slots__} + + +class Word: + __slots__ = ("arena", "slot", "cells", "head") + + def __init__(self, arena, slot): + self.arena, self.slot = arena, slot + self.cells = bytearray([LEFT] + [BLANK]*(arena.bits+1)) + self.head = 1 + + def read(self): + self.arena.meter.reads += 1 + return self.cells[self.head] + + def write(self, symbol): + need(symbol in (ZERO, ONE, RIGHT, BLANK), "word tape alphabet") + self.arena.meter.writes += 1 + self.cells[self.head] = symbol + + def step(self, direction): + need(direction in (-1, 1), "unit word-head movement") + self.head += direction + need(0 <= self.head < len(self.cells), "local word boundary") + self.arena.meter.moves += 1 + + def rewind(self): + self.step(-1) + while self.read() != LEFT: + self.step(-1) + self.step(1) + + def msb(self): + self.rewind() + while self.read() != RIGHT: + self.step(1) + self.step(-1) + + def zero(self): + self.rewind() + nonzero = False + while True: + bit = self.read() + if bit == RIGHT: + break + need(bit in (ZERO, ONE), "complete binary word") + nonzero = nonzero or bit == ONE + self.step(1) + self.rewind() + return not nonzero + + def erase(self): + self.rewind() + while self.read() != RIGHT: + self.write(BLANK) + self.step(1) + self.write(BLANK) + self.rewind() + + def inspect(self): + """Checker-only decoding; arithmetic code must not call this.""" + need(self.head == 1 and self.cells[-1] == RIGHT, "inspect a restored word") + return sum(bit << i for i, bit in enumerate(self.cells[1:-1])) + + +class Arena: + def __init__(self, bits, capacity=65536): + need(bits >= 2 and capacity > 0, "fixed word context") + self.bits, self.capacity = bits, capacity + self.meter = Meter() + self.words, self.available, self.live = [], [], set() + self.template = Word(self, -1) + self.template.cells[1:-1] = bytes([ZERO])*bits + self.template.cells[-1] = RIGHT + + def zero(self): + if self.available: + slot = self.available.pop() + out = self.words[slot] + else: + slot = len(self.words) + need(slot < self.capacity, "fixed register inventory") + out = Word(self, slot) + self.words.append(out) + need(slot not in self.live, "fresh numerical register") + self.live.add(slot) + self.meter.allocations += 1 + self.meter.peak_live = max(self.meter.peak_live, len(self.live)) + source = self.template + source.rewind() + while source.read() != RIGHT: + need(out.read() == BLANK, "erased register before reuse") + out.write(ZERO) + out.step(1) + source.step(1) + need(out.read() == BLANK, "erased right delimiter cell") + out.write(RIGHT) + out.rewind() + source.rewind() + return out + + def literal(self, value): + """Compile-time literal only; never decode a runtime word here.""" + need(isinstance(value, int) and value >= 0, "unsigned literal") + out = self.zero() + for bit in tuple((value >> i) & 1 for i in range(value.bit_length())): + need(out.read() != RIGHT, "literal fits the fixed word") + out.write(bit) + out.step(1) + out.rewind() + return out + + def input(self, value): + """Fixture-only loading of an encoded input word.""" + return self.literal(value) + + def copy(self, source): + need(source.arena is self, "one word extent") + out = self.zero() + source.rewind() + while source.read() != RIGHT: + out.write(source.read()) + source.step(1) + out.step(1) + out.rewind() + source.rewind() + return out + + def free(self, word): + need(word.arena is self and word.slot in self.live, "owned numerical register") + word.erase() + self.live.remove(word.slot) + self.available.append(word.slot) + + def free_many(self, *words): + for word in words: + self.free(word) + + def rollback(self, protected): + """Erase owned temporary roles on a rejecting path; capacity is fixed.""" + for slot in tuple(self.live): + if slot not in protected: + self.free(self.words[slot]) + for slot in protected: + self.words[slot].rewind() + + +class Unsigned: + def __init__(self, arena): + self.arena = arena + + def compare(self, a, b): + need(a.arena is b.arena is self.arena, "comparison word context") + if a is b: + return 0 + a.rewind() + b.rewind() + state = 0 + while a.read() != RIGHT: + x, y = a.read(), b.read() + need(x in (ZERO, ONE) and y in (ZERO, ONE), "comparison binary digits") + if x != y: + state = 1 if x == ONE else -1 + a.step(1) + b.step(1) + need(b.read() == RIGHT, "equal comparison extents") + a.rewind() + b.rewind() + return state + + def add(self, a, b): + out = self.arena.zero() + a.rewind() + b.rewind() + carry = 0 + while a.read() != RIGHT: + x, y = a.read(), b.read() + total = x+y+carry # Four finite carry states, not word arithmetic. + out.write(total & 1) + carry = total >> 1 + a.step(1) + if b is not a: + b.step(1) + out.step(1) + need(b.read() == RIGHT, "equal addition extents") + a.rewind() + b.rewind() + out.rewind() + return out, carry + + def subtract(self, a, b): + out = self.arena.zero() + a.rewind() + b.rewind() + borrow = 0 + while a.read() != RIGHT: + x, y = a.read(), b.read() + digit = x-y-borrow # One finite borrow bit. + out.write(digit & 1) + borrow = int(digit < 0) + a.step(1) + if b is not a: + b.step(1) + out.step(1) + need(b.read() == RIGHT, "equal subtraction extents") + a.rewind() + b.rewind() + out.rewind() + return out, borrow + + def subtract_exact(self, a, b): + out, borrow = self.subtract(a, b) + need(not borrow, "unsigned subtraction precondition") + return out + + def shift_add_bit(self, a, bit): + need(bit in (ZERO, ONE), "one incoming bit") + out = self.arena.zero() + a.rewind() + carry = bit + while a.read() != RIGHT: + previous = a.read() + out.write(carry) + carry = previous + a.step(1) + out.step(1) + a.rewind() + out.rewind() + need(not carry, "reserved high-bit margin") + return out + + def divmod(self, numerator, denominator): + need(not denominator.zero(), "nonzero binary divisor") + # A zero high bit leaves room for 2*remainder+bit. + denominator.msb() + margin = denominator.read() + denominator.rewind() + need(margin == ZERO, "binary divisor has the high-bit margin") + scan = self.arena.copy(numerator) + quotient, remainder = self.arena.zero(), self.arena.zero() + scan.msb() + quotient.msb() + while scan.read() != LEFT: + shifted = self.shift_add_bit(remainder, scan.read()) + self.arena.free(remainder) + if self.compare(shifted, denominator) >= 0: + remainder = self.subtract_exact(shifted, denominator) + self.arena.free(shifted) + quotient.write(ONE) + else: + remainder = shifted + quotient.write(ZERO) + scan.step(-1) + quotient.step(-1) + scan.step(1) + quotient.step(1) + self.arena.free(scan) + return quotient, remainder + + def times_small(self, a, constant): + """Multiply by a fixed finite matrix/rank label; preserve the word margin.""" + need(0 <= constant <= 128, "finite index multiplier") + result = self.arena.zero() + for bit in tuple((constant >> i) & 1 for i in range(constant.bit_length()-1, -1, -1)): + doubled, carry = self.add(result, result) + need(not carry, "index multiplication margin") + self.arena.free(result) + if bit: + result, carry = self.add(doubled, a) + need(not carry, "index multiplication extent") + self.arena.free(doubled) + else: + result = doubled + return result + + def increment_in_place(self, word): + """Ripple increment for a bounded address counter; restore its head.""" + word.rewind() + while word.read() == ONE: + word.write(ZERO) + word.step(1) + need(word.read() == ZERO, "ripple increment has space") + word.write(ONE) + word.rewind() + + +class Ring: + """Canonical residues modulo an encoded M>1 with one leading zero bit.""" + def __init__(self, modulus): + self.modulus, self.arena = modulus, modulus.arena + self.raw = Unsigned(self.arena) + self.one = self.arena.literal(1) + try: + need(self.raw.compare(modulus, self.one) > 0, "modulus exceeds one") + modulus.msb() + margin = modulus.read() + modulus.step(-1) + significant = modulus.read() + modulus.rewind() + need(margin == ZERO and significant == ONE, "canonical modulus word with one high-bit margin") + except ValueError: + self.arena.free(self.one) + raise + + def close(self): + self.arena.free(self.one) + + def add(self, a, b): + total, carry = self.raw.add(a, b) + need(not carry, "canonical modular addition margin") + if self.raw.compare(total, self.modulus) >= 0: + out = self.raw.subtract_exact(total, self.modulus) + self.arena.free(total) + return out + return total + + def subtract(self, a, b): + if self.raw.compare(a, b) >= 0: + return self.raw.subtract_exact(a, b) + larger, carry = self.raw.add(a, self.modulus) + need(not carry, "canonical modular subtraction margin") + out = self.raw.subtract_exact(larger, b) + self.arena.free(larger) + return out + + def negate(self, a): + zero = self.arena.zero() + out = self.subtract(zero, a) + self.arena.free(zero) + return out + + def multiply(self, a, b): + if a.zero() or b.zero(): + return self.arena.zero() + if self.raw.compare(a, self.one) == 0: + return self.arena.copy(b) + if self.raw.compare(b, self.one) == 0: + return self.arena.copy(a) + scan = self.arena.copy(b) + result = self.arena.zero() + scan.msb() + while scan.read() != LEFT: + doubled = self.add(result, result) + self.arena.free(result) + if scan.read() == ONE: + result = self.add(doubled, a) + self.arena.free(doubled) + else: + result = doubled + scan.step(-1) + scan.step(1) + self.arena.free(scan) + return result + + def inverse(self, a): + """Euclid, with Bezout coefficients reduced modulo M; None for nonunits.""" + r0, r1 = self.arena.copy(self.modulus), self.arena.copy(a) + t0, t1 = self.arena.zero(), self.arena.copy(self.one) + while not r1.zero(): + quotient, r2 = self.raw.divmod(r0, r1) + if self.raw.compare(quotient, self.modulus) >= 0: + reduced = self.raw.subtract_exact(quotient, self.modulus) + self.arena.free(quotient) + quotient = reduced + product = self.multiply(quotient, t1) + t2 = self.subtract(t0, product) + self.arena.free_many(quotient, product, r0, t0) + r0, r1, t0, t1 = r1, r2, t1, t2 + unit = self.raw.compare(r0, self.one) == 0 + self.arena.free_many(r0, r1, t1) + if unit: + return t0 + self.arena.free(t0) + return None + + def literal(self, constant): + """Compile a fixed signed integer through binary modular operations.""" + negative = constant < 0 + magnitude = abs(constant) + result = self.arena.zero() + instructions = tuple((magnitude >> i) & 1 for i in range(magnitude.bit_length()-1, -1, -1)) + for bit in instructions: + doubled = self.add(result, result) + self.arena.free(result) + if bit: + result = self.add(doubled, self.one) + self.arena.free(doubled) + else: + result = doubled + if negative: + out = self.negate(result) + self.arena.free(result) + result = out + return result diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/verify.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/verify.py new file mode 100644 index 0000000000..6be4f94eda --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/inputs/pr2769/verify.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +"""Check fixed-tape bank parking against its pinned source contracts.""" +import argparse +from hashlib import sha256 +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(",", ":")) + + +def authenticate(): + manifest = json.loads((HERE / "SOURCES.json").read_text()) + expected = set() + for entry in manifest["snapshots"]: + name = entry["path"] + if name in expected or not name.startswith("vendor/"): + raise ValueError("unique scoped source inventory") + expected.add(name) + if sha256((HERE / name).read_bytes()).hexdigest() != entry["sha256"]: + raise ValueError("pinned predecessor source changed: " + name) + observed = {path.relative_to(HERE).as_posix() for path in (HERE / "vendor").glob("*.py")} + if observed != expected: + raise ValueError("complete predecessor source inventory") + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--emit", action="store_true") + args = parser.parse_args() + authenticate() + sys.path[:0] = [str(HERE), str(HERE / "vendor")] + from checks import run + result = run() + receipt = {"sha256": sha256(canonical(result).encode()).hexdigest(), "result": result} + if not args.emit: + expected = json.loads((HERE / "RESULT.json").read_text()) + if canonical(expected) != canonical(receipt): + print(json.dumps(receipt, indent=2, sort_keys=True)) + raise ValueError("complete numerical-bank parking receipt differs") + print("PASS_SELECTED_BIT_REGISTER_PARKING") + print(json.dumps(receipt, indent=2, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/loader.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/loader.py new file mode 100644 index 0000000000..4a0326c9af --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/loader.py @@ -0,0 +1,92 @@ +"""Load the immutable logical caller and bank codec into one module namespace.""" +from hashlib import sha1, sha256 +import importlib.util +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +REPOSITORY = HERE.parents[1] +CALLER = HERE / "inputs/pr2753" +PARKING = HERE / "inputs/pr2769" +_active = False + +# Main's UTF-8-only HPE verifier correction changes one proof-supplement hash. +# Accept these two complete records, not an unconstrained semantic projection. +SELECTED_RECORDS = { + "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32": + "ae6a99f28aa468649eb66a361e764d769363bf11", + "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129": + "b1fea0c94436b236cc2b7d41a7be032811b94c81", +} + + +def selected_sources(data): + digest = sha256(data).hexdigest() + blob = sha1(b"blob " + str(len(data)).encode() + b"\0" + data).hexdigest() + if SELECTED_RECORDS.get(digest) != blob: + raise ValueError("unrecognized complete selected record") + sources = json.loads((CALLER / "SOURCES.json").read_text()) + rows = [row for row in sources["files"] + if row["path"] == "certificates/selected-result.json"] + if len(rows) != 1 or rows[0]["sha256"] != next(iter(SELECTED_RECORDS)): + raise ValueError("unchanged predecessor selected-record pin") + rows[0].update(sha256=digest, git_blob=blob) + return sources + + +def compatibility_controls(): + selected = json.loads((REPOSITORY / "certificates/selected-result.json").read_bytes()) + for key in ("kappa", "proof_supplements"): + changed = dict(selected) + changed[key] = "unrecognized mutation" + try: + selected_sources(json.dumps(changed).encode()) + except ValueError: + continue + raise ValueError("selected-record mutation accepted: " + key) + + +def module(name, path): + spec = importlib.util.spec_from_file_location(name, path) + result = importlib.util.module_from_spec(spec) + sys.modules[name] = result + spec.loader.exec_module(result) + return result + + +def authenticate(): + entries = json.loads((HERE / "SNAPSHOTS.json").read_text())["files"] + expected = set() + for entry in entries: + path = entry["path"] + if path in expected or not path.startswith("inputs/"): + raise ValueError("unique frozen input inventory") + expected.add(path) + if sha256((HERE / path).read_bytes()).hexdigest() != entry["sha256"]: + raise ValueError("frozen source changed: " + path) + observed = {path.relative_to(HERE).as_posix() for path in (HERE / "inputs").rglob("*") + if path.is_file() and "__pycache__" not in path.parts} + if expected != observed: + raise ValueError("complete frozen input inventory") + source_verifier = module("frozen_caller_verifier", CALLER / "verify.py") + sources = selected_sources((REPOSITORY / "certificates/selected-result.json").read_bytes()) + source_verifier.authenticate(sources=sources, here=CALLER, root=REPOSITORY) + + +def activate(): + global _active + if _active: + return sys.modules["bank_codec"] + authenticate() + module("bootstrap", CALLER / "bootstrap.py") + import sources + sources.ROOT = REPOSITORY + sys.path.insert(0, str(HERE)) + sys.path.append(str(PARKING / "vendor")) + import words + if sha256(Path(words.__file__).read_bytes()).digest() != sha256((PARKING / "vendor/words.py").read_bytes()).digest(): + raise ValueError("logical caller and codec use one unchanged Word interface") + codec = module("bank_codec", PARKING / "codec.py") + _active = True + return codec diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_binding.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_binding.py new file mode 100644 index 0000000000..c197eb6458 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_binding.py @@ -0,0 +1,145 @@ +"""Separate selected generated coefficients from the reduced GL2 fixture.""" +from types import SimpleNamespace + +import loader +loader.activate() +from children import extend +from controller import Callback +from macro_code import Residual +from numeric import selected_coefficient +import oracle +from plan import Plan, Request +from records import Fields, Program, append_finite +from words import need + + +def view(cls, runtime, tape): + result = object.__new__(cls) + result.index_arena, result.residue_arena = runtime.indices, runtime.arena + result.code_bits = runtime.binding.codes.bits + result.tape = tape + return result + + +class SelectedBinding: + cutoff, stock_multiple, child_mode = 64, 9475, 0 + + def __init__(self, specifications): + self.specifications = specifications + self.catalogue = specifications.catalogue + self.codes = self.catalogue.codes + self.ambient = specifications.bind(0, True, tuple(map(tuple, oracle.eye(64)))).code + + def residual(self, identifier, common, low, mode): + need(mode == 0, "one selected source program") + request = self.catalogue.requests[identifier] + need(common == (request.kind != "IDLE"), "selected common/native source view") + spec = self.specifications.bind(identifier, common, low) + return Residual(spec.code, self.specifications.plan(spec.code), identifier, common, low) + + def incoming(self, runtime): + def coefficient(prefix, request): + need(request.kind == "incoming", "incoming coefficient grammar") + fields = view(Fields, runtime, prefix) + frame = Callback(runtime.context.ring, runtime.indices, runtime.program, fields, + self.specifications, self.ambient, allow_fallback=True, leaf=True) + try: + raw = frame.raw + need(raw.compare(frame.final_size, runtime.size) == 0 and + raw.compare(frame.depth, runtime.depth) == 0, "incoming frame width and depth") + value = frame.weight(request.coordinate) + if request.negative_inverse: + inverse = runtime.context.ring.inverse(value) + need(inverse is not None, "incoming unit inverse") + following = runtime.context.ring.negate(inverse) + runtime.arena.free_many(value, inverse) + value = following + frame.close() + return value + except BaseException: + frame.abort() + raise + return SimpleNamespace(coefficient=coefficient) + + def validate_residual(self, runtime, definition, first): + frame = Callback(runtime.context.ring, runtime.indices, runtime.program, + view(Fields, runtime, first), self.specifications, + definition.code, allow_fallback=True) + try: + need(frame.raw.compare(frame.final_size, runtime.size) == 0 and + frame.raw.compare(frame.depth, runtime.depth) == 0, "current residual frame binding") + frame.close() + except BaseException: + frame.abort() + raise + + def coefficient(self, runtime, definition, prefix, request): + return selected_coefficient(definition.plan, runtime.context.ring, runtime.indices, + runtime.program, view(Fields, runtime, prefix), + self.specifications, definition.code, request) + + def child_program(self, runtime, definition, event, first): + callback = Callback(runtime.context.ring, runtime.indices, runtime.program, + view(Fields, runtime, first), self.specifications, + definition.code, allow_fallback=True) + zero = runtime.indices.zero() + try: + result = extend(callback, Request("child", zero, child_kind=event.child_kind, + field=event.field, reverse=event.reverse, half=event.half)) + callback.close() + return result.tape + except BaseException: + callback.abort() + raise + finally: + runtime.indices.free(zero) + + def check_stock(self, runtime): + pass + + +class ToyBinding: + """Fixture-only q2/dimension2 grammar; production uses SelectedBinding.""" + cutoff, stock_multiple, child_mode = 2, 1, 0 + + def __init__(self, catalogue, plans): + self.catalogue, self.codes, self.plans = catalogue, catalogue.codes, plans + + def residual(self, identifier, common, low, mode): + need(common and identifier in (0, 1) and mode in (0, 1), "toy MOVE binding") + plan, constants = self.plans[(identifier, low)] + code = self.codes.encode(identifier, common, low) + if mode: + return Residual(code, Plan(2, 1, True, ()), identifier, common, low, + axis=identifier, constants=constants) + return Residual(code, plan, identifier, common, low, constants=constants) + + def incoming(self, runtime): + return SimpleNamespace(coefficient=lambda _prefix, _request: + runtime.arena.copy(runtime.context.ring.one)) + + def validate_residual(self, runtime, definition, first): + pass + + def coefficient(self, runtime, definition, prefix, request): + if request.kind == "child": + return runtime.arena.copy(runtime.context.ring.one) + return runtime.arena.literal(definition.constants[(request.reference, request.reverse_adapter)]) + + def child_program(self, runtime, definition, event, first): + # The retained toy grammar uses only Program identity. Carry a finite + # source-label record as extra inert data to exercise descriptor parking. + result = runtime.pool.acquire() + from directory import append_tape + append_tape(runtime.program.tape, result) + append_finite(result, definition.code, self.codes.bits) + result.rewind() + return result + + def check_stock(self, runtime): + from cardinal_counts import Count + expected = Count.literal(6 if runtime.root else 1) + try: + need(expected.equals(runtime.count("unused")), "toy exact independent fresh stock") + finally: + expected.close() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_checks.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_checks.py new file mode 100644 index 0000000000..6a9226a647 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_checks.py @@ -0,0 +1,101 @@ +"""Complete reduced-source payload through the generated fixed-role caller.""" +from hashlib import sha256 +import json +from pathlib import Path +import sys +from time import monotonic +from unittest.mock import patch + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import loader +loader.activate() +from cardinal_counts import Count +from check_support import no_decode +from check_runtime import destination +import check_nested_model as model +from directory import Context +from macro_binding import ToyBinding +from macro_code import compile_node +from macro_machine import Machine +from records import Tape +import scheduler +from words import Arena, BLANK, Ring, need + + +def body(tape): + return bytes(tape.cells[1:]).rstrip(bytes([BLANK])) + + +def run(): + started = monotonic() + catalogue = model.Catalogue() + topology = model.Topology(catalogue) + source_arena, source_indices = Arena(3), Arena(8) + modulus = source_arena.input(2) + ring = Ring(modulus) + context = Context(ring, catalogue.codes) + plans = model.compile_coefficients(catalogue, context, source_indices, model.UnitIncoming(context)) + binding = ToyBinding(catalogue, plans) + programs = (compile_node(topology, binding, 0), compile_node(topology, binding, 1)) + context.close() + ring.close() + size, depth = source_indices.input(4), source_indices.input(0) + source, directory, program = Tape(), Tape(), Tape() + for index in range(9216): + source.append(((index * 13) ^ (index >> 3) ^ (index >> 7) ^ 0x53) & 1) + source.rewind() + original = body(source) + old_count, rows, before, gap, suffix = (Count.literal(value) for value in (1, 36, 1, 1, 1)) + runtime = Machine(binding, topology, programs, Arena(3, 512), Arena(8, 512)) + print("compiled", [len(p.operations) for p in programs], "instructions", flush=True, file=sys.stderr) + def reject_invocation(*_args, **_kwargs): + raise ValueError("source recursive Invocation reached the physical controller") + with no_decode(), patch.object(scheduler.Invocation, "__init__", reject_invocation): + output = runtime.run(source, directory, program, modulus, size, depth, + old_count, rows, before, gap, suffix, mode=1) + actual = body(output) + expected = bytearray(9216) + for address in range(9216): + expected[destination(address, 4, 2, (1, 1, 1, 1))] = original[address] + need(actual == expected, "complete generated-controller Boolean endpoint") + need(sha256(bytes([2]) + actual).hexdigest() == + "68477c468bd70d3488f9e1afbfa576aab2fa9db44949874ab873d64c22853b46", + "same complete payload as the pinned logical replay, including LEFT") + need(body(source) == original and not body(directory) and not body(program) and + source.head == directory.head == program.head == output.head == 1, + "generated caller preserves borrowed root streams and heads") + need(runtime.counts["calls"] == runtime.counts["returns"] == 12 and + runtime.counts["residuals"] == 156, "complete model recursive census") + need(not runtime.arena.live and not runtime.indices.live and + all(not body(tape) and tape.head == 1 for tape in runtime.roles.values()) and + all(not body(tape) and tape.head == 1 for tape in runtime.handoff.values()), + "complete generated caller clears working frames and handoff ports") + need(runtime.closed and runtime.numerical.machine.tapes == [{}, {}] and + all(all(symbol == BLANK for symbol in tape.cells) + for tape in (*runtime.roles.values(), *runtime.handoff.values(), *runtime.pool.tapes)) and + all(all(symbol == BLANK for symbol in word.cells) + for bank in (runtime.arena, runtime.indices) for word in (*bank.words, bank.template)), + "final root return erases physical work markers and templates") + result = dict(domain="q2 dimension2 cutoff2 one-family model; root coordinate projectors", + instructions=[len(p.operations) for p in programs], counts=runtime.counts, + payload_sha256=sha256(actual).hexdigest(), physical_stream_roles=len(runtime.roles), + handoff_ports=len(runtime.handoff), scratch_capacity=len(runtime.pool.tapes), + peak_scratch_leases=runtime.pool.peak, scratch_allocations=runtime.pool.allocations, + numerical_slots=[len(runtime.arena.words), len(runtime.indices.words)], + parking_charge=runtime.numerical.machine.counts, + codec_charge=runtime.numerical.codec_counts) + source.clear() + directory.clear() + program.clear() + output.clear() + for value in (old_count, rows, before, gap, suffix): + value.close() + source_arena.free(modulus) + source_indices.free_many(size, depth) + need(not source_arena.live and not source_indices.live, "closed source fixture banks") + print("generated controller completed in", round(monotonic() - started, 2), "seconds", file=sys.stderr) + return result + + +if __name__ == "__main__": + print(json.dumps(run(), sort_keys=True, indent=2)) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_code.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_code.py new file mode 100644 index 0000000000..2f5f8ecfac --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_code.py @@ -0,0 +1,107 @@ +"""Compile fixed source schedules; numerical dimensions never enter this pass.""" +from dataclasses import dataclass + +import loader +loader.activate() +from control import LocalState +from driver import compile_owner +from residual_blocks import Cursor +from words import need + + +@dataclass(frozen=True) +class Residual: + code: int + plan: object + identifier: int + common: bool + low: tuple + axis: object = None + constants: object = None + + +@dataclass(frozen=True) +class Code: + operations: tuple + staged_roles: int + + +def compile_node(topology, binding, mode=0): + """Finite offline expansion of the source's q-dependent instruction word. + + The selected GL64 expansion can be enormous. This routine proves an + effective finite emitter; practical selected runs may compile regions with + the same finite labels. The small model uses the complete emitted tuple. + """ + operations = [("node",)] + staged = 0 + def residual(role, identifier, common, low): + definition = binding.residual(identifier, common, low, mode) + operations.append(("residual_begin", role, definition)) + if definition.axis is not None: + operations.append(("block", definition, ("axis", definition.axis, 0))) + else: + cursor = Cursor(definition.plan) + while not cursor.done: + operations.append(("block", definition, cursor.take())) + operations.append(("residual_end", role, definition)) + for event in topology.schedule: + kind = event["kind"] + if kind == "local_cover_sweep": + for replica in range(topology.replicas): + call = topology.call(event["stage"], replica) + staged = max(staged, len(call.owners) + 1) + for low in topology.catalogue.low_classes(): + slots = [] + for role, owner in enumerate(call.owners): + native, forward, backward = compile_owner( + topology.matrix(owner.chart), low, topology.catalogue.codes) + slots.append((owner.family, native, backward)) + operations.append(("gather_route", ("stage", role), owner.family, native, forward)) + state = LocalState(call) + for position, item in enumerate(call.events): + op, role = state.accept(position) + target = ("stage", role) + if op == 0: + residual(target, call.requests[position], True, low) + elif op == 1: + operations.append(("xor", target, ("stage", item[2]))) + elif op == 2: + operations.append(("copy", target, "copy_source")) + residual("copy_source", call.requests[position], True, low) + operations.append(("move", "copy_source", ("stage", state.private))) + else: + need(op == 3, "closed local opcode") + operations.append(("clear", ("stage", state.private))) + state.finish() + for role, (family, native, backward) in enumerate(slots): + operations.append(("route_scatter", ("stage", role), family, native, backward)) + for role in range(len(call.owners) + 1): + operations.append(("clear", ("stage", role))) + elif kind == "idle": + for replica in range(topology.replicas): + for identifier in topology.idles[event["idx"]]: + family = topology.idle_family(identifier, replica) + for low in topology.catalogue.low_classes(): + operations.append(("gather", "idle", family, low)) + residual("idle", identifier, False, low) + operations.append(("scatter", "idle", family, low)) + operations.append(("clear", "idle")) + elif kind == "bridge": + need(event["coefficient"] in (-1, 1), "native Boolean bridge coefficient") + for replica in range(topology.replicas): + for port in range(topology.ports): + for target, source, side in ((event["dst"], event["src"], 0), + (event["src"], event["dst"], 1)): + operations.append(("family_xor", topology.family(replica, target, side, port), + topology.family(replica, source, side, port))) + else: + need(kind == "exchange", "closed global opcode") + for replica in range(topology.replicas): + for pair in range(topology.pairs): + for port in range(topology.ports): + operations.append(("exchange", topology.family(replica, pair, 0, port), + topology.family(replica, pair, 1, port))) + operations.append(("checkpoint", kind, event.get("stage", event.get("idx", -1)))) + operations.append(("return",)) + return Code(tuple(operations), staged) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_controls.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_controls.py new file mode 100644 index 0000000000..b7c1d28dd4 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_controls.py @@ -0,0 +1,172 @@ +"""Scratch ownership controls and a complete nonzero remainder-peel block.""" +from hashlib import sha256 +from pathlib import Path +import sys + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import loader +loader.activate() +from cardinal_counts import Count +from bitstream import atom_swap +from check_runtime import destination +from check_support import no_decode +from directory import Context +from frame_checks import restored, snapshot +import model +import peel +from records import Tape +from scratch_pool import ScratchPool +from stream import Counter +from words import Arena, BLANK, Ring, need + + +def body(tape): + return bytes(tape.cells[1:]).rstrip(bytes([BLANK])) + + +def ownership(): + pool = ScratchPool(2) + first = pool.acquire() + first.append(0) + first.clear() + second = pool.acquire() + second.append(1) + second.rewind() + need(first.slot == second.slot, "reuse a physical scratch role") + first.clear() + need(second.read() == 1, "stale cleanup preserves the new borrower's data") + rejected = [] + try: + first.read() + except ValueError: + rejected.append("stale_read") + literal = Count.literal(1) + with pool.install(): + counter = Counter(literal) + for label, operation in (("exhaustion", pool.acquire), + ("physical_tape", Tape), ("numerical_arena", lambda: Arena(3))): + try: + operation() + except ValueError: + rejected.append(label) + counter.decrement() + counter.close() + second.clear() + pool.empty() + literal.close() + need(rejected == ["stale_read", "exhaustion", "physical_tape", "numerical_arena"], + "scratch ownership and fixed-inventory controls reject") + return dict(rejected=rejected, peak=pool.peak, stale_cleanup_preserves_new_owner=True) + + +def lease_traffic(): + for length in (0, 1, 3, 17): + pool = ScratchPool(1) + lease, reference = pool.acquire(), Tape() + for tape in (lease, reference): + for i in range(length): + tape.append(i & 1) + tape.rewind() + tape.step(1) + tape.read() + tape.rewind() + tape.clear() + need(lease.meter.record() == reference.meter.record(), + "delegated lease loops retain the literal tape API invoice") + pool.empty() + return dict(extents=[0, 1, 3, 17], exact_api_traffic=True) + + +def remainder(): + catalogue = model.Catalogue() + arena, indices = Arena(3, 512), Arena(8, 512) + modulus = arena.input(3) + ring = Ring(modulus) + context = Context(ring, catalogue.codes) + incoming = model.Incoming(context, indices, (2, 1, 2)) + size, depth = indices.input(3), indices.zero() + source, directory = Tape(), Tape() + for address in range(1458): + source.append(((address * 7) ^ (address >> 3) ^ 0x57) & 1) + source.rewind() + original = body(source) + counts = [Count.literal(value) for value in (1, 1, 1, 2, 1)] + before = snapshot(arena), snapshot(indices) + pool = ScratchPool(3 ** 2 + 128) + with pool.install(), no_decode(): + output = peel.run(source, context, indices, size, depth, object(), directory, *counts, incoming) + actual = body(output.physical) + expected = bytearray(1458) + for address in range(1458): + expected[destination(address, 3, 3, (2, 1, 2), 2, active=(2,))] = original[address] + need(actual == expected and body(source) == original and not body(directory), + "complete nonzero remainder peel preserves other atoms and the external gap") + output.clear() + pool.empty() + restored(arena, before[0]) + restored(indices, before[1]) + result = dict(addresses=1458, remainder_atoms=1, gap=2, peak_scratch_leases=pool.peak, + payload_sha256=sha256(actual).hexdigest()) + source.clear() + directory.clear() + incoming.close() + for value in counts: + value.close() + context.close() + ring.close() + arena.free(modulus) + indices.free_many(size, depth) + need(not arena.live and not indices.live, "closed remainder fixture") + return result + + +def run(): + return dict(ownership=ownership(), remainder=remainder(), two_digit=two_digit(), traffic=lease_traffic()) + + +def two_digit(): + arena = Arena(5, 512) + modulus = arena.input(9) + ring = Ring(modulus) + parameters = [] + for value in (2, 5, 3): + count = Count.literal(value) + parameters.append(count.marginal()) + count.close() + source = Tape() + for address in range(2430): + source.append(((address * 11) ^ (address >> 2) ^ (address >> 5)) & 1) + source.rewind() + original = body(source) + saved = snapshot(arena) + pool = ScratchPool(137) + with pool.install(), no_decode(): + output = atom_swap(source, ring, 3, *parameters) + actual = body(output.physical) + expected = bytearray(2430) + for address in range(2430): + rest, suffix = divmod(address, 3) + rest, second = divmod(rest, 9) + rest, middle = divmod(rest, 5) + outer, first = divmod(rest, 9) + target = ((((outer * 9 + second) * 5 + middle) * 9 + first) * 3 + suffix) + expected[target] = original[address] + need(actual == expected and body(source) == original and source.head == output.head == 1, + "complete two-digit swap preserves all spectator coordinates") + output.clear() + pool.empty() + restored(arena, saved) + result = dict(modulus=9, digits=2, addresses=2430, peak_scratch_leases=pool.peak, + payload_sha256=sha256(actual).hexdigest()) + source.clear() + for parameter in parameters: + parameter.close() + ring.close() + arena.free(modulus) + need(not arena.live, "closed two-digit fixture") + return result + + +if __name__ == "__main__": + import json + print(json.dumps(run(), indent=2, sort_keys=True)) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_local_checks.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_local_checks.py new file mode 100644 index 0000000000..421f9030f9 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_local_checks.py @@ -0,0 +1,246 @@ +"""Generated four-family GL2(F3) caller, including private and global operations.""" +from collections import Counter +from hashlib import sha256 +from pathlib import Path +import sys +from time import monotonic +from types import SimpleNamespace +from unittest.mock import patch + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import loader +loader.activate() +from cardinal_counts import Count +from check_headers import residual_address +from check_runtime import destination +from check_support import no_decode +from controller import finite_word +from directory import Context +from forms import fallback_form, good_form +from macro_code import Residual, compile_node +from macro_machine import Machine +from matrices import Matrices +import model +from numeric import Page +import oracle +from plan import compile_plan +from records import RECORD_END, Tape, read_finite, read_word +import scheduler +from trace import execute +from words import Arena, BLANK, Ring, need + + +def body(tape): + return bytes(tape.cells[1:]).rstrip(bytes([BLANK])) + + +def request_key(request): + return (request.kind, request.reference, request.reverse_adapter, request.child_kind, + request.field, request.reverse, request.negative_inverse, request.half) + + +class Binding: + """Only the fixed w1/n2/weights(2,1) model may use these compiled scalars.""" + cutoff, stock_multiple, child_mode = 2, 1, 0 + + def __init__(self, catalogue, definitions, projectors): + self.catalogue, self.codes = catalogue, catalogue.codes + self.definitions, self.projectors = definitions, projectors + + def residual(self, identifier, common, low, mode): + need(mode == 0, "one first-range fixture program") + return self.definitions[(identifier, common, low)] + + def incoming(self, runtime): + def coefficient(prefix, request): + need(prefix.read() == BLANK and request.kind == "incoming", "fixture frozen-only root") + value = (2, 1)[finite_word(request.coordinate, 2)] + if request.negative_inverse: + value = (-pow(value, -1, 3)) % 3 + return runtime.arena.literal(value) + return SimpleNamespace(coefficient=coefficient) + + def validate_residual(self, runtime, definition, first): + two = runtime.indices.literal(2) + try: + need(runtime.depth.zero() and runtime.context.raw.compare(runtime.context.cap, runtime.context.ring.one) == 0 + and runtime.indices is runtime.size.arena and + runtime.context.q == 3 and runtime.context.dimension == 2 and + runtime.context.ring.raw.arena is runtime.arena, + "first-range fixture domain") + from words import Unsigned + need(Unsigned(runtime.indices).compare(runtime.size, two) == 0, "fixture f equals one") + finally: + runtime.indices.free(two) + + def coefficient(self, runtime, definition, prefix, request): + need(request.coordinate.zero(), "fixture coefficient coordinate zero") + prefix.rewind() + need(read_finite(prefix, self.codes.bits) == definition.code, "exact fixture request and view code") + for _ in range(4): + word = read_word(prefix, runtime.arena) + try: + need(word.zero(), "complete w1 high field is zero") + finally: + runtime.arena.free(word) + need(prefix.read() == RECORD_END, "fixture current field terminator") + prefix.step(1) + need(prefix.read() == BLANK, "fixture current field is last") + prefix.rewind() + return runtime.arena.literal(definition.constants[request_key(request)]) + + def child_program(self, *_args): + raise ValueError("first-range fixture has no internal child") + + def check_stock(self, runtime): + expected = Count.literal(1) + try: + need(expected.equals(runtime.count("unused")), "fixture unused row quotient") + finally: + expected.close() + + +def compile_binding(catalogue, context, indices): + ring, matrices = context.ring, Matrices(context.ring) + incoming = model.Incoming(context, indices, (2, 1)) + definitions, projectors, cache = {}, {}, {} + try: + for identifier, request in enumerate(catalogue.requests): + common = request.kind != "IDLE" + basis = model.I if request.base == 0 else model.S + chart = model.I if common else request.chart + preparation = tuple(tuple(sum(chart[i][k] * basis[k][j] for k in range(2)) + for j in range(2)) for i in range(2)) + for low in catalogue.low_classes(): + header = oracle.multiply(low, oracle.reduce_rational(preparation, 3), 3) + projector = tuple(map(tuple, oracle.multiply([[row[0]] for row in header], oracle.inverse(header, 3)[:1], 3))) + if projector not in cache: + plan = compile_plan(projector, 1, 3, projector[0][0] != 0) + encoded = matrices.constants(projector) + form = good_form(encoded, 1, ring) if plan.good else fallback_form(encoded, ring) + columns, depth = indices.literal(1), indices.zero() + page = Page(plan, form, ring, indices, columns, incoming.weight, depth, 0, object()) + constants = {} + for event in execute(page): + if event.request is None: + continue + need(event.request.coordinate.zero(), "compile only fixture coordinate zero") + value = page.evaluate(event.request) + key, scalar = request_key(event.request), value.inspect() + need(key not in constants or constants[key] == scalar, "one finite fixture coefficient per key") + constants[key] = scalar + ring.arena.free(value) + page.close() + matrices.free(encoded) + indices.free_many(columns, depth) + cache[projector] = plan, constants + plan, constants = cache[projector] + code = catalogue.codes.encode(identifier, common, low) + definitions[(identifier, common, low)] = Residual(code, plan, identifier, common, low, constants=constants) + projectors[code] = projector + finally: + incoming.close() + need(len(definitions) == 672 and len(cache) == 12, "complete fixed fixture binding compilation") + return Binding(catalogue, definitions, projectors) + + +def run(gap_size=2): + started = monotonic() + catalogue = model.Catalogue() + topology = model.Topology(catalogue) + arena, indices = Arena(3), Arena(8) + modulus = arena.input(3) + ring = Ring(modulus) + context = Context(ring, catalogue.codes) + binding = compile_binding(catalogue, context, indices) + code = compile_node(topology, binding) + context.close() + ring.close() + size, depth = indices.input(2), indices.zero() + source, directory, program = Tape(), Tape(), Tape() + fibre_size, length = 81 * gap_size, 192 * 81 * gap_size + for i in range(length): + source.append(((i * 13) ^ (i >> 3) ^ (i >> 7) ^ 0x53) & 1) + source.rewind() + original = body(source) + counts = [Count.literal(value) for value in (1, 192, 1, gap_size, 1)] + residuals, checkpoints = Counter(), [] + private = {} + copy_checks = 0 + def observe(machine, kind, *labels): + nonlocal copy_checks + if kind == "copy_source": + src, dst = labels + need(not private, "one private-copy checker scope") + private.update(source=src, copied=body(machine.tape(src))) + need(body(machine.tape(dst)) == private["copied"], "complete private source clone") + elif kind == "residual_begin": + definition, role = labels + request = catalogue.requests[definition.identifier] + residuals[request.kind] += 1 + if request.kind == "COPY": + need(private and body(machine.tape(role)) == private["copied"], "COPY enters its retained dirty source") + elif kind == "residual_end": + definition, role = labels + if catalogue.requests[definition.identifier].kind == "COPY": + expected = bytearray(fibre_size) + for address in range(fibre_size): + target = residual_address(address, binding.projectors[definition.code], (2, 1), 3, gap_size) + expected[target] = private["copied"][address] + need(body(machine.tape(role)) == expected and + body(machine.tape(private["source"])) == private["copied"], + "independent dirty COPY endpoint and unchanged source before cancelling XORs") + private.clear() + copy_checks += 1 + elif kind == "local_cover_sweep" and labels[0] in (0, 1): + stage = labels[0] + family = body(machine.tape(("family", 0))) + for low in range(48): + for address in range(fibre_size): + target = destination(address, 2, 3, (2, 1), gap_size) if stage == 0 else address + need(family[low * fibre_size + target] == original[low * fibre_size + address], + "independent intermediate family endpoint before sweep cancellation") + checkpoints.append(stage) + machine = Machine(binding, topology, (code,), Arena(3, 512), Arena(8, 512), observe) + print("compiled local model", len(code.operations), "instructions", file=sys.stderr, flush=True) + def reject_invocation(*_args, **_kwargs): + raise ValueError("source recursive Invocation reached the physical controller") + with no_decode(), patch.object(scheduler.Invocation, "__init__", reject_invocation): + output = machine.run(source, directory, program, modulus, size, depth, *counts) + actual = body(output) + expected = bytearray(length) + for row in range(192): + for address in range(fibre_size): + target = destination(address, 2, 3, (2, 1), gap_size) + expected[row * fibre_size + target] = original[row * fibre_size + address] + need(actual == expected and body(source) == original and not body(directory) and not body(program), + "complete four-family caller endpoint and borrowed input preservation") + need(checkpoints == [0, 1] and copy_checks == 96 and not private and + residuals == {"MOVE": 192, "COPY": 96, "IDLE": 384}, "complete chronological fixture coverage") + need(machine.closed and not machine.arena.live and not machine.indices.live and + machine.numerical.machine.tapes == [{}, {}] and + all(all(symbol == BLANK for symbol in tape.cells) + for tape in (*machine.roles.values(), *machine.handoff.values(), *machine.pool.tapes)), + "complete first-range fixed workspace cleanup") + result = dict(domain="q3 w1 n2 four-family fixture with weights(2,1)", addresses=length, + gap=gap_size, instructions=len(code.operations), counts=machine.counts, + residuals=dict(residuals), private_copy_oracles=copy_checks, + intermediate_sweeps=checkpoints, payload_sha256=sha256(actual).hexdigest(), + peak_scratch_leases=machine.pool.peak, scratch_capacity=len(machine.pool.tapes), + numerical_slots=[len(machine.arena.words), len(machine.indices.words)]) + source.clear() + directory.clear() + program.clear() + output.clear() + for count in counts: + count.close() + arena.free(modulus) + indices.free_many(size, depth) + need(not arena.live and not indices.live, "closed local fixture input banks") + print("generated local controller completed in", round(monotonic() - started, 2), "seconds", file=sys.stderr) + return result + + +if __name__ == "__main__": + import json + print(json.dumps(run(), indent=2, sort_keys=True)) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_machine.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_machine.py new file mode 100644 index 0000000000..5a032e8923 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_machine.py @@ -0,0 +1,453 @@ +"""One active frame, fixed stream roles and an encoded parent continuation.""" +from contextlib import contextmanager + +import loader +codec = loader.activate() +from cardinal_counts import Count, positive +from cardinality import multiply_atom_power +from directory import Context, append_tape, produce +from driver import xor_family +from episode import xor_packet +import fresh_rows +from layout import Layout +from macro_binding import view +from numeric import Geometry +from packet import read_prefix +import packet_engine +import peel +from plan import Request +from records import Program, Tape +from recursive_call import copy_word +from residual_blocks import events as block_events +from role_parking import FiniteFields, RoleParking, transfer +from routes import copy_rows, route_packet +from scratch_pool import Lease, ScratchPool +from selection import gather, scatter +from stream import Counter +from trace import child +from words import BLANK, LEFT, Ring, Unsigned, need + + +NAMES = ("source", "peeled", "old_directory", "program", "old_count", "rows", + "before", "gap", "suffix", "unused", "leading", "fibre", "highs", + "family_rows", "directory", "prefixes", "current", "copy_source", "idle", "swap", "header") +CAPSULE = ("source", "old_directory", "program", "old_count", "rows", "before", "gap", "suffix") + + +class Machine: + def __init__(self, binding, topology, programs, arena, indices, observe=None): + self.binding, self.topology, self.programs = binding, topology, tuple(programs) + self.arena, self.indices = arena, indices + staged = max(program.staged_roles for program in programs) + labels = (*NAMES, *(("family", i) for i in range(topology.families)), + *(("stage", i) for i in range(staged))) + self.roles = {label: Tape() for label in labels} + self.handoff = {label: Tape() for label in CAPSULE} + self.output = Tape() + self.pool = ScratchPool(binding.codes.q ** 2 + 128) + self.numerical = codec.BankParking(arena, indices) + self.streams = RoleParking(self.numerical, self.roles.values()) + self.header = FiniteFields((2, len(programs), max(len(p.operations) for p in programs), + arena.capacity, arena.capacity, arena.capacity, + indices.capacity, indices.capacity)) + self.context = self.program = self.size = self.depth = None + self.geometry_state = None + self.pc = self.mode = 0 + self.root = True + self.closed = False + self.observe = observe # Checker-only; the controller never reads its result. + self.counts = dict(macros=0, residuals=0, calls=0, returns=0) # Observers only. + + def tape(self, label): + return self.roles[label] + + def count(self, label): + result = object.__new__(Count) + result.tape = self.tape(label) + return result + + def commit(self, result, label): + target = self.tape(label) + if result is target: + return + target.clear() + append_tape(result, target) + target.rewind() + if isinstance(result, Lease): + result.clear() + + def save_count(self, value, label): + self.commit(value.tape, label) + value.close() + + def new_context(self, modulus, size, depth): + ring = Ring(modulus) + context = Context(ring, self.binding.codes) + self.save_count(context.highs, "highs") + context.highs = self.count("highs") + self.context, self.size, self.depth = context, size, depth + self.program = view(Program, self, self.tape("program")) + + def restore_context(self, labels): + modulus, one, cap, size, depth = labels + ring = object.__new__(Ring) + ring.arena, ring.raw = self.arena, Unsigned(self.arena) + ring.modulus, ring.one = self.arena.words[modulus], self.arena.words[one] + context = object.__new__(Context) + context.ring, context.arena, context.raw = ring, self.arena, ring.raw + context.codes = self.binding.codes + context.q, context.dimension = context.codes.q, context.codes.dimension + context.cap, context.highs = self.arena.words[cap], self.count("highs") + self.context = context + self.size, self.depth = self.indices.words[size], self.indices.words[depth] + self.program = view(Program, self, self.tape("program")) + + def boundary(self): + self.pool.empty() + for tape in self.roles.values(): + tape.step(-1) + need(tape.read() == LEFT, "completed canonical head stands after LEFT") + tape.step(1) + ring = self.context.ring + expected_indices = {self.size.slot, self.depth.slot} + if self.geometry_state is not None: + _definition, page, layout, fields, columns = self.geometry_state + expected_indices.update(word.slot for word in + (columns, page.one, page.two, page.leaf_cutoff, fields, + layout.core, layout.extra, layout.total)) + need(self.arena.live == {ring.modulus.slot, ring.one.slot, self.context.cap.slot} and + self.indices.live == expected_indices, + "only declared persistent and active geometry words at a completed macro") + + @contextmanager + def geometry(self, definition): + if self.geometry_state is not None: + owner, page, layout, fields, _columns = self.geometry_state + need(owner is definition, "one active residual geometry") + yield page, layout, fields + return + divisor = self.indices.literal(self.context.dimension) + columns, remainder = Unsigned(self.indices).divmod(self.size, divisor) + self.indices.free_many(divisor, remainder) + page = Geometry(definition.plan, self.indices, columns, self.depth, definition.code, self.program) + if self.binding.cutoff != 64: + self.indices.free(page.leaf_cutoff) + page.leaf_cutoff = self.indices.literal(self.binding.cutoff) + layout = Layout(page, self.size, self.context.ring, self.context.q, + self.count("leading"), self.count("gap"), self.count("suffix")) + fields = page.plus(self.depth, page.one) + self.geometry_state = definition, page, layout, fields, columns + yield page, layout, fields + + def close_geometry(self): + if self.geometry_state is None: + return + _definition, page, layout, fields, columns = self.geometry_state + self.geometry_state = None + self.indices.free(fields) + layout.close() + page.close() + self.indices.free(columns) + + def node(self): + divisor = self.indices.literal(self.context.dimension) + columns, remainder = Unsigned(self.indices).divmod(self.size, divisor) + valid = not columns.zero() + self.indices.free_many(divisor, columns, remainder) + need(valid, "complete internal node width") + for label in ("old_count", "rows", "before", "gap", "suffix"): + self.count(label).normalize() + positive(self.count(label)) + # Preserve source ingress validation before the first payload operation. + first = read_prefix(self.tape("old_directory"), self.depth) + self.tape("old_directory").rewind() + zero = self.indices.zero() + incoming = self.binding.incoming(self) + try: + value = incoming.coefficient(first, Request("incoming", zero)) + self.arena.free(value) + finally: + first.clear() + self.indices.free(zero) + unused = fresh_rows.quotient(self.count("rows"), self.context, self.topology.families) + self.save_count(unused, "unused") + stock = Count(self.count("unused")) + try: + need(stock.divide_small(self.binding.stock_multiple) == 0, "compatible fresh stock factor") + finally: + stock.close() + self.save_count(Count.product(self.count("unused"), self.count("before")), "leading") + fibre = Count.product(self.count("leading"), self.count("gap")) + total = Unsigned(self.indices).times_small(self.size, 2) + multiply_atom_power(fibre, total, self.context.ring, self.context.q) + self.indices.free(total) + complete = Count.product(fibre, self.count("suffix")) + fibre.close() + self.save_count(complete, "fibre") + peeled = peel.run(self.tape("source"), self.context, self.indices, self.size, self.depth, + self.program, self.tape("old_directory"), self.count("old_count"), + self.count("rows"), self.count("before"), self.count("gap"), + self.count("suffix"), incoming) + self.commit(peeled, "peeled") + self.save_count(fresh_rows.family_rows(self.context), "family_rows") + source = self.tape("peeled") + outer = Counter(self.count("old_count")) + try: + while not outer.finished: + for family in range(self.topology.families): + copy_rows(source, self.tape(("family", family)), self.count("family_rows"), self.count("fibre")) + outer.decrement() + need(source.read() == BLANK, "complete canonical fresh-row split") + finally: + outer.close() + source.rewind() + for family in range(self.topology.families): + self.tape(("family", family)).rewind() + + def residual_begin(self, role, definition): + self.binding.check_stock(self) + directory, prefixes = produce(self.tape("old_directory"), self.depth, self.count("old_count"), + definition.code, self.context) + self.commit(directory, "directory") + self.save_count(prefixes, "prefixes") + with self.geometry(definition) as (_page, _layout, fields): + first = read_prefix(self.tape("directory"), fields) + self.tape("directory").rewind() + try: + self.binding.validate_residual(self, definition, first) + finally: + first.clear() + self.commit(self.tape(role), "current") + self.counts["residuals"] += 1 + if self.observe is not None: + self.observe(self, "residual_begin", definition, role) + + def prepare_child(self, definition, event, layout, fields): + need(event.parent_identity is self.program and + event.source_code == definition.code == layout.geometry.source_code, + "recursive gate belongs to the current program and source") + raw = Unsigned(self.indices) + need(raw.compare(event.width, self.size) < 0, "strict child contraction") + extents = layout.child_extents(event.first, event.second, event.width, before=self.count("before")) + first = read_prefix(self.tape("directory"), fields) + self.tape("directory").rewind() + program = None + try: + program = self.binding.child_program(self, definition, event, first) + inputs = (self.tape("current"), self.tape("directory"), program, + self.tape("prefixes"), self.tape("unused"), *(extent.tape for extent in extents)) + for label, source in zip(CAPSULE, inputs): + target = self.handoff[label] + need(target.read() == BLANK, "empty fixed child handoff port") + append_tape(source, target) + target.rewind() + return (self.arena.copy(self.context.ring.modulus), + self.indices.copy(event.width), self.indices.copy(event.depth)) + finally: + if program is not None: + program.clear() + first.clear() + for extent in extents: + extent.close() + + def block(self, definition, block): + grants = None + with self.geometry(definition) as (page, layout, fields): + if block[0] == "axis": + axis = block[1] + trace = child(page, page.raw.times_small(page.columns, axis), + page.raw.times_small(page.columns, 3 - axis), + self.indices.copy(page.columns), "good") + else: + trace = block_events(page, block) + try: + first = next(trace, None) + if first is not None and first.kind == "enter" and page.raw.compare(first.width, page.leaf_cutoff) >= 0: + grants = self.prepare_child(definition, first, layout, fields) + else: + def complete_events(): + if first is not None: + yield first + yield from trace + result = packet_engine.run(self.tape("current"), complete_events(), layout, + self.tape("directory"), self.count("prefixes"), fields, + lambda prefix, request: self.binding.coefficient(self, definition, prefix, request)) + self.commit(result, "current") + finally: + trace.close() + if grants is not None: + self.close_geometry() + self.call(grants) + return True + return False + + def call(self, grants): + self.pool.empty() + need(self.geometry_state is None, "close derived geometry before the recursive cut") + ring = self.context.ring + self.header.write(self.tape("header"), (int(self.root), self.mode, self.pc + 1, + ring.modulus.slot, ring.one.slot, self.context.cap.slot, + self.size.slot, self.depth.slot)) + self.streams.park() + modulus, size, depth = grants + self.numerical.park(({modulus.slot}, {size.slot, depth.slot})) + for label in CAPSULE: + transfer(self.handoff[label], self.tape(label)) + self.new_context(modulus, size, depth) + self.root, self.mode, self.pc = False, self.binding.child_mode, 0 + self.counts["calls"] += 1 + + def close_frame(self): + self.close_geometry() + ring = self.context.ring + self.context.close() + ring.close() + self.arena.free(ring.modulus) + self.indices.free_many(self.size, self.depth) + for tape in self.roles.values(): + tape.clear() + self.pool.empty() + need(not self.arena.live and not self.indices.live, "child numerical cleanup before restoration") + + def returned(self): + families = {i: self.tape(("family", i)) for i in range(self.topology.families)} + result = fresh_rows.merge(families, self.context, self.topology.families, + self.count("old_count"), self.count("fibre")) + need(self.output.read() == BLANK, "empty protected return port") + append_tape(result, self.output) + self.output.rewind() + result.clear() + return self.complete_return() + + def complete_return(self): + """Return the already completed protected output through one frame.""" + self.close_frame() + if self.root: + return True + self.numerical.restore() + self.streams.restore() + root, self.mode, self.pc, *labels = self.header.read(self.tape("header")) + self.root = bool(root) + self.tape("header").clear() + self.restore_context(labels) + transfer(self.output, self.tape("current")) + self.counts["returns"] += 1 + return False + + def dispatch(self, operation): + kind, *args = operation + context, old_count, fibre = self.context, self.count("old_count"), self.count("fibre") + if kind == "node": + self.node() + elif kind == "residual_begin": + self.residual_begin(*args) + elif kind == "block": + if self.block(*args): + return "jump" + elif kind == "residual_end": + self.close_geometry() + transfer(self.tape("current"), self.tape(args[0])) + self.tape("directory").clear() + self.tape("prefixes").clear() + if self.observe is not None: + self.observe(self, "residual_end", args[1], args[0]) + elif kind == "gather_route": + role, family, low, route = args + selected = gather(self.tape(("family", family)), context, old_count, low, fibre) + try: + self.commit(route_packet(selected, route, context, old_count, fibre), role) + finally: + selected.clear() + elif kind == "route_scatter": + role, family, low, route = args + result = route_packet(self.tape(role), route, context, old_count, fibre) + try: + changed = scatter(self.tape(("family", family)), result, context, old_count, low, fibre) + self.commit(changed, ("family", family)) + finally: + result.clear() + elif kind == "gather": + role, family, low = args + self.commit(gather(self.tape(("family", family)), context, old_count, low, fibre), role) + elif kind == "scatter": + role, family, low = args + self.commit(scatter(self.tape(("family", family)), self.tape(role), context, old_count, low, fibre), ("family", family)) + elif kind == "xor": + target, source = args + self.commit(xor_packet(self.tape(source), self.tape(target), context, old_count, fibre), target) + elif kind == "family_xor": + target, source = args + self.commit(xor_family(self.tape(("family", source)), self.tape(("family", target)), + old_count, self.count("family_rows"), fibre), ("family", target)) + elif kind == "exchange": + first, second = (("family", index) for index in args) + transfer(self.tape(first), self.tape("swap")) + transfer(self.tape(second), self.tape(first)) + transfer(self.tape("swap"), self.tape(second)) + elif kind == "copy": + self.commit(self.tape(args[0]), args[1]) + if self.observe is not None: + self.observe(self, "copy_source", *args) + elif kind == "move": + transfer(self.tape(args[0]), self.tape(args[1])) + elif kind == "clear": + self.tape(args[0]).clear() + elif kind == "checkpoint": + if self.observe is not None: + self.observe(self, *args) + else: + need(kind == "return", "closed finite macro alphabet") + return "done" if self.returned() else "jump" + return "next" + + def load_root(self, source, directory, program, modulus, size, depth, old_count, rows, before, gap, suffix, mode=0): + need(not self.arena.live and not self.indices.live, "empty supplied working banks") + inputs = (source, directory, program, old_count.tape, rows.tape, before.tape, gap.tape, suffix.tape) + owned = (*self.roles.values(), *self.handoff.values(), self.output, *self.pool.tapes) + need(all(input_tape is not work_tape for input_tape in inputs for work_tape in owned), + "borrowed root input ports are outside the reusable working bank") + for label, tape in zip(CAPSULE, inputs): + self.commit(tape, label) + self.new_context(copy_word(modulus, self.arena), copy_word(size, self.indices), copy_word(depth, self.indices)) + self.mode, self.pc, self.root = mode, 0, True + + def run(self, source, directory, program, modulus, size, depth, old_count, rows, before, gap, suffix, mode=0): + need(not self.closed, "one owned root invocation per machine initialization") + with self.pool.install(): + self.load_root(source, directory, program, modulus, size, depth, old_count, rows, before, gap, suffix, mode) + while True: + self.boundary() + operation = self.programs[self.mode].operations[self.pc] + action = self.dispatch(operation) + self.counts["macros"] += 1 + if action == "done": + break + if action == "next": + self.pc += 1 + self.pool.empty() + need(self.numerical.machine.tapes == [{}, {0: "^"}], "complete physical stack return") + self.erase_work() + return self.output + + def erase_work(self): + """Erase permanent owned markers/templates at the final root return.""" + need(not self.arena.live and not self.indices.live and not self.pool.live, + "root cleanup follows complete frame and scratch cleanup") + def marker(tape): + tape.step(-1) + need(tape.read() == LEFT, "owned work marker at the known origin") + tape.write(BLANK) + tape.step(1) + for tape in (*self.roles.values(), *self.handoff.values(), *self.pool.tapes): + need(tape.read() == BLANK, "empty body before owned marker erasure") + marker(tape) + for arena in (self.arena, self.indices): + for word in arena.words: + marker(word) + arena.template.erase() + marker(arena.template) + self.numerical._empty_port() + self.numerical._move(1, -1) + self.numerical._write(1, "_") + self.numerical._move(1, 1) + self.closed = True diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_selected_checks.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_selected_checks.py new file mode 100644 index 0000000000..14f224e975 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/macro_selected_checks.py @@ -0,0 +1,180 @@ +"""Selected grammar through the new fixed-role CALL/RETURN boundary. + +The controlled 23-bit child body checks the protocol, not a GL64 payload. +""" +from pathlib import Path +from dataclasses import replace +import sys +from types import SimpleNamespace +from unittest.mock import patch + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import loader +loader.activate() +from cardinal_counts import Count +from catalogue import Catalogue, Specifications +from check_support import inspect_count, no_decode +from directory import append_tape +from frame_checks import restored, snapshot +from macro_binding import SelectedBinding, view +from macro_code import Code +from macro_machine import Machine +import macro_machine +import oracle +from packet import read_prefix +from plan import Request +from records import Fields, Program, Tape +from words import Arena, BLANK, need + + +def body(tape): + return bytes(tape.cells[1:]).rstrip(bytes([BLANK])) + + +def run(): + catalogue = Catalogue(3) + specifications = Specifications(catalogue) + binding = SelectedBinding(specifications) + identifier = next(i for i, request in enumerate(catalogue.requests) + if request.kind == "IDLE" and request.base.rank == 42) + template = catalogue.template_for(identifier, False) + low = tuple(map(tuple, oracle.inverse(oracle.reduce_rational(template.preparation, 3), 3))) + definition = binding.residual(identifier, False, low, 0) + need(definition.plan.good, "selected native good source") + arena, indices = Arena(3), Arena(10) + modulus, size, depth = arena.input(3), indices.input(256), indices.input(0) + program = Program.fixture(indices, arena, 256, 2, (), catalogue.codes.bits) + field = Fields.fixture(indices, arena, [(definition.code, [[0] * 64 for _ in range(64)])], catalogue.codes.bits) + directory, old_directory, source = Tape(), Tape(), Tape() + for _ in range(2): + append_tape(field.tape, directory) + directory.rewind() + initial = bytes((i * 7 ^ i // 3) & 1 for i in range(23)) + for bit in initial: + source.append(bit) + source.rewind() + saved_directory, saved_program = body(directory), body(program.tape) + borrowed_words = snapshot(arena), snapshot(indices) + old_count, stock, before, gap, suffix = [Count.literal(value) for value in (2, 11, 2, 5, 3)] + topology = SimpleNamespace(families=1) + code = Code((("block", definition, ("good", 1, 0)), ("return",)), 0) + machine = Machine(binding, topology, (code,), Arena(3, 65536), Arena(10, 512)) + with machine.pool.install(): + machine.load_root(source, old_directory, program.tape, modulus, size, depth, + old_count, stock, before, gap, suffix) + machine.commit(source, "current") + machine.commit(directory, "directory") + machine.commit(old_count.tape, "prefixes") + machine.commit(stock.tape, "unused") + machine.save_count(Count.product(stock, before), "leading") + field_count, coordinate = machine.indices.literal(1), machine.indices.zero() + first = read_prefix(machine.tape("directory"), field_count) + machine.tape("directory").rewind() + try: + requests = (Request("adapter", coordinate, definition.plan.commands[0].reference), + Request("child", coordinate, child_kind="good")) + for request, expected_value in zip(requests, (0, 2)): + with no_decode(): + coefficient = binding.coefficient(machine, definition, first, request) + expected = machine.arena.literal(expected_value) + need(machine.context.raw.compare(coefficient, expected) == 0, + "selected identity-projector adapter and generated child coefficients") + machine.arena.free_many(coefficient, expected) + finally: + first.clear() + machine.indices.free_many(field_count, coordinate) + machine.boundary() + parent_words = snapshot(machine.arena), snapshot(machine.indices) + parent_roles = {label: body(tape) for label, tape in machine.roles.items()} + rejected = [] + original_events = macro_machine.block_events + for label, changes in (("wrong_parent", {"parent_identity": None}), + ("foreign_program", {"parent_identity": view(Program, machine, machine.program.tape)}), + ("wrong_source", {"source_code": definition.code + 1})): + def malformed(page, block): + iterator = original_events(page, block) + try: + for event in iterator: + yield replace(event, **changes) if event.kind == "enter" else event + finally: + iterator.close() + try: + with patch.object(macro_machine, "block_events", malformed): + machine.block(definition, ("good", 1, 0)) + except ValueError as error: + need(str(error) == "recursive gate belongs to the current program and source", + "malformed gate rejects at its binding check") + rejected.append(label) + else: + raise ValueError("malformed selected gate accepted") + finally: + machine.close_geometry() + machine.boundary() + restored(machine.arena, parent_words[0]) + restored(machine.indices, parent_words[1]) + need(all(body(tape) == parent_roles[name] for name, tape in machine.roles.items()) and + all(not body(tape) for tape in machine.handoff.values()) and machine.counts["calls"] == 0, + "reject before changing the parent or preparing a child capsule") + with no_decode(): + need(machine.block(definition, ("good", 1, 0)), "internal selected child gate") + machine.boundary() + need(not machine.root and machine.pc == 0, "child enters its finite node label") + need((inspect_count(machine.size), inspect_count(machine.depth)) == (168, 1), + "selected width and generation grants") + need(tuple(inspect_count(machine.count(label)) for label in ("old_count", "rows", "before", "gap", "suffix")) + == (2, 11, 2, 5 * 3 ** 176, 3), "complete selected child capsule extents") + root_size, root_unit, root_depth = machine.program.root() + need(tuple(inspect_count(word) for word in (root_size, root_unit, root_depth)) == (256, 2, 1), + "real selected extended root program") + machine.indices.free_many(root_size, root_depth) + machine.arena.free(root_unit) + level = machine.indices.literal(1) + metadata, parent_size, child_size = machine.program.step(level) + need(metadata == (0, definition.code, 42, 0, 0, 0) and + (inspect_count(parent_size), inspect_count(child_size)) == (256, 168), + "real selected appended descriptor") + machine.indices.free_many(level, parent_size, child_size) + changed = bytes(1 - bit for bit in reversed(initial)) + for bit in changed: + machine.output.append(bit) + machine.output.rewind() + with no_decode(): + need(not machine.complete_return(), "one parent restoration") + need(machine.root and machine.pc == 1, "resume the serialized successor without replay") + machine.boundary() + restored(machine.arena, parent_words[0]) + restored(machine.indices, parent_words[1]) + for label, tape in machine.roles.items(): + need(body(tape) == (changed if label == "current" else parent_roles[label]), + "exact parent stream restoration and protected result commit") + need(not body(machine.output), "consume protected child return port") + machine.close_frame() + machine.erase_work() + need(body(source) == initial and body(directory) == saved_directory and + body(program.tape) == saved_program and not body(old_directory) and + source.head == directory.head == old_directory.head == program.tape.head == 1, + "controlled borrowed streams and heads preserved") + restored(arena, borrowed_words[0]) + restored(indices, borrowed_words[1]) + result = dict(source_request=identifier, child_width=168, depth=1, + parent_successor_pc=1, source_bits=23, peak_scratch_leases=machine.pool.peak, + selected_coefficients=[0, 2], + rejected_gates=rejected, + counts=machine.counts, parking_charge=machine.numerical.machine.counts, + scope="Actual selected grammar, fixed-role CALL/RETURN; controlled child body and unused stock 11") + field.tape.clear() + program.tape.clear() + source.clear() + directory.clear() + old_directory.clear() + for value in (old_count, stock, before, gap, suffix): + value.close() + arena.free(modulus) + indices.free_many(size, depth) + need(not arena.live and not indices.live, "closed selected fixture") + return result + + +if __name__ == "__main__": + import json + print(json.dumps(run(), indent=2, sort_keys=True)) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/nested_bank_checks.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/nested_bank_checks.py new file mode 100644 index 0000000000..c48f874297 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/nested_bank_checks.py @@ -0,0 +1,81 @@ +"""The predecessor's complete recursive GL2 payload with shared numeric banks. + +Only the model's child frame construction changes. Its production Node, +Driver, residuals, routes and stream primitives keep their pinned bodies. +""" +from pathlib import Path +import sys +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import loader +loader.activate() + +import json +from unittest.mock import patch +import check_nested_model as model +from numerical_frame import NumericLease, Session +from words import need + + +def run(): + original_consumer, original_node = model.Consumer, model.Node + holder = {"leases": 0, "returns": 0} + + class Consumer(original_consumer): + def __init__(self, context, indices, program, size, depth, catalogue, topology, + incoming, plans, tracker, counters, root_axes=False, root_level=False): + self.lease = None + if root_level: + need("session" not in holder, "one shared numerical session for the model root") + holder["session"] = Session(context.arena, indices) + else: + session = holder["session"] + self.lease = NumericLease(session, context, indices, size, depth) + context, size, depth = self.lease.context, self.lease.width, self.lease.depth + incoming = model.UnitIncoming(context) + holder["leases"] += 1 + super().__init__(context, indices, program, size, depth, catalogue, topology, + incoming, plans, tracker, counters, root_axes, root_level) + + class Node(original_node): + def __init__(self, context, indices, program, parent_size, depth, + topology, consumer, incoming, stock_multiple=1): + self.lease = consumer.lease + if self.lease is not None: + # The old local invoke still passes its parent references. + # Replace them before the source Node reads any numeric value. + context, parent_size, depth = self.lease.context, self.lease.width, self.lease.depth + incoming = consumer.incoming + try: + super().__init__(context, indices, program, parent_size, depth, + topology, consumer, incoming, stock_multiple) + except BaseException: + if self.lease is not None: + self.lease.close(strict=False) + raise + + def run_generator(self, *args, **kwargs): + completed = False + try: + output = yield from super().run_generator(*args, **kwargs) + completed = True + return output + finally: + if self.lease is not None: + self.lease.close(strict=completed) + holder["returns"] += 1 + + with patch.object(model, "Consumer", Consumer), patch.object(model, "Node", Node): + result = model.run() + session = holder["session"] + need(holder["leases"] == holder["returns"] == 12, "twelve real completed shared-bank child calls") + need(session.codec.machine.tapes == [{}, {0: "^"}] and session.codec.machine.heads == [0, 1], + "complete payload run leaves no parked numerical frame") + need(not session.arena.live and not session.indices.live, "complete payload run closes both numerical banks") + return {"model": result, "shared_bank_calls": holder["leases"], + "shared_bank_returns": holder["returns"], "separate_child_arenas": 0, + "parking_charge": dict(session.codec.machine.counts), + "codec_charge": dict(session.codec.codec_counts)} + + +if __name__ == "__main__": + print(json.dumps(run(), indent=2)) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/numerical_frame.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/numerical_frame.py new file mode 100644 index 0000000000..dc92611dd5 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/numerical_frame.py @@ -0,0 +1,161 @@ +"""Actual recursive Frame entry/return using one pair of numerical banks.""" +from contextlib import contextmanager + +import loader +bank_codec = loader.activate() +from directory import Context, append_tape +from records import Program +from words import Ring, need + + +class NumericLease: + """Three owned argument grants and one matched parent-bank checkpoint.""" + def __init__(self, session, parent_context, parent_indices, width, depth): + self.session = session + self.arena, self.indices = session.arena, session.indices + need(parent_context.arena is self.arena and parent_indices is self.indices, + "one shared bank pair throughout the recursive run") + self.modulus = self.width = self.depth = self.ring = self.context = None + self.phase = "preparing" + self.entry_residues, self.entry_indices = frozenset(self.arena.live), frozenset(self.indices.live) + codes = parent_context.codes + try: + # All reads of parent numerical values finish before PARK. + self.modulus = self.arena.copy(parent_context.ring.modulus) + self.width = self.indices.copy(width) + self.depth = self.indices.copy(depth) + keep = ({self.modulus.slot}, {self.width.slot, self.depth.slot}) + self.phase = "parking" + session.codec.park(keep) + self.phase = "child" + self.ring = Ring(self.modulus) + self.context = Context(self.ring, codes) + except BaseException: + if self.phase == "preparing": + self.arena.rollback(self.entry_residues) + self.indices.rollback(self.entry_indices) + self.phase = "closed" + elif self.phase == "child": + self.close(strict=False) + # Incomplete codec operations are outside the retained interruption + # contract. Do not pretend that a partially written PUSH completed. + raise + + def close(self, strict=True): + need(self.phase == "child", "one completed numerical lease return") + first_error = None + if strict: + residues = {self.modulus.slot, self.ring.one.slot, self.context.cap.slot} + indices = {self.width.slot, self.depth.slot} + if self.arena.live != residues or self.indices.live != indices: + first_error = ValueError("callee closes its numerical locals before Frame return") + actions = [] + if self.context is not None: + actions.append(self.context.close) + if self.ring is not None: + actions.append(self.ring.close) + for arena, word in ((self.arena, self.modulus), (self.indices, self.width), (self.indices, self.depth)): + if word is not None: + def release(arena=arena, word=word): + if word.slot in arena.live: + arena.free(word) + actions.append(release) + for action in actions: + try: + action() + except ValueError as error: + if first_error is None: + first_error = error + # Any remaining live words belong to this child; the parent is still + # parked. Clear them before restoring the parent's original aliases. + self.arena.rollback(frozenset()) + self.indices.rollback(frozenset()) + self.session.codec.restore() + self.phase = "closed" + if first_error is not None and strict: + raise first_error + + +class Callee: + """Keep the source node body and distinguish return from interrupted exit.""" + def __init__(self, frame, node): + self.frame, self.node = frame, node + + def run_generator(self, source, *args, **kwargs): + self.frame.borrowed_source = source + result = yield from self.node.run_generator(source, *args, **kwargs) + self.frame.output = result + self.frame.callee_returned = True + return result + + +class SharedFrame: + def __init__(self, parent, program, event, session): + self.session = session + self.arena, self.indices = session.arena, session.indices + self.lease = self.program = self.node = None + self.closed = False + self.callee_returned = False + self.output = self.borrowed_source = None + try: + self.lease = NumericLease(session, parent.context, parent.indices, event.width, event.depth) + self.modulus, self.size, self.depth = self.lease.modulus, self.lease.width, self.lease.depth + self.ring, self.context = self.lease.ring, self.lease.context + self.program = Program(self.indices, self.arena, program.code_bits) + append_tape(program.tape, self.program.tape) + self.program.tape.rewind() + from node import SelectedNode + node = SelectedNode(self.context, self.indices, self.program, self.size, self.depth, + parent.specifications.catalogue, parent.specifications) + self.node = Callee(self, node) + if session.observe is not None: + session.observe("enter", self) + except BaseException: + if self.program is not None: + self.program.tape.clear() + if self.lease is not None and self.lease.phase == "child": + self.lease.close(strict=False) + self.closed = True + raise + + def close(self): + need(not self.closed, "shared Frame closes once") + try: + self.program.tape.clear() + self.lease.close(strict=self.callee_returned) + except BaseException: + if self.output is not None and self.output is not self.borrowed_source: + self.output.clear() + raise + finally: + self.closed = True + if self.session.observe is not None: + self.session.observe("return", self) + + +class Session: + """One physical codec shared by the source caller's whole nested run. + + The frozen logical scheduler still owns its generator continuation. + This adapter closes the numerical bank interface, not that separate one. + """ + def __init__(self, arena, indices, machine=None, observe=None): + self.arena, self.indices = arena, indices + self.codec = bank_codec.BankParking(arena, indices, machine) + self.observe = observe + self.installed = False + + @contextmanager + def install(self): + import recursive_call + need(not self.installed, "one active Frame adapter per session") + previous = recursive_call.Frame + self.installed = True + def frame(parent, program, event): + return SharedFrame(parent, program, event, self) + recursive_call.Frame = frame + try: + yield self + finally: + recursive_call.Frame = previous + self.installed = False diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/residual_blocks.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/residual_blocks.py new file mode 100644 index 0000000000..fba75e7649 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/residual_blocks.py @@ -0,0 +1,106 @@ +"""Defunctionalized residual itinerary at complete column-sweep boundaries. + +The cursor contains only a fixed-source command label and a three-way stage. +Variable column loops finish inside a block; an internal child can suspend +only its finite return label. This module does not interpret payload blocks. +""" +import loader +loader.activate() +from plan import Request +from role_parking import FiniteFields +from trace import adapters, child, columns, primitive +from words import need + + +class Cursor: + def __init__(self, plan, position=0, stage=0): + self.plan, self.position, self.stage = plan, position, stage + self.bound = 3 if plan.good else len(plan.commands) + self.schema = FiniteFields((self.bound + 1, 3)) + need(0 <= position <= self.bound and 0 <= stage < 3, + "finite residual cursor") + need(stage == 0 or (not plan.good and position < self.bound and + plan.commands[position].kind == "child"), + "pair stages belong to fallback child commands") + + @property + def done(self): + return self.position == self.bound + + def save(self, tape): + self.schema.write(tape, (self.position, self.stage)) + + @classmethod + def restore(cls, plan, tape): + schema = FiniteFields(((3 if plan.good else len(plan.commands)) + 1, 3)) + return cls(plan, *schema.read(tape)) + + def take(self): + """Advance before execution; the new cursor is the return continuation.""" + need(not self.done, "unfinished residual block") + position, stage = self.position, self.stage + if self.plan.good: + self.position += 1 + return ("forward", "good", "backward")[position], position, 0 + command = self.plan.commands[position] + if command.kind == "child": + if stage < 2: + self.stage += 1 + else: + self.position += 1 + self.stage = 0 + return "pair", position, stage + self.position += 1 + return "sweep", position, 0 + + +def events(page, block): + """Reference expansion of one block, using the pinned primitive events. + + A physical interpreter runs forward/backward/sweep and below-cutoff leaves + to completion. For an internal good/pair child it prepares the capsule and + parks the finite return cursor; this reference generator is not that stack. + """ + kind, position, stage = block + if kind in ("forward", "backward"): + yield from adapters(page, kind == "backward") + elif kind == "good": + yield from child(page, page.index.zero(), + page.raw.times_small(page.columns, 2 * page.plan.dimension - page.plan.rank), + page.raw.times_small(page.columns, page.plan.rank), "good") + elif kind == "sweep": + command = page.plan.commands[position] + need(command.kind in ("add", "sign"), "complete nonrecursive column sweep") + for column in columns(page): + target = page.point(command.target, column) + if command.kind == "sign": + yield from primitive("sign", target, None, None, page) + else: + source = page.point(command.source, column) + request = Request("adapter", page.index.copy(column), command.reference) + yield from primitive("add", target, source, request, page) + else: + need(kind == "pair", "closed residual block alphabet") + command = page.plan.commands[position] + i, k, dimension = command.target, command.source, page.plan.dimension + need(i < k, "ordered fallback child fields") + if stage != 1: + if (i < dimension) != (k < dimension): + return + half, remainder = page.raw.divmod(page.columns, page.two) + page.index.free(remainder) + if half.zero(): + page.index.free(half) + return + after = page.raw.times_small(page.columns, k + 1) + second = page.raw.subtract_exact(after, half) + page.index.free(after) + yield from child(page, page.raw.times_small(page.columns, k), second, + half, "unit", half=True) + else: + child_kind = command.reference.kind + need(child_kind in ("unit", "pair"), "selected fallback child kind") + yield from child(page, page.raw.times_small(page.columns, i), + page.raw.times_small(page.columns, k), page.index.copy(page.columns), + child_kind, i if child_kind == "pair" else 0, + i >= dimension if child_kind == "pair" else False) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/role_parking.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/role_parking.py new file mode 100644 index 0000000000..fc48c244ee --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/role_parking.py @@ -0,0 +1,116 @@ +"""Fixed canonical stream roles and finite control on the shared parking tape. + +The caller supplies dense role bodies over the retained record alphabet and +finishes numerical restoration before restoring this enclosing stream frame. +The codec reads no payload length or physical head coordinate into control. +""" +import loader +loader.activate() +from records import Tape +from words import BLANK, LEFT, ONE, ZERO, need + +BODY = (0, 1, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13) + + +class RoleParking: + def __init__(self, numerical_codec, roles): + self.port = numerical_codec + self.roles = tuple(roles) + need(len({id(tape) for tape in self.roles}) == len(self.roles), + "distinct permanent stream roles") + + def park(self): + port = self.port + port._empty_port() + port._command("begin") + for tape in self.roles: + tape.rewind() + while True: + symbol = tape.read() + if symbol == BLANK: + break + need(symbol in BODY, "dense fixed-alphabet role body") + for shift in range(4): + port._put_bit((symbol >> shift) & 1) + tape.write(BLANK) + tape.step(1) + tape.rewind() + port._write(1, "$") + port._rewind_port() + port._command("push") + port._empty_port() + + def restore(self): + port = self.port + port._empty_port() + # The record count and order are fixed at compilation, including empty + # roles. No unbounded handle or record-count decoder is necessary. + for tape in reversed(self.roles): + tape.rewind() + need(tape.read() == BLANK, "child clears canonical roles before return") + port._command("pop") + while port._read(1) != "$": + symbol = 0 + for shift in range(4): + symbol |= port._take_bit() << shift + need(symbol in BODY, "restored fixed-alphabet role symbol") + tape.append(symbol) + port._write(1, "_") + port._rewind_port() + tape.rewind() + port._command("end") + port._empty_port() + + +class FiniteFields: + """A fixed schema for source labels, slot labels and continuation states. + + Bounds belong to the compiled fixed-q source. Runtime dimensions, residue + values, tape extents and recursion depth must use encoded data roles. + """ + def __init__(self, bounds): + self.bounds = tuple(bounds) + need(all(type(bound) is int and bound > 0 for bound in self.bounds), + "positive compile-time finite-field bounds") + self.widths = tuple(max(1, (bound - 1).bit_length()) for bound in self.bounds) + + def write(self, tape, values): + need(len(values) == len(self.bounds), "finite continuation arity") + tape.rewind() + need(tape.read() == BLANK, "empty finite-control destination") + for value, bound, width in zip(values, self.bounds, self.widths): + need(type(value) is int and 0 <= value < bound, "finite continuation label") + for shift in range(width): + tape.append((value >> shift) & 1) + tape.rewind() + + def read(self, tape): + tape.rewind() + values = [] + for bound, width in zip(self.bounds, self.widths): + value = 0 + for shift in range(width): + bit = tape.read() + need(bit in (ZERO, ONE), "complete finite-control bit field") + value |= bit << shift + tape.step(1) + need(value < bound, "admitted finite continuation label") + values.append(value) + need(tape.read() == BLANK, "exact finite-control record extent") + tape.rewind() + return tuple(values) + + +def transfer(source, target): + """Move a complete owned result to its permanent canonical destination.""" + need(source is not target, "distinct result and canonical destination") + target.clear() + source.rewind() + while source.read() != BLANK: + symbol = source.read() + need(symbol in BODY, "dense transferred body") + target.append(symbol) + source.write(BLANK) + source.step(1) + source.rewind() + target.rewind() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/scratch_pool.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/scratch_pool.py new file mode 100644 index 0000000000..0f22807c65 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/scratch_pool.py @@ -0,0 +1,151 @@ +"""Reusable physical stream tapes for completed, nonrecursive source blocks. + +Each lease has an explicit end. A repeated cleanup of an ended lease cannot +erase a later borrower of the same physical role. No lease crosses CALL. +""" +from contextlib import contextmanager +import sys +from types import FunctionType + +import loader +loader.activate() +from records import Tape +from words import Arena, BLANK, LEFT, Meter, need + + +class Lease: + def __init__(self, pool, slot): + self.pool, self.slot, self.active = pool, slot, True + self.physical = pool.tapes[slot] + self.meter = Meter() + + def owned(self): + need(self.active and self.pool.live.get(self.slot) is self, "live scratch lease") + return self.physical + + @property + def head(self): + return self.owned().head + + def read(self): + if not self.active: + raise ValueError("live scratch lease") + self.meter.reads += 1 + return self.physical.read() + + def write(self, symbol): + if not self.active: + raise ValueError("live scratch lease") + self.meter.writes += 1 + self.physical.write(symbol) + + def step(self, direction): + if not self.active: + raise ValueError("live scratch lease") + self.meter.moves += 1 + self.physical.step(direction) + + def append(self, symbol): + self.operation(self.physical.append, symbol) + + def rewind(self): + self.operation(self.physical.rewind) + + def operation(self, method, *args): + """Run the same literal tape loop without a lease wrapper at each cell. + + Counter differences update only the observer's lease meter; the method + still performs its real reads, writes and unit moves on the physical tape. + """ + if not self.active: + raise ValueError("live scratch lease") + meter = self.physical.meter + before = meter.reads, meter.writes, meter.moves + try: + return method(*args) + finally: + self.meter.reads += meter.reads - before[0] + self.meter.writes += meter.writes - before[1] + self.meter.moves += meter.moves - before[2] + + def clear(self): + if not self.active: + return + self.operation(self.physical.clear) + self.active = False + del self.pool.live[self.slot] + + +class ScratchPool: + def __init__(self, capacity): + need(type(capacity) is int and capacity > 0, "fixed scratch capacity") + self.tapes = tuple(Tape() for _ in range(capacity)) + self.live = {} + self.peak = self.allocations = 0 # Checker observations, never selectors. + + def acquire(self): + for slot, tape in enumerate(self.tapes): + if slot not in self.live: + # clear()'s rewind supplies the origin invariant. No physical + # head coordinate enters the allocator's finite slot choice. + need(tape.read() == BLANK, "empty scratch role before reuse") + lease = Lease(self, slot) + self.live[slot] = lease + self.peak = max(self.peak, len(self.live)) + self.allocations += 1 + return lease + raise ValueError("fixed scratch role inventory exhausted") + + def empty(self): + need(not self.live, "completed macro closes all scratch leases") + for tape in self.tapes: + need(tape.read() == BLANK, "completed macro leaves scratch bodies empty") + tape.step(-1) + need(tape.read() == LEFT, "completed scratch head stands after LEFT") + tape.step(1) + + @contextmanager + def install(self): + """Specialize only the authenticated source's Tape allocation sites. + + Defaults retain the original Tape class object after imports; specialize + those defaults as well as module globals. Restore the process namespace + on exit. This adapter never changes a frozen file. + """ + import controller + saved = [] + for module in tuple(sys.modules.values()): + path = getattr(module, "__file__", None) + if path is None or not str(path).startswith(str(loader.CALLER)): + continue + for name, value in tuple(vars(module).items()): + if value is Tape: + saved.append((module, name, value)) + setattr(module, name, self.acquire) + elif isinstance(value, FunctionType) and value.__defaults__: + old = value.__defaults__ + if any(item is Tape for item in old): + saved.append((value, "__defaults__", old)) + value.__defaults__ = tuple(self.acquire if item is Tape else item for item in old) + original_close = controller.Callback.close + original_tape_init, original_arena_init = Tape.__init__, Arena.__init__ + def close(callback): + original_close(callback) + # The source's close ends these borrows but leaves their empty Tape + # objects to the host allocator. End the four physical leases here. + for stack in (callback.pending, callback.values): + stack.tape.clear() + stack.reverse.clear() + controller.Callback.close = close + def forbid_tape(_self, *_args, **_kwargs): + raise ValueError("physical Tape allocation inside a completed macro") + def forbid_arena(_self, *_args, **_kwargs): + raise ValueError("numerical Arena allocation inside a completed macro") + Tape.__init__, Arena.__init__ = forbid_tape, forbid_arena + try: + yield self + finally: + Tape.__init__, Arena.__init__ = original_tape_init, original_arena_init + controller.Callback.close = original_close + for owner, name, value in reversed(saved): + setattr(owner, name, value) diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/verify.py b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/verify.py new file mode 100644 index 0000000000..fbdc87b9f9 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-physical-caller/verify.py @@ -0,0 +1,52 @@ +"""Replay distinct executable boundaries of the fixed-role caller argument.""" +import argparse +from hashlib import sha256 +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import loader + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--suite", choices=("frame", "continuation", "nested", "macro_nested", "macro_local", "macro_selected"), required=True) + parser.add_argument("--emit", action="store_true") + args = parser.parse_args() + loader.activate() + loader.compatibility_controls() + if args.suite == "frame": + import frame_checks + result = frame_checks.run() + elif args.suite == "continuation": + import continuation_checks as checks + result = dict(cursor=checks.cursor_checks(), roles=checks.nested_roles(), + transfer=checks.transfer_checks(), parents=checks.parent_controls()) + elif args.suite == "nested": + import nested_bank_checks + result = nested_bank_checks.run() + elif args.suite == "macro_nested": + import macro_checks + result = macro_checks.run() + elif args.suite == "macro_local": + import macro_local_checks + result = macro_local_checks.run() + else: + import macro_selected_checks + import macro_controls + result = dict(selected=macro_selected_checks.run(), controls=macro_controls.run()) + encoded = json.dumps(result, sort_keys=True, separators=(",", ":")).encode() + receipt = sha256(encoded).hexdigest() + if not args.emit: + expected = json.loads((HERE / "RESULT.json").read_text())[args.suite]["sha256"] + if receipt != expected: + print(json.dumps(dict(suite=args.suite, sha256=receipt, result=result), indent=2, sort_keys=True)) + raise ValueError("complete suite receipt differs: " + args.suite + ": " + receipt) + print("PASS_SELECTED_BIT_PHYSICAL_CALLER_" + args.suite.upper()) + print(json.dumps(dict(suite=args.suite, sha256=receipt, result=result), indent=2, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/r437-preparation-composition/vendor/research/selected-bit-recursive-closure/PROOF.md b/research/r437-preparation-composition/vendor/research/selected-bit-recursive-closure/PROOF.md new file mode 100644 index 0000000000..6c410cab57 --- /dev/null +++ b/research/r437-preparation-composition/vendor/research/selected-bit-recursive-closure/PROOF.md @@ -0,0 +1,433 @@ +# Recursive closure of the selected BIT interchange + +We give a written construction on a fixed number of finite-alphabet multitape +streams. We retain the sequential stream model of `02-streams.tex`: complete +address ranges, arbitrary Boolean payload, charged scans, counters, rewinds and +scratch erasure. We prove an ordinary binary chunk-interchange bound + + O(V E^(1-a)), a = 169711/100000000 = 0.00169711, + +for two complete E-bit address chunks and arbitrary complete spectators, where +V counts payload bits. The machine restores spectators and clears its work. +We fix one odd prime q>2^80 throughout; constants and the fixed tape count may +depend on q and the selected word. We make no practical runtime claim. + +We supply a mathematical algorithm and finite interface checks. We have not +translated the entire recursive machine into transition tables or a proof +assistant. Reviewers must assess the composition argument below. The selected +finite certificate and the multiplication theorem have further interfaces, +including the complex supplier and analytic transfer; we leave their status +unchanged. + +## 1. Sources and the recursive contract + +We use DreamingOfClouds' selected PR589 word, building on eumemic's PR555 word, +and alephnan's PR1627 literal/chronological proof. We reuse the GL local-ring +packet integration of PR2195, the good adapters of PR2171, the fallback word +of PR2159/PR2207, and commdata2338's PR2188 weight grammar. Source527 already +gives the weighted factorization and outer borrowing method. PR1379 supplies +the unequal-buffer parking boundary. `SOURCES.json` pins the executable inputs; +`NOTICE.md` identifies the pending source commits and mathematical reuse. + +Fix an original radix-q width e, c=17/10000, and w=ceil(e^c). Put B=q^w and +R=Z/B. We keep w fixed throughout one coarse recursion. Let C_n reverse n +atom positions. For a diagonal unit vector A, we construct + + F_A(H,D) = (A C_n D, C_n A^-1 H). + +We quantify over any two ordered complete n-atom chunks, with arbitrary +complete preceding, intervening and following fields. This includes two +subchunks of one former bank, which we need for fallback reversals. We allow +arbitrary correlated dirty payload values. + +We generate A from a constant unit by the Good and FallbackPair expressions +below. A may read earlier frozen matrix fields; it may not read this node's +fresh family, matrix or unused stock. A unit child starts a new constant +expression but retains its global generation depth. We bound that depth by +the original root width, including after such a reset. + +At return we require the specified address permutation on I/O, pointwise +restoration of row and spectator coordinates, empty local work and restored +head positions. For a parking top h, we visit no cell below h-1 and write no +cell below h. We require a time bound uniform in parked contents and h. + +## 2. Actual residuals and full-ring preparation + +PR1627 reconstructs 636 rational frame projectors and proves the nesting +identities used by both selected literal programs. Their entries lie in +Z[1/2]. For an idempotent P0 of rational rank r, its characteristic polynomial +is T^(64-r)(T-1)^r. Reduction modulo an odd q preserves this identity and +idempotent diagonalizability, hence rank r, including when q divides r. + +Choose independent image columns of P0 and kernel columns of I-P0 modulo q. +Their lifts form a unit matrix B0 over R and satisfy + + P0 = B0 diag(I_r,0) B0^-1. + +We compute this identity in control arithmetic. We do not move payload through +B0. For the actual owner chart sigma and raw physical header g, the provider +passes g sigma B0 to the retained coordinate normalizer. It therefore computes +exactly P=g sigma P0 sigma^-1 g^-1. + +For MOVE, we use the positive nested frame difference and the actual owner +sigma. The common stage projector cancels. The reflected orientation gives +the same positive residual. For COPY, we first copy and align the source +packet to d=g sigma. Its private header is d and its projector label is P0; +we set its additional chart to I. Applying sigma again would change the +operator. ERASE retains the literal transported-source equality guard. + +For an idle remainder, we subtract the actual hosted slots from its pending +axes and use the fixed family chart. We skip the zero remainder. The provider +binds 28,278 canonical requests and 32 replicas, giving + + H_1=381024, H_2=400416, H_3=22752, H_4=26880, + H_5=29376, H_6=17376, H_7=26784, H_42=288. + +We obtain 541 distinct base labels and 1,235 assembled charts. The finite +checks verify image/kernel bases over Z/9 and Z/25 for each label, and 120 +full 128-coordinate operators from selected MOVE, COPY and idle requests. +These cases supplement the identities; they do not enumerate GL64(R). + +## 3. One schedule per complete low packet + +Write g=g0+qG with g0 in GL64(F_q) and G in [q^(w-1)]^4096. For a fixed +request, call g0 good when the first r northeast pivots of PC are units. +Equivalently, require the leading k principal minors of P to be nonzero +modulo q for 1<=k<=r. Unit tests depend only on g0. The full coefficients +still depend on G. + +For each k, multiply its minor by det(g)^k to obtain a polynomial of degree +at most 64k in the entries of g. Conjugating the fixed split rank-r projector +to diag(I_r,0) gives a nonzero witness. The union of these zero sets has +fraction at most 64r(r+1)/(2q) in all matrices. Since + + |GL64(F_q)|/q^4096 = product_(i=1)^64 (1-q^-i) > 1/2, + +the bad fraction for this request is at most 2*64^3/q<10^-16. We use this +bound separately for each paid edge. We do not require one matrix to be good +for every label or multiply the bound by the number of labels. + +On a good packet, unweighted northeast elimination gives unit-lower matrices +L,R0 and a pivot vector delta. Split rank and a unit rank-r minor force the +remaining Schur block to vanish over R itself. We retain q-multiples in the +arithmetic; reduction modulo q alone would not establish that conclusion. +The normal-form factorization in source527/PR2171 uses ordered head, tail +and cross ADDs, one weighted child, and the inverse adapters. For n=64f, + + A_child[k f+j] = A[k f+j] delta_k, 0<=k=1. Recompute on split and merge rather than retaining +an array indexed by the high fibre. Ripple counters have amortized linear +movement cost; initialize them once per scan and do not reread unrelated +spectator counters per fibre. Fixed low tables and finite labels depend on +q, not e. Thus these scans have the stated uniform bounds. For independently +chosen n,w,d, retain the preparation quotient instead of this absorption. + +The selected word has fixed length. Good and bad bodies use O(n) ordered +atom passes; header routes use O(Vw) each; selections, XORs, erasure and +parking use O(V) each. We include their finite q-dependent multiplicities +in a constant C. The local nonrecursive charge is C V(n+w), including the +remainder leaf. This is an asymptotic accounting, not an explicit optimized +finite invoice for the selected multiplier. PR2212 prices the separate +same-family route inventory and leaves further whole-invocation charges. + +Normalize by logical volume and bound the worst generated call by T(n,w). +For positive widths below 64, T<=Cw. The bad fraction is at most epsilon=10^-16 +for each request, and each fallback has at most 32*64^2 children of width at +most f=floor(n/64). We may overcount good calls on bad classes, obtaining + + T(n,w) <= sum_r (H_r/W) T(r f,w) + + epsilon F/W * max_(1<=j<=f) T(j,w) + C(n+w), + F=32*64^2*sum_r H_r=118606528512. + +We prove a monotone upper bound, so the maximum causes no extra factor. +Define mu_t=(sum H_r(r/64)^t + epsilon F(1/64)^t)/W. The two retained outward +rational engines independently give + + mu_1 = 2874298095721977/2890625000000000 < 199/200, + mu_(1-c) < 9999/10000. + +Induct on n and use f<=n/64. Increasing C to cover the leaf constants gives + + T(n,w) <= 200 C n + 10000 C n^(1-c) w. + +Indeed the first term leaves at least Cn after the recursive linear mass, +and the second leaves at least C n^(1-c)w>=Cw. We treat n=0 separately. +The resulting constants are independent of ancestor contents, stack top, +row multiplicity and original e. + +## 8. Internal borrowing and binary interchange + +Choose the sufficient stock S=K(w)^D(e) from the original width e, before +choosing a body width. Since M complete bounded preparation interval. +Apache-2.0. Chris R / Clear1nsight, substantial OpenAI Codex assistance. +""" +from pathlib import Path +from types import SimpleNamespace as NS +import hashlib,importlib.util,itertools,json,sys,tempfile +HERE=Path(__file__).resolve().parent + +def need(ok,msg): + if not ok: raise ValueError(msg) +def sha(data):return hashlib.sha256(data).hexdigest() +def actions(m):return {k:getattr(m,k) for k in ('reads','writes','moves')} +def minus(a,b):return {k:a[k]-b[k] for k in a} +def add(rows):return {k:sum(r[k] for r in rows) for k in ('reads','writes','moves')} +def load(name,path): + m=NS(__file__=str(path));exec(compile(path.read_bytes(),str(path),'exec'),m.__dict__);return m + +def authenticate_vendor(base): + pins=json.loads((HERE/'PREDECESSORS.json').read_text()) + need(sha((HERE/'POOLED-SOURCES.json').read_bytes())==pins['pooled_manifest_sha256'],'exact pooled source manifest') + rows=json.loads((HERE/'POOLED-SOURCES.json').read_text());expected={r['path']:r['sha256'] for r in rows} + need(len(rows)==len(expected)==154,'unique complete pooled source inventory') + expected_dirs=set() + for name in expected: + path=Path(name);need(not path.is_absolute() and '..' not in path.parts,'relative retained source path') + expected_dirs.update(str(x) for x in path.parents if str(x)!='.') + need(base.is_dir() and not base.is_symlink(),'regular vendor root') + observed_files=set();observed_dirs=set() + for path in base.rglob('*'): + need(not path.is_symlink(),'no retained source links') + relative=path.relative_to(base).as_posix() + if path.is_dir():observed_dirs.add(relative) + else: + need(path.is_file(),'regular retained source file');observed_files.add(relative) + need(observed_files==set(expected) and observed_dirs==expected_dirs,'exact materialized source inventory') + for name,digest in expected.items(): + need(sha((base/name).read_bytes())==digest,'authenticated pooled source '+name) + return rows + +def sources(destination): + pins=json.loads((HERE/'PREDECESSORS.json').read_text()) + for name,pin in pins['files'].items(): + raw=(HERE/name).read_bytes();need(sha(raw)==pin['sha256'],'exact predecessor adapter/source '+name) + need(hashlib.sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest()==pin['git_blob'],'predecessor Git blob '+name) + rows=authenticate_vendor(HERE/'vendor') + for row in rows: + target=destination/row['path'];target.parent.mkdir(parents=True,exist_ok=True) + target.write_bytes((HERE/'vendor'/row['path']).read_bytes()) + sys.path.insert(0,str(destination/'research/r437-pooled-native-interface')) + import replica_catalogue as rc + cat,top=rc.load() + from catalogue import Specifications + from sources import identity + specs=Specifications(cat) + low=tuple(tuple(map(int,row)) for row in identity(64)) + handle=rc.source_handle(cat,896352,False,low);spec=rc.resolve_handle(cat,specs,handle) + need(spec.template.rank==14 and not spec.good and cat.codes.bits==6512,'actual pooled IDLE specification') + old_handle=rc.source_handle(cat,1603,True,low);old_spec=rc.resolve_handle(cat,specs,old_handle) + need(cat.requests[1603].kind=='COPY' and old_spec.template.rank==7,'actual old COPY source context') + plan=specs.plan(handle.code);command=plan.commands[0] + need(command.kind=='child' and command.reference.kind=='unit','actual first fallback UNIT child') + prior=load('prior4025',HERE/'predecessor4025/verify.py');prior.authenticate() + import words,records,directory,counts,cardinality,stream + for name,module in [('words',words),('records',records),('directory',directory),('counts',counts),('cardinality',cardinality),('stream',stream)]: + need(sha(Path(module.__file__).read_bytes())==prior.PINS[name+'.py'][0],'same complete predecessor runtime '+name) + return NS(cat=cat,specs=specs,handle=handle,spec=spec,plan=plan,prior=prior,source_identity=cat.source_identity,old_handle=old_handle,old_spec=old_spec) + +def run_case(source,h,B,shared,cursor,mutation=None): + import words as w,records as r,directory as d,counts,controller,macro_binding,packet,cardinality + import forward_fields + registry=[];old_init=r.Tape.__init__ + def register(t):old_init(t);registry.append(t) + r.Tape.__init__=register + original_callback=macro_binding.Callback;original_dir=d.high_power;original_counts=counts.high_power + if cursor:macro_binding.Callback=forward_fields.install(controller.Callback,r,Path(controller.__file__),vars(controller)) + if shared: + replacement=lambda value,ring,q,dimension:source.prior.high_power_shared(value,ring,q,dimension,cardinality.radix_power) + d.high_power=counts.high_power=replacement + Q=source.cat.codes.bits;L=3;root=2048*64**h;I=root.bit_length()+1 + ia=w.Arena(I,128);ra=w.Arena(L,4200);modulus=ra.literal(3);ring=w.Ring(modulus) + code=source.handle.code + history_codes=[source.old_handle.code if i%2==0 else code for i in range(h)] + program=r.Program.fixture(ia,ra,root,2,[(2,c,source.specs[c].template.rank,0,False,False) for c in history_codes],Q) + high=[[0]*64 for _ in range(64)] + old_fields=r.Fields.fixture(ia,ra,[(c,high) for c in history_codes],Q) + old=r.Tape();old.cells=bytearray([w.LEFT])+old_fields.tape.cells[1:]*B;old_fields.tape.clear() + old_count=counts.Count.literal(B);depth=ia.literal(h) + spectator=ra.literal(1);spectator.head=2;ispectator=ia.literal(1);ispectator.head=2 + protected_tapes=[program.tape,old,old_count.tape] + protected=[(x,bytes(x.cells),x.head) for x in [ra.template,ia.template]+[ra.words[i] for i in ra.live]+[ia.words[i] for i in ia.live]+protected_tapes] + live=(set(ra.live),set(ia.live));base_slots=(len(ra.words),len(ia.words)) + before_tapes=set(map(id,registry)); phases={} + def snapshot():return {'record':add([actions(x.meter) for x in registry]),'residue':actions(ra.meter),'index':actions(ia.meter)} + def phase(name,fun): + before=snapshot();v=fun();after=snapshot();phases[name]={lane:minus(after[lane],before[lane]) for lane in before};return v + original_inspect=w.Word.inspect + w.Word.inspect=lambda self:(_ for _ in ()).throw(ValueError('runtime Word decoding forbidden')) + before=snapshot();ra.meter.peak_live=len(ra.live);ia.meter.peak_live=len(ia.live) + if mutation=='skip_context_share':counts.high_power=original_counts + context=phase('context_create',lambda:d.Context(ring,source.cat.codes)) + if shared:counts.high_power=d.high_power + size,fields=phase('frame_controls',lambda:(ia.literal(2048),ia.literal(h+1))) + runtime=NS(indices=ia,arena=ra,context=context,program=program,binding=NS(codes=source.cat.codes),size=size,depth=depth) + # size is part of the owned preparation interval and is released below. + binding=object.__new__(macro_binding.SelectedBinding);binding.specifications=source.specs + definition=NS(code=code);event=NS(child_kind='unit',field=0,reverse=False,half=False) + if mutation=='stale_code':definition.code=code^1 + directory,prefixes=phase('directory_produce',lambda:d.produce(old,depth,old_count,code,context)) + def validate(): + first=packet.read_prefix(directory,fields);directory.rewind() + try:binding.validate_residual(runtime,definition,first) + finally:first.clear() + phase('read_validate_clear',lambda:None) if mutation=='skip_validation' else phase('read_validate_clear',validate) + def child(): + first=packet.read_prefix(directory,fields);directory.rewind() + try:return binding.child_program(runtime,definition,event,first) + finally:first.clear() + output=phase('read_child_clear',child) + out_sha=sha(bytes(output.cells));dir_sha=sha(bytes(directory.cells)) + # Independent mathematical serialization, external to runtime control. + def field(value,width):return [(value>>i)&1 for i in range(width)]+[5] + expected=[w.LEFT,7]+field(root,I)+field(2,L)+field(h+1,I)+[6] + parent=root + for c in history_codes+[code]: + child=parent//64;rank=source.specs[c].template.rank + expected += [8] + for j,value in enumerate((2,c,rank,0,0,0)):expected += field(value,Q if j==1 else 16) + expected += field(parent,I)+field(child,I)+[6];parent=child + need(parent==32 and bytes(output.cells)==bytes(expected),'independent full child bytes and 2048-to32 extent') + need(len(directory.cells)==1+B*(h+1)*(Q+2+4096*(L+1)),'complete cap1 directory extent and duplicate prefixes') + need(all(bytes(x.cells)==raw and x.head==head for x,raw,head in protected),'all borrowed bytes and heads protected') + need(directory.head==output.head==prefixes.tape.head==1,'all returned heads') + def dispose(): + output.clear();directory.clear();prefixes.close();ia.free_many(fields,runtime.size);context.close() + phase('dispose_context_and_outputs',dispose) + after=snapshot();total={lane:minus(after[lane],before[lane]) for lane in before} + need(live==(set(ra.live),set(ia.live)),'full interval numerical ownership restored') + need(all(add([p[lane] for p in phases.values()])==total[lane] for lane in total),'phase invoice partitions complete interval') + need(all(bytes(x.cells)==raw and x.head==head for x,raw,head in protected),'teardown protected bytes and heads') + need(all(t.head==1 and all(c==w.BLANK for c in t.cells[1:]) for t in registry if id(t) not in before_tapes),'all new record tapes cleared') + need(all(word.head==1 and all(c==w.BLANK for c in word.cells[1:]) for bank in (ra,ia) for i,word in enumerate(bank.words) if i not in bank.live),'all released numerical backing erased') + result=dict(h=h,B=B,Q=Q,I=I,L=L,shared=shared,cursor=cursor,phases=phases,total=total,output_sha256=out_sha,directory_sha256=dir_sha, + created_record_tapes=sum(id(t) not in before_tapes for t in registry),additional_residue_peak=ra.meter.peak_live-len(live[0]),additional_index_peak=ia.meter.peak_live-len(live[1]), + new_residue_slots=len(ra.words)-base_slots[0],new_index_slots=len(ia.words)-base_slots[1],protected_state_restored=True, + source_request=896352,source_rank=14,source_good=False,child_kind='unit',parent_width=2048,child_width=32) + w.Word.inspect=original_inspect + macro_binding.Callback=original_callback;d.high_power=original_dir;counts.high_power=original_counts;r.Tape.__init__=old_init + return result + +def audit(): + with tempfile.TemporaryDirectory() as td: + source=sources(Path(td));pairs=[] + for h,B in [(0,1),(2,2)]: + variants=[run_case(source,h,B,s,c) for s,c in itertools.product((False,True),repeat=2)] + a,b,c,d=variants + need(len({x['output_sha256'] for x in variants})==len({x['directory_sha256'] for x in variants})==1,'four-way identical output') + for lane in ('record','index','residue'): + need(minus(a['total'][lane],d['total'][lane])==add([minus(a['total'][lane],b['total'][lane]),minus(a['total'][lane],c['total'][lane])]),'exact independent additive saving '+lane) + need(a['total']['record']==c['total']['record'],'radix sharing preserves complete record invoice') + need(a['total']['residue']==b['total']['residue'],'cursor preserves complete residue invoice') + for field in ('additional_residue_peak','additional_index_peak','created_record_tapes','new_residue_slots','new_index_slots'): + need(len({x[field] for x in variants})==1,'same full lifecycle storage '+field) + # Every interval has two independent 64^2 radix families: Context and producer. + for phase in ('context_create','directory_produce'): + delta=minus(a['phases'][phase]['residue'],c['phases'][phase]['residue']) + need(delta=={'reads':2141685,'writes':389025,'moves':2276820},'exact 4095 removed validated radix traversals') + pairs.append(dict(variants=variants,saved={lane:minus(a['total'][lane],d['total'][lane]) for lane in ('record','residue','index')})) + return dict(status='PASS_ACTUAL_POOLED_PREPARATION_COMPOSITION',source_identity=source.source_identity,cases=pairs, + full_Pi_closed=False,physical_payload_executed=False,selected_kappa_changed=False) +if __name__=='__main__': + result=audit() + if '--write' in sys.argv:(HERE/'RESULT.json').write_text(json.dumps(result,sort_keys=True,indent=2)+'\n') + else:need(result==json.loads((HERE/'RESULT.json').read_text()),'exact complete receipt') + print(result['status'])