From 9ba652f6e10ff296ca467fc69a24246c9a5b91af Mon Sep 17 00:00:00 2001 From: Nick Petalas Date: Tue, 27 Oct 2026 21:16:43 +0000 Subject: [PATCH] feat(research): prove prime-exponent group labels cost one rank unit each Answers the four-or-more-target question of research/group-subproduct-cover for groups of prime exponent, over every field, with a representation rank cut and exact finite corroboration. No new kappa. --- research/prime-exponent-rank-cut/PROOF.md | 141 ++++++ research/prime-exponent-rank-cut/README.md | 109 ++++ research/prime-exponent-rank-cut/SOURCES.json | 42 ++ research/prime-exponent-rank-cut/TASK.json | 83 ++++ research/prime-exponent-rank-cut/VERIFY.json | 34 ++ research/prime-exponent-rank-cut/verify.py | 467 ++++++++++++++++++ 6 files changed, 876 insertions(+) create mode 100644 research/prime-exponent-rank-cut/PROOF.md create mode 100644 research/prime-exponent-rank-cut/README.md create mode 100644 research/prime-exponent-rank-cut/SOURCES.json create mode 100644 research/prime-exponent-rank-cut/TASK.json create mode 100644 research/prime-exponent-rank-cut/VERIFY.json create mode 100644 research/prime-exponent-rank-cut/verify.py diff --git a/research/prime-exponent-rank-cut/PROOF.md b/research/prime-exponent-rank-cut/PROOF.md new file mode 100644 index 0000000000..6f1b9d8069 --- /dev/null +++ b/research/prime-exponent-rank-cut/PROOF.md @@ -0,0 +1,141 @@ +# A representation rank cut for diagonal group-label targets + +Nick Petalas. Apache-2.0. + +## 1. Model + +Use the model of Ali Romman's `research/group-subproduct-cover` (PR #5394), +section 1, unchanged. K is any field and G any group with identity e. A +circuit has finitely many registers. Free operations are fixed scalar +matrices over K. They may be rectangular or singular, and they may copy, +clear or discard registers. A paid gate on R registers is + + D(N,g) = (I_R - N)[e] + N[g], N in M_R(K). + +The rank-charged cost of a word is sum_j rank(N_j). The rank-one count is +the number of gates when every N_j has rank at most one. The idempotent +condition is allowed but not used. The target is the data block +diag([t_1],...,[t_d]). Repeated entries are allowed. For the lower bound, +workspace may change arbitrarily, with clean or dirty initial values. + +## 2. The cut + +For a matrix representation rho: G -> GL_m(K') over an extension field +K' of K, put + + r_rho(g) = rank_{K'}(rho(g) - I_m). + +**Theorem 1.** Let C_0 D(N_1,g_1) C_1 ... D(N_k,g_k) C_k realize the +data block diag([t_1],...,[t_d]). Then + + sum_i r_rho(t_i) <= sum_j rank(N_j) * r_rho(g_j). + +*Proof.* Extend rho linearly to an algebra homomorphism K[G] -> M_m(K'). +Apply it entrywise to a matrix over K[G]. This map is multiplicative on +block matrices and commutes with taking the data-row/data-column submatrix. +A scalar matrix C becomes C (x) I_m. The gate becomes + + I (x) I_m + N_j (x) (rho(g_j) - I_m). + +Its second term has rank rank(N_j) * r_rho(g_j). Write A_j for the image of +C_j and B_j for that second term. Then the image of the circuit is +A_0 (I + B_1) A_1 ... (I + B_k) A_k. Expand it one gate at a time, +replacing (I + B_j) by I from the left: + + image - A_0 A_1 ... A_k = sum_j A_0 ... A_{j-1} B_j A_j (I+B_{j+1}) ... A_k, + +where gates 1..j-1 have already been replaced by I. Each summand has rank +at most rank(B_j). Rank is subadditive, so the left side has rank at most +sum_j rank(N_j) r_rho(g_j). + +Apply the augmentation map [g] -> 1 entrywise. Every gate maps to I, so the +circuit maps to C_0 C_1 ... C_k. The target maps to I_d. Its data block is +therefore I_d, and the data block of A_0 ... A_k is I_d (x) I_m. The data +block of the image is diag(rho(t_1),...,rho(t_d)). The data block of the +difference has rank sum_i r_rho(t_i). A submatrix has rank at most the +rank of the whole matrix. QED. + +The telescoping step is not new. This account's PR #5202 +(`research/order21-normal-tariff`) used it for one F2 representation of +the order-21 group, and `research/cut58-separable-query-floor` uses a +character twist. Theorem 1 states it for an arbitrary representation, an +arbitrary field and projectors of any rank. + +## 3. The regular representation over K itself + +Let G be finite and let rho be the left regular permutation representation +over K. A permutation matrix P has (P - I)v = 0 exactly when v is constant +on every cycle. In every characteristic the kernel has dimension equal to +the number of cycles. Left multiplication by g has |G|/ord(g) cycles, each +of length ord(g). Hence + + r_reg(g) = |G| (1 - 1/ord(g)) over every field. + +**Corollary 2.** Over every field, for every finite group and alphabet, + + sum_i (1 - 1/ord(t_i)) <= sum_j rank(N_j) (1 - 1/ord(g_j)). + +In particular, the rank-charged cost is at least +sum_i (1 - 1/ord(t_i)) / (1 - 1/M), where M is the largest order of a paid +label. + +## 4. Prime exponent + +**Corollary 3.** Let G have prime exponent p: every nonidentity element +has order p. G may be nonabelian. Let K be any field and take any +finite clean or dirty scalar workspace. Any diagonal target with d +nonidentity entries, repetitions allowed and identity entries ignored, +has + + rank-charged cost >= d, rank-one count >= d. + +If every target label is allowed, d direct rank-one coordinate gates attain +both bounds. The exact rank-one count and the exact rank-charged cost are +then both d. + +*Proof.* Identity entries and identity labels contribute zero to both sides +of Corollary 2. Every other term is 1 - 1/p. Divide by 1 - 1/p. The direct +word puts N = E_ii with label t_i on data role i and touches nothing else. QED. + +**Answer for these groups.** By Ali Romman's cover theorem, the +arbitrary-rank unit-cost count is the cover cost c_L(T). In a group of prime +exponent, with every target label allowed, the rank-one count is d. +Thus the rank-one count exceeds the relaxed cover cost exactly when +c_L(T) < d. The gap can be exponential. Take G = (C_p)^n and all +p^n - 1 nonidentity targets. Any word of length k has at most 2^k ordered +subproducts. Words covering all of G exist, for example each basis +vector repeated p-1 times, so c(T) <= n(p-1). For p = 2 the cover cost is +exactly n and the rank-one count is 2^n - 1. The verifier computes the +exact cover costs 2, 3 and 4 for (C2)^2, (C2)^3 and (C3)^2, with rank-one +counts 3, 7 and 8. It also realizes the length-four basis cover of all 15 +nonidentity labels of (C2)^4 over F2. + +The nonabelian Heisenberg group of order p^3 (p odd) has exponent p, so +Corollary 3 applies to it over every field. The verifier checks the order-27 +case. + +## 5. Relation to predecessors + +Wentao Li's `research/elementary-abelian-diagonal-minimum` proves the exact +rank-one count t for F2[(C2)^k], using a graded image in m/m^2. Corollary 3 +contains that statement. It also adds every field, every prime p, +nonabelian groups of prime exponent, repeated and rank-charged projectors, +rectangular or singular free maps, and arbitrary workspace changes. Ali +Romman's corollary for three distinct labels holds in every group. Corollary +3 recovers it only for groups of prime exponent. Its two-call rank argument +is not reused here. + +## 6. Scope limits + +Corollary 2 is the regular cut only. It is weaker when the labels have mixed +orders. For three copies of a^2 in C4 it gives only 2 < 3; a different +argument is needed there. In Q8, targets {i,j,k,-1} still get the bound 4. +Other representations can do better. A faithful character of C_m over an +extension of K with char K not dividing m gives r = 1 at every nonidentity +element. Theorem 1 then gives rank-charged cost >= d for cyclic groups in +those characteristics. That remark is proved by the same theorem but has no +separate finite check here. + +The proved bill is an abstract gate count in the relaxed model. Physical +group gates, scalar maps, source reads, precision, recursive children, +hosting and cleanup are not priced. No complete kappa calculation changes. diff --git a/research/prime-exponent-rank-cut/README.md b/research/prime-exponent-rank-cut/README.md new file mode 100644 index 0000000000..a23cf9be5d --- /dev/null +++ b/research/prime-exponent-rank-cut/README.md @@ -0,0 +1,109 @@ +# Prime-exponent group labels cost one rank unit per target + +This contribution was produced by Nick Petalas. Apache-2.0. + +**Scoped proof with exact finite corroboration; no new κ.** This uses Ali +Romman's relaxed group-gate model ([PR #5394](https://github.com/CrocSwap/integer-mult-bounds/pull/5394), +`research/group-subproduct-cover`), unchanged. Let G be a group of prime +exponent and K any field. Any diagonal target with d nonidentity entries, +repetitions allowed, needs total projector rank at least d. Arbitrary +finite clean or dirty scalar workspace and singular or rectangular free +maps do not change this. The rank-one count is therefore exactly d whenever +every target label is allowed. + +This answers that package's Open next question for these groups. The +rank-one count exceeds the relaxed subproduct-cover cost exactly when the +cover is shorter than d. The gap can be exponential: in (C2)^n, the +2^n − 1 nonidentity labels have cover cost n and rank-one count 2^n − 1. + +## Method + +[PROOF.md](PROOF.md) proves a representation rank cut. For any +representation ρ over an extension field, + + Σ_i rank(ρ(t_i) − I) ≤ Σ_j rank(N_j) · rank(ρ(g_j) − I). + +The left regular permutation representation over K itself has +rank(ρ(g) − I) = |G|(1 − 1/ord g) in every characteristic. In a group of +prime exponent every nonidentity label gives the same value, and the +bound becomes d. + +## Evidence + +[verify.py](verify.py) uses only the standard library. It is read-only and +uses no network or Git. It checks: + +- the regular defect rank formula for all 405 element/field pairs in + (C2)^2, (C2)^3, (C2)^4, (C3)^2, C5, the order-27 Heisenberg group, C4 and + Q8, over Q, F2, F3, F5 and F7; +- 206 seeded random circuits with rectangular and singular free maps, + projectors of every rank, and any labels. Each circuit checks the + augmentation identity and multiplicativity of the entrywise regular image, + and that the cut holds; +- exact cover costs 2, 3 and 4 for all nonidentity targets of (C2)^2, (C2)^3 + and (C3)^2. For those groups, over Q, F2 and F3, it checks the attaining + cover word and the direct d-gate word, both with an untouched dirty role. + It also checks the length-4 basis cover of all 15 labels in (C2)^4 over F2; +- five controls: a dropped cover letter, the C4 case where the regular cut + alone is weaker, Q8 with mixed orders, a zero identity defect, and a + rank-two projector. + +The finite checks corroborate the written proof. They do not replace its +all-group, all-field argument. + +## Reproduce + +From the repository root, with CPython 3.12 (here +`/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12`; any CPython 3.12 +works): + +```sh +python3.12 -I -B -W error research/prime-exponent-rank-cut/verify.py +python3.12 -I -O -B -W error research/prime-exponent-rank-cut/verify.py +python3.12 -B scripts/research_package.py --package research/prime-exponent-rank-cut +python3.12 -B scripts/check_research_commit.py --package research/prime-exponent-rank-cut --check-source-history +``` + +The verifier ends with +`PASS_PRIME_EXPONENT_RANK_CUT regular_checks=405 random_circuits=206 separations=4 controls=5 no_new_kappa`. +It runs in under a second locally. No receipt file is written. The printed +JSON summary is the run record. + +## Limits + +This is an abstract count in an optimistic relaxed model. It does not price +physical group gates, scalar maps, source reads, precision, recursive +children, hosting or cleanup. The selected frontier and κ are unchanged. +Groups without prime exponent are not settled. For three copies of a² in C4 +the regular cut alone gives 2, not 3. PROOF.md section 6 notes that +faithful characters give the same d bound for cyclic groups when the +characteristic does not divide the order; that remark has no separate +finite check here. No independent human or formal proof-kernel review is +claimed. + +## Credit and overlap + +- Ali Romman, [PR #5394](https://github.com/CrocSwap/integer-mult-bounds/pull/5394) + (`research/group-subproduct-cover`): model, cover theorem, the question, + and the all-group three-label rank-one floor. It is cited, not re-verified. +- Wentao Li, `research/elementary-abelian-diagonal-minimum`: the rank-one + minimum t in F2[(C2)^k]. Corollary 3 contains that statement and extends + it to every field, every prime, nonabelian prime-exponent groups, + projectors of any rank and singular free maps. +- Rank telescoping through a representation: this account's + [PR #5202](https://github.com/CrocSwap/integer-mult-bounds/pull/5202) + (`research/order21-normal-tariff`) and the character twist in + `research/cut58-separable-query-floor`. + +## Open next questions + +1. For groups without prime exponent, is the rank-one count always at least + the number of nonidentity entries? The first case is three copies of a² + in C4. The regular cut gives 2, and a top-coefficient argument may give 3. +2. Which positive combination of permutation representations gives the + best cut for a fixed group and target, for example in D8 or Q8 over F2? + This is a finite linear program over transitive G-sets, and it is valid + in every characteristic. +3. Does any physically realizable label family have prime exponent and a + priced native implementation? Without one, these counts do not move a + supplier bill. diff --git a/research/prime-exponent-rank-cut/SOURCES.json b/research/prime-exponent-rank-cut/SOURCES.json new file mode 100644 index 0000000000..3a25d8e506 --- /dev/null +++ b/research/prime-exponent-rank-cut/SOURCES.json @@ -0,0 +1,42 @@ +{ + "schema_version": 1, + "base_commit": "19fdb086ea96af9a9f87936a2b888e10af4ed810", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "581f8d87008354eb5b869f7ed9de1317ad837ce8", + "sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/group-subproduct-cover/PROOF.md", + "usage": "provenance", + "git_blob": "308e63dcc668b0089b4a0c5152dda0733b01fed5", + "sha256": "7392dca9e7258dcdb4802a3c9f60cd8e5ccced271950a4ce2e4823f449586c00" + }, + { + "path": "research/group-subproduct-cover/README.md", + "usage": "provenance", + "git_blob": "36faba920c546d36f3a51a026e8e84d925acf723", + "sha256": "b9241c29301d2d20af35fe9f09ff2b0e7e7aca0566394b8e4c7708924e59d161" + }, + { + "path": "research/elementary-abelian-diagonal-minimum/README.md", + "usage": "provenance", + "git_blob": "32337254f5eb7f941d044ed08c3a815c75d685c0", + "sha256": "c6ec7fbe9848ba0c9fa0a914b0fbd8b40ce8d56ffff996ea61c6b7d3b57eeee4" + }, + { + "path": "research/order21-normal-tariff/README.md", + "usage": "provenance", + "git_blob": "eaa7bb551ea8f212ac08d373cfd6602d39edd6ab", + "sha256": "bcf01e91ac59b3393479b70ddda9122f9848a26577fc0a4d35654e3b56af2786" + } + ] +} diff --git a/research/prime-exponent-rank-cut/TASK.json b/research/prime-exponent-rank-cut/TASK.json new file mode 100644 index 0000000000..e1fc769efa --- /dev/null +++ b/research/prime-exponent-rank-cut/TASK.json @@ -0,0 +1,83 @@ +{ + "schema_version": 1, + "task_id": "bit-new-register-model", + "priority_revision": 8, + "base_commit": "19fdb086ea96af9a9f87936a2b888e10af4ed810", + "original_card": { + "id": "bit-new-register-model", + "question": "Can an explicitly larger or nonabelian register model escape the scoped three-register obstruction?", + "starting_points": [ + "docs/research/research-family-status.md", + "research/bit-three-register-lower-bound/README.md", + "certificates/selected-result.json", + "research/bit-gl3-mixed-targets-length10/README.md", + "docs/research/community-efficient1000-review.md" + ], + "methods": [ + "Construct the smallest exact identity in a newly specified legal operation alphabet.", + "Derive a target-specific relaxation bound for that same explicit alphabet." + ], + "acceptance_gate": "Name the changed hypothesis, all counted roles and a uniform identity; finite column tests alone do not certify it. A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Resolve the current selected review, separate complex/ordinary BIT/admitted BIT/outer budgets, and compare the card against live handoffs before starting. Historical ceilings require exact source/model equivalence.", + "scope": "Source-binding orientation only; not a scientific replay or all-size proof. Materialize selected inputs if this checkout is sparse." + }, + "first_experiment": "First compare the alphabet, role count and length with the fully replayed #1974 census and #2027 mixed-root tariff. Identify a changed premise and a legal native implementation; then price one smallest completed instance before searching larger words.", + "bottleneck_link": "A small-width completed saving changes the bit primitive; a finite-address identity alone is insufficient.", + "allowed_variations": [ + "Choose a fixed larger register count or a specified nonabelian operation family." + ], + "scope_change_triggers": [ + "Remaining inside the already-excluded three-register abelian model.", + "Repeating the two-register GL3 census or a covered three-register length without changing a hypothesis; a formal group-algebra word without native conversion is a partial result." + ], + "overlap_terms": [ + "three-register", + "nonabelian", + "group algebra" + ] + }, + "scope_status": "changed", + "actual_scope": "Answer Open next question 1 of PR #5394 (research/group-subproduct-cover) for groups of prime exponent: prove a representation rank cut in its relaxed group-gate model and show that any d nonidentity diagonal entries need total projector rank d over every field, with arbitrary finite scalar workspace.", + "scope_change_reason": "The card asks whether a larger or nonabelian register model escapes the three-register obstruction. This package takes the explicitly open four-or-more-target question of the arbitrary-rank group-gate model from PR #5394 and settles it for every group of prime exponent, including nonabelian ones.", + "bottleneck_link": "Side result. It closes multi-target sharing below one rank unit per target for prime-exponent labels in the relaxed model, before any native compiler search. No supplier bill changes.", + "budget_minutes": 60, + "stop_rule": "Ship the written cut and the prime-exponent corollary with finite corroboration; do not search non-prime-exponent groups or build a native supplier.", + "outcome": "completed", + "evidence": "PROOF.md gives the all-field, all-group representation rank cut and the prime-exponent corollary. verify.py checks 405 regular defect ranks over Q, F2, F3, F5 and F7, 206 random circuits with rectangular and singular free maps, exact cover costs 2/3/4 with attaining words, the 15-label (C2)^4 basis cover and five controls.", + "author": "Nick Petalas", + "ai_assistance": "Independent human and formal proof-kernel review are unclaimed.", + "open_questions": [ + { + "question": "For groups without prime exponent, is the rank-one count always at least the number of nonidentity diagonal entries?", + "why_it_matters": "The regular cut is weaker with mixed element orders; three copies of a^2 in C4 get only 2.", + "first_step": "Prove or refute rank-one count 3 for diag([a^2],[a^2],[a^2]) in C4 over F2 with arbitrary workspace, using top subproduct coefficients.", + "blocked_by": "No cut stronger than the permutation-representation cut is proved for mixed orders." + }, + { + "question": "Which positive combination of permutation representations gives the best cut for a fixed group and target?", + "why_it_matters": "Permutation cuts are valid in every characteristic, including p-groups in characteristic p.", + "first_step": "Solve the finite linear program over transitive G-sets for D8 or Q8 and compare with exact small-workspace counts.", + "blocked_by": "The linear program and matching constructions are not computed here." + }, + { + "question": "Does a physically realizable prime-exponent label family have a priced native implementation?", + "why_it_matters": "Only a physical implementation could change a supplier bill.", + "first_step": "Specify the address action, routing and restoration of one producer/consumer pair and charge every operation.", + "blocked_by": "No native boundary contract or complete cost model is supplied." + } + ], + "claim_url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19227703", + "claim_type": "scoped proof with exact finite corroboration", + "environment": { + "python": "CPython 3.12.15", + "platform": "macOS arm64", + "dependencies": "standard library only" + } +} diff --git a/research/prime-exponent-rank-cut/VERIFY.json b/research/prime-exponent-rank-cut/VERIFY.json new file mode 100644 index 0000000000..fa2128626b --- /dev/null +++ b/research/prime-exponent-rank-cut/VERIFY.json @@ -0,0 +1,34 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "-W", + "error", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Regular defect ranks over five fields, 206 random-circuit rank cuts, exact cover costs and attaining words, five controls." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "-W", + "error", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Repeat the full corroboration with Python assertions disabled; all checks use explicit need() calls." + } + ] +} diff --git a/research/prime-exponent-rank-cut/verify.py b/research/prime-exponent-rank-cut/verify.py new file mode 100644 index 0000000000..2c987c4cf8 --- /dev/null +++ b/research/prime-exponent-rank-cut/verify.py @@ -0,0 +1,467 @@ +#!/usr/bin/env python3 +"""Exact finite corroboration of the prime-exponent representation rank cut. + +Nick Petalas. Apache-2.0. Standard library only; read-only; no network or Git. + +The written proof is PROOF.md. This script checks its finite ingredients: +regular-permutation defect ranks over Q and four prime fields, the entrywise +representation step and the rank cut on seeded random circuits with +rectangular and singular free maps, the attaining direct and cover words, +exact cover costs for the separation examples, and rejection controls. +It does not replace the written all-size argument. +""" + +from __future__ import annotations + +import itertools +import json +import random +import sys +from fractions import Fraction + +FIELDS = (0, 2, 3, 5, 7) # 0 means the rationals +SEED = 20261027 + + +def need(cond: bool, msg: str) -> None: + if not cond: + raise SystemExit(f"FAIL: {msg}") + + +# ---------------------------------------------------------------- groups + + +class Group: + def __init__(self, name, elems, mul, ident): + self.name = name + self.elems = list(elems) + self.index = {g: i for i, g in enumerate(self.elems)} + need(len(self.index) == len(self.elems), f"{name}: duplicate elements") + n = len(self.elems) + self.e = self.index[ident] + self.table = [[self.index[mul(a, b)] for b in self.elems] for a in self.elems] + for a, b, c in itertools.product(range(n), repeat=3): + if a < 4 or n <= 16: + need( + self.table[self.table[a][b]][c] == self.table[a][self.table[b][c]], + f"{name}: associativity", + ) + self.order = [self._order(i) for i in range(n)] + self.abelian = all( + self.table[a][b] == self.table[b][a] for a in range(n) for b in range(n) + ) + + def _order(self, g): + x, k = g, 1 + while x != self.e: + x, k = self.table[x][g], k + 1 + return k + + def exponent(self): + out = 1 + for o in self.order: + out = out * o // _gcd(out, o) + return out + + +def _gcd(a, b): + while b: + a, b = b, a % b + return a + + +def cyclic_product(mods): + return Group( + "x".join(f"C{m}" for m in mods), + itertools.product(*[range(m) for m in mods]), + lambda a, b: tuple((x + y) % m for x, y, m in zip(a, b, mods)), + tuple(0 for _ in mods), + ) + + +def heisenberg(p): + # (a,b,c)(a',b',c') = (a+a', b+b', c+c'+a*b'); exponent p for odd p. + return Group( + f"Heis{p}", + itertools.product(range(p), repeat=3), + lambda x, y: ((x[0] + y[0]) % p, (x[1] + y[1]) % p, (x[2] + y[2] + x[0] * y[1]) % p), + (0, 0, 0), + ) + + +def quaternion(): + # Q8 as signed units (s, u), u in 1,i,j,k encoded 0..3. + t = {(0, 0): (1, 0), (0, 1): (1, 1), (0, 2): (1, 2), (0, 3): (1, 3), + (1, 0): (1, 1), (1, 1): (-1, 0), (1, 2): (1, 3), (1, 3): (-1, 2), + (2, 0): (1, 2), (2, 1): (-1, 3), (2, 2): (-1, 0), (2, 3): (1, 1), + (3, 0): (1, 3), (3, 1): (1, 2), (3, 2): (-1, 1), (3, 3): (-1, 0)} + + def mul(x, y): + s, u = t[(x[1], y[1])] + return (x[0] * y[0] * s, u) + + return Group("Q8", [(s, u) for s in (1, -1) for u in range(4)], mul, (1, 0)) + + +# --------------------------------------------------------- linear algebra + + +def norm(x, p): + return Fraction(x) if p == 0 else x % p + + +def inv(x, p): + return 1 / x if p == 0 else pow(x, p - 2, p) + + +def rank(rows, p): + m = [[norm(x, p) for x in r] for r in rows] + if not m: + return 0 + r, ncols = 0, len(m[0]) + for c in range(ncols): + piv = next((i for i in range(r, len(m)) if m[i][c] != 0), None) + if piv is None: + continue + m[r], m[piv] = m[piv], m[r] + iv = inv(m[r][c], p) + m[r] = [norm(x * iv, p) for x in m[r]] + for i in range(len(m)): + if i != r and m[i][c] != 0: + f = m[i][c] + m[i] = [norm(a - f * b, p) for a, b in zip(m[i], m[r])] + r += 1 + if r == len(m): + break + return r + + +def matmul(a, b, p): + return [[norm(sum(x * y for x, y in zip(row, col)), p) for col in zip(*b)] for row in a] + + +def ident(n): + return [[1 if i == j else 0 for j in range(n)] for i in range(n)] + + +def regular(G, g): + """Left regular permutation matrix: column h maps to row g*h.""" + n = len(G.elems) + m = [[0] * n for _ in range(n)] + for h in range(n): + m[G.table[g][h]][h] = 1 + return m + + +def defect_rank(G, g, p): + n = len(G.elems) + P = regular(G, g) + return rank([[P[i][j] - (1 if i == j else 0) for j in range(n)] for i in range(n)], p) + + +# -------------------------------------------- group-algebra matrices (K[G]) + + +def ga_mul(G, A, B, p): + """Matrices with entries {group index: coefficient}.""" + out = [] + for row in A: + orow = [] + for col in zip(*B): + acc = {} + for x, y in zip(row, col): + for g, cg in x.items(): + for h, ch in y.items(): + k = G.table[g][h] + acc[k] = norm(acc.get(k, 0) + cg * ch, p) + orow.append({k: v for k, v in acc.items() if v != 0}) + out.append(orow) + return out + + +def scalar_ga(G, C): + return [[({G.e: c} if c else {}) for c in row] for row in C] + + +def gate_ga(G, N, g, p): + n = len(N) + out = [] + for i in range(n): + row = [] + for j in range(n): + ie = norm((1 if i == j else 0) - N[i][j], p) + ent = {} + if g == G.e: + ent = {G.e: norm(ie + N[i][j], p)} + else: + if ie: + ent[G.e] = ie + if norm(N[i][j], p): + ent[g] = norm(N[i][j], p) + row.append({k: v for k, v in ent.items() if v != 0}) + out.append(row) + return out + + +def rho_of_ga(G, A, p): + """Entrywise left-regular image: an (r*|G|) x (c*|G|) scalar matrix.""" + n = len(G.elems) + regs = [regular(G, g) for g in range(n)] + rows = len(A) * n + cols = len(A[0]) * n + out = [[0] * cols for _ in range(rows)] + for i, row in enumerate(A): + for j, ent in enumerate(row): + for g, c in ent.items(): + R = regs[g] + for a in range(n): + for b in range(n): + if R[a][b]: + out[i * n + a][j * n + b] = norm(out[i * n + a][j * n + b] + c, p) + return out + + +def kron_id(C, n): + rows, cols = len(C), len(C[0]) + out = [[0] * (cols * n) for _ in range(rows * n)] + for i in range(rows): + for j in range(cols): + if C[i][j]: + for a in range(n): + out[i * n + a][j * n + a] = C[i][j] + return out + + +def augmentation(A, p): + return [[norm(sum(ent.values()), p) for ent in row] for row in A] + + +# -------------------------------------------------------- random circuits + + +def rand_mat(rng, r, c, p): + lo, hi = (-2, 2) if p == 0 else (0, p - 1) + return [[norm(rng.randint(lo, hi), p) for _ in range(c)] for _ in range(r)] + + +def rand_idempotent(rng, n, k, p): + while True: + S = rand_mat(rng, n, n, p) + if rank(S, p) == n: + break + # invert S by elimination on [S | I] + aug = [S[i] + ident(n)[i] for i in range(n)] + for c in range(n): + piv = next(i for i in range(c, n) if norm(aug[i][c], p) != 0) + aug[c], aug[piv] = aug[piv], aug[c] + iv = inv(norm(aug[c][c], p), p) + aug[c] = [norm(x * iv, p) for x in aug[c]] + for i in range(n): + if i != c and norm(aug[i][c], p): + f = aug[i][c] + aug[i] = [norm(a - f * b, p) for a, b in zip(aug[i], aug[c])] + Sinv = [row[n:] for row in aug] + D = [[1 if (i == j and i < k) else 0 for j in range(n)] for i in range(n)] + N = matmul(matmul(S, D, p), Sinv, p) + need(matmul(N, N, p) == N, "random idempotent") + need(rank(N, p) == k, "random idempotent rank") + return N + + +def check_random_cuts(G, p, trials, rng): + """Rank cut on random circuits with rectangular/singular free maps.""" + n = len(G.elems) + r_of = [defect_rank(G, g, p) for g in range(n)] + tight = 0 + for _ in range(trials): + d, R = rng.choice([(1, 2), (2, 2), (2, 3)]) + k = rng.randint(1, 3) + labels = [rng.randrange(n) for _ in range(k)] + ranks = [rng.randint(0, R) for _ in range(k)] + Ns = [rand_idempotent(rng, R, rk, p) for rk in ranks] + Cs = [rand_mat(rng, d, R, p)] + [rand_mat(rng, R, R, p) for _ in range(k - 1)] + Cs.append(rand_mat(rng, R, d, p)) + # F = C0 D1 C1 ... Dk Ck over K[G] + F = scalar_ga(G, Cs[0]) + for j in range(k): + F = ga_mul(G, F, gate_ga(G, Ns[j], labels[j], p), p) + F = ga_mul(G, F, scalar_ga(G, Cs[j + 1]), p) + Cprod = Cs[0] + for C in Cs[1:]: + Cprod = matmul(Cprod, C, p) + need(augmentation(F, p) == Cprod, "augmentation of endpoint equals free-map product") + # entrywise representation equals the product of represented factors + rF = rho_of_ga(G, F, p) + rP = kron_id(Cs[0], n) + for j in range(k): + rP = matmul(rP, rho_of_ga(G, gate_ga(G, Ns[j], labels[j], p), p), p) + rP = matmul(rP, kron_id(Cs[j + 1], n), p) + need(rF == rP, "entrywise representation is multiplicative") + E = kron_id(Cprod, n) + defect = [[norm(a - b, p) for a, b in zip(ra, rb)] for ra, rb in zip(rF, E)] + lhs = rank(defect, p) + rhs = sum(rk * r_of[g] for rk, g in zip(ranks, labels)) + need(lhs <= rhs, f"{G.name} p={p}: rank cut violated {lhs} > {rhs}") + tight += lhs == rhs + return tight + + +# ----------------------------------------------------- covers and words + + +def subproducts(G, word): + out = {G.e} + for bits in itertools.product((0, 1), repeat=len(word)): + x = G.e + for b, g in zip(bits, word): + if b: + x = G.table[x][g] + out.add(x) + return out + + +def cover_cost(G, targets, max_len): + labels = [g for g in range(len(G.elems)) if g != G.e] + tset = set(targets) + for k in range(max_len + 1): + for word in itertools.product(labels, repeat=k): + if tset <= subproducts(G, word): + return k, word + return None, None + + +def realize(G, word, targets, p, dirty=1): + """Diagonal-projector word on len(targets) data roles plus untouched dirt.""" + masks = [] + for t in targets: + m = next( + bits + for bits in itertools.product((0, 1), repeat=len(word)) + if _eval(G, word, bits) == t + ) + masks.append(m) + R = len(targets) + dirty + F = scalar_ga(G, ident(R)) + for j, g in enumerate(word): + N = [[(masks[i][j] if (i == c and i < len(targets)) else 0) for c in range(R)] for i in range(R)] + F = ga_mul(G, F, gate_ga(G, N, g, p), p) + want = [[({targets[i] if i < len(targets) else G.e: 1} if i == c else {}) for c in range(R)] for i in range(R)] + return F == want, masks + + +def _eval(G, word, bits): + x = G.e + for b, g in zip(bits, word): + if b: + x = G.table[x][g] + return x + + +# ------------------------------------------------------------------- main + + +def main() -> int: + rng = random.Random(SEED) + groups = { + "C2^2": cyclic_product((2, 2)), + "C2^3": cyclic_product((2, 2, 2)), + "C2^4": cyclic_product((2, 2, 2, 2)), + "C3^2": cyclic_product((3, 3)), + "C5": cyclic_product((5,)), + "Heis3": heisenberg(3), + "C4": cyclic_product((4,)), + "Q8": quaternion(), + } + report = {"marker": None, "regular_defect_ranks": {}, "random_cuts": {}, "words": {}, "controls": []} + + # A. regular defect rank |G|(1 - 1/ord g), every element, five fields + checked = 0 + for name, G in groups.items(): + n = len(G.elems) + for p in FIELDS: + for g in range(n): + need(defect_rank(G, g, p) == n - n // G.order[g], f"{name} p={p} regular defect") + checked += 1 + report["regular_defect_ranks"][name] = { + "order": n, "exponent": G.exponent(), "abelian": G.abelian, + } + need(not groups["Heis3"].abelian and groups["Heis3"].exponent() == 3, "Heis3 nonabelian, exponent 3") + report["regular_defect_checks"] = checked + + # B. rank cut on random circuits (rectangular, singular free maps, all projector ranks) + total = 0 + for name, p, trials in [("C2^3", 2, 40), ("C2^3", 3, 25), ("C3^2", 3, 25), + ("C3^2", 2, 25), ("C5", 0, 25), ("Heis3", 2, 8), + ("Heis3", 3, 8), ("Q8", 5, 25), ("C4", 2, 25)]: + tight = check_random_cuts(groups[name], p, trials, rng) + report["random_cuts"][f"{name}/F{p or 'Q'}"] = {"circuits": trials, "tight": tight} + total += trials + report["random_circuits"] = total + + # C. separation examples: all nonidentity targets + for name, max_len in [("C2^2", 2), ("C2^3", 3), ("C3^2", 4)]: + G = groups[name] + targets = [g for g in range(len(G.elems)) if g != G.e] + d = len(targets) + k, word = cover_cost(G, targets, max_len) + need(k is not None, f"{name}: cover found") + need((1 << (k - 1)) - 1 < d, f"{name}: shorter covers excluded by counting") + for p in (0, 2, 3): + ok, _ = realize(G, list(word), targets, p) + need(ok, f"{name} p={p}: cover word realizes all targets") + ok, _ = realize(G, targets, targets, p) + need(ok, f"{name} p={p}: direct rank-one word realizes all targets") + report["words"][name] = {"targets": d, "cover_cost": k, "rank_one_cost": d} + # C2^4: cover word is the basis word; length 4 is forced by 2^3 < 16 + G = groups["C2^4"] + targets = [g for g in range(len(G.elems)) if g != G.e] + basis = [G.index[v] for v in [(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1)]] + need(set(targets) <= subproducts(G, basis), "C2^4 basis word covers") + ok, _ = realize(G, basis, targets, 2) + need(ok, "C2^4 basis word realizes all 15 targets over F2") + report["words"]["C2^4"] = {"targets": 15, "cover_cost": 4, "rank_one_cost": 15} + # Heis3: every nonidentity element, regular cut value equals d + G = groups["Heis3"] + vals = {G.order[g] for g in range(len(G.elems)) if g != G.e} + need(vals == {3}, "Heis3 prime exponent") + + # D. controls + c = [] + G = groups["C2^3"] + targets = [g for g in range(len(G.elems)) if g != G.e] + _, word = cover_cost(G, targets, 3) + shorter = set(targets) <= subproducts(G, list(word)[:-1]) + need(not shorter, "control: dropping a cover letter loses a target") + c.append("dropped cover letter uncovers a target") + # regular-cut bound in C4 for three copies of a^2 is only 2: hypothesis needed + G = groups["C4"] + a2 = G.index[(2,)] + lhs = 3 * Fraction(len(G.elems) - len(G.elems) // G.order[a2]) + per = Fraction(max(len(G.elems) - len(G.elems) // o for o in G.order)) + need(-(-lhs // per) == 2, "control: C4 regular cut for three a^2 targets is 2 < 3") + c.append("C4 non-prime exponent: regular cut alone gives 2 for three a^2 entries") + # Q8: mixed orders, regular cut on {i,j,k,-1} over any field + G = groups["Q8"] + lhs = sum(Fraction(8 - 8 // G.order[G.index[x]]) for x in [(1, 1), (1, 2), (1, 3), (-1, 0)]) + need(-(-lhs // 6) == 4, "control: Q8 regular cut {i,j,k,-1} gives 4") + c.append("Q8 targets i,j,k,-1: regular cut 4 = d although orders differ") + # a fake defect claim: identity labels have zero defect + G = groups["C3^2"] + need(defect_rank(G, G.e, 3) == 0, "control: identity label has zero defect") + c.append("identity label contributes zero defect") + # an idempotent of rank 2 on a nonidentity label contributes 2 r(g), not r(g) + need(rank(kron_id(rand_idempotent(rng, 3, 2, 3), 1), 3) == 2, "control: projector rank") + c.append("rank-two projector rank detected") + report["controls"] = c + + report["marker"] = "PASS_PRIME_EXPONENT_RANK_CUT" + print(json.dumps(report, indent=1, sort_keys=True)) + print( + f"PASS_PRIME_EXPONENT_RANK_CUT regular_checks={checked} random_circuits={total}" + f" separations=4 controls={len(c)} no_new_kappa" + ) + return 0 + + +if __name__ == "__main__": + sys.exit(main())