From 91df334ccd2a4bc9959e311f118ac8aaf967ffc2 Mon Sep 17 00:00:00 2001 From: Nick Petalas Date: Thu, 29 Oct 2026 16:23:11 +0000 Subject: [PATCH] feat(research): bound odd cyclotomic Clifford response rank --- research/odd-cyclotomic-response/PROOF.md | 159 +++++++++ research/odd-cyclotomic-response/README.md | 125 +++++++ research/odd-cyclotomic-response/SOURCES.json | 36 ++ research/odd-cyclotomic-response/TASK.json | 99 ++++++ research/odd-cyclotomic-response/VERIFY.json | 32 ++ research/odd-cyclotomic-response/verify.py | 312 ++++++++++++++++++ 6 files changed, 763 insertions(+) create mode 100644 research/odd-cyclotomic-response/PROOF.md create mode 100644 research/odd-cyclotomic-response/README.md create mode 100644 research/odd-cyclotomic-response/SOURCES.json create mode 100644 research/odd-cyclotomic-response/TASK.json create mode 100644 research/odd-cyclotomic-response/VERIFY.json create mode 100644 research/odd-cyclotomic-response/verify.py diff --git a/research/odd-cyclotomic-response/PROOF.md b/research/odd-cyclotomic-response/PROOF.md new file mode 100644 index 0000000000..cbb01d01ff --- /dev/null +++ b/research/odd-cyclotomic-response/PROOF.md @@ -0,0 +1,159 @@ +# Odd cyclotomic response gate + +This scoped proof was produced by Nick Petalas. It extends Ross Richardson's +whole-bank cubic trace gate in [PR4081](https://github.com/CrocSwap/integer-mult-bounds/pull/4081). +The cyclotomic extension and the degree-four sharpness example are the new steps. +The predecessor's Pauli character argument is credited below. No historical +priority is claimed for the classical field-degree or Clifford facts. + +## Statement + +Let n>1 be odd. Let U be a unitary Clifford on M qubits, with every matrix +entry in Q(i), and suppose the **actual whole-bank matrix** satisfies + + Phi_n(U)=0. + +Here Phi_n is the nth cyclotomic polynomial. Write S_U for the induced +symplectic matrix on the 2M binary Pauli coordinates. Then: + +1. phi(n)=2^a for some integer 1<=a<=M. Equivalently, n is a squarefree + product of distinct Fermat primes. +2. The characteristic polynomial is Phi_n(X)^(2^(M-a)), and + Tr(U)=mu(n) 2^(M-a). +3. rank_F2(S_U-I)=2a, exactly. In particular, the native off-diagonal + B-block rank is at most min(M,2a). + +The condition on n is necessary. This proof does not assert Clifford +existence for every such n. A Fermat prime means a prime of the form +2^(2^j)+1, including any not presently known. The statement does not assume +that the currently known Fermat primes are the only ones. + +At n=5, the bound B-rank<=4 is attained on four qubits, as constructed below. +Thus the degree-four cap cannot be reduced for all ambient widths. + +## Cyclotomic degree and trace + +For odd n, adjoining i and a primitive nth root gives Q(zeta_(4n)). Indeed, +the orders 4 and n are coprime, so the product of primitive roots of those +orders has order 4n, and its powers recover both factors. Classical +cyclotomic irreducibility therefore gives + + [Q(i,zeta_n):Q(i)] = phi(4n)/2 = phi(n). + +For a proof of the classical irreducibility theorem, see Romyar Sharifi's +[Abstract Algebra, Theorem 6.6.11](https://math.ucla.edu/~sharifi/notes/algebra-ch06.html). +Consequently Phi_n remains irreducible over Q(i). Its roots are distinct. +Since Phi_n(U)=0, the Q(i)[X]-module defined by U is a direct sum of copies +of Q(i)[X]/(Phi_n). Equivalently, its characteristic polynomial is Phi_n^t +for a positive integer t, and + + 2^M = t phi(n). + +Thus phi(n) is a power of two, say 2^a, with a<=M. If +n=product_p p^e_p, then phi(n)=product_p p^(e_p-1)(p-1). Every p is odd. +No e_p can exceed one, and every p-1 must be a power of two. If p=1+2^b +is prime, b is itself a power of two: an odd divisor c>1 of b would factor +(2^(b/c))^c+1. Conversely, a squarefree product of Fermat primes has +power-of-two totient. This proves the stated equivalence. + +Each primitive nth root occurs t times. The sum of the primitive nth roots +is mu(n). One elementary derivation partitions all nth roots by their +exact orders and applies Mobius inversion to their sum. Hence + + Tr(U)=t mu(n)=mu(n) 2^(M-a). + +Squarefreeness makes mu(n) equal to plus or minus one. In particular the +trace is nonzero, and its squared absolute value is 2^(2M-2a). + +## Pauli adjoint trace + +This is the Pauli-character step used in the predecessor's cubic proof. +For completeness, let P_v be Hermitian Pauli representatives, indexed by +v in F2^(2M). Clifford conjugation sends P_v to epsilon(v) P_(S_U v), +where epsilon(v) is plus or minus one. On K=ker(S_U-I), comparing the +conjugation of P_v P_w with the product of the conjugations cancels the +same Pauli multiplication phase. It gives + + epsilon(v+w)=epsilon(v)epsilon(w), v,w in K. + +Thus epsilon restricted to K is a character. Its sum over K is zero if +the character is nontrivial, and 2^dim(K) otherwise. This sum is the trace +of conjugation by U in the Pauli basis. The same linear map on matrices +has trace Tr(U) conjugate(Tr(U)), by its tensor representation U tensor +conjugate(U). The trace computed above is nonzero. Therefore + + 2^dim(K) = 2^(2M-2a), + rank(S_U-I) = 2M-dim(K) = 2a. + +In the physical X/Z coordinates, the off-diagonal B block of S_U is also +a submatrix of S_U-I. Its rank is at most 2a, and its size is M by M. +This proves the native-rank cap without any tensor or support restriction. + +## A sharp degree-four example + +Define H_g=(1+i)[[1,1],[1,-1]]/2, S=diag(1,i), and let C be CNOT with +the first qubit controlling the second. The Gaussian-dyadic Clifford + + U5 = - C (S tensor I) (H_g tensor H_g) + +has matrix + + 1/2 * [ -i -i -i -i ] + [ -i i -i i ] + [ 1 -1 -1 1 ] + [ 1 1 -1 -1 ]. + +Direct matrix multiplication gives U5^5=I and +I+U5+U5^2+U5^3+U5^4=0. Its trace is -1, and its symplectic defect has +rank four. These are complete 4-by-4 identities, checked with integer +Gaussian numerators in verify.py. + +Add two identity spectators. On the four qubits numbered 0,1,2,3, let V +be Bell preparation on pairs (0,2) and (1,3). Apply H_g on 0 and 1, then +CNOT 0->2 and 1->3. Set + + W = V^-1 (U5 tensor I_4) V. + +Conjugation preserves Phi5(W)=0. Its B block is nonsingular. To see this +without relying on a computed rank, write A for the four-dimensional +symplectic coordinate space of the first two qubits, and E for that of +the spectators. Bell preparation sends the standard Z Lagrangian L to +a graph L' of a symplectic isomorphism A->E. In characteristic two this +graph is Lagrangian, has dimension four, and intersects A trivially. +The active symplectic map T of U5 has T-I invertible. For l in L', + + ((T direct_sum I)-I)l = ((T-I) projection_A(l), 0). + +If (T direct_sum I)l also lies in L', the displayed difference lies in +A intersect L', hence is zero. Invertibility of T-I and of +projection_A restricted to L' forces l=0. Thus L' and its image are +transverse. Pulling back by V, L and S_W L are transverse. The map from +input Z coordinates to output X coordinates is therefore invertible, +which is exactly B-rank four. The standalone verifier also checks this +complete 16-by-16 matrix, all eight Pauli generators and every fixed +Pauli sign. + +## Meaning for a proposed response interface + +The n=3 case is Richardson's result. New examples of the necessary bound +are n=5 with defect four, n=15 with defect six, and n=17 with defect eight. +Orders 7,9,25 and 27 cannot satisfy their primitive cyclotomic relation +on any Gaussian-rational qubit bank, even before Cliffordness is imposed. +Those are exclusions of the primitive relation, not exclusions of those +finite orders among Clifford operators. + +For fixed odd n, no family with unbounded native B rank can retain +Phi_n(U)=0 on the whole bank. In terms of a rank r, any such primitive +response needs phi(n)>=2^(r/2). This is an obstruction to a fixed-degree +primitive response identity, not a complete query-price +or caller impossibility theorem. + +Order alone is insufficient: U5 tensor U5 still has order five but +does not satisfy Phi5=0, and its symplectic defect rank is eight. +Arbitrary global phases also do not preserve the premise. Non-Gaussian +coefficient fields, non-Clifford operators, restricted-input quotients, +responses with several cyclotomic factors, and complete changed callers +are outside this theorem. No physical implementation invoice, dirty +restoration, supplier admission, new kappa or complete multiplication +theorem follows. The universal proof is written mathematics, not a +finite extrapolation or a formal-kernel result. diff --git a/research/odd-cyclotomic-response/README.md b/research/odd-cyclotomic-response/README.md new file mode 100644 index 0000000000..e695506e8f --- /dev/null +++ b/research/odd-cyclotomic-response/README.md @@ -0,0 +1,125 @@ +# Odd cyclotomic Clifford response gate + +Scoped written proof with exact finite corroboration, produced by Nick Petalas. +For every odd n>1, an actual Gaussian-rational M-qubit Clifford U satisfying +Phi_n(U)=0 on the whole bank necessarily obeys + +```text +phi(n)=2^a, 1<=a<=M +n is a squarefree product of distinct Fermat primes +Tr(U)=mu(n) 2^(M-a) +rank_F2(S_U-I)=2a +native B-rank <= min(M,2a). +``` + +The degree-four cap is sharp: a complete four-qubit Clifford W satisfies +Phi5(W)=0 and has native B-rank four. Its construction adds two identity +spectators to an explicit two-qubit order-five Clifford and conjugates by +Bell preparation. For fixed odd n, the primitive relation cannot carry +unbounded native rank. This is an interface obstruction, with no new kappa. + +[PROOF.md](PROOF.md) gives the all-parameter argument and the explicit +sharpness construction. The new step extends Ross Richardson's +[PR4081](https://github.com/CrocSwap/integer-mult-bounds/pull/4081) +whole-bank cubic gate to every odd cyclotomic polynomial. His cubic result +and fixed-Pauli character argument retain their credit. Classical cyclotomic +irreducibility, totient arithmetic and Clifford/Bell gates retain their +classical status. Global literature priority is unclaimed. No predecessor +verifier is imported or replayed. + +## Evidence and reproduction + +The standalone standard-library verifier uses exact integer Gaussian +numerators, common positive denominators and binary elimination. It checks: + +- All 2,047 odd n in 3..4095. Totients from explicit coprime enumeration + equal the independently factored formula, and the degree condition equals + the squarefree Fermat-prime condition. Eleven n in this interval pass the + necessary degree test. This is not an existence census. +- The complete two-qubit degree-four matrix and four-qubit sharp example, + including their polynomial identities, unitarity, all Pauli generators, + every fixed-Pauli sign, both ranks and the adjoint trace identity. +- An order-five tensor control with symplectic defect eight that fails + Phi5=0; a wrong global phase; a passing primitive-power control; a + nonunitary companion matrix satisfying Phi5; and four invalid domains. + +Run from the repository root with CPython 3.12: + +```sh +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -W error -B research/odd-cyclotomic-response/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -W error -O -B research/odd-cyclotomic-response/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/odd-cyclotomic-response +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/odd-cyclotomic-response --check-source-history --check-modes +``` + +Other installations may substitute their CPython 3.12 path. Expected markers +are `PASS_ODD_CYCLOTOMIC_RESPONSE`, `PASS_REGISTERED_RESEARCH_PACKAGE` and +`PASS_RESEARCH_COMMIT_BYTES`. Each direct check takes less than one second +locally and has a registered 30-second limit. Normal and optimized runs +generate the same six-file SHA256-bound receipt on stdout. No receipt is +hand-written or stored in the package. Direct replay also works in a +read-only Git-free export. + +[SOURCES.json](SOURCES.json) pins the catalogue, selected record and source +proof as historical provenance. They are not executable inputs. The +scientific base is `a5bff3bf133e482541c09eba4e773884bdb2b1b7`, priority +revision 8. The selected source-binding first command passed as metadata +orientation only. The `joint-query-controller` card is explicitly changed +to this algebraic response-interface result; it does not solve the installed +QQ16 caller task. [TASK.json](TASK.json) records the overlap limits and +structured next questions. + +## Limits + +The universal result is the written proof. Finite checks corroborate the +identities and bounded arithmetic, and do not prove the all-n statement. +The necessary condition on n is not a sufficient existence classification. +Order n alone, non-Gaussian coefficient fields, non-Clifford operators, +several cyclotomic factors and restricted-input identities are outside the +theorem. A sparse reader relation of unbounded degree is also outside the +fixed-degree consequence. + +No actual selected caller, physical native program, complete signed invoice, +dirty restoration, ownership, hosting, precision, stock, tape execution or +supplier admission is supplied. No selected scientific replay, Lean or +Docker run was performed. All five selected framework assumptions remain. +Independent human and formal proof-kernel review are unclaimed. No complete +multiplication theorem or selected-frontier change follows. + +## Open next questions + +- Determine which degree-permitted n admit Gaussian-rational Clifford + responses. Begin with a complete primitive order-seventeen example and + its Pauli action; the necessary degree condition alone supplies no such + construction. +- Bound native rank when a fixed product of several odd cyclotomic factors + annihilates U. Begin with the exact multiplicity and trace equations for + Phi3*Phi5; cancellation can make the adjoint trace vanish, so the present + nonzero-character argument does not automatically apply. + +These are follow-on questions. Any favorable physical caller still needs +its complete producer/consumer contract and paid bill before expansion. + +## Verification implementation bounds + +There is no recursion or dynamic code loading. Every matrix has dimension +at most 16, every scalar numerator and denominator is bounded by 2^256, +matrix powers use at most 32 factors, polynomials have at most 33 bounded +integer coefficients, and the factor domain ends at 4095. Pauli loops have +at most 256 labels and eight generators. Every function is below 60 lines. +Explicit invariant failures remain active under optimized Python. + +Power of Ten rule 3 has a managed-runtime deviation at verify.py: Python +allocates integer, tuple and dictionary objects during exact arithmetic. +Fixed dimensions, bit capacities, factor bounds and sequential fixtures +bound live collections. No asynchronous resources or retained output files +exist. Rule 8 uses the standard dataclass decorator for one fixed four-field +immutable record; it loads no external schema or executable input. Rule 9 +uses reduce with the single built-in gcd target over at most 512 integers. +Warning-strict normal and optimized runs plus AST compilation supply the +available Python diagnostics. A static type-checking configuration is not +introduced for this isolated research package. A future larger replay must +reassess these capacities before raising them. + +New work is Apache-2.0. Exact predecessor pins and credit are in +[SOURCES.json](SOURCES.json) and [PROOF.md](PROOF.md). diff --git a/research/odd-cyclotomic-response/SOURCES.json b/research/odd-cyclotomic-response/SOURCES.json new file mode 100644 index 0000000000..48b249b7d7 --- /dev/null +++ b/research/odd-cyclotomic-response/SOURCES.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "base_commit": "a5bff3bf133e482541c09eba4e773884bdb2b1b7", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a", + "sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/skew-cubic-response-gates/README.md", + "usage": "provenance", + "git_blob": "83ddd8f53075f8b346ebd601022f09998c8a1422", + "sha256": "00e559ae7e58141172ebe71b7182095f6adce72895d935e2124eb75e9fd789e9" + }, + { + "path": "research/skew-cubic-response-gates/source/general-clifford-retiming/order-three-response/PROOF.md", + "usage": "provenance", + "git_blob": "2a3b557c2a72679d24635bbaf8ed48394cb8a1c3", + "sha256": "d1c56a1bcb0d78dd830d2731e60805b8f86cbfe667a8ae8beb436c581ab33ca3" + } + ], + "classical_reference": { + "author": "Romyar Sharifi", + "title": "Abstract Algebra, Theorem 6.6.11", + "url": "https://math.ucla.edu/~sharifi/notes/algebra-ch06.html", + "use": "Classical cyclotomic irreducibility; no code or text copied." + } +} diff --git a/research/odd-cyclotomic-response/TASK.json b/research/odd-cyclotomic-response/TASK.json new file mode 100644 index 0000000000..0a8a97b874 --- /dev/null +++ b/research/odd-cyclotomic-response/TASK.json @@ -0,0 +1,99 @@ +{ + "schema_version": 1, + "task_id": "joint-query-controller", + "priority_revision": 8, + "base_commit": "a5bff3bf133e482541c09eba4e773884bdb2b1b7", + "original_card": { + "id": "joint-query-controller", + "question": "Can a changed query demand or caller remove real work while satisfying native chronology and restoration?", + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md" + ], + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "acceptance_gate": "A source-bound arbitrary-input identity and legal producer/consumer boundary with the complete paid and productive target invoice, including restoration, ownership, native alignment and extra charges. Price under the actual current model; historical ceiling.py assumptions must be established before use. A favorable optimistic relaxation keeps a route open but is not a completed supplier. A scoped local result remains useful; expansion requires the family-level budget gate.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "first_experiment": "Choose an exact caller and a new demand/interface hypothesis. Read the scoped #5617/#5631/#5649/#5747 and #5720/#5745 objections before rebuilding an excluded schedule. Compare the complete matched source/consumer protocols including all retained helper outputs. For an active-mode injection, first check #5745: its canonical delivery claim repays the eight removed centre jobs. Audit that exact claim or change its channel/feedback hypothesis; do not repeat the same free-injection search. Stop if the full favorable budget fails or the required restored output is unobservable.", + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "overlap_terms": [ + "query demand", + "active mode", + "5720", + "5745", + "5747", + "caller" + ], + "existing_checks": [ + { + "scope": "PR #4166: author-checked installed producer/service/return/bridge connection; native-component comparison loses.", + "evidence": "research/qq16-caller-install/README.md", + "remaining": "Complete matched physical protocol bill, or changed source-compatible demand/circuit; no affordable supplier yet.", + "status": "author-checked", + "source_commit": "0b082d22a0e9a442d264ab0633e35ef26c790630", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Whole-bank odd cyclotomic Gaussian-rational Clifford response gate: necessary degree and exact symplectic defect, with a sharp degree-four native-rank example.", + "scope_change_reason": "This algebraic side result changes the response polynomial in PR4081 rather than auditing or implementing the installed QQ16 caller. It tests whether a fixed-degree primitive identity can retain unbounded native rank.", + "bottleneck_link": "A fixed-degree primitive response cannot provide unbounded native B rank. This screens one proposed interface before complete caller synthesis; no paid-moment or kappa gain follows.", + "budget_minutes": 60, + "stop_rule": "Ship the first scoped theorem and sharp degree-four example after exact bounded checks. No broader existence classification or physical caller construction.", + "outcome": "negative-result", + "evidence": "PROOF.md universal argument; verify.py exact finite number-theory and complete Clifford matrix evidence; generated stdout hash receipts.", + "author": "Nick Petalas", + "ai_assistance": "Independent human and formal proof-kernel review are unclaimed.", + "open_questions": [ + { + "question": "Which degree-permitted odd n admit whole-bank Gaussian-rational Clifford responses?", + "why_it_matters": "The theorem proves only necessary existence conditions.", + "first_step": "Construct one primitive order-seventeen Clifford and its complete Pauli action.", + "blocked_by": "No general sufficiency construction is supplied." + }, + { + "question": "What native-rank bounds survive a fixed product of distinct odd cyclotomic factors?", + "why_it_matters": "Several response factors can evade the nonzero trace mechanism.", + "first_step": "Derive multiplicity and trace constraints for Phi3 times Phi5 before any caller synthesis.", + "blocked_by": "The adjoint trace can vanish; full caller costs remain unpriced." + } + ], + "source_pr": 4081, + "source_author": "RossRichardson", + "source_head": "f303d156a886d4ee866c926ec8439fde8d1dd63d", + "claim_url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19272042", + "overlap": { + "checked_at": "2026-10-29T16:13:00Z", + "main": "a5bff3bf133e482541c09eba4e773884bdb2b1b7", + "coverage": "All open PR bodies and Discussion records in a refreshed cache; all main research README matches for distinctive terms; targeted merged-PR searches. Sparse working-tree note inventory is incomplete, and unpublished work is not covered." + } +} diff --git a/research/odd-cyclotomic-response/VERIFY.json b/research/odd-cyclotomic-response/VERIFY.json new file mode 100644 index 0000000000..0d3a585870 --- /dev/null +++ b/research/odd-cyclotomic-response/VERIFY.json @@ -0,0 +1,32 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 30, + "checks": "Exact bounded totient/Fermat equivalence, complete degree-four Clifford and sharp native-rank matrices, full fixed-Pauli traces, order/phase/unitarity and domain controls; generated package hashes." + }, + { + "argv": [ + "{python}", + "-W", + "error", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 30, + "checks": "Exact bounded totient/Fermat equivalence, complete degree-four Clifford and sharp native-rank matrices, full fixed-Pauli traces, order/phase/unitarity and domain controls; generated package hashes." + } + ] +} diff --git a/research/odd-cyclotomic-response/verify.py b/research/odd-cyclotomic-response/verify.py new file mode 100644 index 0000000000..7389faa2dc --- /dev/null +++ b/research/odd-cyclotomic-response/verify.py @@ -0,0 +1,312 @@ +#!/usr/bin/env python3 +"""Exact finite evidence. Produced by Nick Petalas. Apache-2.0.""" +from dataclasses import dataclass +from fractions import Fraction +from functools import reduce +import hashlib +import json +from math import gcd, lcm +from pathlib import Path + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +@dataclass(frozen=True) +class Matrix: + n: int + real: tuple + imag: tuple + denominator: int = 1 + + def __post_init__(self): + require(1 <= self.n <= 16, "matrix dimension outside 1..16") + require(len(self.real) == len(self.imag) == self.n**2, "matrix shape") + require(1 <= self.denominator <= 2**256, "denominator capacity") + require(all(type(x) is int and abs(x) <= 2**256 + for x in self.real + self.imag), "numerator capacity") + + +def matrix(rows, denominator=1): + n = len(rows) + require(1 <= n <= 16 and type(denominator) is int and denominator > 0, + "matrix input domain") + require(all(len(row) == n for row in rows), "square rows required") + real = tuple(z[0] for row in rows for z in row) + imag = tuple(z[1] for row in rows for z in row) + common = reduce(gcd, real + imag, denominator) + return Matrix(n, tuple(x // common for x in real), + tuple(x // common for x in imag), denominator // common) + + +def identity(n): + require(type(n) is int and 1 <= n <= 16, "identity dimension") + return matrix([[(int(i == j), 0) for j in range(n)] for i in range(n)]) + + +def multiply(a, b): + require(a.n == b.n, "matrix multiplication dimension") + n = a.n + rows = [] + for i in range(n): + row = [] + for j in range(n): + real = imag = 0 + for k in range(n): + ar, ai = a.real[i*n+k], a.imag[i*n+k] + br, bi = b.real[k*n+j], b.imag[k*n+j] + real += ar*br - ai*bi + imag += ar*bi + ai*br + row.append((real, imag)) + rows.append(row) + return matrix(rows, a.denominator*b.denominator) + + +def add(a, b): + require(a.n == b.n, "matrix addition dimension") + d = lcm(a.denominator, b.denominator) + x, y = d // a.denominator, d // b.denominator + return matrix([[(x*a.real[i*a.n+j] + y*b.real[i*a.n+j], + x*a.imag[i*a.n+j] + y*b.imag[i*a.n+j]) + for j in range(a.n)] for i in range(a.n)], d) + + +def scale(a, real, imag=0): + return matrix([[(real*a.real[i*a.n+j] - imag*a.imag[i*a.n+j], + real*a.imag[i*a.n+j] + imag*a.real[i*a.n+j]) + for j in range(a.n)] for i in range(a.n)], a.denominator) + + +def adjoint(a): + return matrix([[(a.real[j*a.n+i], -a.imag[j*a.n+i]) + for j in range(a.n)] for i in range(a.n)], a.denominator) + + +def tensor(a, b): + require(a.n*b.n <= 16, "tensor dimension capacity") + rows = [] + for i in range(a.n*b.n): + row = [] + for j in range(a.n*b.n): + u, v = (i//b.n)*a.n+j//b.n, (i%b.n)*b.n+j%b.n + row.append((a.real[u]*b.real[v] - a.imag[u]*b.imag[v], + a.real[u]*b.imag[v] + a.imag[u]*b.real[v])) + rows.append(row) + return matrix(rows, a.denominator*b.denominator) + + +def power(a, k): + require(type(k) is int and 0 <= k <= 32, "power capacity") + result = identity(a.n) + for _ in range(k): + result = multiply(result, a) + return result + + +def trace(a): + return (Fraction(sum(a.real[i*a.n+i] for i in range(a.n)), a.denominator), + Fraction(sum(a.imag[i*a.n+i] for i in range(a.n)), a.denominator)) + + +def polynomial(a, coefficients): + require(1 <= len(coefficients) <= 33, "matrix polynomial capacity") + require(all(type(c) is int and abs(c) <= 32 for c in coefficients), + "matrix polynomial coefficient capacity") + result = scale(identity(a.n), 0) + for c in reversed(coefficients): + result = add(multiply(result, a), scale(identity(a.n), c)) + return result + + +def pauli(qubits, label): + require(1 <= qubits <= 4 and 0 <= label < 4**qubits, "Pauli capacity") + n = 2**qubits + x, z = label % n, label // n + phase = (x & z).bit_count() % 4 + unit = ((1, 0), (0, 1), (-1, 0), (0, -1))[phase] + rows = [[(0, 0)]*n for _ in range(n)] + for j in range(n): + sign = (-1)**((z & j).bit_count()) + rows[j ^ x][j] = (sign*unit[0], sign*unit[1]) + return matrix(rows) + + +def binary_rank(columns): + require(len(columns) <= 8 and all(0 <= x < 256 for x in columns), + "binary rank capacity") + basis = [0]*8 + rank = 0 + for column in columns: + for bit in range(7, -1, -1): + if column & (1 << bit): + if basis[bit]: + column ^= basis[bit] + else: + basis[bit] = column + rank += 1 + break + return rank + + +def clifford_record(u): + qubits = u.n.bit_length()-1 + require(u.n == 2**qubits and 1 <= qubits <= 4, "qubit dimension") + require(multiply(u, adjoint(u)) == identity(u.n), "unitarity") + lookup = {} + for label in range(4**qubits): + p = pauli(qubits, label) + lookup[p] = (label, 1) + lookup[scale(p, -1)] = (label, -1) + columns = [] + for bit in range(2*qubits): + image = multiply(multiply(u, pauli(qubits, 1 << bit)), adjoint(u)) + require(image in lookup, "not Clifford") + columns.append(lookup[image][0]) + defect = binary_rank([c ^ (1 << j) for j, c in enumerate(columns)]) + native = binary_rank([columns[qubits+j] % u.n for j in range(qubits)]) + fixed = [] + character_sum = 0 + for label in range(4**qubits): + image_label = 0 + for bit in range(2*qubits): + if label & (1 << bit): + image_label ^= columns[bit] + if image_label == label: + image = multiply(multiply(u, pauli(qubits, label)), adjoint(u)) + require(image in lookup and lookup[image][0] == label, "fixed label") + character_sum += lookup[image][1] + fixed.append(label) + tr = trace(u) + require(tr[0]**2 + tr[1]**2 == character_sum, "adjoint trace identity") + return {"qubits": qubits, "trace": [str(x) for x in tr], + "symplectic_defect_rank": defect, "native_B_rank": native, + "fixed_labels": len(fixed), "fixed_character_sum": character_sum} + + +def fixture_checks(): + # H_g=(1+i)H/sqrt(2); U5=-CNOT_(0->1) S_0 (H_g tensor H_g). + h = matrix([[(1, 1), (1, 1)], [(1, 1), (-1, -1)]], 2) + s = matrix([[(1, 0), (0, 0)], [(0, 0), (0, 1)]]) + c = permutation([0, 1, 3, 2]) + u = scale(multiply(multiply(c, tensor(s, identity(2))), tensor(h, h)), -1) + displayed = matrix([[(0, -1), (0, -1), (0, -1), (0, -1)], + [(0, -1), (0, 1), (0, -1), (0, 1)], + [(1, 0), (-1, 0), (-1, 0), (1, 0)], + [(1, 0), (1, 0), (-1, 0), (-1, 0)]], 2) + require(u == displayed, "displayed matrix and literal circuit agree") + zero = scale(identity(4), 0) + require(power(u, 5) == identity(4), "degree-four order") + require(polynomial(u, (1, 1, 1, 1, 1)) == zero, "primitive degree four") + basic = clifford_record(u) + require(basic["symplectic_defect_rank"] == 4, "degree-four defect") + # Bell preparation on (0,2),(1,3), with two spectator qubits. + bell_h = tensor(tensor(h, h), identity(4)) + bell_c = permutation([j ^ (((j >> 3) & 1) << 1) ^ (((j >> 2) & 1)) + for j in range(16)]) + bell = multiply(bell_c, bell_h) + sharp_u = multiply(multiply(adjoint(bell), tensor(u, identity(4))), bell) + require(polynomial(sharp_u, (1, 1, 1, 1, 1)) == scale(identity(16), 0), + "Bell primitive response") + sharp = clifford_record(sharp_u) + require(sharp["native_B_rank"] == sharp["symplectic_defect_rank"] == 4, + "sharp degree-four native rank") + mixed = tensor(u, u) + require(power(mixed, 5) == identity(16), "tensor order control") + require(polynomial(mixed, (1, 1, 1, 1, 1)) != scale(identity(16), 0), + "order alone is not primitive response") + mixed_record = clifford_record(mixed) + require(mixed_record["symplectic_defect_rank"] == 8, "tensor defect control") + require(polynomial(scale(u, 0, 1), (1, 1, 1, 1, 1)) != zero, + "global phase matters") + require(polynomial(power(u, 2), (1, 1, 1, 1, 1)) == zero, + "primitive-power positive control") + return {"degree_four": basic, "sharp_degree_four": sharp, + "order_only_tensor_control": mixed_record} + + +def permutation(images): + n = len(images) + require(1 <= n <= 16, "permutation dimension") + require(sorted(images) == list(range(n)), "permutation required") + return matrix([[(int(i == images[j]), 0) for j in range(n)] for i in range(n)]) + + +def factors(n): + require(type(n) is int and 1 <= n <= 4095, "factor domain 1..4095") + result = [] + remaining = n + for p in range(2, n+1): + if remaining % p == 0: + exponent = 0 + for _ in range(n.bit_length()): + if remaining % p: + break + exponent += 1 + remaining //= p + result.append((p, exponent)) + require(remaining == 1, "factor exhaustion") + return result + + +def number_checks(): + permitted = [] + cases = 0 + for n in range(3, 4096, 2): + fs = factors(n) + phi = sum(gcd(k, n) == 1 for k in range(1, n+1)) + product = 1 + for p, exponent in fs: + product *= p**(exponent-1)*(p-1) + require(product == phi, "totient independent enumeration") + power_two = phi & (phi-1) == 0 + squarefree_fermat = all(e == 1 and (p-1) & (p-2) == 0 for p, e in fs) + require(power_two == squarefree_fermat, "odd degree classification") + if power_two: + permitted.append([n, phi, 2*(phi.bit_length()-1)]) + cases += 1 + require(all(n not in (7, 9, 25, 27) for n, _, _ in permitted), "excluded orders") + return {"odd_orders_checked": cases, "degree_permitted_orders": permitted} + + +def rejection_checks(): + rejected = 0 + for n in (0, 4096, -1, Fraction(3)): + try: + factors(n) + except ValueError: + rejected += 1 + else: + raise ValueError("factor domain accepted invalid value") + require(rejected == 4, "domain rejection count") + # Phi5 alone does not imply the Clifford or unitary hypothesis. + companion = matrix([[(0, 0), (0, 0), (0, 0), (-1, 0)], + [(1, 0), (0, 0), (0, 0), (-1, 0)], + [(0, 0), (1, 0), (0, 0), (-1, 0)], + [(0, 0), (0, 0), (1, 0), (-1, 0)]]) + require(polynomial(companion, (1, 1, 1, 1, 1)) == scale(identity(4), 0), + "companion primitive positive algebra control") + try: + clifford_record(companion) + except ValueError as error: + require(str(error) == "unitarity", "companion rejection reason") + rejected += 1 + else: + raise ValueError("nonunitary companion accepted") + return rejected + + +def main(): + result = {"status": "PASS_ODD_CYCLOTOMIC_RESPONSE", "claim_type": "scoped-proof", + "number_theory": number_checks(), "matrices": fixture_checks(), + "invalid_domain_and_unitarity_rejections": rejection_checks()} + directory = Path(__file__).resolve().parent + names = ("README.md", "PROOF.md", "TASK.json", "SOURCES.json", "VERIFY.json", "verify.py") + result["package_sha256"] = { + name: hashlib.sha256((directory / name).read_bytes()).hexdigest() for name in names} + print(json.dumps(result, indent=2, sort_keys=True)) + + +if __name__ == "__main__": + main()