diff --git a/.github/workflows/e8-combined.yml b/.github/workflows/e8-combined.yml new file mode 100644 index 0000000000..7ae5f46297 --- /dev/null +++ b/.github/workflows/e8-combined.yml @@ -0,0 +1,39 @@ +name: Verify combined E8 witness + +on: + push: + paths: + - 'research/e8-combined/**' + - '.github/workflows/e8-combined.yml' + - 'Makefile' + pull_request: + paths: + - 'research/e8-combined/**' + - '.github/workflows/e8-combined.yml' + - 'Makefile' + workflow_dispatch: + +permissions: + contents: read + +jobs: + verify: + runs-on: ubuntu-24.04 + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + python-version: ['3.11', '3.14'] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + persist-credentials: false + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 + with: + python-version: ${{ matrix.python-version }} + - name: Install the exact geometry dependency + run: python3 -m pip install -r research/e8-combined/requirements.txt + - name: Rebuild and check both suppliers and their composition + run: make e8-combined-verify + - name: Require unchanged tracked files + run: git diff --exit-code diff --git a/Makefile b/Makefile index 61fc5ef410..e8feb53b57 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ verify: $(MAKE) verify-recycled-bit $(MAKE) verify-entrance-banks $(MAKE) gen4-bank-verify + $(MAKE) e8-combined-verify $(MAKE) verify-certificates $(MAKE) verify-ternary $(MAKE) verify-research @@ -547,3 +548,7 @@ recycled-bit-full-verify: verify-recycled-bit: recycled-bit-full-verify python3 -m unittest discover -s tests -p 'test_recycled_bit_integration.py' -v + +.PHONY: e8-combined-verify +e8-combined-verify: + python3 -B research/e8-combined/verify.py --output "$$(mktemp -d)" diff --git a/research/e8-combined/NOTICE b/research/e8-combined/NOTICE new file mode 100644 index 0000000000..1b93d4e38f --- /dev/null +++ b/research/e8-combined/NOTICE @@ -0,0 +1,89 @@ +Attribution and assistance + +Ali Romman prepared the two changed words, their composition, and this +compact replay package with OpenAI Codex assistance. The fixed witness is +not a claim of a global optimum. Source code is under Apache-2.0; see the +repository LICENSE. The source manifests record original file hashes, +extractions, and path changes. Generated output is not an input premise. + +The bit construction builds on DreamingOfClouds' R715 word and XOR hierarchy +(PR463), rohanarun's response kernel and whole-residual pooling (PR467/462), +DaysSky's idle hosting (PR442), and the E8 producer and geometry lineage of +Dylan Crow, Jacob Sussman, Zhihao Chen, eumemic, and other contributors. +The complex construction retains DreamingOfClouds' PR449 kernel scripts, +chafreaky's PR458 paid adapters and distinct-host construction, icekylinx's +PR433 split centres, and the prior supplier and geometry work. +The comparison is with pinned main, not every open PR. + +Pinned source records + + Main: 12a4934d15006e8c10f9b2264f13f8f341be802b. + PR467 cached head: f92d6a7ffcf74553522e967c2600e30c05ffe938. + PR462 cached tree: c4df4fdbf411f047ff7d63c73c432e828e94d924. + PR449: 7fac5292693bf738ff5eed6ec754f8ec22ebcf8e. + PR451: f3a38153678b55063fc005901cc968266166507d. + PR442: 4e16d001d505d4f21dd2bcfc44591f9be4c279bd. + +The vendor/bit/SOURCES.json and vendor/complex/SOURCES.json files identify +all imported files and their changes. Paths in those manifests name the +cached source packages. The two final words and compact schedule are +included, so replay does not require those caches or pending PR branches. + +Retained upstream notices + +The notices below are copied without changes from the source packages. +Their paths and descriptions refer to those packages. + + +Source: research/e8-complex-adapted-kernel/NOTICE.md + +# Attribution and assistance + +The shared-donor complex kernel selection and three generalized local +checker/emitter/phase scripts come from DreamingOfClouds PR449 at +`7fac5292693bf738ff5eed6ec754f8ec22ebcf8e`, prepared with Claude Opus 5.5 +through Claude Code. The original PROOF and NOTICE are retained verbatim +under `upstream449`. That draft's entrance-gauge construction and numerical +claims are not adopted here. + +Exact frozen reconstruction, the paid two-sided residual construction, +distinct-host assignment, independent local/global audits, new cost invoice +and this release were prepared by chafreaky with OpenAI Codex assistance. +They build on PR454 target mixing, PR451's eleven-stage complex geometry, +PR443–445 kernels and row bounds, DaysSky's PR442 idle-data hosting, +icekylinx's PR433 split centres, Zhihao Chen's PR425 common-frame realization +and PR377/386 geometry, and the inherited E8 work by Jacob Sussman, Dylan +Crow, eumemic and other contributors. All parent notices and licenses remain +in their source-pinned packages. + +Apache License 2.0; see LICENSE. This is a conditional research artifact. + + +Source: research/e8-complex-adapted-kernel/upstream449/NOTICE.md + +Apache-2.0. `code/audit_cxg.py`, `emit_cxg.py`, `phases_cxg.py` are modified copies of PR #433's `complex_audit.py`, +`complex_emit.py`, `complex_phases_full.py` (icekylinx with Codex; adapted from PR #425 by jacklightChen / Zhihao Chen). +`code/hostmodel.py` replicates the profile arithmetic of PR #442's `complex_hosted.py` (DaysSky) for mixed widths. +Prepared by DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code. + + +Source: work/next-track/bit/pinned467/research/r715-kernel-pool/NOTICE.md + +R715 producer and carrier/XOR construction: DreamingOfClouds, with Claude Opus 5.5, PR463. Shared-donor kernel mechanism and exact engines: chafreaky and the PR417/443 lineage. Whole hosting: DaysSky PR442. Target mixing: DreamingOfClouds PR450/463; no cross-family split used. New selection, 74 retiming moves and four-replica pooling: Rohan Arun with OpenAI Codex. Complex supplier: chafreaky PR458, unchanged and cited only at this stage. The inherited repository package notices and Apache-2.0 licenses remain applicable. See the retained PR463 README and source pins. + + +Source: work/next-track/bit/pinned462/research/bit-whole-pool4/NOTICE.md + +Apache-2.0. Original upstream notices and licenses are retained. +Four-replica selection, changed owner mapping, physical-family prefix audit, +finite repricing and composition by Rohan Arun with OpenAI Codex assistance. + +Unchanged bit word: Rohan Arun with Claude Opus5.5, PR459, including DreamingOfClouds' +target-prefix mixing from PR450. Unchanged complex supplier: chafreaky with +OpenAI Codex, PR458, building on DreamingOfClouds' PR449 kernel. +Parent composition: Rohan Arun with OpenAI Codex, PR460. +Hosting and solver lineage: DaysSky PR442; chafreaky PR443/445/451/454; +DreamingOfClouds' whole-hosting solver; Rohan Arun PR456 whole-replica pooling. +Retained geometry and local tools: icekylinx, eumemic, Zhihao Chen, Dylan Crow, +Jacob Sussman, Henry Grant and all authors in the upstream source-pinned notices. +No independent discovery of either unchanged local supplier is claimed. diff --git a/research/e8-combined/PROOF.txt b/research/e8-combined/PROOF.txt new file mode 100644 index 0000000000..bd65586bc4 --- /dev/null +++ b/research/e8-combined/PROOF.txt @@ -0,0 +1,184 @@ +Conditional composition of two E8 suppliers + +Claim. In the interfaces stated in the conditions below, this construction gives +T(n) = O(n (log n)^(1-kappa)), where + + kappa = 1307044366925301 / 10^18 = 0.001307044366925301. + +This is a conditional exponent bound. It is 80.6378781278% above the selected +bound on main at 12a4934d15006e8c10f9b2264f13f8f341be802b. It is not a +runtime measurement or a proof of the full multiplication theorem. + +1. Local identities + +The bit word uses 120 source and 120 target streams and 705 dirty helper +streams. Its 111 response-kernel pivots, 45 target receivers and 72 frame +changes are fixed data. Both directions act correctly on all 945 independent +input columns. The emitted 19,550 records include nine COPY/ERASE windows. +Each common-frame ADD is the scalar XOR on the normalized streams. Each MOVE +is the exact frame change. COPY/ERASE uses a fresh temporary and an unchanged +source. Thus the common-frame induction gives the full local address operator +on arbitrary streams. The helper endpoint is its charged residual projector, +not an identity inferred from scalar restoration. + +The complex word uses 240 data and 560 dirty helper streams. Retiming changes +728 frame labels and preserves every scalar operation and both endpoints. +The same common-frame induction preserves the local physical operator. +Both scalar directions check all 800 input columns. Exact Clifford checks +include phase. For a helper entrance E, its residual is T_FULL T_E^-1. +The paid pre/post monomials convert this residual into the exact coordinate +Fourier factor of width 8 or 9. No isotropic entrance is treated as a +coordinate entrance by an orthogonal conjugation. + +2. Complete finite templates + +Each supplier uses the signed eleven-stage layout. The bit template has four +replicas, 4,800 live families and 4,809 physical families. Each of the 31,020 +whole helper occurrences has an exact owner route. Concrete routes are +injective within a call, even when several helpers use one family. The routes +use at most 106 factors; the invoice allows 144. All 8,955 unbanked scalar +columns and all 1,320 data routes pass. The complex template has eight +replicas, 9,600 live families and 10,178 physical families. Its 49,280 whole +helper occurrences use distinct families within each call. All 8,520 phase +equalities and 1,320 data routes pass. + +Each host lies in a checked idle window. Whole helper residuals occupy +disjoint pending coordinates. The complementary idle child completes the +original idle operator. No residual is split across physical families. +Bridges, terminal shifts, exchanges and the complex cover correction remain +in the emitted program and paid profile. + +3. Finite costs and moments + +The independent invoice uses the emitted counts, actual physical stock and +fresh prefix bounds. The bit prefix has 610 bits and is charged at 640 bits. +Its three-level coefficient has 1,883 bits and is charged at 1,920 bits. +Its row slope is 19,428. The ceiling term adds 9,267. At log2(e) >= 32, +the 20,161 reserve covers both terms, with margin 14,189 at the threshold. The complex invoice charges 788,480 restored +rank-zero wrapper groups. Its router, literal and precision charges fit the +retained bounds. Since 89^9 > 16*64^9, nine recursive steps give four binary +halvings. The row cost is at most (9/4*3929+9909+252)*log2(e)+9*3929. For +log2(e) >= 32 it is strictly below 20,161*log2(e), with margin 1,751 at the +threshold. Smaller widths use the retained ordinary leaf interface. + +For profile H, dimension m and live stock W, the moment is + + sum_r H_r*(r/m)^(1-z)/W + + 10^-16 * 32*m^2*sum_r H_r * m^(z-1)/W. + +The second term charges the retained bad-class fallback. Rational intervals +give the strict lower endpoints + + bit c = 1308789373120170692069 / 10^24, + complex b = 654377483866781393011 / (5*10^23). + +The moment is below 1 at each lower endpoint and above 1 one 10^-24 step +later. The complex supplier is the smaller endpoint. + +4. Outer composition + +Set eta = beta = 10^-18 and s = min(c,(1-beta)*b)-10^-24. Start at +a_0 = 384599/10^10 and apply the completed-ordinary-leaf bound six times: +a_j = s-s^j*(s-a_0). Each step has a strictly positive gap. The cutoff constants are chosen +sequentially, as stated below. Put a=a_6, q=a*(1-2*eta) and epsilon=(1-eta)/(1+q). +The seven cost margins have minimum mu=epsilon*q. All 47 strict outer +constraints hold. The largest 10^-18 grid point strictly below mu is the +claimed kappa. The adjacent grid point fails. Every calculation uses exact +rational arithmetic; finite certificates do not discharge the conditions below. + + +Proof boundary and source map + +This submission is a finite E8 construction and an exact arithmetic +composition. It does not complete the all-size multiplication proof. +Its bound is conditional on the interfaces below. The finite checks do +not establish these interfaces for every input size. + +Conditions already stated on main + +Main at 12a4934d15006e8c10f9b2264f13f8f341be802b states conditions for: +the all-size weighted compiler; common-ancestor and weighted charts; +complete-stream movement; restored rows and selectors; exact-tape routing; +prime supply; precision and exact recovery; complex symbolic correctness; +and the analytic reduction from transforms to multiplication. The source +proof's normalization by live stock W, rather than physical stock, is part +of this contract. The complete finite router uses physical stock. + +The initial saving a_0=384599/10^10 and the completed-ordinary-leaf bootstrap +theorem are inherited. Their application uses the fresh finite coefficients. +The checks establish the six positive gaps. They do not prove the initial +theorem or the uniform recursion schedule. The supplier coefficient alone +does not bound the constants of each earlier ordinary algorithm. + +Conditions from pending E8 work + +These are extensions of the main framework. They must not be described as +unchanged hypotheses already reviewed on main. + +1. The E8 bit compiler must realize the projector label on mutable source, +helper and target streams, including target-to-target additions, at all +address widths. Common-frame induction proves the finite operator identity. +It does not prove the compiler cost, fine grid or uniform exact-tape lowering. +The relevant pending lineage includes PR370, PR386, PR433 and PR450/454. + +2. The whole-call hosting interface must allow arbitrary correlated dirty +streams on idle data families. The finite argument checks distinct owners, +unused windows, whole residuals, disjoint coordinates and exact complements. +It does not enumerate the complete cover or establish the all-size compressed +window, row restoration and selector implementation. PR442 introduces this +extension; PR456/462 applies whole-residual pooling. No PR448 split-residual +compiler premise is used. + +3. The complex Gaussian compiler must implement canonical Clifford frame +changes and the paid two-sided monomial adapters on arbitrary streams, with +restored work and the stated fixed-group costs at all sizes. Exact tableau +and state checks establish the local phases and operator factors. They do +not establish the full all-size compiler or analytic precision routine. +The relevant lineage includes PR433, PR449/458 and their source notices. + +4. The bad-prime and bad-class envelope must apply to these new E8 frames, +covers and compiler operations. The moment retains the same 10^-16 envelope +and 32*m^2 rank-one fallback calls per paid child. This is an admitted +framework condition, not a consequence of the moment's rational signs. + +5. The restored-row interface must charge stock once per actual recursion +level and use the retained small ordinary leaves. The new complex nine-step +row estimate proves that the numerical 20,161 reserve suffices under that +contract. It does not construct a new tape machine or row divisor. + + +Sequential ordinary bootstrap + +Let A_0 be a finite constant for the admitted initial ordinary algorithm with +saving a_0. At level j, the earlier algorithm and its constant A_(j-1) have +already been fixed. The admitted ordinary-wrapper theorem supplies the new +construction and its finite coefficients. Choose an integer C_j >= 1 which +bounds all its primitive, recurrence, wrapper, row, setup and padding +constants, its large-width constant, and the earlier ordinary constant. Such +a C_j exists under the admitted interfaces. It need not be at most 2^1920. + +The saving is a_j = s*(1-s+a_(j-1)). Let delta_j be the minimum of its four +exact positive exponent gaps. Set B_j = ceil(log2(C_j)) and choose + + L_j = ceil(max(1, 36/delta_j^2, 2*(4+B_j)/delta_j)), + e_j = 2^L_j. + +For t = log2(e) >= L_j, use + + log2(1+t) <= 3*sqrt(t) <= delta_j*t/2, + log2(C_j)+4 <= delta_j*t/2. + +Then C_j*(1+log2(e))*e^(-delta_j) <= 1/16. This pays the lower +order terms and makes the high borrowed row fit. For e < e_j, use the earlier +ordinary algorithm. A finite constant which covers both ranges is + + A_j = C_j + A_(j-1)*2^ceil(L_j*(a_j-a_(j-1))). + +This choice is sequential. C_j uses A_(j-1), while A_j is assigned after L_j. +No constant depends on itself. Six steps give the stated exponent a_6, with +finite constants and cutoffs whose numerical values are not certified by this +package. The exact saving exponents, their positive gaps, and the formula for +sufficient cutoffs are certified. The source's ordinary algorithm and its +uniform scheduling remain admitted interfaces. + +The 1,920-bit supplier charge is separate from the stage constants C_j. diff --git a/research/e8-combined/README.md b/research/e8-combined/README.md new file mode 100644 index 0000000000..21bbcd6b6a --- /dev/null +++ b/research/e8-combined/README.md @@ -0,0 +1,37 @@ +# Combined E8 witness + +This package checks the conditional bound + +\[ +\kappa=1307044366925301/10^{18}=0.001307044366925301. +\] + +It is 80.637878% above the selected value on main at +`12a4934d15006e8c10f9b2264f13f8f341be802b`. This compares exponent +savings. It does not measure runtime. The complex supplier limits the bound. + +The package combines an R705 bit word with a retimed R560 complex word. +It contains the fixed positive words, owner choices, finite schedule, and +the source code needed to check them. It regenerates records, geometry, +phases, templates, costs, and all 47 strict outer inequalities. It does +not contain searches or the nested historical source packages. + +Use Python 3.11 or later. The replay was checked with Python 3.14 and +SymPy 1.14.0. Install the one external dependency, then run: + +```sh +python3 -m pip install -r research/e8-combined/requirements.txt +python3 -B research/e8-combined/verify.py --output "$(mktemp -d)" +``` + +The command uses an empty output directory outside the source package. It checks the committed +`certificate.json` against a fresh construction. The output includes +the complete inequalities and component audit records. No network access, +C++ compiler, old checkout, or saved build directory is needed. + +Read [PROOF.txt](PROOF.txt) for the dependency argument and assumptions. +The finite checks do not prove all-size compilation, complete-cover +execution, bad-class portability, or the analytic multiplication theorem. +The pending E8 mutable-target, idle-hosting, and Gaussian-adapter interfaces +extend the conditions stated on main. This package does not select a new +main result. Source attribution and AI assistance are in [NOTICE](NOTICE). diff --git a/research/e8-combined/certificate.json b/research/e8-combined/certificate.json new file mode 100644 index 0000000000..2a6bf4c984 --- /dev/null +++ b/research/e8-combined/certificate.json @@ -0,0 +1,123 @@ +{ + "status": "PASS_CONDITIONAL_COMBINED_E8_WITNESS", + "kappa": "1307044366925301/1000000000000000000", + "kappa_decimal": "0.001307044366925301", + "main_commit": "12a4934d15006e8c10f9b2264f13f8f341be802b", + "main_kappa": "90446448750933/125000000000000000", + "relative_gain": "194490925639279/241190530002488", + "gain_percent": "80.637878127832", + "binding_component": "complex", + "bit": { + "profile": { + "1": 105000, + "2": 48602, + "3": 8095, + "4": 15904, + "5": 3300, + "6": 4240, + "7": 2205, + "8": 396, + "56": 395 + }, + "invoice": { + "live": 4800, + "physical": 4809, + "prefix_bits": 610, + "charged_prefix_bits": 640, + "coefficient_bits": 610, + "three_level_coefficient_bits": 1883, + "charged_three_level_coefficient_bits": 1920, + "row_coefficient": 19428, + "row_bound": { + "stock_exponent": 3089, + "additive_stock_charge": 9267, + "minimum_log2_width": 32, + "threshold_margin": 14189 + } + }, + "moment": { + "lower": "1308789373120170692069/1000000000000000000000000", + "upper": "130878937312017069207/100000000000000000000000", + "lower_residual_upper": "-3793944254784504604944273595931373/1569275433846670190958947355801916604025588861116008628224", + "upper_residual_lower": "5780079706686843942254062593913837/6277101735386680763835789423207666416102355444464034512896", + "method": "64-term atanh log series after binary reduction;18-degree exponential;192-bit outward dyadic rounding" + }, + "emitted_program_sha256": "76d3cae169dc5c9dda300f58936b433bbfbe975ae556f52491eca4cae9ecfb0b" + }, + "complex": { + "profile": { + "1": 205312, + "2": 22880, + "3": 49320, + "4": 5560, + "5": 22288, + "6": 16048, + "7": 2568, + "8": 7264, + "16": 8, + "46": 512, + "64": 1912 + }, + "invoice": { + "live": 9600, + "physical": 10178, + "maxchild": 64, + "rank_mass": 851136, + "hosted_residuals": 49280, + "wrapper_events": 13904, + "charged_wrapper_groups": 788480, + "max_helpers_per_physical_family_per_call": 1, + "physical_stock_bits": 3929, + "router_bits": 11850, + "literal_bits": 37859, + "row_coefficient": 20161, + "local_bound": 18687781085682, + "pervertex": 1772686901993840, + "halving_depth": 3, + "row_bound": { + "status": "PASS_FRACTIONAL_DEPTH_ROW_RESERVE", + "block_steps": 9, + "block_halvings": 4, + "exact_shrink_inequality": [ + 350356403707485209, + 288230376151711744 + ], + "stock_bits": 3929, + "row_slope": "76005/4", + "additive_stock_charge": 35361, + "minimum_log2_width": 32, + "retained_row_coefficient": 20161, + "threshold_margin": "1751", + "coarse_three_level_row": 21948, + "finite_three_level_halving": [ + 704969, + 524288 + ] + } + }, + "moment": { + "lower": "654377483866781393011/500000000000000000000000", + "upper": "1308754967733562786023/1000000000000000000000000", + "lower_residual_upper": "-3748694116234626921713465867287277/1569275433846670190958947355801916604025588861116008628224", + "upper_residual_lower": "1685218799484082240877453220685041/3138550867693340381917894711603833208051177722232017256448", + "method": "64-term atanh log series after binary reduction;18-degree exponential;192-bit outward dyadic rounding" + }, + "emitted_program_sha256": "4592b40412f8dfb5ffa69b3af4e5f104da5e7f38242f5d8b4b54742d9a5bac4c" + }, + "next_grid_rejected": true, + "scope": "Finite local identities, exact phases, routed templates, invoices, moment signs and outer arithmetic. The all-size interfaces in PROOF.txt remain conditions.", + "independent_outer_check": { + "strict_constraints_checked": 47, + "bootstrap_levels_checked": 6, + "adjacent_grid_fails": true, + "complex_row_threshold_margin": 1751 + }, + "input_sha256": { + "data/bit/selection.json": "d886c0b85a90fb741897f68a35dd24eeb0d3acd23a7f467060d8acaf65792b6e", + "data/bit/word.json.gz": "b333c32bc6bbc88fc2dc444e4890e55341f5a513b612fc781aa3cbf16ed9be7d", + "data/complex/FULL-WORD.json.gz": "66655cd858afb515dfd4cad43c4fef01f9185af670e144750e9977588ebd4ecf", + "data/complex/hosting.json": "dc5fe719e71c26e856f0da96518af635ed2026b1c323052d97ee4e6b9839f2f1", + "data/complex/ports.json": "c4a4288b6052341eddff69e93999525b74512bb2fcdddb00bcdfe80ee42526ce", + "data/complex/schedule.json": "f62975a9146a4a0c9d1ecaa6f8567aeedf30bce484cc2105a74e4d7e9afc2522" + } +} diff --git a/research/e8-combined/check_outer.py b/research/e8-combined/check_outer.py new file mode 100644 index 0000000000..c5fee06cff --- /dev/null +++ b/research/e8-combined/check_outer.py @@ -0,0 +1,95 @@ +"""Check the outer composition from its unsimplified physical parameters.""" +from fractions import Fraction as F + + +def check(bit): + bit_bound, complex_bound = map(F, (bit['bit']['moment']['lower'], bit['complex']['moment']['lower'])) + eta = beta = F(1, 10**18) + backoff = min(bit_bound, (1-beta)*complex_bound) - F(1, 10**24) + base = F(384599, 10**10) + a = base + for j in range(1, 7): + old = a + # This closed form does not use the assembly's iterative expression. + a = backoff - backoff**j * (backoff-base) + gap = backoff-a + assert old < a < backoff + assert gap == min(backoff-a, 1-a-backoff, 1-a-backoff*(1-old), 1-backoff) + assert F(bit['bootstrap'][j-1]['gap']) == gap + + tau, sigma = 1-a, 1-complex_bound + q = a*(1-2*eta) + lambda_prime = 1-q + lambda_value = (tau+lambda_prime)/2 + reservation = q+eta/4 + epsilon = (1-eta)/(1+q) + internal = tau+(1-beta)*max(sigma-tau, F(0)) + leaf = sigma+beta*(1-sigma) + mu = epsilon*q + alpha = (mu+1-epsilon)/2 + delta = eta/8 + kappa = F((mu.numerator*10**18-1)//mu.denominator, 10**18) + assert kappa == F(bit['kappa']) + + # Use the unsimplified inequalities on physical assembly parameters. + slacks = { + 'bit_positive': a, 'complex_above_bit': complex_bound-a, + 'complex_below_one_over32': F(1,32)-complex_bound, + 'beta_positive': beta, 'beta_below_one': 1-beta, + 'leaf_saving_above_bit': (1-beta)*complex_bound-a, + 'q_positive': q, 'q_below_internal': 1-internal-q, + 'q_below_leaf': 1-leaf-q, + 'c_positive': reservation, 'c_below_one': 1-reservation, + 'q_below_reservations': reservation-q, + 'lambda_above_tau': lambda_value-tau, + 'lambda_above_sigma': lambda_value-sigma, + 'lambda_above_internal': lambda_value-internal, + 'lambda_prime_above_lambda': lambda_prime-lambda_value, + 'compact_leaf': lambda_prime-leaf, + 'compact_reservations': lambda_prime-(1-reservation), + 'lambda_prime_below_one': 1-lambda_prime, + 'epsilon_positive': epsilon, 'epsilon_below_one': 1-epsilon, + 'guard_width': 1-epsilon, 'K_geometry': 1-epsilon*(1+reservation), + 'K_dominates_log': epsilon*reservation, + 'record_suffix': 1-epsilon, 'phase_local': 1-epsilon-delta, + 'phase_boundary': alpha-delta, 'gamma_sublinear': 1-epsilon-alpha, + 'cell_above_band': epsilon-(1-alpha)/2, + 'prime_interval_packing': 1-epsilon, + 'alpha_positive': alpha, 'alpha_below_one': 1-alpha, + 'alpha_below_one_fourth': F(1,4)-alpha, + 'delta_positive': delta, 'delta_below_one_eighth': F(1,8)-delta, + 'short_record_fallback': epsilon-a, + 'small_field_exposure': 1-epsilon-mu, + 'artificial_boundary': 8-epsilon+alpha-delta-mu, + # These two premises need the separate checked finite invoices. + 'literal_scalar_guard': F(1), + 'row_product_gap': F(10**6)-F(51*20161,25), + } + margins = { + 'balanced_prefix': 1-epsilon, + 'coordinate_movement': a, + 'compact_phase_layer': mu, + 'bulk_exposure': a, + 'Gaussian_arithmetic': min(1-epsilon-delta, alpha-delta), + 'scalar_work': 1-epsilon-delta, + 'dimension': epsilon, + } + slacks.update({name+'_above_kappa': value-kappa for name,value in margins.items()}) + assert len(slacks) == 47 + assert all(value > 0 for value in slacks.values()) + assert slacks == {name: F(value) for name,value in bit['strict_outer_constraints'].items()} + assert min(margins.values()) == mu + assert mu-kappa > 0 and mu-kappa <= eta + assert kappa+eta >= mu + assert (1-beta)*complex_bound < bit_bound + + # Check the changed complex row estimate. This proves the arithmetic bound, + # conditional on the inherited cost per recursion level and small leaves. + stock_bits = 3929 + assert 89**9 > 2**4*64**9 + row_slope = F(9,4)*stock_bits + 9909 + 252 + row_additive = 9*stock_bits + assert (20161-row_slope)*32-row_additive == 1751 + assert row_slope*32+row_additive < 20161*32 + return {'strict_constraints_checked':47, 'bootstrap_levels_checked':6, + 'adjacent_grid_fails':True, 'complex_row_threshold_margin':1751} diff --git a/research/e8-combined/costs.py b/research/e8-combined/costs.py new file mode 100644 index 0000000000..ac6b92d695 --- /dev/null +++ b/research/e8-combined/costs.py @@ -0,0 +1,126 @@ +"""Recompute the finite costs, strict supplier moments, and outer bound.""" +import json +import math +from fractions import Fraction as Q +from moments import certify as moment_certificate +from outer import outer + +MAIN_COMMIT = '12a4934d15006e8c10f9b2264f13f8f341be802b' +MAIN_KAPPA = Q(90446448750933,125000000000000000) +KAPPA = Q(1307044366925301,10**18) +BIT_LOWER = Q(1308789373120170692069,10**24) +COMPLEX_LOWER = Q(654377483866781393011,5*10**23) + + +def read(path): + return json.loads(path.read_text()) + + +def round64(number): + return 64*((number+63)//64) + +def bit_invoice(g,geo): + profile={int(k):v for k,v in g['profile'].items()};E=sum(profile.values()) + m,W,R,T,L,V=78,4800,705,4,11,120 + assert (g['m'],g['live'],g['R'],g['replicas'],g['physical'])==(m,W,R,T,W+9) + assert sum(r*n for r,n in profile.items())==m*W-1632 + assert m**3>2*max(profile)**3 + J=L*T*(8*(2*V+R)+2*R)+8*W+2*g['copy_erase_episodes'] + coefficient=int(g['global_prefix_bound'])+1+L*T*g['local_additions']+g['bridge_additions'] + coefficient+=J*(16*(m*m+1)**2+g['physical'])+E*(8*m*m+8+128*(2*m)**3) + coefficient+=16*m**3+g['copy_erase_episodes'] + coefficient+=2*L*T*((W-1)+R*m*(geo['max_route_factors']+144+4+m-1+m)) + three=((coefficient+1)*(E+1))**3 + stock_power=0 + while 3**stock_power<=g['physical']:stock_power+=1 + row=3*(m*(m+1)//2+stock_power)+9909+252 + additive=3*(m*(m+1)//2+stock_power) + assert row<20161 and (20161-row)*32>additive + bits=int(g['global_prefix_bound']).bit_length() + return dict(live=W,physical=W+9,prefix_bits=bits,charged_prefix_bits=round64(bits), + coefficient_bits=coefficient.bit_length(),three_level_coefficient_bits=three.bit_length(), + charged_three_level_coefficient_bits=round64(three.bit_length()),row_coefficient=row, + row_bound=dict(stock_exponent=m*(m+1)//2+stock_power, + additive_stock_charge=additive,minimum_log2_width=32, + threshold_margin=(20161-row)*32-additive)) + +def complex_invoice(g): + p={int(k):v for k,v in g['profile'].items()};count=sum(p.values());mass=sum(r*n for r,n in p.items()) + assert (g['m'],g['live'],g['physical'],mass,max(p))==(89,9600,10178,851136,64) + checks=g['source_local_checks'];forward,backward=checks['forward'],checks['backward'] + assert all(z['all_columns']==800 and z['private_centers_cleared'] and z['helpers_restored_as_scalar_rows'] for z in checks.values()) + macros=max(z['scalar_macros'] for z in checks.values());children=sum(forward['paid_profile'].values()) + compiler=64*90**3 + adapters=16*(macros+children+240+560+g['private_centers'])+64*89+2*560*8 + assert g['charged_wrapper_groups']==11*8*2*560*8 and g['wrapper_events']==11*8*158 + local=max(z['real_component_primitive_bound'] for z in checks.values())+adapters*compiler + scalar=8*(6*forward['real_component_primitive_bound']+5*backward['real_component_primitive_bound']) + bridges=6*4*120*8;shifts=5*120*8;moves=10*120*8 + external=6*120*8*11+4*11*8*560+26*120*8+bridges+shifts+moves+9600+10178 + pervertex=scalar+bridges+shifts+moves+9600+(88*adapters+8*external+64*89)*compiler+64*10178 + group=(1<<(44*44))*math.prod((1<<(2*j))-1 for j in range(1,45)) + stock=group*10178;logical=group*pervertex+64;router=compiler*(logical+1)*(stock+1)**2 + scaled_mass=group*mass;literal=2*(1<<30000)*stock**2+8*scaled_mass+4*stock+4+32*89 + boundary=scaled_mass+(1<<100000) + assert local<1<<48 and logical<1<<6050 and router<1<<30000 and literal<1<<100000 + assert boundary<1<<100001 and 32*89*boundary**2<1<<210000 and 2*boundary+18<1<<210000 + assert (pervertex+1)**3*(count+1)**3<1<<1024 + bits=stock.bit_length();slope=Q(9,4)*bits+9909+252;additive=9*bits + assert 89**2<=2*64**2 and 89**3>2*64**3 + assert 89**9>16*64**9 and (20161-slope)*32>additive + expected=dict(live=9600,physical=10178,maxchild=64,rank_mass=mass,hosted_residuals=11*8*560, + wrapper_events=g['wrapper_events'],charged_wrapper_groups=g['charged_wrapper_groups'], + max_helpers_per_physical_family_per_call=1,physical_stock_bits=bits,router_bits=router.bit_length(), + literal_bits=literal.bit_length(),row_coefficient=20161,local_bound=local,pervertex=pervertex,halving_depth=3) + row=dict(status='PASS_FRACTIONAL_DEPTH_ROW_RESERVE',block_steps=9,block_halvings=4, + exact_shrink_inequality=[89**9,16*64**9],stock_bits=bits,row_slope=str(slope), + additive_stock_charge=additive,minimum_log2_width=32,retained_row_coefficient=20161, + threshold_margin=str((20161-slope)*32-additive),coarse_three_level_row=3*bits+9909+252, + finite_three_level_halving=[89**3,2*64**3]) + expected['row_bound']=row + return expected + +def compose(bit, complex_dir): + """Use fresh emitted data and checked global audits.""" + bg = read(bit/'GLOBAL.json') + ba = read(bit/'AUDIT.json') + geo = read(bit/'GEOMETRY.json') + cg = read(complex_dir/'GLOBAL.json') + ca = read(complex_dir/'AUDIT.json') + assert ba['status'] == 'PASS_INDEPENDENT_ELEVEN_STAGE_HOSTING_AUDIT' + assert ca['status'] == 'PASS_INDEPENDENT_ADAPTED_KERNEL_GLOBAL_AUDIT' + for data, audit in ((bg,ba),(cg,ca)): + for key in ('profile','template_sha256','emitted_program_sha256'): + assert data[key] == audit[key] + bp = {int(rank): count for rank,count in ba['profile'].items()} + cp = {int(rank): count for rank,count in ca['profile'].items()} + bit_cost = bit_invoice(bg,geo) + complex_cost = complex_invoice(cg) + bit_moment = moment_certificate(bp,78,4800,BIT_LOWER) + complex_moment = moment_certificate(cp,89,9600,COMPLEX_LOWER) + combined = outer(BIT_LOWER,COMPLEX_LOWER) + assert combined['kappa'] == KAPPA + assert combined['binding_component'] == 'complex' + assert len(combined['strict_outer_constraints']) == 47 + assert len(combined['bootstrap']) == 6 + assert combined['minimum_margin'] <= KAPPA+Q(1,10**18) + assert KAPPA > Q(9,5)*MAIN_KAPPA + gain = KAPPA/MAIN_KAPPA-1 + return { + 'status':'PASS_CONDITIONAL_COMBINED_E8_WITNESS', + 'kappa':str(KAPPA), + 'kappa_decimal':'0.001307044366925301', + 'main_commit':MAIN_COMMIT, + 'main_kappa':str(MAIN_KAPPA), + 'relative_gain':str(gain), + 'gain_percent':format(float(100*gain),'.12f'), + 'binding_component':combined['binding_component'], + 'bit':{'profile':bg['profile'],'invoice':bit_cost,'moment':bit_moment, + 'emitted_program_sha256':bg['emitted_program_sha256']}, + 'complex':{'profile':cg['profile'],'invoice':complex_cost,'moment':complex_moment, + 'emitted_program_sha256':cg['emitted_program_sha256']}, + 'strict_outer_constraints':{name:str(value) for name,value in combined['strict_outer_constraints'].items()}, + 'bootstrap':combined['bootstrap'], + 'next_grid_rejected':True, + 'scope':'Finite local identities, exact phases, routed templates, invoices, moment signs and outer arithmetic. The all-size interfaces in PROOF.txt remain conditions.' + } diff --git a/research/e8-combined/data/bit/selection.json b/research/e8-combined/data/bit/selection.json new file mode 100644 index 0000000000..5cc285828a --- /dev/null +++ b/research/e8-combined/data/bit/selection.json @@ -0,0 +1,654 @@ +{ + "bit": { + "patterns": [ + [ + 0, + [ + 7, + 7 + ], + 416 + ], + [ + 0, + [ + 8 + ], + 536 + ], + [ + 0, + [ + 8, + 6 + ], + 8 + ], + [ + 1, + [], + 540 + ], + [ + 1, + [ + 6 + ], + 4 + ], + [ + 1, + [ + 7 + ], + 416 + ], + [ + 2, + [ + 7, + 7, + 7, + 7 + ], + 102 + ], + [ + 2, + [ + 8, + 7, + 7, + 6 + ], + 4 + ], + [ + 2, + [ + 8, + 8, + 8 + ], + 758 + ], + [ + 2, + [ + 8, + 8, + 8, + 4 + ], + 96 + ], + [ + 3, + [], + 521 + ], + [ + 3, + [ + 4 + ], + 19 + ], + [ + 3, + [ + 6 + ], + 4 + ], + [ + 3, + [ + 7 + ], + 416 + ], + [ + 4, + [ + 8, + 8, + 8, + 6, + 6, + 6 + ], + 1 + ], + [ + 4, + [ + 8, + 8, + 8, + 7, + 7, + 4 + ], + 28 + ], + [ + 4, + [ + 8, + 8, + 8, + 8, + 8 + ], + 931 + ], + [ + 5, + [], + 516 + ], + [ + 5, + [ + 4 + ], + 24 + ], + [ + 5, + [ + 6 + ], + 4 + ], + [ + 5, + [ + 7 + ], + 416 + ], + [ + 6, + [], + 395 + ], + [ + 6, + [ + 8, + 8, + 8, + 8, + 8, + 8, + 8 + ], + 565 + ], + [ + 7, + [], + 540 + ], + [ + 7, + [ + 6 + ], + 4 + ], + [ + 7, + [ + 7 + ], + 416 + ], + [ + 8, + [ + 8, + 8, + 8, + 8, + 8, + 8, + 8 + ], + 960 + ], + [ + 9, + [ + 7, + 7, + 7, + 7, + 7, + 7 + ], + 60 + ], + [ + 9, + [ + 8, + 8, + 8, + 8, + 6, + 4 + ], + 1 + ], + [ + 9, + [ + 8, + 8, + 8, + 8, + 8 + ], + 899 + ], + [ + 10, + [ + 7, + 7, + 7, + 7 + ], + 102 + ], + [ + 10, + [ + 8, + 7, + 7, + 6 + ], + 4 + ], + [ + 10, + [ + 8, + 8, + 8 + ], + 758 + ], + [ + 10, + [ + 8, + 8, + 8, + 4 + ], + 96 + ], + [ + 11, + [ + 7, + 7 + ], + 416 + ], + [ + 11, + [ + 8 + ], + 536 + ], + [ + 11, + [ + 8, + 6 + ], + 8 + ] + ], + "proxy_saving": 0, + "stages": [ + [ + 0, + 6, + 0, + 4 + ], + [ + 0, + 6, + 1, + 4 + ], + [ + 0, + 7, + 0, + 416 + ], + [ + 0, + 7, + 1, + 416 + ], + [ + 0, + 8, + 0, + 544 + ], + [ + 1, + 6, + 2, + 4 + ], + [ + 1, + 7, + 2, + 416 + ], + [ + 2, + 4, + 0, + 24 + ], + [ + 2, + 4, + 1, + 24 + ], + [ + 2, + 4, + 2, + 24 + ], + [ + 2, + 4, + 3, + 24 + ], + [ + 2, + 6, + 3, + 4 + ], + [ + 2, + 7, + 3, + 416 + ], + [ + 2, + 8, + 0, + 190 + ], + [ + 2, + 8, + 2, + 2376 + ], + [ + 3, + 4, + 4, + 19 + ], + [ + 3, + 6, + 4, + 4 + ], + [ + 3, + 7, + 4, + 416 + ], + [ + 4, + 4, + 4, + 5 + ], + [ + 4, + 4, + 5, + 23 + ], + [ + 4, + 6, + 5, + 3 + ], + [ + 4, + 7, + 5, + 56 + ], + [ + 4, + 8, + 1, + 2366 + ], + [ + 4, + 8, + 5, + 2376 + ], + [ + 5, + 4, + 6, + 24 + ], + [ + 5, + 6, + 6, + 4 + ], + [ + 5, + 7, + 6, + 416 + ], + [ + 6, + 8, + 0, + 1642 + ], + [ + 6, + 8, + 1, + 10 + ], + [ + 6, + 8, + 4, + 2240 + ], + [ + 6, + 8, + 6, + 63 + ], + [ + 7, + 6, + 8, + 4 + ], + [ + 7, + 7, + 8, + 416 + ], + [ + 8, + 8, + 3, + 2376 + ], + [ + 8, + 8, + 4, + 136 + ], + [ + 8, + 8, + 9, + 1832 + ], + [ + 8, + 8, + 10, + 2376 + ], + [ + 9, + 4, + 5, + 1 + ], + [ + 9, + 6, + 5, + 1 + ], + [ + 9, + 7, + 5, + 360 + ], + [ + 9, + 8, + 6, + 2313 + ], + [ + 9, + 8, + 7, + 2186 + ], + [ + 10, + 4, + 7, + 24 + ], + [ + 10, + 4, + 8, + 24 + ], + [ + 10, + 4, + 9, + 24 + ], + [ + 10, + 4, + 10, + 24 + ], + [ + 10, + 6, + 7, + 4 + ], + [ + 10, + 7, + 7, + 416 + ], + [ + 10, + 8, + 7, + 190 + ], + [ + 10, + 8, + 8, + 2376 + ], + [ + 11, + 6, + 9, + 4 + ], + [ + 11, + 6, + 10, + 4 + ], + [ + 11, + 7, + 9, + 416 + ], + [ + 11, + 7, + 10, + 416 + ], + [ + 11, + 8, + 9, + 544 + ] + ] + } +} diff --git a/research/e8-combined/data/bit/word.json.gz b/research/e8-combined/data/bit/word.json.gz new file mode 100644 index 0000000000..dc498d5e8a Binary files /dev/null and b/research/e8-combined/data/bit/word.json.gz differ diff --git a/research/e8-combined/data/complex/FULL-WORD.json.gz b/research/e8-combined/data/complex/FULL-WORD.json.gz new file mode 100644 index 0000000000..79b1622b1e Binary files /dev/null and b/research/e8-combined/data/complex/FULL-WORD.json.gz differ diff --git a/research/e8-combined/data/complex/hosting.json b/research/e8-combined/data/complex/hosting.json new file mode 100644 index 0000000000..2813405c44 --- /dev/null +++ b/research/e8-combined/data/complex/hosting.json @@ -0,0 +1,532 @@ +{ + "policy": "At most one helper per physical family per invocation; whole residuals only", + "selected": [ + { + "idle": 0, + "pattern": [], + "copies": 1 + }, + { + "idle": 0, + "pattern": [ + [ + 1, + 9 + ] + ], + "copies": 160 + }, + { + "idle": 0, + "pattern": [ + [ + 0, + 8 + ], + [ + 1, + 8 + ] + ], + "copies": 79 + }, + { + "idle": 1, + "pattern": [], + "copies": 161 + }, + { + "idle": 1, + "pattern": [ + [ + 2, + 8 + ] + ], + "copies": 79 + }, + { + "idle": 2, + "pattern": [ + [ + 1, + 9 + ], + [ + 2, + 9 + ], + [ + 3, + 8 + ] + ], + "copies": 79 + }, + { + "idle": 2, + "pattern": [ + [ + 0, + 9 + ], + [ + 2, + 9 + ], + [ + 3, + 9 + ] + ], + "copies": 161 + }, + { + "idle": 3, + "pattern": [], + "copies": 161 + }, + { + "idle": 3, + "pattern": [ + [ + 4, + 8 + ] + ], + "copies": 79 + }, + { + "idle": 4, + "pattern": [ + [ + 0, + 9 + ], + [ + 1, + 9 + ], + [ + 3, + 9 + ], + [ + 4, + 9 + ], + [ + 5, + 8 + ] + ], + "copies": 79 + }, + { + "idle": 4, + "pattern": [ + [ + 0, + 9 + ], + [ + 1, + 9 + ], + [ + 2, + 9 + ], + [ + 4, + 9 + ], + [ + 5, + 9 + ] + ], + "copies": 97 + }, + { + "idle": 4, + "pattern": [ + [ + 0, + 9 + ], + [ + 1, + 9 + ], + [ + 2, + 9 + ], + [ + 3, + 9 + ], + [ + 4, + 9 + ] + ], + "copies": 64 + }, + { + "idle": 5, + "pattern": [], + "copies": 161 + }, + { + "idle": 5, + "pattern": [ + [ + 6, + 8 + ] + ], + "copies": 79 + }, + { + "idle": 6, + "pattern": [], + "copies": 96 + }, + { + "idle": 6, + "pattern": [ + [ + 4, + 9 + ], + [ + 6, + 9 + ] + ], + "copies": 64 + }, + { + "idle": 6, + "pattern": [ + [ + 0, + 9 + ], + [ + 2, + 9 + ], + [ + 3, + 9 + ], + [ + 4, + 9 + ], + [ + 5, + 9 + ], + [ + 6, + 9 + ], + [ + 7, + 9 + ] + ], + "copies": 78 + }, + { + "idle": 6, + "pattern": [ + [ + 0, + 9 + ], + [ + 1, + 9 + ], + [ + 2, + 9 + ], + [ + 3, + 9 + ], + [ + 4, + 9 + ], + [ + 5, + 9 + ], + [ + 6, + 9 + ] + ], + "copies": 2 + }, + { + "idle": 7, + "pattern": [], + "copies": 161 + }, + { + "idle": 7, + "pattern": [ + [ + 8, + 8 + ] + ], + "copies": 79 + }, + { + "idle": 8, + "pattern": [], + "copies": 143 + }, + { + "idle": 8, + "pattern": [ + [ + 3, + 9 + ], + [ + 4, + 9 + ], + [ + 6, + 9 + ], + [ + 7, + 9 + ], + [ + 8, + 9 + ], + [ + 9, + 9 + ], + [ + 10, + 9 + ] + ], + "copies": 33 + }, + { + "idle": 8, + "pattern": [ + [ + 3, + 9 + ], + [ + 4, + 9 + ], + [ + 5, + 9 + ], + [ + 6, + 9 + ], + [ + 7, + 9 + ], + [ + 8, + 9 + ], + [ + 9, + 9 + ] + ], + "copies": 64 + }, + { + "idle": 9, + "pattern": [ + [ + 5, + 9 + ], + [ + 6, + 9 + ], + [ + 8, + 9 + ], + [ + 9, + 9 + ], + [ + 10, + 9 + ] + ], + "copies": 95 + }, + { + "idle": 9, + "pattern": [ + [ + 5, + 9 + ], + [ + 6, + 9 + ], + [ + 7, + 9 + ], + [ + 9, + 9 + ], + [ + 10, + 9 + ] + ], + "copies": 96 + }, + { + "idle": 9, + "pattern": [ + [ + 5, + 9 + ], + [ + 6, + 9 + ], + [ + 7, + 9 + ], + [ + 8, + 9 + ], + [ + 10, + 9 + ] + ], + "copies": 17 + }, + { + "idle": 9, + "pattern": [ + [ + 5, + 9 + ], + [ + 6, + 9 + ], + [ + 7, + 9 + ], + [ + 8, + 9 + ], + [ + 9, + 9 + ] + ], + "copies": 32 + }, + { + "idle": 10, + "pattern": [ + [ + 7, + 8 + ], + [ + 8, + 9 + ], + [ + 10, + 9 + ] + ], + "copies": 79 + }, + { + "idle": 10, + "pattern": [ + [ + 7, + 9 + ], + [ + 8, + 9 + ], + [ + 10, + 9 + ] + ], + "copies": 161 + }, + { + "idle": 11, + "pattern": [ + [ + 9, + 8 + ], + [ + 10, + 8 + ] + ], + "copies": 79 + }, + { + "idle": 11, + "pattern": [ + [ + 9, + 9 + ] + ], + "copies": 161 + } + ] +} diff --git a/research/e8-combined/data/complex/ports.json b/research/e8-combined/data/complex/ports.json new file mode 100644 index 0000000000..e1d76517d2 --- /dev/null +++ b/research/e8-combined/data/complex/ports.json @@ -0,0 +1 @@ +{"ports":[7,11,19,35,67,131,259,13,21,37,69,133,261,25,41,73,137,265,49,81,145,273,97,161,289,193,321,385,14,22,38,70,134,262,26,42,74,138,266,50,82,146,274,98,162,290,194,322,386,28,44,76,140,268,52,84,148,276,100,164,292,196,324,388,56,88,152,280,104,168,296,200,328,392,112,176,304,208,336,400,224,352,416,448,508,506,502,494,478,446,382,254,505,501,493,477,445,381,253,499,491,475,443,379,251,487,471,439,375,247,463,431,367,239,415,351,223,319,191,127]} diff --git a/research/e8-combined/data/complex/schedule.json b/research/e8-combined/data/complex/schedule.json new file mode 100644 index 0000000000..8ad4deb3b5 --- /dev/null +++ b/research/e8-combined/data/complex/schedule.json @@ -0,0 +1 @@ +{"bank_padding":null,"cover":"all matrices in O(89,2), in lexicographic row order","cover_final_correction":{"charged_calls_per_cover":9600,"families":[0,9600],"formula":"delta_i=(weight(row_i(g))-1)/2 mod 2","kind":"translate_every_live_family","must_follow_data_signed_exchange":true},"execution_schedule":[{"kind":"local","pair":0,"reverse":false,"stage":0},{"kind":"local","pair":0,"reverse":true,"stage":1},{"idx":0,"kind":"idle","pair":1,"phase_children":[0,2],"rank":16,"source_level":-1,"target_level":1},{"coefficient":1,"dst":0,"kind":"bridge","src":1},{"kind":"local","pair":0,"reverse":false,"stage":2},{"idx":1,"kind":"idle","pair":1,"phase_children":[1,3],"rank":8,"source_level":1,"target_level":2},{"coefficient":-1,"dst":0,"kind":"bridge","src":1},{"kind":"local","pair":1,"reverse":true,"stage":3},{"idx":2,"kind":"idle","pair":2,"phase_children":[4,6],"rank":32,"source_level":-1,"target_level":3},{"coefficient":1,"dst":1,"kind":"bridge","src":2},{"kind":"local","pair":1,"reverse":false,"stage":4},{"idx":3,"kind":"idle","pair":2,"phase_children":[5,7],"rank":8,"source_level":3,"target_level":4},{"coefficient":-1,"dst":1,"kind":"bridge","src":2},{"kind":"local","pair":2,"reverse":true,"stage":5},{"idx":4,"kind":"idle","pair":3,"phase_children":[8,10],"rank":48,"source_level":-1,"target_level":5},{"coefficient":1,"dst":2,"kind":"bridge","src":3},{"kind":"local","pair":2,"reverse":false,"stage":6},{"idx":5,"kind":"idle","pair":3,"phase_children":[9,11],"rank":8,"source_level":5,"target_level":6},{"coefficient":-1,"dst":2,"kind":"bridge","src":3},{"kind":"local","pair":3,"reverse":true,"stage":7},{"idx":6,"kind":"idle","pair":4,"phase_children":[12,14],"rank":64,"source_level":-1,"target_level":7},{"coefficient":1,"dst":3,"kind":"bridge","src":4},{"kind":"local","pair":3,"reverse":false,"stage":8},{"idx":7,"kind":"idle","pair":4,"phase_children":[13,15],"rank":8,"source_level":7,"target_level":8},{"coefficient":-1,"dst":3,"kind":"bridge","src":4},{"kind":"local","pair":4,"reverse":true,"stage":9},{"kind":"local","pair":4,"reverse":false,"stage":10},{"idx":8,"kind":"idle","pair":0,"phase_children":[16,17],"rank":64,"source_level":2,"target_level":10},{"idx":9,"kind":"idle","pair":1,"phase_children":[18,19],"rank":48,"source_level":4,"target_level":10},{"idx":10,"kind":"idle","pair":2,"phase_children":[20,21],"rank":32,"source_level":6,"target_level":10},{"idx":11,"kind":"idle","pair":3,"phase_children":[22,23],"rank":16,"source_level":8,"target_level":10},{"idx":12,"kind":"idle","pair":4,"phase_children":[24,25],"rank":0,"source_level":10,"target_level":10},{"coefficient":1,"dst":4,"kind":"bridge","src":3},{"coefficient":1,"dst":3,"kind":"bridge","src":2},{"coefficient":1,"dst":2,"kind":"bridge","src":1},{"coefficient":1,"dst":1,"kind":"bridge","src":0},{"kind":"terminal_Y_translations","pairs":[0,1,2,3,4],"vector":"port q transported by cover matrix"},{"kind":"terminal"},{"charged_calls_per_cover":9600,"families":[0,9600],"formula":"delta_i=(weight(row_i(g))-1)/2 mod 2","kind":"translate_every_live_family","must_follow_data_signed_exchange":true}],"h":9,"hosting":{"windows":{"0":[1,16,[0,1]],"1":[1,8,[2]],"10":[2,32,[7,8,9,10]],"11":[3,16,[9,10]],"2":[2,32,[0,1,2,3]],"3":[2,8,[4]],"4":[3,48,[0,1,2,3,4,5]],"5":[3,8,[6]],"6":[4,64,[0,1,2,3,4,5,6,7]],"7":[4,8,[8]],"8":[0,64,[3,4,5,6,7,8,9,10]],"9":[1,48,[5,6,7,8,9,10]]}},"live":9600,"m":89,"physical":10178,"private_namespace":{"centers":[9600,9616],"coefficient":[10176,10178],"tableau":[9616,10176]},"recipe":[{"kind":"local","pair":0,"reverse":false,"stage":0},{"kind":"local","pair":0,"reverse":true,"stage":1},{"coefficient":1,"dst":0,"kind":"bridge","src":1},{"kind":"local","pair":0,"reverse":false,"stage":2},{"coefficient":-1,"dst":0,"kind":"bridge","src":1},{"kind":"local","pair":1,"reverse":true,"stage":3},{"coefficient":1,"dst":1,"kind":"bridge","src":2},{"kind":"local","pair":1,"reverse":false,"stage":4},{"coefficient":-1,"dst":1,"kind":"bridge","src":2},{"kind":"local","pair":2,"reverse":true,"stage":5},{"coefficient":1,"dst":2,"kind":"bridge","src":3},{"kind":"local","pair":2,"reverse":false,"stage":6},{"coefficient":-1,"dst":2,"kind":"bridge","src":3},{"kind":"local","pair":3,"reverse":true,"stage":7},{"coefficient":1,"dst":3,"kind":"bridge","src":4},{"kind":"local","pair":3,"reverse":false,"stage":8},{"coefficient":-1,"dst":3,"kind":"bridge","src":4},{"kind":"local","pair":4,"reverse":true,"stage":9},{"kind":"local","pair":4,"reverse":false,"stage":10},{"coefficient":1,"dst":4,"kind":"bridge","src":3},{"coefficient":1,"dst":3,"kind":"bridge","src":2},{"coefficient":1,"dst":2,"kind":"bridge","src":1},{"coefficient":1,"dst":1,"kind":"bridge","src":0},{"kind":"terminal"}],"replicas":8,"route_semantics":{"data":"right factor rho(q,stage), exact orthogonal involution in DATA-PHASES proof","helper":"coordinate permutation followed by pending idle basis U_q; maps whole rank9 residual onto its assigned interval","work":"private disjoint family, cleared after every invocation"},"stages":11,"terminal_translations":{"pairs":[0,1,2,3,4],"vector":"port q transported by cover matrix"},"version":"complex-eleven-hosted-v1"} diff --git a/research/e8-combined/moments.py b/research/e8-combined/moments.py new file mode 100644 index 0000000000..d0490b7fcd --- /dev/null +++ b/research/e8-combined/moments.py @@ -0,0 +1,48 @@ +"""Enclose the supplier moment with rational series and outward rounding.""" +from fractions import Fraction as Q +from functools import cache +GRID=1<<192 + +def down(x):return Q(x.numerator*GRID//x.denominator,GRID) +def up(x):return -down(-x) + +@cache +def log_bounds(x): + x=Q(x);power=0 + while x>=2:x/=2;power+=1 + assert 1<=x<2 + def unit(y): + z=(y-1)/(y+1);term=z;lower=Q(0) + for j in range(64): + lower+=2*term/(2*j+1);term*=z*z + return lower,lower+2*term/(129*(1-z*z)) + lo,hi=unit(x);two_lo,two_hi=unit(Q(2)) + return down(lo+power*two_lo),up(hi+power*two_hi) + +def exp_bounds(lo,hi): + assert 0<=lo<=hi0 + steps.append(dict(gap=str(gap))) + assert b>a>0 + q=a*(1-2*eta) + epsilon=(1-eta)/(1+q) + minimum=epsilon*q + kappa=Q(minimum.numerator*10**18//minimum.denominator,10**18) + if kappa==minimum:kappa-=eta + assert kappa0 for v in slacks.values()) + assert minimum==min(margins.values()) and minimum-kappa<=eta + return dict(kappa=kappa,bootstrap=steps,strict_outer_constraints=slacks, + effective_bit=a,supplier_backoff=s,minimum_margin=minimum, + binding_component='bit' if c<(1-beta)*b else 'complex') diff --git a/research/e8-combined/requirements.txt b/research/e8-combined/requirements.txt new file mode 100644 index 0000000000..1ca5fd0616 --- /dev/null +++ b/research/e8-combined/requirements.txt @@ -0,0 +1 @@ +sympy==1.14.0 diff --git a/research/e8-combined/vendor/bit/SOURCES.json b/research/e8-combined/vendor/bit/SOURCES.json new file mode 100644 index 0000000000..840a3c8ac8 --- /dev/null +++ b/research/e8-combined/vendor/bit/SOURCES.json @@ -0,0 +1,326 @@ +{ + "scope": "Source closure for the bit witness and exact checks. Search code is excluded.", + "files": [ + { + "file": "vendor/bit/local.py", + "origin": "work/next-track/bit/integration/local.py", + "origin_sha256": "76146b884ad99327844ae5706fcf759be4271df7287e7a2755d09aaba1db6c33", + "sha256": "d7d1fde95293d4a815e7ba75379a4347ecc0b27172f85fc4e7b27711ad3b328f", + "adaptations": [ + { + "type": "path_adaptation", + "old": "ROOT=Path(__file__).resolve().parents[1]\nsys.path[:0]=[str(ROOT/'pinned462/research/e8-r740-replica32/code'),str(ROOT/'r707-audit')]", + "new": "ROOT=Path(__file__).resolve().parent\nsys.path.insert(0,str(ROOT))" + } + ] + }, + { + "file": "vendor/bit/geometry.py", + "origin": "work/next-track/bit/integration/geometry.py", + "origin_sha256": "be6e83c4905790a0d3b345d33ae949589560d1dc0602297e3ac1b993e2678358", + "sha256": "be6e83c4905790a0d3b345d33ae949589560d1dc0602297e3ac1b993e2678358", + "adaptations": [] + }, + { + "file": "vendor/bit/emit.py", + "origin": "work/next-track/bit/integration/emit.py", + "origin_sha256": "c42ac18978fcaeaf08b347f00d3c4a55a47e70a2035e08ab4b762cf0d261f296", + "sha256": "fe30eaede300e8d418884aed6f56f7e142ca9ced7a7ed803e08a4741167c2e46", + "adaptations": [ + { + "type": "path_adaptation", + "old": "sys.path.insert(0,str(HERE.parent/\"pinned462/research/e8-r740-replica32/code\"))\nsys.path.insert(0,str(HERE.parent/\"pinned462/research/idle-axis-hosting\"))", + "new": "sys.path.insert(0,str(HERE))" + }, + { + "type": "description_only", + "old": "Source-bound eleven-stage bit template with 8 independent replicas and no helper banks.", + "new": "Source-bound eleven-stage bit template with 4 independent replicas and no helper banks." + }, + { + "type": "description_only", + "old": "Historical PR386 regression is performed by the unchanged parent wrapper.", + "new": "Historical PR386 wrapper regression is outside this package." + } + ] + }, + { + "file": "vendor/bit/e8core.py", + "origin": "work/next-track/bit/pinned462/research/e8-r740-replica32/code/e8core.py", + "origin_sha256": "1cb286196c1530d06f50f0997febc5993b388f33464e295611b920ba30a24eeb", + "sha256": "02b4df319c6475e315b1c59bddb1112f84c8ad8b5f200cf0a62df5d1b4261ddb", + "adaptations": [ + { + "type": "retain_functions_and_class", + "names": [ + "load_word", + "rank", + "Lat", + "to_masks", + "replay" + ], + "origin_ranges": [ + [ + 18, + 20 + ], + [ + 28, + 39 + ], + [ + 42, + 77 + ], + [ + 80, + 81 + ], + [ + 87, + 146 + ] + ], + "retained_imports": [ + "import gzip, json", + "from fractions import Fraction as Q", + "from collections import Counter" + ] + }, + { + "type": "formatting_only", + "description": "Remove one added blank line at the end of the file." + } + ], + "public_source": { + "repository": "rohanarun/integer-mult-bounds", + "tree": "c4df4fdbf411f047ff7d63c73c432e828e94d924", + "path": "research/e8-r740-replica32/code/e8core.py", + "blob": "78983b368715e89fe8524a6dd2c13585d2b5394e" + } + }, + { + "file": "vendor/bit/export249.py", + "origin": "work/next-track/bit/pinned462/research/e8-r740-replica32/code/export249.py", + "origin_sha256": "6d9817f7c431573aff695e1eacfa7c2ca6d3a2a10baa3a2ea814ab9b9f7b13ab", + "sha256": "6d9817f7c431573aff695e1eacfa7c2ca6d3a2a10baa3a2ea814ab9b9f7b13ab", + "adaptations": [], + "public_source": { + "repository": "rohanarun/integer-mult-bounds", + "tree": "c4df4fdbf411f047ff7d63c73c432e828e94d924", + "path": "research/e8-r740-replica32/code/export249.py", + "blob": "462a0f121f5363265b02d812cb12bed39e33dc74" + } + }, + { + "file": "vendor/bit/bank_routes.py", + "origin": "work/next-track/bit/pinned462/research/e8-r740-replica32/code/bank_routes.py", + "origin_sha256": "7c6997c455bd55acca3a1603797c34e7733d557c27a7694a1429ff15773a505d", + "sha256": "b599275d463feadb8d65c7c578edb53ae7254bfa8b5d4b93c13147bbf87070a6", + "adaptations": [ + { + "type": "retain_functions", + "functions": [ + "validate_isometries" + ], + "origin_ranges": [ + [ + 36, + 65 + ] + ] + }, + { + "type": "remove_unused_import", + "old": "from collections import Counter, defaultdict\n\n", + "new": "" + }, + { + "type": "formatting_only", + "description": "Remove one added blank line at the end of the file." + } + ], + "public_source": { + "repository": "rohanarun/integer-mult-bounds", + "tree": "c4df4fdbf411f047ff7d63c73c432e828e94d924", + "path": "research/e8-r740-replica32/code/bank_routes.py", + "blob": "9e43a876664a26899762f3b8e9a582e684a3650a" + } + }, + { + "file": "vendor/bit/hosting_core.py", + "origin": "work/next-track/bit/pinned462/research/idle-axis-hosting/hosting_core.py", + "origin_sha256": "d8b90cd5d152df3c7c351230863d9e61816ad5e1f21d69bea1a86a5daad559a3", + "sha256": "4ad4adc221251da166af9bdaa22907c62d8129e6fba5efe7c3e9e77151119e42", + "adaptations": [ + { + "type": "retain_functions", + "functions": [ + "windows", + "expand", + "load_selection" + ], + "origin_ranges": [ + [ + 13, + 28 + ], + [ + 97, + 121 + ], + [ + 132, + 138 + ] + ] + }, + { + "type": "module_header", + "old": "\"\"\"Idle-axis hosting: place whole dirty-helper residuals on the pending coordinates of an idle data family.\n\nA data family that is advanced by an idle child from level a to level b receives the commuting coordinate factors of\nthat child. If the family is untouched (no local invocation on its pair and no bridge naming its pair) during an\ninterval of local invocations ending at the child, a helper residual of width w from an invocation inside that\ninterval may own w of those pending coordinates instead of a bank slot. The child keeps only the remaining\ncoordinates. This module computes the windows from the recipe and chooses, per replica, how many residuals of each\nwidth each child hosts (exact integer programme), then expands that choice into explicit slot assignments.\nStandard library plus scipy for the integer programme; the emitted assignment is re-checked without scipy.\"\"\"", + "new": "\"\"\"Replay a saved idle-axis hosting selection. The search solver is excluded.\"\"\"" + }, + { + "type": "description_only", + "old": "Replay a saved idle-axis hosting selection. The search solver is excluded.", + "new": "Replay a saved idle-axis hosting selection with the standard library. The search solver is excluded." + }, + { + "type": "formatting_only", + "description": "Remove one added blank line at the end of the file." + } + ], + "public_source": { + "repository": "rohanarun/integer-mult-bounds", + "tree": "c4df4fdbf411f047ff7d63c73c432e828e94d924", + "path": "research/idle-axis-hosting/hosting_core.py", + "blob": "68b536daa9e6546c0aa046934bf840aaa3c3fde3" + } + }, + { + "file": "vendor/bit/check_streams.py", + "origin": "work/next-track/bit/r707-audit/check_streams.py", + "origin_sha256": "491fcf5c556dbcec89843bceed11061cdd0da1a6d791c286c9d150c676953fff", + "sha256": "491fcf5c556dbcec89843bceed11061cdd0da1a6d791c286c9d150c676953fff", + "adaptations": [] + }, + { + "file": "vendor/bit/check_exact.py", + "origin": "work/next-track/bit/r707-audit/check_exact.py", + "origin_sha256": "c9a888ab1ad5c65a3981f0b7dae82bec72bf3dc5027644bf26c4a2ce32ae9670", + "sha256": "5bfef61e17c388c9b539a7aae224d48d4c35bd6de6578e9238d42cc56002365b", + "adaptations": [ + { + "type": "retain_functions", + "functions": [ + "row_space" + ], + "origin_ranges": [ + [ + 12, + 28 + ] + ], + "module_header": "Use exact row reduction for the local stream check.", + "retained_import": "from fractions import Fraction as Q" + }, + { + "type": "formatting_only", + "description": "Remove one added blank line at the end of the file." + } + ] + }, + { + "file": "vendor/bit/check_word.py", + "origin": "work/next-track/whole-pipeline/independent/check_word.py", + "origin_sha256": "f2692a9f56f9caafcd123dc928df573a1ab51eea30897b70868da58ecd4ba186", + "sha256": "f2692a9f56f9caafcd123dc928df573a1ab51eea30897b70868da58ecd4ba186", + "adaptations": [] + }, + { + "file": "vendor/bit/check_records.py", + "origin": "work/next-track/whole-pipeline/independent/check_records.py", + "origin_sha256": "925b6e3d6a36bad0c23e442f2c9006f7b39f2ce60adc0328956acafaf93beef5", + "sha256": "925b6e3d6a36bad0c23e442f2c9006f7b39f2ce60adc0328956acafaf93beef5", + "adaptations": [] + }, + { + "file": "vendor/bit/check_global106.py", + "origin": "work/next-track/whole-pipeline/independent/check_global106.py", + "origin_sha256": "27adc06ab8814959bedc0fdf9dcf95f985faff12911f29be0d7e1ae639e966c4", + "sha256": "27adc06ab8814959bedc0fdf9dcf95f985faff12911f29be0d7e1ae639e966c4", + "adaptations": [] + }, + { + "file": "vendor/bit/check_routes.py", + "origin": "work/next-track/whole-pipeline/independent/routes106-check.py", + "origin_sha256": "cdca5ecbabb2295391f4b4868956ba93b02683977d3f65a765fc2a55696d6866", + "sha256": "4d5ed1aa4cda8709f921627a46b3b19122bb246509c38a522fb1f488cecce1a4", + "adaptations": [ + { + "type": "path_adaptation", + "old": "parser.add_argument(\"--base\", type=Path, default=Path(\"work/next-track/bit/integration/global106\"))", + "new": "parser.add_argument(\"--base\", type=Path, required=True)" + }, + { + "type": "path_adaptation", + "old": "parser.add_argument(\"--word\", type=Path, default=Path(\"work/next-track/bit/kernel-mix/four-family-106/word.json\"))", + "new": "parser.add_argument(\"--word\", type=Path, required=True)" + } + ] + }, + { + "file": "vendor/bit/check_controls.py", + "origin": "work/next-track/whole-pipeline/independent/check_controls111.py", + "origin_sha256": "edbf6a01291785f3e286b1591527d2ff11ad25442cf4810e5704a9873e534205", + "sha256": "2dcec6a045ac069e6211a6550baf8c0613aabb8ab7a79ee50c943b68378309c3", + "adaptations": [ + { + "type": "path_adaptation", + "old": "import copy,json,struct,tempfile", + "new": "import copy,json,struct,tempfile,sys" + }, + { + "type": "path_adaptation", + "old": "base=Path('work/next-track/bit/kernel-mix/four-family-component111/word.json')", + "new": "base,source,result_path=map(Path,sys.argv[1:])" + }, + { + "type": "path_adaptation", + "old": "source=Path('work/next-track/bit/integration/global111/local/records')\nwith tempfile.TemporaryDirectory(dir='work/next-track/whole-pipeline') as directory:", + "new": "with tempfile.TemporaryDirectory() as directory:" + }, + { + "type": "path_adaptation", + "old": "Path('work/next-track/whole-pipeline/independent/candidate111-controls.json').write_text(json.dumps(result,indent=2)+'\\n')", + "new": "result_path.write_text(json.dumps(result,indent=2)+'\\n')" + } + ] + }, + { + "file": "data/bit/word.json.gz", + "origin": "work/next-track/bit/integration/global111/word.json.gz", + "origin_sha256": "b333c32bc6bbc88fc2dc444e4890e55341f5a513b612fc781aa3cbf16ed9be7d", + "sha256": "b333c32bc6bbc88fc2dc444e4890e55341f5a513b612fc781aa3cbf16ed9be7d", + "adaptations": [] + }, + { + "file": "data/bit/selection.json", + "origin": "work/next-track/bit/kernel-mix/four-family-component111/hosted-exact/selection.json", + "origin_sha256": "d886c0b85a90fb741897f68a35dd24eeb0d3acd23a7f467060d8acaf65792b6e", + "sha256": "d886c0b85a90fb741897f68a35dd24eeb0d3acd23a7f467060d8acaf65792b6e", + "adaptations": [] + }, + { + "file": "vendor/bit/replay.py", + "origin": null, + "origin_sha256": null, + "sha256": "6cf1c5ad0d2ff6bb474586253e560706996b192888de9b96758e183aa1eecffb", + "adaptations": [ + { + "type": "new_replay_driver" + } + ] + } + ] +} diff --git a/research/e8-combined/vendor/bit/bank_routes.py b/research/e8-combined/vendor/bit/bank_routes.py new file mode 100644 index 0000000000..84ffbdad0d --- /dev/null +++ b/research/e8-combined/vendor/bit/bank_routes.py @@ -0,0 +1,38 @@ +"""Exact residual bank routes for the kernel word; chafreaky with OpenAI Codex. + +The stored integer rows divided by two are an orthonormal basis. Entrance +rows span E; the remaining rows span E-perp. A coordinate permutation sends +the latter to the assigned contiguous block in a width-64 bank. This gives +an explicit rational isometry, with only powers of two in denominators. +""" + +def validate_isometries(rows, frames, roots, dimensions): + seen = set() + dot = lambda a, b: sum(x*y for x, y in zip(a, b)) + for record in rows: + f = record['frame'] + assert f not in seen + seen.add(f) + e = record['entrance_rank'] + assert e == dimensions[f] and record['denominator'] == 2 + basis = record['entrance_basis'] + record['residual_basis'] + matrix = record['orthogonal_rows_numerator'] + assert len(basis) == len(matrix) == 8 + assert matrix == [roots[i] for i in basis] + assert all(len(r) == 8 and all(type(x) is int for x in r) for r in matrix) + assert all(dot(a,b) == 4*(i==j) for i,a in enumerate(matrix) for j,b in enumerate(matrix)) + # The first e rows span precisely the frame, not only its dimension. + for i in frames[f]: + assert sum(dot(roots[i], q)**2 for q in matrix[:e]) == 4*dot(roots[i], roots[i]) + assert len(record['entrance_basis']) == e + # This selected family needs coordinate permutations only. Checking the + # elementary reduction also bounds the literal route cost and primes. + reduced = [[x // 2 for x in row] for row in matrix] + assert all(x % 2 == 0 for row in matrix for x in row) + operations = record['gaussian_reduction'] + assert len(operations) <= 7 + for kind, i, j, scalar in operations: + assert kind == 'swap' and scalar is None and 0 <= i < 8 and 0 <= j < 8 + reduced[i], reduced[j] = reduced[j], reduced[i] + assert reduced == [[int(i == j) for j in range(8)] for i in range(8)] + return seen diff --git a/research/e8-combined/vendor/bit/check_controls.py b/research/e8-combined/vendor/bit/check_controls.py new file mode 100644 index 0000000000..5e8bafa047 --- /dev/null +++ b/research/e8-combined/vendor/bit/check_controls.py @@ -0,0 +1,33 @@ +"""Check rejection at the word and record boundaries.""" +import copy,json,struct,tempfile,sys +from pathlib import Path +from check_word import check as word_check +from check_records import check as records_check + +base,source,result_path=map(Path,sys.argv[1:]) +word=json.loads(base.read_text());controls=[] + +def reject_word(name,mutate): + altered=copy.deepcopy(word);mutate(altered) + try:word_check(altered) + except AssertionError:controls.append(name) + else:raise AssertionError('accepted '+name) + +full=next(i for i,ids in enumerate(word['frames']) if len(ids)==120) +helper=next(r for r in range(240,945) if word['start'][r]!=0) +reject_word('full helper entrance has no residual',lambda c:c['start'].__setitem__(helper,full)) +reject_word('missing dirty-target correction',lambda c:c['D'].pop(0)) +with tempfile.TemporaryDirectory() as directory: + folder=Path(directory) + for name in ('249-records.bin','249-states.json','frames.json'): + (folder/name).write_bytes((source/name).read_bytes()) + records=list(struct.iter_unpack('<6i',(folder/'249-records.bin').read_bytes())) + index=next(i for i,row in enumerate(records) if row[0]==1) + row=list(records[index]);row[3]=0;records[index]=tuple(row) + (folder/'249-records.bin').write_bytes(b''.join(struct.pack('<6i',*row) for row in records)) + try:records_check(base,folder) + except AssertionError:controls.append('exported ADD coefficient differs from word') + else:raise AssertionError('accepted corrupt export') +result=dict(status='PASS_INDEPENDENT_BOUNDARY_CONTROLS',rejected=controls) +result_path.write_text(json.dumps(result,indent=2)+'\n') +print(json.dumps(result,indent=2)) diff --git a/research/e8-combined/vendor/bit/check_exact.py b/research/e8-combined/vendor/bit/check_exact.py new file mode 100644 index 0000000000..b9e5cbfa55 --- /dev/null +++ b/research/e8-combined/vendor/bit/check_exact.py @@ -0,0 +1,21 @@ +"""Use exact row reduction for the local stream check.""" +from fractions import Fraction as Q + + +def row_space(rows): + basis = {} + for row in rows: + row = list(map(Q, row)) + for p, b in sorted(basis.items()): + a = row[p] + row = [x - a * y for x, y in zip(row, b)] + p = next((j for j, x in enumerate(row) if x), None) + if p is None: + continue + a = row[p] + row = tuple(x / a for x in row) + for k, b in list(basis.items()): + a = b[p] + basis[k] = tuple(x - a * y for x, y in zip(b, row)) + basis[p] = row + return tuple(b for _, b in sorted(basis.items())) diff --git a/research/e8-combined/vendor/bit/check_global106.py b/research/e8-combined/vendor/bit/check_global106.py new file mode 100644 index 0000000000..ac2b31ebcf --- /dev/null +++ b/research/e8-combined/vendor/bit/check_global106.py @@ -0,0 +1,278 @@ +"""Independent eleven-stage schedule, geometry embedding and hosted ownership audit. +Derived from PR386/436/443/444 and DaysSky PR442; all source notices retained. +Eleven-stage integration by chafreaky with OpenAI Codex assistance, Apache-2.0. +No emitter, schedule constructor, hosting solver or expander is imported. +The local programs come from a separate exact record replay. +""" +import copy,gzip,hashlib,json,sys +from collections import Counter,defaultdict +from pathlib import Path +K,L,M,T,V,R=5,11,78,4,120,705 +DATA=2*K*V*T +read=lambda p:json.loads(p.read_text()) +sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest() +load_template=lambda p:json.loads(gzip.decompress(p.read_bytes())) + +def windows(schedule): + last={};seen=[];win={};ranks={};pairs={} + for position,event in enumerate(schedule): + kind=event['kind'] + if kind=='local_cover_sweep': + seen.append((position,event['stage'],event['pair']));last[event['pair']]=position + elif kind=='bridge': + last[event['dst']]=position;last[event['src']]=position + elif kind=='idle': + i=event['idx'];assert i not in win + win[i]={s for pos,s,p in seen if last.get(event['pair'],-1)0 and 0<=off and off+w<=rank[i] + cells=set(range(off,off+w));assert not cells&used[i,cp];used[i,cp]|=cells + assert (s,h) not in hosted;hosted[s,h]=(i,cp,off,w) + assert set(hosted)=={(s,h) for s in range(L) for h in range(R*T)} + rem={};summaries={} + for i in rank: + if not rank[i]:continue + for cp in range(2*V*T):rem[i,cp]=rank[i]-len(used[i,cp]) + if str(i) in hs['windows']: + summaries[str(i)]={str(r):n for r,n in sorted(Counter(rem[i,cp] for cp in range(2*V*T)).items())} + assert hs['remainders']==summaries + assert len(t['calls'])==L*T;seen=set();paid=Counter() + localhash={ori:hashlib.sha256(json.dumps(es,separators=(',',':')).encode()).hexdigest() for ori,es in t['local_programs'].items()} + for index,c in enumerate(t['calls']): + s,rep=c['stage'],c['replica'];p=max(0,(s-1)//2);rev=bool(s%2) + assert (s,rep)==divmod(index,T) and c['pair']==p and c['orientation']==('reverse' if rev else 'forward') + assert c['local_hash']==localhash[c['orientation']] + own=c['owners'];assert len(own)==2*V+R + assert len({(f,tuple(route)) for f,route in own})==2*V+R + for j,(f,route) in enumerate(own): + assert 0<=f2*max(paid)**3 + return paid + +def expanded_digest(t): + h=hashlib.sha256();count=0 + for call in t['calls']: + for op in t['local_programs'][call['orientation']]: + row=[op[0],call['owners'][op[1]]] + if op[0]==0:row.extend(op[2:]) + else: + row.append(call['owners'][op[2]] if op[2]<2*V+R else [t['live'],['private',0]]) + row.extend(op[3:]) + h.update(json.dumps(row,separators=(',',':')).encode());h.update(b'\n');count+=1 + return h.hexdigest(),count + + +def physical_prefix(t): + bounds={i:1 for i in range(t['live'])};scratch=t['live'];bounds[scratch]=0;maximum=1 + stages=defaultdict(list) + for c in t['calls']:stages[c['stage']].append(c) + for e in t['schedule']: + if e['kind']=='local_cover_sweep': + for c in stages[e['stage']]: + for z in t['local_programs'][c['orientation']]: + tag=z[0] + if tag==0:continue + dst=c['owners'][z[1]][0] + if tag==1: + sr=scratch if z[2]==2*V+R else c['owners'][z[2]][0] + bounds[dst]=bounds[dst]+abs(z[3])*bounds[sr] + elif tag==2:bounds[scratch]=bounds[dst] + else:assert tag==3;bounds[scratch]=0 + maximum=max(maximum,bounds[dst],bounds[scratch]) + elif e['kind']=='bridge': + for replica in range(T): + for port in range(V): + for side in (0,1): + dp,sp=(e['dst'],e['src']) if side==0 else (e['src'],e['dst']) + dst=replica*2*K*V+(2*dp+side)*V+port;sr=replica*2*K*V+(2*sp+side)*V+port + bounds[dst]+=bounds[sr];maximum=max(maximum,bounds[dst]) + assert bounds[scratch]==0 + return maximum + +def scalar_replay(t): + n=2*K*V+L*R;local=2*V+R;scratch=n + values=[1<0 + old,new=bases[before],bases[after] + low,high=(new,old) if reverse else (old,new) + assert all(contains(high,row) for row in low) + current[x]=after;hist[f]+=1 + events.append([0,x,before,after,f,int(reverse)]) + elif op==1: + assert current[x]==current[y]==f and x> (axis - 8) & 1 else 1 for axis in range(M)) + assert signs[:8] == (1,) * 8 and signs[18:] == (1,) * 60 + normalized = tuple(signs[axis] * (perm[axis] + 1) for axis in range(M)) + assert normalized not in seen[family] + seen[family].add(normalized) + load[family] += 1 + cost = host_costs[port] + swap_cost(perm) + tag.bit_count() + assert cost <= 144 + route_costs[cost] += 1 + tags[tag] += 1 + counts[width] += 1 + max_family_load = max(max_family_load, max(load.values())) +assert sum(counts.values()) == EXPECTED_HELPERS +assert verified_helpers == {(s, r, j) for s in range(11) for r in range(4) for j in range(2 * V, LOCAL)} +assert all(x.denominator & (x.denominator - 1) == 0 for x in host_coefficients + geometry_coefficients) +assert all(abs(x.numerator) & (abs(x.numerator) - 1) == 0 for x in host_scales + geometry_scales) +assert inputs == {str(path): hashlib.sha256(path.read_bytes()).hexdigest() for path in PATHS} +result = dict(status="PASS_INDEPENDENT_EXACT_SIGNED_OWNER_ROUTES", inputs=inputs, + helper_routes=sum(counts.values()), call_count=44, geometry_routes=geometry_routes, + residual_frames=len(residuals), helper_widths=dict(sorted(counts.items())), + sign_tags=dict(sorted(tags.items())), max_helpers_on_one_family_in_one_call=max_family_load, + host_basis_factor_counts=dict(sorted(Counter(host_costs).items())), + maximum_geometry_route_factors=max(geometry_costs), + maximum_actual_route_factors=max(route_costs), charged_route_factors=144, + host_coefficient_denominators=sorted({x.denominator for x in host_coefficients}), + host_scale_numerator_magnitudes=sorted({abs(x.numerator) for x in host_scales}), + mutation_controls=mutation_controls, + exact_field_scope="Rational identities; injective owners over every admitted odd field", + verification="Orthogonal host bases; signed-permutation routes; exported entrance complements; pending projector images; concrete per-call owner injection") +print(json.dumps(result, indent=2)) diff --git a/research/e8-combined/vendor/bit/check_streams.py b/research/e8-combined/vendor/bit/check_streams.py new file mode 100644 index 0000000000..afa5c3070f --- /dev/null +++ b/research/e8-combined/vendor/bit/check_streams.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python3 +"""Build and check both local streams, including a private COPY register.""" +from collections import Counter +import gzip +import hashlib +import json +from pathlib import Path +import sys +from check_exact import row_space + + +def check(c): + v = c['v'] + n = 2*v + c['R'] + frames = [row_space(c['lines'][i] for i in ids) for ids in c['frames']] + zero = next(i for i, f in enumerate(frames) if not f) + cur = list(c['start']) + records = [] + + def move(r, frame): + if frames[cur[r]] != frames[frame]: + records.append(('move', r, cur[r], frame)) + cur[r] = frame + + def gates(phase): + for frame, dst, sources in c[phase]: + for r in [dst] + sources: + move(r, frame) + records.extend(('add', dst, src, frame) for src in sources) + + gates('D') + gates('A') + for k, source in enumerate(c['ret']): + records.append(('copy', source, cur[source], zero)) + records.extend(('add', v+t, n, zero) for t, row in enumerate(c['scatter']) if k in row) + records.append(('erase', source, cur[source], zero)) + gates('B') + gates('C') + for r, frame in enumerate(c['final']): + move(r, frame) + result = {} + for reverse in (False, True): + current = list(c['final'] if reverse else c['start']) + [None] + values = [{r} for r in range(n)] + [set()] + norm = [1]*n + [0] + maximum = 1 + center = None + histogram = Counter() + copies = adds = 0 + dimension = lambda f: 8-len(frames[f]) if reverse else len(frames[f]) + for kind, a, b, frame in reversed(records) if reverse else records: + if kind == 'move': + before, after = (frame, b) if reverse else (b, frame) + assert frames[current[a]] == frames[before] + rank = dimension(after) - dimension(before) + assert rank > 0 + current[a] = after + histogram[rank] += 1 + elif kind == 'add': + assert frames[current[a]] == frames[current[b]] == frames[frame] + assert a != center and a != n and a != b + if b == n: + assert center is not None + values[a].symmetric_difference_update(values[b]) + norm[a] += norm[b] + maximum = max(maximum, norm[a]) + adds += 1 + elif kind == ('erase' if reverse else 'copy'): + assert center is None and not values[n] and current[n] is None + assert frames[current[a]] == frames[b] + center = a + current[n] = frame + values[n] = set(values[a]) + norm[n] = norm[a] + rank = abs(dimension(b) - dimension(frame)) + assert rank == 8 + histogram[rank] += 1 + copies += 1 + else: + assert kind == ('copy' if reverse else 'erase') and center == a + assert frames[current[a]] == frames[b] and frames[current[n]] == frames[frame] + assert values[n] == values[a] + values[n] = set() + norm[n] = 0 + current[n] = None + center = None + assert center is None and not values[n] and current[n] is None + want_frames = c['start'] if reverse else c['final'] + assert all(frames[current[r]] == frames[want_frames[r]] for r in range(n)) + assert all(values[r] == ({r, r-v} if v <= r < 2*v else {r}) for r in range(n)) + result['reverse' if reverse else 'forward'] = dict(columns=n, copies=copies, adds=adds, + row_l1_bound=maximum, histogram=dict(sorted(histogram.items()))) + assert result['forward']['histogram'] == result['reverse']['histogram'] + cf, cb = result['forward']['row_l1_bound'], result['reverse']['row_l1_bound'] + result['nine_stage_prefix_bits'] = ((1 << 18)*cf**5*cb**4).bit_length() + result['eleven_stage_prefix_bits'] = ((1 << 18)*cf**6*cb**5).bit_length() + result['records'] = len(records) + result['all_checks_pass'] = True + return result + + +if __name__ == '__main__': + path = Path(sys.argv[1]) + raw = path.read_bytes() + c = json.loads(gzip.decompress(raw) if path.suffix == '.gz' else raw) + result = check(c) + result['word_sha256'] = hashlib.sha256(raw).hexdigest() + print(json.dumps(result, indent=2)) diff --git a/research/e8-combined/vendor/bit/check_word.py b/research/e8-combined/vendor/bit/check_word.py new file mode 100644 index 0000000000..bc07e61eed --- /dev/null +++ b/research/e8-combined/vendor/bit/check_word.py @@ -0,0 +1,203 @@ +#!/usr/bin/env python3 +"""Check a bitE8/1 word with exact row spaces and explicit F2 column sets.""" +import argparse +from collections import Counter +from fractions import Fraction as Q +from functools import cache +import gzip +import hashlib +import json +from pathlib import Path + + +def row_space(rows): + return _row_space(tuple(tuple(row) for row in rows)) + + +@cache +def _row_space(rows): + basis = {} + for row in rows: + row = list(map(Q, row)) + for p, b in sorted(basis.items()): + a = row[p] + row = [x - a * y for x, y in zip(row, b)] + p = next((j for j, x in enumerate(row) if x), None) + if p is None: + continue + a = row[p] + row = tuple(x / a for x in row) + for k, b in list(basis.items()): + a = b[p] + basis[k] = tuple(x - a * y for x, y in zip(b, row)) + basis[p] = row + return tuple(b for _, b in sorted(basis.items())) + + +@cache +def contains(basis, row): + row = list(map(Q, row)) + for b in basis: + p = next(j for j, x in enumerate(b) if x) + a = row[p] + row = [x - a * y for x, y in zip(row, b)] + return not any(row) + + +def determinant(rows): + a = [list(map(Q, r)) for r in rows] + result = Q(1) + for j in range(len(a)): + k = next((k for k in range(j, len(a)) if a[k][j]), None) + if k is None: + return Q(0) + if k != j: + a[k], a[j] = a[j], a[k] + result = -result + pivot = a[j][j] + result *= pivot + for k in range(j + 1, len(a)): + coefficient = a[k][j] / pivot + a[k] = [x - coefficient * y for x, y in zip(a[k], a[j])] + return result + + +def check(c): + assert c['format'] == 'bitE8/1' and c['form'] == '/2' + assert c['v'] == 120 and c['h'] == 8 + v, n = c['v'], 2 * c['v'] + c['R'] + roots = [tuple(r) for r in c['lines']] + assert len(roots) == v and all(len(r) == 8 for r in roots) + assert all(type(x) is int for r in roots for x in r) + dot = lambda a, b: sum(x*y for x, y in zip(a, b)) + assert all(dot(r, r) == 4 for r in roots) + assert all(dot(a, b) in (-2, 0, 2) for j, a in enumerate(roots) for b in roots[j+1:]) + full = row_space(roots) + assert len(full) == 8 + signed_roots = set(roots) | {tuple(-x for x in r) for r in roots} + assert len(signed_roots) == 240 + assert all(tuple(x - dot(a, b)//2*y for x, y in zip(a, b)) in signed_roots + for a in signed_roots for b in roots) + frames = [] + for ids in c['frames']: + assert len(ids) == len(set(ids)) and all(type(i) is int and 0 <= i < v for i in ids) + frames.append(row_space(roots[i] for i in ids)) + support = [{i for i, r in enumerate(roots) if contains(b, r)} for b in frames] + assert len(c['start']) == len(c['final']) == n + assert all(type(f) is int and 0 <= f < len(frames) for f in c['start'] + c['final']) + current = list(c['start']) + assert all(frames[current[r]] == row_space([roots[r]]) for r in range(v)) + assert all(not frames[current[r]] for r in range(v, 2*v)), 'targets start at zero' + entrance_ranks = [len(frames[current[r]]) for r in range(2*v, n)] + assert all(rank < 8 for rank in entrance_ranks), 'each helper has a nonzero residual' + for r in range(2*v, n): + b = frames[current[r]] + assert all(sum(x != 0 for x in row) == 1 for row in b), ('non-coordinate helper entrance', r) + values = [{r} for r in range(n)] + integer_support = [{r} if r < v else set() for r in range(n)] + histogram = Counter() + z_failures = [] + support_checks = 0 + common_gates = 0 + used_frames = set(c['start']) | set(c['final']) + phase_states = {} + + def move(r, f): + old, new = frames[current[r]], frames[f] + assert all(contains(new, row) for row in old), ('frame not nested', r, current[r], f) + if old != new: + assert len(new) > len(old) + histogram[len(new) - len(old)] += 1 + current[r] = f + + def check_source(r, f, phase, gate): + nonlocal support_checks + active = {x for x in values[r] if x < v} + assert active <= support[f], ('source support', phase, gate, r, sorted(active - support[f])) + support_checks += 1 + missing = integer_support[r] - support[f] + if missing: + z_failures.append(dict(phase=phase, gate=gate, register=r, outside=sorted(missing))) + + def run(phase): + nonlocal common_gates + for j, (f, dest, sources) in enumerate(c[phase]): + assert type(f) is int and 0 <= f < len(frames) + assert v <= dest < n and len(sources) == len(set(sources)) + assert dest not in sources and all(type(s) is int and 0 <= s < n for s in sources) + for r in [dest] + sources: + move(r, f) + used_frames.add(f) + common_gates += 1 + for s in sources: + if s < v or s >= 2*v: + check_source(s, f, phase, j) + values[dest].symmetric_difference_update(values[s]) + integer_support[dest].update(integer_support[s]) + if dest >= 2*v: + check_source(dest, f, phase, j) + phase_states[phase] = dict(nonzero_frames=sum(bool(frames[f]) for f in current[v:]), + dirty_helpers=sum(values[r] != {r} for r in range(2*v, n))) + + assert all(v <= dest < 2*v and not frames[f] for f, dest, sources in c['D']), 'zero-frame target preconditioner' + run('D') + assert current == c['start'], 'D must keep all entrance frames' + run('A') + retained = c['ret'] + assert len(retained) == len(set(retained)) + assert all(type(r) is int and 2*v <= r < n for r in retained) + assert all(not frames[current[r]] for r in range(v, 2*v)) + copies = [set(values[r]) for r in retained] + copy_ranks = [len(frames[current[r]]) for r in retained] + assert all(r == 8 for r in copy_ranks) + assert len(c['scatter']) == v + for t, row in enumerate(c['scatter']): + assert len(row) == len(set(row)) and all(type(k) is int and 0 <= k < len(copies) for k in row) + for k in row: + values[v+t].symmetric_difference_update(copies[k]) + histogram.update(copy_ranks) + run('B') + run('C') + for r, f in enumerate(c['final']): + move(r, f) + assert all(frames[current[r]] == full for r in list(range(v)) + list(range(2*v, n))) + for t in range(v): + b = frames[current[v+t]] + assert len(b) == 7 and all(dot(roots[t], row) == 0 for row in b) + assert all(values[r] == {r} for r in range(v)), 'source columns not restored' + assert all(values[r] == {r} for r in range(2*v, n)), 'helper columns not restored' + assert all(values[v+t] == {v+t, t} for t in range(v)), 'wrong target columns' + grams = {} + for f in sorted(used_frames): + b = frames[f] + d = determinant([[Q(dot(x, y), 2) for y in b] for x in b]) + assert d > 0 + grams[f] = str(d) + mass = sum(r*m for r, m in histogram.items()) + expected_mass = 8*c['R'] - sum(entrance_ranks) + sum(copy_ranks) + 2*v*7 + assert mass == expected_mass, ('local rank mass', mass, expected_mass) + assert not z_failures, ('integer source support', z_failures[:5]) + return dict(R=c['R'], columns=n, gates={p:len(c[p]) for p in 'DABC'}, + exact_columns_pass=True, rational_frames_pass=True, f2_source_support_pass=True, + source_support_checks=support_checks, common_frame_gates=common_gates, + retained_registers=retained, retained_ranks=copy_ranks, local_histogram=dict(sorted(histogram.items())), + local_rank_mass=mass, entrance_rank_total=sum(entrance_ranks), + entrance_rank_counts=dict(sorted(Counter(entrance_ranks).items())), phase_states=phase_states, + used_frames=len(used_frames), gram_determinants=grams, + integer_support_failure_count=len(z_failures), integer_support_failure_examples=z_failures[:5]) + + +if __name__ == '__main__': + p = argparse.ArgumentParser() + p.add_argument('word', type=Path) + p.add_argument('--out', type=Path) + args = p.parse_args() + raw = args.word.read_bytes() + c = json.loads(gzip.decompress(raw) if args.word.suffix == '.gz' else raw) + result = check(c) + result['word_sha256'] = hashlib.sha256(raw).hexdigest() + text = json.dumps(result, indent=2) + '\n' + if args.out: + args.out.write_text(text) + else: + print(text, end='') diff --git a/research/e8-combined/vendor/bit/e8core.py b/research/e8-combined/vendor/bit/e8core.py new file mode 100644 index 0000000000..118feafc29 --- /dev/null +++ b/research/e8-combined/vendor/bit/e8core.py @@ -0,0 +1,129 @@ +"""Our own engine for bitE8/1 words (E8 root-line labels, h = 8): frame algebra over Q via root-line masks, +legality/F2 replay, five-stage histogram, exact bit coarse saving and PR #315 outer assembly (our engine copies). +Chafik Boukhalfa (chafreaky) with Anthropic Claude assistance; Apache-2.0.""" + +import gzip, json +from fractions import Fraction as Q +from collections import Counter + +def load_word(p): + with (gzip.open(p, 'rt') if p.endswith('.gz') else open(p)) as f: + return json.load(f) + + +def rank(vecs): + rows = [[Q(x) for x in r] for r in vecs]; rk = 0 + n = len(rows[0]) if rows else 0 + for col in range(n): + p = next((i for i in range(rk, len(rows)) if rows[i][col] != 0), None) + if p is None: continue + rows[rk], rows[p] = rows[p], rows[rk] + for i in range(len(rows)): + if i != rk and rows[i][col] != 0: + f = rows[i][col] / rows[rk][col]; rows[i] = [a - f * b for a, b in zip(rows[i], rows[rk])] + rk += 1 + return rk + + +class Lat: + """Root-spanned subspaces of Q^8 represented by the mask of root lines they contain.""" + def __init__(self, lines): + self.lines = [tuple(x) for x in lines]; self.v = len(lines) + self._dim = {0: 0}; self._close = {} + # Gram (form /2) for orthogonality + self.ip = [[sum(a * b for a, b in zip(x, y)) // 2 for y in self.lines] for x in self.lines] + + def close(self, mask): + """mask of all root lines in span(roots of mask)""" + if mask in self._close: return self._close[mask] + idx = [i for i in range(self.v) if mask >> i & 1] + basis = [] + for i in idx: + if rank([self.lines[j] for j in basis] + [self.lines[i]]) > len(basis): basis.append(i) + d = len(basis); out = 0 + if d == 8: out = (1 << self.v) - 1 + elif d: + B = [self.lines[j] for j in basis] + for i in range(self.v): + if rank(B + [self.lines[i]]) == d: out |= 1 << i + self._close[mask] = out; self._close[out] = out; self._dim[out] = d + return out + + def dim(self, mask): + if mask not in self._dim: self.close(mask) + return self._dim[mask] + + def basis(self, mask): + b = [] + for i in range(self.v): + if mask >> i & 1 and rank([self.lines[j] for j in b] + [self.lines[i]]) > len(b): b.append(i) + return b + + def perp(self, t): + return self.close(sum(1 << j for j in range(self.v) if self.ip[t][j] == 0)) + + +def to_masks(c, L): + return [L.close(sum(1 << i for i in fr)) for fr in c['frames']] + + +def replay(c, L=None, masks=None, check_f2=True, span=True, span_mode='z'): + """Exact legality + F2 replay + histogram of a bitE8/1 word. Returns dict(H_local, steps, ...). + Legality: each register's frames nested (mask inclusion = exact Q-subspace inclusion for root-spanned frames) and + strictly increasing at each move; every gate at one common frame; D compensation at frame 0; y at frame 0 at the + scatter; COPY of retained totals; final frames (x, helpers FULL; y_t at its cap t-perp). + Source-span: every non-target operand's x-support lies in the gate frame.""" + L = L or Lat(c['lines']); masks = masks or to_masks(c, L) + v, R, h = c['v'], c['R'], c['h']; n = 2 * v + R; FULL = (1 << v) - 1 + cur = [masks[f] for f in c['start']] + for r in range(v): assert cur[r] == L.close(1 << r), 'x start' + for r in range(v, 2 * v): assert cur[r] == 0, 'y start at 0' + sig = [L.dim(cur[r]) for r in range(n)] + H = Counter(); steps = 0; viol = [] + val = [1 << i for i in range(n)] + zsupp = [{i: 1} if i < v else {} for i in range(n)] # integer support of each register over the x columns (all ADDs are +1) + def climb(r, m): + nonlocal steps + if cur[r] == m: return + assert cur[r] & ~m == 0 and cur[r] != m, ('not nested', r) + H[L.dim(m) - L.dim(cur[r])] += 1; steps += 1; cur[r] = m + def run(gates, ph): + for k, (f, d, srcs) in enumerate(gates): + m = masks[f] + assert d >= v and d not in srcs and len(set(srcs)) == len(srcs), (ph, k) + for x in [d] + srcs: climb(x, m) + for s in srcs: + val[d] ^= val[s] + if span: + if s < v or s >= 2 * v: + ms = sum(1 << i for i in zsupp[s]) + if ms & ~m: viol.append((ph, k, s)) + zd = zsupp[d] + for i, a in zsupp[s].items(): + w = zd.get(i, 0) + a + if w: zd[i] = w + else: zd.pop(i, None) + if span_mode == 'f2': + zsupp[d] = {i: 1 for i in range(v) if val[d] >> i & 1} + if span and d >= 2 * v: + md = sum(1 << i for i in zsupp[d]) + if md & ~m: viol.append((ph, k, d)) + run(c['D'], 'D') + for r in range(v, n): assert cur[r] == masks[c['start'][r]], 'D compensation at frame 0 (helpers untouched otherwise)' + run(c['A'], 'A') + for t in range(v): assert cur[v + t] == 0, 'y at frame 0 at the scatter' + copies = [val[q] for q in c['ret']] + for q in c['ret']: + assert q >= 2 * v; H[L.dim(cur[q])] += 1 + for t, row in enumerate(c['scatter']): + for k in row: val[v + t] ^= copies[k] + run(c['B'], 'B'); run(c['C'], 'C') + for r in range(n): climb(r, masks[c['final'][r]]) + for r in range(v): assert cur[r] == FULL + for r in range(2 * v, n): assert cur[r] == FULL + for t in range(v): assert cur[v + t] == L.perp(t), 'y final at cap' + if check_f2: + for s in range(v): assert val[s] == 1 << s + for t in range(v): assert val[v + t] == (1 << (v + t)) | (1 << t), ('target', t) + for r in range(2 * v, n): assert val[r] == 1 << r, ('helper', r) + return dict(sig=sig, viol=viol, H=H, steps=steps, n=n, v=v, R=R, h=h, L=L, masks=masks, ncopy=len(c['ret'])) diff --git a/research/e8-combined/vendor/bit/emit.py b/research/e8-combined/vendor/bit/emit.py new file mode 100644 index 0000000000..63bbb8a3d3 --- /dev/null +++ b/research/e8-combined/vendor/bit/emit.py @@ -0,0 +1,303 @@ +# Four-replica whole-family pooling by Rohan Arun with OpenAI Codex. Upstream notices retained. +# Kernel integration of PR436/PR386 by chafreaky, with OpenAI Codex assistance. +# Original copyright and attribution retained below. This variant uses explicit +# residual isometries and mixed-width banks; the original all-zero-start +# requirement is replaced by the verified kernel entrance contract. +"""Source-bound eleven-stage bit template with 4 independent replicas and no helper banks. +PR386 global identity and PR436 generalization by Zhihao Chen and eumemic, +with their disclosed OpenAI Codex and Anthropic Claude assistance, Apache-2.0. +PR439 explicit residual routes and this replication extension by chafreaky, +with OpenAI Codex assistance. All owner assignments and emitted calls are checked. +Historical PR386 wrapper regression is outside this package. +""" +import argparse, gzip, hashlib, json, struct, time, sys +from collections import Counter +from pathlib import Path +HERE=Path(__file__).resolve().parent +sys.path.insert(0,str(HERE)) +from bank_routes import validate_isometries +import hosting_core as HC + +H,L,K,T,M=8,11,5,4,78 +def sha(p): return hashlib.sha256(p.read_bytes()).hexdigest() +def write(p,x): p.write_text(json.dumps(x,indent=2)+'\n') + +def recipe(): + out=[dict(kind='local',stage=0,pair=0,reverse=False)]; stage=1 + for j in range(K): + out.append(dict(kind='local',stage=stage,pair=j,reverse=True)); stage+=1 + if j/2') + geo=json.loads((out/'GEOMETRY.json').read_text()) + assert geo['status']=='PASS_COMPRESSED_ELEVEN_BIT_GEOMETRY' + # the port routes depend only on the labels: same 120 label vectors, in the same order + assert len(geo['ports'])==V and all(p['port']==t and p['q']==w['lines'][t] for t,p in enumerate(geo['ports'])) + rp=a.local_check/'records/249-records.bin'; raw=rp.read_bytes(); rec=list(struct.iter_unpack('<6i',raw)) + state=json.loads((a.local_check/'records/249-states.json').read_text()) + fs=json.loads((a.local_check/'records/frames.json').read_text())['frames'] + dims={int(f):z['dim'] for f,z in fs.items()} + lg=json.loads((a.local_check/'cout/legality.json').read_text()) + cc=json.loads((a.local_check/'cout/columns.json').read_text()) + assert lg['status'].startswith('PASS') and cc['status'].startswith('PASS') + assert (state['v'],state['n'])==(V,LOCAL) and lg['copies']==lg['erasures']==9 + ADDS=lg['common_frame_ADDs'] + assert cc['formal_columns_checked']==LOCAL and cc['local_scalar_additions']==ADDS + initial=[state['initial'][str(i)] for i in range(LOCAL)] + final=[state['final'][str(i)] for i in range(LOCAL)] + assert all(dims[final[i]]==H for i in range(2*V,LOCAL)) + widths=[H-dims[initial[i]] for i in range(2*V,LOCAL)] + ENT=sum(H-z for z in widths) + NB=0;LIVE=DATA + assert T==4 and M==8+7*(L-1) + isometries=json.loads(a.isometries.read_text()) + assert validate_isometries(isometries,w['frames'],w['lines'],dims)==set(initial[2*V:]) + streams={}; checks={}; localH=None + for reverse in (False,True): + cur=(final if reverse else initial)[:]+[-1]; val=[1<=0 + cur[x]=newf + if f: hist[f]+=1 + events.append([0,x,oldf,newf,f,int(reverse)]) + elif op==1: + assert cur[x]==cur[y]==f and x!=y and x/2') + lines=[S.Matrix(x) for x in w['lines']]; I=S.eye(8); Z=S.zeros(8) + assert lines[0]==S.Matrix([2,0,0,0,0,0,0,0]) + ip=lambda u,v:(u.T*v)[0]/2 + gs={0:I}; todo=[0] + while todo: + more=[] + for i in todo: + for j in range(120): + if j in gs or abs(ip(lines[i],lines[j]))!=1: continue + d=lines[i]-lines[j] if ip(lines[i],lines[j])==1 else lines[i]+lines[j] + r=I-d*d.T/(d.T*d)[0]*2 + gs[j]=r*gs[i]; more.append(j) + todo=more + assert len(gs)==120 + recipes=[]; denoms=set(); max_factors=0 + for t,q in enumerate(lines): + g=gs[t]; assert g.T*g==I and g*lines[0] in (q,-q) + P=q*q.T/4; K=I-P; A=g[:,1:] + assert A.T*A==S.eye(7) and A*A.T==K and P*A==S.zeros(8,7) + rho=P.row_join(A).col_join(A.T.row_join(S.zeros(7))) + assert rho.T==rho and rho*rho==S.eye(15) + expected={'P':S.diag(I,S.zeros(7)), 'H':S.eye(15), + '0':S.diag(K,S.zeros(7)), 'K':S.diag(K,S.eye(7))} + for name,U in [('P',P),('H',I),('0',Z),('K',K)]: + assert rho*S.diag(U,S.eye(7))*rho==expected[name] + # Exact bit address operators D_U: head/tail exchange on U. + # Unlike complex C_U, they carry no omitted scalar/translation phase. + def D(U): return (I-U).row_join(U).col_join(U.row_join(I-U)) + assert D(I)*D(P)==D(K) and D(P)*D(P)==S.eye(16) + ops=factor(rho); max_factors=max(max_factors,len(ops)) + for typ,i,j,c in ops: + if c is not None: denoms.add(int(S.Rational(c).q)) + # Compact exact global matrices: these 15 axes are the first eight + # local coordinates and exterior block s. All other axes are fixed. + routes=[dict(stage=0,axes=list(range(8)),identity=True)] + for s in range(1,11): + axes=list(range(8))+list(range(8+7*(s-1),8+7*s)) + assert len(set(axes))==15 and max(axes)<78 + routes.append(dict(stage=s,axes=axes,elementary_inverse_replay=ops)) + recipes.append(dict(port=t,q=list(map(int,q)),complement_columns=[[str(x) for x in row] for row in A.tolist()], + rho15=[[str(x) for x in row] for row in rho.tolist()],routes=routes)) + if t%30==0: print('compressed geometry',t+1,flush=True) + # Exact nested data levels: local I (or K_q) plus s exterior rank-7 + # blocks. Width 78=8+10*7; each bridge sees identical complete operators. + idle=[] + for j in range(1,5): + idle += [dict(pair=j,source_level=-1,target_level=2*j-1,rank=14*j,phase='before_positive_bridge'), + dict(pair=j,source_level=2*j-1,target_level=2*j,rank=7,phase='before_negative_bridge')] + for j in range(5): + idle.append(dict(pair=j,source_level=2*j+2,target_level=10,rank=14*(4-j),phase='terminal')) + assert sum(z['rank'] for z in idle)==308 + # Every residual is hosted in a data family; no helper bank exists. + slots=[];perms=[] + out=dict(status='PASS_COMPRESSED_ELEVEN_BIT_GEOMETRY',h=8,m=78,stages=11, + word_sha256=digest(p),ports=recipes,idle_per_port_and_data_member=idle, + local_window='U direct_sum E_s, with E_s the first s exterior coordinate 7-blocks', + ambient_form='I_78/2',bank_slots=slots,bank_permutations=perms, + route_checks=1320,exact_bit_endpoint_operator_checks=240, + max_route_factors=max_factors,route_denominators=sorted(denoms), + bad_prime_factors=sorted({int(q) for d in denoms for q in S.factorint(d)}), + missing_route_factor_controls=120,bank_free=True, + scope='All port isometries, stage boundary identities, nested idle ranks, exact bit endpoint operators and coordinate embeddings. No residual banks are used. Full local-word scalar and chronological lowering are checked separately.') + dump(a.out/'GEOMETRY.json',out) + print(json.dumps({k:v for k,v in out.items() if k not in ('ports','bank_permutations','idle_per_port_and_data_member')}),flush=True) + +if __name__=='__main__': main() diff --git a/research/e8-combined/vendor/bit/hosting_core.py b/research/e8-combined/vendor/bit/hosting_core.py new file mode 100644 index 0000000000..14298204b1 --- /dev/null +++ b/research/e8-combined/vendor/bit/hosting_core.py @@ -0,0 +1,56 @@ +"""Replay a saved idle-axis hosting selection with the standard library. The search solver is excluded.""" + +from collections import Counter, defaultdict + +def windows(schedule): + """schedule: ordered events dict(kind='local',stage,pair) | dict(kind='bridge',dst,src) | dict(kind='idle',pair,rank,idx). + Returns {idx: (pair, rank, frozenset(stages))} - stages whose invocation lies strictly between the last touch of + the pair and the idle child.""" + last = {}; out = {}; locals_ = [] + for pos, e in enumerate(schedule): + k = e['kind'] + if k == 'local': + locals_.append((pos, e['stage'], e['pair'])); last[e['pair']] = pos + elif k == 'bridge': + last[e['dst']] = pos; last[e['src']] = pos + elif k == 'idle': + p = e['pair']; lo = last.get(p, -1) + st = frozenset(s for q, s, pp in locals_ if lo < q < pos and pp != p) + out[e['idx']] = (p, e['rank'], st) # an idle child acts on other coordinates (or the other member): not a touch + return out + + +def expand(win, ys, zs, helpers, V2): + """helpers: {stage: [(helper, width), ...]} for ONE replica; returns list of + (idx, copy, offset, width, stage, helper) and the remainder rank of every (idx, copy). + Copies of a piece are the 2V (side, port) data families; residuals packed from offset 0 in decreasing width.""" + pool = defaultdict(list) # (stage, width) -> helpers + for s, hs in helpers.items(): + for h, w in hs: pool[s, w].append(h) + for k in pool: pool[k].sort() + need = defaultdict(list) # (idx, width) -> stages multiset in deterministic order + for (idx, w, s), cnt in sorted(zs.items()): need[idx, w] += [s] * cnt + out = []; rem = {} + for idx in sorted(win): + pats = sorted([(pat, cnt) for (i, pat), cnt in ys.items() if i == idx], key=lambda t: (-sum(t[0]), t[0])) + copy = 0; ptr = Counter() + r = win[idx][1] + for pat, cnt in pats: + for _ in range(cnt): + off = 0 + for w in sorted(pat, reverse=True): + s = need[idx, w][ptr[idx, w]]; ptr[idx, w] += 1 + h = pool[s, w].pop(0) + out.append((idx, copy, off, w, s, h)); off += w + rem[idx, copy] = r - off; copy += 1 + while copy < V2: rem[idx, copy] = r; copy += 1 + return out, rem + + +def load_selection(path, key): + import json + from pathlib import Path + d = json.loads(Path(path).read_text())[key] + ys = {(i, tuple(pat)): n for i, pat, n in d['patterns']} + zs = {(i, w, s): n for i, w, s, n in d['stages']} + return ys, zs, d['proxy_saving'] diff --git a/research/e8-combined/vendor/bit/local.py b/research/e8-combined/vendor/bit/local.py new file mode 100644 index 0000000000..5b9fe13634 --- /dev/null +++ b/research/e8-combined/vendor/bit/local.py @@ -0,0 +1,44 @@ +"""Check a local word and emit its complete instruction records.""" +from pathlib import Path +import gzip, hashlib, json, sys +ROOT=Path(__file__).resolve().parent +sys.path.insert(0,str(ROOT)) +import e8core as E +from export249 import export +from check_streams import check + +word,out=map(Path,sys.argv[1:]);out.mkdir(parents=True,exist_ok=True) +raw=word.read_bytes();c=json.loads(gzip.decompress(raw) if word.suffix=='.gz' else raw) +replay=E.replay(c,span_mode='z');assert not replay['viol'],replay['viol'][:5] +streams=check(c) +assert streams['forward']['histogram']==dict(replay['H']) +state,frames,records=export(c,str(out/'records')) +(out/'cout').mkdir(exist_ok=True) +legality=dict(status='PASS_PYTHON_EXACT_LOCAL_AND_REFLECTED_REPLAY',copies=len(c['ret']),erasures=len(c['ret']), + common_frame_ADDs=streams['forward']['adds'],integer_union_violations=0) +columns=dict(status='PASS_PYTHON_ALL_FORMAL_COLUMNS',formal_columns_checked=replay['n'], + local_scalar_additions=streams['forward']['adds'],local_raw_H=sorted(replay['H'].items())) +for name,value in [('legality',legality),('columns',columns)]: + (out/'cout'/f'{name}.json').write_text(json.dumps(value,indent=2)+'\n') +roots=c['lines'];isos=[] +axes={i:next(j for j,x in enumerate(roots) if x==[2*int(k==i) for k in range(8)]) for i in range(8)} +for f in sorted(set(state['initial'][str(h)] for h in range(240,state['n']))): + B=frames[str(f)]['B'];dim=frames[str(f)]['dim'] + active=[i for i in range(8) if any(row[i] for row in B)] + assert len(active)==dim,('entrance must be a coordinate subspace',f,B) + order=active+[i for i in range(8) if i not in active] + current=order[:];ops=[] + for i in range(8): + j=current.index(i) + if j!=i:current[i],current[j]=current[j],current[i];ops.append(['swap',i,j,None]) + basis=[axes[i] for i in order] + isos.append(dict(frame=f,entrance_rank=dim,denominator=2,entrance_basis=basis[:dim],residual_basis=basis[dim:], + orthogonal_rows_numerator=[roots[i] for i in basis],gaussian_reduction=ops)) +from bank_routes import validate_isometries +assert validate_isometries(isos,c['frames'],roots,{int(f):v['dim'] for f,v in frames.items()})=={x['frame'] for x in isos} +(out/'isometries.json').write_text(json.dumps(isos,indent=2)+'\n') +receipt=dict(status='PASS_LOCAL_REPLAY_AND_RECORD_EXPORT',word_sha256=hashlib.sha256(raw).hexdigest(), + columns=replay['n'],records=len(records),frames=len(frames),residual_isometries=len(isos), + local_profile=dict(sorted(replay['H'].items())),streams=streams, + scope='Two Python local replays and exact record export. Independent global audit is separate.') +(out/'RESULT.json').write_text(json.dumps(receipt,indent=2)+'\n');print(json.dumps(receipt,indent=2)) diff --git a/research/e8-combined/vendor/bit/replay.py b/research/e8-combined/vendor/bit/replay.py new file mode 100644 index 0000000000..6946638d88 --- /dev/null +++ b/research/e8-combined/vendor/bit/replay.py @@ -0,0 +1,96 @@ +"""Rebuild the bit template and run the exact checks in a new output folder.""" +import gzip +import hashlib +import json +import os +from pathlib import Path +import shutil +import subprocess +import sys + +HERE = Path(__file__).resolve().parent +PACKAGE = HERE.parents[1] +ENV = os.environ.copy() +ENV.pop('PYTHONOPTIMIZE', None) +ENV['PYTHONDONTWRITEBYTECODE'] = '1' + + +def source_tree(): + return {str(p.relative_to(PACKAGE)): sha(p) + for folder in (HERE, PACKAGE / 'data/bit') + for p in sorted(folder.rglob('*')) if p.is_file()} + + +def read(path): + return json.loads(path.read_text()) + + +def sha(path): + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def run(script, *arguments): + print('bit: ' + script, flush=True) + result = subprocess.run([sys.executable, '-B', str(HERE / script), *map(str, arguments)], + capture_output=True, text=True, env=ENV) + if result.returncode: + sys.stderr.write(result.stdout + result.stderr) + raise subprocess.CalledProcessError(result.returncode, result.args) + return result.stdout + + +def main(): + if sys.flags.optimize: + raise RuntimeError('Run the verifier without Python optimization.') + out = Path(sys.argv[1]).resolve() + if out == PACKAGE or PACKAGE in out.parents: + raise ValueError('The output folder must be outside the source package.') + before = source_tree() + out.mkdir(parents=True, exist_ok=True) + for entry in read(HERE / 'SOURCES.json')['files']: + assert sha(PACKAGE / entry['file']) == entry['sha256'], entry['file'] + shutil.copyfile(PACKAGE / 'data/bit/word.json.gz', out / 'word.json.gz') + word = out / 'word.json' + word.write_bytes(gzip.decompress((out / 'word.json.gz').read_bytes())) + local = out / 'local' + run('local.py', out / 'word.json.gz', local) + run('geometry.py', '--word', out / 'word.json.gz', '--out', out) + run('emit.py', '--word', out / 'word.json.gz', '--local-check', local, + '--out', out, '--isometries', local / 'isometries.json', + '--selection', PACKAGE / 'data/bit/selection.json') + run('check_word.py', word, '--out', out / 'word-check.json') + run('check_records.py', word, local / 'records', out / 'records-check.json') + run('check_global106.py', out, out / 'records-check.json', out / 'word-check.json', + out / 'global-check.json', word) + routes = json.loads(run('check_routes.py', '--base', out, '--word', word)) + (out / 'routes-check.json').write_text(json.dumps(routes, indent=2) + '\n') + run('check_controls.py', word, local / 'records', out / 'controls-check.json') + audit = read(out / 'global-check.json') + assert audit['status'] == 'PASS_INDEPENDENT_LOCAL_AND_GLOBAL_AUDIT_ROUTES_SEPARATE' + assert routes['status'] == 'PASS_INDEPENDENT_EXACT_SIGNED_OWNER_ROUTES' + controls = read(out / 'controls-check.json') + assert controls['status'] == 'PASS_INDEPENDENT_BOUNDARY_CONTROLS' + audit['status'] = 'PASS_INDEPENDENT_ELEVEN_STAGE_HOSTING_AUDIT' + audit['routes'] = routes + audit['local_boundary_controls'] = controls['rejected'] + audit['receipt_hashes'] = {name: sha(out / name) for name in + ('word-check.json', 'records-check.json', 'global-check.json', + 'routes-check.json', 'controls-check.json')} + audit['audit_source_hashes'] = {name: sha(HERE / name) for name in + ('check_word.py', 'check_records.py', 'check_global106.py', + 'check_routes.py', 'check_controls.py', 'replay.py')} + audit['scope'] = ('Exact local word and records; both orientations; unbanked global columns; ' + 'signed schedule; owner routes; geometry; child profile; and physical prefix. ' + 'Complete-cover hosting, compiler, and all-size analytic interfaces remain ' + 'conditional assumptions. No C++ replay is claimed.') + (out / 'AUDIT.json').write_text(json.dumps(audit, indent=2) + '\n') + assert source_tree() == before, 'The source files changed during replay.' + (out / 'SOURCE-READ-ONLY.json').write_text(json.dumps(before, indent=2) + '\n') + print(json.dumps({'status': audit['status'], 'output': str(out), + 'emitted_events': audit['emitted_events'], + 'hosted_residuals': audit['hosted_residuals'], + 'physical_prefix_bits': audit['physical_prefix_bits']}, indent=2)) + + +if __name__ == '__main__': + main() diff --git a/research/e8-combined/vendor/complex/SOURCES.json b/research/e8-combined/vendor/complex/SOURCES.json new file mode 100644 index 0000000000..62327bab00 --- /dev/null +++ b/research/e8-combined/vendor/complex/SOURCES.json @@ -0,0 +1,181 @@ +[ + { + "path": "vendor/complex/scalar.py", + "source": "work/next-track/complex/pipeline/full-source/research/e8-complex-adapted-kernel/upstream449/audit_cxg.py", + "source_sha256": "12e8fe32136a0f32e5363f97113cf0c32efda6a331dc391758cd58ed8f5f9d1b", + "sha256": "1544d074e38cad5529ffc12c1825b9f3979c8fbdcd277803eff1e51dc23d77fb", + "edits": [ + { + "old": "old=json.load(gzip.open('work/higher-stage-e8/verified/gcert1-e8-retimed.json.gz'))", + "new": "old=json.loads((Path(__file__).resolve().parents[2]/'data/complex/ports.json').read_text())" + }, + { + "old": "b=Q(0);grid=Q(1,10**18)\n", + "new": "" + }, + { + "old": "'status':'PASS_EXACT_SCALAR_AND_FRAME_RESEARCH_CANDIDATE_NOT_YET_ADMITTED'", + "new": "'status':'PASS_EXACT_SCALAR_AND_FRAME_AUDIT'" + }, + { + "old": " 'two_rational_moment_engines':True,'next_b_grid_rejected':True,\n", + "new": "" + }, + { + "old": " 'remaining':['new general scalar-interface proof integration','exact phase and emitted local/global program','finite invoice and outer assembly'],", + "new": " 'remaining':['exact phase and emitted local/global program','finite invoice and outer assembly']," + }, + { + "old": " 'scope':'Substantial new scalar-network candidate. All parameter values remain prospective until the expanded scalar interface and complete phase-aware supplier are admitted.',", + "new": " 'scope':'Exact arbitrary-input scalar maps and nested frames. Separate scripts check phases, physical programs and invoices.'," + } + ] + }, + { + "path": "vendor/complex/programs.py", + "source": "work/next-track/complex/pipeline/full-source/research/e8-complex-adapted-kernel/upstream449/emit_cxg.py", + "source_sha256": "26c646d5a777c1306224abb08d4031b3b1ffcbed8a212a0e58579de13b0ee658", + "sha256": "521950ee178cdf60bbf7984ffb47da6dfa14aa74d18312bf98cdf2c331901ebb", + "edits": [ + { + "old": "\"\"\"Emit both local programs, integrate the fixed nine-stage geometry, and bill.\n\nThe expanded scalar interface is justified in PROOF.txt. This script does not\nclaim a Lean proof or discharge the inherited all-size/analytic interfaces.\n\"\"\"", + "new": "\"\"\"Emit both local programs and check their exact scalar action.\n\nThe package proof states the scalar interface and inherited assumptions.\nThis script does not discharge the all-size or analytic interfaces.\n\"\"\"" + } + ] + }, + { + "path": "vendor/complex/phases.py", + "source": "work/next-track/complex/pipeline/full-source/research/e8-complex-adapted-kernel/upstream449/phases_cxg.py", + "source_sha256": "0f2795aaffafe0c64d77f3748ef2109a3c42c58da867e4cf269a0a8cb6109466", + "sha256": "e2126f9be35b8f61b5f4374d8ac521a153e90a58bd59f69e7dfd80f8195d4c10", + "edits": [ + { + "old": "sys.path.insert(0,str(Path('work/odd-stages').resolve()))\n", + "new": "" + }, + { + "old": "import gzip,hashlib,json,sys,time", + "new": "import gzip,hashlib,json,time", + "reason": "Remove an import made unused by the source extraction." + } + ] + }, + { + "path": "vendor/complex/adapters.py", + "source": "work/next-track/complex/pipeline/full-source/research/e8-complex-adapted-kernel/code/adapters.py", + "source_sha256": "001b80a9366e29f28f3785e146062e12b1913e5da79b5e6d6b7090c6425d7015", + "sha256": "81b551b711e14239fb8ed2675824313d84671365d921c5d53fbde5fd8246ef21", + "edits": [ + { + "old": "sys.path.insert(0,str(ROOT.parent/'split-centres-global/vendor'))\n", + "new": "" + } + ] + }, + { + "path": "vendor/complex/local_audit.py", + "source": "work/next-track/complex/pipeline/full-source/research/e8-complex-adapted-kernel/code/local_audit.py", + "source_sha256": "ae5baeaaeea26cf0a1faa59fbc18a8ad4805f5a8f2eba9644abf44f82c74845d", + "sha256": "1dee2bf0608940786143fdfa8651e56c98028a5e3a41396ca84dd49973916b03", + "edits": [ + { + "old": "sys.path.insert(0,str(ROOT.parent/'split-centres-global/vendor'))\n", + "new": "" + } + ] + }, + { + "path": "vendor/complex/emit.py", + "source": "work/next-track/complex/pipeline/full-source/research/e8-complex-adapted-kernel/code/emit.py", + "source_sha256": "b5170f68223c910ae806255ee1975b33801df3a729da0d6c2ba50ae96ec0c911", + "sha256": "a5926f58f3cbcdfb5a902f844d86cdb3b63df52c2493709a7fc9d8354ad0029c", + "edits": [ + { + "old": "ROOT=Path(__file__).resolve().parents[1];M,H,K,L,T,V,R=89,9,5,11,8,120,560;W=9600", + "new": "ROOT=Path(__file__).resolve().parents[2];M,H,K,L,T,V,R=89,9,5,11,8,120,560;W=9600" + }, + { + "old": "selected=ld(ROOT/'data/hosting.json')['selected']", + "new": "selected=ld(ROOT/'data/complex/hosting.json')['selected']" + } + ] + }, + { + "path": "vendor/complex/audit.py", + "source": "work/next-track/complex/pipeline/full-source/research/e8-complex-adapted-kernel/code/audit.py", + "source_sha256": "2dd35e3d583ae27004d1ff53fd0f96e0f2f10dae3b5376dc8bb6aebeafe9f349", + "sha256": "99fa203c64f6d0e3482b1c50c6d394deff10fccee0f460d419ebeb0ccc8e7137", + "edits": [ + { + "old": "sp=importlib.util.spec_from_file_location('unchanged_phase_audit',ROOT.parent/'r740-hosted-rank149/code/complex_audit.py');PA=importlib.util.module_from_spec(sp);sp.loader.exec_module(PA)", + "new": "import phase_audit as PA" + }, + { + "old": "import copy,gzip,hashlib,importlib.util,json,sys", + "new": "import copy,gzip,hashlib,json,sys", + "reason": "Remove an import made unused by the source extraction." + } + ] + }, + { + "path": "vendor/complex/clifford_exact.py", + "source": "work/next-track/complex/pipeline/full-source/research/split-centres-global/vendor/clifford_exact.py", + "source_sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962", + "edits": [] + }, + { + "path": "vendor/complex/data_phases.py", + "source": "work/next-track/complex/pipeline/full-source/research/r740-hosted-rank149/code/complex_phases.py", + "source_sha256": "4339fde687c041c381d01bc81e90a2abec0092c51920eb02166aaf628a7f25a2", + "sha256": "498190815600ab5d945ac10d1d573fab4eb74f12c77d11e91b11afb15893f1fe", + "edits": [ + { + "old": "sys.path.insert(0,str(Path(__file__).resolve().parents[2]/'split-centres-global/vendor'))\n", + "new": "" + } + ] + }, + { + "path": "vendor/complex/phase_audit.py", + "source": "work/next-track/complex/pipeline/full-source/research/r740-hosted-rank149/code/complex_audit.py", + "source_sha256": "403f95ed28025e552f33d54a5e61da24714bcb757f12a75f66012999c7f37896", + "sha256": "15cda1d7ce09599952d7e91201d1c6732a0c21232155339d9236456db7c91ea3", + "extraction": "polynomial, phases, bridge_controls; validate prefix through hosting windows, with its fixed inherited cover correction formula and no old program comparison", + "edits": [ + { + "old": "from collections import defaultdict\n", + "new": "", + "reason": "Remove an import made unused by the source extraction." + } + ] + }, + { + "path": "data/complex/FULL-WORD.json.gz", + "source": "work/next-track/complex/pipeline/retimed-4/split-centres/FULL-WORD.json.gz", + "source_sha256": "66655cd858afb515dfd4cad43c4fef01f9185af670e144750e9977588ebd4ecf", + "sha256": "66655cd858afb515dfd4cad43c4fef01f9185af670e144750e9977588ebd4ecf", + "edits": [] + }, + { + "path": "data/complex/hosting.json", + "source": "work/next-track/complex/pipeline/full-source/research/e8-complex-adapted-kernel/data/hosting.json", + "source_sha256": "dc5fe719e71c26e856f0da96518af635ed2026b1c323052d97ee4e6b9839f2f1", + "sha256": "dc5fe719e71c26e856f0da96518af635ed2026b1c323052d97ee4e6b9839f2f1", + "edits": [] + }, + { + "path": "data/complex/ports.json", + "source": "work/e8-project/lean-verification/final-reproduction/tools/certificate/gcert1-e8-retimed.json.gz", + "source_sha256": "31467ace2b1667630b72e488e688911a0404b4755d0d2c87560b111ed4c07998", + "sha256": "c4a4288b6052341eddff69e93999525b74512bb2fcdddb00bcdfe80ee42526ce", + "extraction": "only ports are read by the scalar canonicalization" + }, + { + "path": "data/complex/schedule.json", + "source": "work/next-track/complex/pipeline/fresh-parent-complex/GLOBAL-TEMPLATE.json.gz", + "source_sha256": "a2e46da30e6391109bf4eb3314388dfd39d3e8541e1ebf09b27802e9b4df50b4", + "sha256": "f62975a9146a4a0c9d1ecaa6f8567aeedf30bce484cc2105a74e4d7e9afc2522", + "extraction": "fixed geometry and schedule specification only; programs, calls, idle remainders, redundant old phases and old receipts omitted; phase hash regenerated" + } +] diff --git a/research/e8-combined/vendor/complex/adapters.py b/research/e8-combined/vendor/complex/adapters.py new file mode 100644 index 0000000000..b4712aa3c6 --- /dev/null +++ b/research/e8-combined/vendor/complex/adapters.py @@ -0,0 +1,40 @@ +"""Exact paid two-sided adapters for the fourteen isotropic helper entrances. +Each wrapped residual is a coordinate C child; no orthogonal-conjugacy claim. +Chafreaky with OpenAI Codex; uses inherited Gaussian compiler. Apache-2.0. +Usage: adapters.py LOCAL_SPLIT_CENTRES_DIR +""" +import gzip,hashlib,json,sys +from pathlib import Path +ROOT=Path(__file__).resolve().parents[1] +from clifford_exact import canonical_frame,lower_child,monomial,diag,perm,xgate,Op,identity,fourier +out=Path(sys.argv[1]);ld=lambda p:json.loads(gzip.decompress(p.read_bytes())) if p.suffix=='.gz' else json.loads(p.read_text()) +word=ld(out/'CANONICAL-WORD.json.gz');raw=ld(out/'LOCAL-PROGRAMS.json.gz');n=word['h'];v=word['v'];R=word['R'];full=tuple(1<=2*v: + assert e[1] in ('old_to_new','new_to_old') and e[3]==(word['start'] if e[1]=='old_to_new' else word['final'])[e[2]];removed.append(e) + else:body.append(e) + assert len(removed)==2*R + # Both scalar orientations leave helpers unchanged; both residuals are S, + # not inverses. Wrappers surround the ENTIRE invocation including cleanup. + pre=[['residual_adapter','pre',r,word['start'][r]] for r in helpers] + post=[['residual_adapter','post',r,word['start'][r]] for r in helpers] + programs[orientation]=pre+body+post +(out/'RESIDUAL-ADAPTERS.json').write_text(json.dumps(dict(h=n,recipes=recipes,helper_entry_gate='none: initial frame is the interpretation of arbitrary helper data',factorization='S=L C_w R; pre=R^-1; post=L^-1; same residual in both scalar orientations'),indent=2)+'\n') +(out/'ADAPTED-PROGRAMS.json.gz').write_bytes(gzip.compress(canonical(programs),mtime=0)) +print('PASS constructed 14 exact nontrivial two-sided adapters, 79 wrapped helpers in each orientation') diff --git a/research/e8-combined/vendor/complex/audit.py b/research/e8-combined/vendor/complex/audit.py new file mode 100644 index 0000000000..20925ef468 --- /dev/null +++ b/research/e8-combined/vendor/complex/audit.py @@ -0,0 +1,155 @@ +"""Independent full owner/window/route/phase/program audit of paid adapters. +Does not import the emitter or hosting solver. Parent phase checks are unchanged. +Chafreaky with OpenAI Codex assistance; Apache-2.0. +""" +import copy,gzip,hashlib,json,sys +from collections import Counter,defaultdict +from pathlib import Path +ROOT=Path(__file__).resolve().parents[1];M,H,K,L,T,V,R,W=89,9,5,11,8,120,560,9600 +import phase_audit as PA +from local_audit import adapter_check +blob=lambda x:json.dumps(x,sort_keys=True,separators=(',',':')).encode() +sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest() +ld=lambda p:json.loads(gzip.decompress(p.read_bytes())) if p.suffix=='.gz' else json.loads(p.read_text()) + +def validate(t,parent,word,programs,ad,ph): + assert (t['m'],t['h'],t['stages'],t['replicas'],t['live'],t['physical'])==(M,H,L,T,W,10178) + unchanged=['cover','recipe','execution_schedule','bank_padding','private_namespace','cover_final_correction','terminal_translations','exact_data_phase_recipe_sha256'] + for k in unchanged:assert t[k]==parent[k],('changed parent field',k) + assert t['source_template_sha256']==hashlib.sha256(blob(parent)).hexdigest() + assert t['local_programs']==programs and t['residual_adapters']==ad + assert t['residual_route_semantics']==dict(chart='sigma columns are the recorded first-nine indices in U_q plus exterior axes, then unused basis indices in increasing order',owner='g=d*sigma^-1 in O(89,2)',pre='P_d (R^-1 tensor I) P_d^-1 before the entire local invocation',post='P_d (L^-1 tensor I) P_d^-1 after full-frame cleanup',net='P_g C_selected_pending_axes P_g^-1; identity on all spectator axes',helper_entry='no entrance gate; the borrowed value has the declared initial label interpretation',monomial_compiler_groups_per_wrapper=8) + idle={};wins={};last={};locals_=[] + for position,e in enumerate(t['execution_schedule']): + k=e['kind'] + if k=='local':locals_.append((position,e['stage'],e['pair']));last[e['pair']]=position + elif k=='bridge':last[e['dst']]=last[e['src']]=position + elif k=='idle': + i,p=e['idx'],e['pair'];assert i==len(idle);idle[i]=e;wins[i]={s for pos,s,pair in locals_ if last.get(p,-1)>j)&1);a=q^(1<>j)&1 else 0) for j in order]+[1<>i)&1)<>j&1);a[j],a[k]=a[k],a[j] + for i in range(n): + if i!=j and a[i]>>j&1:a[i]^=a[j] + assert [r&((1<>n for r in a) +def basis_extend(cols,n): + out=[] + for x in list(cols)+[1<len(out):out.append(x) + assert len(out)==n + return tuple(out) +def nullspace(rows,n): + a=list(rows);p=[];k=0 + for j in range(n): + t=next((i for i in range(k,len(a)) if a[i]>>j&1),None) + if t is None:continue + a[t],a[k]=a[k],a[t] + for i in range(len(a)): + if i!=k and a[i]>>j&1:a[i]^=a[k] + p.append(j);k+=1 + return tuple((1<>j)&1)<>i&1:out=pmul(out,T[i]) + for i in range(n): + if z>>i&1:out=pmul(out,T[n+i]) + return out +def compose(A,B):return tuple(apply(A,p) for p in B) +def inverse(T): + n=len(T)//2;cols=[x|(z<>n;u,v,p=apply(T,(x,z,0));assert (u,v)==identity(n)[j][:2];out.append((x,z,(-p)%4)) + return tuple(out) +def qvalue(Q,alpha,x,n): + return (sum(alpha[i] for i in range(n) if x>>i&1)+2*sum(parity((Q[i]>>(i+1))&(x>>(i+1))) for i in range(n) if x>>i&1))%4 +def mul_i(a,p): + x,y=a;p%=4 + return [(x,y),(-y,x),(-x,-y),(y,-x)][p] +@dataclass +class Op: + n:int + tab:tuple + circuit:list + def then(self,b): + assert self.n==b.n + return Op(self.n,compose(b.tab,self.tab),self.circuit+b.circuit) + def adjoint(self): + circ=[] + for e in reversed(self.circuit): + if e[0]=='P':circ.append(('P',inv(e[1],self.n))) + elif e[0]=='D':circ.append(('D',e[1],tuple((-x)%4 for x in e[2]))) + elif e[0]=='C':circ.append(('C',e[1],-e[2])) + elif e[0]=='phase':circ.append(('phase',(-e[1])%4)) + else:circ.append(e) + return Op(self.n,inverse(self.tab),circ) + def zero_state(self,basis=0): + N=1<>i)&1 for i in range(n)) + assert all(alpha[i]%2==(Q[i]>>i)&1 for i in range(n)) + return Op(n,tuple([(1<>i&1 else 0,1<>i&1 else 0) for i in range(n)]),[('C',q,sgn)]) +def xgate(n,b):return Op(n,tuple([(1<>i)&1)) for i in range(n)]),[('X',b)]) +def fourier(n,axes=None): + out=ident(n) + for i in range(n) if axes is None else axes:out=out.then(cgate(n,1<len(selected):picks.append(j);selected.append(x) + assert len(picks)==r and all(x>>r==0 for x in Bcols) + Br=transpose(selected,r);Bi=inv(Br,r);Dr=transpose([Dcols[j]&((1<. +Their Fourier multipliers are i^(sum sign*parity(q.y)), represented exactly +as a Z4 quadratic polynomial. This includes the global phase, not just Paulis. +""" +import json,gzip,hashlib,random,sys +from pathlib import Path +from clifford_exact import rank,mv,transpose,parity +H=9;M=89;K=5;L=11 +def normal(terms,m=M): + lin=[0]*m;B=[0]*m + for q,sgn in terms: + for i in range(m): + if q>>i&1:lin[i]=(lin[i]+sgn)%4;B[i]^=q + return tuple(lin),tuple(B) +def shift_adapter(actual,wanted): + a,A=normal(actual);b,B=normal(wanted);assert A==B + delta=[(v-u)%4 for u,v in zip(a,b)];assert all(x in (0,2) for x in delta) + return sum((x//2)<>i&1));w=q^(1<>i&1 else 0)|sum(((cols[j+1]>>i)&1)<<(off+j) for j in range(8)) + for j in range(8):rows[off+j]=cols[j+1] + assert transpose(rows,M)==tuple(rows) and all(mv(rows,mv(rows,1<>i)&1))%4==w0[i] for i in range(M)) + return dict(rank=len(cols),orthogonal_axes=cols,translation_after=delta) +def run(): + c=json.load(gzip.open(Path(sys.argv[1])));ports=[];nonzero=0;idle=[] + for p,q in enumerate(c['ports']): + align=[] + for s in range(L): + z={} + for name,kind,previous in [('entry_X','P',s-1),('entry_Y','0',s-1),('exit_X','H',s),('exit_Y','K',s)]: + canon=desired(q,previous,'X' if name.endswith('X') else 'Y');raw=stage_frame(q,s,kind) + delta=shift_adapter(canon,raw) if name.startswith('entry') else shift_adapter(raw,canon) + z[name]=delta;nonzero+=bool(delta) + align.append(z) + children=[] + for j in range(1,K): + for side in ['X','Y']: + children.append(exact_child(q,desired(q,-1,side),desired(q,2*j-1,side))) + children.append(exact_child(q,desired(q,2*j-1,side),desired(q,2*j,side))) + for j in range(1,K+1): + for side in ['X','Y']:children.append(exact_child(q,desired(q,2*j,side),desired(q,2*K,side))) + # After the signed scalar exchange, the incoming X contributes C_q^{-2}. + # X_q is essential: C_q^2=X_q, so X_q*C_q^{-2}=I exactly. + terminal=diff([(q,1)],desired(q,2*K,'Y'));lin,B=normal(terminal);full=[(1<>i&1)+2*sum(parity((B[i]>>(i+1))&(y>>(i+1))) for i in range(H) if y>>i&1))%4 + assert lhs==rhs;polynomial_checks+=1 + cover=[] + for n in range(1,6): + odd=[x for x in range(1,1<>i)&1))%4==1 for i in range(n)) + cover.append(dict(n=n,orthogonal_matrices=len(mats),nonzero_full_kernel_corrections=nonzero_cover)) + out=dict(status='PASS_EXACT_Z4_DATA_ROUTE_IDLE_AND_TERMINAL_PHASES',m=M,ports=len(ports),nonzero_stage_alignment_translations=nonzero,terminal_omission_controls_rejected=len(ports),exact_phase_polynomial_evaluations=polynomial_checks,recipes=ports,cover_correction=dict(formula='delta(g)_i = (weight(row_i(g))-1)/2 mod 2; apply X_delta(g) to EVERY final live stream in cover class g.',reason='P_g C_all P_g^-1 = C_all X_delta(g) exactly. Orthogonality cancels all quadratic cross terms; both sides fix the uniform vector.',mandatory=True,complete_small_cover_checks=cover),global_phase_argument='Every C_q and every linear address permutation fixes the uniform vector. Equality of the exact Z4 Fourier multiplier therefore fixes the scalar phase as well.',scope='All compressed data boundary operators, idle children, terminal X_q and all-live cover correction. Internal arbitrary-subspace canonical labels are checked separately.') + Path(sys.argv[2]).write_text(json.dumps(out,indent=2));print({k:v for k,v in out.items() if k!='recipes'},flush=True) +if __name__=='__main__':run() diff --git a/research/e8-combined/vendor/complex/emit.py b/research/e8-combined/vendor/complex/emit.py new file mode 100644 index 0000000000..c5d12d2113 --- /dev/null +++ b/research/e8-combined/vendor/complex/emit.py @@ -0,0 +1,82 @@ +"""Whole-residual complex hosting with paid adapters and one helper per host/call. +Schedule/phase lineage PR451, hosting PR442, kernel PR449. +Chafreaky with OpenAI Codex assistance; Apache-2.0. +Usage: emit.py PARENT451_COMPLEX LOCAL_SPLIT_CENTRES OUT +""" +import copy,gzip,hashlib,json,sys +from collections import Counter,defaultdict +from pathlib import Path +ROOT=Path(__file__).resolve().parents[2];M,H,K,L,T,V,R=89,9,5,11,8,120,560;W=9600 +ld=lambda p:json.loads(gzip.decompress(p.read_bytes())) if p.suffix=='.gz' else json.loads(p.read_text()) +blob=lambda x:json.dumps(x,sort_keys=True,separators=(',',':')).encode() +sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest() +def build(parent,local,out): + out.mkdir(exist_ok=True,parents=True);old=ld(parent/'GLOBAL-TEMPLATE.json.gz');ph=ld(parent/'DATA-PHASES.json');c=ld(local/'CANONICAL-WORD.json.gz');review=ld(local/'LOCAL-REVIEW.json');ad=ld(local/'RESIDUAL-ADAPTERS.json');programs=ld(local/'ADAPTED-PROGRAMS.json.gz') + assert review['status']=='PASS_INDEPENDENT_COMPLEX_KERNEL_LOCAL_REALIZATION' + assert (old['m'],old['h'],old['stages'],old['replicas'])==(M,H,L,T) + assert ph['ports']==V and [p['q'] for p in ph['recipes']]==c['ports'] + (out/'DATA-PHASES.json').write_bytes((parent/'DATA-PHASES.json').read_bytes()) + schedule=copy.deepcopy(old['execution_schedule']);idle={e['idx']:e for e in schedule if e['kind']=='idle'} + wins={int(i):(p,r,set(st)) for i,(p,r,st) in old['hosting']['windows'].items()} + widths={h:H-len(c['frames'][c['start'][2*V+h]]) for h in range(R)} + pool={(s,w):[h for h in range(R) if widths[h]==w] for s in range(L) for w in set(widths.values())} + selected=ld(ROOT/'data/complex/hosting.json')['selected'];counts=Counter();slots=[];rem={};helpers={} + for e in selected: + i=e['idle'];pair,rank,allowed=wins[i];pat=e['pattern'];assert len(pat)==len({s for s,w in pat}) + for _ in range(e['copies']): + cp=counts[i];counts[i]+=1;assert cp<240;off=0 + for s,w in pat: + assert s in allowed and off+w<=rank;h=pool[s,w].pop();slots.append([i,cp,off,w,s,h]);helpers[s,h]=(i,cp,off,w);off+=w + rem[i,cp]=rank-off + assert len(slots)==L*R and all(n==240 for n in counts.values()) and all(not xs for xs in pool.values()) + # U_q followed by exterior coordinate vectors is the parent's exact idle basis. + bases=[] + for q in c['ports']: + z=next(i for i in range(H) if not(q>>i&1));a=q^(1<>i&1 else 0) for i in order]+[1<>k&1:x^=rows[k] + if x: + k=x.bit_length()-1 + for j in rows: + if rows[j]>>k&1:rows[j]^=x + rows[k]=x + return tuple(rows[k] for k in sorted(rows,reverse=True)) +def adapter_check(word,ad): + h=word['h'];assert h==9 and ad['h']==h;full=tuple(1<0 + cur['L',r]=new;paid[width]+=1;continue + if tag=='center': + _,r,old,new,width=e;assert centers=={r} and cur['C',r]==old + assert width==abs(len(frames[new])-len(frames[old]))>0 + assert basis(frames[old]+frames[new]) in (basis(frames[old]),basis(frames[new])) + cur['C',r]=new;paid[width]+=1;continue + assert tag=='scalar';_,op,f=e;kind=op[0];t=tuple(op[1]);macros+=1;primitives+=2*bound(op) + if kind=='clear': + assert t[0]=='C';state[t]={};cur[t]=f;centers.discard(t[1]);continue + if t not in cur:assert t[0]=='C';cur[t]=f + assert cur[t]==f + if kind in ('add','copy'):s=tuple(op[2]);assert cur[s]==f,'scalar operands must share their actual current label' + if kind=='copy': + assert t[0]=='C' and not state.get(t);state[t]=dict(state[s]);centers.add(t[1]) + elif kind=='scale':state[t]={i:Q(op[2],op[3])*z for i,z in state[t].items()} + else: + assert kind=='add';q=Q(op[3],op[4]);assert t!=s + if t[0]=='C':centers.add(t[1]) + for i,z in list(state[s].items()): + a=state[t].get(i,Q(0))+q*z + if a:state[t][i]=a + else:state[t].pop(i,None) + for q in state[t].values():largest_num=max(largest_num,abs(q.numerator).bit_length());largest_den=max(largest_den,q.denominator.bit_length()) + wanted=[r for r in range(240,n) if word['start'][r]];assert pre==post==wanted and len(wanted)==79 + assert not centers and all(not row for k,row in state.items() if k[0]=='C') + assert Counter(endpoint)==Counter((direction,r) for direction in ('old_to_new','new_to_old') for r in range(240)) + assert [cur['L',r] for r in range(n)]==word['final'] + for r in range(n): + expected={r:Q(1)} + if back and r=240)];assert body==expected + checks[o]=replay(word,p,o=='backward') + assert set(checks)=={'forward','backward'} + rejected=[] + def reject(name,fn): + try:fn() + except (AssertionError,KeyError,IndexError,ValueError,ZeroDivisionError):rejected.append(name) + else:raise AssertionError('accepted '+name) + reject('omit first pre adapter',lambda:replay(word,ps['forward'][1:],False)) + reject('omit final post adapter',lambda:replay(word,ps['forward'][:-1],False)) + q=copy.deepcopy(ps['forward']);e=next(e for e in q if e[0]=='scalar' and e[1][0]=='add');e[2]=(e[2]+1)%len(word['frames']);reject('scalar at wrong frame',lambda:replay(word,q,False)) + q=copy.deepcopy(ps['forward']);q=[e for e in q if not(e[0]=='scalar' and e[1][0]=='add' and e[1][1][0]=='L' and e[1][1][1]>=240)];reject('omit helper scalar restoration',lambda:replay(word,q,False)) + f=next(k for k,r in ad['recipes'].items() if not r['identity_adapters']) + q=copy.deepcopy(ad);q['recipes'][f]['post']['phase']=(q['recipes'][f]['post']['phase']+1)%4;reject('wrong residual global phase',lambda:adapter_check(word,q)) + q=copy.deepcopy(ad);q['recipes'][f]['rank']+=1;reject('wrong residual width',lambda:adapter_check(word,q)) + q=copy.deepcopy(ad);q['recipes'][f]['pre']=q['recipes'][f]['post'];reject('wrong pre adapter order',lambda:adapter_check(word,q)) + result=dict(status='PASS_INDEPENDENT_COMPLEX_KERNEL_LOCAL_REALIZATION',nontrivial_entrance_frames=nontrivial,wrappers_per_call=158,helper_entry_recursive_calls=0,checks=checks,mutations_rejected=rejected,canonical_word_sha256=hashlib.sha256(blob(word)).hexdigest(),adapters_sha256=hashlib.sha256((out/'RESIDUAL-ADAPTERS.json').read_bytes()).hexdigest(),phase_recipes_sha256=hashlib.sha256((out/'CLIFFORD-RECIPES.json').read_bytes()).hexdigest()) + (out/'LOCAL-REVIEW.json').write_text(json.dumps(result,indent=2)+'\n');print(json.dumps(result),flush=True) +if __name__=='__main__':main(Path(sys.argv[1])) diff --git a/research/e8-combined/vendor/complex/phase_audit.py b/research/e8-combined/vendor/complex/phase_audit.py new file mode 100644 index 0000000000..b931725157 --- /dev/null +++ b/research/e8-combined/vendor/complex/phase_audit.py @@ -0,0 +1,127 @@ +"""Exact data phases, signed bridges, and the inherited finite schedule. +Adapted from Zhihao Chen PR377, icekylinx PR433 and DaysSky PR442. +Chafreaky with OpenAI Codex assistance. Apache-2.0. +""" +M,H,K,L,T,V,R=89,9,5,11,8,120,560 +W=2*K*V*T +def polynomial(terms): + linear=[0]*M;quadratic=[0]*M + for vector,sign in terms: + assert 0<=vector<1<>i&1:linear[i]=(linear[i]+sign)%4;quadratic[i]^=vector + return linear,quadratic + +def phases(ph,ports): + assert ph['m']==M and ph['ports']==V and len(ph['recipes'])==V + assert ph['terminal_omission_controls_rejected']==V and ph['cover_correction']['mandatory'] + checked=0 + for port,q in enumerate(ports): + rec=ph['recipes'][port];assert rec['port']==port and rec['q']==q and q.bit_count()%2==1 and q.bit_count()!=H + zero=next(i for i in range(H) if not q>>i&1);reflect=q^(1<>i)&1 else 0) for i in order]+[1<>i&1: + answer^=(q if q>>i&1 else 0) + for j in range(8): + if basis[j+1]>>i&1:answer^=1<<(off+j) + for j in range(8): + if vector>>(off+j)&1:answer^=basis[j+1] + mask=((1<>i)&1))%4==lb[i] for i in range(M));checked+=1 + expected=[] + for j in range(1,K): + for side in range(2):expected.extend([(-1,2*j-1,side),(2*j-1,2*j,side)]) + for j in range(K): + for side in range(2):expected.append((2*j+2,L-1,side)) + assert len(rec['idle_children'])==len(expected) + for child,(a,b,side) in zip(rec['idle_children'],expected): + axes=child['orthogonal_axes'];assert child['rank']==len(axes)==8*(b-a) + assert all(v in basis for v in axes) and len(set(axes))==len(axes) + la,qa=polynomial([(v,1) for v in axes]);lb,qb=polynomial([(v,-sgn) for v,sgn in desired(a,side)]+desired(b,side)) + shift=child['translation_after'];assert 0<=shift<1<>i)&1))%4==lb[i] for i in range(M));checked+=1 + la,qa=polynomial([(q,-1)]+desired(L-1,1));lb,qb=polynomial([(1<>i)&1))%4==lb[i] for i in range(M));checked+=1 + return checked + +def bridge_controls(recipe): + def matrix(skip): + rows=[[int(i==j) for j in range(10)] for i in range(10)];count=0 + def add(d,s,c):rows[d]=[x+c*y for x,y in zip(rows[d],rows[s])] + for e in recipe: + if e['kind']=='local': + p=e['pair'];add(2*p,2*p+1,-1) if e['reverse'] else add(2*p+1,2*p,1) + elif e['kind']=='bridge': + a,b,c=e['dst'],e['src'],e['coefficient'] + for d,s,sign in [(2*a,2*b,c),(2*b+1,2*a+1,-c)]: + if count!=skip:add(d,s,sign) + count+=1 + else: + for j in range(5):rows[2*j],rows[2*j+1]=rows[2*j+1],[-x for x in rows[2*j]] + assert count==24;return rows + ident=[[int(i==j) for j in range(10)] for i in range(10)] + assert matrix(-1)==ident + for skip in range(24):assert matrix(skip)!=ident + return list(range(24)) + +def schedule_check(t): + assert (t['m'],t['h'],t['stages'],t['replicas'],t['live'],t['physical'])==(M,H,L,T,W,10178) + assert t['cover']=='all matrices in O(89,2), in lexicographic row order' + assert t['bank_padding'] is None and t['private_namespace']==dict(centers=[W,W+16],tableau=[W+16,W+576],coefficient=[W+576,W+578]) + rows=[[int(i==j) for j in range(2*K)] for i in range(2*K)];levels=[-1]*K;last={};locals_=[];idle={};wins={};bridges=0;terminal=False;translated=False;corrected=False + def add(d,s,c):rows[d]=[x+c*y for x,y in zip(rows[d],rows[s])] + for position,e in enumerate(t['execution_schedule']): + assert not corrected;kind=e['kind'] + if kind=='local': + s,p,rev=e['stage'],e['pair'],e['reverse'];assert not terminal and s==len(locals_) and p==max(0,(s-1)//2) and rev==bool(s%2) + assert levels[p]==s-1;levels[p]=s;locals_.append((position,s,p));last[p]=position + add(2*p,2*p+1,-1) if rev else add(2*p+1,2*p,1) + elif kind=='bridge': + a,b,c=e['dst'],e['src'],e['coefficient'];assert 0<=a>p&1:x^=b[p] + if x: + p=x.bit_length()-1 + for q in b: + if b[q]>>p&1:b[q]^=x + b[p]=x + return tuple(b[p] for p in sorted(b,reverse=True)) +def dual(e): + e=list(e) + if e[0]=='add':e[1],e[2]=e[2],e[1];e[3]*=-1 + else:e[2],e[3]=e[3],e[2] + return e +def scalar(e,back): + e=dual(e) if back else list(e) + if e[0]=='add':return ['add',['L',e[1]],['L',e[2]],e[3],e[4]] + return ['scale',['L',e[1]],e[2],e[3]] +def primitive_bound(e): + if e[0] in ('clear','copy'):return 1 + q=Q(e[3],e[4]) if e[0]=='add' else Q(e[2],e[3]) + a,b=abs(q.numerator),q.denominator + assert b&(b-1)==0 + if e[0]=='scale': + assert a&(a-1)==0 + return abs(a.bit_length()-b.bit_length())+int(q<0) + # Exact binary Horner multiplication on a cleared private stream, repeated + # halving, signed accumulation into the target, then clear the private stream. + return 3+(a.bit_length()-1)+a.bit_count()+(b.bit_length()-1) + +def emit(back): + out=[];cur=c['start'].copy() + def event(e):out.append(e) + def scal(e,f):event(['scalar',e,f]) + event(['phase','zero_frame_precondition']) + for e in c['precondition']+c['compensation']: + regs=[e[1]]+([e[2]] if e[0]=='add' else []) + assert all(c['start'][r]==0 for r in regs) + scal(scalar(e,back),0) + event(['phase','entry_adapters']) + for r,f in enumerate(c['start']):event(['adapter','old_to_new',r,f]) + def climb(r,f,part): + old=cur[r] + if old==f:return + assert basis(frames[old]+frames[f])==tuple(frames[f]) + rank=len(frames[f])-len(frames[old]);assert rank>0 + event(['climb',part,r,old,f,rank]);cur[r]=f + for part in ('A','centers','B','final'): + event(['phase',part]) + if part in ('A','B'): + for e in c[part]: + regs=[e[1]]+([e[2]] if e[0]=='add' else []) + for r in regs:climb(r,e[-1],part) + scal(scalar(e,back),e[-1]) + elif part=='centers': + tl=c.get('target_levels',{}) + lv=lambda r:tl.get(str(r-v),tl.get(r-v,0)) + assert all(cur[r]==lv(r) for r in range(v,2*v)) + for k,r in enumerate(c['centers']): + cf=c['center_frames'][k];assert cur[r]==cf + terms=[e for e in c['cut'] if e[2]==r] + served=sorted({lv(e[1]) for e in terms},key=lambda L:-len(frames[L])) + path=[cf]+[L for L in served if L!=cf] # descending chain of frames + C=['C',k] + if not back: + scal(['clear',C],cf);scal(['copy',C,['L',r]],cf) + for a in range(len(path)): + if a>0:event(['center',k,path[a-1],path[a],len(frames[path[a-1]])-len(frames[path[a]])]) + for e in terms: + if lv(e[1])==path[a] or (a==0 and lv(e[1])==cf):scal(['add',['L',e[1]],C,e[3],e[4]],path[a]) + scal(['clear',C],path[-1]) + else: + scal(['clear',C],path[-1]) + for a in range(len(path)-1,-1,-1): + for e in terms: + if lv(e[1])==path[a] or (a==0 and lv(e[1])==cf):scal(['add',C,['L',e[1]],e[3],e[4]],path[a]) + if a>0:event(['center',k,path[a],path[a-1],len(frames[path[a-1]])-len(frames[path[a]])]) + scal(['add',['L',r],C,-1,1],cf);scal(['clear',C],cf) + else: + for r,f in enumerate(c['final']):climb(r,f,part) + event(['phase','exit_adapters']) + for r,f in enumerate(c['final']):event(['adapter','new_to_old',r,f]) + event(['phase','full_frame_cleanup']) + for e in c['cleanup']: + regs=[e[1]]+([e[2]] if e[0]=='add' else []) + assert all(c['final'][r]==1 for r in regs) + scal(scalar(e,back),1) + event(['phase','done']) + return out + +def check_local(events,back): + # Literal scalar replay of the emitted stream, including center lifetimes. + state={('L',r):{r:Q(1)} for r in range(n)};live=[];paid=Counter();prims=0;macros=0 + for e in events: + if e[0]=='climb':assert not live;paid[e[5]]+=1 + elif e[0]=='center':assert live==[e[1]];paid[e[4]]+=1 + elif e[0]=='scalar': + op=e[1];tag=op[0];t=tuple(op[1]);macros+=1;prims+=2*primitive_bound(op) + if tag=='clear': + state[t]={} + if t[0]=='C' and t[1] in live:live.remove(t[1]) + elif tag=='copy':state[t]=dict(state.get(tuple(op[2]),{}));live.append(t[1]) + elif tag=='scale':state[t]={j:Q(op[2],op[3])*x for j,x in state[t].items()} + else: + s=tuple(op[2]);q=Q(op[3],op[4]);row=state.setdefault(t,{}) + if t[0]=='C' and t[1] not in live:live.append(t[1]) + for j,x in list(state.get(s,{}).items()): + z=row.get(j,Q(0))+q*x + if z:row[j]=z + else:row.pop(j,None) + assert not live and all(not row for r,row in state.items() if r[0]=='C') + for r in range(n): + expected={r:Q(1)} + if back and r=2*v} +for e in word['precondition']:apply(e,dirty) +comp=[] +for r in range(v,2*v): + for j,q in sorted(dirty[r].items()):comp.append(['add',r,j,-q.numerator,q.denominator,[]]) + +cleanup=[inv(e) for e in reversed(word['A']+word['B']) if not v<=e[1]<2*v] +assert [e[:-1] for e in cleanup]==[e[:-1] for e in word['cleanup']] +program=word['precondition']+comp+main+cleanup +actual=ident() +for e in program:apply(e,actual) +expected=ident() +for t in range(v):expected[v+t][t]=Q(1) +assert actual==expected +print('PASS exact arbitrary dirt and restored sources/helpers',flush=True) +back=ident() +for e in program:apply(dual(e),back) +expected_back=ident() +for t in range(v):expected_back[t][v+t]=Q(-1) +assert back==expected_back +print('PASS exact inverse-transpose on every column',flush=True) +# Independent sparse vector controls avoid repeating a dense full replay. +def vector(es,x): + x=list(map(Q,x)) + for e in es: + if e[0]=='scale':x[e[1]]*=Q(e[2],e[3]) + else:x[e[1]]+=Q(e[3],e[4])*x[e[2]] + return x +sample=[((i*137+13)%101)-50 for i in range(n)] +want=vector(program,sample) +controls={ + 'missing_dirty_compensation':word['precondition']+main+cleanup, + 'missing_Y_inverse_basis':comp+main+cleanup, + 'missing_source_cleanup':word['precondition']+comp+main, + 'wrong_dual_event_order':[dual(e) for e in reversed(program)], +} +for name,es in controls.items(): + expected_sample=vector([dual(e) for e in program],sample) if name=='wrong_dual_event_order' else want + assert vector(es,sample)!=expected_sample,name + +# Orthogonal transvection and a port permutation bring the new geometry onto +# the already fixed 120-port routing family. Every incidence is transformed. +old=json.loads((Path(__file__).resolve().parents[2]/'data/complex/ports.json').read_text()) +def tau(x):return x^(43 if (x&43).bit_count()%2 else 0) +assert 43 .bit_count()%2==0 +assert set(map(tau,word['ports']))==set(old['ports']) +mapping={i:old['ports'].index(tau(q)) for i,q in enumerate(word['ports'])} +mapping.update({v+i:v+mapping[i] for i in range(v)}) +mapping.update({r:r for r in range(2*v,n)}) +def basis(vs): + b={} + for x in vs: + for k in sorted(b,reverse=True): + if x>>k&1:x^=b[k] + if x: + k=x.bit_length()-1 + for j in b: + if b[j]>>k&1:b[j]^=x + b[k]=x + return tuple(b[k] for k in sorted(b,reverse=True)) +def perp(x):return basis([z for z in range(1,512) if not (x&z).bit_count()%2]) +full=tuple(1<0 + edges.add((old,f));paid[delta]+=1;cur[r]=f +for part in ('A','B'): + if part=='B': + assert all(cur[r]==f for r,f in zip(can['centers'],can['center_frames'])) + assert all(cur[r]==can['target_levels'].get(r-v,0) for r in range(v,2*v)) + for r_c,f in zip(can['centers'],can['center_frames']): + # mass-neutral descent: cf -> served levels (descending) -> lowest served level + served={can['target_levels'].get(e[1]-v,0) for e in can['cut'] if e[2]==r_c} + o=f + for L in sorted(served,key=lambda L:-len(frames[L])): + assert basis(frames[L]+frames[o])==tuple(frames[o]),('centre frame must contain served level',r_c) + if L!=o:paid[len(frames[o])-len(frames[L])]+=1;edges.add((o,L));edges.add((L,o));o=L + if o==f:paid[0]+=0 + for e in can[part]: + rs=[e[1]]+([e[2]] if e[0]=='add' else []) + for r in rs:climb(r,e[-1]);incidences+=1 +for r,f in enumerate(can['final']):climb(r,f) +assert dict(paid)=={int(r):x for r,x in word['report']['local_profile'].items()} +assert sum(r*x for r,x in paid.items())==sum(int(r)*x for r,x in word['report']['local_profile'].items()) +can['local_profile']=dict(sorted(paid.items()));can['edges']=sorted(edges) +cp=OUT/'CANONICAL-WORD.json.gz';cp.write_bytes(gzip.compress(json.dumps(can,sort_keys=True,separators=(',',':')).encode(),mtime=0)) + +coeff=Counter(str(Q(e[3],e[4]) if e[0]=='add' else Q(e[2],e[3])) for e in program) +report={'status':'PASS_EXACT_SCALAR_AND_FRAME_AUDIT', + 'full_word_sha256':hashlib.sha256(p.read_bytes()).hexdigest(), + 'canonical_word_sha256':hashlib.sha256(cp.read_bytes()).hexdigest(), + 'live_columns_each_orientation':n,'arbitrary_helper_columns':can['R'], + 'all_live_source_and_helper_rows_restored':True,'all_target_rows_correct':True, + 'negative_controls_rejected':list(controls),'old_response_additions':len(comp), + 'complete_forward_scalar_operations':len(program),'coefficient_histogram':dict(coeff), + 'frames':len(frames),'nested_directed_edges':len(edges),'common_frame_incidences':incidences, + 'orthogonal_transport_vector':43,'transported_ports_exactly_match_fixed_routes':True, + 'local_profile':dict(sorted(paid.items())), + 'remaining':['exact phase and emitted local/global program','finite invoice and outer assembly'], + 'scope':'Exact arbitrary-input scalar maps and nested frames. Separate scripts check phases, physical programs and invoices.', + 'seconds':time.monotonic()-start} +(OUT/'SCALAR-FRAME-AUDIT.json').write_text(json.dumps(report,indent=2)+'\n') +print('PASS audit',report['seconds'],flush=True) diff --git a/research/e8-combined/verify.py b/research/e8-combined/verify.py new file mode 100644 index 0000000000..e7c0adfcd8 --- /dev/null +++ b/research/e8-combined/verify.py @@ -0,0 +1,58 @@ +"""Rebuild both finite suppliers and check their conditional composition.""" +import argparse +import hashlib +import json +import os +from pathlib import Path +import subprocess +import sys + +from check_outer import check as check_outer +from costs import compose + +HERE = Path(__file__).resolve().parent + + +def public_certificate(result): + return {key: value for key, value in result.items() + if key not in ('strict_outer_constraints', 'bootstrap')} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--output', type=Path, required=True) + parser.add_argument('--write-certificate', action='store_true') + args = parser.parse_args() + if not __debug__: + parser.error('Run Python without -O or PYTHONOPTIMIZE.') + out = args.output.resolve() + if out == HERE or HERE in out.parents: + parser.error('--output must be outside the source package.') + if out.exists() and any(out.iterdir()): + parser.error('--output must name an empty or new directory.') + out.mkdir(parents=True, exist_ok=True) + env = dict(os.environ, PYTHONDONTWRITEBYTECODE='1', PYTHONINTMAXSTRDIGITS='0') + env.pop('PYTHONOPTIMIZE', None) + for name in ('bit', 'complex'): + subprocess.run([sys.executable, '-B', str(HERE/'vendor'/name/'replay.py'), + str(out/name)], cwd=out, env=env, check=True) + result = compose(out/'bit', out/'complex/complex') + result['independent_outer_check'] = check_outer(result) + result['input_sha256'] = { + str(path.relative_to(HERE)): hashlib.sha256(path.read_bytes()).hexdigest() + for path in sorted((HERE/'data').rglob('*')) if path.is_file() + } + (out/'RESULT.json').write_text(json.dumps(result, indent=2)+'\n') + certificate = public_certificate(result) + if args.write_certificate: + (HERE/'certificate.json').write_text(json.dumps(certificate, indent=2)+'\n') + else: + expected = json.loads((HERE/'certificate.json').read_text()) + assert certificate == expected, 'The fresh certificate differs.' + print(json.dumps({key: result[key] for key in + ('status', 'kappa_decimal', 'gain_percent', 'binding_component')}, + indent=2)) + + +if __name__ == '__main__': + main()