diff --git a/WORKSPACE.md b/WORKSPACE.md index dd05eaa..1f97d72 100644 --- a/WORKSPACE.md +++ b/WORKSPACE.md @@ -11,15 +11,13 @@ Manuscript drafting and the changed-decoder supplement are separate tasks. ## Current checkpoint -Verified baseline: [PR #267](https://github.com/GoGoKo699/Hopf-Frame-Compilation/pull/267), -`68f0ce342bf105e4b3aa3b1a7c5d76c3f579998b`, 28 October 2026. -Its reviewed tree passed 2,020 tests locally and in both CI versions, plus the full gate and presentation checks. -Fetch current main; this baseline is not a pin. Exact-tree receipts belong in the PR record. +Verified baseline: [PR #268](https://github.com/GoGoKo699/Hopf-Frame-Compilation/pull/268), +`156f2cd4f5bc2e3c3d1f4afec17b31d0627764d3`, 28 October 2026. +Its reviewed tree passed 2,035 tests locally and in both CI versions, plus the full gate and presentation checks. Read the [resource frontier](docs/OPEN_PROBLEM.md) for general theorems, then the [route decisions](research/ROUTE_DECISIONS.md) for the chosen mechanism. Use the [research catalogue](research/README.md) to find its proof dependencies. -The source, decoder and copy screens are integrated; none improves R96. @@ -123,27 +121,29 @@ requires strong cross-commutators on every independent address pair; monomial query-eigenbasis seeds have a half-error floor. The full-Hadamard field seed passes the mixing test but still has a half-error spectral floor. -The [flat-seed four-address pilot](research/depth/FLAT_FIELD_BANK_PILOT.md) has a six-T, -three-band decoder and a complete 72-T, 28-band indicator with three dirty wires. -Its full intertwiner has a Clifford completion; no uniform decoder is yet paid. -The [Clifford-seed bounds](research/depth/CLIFFORD_SEED_COPY_STRUCTURE.md) give -error at least 1/64 for p at least seven for projectively involutive seeds with commuting symplectic orbits, -even for an arbitrary copy. For p at least nine, every Clifford seed has one-band -copy error at least $`\sin(\pi/8)`$, without an orbit-commutation assumption. - -[One-band copy feasibility](research/depth/ONE_BAND_COPY_FEASIBILITY.md) -gives signed Walsh slices, their spectrum and the complete carrier fixed point. -All output probes alone can miss wrong carrier action. The triple-axis joint walls -pass the tensor screen but have zero complete seed space for p at least two, -and full copy error at least $`1/\sqrt6`$ for every unitary seed. This family is stopped. -The [Clifford-dual grading](research/depth/CLIFFORD_DUAL_COPY_GRADING.md) requires each -output dual's symplectic orbit group to have binary abelianization rank at least -$`m-p-1`$ exactly. An odd-order pair gives an explicit robust word obstruction. -The [seed fingerprint](research/depth/NATIVE_COPY_INTERACTION.md#seed-coefficient-rigidity) -excludes product THT-dagger seeds below 3/32 for every one-band field copy at p at least two. -**Next question:** extend the flat decoder uniformly, allowing the complete probe's -commutant freedom, with sublogarithmic depth and polynomial discovery budgets. -The joint seed/copy alternative remains open; two-band V and one-band C would give 42 bands conditionally. +The [flat four-address pilot](research/depth/FLAT_FIELD_BANK_PILOT.md) retains its six-T decoder and complete 72-T indicator. +The [projective recoupler](research/depth/PROJECTIVE_FIELD_RECOUPLER.md) now pays an exact eight-address full decoder: +172 T gates, at most 83 bands, eight arbitrary wires and no extra helpers. Selected reflection phases cancel jointly. +Projective-line enumeration grows exponentially in field degree; this is a finite calibration. + +[Pauli-domain rigidity](research/depth/FIELD_DECODER_PAULI_DOMAIN.md) requires absorbed-axis rank at least $`2m-2`$, +including moving Clifford helpers. Independent finite cells fail even with joint outer Clifford walls. +The [two-band screen](research/depth/TWO_BAND_FIELD_DECODER_OBSTRUCTION.md) excludes disjoint +absorbed spans at fixed error; shared-span collisions and coupled three-band words remain open. +The [scalar-field radical model](research/depth/SCALAR_FIELD_RADICAL_COPY_SCREEN.md) +has a four-address identity for every address embedding; changing its address space does not repair it. +These restrictions do not exclude the weaker complete-probe decoder contract. + +The [Clifford-seed bounds](research/depth/CLIFFORD_SEED_COPY_STRUCTURE.md) retain their +commuting-orbit and one-band-copy scopes. The [seed fingerprint](research/depth/NATIVE_COPY_INTERACTION.md#seed-coefficient-rigidity) +excludes product THT-dagger seeds below 3/32 for one-band field copies at p at least two. +[Complete copy feasibility](research/depth/ONE_BAND_COPY_FEASIBILITY.md) still requires +the carrier equation; triple-axis joint walls have zero full seed space. +[Clifford-dual grading](research/depth/CLIFFORD_DUAL_COPY_GRADING.md) requires binary +abelianization rank at least $`m-p-1`$; explicit relation words give robust floors. +**Next question:** jointly resynthesize the projective corrections and recursive levels, +using zero-sector and complete-probe freedom, within sublogarithmic depth and polynomial budgets. +The joint seed/copy alternative remains open; no uniform decoder or improved R96 bound is supplied. The [four-band Clifford front end](research/depth/CLIFFORD_INVOLUTION_SOURCE.md), [weighted outer-phase route](research/depth/JOINT_ADDRESS_HELPER_SOURCE.md), diff --git a/docs/reference/VERIFICATION_CATALOGUE.md b/docs/reference/VERIFICATION_CATALOGUE.md index db36419..5e10d8a 100644 --- a/docs/reference/VERIFICATION_CATALOGUE.md +++ b/docs/reference/VERIFICATION_CATALOGUE.md @@ -282,6 +282,10 @@ without an extra native fixture. | Monomial query seed | [Proof](../../research/depth/MONOMIAL_QUERY_SEED_OBSTRUCTION.md), [exact fixtures](../../tests/test_monomial_query_seed_obstruction.py) | Non-Hermitian phases, shifted planes, Fourier field queries and arbitrary helper mixing check the alternating word. A nonmonomial escape guards the hypothesis. Rational/native commutator fixtures and an exact order-three Hadamard pilot check the stronger mixing requirement and its insufficiency. All-size floors are analytic; escape alone supplies no source | | Finite Clifford field copy | [Proof](../../research/depth/FIELD_COPY_CLIFFORD_PILOT.md), [algebra fixtures](../../tests/test_field_copy_clifford_pilot.py), [native fixtures](../../tests/test_field_copy_clifford_native.py) | Exact seed and central-sector algebra; all sector-controlled native factors and actual inverses; all 16 output-X copy sectors; every principal/dirty query column and the finite ledgers. The copy indicator has 288 T gates, 96 bands and seven dirty wires; reusing the improved query in the direct decoder gives 300 T, 160 bands and three dirty wires. Both assembled native directions are checked; neither is an all-size compiler | | Flat field bank and six-T decoder | [Proof](../../research/depth/FLAT_FIELD_BANK_PILOT.md), [native fixtures](../../tests/test_flat_field_bank_native.py), [dual and completion fixtures](../../tests/test_flat_field_bank_duals.py) | Exact flat seed, full commuting-bank grading, three physical decoder bands, literal copy action, full intertwiner completion and actual inverses. All 512 direct-indicator columns retain arbitrary address, output and dirty-mask inputs and literal phases. The 72-T, 28-band, 350-gate finite word uses three returned dirty wires. Exact signed-support enumeration proves no Clifford singleton dual; its gap is scoped to this seed. No uniform compiler or minimum-cost claim | +| Projective field recoupler | [Proof](../../research/depth/PROJECTIVE_FIELD_RECOUPLER.md), [native fixtures](../../tests/test_projective_field_recoupler.py) | Exact field Fourier walls, all projective fibers, literal paired-reflection tables, borrowed-wire quartic phases, all 240 nonzero-U recoupler columns, every actual-inverse column and all eight full-query intertwinings retain scalar phases and arbitrary inputs. The 172-T, 83-band finite full decoder uses eight wires and no extra helpers; exponential line enumeration gives no uniform compiler | +| Complete field decoder Pauli domain | [Proof](../../research/depth/FIELD_DECODER_PAULI_DOMAIN.md), [exact fixtures](../../tests/test_field_decoder_pauli_domain.py) | Literal field derivatives, second-difference masks, the moving-helper quotient, its essential boundary example, and the finite decoder domain check the robust all-size proof. The absorbed-axis and T-count floor is $`2m-2`$, including arbitrary Clifford target-helper motion; it is not a depth bound or a restriction on the weaker probe contract | +| Disjoint-span two-band field decoder | [Proof](../../research/depth/TWO_BAND_FIELD_DECODER_OBSTRUCTION.md), [exact fixtures](../../tests/test_disjoint_two_band_decoder.py) | Exact collision-free Pauli supports, the sharp two-term fingerprint gap, partial-band normalization, moving residual-query deviations and actual shared-span collisions test the scope. The analytic fixed error floor permits arbitrary Clifford helper motion; overlapping bands remain open | +| Scalar-field radical copy screen | [Proof](../../research/depth/SCALAR_FIELD_RADICAL_COPY_SCREEN.md), [exact fixtures](../../tests/test_scalar_field_radical_copy.py) | Complete small equivariant bilinear-product kernels, multiple banks, fixed helpers and changed address scalars support the square-zero image lemma. A one-address counterexample guards the threshold, and all-column regular affine words check the four-address relation. Direct-copy and output-dual floors concern the stated associative-algebra model only | | Seed coefficient and fingerprint rigidity | [Proof](../../research/depth/NATIVE_COPY_INTERACTION.md#seed-coefficient-rigidity), [exact fixtures](../../tests/test_seed_fingerprint.py) | Exact Pauli correlation levels, helper subgroup preservation, paired-axis normalizers, literal one-cell Clifford overlaps and affine scalar words challenge the analytic rigidity proof. Unique maxima give a coefficient-gap floor; product THT-dagger seeds give 3/32 independently of width, under Clifford output duals and arbitrary fixed Clifford embedding. Flat seeds and unrestricted copies are outside that product theorem | | Clifford seed copy structure | [Proof](../../research/depth/CLIFFORD_SEED_COPY_STRUCTURE.md), [nested-cube fixtures](../../tests/test_clifford_seed_copy_structure.py), [one-band fixtures](../../tests/test_one_band_clifford_seed.py) | Degree inflation, literal scalar phases and a complete 128-address field word support the commuting-orbit theorem. Exact signed affine-axis and modulo-four phase checks support the separate one-band theorem for every Clifford seed: error at least $`\sin(\pi/8)`$ for p at least nine. The analytic rigidity and degree-eight proof permit arbitrary dirty width and joint Clifford walls; non-Clifford seeds and general copies remain outside that second theorem | | Clifford output-dual grading | [Proof](../../research/depth/CLIFFORD_DUAL_COPY_GRADING.md), [exact fixtures](../../tests/test_clifford_dual_copy_grading.py) | Regular-module annihilators, Pauli-kernel transport and literal relation-word checks support the necessary symplectic-group quotient. Each exact one-band output dual needs binary abelianization rank at least $`m-p-1`$, for arbitrary unitary seeds. Quantitative gaps require explicit bounded words; the group-rank bound itself is exact and does not exclude every one-band copy | diff --git a/research/README.md b/research/README.md index 13b4f70..d2ba23a 100644 --- a/research/README.md +++ b/research/README.md @@ -199,6 +199,10 @@ These are complete interfaces and conditional transfers, not constructions of th - [Monomial query-seed copy obstruction](depth/MONOMIAL_QUERY_SEED_OBSTRUCTION.md) — commuting original and seed-conjugated query algebras force a four-word identity and copy error at least one half, even with an arbitrary physical copy - [Four-address Clifford seed and physical copy](depth/FIELD_COPY_CLIFFORD_PILOT.md) — a noncommuting central-sector grading, a paid native copy and a complete 288-T, 96-band finite indicator with seven arbitrary dirty wires - [Flat-seed field bank and six-T decoder](depth/FLAT_FIELD_BANK_PILOT.md) — a genuinely non-Clifford graded four-address bank, a three-band decoder with a full Clifford intertwiner completion, and a complete 72-T, 28-band indicator with three returned dirty wires; no all-size depth improvement +- [Projective field recoupler](depth/PROJECTIVE_FIELD_RECOUPLER.md) — projective homogeneity, an allowed emitted zero fiber, and joint selected-reflection phases give a complete eight-address native decoder with 172 T gates, at most 83 bands, eight arbitrary wires and no extra helpers; line enumeration is not a uniform polynomial-budget construction +- [Complete field decoder Pauli domain](depth/FIELD_DECODER_PAULI_DOMAIN.md) — a robust $`2m-2`$ absorbed-axis and T-count requirement, including arbitrary Clifford motion of decoded helpers; independent finite cells fail even with joint outer Clifford walls +- [Disjoint-span two-band field decoders](depth/TWO_BAND_FIELD_DECODER_OBSTRUCTION.md) — a uniform error floor for partial or full bands with zero span intersection, including arbitrary source identity helpers and Clifford target-helper motion; shared-span cancellation remains outside the theorem +- [Scalar-field radical copy screen](depth/SCALAR_FIELD_RADICAL_COPY_SCREEN.md) — algebra-automorphism equivariance forces a square-zero shear image and a four-address relation for every address embedding, giving direct-copy error at least one half and output-dual copy error at least one quarter - [Clifford seed copy structure](depth/CLIFFORD_SEED_COPY_STRUCTURE.md) — projectively involutive seeds with commuting symplectic orbits have a 1/64 field-copy floor at p at least seven for arbitrary copies; every Clifford seed has a $`\sin(\pi/8)`$ floor at p at least nine when the copy has one physical T band - [Joint bank routing and the complete dirty indicator](depth/JOINT_ROUTING_INDICATOR_INTERFACES.md) diff --git a/research/ROUTE_DECISIONS.md b/research/ROUTE_DECISIONS.md index d00d601..7797199 100644 --- a/research/ROUTE_DECISIONS.md +++ b/research/ROUTE_DECISIONS.md @@ -25,7 +25,11 @@ Start with a complete interface; consult component families only when the propos | [Localized non-Clifford copy repair](depth/COPY_AXIS_SPAN.md) | A one-shear orbit requires at least $`m-p-1`$ independent physical-X directions in the copy rotation-axis span exactly, and an extensive span at constant error below square root two. | This span bound alone does not exclude a broad one-band copy; pay it jointly with the seed. This is a count/span screen, not a growing depth obstruction. | | [Monomial seed in query eigen-coordinates](depth/MONOMIAL_QUERY_SEED_OBSTRUCTION.md) | Copy error is at least one half for p at least two, even for arbitrary non-Clifford copies. The broader screen is commutation of original and seed-conjugated query algebras. | Break that algebra condition with genuine eigenspace mixing and certify the complete copy. Nonlinear reversible permutations or phases in the same query eigenbasis do not suffice. The all-Hadamard field seed passes the quantitative mixing test but still has a half-error floor from an order-three orbit-pair product. | | [Finite Clifford field copy](depth/FIELD_COPY_CLIFFORD_PILOT.md) | A noncommuting four-address Clifford orbit has a central-sector grading and a paid physical copy. Its indicator uses 288 T gates, at most 96 bands and seven arbitrary dirty wires. The same cheaper query improves the direct decoder to 300 T, 160 bands and three dirty wires; the copy's depth gain costs more workspace and total gates. | Use its explicit sector-control construction as a component, not an all-size compiler. Its Pauli-valued commutators fall under the eventual obstruction below. | -| [Flat field bank and shallow finite decoder](depth/FLAT_FIELD_BANK_PILOT.md) | A genuinely non-Clifford four-address seed has full commuting-bank grading. A six-T three-band decoder yields a 12-T six-band complete copy and a cheaper direct indicator with 72 T gates, at most 28 bands, 350 total gates and three returned dirty wires. A separate Clifford completion makes the decoder a full field intertwiner. The same seed has one-band copy error at least $`1/(2\sqrt2)`$. | Extend the decoder uniformly within the polynomial discovery budgets and sublogarithmic depth, allowing the complete probe's commutant freedom. A full intertwiner below error one needs axis pairing rank at least $`m-2`$ on the query-fixed Pauli space; disjoint cells retaining all their core-fixed controls fail. This rank condition does not constrain the weaker one-probe decoder. The finite words establish no asymptotic bound or minimum cost. | +| [Flat field bank and shallow finite decoder](depth/FLAT_FIELD_BANK_PILOT.md) | A genuinely non-Clifford four-address seed has full commuting-bank grading. A six-T three-band decoder yields a 12-T six-band complete copy and a direct indicator with 72 T gates, at most 28 bands, 350 total gates and three returned dirty wires. A separate Clifford completion makes it a full field intertwiner. The same seed has one-band copy error at least $`1/(2\sqrt2)`$. | Extend the decoder uniformly within polynomial discovery budgets and sublogarithmic depth, allowing the complete probe's commutant freedom. The finite words establish no asymptotic bound or minimum cost; full-intertwiner restrictions are separated below from the weaker probe contract. | +| [Projective field recoupler](depth/PROJECTIVE_FIELD_RECOUPLER.md) | Projective homogeneity reduces each nonzero conditional cell to one Clifford per field line and a linear displacement. A common baseline and paired-reflection phase cancellation give a complete eight-address decoder with 172 T gates, at most 83 bands, eight arbitrary wires and no extra helpers. Its emitted zero fiber needs no separate detector. | Jointly synthesize the projective action or change its representation. Enumerating the lines costs exponentially many factors in bank width, and separate recursive levels retain depth contributions. This is a finite native calibration, not an improved general indicator or frame-depth bound. | +| [Full decoder Pauli domain](depth/FIELD_DECODER_PAULI_DOMAIN.md) | At p at least three, absorbed axes must span at least $`2m-2`$ directions below error $`\sqrt2/6`$ with arbitrary Clifford target-helper motion, or below one-third for identity and residual-field helpers. Independent finite cells fail even after joint outer Clifford mixing. | Couple the non-Clifford bands themselves or use the weaker complete-probe contract. The required extensive T count fits the discovery budget and gives no growing depth lower bound. Enlarging the active field and moving Clifford helpers do not remove this rank requirement. | +| [Disjoint-span two-band decoder](depth/TWO_BAND_FIELD_DECODER_OBSTRUCTION.md) | Partial or full bands whose absorbed spans have zero intersection have full-intertwining error at least $`\frac12\sqrt{1-1/\sqrt2}`$ for p at least two, including enlarged sources and arbitrary Clifford target-helper action. Intrinsic two-term Pauli images recover the outer axis list. | An eligible two-band word must exploit actual shared-span collisions; general overlapping bands remain open. A coupled three-band word or a non-Clifford endpoint satisfying only the complete-probe equation also leaves this screen. | +| [Scalar-field radical algebra](depth/SCALAR_FIELD_RADICAL_COPY_SCREEN.md) | Algebra-automorphism equivariance forces the shear image to be square-zero for every address embedding at p at least two. The resulting four-address identity gives direct-copy error at least one half or selected-output-dual copy error at least one quarter, with arbitrary identical field banks and fixed helpers. | Leave the associative-algebra realization or the scalar-shear automorphism assumptions. Changed address embeddings, including collision-free product spaces, do not repair this model. Arbitrary Clifford duals, general regular affine groups and non-scalar dressings remain outside the theorem. | | [Seed coefficient and fingerprint rigidity](depth/NATIVE_COPY_INTERACTION.md#seed-coefficient-rigidity) | A unique largest Pauli magnitude with gap g forces field-copy error at least g/2 for p at least two when a selected output dual is Clifford. Product THT-dagger seeds have the width-independent floor 3/32, even after an arbitrary Clifford embedding and with arbitrary identity helpers. | For a one-band copy, change the product seed and remove its distinguished Pauli witness; degeneracy alone is insufficient. Deeper copies with non-Clifford duals remain eligible, as the paid flat-bank pilot illustrates. This is a seed/readout restriction, not an all-two-band-seed or unrestricted-copy theorem. | | [Clifford seed copy structure](depth/CLIFFORD_SEED_COPY_STRUCTURE.md) | A projectively involutive Clifford seed with commuting symplectic orbit has field-copy error at least 1/64 for p at least seven, for an arbitrary copy. With one physical copy band, every Clifford seed has error at least $`\sin(\pi/8)`$ for p at least nine; no orbit commutation or seed-order assumption is needed. | A one-band field copy needs a genuinely non-Clifford seed at sufficiently small error. In $`R=VPV^\dagger`$, V must therefore use at least two T bands. A Clifford-seed route needs more copy bands and must still leave the older commuting-orbit class. Neither condition supplies a construction. | | [Clifford output-dual grading](depth/CLIFFORD_DUAL_COPY_GRADING.md) | Every exact one-band copy induces a copyable Clifford orbit at each physical output dual, even for an arbitrary unitary seed. Its symplectic orbit group needs elementary binary abelianization rank at least $`m-p-1`$ for the field query. Explicit symplectic relation words yield quantitative scalar-word tests; the rank bound alone has no uniform approximate gap. | Design a dual group that retains the required address grades, then satisfy the complete carrier equations and synthesize the seed. Noncommuting symplectic generators alone are insufficient. An odd-order orbit-pair product already gives a robust obstruction for p at least three, with its certified order in the denominator. | diff --git a/research/depth/ENCODED_DIRTY_COPY_INTERFACE.md b/research/depth/ENCODED_DIRTY_COPY_INTERFACE.md index 5a73d49..0fa12f9 100644 --- a/research/depth/ENCODED_DIRTY_COPY_INTERFACE.md +++ b/research/depth/ENCODED_DIRTY_COPY_INTERFACE.md @@ -278,6 +278,15 @@ genuinely non-Clifford seed, a 12-T six-band physical copy, and a cheaper direct indicator through its six-T three-band decoder. Extending that complete probe decoder uniformly is another concrete route; its finite word does not settle either all-size interface. +Full intertwiners must also meet the +[Pauli-domain requirement](FIELD_DECODER_PAULI_DOMAIN.md), including with +moving Clifford helpers, and the +[disjoint-span two-band screen](TWO_BAND_FIELD_DECODER_OBSTRUCTION.md). +These conditions do not restrict a decoder required only to transport the +complete physical probe. For the Clifford-dual alternative, an associative +algebra preserved by scalar-field shears has a +[four-address relation](SCALAR_FIELD_RADICAL_COPY_SCREEN.md) for every +address embedding; changing the field basis does not repair that model. For a Clifford seed, noncommuting symplectic dynamics are therefore necessary at arbitrarily small fixed error; non-Clifford seeds are another possibility. The complete dual readout, native inverse and every arbitrary-input sector diff --git a/research/depth/FIELD_DECODER_PAULI_DOMAIN.md b/research/depth/FIELD_DECODER_PAULI_DOMAIN.md new file mode 100644 index 0000000..39272ea --- /dev/null +++ b/research/depth/FIELD_DECODER_PAULI_DOMAIN.md @@ -0,0 +1,268 @@ +# Pauli-domain requirements for a complete field decoder + +[Flat four-address decoder](FLAT_FIELD_BANK_PILOT.md) · +[Encoded-copy contract](ENCODED_DIRTY_COPY_INTERFACE.md) · +[Pauli-domain localization](BOUNDED_DEFICIENCY_TRANSPORT.md#2-signed-localization-of-a-possibly-degenerate-domain) + +A complete decoder from the additive field query to wire translation must +move almost every physical Pauli out of the Pauli group. At three or more +address bits, its absorbed T axes span at least $`2m-2`$ binary directions, +where $`m=2^p`$ is the translated bank size. This remains necessary when the +decoded helper register has an arbitrary Clifford action. + +The conclusion concerns axis rank and T count. It gives no growing T-depth +bound and does not apply to a decoder constrained only on one physical probe. +In particular it does not improve R96 or pay an all-size decoder. + + + +## 1. Full-space statement, including moving helpers + +Let $`p\ge3`$, $`m=2^p`$, and let $`Q_x`$ be a literal additive field +shear of degree K, tensored with identity on h arbitrary helper qubits: + +```math +Q_x|u,v,w\rangle=|u,v+M_xu,w\rangle, +\qquad M_x=\sum_{i=0}^{p-1}x_iM_i. +``` + +Every nonzero $`M_x`$ is invertible. The source acts on $`n=2K+h`$ +qubits, and we require $`n\ge m`$. Its symplectic matrices satisfy +$`F_x=I+N_x`$ and $`N_xN_y=0`$. These conditions permit any injective +address subspace of the field, not only consecutive powers of its generator. + +The target has an m-qubit bank whose wires are indexed by +$`z\in\mathbb F_2^p`$, and $`q=n-m`$ other arbitrary qubits. Let + +```math +T_x=W_x\otimes R_x,\qquad W_x:z\longmapsto z+x, +``` + +where every $`R_x`$ is a Clifford. It may move the helper register; no +identity promise or additive representation law for R is needed here. +For an arbitrary unitary E define + +```math +\eta=\max_x\|EQ_xE^\dagger-T_x\|_{\rm op},\qquad +H_E=\{v:EP(v)E^\dagger\text{ is a signed Hermitian Pauli}\}. +``` + +The [retained domain argument](BOUNDED_DEFICIENCY_TRANSPORT.md#2-signed-localization-of-a-possibly-degenerate-domain) +makes $`H_E`$ a binary linear subspace, with an injective symplectic +label map under conjugation. Let A be the binary span of the actual axes +after all Cliffords in a native word for E have been absorbed to one side. + +**Theorem.** For arbitrary Clifford helper actions, + +```math +\eta\lt\frac{\sqrt2}{6} +\quad\Longrightarrow\quad +\dim H_E\le2+2q,\qquad \dim A\ge2m-2,\qquad T(E)\ge2m-2. + \qquad(1) +``` + +If every target query maps every Hermitian Pauli to a commuting Pauli, +the same conclusion holds under the stronger threshold + +```math +\eta\lt\frac13. \qquad(2) +``` + +Identity helper action and a residual field shear both satisfy this +condition. All comparisons concern the complete operator, with arbitrary +dirty inputs and reference entanglement. The theorem makes no assertion +that an approximately transported Pauli domain is query-invariant. + +## 2. Literal source derivatives and the target gap + +Use the Hermitian section $`P(a,b)=i^{a\cdot b}X^aZ^b`$, with the +dot product in the exponent taken over the integers. Field CNOT queries +map the ordered section $`X^aZ^b`$ without an extra phase. Their common +fixed-label space is + +```math +F=\mathrm{span}\{Z_u,X_v\}\oplus V_h, +\qquad \ker N_x=F\quad(x\ne0), \qquad(3) +``` + +where $`V_h`$ is the full helper Pauli space. Every fixed label is fixed +literally, including its sign. + +For any Hermitian Pauli P put $`P_x=Q_xPQ_x^\dagger`$. The derivative +$`P_xP`$ has label $`N_xv\in F`$, hence is fixed literally by every +query. Moreover P commutes with $`P_x`$: writing +$`v=(a_u,a_v,b_u,b_v)`$, their pairing is + +```math +\langle v,N_xv\rangle +=a_u\cdot M_x^Tb_v+b_v\cdot M_xa_u=0. \qquad(4) +``` + +Thus unequal source Paulis of this form have operator distance two. + +Fix $`v\in H_E`$, and write $`S=EPE^\dagger`$ and +$`U_x=EQ_xE^\dagger`$. Define + +```math +A_x=U_xSU_x^\dagger S=E(P_xP)E^\dagger,\qquad +B_x=T_xST_x^\dagger S. +``` + +The first is fixed by every $`U_y`$. The second is a scalar times a +Pauli, since the target is Clifford. Unitary telescoping gives + +```math +\|A_x-B_x\|\le2\eta,\qquad +\|T_yB_xT_y^\dagger-B_x\| +\le2\eta+2\|A_x-B_x\|\le6\eta. \qquad(5) +``` + +Two unequal Pauli operators with the same overall scalar convention +have distance at least $`\sqrt2`$. Hence (1) forces every $`B_x`$ to +be fixed literally by every target query. In the commuting-image case, +$`B_x`$ is Hermitian and commutes with its target conjugate; the gap is +two, giving (2). The latter condition holds for involutive wire +permutations and field shears separately, and for their tensor product. + +## 3. The helper quotient removes the apparent escape + +Let $`\mathcal U`$ be the image-label space of $`H_E`$. At the label +level, the conclusion of (5) says that every $`s\in\mathcal U`$ +has zero second target differences. In particular its two bank masks +obey + +```math +(\Pi_y-I)(\Pi_x-I)a=0,\qquad +(\Pi_y-I)(\Pi_x-I)b=0\quad\text{for every }x,y. +``` + +First translation differences are therefore constants, so + +```math +a(z)=a(0)+\alpha\cdot z,\qquad +b(z)=b(0)+\beta\cdot z. \qquad(6) +``` + +This conclusion concerns only the bank; the helper masks need not be +fixed. Let $`F_R`$ be the subspace of helper Pauli labels whose operators +are **literally** fixed by every $`R_x`$. It is linear because a product +of literally fixed Pauli operators is literally fixed, including its +scalar multiplication phase. Put $`f=\dim F_R`$ and project + +```math +\pi:\mathcal U\longrightarrow V_q/F_R. \qquad(7) +``` + +For $`s\in\ker\pi`$, the helper Pauli is fixed. The two linear forms +in (6) have a common nonzero kernel element x because $`p\ge3`$. +Thus $`T_xST_x^\dagger=S`$ literally. Comparing with the source gives + +```math +\|Q_xPQ_x^\dagger-P\| +=\|U_xSU_x^\dagger-S\|\le2\eta\lt2. +``` + +The source gap and (3) fix P under every query. Comparing again with +the target fixes S under every target query: $`2\eta\lt\sqrt2`$ +in (1), and the stronger commuting gap is also available in (2). + +The full target fixed space has dimension $`2+f`$: both bank masks +are constant, and the helper label belongs to $`F_R`$. Therefore + +```math +\dim\ker(\pi|_{\mathcal U})\le2+f,\qquad +\dim\mathcal U\le(2+f)+(2q-f)=2+2q. \qquad(8) +``` + +This proves the domain bound. It also explains why simply requiring an +individual moving-helper Pauli to have a nonzero target stabilizer would +be invalid: a nonfixed residual-field Pauli has none. Only the kernel +in (7) needs such a stabilizer. + +Every Pauli commuting with all absorbed axes remains a Pauli after E, +so $`A^\perp\subset H_E`$. Nondegeneracy of the n-qubit pairing gives + +```math +2n-\dim A\le2+2q,\qquad \dim A\ge2(n-q)-2=2m-2. +``` + +The T count is at least the span rank of its individual axes, proving +the remaining conclusions of (1). + + + +## 4. Identity helpers and a residual field query + +For the original field degree $`K=m/2`$ and identity target helpers, +$`q=h`$. Every element of $`H_E`$ is then source-fixed and its image +is target-fixed, not merely dimension bounded. At error below one-third, + +```math +\dim H_E\le2+2h,\qquad +\mathrm{rank}_{\rm symp}H_E\le2h. \qquad(9) +``` + +The two bank fixed labels, all-X and all-Z, commute because m is even. +The boundary $`p\ge3`$ is essential to this proof: at p equal to two, +the masks $`a(z)=z_0`$ and $`b(z)=z_1`$ have no common nonzero +translating stabilizer. The finite four-address decoder is consistent +with (9). + +For an enlarged field degree $`K=m/2+\delta`$, with +$`\delta\ge p`$, consider the allowed target + +```math +T_x=W_x\otimes Q_{\delta,x}\otimes I_h. +``` + +The residual full-rank field shear acts on $`2\delta`$ helper qubits. +The source and target characters agree: for nonzero x both traces are +$`2^{m/2+\delta+h}`$. This supports an abstract simultaneous +intertwiner, but does not pay its native word. In this target, (2) gives + +```math +\dim H_E\le2+4\delta+2h,\qquad +\mathrm{rank}_{\rm symp}H_E\le4\delta+2h,\qquad +\dim A\ge2m-2. \qquad(10) +``` + +For the symplectic rank statement, all affine bank masks in (6) pair +to zero at $`p\ge3`$: the summed product has degree at most two on +the p-dimensional binary cube. Only the helper coordinates contribute. +Thus moving Clifford helpers do not remove the extensive axis requirement. +Their actual motion and inverse calls must still be charged in a complete +indicator echo. + + + +## 5. Independent finite cells cannot give a growing decoder + +The [six-T four-address decoder D](FLAT_FIELD_BANK_PILOT.md) has exact +Pauli domain + +```math +H_D=\mathrm{span}\{X_0,X_2,X_3,X_1Z_0\}. +``` + +It has dimension four and symplectic rank two; each of these Paulis is +fixed with positive sign. The domain equals the symplectic orthogonal +complement of D's absorbed-axis span. + +Let $`m=4r=2^p`$ with $`p\ge3`$. A tensor product of r such cells +and q untouched physical helpers has a Pauli domain of dimension at +least $`4r+2q`$. Arbitrary fixed input and output Clifford walls preserve +that dimension, even when they mix cells and helpers. It exceeds the +$`2+2q`$ permitted by (1). Consequently this entire independent-cell +class fails full field-to-bank intertwining below $`\sqrt2/6`$ for +arbitrary Clifford target-helper actions, and below one-third for identity +or residual-field helper actions. + +Coupling the non-Clifford bands can change this domain and remains open. +The necessary axis count is compatible with the desired linear T budget; +neither this failure nor the count bound rules out constant-depth coupled +decoders. The separate [two-band screen](TWO_BAND_FIELD_DECODER_OBSTRUCTION.md) +also requires any successful two-band word to have intersecting absorbed +axis spans; it uses a different sparse-image argument. +The [focused fixtures](../../tests/test_field_decoder_pauli_domain.py) +check source phases, second differences, the helper quotient's boundary +case, and the finite domain. The all-size conclusion is the proof above. diff --git a/research/depth/FLAT_FIELD_BANK_PILOT.md b/research/depth/FLAT_FIELD_BANK_PILOT.md index efee82e..9d6c75c 100644 --- a/research/depth/FLAT_FIELD_BANK_PILOT.md +++ b/research/depth/FLAT_FIELD_BANK_PILOT.md @@ -383,6 +383,12 @@ every level; the still applies. The finite six-T identity does not supply that missing uniform construction, and R96 remains unchanged. +The [projective recoupler](PROJECTIVE_FIELD_RECOUPLER.md) uses this full +six-T intertwiner on both half banks to pay the next finite size. Its +eight-address decoder has 172 T gates and at most 83 bands without extra +helpers. Joint reflection phases and zero-fiber freedom reduce that word; +the exponential projective-line count still prevents uniform scaling. + ### A necessary test for extending the full intertwiner @@ -436,3 +442,13 @@ arbitrary three-band designs or a weaker probe-only construction. The [fixed-Pauli fixture](../../tests/test_flat_field_bank_duals.py) checks the two-control kernel, a failed eight-wire disjoint extension and the target Pauli-distance premise exactly. + +The stronger [Pauli-domain theorem](FIELD_DECODER_PAULI_DOMAIN.md) requires +absorbed-axis span at least $`2m-2`$ at p at least three, below error +one-third for identity or residual-field helpers and below $`\sqrt2/6`$ +for arbitrary Clifford helper motion. It excludes independent finite cells +even after arbitrary joint outer Clifford walls. The separate +[two-band theorem](TWO_BAND_FIELD_DECODER_OBSTRUCTION.md) gives a fixed +error floor when the two absorbed spans have zero intersection, including +partial bands. Neither statement excludes a coupled three-band decoder +or the weaker complete-probe contract. diff --git a/research/depth/PROJECTIVE_FIELD_RECOUPLER.md b/research/depth/PROJECTIVE_FIELD_RECOUPLER.md new file mode 100644 index 0000000..a77627a --- /dev/null +++ b/research/depth/PROJECTIVE_FIELD_RECOUPLER.md @@ -0,0 +1,262 @@ +# A projective-line recoupler and a paid eight-address decoder + +[Recursive field decoder](RECURSIVE_FIELD_SHEAR_DECODER.md) · +[Four-address flat decoder](FLAT_FIELD_BANK_PILOT.md) + +The top recursive field recoupler can be organized by projective lines instead +of treating every nonzero field input as a separate Clifford fiber. A common +unconditional Clifford removes every selected Fourier transform. The remaining +selected maps are binary-linear permutations and displacements. The zero fiber +is specified by the emitted product; it needs no separate nonzero flag. + +For three address bits this gives a complete native eight-wire intertwiner, +with every input arbitrary and no additional helper. It is a finite paid +calibration of the recursive construction. Enumerating the projective lines is +exponential in bank width, so the construction does not improve R96 or supply +the uniform depth bound required by the frame transfer. + + + +## 1. Homogeneity of the complete conditional cell + +Use the [recursive tower](RECURSIVE_FIELD_SHEAR_DECODER.md#1-a-compatible-tower-and-address-pencil). +At level p let $`F=K_{p-1}`$, $`K=F[\theta]`$, +$`\theta^2+\theta+\delta=0`$, and write +$`U=d_0+d_1\theta`$. Put + +```math +\nu(U)=d_0^2+d_0d_1+\delta d_1^2,\qquad q_0(U)=d_0d_1. +``` + +For nonzero U, the linear parts of the two controlled coordinate maps are + +```math +A_U=\begin{pmatrix} +d_0+d_1&d_0+(\delta+1)d_1\\ +d_1/\nu&(d_0+d_1)/\nu +\end{pmatrix},\qquad +B_U=\begin{pmatrix}d_0&\delta d_1\\d_1&d_0+d_1\end{pmatrix}. +``` + +Let $`L_M`$ denote the literal permutation $`|v\rangle\mapsto|Mv\rangle`$, +and let H denote the trace-pairing Fourier transform on the first F coordinate. +The complete middle cell of the recoupler is + +```math +K_U=X_{f_U}C_U,\qquad +C_U=L_{B_U}H L_{A_U},\qquad +f_U=B_U\binom{0}{q_0(U)/\nu(U)}. \qquad(1) +``` + +This includes the affine offset, which cannot be omitted when compiling the +literal operator. For every $`s\in F^\times`$, + +```math +A_{sU}=\mathrm{diag}(s,s^{-1})A_U,\qquad +B_{sU}=sB_U,\qquad f_{sU}=s f_U. \qquad(2) +``` + +The Fourier identity $`H L_s=L_{s^{-1}}H`$ holds literally for the trace +pairing, with no input-dependent or scalar phase. The two scalings in (2) +therefore cancel across H and give + +```math +C_{sU}=C_U,\qquad K_{sU}=X_{s f_U}C_U. \qquad(3) +``` + +Thus the nonzero inputs have only $`|F|+1`$ Clifford linear fibers, one for each +projective line in $`F^2`$. The displacement is F-linear along each line. This +statement is about the entire conditional operator, not only its symplectic +matrix or its action on a promised state. + + + +## 2. A common baseline removes selected Fourier transforms + +Choose line representatives $`\mathcal D=\{1\}\cup\{\theta+a:a\in F\}`$. +For D=1, $`B_1=I`$ and $`f_1=0`$, so $`C_1=H L_{A_1}`$. Apply $`C_1`$ +unconditionally. On the line represented by $`D\ne1`$, the required linear +correction is + +```math +C_D C_1^\dagger + =L_{B_D}H L_{A_D A_1^{-1}}H. \qquad(4) +``` + +Use the fixed linear change of the existing U register +$`U/D=s+t\theta`$. Its line predicate is exactly $`t=0`$. For each nonbaseline +D, apply the following complete factor and then undo that change of U: + +1. Apply H unconditionally on the first F coordinate of V. +2. Apply $`L_{A_D A_1^{-1}}`$ only when $`t=0`$. +3. Apply H unconditionally again. +4. Apply $`L_{B_D}`$ only when $`t=0`$. +5. Add $`s f_D`$ to V only when $`t=0`$. + +On a disabled line the two Fourier walls cancel. On an enabled line the factor +is $`X_{s f_D}C_D C_1^\dagger`$. Every nonzero U enables exactly one factor, +or none when U lies on the baseline line. Equation (3) then proves the required +cell on every nonzero input, including every V input and literal phase. + +The zero input belongs to all lines. There s=0, so all displacements vanish, +and the zero fiber is the explicitly ordered product + +```math +K_0^{\rm emitted} + =\left(\prod_{D\in\mathcal D\setminus\{1\}}^{\rm chronological} + C_D C_1^\dagger\right) C_1. \qquad(5) +``` + +Here chronological order means later operators multiply on the left. Equation +(5) is a fixed Clifford, not an identity promise. The source queries are the +identity on the entire U=0 sector. After the recoupler's fixed coordinate sum, +the target pairs satisfy $`a=c`$; the lower queries and the half swap are also +the identity on that entire intermediate sector. Consequently any unitary +zero fiber, including (5), preserves the complete intertwining proof. There +is no zero detector, clean flag, discarded sector or unreturned workspace. + +Let $`\widehat R_p`$ be this cell with the same external Fourier and coordinate +walls as the recursive recoupler. Its complete identity remains + +```math +\widehat R_p Q^{(p)}_{(x',b)}\widehat R_p^\dagger + =(Q^{(p-1)}_{x'}\otimes Q^{(p-1)}_{x'})S^b. \qquad(6) +``` + +The inverse is the reversed complete word, including the inverse of (5). +It need not agree with the original recoupler on U=0. + + + +## 3. A sixteen-T quartic phase with one returned borrow + +The retained four-T relative Toffoli is the literal unitary + +```math +R(a,b;h)=(-i)^{ab}X_h^{ab}. +``` + +Let $`U=H_hR(a,b;h)H_h=(-i)^{ab}Z_h^{ab}`$ and +$`V=R(c,d;h)=(-i)^{cd}X_h^{cd}`$. Their chronological commutator +$`U,V,U^\dagger,V^\dagger`$ is + +```math +V^\dagger U^\dagger VU=(-1)^{abcd}I_h. \qquad(7) +``` + +The two relative phases cancel, and the remaining sign is the Pauli X/Z +commutator. This holds for both arbitrary values of h and all coherent +control inputs. Hadamards on d turn (7) into a three-control X on d. +The emitted word has **16 T gates, at most eight physical T bands and 46 total +elementary gates**. The actual inverse has the same counts. It uses only +H, S, CNOT, T and T-dagger, and h returns literally. The p=3 construction +borrows an unused logical coordinate for h; it allocates no additional wire. + +## 4. The finite p=3 emitter + +For p=3, $`F=\mathbb F_4`$, $`K=\mathbb F_{16}`$ and the nonbaseline +representatives are $`D=4,5,6,7`$ in the retained little-endian tower basis. +A direct selected-CNOT compilation of (4) is possible, but the four linear +corrections admit a smaller joint reflection factorization. + +Use local V-wire labels +$`P_{a+16b}=i^{\mathrm{wt}(a\mathbin\&b)}X^a Z^b`$ and +$`T(P)=\exp(i\pi(I-P)/8)`$. For commuting independent A and B that both +anticommute with P, define the Hermitian Clifford reflection + +```math +J(A,B;P)=T(A)T(B)P T(B)^\dagger T(A)^\dagger. \qquad(8) +``` + +Anticommutation rewrites J as P times the two quarter-turn Pauli rotations +$`\exp(i\pi A/4)`$ and $`\exp(i\pi B/4)`$, which are Clifford. +Hermiticity and the involution property follow from its displayed conjugation. + +The following literal identities specify each correction. Each row lists the +earlier and later reflection; the final column means +$`C_D C_1^\dagger=\sigma J_1J_0`$. + +| D | Earlier $`(A,B;P)`$ | Later $`(A,B;P)`$ | $`\sigma`$ | +| --- | --- | --- | ---: | +| 4 | (19, 50; 32) | (156, 228; 112) | +1 | +| 5 | (156, 228; 64) | (19, 50; 32) | +1 | +| 6 | (89, 247; 1) | (19, 50; 13) | +1 | +| 7 | (19, 50; 32) | (89, 247; 87) | -1 | + +There is no residual Pauli correction. The finite identities can be verified +directly by multiplying the displayed signed Paulis or comparing their +Clifford action and one literal column; the exact fixture compares all 16 +columns with the field matrices in (4). + +For each pair the emitter constructs one joint Clifford K taking two distinct +physical Z axes to A and B, with their positive signs. One explicit procedure +first diagonalizes A, pulls B through that inverse, then diagonalizes the +remaining independent Pauli while fixing the first Z axis; an X corrects a +negative pulled sign. It emits +$`K^\dagger,[T,T],K`$, so the two T rotations occupy one physical band. +The words for K and its actual inverse contribute their elementary Clifford +gates to the ledger. + +The line predicate has two binary zero controls. A Clifford-conjugated +relative Toffoli gives the selected Pauli P with the common phase +$`(-i)^{ab}`$. Conjugating it by the joint two-T word gives a selected J, +using **eight T gates in four bands**. The two selected J factors contribute +$`(-1)^{ab}`$ together. A CZ on the two controls corrects this for D=4, 5 and +6; for D=7 it is exactly the required negative sign. These phases remain +literal throughout the emitted word. + +Thus the four linear corrections cost 64 T gates and 32 bands. The three +nonzero displacement maps use two three-control X gates each, paid by (7), +adding 96 T gates and 48 bands. Every such gate borrows an existing logical +coordinate and returns it. The baseline, line-coordinate maps and exterior +Fourier walls are Clifford. No oracle, initialized flag or controlled gate +remains in the elementary emitted alphabet. + +| Complete native word | T count | T bands | Forward total gates | Actual inverse gates | Physical wires | Extra helpers | +| --- | ---: | ---: | ---: | ---: | ---: | ---: | +| $`\widehat R_3`$ | 160 | 80 | 1,104 | 1,104 | 8 | 0 | +| $`\widehat E_3=(E_2\otimes E_2)\widehat R_3`$ | 172 | 83 | 1,234 | 1,286 | 8 | 0 | + +Here $`E_2`$ is the full six-T intertwiner from the +[four-address pilot](FLAT_FIELD_BANK_PILOT.md), including its final Clifford +completion. The two identical half-bank words run in parallel, contributing +12 T gates and three bands. Using the complete intertwiner rather than only +its bank-decoding prefix gives, with literal scalar phase one, + +```math +\widehat E_3 Q^{(3)}_x\widehat E_3^\dagger=W_x +\quad\text{for every three-bit address }x. \qquad(9) +``` + +All eight bank inputs are arbitrary. The internal borrowed logical +coordinates return before their next use; the actual complete inverse is +paid separately. Equation (9) therefore also holds on arbitrary coherent +addresses and external references. + +## 5. Verification, scope and the next operation + +The [native fixture](../../tests/test_projective_field_recoupler.py) checks +the quartic primitive on every five-wire column and its actual inverse, +the projective scaling identity, all paired reflection factorizations and +their simultaneous signed native axis maps, all 240 nonzero-U columns against the original recursive +recoupler, and every column of both actual native inverses. It checks (9) +for all eight addresses and all 256 bank columns, including the modified +zero fiber. Integer arithmetic in $`\mathbb Z[\omega]/2^d`$, +$`\omega=e^{i\pi/4}`$, retains literal phases; normalization and overflow +bounds are explicit. These checks do not use a numerical tolerance. + +This removes the unpaid primitive at this finite size. It does not claim +that this is a better general eight-address indicator than the repository's +other constructions. The projective-fiber count at level p is + +```math +|F|+1=2^{2^{p-2}}+1=2^{m/4}+1. +``` + +Enumerating these factors is exponential in m and outside the polynomial +discovery budgets. Separately composing levels also retains a stage cost +at each level. The useful new target is the joint projective-line action in +(4), including its allowed zero-fiber freedom: a uniform coupled synthesis +must compress these factors or change their representation while retaining +the full operator identity and paid work return. Neither a constant-depth +source nor a new frame-depth theorem is established here. diff --git a/research/depth/RECURSIVE_FIELD_SHEAR_DECODER.md b/research/depth/RECURSIVE_FIELD_SHEAR_DECODER.md index 55055b0..b8c1512 100644 --- a/research/depth/RECURSIVE_FIELD_SHEAR_DECODER.md +++ b/research/depth/RECURSIVE_FIELD_SHEAR_DECODER.md @@ -17,6 +17,13 @@ words. Compiling the recursion one level at a time also retains a depth cost at every level. The query itself is fully paid below, even for the dense multiplication matrices of a field tower. R96 is unchanged. +The later [projective recoupler](PROJECTIVE_FIELD_RECOUPLER.md) jointly compiles +the two conditional coordinate maps at p equal to three, with a different +allowed zero fiber. Its full eight-wire decoder costs 172 T gates in at most +83 bands and has no extra helper. The projective identity is general, but +enumerating its fibers grows exponentially in bank width; the uniform native +obligation and the separate-level depth limitation below remain. + ## 1. A compatible tower and address pencil Write $`K_1=\mathbb F_2`$. For $`j\ge2`$, define diff --git a/research/depth/SCALAR_FIELD_RADICAL_COPY_SCREEN.md b/research/depth/SCALAR_FIELD_RADICAL_COPY_SCREEN.md new file mode 100644 index 0000000..0960897 --- /dev/null +++ b/research/depth/SCALAR_FIELD_RADICAL_COPY_SCREEN.md @@ -0,0 +1,222 @@ +# Scalar-field automorphisms force a four-address radical relation + +[Field query](FIELD_SHEAR_INTERTWINER.md) · +[Complete copy grading](DIRTY_COPY_GRADING.md) · +[Clifford output duals](CLIFFORD_DUAL_COPY_GRADING.md) + +An associative radical algebra offers a natural way to construct a trace-graded +Clifford family: its unit group acts regularly by binary affine permutations, +so every nonidentity word has zero trace. For a scalar-field shear query, +however, the algebra-automorphism condition itself forces a four-address +identity word. This holds for every address subspace, arbitrary numbers of +identical field banks, enlarged fields and arbitrary query-fixed coordinates. +The resulting error floor is $`1/2`$ for a direct copy, or $`1/4`$ when the +family is a transported Clifford output dual of a proposed copy. + +The theorem concerns this associative-algebra construction. It does not +exclude arbitrary Clifford duals, arbitrary regular affine groups, non-scalar +phase dressings, or the field query itself. In particular, changing the address +embedding still defines a valid field query; it does not reopen this algebra +model. + +## 1. The proposed regular-affine construction + +Let A be a finite-dimensional associative nilpotent algebra over the binary +field, without requiring a multiplicative identity. Its unitization contains +the group $`1+A`$. On the underlying affine space of A, define + +```math +L_a(y)=a+y+ay,\qquad L_aL_b=L_{a+b+ab}. \qquad(1) +``` + +These maps are binary affine permutations and hence Clifford operations. +If $`L_a(y)=y`$, then $`a(1+y)=0`$. Nilpotence makes $`1+y`$ +invertible, so a is zero. Thus every nonidentity group element has no fixed +computational basis vector and its literal permutation matrix has zero trace. +This would supply the complete trace-grading condition if the desired orbit +generators had independent occurrence parities. + +Assume the underlying vector space decomposes as + +```math +A=U\oplus W\oplus H,\qquad U=W=F^r,\qquad +F=\mathbb F_{2^k},\qquad r\ge1. \qquad(2) +``` + +Choose any p-dimensional binary subspace S of F. Suppose every literal map + +```math +Q_\lambda(u,w,h)=(u,w+\lambda u,h),\qquad\lambda\in S, \qquad(3) +``` + +is an algebra automorphism. Coordinates in H are arbitrary and query-fixed; +no prepared value is assumed. Different field banks carry the same scalar +$`\lambda`$. Let $`a^2=0`$, and put + +```math +a_\lambda=Q_\lambda(a),\qquad g_\lambda=1+a_\lambda, +\qquad J_\lambda=L_{a_\lambda}. \qquad(4) +``` + +Every generator is an involution. Moreover an algebra automorphism conjugates +$`L_a`$ to $`L_{Q_\lambda(a)}`$, so (4) is precisely the proposed query orbit. + +## 2. The image of the shear is square-zero + +The following structural lemma needs only a binary-bilinear multiplication +preserved by (3). Associativity and nilpotence are not used until the group +consequence. + +**Lemma.** If $`p\ge2`$, then $`WW=0`$. + +Choose a nonzero $`\lambda_0\in S`$, write +$`S'=S/\lambda_0`$, and let K be the subfield of F generated by S'. Set + +```math +N=Q_{\lambda_0}-I,\qquad N_s=Q_{\lambda_0s}-I=sN +\quad(s\in S'),\qquad Z=\ker N=W\oplus H. \qquad(5) +``` + +Here s multiplies vectors in W by their inherited field scalar. The map N +sends U onto W. If $`z\in Z`$, multiplicativity gives + +```math +N(uz)=(Nu)z,\qquad N(zu)=z(Nu). \qquad(6) +``` + +Consequently $`WZ,ZW\subseteq W`$. Compare (6) with the same identity for +$`N_s=sN`$. For $`w\in W`$ and $`z\in Z`$, + +```math +(sw)z=s(wz),\qquad z(sw)=s(zw). \qquad(7) +``` + +The scalars satisfying both identities are closed under addition and +multiplication and contain one. Their finite integral subring is a subfield, +so (7) holds for all of K. In particular the product $`W\times W\to W`$ +is K-bilinear. Notice that its range cannot enter H. + +Put $`C=U\oplus W`$ and let $`\pi:A\to C`$ be the projection along H. +It commutes with every query. The map +$`\mu(u,v)=\pi(uv)`$ on $`C\times C`$ is binary-bilinear and query-equivariant. +Average it over independent nonzero scalars on its two inputs: + +```math +\nu(u,v)=\sum_{\alpha,\beta\in K^\times} + (\alpha\beta)^{-1}\mu(\alpha u,\beta v). \qquad(8) +``` + +All output scalings in (8) act on C, where they are defined on both U and W. +They commute with the query, so $`\nu`$ remains query-equivariant. +Reindexing $`\alpha`$ or $`\beta`$ proves that $`\nu`$ is K-bilinear. +For $`w,z\in W`$, every summand in (8) equals wz by (7). There are +$`(|K|-1)^2`$ summands, an odd number, hence + +```math +\nu(w,z)=wz. \qquad(9) +``` + +Equivariance under $`I+N`$ and $`I+sN`$, respectively, gives + +```math +N\nu(u,v)=\nu(Nu,v)+\nu(u,Nv)+\nu(Nu,Nv), +``` +```math +sN\nu(u,v)=s\nu(Nu,v)+s\nu(u,Nv)+s^2\nu(Nu,Nv). \qquad(10) +``` + +Subtract s times the first identity from the second. Since $`p\ge2`$, +S' contains s outside the binary field, so $`s^2+s\ne0`$. Therefore +$`\nu(Nu,Nv)=0`$. Surjectivity of $`N:C\to W`$ and (9) prove $`WW=0`$. + +The averaging is an algebraic proof device, not an operation in a quantum +circuit. It introduces no prepared register, random choice or computational +resource claim. + +## 3. A literal four-address word and its error floor + +Write $`w_\lambda=(Q_\lambda-I)a\in W`$. Since both a and +$`a+w_\lambda`$ square to zero, the lemma implies + +```math +aw_\lambda=w_\lambda a,\qquad +w_\lambda w_\mu=0. \qquad(11) +``` + +The differences are additive in the address. Thus the involutions in (4) +commute and satisfy + +```math +g_\lambda g_\mu=g_0g_{\lambda+\mu}. \qquad(12) +``` + +For every base v and two independent address directions s,t, (12) gives + +```math +g_vg_{v+s}g_{v+t}g_{v+s+t}=1. \qquad(13) +``` + +All four addresses are distinct. Equation (13) holds literally in the regular +affine representation, with phase one on every computational column. If the +seed has zero U component the orbit is constant and already has a two-address +identity word. + +A complete copy with per-generator operator error at most $`\epsilon`$ +would send the left side of (13) within $`4\epsilon`$ of its product tensored +with four distinct physical X probes. The original product is the identity; +the target product is a nontrivial Pauli and has distance two from it. Hence + +```math +\epsilon\ge\frac12. \qquad(14) +``` + +For a transported Clifford output-dual family of a proposed original copy, +the retained dual-conjugation estimate gives per-generator signed-conjugation +error at most $`2\eta`$. Choose the plane through the selected output index; +its four desired signs have product minus one. Equation (13) then yields + +```math +\eta\ge\frac14. \qquad(15) +``` + +Individual scalar phase factors change (13) only to a scalar unitary, so the +same contradictions and floors hold. A common disjoint query-fixed involution +and a fixed simultaneous conjugation also preserve the relation. General +non-scalar Pauli or Clifford dressings are outside the assertion unless their +full word is separately evaluated. + +## 4. Changed addresses and moving helper targets + +The proof did not assume canonical powers, a multiplicative collision in S, +or that the ratio field K equals all of F. In particular an injective map +$`\mathrm{Sym}^2(S)\to F`$ does not rescue this construction. The closure +and averaging in (6)--(10) supply the obstruction even when that injectivity +holds. Enlarging F or adding identical field banks also does not help. + +For the explicit exponent choice $`d_i=i+(2p-1)i^2`$ and +$`S=\mathrm{span}\{t^{d_i}:0\le i\lt p\}`$, there is an additional simple +check. When $`p\ge3`$, $`d_1=2p`$ and $`d_2=8p-2`$ have greatest common +divisor two. The ratio field contains their powers of t and their inverses, +hence contains $`t^2`$ by a Bezout identity. Squaring is an automorphism of a +finite binary field, so it contains t and therefore all of F. This observation +is consistent with the lemma but is not needed for it. + +The enlarged-field character identity with a moving residual helper query +remains a valid abstract target. Its native decoder is still unpaid. This +screen retires only the associative radical-algebra realization under (2)--(3); +a different Clifford-dual construction or a jointly synthesized native decoder +remains open. + +## 5. Exact fixtures and scope + +The [focused fixture](../../tests/test_scalar_field_radical_copy.py) computes the complete binary-linear space of +query-equivariant bilinear multiplications in small one-bank, multiple-bank +and fixed-helper cases and verifies that every such multiplication vanishes +on $`W\times W`$. It also checks a one-address counterexample, showing why +$`p\ge2`$ is needed, and the literal four-address word in a regular affine +representation of a strictly upper-triangular matrix algebra. + +These exact cases test the algebraic steps and complete permutation action; +they do not replace the all-size proof or construct a shallow copy. No new +unrestricted native-depth lower bound or improved general frame upper bound +follows from this restricted-family screen. diff --git a/research/depth/TWO_BAND_FIELD_DECODER_OBSTRUCTION.md b/research/depth/TWO_BAND_FIELD_DECODER_OBSTRUCTION.md new file mode 100644 index 0000000..9621755 --- /dev/null +++ b/research/depth/TWO_BAND_FIELD_DECODER_OBSTRUCTION.md @@ -0,0 +1,197 @@ +# Disjoint-axis two-band field decoders have a fixed error floor + +[Field query and full contract](FIELD_SHEAR_INTERTWINER.md) · +[One-band axis matching](ONE_BAND_AXIS_MATCHING.md) · +[Four-address decoder](FLAT_FIELD_BANK_PILOT.md) + +A full field-to-wire decoder cannot be made from two physical T bands +whose absorbed axis spans have zero intersection. The bands may be partial, +have arbitrary T/T-dagger orientations, and act jointly on arbitrary +helpers. The source field may be enlarged, and the decoded helper query +may have arbitrary Clifford action. Fixed Clifford walls may mix every register. +The full-intertwining operator error is at least + +```math +c_2=\frac12\sqrt{1-\frac1{\sqrt2}}\simeq0.270598. +``` + +This is a restriction on the two-band arrangement, not on all two-band +words. Shared axis spans permit collisions not covered by the proof. +It does not apply to the weaker single-probe decoder contract, nor does +it give a growing depth lower bound for general frame compilation. + +## 1. Scope and a stronger endpoint statement + +Let p be at least two, $`m=2^p`$, and let $`Q_x`$ be a literal full-rank affine +field-shear family on 2K core qubits, with identity on h source helpers. +The field degree K is at least p; the p address scalars are independent. +Put n=2K+h and suppose n is at least m. Every nonzero address has the +same fixed Pauli-label space. Every other +Pauli label has a free address orbit of size m, contained in the binary +span of at most p+1 labels. These properties survive a fixed Clifford +change of coordinates and identity helpers. + +Absorb the Clifford interlayers of a two-band unitary into + +```math +E=L D_B D_A K, +``` + +where K,L are fixed Cliffords, the physical axes of each D are independent +commuting Hermitian Paulis, and their binary spans A,B satisfy +$`A\cap B=0`$. Either band can have inactive wires. Put +$`\widehat Q_x=KQ_xK^\dagger`$. + +The stronger statement is: if every +$`D_BD_A\widehat Q_xD_A^\dagger D_B^\dagger`$ is within operator +distance strictly below $`c_2`$ of some projective Clifford, then +$`D_BD_A`$ commutes literally with every $`\widehat Q_x`$. +Consequently every endpoint is already the Clifford conjugate +$`L\widehat Q_xL^\dagger`$. + +The full-intertwining bound applies to every target + +```math +T_x=W_x\otimes R_x, +``` + +where $`W_x`$ translates m bank wires and $`R_x`$ is any Clifford on the +remaining n-m wires. The $`R_x`$ need not be identity; residual helper +queries that are later canceled by the complete probe echo are allowed. +Clifford similarity preserves the source identity $`N_xN_y=0`$ for the symplectic deviations +$`N_x=F_x-I`$. For wire translations on m bank wires, the deviations of +two independent address translations have nonzero product. The target +symplectic matrices are block diagonal between bank and residual wires, +so no residual block can cancel this bank product. Identity source helpers +also preserve the zero-product identity. Thus some source and target +endpoint symplectic actions differ. Such projective Clifford operators +have distance at least $`1/\sqrt2`$, exceeding $`c_2`$; see the separation +argument in [one-band matching](ONE_BAND_AXIS_MATCHING.md#3-exact-and-robust-proofs). + +## 2. Normalize the two bands without adding a gate + +Move every individual axis of $`D_A`$ that commutes with all axes of $`D_B`$ +into the outer band. Denote the remaining inner band by $`D_U`$ and the +combined outer band by $`D_V`$. The moved rotations commute with both +bands, so this only reorders the original factors and preserves every +native scalar phase and T orientation. + +The combined outer axes are commuting and independent because +$`A\cap B=0`$. The new spans U,V still have zero intersection. +Every remaining individual inner axis pairs nontrivially with at least +one outer axis. The reordered word remains two physical bands in fixed +Clifford coordinates, with exactly the original count and width. +If all inner axes moved, the statements below still hold with an empty +inner band. + +## 3. Recover the entire outer axis list from two-term images + +For a Hermitian Pauli P with label v, let r be the number of inner axes +anticommuting with P. Conjugation by $`D_U`$ produces a flat expansion on +$`v+U_v`$, where $`U_v`$ is the r-dimensional span of those active axes. +For each $`s\in U_v`$, let $`\beta(v+s)`$ be the binary activation vector +against the individual outer axes. Conjugation by the outer band then +has exactly + +```math +\left|\mathrm{supp}(D_VD_U P D_U^\dagger D_V^\dagger)\right| + =\sum_{s\in U_v}2^{\mathrm{wt}(\beta(v+s))}. \qquad(1) +``` + +There are no collisions: equality between labels from different paths +would place a nonzero difference in $`U\cap V`$. A coefficient on the +branch s has magnitude +$`2^{-(r+\mathrm{wt}(\beta(v+s)))/2}`$. + +If r is positive, toggling any active inner axis changes beta, by the +normalization in Section 2. For r=1 the two beta values are distinct, +so the sum in (1) is at least three. For r at least two the sum is at +least four. Thus a two-term output occurs exactly when + +```math +r=0,\qquad \mathrm{wt}(\beta(v))=1. \qquad(2) +``` + +Every such output is a signed flat sum of two Hermitian Paulis with +coefficients of magnitude $`1/\sqrt2`$. Its two support labels differ +by the unique active outer axis. Conversely, each outer axis is +realized as such a difference: independence of the combined inner and +outer axes makes the commutation equations r=0 and beta equal to the +chosen unit vector simultaneously solvable. + +Therefore the set of binary differences of all two-term Pauli images +is exactly the set of individual outer axes. This recovers the axis +list itself, rather than only its span. The input labels satisfying +(2) need not form a basis; no such assumption is used. + +## 4. The support fingerprint is stable at fixed operator error + +Use normalized Hilbert--Schmidt norm, for which Hermitian Paulis are an +orthonormal basis and a unitary has norm one. Every image that is not a +signed flat two-term sum has distance at least + +```math +\delta=\sqrt{1-1/\sqrt2}=2c_2 \qquad(3) +``` + +from every such sum. To see this, the overlap with a normalized flat +two-term sum is at most the sum of the two largest coefficient +magnitudes divided by $`\sqrt2`$. + +If r=0 and the outer activation has weight other than one, the image +is either a single Pauli or has at least four equal-magnitude terms; +that overlap is at most $`1/\sqrt2`$. If r is at least two, every +coefficient has magnitude at most one half, giving the same bound. +For r=1, distinct beta values allow at most one coefficient of +magnitude $`1/\sqrt2`$, and every other coefficient is at most one +half. The overlap is at most $`(1+1/\sqrt2)/2`$, proving (3). + +Let $`F=D_VD_U`$. Suppose a projective Clifford $`C_x`$ obeys + +```math +\|F\widehat Q_xF^\dagger-C_x\|_{\rm op}\lt c_2. +``` + +For any two-term image $`FPF^\dagger`$, its $`C_x`$ conjugate is again a signed +flat two-term sum. Its distance from +$`F\widehat Q_xP\widehat Q_x^\dagger F^\dagger`$ is below +$`2c_2=\delta`$. Equation (3) forces the latter to be a two-term +image as well. Thus each source query permutes the intrinsic input set +of two-term images. + +Moreover these two signed flat expansions must be exactly equal. +Two unequal signed flat two-term expansions have normalized +Hilbert--Schmidt distance at least one: their coefficient inner product +is at most one half. Their present distance is below delta, which is +less than one. Consequently $`C_x`$ sends the support differences of these +images onto themselves. Section 3 proves that $`C_x`$ permutes the +individual outer axes up to Hermitian signs. + +## 5. Two applications of one-band matching close the argument + +By the converse direction of one-band matching, +$`D_V^\dagger C_xD_V`$ is a projective Clifford. It is within $`c_2`$ of +$`D_U\widehat Q_xD_U^\dagger`$. Since +$`c_2\lt\sqrt2/4`$, robust one-band matching forces +$`\widehat Q_x`$ to permute the individual inner axes. + +A nonfixed field Pauli orbit has m distinct labels in a span of +dimension at most p+1. Because $`m\gt p+1`$ for p at least two, +such an orbit cannot lie in an independent axis list. Every inner +axis is therefore fixed as a label by every query. A fixed field +Pauli label is fixed with positive literal sign, including after the +fixed Clifford coordinate change. Hence $`D_U`$ commutes with every query. + +The nearby endpoint now has the form +$`D_V\widehat Q_xD_V^\dagger`$. Robust one-band matching applies +again and forces the query to permute the outer axes. The same orbit +argument fixes every outer axis literally. $`D_V`$ also commutes with every +query, proving the endpoint statement in Section 1. + +The proof is independent of the source field degree and helper count, +subject to the dimensions in Section 1. The decoded residual action +can be Clifford and nontrivial. All norms concern complete operators, +so coherent addresses, dirty inputs and external references are retained. The overlap assumption on the +two absorbed spans is essential to this proof. A candidate outside it +must exploit actual shared-span support collisions; merely using +partial independent bands does not evade the result. diff --git a/tests/test_disjoint_two_band_decoder.py b/tests/test_disjoint_two_band_decoder.py new file mode 100644 index 0000000..a60732e --- /dev/null +++ b/tests/test_disjoint_two_band_decoder.py @@ -0,0 +1,212 @@ +"""Exact finite support fingerprints for disjoint-axis two-band decoders. + +These checks exercise the proof's collision-free expansion and robust gap. +They are not a search for all-size decoders or a bound on overlapping bands. +""" +from collections import Counter +from fractions import Fraction +import unittest + +from tests.exact_matrices import Q2 +from tests.test_one_band_copy_feasibility import _pauli_product + + +_ZERO, _ONE = Q2(0), Q2(1) +_ISQRT2 = Q2(0, Fraction(1, 2)) + + +def _pair(left, right, width): + mask = (1 << width) - 1 + return (((left & mask) & (right >> width)).bit_count() + + ((right & mask) & (left >> width)).bit_count()) & 1 + + +def _span(axes): + result = {0} + for axis in axes: + result |= {v ^ axis for v in result} + return result + + +def _rotate(row, axis, orientation, width): + result = {} + for label, value in row.items(): + images = ((label, value),) + if _pair(label, axis, width): + other, phase = _pauli_product(axis, label, width) + phase = (phase - 1) % 4 + assert phase in (0, 2) + sign = orientation * (1 if phase == 0 else -1) + images = ((label, value * _ISQRT2), + (other, sign * value * _ISQRT2)) + for other, coefficient in images: + total = result.get(other, _ZERO) + coefficient + if total != _ZERO: + result[other] = total + else: + result.pop(other, None) + return result + + +def _image(label, inner, outer, signs, width): + row = {label: _ONE} + for axis, sign in zip(inner + outer, signs): + row = _rotate(row, axis, sign, width) + return row + + +def _normalized_bands(inner, outer, signs, width): + first = list(zip(inner, signs[:len(inner)])) + second = list(zip(outer, signs[len(inner):])) + moved = [(a, s) for a, s in first + if not any(_pair(a, b, width) for b in outer)] + kept = [(a, s) for a, s in first if (a, s) not in moved] + return (tuple(a for a, _ in kept), + tuple(a for a, _ in second + moved), + tuple(s for _, s in kept + second + moved)) + + +class DisjointTwoBandDecoderTests(unittest.TestCase): + def test_partial_band_normalization_and_outer_axis_recovery(self): + width = 3 + x = [1 << j for j in range(width)] + z = [1 << (width + j) for j in range(width)] + templates = ( + ((), ()), + ((), (z[0], z[2])), + ((z[0], z[1]), (x[0], x[1])), + ((z[0], z[1]), (x[0],)), + ((z[0], z[1]), (x[0] ^ x[1], z[2])), + ((z[0], z[1], z[2]), + (x[0] ^ x[1], x[1] ^ x[2], x[0])), + ((z[0], z[1], z[2]), (x[0] ^ x[1],)), + ) + cases = 0 + for inner, outer in templates: + self.assertEqual(_span(inner) & _span(outer), {0}) + for axes in (inner, outer): + self.assertEqual(len(_span(axes)), 1 << len(axes)) + self.assertTrue(all(not _pair(a, b, width) + for a in axes for b in axes)) + for pattern in range(4): + signs = tuple(-1 if (j + pattern) % 3 == 0 else 1 + for j in range(len(inner) + len(outer))) + first, second, reordered = _normalized_bands( + inner, outer, signs, width) + recovered = set() + for label in range(1 << (2 * width)): + image = _image(label, inner, outer, signs, width) + self.assertEqual(image, _image(label, first, second, + reordered, width)) + active = [a for a in first if _pair(label, a, width)] + expected_squares = Counter() + for branch in _span(active): + weight = sum(_pair(label ^ branch, b, width) + for b in second) + expected_squares[Fraction(1, 1 << (len(active) + weight))] += 1 << weight + actual_squares = Counter() + for coefficient in image.values(): + square = coefficient * coefficient + self.assertEqual(square.b, 0) + actual_squares[square.a] += 1 + self.assertEqual(actual_squares, expected_squares) + self.assertEqual(sum((c * c for c in image.values()), _ZERO), _ONE) + is_two = not active and sum(_pair(label, b, width) + for b in second) == 1 + self.assertEqual(len(image) == 2, is_two) + if is_two: + left, right = image + recovered.add(left ^ right) + self.assertEqual({abs(c) for c in image.values()}, {_ISQRT2}) + else: + largest = sorted((abs(c) for c in image.values()), + reverse=True)[:2] + overlap = sum(largest, _ZERO) * _ISQRT2 + # Exact squared distance to the nearest signed flat two-term sum. + self.assertGreaterEqual(2 - 2 * overlap, Q2(1, Fraction(-1, 2))) + cases += 1 + self.assertEqual(recovered, set(second)) + self.assertEqual(cases, 1792) + + def test_gap_is_attained_and_two_term_supports_are_separated(self): + # E=T(X) T(Z), P=X has magnitudes 1/sqrt(2),1/2,1/2. + row = _image(1, (2,), (1,), (1, 1), 1) + self.assertEqual(sorted(abs(c) for c in row.values()), + [Q2(Fraction(1, 2)), Q2(Fraction(1, 2)), _ISQRT2]) + top = sorted((abs(c) for c in row.values()), reverse=True)[:2] + self.assertEqual(2 - 2 * sum(top, _ZERO) * _ISQRT2, + Q2(1, Fraction(-1, 2))) + flats = [] + for left in range(4): + for right in range(left + 1, 4): + for signs in ((1, 1), (1, -1), (-1, 1), (-1, -1)): + flats.append({left: signs[0] * _ISQRT2, + right: signs[1] * _ISQRT2}) + for i, left in enumerate(flats): + for right in flats[:i]: + distance2 = _ZERO + for j in range(4): + difference = left.get(j, _ZERO) - right.get(j, _ZERO) + distance2 += difference * difference + self.assertGreaterEqual(distance2, 1) + + def test_enlarged_field_and_moving_residual_keep_distinct_deviations(self): + # Source: p=2 over GF(16), eight core wires. Target: four bank wires + # and a genuine p=2 GF(4) shear on four moving residual wires. + def multiply_field(left, right, degree, modulus): + value = 0 + while right: + if right & 1: + value ^= left + right >>= 1 + left <<= 1 + if left & (1 << degree): + left ^= modulus + return value + + def shear(label, address, degree, modulus): + width = 2 * degree + mask = (1 << degree) - 1 + a_u, a_v = label & mask, (label >> degree) & mask + b_u, b_v = (label >> width) & mask, label >> (width + degree) + a_v ^= multiply_field(address, a_u, degree, modulus) + for j in range(degree): + if (multiply_field(address, 1 << j, degree, modulus) & b_v).bit_count() & 1: + b_u ^= 1 << j + return a_u | (a_v << degree) | (b_u << width) | (b_v << (width + degree)) + + source = lambda v, x: shear(v, x, 4, 0b10011) + + def target(label, address): + x, z = label & 255, label >> 8 + bank_x = sum(((x >> j) & 1) << (j ^ address) for j in range(4)) + bank_z = sum(((z >> j) & 1) << (j ^ address) for j in range(4)) + residual = shear((x >> 4) | ((z >> 4) << 4), address, 2, 0b111) + return (bank_x | ((residual & 15) << 4) + | (bank_z << 8) | ((residual >> 4) << 12)) + + for left in range(4): + for right in range(4): + for j in range(16): + first = source(1 << j, right) ^ (1 << j) + self.assertEqual(source(first, left) ^ first, 0) + bank = 1 # X on bank wire zero, with no residual component. + first = target(bank, 2) ^ bank + second = target(first, 1) ^ first + self.assertEqual(second, 15) # X on every bank wire, never canceled. + self.assertNotEqual(target(1 << 4, 1), 1 << 4) + + def test_shared_spans_can_have_actual_path_collisions(self): + # Four mutually commuting axes with one relation; this lies outside the theorem. + width = 3 + inner, outer = (8, 16), (12, 20) + self.assertEqual(_span(inner) & _span(outer), {0, 24}) + label = 3 + row = _image(label, inner, outer, (1, 1, 1, 1), width) + paths = sum(1 << sum(_pair(label ^ branch, b, width) for b in outer) + for branch in _span(inner)) + self.assertLess(len(row), paths) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_field_decoder_pauli_domain.py b/tests/test_field_decoder_pauli_domain.py new file mode 100644 index 0000000..d10bb12 --- /dev/null +++ b/tests/test_field_decoder_pauli_domain.py @@ -0,0 +1,250 @@ +"""Exact fixtures for the complete field decoder's Pauli-domain restriction. + +The analytic proof, rather than the bounded checks, supplies the all-size +count bound. No fixture synthesizes a uniform decoder or implies a depth bound. +""" +from itertools import combinations, product +import unittest + +from tests.exact_matrices import Q2 +from tests.test_flat_field_bank_native import AXES, decoder_word +from tests.test_one_band_copy_feasibility import _conjugate + + +def _rank(values): + pivots = {} + for value in values: + while value: + bit = value.bit_length() - 1 + if bit not in pivots: + pivots[bit] = value + break + value ^= pivots[bit] + return len(pivots) + + +def _span(values): + result = {0} + for value in values: + result |= {old ^ value for old in tuple(result)} + return result + + +def _pairing(left, right, width): + mask = (1 << width) - 1 + return (((left & mask) & (right >> width)).bit_count() + + ((right & mask) & (left >> width)).bit_count()) % 2 + + +def _hermitian_phase(label, width): + return ((label & ((1 << width) - 1)) & (label >> width)).bit_count() % 4 + + +def _product_phase(left, right, width): + return (_hermitian_phase(left, width) + _hermitian_phase(right, width) + - _hermitian_phase(left ^ right, width) + + 2 * ((left >> width) + & (right & ((1 << width) - 1))).bit_count()) % 4 + + +def _field_multiply(left, right, degree, polynomial): + result = 0 + while right: + if right & 1: + result ^= left + right >>= 1 + left <<= 1 + if (left >> degree) & 1: + left ^= polynomial + return result + + +def _field_image(label, address, degree, polynomial, helpers=0): + width = 2 * degree + helpers + mask = (1 << width) - 1 + low = (1 << degree) - 1 + a, b = label & mask, label >> width + columns = [_field_multiply(address, 1 << j, degree, polynomial) + for j in range(degree)] + change_a = _field_multiply(address, a & low, degree, polynomial) + change_b = sum(((col & ((b >> degree) & low)).bit_count() % 2) << j + for j, col in enumerate(columns)) + return (a ^ (change_a << degree)) | ((b ^ change_b) << width) + + +def _translate(mask, address, size): + return sum(((mask >> j) & 1) << (j ^ address) for j in range(size)) + + +def _target_image(label, address, p=3, degree=3, polynomial=0b1011, + helpers=0): + size = 1 << p + residual_width = 2 * degree + helpers + width = size + residual_width + mask = (1 << width) - 1 + bank_mask = (1 << size) - 1 + a, b = label & mask, label >> width + helper_label = (a >> size) | ((b >> size) << residual_width) + helper_image = _field_image(helper_label, address, degree, polynomial, + helpers) + helper_mask = (1 << residual_width) - 1 + aa = (_translate(a & bank_mask, address, size) + | ((helper_image & helper_mask) << size)) + bb = (_translate(b & bank_mask, address, size) + | ((helper_image >> residual_width) << size)) + return aa | (bb << width) + + +class FieldDecoderPauliDomainTests(unittest.TestCase): + def test_source_fixed_kernels_and_literal_derivatives(self): + # Original p=3 field and a character-compatible enlarged source. + # Basis and pair probes include every term in the bilinear phases. + for degree, polynomial in ((4, 0b10011), (7, 0b10000011)): + for helpers in (0, 1): + width = 2 * degree + helpers + basis = [1 << j for j in range(2 * width)] + probes = ({0, (1 << (2 * width)) - 1} | set(basis) + | {a ^ b for a, b in combinations(basis, 2)}) + fixed = ([1 << (width + j) for j in range(degree)] + + [1 << (degree + j) for j in range(degree)] + + [1 << j for j in range(2 * degree, width)] + + [1 << (width + j) + for j in range(2 * degree, width)]) + self.assertEqual(_rank(fixed), 2 * degree + 2 * helpers) + for address in range(1, 8): + image = lambda v: _field_image( + v, address, degree, polynomial, helpers) + self.assertEqual(_rank([image(v) ^ v for v in basis]), + 2 * degree) + self.assertTrue(all(image(v) == v for v in fixed)) + for label in probes: + target = image(label) + self.assertEqual(_pairing(label, target, width), 0) + self.assertEqual(image(target), label) + sign = (_hermitian_phase(label, width) + - _hermitian_phase(target, width)) % 4 + self.assertIn(sign, (0, 2)) + derivative = label ^ target + phase = (sign + _product_phase(target, label, width)) % 4 + self.assertIn(phase, (0, 2)) + for other in range(8): + self.assertEqual(_field_image( + derivative, other, degree, polynomial, helpers), + derivative) + if target == label: + self.assertEqual(sign, 0) + + def test_target_second_difference_space_and_literal_commutation(self): + p, degree, helpers = 3, 3, 1 + size, residual_width = 1 << p, 2 * degree + helpers + width = size + residual_width + image = lambda v, x: _target_image(v, x, p, degree, 0b1011, helpers) + basis = [1 << j for j in range(2 * width)] + first_columns = [] + second_columns = [] + for label in basis: + first, second = 0, 0 + for x in range(8): + delta = image(label, x) ^ label + first |= delta << (2 * width * x) + for y in range(8): + delta2 = image(delta, y) ^ delta + second |= delta2 << (2 * width * (8 * x + y)) + first_columns.append(first) + second_columns.append(second) + self.assertEqual(2 * width - _rank(first_columns), + 2 + 2 * degree + 2 * helpers) + self.assertEqual(2 * width - _rank(second_columns), + 2 * (p + 1) + 4 * degree + 2 * helpers) + probes = basis + [a ^ b for a, b in combinations(basis, 2)] + for label, x in product(probes, range(8)): + target = image(label, x) + self.assertEqual(_pairing(label, target, width), 0) + if target == label: + # Both factors are literal linear basis permutations. + self.assertEqual((_hermitian_phase(label, width) + - _hermitian_phase(target, width)) % 4, 0) + + def test_helper_quotient_kernel_has_a_nonzero_bank_stabilizer(self): + p, size, degree, helpers = 3, 8, 3, 1 + width = size + 2 * degree + helpers + affine = [mask for mask in range(1 << size) + if all((_translate(mask, x, size) ^ mask) in (0, 255) + for x in range(8))] + self.assertEqual(len(affine), 16) + helper_fixed = ([1 << (width + size + j) for j in range(degree)] + + [1 << (size + degree + j) for j in range(degree)] + + [1 << (width - 1), 1 << (2 * width - 1)]) + self.assertEqual(_rank(helper_fixed), 2 * degree + 2 * helpers) + for a, b in product(affine, repeat=2): + bank_label = a | (b << width) + for helper in [0] + helper_fixed: + label = bank_label ^ helper + stabilizers = [x for x in range(1, 8) + if _target_image(label, x, helpers=helpers) + == label] + self.assertTrue(stabilizers) + # The p=2 boundary has two independent mask slopes and no nonzero + # common translating stabilizer; the finite decoder is not excluded. + self.assertFalse([x for x in range(1, 4) + if _translate(0b1010, x, 4) == 0b1010 + and _translate(0b1100, x, 4) == 0b1100]) + + def test_moving_helper_requires_the_quotient_argument(self): + # This helper Pauli has query-fixed first derivatives but no nonzero + # stabilizing query. It falsifies the tempting individual-fixedness + # inference for the enlarged target, not the quotient theorem. + label = 1 << 8 # X on the residual field's first u wire. + for address in range(1, 8): + target = _target_image(label, address) + self.assertNotEqual(target, label) + derivative = target ^ label + for other in range(8): + self.assertEqual(_target_image(derivative, other), derivative) + # Arbitrary Clifford helper motion need not have the commuting gap. + # H maps X to Z; ZX=iY, so a derivative need not be Hermitian. + self.assertEqual(_pairing(1, 2, 1), 1) + self.assertEqual(_product_phase(2, 1, 1), 1) + + def test_finite_decoder_domain_and_outer_clifford_invariants(self): + word = decoder_word() + domain = {} + for label in range(256): + expansion = _conjugate({label: Q2(1)}, word, 4) + if len(expansion) == 1: + target, coefficient = next(iter(expansion.items())) + self.assertIn(coefficient, (Q2(1), Q2(-1))) + domain[label] = (target, coefficient) + expected = _span((1, 4, 8, 18)) + self.assertEqual(set(domain), expected) + self.assertTrue(all(domain[v] == (v, Q2(1)) for v in expected)) + self.assertEqual(_rank(expected), 4) + gram = [sum(_pairing(v, w, 4) << j + for j, w in enumerate((1, 4, 8, 18))) + for v in (1, 4, 8, 18)] + self.assertEqual(_rank(gram), 2) + axes = [axis for band in AXES for axis in band] + self.assertEqual(_rank(axes), 4) + self.assertEqual({v for v in range(256) + if all(_pairing(v, a, 4) == 0 for a in axes)}, + expected) + # Tensor cells have an extensive exact domain even before any + # optional fixed Clifford wall is chosen. Clifford walls preserve + # its dimension, including walls mixing the identity helpers. + for cells, helpers in ((2, 0), (2, 3), (4, 5)): + size = 4 * cells + width = size + helpers + generators = [] + for cell in range(cells): + for value in (1, 4, 8, 18): + a, b = value & 15, value >> 4 + generators.append((a << (4 * cell)) + | (b << (width + 4 * cell))) + generators += [1 << j for j in range(size, width)] + generators += [1 << (width + j) for j in range(size, width)] + self.assertEqual(_rank(generators), 4 * cells + 2 * helpers) + self.assertGreater(_rank(generators), 2 + 2 * helpers) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_projective_field_recoupler.py b/tests/test_projective_field_recoupler.py new file mode 100644 index 0000000..4b66efa --- /dev/null +++ b/tests/test_projective_field_recoupler.py @@ -0,0 +1,362 @@ +"""Paid eight-wire field recoupler with four projective-line corrections. + +Every column, literal phase, arbitrary borrowed input and actual inverse is +checked exactly. The exponentially many all-size lines are not a uniform +polynomial-budget decoder. +""" +from collections import Counter +from functools import lru_cache +import unittest + +import numpy as np + +from tests.test_recursive_field_shear_decoder import (_tower_product as mul, + _tower_inverse as inv, _tower_trace as trace, _tower_shear, + _recursive_decoder_word, _apply_decoder) +from tests.test_dirty_indicator_depth import _parity_basis +from tests.test_joint_lookup_pauli_source import _inverse, _bands +from tests.test_three_layer_native_mechanisms import _relative_toffoli +from tests.test_field_shear_intertwiner import _native_x, _translation +from tests.test_flat_field_bank_native import full_intertwiner +from tests.exact_matrices import Q2 +from tests.test_one_band_copy_feasibility import _conjugate + +DIRECTIONS = (1, 4, 5, 6, 7) + + +def linear_word(columns, wires): + rows = [sum(((column >> row) & 1) << j for j, column in enumerate(columns)) + for row in range(len(wires))] + return _parity_basis(list(wires), rows) + + +def fourier_word(level, offset): + degree = 1 << (level - 1) + # The trace-pairing matrix is symmetric and invertible over F2. + columns = [sum(trace(level, mul(level, 1 << i, 1 << j)) << i + for i in range(degree)) for j in range(degree)] + # H T = T^-T H. Native action desired H T; emit trace map then H. + return linear_word(columns, range(offset, offset + degree)) + [ + ('H', offset + j) for j in range(degree)] + + +def _raw_linear_cell(direction): + d0, d1 = direction & 3, direction >> 2 + norm = mul(2, d0, d0) ^ mul(2, d0, d1) ^ mul(2, 2, mul(2, d1, d1)) + cols_a = [] + for j in range(4): + uv = mul(3, direction, 1 << j) + cols_a.append((mul(3, 4, uv) >> 2) + | (mul(2, uv >> 2, inv(2, norm)) << 2)) + cols_b = [mul(3, direction, 1 << j) for j in range(4)] + shift = mul(3, direction, mul(2, mul(2, d0, d1), inv(2, norm)) << 2) + return (linear_word(cols_a, range(4, 8)) + fourier_word(2, 4) + + linear_word(cols_b, range(4, 8)), shift) + + +def _cancel_clifford_pairs(word): + out = [] + for gate in word: + if out and gate == out[-1] and gate[0] in ('H', 'CX'): + out.pop() + else: + out.append(gate) + return out + + +def c3x(a, b, c, target, borrow): + """16 T, eight bands, one returned arbitrary borrow. + + U=(-i)^(ab) Z_borrow^(ab), V=(-i)^(c target) X_borrow^(c target). + Their literal commutator is (-1)^(ab c target) I_borrow; the scalar + relative-Toffoli phases cancel. Target Hadamards turn C3Z into C3X. + """ + assert len({a, b, c, target, borrow}) == 5 + h = [('H', borrow)] + u = h + _relative_toffoli(a, b, borrow) + h + v = _relative_toffoli(c, target, borrow) + return _cancel_clifford_pairs([('H', target)] + u + v + + _inverse(u) + _inverse(v) + [('H', target)]) + + +def _baseline_word(): + # C1=H_F(first) A1, with the trace-pairing wall absorbed into A1. + return [('CX',4,5),('CX',7,5),('CX',5,4),('CX',6,5), + ('H',4),('H',5)] + + +def _controlled_shift(control, vector): + if not vector: + return [] + pivot = (vector & -vector).bit_length() - 1 + # F sends X_pivot to X_vector; exact common conjugation costs no T. + f = [('CX', 4 + pivot, 4 + j) + for j in range(4) if j != pivot and (vector >> j) & 1] + borrow = 1 - control + return _inverse(f) + c3x(2, 3, control, 4 + pivot, borrow) + f + + +def pauli_diagonalizer(label, pivot=None): + x,z=label&15,label>>4 + support=x|z + assert support + if pivot is None:pivot=(support&-support).bit_length()-1 + assert (support>>pivot)&1 + word=[('CX',4+j,4+pivot) for j in range(4) + if j!=pivot and (support>>j)&1] + for j in range(4): + if (x>>j)&1: + word.append(('H',4+j)) + if (z>>j)&1:word.append(('S',4+j)) + return word, 4+pivot + + +# J(A,B;P)=T(A)T(B) P T(B)^dagger T(A)^dagger. +# The two axes commute, are independent, and both anticommute with P. +# Chronological J0,J1 equals sign*(C_D C1^dagger), with no residual Pauli. +_PAIRED_REFLECTIONS = { + 4: (((19,50,32),(156,228,112)),1), + 5: (((156,228,64),(19,50,32)),1), + 6: (((89,247,1),(19,50,13)),1), + 7: (((19,50,32),(89,247,87)),-1), +} + + +def pair_diagonalizer(left,right): + first,pivot=pauli_diagonalizer(left) + low_inverse=[(g[0],*(j-4 for j in g[1:])) for g in _inverse(first)] + pulled=_conjugate({right:Q2(1)},low_inverse,4) + assert len(pulled)==1 + label,coefficient=next(iter(pulled.items())) + assert coefficient in (Q2(1),Q2(-1)) + other=(label&15)|(label>>4) + other &= ~(1<<(pivot-4)) + assert other + second_pivot=(other&-other).bit_length()-1 + second,target=pauli_diagonalizer(label,second_pivot) + sign=_native_x(target) if coefficient==Q2(-1) else [] + return sign+second+first,(pivot,target) + + +def paired_t(left,right): + k,wires=pair_diagonalizer(left,right) + return _inverse(k)+[('T',wire) for wire in wires]+k + + +def selected_correction(direction): + pairs,sign=_PAIRED_REFLECTIONS[direction] + word=[] + for left,right,probe in pairs: + tau=paired_t(left,right) + k,pivot=pauli_diagonalizer(probe) + relative_p=(_inverse(k)+[('H',pivot)] + +_relative_toffoli(2,3,pivot)+[('H',pivot)]+k) + word += _inverse(tau)+relative_p+tau + # Two relative-control phases multiply to (-1)^(ab). + if sign>0: + word += [('H',3),('CX',2,3),('H',3)] + return word + + +def line_factor(direction): + # The unconditional baseline C1 already handles its own line. + assert direction in _PAIRED_REFLECTIONS + coords=linear_word([mul(3,inv(3,direction),1<(a,a+d), two CNOTs per coordinate. + sum_wall = [g for j in range(4) for g in [('CX', j, 4+j), ('CX', 4+j, j)]] + return (fourier_word(3, 4) + cell + sum_wall + + fourier_word(2, 2) + fourier_word(2, 6)) + + +def decoder_word(): + bottom = [g for gate in full_intertwiner() + for g in [gate, (gate[0], *(j + 4 for j in gate[1:]))]] + return recoupler_word() + bottom + + +def ledger(word): + c = Counter(g[0] for g in word) + return {'T': c['T'] + c['TDG'], 'bands': len(_bands(word)), + 'gates': len(word), 'width': max(j for g in word for j in g[1:]) + 1, + 'counts': dict(c)} + + +def ring_matrix(word, width=8): + """Exact Z[omega]/2^den matrices, omega^4=-1, vectorized integer arithmetic. + + All H gates multiply by (omega-omega^3)/2. Normalize common factors + two after each H. Overflow guards precede every arithmetic operation. + """ + size = 1 << width + a = np.zeros((4, size, size), dtype=np.int64) + a[0] = np.eye(size, dtype=np.int64) + den = 0 + rows = np.arange(size) + for index, gate in enumerate(word): + name, *wires = gate + assert np.max(np.abs(a)) < (1 << 57), ('overflow guard', index, den) + if name == 'CX': + c, t = wires + perm = rows ^ (((rows >> c) & 1) << t) + a = a[:, perm, :] + elif name == 'H': + t, = wires + lo = rows[(rows & (1 << t)) == 0] + hi = lo ^ (1 << t) + b = a.copy() + b[:, lo, :] = a[:, lo, :] + a[:, hi, :] + b[:, hi, :] = a[:, lo, :] - a[:, hi, :] + # (omega - omega^3) b, with omega^4=-1. + a = np.array([b[1] - b[3], b[0] + b[2], + b[1] + b[3], b[2] - b[0]]) + den += 1 + while den and not np.any(a & 1): + a //= 2 + den -= 1 + else: + assert name in ('S', 'T', 'TDG') + t, = wires + selected = rows[(rows & (1 << t)) != 0] + exponent = {'S':2, 'T':1, 'TDG':7}[name] + b = a[:, selected, :].copy() + for power in range(4): + target = (power + exponent) % 4 + a[target, selected, :] = ((-1) ** ((power + exponent)//4)) * b[power] + return a, den + + +def equal_ring(left, right): + a, da = left; b, db = right + common = max(da, db) + for value,shift in ((a,common-da),(b,common-db)): + assert int(np.max(np.abs(value))).bit_length()+shift<63 + return np.array_equal(a * (1 << (common-da)), b * (1 << (common-db))) + + +def adjoint_ring(value): + a, d = value + return np.array([a[0].T, -a[3].T, -a[2].T, -a[1].T]), d + + +def _expected_nonzero(): + columns = [_apply_decoder(_recursive_decoder_word(3)[:6], {j:1}) + for j in range(256)] + assert {n for _, n in columns} == {10} + a = np.zeros((4,256,256),dtype=np.int64) + for col,(entries,n) in enumerate(columns): + for row,value in entries.items():a[0,row,col]=value + return a,5 + + + +class ProjectiveFieldRecouplerTests(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.recoupler = ring_matrix(recoupler_word()) + cls.recoupler_inverse = ring_matrix(_inverse(recoupler_word())) + cls.decoder = ring_matrix(decoder_word()) + cls.decoder_inverse = ring_matrix(_inverse(decoder_word())) + + def test_field_fourier_native_walls(self): + for level in (2,3): + width=1 << (level-1) + size=1 << width + actual=ring_matrix(fourier_word(level,0),width) + expected=np.zeros_like(actual[0]) + for row in range(size): + for col in range(size): + expected[0,row,col]=(-1)**trace(level,mul(level,row,col)) + self.assertTrue(equal_ring(actual,(expected,width//2))) + + def test_every_nonzero_projective_fiber_and_displacement(self): + low=lambda word:[(g[0],*(j-4 for j in g[1:])) for g in word] + for direction in DIRECTIONS: + direct,shift=_raw_linear_cell(direction) + for scalar in (1,2,3): + value=mul(3,scalar,direction) + scaled,scaled_shift=_raw_linear_cell(value) + self.assertTrue(equal_ring(ring_matrix(low(direct),4), + ring_matrix(low(scaled),4))) + self.assertEqual(scaled_shift,mul(3,scalar,shift)) + self.assertTrue(equal_ring(ring_matrix(low(_baseline_word()),4), + ring_matrix(low(_raw_linear_cell(1)[0]),4))) + + def test_quartic_borrow_every_column_and_actual_inverse(self): + word=c3x(0,1,2,3,4) + expected=np.zeros((4,32,32),dtype=np.int64) + for col in range(32): + expected[0,col^(8 if col&7==7 else 0),col]=1 + for actual in (word,_inverse(word)): + self.assertTrue(equal_ring(ring_matrix(actual,5),(expected,0))) + self.assertEqual((ledger(word)['T'],ledger(word)['bands'],len(word)), + (16,8,46)) + + def test_literal_paired_reflections_and_joint_physical_bands(self): + low=lambda word:[(g[0],*(j-4 for j in g[1:])) for g in word] + for direction,(pairs,sign) in _PAIRED_REFLECTIONS.items(): + word=[] + for left,right,probe in pairs: + joint,wires=pair_diagonalizer(left,right) + self.assertNotEqual(*wires) + for wire,label in zip(wires,(left,right)): + self.assertEqual(_conjugate({1<<(wire):Q2(1)},low(joint),4), + {label:Q2(1)}) + tau=paired_t(left,right) + self.assertEqual(ledger(tau)['T'],2) + self.assertEqual(ledger(tau)['bands'],1) + k,pivot=pauli_diagonalizer(probe) + native_p=_inverse(k)+[('S',pivot),('S',pivot)]+k + word += _inverse(tau)+native_p+tau + actual,den=ring_matrix(low(word),4) + wanted=ring_matrix(low(_inverse(_raw_linear_cell(1)[0]) + +_raw_linear_cell(direction)[0]),4) + self.assertTrue(equal_ring((sign*actual,den),wanted)) + + def test_complete_recoupler_nonzero_columns_and_actual_inverse(self): + old=_expected_nonzero() + columns=[j for j in range(256) if j&15] + self.assertTrue(equal_ring((self.recoupler[0][:,:,columns],self.recoupler[1]), + (old[0][:,:,columns],old[1]))) + self.assertTrue(equal_ring(self.recoupler_inverse, + adjoint_ring(self.recoupler))) + zero=[j for j in range(256) if not j&15] + self.assertFalse(equal_ring((self.recoupler[0][:,:,zero],self.recoupler[1]), + (old[0][:,:,zero],old[1]))) + + def test_full_intertwining_all_addresses_columns_and_actual_inverse(self): + self.assertTrue(equal_ring(self.decoder_inverse,adjoint_ring(self.decoder))) + for address in range(8): + query=[_tower_shear(3,address,j) for j in range(256)] + translation=[_translation(3,address,j) for j in range(256)] + self.assertTrue(np.array_equal(self.decoder[0][:,:,query], + self.decoder[0][:,translation,:])) + + def test_emitted_native_ledgers_and_physical_bands(self): + rows=((recoupler_word(),160,80,1104,1104), + (decoder_word(),172,83,1234,1286)) + for word,t,bands,forward_gates,inverse_gates in rows: + for actual,gates in ((word,forward_gates),(_inverse(word),inverse_gates)): + counted=ledger(actual) + self.assertEqual((counted['T'],counted['bands'],counted['gates'], + counted['width']),(t,bands,gates,8)) + self.assertLessEqual({g[0] for g in actual}, + {'H','S','CX','T','TDG'}) + for band in _bands(actual): + self.assertEqual(len({g[1] for g in band}),len(band)) + + +if __name__=='__main__': + unittest.main() diff --git a/tests/test_scalar_field_radical_copy.py b/tests/test_scalar_field_radical_copy.py new file mode 100644 index 0000000..cc05a90 --- /dev/null +++ b/tests/test_scalar_field_radical_copy.py @@ -0,0 +1,196 @@ +"""Exact fixtures for the scalar-field radical copy screen. + +The linear kernel calculation imposes all bilinear equivariance constraints; +it does not assume associativity, nilpotence, or a sparse product grammar. +""" +from itertools import product +import unittest + + +def _gf_mul(a, b, degree, polynomial): + value = 0 + while b: + if b & 1: + value ^= a + b >>= 1 + a <<= 1 + if a >> degree: + a ^= polynomial + return value + + +def _row_basis(rows): + pivots = {} + for row in rows: + while row: + pivot = row.bit_length() - 1 + if pivot in pivots: + row ^= pivots[pivot] + else: + pivots[pivot] = row + break + return pivots + + +def _nullspace(rows, dimension): + pivots = _row_basis(rows) + answer = [] + for free in range(dimension): + if free in pivots: + continue + vector = 1 << free + for pivot in sorted(pivots): + if (pivots[pivot] & vector).bit_count() & 1: + vector |= 1 << pivot + answer.append(vector) + return answer, len(pivots) + + +def _equivariant_multiplications(degree, polynomial, banks, helpers, scalars): + bank_bits = degree * banks + dimension = 2 * bank_bits + helpers + variables = dimension ** 3 + mask = (1 << degree) - 1 + + def query(vector, scalar): + result = vector + for bank in range(banks): + u = (vector >> (bank * degree)) & mask + result ^= _gf_mul(scalar, u, degree, polynomial) << ( + bank_bits + bank * degree + ) + return result + + def index(left, right, output): + return (left * dimension + right) * dimension + output + + def product_expression(left, right, output): + expression = 0 + for i in range(dimension): + if (left >> i) & 1: + for j in range(dimension): + if (right >> j) & 1: + expression ^= 1 << index(i, j, output) + return expression + + constraints = [] + for scalar, i, j, output in product( + scalars, range(dimension), range(dimension), range(dimension) + ): + row = product_expression(query(1 << i, scalar), query(1 << j, scalar), output) + for bit in range(dimension): + if (query(1 << bit, scalar) >> output) & 1: + row ^= 1 << index(i, j, bit) + constraints.append(row) + basis, rank = _nullspace(constraints, variables) + return dimension, bank_bits, constraints, basis, rank, index + + +class ScalarFieldRadicalCopyTests(unittest.TestCase): + def test_complete_equivariant_product_spaces_have_square_zero_image(self): + # Each tuple fixes the entire linear equation system, not a candidate + # product list. The last two cases have, respectively, a noncanonical + # address embedding and a proper ratio subfield GF(4) inside GF(16). + cases = ( + (2, 0b111, 1, 0, (1, 2), 18), + (2, 0b111, 1, 1, (1, 2), 43), + (2, 0b111, 2, 0, (1, 2), 144), + (3, 0b1011, 1, 1, (1, 2), 103), + (4, 0b10011, 1, 0, (1, 8, 10), 108), + (4, 0b10011, 1, 0, (1, 6), 144), + ) + for degree, polynomial, banks, helpers, scalars, expected in cases: + with self.subTest(degree=degree, banks=banks, helpers=helpers): + n, bank, constraints, basis, rank, index = _equivariant_multiplications( + degree, polynomial, banks, helpers, scalars + ) + self.assertEqual(len(basis), expected) + self.assertEqual(rank + len(basis), n ** 3) + self.assertEqual(len(_row_basis(basis)), len(basis)) + output_mask = (1 << n) - 1 + for multiplication in basis: + self.assertTrue(all( + ((row & multiplication).bit_count() & 1) == 0 + for row in constraints + )) + for left, right in product(range(bank, 2 * bank), repeat=2): + self.assertEqual( + (multiplication >> index(left, right, 0)) & output_mask, + 0, + ) + + def test_one_address_hypothesis_is_essential(self): + # Nilpotent algebra with basis a,d,b,c, products ab=d+c, + # ba=d, b^2=c, and every product involving d or c zero. + # Q(a)=a+b and Q(d)=d+c: U=(a,d), W=(b,c). + def multiply(left, right): + la, lb = left & 1, (left >> 2) & 1 + ra, rb = right & 1, (right >> 2) & 1 + return ((la * rb) ^ (lb * ra)) << 1 | ( + (la * rb) ^ (lb * rb) + ) << 3 + + def query(vector): + return vector ^ ((vector & 1) << 2) ^ ((vector & 2) << 2) + + basis = (1, 2, 4, 8) + for a, b, c in product(basis, repeat=3): + self.assertEqual(multiply(multiply(a, b), c), 0) + self.assertEqual(multiply(a, multiply(b, c)), 0) + for a, b in product(range(16), repeat=2): + self.assertEqual(query(multiply(a, b)), multiply(query(a), query(b))) + for a in range(16): + self.assertEqual(query(query(a)), a) + self.assertEqual(multiply(1, 1), 0) + self.assertEqual(multiply(4, 4), 8) # W^2 is nonzero for p=1. + + def test_regular_affine_four_word_on_every_column(self): + # Strictly upper-triangular 3x3 matrices over GF(4), encoded as + # (u,w,h) = entries (23,13,12). Product has only entry h*u' at 13. + def field(a, b): + return _gf_mul(a, b, 2, 0b111) + + def multiply(left, right): + h = (left >> 4) & 3 + u = right & 3 + return field(h, u) << 2 + + def query(vector, scalar): + return vector ^ (field(scalar, vector & 3) << 2) + + def affine(a, vector): + return a ^ vector ^ multiply(a, vector) + + # Complete multiplication equivariance and generator conjugation. + for scalar, left, right in product(range(4), range(64), range(64)): + self.assertEqual( + query(multiply(left, right), scalar), + multiply(query(left, scalar), query(right, scalar)), + ) + seed = 1 + generators = [query(seed, scalar) for scalar in range(4)] + for scalar, vector in product(range(4), range(64)): + self.assertEqual(affine(generators[scalar], affine(generators[scalar], vector)), vector) + self.assertEqual( + query(affine(seed, query(vector, scalar)), scalar), + affine(generators[scalar], vector), + ) + # All nonidentity units act freely, not just the four generators. + for a in range(1, 64): + self.assertTrue(all(affine(a, vector) != vector for vector in range(64))) + planes = 0 + for origin, first, second in product(range(4), repeat=3): + if len({0, first, second, first ^ second}) != 4: + continue + addresses = (origin, origin ^ first, origin ^ second, origin ^ first ^ second) + for vector in range(64): + result = vector + for address in addresses: + result = affine(generators[address], result) + self.assertEqual(result, vector) + planes += 1 + self.assertEqual(planes, 24) + + +if __name__ == '__main__': + unittest.main()