diff --git a/research/e8-punctured111-star/EXPECTED.json b/research/e8-punctured111-star/EXPECTED.json new file mode 100644 index 0000000000..ac7f102363 --- /dev/null +++ b/research/e8-punctured111-star/EXPECTED.json @@ -0,0 +1,127 @@ +{ + "word": { + "v": 111, + "R": 489, + "cst": 63, + "copy_ranks": [ + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7 + ], + "punctured": [ + 39, + 52, + 57, + 71, + 76, + 78, + 103, + 109, + 114 + ], + "content_sha256": "599dbe2184a0b99f01345543a6523e41df7b164513fc25dc7b5dadab548205d3", + "local_histogram": { + "1": 1182, + "2": 1332, + "3": 63, + "4": 153, + "5": 9, + "6": 129, + "7": 9 + }, + "five_stage_payload_bits": 91, + "eleven_stage_payload_bits": 91, + "source_destination_gates_A": 501 + }, + "eleven": { + "bit_lower": "165947204563779652541/100000000000000000000000", + "bit_lower_decimal": "0.00165947204563779652541", + "profile": { + "1": 104016, + "2": 120768, + "3": 5544, + "4": 17015, + "5": 792, + "6": 14904, + "7": 7896, + "28": 1, + "56": 1971 + }, + "emitted_program_sha256": "80c4e0f4d635a0c09a3e1a0ef81cc7e0590233410840d5b26d1149daa049718b", + "bit": { + "live": 8880, + "physical": 8889, + "maxchild": 56, + "rank_mass": 689304, + "hosted_residuals": 43032, + "prefix_bits": 1843, + "charged_prefix_bits": 1856, + "coefficient_bits": 1843, + "three_level_coefficient_bits": 5583, + "charged_three_level_coefficient_bits": 5632, + "row_coefficient": 19431, + "halving_depth": 3 + } + }, + "kappa": { + "pr535": { + "kappa": "793733736881443/500000000000000000", + "kappa_decimal": "0.001587467473762886", + "binding_component": "complex", + "complex_lower": "1589991533606044174031/1000000000000000000000000" + } + }, + "control": { + "word_content_sha256": "8639e22008c24a5690dd250eba702fe5fca85ddd036dcbec20baba77b7e213ba", + "five_stage_payload_bits": 102, + "bit_lower": "393688338238452162729/250000000000000000000000", + "bit_lower_decimal": "0.001574753352953808650916", + "profile": { + "1": 105600, + "2": 130560, + "4": 19680, + "6": 14400, + "7": 7680, + "8": 792, + "48": 1, + "56": 2742 + }, + "emitted_program_sha256": "7da5e3cb8daa231104f4e55f16c560fa56a59f10b8b2789e173923d9d2ca46fc", + "kappa": { + "pr484": "662515748707749/500000000000000000", + "pr471": "260706019542937/200000000000000000", + "pr458": "323880830669511/250000000000000000" + }, + "stacking": { + "calls": 88, + "calls_with_stacked_helpers": 80, + "max_helpers_on_one_family": 7 + } + }, + "live_bit": { + "source": "PR #510 (R480, nine stages), the bit c of PR #535", + "bit_lower": "396861776523137034277/250000000000000000000000", + "bit_lower_decimal": "0.001587447106092548137108" + }, + "pr535": { + "kappa": "1584931111785787/1000000000000000000", + "kappa_decimal": "0.001584931111785787", + "complex_lower": "1589991533606044174031/1000000000000000000000000" + }, + "hosting": { + "rule": "PR #442's pooled whole-residual integer programme (hosting_core.solve), eight replicas pooled, as in #472 / #493 / #503 / #510", + "stacking": { + "calls": 88, + "calls_with_stacked_helpers": 82, + "max_helpers_on_one_family": 7 + }, + "c_strict_per_stage": "0.001651282591289915996071", + "note": "strict = one helper per family copy per STAGE (stricter than #458 per invocation): a lower bound on the c of any #458-compliant hosting; kappa unchanged (complex-bound)" + } +} diff --git a/research/e8-punctured111-star/LICENSE b/research/e8-punctured111-star/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/e8-punctured111-star/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/e8-punctured111-star/MANIFEST.json b/research/e8-punctured111-star/MANIFEST.json new file mode 100644 index 0000000000..33372c4ec6 --- /dev/null +++ b/research/e8-punctured111-star/MANIFEST.json @@ -0,0 +1,26 @@ +{ + "files": { + "EXPECTED.json": "dd078d075b153ea2ed02a4bbd1fe467315930f4d7dc90f2c34cd2c33e06a5029", + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "NOTICE.md": "21fb6670dee5bf48cbee03db9273af62172e7d4c689102eda132ab3c4f30de19", + "README.md": "90e68ad9c861821ac0b8b5fa75470f6240aacdcc519b3879a53efab2bf44dfb8", + "code/adapt.py": "b9a50303147a3003ad94fc4b1a822d4fca7f9b9e917d165e3c45152575302a0e", + "code/adapt503.py": "04ec15262595e502796efc1f100f1efd4f28585add48377af1bda702a12c0e40", + "code/compose_control.py": "6eba9d46d6c176f4a3898b0b5c8d3047126becd8e552416b3eef5cea08250cc1", + "code/mutants.py": "796655c0eb43143ae6a7d8211a9eb473609818ca0e55e6949dd24b457b792070", + "code/price/price458.py": "25e314d5f020c895ce6753dda5339206ceed81b3909b29bf564ff68d33135983", + "code/price/pricex.py": "3d8aba64c8cad6694a31e0abd7689c139f23d84a8701d6c32e1253421fe8a131", + "code/punct_cfg.py": "7cedd3416d6a8ce2e6393cea32dc1d11032190787a593a0ad964a0b62fc407f3", + "code/word/gen_punct.py": "f2567d223a0fdbf59b14bb0c053fdeaf1178ca47d7616f84d30ac79b085ed101", + "code/word/pword.py": "a15ef6d2d110b69ed2a835ecd5d62df40ebfe76a95055a86603e56da9c04ea60", + "data/bitE8mut-v111-r489.json.gz": "c78317ab05ea175dc380f4dce2bafdbcd7e8b46f0c9d6baf350c2f604bb3ae4e", + "data/complex/pr535/EXPECTED.json": "cb734055c36681d38cf431a6926b7713351a94073cfba37d70a5384a9ef0d178", + "data/complex-b.json": "51426c86f95bc84b30c8c193b5b39b08742587a2eaadd8f83cca5ae3b36bdb49", + "data/control-r480/EXPECTED-pr503.json": "5e4a6b141ffd110a539f3be05be1bd249dc5ecec898cdd838642c71f9c42ac9b", + "data/control-r480/bitE8mut-r480.json.gz": "92e399e9a486b55229b5624632ac54f800dd9e022f2aee97f1e5f264bbc0ef5c", + "data/control-r480/hosting-r480.json": "29d55f5389a6bd7650e083b8318e725b505d8a6460a7afb4ddb08824675b6827", + "data/hosting-v111-r489.json": "862155e5c341053668ac1a18db05591417c38b9fe5f395d64a3b0a17a1502042", + "verify.py": "e897efb99839fab7140c26f255c57eb7e7c9bf78594184c6ddabe875b2a7e251" + }, + "parent_manifest_sha256": "7f25c41d0400ef5adf763eae6e166003a9b59e5a655b860c04b052f6731c7297" +} diff --git a/research/e8-punctured111-star/NOTICE.md b/research/e8-punctured111-star/NOTICE.md new file mode 100644 index 0000000000..623399dbaf --- /dev/null +++ b/research/e8-punctured111-star/NOTICE.md @@ -0,0 +1,28 @@ +# Notice + +Apache-2.0 (`LICENSE`). Prepared by DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code. + +## New in this package + +- `code/punct_cfg.py`: the one configuration (v, R, live labels, totals map, CST) of the punctured chain. +- `code/adapt.py`: writes adapted copies of nine of PR #493's files (`emit`, `audit`, `local_audit`, `assemble`, + `host_select`, the nine- and eleven-stage `geometry`, the independent checker, `mutate_records`) by 56 listed string edits + (each anchor checked to occur exactly the listed number of times). The parent tree is never modified. +- `code/word/` (`pword.py`, `gen_punct.py`): the punctured word builder (PR #493's generator logic restricted to a live port + subset, nine pseudo-target totals). Written for this package; imports the parent's `geom`, `e8`, `wordkit` and plan. +- `code/price/pricex.py`: the exact pricing harness (local-histogram replay of the word, the same whole-residual hosting + programme, `moment.certify`), validated against the registered R489 / R480 values; only its package path was changed. +- `code/mutants.py`, `code/compose_control.py`: the mutation controls and the composition/control with the cited complex b. +- `code/adapt503.py`: PR #503's `adapt.py`, byte-identical (DreamingOfClouds, with Claude Opus 5.5), used only to build the + stock R480 control chain for the regression. +- `data/bitE8mut-v111-r489.json.gz` (the word; `verify.py` rebuilds it byte for byte), `data/hosting-v111-r489.json` (the hosting + selection nominated by `host_select.py` and rediscovered by `verify.py`), `data/control-r480/` (PR #503's R480 word, hosting + selection and EXPECTED.json, byte-identical copies), `data/complex/pr535/EXPECTED.json` (PR #535's receipt, byte-identical, + git blob id in `data/complex-b.json`), `verify.py`, `EXPECTED.json`, `MANIFEST.json`, `README.md`. + +## Used from PR #493 (research/e8-bit-carrier-skeleton, eumemic, commit c3a9a43), unchanged + +The skeleton modules and frozen plan, the vendored PR #370 checker and its relaxation, `interface.py` and the mutants, the +exporter, the official cohort checkers and the Gram check, PR #472's emitter, audit, invoice and assembly (as adapted by #493 +and by `code/adapt.py`), the hosting modules, PR #315's moment engines, the hub files under `code/hub/`. Provenance and +licences of those files are listed in PR #493's `NOTICE.md`; its `MANIFEST.sha256` is checked by step 0 of `verify.py`. diff --git a/research/e8-punctured111-star/README.md b/research/e8-punctured111-star/README.md new file mode 100644 index 0000000000..1c6fc7e48d --- /dev/null +++ b/research/e8-punctured111-star/README.md @@ -0,0 +1,134 @@ +# Punctured star bit unit: 111 ports, nine rank-7 totals, R = 489 + +**Bit c = 0.00165947204563779652541, +4.54% over the live bit c of PR #510.** κ is another matter: composed with #535's +complex b, κ = 0.001587467473762886 is **complex-bound, +0.16% over #535**. The bit word raises the cap on any future complex +gain; it does not move κ by more than that today. + +This package ships one E8 bit word and the parameterisation of PR #493's hosted-audit chain that prices it. The word is +PR #493's quad skeleton with 9 of the 120 labelled E8 lines punctured (neither source nor target), so it has **v = 111 live +ports**. The nine retained decoder totals are nine *pseudo-target* helpers, one per punctured line, each of frame rank 7, so the +decoder constant is **cst = 9 x 7 = 63** (PR #493 / #503: 9 x 8 = 72). The result is **R = 489** helpers (480 skeleton helpers ++ 9 totals). The chain (emit, independent audit, exact price, outer assembly) is #493's, with every hard-coded +120 / 72 / 9600 / 489 derived from the word. + +| quantity | value | +|---|---| +| bit c, eleven stages, eight pooled replicas, every residual whole and hosted (10^-24 grid; #472's pipeline as #493 runs it) | `165947204563779652541/100000000000000000000000` = **0.00165947204563779652541** | +| live bit c: PR #510's R480 word at nine stages (the bit supplier of #535) | 0.001587447106092548137108 (**+4.5372%**) | +| same pipeline on PR #503's R480 word (v = 120), reproduced by `verify.py` | 0.001574753352953808650916 (+5.3798%) | +| pricing harness `code/price/pricex.py` (independent local-histogram replay + the same hosting programme + `moment.certify`) | equal to all 24 digits, same profile | +| κ with #535's complex b = `1589991533606044174031/10^24` | **`793733736881443/500000000000000000` = 0.001587467473762886**, complex-bound; #535 publishes 0.001584931111785787 (bit-bound at the live bit c) | +| robustness: c under a stricter hosting (one helper per family copy per stage), `code/price/price458.py` | >= 0.001651282591289915996071 (at most 0.49% lower; still +4.02% over the live bit c); κ unchanged | + +#535's complex b (0.00158999) is 4.37% below this unit's c, so κ is complex-bound and rises +0.1600% +(0.001584931111785787 -> 0.001587467473762886). The remaining 4.37% of bit headroom pays only against a future complex b above +1.59e-3. The κ line is computed by the same outer code that reproduces #535's published κ from #510's bit c (step 9, control). + +## What the unit is + +* Word: `data/bitE8mut-v111-r489.json.gz`, format `bitE8/1+mut` (PR #493), `v = 111`, `R = 489`, `ports_geom` = the 111 live + labels as indices into the 120-line system, `punctured` = **[39, 52, 57, 71, 76, 78, 103, 109, 114]** (footprint (1^9): one + punctured line in each of nine 4-frames; none of lines 0..7, so the frame-zero residual basis 2e_0..2e_7 is made of live + labels and PR #493's residual-isometry check applies unchanged). `verify.py` rebuilds it byte for byte from PR #493's frozen + plan with `code/word/gen_punct.py`. +* Skeleton: #493's, verbatim, restricted to the live lines. Every helper register is kept; the carriers of punctured lines stay as + junk wires (18). The phase-A total for a punctured line y_j is a fresh helper that reads exactly what the removed target would + read (the two quad outputs and the Q delivery at D6[Hy], then its two needers at y_j-perp): its x-part is z_{y_j} restricted to + the live lines, its frame has rank 7, and it is issued at the end of phase A, so no reader needs an extra climb. Hosting the + totals on dead registers (as #503 does for rank 8) fails here: a rank-7 total can only combine dead registers whose frames lie + inside y_j-perp, and none has a frame in D6[Hy]. +* Frames are the live line sets of the closed 120-line frames; their ranks are recomputed by every checker from the word's own + `lines`. +* Choice of P: of 414 sampled punctures (W1's search), 304 reach R = 489 and 110 need 1-3 Q-node junk wires (R = 490-492); among the + R = 489 words c varies slightly (1.659350e-3 to 1.659472e-3, 8 distinct local histograms). The shipped word has the highest c + found (reached by 145 of the 414). A different representative of footprint (3,3,1,1,1), P = [16,22,32,43,54,70,76,90,103], + builds R = 491 and c = 1.656230e-3; it is not this word. No claim is made that 489 is a floor for other skeletons. + +## What was parameterised (`code/adapt.py`) + +`adapt.py` writes adapted copies of nine parent files by 55 exact string edits (each anchor must occur exactly the listed number +of times, as in #503). The parent tree is never modified. Nothing is read from the environment; the one configuration +(`code/punct_cfg.py`) is derived from the word (v, R, live labels, the totals map) and, in scripts that never see the word, from +the exported records. + +| file | constant (parent) | now | +|---|---|---| +| `emit.py` | `(h, v, form) == (8, 120, ...)` | v from the word; configuration checked against the word | +| | COPY rank `== 8` | `0 < rank <= 8`; the sum over the nine totals is the CST and must equal the word's totals map (63) | +| | `72` (local mass identity, rank-mass deficit, deficit field) | CST | +| | replica stride `1200` (3x) | `2 K v` | +| `audit.py` | `V, R = 120, 489`, `DATA = 9600`, physical `9609`, deficit `3264`, `72`, `len(ports) == 120`, helper offset `240`, stride `1200` (2x), `geometry_routes = 1320` | V, R from the records (`n = 2V + R`); CST from the audit's own replay of the records' COPY ranks; `DATA = 2 K V T` | +| `local_audit.py` | `969`, `729`, `240` (2x), `R489` status string, the word path | `2V + n`, `n`, `2V`, `R%d`, the word given to `adapt.py` (as #503 does) | +| `assemble.py` | `V = 120`, `72`, suppliers file | `V` from the bit's GLOBAL.json; the deficit from the audit (it must fit nine copy ranks); optional suppliers argument | +| `host_select.py` | `V = 120` | `V = word['v']` | +| nine-/eleven-stage `geometry.py` | all 120 ports emitted; `240`, `120`, `1080`, `1320` | only the live ports, re-indexed 0..v-1; counts from `len(LIVE)` | +| `chk/checkword.py` | `len(lines) == v == 120` | `100 <= v <= 120`, plus: every label is one of the 120 E8 root lines (the lines of #493's word, which #370's checker accepts); norm 2, pairwise \|ip\| <= 1, rank 8 still checked; `relax.py` is the parent's, unchanged | +| `mutate_records.py` | "COPY with a cheaper rank" sets the rank to the literal 7 | `rank - 1` (a literal 7 is the true rank of a rank-7 total) | + +Unchanged and already general: the C++ checkers (`-DVPORTS=v -DRHELP=R -DNCOPY=9`, `HDIM = 8`; their COPY check is +`z == dim(frame)`), the residual-isometry check (`validate_isometries`, stock call), `export_records.py`, `stage_cohort.py`, +`gram_frames.py`, `interface.py`, `mutate_mut.py`, `mutate_records_mut.py`, the moment engines, the row bound, and the outer +assembly (it sees only c, b and the bit's charged coefficient bits). The cited complex b enters as a bare rational; there is +**no port count on the complex side of the assembly**, so the bit v = 111 is not tied to the complex word's own v. + +## Checks (`verify.py`) + +0. This package's `MANIFEST.json` and #493's `MANIFEST.sha256`. +P. (full mode) #493's `verify.sh`, unchanged. +1. The word rebuilt from #493's plan is byte-identical; the configuration (v, R, totals map, CST = 63). +2. Independent checker (#370's, `v <= 120` and the E8-membership check, relaxed for mutable sources by #493's `relax.py`): exact F2 + replay of all 2v + R columns, frame nesting, Gram, price; `interface.py` (#425's hypotheses); the word-level mutants. +3. Official cohort checkers at (v, R): legality (NCOPY = 9), five-stage columns (payload 91 bits < 104), eleven-stage columns + (24/24 omitted-bridge controls), KPAIRS = 2 regression, record mutants. +4. Exact Gram on all 636 frames. +5. Geometry (live labels), #442 hosting programme (rediscovers `data/hosting-v111-r489.json`), emit, independent audit (22 template + mutations), assembly (47 strict inequalities and controls) with #535's complex b. +6. `pricex.py` agrees with the hosted-audit c to all 24 digits; hosting-stacking statistics; `price458.py` (stricter hosting). +7. **Regression**: PR #503's R480 word through the stock chain (parent `emit.py` / `assemble.py`, #503's `audit.py` / + `local_audit.py`) and through the adapted chain: `GLOBAL.json`, `GLOBAL-TEMPLATE.json.gz`, `AUDIT.json`, `RESULT.json` are + byte-identical (GEOMETRY.json stores its own run time and is shared), equal to #503's EXPECTED (c, profile, emitted-program + sha256, κ for three suppliers). +8. **Mutation controls** (`code/mutants.py`, 8): dropped gate, wrong frame, payload overflow (legal and F2-correct; refused only by + `columns_h`), cell collision (#442 rule), a helper hosted on the family the call acts on, a cheaper profile claim, v tied to 112 + (the cited complex word's port count), the stock #493 emitter on the 111-port word. M4a tests same-cell collisions only; it is + not a test of #458's one-helper-per-family rule (see Scope). +9. Composition with #535's complex b, and the control that reproduces #535's published κ from #510's bit c with the same code. + +## Rank-mass identity for v < 120 + +The chain asserts `M * live - mass = T (2 K v - L cst)` (here M = 78, T = 8, K = 5, L = 11, live = 2 K v T). It is a telescoping +identity, valid for any v: + +* locally, sources climb rank 1 to 8, targets 0 to 7 and helpers 0 to 8, so the local mass is `8 R + cst + 14 v`; +* at eleven stages the idle ranks sum to 308 per family (2 v families), and the 88 R hosted helper climbs of width 8 are paid out + of that idle rank, so the global mass is `T (11 (8 R + cst + 14 v) + 616 v - 88 R) = T (11 cst + 770 v)`; +* with `M * live = 780 v T` the difference is `T (10 v - 11 cst)`. + +For v = 111 and cst = 63 this is 8 x 417 = 3336 (v = 120, cst = 72: 3264). The same shape, `D = h ((s-1) v - s cst)`, is the one +PR #523 uses for its punctured complex word; emit and audit check the identity numerically on the emitted program. + +## Scope and what is not claimed + +* The word is checked as a `bitE8/1` word with 111 labels (norm 2, pairwise |ip| <= 1, rank 8, labels in the 120-line E8 system); + that a 111-port unit with cst = 63 is an admissible bit supplier for the outer assembly rests on the same hypotheses as v = 120. + Everything #493 and #472 assume (all-size compiler, common-label/mutable-basis interface, whole-call hosting) is assumed + unchanged. This package makes no unconditional claim. +* **Hosting rule.** The hosting is the pooled whole-residual programme of #442 / #472 / #493 (`hosting_core.solve`, eight replicas + pooled, `2 v T` copies per idle child): every helper residual is hosted whole on an idle data family, at disjoint cells. It does + **not** satisfy #458's literal rule that an entering helper is the only owner of its physical family in an invocation: in 82 of + the 88 calls several helpers of that call sit on one family (at most 7), at disjoint offsets. This is inherited: PR #503's + accepted emitted program does the same in 80 of 88 calls (reproduced by step 7). `verify.py` prints both counts. Under the stricter + rule "one helper per family copy per stage" (which implies #458's per-invocation rule) the unit still prices at + c >= 0.001651282591289915996071 (at most 0.49% lower, +4.02% over the live bit c); κ is complex-bound and unchanged. +* Payload margin: 91 bits against 104. Stage count: the unit is feasible only at eleven (and thirteen) stages; the nine-stage + hosting wall is R <= 4 v = 444. +* The pricing harness and the hosted emit/audit share `hosting_core`; their agreement at v = 111 checks the adapted emitter and + audit against an independent local-histogram replay, not the hosting programme itself. + +## Credit + +PR #493 (eumemic) is the skeleton, the word family and the chain; #503 (DreamingOfClouds) the dead-total variant and the +`adapt.py` pattern; #523 (icekylinx) the puncture pattern on the complex side (ports removed, copy ranks lowered, D recomputed); +#472 (chafreaky), #442 (DaysSky), #445, #386, #370 (Dylan Crow), #381, #315 the pipeline and checkers; #510 the live bit c; #535 +(icekylinx) the cited complex b; the independent audit of this package supplied `code/price/price458.py`. Prepared by +DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code. Apache-2.0. diff --git a/research/e8-punctured111-star/code/adapt.py b/research/e8-punctured111-star/code/adapt.py new file mode 100644 index 0000000000..bd1552af18 --- /dev/null +++ b/research/e8-punctured111-star/code/adapt.py @@ -0,0 +1,136 @@ +# Parameterises PR #493's hosted-bit chain (emit, audit, local audit, assembly, hosting nominator, the two geometries, +# the independent checker and one record mutant) for a word with v <= 120 live ports and nine totals of any copy rank. +# Every change is an exact string edit of a pinned parent file; each anchor must occur exactly the listed number of +# times. Nothing is read from the environment: V, R and the sum of the nine copy ranks come from the word, or, in +# scripts that never see the word, from the exported records. For v = 120 and nine rank-8 totals (PR #493, PR #503) +# every adapted script computes exactly what the parent computes (verify.py, step 7, compares the outputs byte for byte). +# Prepared by DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code; the parent files are PR #493's / #472's. Apache-2.0. +"""usage: adapt.py PARENT_PACKAGE WORD.json.gz OUTDIR + OUTDIR/emit.py, audit.py, local_audit.py, assemble.py, host_select.py, nine_geometry.py, eleven_geometry.py + OUTDIR/chk/checkword.py (+ relax.py) the pinned independent checker with ONE assertion changed (v == 120 -> v <= 120) + OUTDIR/mutate_records.py the record mutants, the 'cheaper COPY rank' one made relative to the true rank + WORD is baked into local_audit.py (the word whose records are audited), as PR #503's adapt.py does.""" +import sys +from pathlib import Path + +PARENT, WORD, OUT = Path(sys.argv[1]).resolve(), Path(sys.argv[2]).resolve(), Path(sys.argv[3]).resolve() +HERE = Path(__file__).resolve().parent # punct_cfg.py lives here +H_EMIT = str(PARENT / 'code/hub/e8-r740-replica32/code'); H_HOST = str(PARENT / 'code/hub/idle-axis-hosting') +PKG = str(PARENT) +PC = "sys.path.insert(0,%r)\nimport punct_cfg as PC\n" % str(HERE) + +# (anchor, replacement[, expected count]) +EDITS = { + 'code/eleven/emit.py': ('emit.py', [ + ('sys.path.insert(0,str(HERE.parent/"hub/e8-r740-replica32/code"))\n', "sys.path.insert(0,%r)\n" % H_EMIT), + ('sys.path.insert(0,str(HERE.parent/"hub/idle-axis-hosting"))\n', "sys.path.insert(0,%r)\n" % H_HOST), + ("import hosting_core as HC\n\nH,L,K,T,M=8,11,5,8,78\n", "import hosting_core as HC\n" + PC + "\nH,L,K,T,M=8,11,5,8,78\n"), + # V is the word's port count (a punctured word carries its live labels in ports_geom); config from the word + (" assert (w['h'],V,w['form'])==(8,120,'/2')\n", + " assert (w['h'],w['form'])==(8,'/2'); CFG=PC.config(w,%r); assert (CFG['v'],CFG['R'])==(V,R)\n" % PKG), + # the COPY rank of a total is the dimension of its frame (8 for #493 / #503, 7 for the star unit); the sum is derived + (" streams={}; checks={}; localH=None\n", " streams={}; checks={}; localH=None; CSTD=[]\n"), + ("norm=[1]*LOCAL+[0]; maxnorm=1; center=None; hist=Counter(); events=[]; copies=0; adds=0", + "norm=[1]*LOCAL+[0]; maxnorm=1; center=None; hist=Counter(); events=[]; copies=0; adds=0; crs=[]"), + ("copy_rank=abs(dim(c)-dim(f)); assert copy_rank==8", "copy_rank=abs(dim(c)-dim(f)); assert 0 6 else root / "data/complex-b.json").read_text())["suppliers"]}'), + ]), + 'discovery/host_select.py': ('host_select.py', [ + ('sys.path.insert(0, str(HERE.parent / "code" / "hub" / "idle-axis-hosting"))', "sys.path.insert(0, %r)" % H_HOST), + ("H, L, K, T, M, V = 8, 11, 5, 8, 78, 120\n", "H, L, K, T, M = 8, 11, 5, 8, 78\n"), + (" R = w['R']\n", " R = w['R']; V = w['v']\n"), + ]), + 'code/bit/independent/checkword.py': ('chk/checkword.py', [ + ("assert len(lines)==v==120 and h==8", + "assert len(lines)==v and 100<=v<=120 and h==8 # v live ports of the 120 E8 lines\n" + "# the live labels must be E8 root lines: members of the 120-line system of PR #493's word (the lines PR #370's checker accepts)\n" + "CANON={tuple(x) for l in json.load(gzip.open(%r,'rt'))['lines'] for x in (l,[-y for y in l])}\n" + "assert all(tuple(a) in CANON for a in lines), 'a label is not one of the 120 E8 root lines'" % str(PARENT / 'data/bit/bitE8mut-r489.json.gz')), + ("print('labels: 120 distinct lines of norm 2 (pairwise |ip| <= 1), spanning rank 8')", + "print('labels: %d distinct lines of norm 2 (pairwise |ip| <= 1), spanning rank 8'%v)"), + ]), + 'code/bit/mutate_records.py': ('mutate_records.py', [ + ("lambda e:e.__setitem__(5,7)", "lambda e:e.__setitem__(5,e[5]-1)"), + ]), +} +# the geometries build every port isometry by BFS over all 120 lines; only the live ports are emitted, re-indexed 0..v-1 +GEOM = lambda: [ + ("ap.add_argument('--out',type=Path,required=True); a=ap.parse_args(); t0=time.monotonic()", + "ap.add_argument('--out',type=Path,required=True); ap.add_argument('--word',type=Path,default=None); a=ap.parse_args(); t0=time.monotonic()"), + (" assert len(gs)==120\n", + " assert len(gs)==120\n" + " if a.word is None: LIVE=list(range(120))\n" + " else:\n" + " ww=json.loads(gzip.decompress(a.word.read_bytes())); LIVE=list(ww['ports_geom']) if 'ports_geom' in ww else list(range(120))\n" + " assert len(LIVE)==ww['v'] and all(ww['lines'][i]==list(map(int,lines[p])) for i,p in enumerate(LIVE))\n"), + (" for t,q in enumerate(lines):\n g=gs[t]; assert", " for t,src in enumerate(LIVE):\n q=lines[src]; g=gs[src]; assert"), + ("exact_bit_endpoint_operator_checks=240,", "exact_bit_endpoint_operator_checks=2*len(LIVE),"), + ("missing_route_factor_controls=120,", "missing_route_factor_controls=len(LIVE),"), +] +EDITS['code/nine/geometry.py'] = ('nine_geometry.py', GEOM() + [("route_checks=1080,", "route_checks=9*len(LIVE),")]) +EDITS['code/hub/r740-hosted-eleven/code/geometry.py'] = ('eleven_geometry.py', GEOM() + [("route_checks=1320,", "route_checks=11*len(LIVE),")]) + +OUT.mkdir(parents=True, exist_ok=True); (OUT / 'chk').mkdir(exist_ok=True) +n = 0 +for src, (dst, edits) in EDITS.items(): + text = (PARENT / src).read_text() + for e in edits: + old, new = e[0], e[1]; cnt = e[2] if len(e) > 2 else 1 + assert text.count(old) == cnt, (src, old, text.count(old)) + text = text.replace(old, new); n += 1 + (OUT / dst).write_text("# Adapted from PR #493's %s by research/e8-punctured111-star/code/adapt.py. Apache-2.0.\n" % src + text) +(OUT / 'chk/relax.py').write_bytes((PARENT / 'code/bit/independent/relax.py').read_bytes()) +print(' adapted %d parent files with %d listed edits (each anchor found exactly the listed number of times)' % (len(EDITS), n)) diff --git a/research/e8-punctured111-star/code/adapt503.py b/research/e8-punctured111-star/code/adapt503.py new file mode 100644 index 0000000000..6d855e7688 --- /dev/null +++ b/research/e8-punctured111-star/code/adapt503.py @@ -0,0 +1,41 @@ +# Writes the three adapted files this package runs, from PR #493's package (research/e8-bit-carrier-skeleton), +# by exact string edits; each edited string must occur exactly once in the parent file. Nothing else changes. +# Prepared by DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code. Apache-2.0. +"""usage: adapt.py PARENT_PACKAGE R480_WORD OUTDIR + OUTDIR/gen_r480.py = parent code/skeleton/gen.py, totals hosted on the LAST eligible dead register + OUTDIR/eleven/audit.py = parent code/eleven/audit.py with R = 480 + OUTDIR/eleven/local_audit.py = parent code/eleven/local_audit.py with R = 480 (960 formal columns, 720 registers, + the audited word = the R480 word); parent package root for the shared hub files""" +import sys +from pathlib import Path + +PARENT, WORD, OUT = Path(sys.argv[1]).resolve(), Path(sys.argv[2]).resolve(), Path(sys.argv[3]).resolve() +EDITS = { + 'code/skeleton/gen.py': ('gen_r480.py', [ + # the parent modules (e8, geom, wordkit) are imported from the parent package + ("sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))", + "sys.path.insert(0, %r)" % str(PARENT / 'code/skeleton')), + # THE change: a total formed on a dead register is hosted by the last eligible register of its combination + # (the parent takes the first one; with the first, the payload bill is 129 bits > 104) + ("host = next((r for r in sorted(combo) if r not in used", + "host = next((r for r in sorted(combo, reverse=True) if r not in used"), + ]), + 'code/eleven/audit.py': ('eleven/audit.py', [ + ("K,L,M,T,V,R=5,11,78,8,120,489", "K,L,M,T,V,R=5,11,78,8,120,480"), + ]), + 'code/eleven/local_audit.py': ('eleven/local_audit.py', [ + ("ROOT=Path(__file__).resolve().parents[2]", "ROOT=Path(%r)" % str(PARENT)), + ("cc['formal_columns_checked']==969", "cc['formal_columns_checked']==960"), + ("(ROOT/'data/bit/bitE8mut-r489.json.gz')", "(Path(%r))" % str(WORD)), + ("range(729)", "range(720)"), + ("PASS_EXACT_R489_LOCAL_PROJECTORS", "PASS_EXACT_R480_LOCAL_PROJECTORS"), + ]), +} +n = 0 +for src, (dst, edits) in EDITS.items(): + text = (PARENT / src).read_text() + for old, new in edits: + assert text.count(old) == 1, (src, old, text.count(old)) + text = text.replace(old, new); n += 1 + out = OUT / dst; out.parent.mkdir(parents=True, exist_ok=True); out.write_text(text) +print(' adapted 3 parent files with %d listed edits (each anchor found exactly once)' % n) diff --git a/research/e8-punctured111-star/code/compose_control.py b/research/e8-punctured111-star/code/compose_control.py new file mode 100644 index 0000000000..05ba6fa625 --- /dev/null +++ b/research/e8-punctured111-star/code/compose_control.py @@ -0,0 +1,75 @@ +# Outer composition of a bit c with a cited complex b, and the control that reproduces PR #535's published kappa. +# The outer half is PR #472's / #493's assemble.py verbatim (six bootstrap levels, 47 strict inequalities, next-grid and +# invalid-parameter controls), here as a function of (c, b) so that the SAME code is run on +# control : PR #535's inputs (the live bit c of PR #510, #535's complex b) -> must give #535's published kappa exactly +# star : this package's c and the same b -> must equal the kappa that assemble.py wrote +# No bit port count enters: the bit unit has v = 111 ports, #535's complex word has its own; the outer assembly sees only +# the two real numbers c and b, the bit's charged coefficient bits (bootstrap cutoffs only) and the row bound. +# Prepared by DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code; engines are PR #315's / #361's (pinned in the parent). Apache-2.0. +"""usage: compose_control.py PARENT_PACKAGE RESULT.json PR535_EXPECTED.json OUT.json""" +import importlib.util +import json +import sys +from fractions import Fraction as Q +from pathlib import Path + +parent, resp, e535p, outp = map(Path, sys.argv[1:5]) +eng = parent / 'code/hub/e8-r740-replica32/code/engines' + + +def load(name): + sp = importlib.util.spec_from_file_location('comp_' + name, eng / (name + '.py')) + mod = importlib.util.module_from_spec(sp); sp.loader.exec_module(mod); return mod + + +Outer = load('outer') + + +def ceil(x): return -((-x.numerator) // x.denominator) + + +def compose(c, b, coeff_bits, row=20161): + eta = beta = grid = Q(1, 10 ** 18) + s = min(c, (1 - beta) * b) - Q(1, 10 ** 24) + assert 0 < s < c and s < (1 - beta) * b + chain, cuts = [Q(384599, 10 ** 10)], [] + for _ in range(6): + old = chain[-1]; a = (1 - s) * s + s * old + gap = min(s - a, 1 - a - s, 1 - a - s * (1 - old), 1 - s); assert old < a < s < 1 - a and gap > 0 + cut = max(ceil(36 / gap ** 2), ceil(2 * (4 + coeff_bits) / gap)) + assert cut * gap ** 2 >= 36 and cut * gap >= 2 * (4 + coeff_bits) + cuts.append(str(cut)); chain.append(a) + q = chain[-1] * (1 - 2 * eta); margin = (1 - eta) * q / (1 + q); ticks = margin / grid + k = grid * ((ticks.numerator - 1) // ticks.denominator) + bridge = {'semantic': {'C0': {'base': 2, 'exponent': 210000}, 'strict_literal_gap': 1}, + 'rows': {'degree_gap': Q(10 ** 6) - Q(51 * row, 25)}} + a = Outer.assembly(chain[-1], b, bridge, k, eta=eta, beta=beta) + assert len(a['strict_constraints']) == 47 and all(x > 0 for x in a['strict_constraints'].values()) + ctl = [] + for name, kk, ee, bb in [('next_grid', k + grid, eta, beta), ('zero_eta', k, Q(0), beta), ('zero_beta', k, eta, Q(0)), ('unit_beta', k, eta, Q(1))]: + try: Outer.assembly(chain[-1], b, bridge, kk, eta=ee, beta=bb) + except AssertionError: ctl.append(name) + else: raise AssertionError(name) + return dict(kappa=k, binding='bit' if c < (1 - beta) * b else 'complex', controls=ctl, strict=47) + + +e535 = json.loads(e535p.read_text()); res = json.loads(resp.read_text()) +b = Q(e535['complex_lower']); c510 = Q(e535['bit_lower']); k535 = Q(e535['kappa']) +ctl = compose(c510, b, 512) # #535 adds the PR #510 nine-stage bit (charged two-level coefficient 512 bits) +assert ctl['kappa'] == k535 and ctl['binding'] == e535['binding_component'] == 'bit', (ctl, e535['kappa']) +c = Q(res['bit_lower']) +star = compose(c, b, res['bit']['charged_three_level_coefficient_bits']) +assert str(b) == res['kappa']['pr535']['complex_lower'] and star['kappa'] == Q(res['kappa']['pr535']['kappa']) +assert star['binding'] == res['kappa']['pr535']['binding_component'] +out = dict(complex_lower=str(b), pr535_published_kappa=str(k535), pr535_published_kappa_decimal=e535['kappa_decimal'], + control_bit_lower=str(c510), control_kappa=str(ctl['kappa']), control_binding=ctl['binding'], + control_reproduces_pr535_kappa=True, control_outer_controls=ctl['controls'], + star_bit_lower=str(c), kappa_star_vs_pr535=str(star['kappa']), star_binding=star['binding'], + star_outer_controls=star['controls'], star_strict_constraints=star['strict'], + kappa_gain_over_pr535=str(star['kappa'] / k535 - 1), bit_headroom_over_complex_b=str(c / ((1 - Q(1, 10 ** 18)) * b) - 1)) +outp.write_text(json.dumps(out, indent=1) + '\n') +print(' control: #510 bit c %s + #535 b -> kappa %s == #535 published %s (bit-bound), 47/47 strict, controls %s' + % (e535['bit_decimal'], ctl['kappa'], k535, ','.join(ctl['controls']))) +print(' star : bit c %s + #535 b -> kappa %s (%s-bound), 47/47 strict; %+.4f%% over #535; bit c exceeds (1-1e-18)b by %+.4f%%' + % (res['bit_lower_decimal'], star['kappa'], star['binding'], 100 * float(star['kappa'] / k535 - 1), + 100 * float(c / ((1 - Q(1, 10 ** 18)) * b) - 1))) diff --git a/research/e8-punctured111-star/code/mutants.py b/research/e8-punctured111-star/code/mutants.py new file mode 100644 index 0000000000..f47e4cb97e --- /dev/null +++ b/research/e8-punctured111-star/code/mutants.py @@ -0,0 +1,178 @@ +# Mutation controls for the punctured-word hosted chain. Every mutant is built from the SHIPPED word (or from the chain's +# own emitted files) by one change, pushed through the real chain stages, and must be refused by a named stage. +# Prepared by DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code. Apache-2.0. +"""usage: mutants.py WORD.json.gz WD ADAPTED_DIR PARENT_PACKAGE HOSTING.json OUT.json +WD is verify.py's work dir after steps 1-5 (bin/, records/, cin/, cout/, nine/, bit/, interface.json). + + word-level (the mutated word goes through the relaxed independent checker, the exporter, the official legality and + five-stage / eleven-stage column checkers, and the emitter's gate on their receipts): + M1 dropped gate delete the phase-A gate that forms the first retained total + M2 wrong frame move a phase-B gate to the zero frame (below the frames its registers already stand at) + M3 payload overflow an F2-neutral block of Fibonacci-growth ADDs on two helpers: legal, restores every column, + but the signed prefix payload exceeds 2^104 -> refused by columns_h only + template-level (the chain's own emitted files, tampered; audit.py must refuse, the hashes of the tampered file re-written + so that only the semantic checks can catch it): + M4a cell collision (#442 rule) two helpers of one invocation given the same physical family AND hosted cells. + (NOT a test of #458's one-helper-per-family rule: the pooled whole-residual hosting of + #442/#472/#493/#503 stacks several helpers on one family at disjoint cells; see README) + M4b hosted on the invoked pair a helper's residual placed on the data family the call itself acts on + M5 profile claim GLOBAL.json claims a cheaper paid profile than the template's + assembly-level: + M6 v tied to the complex word GLOBAL.json v := 112 (the cited complex v); assemble.py must refuse + M7 the stock PR #493 emitter refuses any word with v != 120 (what the parameterisation had to change)""" +import copy +import gzip +import hashlib +import json +import shutil +import subprocess +import sys +from pathlib import Path + +WORD, WD, AD, PARENT, HOST, OUT = map(Path, sys.argv[1:7]) +PY = sys.executable +B = PARENT / 'code/bit'; C = PARENT / 'code' +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import punct_cfg as PC # noqa: E402 + +w0 = PC.load(WORD); V, R = w0['v'], w0['R'] +BIN = WD / 'bin' +LEG = BIN / 'legality'; COLH = BIN / ('columns_h_v%d_r%d' % (V, R)); COLK = BIN / ('columns_k5_v%d_r%d' % (V, R)) +PROBE = BIN / ('columns_probe_v%d_r%d' % (V, R)) +MD = WD / 'mut'; shutil.rmtree(MD, ignore_errors=True); MD.mkdir() +controls = [] + + +def run(cmd, **kw): + return subprocess.run([str(x) for x in cmd], capture_output=True, text=True, **kw) + + +def last(p): + t = (p.stderr.strip().splitlines() or p.stdout.strip().splitlines() or ['?']) + return t[-1][:110] + + +def save_word(w, p): + with gzip.open(p, 'wt') as f: json.dump(w, f) + + +def through_chain(w, tag): + """returns [(stage, rejected, message)] and stops reading further stages' receipts as in the real chain.""" + d = MD / tag; d.mkdir(); wp = d / 'word.json.gz'; save_word(w, wp); out = [] + p = run([PY, '-I', '-B', AD / 'rchk/checkword_mut.py', wp, C / 'pricing']) + out.append(('relaxed independent checker (exact F2 replay, frames)', p.returncode != 0, last(p))) + p = run([PY, '-I', '-B', B / 'export_records.py', wp, d / 'records']); assert p.returncode == 0, p.stderr + p = run([PY, '-I', '-B', B / 'regression/stage_cohort.py', d / 'records', d / 'records', d / 'cin', d / 'cout']); assert p.returncode == 0, p.stderr + p = run([LEG, d / 'cin', d / 'cout', d / 'cout/legality.json']) + out.append(('official legality (frames, lifecycle, COPY ranks)', p.returncode != 0, last(p))) + p = run([COLH, d / 'cout/COHORT249-RECORDS.bin', d / 'cout/columns.json']) + out.append(('official five-stage columns_h (all columns, payload < 2^104)', p.returncode != 0, last(p))) + p = run([COLK, d / 'cout/COHORT249-RECORDS.bin', d / 'cout/columns_k5.json']) + out.append(('official eleven-stage columns_k', p.returncode != 0, last(p))) + # the emitter's gate: it needs legality.json and columns.json with a PASS status; a refused word leaves none + (d / 'bit').mkdir() + shutil.copy(WD / 'bit/GEOMETRY.json', d / 'bit/GEOMETRY.json') + p = run([PY, '-E', '-s', '-B', AD / 'emit.py', '--word', wp, '--local-check', d, '--out', d / 'bit', '--isometries', + PARENT / 'data/eleven/residual-isometries.json', '--hosting', HOST]) + out.append(('hosted emitter (needs PASS receipts of the two official checkers)', p.returncode != 0, last(p))) + return out, d + + +def record(name, what, stages, require_reject_at=None): + rej = [s for s in stages if s[1]] + assert rej, ('ACCEPTED', name, stages) + controls.append(dict(name=name, mutation=what, first_rejecting_stage=rej[0][0], message=rej[0][2], + stages=[dict(stage=s, rejected=r, message=m) for s, r, m in stages])) + print(' REJECTED %-26s first at: %s [%s]' % (name, rej[0][0], rej[0][2][:70])) + if require_reject_at: + assert any(s[0].startswith(require_reject_at) and s[1] for s in stages), (name, require_reject_at, stages) + + +# ---------------------------------------------------------------------------------------------------- word-level +w = copy.deepcopy(w0) +tot = w['ret'][0] +k = max(i for i, g in enumerate(w['A']) if g[1] == tot) +dropped = w['A'].pop(k) +st, _ = through_chain(w, 'm1') +record('M1 dropped gate', 'deleted phase-A gate %d (frame %d, destination %d = the first retained total, %d sources)' % (k, dropped[0], dropped[1], len(dropped[2])), + st, 'relaxed independent checker') +assert all(s[1] for s in st[:1] + st[2:3]), st # the checker and columns_h both refuse; the emitter cannot run + +w = copy.deepcopy(w0) +kb = len(w['B']) // 2 +old = w['B'][kb][0]; zero = w['start'][2 * V] +w['B'][kb][0] = zero +st, _ = through_chain(w, 'm2') +record('M2 wrong frame', 'phase-B gate %d moved from frame %d to the zero frame %d' % (kb, old, zero), st, 'relaxed independent checker') + +# M3: Fibonacci-growth block on helpers u, v (both at the zero frame at the start of phase A). Over F2 the six-gate cycle +# (u += v, v += u) x 3 is the identity, so every column is restored and every frame is untouched; the integer bound grows +# like Fibonacci numbers. Smallest block (in cycles) whose payload the probe reports >= 105 bits. +u, vv = 2 * V, 2 * V + 1 +assert w0['start'][u] == w0['start'][vv] == zero +for cycles in range(1, 40): + w = copy.deepcopy(w0) + blk = [] + for _ in range(cycles * 3): + blk += [[zero, u, [vv]], [zero, vv, [u]]] + w['A'] = blk + w['A'] + d = MD / ('m3probe%d' % cycles); d.mkdir(); wp = d / 'word.json.gz'; save_word(w, wp) + run([PY, '-I', '-B', B / 'export_records.py', wp, d / 'records']) + run([PY, '-I', '-B', B / 'regression/stage_cohort.py', d / 'records', d / 'records', d / 'cin', d / 'cout']) + p = run([PROBE, d / 'cout/COHORT249-RECORDS.bin', d / 'cout/probe.json']) + bits = json.loads((d / 'cout/probe.json').read_text())['payload_prefix_bits'] if p.returncode == 0 else None + if bits and bits >= 105: break +assert bits and bits >= 105, bits +st, _ = through_chain(w, 'm3') +assert not st[0][1] and not st[1][1], ('M3 must be a legal, F2-correct word that only the payload bound refuses', st) +record('M3 payload overflow', '%d cycles of the F2-neutral Fibonacci block (%d extra ADDs) at the start of phase A: payload %d bits >= 104 (shipped word: 95); ' + 'the relaxed checker and legality PASS' % (cycles, 12 * cycles, bits), st, 'official five-stage columns_h') +assert 'payloadfiniteprefix2^104' in st[2][2] or 'payload' in st[2][2], st[2] + +# ---------------------------------------------------------------------------------------------------- template-level +BIT = WD / 'bit' +tpl = json.loads(gzip.decompress((BIT / 'GLOBAL-TEMPLATE.json.gz').read_bytes())) +glob = json.loads((BIT / 'GLOBAL.json').read_text()) + + +def tamper(tag, edit, glob_edit=None, expect=None): + d = MD / tag; (d / 'bit').mkdir(parents=True) + for f in ('GEOMETRY.json',): shutil.copy(BIT / f, d / 'bit' / f) + t = copy.deepcopy(tpl); edit(t) + blob = json.dumps(t, separators=(',', ':'), sort_keys=True).encode() + (d / 'bit/GLOBAL-TEMPLATE.json.gz').write_bytes(gzip.compress(blob, mtime=0)) + g = copy.deepcopy(glob); g['template_sha256'] = hashlib.sha256(blob).hexdigest() # re-hashed: only semantics can catch it + if glob_edit: glob_edit(g) + (d / 'bit/GLOBAL.json').write_text(json.dumps(g, indent=2) + '\n') + p = run([PY, '-E', '-s', '-B', AD / 'audit.py', WD, WD / 'nine', d / 'bit']) + if expect: assert p.returncode != 0 and expect in p.stderr, (tag, 'refused for another reason', p.stderr[-600:]) + return [('independent hosted audit (audit.py)', p.returncode != 0, last(p) + ' :: ' + (expect or ''))], d + + +call0 = lambda t: t['calls'][0] +st, _ = tamper('m4a', lambda t: call0(t)['owners'].__setitem__(2 * V + 1, copy.deepcopy(call0(t)['owners'][2 * V])), + expect='len({(f,tuple(route)) for f,route in own})==2*V+R') +record('M4a cell collision', 'call 0: helper 1 given helper 0\'s physical family and hosted cells (two helpers on one owner AND one cell range; #442 disjoint-cells rule)', st) +fam0 = call0(tpl)['owners'][0][0] +st, _ = tamper('m4b', lambda t: call0(t)['owners'][2 * V].__setitem__(0, fam0), expect='pair[i]!=p') +record('M4b hosted on invoked pair', 'call 0 (pair %d): helper 0 re-homed to family %d, a data family the call itself acts on' % (call0(tpl)['pair'], fam0), st) +st, _ = tamper('m5', lambda t: None, lambda g: g.__setitem__('profile', dict(g['profile'], **{'56': g['profile']['56'] - 1, '55': 1})), expect='P==Counter(') +record('M5 profile claim', 'GLOBAL.json claims one rank-56 call as rank-55 (cheaper price) over the same template', st) + +# ---------------------------------------------------------------------------------------------------- assembly-level +d = MD / 'm6'; (d / 'bit').mkdir(parents=True) +for f in ('GLOBAL-TEMPLATE.json.gz', 'GEOMETRY.json', 'AUDIT.json'): shutil.copy(BIT / f, d / 'bit' / f) +g = copy.deepcopy(glob); g['v'] = 112 +(d / 'bit/GLOBAL.json').write_text(json.dumps(g, indent=2) + '\n') +p = run([PY, '-I', '-B', AD / 'assemble.py', d / 'bit', str(R), PARENT, d / 'RESULT.json', 'pr535', str(WORD.parent / 'complex-b.json')]) +assert p.returncode != 0 and 'rem == 0' in p.stderr, ('M6 refused for another reason', p.stderr[-600:]) +record('M6 v tied to complex v', 'GLOBAL.json v := 112 (the cited complex word\'s port count) with the 111-port bit audit', + [('assemble.py (rank-mass deficit must fit nine copy ranks at the bit v)', p.returncode != 0, last(p))]) +d = MD / 'm7'; (d / 'bit').mkdir(parents=True); shutil.copy(WD / 'bit/GEOMETRY.json', d / 'bit/GEOMETRY.json') +p = run([PY, '-E', '-s', '-B', C / 'eleven/emit.py', '--word', WORD, '--local-check', WD, '--out', d / 'bit', '--isometries', + PARENT / 'data/eleven/residual-isometries.json', '--hosting', HOST]) +assert p.returncode != 0 and "(8,120" in p.stderr, ('M7 refused for another reason', p.stderr[-600:]) +record('M7 stock #493 emitter', 'PR #493\'s unmodified emit.py on the 111-port word', [('stock emitter (hard-coded v == 120)', p.returncode != 0, last(p))]) + +OUT.write_text(json.dumps(dict(all_rejected=True, controls=controls), indent=1) + '\n') +print('PASS %d mutation controls, every one rejected' % len(controls)) diff --git a/research/e8-punctured111-star/code/price/price458.py b/research/e8-punctured111-star/code/price/price458.py new file mode 100644 index 0000000000..5e2a5f3c79 --- /dev/null +++ b/research/e8-punctured111-star/code/price/price458.py @@ -0,0 +1,71 @@ +"""Reprice under a stricter hosting than #442 / #472 / #493 / #503 use: every family copy hosts at most ONE helper per stage. +(PR #458's rule is per invocation = stage x replica; one helper per family copy per STAGE is stricter, so the c below is +a lower bound on the c of any #458-compliant hosting of the same word.) Whole width-8 residuals only (frame-zero +entrances, ENT = 0). Pattern = subset S of the window's stages with 8|S| <= rank; same objective as hosting_core.solve +(idle cost saved), same profile / mass identity / moment.certify as pricex.price. +Script written by the independent auditor of this package (star111 audit, 2026-10-11); only its CLI (a word instead of +V R hist cst) and the pricex import path were changed. +usage: price458.py WORD.json.gz s [s ...]""" +import gzip +import itertools +import json +import math +import os +import sys +from collections import Counter + +import numpy as np +from scipy.optimize import milp, LinearConstraint, Bounds + +sys.dont_write_bytecode = True +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import pricex as px # noqa: E402 + +MOM = px.MOM + + +def cost(r, m): return r * math.log(m / r) if r else 0.0 + + +def price458(V, R, hist, cst, s): + K, L, M, T, win, idle = px.stage_cfg(s) + C = 2 * V * T; need = R * T + var = [] + for i, (p, r, st) in win.items(): + for k in range(0, min(r // 8, len(st)) + 1): + for S in itertools.combinations(sorted(st), k): + var.append((i, S)) + n = len(var); c = np.zeros(n) + for j, (i, S) in enumerate(var): + r = win[i][1]; c[j] = -(cost(r, M) - cost(r - 8 * len(S), M)) + rows, lo, hi = [], [], [] + for i in win: + row = np.array([1.0 if vi == i else 0.0 for (vi, S) in var]); rows.append(row); lo.append(C); hi.append(C) + for st in range(L): + row = np.array([1.0 if st in S else 0.0 for (vi, S) in var]); rows.append(row); lo.append(need); hi.append(need) + res = milp(c, constraints=LinearConstraint(np.array(rows), lo, hi), integrality=np.ones(n), + bounds=Bounds(np.zeros(n), np.full(n, np.inf)), options=dict(time_limit=600, disp=False)) + if res.x is None: return dict(s=s, feasible=False, why=res.message) + x = [int(round(t)) for t in res.x] + paid = Counter({r: nn * L * T for r, nn in hist.items() if r}) + for i, r in idle: + if i not in win: paid[r] += C; continue + got = Counter() + for j, (vi, S) in enumerate(var): + if vi == i and x[j]: got[r - 8 * len(S)] += x[j] + assert sum(got.values()) == C + for rem, cnt in got.items(): + if rem: paid[rem] += cnt + LIVE = 2 * K * V * T + mass = sum(r * nn for r, nn in paid.items()); gap = M * LIVE - mass - (2 * K * V - L * cst) * T + assert gap == 0, gap + cert = MOM.certify(dict(paid), M, LIVE, True) + return dict(s=s, feasible=True, c=cert['lower'], profile=dict(sorted(paid.items())), + maxk=max(len(S) for j, (vi, S) in enumerate(var) if x[j])) + + +if __name__ == '__main__': + w = json.loads(gzip.open(sys.argv[1], 'rt').read()); d = px.word_hist(w); assert d['ENT'] == 0 + for s in map(int, sys.argv[2:]): + a = price458(d['V'], d['R'], d['hist'], d['cst'], s); b = px.price(d['V'], d['R'], d['hist'], d['cst'], s) + print(json.dumps(dict(V=d['V'], R=d['R'], s=s, c458=a.get('c'), feasible458=a['feasible'], c_stock=b.get('c'), maxk=a.get('maxk'))), flush=True) diff --git a/research/e8-punctured111-star/code/price/pricex.py b/research/e8-punctured111-star/code/price/pricex.py new file mode 100644 index 0000000000..b74f31bb00 --- /dev/null +++ b/research/e8-punctured111-star/code/price/pricex.py @@ -0,0 +1,137 @@ +"""pricex.py -- exact bit-c harness for E8 bit words of any port count V (R480 family; helpers enter at frame 0, width 8). + word -> local histogram (forward replay exactly as code/eleven/emit.py: MOVE ranks + copy ranks), V, R, cst + hist -> per-stage idle windows (eleven-stage: PR #445/#472 recipe generalised to K pairs; nine-stage: the reconstructed 9-window table that + reproduces R480 s=9 exactly) -> whole-residual hosting by the integer programme (hosting_core.solve, no banks) + -> profile = L*T*hist + idle remainders -> mass identity check -> exact rational certificate (moment.certify, bad envelope on). +usage: pricex.py WORD.json.gz [s ...] (s in 7 9 11 13; default 9 11 13 7) + pricex.py --hist 'R:{rank:count,..}:V:cst' s ... +Validation targets (run pricex.py --validate): R489 s=11 0.001565442026981656908596 ; R480 s=11 0.001574753352953808650916 ; R480 s=9 0.001587447106092548137108""" +import sys, json, gzip, importlib.util, time +from collections import Counter +from fractions import Fraction as Fr +sys.dont_write_bytecode = True +import os +PKG = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..', 'e8-bit-carrier-skeleton') # PR #493's package +sys.path.insert(0, PKG + '/code/hub/idle-axis-hosting') +import hosting_core as HC +_sp = importlib.util.spec_from_file_location('moment', PKG + '/code/pricing/moment.py'); MOM = importlib.util.module_from_spec(_sp); _sp.loader.exec_module(MOM) +H = 8 +# ---------------------------------------------------------------- word -> local histogram +def rank_dim(rows): + rows = [[Fr(x) for x in r] for r in rows]; r = 0 + for c in range(len(rows[0]) if rows else 0): + p = next((i for i in range(r, len(rows)) if rows[i][c] != 0), None) + if p is None: continue + rows[r], rows[p] = rows[p], rows[r] + for i in range(r + 1, len(rows)): + if rows[i][c] != 0: + f = rows[i][c] / rows[r][c]; rows[i] = [a - f * b for a, b in zip(rows[i], rows[r])] + r += 1 + return r +def word_hist(w): + """returns dict(V, R, hist, cst, copies, ENT)""" + V, R, h = w['v'], w['R'], w['h']; assert h == H + lines = w['lines']; assert len(lines) == V + dims = [rank_dim([lines[i] for i in idx]) for idx in w['frames']] + ZERO = [k for k, d in enumerate(dims) if d == 0]; assert len(ZERO) == 1; ZERO = ZERO[0] + cur = list(w['start']); hist = Counter(); copies = [] + def move(r, f): + if cur[r] != f: + d = dims[f] - dims[cur[r]]; assert d >= 0, ('non-nested', r, cur[r], f) + hist[d] += 1; cur[r] = f + def run(gates): + for f, d, srcs in gates: + for r in [d] + list(srcs): move(r, f) + run(w['D']); run(w['A']) + for q in w['ret']: + rk = dims[cur[q]] - dims[ZERO]; hist[rk] += 1; copies.append(rk) + run(w['B']); run(w['C']) + for r in range(len(cur)): move(r, w['final'][r]) + hist.pop(0, None) + n = len(cur) + ENT = sum(dims[w['start'][i]] for i in range(2 * V, n)) # = sum (H - width) of helper entrances (0 if all start at frame 0) + return dict(V=V, R=R, hist=dict(sorted(hist.items())), cst=sum(copies), copies=copies, ENT=ENT, mass=sum(r * c for r, c in hist.items())) +# ---------------------------------------------------------------- schedules / windows +def recipe(K): + out = [dict(kind='local', stage=0, pair=0)]; stage = 1 + for j in range(K): + out.append(dict(kind='local', stage=stage, pair=j)); stage += 1 + if j < K - 1: out.append(dict(kind='bridge', dst=j, src=j + 1)) + out.append(dict(kind='local', stage=stage, pair=j)); stage += 1 + if j < K - 1: out.append(dict(kind='bridge', dst=j, src=j + 1)) + for j in reversed(range(K - 1)): out.append(dict(kind='bridge', dst=j + 1, src=j)) + return out +def schedule(K): + levels = [-1] * K; sched = []; idx = 0 + for e in recipe(K): + if e['kind'] == 'local': + s, p = e['stage'], e['pair']; levels[p] = s; sched.append(dict(kind='local', stage=s, pair=p)); idles = [] + if s in range(1, 2 * K - 1, 2): j = (s + 1) // 2; levels[j] = s; idles.append((j, 7 * (s + 1))) + elif s in range(2, 2 * K, 2): j = s // 2; levels[j] = s; idles.append((j, 7)) + elif s == 2 * K: + for j in range(K): idles.append((j, 7 * (2 * K - levels[j]))); levels[j] = 2 * K + for j, r in idles: sched.append(dict(kind='idle', idx=idx, pair=j, rank=r)); idx += 1 + else: sched.append(e) + return sched +NINE = [(14, (0, 1)), (7, (2,)), (28, (0, 1, 2, 3)), (7, (4,)), (42, tuple(range(6))), (7, (6,)), (42, tuple(range(3, 9))), (28, tuple(range(5, 9))), (14, (7, 8))] +def stage_cfg(s): + """(K, L, M, T, windows{idx:(pair,rank,stages)}, idle_events[(idx,rank)]). s=9 uses the reconstructed nine-stage table (T = 32).""" + if s == 9: + win = {i: (i, r, frozenset(st)) for i, (r, st) in enumerate(NINE)} + return 4, 9, 64, 32, win, [(i, r) for i, (r, st) in enumerate(NINE)] + K = (s - 1) // 2; L = s; M = 7 * s + 1; T = 8 + sch = schedule(K) + win = {i: x for i, x in HC.windows(sch).items() if x[1] and x[2]} + idle = [(e['idx'], e['rank']) for e in sch if e['kind'] == 'idle' and e['rank']] + return K, L, M, T, win, idle +# ---------------------------------------------------------------- pricing +def price(V, R, hist, cst, s, check=True): + K, L, M, T, win, idle = stage_cfg(s) + avail = Counter({(st, H): R * T for st in range(L)}) + t0 = time.time() + try: + ys, zs, val = HC.solve(win, 2 * V * T, dict(avail), M, pad_value=0.0, group={H: 10 ** 9}) + except AssertionError as e: + return dict(s=s, feasible=False, why='hosting infeasible: %s' % str(e)[:60]) + used = Counter() + for (i, wd, st), n in zs.items(): used[st, wd] += n + if any(used[k] != a for k, a in avail.items()): return dict(s=s, feasible=False, why='unhosted residuals') + paid = Counter({r: n * L * T for r, n in hist.items() if r}) + hosted = Counter() # remainder per idle window copy + for i, (r) in idle: + if i not in win: # window with no residual access: full idle child paid + paid[r] += 2 * V * T + continue + got = Counter() + for (ii, pat), cnt in ys.items(): + if ii == i: got[r - sum(pat)] += cnt + assert sum(got.values()) == 2 * V * T, (i, got) + for rem, cnt in got.items(): + if rem: paid[rem] += cnt + LIVE = 2 * K * V * T + mass = sum(r * n for r, n in paid.items()) + gap = M * LIVE - mass - (2 * K * V - L * cst) * T + if check: assert gap == 0, ('mass identity violated', s, gap) + cert = MOM.certify(dict(paid), M, LIVE, True) + return dict(s=s, feasible=True, c=cert['lower'], cf=float(cert['lower']), profile=dict(sorted(paid.items())), gap=gap, R=R, V=V, cst=cst, sec=round(time.time() - t0, 1), M=M, T=T, K=K) +def main(): + a = sys.argv[1:] + if a and a[0] == '--validate': + ref = {('R489', 11): '0.001565442026981656908596', ('R480', 11): '0.001574753352953808650916', ('R480', 9): '0.001587447106092548137108'} + cases = {'R489': (489, {1: 1200, 2: 1440, 4: 180, 6: 120, 8: 18}), 'R480': (480, {1: 1200, 2: 1440, 4: 180, 6: 120, 8: 9})} + for (name, s), want in ref.items(): + R, h = cases[name]; r = price(120, R, h, 72, s) + print(name, 's=%d' % s, r['c'][:26], 'want', want, 'EXACT' if r['c'].startswith(want[:24]) else 'DIFF (%s)' % r['c'][:30], 'profile', r['profile'], flush=True) + return + if a and a[0] == '--hist': + R, rest0 = a[1].split(':', 1); h, V, cst = rest0.rsplit(':', 2); hist = {int(k): v for k, v in json.loads(h).items()}; rest = a[2:] + d = dict(V=int(V), R=int(R), hist=hist, cst=int(cst)) + else: + w = json.loads(gzip.open(a[0], 'rt').read()); d = word_hist(w); rest = a[1:] + print('word: V=%d R=%d cst=%d local hist %s ENT=%d mass %d' % (d['V'], d['R'], d['cst'], d['hist'], d['ENT'], d['mass'])) + assert d['ENT'] == 0 + assert d['mass'] == H * d['R'] + d['cst'] + 2 * d['V'] * (H - 1), 'local mass identity' + for s in (list(map(int, rest)) or [9, 11, 13, 7]): + r = price(d['V'], d['R'], d['hist'], d['cst'], s) + print(json.dumps(r), flush=True) +if __name__ == '__main__': main() diff --git a/research/e8-punctured111-star/code/punct_cfg.py b/research/e8-punctured111-star/code/punct_cfg.py new file mode 100644 index 0000000000..ee5ee42498 --- /dev/null +++ b/research/e8-punctured111-star/code/punct_cfg.py @@ -0,0 +1,79 @@ +# The one configuration of the punctured-word hosted chain: everything that was a hard-coded 120 / 72 / 9600 / 489 in +# PR #493's pipeline is derived here from the WORD (or, for scripts that never see the word, from the exported records). +# Prepared by DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code. Apache-2.0. +"""Config of a bitE8/1 word for the hosted chain. + + v number of live ports (120 for PR #493 / #503, 111 for the punctured star unit) + R number of helper registers + ports_geom the live labels, as indices into the 120-line E8 system, in word order (absent for a full word) + totals map for each of the nine retained totals: the register, and the rank (frame dimension) it is COPYed from, + replayed here from the gates alone (72 = 9 x 8 for #493 / #503, 63 = 9 x 7 for the star unit) + +Nothing in here is read from the environment. `copy_ranks(w)` is an independent replay of the word's gates; the +emitter and the audit derive the same number from the exported records, and the chain asserts the two agree.""" +import gzip +import json +from fractions import Fraction as Fr +from pathlib import Path + + +def load(path): + p = Path(path) + return json.loads((gzip.decompress(p.read_bytes()) if p.suffix == '.gz' else p.read_bytes())) + + +def root120(pkg): + """The 120 labelled E8 root lines of PR #493's package (the order every geometry and port route is indexed by).""" + return load(Path(pkg) / 'data/bit/bitE8mut-r489.json.gz')['lines'] + + +def check_word(w, pkg): + """A full word (v = 120, no ports_geom) or a punctured one: live labels are a subsequence of the 120-line system.""" + v = w['v'] + if 'ports_geom' not in w: + assert v == 120 and len(w['lines']) == 120 + return + pg, r120 = w['ports_geom'], root120(pkg) + assert v < 120 and len(pg) == v == len(w['lines']) and list(pg) == sorted(set(pg)) and 0 <= pg[0] and pg[-1] < 120 + assert all(r120[p] == w['lines'][i] for i, p in enumerate(pg)), 'live lines are not the labelled 120-system lines' + if 'punctured' in w: + assert sorted(w['punctured'] + list(pg)) == list(range(120)) + # the frame-zero residual isometry of PR #493 (data/eleven/residual-isometries.json) is the coordinate frame 2e_0..2e_7, + # lines 0..7 of the 120-system; the stock validate_isometries(frames, lines) call needs them live at positions 0..7 + assert pg[:8] == list(range(8)), 'lines 0..7 must be live so the stock residual-isometry check applies unchanged' + + +def _rank(rows): + rows = [[Fr(x) for x in r] for r in rows] + r = 0 + for c in range(len(rows[0]) if rows else 0): + p = next((i for i in range(r, len(rows)) if rows[i][c] != 0), None) + if p is None: + continue + rows[r], rows[p] = rows[p], rows[r] + for i in range(r + 1, len(rows)): + if rows[i][c] != 0: + f = rows[i][c] / rows[r][c] + rows[i] = [a - f * b for a, b in zip(rows[i], rows[r])] + r += 1 + return r + + +def copy_ranks(w): + """Totals map: replay the gates D, A in order (a register stands at the frame of the last gate it was in) and read + the dimension of the frame each retained total is COPYed from. Frame 0 has dimension 0.""" + lines = w['lines'] + dims = [_rank([lines[i] for i in idx]) for idx in w['frames']] + cur = list(w['start']) + for gates in (w['D'], w['A']): + for f, d, srcs in gates: + for r in [d] + list(srcs): + cur[r] = f + return [dims[cur[q]] for q in w['ret']] + + +def config(w, pkg): + check_word(w, pkg) + cr = copy_ranks(w) + assert len(cr) == 9 and len(w['ret']) == 9 + return dict(v=w['v'], R=w['R'], copy_ranks=cr, cst=sum(cr), punctured=('ports_geom' in w)) diff --git a/research/e8-punctured111-star/code/word/gen_punct.py b/research/e8-punctured111-star/code/word/gen_punct.py new file mode 100644 index 0000000000..e290180974 --- /dev/null +++ b/research/e8-punctured111-star/code/word/gen_punct.py @@ -0,0 +1,305 @@ +"""Punctured quad-skeleton bit word (J3-A W1). gen.py of PR #493 with a removed-line set P (neither source nor target). +V1 = verbatim restriction of the R489/R480 skeleton (every helper register kept as a junk wire where its line is gone) + + totals as PSEUDO-TARGETS: for each y_j in P a fresh helper reads exactly what the (removed) target y_j would read + (qout x2 + qdeliv at D6[Hy], then its two needers at y_j-perp): x-part = J_{y_j}|L' = z_{y_j}|L', frame rank 7. +usage: python gen_punct.py OUT.json.gz P=0,11,38,... [PLAN=...]""" +import itertools, json, os, sys +HERE = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, HERE) +from pword import PWord, V, e8, solve_transform_lu, save # noqa +from geom import Geom # noqa + +GI = e8.GI +PKG = os.path.join(HERE, "..", "..", "..", "e8-bit-carrier-skeleton") # PR #493's package (plan, skeleton modules) + + +def load_plan(path): + d = json.load(open(path)) + return dict(match={tuple(f): k for f, k in d["match"]}, + ext={(q, tuple(H)): e for q, H, e in d["ext"]}, + plus={tuple(H): (l, r) for H, l, r in d["plus"]}) + + +def span_add(basis, v): + for pb, bv in basis: + if v >> pb & 1: + v ^= bv + if v: + basis.append((v.bit_length() - 1, v)); basis.sort(reverse=True) + return True + return False + + +def decoder_rows(cent, live): + rows = {} + for t in e8.bits(live): + want = (((1 << V) - 1) ^ sum((int(GI[t, b]) & 1) << b for b in range(V))) & live + found = None + for k in range(len(cent) + 1): + for C in itertools.combinations(range(len(cent)), k): + m = 0 + for c in C: + m ^= cent[c] + if m == want: + found = list(C); break + if found is not None: + break + assert found is not None, ("row not in span of totals", t) + rows[t] = found + return rows + + +def qnode_transform(inputs_x, outs, nlive_extra=0): + """register-level invertible transform on n = len(inputs) + junk wires: returns (nj, M rows, assign-ready outputs).""" + n0 = len(inputs_x) + # coordinates of each out in terms of the (independent) input x-parts + basis = [] + for i, v in enumerate(inputs_x): + combo = 1 << i + for pb, bv, bc in basis: + if v >> pb & 1: + v ^= bv; combo ^= bc + assert v, "live inputs dependent" + basis.append((v.bit_length() - 1, v, combo)); basis.sort(key=lambda z: -z[0]) + + def coords(w): + c = 0 + for pb, bv, bc in basis: + if w >> pb & 1: + w ^= bv; c ^= bc + assert w == 0, "output not in span of live inputs" + return c + A = [coords(o) for o in outs] + # independence of the A rows; add junk coordinates for dependent ones + bs = [] + rows = [] + nj = 0 + for a in A: + r = a + if not span_add(bs, r): + nj += 1 + r = a | (1 << (n0 + nj - 1)) + assert span_add(bs, r) + rows.append(r) + n = n0 + nj + # complete to a basis of F2^n with the remaining wires' unit vectors (live units first, then junk) + left = [] + for i in range(n): + if len(rows) + len(left) == n: + break + if span_add(bs, 1 << i): + left.append(1 << i) + assert len(rows) + len(left) == n + return nj, rows, left + + +def build(G, sol, P, verbose=True, totals="pseudo", zzleft=None): + zzleft = zzleft or {} + Pset = set(P) + live = ((1 << V) - 1) & ~sum(1 << s for s in Pset) + isl = lambda s: s not in Pset + W = PWord(live) + match, ext, plus = sol["match"], sol["ext"], sol["plus"] + mpairs, yy = {}, set() + for f in G.frames4: + a, b, c, d = f + mp = [((a, b), (c, d)), ((a, c), (b, d)), ((a, d), (b, c))][match[f]] + mpairs[f] = mp + yy.update(mp) + stats = dict(junk_carriers=0) + branch = {} + for f in G.frames4: + for s in f: + cs = list(G.cells_of[s]) + mcell = [c for c in cs if c in yy][0] + for c in cs: + if c == mcell: + branch[(s, c)] = s if isl(s) else None + else: + k = W.helper("carrier") + if isl(s): + W.gate(1 << s, k, [s]) + else: + stats["junk_carriers"] += 1 + branch[(s, c)] = k + delivery, keeper = {}, {} + cell_quads = {} + for q in range(len(G.quads)): + for c in G.qcells[q]: + cell_quads.setdefault(c, []).append(q) + owner_of_dcell = {G.dcell[H]: H for H in G.cells} + for c in G.cells: + F = G.cmask[c] + s, d = c + qa, qb = cell_quads[c] + if c in yy: + e1 = W.helper("empty"); e2 = W.helper("empty") + srcs = [branch[(x, c)] for x in (s, d) if branch[(x, c)] is not None] + if srcs: + W.gate(F, e1, srcs) + W.gate(F, e2, [e1]) + delivery[(c, qa)] = e1; delivery[(c, qb)] = e2 + keeper[(c, s)] = branch[(s, c)]; keeper[(c, d)] = branch[(d, c)] + else: + H = owner_of_dcell[c] + l, _rcv = plus[H] + l2 = d if l == s else s + e = W.helper("empty") + bl, bl2 = branch[(l, c)], branch[(l2, c)] + if isl(l): + W.gate(F, bl2, [bl]) # bl2 (junk or real carrier) <- + x_l + # else: bl junk (x-part 0): the original gate adds nothing to x + if isl(l) or isl(l2): + W.gate(F, e, [bl2]) + delivery[(c, qa)] = bl2 + delivery[(c, qb)] = e + keeper[(c, l)] = bl + # quads + qout = {} + for q in range(len(G.quads)): + U = G.quads[q] + cs = G.qcells[q] + wires = [delivery[(c, q)] for c in cs] + S = 0 + for c in cs: + S |= G.cmask[c] + owners = G.qowners[q] + outs = [] + for H in owners: + e = ext[(q, H)] + D = G.cmask[G.dcell[H]]; Qc = G.cmask[G.qcell[(q, H)]] + outs.append(S ^ D ^ Qc ^ ({"D": D, "Q": Qc, "0": 0}[e])) + full_inputs = [G.cmask[c] for c in cs] + ops, assign = solve_transform_lu(full_inputs, outs) + for a, b in ops: + W.gate(U, wires[a], [wires[b]]) + for k, H in enumerate(owners): + qout[(q, H)] = wires[assign[k]] + assert W.xpart(wires[assign[k]]) == outs[k] & live, ("quad out", q, H) + # (z,z) D6 + needer, dead = {}, [] + for H in G.cells: + if H in yy: + continue + q1, q2 = G.d6quads[H] + o1, o2 = qout[(q1, H)], qout[(q2, H)] + l, rcv = plus[H] + p = keeper[(G.dcell[H], l)] + F = G.D6[H] + other = H[0] if rcv == H[1] else H[1] + opt = zzleft.get(H, 0) + if opt & 1: + o1, o2 = o2, o1 + W.gate(F, o1, [o2]) + W.gate(F, p, [o1]) + if opt & 2: + W.gate(F, o2, [p, o1]) + needer[(H, rcv)] = p + needer[(H, other)] = o1 + dead.append(o2) + # Q needs + qneed = {} + for t in range(V): + f = G.phi[t] + m = [p for p in mpairs[f] if t in p][0] + Hy = tuple(sorted(m)) + acc = e8.HYP[t] & live + for q in G.d6quads[Hy]: + acc ^= W.xpart(qout[(q, Hy)]) + for e in f: + if e == t: + continue + H = tuple(sorted((t, e))) + if H == Hy: + continue + acc ^= W.xpart(needer[(H, t)]) + if Hy in qneed: + assert qneed[Hy] == acc, ("y-partners disagree", t) + qneed[Hy] = acc + # Q-nodes + qdeliv = {} + stats["qnode_junk"] = 0 + for bi, bmask in enumerate(G.blocks): + cb = G.comp[bi] + Hs = sorted(H for H in yy if G.cblk[H] == cb) + outs = [qneed[H] for H in Hs] + assert all((o & ~(bmask & live)) == 0 for o in outs) + wires = [] + for f in G.frames4: + if G.blk[f[0]] != bi: + continue + for c in mpairs[f]: + for s in c: + if isl(s): + wires.append(keeper[(c, s)]) + inputs = [W.xpart(w) for w in wires] + nj, rows, left = qnode_transform(inputs, outs) + stats["qnode_junk"] += nj + for j in range(nj): + wires.append(W.helper("qjunk")) + n = len(wires) + allrows = rows + left + ops, assign = solve_transform_lu([1 << i for i in range(n)], allrows) + for a, b in ops: + W.gate(bmask, wires[a], [wires[b]]) + for k, H in enumerate(Hs): + qdeliv[H] = wires[assign[k]] + assert W.xpart(wires[assign[k]]) == qneed[H], ("qdeliv", bi, H) + # totals + if totals == "pseudo": + for t in sorted(P): + f = G.phi[t] + m = [p for p in mpairs[f] if t in p][0] + Hy = tuple(sorted(m)) + tot = W.helper("total") + srcs = [qout[(q, Hy)] for q in G.d6quads[Hy]] + [qdeliv[Hy]] + W.gate(G.D6[Hy], tot, srcs) + nd = [] + for e in f: + if e == t: + continue + H = tuple(sorted((t, e))) + if H == Hy: + continue + nd.append(needer[(H, t)]) + W.gate(e8.HYP[t], tot, nd) + assert W.xpart(tot) == e8.HYP[t] & live, ("total", t) + W.ret.append(tot) + cvals = [W.xpart(q) for q in W.ret] + rows = decoder_rows(cvals, live) + # phase B + W.phase = "B" + for t in W.ports: + f = G.phi[t] + m = [p for p in mpairs[f] if t in p][0] + Hy = tuple(sorted(m)) + srcs = [qout[(q, Hy)] for q in G.d6quads[Hy]] + [qdeliv[Hy]] + W.gate(G.D6[Hy], V + t, srcs) + for t in W.ports: + f = G.phi[t] + srcs = [] + for e in f: + if e == t: + continue + H = tuple(sorted((t, e))) + if H in yy: + continue + srcs.append(needer[(H, t)]) + W.gate(e8.HYP[t], V + t, srcs) + word = W.build(rows) + word["stats"] = stats + return W, word + + +def main(): + args = dict(a.split("=", 1) for a in sys.argv[2:]) + P = [int(x) for x in args["P"].split(",")] + G = Geom() + sol = load_plan(args.get("PLAN", PKG + "/data/skeleton/plan-skB.json")) + W, word = build(G, sol, P) + print("R", word["R"], "v", word["v"], "gates D/A/B/C", len(word["D"]), len(word["A"]), len(word["B"]), len(word["C"]), word["stats"]) + save(word, sys.argv[1]) + + +if __name__ == "__main__": + main() diff --git a/research/e8-punctured111-star/code/word/pword.py b/research/e8-punctured111-star/code/word/pword.py new file mode 100644 index 0000000000..01bfe54747 --- /dev/null +++ b/research/e8-punctured111-star/code/word/pword.py @@ -0,0 +1,136 @@ +"""Word builder for punctured bit words (live port subset of the 120 E8 lines). +Internal ids follow wordkit.Word (x_s = s, y_t = V+t, helpers 2V+k, geometry line indices); build() renumbers to the +compact v = |live| layout of the bitE8/1 format. Frames are LIVE line sets (closed 120-line mask & live mask); their +rank is that of the live lines (checkers recompute it from the word's `lines`).""" +import os, sys +PARENT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "e8-bit-carrier-skeleton") # PR #493's package +sys.path.insert(0, os.path.join(PARENT, "code", "skeleton")) +import e8 # noqa +from wordkit import solve_transform_lu, inverse_ops_nopivot, save # noqa + +V = e8.V + + +class PWord: + def __init__(self, live): + self.live = live + self.ports = e8.bits(live) + self.nh = 0 + self.cur, self.content, self.role = {}, {}, {} + for s in self.ports: + self.cur[s] = 1 << s + self.content[s] = 1 << s + for t in self.ports: + self.cur[V + t] = 0 + self.content[V + t] = 1 << (V + t) + self.A, self.B = [], [] + self.ret = [] + self.phase = "A" + self.cleanup = "literal" + + def helper(self, role=""): + r = 2 * V + self.nh + self.nh += 1 + self.cur[r] = 0 + self.content[r] = 1 << r + self.role[r] = role + return r + + def fr(self, F): + return (e8.closure(F)[0] if F else 0) & self.live + + def climb(self, r, F): + a = self.cur[r] + if a == F: + return + assert (a & ~F) == 0, ("frame not nested", r, e8.bits(a), e8.bits(F)) + self.cur[r] = F + + def gate(self, F, dst, srcs): + F = self.fr(F) + regs = [dst] + list(srcs) + assert len(set(regs)) == len(regs), regs + assert not (V <= dst < 2 * V and self.phase == "A"), "y written before the scatter" + for r in regs: + assert r in self.cur, ("absent register", r) + if V <= r < 2 * V: + assert self.phase == "B", "y used before the scatter" + self.climb(r, F) + for s in srcs: + self.content[dst] ^= self.content[s] + (self.A if self.phase == "A" else self.B).append((F, dst, list(srcs))) + + def xpart(self, r): + return self.content[r] & ((1 << V) - 1) + + def build(self, scatter_rows): + nh = self.nh + ports = self.ports + v = len(ports) + pidx = {s: i for i, s in enumerate(ports)} + + def rid(r): # internal -> compact id + if r < V: + return pidx[r] + if r < 2 * V: + return v + pidx[r - V] + return 2 * v + (r - 2 * V) + frames = {} + + def fid(mask): + if mask not in frames: + frames[mask] = len(frames) + return frames[mask] + FULL = self.live + fid(0) + fid(FULL) + A = [[fid(F), d, list(s)] for F, d, s in self.A] # internal ids + B = [[fid(F), d, list(s)] for F, d, s in self.B] + dv = {} + for h in range(nh): + dv[2 * V + h] = 1 << h + for s in ports: + dv[s] = 0 + dv[V + s] = 0 + for f, d, srcs in A: + for s in srcs: + dv[d] ^= dv[s] + cdirt = [dv[q] for q in self.ret] + for t in ports: + for k in scatter_rows[t]: + dv[V + t] ^= cdirt[k] + for f, d, srcs in B: + for s in srcs: + dv[d] ^= dv[s] + D = [] + for t in ports: + m = dv[V + t] + srcs = [] + while m: + b = m & -m + srcs.append(2 * V + b.bit_length() - 1) + m ^= b + if srcs: + D.append([fid(0), V + t, srcs]) + Cl = [] + for f, d, srcs in reversed(A + B): + if d < V or d >= 2 * V: + Cl.append([fid(FULL), d, srcs]) + fr = [None] * len(frames) + for mk, i in frames.items(): + fr[i] = [pidx[b] for b in e8.bits(mk)] + z = fid(0) + start = [fid(1 << s) for s in ports] + [z] * (v + nh) + final = [fid(FULL)] * v + [fid(e8.HYP[t] & self.live) for t in ports] + [fid(FULL)] * nh + # frames dict may have grown (fid for start/final): rebuild fr + fr = [None] * len(frames) + for mk, i in frames.items(): + fr[i] = [pidx[b] for b in e8.bits(mk)] + + def rg(gs): + return [[f, rid(d), [rid(s) for s in srcs]] for f, d, srcs in gs] + return dict(format="bitE8/1+mut", coords="ham", h=8, v=v, R=nh, lines=[list(e8.LINES[s]) for s in ports], + form="/2", frames=fr, start=start, final=final, ret=[rid(q) for q in self.ret], + scatter=[list(scatter_rows[t]) for t in ports], D=rg(D), A=rg(A), B=rg(B), C=rg(Cl), + punctured=[s for s in range(V) if not (self.live >> s) & 1], + ports_geom=ports) diff --git a/research/e8-punctured111-star/data/bitE8mut-v111-r489.json.gz b/research/e8-punctured111-star/data/bitE8mut-v111-r489.json.gz new file mode 100644 index 0000000000..f69cc13093 Binary files /dev/null and b/research/e8-punctured111-star/data/bitE8mut-v111-r489.json.gz differ diff --git a/research/e8-punctured111-star/data/complex-b.json b/research/e8-punctured111-star/data/complex-b.json new file mode 100644 index 0000000000..3fec5ba6ce --- /dev/null +++ b/research/e8-punctured111-star/data/complex-b.json @@ -0,0 +1,19 @@ +{ + "note": "Cited complex coarse savings b (not rebuilt here). The value is read from the cited PR's own EXPECTED.json, vendored byte-identical under data/complex/pr535/ and pinned by git blob id; verify.py checks the value against the receipt. Only the outer assembly uses b; it carries no port count (the bit unit has v = 111, the cited complex word its own).", + "suppliers": [ + { + "name": "pr535", + "pr": 535, + "author": "icekylinx", + "commit": "25f9b7c2310d40c9efdfbe368a40ba6e74d3b0a2", + "receipt": "data/complex/pr535/EXPECTED.json", + "receipt_git_blob": "2c5a1a32628e2e93b29a54ecfb9ccfa5d84b9b17", + "field": "complex_lower", + "b": "1589991533606044174031/1000000000000000000000000", + "hosting": "post-center rank-four kernels on PR #531's complex word, whole-call hosting (research/post-center-rank4-global)", + "construction": "PR #535 composes its complex supplier with the live bit c of PR #510 (R480, nine stages) and reaches kappa 0.001584931111785787 (bit-bound)", + "status": "Conditional finite witness under the retained all-size compiler, common-label/mutable-basis, whole-call hosting, restored-work, precision/tape and analytic-transfer contracts. Fresh complex admission and finite invoice are separately hash-bound; no unconditional theorem is claimed.", + "role": "primary" + } + ] +} diff --git a/research/e8-punctured111-star/data/complex/pr535/EXPECTED.json b/research/e8-punctured111-star/data/complex/pr535/EXPECTED.json new file mode 100644 index 0000000000..2c5a1a3262 --- /dev/null +++ b/research/e8-punctured111-star/data/complex/pr535/EXPECTED.json @@ -0,0 +1,62 @@ +{ + "status": "PASS_ASYNC_COMPLEX_AND_CITED_BIT_EXACT_ASSEMBLY", + "kappa": "1584931111785787/1000000000000000000", + "kappa_decimal": "0.001584931111785787", + "complex_lower": "1589991533606044174031/1000000000000000000000000", + "complex_decimal": "0.001589991533606044174031", + "bit_lower": "396861776523137034277/250000000000000000000000", + "bit_decimal": "0.001587447106092548137108", + "binding_component": "bit", + "improvements": { + "PR531": { + "baseline": "1517760977820331/1000000000000000000", + "relative_gain": "67170133965456/1517760977820331", + "percent_display": "4.42560686" + }, + "rejected_POST208_checkpoint": { + "baseline": "771820390859371/500000000000000000", + "relative_gain": "41290330067045/1543640781718742", + "percent_display": "2.67486649" + }, + "PR533": { + "baseline": "381051987698311/250000000000000000", + "relative_gain": "60723160992543/1524207950793244", + "percent_display": "3.98391577" + } + }, + "global_template_content_sha256": "b9f4b60e56e5153c1fc89370e9ceb09f24b23e1c8ff56f2b47ef9d867aa04f2c", + "raw_word_content_sha256": "b9110e8ddb770a3874c2df2019e04a98c1a25684072f7f8e5772653f59f15db2", + "canonical_word_content_sha256": "7c84ac65c8b37173aa4293934f041915895e8ec30595844cc1534e2a19ae0d25", + "global_profile": { + "1": 158976, + "2": 52864, + "3": 15200, + "4": 20160, + "5": 4032, + "6": 4032, + "7": 352, + "8": 576, + "48": 1632 + }, + "local_profile": { + "1": 2208, + "2": 728, + "3": 184, + "4": 280, + "5": 56, + "6": 56, + "8": 8 + }, + "local_rank_mass": 6016, + "entrance_rank": 376, + "width_inventory": { + "5": 56, + "8": 152, + "9": 296 + }, + "global_prefix_bits": 225, + "live": 7168, + "physical": 7682, + "deficit": 2560, + "scope": "Conditional finite witness under the retained all-size compiler, common-label/mutable-basis, whole-call hosting, restored-work, precision/tape and analytic-transfer contracts. Fresh complex admission and finite invoice are separately hash-bound; no unconditional theorem is claimed." +} diff --git a/research/e8-punctured111-star/data/control-r480/EXPECTED-pr503.json b/research/e8-punctured111-star/data/control-r480/EXPECTED-pr503.json new file mode 100644 index 0000000000..e791affeea --- /dev/null +++ b/research/e8-punctured111-star/data/control-r480/EXPECTED-pr503.json @@ -0,0 +1,75 @@ +{ + "word": { + "R": 480, + "content_sha256": "8639e22008c24a5690dd250eba702fe5fca85ddd036dcbec20baba77b7e213ba", + "local_histogram": { + "1": 1200, + "2": 1440, + "4": 180, + "6": 120, + "8": 9 + }, + "five_stage_payload_bits": 102, + "eleven_stage_payload_bits": 102, + "source_destination_gates_A": 577 + }, + "control_first_register": { + "five_stage_payload_bits": 129, + "refused_by": "columns_h: payloadfiniteprefix2^104" + }, + "eleven": { + "bit_lower": "393688338238452162729/250000000000000000000000", + "bit_lower_decimal": "0.001574753352953808650916", + "profile": { + "1": 105600, + "2": 130560, + "4": 19680, + "6": 14400, + "7": 7680, + "8": 792, + "48": 1, + "56": 2742 + }, + "emitted_program_sha256": "7da5e3cb8daa231104f4e55f16c560fa56a59f10b8b2789e173923d9d2ca46fc", + "bit": { + "live": 9600, + "physical": 9609, + "maxchild": 56, + "rank_mass": 745536, + "hosted_residuals": 42240, + "prefix_bits": 5479, + "charged_prefix_bits": 5504, + "coefficient_bits": 5479, + "three_level_coefficient_bits": 16491, + "charged_three_level_coefficient_bits": 16512, + "row_coefficient": 19431, + "halving_depth": 3 + }, + "kappa": { + "pr484": { + "kappa": "662515748707749/500000000000000000", + "kappa_decimal": "0.001325031497415498", + "binding_component": "complex", + "complex_lower": "663394767670133/500000000000000000" + }, + "pr471": { + "kappa": "260706019542937/200000000000000000", + "kappa_decimal": "0.001303530097714685", + "binding_component": "complex", + "complex_lower": "1305231506267591/1000000000000000000" + }, + "pr458": { + "kappa": "323880830669511/250000000000000000", + "kappa_decimal": "0.001295523322678044", + "binding_component": "complex", + "complex_lower": "1297203880559577927527/1000000000000000000000000" + } + } + }, + "parent": { + "pr": 493, + "bit_lower": "391360506745414227149/250000000000000000000000", + "bit_lower_decimal": "0.001565442026981656908596", + "R": 489 + } +} \ No newline at end of file diff --git a/research/e8-punctured111-star/data/control-r480/bitE8mut-r480.json.gz b/research/e8-punctured111-star/data/control-r480/bitE8mut-r480.json.gz new file mode 100644 index 0000000000..8e59c4b538 Binary files /dev/null and b/research/e8-punctured111-star/data/control-r480/bitE8mut-r480.json.gz differ diff --git a/research/e8-punctured111-star/data/control-r480/hosting-r480.json b/research/e8-punctured111-star/data/control-r480/hosting-r480.json new file mode 100644 index 0000000000..e49abb321a --- /dev/null +++ b/research/e8-punctured111-star/data/control-r480/hosting-r480.json @@ -0,0 +1,240 @@ +{ + "bit": { + "patterns": [ + [ + 0, + [ + 8 + ], + 1920 + ], + [ + 1, + [], + 1920 + ], + [ + 2, + [ + 8, + 8, + 8 + ], + 1920 + ], + [ + 3, + [], + 1920 + ], + [ + 4, + [ + 8, + 8, + 8, + 8, + 8 + ], + 1920 + ], + [ + 5, + [], + 1920 + ], + [ + 6, + [], + 1918 + ], + [ + 6, + [ + 8 + ], + 1 + ], + [ + 6, + [ + 8, + 8, + 8, + 8, + 8, + 8, + 8 + ], + 1 + ], + [ + 7, + [], + 1920 + ], + [ + 8, + [], + 824 + ], + [ + 8, + [ + 8, + 8, + 8, + 8, + 8, + 8, + 8 + ], + 1096 + ], + [ + 9, + [ + 8, + 8, + 8, + 8, + 8 + ], + 1920 + ], + [ + 10, + [ + 8, + 8, + 8 + ], + 1920 + ], + [ + 11, + [ + 8 + ], + 1920 + ] + ], + "proxy_saving": 189827.32249716797, + "stages": [ + [ + 0, + 8, + 1, + 1920 + ], + [ + 2, + 8, + 0, + 3840 + ], + [ + 2, + 8, + 1, + 1913 + ], + [ + 2, + 8, + 2, + 7 + ], + [ + 4, + 8, + 2, + 3833 + ], + [ + 4, + 8, + 3, + 8 + ], + [ + 4, + 8, + 4, + 3840 + ], + [ + 4, + 8, + 5, + 1919 + ], + [ + 6, + 8, + 1, + 7 + ], + [ + 6, + 8, + 6, + 1 + ], + [ + 8, + 8, + 3, + 3832 + ], + [ + 8, + 8, + 9, + 1920 + ], + [ + 8, + 8, + 10, + 1920 + ], + [ + 9, + 8, + 5, + 1921 + ], + [ + 9, + 8, + 6, + 3839 + ], + [ + 9, + 8, + 8, + 3840 + ], + [ + 10, + 8, + 7, + 3840 + ], + [ + 10, + 8, + 9, + 1920 + ], + [ + 11, + 8, + 10, + 1920 + ] + ] + } +} diff --git a/research/e8-punctured111-star/data/hosting-v111-r489.json b/research/e8-punctured111-star/data/hosting-v111-r489.json new file mode 100644 index 0000000000..131d6cbc66 --- /dev/null +++ b/research/e8-punctured111-star/data/hosting-v111-r489.json @@ -0,0 +1,213 @@ +{ + "bit": { + "patterns": [ + [ + 0, + [ + 8 + ], + 1776 + ], + [ + 1, + [], + 1776 + ], + [ + 2, + [ + 8, + 8, + 8 + ], + 1776 + ], + [ + 3, + [], + 1776 + ], + [ + 4, + [ + 8, + 8, + 8, + 8, + 8 + ], + 1776 + ], + [ + 5, + [], + 1776 + ], + [ + 6, + [], + 1776 + ], + [ + 7, + [], + 1776 + ], + [ + 8, + [], + 195 + ], + [ + 8, + [ + 8, + 8, + 8, + 8, + 8, + 8, + 8 + ], + 1581 + ], + [ + 9, + [ + 8, + 8, + 8, + 8, + 8 + ], + 1776 + ], + [ + 10, + [], + 1 + ], + [ + 10, + [ + 8, + 8, + 8 + ], + 1775 + ], + [ + 11, + [ + 8 + ], + 1776 + ] + ], + "proxy_saving": 186085.65977536424, + "stages": [ + [ + 0, + 8, + 1, + 1776 + ], + [ + 2, + 8, + 0, + 3912 + ], + [ + 2, + 8, + 1, + 1416 + ], + [ + 4, + 8, + 1, + 720 + ], + [ + 4, + 8, + 2, + 3912 + ], + [ + 4, + 8, + 4, + 3912 + ], + [ + 4, + 8, + 5, + 336 + ], + [ + 8, + 8, + 3, + 3912 + ], + [ + 8, + 8, + 6, + 2520 + ], + [ + 8, + 8, + 9, + 2499 + ], + [ + 8, + 8, + 10, + 2136 + ], + [ + 9, + 8, + 5, + 3576 + ], + [ + 9, + 8, + 6, + 1392 + ], + [ + 9, + 8, + 8, + 3912 + ], + [ + 10, + 8, + 7, + 3912 + ], + [ + 10, + 8, + 9, + 1413 + ], + [ + 11, + 8, + 10, + 1776 + ] + ] + } +} diff --git a/research/e8-punctured111-star/verify.py b/research/e8-punctured111-star/verify.py new file mode 100644 index 0000000000..15574da2b4 --- /dev/null +++ b/research/e8-punctured111-star/verify.py @@ -0,0 +1,366 @@ +# Punctured star bit unit (v = 111 ports, nine rank-7 totals): the word through PR #493's hosted-audit chain. Verifier. +# Prepared by DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code. Apache-2.0. +"""usage: python verify.py /absolute/new/output [--light] [--no-control] [--no-mutants] + +FULL runs PR #493's verify.sh unchanged (the parent: its word, checkers, pipeline, controls and compositions), then +everything below. --light skips the parent run. The parent's manifest is always checked. +Steps: 0 manifests; 1 the word rebuilt from the parent's plan; 2 the independent checker (v <= 120) and its mutants; +3 the official cohort checkers at (v, R); 4 exact Gram; 5 the eleven-stage whole-residual hosted pipeline (geometry, +hosting, emit, audit, assembly) with every constant derived from the word; 6 the pricing harness (pricex.py) must give +the same c to all 24 digits; 7 REGRESSION: the R480 word of PR #503 through the stock chain and through the adapted +chain, outputs compared byte for byte; 8 mutation controls; 9 composition with the cited complex suppliers (#535) and +the control that reproduces #535's published kappa; 10 summary against EXPECTED.json. +Needs Python 3.11+ with numpy, sympy, scipy, a C++17 compiler (CXX) and Boost headers (BOOST_INCLUDE), as the parent does.""" +import filecmp +import gzip +import hashlib +import json +import os +import subprocess +import sys +import time +from fractions import Fraction as F +from pathlib import Path + +HERE = Path(__file__).resolve().parent +PARENT = HERE.parent / 'e8-bit-carrier-skeleton' +args = [a for a in sys.argv[1:] if not a.startswith('--')] +LIGHT, NOCTL, NOMUT = '--light' in sys.argv, '--no-control' in sys.argv, '--no-mutants' in sys.argv +UNTIL = next((int(a.split('=')[1]) for a in sys.argv if a.startswith('--until=')), 99) # development aid: stop after step N +assert len(args) == 1, __doc__ +WD = Path(args[0]).resolve(); WD.mkdir(parents=True, exist_ok=True) +assert not str(WD).startswith(str(HERE.parent)), 'output dir must be outside research/' +PY = sys.executable; CXX = os.environ.get('CXX', 'c++'); BI = os.environ.get('BOOST_INCLUDE', '/usr/include') +ENV = dict(os.environ, PYTHONDONTWRITEBYTECODE='1') +C, B = PARENT / 'code', PARENT / 'code/bit'; CK = B / 'checkers'; HUB = C / 'hub' +WORD = HERE / 'data/bitE8mut-v111-r489.json.gz'; HOST = HERE / 'data/hosting-v111-r489.json' +CTL = HERE / 'data/control-r480'; CWORD, CHOST = CTL / 'bitE8mut-r480.json.gz', CTL / 'hosting-r480.json' +EXP = json.loads((HERE / 'EXPECTED.json').read_text()) +INC = ['-I%s' % (PARENT / 'portable-include'), '-I%s' % CK, '-I%s' % BI] +sys.dont_write_bytecode = True +sys.path.insert(0, str(HERE / 'code')) +import punct_cfg as PC # noqa: E402 +T0 = time.time() + + +def run(cmd, cwd=None, ok=True, quiet=True, env=None, out=None): + p = subprocess.run([str(x) for x in cmd], cwd=cwd, env=env or ENV, capture_output=True, text=True) + if out is not None: + Path(out).write_text(p.stdout) + if ok and p.returncode != 0: + sys.stderr.write(p.stdout[-3000:] + p.stderr[-3000:]); raise SystemExit('FAILED: %s' % ' '.join(map(str, cmd))) + if not quiet: + for line in p.stdout.rstrip().splitlines(): print(' ' + line) + return p + + +def sha(p): return hashlib.sha256(Path(p).read_bytes()).hexdigest() + + +def content_sha(w): return hashlib.sha256(json.dumps(w, sort_keys=True, separators=(',', ':')).encode()).hexdigest() + + +def rj(p): return json.loads(Path(p).read_text()) + + +def step(s): + n = s.split('.')[0] + if n.isdigit() and int(n) > UNTIL: raise SystemExit('stopped before step %s (--until)' % n) + print('== %s [%.0fs]' % (s, time.time() - T0), flush=True) + + +def stacking(bitdir, v): + """hosting disclosure: in how many of the 88 calls does one physical family host more than one helper of that call?""" + from collections import Counter + t = json.loads(gzip.decompress((Path(bitdir) / 'GLOBAL-TEMPLATE.json.gz').read_bytes())) + m = [max(Counter(o[0] for o in c['owners'][2 * v:]).values()) for c in t['calls']] + return dict(calls=len(m), calls_with_stacked_helpers=sum(1 for x in m if x > 1), max_helpers_on_one_family=max(m)) + + +def norm(p, drop=('seconds',)): + d = rj(p) + for k in drop: d.pop(k, None) + return d + + +# ------------------------------------------------------------------------------------------------------------------ +step('0. manifests: this package (MANIFEST.json) and the parent package (its MANIFEST.sha256, as its step 0)') +man = rj(HERE / 'MANIFEST.json') +for rel, h in man['files'].items(): assert sha(HERE / rel) == h, ('MISMATCH', rel) +listed = set(man['files']) | {'MANIFEST.json'} +present = {str(p.relative_to(HERE)) for p in HERE.rglob('*') if p.is_file() and '__pycache__' not in p.parts} +assert present == listed, ('unlisted or missing files', sorted(present ^ listed)) +assert sha(PARENT / 'MANIFEST.sha256') == man['parent_manifest_sha256'], 'parent MANIFEST.sha256 changed' +bad = 0 +for line in (PARENT / 'MANIFEST.sha256').read_text().splitlines(): + h, p = line.split(' ', 1) + if sha(PARENT / p) != h: print('PARENT MISMATCH', p); bad += 1 +assert not bad +print(' %d package files and %d parent files match their manifests' % (len(man['files']), len((PARENT / 'MANIFEST.sha256').read_text().splitlines()))) + +if not LIGHT: + step('P. parent: PR #493 verify.sh, unchanged') + run(['bash', PARENT / 'verify.sh', WD / 'parent'], env=dict(ENV, PYTHON=PY), quiet=False) + +# ------------------------------------------------------------------------------------------------------------------ +step('1. the word, rebuilt from the parent plan (code/word/gen_punct.py); the one configuration') +(WD / 'gen').mkdir(exist_ok=True) +P = EXP['word']['punctured'] +run([PY, '-I', '-B', HERE / 'code/word/gen_punct.py', WD / 'gen/word.json.gz', 'P=' + ','.join(map(str, P))], cwd=WD / 'gen') +assert (WD / 'gen/word.json.gz').read_bytes() == WORD.read_bytes(), 'rebuilt word differs from the shipped word' +w = PC.load(WORD); cfg = PC.config(w, PARENT) +assert content_sha(w) == EXP['word']['content_sha256'] and w['punctured'] == P +V, R, CST = cfg['v'], cfg['R'], cfg['cst'] +assert (V, R, CST) == (EXP['word']['v'], EXP['word']['R'], EXP['word']['cst']) and cfg['copy_ranks'] == EXP['word']['copy_ranks'] +print(' rebuilt word is byte-identical to data/bitE8mut-v111-r489.json.gz (content sha256 %s...)' % content_sha(w)[:16]) +print(' config: v = %d live ports (120 - %d punctured: %s), R = %d helpers, totals map: registers %s copy ranks %s => cst = %d' + % (V, len(P), P, R, w['ret'], cfg['copy_ranks'], CST)) +AD = WD / 'adapted' +run([PY, '-I', '-B', HERE / 'code/adapt.py', PARENT, WORD, AD], quiet=False) + +# ------------------------------------------------------------------------------------------------------------------ +SKIP2 = '--skip2' in sys.argv # development aid only (step 2 is the slow pure-Python checker) +iface = None +if not SKIP2: + step("2. PR #370's checker for v <= 120 ports: the stock-form file refuses source destinations; the relaxed copy passes; interface") + p = run([PY, '-I', '-B', AD / 'chk/checkword.py', WORD, C / 'pricing'], ok=False) + assert p.returncode != 0 and 'x register written' in p.stderr, 'stock-form checker did not refuse' + print(' stock-form checker refuses, as for the parent: x register written') + p = run([PY, '-I', '-B', B / 'independent/checkword.py', WORD, C / 'pricing'], ok=False) + assert p.returncode != 0 and 'AssertionError' in p.stderr and 'x register written' not in p.stderr + print(" the parent's own checker refuses the 111-line word at its v == 120 assertion (the one edit made in chk/checkword.py)") + run([PY, '-I', '-B', AD / 'chk/relax.py', AD / 'rchk']) + run([PY, '-I', '-B', AD / 'rchk/checkword_mut.py', WORD, C / 'pricing'], quiet=False) + run([PY, '-I', '-B', B / 'independent/interface.py', WORD, '--json', WD / 'interface.json'], quiet=False) + run([PY, '-I', '-B', B / 'independent/mutate_mut.py', WORD, AD / 'rchk/checkword_mut.py', C / 'pricing', + B / 'independent/interface.py'], quiet=False) + iface = rj(WD / 'interface.json') +else: + run([PY, '-I', '-B', AD / 'chk/relax.py', AD / 'rchk']) + +# ------------------------------------------------------------------------------------------------------------------ +step('3. official cohort checkers at (v, R): legality (NCOPY = 9), five-stage columns, eleven-stage columns (KPAIRS = 5)') +BIN = WD / 'bin'; BIN.mkdir(exist_ok=True) +cc = [CXX, '-O2', '-std=c++17', '-DHDIM=8'] + + +def build_checkers(v, r): + """compile the official checkers for (v, r); the compiles run concurrently""" + # payload probe = columns_h.cpp minus its payload assertion; used ONLY to report a refused control's bill + probe = (CK / 'columns_h.cpp').read_text() + anchor = 'need(payload<(cpp_int(1)<<104),"payloadfiniteprefix2^104");'; assert probe.count(anchor) == 1 + (BIN / 'columns_probe.cpp').write_text(probe.replace(anchor, '')) + flags = ['-DNCOPY=9', '-DVPORTS=%d' % v, '-DRHELP=%d' % r] + jobs = [cc + ['-DNCOPY=9'] + INC + ['-o', BIN / 'legality', CK / 'legality_h.cpp'], + cc + INC + ['-o', BIN / 'legality_ncopy_h', CK / 'legality_h.cpp'], + cc + flags + INC + ['-o', BIN / ('columns_probe_v%d_r%d' % (v, r)), BIN / 'columns_probe.cpp']] + for name, extra, src in (('columns_h', [], 'columns_h.cpp'), ('columns_k5', ['-DKPAIRS=5'], 'columns_k.cpp'), + ('columns_k2', ['-DKPAIRS=2'], 'columns_k.cpp')): + jobs.append(cc + flags + extra + INC + ['-o', BIN / ('%s_v%d_r%d' % (name, v, r)), CK / src]) + procs = [(j, subprocess.Popen([str(x) for x in j], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, env=ENV)) for j in jobs] + for j, p in procs: + o, e = p.communicate() + if p.returncode != 0: + sys.stderr.write(o[-3000:] + e[-3000:]); raise SystemExit('FAILED: %s' % ' '.join(map(str, j))) + + +def cohort(word, d): + run([PY, '-I', '-B', B / 'export_records.py', word, d / 'records']) + run([PY, '-I', '-B', B / 'regression/stage_cohort.py', d / 'records', d / 'records', d / 'cin', d / 'cout']) + + +def columns(v, r, d, kinds=('columns_h', 'columns_k5', 'columns_k2')): + co = d / 'cout' + run([BIN / 'legality', d / 'cin', co, co / 'legality.json']) + for k in kinds: + out = {'columns_h': 'columns.json', 'columns_k5': 'columns_k5.json', 'columns_k2': 'columns_k2.json'}[k] + run([BIN / ('%s_v%d_r%d' % (k, v, r)), co / 'COHORT249-RECORDS.bin', co / out]) + + +build_checkers(V, R) +cohort(WORD, WD); columns(V, R, WD) +co = WD / 'cout' +lg, cl, k5, k2 = rj(co / 'legality.json'), rj(co / 'columns.json'), rj(co / 'columns_k5.json'), rj(co / 'columns_k2.json') +assert lg['status'] == 'PASS_INDEPENDENT_COHORT_LEGALITY_SOURCE_OWNERS_AND_LIFECYCLE' and lg['copies'] == lg['erasures'] == 9 +assert cl['status'] == 'PASS_NEW_COHORT249_ALL_FIVE_STAGE_FORMAL_COLUMNS_AND_PREFIX_BILL' and cl['formal_columns_checked'] == 4 * V + R +assert k5['status'] == 'PASS_NEW_COHORT249_ALL_BRIDGED_STAGE_FORMAL_COLUMNS_AND_PREFIX_BILL' and k5['formal_columns_checked'] == 10 * V + R +assert len(k5['stages']) == 11 and k5['bridge_additions'] == 24 * V and all(x['rejected'] for x in k5['negative_controls']) +assert len(k5['negative_controls']) == 24 and dict(map(tuple, k5['local_raw_H'])) == dict(map(tuple, cl['local_raw_H'])) +assert {k: v for k, v in cl.items() if k != 'seconds'} == {k: v for k, v in k2.items() if k != 'seconds'} +assert cl['payload_prefix_bits'] < 104 and k5['payload_prefix_bits'] < 104 +print(' legality PASS: %d records, %d common-frame ADDs, rank mass %d, 9 COPY/ERASE (ranks %s)' + % (lg['records'], lg['common_frame_ADDs'], lg['rank_mass'], cfg['copy_ranks'])) +print(' five-stage formal columns PASS: %d columns over F2; prefix payload %d bits < 104 (eleven-stage: %d bits)' + % (cl['formal_columns_checked'], cl['payload_prefix_bits'], k5['payload_prefix_bits'])) +print(' eleven-stage formal columns PASS: %d columns, %d bridge additions, 24/24 omitted-bridge controls rejected;' + ' columns_k at KPAIRS = 2 reproduces the five-stage receipt' % (k5['formal_columns_checked'], k5['bridge_additions'])) +BK = lambda k, v=V, r=R: BIN / ('%s_v%d_r%d' % (k, v, r)) +run([PY, '-I', '-B', AD / 'mutate_records.py', WD / 'records', WD / 'cin', co, BIN / 'legality', BK('columns_k5'), + BIN / 'legality_ncopy_h'], quiet=False) +run([PY, '-I', '-B', B / 'mutate_records_mut.py', WORD, WD / 'records', WD / 'cin', co, BIN / 'legality', + BK('columns_h'), BK('columns_k5')], quiet=False) + +# ------------------------------------------------------------------------------------------------------------------ +step('4. exact nondegeneracy (E8 Gram) and prime witnesses on every frame') +run([PY, '-I', '-B', CK / 'gram_frames.py', WD / 'records', '--gram', 'e8ham', '--h', '8', '--positive'], quiet=False) + +# ------------------------------------------------------------------------------------------------------------------ +step('5. eleven-stage whole-residual hosting (PR #445 geometry, PR #472 emitter and audit), exact price, assembly') +NINE_G, ELEVEN_G = 'nine_geometry.py', 'eleven_geometry.py' + + +def hosted(word, d, hosting_out, suppliers, ad=AD, geom_word=True, outname='bit'): + """geometry (live labels), hosting nomination, emit, audit, assembly of ONE word with the adapted scripts.""" + (d / 'nine').mkdir(exist_ok=True); (d / outname).mkdir(exist_ok=True) + gw = ['--word', word] if geom_word else [] + run([PY, '-I', '-B', ad / NINE_G, '--source', PARENT, '--out', d / 'nine'] + gw) + run([PY, '-I', '-B', ad / ELEVEN_G, '--source', PARENT, '--out', d / outname] + gw) + run([PY, '-I', '-B', ad / 'host_select.py', word, hosting_out]) + return d / outname + + +def emit_audit_assemble(word, d, bitdir, hosting, ad, suppl, nine=None): + run([PY, '-E', '-s', '-B', ad / 'emit.py', '--word', word, '--local-check', d, '--out', bitdir, + '--isometries', PARENT / 'data/eleven/residual-isometries.json', '--hosting', hosting]) + run([PY, '-E', '-s', '-B', ad / 'audit.py', d, nine or d / 'nine', bitdir]) + Rr = rj(bitdir / 'GLOBAL.json')['R'] + run([PY, '-I', '-B', ad / 'assemble.py', bitdir, str(Rr), PARENT, d / 'RESULT.json', suppl[0]] + suppl[1:]) + + +bit = hosted(WORD, WD, WD / 'hosting-rediscovered.json', None) +assert rj(WD / 'hosting-rediscovered.json') == rj(HOST), 'hosting differs from the frozen selection' +print(" PR #442 hosting programme (host_select.py, v from the word) rediscovers data/hosting-v111-r489.json exactly") +emit_audit_assemble(WORD, WD, bit, HOST, AD, ['pr535', str(HERE / 'data/complex-b.json')]) +g, a, r = rj(bit / 'GLOBAL.json'), rj(bit / 'AUDIT.json'), rj(WD / 'RESULT.json') +assert a['status'] == 'PASS_INDEPENDENT_ELEVEN_STAGE_HOSTING_AUDIT' and g['R'] == R and g['v'] == V +assert g['hosted_residuals'] == 88 * R and g['live'] == 2 * 5 * V * 8 and g['deficit'] == 8 * (10 * V - 11 * CST) +print(' template: 88 calls, %d whole helper residuals hosted on idle data families, %d unbanked scalar columns restored;' + ' independent audit PASS: %d renamed instructions, %d template mutations rejected, local audit %s' + % (g['hosted_residuals'], g['independent_unbanked_scalar_columns'], a['emitted_events'], len(a['mutations_rejected']), + a['local_audit']['status'])) +print(' bit c (eleven stages, 10^-24 grid) = %s = %s; live %d, rank-mass deficit %d' % (r['bit_lower'], r['bit_lower_decimal'], g['live'], g['deficit'])) + +# ------------------------------------------------------------------------------------------------------------------ +step("6. pricing harness (code/price/pricex.py: local histogram replay + the same hosting programme + moment.certify) must agree to all digits") +p = run([PY, '-B', HERE / 'code/price/pricex.py', WORD, '11']) +line = [x for x in p.stdout.splitlines() if x.startswith('{')][0]; px = json.loads(line) +assert px['feasible'] and F(px['c']) == F(r['bit_lower_decimal']) and px['profile'] == r['bit_profile'] +assert px['c'].startswith(r['bit_lower_decimal'][:26]) +print(' pricex c = %s == hosted-audit c = %s (24 digits; same profile)' % (px['c'], r['bit_lower_decimal'])) +# robustness: the hosting rule used (PR #442's pooled whole-residual programme, as in #472 / #493 / #503 / #510) lets several helpers of one +# invocation share a family at disjoint cells. Under the STRICTER rule 'one helper per family copy per stage' (PR #458's rule is per invocation, +# so this is a lower bound for any #458-compliant hosting) the c is lower; kappa is complex-bound and unchanged (step 9) +stk = stacking(bit, V) +print(' hosting rule: #442/#472/#493 pooled whole-residual programme; %d of %d calls host several helpers of that call on one family ' + '(at most %d on one family) -- inherited, as in PR #503 (see README, Scope)' % (stk['calls_with_stacked_helpers'], stk['calls'], stk['max_helpers_on_one_family'])) +p458 = json.loads(run([PY, '-B', HERE / 'code/price/price458.py', WORD, '11']).stdout.strip().splitlines()[-1]) +assert p458['feasible458'] and F(p458['c_stock']) == F(r['bit_lower_decimal']) +print(' stricter hosting (one helper per family copy per stage): c >= %s (%+.4f%% vs the shipped c); kappa unchanged (complex-bound)' + % (p458['c458'], 100 * float(F(p458['c458']) / F(r['bit_lower_decimal']) - 1))) +# the harness's other stages: infeasible by the exact hosting wall at s = 9 and 7, feasible at s = 13 +px_all = {s: json.loads([x for x in run([PY, '-B', HERE / 'code/price/pricex.py', WORD, str(s)]).stdout.splitlines() if x.startswith('{')][0]) for s in (9, 13)} +print(' other stages (information): s = 9 feasible: %s (%s); s = 13 c = %s' % (px_all[9]['feasible'], px_all[9].get('why', ''), px_all[13].get('c'))) + +# ------------------------------------------------------------------------------------------------------------------ +if not NOCTL: + step("7. REGRESSION: PR #503's R480 word (v = 120, nine rank-8 totals) through the stock chain and the adapted chain") + CD = WD / 'ctl'; CD.mkdir(exist_ok=True) + cw = PC.load(CWORD); ccfg = PC.config(cw, PARENT) + assert content_sha(cw) == EXP['control']['word_content_sha256'] and (ccfg['v'], ccfg['R'], ccfg['cst']) == (120, 480, 72) + build_checkers(120, 480) + cohort(CWORD, CD); columns(120, 480, CD, kinds=('columns_h', 'columns_k5')) + assert rj(CD / 'cout/columns.json')['payload_prefix_bits'] == EXP['control']['five_stage_payload_bits'] + # (a) the checkers: the adapted copies print exactly what the parent's print on the R480 word + run([PY, '-I', '-B', B / 'independent/relax.py', CD / 'rchk0']) + s0 = run([PY, '-I', '-B', CD / 'rchk0/checkword_mut.py', CWORD, C / 'pricing']).stdout + ADC = CD / 'adapted-for-control' # local_audit.py bakes in the word it audits, so the control has its own adapted copy + run([PY, '-I', '-B', HERE / 'code/adapt.py', PARENT, CWORD, ADC]) + run([PY, '-I', '-B', ADC / 'chk/relax.py', ADC / 'rchk']) + s1 = run([PY, '-I', '-B', ADC / 'rchk/checkword_mut.py', CWORD, C / 'pricing']).stdout + assert s0 == s1, 'relaxed checker output differs on the R480 word' + m0 = run([PY, '-I', '-B', B / 'mutate_records.py', CD / 'records', CD / 'cin', CD / 'cout', BIN / 'legality', + BK('columns_k5', 120, 480), BIN / 'legality_ncopy_h']).stdout + m1 = run([PY, '-I', '-B', ADC / 'mutate_records.py', CD / 'records', CD / 'cin', CD / 'cout', BIN / 'legality', + BK('columns_k5', 120, 480), BIN / 'legality_ncopy_h']).stdout + assert m0 == m1 and 'PASS all 6' in m0, 'record-mutant output differs on the R480 word' + print(' (a) relaxed checker and the 6 record mutants: output identical to the parent files on the R480 word') + # (b) the hosted chain. STOCK = parent emit.py / assemble.py unchanged + PR #503's audit.py / local_audit.py (its adapt.py) + assert sha(HERE / 'code/adapt503.py') == '04ec15262595e502796efc1f100f1efd4f28585add48377af1bda702a12c0e40', "adapt503.py is not PR #503's adapt.py" + AD503 = CD / 'ad503' + run([PY, '-I', '-B', HERE / 'code/adapt503.py', PARENT, CWORD, AD503], quiet=False) + sd, cd_ = CD / 'stock', CD / 'adapted' + for x in (sd, cd_): (x / 'nine').mkdir(parents=True, exist_ok=True); (x / 'bit').mkdir(exist_ok=True) + run([PY, '-I', '-B', C / 'nine/geometry.py', '--source', PARENT, '--out', sd / 'nine']) + run([PY, '-I', '-B', HUB / 'r740-hosted-eleven/code/geometry.py', '--source', PARENT, '--out', sd / 'bit']) + run([PY, '-I', '-B', PARENT / 'discovery/host_select.py', CWORD, sd / 'hosting.json']) + run([PY, '-I', '-B', ADC / NINE_G, '--source', PARENT, '--out', cd_ / 'nine']) + run([PY, '-I', '-B', ADC / ELEVEN_G, '--source', PARENT, '--out', cd_ / 'bit']) + run([PY, '-I', '-B', ADC / 'host_select.py', CWORD, cd_ / 'hosting.json']) + assert norm(sd / 'nine/GEOMETRY.json') == norm(cd_ / 'nine/GEOMETRY.json') and norm(sd / 'bit/GEOMETRY.json') == norm(cd_ / 'bit/GEOMETRY.json') + assert rj(sd / 'hosting.json') == rj(cd_ / 'hosting.json') == rj(CHOST) + # both pipelines read the SAME geometry files (GEOMETRY.json stores its own run time, which is hashed into the template) + for sub in ('nine', 'bit'): (cd_ / sub / 'GEOMETRY.json').write_bytes((sd / sub / 'GEOMETRY.json').read_bytes()) + print(' (b) geometries (nine and eleven stage) and the hosting nomination: equal to the parent scripts modulo run time') + suppl = ['pr484,pr471,pr458'] + for tag, base_, ad_, emit_ in (('stock', sd, AD503, C / 'eleven/emit.py'), ('adapted', cd_, ADC, ADC / 'emit.py')): + run([PY, '-E', '-s', '-B', emit_, '--word', CWORD, '--local-check', CD, '--out', base_ / 'bit', '--isometries', + PARENT / 'data/eleven/residual-isometries.json', '--hosting', CHOST]) + run([PY, '-E', '-s', '-B', (ad_ / 'eleven/audit.py') if tag == 'stock' else (ADC / 'audit.py'), CD, base_ / 'nine', base_ / 'bit']) + run([PY, '-I', '-B', (C / 'eleven/assemble.py') if tag == 'stock' else (ADC / 'assemble.py'), base_ / 'bit', '480', PARENT, + base_ / 'RESULT.json', 'pr484,pr471,pr458']) + same = {} + gs_, ga_ = sd / 'bit/GLOBAL.json', cd_ / 'bit/GLOBAL.json' + same['GLOBAL.json (all fields but run time)'] = norm(gs_) == norm(ga_) + same['GLOBAL-TEMPLATE.json.gz'] = filecmp.cmp(sd / 'bit/GLOBAL-TEMPLATE.json.gz', cd_ / 'bit/GLOBAL-TEMPLATE.json.gz', shallow=False) + same['AUDIT.json'] = filecmp.cmp(sd / 'bit/AUDIT.json', cd_ / 'bit/AUDIT.json', shallow=False) + same['RESULT.json'] = filecmp.cmp(sd / 'RESULT.json', cd_ / 'RESULT.json', shallow=False) + assert all(same.values()), same + rc = rj(cd_ / 'RESULT.json'); ec = EXP['control'] + assert rc['bit_lower'] == ec['bit_lower'] and rc['bit_profile'] == ec['profile'] + assert rj(cd_ / 'bit/GLOBAL.json')['emitted_program_sha256'] == ec['emitted_program_sha256'] + for name, x in ec['kappa'].items(): assert rc['kappa'][name]['kappa'] == x + pc_ = json.loads([x for x in run([PY, '-B', HERE / 'code/price/pricex.py', CWORD, '11']).stdout.splitlines() if x.startswith('{')][0]) + assert F(pc_['c']) == F(rc['bit_lower_decimal']) + stk_c = stacking(cd_ / 'bit', 120) + assert stk_c == ec['stacking'], (stk_c, ec['stacking']) + print(' (c) emit/audit/assemble: GLOBAL.json, GLOBAL-TEMPLATE.json.gz, AUDIT.json and RESULT.json of the adapted chain are' + ' BYTE-IDENTICAL to the stock chain on the R480 word (%s)' % ', '.join(same)) + print(' R480 c = %s = %s, emitted-program sha256 %s... == PR #503 EXPECTED; kappa with #484/#471/#458 unchanged; pricex agrees' + % (rc['bit_lower'], rc['bit_lower_decimal'], ec['emitted_program_sha256'][:16])) + print(' hosting disclosure for the control: %d of %d calls stack several helpers on one family (max %d) -- the same inherited rule' + % (stk_c['calls_with_stacked_helpers'], stk_c['calls'], stk_c['max_helpers_on_one_family'])) + +# ------------------------------------------------------------------------------------------------------------------ +if not NOMUT: + step('8. mutation controls on the star word (code/mutants.py): every one must be rejected') + run([PY, '-I', '-B', HERE / 'code/mutants.py', WORD, WD, AD, PARENT, HOST, WD / 'mutants.json'], quiet=False) + mut = rj(WD / 'mutants.json'); assert mut['all_rejected'] and len(mut['controls']) >= 4 + +# ------------------------------------------------------------------------------------------------------------------ +step('9. composition with the cited complex supplier (#535): kappa; control = #535 reproduced from #510 bit c and the same b') +run([PY, '-I', '-B', HERE / 'code/compose_control.py', PARENT, WD / 'RESULT.json', HERE / 'data/complex/pr535/EXPECTED.json', + WD / 'compose.json'], quiet=False) +comp = rj(WD / 'compose.json') + +# ------------------------------------------------------------------------------------------------------------------ +step('10. summary against EXPECTED.json') +e = EXP +assert {str(k): v for k, v in cl['local_raw_H']} == e['word']['local_histogram'] +assert cl['payload_prefix_bits'] == e['word']['five_stage_payload_bits'] and k5['payload_prefix_bits'] == e['word']['eleven_stage_payload_bits'] +assert iface['source_destination_gates_A'] == e['word']['source_destination_gates_A'] +assert r['bit_lower'] == e['eleven']['bit_lower'] and r['bit_lower_decimal'] == e['eleven']['bit_lower_decimal'] and r['bit_profile'] == e['eleven']['profile'] +assert g['emitted_program_sha256'] == e['eleven']['emitted_program_sha256'] +assert stk == e['hosting']['stacking'] and p458['c458'] == e['hosting']['c_strict_per_stage'] and F(p458['c458']) < F(r['bit_lower']) +for k in ('prefix_bits', 'charged_prefix_bits', 'three_level_coefficient_bits', 'charged_three_level_coefficient_bits', 'row_coefficient', 'hosted_residuals', 'live', 'physical', 'rank_mass'): + assert r['bit'][k] == e['eleven']['bit'][k], k +assert r['kappa']['pr535']['kappa'] == e['kappa']['pr535']['kappa'] and r['kappa']['pr535']['binding_component'] == e['kappa']['pr535']['binding_component'] +assert comp['control_reproduces_pr535_kappa'] and comp['kappa_star_vs_pr535'] == e['kappa']['pr535']['kappa'] +c = F(r['bit_lower']) +print('PASS bit c (v = %d, R = %d, cst = %d; PR #472 eleven-stage whole-residual pipeline, 10^-24 grid) = %s = %s' % (V, R, CST, r['bit_lower'], r['bit_lower_decimal'])) +print(' %+.4f%% over PR #503 (R = 480, v = 120, c = %s) and %+.4f%% over the live bit c of PR #510 (%s)' + % (100 * float(c / F(e['control']['bit_lower']) - 1), e['control']['bit_lower_decimal'], + 100 * float(c / F(e['live_bit']['bit_lower']) - 1), e['live_bit']['bit_lower_decimal'])) +k = r['kappa']['pr535'] +print(" with PR #535's complex b = %s: kappa = %s = %s (%s-bound; #535 published %s from the live bit c)" + % (k['complex_lower'], k['kappa'], k['kappa_decimal'], k['binding_component'], comp['pr535_published_kappa'])) +print('PASS %s [%.0fs]' % ('LIGHT' if LIGHT else 'FULL', time.time() - T0))