From 92e76796eedff77465abd64c80a4320e529fd987 Mon Sep 17 00:00:00 2001 From: Matarener Date: Wed, 21 Oct 2026 20:56:41 +0300 Subject: [PATCH 1/2] Audit #4100 COMPLEX.md common cover, defect correction and stock arithmetic (no new kappa) Co-Authored-By: Claude Opus 5.5 (1M context) --- research/complex-cover-lift-audit/README.md | 155 +++++++ .../complex-cover-lift-audit/SOURCES.json | 54 +++ research/complex-cover-lift-audit/TASK.json | 74 +++ research/complex-cover-lift-audit/VERIFY.json | 34 ++ .../complex-cover-lift-audit/test_verify.py | 61 +++ research/complex-cover-lift-audit/verify.py | 426 ++++++++++++++++++ 6 files changed, 804 insertions(+) create mode 100644 research/complex-cover-lift-audit/README.md create mode 100644 research/complex-cover-lift-audit/SOURCES.json create mode 100644 research/complex-cover-lift-audit/TASK.json create mode 100644 research/complex-cover-lift-audit/VERIFY.json create mode 100644 research/complex-cover-lift-audit/test_verify.py create mode 100644 research/complex-cover-lift-audit/verify.py diff --git a/research/complex-cover-lift-audit/README.md b/research/complex-cover-lift-audit/README.md new file mode 100644 index 0000000000..282db5de87 --- /dev/null +++ b/research/complex-cover-lift-audit/README.md @@ -0,0 +1,155 @@ +# Audit of #4100 COMPLEX.md: common cover, defect correction and stock arithmetic + +**Audit with a positive scoped result; no new κ.** The selected κ is unchanged. + +Pinned #4100 head: `337d04939571a637aeab54a0f58f54fde811663a` +(`research/unconditional-batched-crt/COMPLEX.md`). The provider words are the +literal PR4088 inputs `research/staged544-mixed-fourth-entry/inputs/{THREE,FOUR}-{base,extra}.json.gz`. + +The #4311 coverage map lists "COMPLEX.md's arbitrary-f lift and complete-cover +execution" with no audit. Its free-word lift row, however, shows #4184 +(ToikY) as positive: an exact formal cancellation on all four PR4088 +programs. This package therefore audits the common-cover algebra: the cover +size, the terminal `X_delta` defect correction, the `H0` factorization and +the depth and row-stock arithmetic. It only cross-checks the lift, with +phase-carrying representations. The complex moment and root are already +certified by #4171 and are not redone. +The reading of the rank-r transition (one `C⊗rf` child versus f copies) is +#4375's subject and is not redone either. + +## Results + +| Statement in COMPLEX.md | Outcome | +|---|---| +| `Gamma = 2^1296 prod_{i=1}^{36}(2^(2i)-1) = |O(73,2)|` | Holds (proof below). Brute-force counts of `O(n,2)` for n = 1, 3, 5, 7 are 1, 6, 720, 1,451,520 = `|Sp(n-1,2)|` (n = 7 with `--full`, about 8 minutes). | +| `P_g C_all P_g^-1 = C_all X_delta`, `delta_i = (wt(row_i g)-1)/2 mod 2` | Holds for orthogonal g, with or without a translation (proof below). Checked on all of `O(3,2)` and `O(5,2)` and on 400 random elements of `O(73,2)` × 200 vectors each. It fails for non-orthogonal g, and `delta = 0` fails whenever `delta != 0`. | +| `H0 = ((1-i)/2) D C D`, tensor diagonals `i^wt`, `((1-i)/2)^h` split by parity | Holds exactly (Gaussian rationals), tensor powers h ≤ 6. `H0` is `[[1,1],[1,-1]]/2`. | +| `D(e) = 1 + D(48 floor(e/73))`; every child decreases D; two levels halve e | Holds (proof below; scanned for e ≤ 2·10^5, and ≤ 2·10^6 in the development run). | +| Row stock padded to `R = ceil(2^q/M) M`, `M = (W Gamma)^D(h)`, factor below two | Factor below two holds. **Presentational correction:** `R > 2^q` at every tested h (73 … 10^30), so the padded range needs `q+1` reserved bits (or a radix-R field), not `q`. Only a constant changes. | +| Arbitrary-f lift: each warp generator `G -> G⊗f`, each scalar kept as a scalar, constant monomial phase `i^a -> i^(fa)` | Already audited by #4184 (exact pullback, all 5,784 output functionals). The supplementary check below agrees: there are no complex scalars, and `i^a` monomial representations pass for f = 1, 2, 3. | + +## Supplementary lift check (complements #4184) + +#4184 proves the formal free-word cancellation exactly and specializes it +over F101 and the rationals. This section adds two things: the phase/scalar +separation that COMPLEX.md's `i^a -> i^(fa)` sentence relies on, and +execution with phase-carrying monomial generators. + +**What the certificate is.** In PR4088's exact interpreter +(`vendor/audit_core.py`) a register value is a dict +`{(input, reduced word): Fraction}`. Warps are free generators, reduced only by +`g g^-1 = 1`. Every ADD, SCALE and correction coefficient is a rational. The +four words have 17,428–17,429 scalars each, all real dyadic rationals (about +9,040 negative), 72 warp generators and 36 initial corrections. The event kinds +are only add, scale and warp. So the certificate cancels in `Q[F_72]` and has +no complex phase coefficient at all. A phase `i^a` can only sit inside a warp +generator, and it is tensored with that generator to give `i^(fa)`, as +COMPLEX.md says. A sign or SCALE is a field coefficient and stays scalar. + +**Why that suffices.** `w -> rho(w)^(⊗f)` is a group homomorphism of the free +group for any assignment `rho` of the generators. Extended linearly, it is an +algebra homomorphism of `Q[F_72]`, and every identity certified in `Q[F_72]` +survives. Corrections `c G_word x` stay separate terms, giving `G_word^(⊗f)` +and not `(G_word - I)^(⊗f)`. The dual orientation uses `D_k = K_k^(-T)`, and +`(K^(⊗f))^(-T) = (K^(-T))^(⊗f)`. + +**Execution check.** `verify.py` executes each word end to end with its own +interpreter. The order is corrections, wrapper, A, cut, B with the warps, +restore and cleanup, read from the pinned format, with nothing imported. Each +generator becomes `M^(⊗f)` for a random 4×4 monomial matrix M with entries +`i^a`, for f = 1, 2, 3. Inputs and the 91 dirty private buffers are random +complex vectors. In all 24 runs (4 words × 3 widths × forward/dual), the +contract holds to relative error ≤ 1.7·10^-14: + +- targets become `x_t + x_(t-V)` (forward), or sources `x_r - x_(r+V)` (dual); +- every other live register returns; +- every private buffer is restored, with no leakage. + +**Controls** (`test_verify.py`). Reading every scalar sign as a phase symbol +breaks the lift. So does replacing each `G^-1` by an unrelated matrix. + +## Proofs + +**Cover size.** Let n be odd and `j` the all-one vector. For every x, +`x·x = Σx_i = j·x`. So an isometry g gives `j·(gx) = j·x`, i.e. `g^T j = j`. +Since `g^T` is also orthogonal, `g j = j`. Because `j·j = 1`, +`F_2^n = ⟨j⟩ ⊕ j^⊥`, and on `j^⊥` (the even-weight vectors) the form is +alternating and nondegenerate. Restriction is a bijection +`O(n,2) → Sp(n-1,2)`: it is injective since g fixes j, and surjective since +any symplectic map extended by `j ↦ j` is an isometry. At n = 73 this gives +`2^(36^2) prod(2^(2i)-1)`. + +**Defect correction.** Entrywise, `C_all[x,y] = ((1+i)/2)^n (-i)^wt(x⊕y)`. +With `P_g|x⟩ = |gx⟩`, the identity is equivalent to +`wt(g^-1 z) ≡ wt(z ⊕ delta) (mod 4)` for all z. Since `g^-1 = g^T`, write +`g^-1 z = Σ_k z_k c_k` with `c_k` the rows of g. Then + + wt(g^-1 z) ≡ Σ_k z_k wt(c_k) - 2 Σ_{k 2^q` unless +M divides `2^q`. M is divisible by odd primes (for example +`2^2-1 = 3` divides Gamma), so that never happens for D ≥ 1. + +**Height and time (given #4171).** +- `A(e) ≤ A(48f) + Sf + E` with `e ≥ 73f` gives `A(e) ≤ αe` once + `α ≥ (S+E)/25` and α covers the leaves. #4178's incoming height `t0` is a + separate reported defect and is not re-examined here. +- Internal nodes cost `O(V e^(1-a2) polylog p) ≤ O(V e^tau polylog p)`, since + `a2 = 0.0017333948 > a_eff`. +- A leaf of width `l ≤ h^eta` costs `l = l^(1-b) l^b ≤ l^(1-b) h^(eta b)` + per volume. The `(1-b)` moment then bounds the leaves by + `O(V h^(1-b+eta b))`, and `(1-eta) b > q` gives the stated + `O(V h^(1-q) polylog p)`. + +## Not covered + +- Whether each native warp realization (a 512-point permutation plus its + PHASES data) is exactly a monomial `i^a` matrix, so that the representation + checked here is the executed one. See `TASK.json`. +- The rank-r child reading (#4375), and the physical gather/execute schedule + and work-slot count of the cover. + +## Validation + +```sh +python3.12 -B research/complex-cover-lift-audit/verify.py +python3.12 -B research/complex-cover-lift-audit/test_verify.py +python3.12 scripts/research_package.py --package research/complex-cover-lift-audit +``` + +The finite checks support the written proofs above; they do not replace them. + +## Credit + +The construction is by Cinna Davis (#4100, PR4088). The formal lift audit is +#4184 (ToikY). The exact free-word +interpreter whose format is read here is by Sagar Thakrar (in PR4088's +vendor). The coverage map is #4311 (Ryanson Jonathan), the complex moment +certificate is #4171 (petalas), and the rank-r reading is #4375 (unpaidmoon). +Prepared for Mark (Matarener) with substantial Claude Code assistance. +Apache-2.0. + +## Open next questions + +Is every literal PR4088 warp (a 512-point permutation plus its PHASES data) +exactly a monomial matrix with entries `i^a`, so that the representation +checked here is the one executed? First step: read PR4088's +`inputs/DATA-PHASES.json` and `evidence/*-PHASES-*.json` and check that each +warp's phase table depends only on the input point and takes values in Z/4. +See `TASK.json`. diff --git a/research/complex-cover-lift-audit/SOURCES.json b/research/complex-cover-lift-audit/SOURCES.json new file mode 100644 index 0000000000..c0c29b8d20 --- /dev/null +++ b/research/complex-cover-lift-audit/SOURCES.json @@ -0,0 +1,54 @@ +{ + "schema_version": 1, + "base_commit": "12fa8c5c844be21bfefb38a19503fbd867a11244", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "64bfc5af6709ed9811171e0a2108f05e1219cb65", + "sha256": "352a6184713b8843d96fd2c2071eb7aeaa655906b7c51d45ad444912666c8a96" + }, + { + "path": "research/unconditional-batched-crt/COMPLEX.md", + "usage": "input", + "git_blob": "c3be56fbfdb4fb29c1ace88cbcdfa7475fb6e343", + "sha256": "853e1295850862752e4f854aa9e8b28f9ca6eaa9306e2af110b7b77526d1b5e1" + }, + { + "path": "research/staged544-mixed-fourth-entry/vendor/audit_core.py", + "usage": "input", + "git_blob": "8b5e1d5f2a106402f036b63028ecef31a4e4c462", + "sha256": "888679ca8502cdcb100420fe5382a052529a494bf76cb332928b86e62612b951" + }, + { + "path": "research/staged544-mixed-fourth-entry/inputs/THREE-base.json.gz", + "usage": "input", + "git_blob": "137793e275870db2161048405017b83dcc1824ee", + "sha256": "df31495cff95a1e512da398f52841c6b5ade29067869b3d68b89d756a5641112" + }, + { + "path": "research/staged544-mixed-fourth-entry/inputs/THREE-extra.json.gz", + "usage": "input", + "git_blob": "7cce921b20dc0504cea954ab3297c5b55a9468dc", + "sha256": "9a28f7ef91938c0866e408eb06e03eb5f8e727a00b44eb936ddd5ed48704bd4c" + }, + { + "path": "research/staged544-mixed-fourth-entry/inputs/FOUR-base.json.gz", + "usage": "input", + "git_blob": "65957e5ca322049d985f23fdc0bd8da07ffa4c2a", + "sha256": "aecaddba48fdff6353a6511c3623346b05aa607e30103fb016604a2b1025ce95" + }, + { + "path": "research/staged544-mixed-fourth-entry/inputs/FOUR-extra.json.gz", + "usage": "input", + "git_blob": "1f3239c30e9343cf4e34b4371fcbeebb94a19011", + "sha256": "615093190aa5479034bb8acdd8925d7a910e082b84dec7df84b459b62421235a" + } + ] +} diff --git a/research/complex-cover-lift-audit/TASK.json b/research/complex-cover-lift-audit/TASK.json new file mode 100644 index 0000000000..6314299966 --- /dev/null +++ b/research/complex-cover-lift-audit/TASK.json @@ -0,0 +1,74 @@ +{ + "schema_version": 1, + "task_id": "uniform-transfer-audit", + "priority_revision": 7, + "base_commit": "12fa8c5c844be21bfefb38a19503fbd867a11244", + "original_card": { + "id": "uniform-transfer-audit", + "question": "Does one quantified step of the proposed #4100 all-size construction hold at its actual caller?", + "starting_points": [ + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "research/unconditional-batched-crt/README.md" + ], + "methods": [ + "Prove one missing implication with explicit quantified hypotheses.", + "Find an exact counterexample at the claimed interface boundary." + ], + "acceptance_gate": "Identify the proposition and what would change downstream; do not equate a finite replay with a universal proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read PROOF.md and AUDIT.md in #4100. Select one distinct obligation: CRT total repair, native/free-algebra lifting, precision/conditioning, or complete fixed-tape cost. This is an author-submitted proof, not an accepted unconditional theorem.", + "scope": "Source-binding orientation only; no scientific replay, theorem acceptance or supplier admission. Budget any heavy replay separately." + }, + "first_experiment": "Check live handoffs; name one proposition, its caller, quantified domain and dependency closure. Independently prove the implication or exhibit a precise gap/counterexample. Prioritize CRT.md total repair or COMPLEX.md free-algebra lift only if unclaimed. Stop at the chosen obligation; do not substitute finite samples or root arithmetic for an all-size proof, or launch the complete package by default.", + "bottleneck_link": "Finite supplier improvements are useful only under the retained transfer obligations.", + "allowed_variations": [ + "One CRT repair, native lift, precision/conditioning or tape-cost proposition, with its exact caller." + ], + "scope_change_triggers": [ + "Replacing a quantified obligation with another finite smoke test.", + "Treating archive intake, an author PASS receipt or a finite composed fixture as discharge of the universal hypotheses." + ], + "overlap_terms": [ + "uniform transfer", + "all-size", + "precision", + "4100", + "unconditional-batched-crt" + ], + "existing_checks": [ + { + "scope": "PR #4100: proposed unconditional construction and finite checks, without independent acceptance.", + "evidence": "research/unconditional-batched-crt/README.md", + "remaining": "Independent proof audit of one caller-bound all-size implication; all other premises remain explicit.", + "status": "author-checked", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "refined", + "actual_scope": "One #4100 obligation group: COMPLEX.md's common cover (Gamma=|O(73,2)|, the X_delta defect correction, H0 factorization, depth and row-stock arithmetic), plus a supplementary phase-representation check of the arbitrary-f lift already audited by #4184.", + "scope_change_reason": "The #4311 coverage map lists COMPLEX.md's complete-cover execution with no audit; its free-word lift is covered by #4184, so this package audits the cover algebra and only cross-checks the lift.", + "bottleneck_link": "Side result for the #4100 admission audit: confirms one all-size premise group of the proposed unconditional exponent; it does not move the selected frontier.", + "budget_minutes": 90, + "stop_rule": "Stop after the cover algebra and the lift of the literal PR4088 words are proved or refuted; do not re-derive the complex moment (#4171) or the rank-r child reading (#4375).", + "outcome": "completed", + "evidence": "Written proofs in README.md; verify.py binds sources and runs the finite checks and the four-word lift; test_verify.py has rejecting controls.", + "author": "Mark (Matarener)", + "ai_assistance": "Prepared with substantial Claude Code (Claude) assistance.", + "open_questions": [ + { + "question": "Is the free-word certificate of PR4088 a faithful model of the native warp realizations, i.e. is each literal warp (512-point permutation plus its PHASES data) exactly a monomial matrix with entries i^a, so that the monomial lift checked here is the one executed?", + "why_it_matters": "The lift is proved for every group representation; it applies to the physical program only if each native warp is such a representation of its free symbol.", + "first_step": "Read inputs/DATA-PHASES.json and evidence/*-PHASES-*.json of PR4088 and check that every warp's phase table is a function of the input point only (monomial), with values in Z/4.", + "blocked_by": "none" + } + ] +} diff --git a/research/complex-cover-lift-audit/VERIFY.json b/research/complex-cover-lift-audit/VERIFY.json new file mode 100644 index 0000000000..0a3c3bd0cd --- /dev/null +++ b/research/complex-cover-lift-audit/VERIFY.json @@ -0,0 +1,34 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/unconditional-batched-crt/COMPLEX.md", + "research/staged544-mixed-fourth-entry/vendor/audit_core.py", + "research/staged544-mixed-fourth-entry/inputs/THREE-base.json.gz", + "research/staged544-mixed-fourth-entry/inputs/THREE-extra.json.gz", + "research/staged544-mixed-fourth-entry/inputs/FOUR-base.json.gz", + "research/staged544-mixed-fourth-entry/inputs/FOUR-extra.json.gz" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Bind the quoted COMPLEX.md statements and PR4088's free-word semantics; |O(n,2)|=|Sp(n-1,2)| for n=1,3,5 (n=7 with --full); the X_delta defect identity on all of O(3,2), O(5,2) and on random O(73,2) elements; H0=((1-i)/2)DCD exactly; depth recursion, halving and row-stock padding; the arbitrary-f lift of all four literal PR4088 words with monomial i^a generators, f=1,2,3, forward and dual." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/test_verify.py" + ], + "timeout_seconds": 60, + "checks": "Rejecting controls: non-orthogonal g and delta=0 fail the defect identity; the padded row range exceeds q bits; reading scalar signs as phase symbols or using non-inverse G^-1 breaks the lift; the lift passes at f=1 in the dual orientation." + } + ] +} diff --git a/research/complex-cover-lift-audit/test_verify.py b/research/complex-cover-lift-audit/test_verify.py new file mode 100644 index 0000000000..183cb2d88a --- /dev/null +++ b/research/complex-cover-lift-audit/test_verify.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +"""Rejecting controls for verify.py.""" +import random +import unittest +from fractions import Fraction as Q + +import verify as v + + +class Controls(unittest.TestCase): + def test_non_orthogonal_breaks_defect_identity(self): + rng = random.Random(1) + fails = 0 + for _ in range(40): + g = [rng.randrange(1, 32) for _ in range(5)] + if v.is_orthogonal(g, 5): + continue + # only invertible g give a permutation P_g + if len({v.mat_vec(g, x) for x in range(32)}) < 32: + continue + fails += not v.defect_holds(g, 5) + self.assertGreater(fails, 0) + for g in v.orthogonal_matrices(5): + if v.delta_of(list(g)): + break + rows = list(g) + ginv = v.transpose(rows, 5) + self.assertFalse(all(v.popcount(v.mat_vec(ginv, z)) % 4 == v.popcount(z) % 4 + for z in range(32)), "delta = 0 must fail when delta != 0") + + def test_padded_range_exceeds_q_bits(self): + M = (322560 * v.sp_order(36)) ** v.depth(73) + q = (M - 1).bit_length() + R = -(-2 ** q // M) * M + self.assertGreater(R, 2 ** q) + + def test_signs_read_as_phases_break_lift(self): + w = v.load_word("THREE-base") + rng = random.Random(2) + rep = {k: v.random_mono(4, rng).tensor_power(2) for k in range(1, len(w["warps"]) + 1)} + e = v.run_word(w, rep, False, rng, 16, scalar_hook=lambda q: abs(q)) + self.assertGreater(e, 1.0) + + def test_non_representation_breaks_lift(self): + w = v.load_word("FOUR-base") + rng = random.Random(3) + gens = range(1, len(w["warps"]) + 1) + rep = {k: v.random_mono(4, rng).tensor_power(2) for k in gens} + bad = {k: v.random_mono(4, rng).tensor_power(2) for k in gens} + e = v.run_word(w, rep, False, rng, 16, inv=bad) + self.assertGreater(e, 1e-3) + + def test_lift_passes_at_f1(self): + w = v.load_word("FOUR-extra") + rng = random.Random(4) + rep = {k: v.random_mono(4, rng) for k in range(1, len(w["warps"]) + 1)} + self.assertLess(v.run_word(w, rep, True, rng, 4), 1e-9) + + +if __name__ == "__main__": + unittest.main() diff --git a/research/complex-cover-lift-audit/verify.py b/research/complex-cover-lift-audit/verify.py new file mode 100644 index 0000000000..765ef211c3 --- /dev/null +++ b/research/complex-cover-lift-audit/verify.py @@ -0,0 +1,426 @@ +#!/usr/bin/env python3 +"""Audit #4100 COMPLEX.md: common cover, defect correction and arbitrary-f lift. + +Propositions checked (COMPLEX.md at #4100 head 337d049): +1. Gamma = |O(73,2)| = 2^1296 prod_{i=1}^{36}(2^(2i)-1); +2. P_g C_all P_g^-1 = C_all X_delta, delta_i = (wt(row_i g)-1)/2 mod 2, + for orthogonal g (with or without a translation); +3. H0 = ((1-i)/2) D C D, D = diag(1,i), and its tensor form; +4. the depth recursion D(e), two-level halving and the row-stock padding; +5. the arbitrary-f lift on the four literal PR4088 words: every warp generator + G -> M^(tensor f) and every scalar kept as a scalar preserves the forward + and dual endpoint contracts. + +The word format and endpoint contract are read from PR4088's +vendor/audit_core.py; nothing is imported from it. Standard library only. +Run with --full to add the n = 7 brute-force count of O(7,2) (about 8 min). +""" +import gzip +import json +import random +import sys +from fractions import Fraction as Q +from pathlib import Path + +PKG = Path(__file__).resolve().parent +ROOT = PKG.parents[1] +CRT = ROOT / "research" / "unconditional-batched-crt" +MIXED = ROOT / "research" / "staged544-mixed-fourth-entry" +WORDS = ["THREE-base", "THREE-extra", "FOUR-base", "FOUR-extra"] +V, N = 112, 704 + + +def popcount(x): + return bin(x).count("1") + + +# --------------------------------------------------------------- sources +def check_sources(): + cx = (CRT / "COMPLEX.md").read_text(encoding="utf-8") + for needle in ["Set W=322560 and Gamma=2^1296 product_{i=1}^{36}(2^(2i)-1).", + "This is |O(73,2)|: the all-one vector has norm1", + "Define D(e)=0 for e<73 and D(e)=1+D(48floor(e/73)) otherwise.", + "Reserve q=ceil(log2((W Gamma)^D(h))) row bits. Pad their complete range", + "delta_i=(wt(row_i(g))-1)/2 mod2. The identity", + "P_g C_all P_g^-1=C_all X_delta follows by expanding Hamming weight modulo4.", + "H0=((1-i)/2) D C D. Tensor diagonals are phases from address weight modulo4.", + "Evaluate each unary generator G at G tensor f, and every scalar coefficient", + "becomes i^(fa). A role SCALE or bridge sign stays scalar.", + "{1:8060060,2:2310120,3:751813,4:327210,5:66425,8:25920,48:138492}"]: + assert needle in cx, needle + core = (MIXED / "vendor" / "audit_core.py").read_text(encoding="utf-8") + for needle in ["# Exact free-operator semantics. A value is a dict {(input, word): Fraction};", + "# word is a reduced tuple of signed operator ids (leftmost = applied last).", + "return word[1:] if word and word[0] == -op else (op,) + word", + "V, N, H = 112, 704, 9"]: + assert needle in core, needle + + +# --------------------------------------------------------- 1. cover size +def sp_order(m): + out = 2 ** (m * m) + for i in range(1, m + 1): + out *= 2 ** (2 * i) - 1 + return out + + +def orthogonal_matrices(n): + """All g in GL(n,2) with g g^T = I, as tuples of row bitmasks.""" + odd = [v for v in range(1, 2 ** n) if popcount(v) % 2] + + def rec(rows): + if len(rows) == n: + yield tuple(rows) + return + for v in odd: + if all(popcount(v & r) % 2 == 0 for r in rows): + yield from rec(rows + [v]) + + yield from rec([]) + + +def check_cover(full=False): + out = {} + for n in (1, 3, 5) + ((7,) if full else ()): + count = 0 + for g in orthogonal_matrices(n): + count += 1 + assert all(popcount(r) % 2 for r in g) # g fixes the all-one vector + assert count == sp_order((n - 1) // 2), n + out[n] = count + gamma = sp_order(36) + return out, gamma + + +# ---------------------------------------------------- 2. defect identity +def mat_vec(rows, x): + y = 0 + for i, r in enumerate(rows): + y |= (popcount(r & x) & 1) << i + return y + + +def transpose(rows, n): + return [sum(((rows[i] >> j) & 1) << i for i in range(n)) for j in range(n)] + + +def delta_of(rows): + return sum((((popcount(r) - 1) // 2) % 2) << i for i, r in enumerate(rows)) + + +def defect_holds(rows, n): + """Entrywise: C_all[x,y] = ((1+i)/2)^n (-i)^wt(x^y), P_g sends x to g x. + + (P_g C_all P_g^-1)[x,y] = C_all[g^-1 x, g^-1 y] and (C_all X_delta)[x,y] = + C_all[x, y^delta], so the identity is wt(g^-1 z) = wt(z ^ delta) mod 4 for + every z. A translation x -> x+v cancels in x^y. + """ + ginv = transpose(rows, n) + d = delta_of(rows) + return all(popcount(mat_vec(ginv, z)) % 4 == popcount(z ^ d) % 4 for z in range(2 ** n)) + + +def random_orthogonal(n, rng, steps=60): + """Products of coordinate permutations and transvections x + (x.u)u, wt(u) even.""" + rows = [1 << i for i in range(n)] + for _ in range(steps): + if rng.random() < 0.3: + perm = list(range(n)) + rng.shuffle(perm) + rows = [rows[perm[i]] for i in range(n)] + else: + u = rng.getrandbits(n) + if popcount(u) % 2: + u ^= 1 + ug = 0 + for i in range(n): + if (u >> i) & 1: + ug ^= rows[i] + rows = [r ^ ug if (u >> i) & 1 else r for i, r in enumerate(rows)] + return rows + + +def is_orthogonal(rows, n): + return all(popcount(rows[i] & rows[j]) % 2 == (i == j) for i in range(n) for j in range(n)) + + +def check_defect(): + for n in (1, 3, 5): + for g in orthogonal_matrices(n): + assert defect_holds(list(g), n), (n, g) + rng = random.Random(4100) + nonzero = 0 + for _ in range(400): + g = random_orthogonal(73, rng) + assert is_orthogonal(g, 73) + ginv, d = transpose(g, 73), delta_of(g) + nonzero += d != 0 + assert popcount(d) % 4 == 0 + for _ in range(200): + z = rng.getrandbits(73) + assert popcount(mat_vec(ginv, z)) % 4 == popcount(z ^ d) % 4 + assert nonzero > 300 + return nonzero + + +# --------------------------------------------------------- 3. H0 identity +class G: + """Exact Gaussian rationals.""" + + def __init__(self, re, im=0): + self.re, self.im = Q(re), Q(im) + + def __mul__(self, o): + return G(self.re * o.re - self.im * o.im, self.re * o.im + self.im * o.re) + + def __eq__(self, o): + return self.re == o.re and self.im == o.im + + +def check_h0(): + I = G(0, 1) + c_same, c_diff = G(Q(1, 2), Q(1, 2)), G(Q(1, 2), Q(-1, 2)) + scal = G(Q(1, 2), Q(-1, 2)) + for h in range(1, 7): + s = G(1) + for _ in range(h): + s = s * scal + for x in range(2 ** h): + for y in range(2 ** h): + c = G(1) + for k in range(h): + c = c * (c_same if ((x ^ y) >> k) & 1 == 0 else c_diff) + ph = G(1) + for _ in range(popcount(x) + popcount(y)): + ph = ph * I + rhs = s * ph * c + lhs = G(Q((-1) ** popcount(x & y), 2 ** h)) + assert lhs == rhs, (h, x, y) + z = G(1) + for h in range(1, 200): + z = z * G(1, -1) + w = G(1) + for _ in range(h // 2): + w = w * G(0, -2) + if h % 2: + w = w * G(1, -1) + assert z == w + + +# ------------------------------------------------- 4. depth and stock +def depth(e): + d = 0 + while e >= 73: + e, d = 48 * (e // 73), d + 1 + return d + + +def check_depth_and_stock(limit=200_000): + prev = 0 + for e in range(1, limit + 1): + d = depth(e) + assert d >= prev + prev = d + if e >= 73: + f = e // 73 + assert all(depth(r * f) <= d - 1 for r in (1, 2, 3, 4, 5, 8, 48)) + assert 2 * 48 * ((48 * f) // 73) <= e + M1 = 322560 * sp_order(36) + rows = {} + for h in (73, 10 ** 3, 10 ** 6, 10 ** 12, 10 ** 30): + M = M1 ** depth(h) + q = (M - 1).bit_length() + R = -(-2 ** q // M) * M + assert 2 ** q <= R < 2 ** (q + 1) and R % M == 0 + rows[h] = {"D": depth(h), "q": q, "R_over_2q": float(Q(R, 2 ** q)), + "fits_in_q_bits": R <= 2 ** q} + return rows + + +# ------------------------------------------------------ 5. arbitrary-f lift +def program(w): + """Literal executed sequence: corrections, wrapper, A, cut, B+warps, restore, cleanup.""" + items = [("corr", c["target"], c["source"], tuple(c["operator_word"]), + Q(c["coefficient"])) for c in w["initial_corrections"]] + items += w["precondition"] + w["compensation"] + w["A"] + w["cut"] + at = {} + for k, rec in enumerate(w["warps"], 1): + at.setdefault(rec[0], []).append(["warp", rec[1], k]) + for p in range(len(w["B"]) + 1): + items += at.get(p, []) + if p < len(w["B"]): + items.append(w["B"][p]) + return items + w["restore"] + w["cleanup"] + + +PHASE = [1, 1j, -1, -1j] + + +class Mono: + """Monomial matrix: column x goes to row perm[x] with phase i^ph[x].""" + + def __init__(self, perm, ph): + self.perm, self.ph = perm, ph + + def apply(self, v): + out = [0j] * len(v) + for x, a in enumerate(v): + out[self.perm[x]] = PHASE[self.ph[x]] * a + return out + + def inverse(self): + perm, ph = [0] * len(self.perm), [0] * len(self.perm) + for x, y in enumerate(self.perm): + perm[y], ph[y] = x, (-self.ph[x]) % 4 + return Mono(perm, ph) + + def transpose(self): + inv = self.inverse() + return Mono(inv.perm, [(-p) % 4 for p in inv.ph]) + + def tensor_power(self, f): + d, perm, ph = len(self.perm), [0], [0] + for _ in range(f): + perm = [p * d + self.perm[x] for p in perm for x in range(d)] + ph = [(a + self.ph[x]) % 4 for a in ph for x in range(d)] + return Mono(perm, ph) + + +def random_mono(d, rng): + perm = list(range(d)) + rng.shuffle(perm) + return Mono(perm, [rng.randrange(4) for _ in range(d)]) + + +def run_word(w, rep, dual, rng, dim, scalar_hook=None, inv=None): + """Execute w with warp k -> rep[k]; return the relative contract error.""" + removed = set(w["removed"]) + live = [r for r in range(N) if r not in removed] + restored = sorted(map(int, w["helper_final"])) + rnd = lambda: [complex(rng.gauss(0, 1), rng.gauss(0, 1)) for _ in range(dim)] + x = {r: rnd() for r in live} + for c in restored: + x[c + N] = rnd() + reg = {r: list(v) for r, v in x.items()} + inv = inv or {k: m.inverse() for k, m in rep.items()} + tr = {k: m.transpose() for k, m in rep.items()} + trinv = {k: m.transpose() for k, m in inv.items()} + + def op(k): # dual symbol D_k = K_k^(-T) + if dual: + return trinv[k] if k > 0 else tr[-k] + return rep[k] if k > 0 else inv[-k] + + def axpy(t, s, q): + reg[t] = [a + q * b for a, b in zip(reg[t], s)] + + for g in program(w): + kind = g[0] + if kind == "add": + t, s, q = g[1], g[2], Q(g[3], g[4]) + q = scalar_hook(q) if scalar_hook else q + if dual: + t, s, q = s, t, -q + axpy(t, reg[s], complex(q)) + elif kind == "scale": + q = Q(g[2], g[3]) + q = scalar_hook(q) if scalar_hook else q + if dual: + q = 1 / q + reg[g[1]] = [complex(q) * a for a in reg[g[1]]] + elif kind == "warp": + reg[g[1]] = op(g[2]).apply(reg[g[1]]) + elif kind == "corr": + _, t, s, word, c = g + if dual: + v = reg[t] + for o in word: # (G_w1 ... G_wn)^T x = G_wn^T ... G_w1^T x + v = (tr[o] if o > 0 else trinv[-o]).apply(v) + axpy(s, v, -complex(c)) + else: + v = reg[s] + for o in reversed(word): + v = (rep[o] if o > 0 else inv[-o]).apply(v) + axpy(t, v, complex(c)) + else: + raise AssertionError(f"unknown primitive {g!r}") + + scale = max(abs(a) for v in x.values() for a in v) + err = 0.0 + for r in live: + expect = list(x[r]) + if dual and r < V: + expect = [a - b for a, b in zip(expect, x[r + V])] + if not dual and V <= r < 2 * V: + expect = [a + b for a, b in zip(expect, x[r - V])] + err = max(err, max(abs(a - b) for a, b in zip(reg[r], expect))) + for c in restored: + err = max(err, max(abs(a - b) for a, b in zip(reg[c + N], x[c + N]))) + return err / scale + + +def load_word(name): + with gzip.open(MIXED / "inputs" / f"{name}.json.gz") as fh: + return json.load(fh) + + +def word_scalars(w): + parts = ("precondition", "compensation", "A", "cut", "B", "restore", "cleanup") + qs = [Q(g[3], g[4]) for p in parts for g in w[p] if g[0] == "add"] + qs += [Q(g[2], g[3]) for p in parts for g in w[p] if g[0] == "scale"] + qs += [Q(c["coefficient"]) for c in w["initial_corrections"]] + kinds = {g[0] for p in parts for g in w[p]} + return qs, kinds + + +def check_lift(fs=(1, 2, 3), d=4): + rng = random.Random(4088) + out = {} + for name in WORDS: + w = load_word(name) + qs, kinds = word_scalars(w) + assert kinds <= {"add", "scale", "warp"}, kinds + assert all(q.denominator & (q.denominator - 1) == 0 for q in qs) + gens = range(1, len(w["warps"]) + 1) + assert all(0 < abs(o) <= len(w["warps"]) for c in w["initial_corrections"] + for o in c["operator_word"]) + errs = {} + for f in fs: + for dual in (False, True): + rep = {k: random_mono(d, rng).tensor_power(f) for k in gens} + e = run_word(w, rep, dual, rng, d ** f) + assert e < 1e-9, (name, f, dual, e) + errs[f"f{f}_{'dual' if dual else 'forward'}"] = e + out[name] = {"events": len(program(w)), "scalars": len(qs), + "negative_scalars": sum(q < 0 for q in qs), + "warp_generators": len(w["warps"]), "max_error": max(errs.values())} + return out + + +def main(): + full = "--full" in sys.argv + check_sources() + print("PASS source binding: COMPLEX.md statements and PR4088 free-word semantics") + counts, gamma = check_cover(full) + print(f"PASS cover size: |O(n,2)| = |Sp(n-1,2)| for n in {sorted(counts)} " + f"({counts}); Gamma has {gamma.bit_length()} bits") + nz = check_defect() + print(f"PASS defect identity: all of O(3,2), O(5,2); n = 73 on 400 random g " + f"x 200 z ({nz} with delta != 0, wt(delta) = 0 mod 4 throughout)") + check_h0() + print("PASS H0 = ((1-i)/2) D C D exactly, tensor powers h <= 6, scalar parity split h < 200") + stock = check_depth_and_stock() + print("PASS depth: D monotone, every child rank drops D, two levels halve (e <= 2e5)") + for h, row in stock.items(): + print(f" h={h}: D={row['D']}, q={row['q']}, R/2^q={row['R_over_2q']:.4f}, " + f"fits in q bits: {row['fits_in_q_bits']}") + lift = check_lift() + for name, row in lift.items(): + print(f"PASS lift {name}: {row['events']} events, {row['warp_generators']} warp " + f"generators, {row['scalars']} real dyadic scalars; f = 1,2,3 forward and " + f"dual, max relative error {row['max_error']:.1e}") + print("PASS_COMPLEX_COVER_LIFT_AUDIT") + + +if __name__ == "__main__": + main() From 5d7169599ecb6167cc3e1d17dd374968c225c307 Mon Sep 17 00:00:00 2001 From: Matarener Date: Wed, 21 Oct 2026 21:20:35 +0300 Subject: [PATCH 2/2] Show every native PR4088 warp is a Z4-monomial matrix (answers the native-realization question) Co-Authored-By: Claude Opus 5.5 (1M context) --- research/complex-cover-lift-audit/README.md | 42 ++++- .../complex-cover-lift-audit/SOURCES.json | 24 +++ research/complex-cover-lift-audit/TASK.json | 8 +- research/complex-cover-lift-audit/VERIFY.json | 19 ++- .../complex-cover-lift-audit/native_warps.py | 156 ++++++++++++++++++ 5 files changed, 234 insertions(+), 15 deletions(-) create mode 100644 research/complex-cover-lift-audit/native_warps.py diff --git a/research/complex-cover-lift-audit/README.md b/research/complex-cover-lift-audit/README.md index 282db5de87..e5bb415fad 100644 --- a/research/complex-cover-lift-audit/README.md +++ b/research/complex-cover-lift-audit/README.md @@ -26,6 +26,7 @@ The reading of the rank-r transition (one `C⊗rf` child versus f copies) is | `H0 = ((1-i)/2) D C D`, tensor diagonals `i^wt`, `((1-i)/2)^h` split by parity | Holds exactly (Gaussian rationals), tensor powers h ≤ 6. `H0` is `[[1,1],[1,-1]]/2`. | | `D(e) = 1 + D(48 floor(e/73))`; every child decreases D; two levels halve e | Holds (proof below; scanned for e ≤ 2·10^5, and ≤ 2·10^6 in the development run). | | Row stock padded to `R = ceil(2^q/M) M`, `M = (W Gamma)^D(h)`, factor below two | Factor below two holds. **Presentational correction:** `R > 2^q` at every tested h (73 … 10^30), so the padded range needs `q+1` reserved bits (or a radix-R field), not `q`. Only a constant changes. | +| Each native warp is a monomial `i^a` matrix | Holds: all 720 warp edge classes of the four words (`native_warps.py`). | | Arbitrary-f lift: each warp generator `G -> G⊗f`, each scalar kept as a scalar, constant monomial phase `i^a -> i^(fa)` | Already audited by #4184 (exact pullback, all 5,784 output functionals). The supplementary check below agrees: there are no complex scalars, and `i^a` monomial representations pass for f = 1, 2, 3. | ## Supplementary lift check (complements #4184) @@ -117,11 +118,35 @@ M divides `2^q`. M is divisible by odd primes (for example `O(V h^(1-b+eta b))`, and `(1-eta) b > q` gives the stated `O(V h^(1-q) polylog p)`. +## Native warps are Z4 monomials + +`native_warps.py` (numpy) answers the native-realization question that #4184 left open. A warp +event of operator k, moving its lender from frame U to frame E, executes +`Z = T_E K_G^(±1) T_U^-1` on the lender's 9 hosted axes. Here `K_G` is the +phase-corrected permutation `|x⟩ → i^(q(Gx)) |Gx⟩`, with q the Z4 form of +`M = I + G^-T G^-1`, and `T_U = K_c (C on |U| axes) K_c^-1`. These +definitions are read from PR4088's `bw_gauss.py`; the script imports nothing +from it. + +- **Binding.** Each canonical word (`evidence/{NATIVE,THREE}-CANONICAL-*`, where + NATIVE is FOUR by its PHASES hash) matches its literal input word: the same + 72 warps by B position and G columns, and the same frame spans. Only the + register labels are compacted. +- **Result.** All 180 warp edge classes of each of the four words, 720 in + total, give a matrix with exactly one entry per row and column, each in + `{1, i, -1, -i}`, global phase included. So every native warp is a monomial + `i^a` matrix. Its `⊗f` lift is again monomial, with phase `i^(Σa)`, which is + COMPLEX.md's `i^a → i^(fa)` statement. This independently re-derives + PR4088's own `PASS_WARP_RECIPES_EXACT_ON_ALL_512_COLUMNS` receipt. +- **Controls.** The plain permutation `P_G` without the quadratic phase is + not monomial on any of 40 tested classes, and swapping the frames breaks 86 + classes. So the phase correction in `K_G` is essential. + ## Not covered -- Whether each native warp realization (a 512-point permutation plus its - PHASES data) is exactly a monomial `i^a` matrix, so that the representation - checked here is the executed one. See `TASK.json`. +- The composition of these local recipes into the global emitted program, + which PR4088's PHASES receipts list as a separate obligation (see + `TASK.json`). - The rank-r child reading (#4375), and the physical gather/execute schedule and work-slot count of the cover. @@ -130,6 +155,7 @@ M divides `2^q`. M is divisible by odd primes (for example ```sh python3.12 -B research/complex-cover-lift-audit/verify.py python3.12 -B research/complex-cover-lift-audit/test_verify.py +python3.12 -B research/complex-cover-lift-audit/native_warps.py # numpy, about 2.5 min python3.12 scripts/research_package.py --package research/complex-cover-lift-audit ``` @@ -147,9 +173,7 @@ Apache-2.0. ## Open next questions -Is every literal PR4088 warp (a 512-point permutation plus its PHASES data) -exactly a monomial matrix with entries `i^a`, so that the representation -checked here is the one executed? First step: read PR4088's -`inputs/DATA-PHASES.json` and `evidence/*-PHASES-*.json` and check that each -warp's phase table depends only on the input point and takes values in Z/4. -See `TASK.json`. +Does each PR4088 word's global emitted program compose its local frame, +centre and warp recipes into exactly the free-word shadow? First step: +regenerate LOCAL-PROGRAMS for one word and check that the frame labels between +consecutive events cancel exactly. See `TASK.json`. diff --git a/research/complex-cover-lift-audit/SOURCES.json b/research/complex-cover-lift-audit/SOURCES.json index c0c29b8d20..6930599703 100644 --- a/research/complex-cover-lift-audit/SOURCES.json +++ b/research/complex-cover-lift-audit/SOURCES.json @@ -49,6 +49,30 @@ "usage": "input", "git_blob": "1f3239c30e9343cf4e34b4371fcbeebb94a19011", "sha256": "615093190aa5479034bb8acdd8925d7a910e082b84dec7df84b459b62421235a" + }, + { + "path": "research/staged544-mixed-fourth-entry/evidence/NATIVE-CANONICAL-base.json.gz", + "usage": "input", + "git_blob": "77ee265be3cc15d76054c023d825578d9c62fa5c", + "sha256": "bff67890d0d350646d11f45aa1b098d6a415b1850b4982e8a05b4c146d247eda" + }, + { + "path": "research/staged544-mixed-fourth-entry/evidence/NATIVE-CANONICAL-extra.json.gz", + "usage": "input", + "git_blob": "bc6433bbf5c355d53eec218448fa49c5f4d45346", + "sha256": "e0c473d62127a09cb3cbf451564dbdd19c0c10f1674dab0575e65251aa5e1e3c" + }, + { + "path": "research/staged544-mixed-fourth-entry/evidence/THREE-CANONICAL-base.json.gz", + "usage": "input", + "git_blob": "40d74e5638d08ccb0b8270e6c47843cc45762c72", + "sha256": "f07fae1011160b53e2df1f3135465db1277a093319de2a1da52d648f00a39542" + }, + { + "path": "research/staged544-mixed-fourth-entry/evidence/THREE-CANONICAL-extra.json.gz", + "usage": "input", + "git_blob": "2af11b77b0d1f9ed54584fb1ec63f808d08071e6", + "sha256": "882271d70602354cbada8d77f479703ccc6c47e689e8ccd91f9e4c87de0f4379" } ] } diff --git a/research/complex-cover-lift-audit/TASK.json b/research/complex-cover-lift-audit/TASK.json index 6314299966..dc842fb273 100644 --- a/research/complex-cover-lift-audit/TASK.json +++ b/research/complex-cover-lift-audit/TASK.json @@ -60,14 +60,14 @@ "budget_minutes": 90, "stop_rule": "Stop after the cover algebra and the lift of the literal PR4088 words are proved or refuted; do not re-derive the complex moment (#4171) or the rank-r child reading (#4375).", "outcome": "completed", - "evidence": "Written proofs in README.md; verify.py binds sources and runs the finite checks and the four-word lift; test_verify.py has rejecting controls.", + "evidence": "Written proofs in README.md; verify.py binds sources and runs the finite cover checks and the supplementary lift; native_warps.py shows every native warp edge class of the four PR4088 words is a Z4-monomial matrix; test_verify.py has rejecting controls.", "author": "Mark (Matarener)", "ai_assistance": "Prepared with substantial Claude Code (Claude) assistance.", "open_questions": [ { - "question": "Is the free-word certificate of PR4088 a faithful model of the native warp realizations, i.e. is each literal warp (512-point permutation plus its PHASES data) exactly a monomial matrix with entries i^a, so that the monomial lift checked here is the one executed?", - "why_it_matters": "The lift is proved for every group representation; it applies to the physical program only if each native warp is such a representation of its free symbol.", - "first_step": "Read inputs/DATA-PHASES.json and evidence/*-PHASES-*.json of PR4088 and check that every warp's phase table is a function of the input point only (monomial), with values in Z/4.", + "question": "Does the expanded global emitted program of each PR4088 word compose its local frame, centre and warp recipes into exactly the free-word shadow (the scalar-interface integration that PR4088's PHASES receipts list as a separate obligation)?", + "why_it_matters": "The lift proof needs each executed event to be the representation of its free symbol in context; local recipes are now checked, their global composition is not.", + "first_step": "Regenerate LOCAL-PROGRAMS for one word with PR4088's emitter and check that the frame labels between consecutive events cancel exactly (global phase included).", "blocked_by": "none" } ] diff --git a/research/complex-cover-lift-audit/VERIFY.json b/research/complex-cover-lift-audit/VERIFY.json index 0a3c3bd0cd..4f5b2266fc 100644 --- a/research/complex-cover-lift-audit/VERIFY.json +++ b/research/complex-cover-lift-audit/VERIFY.json @@ -2,14 +2,20 @@ "schema_version": 1, "status": "ready", "python": "3.12", - "requirements": [], + "requirements": [ + "numpy==2.2.6" + ], "inputs": [ "research/unconditional-batched-crt/COMPLEX.md", "research/staged544-mixed-fourth-entry/vendor/audit_core.py", "research/staged544-mixed-fourth-entry/inputs/THREE-base.json.gz", "research/staged544-mixed-fourth-entry/inputs/THREE-extra.json.gz", "research/staged544-mixed-fourth-entry/inputs/FOUR-base.json.gz", - "research/staged544-mixed-fourth-entry/inputs/FOUR-extra.json.gz" + "research/staged544-mixed-fourth-entry/inputs/FOUR-extra.json.gz", + "research/staged544-mixed-fourth-entry/evidence/NATIVE-CANONICAL-base.json.gz", + "research/staged544-mixed-fourth-entry/evidence/NATIVE-CANONICAL-extra.json.gz", + "research/staged544-mixed-fourth-entry/evidence/THREE-CANONICAL-base.json.gz", + "research/staged544-mixed-fourth-entry/evidence/THREE-CANONICAL-extra.json.gz" ], "commands": [ { @@ -29,6 +35,15 @@ ], "timeout_seconds": 60, "checks": "Rejecting controls: non-orthogonal g and delta=0 fail the defect identity; the padded row range exceeds q bits; reading scalar signs as phase symbols or using non-inverse G^-1 breaks the lift; the lift passes at f=1 in the dual orientation." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/native_warps.py" + ], + "timeout_seconds": 600, + "checks": "Bind the four canonical words to the literal input words (B position, G columns, frame spans); every native warp edge class T_E K_G^(+-1) T_U^-1 (720 classes) is a Z4-monomial matrix, global phase included; controls: plain permutation P_G and swapped frames fail." } ] } diff --git a/research/complex-cover-lift-audit/native_warps.py b/research/complex-cover-lift-audit/native_warps.py new file mode 100644 index 0000000000..83353330b5 --- /dev/null +++ b/research/complex-cover-lift-audit/native_warps.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python3 +"""Every native warp of the four PR4088 words is a Z4-monomial matrix. + +A warp event of operator k moving a lender from frame U to frame E executes +Z = T_E K_G^(+-1) T_U^-1 on the lender's 9 hosted axes. Here K_G is the +phase-corrected permutation |x> -> i^(q(Gx)) |Gx>, with q the Z4 form of +M = I + G^-T G^-1, and T_U = K_c (C on |U| axes) K_c^-1 with K_c the change of +basis onto U. These definitions are read from PR4088's native bw_gauss.py; +nothing is imported from it. + +For every warp edge class (sign, op, from, to) of the four canonical words, +the script checks that Z has exactly one nonzero entry per row and column, +each in {1, i, -1, -i} (global phase included). It also binds each +canonical word to its literal input word by B position, G columns and frame +spans. Controls: the plain permutation P_G in place of K_G is not monomial +for any tested class, and some swapped-frame products are not monomial. +""" +import gzip +import json +from pathlib import Path + +import numpy as np + +PKG = Path(__file__).resolve().parent +MIXED = PKG.parents[1] / "research" / "staged544-mixed-fourth-entry" +PAIRS = [("FOUR-base", "NATIVE-CANONICAL-base"), ("FOUR-extra", "NATIVE-CANONICAL-extra"), + ("THREE-base", "THREE-CANONICAL-base"), ("THREE-extra", "THREE-CANONICAL-extra")] +H = 9 +NN = 1 << H +C1 = np.array([[1 + 1j, 1 - 1j], [1 - 1j, 1 + 1j]]) / 2 +UNITS = np.array([1, 1j, -1, -1j]) + + +def lin(cols, x): + out = 0 + for i, c in enumerate(cols): + if x >> i & 1: + out ^= c + return out + + +def inverse_cols(cols): + back = [0] * NN + for x in range(NN): + back[lin(cols, x)] = x + assert sorted(back) == list(range(NN)), "singular G" + return [back[1 << i] for i in range(H)] + + +def f2rank(vs): + basis = {} + for x in vs: + while x: + t = x.bit_length() + if t not in basis: + basis[t] = x + break + x ^= basis[t] + return len(basis) + + +def extend(xs): + out = list(xs) + for i in range(H): + if f2rank(out + [1 << i]) > len(out): + out.append(1 << i) + assert len(out) == H + return out + + +def change(src, dst): + a, b = extend(src), extend(dst) + return [lin(b, x) for x in inverse_cols(a)] + + +def K_of(cols, phases=True): + gi = inverse_cols(cols) + git = [sum(((gi[j] >> i) & 1) << j for j in range(H)) for i in range(H)] + M = [(1 << j) ^ lin(git, gi[j]) for j in range(H)] + K = np.zeros((NN, NN), complex) + for x in range(NN): + y = lin(cols, x) + q = sum(((M[i] >> i) & 1) * (y >> i & 1) for i in range(H)) + q += 2 * sum(((M[j] >> i) & 1) * (y >> i & 1) * (y >> j & 1) + for i in range(H) for j in range(i + 1, H)) + K[y, x] = 1j ** (q % 4) if phases else 1 + return K + + +def C_on(k): + m = np.array([[1]], complex) + for j in range(H): + m = np.kron(C1 if j < k else np.eye(2), m) + return m + + +def frame_op(U): + Kc = K_of(change([1 << i for i in range(len(U))], U)) + return Kc @ C_on(len(U)) @ Kc.conj().T + + +def is_z4_monomial(Z): + nz = np.abs(Z) > 1e-9 + if not (np.all(nz.sum(0) == 1) and np.all(nz.sum(1) == 1)): + return False + return bool(np.all(np.min(np.abs(Z[nz][:, None] - UNITS[None, :]), axis=1) < 1e-9)) + + +def span(b): + s = {0} + for x in b: + s |= {t ^ x for t in s} + return frozenset(s) + + +def main(): + total = 0 + for lit, can in PAIRS: + with gzip.open(MIXED / "inputs" / f"{lit}.json.gz") as fh: + a = json.load(fh) + with gzip.open(MIXED / "evidence" / f"{can}.json.gz") as fh: + c = json.load(fh) + A = {(w[0], tuple(w[2])): (span(w[3]), span(w[4])) for w in a["warps"]} + Cn = {(w["B_pos"], tuple(w["G_columns"])): + (span(c["frames"][w["from_frame"]]), span(c["frames"][w["to_frame"]])) + for w in c["warps"]} + assert A == Cn and len(a["warps"]) == len(c["warps"]) == 72, lit + G = {w["op"]: w["G_columns"] for w in c["warps"]} + T = {} + ok = 0 + for sign, op, f0, f1 in c["warp_edges"]: + for f in (f0, f1): + if f not in T: + T[f] = frame_op(c["frames"][f]) + K = K_of(G[op]) + K = K if sign > 0 else K.conj().T + ok += is_z4_monomial(T[f1] @ K @ T[f0].conj().T) + assert ok == len(c["warp_edges"]), (can, ok) + total += ok + print(f"PASS {lit} ({can}): bound to the literal word; {ok} warp classes, " + f"all Z4-monomial", flush=True) + if lit == "FOUR-base": + bad_perm = sum(not is_z4_monomial(T[f1] @ (K_of(G[op], False) if s > 0 else + K_of(G[op], False).T) @ T[f0].conj().T) + for s, op, f0, f1 in c["warp_edges"][:40]) + bad_swap = sum(not is_z4_monomial(T[f0] @ (K_of(G[op]) if s > 0 else + K_of(G[op]).conj().T) @ T[f1].conj().T) + for s, op, f0, f1 in c["warp_edges"] if f0 != f1) + assert bad_perm == 40 and bad_swap > 0 + print(f"PASS controls: plain permutation P_G non-monomial on 40/40 classes; " + f"swapped frames non-monomial on {bad_swap} classes", flush=True) + print(f"PASS_NATIVE_WARPS_Z4_MONOMIAL {total}") + + +if __name__ == "__main__": + main()