Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Definitions for Schur-Weyl Duality for the Clifford Group with Applications: Property Testing, a Robust Hudson Theorem, and de Finetti Representations

Definition
QAlgorithms_Papers_Independent_Extend50_P30

by Gohan · Oct 29, 2026 · Mathlib 0df444a (Lean v4.33.1)

prove2quantum

The objects the formalized statements of Schur-Weyl Duality for the Clifford Group with Applications: Property Testing, a Robust Hudson Theorem, and de Finetti Representations (arXiv:1712.08628) are stated in. Each was checked against the paper by a blind read-back and a moderator.

  • ResidueRegister: PDF p.14: n qudits in the specified cyclic-residue computational basis.
  • DiscretePhaseSpace: PDF p.15: momentum and position labels over ZMod d, also for composite d.
  • QuditOperator: PDF p.14: operators indexed by the cyclic computational register.
  • QuditCopies: Specialize the accepted copy register to the source cyclic-qudit basis.
  • phaseModulus: PDF p.14: the order of weylPhase.
  • weylRoot: PDF p.14: omega, with the stray q removed as fixed by the action of Z.
  • weylPhase: PDF p.14: weylPhase includes the parity-dependent sign.
  • cyclicWeyl: PDF pp.14--15, (2.1): canonical lifts and output-row convention for Z^p X^q.
  • symplecticBracket: PDF p.15, (2.3), with the source sign.
  • cyclicPauliGroup: PDF pp.14--17: the finite Pauli group, including all powers of weylPhase.
  • IsCyclicStabilizerGroup: PDF p.16: finite Pauli subgroup with no nonidentity scalar.
  • pauliAverageProjector: PDF p.16, (2.14): code projection before trace normalization.
  • mixedStabilizers: PDF p.58 footnote 8: maximally mixed code states, not their convex hull.
  • stabilizers: PDF p.17: phase-free pure stabilizer density matrices.
  • IsStabilizer: Pure stabilizer predicate; vector phases are immaterial.
  • stabilizerOverlap: Fidelity with a pure state specified by its density matrix.
  • FarFromStabilizers: Source maximum upper bound, pointwise on exactly the finite stabilizer set.
  • IsClifford: PDF p.14: full unitary normalizer, retaining scalar representatives.
  • characteristicDistribution: PDF p.18, (3.2): characteristic distribution.
  • weylBellVector: PDF p.19: normalized Bell vector (W_x tensor I)|Phi+>.
  • bellDifference: PDF p.19: two Bell measurements and XOR of the labels, on four copies.
  • qubitTest: PDF p.22, (3.11): Algorithm 1, four sampling copies and two verification copies.
  • realQubitTest: PDF p.22, Remark 3.5: two Bell-sampling and two verification copies.
  • quditInvolution: PDF p.23, (3.15): alternating W and W dagger, with normalization d^{-n}.
  • quditTest: PDF p.24: accepting effect on exactly 2s copies.
  • soundnessConstant: PDF p.25: exact soundness coefficient.
  • CopyTest: Binary POVM on k physical copies, fixed independently of the input.
  • CopyTest.prob: Born probability from the carried effect and copy count.
  • residueQuadratic: PDF p.27: q, with canonical lifts, including reduction modulo 4 at d=2.
  • IsStochasticLagrangian: PDF p.27: at prime d, cardinality d^t is exactly dimension t.
  • Lagrangian
  • relationOperator: PDF p.27: incidence matrix of the actual subspace.
  • tensorRelation: PDF p.27: r(T) tensor n, regrouped into t blocks of n qudits.
  • cliffordCommutant: Concrete commutant of all Clifford tensor powers.
  • commutantCount: The t-1 factors give an empty product at t=1.
  • IsStochasticOrthogonal: PDF p.34, Definition 4.11.
  • StochasticOrthogonal
  • graphRelation: Graph of a computed linear map.
  • perpendicular: PDF p.36: dot-product annihilator.
  • IsDefect: PDF p.36: isotropy and co-stochasticity are both required.
  • leftDefect: PDF p.37: left kernel.
  • rightDefect: PDF p.37: right kernel.
  • defectQuotient: PDF p.36: N-perp/N as a submodule of the ambient quotient.
  • defectClass: Quotient class of an admissible representative.
  • defectRepresentative: Canonical representative for the phase-independent coset vector.
  • DefectIsomorphism: PDF p.36: invertible linear quotient map preserving q on all representatives and the ones class.
  • defectRelationSet: PDF p.36, (4.17): the actual relation, with quotient direction right to left.
  • defectRelation: Linear span construction, accompanied by exact relation-set equality in the theorem.
  • cosetState: PDF p.39: uniform normalized coset ket.
  • cssRelation: PDF p.39, (4.21): CSS relation with equal defects and identity quotient map.
  • cssProjector: PDF p.39, (4.22): independent Pauli definition of the CSS projector.
  • composeRelation: PDF pp.40--41: relational composition with an existential intermediate vector.
  • actedRelation: PDF p.36: left/right action; the right coordinate uses transpose.
  • SameDoubleOrbit: PDF p.38: concrete double orbit predicate.
  • antiPermutation: PDF p.44: binary anti-permutation matrix.
  • phasePointOperator: PDF p.16, (2.11): phase-space point operator.
  • discreteWigner: PDF p.16, (2.10), real for odd d on pure-state inputs.
  • sumNegativity: PDF p.58: negative mass, not the full l1 norm.
  • threeCopyInvolution: PDF p.61, (8.3): the concrete three-copy involution.
  • threeCopyTest: PDF p.62: accepting effect on three copies.
  • stabilizerMoment: PDF p.45: uniform moment without counting state phases repeatedly.
  • momentNormalization: PDF p.46: Z_{n,d,t}.
  • minimalTest: PDF p.48, (5.11): group-average test independent of the stabilizer span.
  • IsOrthogonalProjectionOnto: Orthogonal projection onto a specified concrete vector subspace.
  • stabilizerSpan: PDF p.48: actual span of stabilizer tensor powers.
  • repeatEffect: Tensor product of r copies of a k-copy effect, flattened to k*r physical copies.
  • embeddedLocal: A constant-size block acting on the k corresponding qudits at physical site j.
  • copyPrefixReduction: Copy-prefix partial trace, reusing the accepted construction with reordered arguments. Its n=0 and s=0 values are scalar traces, not junk defaults.
  • compressZero: Zero-ancilla compression in the physical-qudit coordinates.
  • permutationOperator: Computational permutation of the t blocks.
  • IsPermutationSymmetric: The symmetric-subspace condition is vector invariance.
  • embeddedAntiIdentity: Anti-identity on a specified set of six distinct blocks.
  • IsDistributionOn: Finite probability weights on precisely a named finite set.
  • stabilizerMixture: Convex mixture of s-copy density tensors.
  • stabilizerVector: A representative vector for each phase-free pure stabilizer, with a harmless default off the set.
  • stabilizerGram: PDF p.53: source Gram matrix, built from the canonical state representatives.
  • stabilizerFrame: PDF p.53: the frame operator Q, constructed independently of a Gram bound.
  • positivePseudoInverse: Moore--Penrose inverse of a PSD matrix, with zero inverse defined as zero by cfc.
  • rowVectorize: Source row-stacking vectorization; unlike Matrix.vec it indexes the row first.
  • unitaryChoiVector: Normalized Choi ket, ordered as the output register then the reference register.
  • haarMoment: Finite normalized Haar moment, using the exact permutation formula (5.7), PDF p.47. This is a formula for the Haar integral, not a new distributional hypothesis.
  • PauliAction: One scalar-free Clifford is specified by its conjugation action on the finite Pauli group.
  • RealizesAction: The faithful finite image of the Clifford group modulo scalar phases.
  • cliffordActions: The actual finite normalizer quotient; only realized actions are counted.
  • cliffordRepresentative: Choice of scalar representative has no effect on any density-matrix twirl.
  • cliffordMoment: PDF pp.49--50: uniform Clifford-orbit moment, counted once modulo phases.
  • residuePermutation: PDF p.50: permutation matrix over the residue field.
  • transposeRelation: Transposed relation.
  • SameDesignClass: Definition 6.1: permutation double action plus transposition, not O-double-orbits.
  • designClasses: Distinct equivalence classes are represented as finite subsets, avoiding a chosen enumeration.
  • designClassOf: PDF pp.51--52: actual class containing a specified subspace.
  • qutritDefect: All-ones defect of the qutrit example.
  • qutritFourThird: Third representative printed on PDF p.52, with eight coordinates grouped as left/right.
  • qutritFourAnti: Qutrit anti-identity of (4.35) for t=4; entries 1 on diagonal and 2 elsewhere.
  • canonicalDefectMap: PDF p.37: canonical right-to-left quotient function obtained from the relation itself.
  • doubleClasses: Finite collection of actual double orbits.
  • unitaryDistance: Source average-case distance for unitary testing.
  • choiMonomial: Degree-six Choi tensor monomial, without an irrelevant common normalization.
  • cliffordPolynomial: PDF p.8: actual degree-six anti-identity invariance equations in the entries of U.
  • qubitVerificationUnitary: PDF p.22, (3.11): the source six-copy verification unitary, not the anti-identity surrogate.
  • designClassSum: Class sums R_i from Definition 6.1, independent of a state or its twirl.
  • designCoefficients: The coefficients of the concrete Clifford moment, set to zero off the actual class set. The source stable-range theorem guarantees the expansion; no such guarantee is a hypothesis.
  • qutritSymmetricProjector: Physical symmetric projector on three qutrit blocks.
  • qutritAlternatingProjector: Physical alternating projector on three qutrit blocks.
  • qutritCSSProjector: PDF p.42, (4.29): independent CSS Pauli projector, tensorized over physical sites.
  • qutritPieceProjector: PDF pp.42--43: the four compressed pieces, and one physical standard-S3 multiplicity slice. P_minus is defined by alternating compression, which fixes the printed plus-sign error.
  • qutritPiece: Source physical irreducible carriers, constructed from the five projections.
  • IsCliffordInvariant: Invariance under the actual Clifford tensor-power action.
  • IsCliffordIrreducible: Nonzero irreducible physical Clifford module.
  • CliffordModulesEquivalent: Equivalence means an actual linear bijection intertwining the physical action on the two carriers.
  • pieceIndex: Four one-fold constituents and two copies of the (2,1) constituent.
  • QutritDecomposition
  • standardS3: The standard S3 representation in the basis e0-e2,e1-e2 of the zero-sum plane.
Definition code
import Mathlib
import Definitions.Def_QAlgorithms_Defs_Information
import Definitions.Def_QAlgorithms_Defs_MatrixDistances
import Definitions.Def_QAlgorithms_Defs_Ensemble
import Definitions.Def_QAlgorithms_Papers_Independent_Information100_P63
import Definitions.Def_QAlgorithms_Papers_Independent_Advance50_P30
import Definitions.Def_QAlgorithms_Papers_Independent_Gap20_P06

/-! Concrete models for arXiv:1712.08628v3. Computational indices are copy-first.
Accepted tensor powers, copy carriers and prefix partial trace are imported.
Cyclic-residue phases and finite quadratic geometry use paper-specific names;
the similarly named frozen continuous-variable objects have different domains. -/

noncomputable section

open scoped BigOperators ComplexConjugate Matrix

namespace QAlgorithms.Papers.Independent.Extend50.P30

open QAlgorithms.Papers.Independent.Information100.P63 (tensorPower)
open QAlgorithms.Papers.Independent.Gap20.P06 (ketBra)

attribute [local instance] Classical.propDecidable

/-- PDF p.14: n qudits in the specified cyclic-residue computational basis. -/
abbrev ResidueRegister (d n : ℕ) := Fin n → ZMod d

/-- PDF p.15: momentum and position labels over ZMod d, also for composite d. -/
abbrev DiscretePhaseSpace (d n : ℕ) := ResidueRegister d n × ResidueRegister d n

/-- PDF p.14: operators indexed by the cyclic computational register. -/
abbrev QuditOperator (d n : ℕ) := Matrix (ResidueRegister d n) (ResidueRegister d n) ℂ

/-- Specialize the accepted copy register to the source cyclic-qudit basis. -/
abbrev QuditCopies (d n t : ℕ) :=
  QAlgorithms.Papers.Independent.Gap48.P20.Copies (ResidueRegister d n) t

/-- PDF p.14: the order of weylPhase. -/
def phaseModulus (d : ℕ) : ℕ := if Even d then 2 * d else d

/-- PDF p.14: omega, with the stray q removed as fixed by the action of Z. -/
def weylRoot (d : ℕ) : ℂ := Complex.exp (2 * Real.pi * Complex.I / (d : ℂ))

/-- PDF p.14: weylPhase includes the parity-dependent sign. -/
def weylPhase (d : ℕ) : ℂ := (-1 : ℂ) ^ d * Complex.exp (Real.pi * Complex.I / (d : ℂ))

/-- PDF pp.14--15, (2.1): canonical lifts and output-row convention for Z^p X^q. -/
def cyclicWeyl (d n : ℕ) [NeZero d] (x : DiscretePhaseSpace d n) : QuditOperator d n :=
  fun a b => if a = b + x.2 then
    (weylPhase d) ^ (-((∑ j, (x.1 j).val * (x.2 j).val : ℕ) : ℤ)) *
      (weylRoot d) ^ (∑ j, (x.1 j).val * (a j).val) else 0

/-- PDF p.15, (2.3), with the source sign. -/
def symplecticBracket {d n : ℕ} (x y : DiscretePhaseSpace d n) : ZMod d :=
  ∑ j, (x.1 j * y.2 j - x.2 j * y.1 j)

/-- PDF pp.14--17: the finite Pauli group, including all powers of weylPhase. -/
def cyclicPauliGroup (d n : ℕ) [NeZero d] : Finset (QuditOperator d n) :=
  ((Finset.range (phaseModulus d)).product (Finset.univ : Finset (DiscretePhaseSpace d n))).image
    (fun a => (weylPhase d) ^ a.1 • cyclicWeyl d n a.2)

/-- PDF p.16: finite Pauli subgroup with no nonidentity scalar. -/
def IsCyclicStabilizerGroup {d n : ℕ} [NeZero d] (G : Finset (QuditOperator d n)) : Prop :=
  G ⊆ cyclicPauliGroup d n ∧ 1 ∈ G ∧
  (∀ A ∈ G, ∀ B ∈ G, A * B ∈ G) ∧ (∀ A ∈ G, Aᴴ ∈ G) ∧
  (∀ A ∈ G, ∀ c : ℂ, A = c • (1 : QuditOperator d n) → c = 1)

/-- PDF p.16, (2.14): code projection before trace normalization. -/
def pauliAverageProjector {d n : ℕ} [NeZero d] (G : Finset (QuditOperator d n)) : QuditOperator d n :=
  (G.card : ℂ)⁻¹ • ∑ P ∈ G, P

/-- PDF p.58 footnote 8: maximally mixed code states, not their convex hull. -/
def mixedStabilizers (d n : ℕ) [NeZero d] : Finset (QuditOperator d n) :=
  (((cyclicPauliGroup d n).powerset.filter IsCyclicStabilizerGroup).image fun G =>
    ((pauliAverageProjector G).trace)⁻¹ • pauliAverageProjector G)

/-- PDF p.17: phase-free pure stabilizer density matrices. -/
def stabilizers (d n : ℕ) [NeZero d] : Finset (QuditOperator d n) :=
  (mixedStabilizers d n).filter fun A => ∃ v : EuclideanSpace ℂ (ResidueRegister d n),
    ‖v‖ = 1 ∧ A = QAlgorithms.pureDensity v

/-- Pure stabilizer predicate; vector phases are immaterial. -/
def IsStabilizer {d n : ℕ} [NeZero d] (v : EuclideanSpace ℂ (ResidueRegister d n)) : Prop :=
  ‖v‖ = 1 ∧ QAlgorithms.pureDensity v ∈ stabilizers d n

/-- Fidelity with a pure state specified by its density matrix. -/
def stabilizerOverlap {d n : ℕ} [NeZero d] (S : QuditOperator d n)
    (v : EuclideanSpace ℂ (ResidueRegister d n)) : ℝ := QAlgorithms.effectProb S (QAlgorithms.pureDensity v)

/-- Source maximum upper bound, pointwise on exactly the finite stabilizer set. -/
def FarFromStabilizers {d n : ℕ} [NeZero d]
    (v : EuclideanSpace ℂ (ResidueRegister d n)) (epsilon : ℝ) : Prop :=
  ∀ S ∈ stabilizers d n, stabilizerOverlap S v ≤ 1 - epsilon ^ 2

/-- PDF p.14: full unitary normalizer, retaining scalar representatives. -/
def IsClifford {d n : ℕ} [NeZero d] (U : QuditOperator d n) : Prop :=
  U ∈ Matrix.unitaryGroup (ResidueRegister d n) ℂ ∧
  (cyclicPauliGroup d n).image (fun P => U * P * Uᴴ) = cyclicPauliGroup d n

/-- PDF p.18, (3.2): characteristic distribution. -/
def characteristicDistribution {d n : ℕ} [NeZero d]
    (v : EuclideanSpace ℂ (ResidueRegister d n)) (x : DiscretePhaseSpace d n) : ℝ :=
  ((d : ℝ) ^ n)⁻¹ * Complex.normSq (inner ℂ v (QAlgorithms.act (cyclicWeyl d n x) v))

/-- PDF p.19: normalized Bell vector (W_x tensor I)|Phi+>. -/
def weylBellVector (n : ℕ) (x : DiscretePhaseSpace 2 n) :
    EuclideanSpace ℂ (ResidueRegister 2 n × ResidueRegister 2 n) :=
  WithLp.toLp 2 (fun a => ((Real.sqrt ((2 : ℝ) ^ n))⁻¹ : ℂ) * cyclicWeyl 2 n x a.1 a.2)

/-- PDF p.19: two Bell measurements and XOR of the labels, on four copies. -/
def bellDifference (n : ℕ) (a : DiscretePhaseSpace 2 n) :
    Matrix (QuditCopies 2 n 4) (QuditCopies 2 n 4) ℂ :=
  fun u v => ∑ x : DiscretePhaseSpace 2 n,
    QAlgorithms.pureDensity (weylBellVector n x) (u 0, u 1) (v 0, v 1) *
    QAlgorithms.pureDensity (weylBellVector n (x + a)) (u 2, u 3) (v 2, v 3)

/-- PDF p.22, (3.11): Algorithm 1, four sampling copies and two verification copies. -/
def qubitTest (n : ℕ) : Matrix (QuditCopies 2 n 6) (QuditCopies 2 n 6) ℂ :=
  fun u v => ∑ a : DiscretePhaseSpace 2 n,
    bellDifference n a (fun i => u ⟨i.val, by omega⟩) (fun i => v ⟨i.val, by omega⟩) *
    (2⁻¹ : ℂ) * ((if (u 4, u 5) = (v 4, v 5) then 1 else 0) +
      cyclicWeyl 2 n a (u 4) (v 4) * (cyclicWeyl 2 n a)ᴴ (u 5) (v 5))

/-- PDF p.22, Remark 3.5: two Bell-sampling and two verification copies. -/
def realQubitTest (n : ℕ) : Matrix (QuditCopies 2 n 4) (QuditCopies 2 n 4) ℂ :=
  fun u v => ∑ a : DiscretePhaseSpace 2 n,
    QAlgorithms.pureDensity (weylBellVector n a) (u 0, u 1) (v 0, v 1) * (2⁻¹ : ℂ) *
    ((if (u 2, u 3) = (v 2, v 3) then 1 else 0) +
      cyclicWeyl 2 n a (u 2) (v 2) * (cyclicWeyl 2 n a)ᴴ (u 3) (v 3))

/-- PDF p.23, (3.15): alternating W and W dagger, with normalization d^{-n}. -/
def quditInvolution (d n s : ℕ) [NeZero d] :
    Matrix (QuditCopies d n (2 * s)) (QuditCopies d n (2 * s)) ℂ :=
  fun u v => ((d : ℂ) ^ n)⁻¹ * ∑ x : DiscretePhaseSpace d n,
    ∏ j : Fin (2 * s), if Even j.val then cyclicWeyl d n x (u j) (v j)
      else (cyclicWeyl d n x)ᴴ (u j) (v j)

/-- PDF p.24: accepting effect on exactly 2s copies. -/
def quditTest (d n s : ℕ) [NeZero d] :
    Matrix (QuditCopies d n (2 * s)) (QuditCopies d n (2 * s)) ℂ :=
  (2⁻¹ : ℂ) • (1 + quditInvolution d n s)

/-- PDF p.25: exact soundness coefficient. -/
def soundnessConstant (d s : ℕ) : ℝ :=
  (1 - (1 - 1 / (4 * (d : ℝ) ^ 2)) ^ (s - 1)) / 2

/-- Binary POVM on k physical copies, fixed independently of the input. -/
structure CopyTest (d n : ℕ) [NeZero d] where
  copies : ℕ
  accept : Matrix (QuditCopies d n copies) (QuditCopies d n copies) ℂ
  effect : QAlgorithms.IsEffect accept

/-- Born probability from the carried effect and copy count. -/
def CopyTest.prob {d n : ℕ} [NeZero d] (A : CopyTest d n)
    (v : EuclideanSpace ℂ (ResidueRegister d n)) : ℝ :=
  QAlgorithms.effectProb A.accept (tensorPower A.copies (QAlgorithms.pureDensity v))

/-- PDF p.27: q, with canonical lifts, including reduction modulo 4 at d=2. -/
def residueQuadratic {d t : ℕ} [NeZero d] (x : ResidueRegister d t) : ZMod (phaseModulus d) :=
  ∑ j, ((x j).val : ZMod (phaseModulus d)) ^ 2

/-- PDF p.27: at prime d, cardinality d^t is exactly dimension t. -/
def IsStochasticLagrangian {d t : ℕ} [NeZero d]
    (T : Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t)) : Prop :=
  (∀ z ∈ T, residueQuadratic z.1 = residueQuadratic z.2) ∧ Nat.card T = d ^ t ∧
    ((fun _ => 1), (fun _ => 1)) ∈ T

abbrev Lagrangian (d t : ℕ) [NeZero d] :=
  {T : Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t) // IsStochasticLagrangian T}

/-- Finite enumeration of source Sigma; no mathematical assumptions added. -/
instance instFintypeLagrangian (d t : ℕ) [NeZero d] : Fintype (Lagrangian d t) := Fintype.ofFinite _

/-- PDF p.27: incidence matrix of the actual subspace. -/
def relationOperator {d t : ℕ} [NeZero d]
    (T : Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t)) : QuditOperator d t :=
  fun x y => if (x, y) ∈ T then 1 else 0

/-- PDF p.27: r(T) tensor n, regrouped into t blocks of n qudits. -/
def tensorRelation {d t : ℕ} [NeZero d] (n : ℕ)
    (T : Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t)) :
    Matrix (QuditCopies d n t) (QuditCopies d n t) ℂ :=
  fun x y => ∏ j : Fin n, relationOperator T (fun i => x i j) (fun i => y i j)

/-- Concrete commutant of all Clifford tensor powers. -/
def cliffordCommutant (d n t : ℕ) [NeZero d] :
    Submodule ℂ (Matrix (QuditCopies d n t) (QuditCopies d n t) ℂ) where
  carrier := {A | ∀ U : QuditOperator d n, IsClifford U →
    A * tensorPower t U = tensorPower t U * A}
  zero_mem' := by simp
  add_mem' := by intro A B hA hB U hU; simp [Matrix.add_mul, Matrix.mul_add, hA U hU, hB U hU]
  smul_mem' := by intro c A hA U hU; simp [Matrix.smul_mul, Matrix.mul_smul, hA U hU]

/-- The t-1 factors give an empty product at t=1. -/
def commutantCount (d t : ℕ) : ℕ := ∏ k ∈ Finset.range (t - 1), (d ^ k + 1)

/-- PDF p.34, Definition 4.11. -/
def IsStochasticOrthogonal {d t : ℕ} [NeZero d]
    (O : Matrix (Fin t) (Fin t) (ZMod d)) : Prop :=
  (∀ x, residueQuadratic (O.mulVec x) = residueQuadratic x) ∧ O.mulVec (fun _ => 1) = (fun _ => 1)

abbrev StochasticOrthogonal (d t : ℕ) [NeZero d] :=
  {O : Matrix (Fin t) (Fin t) (ZMod d) // IsStochasticOrthogonal O}

/-- Finite enumeration of source stochastic isometries. -/
instance instFintypeStochasticOrthogonal (d t : ℕ) [NeZero d] : Fintype (StochasticOrthogonal d t) := Fintype.ofFinite _

/-- Graph of a computed linear map. -/
def graphRelation {d t : ℕ} [NeZero d] (O : Matrix (Fin t) (Fin t) (ZMod d)) :
    Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t) where
  carrier := {z | z.1 = O.mulVec z.2}
  zero_mem' := by simp
  add_mem' := by
    intro a b ha hb
    change a.1 = O.mulVec a.2 at ha
    change b.1 = O.mulVec b.2 at hb
    change a.1 + b.1 = O.mulVec (a.2 + b.2)
    rw [Matrix.mulVec_add, ha, hb]
  smul_mem' := by
    intro c b hb
    change b.1 = O.mulVec b.2 at hb
    change c • b.1 = O.mulVec (c • b.2)
    rw [Matrix.mulVec_smul, hb]

/-- PDF p.36: dot-product annihilator. -/
def perpendicular {d t : ℕ} (N : Submodule (ZMod d) (ResidueRegister d t)) :
    Submodule (ZMod d) (ResidueRegister d t) where
  carrier := {x | ∀ y ∈ N, dotProduct x y = 0}
  zero_mem' := by simp [dotProduct]
  add_mem' := by
    intro a b ha hb y hy
    change (∑ i, (a i + b i) * y i) = 0
    simp only [add_mul, Finset.sum_add_distrib]
    change dotProduct a y + dotProduct b y = 0
    rw [ha y hy, hb y hy, add_zero]
  smul_mem' := by
    intro c x hx y hy
    change (∑ i, (c * x i) * y i) = 0
    simp only [mul_assoc, ← Finset.mul_sum]
    change c * dotProduct x y = 0
    rw [hx y hy, mul_zero]

/-- PDF p.36: isotropy and co-stochasticity are both required. -/
def IsDefect {d t : ℕ} [NeZero d] (N : Submodule (ZMod d) (ResidueRegister d t)) : Prop :=
  (∀ x ∈ N, residueQuadratic x = 0) ∧ (fun _ => 1) ∈ perpendicular N

/-- PDF p.37: left kernel. -/
def leftDefect {d t : ℕ} (T : Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t)) :
    Submodule (ZMod d) (ResidueRegister d t) := T.comap (LinearMap.inl (ZMod d) _ _)

/-- PDF p.37: right kernel. -/
def rightDefect {d t : ℕ} (T : Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t)) :
    Submodule (ZMod d) (ResidueRegister d t) := T.comap (LinearMap.inr (ZMod d) _ _)

/-- PDF p.36: N-perp/N as a submodule of the ambient quotient. -/
def defectQuotient {d t : ℕ} (N : Submodule (ZMod d) (ResidueRegister d t)) :=
  (perpendicular N).map N.mkQ

/-- Quotient class of an admissible representative. -/
def defectClass {d t : ℕ} (N : Submodule (ZMod d) (ResidueRegister d t))
    (x : ResidueRegister d t) (hx : x ∈ perpendicular N) : defectQuotient N :=
  ⟨N.mkQ x, ⟨x, hx, rfl⟩⟩

/-- Canonical representative for the phase-independent coset vector. -/
def defectRepresentative {d t : ℕ} (N : Submodule (ZMod d) (ResidueRegister d t))
    (x : defectQuotient N) : ResidueRegister d t := Classical.choose x.property

/-- PDF p.36: invertible linear quotient map preserving q on all representatives and the ones class. -/
structure DefectIsomorphism {d t : ℕ} [NeZero d]
    (N M : Submodule (ZMod d) (ResidueRegister d t)) where
  linearEquiv : defectQuotient N ≃ₗ[ZMod d] defectQuotient M
  residueQuadratic : ∀ x hx y hy, linearEquiv (defectClass N x hx) = defectClass M y hy →
    P30.residueQuadratic x = P30.residueQuadratic y
  stochastic : ∀ hx hy,
    linearEquiv (defectClass N (fun _ => 1) hx) = defectClass M (fun _ => 1) hy

/-- PDF p.36, (4.17): the actual relation, with quotient direction right to left. -/
def defectRelationSet {d t : ℕ} [NeZero d] (N M : Submodule (ZMod d) (ResidueRegister d t))
    (J : DefectIsomorphism M N) : Set (ResidueRegister d t × ResidueRegister d t) :=
  {z | ∃ hx : z.1 ∈ perpendicular N, ∃ hy : z.2 ∈ perpendicular M,
    J.linearEquiv (defectClass M z.2 hy) = defectClass N z.1 hx}

/-- Linear span construction, accompanied by exact relation-set equality in the theorem. -/
def defectRelation {d t : ℕ} [NeZero d] (N M : Submodule (ZMod d) (ResidueRegister d t))
    (J : DefectIsomorphism M N) : Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t) :=
  Submodule.span (ZMod d) (defectRelationSet N M J)

/-- PDF p.39: uniform normalized coset ket. -/
def cosetState {d t : ℕ} [NeZero d] (N : Submodule (ZMod d) (ResidueRegister d t))
    (q : defectQuotient N) : EuclideanSpace ℂ (ResidueRegister d t) :=
  WithLp.toLp 2 (fun x => if x - defectRepresentative N q ∈ N then
    ((Real.sqrt (Nat.card N : ℝ))⁻¹ : ℂ) else 0)

/-- PDF p.39, (4.21): CSS relation with equal defects and identity quotient map. -/
def cssRelation {d t : ℕ} (N : Submodule (ZMod d) (ResidueRegister d t)) :
    Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t) where
  carrier := {z | z.1 ∈ perpendicular N ∧ z.2 ∈ perpendicular N ∧ z.1 - z.2 ∈ N}
  zero_mem' := by simp
  add_mem' := by
    rintro a b ⟨ha, hb, hc⟩ ⟨hd, he, hf⟩
    exact ⟨(perpendicular N).add_mem ha hd, (perpendicular N).add_mem hb he,
      by simpa [add_sub_add_comm] using N.add_mem hc hf⟩
  smul_mem' := by
    rintro c a ⟨ha, hb, hc⟩
    exact ⟨(perpendicular N).smul_mem c ha, (perpendicular N).smul_mem c hb,
      by simpa [smul_sub] using N.smul_mem c hc⟩

/-- PDF p.39, (4.22): independent Pauli definition of the CSS projector. -/
def cssProjector {d t : ℕ} [NeZero d] (N : Submodule (ZMod d) (ResidueRegister d t)) : QuditOperator d t :=
  ((Nat.card N : ℂ) ^ 2)⁻¹ • ∑ p : N, ∑ q : N,
    cyclicWeyl d t (p.val, 0) * cyclicWeyl d t (0, q.val)

/-- PDF pp.40--41: relational composition with an existential intermediate vector. -/
def composeRelation {d t : ℕ}
    (A B : Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t)) :
    Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t) :=
  Submodule.span (ZMod d) {z | ∃ y, (z.1, y) ∈ A ∧ (y, z.2) ∈ B}

/-- PDF p.36: left/right action; the right coordinate uses transpose. -/
def actedRelation {d t : ℕ} (O P : Matrix (Fin t) (Fin t) (ZMod d))
    (T : Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t)) :
    Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t) :=
  Submodule.span (ZMod d) {z | ∃ w ∈ T, z = (O.mulVec w.1, P.transpose.mulVec w.2)}

/-- PDF p.38: concrete double orbit predicate. -/
def SameDoubleOrbit {d t : ℕ} [NeZero d] (T S : Lagrangian d t) : Prop :=
  ∃ O P : StochasticOrthogonal d t, S.val = actedRelation O.val P.val T.val

/-- PDF p.44: binary anti-permutation matrix. -/
def antiPermutation {t : ℕ} (p : Equiv.Perm (Fin t)) : Matrix (Fin t) (Fin t) (ZMod 2) :=
  fun i j => 1 - if i = p j then 1 else 0

/-- PDF p.16, (2.11): phase-space point operator. -/
def phasePointOperator (d n : ℕ) [NeZero d] (x : DiscretePhaseSpace d n) : QuditOperator d n :=
  ((d : ℂ) ^ n)⁻¹ • ∑ y : DiscretePhaseSpace d n,
    (weylRoot d) ^ (-((symplecticBracket x y).val : ℤ)) • (cyclicWeyl d n y)ᴴ

/-- PDF p.16, (2.10), real for odd d on pure-state inputs. -/
def discreteWigner {d n : ℕ} [NeZero d] (v : EuclideanSpace ℂ (ResidueRegister d n))
    (x : DiscretePhaseSpace d n) : ℝ :=
  ((d : ℝ) ^ n)⁻¹ * QAlgorithms.effectProb (phasePointOperator d n x) (QAlgorithms.pureDensity v)

/-- PDF p.58: negative mass, not the full l1 norm. -/
def sumNegativity {d n : ℕ} [NeZero d] (v : EuclideanSpace ℂ (ResidueRegister d n)) : ℝ :=
  ∑ x : DiscretePhaseSpace d n, max 0 (-discreteWigner v x)

/-- PDF p.61, (8.3): the concrete three-copy involution. -/
def threeCopyInvolution (d n : ℕ) [NeZero d] : Matrix (QuditCopies d n 3) (QuditCopies d n 3) ℂ :=
  ((d : ℂ) ^ n)⁻¹ • ∑ x : DiscretePhaseSpace d n, tensorPower 3 (phasePointOperator d n x)

/-- PDF p.62: accepting effect on three copies. -/
def threeCopyTest (d n : ℕ) [NeZero d] : Matrix (QuditCopies d n 3) (QuditCopies d n 3) ℂ :=
  (2⁻¹ : ℂ) • (1 + threeCopyInvolution d n)

/-- PDF p.45: uniform moment without counting state phases repeatedly. -/
def stabilizerMoment (d n t : ℕ) [NeZero d] : Matrix (QuditCopies d n t) (QuditCopies d n t) ℂ :=
  ((stabilizers d n).card : ℂ)⁻¹ • ∑ S ∈ stabilizers d n, tensorPower t S

/-- PDF p.46: Z_{n,d,t}. -/
def momentNormalization (d n t : ℕ) : ℕ :=
  d ^ n * ∏ k ∈ Finset.range (t - 1), (d ^ k + d ^ n)

/-- PDF p.48, (5.11): group-average test independent of the stabilizer span. -/
def minimalTest (d n t : ℕ) [NeZero d] : Matrix (QuditCopies d n t) (QuditCopies d n t) ℂ :=
  (Nat.card (StochasticOrthogonal d t) : ℂ)⁻¹ •
    ∑ O : StochasticOrthogonal d t, tensorRelation n (graphRelation O.val)

/-- Orthogonal projection onto a specified concrete vector subspace. -/
def IsOrthogonalProjectionOnto {I : Type*} [Fintype I] [DecidableEq I]
    (P : Matrix I I ℂ) (V : Submodule ℂ (I → ℂ)) : Prop :=
  Pᴴ = P ∧ P * P = P ∧ LinearMap.range (Matrix.toLin' P) = V

/-- PDF p.48: actual span of stabilizer tensor powers. -/
def stabilizerSpan (d n t : ℕ) [NeZero d] : Submodule ℂ (QuditCopies d n t → ℂ) :=
  Submodule.span ℂ {w | ∃ v : EuclideanSpace ℂ (ResidueRegister d n), IsStabilizer v ∧
    w = fun x => QAlgorithms.tensorPow t v x}

/-- Empty tensors are scalars, including the zero-qudit corner. -/
example {I : Type*} (A : Matrix I I ℂ) (x y : Fin 0 → I) : tensorPower 0 A x y = 1 := by
  simp [tensorPower]

/-- Graph incidence agrees with the computational permutation matrix. -/
example {d t : ℕ} [NeZero d] (O : Matrix (Fin t) (Fin t) (ZMod d)) (x y : ResidueRegister d t) :
    relationOperator (graphRelation O) x y = (if x = O.mulVec y then 1 else 0) := by
  simp [relationOperator, graphRelation]

/-- The t=1 product is empty. -/
example (d : ℕ) : commutantCount d 1 = 1 := by simp [commutantCount]

/-- Qubit q takes values modulo four. -/
example : phaseModulus 2 = 4 := by norm_num [phaseModulus]

/-- Tensor product of r copies of a k-copy effect, flattened to k*r physical copies. -/
def repeatEffect {d n k : ℕ} [NeZero d] (r : ℕ)
    (A : Matrix (QuditCopies d n k) (QuditCopies d n k) ℂ) :
    Matrix (QuditCopies d n (k * r)) (QuditCopies d n (k * r)) ℂ :=
  fun x y => ∏ j : Fin r, A
    (fun i => x ⟨j.val * k + i.val, by nlinarith [j.isLt, i.isLt, Nat.mul_le_mul_right k (Nat.succ_le_of_lt j.isLt)]⟩)
    (fun i => y ⟨j.val * k + i.val, by nlinarith [j.isLt, i.isLt, Nat.mul_le_mul_right k (Nat.succ_le_of_lt j.isLt)]⟩)

/-- A constant-size block acting on the k corresponding qudits at physical site j. -/
def embeddedLocal {d n k : ℕ} [NeZero d] (j : Fin n)
    (L : Matrix (QuditCopies d 1 k) (QuditCopies d 1 k) ℂ) :
    Matrix (QuditCopies d n k) (QuditCopies d n k) ℂ :=
  fun x y => if ∀ i l, l ≠ j → x i l = y i l then
    L (fun i _ => x i j) (fun i _ => y i j) else 0

/-- Copy-prefix partial trace, reusing the accepted construction with reordered arguments.
Its n=0 and s=0 values are scalar traces, not junk defaults. -/
def copyPrefixReduction {d n t : ℕ} [NeZero d] (s : ℕ) (hs : s ≤ t)
    (A : Matrix (QuditCopies d n t) (QuditCopies d n t) ℂ) :
    Matrix (QuditCopies d n s) (QuditCopies d n s) ℂ :=
  QAlgorithms.Papers.Independent.Advance50.P30.reduceCopies A s hs

/-- Zero-ancilla compression in the physical-qudit coordinates. -/
def compressZero {d N n t : ℕ} [NeZero d] (hn : n ≤ N)
    (A : Matrix (QuditCopies d N t) (QuditCopies d N t) ℂ) :
    Matrix (QuditCopies d n t) (QuditCopies d n t) ℂ :=
  fun x y => A
    (fun i j => if h : j.val < n then x i ⟨j.val, h⟩ else 0)
    (fun i j => if h : j.val < n then y i ⟨j.val, h⟩ else 0)

/-- Computational permutation of the t blocks. -/
def permutationOperator (d n t : ℕ) [NeZero d] (p : Equiv.Perm (Fin t)) :
    Matrix (QuditCopies d n t) (QuditCopies d n t) ℂ :=
  fun x y => if x = fun i => y (p.symm i) then 1 else 0

/-- The symmetric-subspace condition is vector invariance. -/
def IsPermutationSymmetric {d n t : ℕ} [NeZero d] (v : EuclideanSpace ℂ (QuditCopies d n t)) : Prop :=
  ∀ p : Equiv.Perm (Fin t), QAlgorithms.act (permutationOperator d n t p) v = v

/-- Anti-identity on a specified set of six distinct blocks. -/
def embeddedAntiIdentity {n t : ℕ} (e : Fin 6 ↪ Fin t) :
    Matrix (QuditCopies 2 n t) (QuditCopies 2 n t) ℂ :=
  fun x y => if ∀ i, i ∉ Set.range e → x i = y i then
    quditInvolution 2 n 3 (fun i => x (e i)) (fun i => y (e i)) else 0

/-- Finite probability weights on precisely a named finite set. -/
def IsDistributionOn {I : Type*} (F : Finset I) (p : I → ℝ) : Prop :=
  (∀ i ∈ F, 0 ≤ p i) ∧ ∑ i ∈ F, p i = 1

/-- Convex mixture of s-copy density tensors. -/
def stabilizerMixture {d n : ℕ} [NeZero d] (s : ℕ) (F : Finset (QuditOperator d n))
    (p : QuditOperator d n → ℝ) : Matrix (QuditCopies d n s) (QuditCopies d n s) ℂ :=
  ∑ S ∈ F, (p S : ℂ) • tensorPower s S

/-- A representative vector for each phase-free pure stabilizer, with a harmless default off the set. -/
def stabilizerVector {d n : ℕ} [NeZero d] (S : QuditOperator d n) :
    EuclideanSpace ℂ (ResidueRegister d n) :=
  if h : ∃ v : EuclideanSpace ℂ (ResidueRegister d n), ‖v‖ = 1 ∧ S = QAlgorithms.pureDensity v
  then Classical.choose h else 0

/-- PDF p.53: source Gram matrix, built from the canonical state representatives. -/
def stabilizerGram (d n t : ℕ) [NeZero d] :
    Matrix {S // S ∈ stabilizers d n} {S // S ∈ stabilizers d n} ℂ :=
  fun S T => (inner ℂ (stabilizerVector S.val) (stabilizerVector T.val)) ^ t

/-- PDF p.53: the frame operator Q, constructed independently of a Gram bound. -/
def stabilizerFrame (d n t : ℕ) [NeZero d] : Matrix (QuditCopies d n t) (QuditCopies d n t) ℂ :=
  ∑ S ∈ stabilizers d n, tensorPower t S

/-- Moore--Penrose inverse of a PSD matrix, with zero inverse defined as zero by cfc. -/
def positivePseudoInverse {I : Type*} [Fintype I] [DecidableEq I]
    (A : Matrix I I ℂ) : Matrix I I ℂ := cfc (fun x : ℝ => x⁻¹) A

/-- Source row-stacking vectorization; unlike Matrix.vec it indexes the row first. -/
def rowVectorize {I : Type*} (A : Matrix I I ℂ) : EuclideanSpace ℂ (I × I) :=
  WithLp.toLp 2 (fun x => A x.1 x.2)

/-- Normalized Choi ket, ordered as the output register then the reference register. -/
def unitaryChoiVector (n : ℕ) (U : QuditOperator 2 n) : EuclideanSpace ℂ (ResidueRegister 2 (n + n)) :=
  WithLp.toLp 2 (fun x => ((Real.sqrt ((2 : ℝ) ^ n))⁻¹ : ℂ) *
    U (fun i => x (Fin.castAdd n i)) (fun i => x (Fin.natAdd n i)))

/-- Finite normalized Haar moment, using the exact permutation formula (5.7), PDF p.47.
This is a formula for the Haar integral, not a new distributional hypothesis. -/
def haarMoment (d n t : ℕ) [NeZero d] : Matrix (QuditCopies d n t) (QuditCopies d n t) ℂ :=
  (∏ k ∈ Finset.range t, ((d : ℂ) ^ n + k))⁻¹ •
    ∑ p : Equiv.Perm (Fin t), permutationOperator d n t p

/-- One scalar-free Clifford is specified by its conjugation action on the finite Pauli group. -/
abbrev PauliAction (d n : ℕ) [NeZero d] :=
  {P // P ∈ cyclicPauliGroup d n} → {P // P ∈ cyclicPauliGroup d n}

/-- The faithful finite image of the Clifford group modulo scalar phases. -/
def RealizesAction {d n : ℕ} [NeZero d] (a : PauliAction d n) (U : QuditOperator d n) : Prop :=
  IsClifford U ∧ ∀ P, U * P.val * Uᴴ = (a P).val

/-- The actual finite normalizer quotient; only realized actions are counted. -/
def cliffordActions (d n : ℕ) [NeZero d] : Finset (PauliAction d n) :=
  Finset.univ.filter fun a => ∃ U, RealizesAction a U

/-- Choice of scalar representative has no effect on any density-matrix twirl. -/
def cliffordRepresentative {d n : ℕ} [NeZero d] (a : PauliAction d n) : QuditOperator d n :=
  if h : ∃ U, RealizesAction a U then Classical.choose h else 1

/-- PDF pp.49--50: uniform Clifford-orbit moment, counted once modulo phases. -/
def cliffordMoment {d n : ℕ} [NeZero d] (t : ℕ)
    (v : EuclideanSpace ℂ (ResidueRegister d n)) : Matrix (QuditCopies d n t) (QuditCopies d n t) ℂ :=
  ((cliffordActions d n).card : ℂ)⁻¹ • ∑ a ∈ cliffordActions d n,
    tensorPower t (QAlgorithms.pureDensity (QAlgorithms.act (cliffordRepresentative a) v))

/-- PDF p.50: permutation matrix over the residue field. -/
def residuePermutation {d t : ℕ} (p : Equiv.Perm (Fin t)) : Matrix (Fin t) (Fin t) (ZMod d) :=
  fun i j => if i = p j then 1 else 0

/-- Transposed relation. -/
def transposeRelation {d t : ℕ} (T : Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t)) :
    Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t) :=
  T.comap (LinearEquiv.prodComm (ZMod d) (ResidueRegister d t) (ResidueRegister d t)).toLinearMap

/-- Definition 6.1: permutation double action plus transposition, not O-double-orbits. -/
def SameDesignClass {d t : ℕ} [NeZero d] (T S : Lagrangian d t) : Prop :=
  ∃ p q : Equiv.Perm (Fin t),
    S.val = actedRelation (residuePermutation p) (residuePermutation q) T.val ∨
    S.val = actedRelation (residuePermutation p) (residuePermutation q) (transposeRelation T.val)

/-- Distinct equivalence classes are represented as finite subsets, avoiding a chosen enumeration. -/
def designClasses (d t : ℕ) [NeZero d] : Finset (Finset (Lagrangian d t)) :=
  Finset.univ.image fun T => Finset.univ.filter (SameDesignClass T)

/-- PDF pp.51--52: actual class containing a specified subspace. -/
def designClassOf {d t : ℕ} [NeZero d]
    (T : Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t)) : Finset (Lagrangian d t) :=
  Finset.univ.filter fun S => ∃ p q : Equiv.Perm (Fin t),
    S.val = actedRelation (residuePermutation p) (residuePermutation q) T ∨
    S.val = actedRelation (residuePermutation p) (residuePermutation q) (transposeRelation T)

/-- All-ones defect of the qutrit example. -/
def qutritDefect : Submodule (ZMod 3) (ResidueRegister 3 3) :=
  Submodule.span (ZMod 3) {(fun _ => 1)}

/-- Third representative printed on PDF p.52, with eight coordinates grouped as left/right. -/
def qutritFourThird : Submodule (ZMod 3) (ResidueRegister 3 4 × ResidueRegister 3 4) :=
  Submodule.span (ZMod 3) (Set.range (fun i : Fin 4 =>
    let A : Matrix (Fin 4) (Fin 8) (ZMod 3) :=
      ![![1,1,1,1,1,1,1,1], ![0,1,2,0,0,2,1,0],
        ![0,0,0,0,1,1,1,0], ![1,1,1,0,0,0,0,0]]
    ((fun j => A i (Fin.castAdd 4 j)), (fun j => A i (Fin.natAdd 4 j)))))

/-- Qutrit anti-identity of (4.35) for t=4; entries 1 on diagonal and 2 elsewhere. -/
def qutritFourAnti : Matrix (Fin 4) (Fin 4) (ZMod 3) :=
  fun i j => if i = j then 1 else 2

/-- Sanity: a zero vector has zero characteristic mass, hence normalization cannot be omitted. -/
example {d n : ℕ} [NeZero d] (x : DiscretePhaseSpace d n) :
    characteristicDistribution (0 : EuclideanSpace ℂ (ResidueRegister d n)) x = 0 := by
  simp [characteristicDistribution, QAlgorithms.act]

/-- Sanity: zero independent repetitions accept as the scalar identity. -/
example {d n k : ℕ} [NeZero d] (A : Matrix (QuditCopies d n k) (QuditCopies d n k) ℂ)
    (x y : QuditCopies d n (k * 0)) : repeatEffect 0 A x y = 1 := by simp [repeatEffect]

/-- Finite enumeration of the concrete defect quotient. -/
instance instFintypeDefectQuotient {d t : ℕ} [NeZero d] (N : Submodule (ZMod d) (ResidueRegister d t)) :
    Fintype (defectQuotient N) := Fintype.ofFinite _

/-- PDF p.37: canonical right-to-left quotient function obtained from the relation itself. -/
def canonicalDefectMap {d t : ℕ} [NeZero d]
    (T : Submodule (ZMod d) (ResidueRegister d t × ResidueRegister d t))
    (q : defectQuotient (rightDefect T)) : defectQuotient (leftDefect T) :=
  let y := defectRepresentative (rightDefect T) q
  if h : ∃ x : ResidueRegister d t, x ∈ perpendicular (leftDefect T) ∧ (x, y) ∈ T then
    defectClass (leftDefect T) (Classical.choose h) (Classical.choose_spec h).1
  else 0

/-- Finite collection of actual double orbits. -/
def doubleClasses (d t : ℕ) [NeZero d] : Finset (Finset (Lagrangian d t)) :=
  Finset.univ.image fun T => Finset.univ.filter (SameDoubleOrbit T)

/-- Source average-case distance for unitary testing. -/
def unitaryDistance {n : ℕ} (U V : QuditOperator 2 n) : ℝ :=
  Real.sqrt (1 - Complex.normSq ((Uᴴ * V).trace / (2 : ℂ) ^ n))

/-- Degree-six Choi tensor monomial, without an irrelevant common normalization. -/
def choiMonomial (n : ℕ) (x : QuditCopies 2 (n + n) 6) :
    MvPolynomial (ResidueRegister 2 n × ResidueRegister 2 n) ℂ :=
  ∏ i : Fin 6, MvPolynomial.X
    ((fun j => x i (Fin.castAdd n j)), (fun j => x i (Fin.natAdd n j)))

/-- PDF p.8: actual degree-six anti-identity invariance equations in the entries of U. -/
def cliffordPolynomial (n : ℕ) (x : QuditCopies 2 (n + n) 6) :
    MvPolynomial (ResidueRegister 2 n × ResidueRegister 2 n) ℂ :=
  (∑ y : QuditCopies 2 (n + n) 6,
    MvPolynomial.C (quditInvolution 2 (n + n) 3 x y) * choiMonomial n y) - choiMonomial n x

/-- PDF p.22, (3.11): the source six-copy verification unitary, not the anti-identity surrogate. -/
def qubitVerificationUnitary (n : ℕ) : Matrix (QuditCopies 2 n 6) (QuditCopies 2 n 6) ℂ :=
  (2 : ℂ) • qubitTest n - 1

/-- Class sums R_i from Definition 6.1, independent of a state or its twirl. -/
def designClassSum {d t : ℕ} [NeZero d] (n : ℕ) (F : Finset (Lagrangian d t)) :
    Matrix (QuditCopies d n t) (QuditCopies d n t) ℂ := ∑ T ∈ F, tensorRelation n T.val

/-- The coefficients of the concrete Clifford moment, set to zero off the actual class set.
The source stable-range theorem guarantees the expansion; no such guarantee is a hypothesis. -/
def designCoefficients {d n t : ℕ} [NeZero d]
    (v : EuclideanSpace ℂ (ResidueRegister d n)) : Finset (Lagrangian d t) → ℝ :=
  if h : ∃ a : Finset (Lagrangian d t) → ℝ,
    (∀ F, F ∉ designClasses d t → a F = 0) ∧
    cliffordMoment t v = ∑ F ∈ designClasses d t, (a F : ℂ) • designClassSum n F
  then Classical.choose h else fun _ => 0

/-- Physical symmetric projector on three qutrit blocks. -/
def qutritSymmetricProjector (n : ℕ) : Matrix (QuditCopies 3 n 3) (QuditCopies 3 n 3) ℂ :=
  (6⁻¹ : ℂ) • ∑ p : Equiv.Perm (Fin 3), permutationOperator 3 n 3 p

/-- Physical alternating projector on three qutrit blocks. -/
def qutritAlternatingProjector (n : ℕ) : Matrix (QuditCopies 3 n 3) (QuditCopies 3 n 3) ℂ :=
  (6⁻¹ : ℂ) • ∑ p : Equiv.Perm (Fin 3),
    (if Equiv.Perm.sign p = 1 then (1 : ℂ) else -1) • permutationOperator 3 n 3 p

/-- PDF p.42, (4.29): independent CSS Pauli projector, tensorized over physical sites. -/
def qutritCSSProjector (n : ℕ) : Matrix (QuditCopies 3 n 3) (QuditCopies 3 n 3) ℂ :=
  fun x y => ∏ j : Fin n, cssProjector qutritDefect (fun i => x i j) (fun i => y i j)

/-- PDF pp.42--43: the four compressed pieces, and one physical standard-S3 multiplicity slice.
P_minus is defined by alternating compression, which fixes the printed plus-sign error. -/
def qutritPieceProjector (n : ℕ) : Fin 5 → Matrix (QuditCopies 3 n 3) (QuditCopies 3 n 3) ℂ :=
  let S := qutritSymmetricProjector n
  let A := qutritAlternatingProjector n
  let P := qutritCSSProjector n
  let plus := S * P * S
  let minus := A * P * A
  ![plus, S - plus, minus, A - minus,
    (2⁻¹ : ℂ) • (1 + permutationOperator 3 n 3 (Equiv.swap 0 1)) - S]

/-- Source physical irreducible carriers, constructed from the five projections. -/
def qutritPiece (n : ℕ) (i : Fin 5) : Submodule ℂ (QuditCopies 3 n 3 → ℂ) :=
  LinearMap.range (Matrix.toLin' (qutritPieceProjector n i))

/-- Invariance under the actual Clifford tensor-power action. -/
def IsCliffordInvariant {d n t : ℕ} [NeZero d] (V : Submodule ℂ (QuditCopies d n t → ℂ)) : Prop :=
  ∀ U : QuditOperator d n, IsClifford U → ∀ v ∈ V, (tensorPower t U).mulVec v ∈ V

/-- Nonzero irreducible physical Clifford module. -/
def IsCliffordIrreducible {d n t : ℕ} [NeZero d] (V : Submodule ℂ (QuditCopies d n t → ℂ)) : Prop :=
  V ≠ ⊥ ∧ IsCliffordInvariant V ∧ ∀ W : Submodule ℂ (QuditCopies d n t → ℂ),
    W ≤ V → IsCliffordInvariant W → W = ⊥ ∨ W = V

/-- Equivalence means an actual linear bijection intertwining the physical action on the two carriers. -/
def CliffordModulesEquivalent {d n t : ℕ} [NeZero d]
    (V W : Submodule ℂ (QuditCopies d n t → ℂ)) : Prop :=
  ∃ L : (QuditCopies d n t → ℂ) →ₗ[ℂ] (QuditCopies d n t → ℂ),
    Set.BijOn L (V : Set _) (W : Set _) ∧
    ∀ U : QuditOperator d n, IsClifford U → ∀ v ∈ V,
      L ((tensorPower t U).mulVec v) = (tensorPower t U).mulVec (L v)

/-- Four one-fold constituents and two copies of the (2,1) constituent. -/
def pieceIndex (i : Fin 6) : Fin 5 := ⟨if i.val < 4 then i.val else 4, by split_ifs <;> omega⟩

abbrev QutritDecomposition (n : ℕ) := (i : Fin 6) → qutritPiece n (pieceIndex i)

/-- The standard S3 representation in the basis e0-e2,e1-e2 of the zero-sum plane. -/
def standardS3 (p : Equiv.Perm (Fin 3)) : Matrix (Fin 2) (Fin 2) ℂ :=
  fun i j => if p.symm ⟨i.val, by omega⟩ = ⟨j.val, by omega⟩ then 1
    else if p.symm ⟨i.val, by omega⟩ = 2 then -1 else 0

end QAlgorithms.Papers.Independent.Extend50.P30
Source
Schur-Weyl Duality for the Clifford Group with Applications: Property Testing, a Robust Hudson Theorem, and de Finetti Representations, arXiv:1712.08628v3, https://arxiv.org/abs/1712.08628v3
Read-back

What the Lean code literally says, in plain math · gpt-6.1-sol

QAlgorithms.Papers.Independent.Extend50.P30.CliffordModulesEquivalent

For any natural numbers d,n,td,n,td,n,t with d≠0d\ne0d=0, and any complex linear subspaces V,W⊆CRtV,W\subseteq\mathbb C^{R^t}V,W⊆CRt, where R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n, this predicate asserts the existence of a complex linear map L:CRt→CRtL:\mathbb C^{R^t}\to\mathbb C^{R^t}L:CRt→CRt whose restriction maps VVV bijectively onto WWW, and such that L(U⊗tv)=U⊗tL(v)L(U^{\otimes t}v)=U^{\otimes t}L(v)L(U⊗tv)=U⊗tL(v) for every v∈Vv\in Vv∈V and every unitary UUU with {UPU†:P∈Pd,n}=Pd,n\{UPU^\dagger:P\in\mathcal P_{d,n}\}=\mathcal P_{d,n}{UPU†:P∈Pd,n​}=Pd,n​. Here

Pd,n={τdcWp,q:0≤c<md, p,q∈R},Wp,q(a,b)=1{a=b+q}τd−∑jpˉjqˉjωd∑jpˉjaˉj,\mathcal P_{d,n}=\{\tau_d^cW_{p,q}:0\le c<m_d,\ p,q\in R\}, \qquad W_{p,q}(a,b)= \mathbf1_{\{a=b+q\}}\tau_d^{-\sum_j\bar p_j\bar q_j} \omega_d^{\sum_j\bar p_j\bar a_j},Pd,n​={τdc​Wp,q​:0≤c<md​, p,q∈R},Wp,q​(a,b)=1{a=b+q}​τd−∑j​pˉ​j​qˉ​j​​ωd∑j​pˉ​j​aˉj​​,

with ωd=e2πi/d\omega_d=e^{2\pi i/d}ωd​=e2πi/d, τd=(−1)deπi/d\tau_d=(-1)^d e^{\pi i/d}τd​=(−1)deπi/d, md=2dm_d=2dmd​=2d for even ddd and md=dm_d=dmd​=d otherwise, and bars denoting natural-number residue representatives; also U⊗t(x,y)=∏i=0t−1U(xi,yi)U^{\otimes t}(x,y)=\prod_{i=0}^{t-1}U(x_i,y_i)U⊗t(x,y)=∏i=0t−1​U(xi​,yi​). The definition does not separately require either subspace to be invariant, nor does it require LLL to be invertible on the whole ambient space. Zero subspaces and n=0n=0n=0 or t=0t=0t=0 are included, with empty products equal to 111.

QAlgorithms.Papers.Independent.Extend50.P30.CopyTest

For natural numbers d,nd,nd,n with d≠0d\ne0d=0, this structure consists of a natural number ccc, called its number of copies, and a complex matrix AAA indexed by ccc-tuples of elements of (Z/dZ)n(\mathbb Z/d\mathbb Z)^n(Z/dZ)n, together with the requirements that both AAA and I−AI-AI−A are positive semidefinite. The values c=0c=0c=0 and n=0n=0n=0 are allowed; in either case the matrix index set is a singleton.

QAlgorithms.Papers.Independent.Extend50.P30.CopyTest.prob

For natural numbers d,nd,nd,n with d≠0d\ne0d=0, a copy test with copy count ccc and acceptance matrix AAA, where AAA and I−AI-AI−A are positive semidefinite, and any vector v∈C(Z/dZ)nv\in\mathbb C^{(\mathbb Z/d\mathbb Z)^n}v∈C(Z/dZ)n equipped with the Euclidean norm, this defines

prob⁡(A,v)=Re⁡Tr⁡(Aρc),(ρc)x,y=∏j=0c−1v(xj)v(yj)‾,\operatorname{prob}(A,v)=\operatorname{Re}\operatorname{Tr}(A\rho_c), \qquad (\rho_c)_{x,y}=\prod_{j=0}^{c-1}v(x_j)\overline{v(y_j)},prob(A,v)=ReTr(Aρc​),(ρc​)x,y​=j=0∏c−1​v(xj​)v(yj​)​,

where x,yx,yx,y are ccc-tuples of residue-register elements. No unit-norm assumption is imposed on vvv. When c=0c=0c=0, the index set is a singleton and ρc\rho_cρc​ has its sole entry equal to 111, independently of vvv; n=0n=0n=0 is also included.

QAlgorithms.Papers.Independent.Extend50.P30.DefectIsomorphism

For natural numbers d≠0,td\ne0,td=0,t and arbitrary submodules N,MN,MN,M of V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, this structure consists of a Z/dZ\mathbb Z/d\mathbb ZZ/dZ-linear bijection L:{x+N:x∈N⊥}→{y+M:y∈M⊥}L:\{x+N:x\in N^\perp\}\to\{y+M:y\in M^\perp\}L:{x+N:x∈N⊥}→{y+M:y∈M⊥}, together with two requirements: for every x∈N⊥x\in N^\perpx∈N⊥ and y∈M⊥y\in M^\perpy∈M⊥, if L(x+N)=y+ML(x+N)=y+ML(x+N)=y+M, then q(x)=q(y)q(x)=q(y)q(x)=q(y); and for every proof that 1∈N⊥\mathbf1\in N^\perp1∈N⊥ and every proof that 1∈M⊥\mathbf1\in M^\perp1∈M⊥, one has L(1+N)=1+ML(\mathbf1+N)=\mathbf1+ML(1+N)=1+M. Here N⊥={x:∑ixizi=0 for every z∈N}N^\perp=\{x:\sum_i x_i z_i=0\text{ for every }z\in N\}N⊥={x:∑i​xi​zi​=0 for every z∈N}, similarly for M⊥M^\perpM⊥, 1\mathbf11 is the all-ones vector, and q(x)q(x)q(x) sums the squares of the least nonnegative coordinate representatives modulo 2d2d2d for even ddd and modulo ddd otherwise. Membership of 1\mathbf11 in either perpendicular submodule is not itself required, so the second requirement is vacuous if either membership fails. The cases d=1d=1d=1 and t=0t=0t=0 are included.

QAlgorithms.Papers.Independent.Extend50.P30.DiscretePhaseSpace

For natural numbers d,nd,nd,n, this denotes the set of ordered pairs (p,q)(p,q)(p,q) of functions {0,…,n−1}→Z/dZ\{0,\ldots,n-1\}\to\mathbb Z/d\mathbb Z{0,…,n−1}→Z/dZ. For d=0d=0d=0, these are integer-valued functions; for n=0n=0n=0, the phase space has exactly one element, the pair of empty functions.

QAlgorithms.Papers.Independent.Extend50.P30.FarFromStabilizers

For natural numbers d,nd,nd,n with d≠0d\ne0d=0, an arbitrary vector v∈CHv\in\mathbb C^Hv∈CH, H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n, and any real number ϵ\epsilonϵ, this predicate requires

Re⁡tr⁡(Svv†)≤1−ϵ2\operatorname{Re}\operatorname{tr}(Svv^\dagger)\le 1-\epsilon^2Retr(Svv†)≤1−ϵ2

for every matrix SSS in the following finite set. Put ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d, and h=2dh=2dh=2d for even ddd, h=dh=dh=d otherwise; define Wp,q(a,b)=τ−∑jpˉjqˉjω∑jpˉjaˉjW_{p,q}(a,b)=\tau^{-\sum_j\bar p_j\bar q_j}\omega^{\sum_j\bar p_j\bar a_j}Wp,q​(a,b)=τ−∑j​pˉ​j​qˉ​j​ω∑j​pˉ​j​aˉj​ when a=b+qa=b+qa=b+q, and 000 otherwise, with standard residue representatives and modular addition. For each subset GGG of {τcWp,q:0≤c<h, p,q∈H}\{\tau^cW_{p,q}:0\le c<h,\ p,q\in H\}{τcWp,q​:0≤c<h, p,q∈H} that contains the identity, is closed under multiplication and conjugate transpose, and satisfies P∈G, P=cI⇒c=1P\in G,\ P=cI\Rightarrow c=1P∈G, P=cI⇒c=1, form AG=∣G∣−1∑P∈GPA_G=|G|^{-1}\sum_{P\in G}PAG​=∣G∣−1∑P∈G​P. The tested set consists of those trace normalizations S=(tr⁡AG)−1AGS=(\operatorname{tr}A_G)^{-1}A_GS=(trAG​)−1AG​ that equal ww†ww^\daggerww† for some Euclidean unit vector www. Here (vv†)(a,b)=v(a)v(b)‾(vv^\dagger)(a,b)=v(a)\overline{v(b)}(vv†)(a,b)=v(a)v(b)​, and complex inversion has 0−1=00^{-1}=00−1=0. No unit-norm hypothesis on vvv or sign restriction on ϵ\epsilonϵ is imposed; the bound depends only on ϵ2\epsilon^2ϵ2. The cases d=1d=1d=1 and n=0n=0n=0 are included, with empty exponent sums for n=0n=0n=0.

QAlgorithms.Papers.Independent.Extend50.P30.IsClifford

For natural numbers d,nd,nd,n with d≠0d\ne0d=0 and a complex matrix UUU indexed by H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n, this predicate says that UUU is unitary and

{UPU†:P∈P}=P.\{UPU^\dagger:P\in\mathcal P\}=\mathcal P.{UPU†:P∈P}=P.

Here P={τcWp,q:0≤c<h, p,q∈H}\mathcal P=\{\tau^cW_{p,q}:0\le c<h,\ p,q\in H\}P={τcWp,q​:0≤c<h, p,q∈H}, where ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d, h=2dh=2dh=2d for even ddd and h=dh=dh=d otherwise, and

Wp,q(a,b)={τ−∑jpˉjqˉjω∑jpˉjaˉj,a=b+q,0,otherwise.W_{p,q}(a,b)= \begin{cases} \tau^{-\sum_j\bar p_j\bar q_j}\omega^{\sum_j\bar p_j\bar a_j},&a=b+q,\\ 0,&\text{otherwise}. \end{cases}Wp,q​(a,b)={τ−∑j​pˉ​j​qˉ​j​ω∑j​pˉ​j​aˉj​,0,​a=b+q,otherwise.​

The bars are standard nonnegative residue representatives, and addition is coordinatewise modulo ddd. The displayed condition is equality of finite sets, including every phase multiple in P\mathcal PP. The definition includes d=1d=1d=1 and n=0n=0n=0, with a singleton register and empty exponent sums when n=0n=0n=0.

QAlgorithms.Papers.Independent.Extend50.P30.IsCliffordInvariant

For any natural numbers d,n,td,n,td,n,t with d≠0d\ne0d=0, and any complex linear subspace V⊆CHV\subseteq\mathbb C^{H}V⊆CH, where R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n and H=RtH=R^tH=Rt, this predicate requires that U⊗tv∈VU^{\otimes t}v\in VU⊗tv∈V for every v∈Vv\in Vv∈V and every matrix UUU satisfying the following explicit Clifford condition. Write ωd=e2πi/d\omega_d=e^{2\pi i/d}ωd​=e2πi/d, τd=(−1)deπi/d\tau_d=(-1)^d e^{\pi i/d}τd​=(−1)deπi/d, and md=2dm_d=2dmd​=2d if ddd is even and md=dm_d=dmd​=d otherwise; for p,q,a,b∈Rp,q,a,b\in Rp,q,a,b∈R, with bars denoting representatives in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, set

Wp,q(a,b)={τd−∑jpˉjqˉj ωd∑jpˉjaˉj,a=b+q,0,a≠b+q,Pd,n={τdcWp,q:0≤c<md, p,q∈R}.W_{p,q}(a,b)= \begin{cases} \tau_d^{-\sum_j\bar p_j\bar q_j}\, \omega_d^{\sum_j\bar p_j\bar a_j},&a=b+q,\\ 0,&a\ne b+q, \end{cases} \qquad \mathcal P_{d,n}=\{\tau_d^cW_{p,q}:0\le c<m_d,\ p,q\in R\}.Wp,q​(a,b)={τd−∑j​pˉ​j​qˉ​j​​ωd∑j​pˉ​j​aˉj​​,0,​a=b+q,a=b+q,​Pd,n​={τdc​Wp,q​:0≤c<md​, p,q∈R}.

The condition on UUU is that it is unitary on CR\mathbb C^RCR and {UPU†:P∈Pd,n}=Pd,n\{UPU^\dagger:P\in\mathcal P_{d,n}\}=\mathcal P_{d,n}{UPU†:P∈Pd,n​}=Pd,n​. Here U⊗t(x,y)=∏i=0t−1U(xi,yi)U^{\otimes t}(x,y)=\prod_{i=0}^{t-1}U(x_i,y_i)U⊗t(x,y)=∏i=0t−1​U(xi​,yi​), acting by matrix multiplication. No primality assumption on ddd, positivity assumption on n,tn,tn,t, or nonzero assumption on VVV is imposed; when t=0t=0t=0, the displayed product is 111.

QAlgorithms.Papers.Independent.Extend50.P30.IsCliffordIrreducible

For any natural numbers d,n,td,n,td,n,t with d≠0d\ne0d=0, and any complex linear subspace V⊆CRtV\subseteq\mathbb C^{R^t}V⊆CRt, where R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n, this predicate requires three things: V≠{0}V\ne\{0\}V={0}; every U⊗tU^{\otimes t}U⊗t described below maps VVV into itself; and every complex linear subspace W⊆VW\subseteq VW⊆V also mapped into itself by all these matrices satisfies W={0}W=\{0\}W={0} or W=VW=VW=V. The matrices UUU in question are precisely the unitary matrices on CR\mathbb C^RCR whose conjugation preserves the finite set

Pd,n={τdcWp,q:0≤c<md, p,q∈R},Wp,q(a,b)=1{a=b+q} τd−∑jpˉjqˉjωd∑jpˉjaˉj,\mathcal P_{d,n}=\{\tau_d^cW_{p,q}:0\le c<m_d,\ p,q\in R\}, \quad W_{p,q}(a,b)= \mathbf1_{\{a=b+q\}}\, \tau_d^{-\sum_j\bar p_j\bar q_j} \omega_d^{\sum_j\bar p_j\bar a_j},Pd,n​={τdc​Wp,q​:0≤c<md​, p,q∈R},Wp,q​(a,b)=1{a=b+q}​τd−∑j​pˉ​j​qˉ​j​​ωd∑j​pˉ​j​aˉj​​,

where ωd=e2πi/d\omega_d=e^{2\pi i/d}ωd​=e2πi/d, τd=(−1)deπi/d\tau_d=(-1)^d e^{\pi i/d}τd​=(−1)deπi/d, md=2dm_d=2dmd​=2d for even ddd and md=dm_d=dmd​=d otherwise, and bars denote natural-number residue representatives. Preservation means {UPU†:P∈Pd,n}=Pd,n\{UPU^\dagger:P\in\mathcal P_{d,n}\}=\mathcal P_{d,n}{UPU†:P∈Pd,n​}=Pd,n​, and U⊗t(x,y)=∏i=0t−1U(xi,yi)U^{\otimes t}(x,y)=\prod_{i=0}^{t-1}U(x_i,y_i)U⊗t(x,y)=∏i=0t−1​U(xi​,yi​). The quantifiers include d=1d=1d=1, n=0n=0n=0, and t=0t=0t=0; empty products equal 111, while the zero subspace is explicitly excluded.

QAlgorithms.Papers.Independent.Extend50.P30.IsCyclicStabilizerGroup

For natural numbers d,nd,nd,n with d≠0d\ne0d=0, and a finite set GGG of complex matrices indexed by R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n, this predicate requires all of the following: every element of GGG has the form τhWp,q\tau^hW_{p,q}τhWp,q​, where τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d, 0≤h<m0\le h<m0≤h<m, m=2dm=2dm=2d for even ddd and m=dm=dm=d otherwise, p,q∈Rp,q\in Rp,q∈R, and

(Wp,q)a,b={τ−∑j[pj][qj]e(2πi/d)∑j[pj][aj],a=b+q,0,a≠b+q;(W_{p,q})_{a,b}= \begin{cases} \tau^{-\sum_j[p_j][q_j]}e^{(2\pi i/d)\sum_j[p_j][a_j]},&a=b+q,\\ 0,&a\ne b+q; \end{cases}(Wp,q​)a,b​={τ−∑j​[pj​][qj​]e(2πi/d)∑j​[pj​][aj​],0,​a=b+q,a=b+q;​

here [r][r][r] denotes the natural representative of a residue; the identity matrix belongs to GGG; for every A,B∈GA,B\in GA,B∈G, their matrix product ABABAB belongs to GGG; for every A∈GA\in GA∈G, its conjugate transpose A†A^\daggerA† belongs to GGG; and for every A∈GA\in GA∈G and every c∈Cc\in\mathbb Cc∈C, the equality A=cIA=cIA=cI implies c=1c=1c=1. The cases d=1d=1d=1 and n=0n=0n=0 are included, and the identity-membership requirement excludes G=∅G=\varnothingG=∅.

QAlgorithms.Papers.Independent.Extend50.P30.IsDefect

For natural numbers d≠0d\ne0d=0 and ttt, and a submodule NNN of (Z/dZ)t(\mathbb Z/d\mathbb Z)^t(Z/dZ)t, this predicate requires that q(x)=0q(x)=0q(x)=0 for every x∈Nx\in Nx∈N and that ∑i=0t−1yi=0\sum_{i=0}^{t-1}y_i=0∑i=0t−1​yi​=0 in Z/dZ\mathbb Z/d\mathbb ZZ/dZ for every y∈Ny\in Ny∈N. Here q(x)q(x)q(x) is the sum of the squares of the least nonnegative representatives of the coordinates of xxx, evaluated modulo 2d2d2d if ddd is even and modulo ddd otherwise; the second requirement is precisely that the all-ones vector belongs to N⊥N^\perpN⊥ for the bilinear pairing ∑ixiyi\sum_i x_i y_i∑i​xi​yi​. The cases d=1d=1d=1 and t=0t=0t=0 are included, and both requirements hold for every available submodule in either case.

QAlgorithms.Papers.Independent.Extend50.P30.IsDistributionOn

For any type III, finite subset F⊆IF\subseteq IF⊆I, and function p:I→Rp:I\to\mathbb Rp:I→R, this predicate means that p(i)≥0p(i)\ge0p(i)≥0 for every i∈Fi\in Fi∈F and ∑i∈Fp(i)=1\sum_{i\in F}p(i)=1∑i∈F​p(i)=1. Values outside FFF are unrestricted. When FFF is empty, the predicate is false because its sum condition becomes 0=10=10=1.

QAlgorithms.Papers.Independent.Extend50.P30.IsOrthogonalProjectionOnto

For any finite type III equipped with decidable equality, a complex matrix PPP indexed by I×II\times II×I, and a complex linear subspace V⊆CIV\subseteq\mathbb C^IV⊆CI, this predicate means exactly

P†=P,P2=P,{Pv:v∈CI}=V.P^\dagger=P,\qquad P^2=P,\qquad \{Pv:v\in\mathbb C^I\}=V.P†=P,P2=P,{Pv:v∈CI}=V.

The empty index type is allowed; then CI\mathbb C^ICI is the zero vector space and the range condition requires V={0}V=\{0\}V={0}.

QAlgorithms.Papers.Independent.Extend50.P30.IsPermutationSymmetric

For natural numbers d,n,td,n,td,n,t with d≠0d\ne0d=0, put R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n, so a coordinate of v∈CRtv\in\mathbb C^{R^t}v∈CRt is indexed by a tuple x:{0,…,t−1}→Rx:\{0,\ldots,t-1\}\to Rx:{0,…,t−1}→R. The predicate holds precisely when every permutation ppp of the ttt copies fixes vvv under multiplication by the matrix whose (x,y)(x,y)(x,y)-entry is 111 if xi=yp−1(i)x_i=y_{p^{-1}(i)}xi​=yp−1(i)​ for every iii, and 000 otherwise; equivalently, v(x∘p)=v(x)v(x\circ p)=v(x)v(x∘p)=v(x) for every xxx and ppp. No normalization of vvv is required. This includes d=1d=1d=1, n=0n=0n=0, and t=0t=0t=0; for t=0t=0t=0, the condition holds for every vvv.

QAlgorithms.Papers.Independent.Extend50.P30.IsStabilizer

For natural numbers d,nd,nd,n with d≠0d\ne0d=0 and a vector v∈CHv\in\mathbb C^Hv∈CH, where H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n carries the Euclidean norm, this predicate requires ∥v∥=1\|v\|=1∥v∥=1 and membership of vv†vv^\daggervv†, whose (a,b)(a,b)(a,b)-entry is v(a)v(b)‾v(a)\overline{v(b)}v(a)v(b)​, in the following finite set: take ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d, h=2dh=2dh=2d for even ddd and h=dh=dh=d otherwise, and

Wp,q(a,b)={τ−∑jpˉjqˉjω∑jpˉjaˉj,a=b+q,0,otherwise.W_{p,q}(a,b)= \begin{cases} \tau^{-\sum_j\bar p_j\bar q_j}\omega^{\sum_j\bar p_j\bar a_j},&a=b+q,\\ 0,&\text{otherwise}. \end{cases}Wp,q​(a,b)={τ−∑j​pˉ​j​qˉ​j​ω∑j​pˉ​j​aˉj​,0,​a=b+q,otherwise.​

The bars denote standard nonnegative residue representatives and addition is modulo ddd. For every subset GGG of {τcWp,q:0≤c<h, p,q∈H}\{\tau^cW_{p,q}:0\le c<h,\ p,q\in H\}{τcWp,q​:0≤c<h, p,q∈H} containing the identity, closed under multiplication and conjugate transpose, and satisfying P=cI, P∈G⇒c=1P=cI,\ P\in G\Rightarrow c=1P=cI, P∈G⇒c=1, form AG=∣G∣−1∑P∈GPA_G=|G|^{-1}\sum_{P\in G}PAG​=∣G∣−1∑P∈G​P and its trace normalization (tr⁡AG)−1AG(\operatorname{tr}A_G)^{-1}A_G(trAG​)−1AG​; retain such a normalized matrix exactly when it equals ww†ww^\daggerww† for some Euclidean unit vector www. Complex inversion uses 0−1=00^{-1}=00−1=0. The predicate also applies when d=1d=1d=1 or n=0n=0n=0, with empty exponent sums when n=0n=0n=0.

QAlgorithms.Papers.Independent.Extend50.P30.IsStochasticLagrangian

For natural numbers d,td,td,t with d≠0d\ne0d=0, this predicate on a Z/dZ\mathbb Z/d\mathbb ZZ/dZ-submodule T⊆(Z/dZ)t×(Z/dZ)tT\subseteq(\mathbb Z/d\mathbb Z)^t\times(\mathbb Z/d\mathbb Z)^tT⊆(Z/dZ)t×(Z/dZ)t requires all three conditions

∀(x,y)∈T,∑j=0t−1xˉj 2=∑j=0t−1yˉj 2 in Z/DZ,∣T∣=dt,(1,1)∈T,\forall(x,y)\in T,\quad \sum_{j=0}^{t-1}\bar x_j^{\,2}= \sum_{j=0}^{t-1}\bar y_j^{\,2}\ \text{in }\mathbb Z/D\mathbb Z, \qquad |T|=d^t, \qquad (\mathbf1,\mathbf1)\in T,∀(x,y)∈T,j=0∑t−1​xˉj2​=j=0∑t−1​yˉ​j2​ in Z/DZ,∣T∣=dt,(1,1)∈T,

where D=2dD=2dD=2d for even ddd and D=dD=dD=d otherwise, bars denote canonical representatives modulo ddd, and 1\mathbf11 is the vector with every coordinate equal to 111 modulo ddd. No primality assumption on ddd is imposed. For t=0t=0t=0, the ambient module has one element, and its unique submodule satisfies these conditions.

QAlgorithms.Papers.Independent.Extend50.P30.IsStochasticOrthogonal

For natural numbers d≠0d\ne0d=0 and ttt, and a t×tt\times tt×t matrix OOO over Z/dZ\mathbb Z/d\mathbb ZZ/dZ, this predicate requires both q(Ox)=q(x)q(Ox)=q(x)q(Ox)=q(x) for every x∈(Z/dZ)tx\in(\mathbb Z/d\mathbb Z)^tx∈(Z/dZ)t and O1=1O\mathbf1=\mathbf1O1=1, where 1\mathbf11 is the vector whose coordinates are all 111. Here q(x)=∑j=0t−1xj~ 2q(x)=\sum_{j=0}^{t-1}\widetilde{x_j}^{\,2}q(x)=∑j=0t−1​xj​​2 is evaluated modulo 2d2d2d if ddd is even and modulo ddd otherwise, with xj~∈{0,…,d−1}\widetilde{x_j}\in\{0,\ldots,d-1\}xj​​∈{0,…,d−1} the least nonnegative representative of xjx_jxj​; the coordinates of OxOxOx are first computed modulo ddd before their representatives are used in qqq. The definition includes d=1d=1d=1 and t=0t=0t=0; when t=0t=0t=0, both requirements hold for the unique empty matrix.

QAlgorithms.Papers.Independent.Extend50.P30.Lagrangian

For natural numbers d,td,td,t with d≠0d\ne0d=0, this is the type of Z/dZ\mathbb Z/d\mathbb ZZ/dZ-submodules T⊆(Z/dZ)t×(Z/dZ)tT\subseteq(\mathbb Z/d\mathbb Z)^t\times(\mathbb Z/d\mathbb Z)^tT⊆(Z/dZ)t×(Z/dZ)t satisfying

∣T∣=dt,(1,1)∈T,∀(x,y)∈T,∑j=0t−1xˉj 2=∑j=0t−1yˉj 2 in Z/DZ.|T|=d^t,\qquad (\mathbf1,\mathbf1)\in T,\qquad \forall(x,y)\in T,\quad \sum_{j=0}^{t-1}\bar x_j^{\,2}= \sum_{j=0}^{t-1}\bar y_j^{\,2}\ \text{in }\mathbb Z/D\mathbb Z.∣T∣=dt,(1,1)∈T,∀(x,y)∈T,j=0∑t−1​xˉj2​=j=0∑t−1​yˉ​j2​ in Z/DZ.

Here D=2dD=2dD=2d when ddd is even and D=dD=dD=d otherwise, each bar denotes the canonical representative modulo ddd, and 1\mathbf11 is the all-ones residue vector. The type includes the case t=0t=0t=0, when it has exactly one element, the unique submodule of the singleton ambient module; ddd need not be prime.

QAlgorithms.Papers.Independent.Extend50.P30.PauliAction

For natural numbers d,nd,nd,n with d≠0d\ne0d=0, put R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n, h=2dh=2dh=2d when ddd is even and h=dh=dh=d otherwise, ω=e2πi/d\omega=e^{2\pi\mathrm i/d}ω=e2πi/d, and τ=(−1)deπi/d\tau=(-1)^d e^{\pi\mathrm i/d}τ=(−1)deπi/d. For a,b∈Ra,b\in Ra,b∈R, define a matrix Wa,bW_{a,b}Wa,b​ by

Wa,b(u,v)={τ−∑jaˉjbˉjω∑jaˉjuˉj,u=v+b,0,u≠v+b,W_{a,b}(u,v)= \begin{cases} \tau^{-\sum_j\bar a_j\bar b_j}\omega^{\sum_j\bar a_j\bar u_j},&u=v+b,\\ 0,&u\ne v+b, \end{cases}Wa,b​(u,v)={τ−∑j​aˉj​bˉj​ω∑j​aˉj​uˉj​,0,​u=v+b,u=v+b,​

where bars denote representatives in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}. Let P\mathcal PP be the finite set of distinct matrices τrWa,b\tau^rW_{a,b}τrWa,b​ for 0≤r<h0\le r<h0≤r<h and a,b∈Ra,b\in Ra,b∈R. This abbreviation denotes the type of all functions P→P\mathcal P\to\mathcal PP→P, with membership in P\mathcal PP included in the domain and codomain. No bijectivity, multiplication-preservation, or realization by conjugation is required. The parameters include d=1d=1d=1 and n=0n=0n=0.

QAlgorithms.Papers.Independent.Extend50.P30.QuditCopies

For natural numbers d,n,td,n,td,n,t, this denotes functions assigning to each i∈{0,…,t−1}i\in\{0,\ldots,t-1\}i∈{0,…,t−1} a function {0,…,n−1}→Z/dZ\{0,\ldots,n-1\}\to\mathbb Z/d\mathbb Z{0,…,n−1}→Z/dZ, equivalently arrays of residues with ttt rows and nnn columns. For d=0d=0d=0, the entries are integers. If t=0t=0t=0 or n=0n=0n=0, there is exactly one such array.

QAlgorithms.Papers.Independent.Extend50.P30.QuditOperator

For natural numbers d,nd,nd,n, this denotes complex matrices whose rows and columns are both indexed by functions {0,…,n−1}→Z/dZ\{0,\ldots,n-1\}\to\mathbb Z/d\mathbb Z{0,…,n−1}→Z/dZ. No nonzero assumption on ddd is imposed: for d=0d=0d=0, the indexing functions are integer-valued and, when n>0n>0n>0, the index set is infinite. For n=0n=0n=0, these are 1×11\times11×1 matrices.

QAlgorithms.Papers.Independent.Extend50.P30.QutritDecomposition

For every natural number nnn, this abbreviates the complex vector space of six-tuples (v0,…,v5)(v_0,\ldots,v_5)(v0​,…,v5​) with vi∈Viv_i\in V_ivi​∈Vi​ for i<4i<4i<4 and v4,v5∈V4v_4,v_5\in V_4v4​,v5​∈V4​, where the two occurrences of V4V_4V4​ are independently chosen. To define these spaces, put Hn=((Z/3Z)n)3H_n=((\mathbb Z/3\mathbb Z)^n)^3Hn​=((Z/3Z)n)3, Πp(x,y)=1{xj=yp−1(j) ∀j}\Pi_p(x,y)=\mathbf1_{\{x_j=y_{p^{-1}(j)}\ \forall j\}}Πp​(x,y)=1{xj​=yp−1(j)​ ∀j}​, S=16∑pΠpS=\frac16\sum_p\Pi_pS=61​∑p​Πp​, and A=16∑psgn⁡(p)ΠpA=\frac16\sum_p\operatorname{sgn}(p)\Pi_pA=61​∑p​sgn(p)Πp​, summing over permutations of three positions. With ω=e2πi/3\omega=e^{2\pi i/3}ω=e2πi/3 and bars denoting representatives in {0,1,2}\{0,1,2\}{0,1,2}, put

C(u,v)=19∑a,b∈Z/3Z1{u=v+b(1,1,1)}ωaˉ(uˉ0+uˉ1+uˉ2),P(x,y)=∏j=0n−1C((x0j,x1j,x2j),(y0j,y1j,y2j)).C(u,v)=\frac19\sum_{a,b\in\mathbb Z/3\mathbb Z} \mathbf1_{\{u=v+b(1,1,1)\}}\omega^{\bar a(\bar u_0+\bar u_1+\bar u_2)},\qquad P(x,y)=\prod_{j=0}^{n-1}C((x_{0j},x_{1j},x_{2j}),(y_{0j},y_{1j},y_{2j})).C(u,v)=91​a,b∈Z/3Z∑​1{u=v+b(1,1,1)}​ωaˉ(uˉ0​+uˉ1​+uˉ2​),P(x,y)=j=0∏n−1​C((x0j​,x1j​,x2j​),(y0j​,y1j​,y2j​)).

Then ViV_iVi​ is the matrix range of the iii-th member of (SPS, S−SPS, APA, A−APA, 12(I+Π(01))−S)(SPS,\ S-SPS,\ APA,\ A-APA,\ \frac12(I+\Pi_{(01)})-S)(SPS, S−SPS, APA, A−APA, 21​(I+Π(01)​)−S), acting on CHn\mathbb C^{H_n}CHn​. This abbreviation itself asserts no isomorphism with CHn\mathbb C^{H_n}CHn​ and imposes no normalization on the tuple entries. It includes n=0n=0n=0, with empty products equal to 111.

QAlgorithms.Papers.Independent.Extend50.P30.RealizesAction

For natural numbers d≠0d\ne0d=0 and nnn, let V=(Z/dZ)nV=(\mathbb Z/d\mathbb Z)^nV=(Z/dZ)n, ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d, and h=2dh=2dh=2d if ddd is even and h=dh=dh=d otherwise. For p,q∈Vp,q\in Vp,q∈V, define the matrix

Wp,q(a,b)={τ−∑jpj‾ qj‾ ω∑jpj‾ aj‾,a=b+q,0,a≠b+q,W_{p,q}(a,b)= \begin{cases} \tau^{-\sum_j\overline{p_j}\,\overline{q_j}}\, \omega^{\sum_j\overline{p_j}\,\overline{a_j}},&a=b+q,\\ 0,&a\ne b+q, \end{cases}Wp,q​(a,b)={τ−∑j​pj​​qj​​ω∑j​pj​​aj​​,0,​a=b+q,a=b+q,​

where bars denote the natural-number representatives of residues and the negative exponent is an integer exponent. Let P={τcWp,q:0≤c<h, p,q∈V}\mathcal P=\{\tau^cW_{p,q}:0\le c<h,\ p,q\in V\}P={τcWp,q​:0≤c<h, p,q∈V}, regarded as a set of distinct matrices. Given any function a:P→Pa:\mathcal P\to\mathcal Pa:P→P and any complex matrix UUU indexed by VVV, this predicate means that UUU is unitary, {UPU†:P∈P}=P\{UPU^\dagger:P\in\mathcal P\}=\mathcal P{UPU†:P∈P}=P, and UPU†=a(P)UPU^\dagger=a(P)UPU†=a(P) for every P∈PP\in\mathcal PP∈P. No primality assumption on ddd is imposed, and n=0n=0n=0 is included, with empty sums equal to zero.

QAlgorithms.Papers.Independent.Extend50.P30.ResidueRegister

For natural numbers d,nd,nd,n, this denotes the set of functions {0,…,n−1}→Z/dZ\{0,\ldots,n-1\}\to\mathbb Z/d\mathbb Z{0,…,n−1}→Z/dZ. The case d=0d=0d=0 is included, with the residue type interpreted as Z\mathbb ZZ. When n=0n=0n=0, there is exactly one such function, the empty function.

QAlgorithms.Papers.Independent.Extend50.P30.SameDesignClass

For natural numbers d≠0d\ne0d=0 and ttt, let V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, let h=2dh=2dh=2d if ddd is even and h=dh=dh=d otherwise, and define Q(x)=∑jxj‾ 2Q(x)=\sum_j\overline{x_j}^{\,2}Q(x)=∑j​xj​​2 in Z/hZ\mathbb Z/h\mathbb ZZ/hZ, using natural-number representatives of residues. Let T,S⊆V×VT,S\subseteq V\times VT,S⊆V×V be Z/dZ\mathbb Z/d\mathbb ZZ/dZ-submodules, each having cardinality dtd^tdt, containing (1,1)(\mathbf1,\mathbf1)(1,1), and satisfying Q(x)=Q(y)Q(x)=Q(y)Q(x)=Q(y) for every member (x,y)(x,y)(x,y). This predicate means that there exist permutations p,qp,qp,q of the ttt coordinates such that either

S=span⁡Z/dZ{(x∘p−1,y∘q):(x,y)∈T},orS=span⁡Z/dZ{(y∘p−1,x∘q):(x,y)∈T}.S=\operatorname{span}_{\mathbb Z/d\mathbb Z} \{(x\circ p^{-1},y\circ q):(x,y)\in T\}, \quad\text{or}\quad S=\operatorname{span}_{\mathbb Z/d\mathbb Z} \{(y\circ p^{-1},x\circ q):(x,y)\in T\}.S=spanZ/dZ​{(x∘p−1,y∘q):(x,y)∈T},orS=spanZ/dZ​{(y∘p−1,x∘q):(x,y)∈T}.

The disjunction is inclusive. The definition includes d=1d=1d=1 and t=0t=0t=0, and does not require ddd to be prime.

QAlgorithms.Papers.Independent.Extend50.P30.SameDoubleOrbit

For natural numbers d≠0d\ne0d=0 and ttt, put V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, let 1∈V\mathbf1\in V1∈V be the all-ones vector, and define q(x)=∑jrep⁡(xj)2q(x)=\sum_j\operatorname{rep}(x_j)^2q(x)=∑j​rep(xj​)2 modulo 2d2d2d for even ddd and modulo ddd otherwise. Let T,S≤V×VT,S\le V\times VT,S≤V×V each satisfy q(x)=q(y)q(x)=q(y)q(x)=q(y) for every (x,y)(x,y)(x,y) in that submodule, have cardinality dtd^tdt, and contain (1,1)(\mathbf1,\mathbf1)(1,1). The defined proposition says that there exist t×tt\times tt×t matrices O,PO,PO,P over Z/dZ\mathbb Z/d\mathbb ZZ/dZ such that q(Ox)=q(x)q(Ox)=q(x)q(Ox)=q(x), q(Px)=q(x)q(Px)=q(x)q(Px)=q(x) for every x∈Vx\in Vx∈V, O1=P1=1O\mathbf1=P\mathbf1=\mathbf1O1=P1=1, and S=span⁡Z/dZ{(Ox,PTy):(x,y)∈T}S=\operatorname{span}_{\mathbb Z/d\mathbb Z}\{(Ox,P^{\mathsf T}y):(x,y)\in T\}S=spanZ/dZ​{(Ox,PTy):(x,y)∈T}. These are the literal conditions on O,PO,PO,P; invertibility is not an additional hypothesis. The parameters allow d=1d=1d=1 and t=0t=0t=0.

QAlgorithms.Papers.Independent.Extend50.P30.StochasticOrthogonal

For natural numbers d≠0d\ne0d=0 and ttt, this is the type of t×tt\times tt×t matrices OOO over Z/dZ\mathbb Z/d\mathbb ZZ/dZ equipped with proofs that O1=1O\mathbf1=\mathbf1O1=1 and q(Ox)=q(x)q(Ox)=q(x)q(Ox)=q(x) for every x∈(Z/dZ)tx\in(\mathbb Z/d\mathbb Z)^tx∈(Z/dZ)t. Here 1\mathbf11 has every coordinate equal to 111, and q(x)q(x)q(x) is the sum of the squares of the least nonnegative representatives of its coordinates, taken modulo 2d2d2d for even ddd and modulo ddd for odd ddd. Both d=1d=1d=1 and t=0t=0t=0 are allowed; for t=0t=0t=0, the unique empty matrix satisfies these conditions.

QAlgorithms.Papers.Independent.Extend50.P30.actedRelation

For arbitrary natural numbers d,td,td,t, let V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, let O,PO,PO,P be arbitrary t×tt\times tt×t matrices over Z/dZ\mathbb Z/d\mathbb ZZ/dZ, and let T≤V×VT\le V\times VT≤V×V be a submodule. The definition gives the linear span of {(Ox,PTy):(x,y)∈T}\{(Ox,P^{\mathsf T}y):(x,y)\in T\}{(Ox,PTy):(x,y)∈T} over Z/dZ\mathbb Z/d\mathbb ZZ/dZ. Thus the first component is multiplied by OOO, and the second by the transpose of PPP; neither matrix is required to be invertible or to preserve any form. The parameters include t=0t=0t=0 and d=0d=0d=0, with Z/0Z=Z\mathbb Z/0\mathbb Z=\mathbb ZZ/0Z=Z.

QAlgorithms.Papers.Independent.Extend50.P30.antiPermutation

For any natural number ttt and permutation ppp of {0,…,t−1}\{0,\ldots,t-1\}{0,…,t−1}, the definition gives the t×tt\times tt×t matrix over Z/2Z\mathbb Z/2\mathbb ZZ/2Z whose (i,j)(i,j)(i,j)-entry is 000 if i=p(j)i=p(j)i=p(j) and 111 otherwise. For t=0t=0t=0 this is the empty matrix, and for t=1t=1t=1 it is the zero matrix.

QAlgorithms.Papers.Independent.Extend50.P30.bellDifference

For every natural number nnn and every a∈H×Ha\in H\times Ha∈H×H, where H=(Z/2Z)nH=(\mathbb Z/2\mathbb Z)^nH=(Z/2Z)n, the declaration defines a complex matrix on four ordered copies of HHH by

Da(u,v)=∑x∈H×HPx((u0,u1),(v0,v1))Px+a((u2,u3),(v2,v3)),u,v∈H4,D_a(u,v)= \sum_{x\in H\times H} P_x\bigl((u_0,u_1),(v_0,v_1)\bigr) P_{x+a}\bigl((u_2,u_3),(v_2,v_3)\bigr), \qquad u,v\in H^4,Da​(u,v)=x∈H×H∑​Px​((u0​,u1​),(v0​,v1​))Px+a​((u2​,u3​),(v2​,v3​)),u,v∈H4,

where addition of phase-space pairs is coordinatewise modulo 222, and

Px((r,s),(r′,s′))=2−nWx(r,s)Wx(r′,s′)‾.P_x\bigl((r,s),(r',s')\bigr) =2^{-n}W_x(r,s)\overline{W_x(r',s')}.Px​((r,s),(r′,s′))=2−nWx​(r,s)Wx​(r′,s′)​.

For x=(p,q)x=(p,q)x=(p,q), the entries used here are Wx(r,s)=i−∑jpˉjqˉj(−1)∑jpˉjrˉjW_x(r,s)=i^{-\sum_j\bar p_j\bar q_j}(-1)^{\sum_j\bar p_j\bar r_j}Wx​(r,s)=i−∑j​pˉ​j​qˉ​j​(−1)∑j​pˉ​j​rˉj​ if r=s+qr=s+qr=s+q, and 000 otherwise; barred residues are 000 or 111. Thus each PxP_xPx​ is explicitly the matrix of products of coordinates and conjugate coordinates of the vector with entries 2−n/2Wx(r,s)2^{-n/2}W_x(r,s)2−n/2Wx​(r,s). The case n=0n=0n=0 is included; all register sets are singletons and the resulting matrix has sole entry 111.

QAlgorithms.Papers.Independent.Extend50.P30.canonicalDefectMap

For natural numbers d,td,td,t with d≠0d\ne0d=0, let V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t and let TTT be any Z/dZ\mathbb Z/d\mathbb ZZ/dZ-submodule of V×VV\times VV×V. Set NL={x:(x,0)∈T}N_L=\{x:(x,0)\in T\}NL​={x:(x,0)∈T} and NR={y:(0,y)∈T}N_R=\{y:(0,y)\in T\}NR​={y:(0,y)∈T}. For any submodule NNN, write N⊥={x:∑jxjzj=0 for every z∈N}N^\perp=\{x:\sum_jx_jz_j=0\text{ for every }z\in N\}N⊥={x:∑j​xj​zj​=0 for every z∈N} and QN={x+N:x∈N⊥}⊆V/NQ_N=\{x+N:x\in N^\perp\}\subseteq V/NQN​={x+N:x∈N⊥}⊆V/N. Given q∈QNRq\in Q_{N_R}q∈QNR​​, choose the representative y∈NR⊥y\in N_R^\perpy∈NR⊥​ supplied by the definition of a representative, so that y+NR=qy+N_R=qy+NR​=q. The defined map returns

{x+NL,if there exists x∈NL⊥ with (x,y)∈T,0∈QNL,if no such x exists,\begin{cases} x+N_L,&\text{if there exists }x\in N_L^\perp\text{ with }(x,y)\in T, \\ 0\in Q_{N_L},&\text{if no such }x\text{ exists}, \end{cases}{x+NL​,0∈QNL​​,​if there exists x∈NL⊥​ with (x,y)∈T,if no such x exists,​

where in the first case xxx is selected by classical choice. No additional condition on TTT, independence from representative choices, or linearity of this map is asserted. The definition also applies when d=1d=1d=1 or t=0t=0t=0.

QAlgorithms.Papers.Independent.Extend50.P30.characteristicDistribution

For natural numbers d,nd,nd,n with d≠0d\ne0d=0, any Euclidean vector v∈CHv\in\mathbb C^Hv∈CH, H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n, and a pair x=(p,q)∈H×Hx=(p,q)\in H\times Hx=(p,q)∈H×H, the declaration defines

d−n∣⟨v,Wp,qv⟩∣2=d−n∣∑a,b∈Hv(a)‾Wp,q(a,b)v(b)∣2,d^{-n}\left|\langle v,W_{p,q}v\rangle\right|^2 =d^{-n}\left|\sum_{a,b\in H}\overline{v(a)}W_{p,q}(a,b)v(b)\right|^2,d−n∣⟨v,Wp,q​v⟩∣2=d−n​a,b∈H∑​v(a)​Wp,q​(a,b)v(b)​2,

where matrix action is ordinary matrix multiplication and

Wp,q(a,b)={τ−∑jpˉjqˉjω∑jpˉjaˉj,a=b+q,0,otherwise,ω=e2πi/d,τ=(−1)deπi/d.W_{p,q}(a,b)= \begin{cases} \tau^{-\sum_j\bar p_j\bar q_j}\omega^{\sum_j\bar p_j\bar a_j},&a=b+q,\\ 0,&\text{otherwise}, \end{cases} \qquad \omega=e^{2\pi i/d},\quad \tau=(-1)^d e^{\pi i/d}.Wp,q​(a,b)={τ−∑j​pˉ​j​qˉ​j​ω∑j​pˉ​j​aˉj​,0,​a=b+q,otherwise,​ω=e2πi/d,τ=(−1)deπi/d.

Bars denote standard nonnegative residue representatives, and addition is modulo ddd. No normalization of vvv, or assertion that these values sum to 111, is part of this definition. It includes d=1d=1d=1 and n=0n=0n=0; the exponent sums are empty when n=0n=0n=0.

QAlgorithms.Papers.Independent.Extend50.P30.choiMonomial

For every natural number nnn and every six-tuple x=(x0,…,x5)x=(x_0,\ldots,x_5)x=(x0​,…,x5​) of elements of (Z/2Z)2n(\mathbb Z/2\mathbb Z)^{2n}(Z/2Z)2n, split each xix_ixi​ into its first nnn coordinates aia_iai​ and its last nnn coordinates bib_ibi​. In the commutative polynomial ring over C\mathbb CC with variables Xa,bX_{a,b}Xa,b​ indexed by (a,b)∈(Z/2Z)n×(Z/2Z)n(a,b)\in(\mathbb Z/2\mathbb Z)^n\times(\mathbb Z/2\mathbb Z)^n(a,b)∈(Z/2Z)n×(Z/2Z)n, this defines

∏i=05Xai,bi.\prod_{i=0}^{5}X_{a_i,b_i}.i=0∏5​Xai​,bi​​.

Repeated index pairs give repeated factors. For n=0n=0n=0, there is a single index pair and the result is the sixth power of its variable.

QAlgorithms.Papers.Independent.Extend50.P30.cliffordActions

For natural numbers d≠0d\ne0d=0 and nnn, put V=(Z/dZ)nV=(\mathbb Z/d\mathbb Z)^nV=(Z/dZ)n, ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d, and h=2dh=2dh=2d for even ddd, otherwise h=dh=dh=d. Define Wp,q(a,b)W_{p,q}(a,b)Wp,q​(a,b) to be zero unless a=b+qa=b+qa=b+q, and otherwise to be τ−∑jpj‾qj‾ω∑jpj‾aj‾\tau^{-\sum_j\overline{p_j}\overline{q_j}}\omega^{\sum_j\overline{p_j}\overline{a_j}}τ−∑j​pj​​qj​​ω∑j​pj​​aj​​, using natural-number residue representatives and an integer negative exponent. Let P={τcWp,q:0≤c<h, p,q∈V}\mathcal P=\{\tau^cW_{p,q}:0\le c<h,\ p,q\in V\}P={τcWp,q​:0≤c<h, p,q∈V}, with duplicate matrices removed. The defined finite set consists of exactly those functions a:P→Pa:\mathcal P\to\mathcal Pa:P→P for which there exists a complex matrix UUU indexed by VVV such that UUU is unitary, {UPU†:P∈P}=P\{UPU^\dagger:P\in\mathcal P\}=\mathcal P{UPU†:P∈P}=P, and UPU†=a(P)UPU^\dagger=a(P)UPU†=a(P) for every P∈PP\in\mathcal PP∈P. This includes d=1d=1d=1 and n=0n=0n=0; ddd need not be prime.

QAlgorithms.Papers.Independent.Extend50.P30.cliffordCommutant

For natural numbers d,n,td,n,td,n,t with d≠0d\ne0d=0, put R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n. This defines the complex vector subspace of matrices AAA indexed by RtR^tRt satisfying

A U⊗t=U⊗tAA\,U^{\otimes t}=U^{\otimes t}AAU⊗t=U⊗tA

for every unitary matrix UUU on CR\mathbb C^RCR for which {UPU†:P∈P}=P\{UPU^\dagger:P\in\mathcal P\}=\mathcal P{UPU†:P∈P}=P, where (U⊗t)x,y=∏j=0t−1Uxj,yj(U^{\otimes t})_{x,y}=\prod_{j=0}^{t-1}U_{x_j,y_j}(U⊗t)x,y​=∏j=0t−1​Uxj​,yj​​. The finite set P\mathcal PP is

P={τaWp,q:0≤a<D, p,q∈R},D={2d,d even,d,d odd,\mathcal P=\{\tau^aW_{p,q}:0\le a<D,\ p,q\in R\}, \qquad D=\begin{cases}2d,&d\text{ even},\\d,&d\text{ odd},\end{cases}P={τaWp,q​:0≤a<D, p,q∈R},D={2d,d,​d even,d odd,​

with ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^de^{\pi i/d}τ=(−1)deπi/d, and

(Wp,q)u,v={τ−∑k=0n−1pˉkqˉkω∑k=0n−1pˉkuˉk,u=v+q,0,u≠v+q,(W_{p,q})_{u,v}= \begin{cases} \tau^{-\sum_{k=0}^{n-1}\bar p_k\bar q_k} \omega^{\sum_{k=0}^{n-1}\bar p_k\bar u_k},&u=v+q,\\ 0,&u\ne v+q, \end{cases}(Wp,q​)u,v​={τ−∑k=0n−1​pˉ​k​qˉ​k​ω∑k=0n−1​pˉ​k​uˉk​,0,​u=v+q,u=v+q,​

using canonical representatives modulo ddd and coordinatewise residue addition. No primality assumption is imposed. Both n=0n=0n=0 and t=0t=0t=0 are included; in either case the matrix space defining this subspace has a singleton index set, and every matrix in that space satisfies the commutation condition.

QAlgorithms.Papers.Independent.Extend50.P30.cliffordMoment

For natural numbers d≠0d\ne0d=0, nnn, and ttt, and any vector v∈CVv\in\mathbb C^{V}v∈CV, where V=(Z/dZ)nV=(\mathbb Z/d\mathbb Z)^nV=(Z/dZ)n, define ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d, and h=2dh=2dh=2d for even ddd, otherwise h=dh=dh=d. Let P={τcWp,q:0≤c<h, p,q∈V}\mathcal P=\{\tau^cW_{p,q}:0\le c<h,\ p,q\in V\}P={τcWp,q​:0≤c<h, p,q∈V} be a set of distinct matrices, where Wp,q(a,b)=0W_{p,q}(a,b)=0Wp,q​(a,b)=0 unless a=b+qa=b+qa=b+q, and otherwise equals τ−∑jpj‾qj‾ω∑jpj‾aj‾\tau^{-\sum_j\overline{p_j}\overline{q_j}}\omega^{\sum_j\overline{p_j}\overline{a_j}}τ−∑j​pj​​qj​​ω∑j​pj​​aj​​, using natural-number residue representatives and integer negative powers. Let A\mathcal AA consist of all functions a:P→Pa:\mathcal P\to\mathcal Pa:P→P admitting a unitary UaU_aUa​ with {UaPUa†:P∈P}=P\{U_aPU_a^\dagger:P\in\mathcal P\}=\mathcal P{Ua​PUa†​:P∈P}=P and UaPUa†=a(P)U_aPU_a^\dagger=a(P)Ua​PUa†​=a(P) for every PPP; for each such function choose one realizing matrix arbitrarily. The defined matrix, indexed by x,y∈Vtx,y\in V^tx,y∈Vt, has entries

1∣A∣∑a∈A∏j=0t−1(∑b∈VUa(xj,b)v(b))(∑b∈VUa(yj,b)v(b))‾.\frac{1}{|\mathcal A|} \sum_{a\in\mathcal A}\prod_{j=0}^{t-1} \left(\sum_{b\in V}U_a(x_j,b)v(b)\right) \overline{\left(\sum_{b\in V}U_a(y_j,b)v(b)\right)}.∣A∣1​a∈A∑​j=0∏t−1​(b∈V∑​Ua​(xj​,b)v(b))(b∈V∑​Ua​(yj​,b)v(b))​.

The vector vvv is not required to have norm one. The parameters n=0n=0n=0 and t=0t=0t=0 are allowed; for t=0t=0t=0 the products are empty products equal to one. The scalar inverse is the total complex inverse, which is zero at zero.

QAlgorithms.Papers.Independent.Extend50.P30.cliffordPolynomial

For every n∈Nn\in\mathbb Nn∈N, put m=2nm=2nm=2n, Rm=(Z/2Z)mR_m=(\mathbb Z/2\mathbb Z)^mRm​=(Z/2Z)m, and define matrices indexed by RmR_mRm​, for z=(p,q)∈Rm×Rmz=(p,q)\in R_m\times R_mz=(p,q)∈Rm​×Rm​, by

Wp,q(a,b)={i−∑jval⁡(pj)val⁡(qj)(−1)∑jval⁡(pj)val⁡(aj),a=b+q,0,a≠b+q.W_{p,q}(a,b)= \begin{cases} i^{-\sum_j\operatorname{val}(p_j)\operatorname{val}(q_j)} (-1)^{\sum_j\operatorname{val}(p_j)\operatorname{val}(a_j)},&a=b+q,\\ 0,&a\ne b+q. \end{cases}Wp,q​(a,b)={i−∑j​val(pj​)val(qj​)(−1)∑j​val(pj​)val(aj​),0,​a=b+q,a=b+q.​

For six-tuples x,y∈Rm6x,y\in R_m^6x,y∈Rm6​, set

Jm(x,y)=2−m∑z∈Rm×Rm∏h=02Wz(x2h,y2h) Wz(y2h+1,x2h+1)‾.J_m(x,y)=2^{-m}\sum_{z\in R_m\times R_m} \prod_{h=0}^{2}W_z(x_{2h},y_{2h})\, \overline{W_z(y_{2h+1},x_{2h+1})}.Jm​(x,y)=2−mz∈Rm​×Rm​∑​h=0∏2​Wz​(x2h​,y2h​)Wz​(y2h+1​,x2h+1​)​.

For a six-tuple yyy, let ah(y),bh(y)∈(Z/2Z)na_h(y),b_h(y)\in(\mathbb Z/2\mathbb Z)^nah​(y),bh​(y)∈(Z/2Z)n be the first and last nnn coordinates of yhy_hyh​, and let My=∏h=05Xah(y),bh(y)M_y=\prod_{h=0}^{5}X_{a_h(y),b_h(y)}My​=∏h=05​Xah​(y),bh​(y)​. Given any x∈Rm6x\in R_m^6x∈Rm6​, the declaration defines the polynomial

∑y∈Rm6Jm(x,y)My−Mx\sum_{y\in R_m^6}J_m(x,y)M_y-M_xy∈Rm6​∑​Jm​(x,y)My​−Mx​

over C\mathbb CC, with variables indexed by pairs in (Z/2Z)n×(Z/2Z)n(\mathbb Z/2\mathbb Z)^n\times(\mathbb Z/2\mathbb Z)^n(Z/2Z)n×(Z/2Z)n. No matrix or state is an argument to this definition. For n=0n=0n=0, the defined polynomial is zero.

QAlgorithms.Papers.Independent.Extend50.P30.cliffordRepresentative

For natural numbers d≠0d\ne0d=0 and nnn, put V=(Z/dZ)nV=(\mathbb Z/d\mathbb Z)^nV=(Z/dZ)n, ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d, and h=2dh=2dh=2d for even ddd, otherwise h=dh=dh=d. Let P\mathcal PP be the set of distinct matrices τcWp,q\tau^cW_{p,q}τcWp,q​, where 0≤c<h0\le c<h0≤c<h, p,q∈Vp,q\in Vp,q∈V, and

Wp,q(a,b)={τ−∑jpj‾qj‾ω∑jpj‾aj‾,a=b+q,0,otherwise,W_{p,q}(a,b)= \begin{cases} \tau^{-\sum_j\overline{p_j}\overline{q_j}}\omega^{\sum_j\overline{p_j}\overline{a_j}},&a=b+q,\\ 0,&\text{otherwise}, \end{cases}Wp,q​(a,b)={τ−∑j​pj​​qj​​ω∑j​pj​​aj​​,0,​a=b+q,otherwise,​

with natural-number residue representatives and integer negative powers. For any function a:P→Pa:\mathcal P\to\mathcal Pa:P→P, the defined matrix is an arbitrarily chosen matrix UUU satisfying unitarity, {UPU†:P∈P}=P\{UPU^\dagger:P\in\mathcal P\}=\mathcal P{UPU†:P∈P}=P, and UPU†=a(P)UPU^\dagger=a(P)UPU†=a(P) for all P∈PP\in\mathcal PP∈P, if such a matrix exists; if none exists, it is the identity matrix indexed by VVV. No uniqueness or prescribed choice among realizing matrices is asserted. The definition includes d=1d=1d=1 and n=0n=0n=0.

QAlgorithms.Papers.Independent.Extend50.P30.commutantCount

For arbitrary natural numbers d,td,td,t, this defines the natural number

c(d,t)=∏k=0max⁡(t−1,0)−1(dk+1).c(d,t)=\prod_{k=0}^{\max(t-1,0)-1}(d^k+1).c(d,t)=k=0∏max(t−1,0)−1​(dk+1).

The subtraction t−1t-1t−1 is truncated at zero, so the product is empty and equals 111 when t=0t=0t=0 or t=1t=1t=1. There is no assumption that d≠0d\ne0d=0; when d=0d=0d=0, the convention 00=10^0=100=1 gives c(0,t)=2c(0,t)=2c(0,t)=2 for every t≥2t\ge2t≥2.

QAlgorithms.Papers.Independent.Extend50.P30.composeRelation

For arbitrary natural numbers d,td,td,t, put V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t and let A,B≤V×VA,B\le V\times VA,B≤V×V be submodules. The definition gives the Z/dZ\mathbb Z/d\mathbb ZZ/dZ-linear span of {(x,z)∈V×V:∃y∈V, (x,y)∈A and (y,z)∈B}\{(x,z)\in V\times V:\exists y\in V,\ (x,y)\in A\text{ and }(y,z)\in B\}{(x,z)∈V×V:∃y∈V, (x,y)∈A and (y,z)∈B}, so its elements are all finite linear combinations of pairs admitting such an intermediate vector yyy. There are no further hypotheses on AAA or BBB. Zero values of ttt and ddd are allowed, with Z/0Z=Z\mathbb Z/0\mathbb Z=\mathbb ZZ/0Z=Z.

QAlgorithms.Papers.Independent.Extend50.P30.compressZero

For natural numbers d≠0,N,n,td\ne0,N,n,td=0,N,n,t, a hypothesis n≤Nn\le Nn≤N, and any complex matrix AAA on ttt copies of (Z/dZ)N(\mathbb Z/d\mathbb Z)^N(Z/dZ)N, this defines a matrix on ttt copies of (Z/dZ)n(\mathbb Z/d\mathbb Z)^n(Z/dZ)n by

B(x,y)=A(x~,y~),x~i,j={xi,j,j<n,0,n≤j<N,B(x,y)=A(\widetilde x,\widetilde y),\qquad \widetilde x_{i,j}= \begin{cases} x_{i,j},&j<n,\\ 0,&n\le j<N, \end{cases}B(x,y)=A(x,y​),xi,j​={xi,j​,0,​j<n,n≤j<N,​

and likewise for y~\widetilde yy​. Thus every copy is extended by zero residues in its last N−nN-nN−n sites. There is no positivity or normalization hypothesis on AAA. If n=Nn=Nn=N, this leaves the entries unchanged; if n=0n=0n=0, the result is the single entry of AAA whose row and column have every site zero. The case t=0t=0t=0 is included.

QAlgorithms.Papers.Independent.Extend50.P30.copyPrefixReduction

For natural numbers d≠0,n,t,sd\ne0,n,t,sd=0,n,t,s, a hypothesis s≤ts\le ts≤t, and any complex matrix AAA on HtH^tHt, where H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n, this defines the matrix on HsH^sHs

B(x,y)=∑z∈Ht−sA(x∥z, y∥z).B(x,y)=\sum_{z\in H^{t-s}}A(x\mathbin{\|}z,\ y\mathbin{\|}z).B(x,y)=z∈Ht−s∑​A(x∥z, y∥z).

Here concatenation places xxx or yyy in positions 0,…,s−10,\ldots,s-10,…,s−1 and places zzz in the remaining positions, using index i−si-si−s there. This is defined without any density or positivity hypothesis on AAA. If s=ts=ts=t, the suffix has length zero and the result is AAA; if s=0s=0s=0, the result is the scalar tr⁡A\operatorname{tr}AtrA. Zero sites n=0n=0n=0 are allowed.

QAlgorithms.Papers.Independent.Extend50.P30.cosetState

For natural numbers d≠0d\ne0d=0 and ttt, put V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, let N≤VN\le VN≤V be any submodule, and define N⊥={x:∑jxjyj=0 ∀y∈N}N^\perp=\{x:\sum_jx_jy_j=0\ \forall y\in N\}N⊥={x:∑j​xj​yj​=0 ∀y∈N}. Let qqq belong to the image of N⊥N^\perpN⊥ under the quotient map πN:V→V/N\pi_N:V\to V/NπN​:V→V/N, and let rq∈N⊥r_q\in N^\perprq​∈N⊥ be the classically chosen representative satisfying πN(rq)=q\pi_N(r_q)=qπN​(rq​)=q. The definition gives the complex Euclidean vector with coordinates ψq(x)=1/∣N∣\psi_q(x)=1/\sqrt{|N|}ψq​(x)=1/∣N∣​ when x−rq∈Nx-r_q\in Nx−rq​∈N, and ψq(x)=0\psi_q(x)=0ψq​(x)=0 otherwise. Thus its nonzero coordinates are precisely those on rq+Nr_q+Nrq​+N. The finite submodule NNN contains zero, so ∣N∣≥1|N|\ge1∣N∣≥1; no assumption N⊆N⊥N\subseteq N^\perpN⊆N⊥ is made. The cases d=1d=1d=1 or t=0t=0t=0 give a singleton coordinate set and coordinate value 111.

QAlgorithms.Papers.Independent.Extend50.P30.cssProjector

For natural numbers d≠0d\ne0d=0 and ttt, let V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, let N≤VN\le VN≤V be any submodule, and put ω=exp⁡(2πi/d)\omega=\exp(2\pi i/d)ω=exp(2πi/d). The definition gives a complex matrix indexed by VVV, with entries

P(a,b)=1∣N∣2∑p∈N∑q∈N{ω∑j=0t−1rep⁡(pj)rep⁡(aj),a=b+q,0,a≠b+q,P(a,b)=\frac{1}{|N|^2}\sum_{p\in N}\sum_{q\in N} \begin{cases} \omega^{\sum_{j=0}^{t-1}\operatorname{rep}(p_j)\operatorname{rep}(a_j)},&a=b+q,\\ 0,&a\ne b+q, \end{cases}P(a,b)=∣N∣21​p∈N∑​q∈N∑​{ω∑j=0t−1​rep(pj​)rep(aj​),0,​a=b+q,a=b+q,​

where each representative lies in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}. This is the entrywise expansion of the specified average of products of the two Weyl matrices. No isotropy or other condition on NNN is assumed, and the definition itself imposes no Hermitian or idempotence condition on PPP. Since NNN contains zero, its finite cardinality is positive. The cases d=1d=1d=1 and t=0t=0t=0 are included.

QAlgorithms.Papers.Independent.Extend50.P30.cssRelation

For arbitrary natural numbers d,td,td,t and a submodule N≤V=(Z/dZ)tN\le V=(\mathbb Z/d\mathbb Z)^tN≤V=(Z/dZ)t, define N⊥={x∈V:∑jxjyj=0 for every y∈N}N^\perp=\{x\in V:\sum_jx_jy_j=0\text{ for every }y\in N\}N⊥={x∈V:∑j​xj​yj​=0 for every y∈N}. The definition gives the submodule of V×VV\times VV×V whose elements are exactly the pairs (x,y)(x,y)(x,y) satisfying x∈N⊥x\in N^\perpx∈N⊥, y∈N⊥y\in N^\perpy∈N⊥, and x−y∈Nx-y\in Nx−y∈N. There is no assumption N⊆N⊥N\subseteq N^\perpN⊆N⊥. Both t=0t=0t=0 and d=0d=0d=0 are allowed; for d=0d=0d=0, the coefficient ring Z/0Z\mathbb Z/0\mathbb ZZ/0Z here is Z\mathbb ZZ.

QAlgorithms.Papers.Independent.Extend50.P30.cyclicPauliGroup

For natural numbers d,nd,nd,n with d≠0d\ne0d=0, let R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n, τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d, ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, and m=2dm=2dm=2d if ddd is even, otherwise m=dm=dm=d. This defines the finite set of complex matrices indexed by RRR consisting of all matrices Ph,p,qP_{h,p,q}Ph,p,q​, for 0≤h<m0\le h<m0≤h<m and p,q∈Rp,q\in Rp,q∈R, with entries

(Ph,p,q)a,b={τhτ−∑j=0n−1[pj][qj]ω∑j=0n−1[pj][aj],a=b+q,0,a≠b+q,(P_{h,p,q})_{a,b}= \begin{cases} \tau^h\tau^{-\sum_{j=0}^{n-1}[p_j][q_j]} \omega^{\sum_{j=0}^{n-1}[p_j][a_j]},&a=b+q,\\ 0,&a\ne b+q, \end{cases}(Ph,p,q​)a,b​={τhτ−∑j=0n−1​[pj​][qj​]ω∑j=0n−1​[pj​][aj​],0,​a=b+q,a=b+q,​

where brackets denote representatives in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, and the condition uses coordinatewise residue addition. Equal matrices produced by different choices occur only once in this finite set. Both d=1d=1d=1 and n=0n=0n=0 are included, with empty exponent sums equal to zero.

QAlgorithms.Papers.Independent.Extend50.P30.cyclicWeyl

For natural numbers d,nd,nd,n with d≠0d\ne0d=0, and an ordered pair x=(p,q)x=(p,q)x=(p,q) of functions from {0,…,n−1}\{0,\ldots,n-1\}{0,…,n−1} to Z/dZ\mathbb Z/d\mathbb ZZ/dZ, this defines a complex matrix WxW_xWx​ indexed by such functions. Write [r]∈{0,…,d−1}[r]\in\{0,\ldots,d-1\}[r]∈{0,…,d−1} for the natural-number representative of a residue rrr, and put τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d and ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d. Its row-aaa, column-bbb entry is

(Wx)a,b={τ−∑j=0n−1[pj][qj] ω∑j=0n−1[pj][aj],a=b+q,0,a≠b+q.(W_x)_{a,b}= \begin{cases} \tau^{-\sum_{j=0}^{n-1}[p_j][q_j]}\, \omega^{\sum_{j=0}^{n-1}[p_j][a_j]},&a=b+q,\\ 0,&a\ne b+q. \end{cases}(Wx​)a,b​={τ−∑j=0n−1​[pj​][qj​]ω∑j=0n−1​[pj​][aj​],0,​a=b+q,a=b+q.​

The equality and addition in the condition are coordinatewise modulo ddd; the sums in the exponents use ordinary natural-number representatives, and the negative exponent is an integer exponent. The cases d=1d=1d=1 and n=0n=0n=0 are allowed; for n=0n=0n=0, both sums are empty and the resulting 1×11\times11×1 matrix has entry 111.

QAlgorithms.Papers.Independent.Extend50.P30.defectClass

For natural numbers d,td,td,t, a submodule NNN of V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, and a vector x∈Vx\in Vx∈V together with a proof that ∑ixiyi=0\sum_i x_i y_i=0∑i​xi​yi​=0 for every y∈Ny\in Ny∈N, this returns the quotient class x+Nx+Nx+N, regarded as an element of the image {z+N:z∈N⊥}⊆V/N\{z+N:z\in N^\perp\}\subseteq V/N{z+N:z∈N⊥}⊆V/N, where N⊥N^\perpN⊥ is defined by that same bilinear orthogonality condition. The supplied orthogonality proof certifies membership in this image. Neither d≠0d\ne0d=0 nor N⊆N⊥N\subseteq N^\perpN⊆N⊥ is assumed; d=0d=0d=0 uses the coefficient ring Z\mathbb ZZ, and t=0t=0t=0 is allowed.

QAlgorithms.Papers.Independent.Extend50.P30.defectQuotient

For natural numbers d,td,td,t and a submodule NNN of V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, this defines the image of N⊥N^\perpN⊥ under the quotient map V→V/NV\to V/NV→V/N, where N⊥={x:∑ixiyi=0 for every y∈N}N^\perp=\{x:\sum_i x_i y_i=0\text{ for every }y\in N\}N⊥={x:∑i​xi​yi​=0 for every y∈N}. Thus it is the submodule {x+N:x∈N⊥}\{x+N:x\in N^\perp\}{x+N:x∈N⊥} of V/NV/NV/N; no assumption N⊆N⊥N\subseteq N^\perpN⊆N⊥ is required. The definition allows d=0d=0d=0, when the coefficient ring is Z\mathbb ZZ, and t=0t=0t=0.

QAlgorithms.Papers.Independent.Extend50.P30.defectRelation

For natural numbers d≠0d\ne0d=0 and ttt, let V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t and let N,M≤VN,M\le VN,M≤V be arbitrary submodules. Write L⊥={x:∑jxjyj=0 ∀y∈L}L^\perp=\{x:\sum_jx_jy_j=0\ \forall y\in L\}L⊥={x:∑j​xj​yj​=0 ∀y∈L}, πL:V→V/L\pi_L:V\to V/LπL​:V→V/L, and QL=πL(L⊥)Q_L=\pi_L(L^\perp)QL​=πL​(L⊥). Let J:QM→QNJ:Q_M\to Q_NJ:QM​→QN​ be a linear equivalence that preserves ∑jrep⁡(xj)2\sum_j\operatorname{rep}(x_j)^2∑j​rep(xj​)2, computed modulo 2d2d2d for even ddd and modulo ddd for odd ddd, whenever classes of perpendicular representatives correspond under JJJ; it must also send the class of the all-ones vector to that class whenever both requisite perpendicular memberships hold. The definition gives the Z/dZ\mathbb Z/d\mathbb ZZ/dZ-linear span of {(x,y):x∈N⊥, y∈M⊥, J(πM(y))=πN(x)}\{(x,y):x\in N^\perp,\ y\in M^\perp,\ J(\pi_M(y))=\pi_N(x)\}{(x,y):x∈N⊥, y∈M⊥, J(πM​(y))=πN​(x)} inside V×VV\times VV×V, namely all finite linear combinations of such pairs. There is no assumption that either submodule is contained in its perpendicular submodule; d=1d=1d=1 and t=0t=0t=0 are included.

QAlgorithms.Papers.Independent.Extend50.P30.defectRelationSet

For natural numbers d≠0d\ne0d=0 and ttt, put V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, and let N,MN,MN,M be arbitrary submodules of VVV. For any submodule LLL, define L⊥={x∈V:∑jxjyj=0 for every y∈L}L^\perp=\{x\in V:\sum_jx_jy_j=0\text{ for every }y\in L\}L⊥={x∈V:∑j​xj​yj​=0 for every y∈L}, let πL:V→V/L\pi_L:V\to V/LπL​:V→V/L be the quotient map, and put QL=πL(L⊥)Q_L=\pi_L(L^\perp)QL​=πL​(L⊥). The argument JJJ consists of a Z/dZ\mathbb Z/d\mathbb ZZ/dZ-linear equivalence J:QM→QNJ:Q_M\to Q_NJ:QM​→QN​ with these additional properties: whenever y∈M⊥y\in M^\perpy∈M⊥, x∈N⊥x\in N^\perpx∈N⊥, and J(πM(y))=πN(x)J(\pi_M(y))=\pi_N(x)J(πM​(y))=πN​(x), their quadratic residues agree; and whenever the all-ones vector belongs to both perpendicular submodules, JJJ sends its class to its class. Here the quadratic residue of zzz is ∑jrep⁡(zj)2\sum_j\operatorname{rep}(z_j)^2∑j​rep(zj​)2 modulo 2d2d2d if ddd is even and modulo ddd otherwise, with rep⁡(zj)∈{0,…,d−1}\operatorname{rep}(z_j)\in\{0,\ldots,d-1\}rep(zj​)∈{0,…,d−1}. The definition gives the set {(x,y)∈V×V:x∈N⊥, y∈M⊥, J(πM(y))=πN(x)}\{(x,y)\in V\times V:x\in N^\perp,\ y\in M^\perp,\ J(\pi_M(y))=\pi_N(x)\}{(x,y)∈V×V:x∈N⊥, y∈M⊥, J(πM​(y))=πN​(x)}. Neither N⊆N⊥N\subseteq N^\perpN⊆N⊥ nor M⊆M⊥M\subseteq M^\perpM⊆M⊥ is assumed; the condition about the all-ones vector imposes no requirement when its requisite memberships do not hold. The parameters allow d=1d=1d=1 and t=0t=0t=0.

QAlgorithms.Papers.Independent.Extend50.P30.defectRepresentative

For natural numbers d,td,td,t, a submodule NNN of V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, and an element ξ\xiξ of the image {x+N:x∈N⊥}⊆V/N\{x+N:x\in N^\perp\}\subseteq V/N{x+N:x∈N⊥}⊆V/N, this noncomputably chooses a vector x∈N⊥x\in N^\perpx∈N⊥ whose quotient class is ξ\xiξ, where N⊥={x:∑ixiyi=0 for every y∈N}N^\perp=\{x:\sum_i x_i y_i=0\text{ for every }y\in N\}N⊥={x:∑i​xi​yi​=0 for every y∈N}. No particular representative is specified beyond these properties. The definition permits d=0d=0d=0, with coefficient ring Z\mathbb ZZ, and t=0t=0t=0, and requires no inclusion N⊆N⊥N\subseteq N^\perpN⊆N⊥.

QAlgorithms.Papers.Independent.Extend50.P30.designClassOf

For natural numbers d≠0d\ne0d=0 and ttt, put V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, and let TTT be any Z/dZ\mathbb Z/d\mathbb ZZ/dZ-submodule of V×VV\times VV×V, with no additional condition on TTT. Set h=2dh=2dh=2d for even ddd, otherwise h=dh=dh=d, and Q(x)=∑jxj‾ 2∈Z/hZQ(x)=\sum_j\overline{x_j}^{\,2}\in\mathbb Z/h\mathbb ZQ(x)=∑j​xj​​2∈Z/hZ, using natural-number residue representatives. This defines the finite set of all submodules S⊆V×VS\subseteq V\times VS⊆V×V that have cardinality dtd^tdt, contain (1,1)(\mathbf1,\mathbf1)(1,1), satisfy Q(x)=Q(y)Q(x)=Q(y)Q(x)=Q(y) for all (x,y)∈S(x,y)\in S(x,y)∈S, and admit coordinate permutations p,qp,qp,q such that

S=span⁡Z/dZ{(x∘p−1,y∘q):(x,y)∈T}orS=span⁡Z/dZ{(y∘p−1,x∘q):(x,y)∈T}.S=\operatorname{span}_{\mathbb Z/d\mathbb Z} \{(x\circ p^{-1},y\circ q):(x,y)\in T\} \quad\text{or}\quad S=\operatorname{span}_{\mathbb Z/d\mathbb Z} \{(y\circ p^{-1},x\circ q):(x,y)\in T\}.S=spanZ/dZ​{(x∘p−1,y∘q):(x,y)∈T}orS=spanZ/dZ​{(y∘p−1,x∘q):(x,y)∈T}.

The definition permits d=1d=1d=1 and t=0t=0t=0.

QAlgorithms.Papers.Independent.Extend50.P30.designClassSum

For natural numbers d,t,nd,t,nd,t,n with d≠0d\ne0d=0, and any finite subset FFF of the following collection Ld,t\mathcal L_{d,t}Ld,t​, this definition returns a complex matrix indexed by ttt-tuples of elements of Vn=(Z/dZ)nV_n=(\mathbb Z/d\mathbb Z)^nVn​=(Z/dZ)n. To define the collection, put Dd=2dD_d=2dDd​=2d for even ddd and Dd=dD_d=dDd​=d otherwise, and q(x)=∑i<tx^i2q(x)=\sum_{i<t}\widehat x_i^2q(x)=∑i<t​xi2​ in Z/DdZ\mathbb Z/D_d\mathbb ZZ/Dd​Z, where hats denote least nonnegative representatives. The members of Ld,t\mathcal L_{d,t}Ld,t​ are exactly the submodules T≤Vt×VtT\le V_t\times V_tT≤Vt​×Vt​ with ∣T∣=dt|T|=d^t∣T∣=dt, (1,1)∈T(\mathbf1,\mathbf1)\in T(1,1)∈T, and q(x)=q(y)q(x)=q(y)q(x)=q(y) for every (x,y)∈T(x,y)\in T(x,y)∈T. The returned matrix has entries

(∑T∈FRn(T))x,y=∑T∈F∏j<n1((xi(j))i<t,(yi(j))i<t)∈T.\left(\sum_{T\in F}R_n(T)\right)_{x,y} = \sum_{T\in F}\prod_{j<n} \mathbf1_{\big((x_i(j))_{i<t},(y_i(j))_{i<t}\big)\in T}.(T∈F∑​Rn​(T))x,y​=T∈F∑​j<n∏​1((xi​(j))i<t​,(yi​(j))i<t​)∈T​.

There is no primality assumption, no positivity requirement on nnn or ttt, and no requirement that FFF be one of the particular subsets called design classes. If FFF is empty the matrix is zero; if n=0n=0n=0, its index set is a singleton and each summand has sole entry 111.

QAlgorithms.Papers.Independent.Extend50.P30.designClasses

For natural numbers d≠0d\ne0d=0 and ttt, put V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, h=2dh=2dh=2d for even ddd and h=dh=dh=d otherwise, and Q(x)=∑jxj‾ 2∈Z/hZQ(x)=\sum_j\overline{x_j}^{\,2}\in\mathbb Z/h\mathbb ZQ(x)=∑j​xj​​2∈Z/hZ, using natural-number residue representatives. Let L\mathcal LL be the finite collection of Z/dZ\mathbb Z/d\mathbb ZZ/dZ-submodules of V×VV\times VV×V having cardinality dtd^tdt, containing (1,1)(\mathbf1,\mathbf1)(1,1), and satisfying Q(x)=Q(y)Q(x)=Q(y)Q(x)=Q(y) on every member (x,y)(x,y)(x,y). For each T∈LT\in\mathcal LT∈L, form the finite set of all S∈LS\in\mathcal LS∈L for which some coordinate permutations p,qp,qp,q satisfy

S=span⁡Z/dZ{(x∘p−1,y∘q):(x,y)∈T}orS=span⁡Z/dZ{(y∘p−1,x∘q):(x,y)∈T}.S=\operatorname{span}_{\mathbb Z/d\mathbb Z} \{(x\circ p^{-1},y\circ q):(x,y)\in T\} \quad\text{or}\quad S=\operatorname{span}_{\mathbb Z/d\mathbb Z} \{(y\circ p^{-1},x\circ q):(x,y)\in T\}.S=spanZ/dZ​{(x∘p−1,y∘q):(x,y)∈T}orS=spanZ/dZ​{(y∘p−1,x∘q):(x,y)∈T}.

The definition returns the finite set of these finite sets as TTT ranges over L\mathcal LL, removing repeated finite sets. The parameters d=1d=1d=1 and t=0t=0t=0 are included.

QAlgorithms.Papers.Independent.Extend50.P30.designCoefficients

For natural numbers d,n,td,n,td,n,t with d≠0d\ne0d=0, and any vector v∈ℓ2((Z/dZ)n;C)v\in\ell^2((\mathbb Z/d\mathbb Z)^n;\mathbb C)v∈ℓ2((Z/dZ)n;C), this definition returns a real-valued function on all finite subsets of Ld,t\mathcal L_{d,t}Ld,t​, without assuming that ddd is prime or that vvv is normalized. Here, writing Vr=(Z/dZ)rV_r=(\mathbb Z/d\mathbb Z)^rVr​=(Z/dZ)r and Dd=2dD_d=2dDd​=2d for even ddd, Dd=dD_d=dDd​=d otherwise, Ld,t\mathcal L_{d,t}Ld,t​ consists of submodules T≤Vt×VtT\le V_t\times V_tT≤Vt​×Vt​ with ∣T∣=dt|T|=d^t∣T∣=dt, (1,1)∈T(\mathbf1,\mathbf1)\in T(1,1)∈T, and ∑ix^i2=∑iy^i2\sum_i\widehat x_i^2=\sum_i\widehat y_i^2∑i​xi2​=∑i​y​i2​ modulo DdD_dDd​ for every (x,y)∈T(x,y)\in T(x,y)∈T. For coordinate permutation matrices Pπ,PσP_\pi,P_\sigmaPπ​,Pσ​, let C(T)C(T)C(T) contain exactly the members of Ld,t\mathcal L_{d,t}Ld,t​ equal to the span of {(Pπx,PσTy):(x,y)∈T}\{(P_\pi x,P_\sigma^{\mathsf T}y):(x,y)\in T\}{(Pπ​x,PσT​y):(x,y)∈T}, or the analogous span for the transposed relation TopT^{\mathrm{op}}Top, for some π,σ\pi,\sigmaπ,σ; set C={C(T):T∈Ld,t}\mathcal C=\{C(T):T\in\mathcal L_{d,t}\}C={C(T):T∈Ld,t​}. Define Rn(T)x,y=∏j<n1((xi(j))i<t,(yi(j))i<t)∈TR_n(T)_{x,y}=\prod_{j<n}\mathbf1_{((x_i(j))_{i<t},(y_i(j))_{i<t})\in T}Rn​(T)x,y​=∏j<n​1((xi​(j))i<t​,(yi​(j))i<t​)∈T​ and BF=∑T∈FRn(T)B_F=\sum_{T\in F}R_n(T)BF​=∑T∈F​Rn​(T). To define the matrix being expanded, put ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^de^{\pi i/d}τ=(−1)deπi/d, let Wa,b(u,w)=τ−∑ja^jb^jω∑ja^ju^jW_{a,b}(u,w)=\tau^{-\sum_j\widehat a_j\widehat b_j}\omega^{\sum_j\widehat a_j\widehat u_j}Wa,b​(u,w)=τ−∑j​aj​bj​ω∑j​aj​uj​ if u=w+bu=w+bu=w+b, and 000 otherwise, and form P={τcWa,b:0≤c<Dd, a,b∈Vn}\mathcal P=\{\tau^cW_{a,b}:0\le c<D_d,\ a,b\in V_n\}P={τcWa,b​:0≤c<Dd​, a,b∈Vn​}. Let A\mathcal AA be the finite set of functions P→P\mathcal P\to\mathcal PP→P realized by conjugation by a unitary normalizing P\mathcal PP, select a realizing unitary UaU_aUa​ for each a∈Aa\in\mathcal Aa∈A, and set Mt(v)=∣A∣−1∑a∈A((Uav)(Uav)†)⊗t\mathcal M_t(v)=|\mathcal A|^{-1}\sum_{a\in\mathcal A}((U_av)(U_av)^\dagger)^{\otimes t}Mt​(v)=∣A∣−1∑a∈A​((Ua​v)(Ua​v)†)⊗t, where tensor-power entries are products over copies. If there exists a function aaa on finite subsets of Ld,t\mathcal L_{d,t}Ld,t​ such that a(F)=0a(F)=0a(F)=0 whenever F∉CF\notin\mathcal CF∈/C and

Mt(v)=∑F∈Ca(F)BF,\mathcal M_t(v)=\sum_{F\in\mathcal C}a(F)B_F,Mt​(v)=F∈C∑​a(F)BF​,

the returned function is one unspecified choice of such an aaa; otherwise it is identically zero. The definition imposes no uniqueness, nonnegativity, or normalization condition on these coefficients. All natural parameters may be zero except ddd, and empty products and sums retain their usual values.

QAlgorithms.Papers.Independent.Extend50.P30.discreteWigner

For natural numbers d≠0d\ne0d=0 and nnn, let V=(Z/dZ)nV=(\mathbb Z/d\mathbb Z)^nV=(Z/dZ)n, let v∈CVv\in\mathbb C^Vv∈CV be any complex Euclidean vector, and let x=(r,s)∈V×Vx=(r,s)\in V\times Vx=(r,s)∈V×V. Put ω=exp⁡(2πi/d)\omega=\exp(2\pi i/d)ω=exp(2πi/d), τ=(−1)dexp⁡(πi/d)\tau=(-1)^d\exp(\pi i/d)τ=(−1)dexp(πi/d), and define W(u,w)(a,b)W_{(u,w)}(a,b)W(u,w)​(a,b) to be zero unless a=b+wa=b+wa=b+w, in which case it equals τ−∑jrep⁡(uj)rep⁡(wj)ω∑jrep⁡(uj)rep⁡(aj)\tau^{-\sum_j\operatorname{rep}(u_j)\operatorname{rep}(w_j)}\omega^{\sum_j\operatorname{rep}(u_j)\operatorname{rep}(a_j)}τ−∑j​rep(uj​)rep(wj​)ω∑j​rep(uj​)rep(aj​). With Ax=d−n∑u,w∈Vω−rep⁡(∑j(rjwj−sjuj))W(u,w)†A_x=d^{-n}\sum_{u,w\in V}\omega^{-\operatorname{rep}(\sum_j(r_jw_j-s_ju_j))}W_{(u,w)}^\daggerAx​=d−n∑u,w∈V​ω−rep(∑j​(rj​wj​−sj​uj​))W(u,w)†​, the definition gives the real number

Wv(x)=d−nRe⁡tr⁡(Axvv†)=d−nRe⁡∑a,b∈VAx(a,b)v(b)v(a)‾.\mathcal W_v(x)=d^{-n}\operatorname{Re}\operatorname{tr}(A_xvv^\dagger) =d^{-n}\operatorname{Re}\sum_{a,b\in V}A_x(a,b)v(b)\overline{v(a)}.Wv​(x)=d−nRetr(Ax​vv†)=d−nRea,b∈V∑​Ax​(a,b)v(b)v(a)​.

All representatives are the least nonnegative residues, and negative exponents are integer powers. There is no normalization assumption on vvv, nor any primality or oddness assumption on ddd. For n=0n=0n=0, the value is the squared modulus of the vector’s sole coordinate.

QAlgorithms.Papers.Independent.Extend50.P30.doubleClasses

For every d,t∈Nd,t\in\mathbb Nd,t∈N with d≠0d\ne0d=0, put V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, let D=2dD=2dD=2d when ddd is even and D=dD=dD=d otherwise, and define q(x)=∑jval⁡(xj)2q(x)=\sum_j\operatorname{val}(x_j)^2q(x)=∑j​val(xj​)2 in Z/DZ\mathbb Z/D\mathbb ZZ/DZ, using the representatives val⁡(xj)∈{0,…,d−1}\operatorname{val}(x_j)\in\{0,\ldots,d-1\}val(xj​)∈{0,…,d−1}. Let L\mathcal LL consist of the submodules T⊆V×VT\subseteq V\times VT⊆V×V satisfying q(x)=q(y)q(x)=q(y)q(x)=q(y) for every (x,y)∈T(x,y)\in T(x,y)∈T, ∣T∣=dt|T|=d^t∣T∣=dt, and (1,1)∈T(\mathbf1,\mathbf1)\in T(1,1)∈T. Let O\mathcal OO consist of the t×tt\times tt×t matrices OOO over Z/dZ\mathbb Z/d\mathbb ZZ/dZ satisfying q(Ox)=q(x)q(Ox)=q(x)q(Ox)=q(x) for every x∈Vx\in Vx∈V and O1=1O\mathbf1=\mathbf1O1=1; these conditions do not explicitly require invertibility. The defined finite set is

{{S∈L:∃O,P∈O,S=span⁡Z/dZ{(Ox,PTy):(x,y)∈T}}:T∈L}.\left\{ \left\{S\in\mathcal L: \exists O,P\in\mathcal O,\quad S=\operatorname{span}_{\mathbb Z/d\mathbb Z} \{(Ox,P^{\mathsf T}y):(x,y)\in T\} \right\}:T\in\mathcal L \right\}.{{S∈L:∃O,P∈O,S=spanZ/dZ​{(Ox,PTy):(x,y)∈T}}:T∈L}.

Repeated identical subsets are included only once. The definition includes d=1d=1d=1 and t=0t=0t=0, and does not separately assert that these subsets form a partition.

QAlgorithms.Papers.Independent.Extend50.P30.embeddedAntiIdentity

For natural numbers n,tn,tn,t and an injection e:{0,…,5}↪{0,…,t−1}e:\{0,\ldots,5\}\hookrightarrow\{0,\ldots,t-1\}e:{0,…,5}↪{0,…,t−1}, this defines a complex matrix indexed by ttt-tuples of elements of R=(Z/2Z)nR=(\mathbb Z/2\mathbb Z)^nR=(Z/2Z)n. For a,b,u,v∈Ra,b,u,v\in Ra,b,u,v∈R, define Wa,b(u,v)=0W_{a,b}(u,v)=0Wa,b​(u,v)=0 unless u=v+bu=v+bu=v+b, and otherwise define

Wa,b(u,v)=i−∑jaˉjbˉj(−1)∑jaˉjuˉj,W_{a,b}(u,v)=\mathrm i^{-\sum_j\bar a_j\bar b_j}(-1)^{\sum_j\bar a_j\bar u_j},Wa,b​(u,v)=i−∑j​aˉj​bˉj​(−1)∑j​aˉj​uˉj​,

where bars denote representatives in {0,1}\{0,1\}{0,1}, and Wa,b†W_{a,b}^{\dagger}Wa,b†​ denotes the conjugate transpose. The matrix entry at x,y∈Rtx,y\in R^tx,y∈Rt is zero unless xi=yix_i=y_ixi​=yi​ at every position outside the image of eee; when those equalities hold, it is

2−n∑a,b∈R∏j=05{Wa,b(xe(j),ye(j)),j even,Wa,b†(xe(j),ye(j)),j odd.2^{-n}\sum_{a,b\in R}\prod_{j=0}^{5} \begin{cases} W_{a,b}(x_{e(j)},y_{e(j)}),&j\text{ even},\\ W_{a,b}^{\dagger}(x_{e(j)},y_{e(j)}),&j\text{ odd}. \end{cases}2−na,b∈R∑​j=0∏5​{Wa,b​(xe(j)​,ye(j)​),Wa,b†​(xe(j)​,ye(j)​),​j even,j odd.​

The injection requires t≥6t\ge6t≥6; n=0n=0n=0 is allowed, with empty coordinate sums equal to zero.

QAlgorithms.Papers.Independent.Extend50.P30.embeddedLocal

For natural numbers d≠0,n,kd\ne0,n,kd=0,n,k, a site j∈{0,…,n−1}j\in\{0,\ldots,n-1\}j∈{0,…,n−1}, and any complex matrix LLL on kkk copies of the one-site register Z/dZ\mathbb Z/d\mathbb ZZ/dZ, this defines a matrix on kkk copies of (Z/dZ)n(\mathbb Z/d\mathbb Z)^n(Z/dZ)n by

B(x,y)={L((xi,j)i=0k−1,(yi,j)i=0k−1),xi,ℓ=yi,ℓ for every i and every ℓ≠j,0,otherwise.B(x,y)= \begin{cases} L\bigl((x_{i,j})_{i=0}^{k-1},(y_{i,j})_{i=0}^{k-1}\bigr), &x_{i,\ell}=y_{i,\ell}\text{ for every }i\text{ and every }\ell\ne j,\\ 0,&\text{otherwise}. \end{cases}B(x,y)={L((xi,j​)i=0k−1​,(yi,j​)i=0k−1​),0,​xi,ℓ​=yi,ℓ​ for every i and every ℓ=j,otherwise.​

The one-site arguments of LLL are understood as functions on a singleton site index. The choice of jjj requires n>0n>0n>0, so there are no such inputs when n=0n=0n=0. If k=0k=0k=0, the agreement condition is vacuous and the result is the sole entry of LLL. No additional assumption on LLL is imposed.

QAlgorithms.Papers.Independent.Extend50.P30.graphRelation

For natural numbers d≠0d\ne0d=0 and ttt, and any t×tt\times tt×t matrix OOO over Z/dZ\mathbb Z/d\mathbb ZZ/dZ, this defines the Z/dZ\mathbb Z/d\mathbb ZZ/dZ-submodule

{(x,y)∈(Z/dZ)t×(Z/dZ)t:x=Oy}.\{(x,y)\in(\mathbb Z/d\mathbb Z)^t\times(\mathbb Z/d\mathbb Z)^t:x=Oy\}.{(x,y)∈(Z/dZ)t×(Z/dZ)t:x=Oy}.

No quadratic-preservation or all-ones-preservation condition is imposed on OOO. The definition includes d=1d=1d=1 and t=0t=0t=0; for t=0t=0t=0, the relation consists of the unique pair of empty vectors.

QAlgorithms.Papers.Independent.Extend50.P30.haarMoment

For natural numbers d,n,td,n,td,n,t with d≠0d\ne0d=0, put R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n. This defines a complex matrix indexed by x,y:{0,…,t−1}→Rx,y:\{0,\ldots,t-1\}\to Rx,y:{0,…,t−1}→R, whose entries are

∑p∈Sym⁡(t)1 ⁣[xi=yp−1(i) for every i]∏k=0t−1(dn+k).\frac{\displaystyle\sum_{p\in\operatorname{Sym}(t)} \mathbf 1\!\left[x_i=y_{p^{-1}(i)}\text{ for every }i\right]} {\displaystyle\prod_{k=0}^{t-1}(d^n+k)}.k=0∏t−1​(dn+k)p∈Sym(t)∑​1[xi​=yp−1(i)​ for every i]​.

Thus the numerator counts permutations satisfying the indicated coordinate equalities. The denominator is nonzero since d≥1d\ge1d≥1. The definition includes d=1d=1d=1, n=0n=0n=0, and t=0t=0t=0; for t=0t=0t=0, the empty product is 111, there is one permutation, and the matrix has sole entry 111.

QAlgorithms.Papers.Independent.Extend50.P30.instFintypeDefectQuotient

For every pair of natural numbers d,td,td,t with d≠0d\ne0d=0, and every Z/dZ\mathbb Z/d\mathbb ZZ/dZ-submodule NNN of V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, this declaration equips the set

QN={x+N∈V/N:x∈N⊥},N⊥={x∈V:∑j=0t−1xjyj=0 for every y∈N},Q_N=\{x+N\in V/N:x\in N^\perp\}, \qquad N^\perp=\left\{x\in V:\sum_{j=0}^{t-1}x_jy_j=0\text{ for every }y\in N\right\},QN​={x+N∈V/N:x∈N⊥},N⊥={x∈V:j=0∑t−1​xj​yj​=0 for every y∈N},

with a finite enumeration, using its existing finiteness. Here QNQ_NQN​ is the image of N⊥N^\perpN⊥ in V/NV/NV/N; no assumption N⊆N⊥N\subseteq N^\perpN⊆N⊥ is imposed. The declaration includes composite ddd, d=1d=1d=1, and t=0t=0t=0.

QAlgorithms.Papers.Independent.Extend50.P30.instFintypeLagrangian

For every pair of natural numbers d,td,td,t with d≠0d\ne0d=0, this supplies a finite enumeration of all Z/dZ\mathbb Z/d\mathbb ZZ/dZ-submodules T⊆(Z/dZ)t×(Z/dZ)tT\subseteq(\mathbb Z/d\mathbb Z)^t\times(\mathbb Z/d\mathbb Z)^tT⊆(Z/dZ)t×(Z/dZ)t having cardinality dtd^tdt, containing the pair of all-ones vectors, and satisfying ∑jxˉj 2=∑jyˉj 2\sum_j\bar x_j^{\,2}=\sum_j\bar y_j^{\,2}∑j​xˉj2​=∑j​yˉ​j2​ in Z/DZ\mathbb Z/D\mathbb ZZ/DZ for every (x,y)∈T(x,y)\in T(x,y)∈T, where D=2dD=2dD=2d for even ddd and D=dD=dD=d otherwise and bars denote canonical representatives modulo ddd. This includes t=0t=0t=0, for which the enumeration has one element; it does not specify a numerical cardinality formula in general.

QAlgorithms.Papers.Independent.Extend50.P30.instFintypeStochasticOrthogonal

For every pair of natural numbers d≠0d\ne0d=0 and ttt, this instance supplies a finite enumeration of the type of t×tt\times tt×t matrices OOO over Z/dZ\mathbb Z/d\mathbb ZZ/dZ satisfying O1=1O\mathbf1=\mathbf1O1=1 and q(Ox)=q(x)q(Ox)=q(x)q(Ox)=q(x) for every x∈(Z/dZ)tx\in(\mathbb Z/d\mathbb Z)^tx∈(Z/dZ)t. Here 1\mathbf11 is the all-ones vector, and q(x)q(x)q(x) sums the squares of the least nonnegative coordinate representatives modulo 2d2d2d when ddd is even and modulo ddd otherwise. The enumeration is obtained from the finiteness of this type; no particular ordering is specified. The cases d=1d=1d=1 and t=0t=0t=0 are included.

QAlgorithms.Papers.Independent.Extend50.P30.leftDefect

For natural numbers d,td,td,t, put V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t. For any submodule TTT of V×VV\times VV×V, this defines the submodule {x∈V:(x,0)∈T}\{x\in V:(x,0)\in T\}{x∈V:(x,0)∈T}, namely the inverse image of TTT under the linear map x↦(x,0)x\mapsto(x,0)x↦(x,0). No nonzero-modulus assumption is imposed, so d=0d=0d=0, with coefficient ring Z\mathbb ZZ, is included; t=0t=0t=0 is also included.

QAlgorithms.Papers.Independent.Extend50.P30.minimalTest

For natural numbers d≠0,n,td\ne0,n,td=0,n,t, let H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n, and let O\mathcal OO be the finite set of t×tt\times tt×t matrices OOO over Z/dZ\mathbb Z/d\mathbb ZZ/dZ such that O1=1O\mathbf1=\mathbf1O1=1 and Q(Oz)=Q(z)Q(Oz)=Q(z)Q(Oz)=Q(z) for every z∈(Z/dZ)tz\in(\mathbb Z/d\mathbb Z)^tz∈(Z/dZ)t, where

Q(z)=∑i=0t−1[zi]2(modD),D={2d,d even,d,d odd.Q(z)=\sum_{i=0}^{t-1}[z_i]^2\pmod D,\qquad D=\begin{cases}2d,&d\text{ even},\\d,&d\text{ odd}.\end{cases}Q(z)=i=0∑t−1​[zi​]2(modD),D={2d,d,​d even,d odd.​

Here each [zi][z_i][zi​] is the least nonnegative representative, mapped into Z/DZ\mathbb Z/D\mathbb ZZ/DZ. The definition gives the matrix on HtH^tHt

E(u,v)=∣O∣−1∑O∈O∏j=0n−11 (ui,j)i=0t−1=O(vi,j)i=0t−1.E(u,v)=|\mathcal O|^{-1}\sum_{O\in\mathcal O} \prod_{j=0}^{n-1} \mathbf1_{\,(u_{i,j})_{i=0}^{t-1}=O(v_{i,j})_{i=0}^{t-1}}.E(u,v)=∣O∣−1O∈O∑​j=0∏n−1​1(ui,j​)i=0t−1​=O(vi,j​)i=0t−1​​.

Thus each summand uses the relation {(a,b):a=Ob}\{(a,b):a=Ob\}{(a,b):a=Ob}, separately at every site. The normalization is a complex inverse. The identity matrix belongs to O\mathcal OO, so this finite set is nonempty. Empty products are 111, and n=0n=0n=0 or t=0t=0t=0 gives the scalar matrix 111. No assertion that this matrix is a test or projection accompanies the definition.

QAlgorithms.Papers.Independent.Extend50.P30.mixedStabilizers

For natural numbers d,nd,nd,n with d≠0d\ne0d=0, let H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n, put ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d, and let h=2dh=2dh=2d when ddd is even and h=dh=dh=d otherwise. For p,q,a,b∈Hp,q,a,b\in Hp,q,a,b∈H, define the matrix

Wp,q(a,b)={τ−∑j=0n−1pˉjqˉj ω∑j=0n−1pˉjaˉj,a=b+q,0,a≠b+q,W_{p,q}(a,b)= \begin{cases} \tau^{-\sum_{j=0}^{n-1}\bar p_j\bar q_j}\, \omega^{\sum_{j=0}^{n-1}\bar p_j\bar a_j},&a=b+q,\\ 0,&a\ne b+q, \end{cases}Wp,q​(a,b)={τ−∑j=0n−1​pˉ​j​qˉ​j​ω∑j=0n−1​pˉ​j​aˉj​,0,​a=b+q,a=b+q,​

where bars denote representatives in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, addition in HHH is coordinatewise modulo ddd, and the exponent of τ\tauτ is an integer. Form the finite set P={τcWp,q:0≤c<h, p,q∈H}\mathcal P=\{\tau^cW_{p,q}:0\le c<h,\ p,q\in H\}P={τcWp,q​:0≤c<h, p,q∈H}. The declaration defines the finite set of matrices (tr⁡AG)−1AG(\operatorname{tr}A_G)^{-1}A_G(trAG​)−1AG​, where AG=∣G∣−1∑P∈GPA_G=|G|^{-1}\sum_{P\in G}PAG​=∣G∣−1∑P∈G​P, as GGG ranges over all subsets of P\mathcal PP that contain the identity, are closed under multiplication and conjugate transpose, and satisfy: whenever P∈GP\in GP∈G and P=cIP=cIP=cI for a complex number ccc, then c=1c=1c=1. All inverses in these matrix scalings are complex inverses, with 0−1=00^{-1}=00−1=0; duplicate resulting matrices occur only once in the finite set. The parameters include d=1d=1d=1 and n=0n=0n=0; when n=0n=0n=0, HHH is a singleton and the sums defining the exponents are empty.

QAlgorithms.Papers.Independent.Extend50.P30.momentNormalization

For arbitrary natural numbers d,n,td,n,td,n,t, including d=0d=0d=0, this defines the natural number

dn∏k=0max⁡(t−1,0)−1(dk+dn).d^n\prod_{k=0}^{\max(t-1,0)-1}(d^k+d^n).dnk=0∏max(t−1,0)−1​(dk+dn).

The index set is empty when t=0t=0t=0 or t=1t=1t=1, so in either case the value is dnd^ndn. All powers are natural number powers, including the convention 00=10^0=100=1.

QAlgorithms.Papers.Independent.Extend50.P30.pauliAverageProjector

For natural numbers d,nd,nd,n with d≠0d\ne0d=0, and any finite set GGG of complex matrices indexed by functions {0,…,n−1}→Z/dZ\{0,\ldots,n-1\}\to\mathbb Z/d\mathbb Z{0,…,n−1}→Z/dZ, this defines

1∣G∣∑P∈GP,\frac{1}{|G|}\sum_{P\in G}P,∣G∣1​P∈G∑​P,

where the inverse of ∣G∣|G|∣G∣ is taken in C\mathbb CC. No group or stabilizer condition on GGG is assumed. If GGG is empty, the sum and the inverse of its cardinality are both zero, so the result is the zero matrix. The cases d=1d=1d=1 and n=0n=0n=0 are allowed.

QAlgorithms.Papers.Independent.Extend50.P30.permutationOperator

For natural numbers d≠0,n,td\ne0,n,td=0,n,t and a permutation ppp of {0,…,t−1}\{0,\ldots,t-1\}{0,…,t−1}, this defines a complex matrix on HtH^tHt, where H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n, by

Pp(x,y)={1,xi=yp−1(i) for every i,0,otherwise.P_p(x,y)= \begin{cases} 1,&x_i=y_{p^{-1}(i)}\text{ for every }i,\\ 0,&\text{otherwise}. \end{cases}Pp​(x,y)={1,0,​xi​=yp−1(i)​ for every i,otherwise.​

In particular, its action on the basis vector indexed by yyy produces the basis vector indexed by y∘p−1y\circ p^{-1}y∘p−1. Both t=0t=0t=0 and n=0n=0n=0 are allowed; in either case the configuration set is a singleton and the matrix is the scalar 111.

QAlgorithms.Papers.Independent.Extend50.P30.perpendicular

For natural numbers d,td,td,t and a submodule NNN of V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, this defines the submodule

N⊥={x∈V: ∑i=0t−1xiyi=0 in Z/dZ for every y∈N}.N^\perp=\left\{x\in V:\ \sum_{i=0}^{t-1}x_i y_i=0\text{ in }\mathbb Z/d\mathbb Z\text{ for every }y\in N\right\}.N⊥={x∈V: i=0∑t−1​xi​yi​=0 in Z/dZ for every y∈N}.

There is no assumption that d≠0d\ne0d=0; when d=0d=0d=0, the coefficient ring is Z\mathbb ZZ. When t=0t=0t=0, the sum is empty and N⊥=VN^\perp=VN⊥=V.

QAlgorithms.Papers.Independent.Extend50.P30.phaseModulus

For every natural number ddd, this defines the natural number 2d2d2d when ddd is even, and ddd when ddd is odd. In particular, its value at d=0d=0d=0 is 000.

QAlgorithms.Papers.Independent.Extend50.P30.phasePointOperator

For natural numbers d≠0d\ne0d=0 and nnn, put V=(Z/dZ)nV=(\mathbb Z/d\mathbb Z)^nV=(Z/dZ)n, ω=exp⁡(2πi/d)\omega=\exp(2\pi i/d)ω=exp(2πi/d), and τ=(−1)dexp⁡(πi/d)\tau=(-1)^d\exp(\pi i/d)τ=(−1)dexp(πi/d). For y=(u,v)∈V×Vy=(u,v)\in V\times Vy=(u,v)∈V×V, define the matrix WyW_yWy​ by

Wy(a,b)={τ−∑jrep⁡(uj)rep⁡(vj)ω∑jrep⁡(uj)rep⁡(aj),a=b+v,0,otherwise.W_y(a,b)= \begin{cases} \tau^{-\sum_j\operatorname{rep}(u_j)\operatorname{rep}(v_j)} \omega^{\sum_j\operatorname{rep}(u_j)\operatorname{rep}(a_j)},&a=b+v,\\ 0,&\text{otherwise}. \end{cases}Wy​(a,b)={τ−∑j​rep(uj​)rep(vj​)ω∑j​rep(uj​)rep(aj​),0,​a=b+v,otherwise.​

For x=(r,s)∈V×Vx=(r,s)\in V\times Vx=(r,s)∈V×V, the definition gives the matrix Ax=d−n∑y=(u,v)∈V×Vω−rep⁡(∑j(rjvj−sjuj))Wy†A_x=d^{-n}\sum_{y=(u,v)\in V\times V}\omega^{-\operatorname{rep}(\sum_j(r_jv_j-s_ju_j))}W_y^\daggerAx​=d−n∑y=(u,v)∈V×V​ω−rep(∑j​(rj​vj​−sj​uj​))Wy†​, where the bracket is computed in Z/dZ\mathbb Z/d\mathbb ZZ/dZ, its representative lies in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, and †\dagger† denotes conjugate transpose. Negative exponents are integer powers. No primality or oddness assumption on ddd is made; d=1d=1d=1 and n=0n=0n=0 are included.

QAlgorithms.Papers.Independent.Extend50.P30.pieceIndex

This defines a function from {0,1,2,3,4,5}\{0,1,2,3,4,5\}{0,1,2,3,4,5} to {0,1,2,3,4}\{0,1,2,3,4\}{0,1,2,3,4}, sending 0,1,2,30,1,2,30,1,2,3 to themselves and sending both 444 and 555 to 444.

QAlgorithms.Papers.Independent.Extend50.P30.positivePseudoInverse

For any finite type III equipped with decidable equality and any complex matrix AAA indexed by III, this defines f(A)f(A)f(A) through the real continuous functional calculus, where f(x)=x−1f(x)=x^{-1}f(x)=x−1 and 0−1=00^{-1}=00−1=0. For Hermitian AAA, this replaces each nonzero eigenvalue by its reciprocal and leaves zero eigenvalues at zero. The definition imposes no Hermitian, positivity, or invertibility hypothesis on AAA. The index type III may be empty.

QAlgorithms.Papers.Independent.Extend50.P30.qubitTest

For every natural number nnn, let H=(Z/2Z)nH=(\mathbb Z/2\mathbb Z)^nH=(Z/2Z)n. The declaration defines a complex matrix on six ordered copies of HHH, with entries

T(u,v)=12∑a,x∈H×HPx((u0,u1),(v0,v1))Px+a((u2,u3),(v2,v3))[1(u4,u5)=(v4,v5)+Wa(u4,v4)Wa(v5,u5)‾],u,v∈H6.T(u,v)=\frac12\sum_{a,x\in H\times H} P_x\bigl((u_0,u_1),(v_0,v_1)\bigr) P_{x+a}\bigl((u_2,u_3),(v_2,v_3)\bigr) \left[ \mathbf1_{(u_4,u_5)=(v_4,v_5)} +W_a(u_4,v_4)\overline{W_a(v_5,u_5)} \right], \qquad u,v\in H^6.T(u,v)=21​a,x∈H×H∑​Px​((u0​,u1​),(v0​,v1​))Px+a​((u2​,u3​),(v2​,v3​))[1(u4​,u5​)=(v4​,v5​)​+Wa​(u4​,v4​)Wa​(v5​,u5​)​],u,v∈H6.

Here 1\mathbf11 is 111 when its condition holds and 000 otherwise, Px((r,s),(r′,s′))=2−nWx(r,s)Wx(r′,s′)‾P_x((r,s),(r',s'))=2^{-n}W_x(r,s)\overline{W_x(r',s')}Px​((r,s),(r′,s′))=2−nWx​(r,s)Wx​(r′,s′)​, and, for x=(p,q)x=(p,q)x=(p,q), Wx(r,s)=i−∑jpˉjqˉj(−1)∑jpˉjrˉjW_x(r,s)=i^{-\sum_j\bar p_j\bar q_j}(-1)^{\sum_j\bar p_j\bar r_j}Wx​(r,s)=i−∑j​pˉ​j​qˉ​j​(−1)∑j​pˉ​j​rˉj​ when r=s+qr=s+qr=s+q, and 000 otherwise. Bars denote representatives 0,10,10,1, and all register and phase-space addition is modulo 222. In particular, the conjugated entry in brackets is the (u5,v5)(u_5,v_5)(u5​,v5​)-entry of Wa†W_a^\daggerWa†​. This definition itself imposes no additional matrix property. It includes n=0n=0n=0, where the matrix has sole entry 111.

QAlgorithms.Papers.Independent.Extend50.P30.qubitVerificationUnitary

For every n∈Nn\in\mathbb Nn∈N, put R=(Z/2Z)nR=(\mathbb Z/2\mathbb Z)^nR=(Z/2Z)n and Z=R×RZ=R\times RZ=R×R. For z=(p,q)z=(p,q)z=(p,q), define Wz(a,b)=i−∑jval⁡(pj)val⁡(qj)(−1)∑jval⁡(pj)val⁡(aj)W_z(a,b)=i^{-\sum_j\operatorname{val}(p_j)\operatorname{val}(q_j)}(-1)^{\sum_j\operatorname{val}(p_j)\operatorname{val}(a_j)}Wz​(a,b)=i−∑j​val(pj​)val(qj​)(−1)∑j​val(pj​)val(aj​) if a=b+qa=b+qa=b+q, and zero otherwise. Let Bz(a,b)=2−n/2Wz(a,b)B_z(a,b)=2^{-n/2}W_z(a,b)Bz​(a,b)=2−n/2Wz​(a,b), let PBz(u,w)=Bz(u)Bz(w)‾P_{B_z}(u,w)=B_z(u)\overline{B_z(w)}PBz​​(u,w)=Bz​(u)Bz​(w)​, and define

Da=∑z∈ZPBz⊗PBz+a,Tn=12∑a∈ZDa⊗(I+Wa⊗Wa†).D_a=\sum_{z\in Z}P_{B_z}\otimes P_{B_{z+a}}, \qquad T_n=\frac12\sum_{a\in Z}D_a\otimes(I+W_a\otimes W_a^\dagger).Da​=z∈Z∑​PBz​​⊗PBz+a​​,Tn​=21​a∈Z∑​Da​⊗(I+Wa​⊗Wa†​).

Here DaD_aDa​ acts on the first four copies and the parenthesized factor on the last two copies of RRR. The declaration defines the matrix 2Tn−I2T_n-I2Tn​−I on R6R^6R6. Its name does not itself impose or assert unitarity. For n=0n=0n=0, all registers are singletons and the defined matrix is 111.

QAlgorithms.Papers.Independent.Extend50.P30.quditInvolution

For natural numbers d,n,sd,n,sd,n,s with d≠0d\ne0d=0, let H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n, ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, and τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d. The declaration defines a complex matrix on 2s2s2s ordered copies of HHH by

J(u,v)=d−n∑x∈H×H∏j=02s−1{Wx(uj,vj),j is even,Wx(vj,uj)‾,j is odd,u,v∈H2s,J(u,v)=d^{-n}\sum_{x\in H\times H} \prod_{j=0}^{2s-1} \begin{cases} W_x(u_j,v_j),&j\text{ is even},\\ \overline{W_x(v_j,u_j)},&j\text{ is odd}, \end{cases} \qquad u,v\in H^{2s},J(u,v)=d−nx∈H×H∑​j=0∏2s−1​{Wx​(uj​,vj​),Wx​(vj​,uj​)​,​j is even,j is odd,​u,v∈H2s,

where, for x=(p,q)x=(p,q)x=(p,q),

Wx(a,b)={τ−∑ℓ=0n−1pˉℓqˉℓω∑ℓ=0n−1pˉℓaˉℓ,a=b+q,0,otherwise.W_x(a,b)= \begin{cases} \tau^{-\sum_{\ell=0}^{n-1}\bar p_\ell\bar q_\ell} \omega^{\sum_{\ell=0}^{n-1}\bar p_\ell\bar a_\ell},&a=b+q,\\ 0,&\text{otherwise}. \end{cases}Wx​(a,b)={τ−∑ℓ=0n−1​pˉ​ℓ​qˉ​ℓ​ω∑ℓ=0n−1​pˉ​ℓ​aˉℓ​,0,​a=b+q,otherwise.​

Bars denote standard nonnegative residue representatives and addition is modulo ddd. The scalar d−nd^{-n}d−n is interpreted in C\mathbb CC, and the odd-indexed factor is an entry of Wx†W_x^\daggerWx†​. No assertion that J2=IJ^2=IJ2=I is part of the definition. It includes d=1d=1d=1, n=0n=0n=0, and s=0s=0s=0; when s=0s=0s=0, the product is empty and the matrix is a singleton matrix with entry dnd^ndn, while n=0n=0n=0 gives a singleton matrix with entry 111.

QAlgorithms.Papers.Independent.Extend50.P30.quditTest

For natural numbers d,n,sd,n,sd,n,s with d≠0d\ne0d=0, put R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n. This defines the complex matrix QQQ, indexed by 2s2s2s-tuples u,v∈R2su,v\in R^{2s}u,v∈R2s, by

Qu,v=12(1u=v+d−n∑p,q∈R∏j=02s−1{(Wp,q)uj,vj,j even,(Wp,q†)uj,vj,j odd.).Q_{u,v}=\frac12\left(\mathbf1_{u=v} +d^{-n}\sum_{p,q\in R}\prod_{j=0}^{2s-1} \begin{cases} (W_{p,q})_{u_j,v_j},&j\text{ even},\\ (W_{p,q}^{\dagger})_{u_j,v_j},&j\text{ odd}. \end{cases}\right).Qu,v​=21​​1u=v​+d−np,q∈R∑​j=0∏2s−1​{(Wp,q​)uj​,vj​​,(Wp,q†​)uj​,vj​​,​j even,j odd.​​.

Here ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d, and, writing aˉk∈{0,…,d−1}\bar a_k\in\{0,\ldots,d-1\}aˉk​∈{0,…,d−1} for a residue’s canonical representative,

(Wp,q)a,b={τ−∑k=0n−1pˉkqˉkω∑k=0n−1pˉkaˉk,a=b+q,0,a≠b+q.(W_{p,q})_{a,b}= \begin{cases} \tau^{-\sum_{k=0}^{n-1}\bar p_k\bar q_k} \omega^{\sum_{k=0}^{n-1}\bar p_k\bar a_k},&a=b+q,\\ 0,&a\ne b+q. \end{cases}(Wp,q​)a,b​={τ−∑k=0n−1​pˉ​k​qˉ​k​ω∑k=0n−1​pˉ​k​aˉk​,0,​a=b+q,a=b+q.​

Addition in RRR is coordinatewise modulo ddd, and †\dagger† means conjugate transpose. Both n=0n=0n=0 and s=0s=0s=0 are included: empty products equal 111, and the corresponding tuple spaces are singletons; in particular, for s=0s=0s=0, QQQ is the one-entry matrix with entry (1+dn)/2(1+d^n)/2(1+dn)/2.

QAlgorithms.Papers.Independent.Extend50.P30.qutritAlternatingProjector

For every natural number nnn, put R=(Z/3Z)nR=(\mathbb Z/3\mathbb Z)^nR=(Z/3Z)n. This defines a complex matrix AAA indexed by triples x,y∈R3x,y\in R^3x,y∈R3 by

Ax,y=16∑π∈Sym⁡({0,1,2})sgn⁡(π) 1{xi=yπ−1(i) for every i},A_{x,y}=\frac16\sum_{\pi\in\operatorname{Sym}(\{0,1,2\})} \operatorname{sgn}(\pi)\, \mathbf1_{\{x_i=y_{\pi^{-1}(i)}\ \text{for every }i\}},Ax,y​=61​π∈Sym({0,1,2})∑​sgn(π)1{xi​=yπ−1(i)​ for every i}​,

where the coefficient is 111 when the permutation has sign 111, and −1-1−1 otherwise. The definition includes n=0n=0n=0, when every permutation matrix is the scalar matrix 111 and the resulting matrix is zero.

QAlgorithms.Papers.Independent.Extend50.P30.qutritCSSProjector

For every natural number nnn, put R=(Z/3Z)nR=(\mathbb Z/3\mathbb Z)^nR=(Z/3Z)n, let N⊆(Z/3Z)3N\subseteq(\mathbb Z/3\mathbb Z)^3N⊆(Z/3Z)3 be the linear span of the all-ones vector, and let ω=e2πi/3\omega=e^{2\pi i/3}ω=e2πi/3. For p,q,a,b∈(Z/3Z)3p,q,a,b\in(\mathbb Z/3\mathbb Z)^3p,q,a,b∈(Z/3Z)3, define Zp(a,b)=1{a=b}ω∑ipˉiaˉiZ_p(a,b)=\mathbf1_{\{a=b\}}\omega^{\sum_i\bar p_i\bar a_i}Zp​(a,b)=1{a=b}​ω∑i​pˉ​i​aˉi​ and Xq(a,b)=1{a=b+q}X_q(a,b)=\mathbf1_{\{a=b+q\}}Xq​(a,b)=1{a=b+q}​, with bars denoting representatives in {0,1,2}\{0,1,2\}{0,1,2}, and set C=∣N∣−2∑p∈N∑q∈NZpXqC=|N|^{-2}\sum_{p\in N}\sum_{q\in N}Z_pX_qC=∣N∣−2∑p∈N​∑q∈N​Zp​Xq​. This defines a complex matrix PPP indexed by triples x,y∈R3x,y\in R^3x,y∈R3 through

Px,y=∏j=0n−1C(x0(j),x1(j),x2(j)), (y0(j),y1(j),y2(j)).P_{x,y}=\prod_{j=0}^{n-1} C_{(x_0(j),x_1(j),x_2(j)),\,(y_0(j),y_1(j),y_2(j))}.Px,y​=j=0∏n−1​C(x0​(j),x1​(j),x2​(j)),(y0​(j),y1​(j),y2​(j))​.

Thus the local matrix uses the sum over all pairs of vectors in the span NNN, which has three elements. For n=0n=0n=0, the product is empty and every entry is 111, giving a one-dimensional scalar matrix.

QAlgorithms.Papers.Independent.Extend50.P30.qutritDefect

This defines the Z/3Z\mathbb Z/3\mathbb ZZ/3Z-submodule of (Z/3Z)3(\mathbb Z/3\mathbb Z)^3(Z/3Z)3 spanned by the constant vector (1,1,1)(1,1,1)(1,1,1), namely {c(1,1,1):c∈Z/3Z}\{c(1,1,1):c\in\mathbb Z/3\mathbb Z\}{c(1,1,1):c∈Z/3Z}.

QAlgorithms.Papers.Independent.Extend50.P30.qutritFourAnti

This defines the 4×44\times44×4 matrix over Z/3Z\mathbb Z/3\mathbb ZZ/3Z with every diagonal entry equal to 111 and every off-diagonal entry equal to 222:

(1222212222122221).\begin{pmatrix} 1&2&2&2\\ 2&1&2&2\\ 2&2&1&2\\ 2&2&2&1 \end{pmatrix}.​1222​2122​2212​2221​​.

QAlgorithms.Papers.Independent.Extend50.P30.qutritFourThird

This defines the Z/3Z\mathbb Z/3\mathbb ZZ/3Z-submodule of (Z/3Z)4×(Z/3Z)4(\mathbb Z/3\mathbb Z)^4\times(\mathbb Z/3\mathbb Z)^4(Z/3Z)4×(Z/3Z)4 spanned by the four pairs

((1,1,1,1),(1,1,1,1)),((0,1,2,0),(0,2,1,0)),((0,0,0,0),(1,1,1,0)),((1,1,1,0),(0,0,0,0)).\bigl((1,1,1,1),(1,1,1,1)\bigr),\quad \bigl((0,1,2,0),(0,2,1,0)\bigr),\quad \bigl((0,0,0,0),(1,1,1,0)\bigr),\quad \bigl((1,1,1,0),(0,0,0,0)\bigr).((1,1,1,1),(1,1,1,1)),((0,1,2,0),(0,2,1,0)),((0,0,0,0),(1,1,1,0)),((1,1,1,0),(0,0,0,0)).

Thus its elements are all linear combinations of these pairs with coefficients in Z/3Z\mathbb Z/3\mathbb ZZ/3Z.

QAlgorithms.Papers.Independent.Extend50.P30.qutritPiece

For every natural number nnn and every i∈{0,1,2,3,4}i\in\{0,1,2,3,4\}i∈{0,1,2,3,4}, this defines a complex linear subspace of all functions Hn→CH_n\to\mathbb CHn​→C, where Hn=((Z/3Z)n)3H_n=((\mathbb Z/3\mathbb Z)^n)^3Hn​=((Z/3Z)n)3. Define Πp(x,y)=1{xj=yp−1(j) ∀j}\Pi_p(x,y)=\mathbf1_{\{x_j=y_{p^{-1}(j)}\ \forall j\}}Πp​(x,y)=1{xj​=yp−1(j)​ ∀j}​ for permutations ppp of three positions, S=16∑pΠpS=\frac16\sum_p\Pi_pS=61​∑p​Πp​, and A=16∑psgn⁡(p)ΠpA=\frac16\sum_p\operatorname{sgn}(p)\Pi_pA=61​∑p​sgn(p)Πp​. With ω=e2πi/3\omega=e^{2\pi i/3}ω=e2πi/3 and bars denoting representatives in {0,1,2}\{0,1,2\}{0,1,2}, define

C(u,v)=19∑a,b∈Z/3Z1{u=v+b(1,1,1)}ωaˉ(uˉ0+uˉ1+uˉ2),P(x,y)=∏j=0n−1C((x0j,x1j,x2j),(y0j,y1j,y2j)).C(u,v)=\frac19\sum_{a,b\in\mathbb Z/3\mathbb Z} \mathbf1_{\{u=v+b(1,1,1)\}}\omega^{\bar a(\bar u_0+\bar u_1+\bar u_2)},\qquad P(x,y)=\prod_{j=0}^{n-1}C((x_{0j},x_{1j},x_{2j}),(y_{0j},y_{1j},y_{2j})).C(u,v)=91​a,b∈Z/3Z∑​1{u=v+b(1,1,1)}​ωaˉ(uˉ0​+uˉ1​+uˉ2​),P(x,y)=j=0∏n−1​C((x0j​,x1j​,x2j​),(y0j​,y1j​,y2j​)).

Let P0=SPSP_0=SPSP0​=SPS, P1=S−SPSP_1=S-SPSP1​=S−SPS, P2=APAP_2=APAP2​=APA, P3=A−APAP_3=A-APAP3​=A−APA, and P4=12(I+Π(01))−SP_4=\frac12(I+\Pi_{(01)})-SP4​=21​(I+Π(01)​)−S. The defined subspace is exactly {Piv:v∈CHn}\{P_i v:v\in\mathbb C^{H_n}\}{Pi​v:v∈CHn​}, where (Piv)(x)=∑y∈HnPi(x,y)v(y)(P_i v)(x)=\sum_{y\in H_n}P_i(x,y)v(y)(Pi​v)(x)=∑y∈Hn​​Pi​(x,y)v(y); vectors in this range need not have norm 111. The definition includes n=0n=0n=0, with empty products equal to 111.

QAlgorithms.Papers.Independent.Extend50.P30.qutritPieceProjector

For every natural number nnn, let Hn=((Z/3Z)n)3H_n=((\mathbb Z/3\mathbb Z)^n)^3Hn​=((Z/3Z)n)3, the set indexing three copies of an nnn-qutrit register. For a permutation ppp of {0,1,2}\{0,1,2\}{0,1,2}, define the matrix Πp\Pi_pΠp​ by Πp(x,y)=1\Pi_p(x,y)=1Πp​(x,y)=1 when xi=yp−1(i)x_i=y_{p^{-1}(i)}xi​=yp−1(i)​ for all iii, and 000 otherwise. Put S=16∑pΠpS=\frac16\sum_p\Pi_pS=61​∑p​Πp​ and A=16∑psgn⁡(p)ΠpA=\frac16\sum_p\operatorname{sgn}(p)\Pi_pA=61​∑p​sgn(p)Πp​. To specify the third matrix, write ω=e2πi/3\omega=e^{2\pi i/3}ω=e2πi/3, let aˉ∈{0,1,2}\bar a\in\{0,1,2\}aˉ∈{0,1,2} denote the natural-number representative of a∈Z/3Za\in\mathbb Z/3\mathbb Za∈Z/3Z, and, for u,v∈(Z/3Z)3u,v\in(\mathbb Z/3\mathbb Z)^3u,v∈(Z/3Z)3, put

C(u,v)=19∑a,b∈Z/3Z1{u=v+b(1,1,1)} ωaˉ(uˉ0+uˉ1+uˉ2),P(x,y)=∏j=0n−1C((x0j,x1j,x2j),(y0j,y1j,y2j)).C(u,v)=\frac19\sum_{a,b\in\mathbb Z/3\mathbb Z} \mathbf1_{\{u=v+b(1,1,1)\}}\, \omega^{\bar a(\bar u_0+\bar u_1+\bar u_2)},\qquad P(x,y)=\prod_{j=0}^{n-1}C((x_{0j},x_{1j},x_{2j}),(y_{0j},y_{1j},y_{2j})).C(u,v)=91​a,b∈Z/3Z∑​1{u=v+b(1,1,1)}​ωaˉ(uˉ0​+uˉ1​+uˉ2​),P(x,y)=j=0∏n−1​C((x0j​,x1j​,x2j​),(y0j​,y1j​,y2j​)).

The declaration defines a five-entry family of complex matrices on HnH_nHn​, indexed starting at 000, whose entries are respectively SPSSPSSPS, S−SPSS-SPSS−SPS, APAAPAAPA, A−APAA-APAA−APA, and 12(I+Π(01))−S\frac12(I+\Pi_{(01)})-S21​(I+Π(01)​)−S. This is a definition of matrices; it imposes no additional projector or irreducibility condition. It includes n=0n=0n=0, with the product defining PPP interpreted as the empty product 111.

QAlgorithms.Papers.Independent.Extend50.P30.qutritSymmetricProjector

For every natural number nnn, put R=(Z/3Z)nR=(\mathbb Z/3\mathbb Z)^nR=(Z/3Z)n. This defines a complex matrix SSS indexed by triples x,y∈R3x,y\in R^3x,y∈R3 by averaging the six permutations of the three copies:

Sx,y=16∑π∈Sym⁡({0,1,2})1{xi=yπ−1(i) for every i}.S_{x,y}=\frac16\sum_{\pi\in\operatorname{Sym}(\{0,1,2\})} \mathbf1_{\{x_i=y_{\pi^{-1}(i)}\ \text{for every }i\}}.Sx,y​=61​π∈Sym({0,1,2})∑​1{xi​=yπ−1(i)​ for every i}​.

The definition includes n=0n=0n=0, when RRR has one element and the resulting matrix is the scalar matrix 111.

QAlgorithms.Papers.Independent.Extend50.P30.realQubitTest

For every natural number nnn, let H=(Z/2Z)nH=(\mathbb Z/2\mathbb Z)^nH=(Z/2Z)n. The declaration defines a complex matrix on four ordered copies of HHH by

Tr(u,v)=12∑a∈H×HPa((u0,u1),(v0,v1))[1(u2,u3)=(v2,v3)+Wa(u2,v2)Wa(v3,u3)‾],u,v∈H4,T_{\mathrm r}(u,v)=\frac12\sum_{a\in H\times H} P_a\bigl((u_0,u_1),(v_0,v_1)\bigr) \left[ \mathbf1_{(u_2,u_3)=(v_2,v_3)} +W_a(u_2,v_2)\overline{W_a(v_3,u_3)} \right], \qquad u,v\in H^4,Tr​(u,v)=21​a∈H×H∑​Pa​((u0​,u1​),(v0​,v1​))[1(u2​,u3​)=(v2​,v3​)​+Wa​(u2​,v2​)Wa​(v3​,u3​)​],u,v∈H4,

where Pa((r,s),(r′,s′))=2−nWa(r,s)Wa(r′,s′)‾P_a((r,s),(r',s'))=2^{-n}W_a(r,s)\overline{W_a(r',s')}Pa​((r,s),(r′,s′))=2−nWa​(r,s)Wa​(r′,s′)​. For a=(p,q)a=(p,q)a=(p,q), Wa(r,s)=i−∑jpˉjqˉj(−1)∑jpˉjrˉjW_a(r,s)=i^{-\sum_j\bar p_j\bar q_j}(-1)^{\sum_j\bar p_j\bar r_j}Wa​(r,s)=i−∑j​pˉ​j​qˉ​j​(−1)∑j​pˉ​j​rˉj​ if r=s+qr=s+qr=s+q, and 000 otherwise, using residues pˉj,qˉj,rˉj∈{0,1}\bar p_j,\bar q_j,\bar r_j\in\{0,1\}pˉ​j​,qˉ​j​,rˉj​∈{0,1} and addition modulo 222. The indicator is 111 exactly when the two ordered pairs agree, and the conjugated entry is the corresponding entry of Wa†W_a^\daggerWa†​. No restriction to real vectors or real matrices is imposed by this declaration. The case n=0n=0n=0 is included and gives a matrix with sole entry 111.

QAlgorithms.Papers.Independent.Extend50.P30.relationOperator

For natural numbers d,td,td,t with d≠0d\ne0d=0 and any Z/dZ\mathbb Z/d\mathbb ZZ/dZ-submodule T⊆(Z/dZ)t×(Z/dZ)tT\subseteq(\mathbb Z/d\mathbb Z)^t\times(\mathbb Z/d\mathbb Z)^tT⊆(Z/dZ)t×(Z/dZ)t, this defines the complex matrix indexed by x,y∈(Z/dZ)tx,y\in(\mathbb Z/d\mathbb Z)^tx,y∈(Z/dZ)t with entries

(RT)x,y={1,(x,y)∈T,0,(x,y)∉T.(R_T)_{x,y}= \begin{cases} 1,&(x,y)\in T,\\ 0,&(x,y)\notin T. \end{cases}(RT​)x,y​={1,0,​(x,y)∈T,(x,y)∈/T.​

No additional quadratic, cardinality, or all-ones condition is required of TTT. For t=0t=0t=0, this is the one-entry matrix with entry 111.

QAlgorithms.Papers.Independent.Extend50.P30.repeatEffect

For natural numbers d≠0,n,k,rd\ne0,n,k,rd=0,n,k,r and any complex matrix AAA on HkH^kHk, where H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n, this defines a complex matrix on HkrH^{kr}Hkr by

B(x,y)=∏j=0r−1A((xjk+i)i=0k−1,(yjk+i)i=0k−1).B(x,y)=\prod_{j=0}^{r-1} A\bigl((x_{jk+i})_{i=0}^{k-1},(y_{jk+i})_{i=0}^{k-1}\bigr).B(x,y)=j=0∏r−1​A((xjk+i​)i=0k−1​,(yjk+i​)i=0k−1​).

Thus AAA is evaluated on each consecutive block of kkk copies, and the resulting entries are multiplied. There is no positivity or effect hypothesis on AAA. If r=0r=0r=0, the result is the scalar 111; if k=0k=0k=0, writing aaa for the sole entry of AAA, the result is the scalar ara^rar. The case n=0n=0n=0 is permitted.

QAlgorithms.Papers.Independent.Extend50.P30.residuePermutation

For any natural numbers d,td,td,t and any permutation ppp of {0,…,t−1}\{0,\ldots,t-1\}{0,…,t−1}, this defines the t×tt\times tt×t matrix over Z/dZ\mathbb Z/d\mathbb ZZ/dZ whose entry in row iii, column jjj, is 111 if i=p(j)i=p(j)i=p(j) and 000 otherwise. No nonzero-modulus hypothesis is imposed: d=0d=0d=0, for which the coefficient ring is Z\mathbb ZZ, and d=1d=1d=1, for which 0=10=10=1, are included. For t=0t=0t=0 this is the empty matrix.

QAlgorithms.Papers.Independent.Extend50.P30.residueQuadratic

For natural numbers d,td,td,t with d≠0d\ne0d=0 and a vector x∈(Z/dZ)tx\in(\mathbb Z/d\mathbb Z)^tx∈(Z/dZ)t, let D=2dD=2dD=2d if ddd is even and D=dD=dD=d otherwise. This defines the element

qd(x)=∑j=0t−1xˉj 2(modD)of Z/DZ,q_d(x)=\sum_{j=0}^{t-1}\bar x_j^{\,2}\pmod D \quad\text{of }\mathbb Z/D\mathbb Z,qd​(x)=j=0∑t−1​xˉj2​(modD)of Z/DZ,

where each xˉj\bar x_jxˉj​ is the canonical integer representative in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, first mapped into Z/DZ\mathbb Z/D\mathbb ZZ/DZ and then squared. For t=0t=0t=0, this is the empty sum, equal to zero.

QAlgorithms.Papers.Independent.Extend50.P30.rightDefect

For natural numbers d,td,td,t, put V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t. For any submodule TTT of V×VV\times VV×V, this defines the submodule {y∈V:(0,y)∈T}\{y\in V:(0,y)\in T\}{y∈V:(0,y)∈T}, namely the inverse image of TTT under the linear map y↦(0,y)y\mapsto(0,y)y↦(0,y). No nonzero-modulus assumption is imposed, so d=0d=0d=0, with coefficient ring Z\mathbb ZZ, is included; t=0t=0t=0 is also included.

QAlgorithms.Papers.Independent.Extend50.P30.rowVectorize

For any type III and any complex matrix AAA indexed by III, this defines a complex coordinate vector indexed by I×II\times II×I, whose coordinate at (i,j)(i,j)(i,j) is exactly A(i,j)A(i,j)A(i,j). No finiteness assumption on III, normalization factor, conjugation, or condition on AAA is included.

QAlgorithms.Papers.Independent.Extend50.P30.soundnessConstant

For arbitrary natural numbers d,sd,sd,s, this defines the real number

c(d,s)=1−(1−14d2)max⁡(s−1,0)2.c(d,s)=\frac{1-\left(1-\frac{1}{4d^2}\right)^{\max(s-1,0)}}{2}.c(d,s)=21−(1−4d21​)max(s−1,0)​.

The subtraction in the exponent is truncated natural-number subtraction, so c(d,0)=c(d,1)=0c(d,0)=c(d,1)=0c(d,0)=c(d,1)=0. There is no assumption that d≠0d\ne0d=0; real division by zero is defined as zero here, giving c(0,s)=0c(0,s)=0c(0,s)=0 for every sss.

QAlgorithms.Papers.Independent.Extend50.P30.stabilizerFrame

For natural numbers d,n,td,n,td,n,t with d≠0d\ne0d=0, put R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n, h=2dh=2dh=2d when ddd is even and h=dh=dh=d otherwise, ω=e2πi/d\omega=e^{2\pi\mathrm i/d}ω=e2πi/d, and τ=(−1)deπi/d\tau=(-1)^d e^{\pi\mathrm i/d}τ=(−1)deπi/d. Define Wa,b(u,v)=0W_{a,b}(u,v)=0Wa,b​(u,v)=0 unless u=v+bu=v+bu=v+b, and otherwise define Wa,b(u,v)=τ−∑jaˉjbˉjω∑jaˉjuˉjW_{a,b}(u,v)=\tau^{-\sum_j\bar a_j\bar b_j}\omega^{\sum_j\bar a_j\bar u_j}Wa,b​(u,v)=τ−∑j​aˉj​bˉj​ω∑j​aˉj​uˉj​, using representatives in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, and set P={τrWa,b:0≤r<h, a,b∈R}\mathcal P=\{\tau^rW_{a,b}:0\le r<h,\ a,b\in R\}P={τrWa,b​:0≤r<h, a,b∈R}. For every subset G⊆PG\subseteq\mathcal PG⊆P containing the identity, closed under multiplication and conjugate transpose, and satisfying A=cI, A∈G⇒c=1A=cI,\ A\in G\Rightarrow c=1A=cI, A∈G⇒c=1, form AG=∣G∣−1∑P∈GPA_G=|G|^{-1}\sum_{P\in G}PAG​=∣G∣−1∑P∈G​P and SG=(tr⁡AG)−1AGS_G=(\operatorname{tr}A_G)^{-1}A_GSG​=(trAG​)−1AG​, using zero for the inverse of zero. Let S\mathcal SS be the set of distinct resulting SGS_GSG​ that equal vv†vv^\daggervv† for some unit vector vvv. The defined matrix, indexed by x,y:{0,…,t−1}→Rx,y:\{0,\ldots,t-1\}\to Rx,y:{0,…,t−1}→R, has entries

∑S∈S∏i=0t−1S(xi,yi).\sum_{S\in\mathcal S}\prod_{i=0}^{t-1}S(x_i,y_i).S∈S∑​i=0∏t−1​S(xi​,yi​).

There is no division by ∣S∣|\mathcal S|∣S∣. For t=0t=0t=0, its sole entry is ∣S∣|\mathcal S|∣S∣; d=1d=1d=1 and n=0n=0n=0 are included.

QAlgorithms.Papers.Independent.Extend50.P30.stabilizerGram

For natural numbers d,n,td,n,td,n,t with d≠0d\ne0d=0, put R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n, h=2dh=2dh=2d when ddd is even and h=dh=dh=d otherwise, ω=e2πi/d\omega=e^{2\pi\mathrm i/d}ω=e2πi/d, and τ=(−1)deπi/d\tau=(-1)^d e^{\pi\mathrm i/d}τ=(−1)deπi/d. For a,b,u,v∈Ra,b,u,v\in Ra,b,u,v∈R, let Wa,b(u,v)W_{a,b}(u,v)Wa,b​(u,v) be zero unless u=v+bu=v+bu=v+b, and otherwise let it equal τ−∑jaˉjbˉjω∑jaˉjuˉj\tau^{-\sum_j\bar a_j\bar b_j}\omega^{\sum_j\bar a_j\bar u_j}τ−∑j​aˉj​bˉj​ω∑j​aˉj​uˉj​, using representatives aˉj,bˉj,uˉj∈{0,…,d−1}\bar a_j,\bar b_j,\bar u_j\in\{0,\ldots,d-1\}aˉj​,bˉj​,uˉj​∈{0,…,d−1}. Form the finite set P={τrWa,b:0≤r<h, a,b∈R}\mathcal P=\{\tau^rW_{a,b}:0\le r<h,\ a,b\in R\}P={τrWa,b​:0≤r<h, a,b∈R}. Consider every subset G⊆PG\subseteq\mathcal PG⊆P containing the identity, closed under multiplication and conjugate transpose, and satisfying A=cI, A∈G⇒c=1A=cI,\ A\in G\Rightarrow c=1A=cI, A∈G⇒c=1. For each such GGG, set AG=∣G∣−1∑P∈GPA_G=|G|^{-1}\sum_{P\in G}PAG​=∣G∣−1∑P∈G​P and SG=(tr⁡AG)−1AGS_G=(\operatorname{tr}A_G)^{-1}A_GSG​=(trAG​)−1AG​, with the complex inverse of zero defined as zero, and retain those SGS_GSG​ expressible as vv†v v^\daggervv† for a unit vector vvv. The resulting finite set S\mathcal SS, with duplicates removed, indexes both rows and columns of the defined matrix. For each S∈SS\in\mathcal SS∈S, choose a unit vector vSv_SvS​ with S=vSvS†S=v_Sv_S^\daggerS=vS​vS†​; the (S,T)(S,T)(S,T)-entry is ⟨vS,vT⟩t\langle v_S,v_T\rangle^t⟨vS​,vT​⟩t, with the complex inner product conjugate-linear in its first argument. These choices specify no particular phases. When t=0t=0t=0, every entry is 111, including when the inner product is zero; d=1d=1d=1 and n=0n=0n=0 are allowed.

QAlgorithms.Papers.Independent.Extend50.P30.stabilizerMixture

For natural numbers d,nd,nd,n with d≠0d\ne0d=0, any natural number sss, any finite set FFF of complex matrices indexed by R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n, and any real function ppp on all such matrices, this defines the matrix indexed by x,y:{0,…,s−1}→Rx,y:\{0,\ldots,s-1\}\to Rx,y:{0,…,s−1}→R with entries

∑S∈Fp(S)∏i=0s−1S(xi,yi).\sum_{S\in F}p(S)\prod_{i=0}^{s-1}S(x_i,y_i).S∈F∑​p(S)i=0∏s−1​S(xi​,yi​).

There is no requirement that the matrices in FFF be stabilizer matrices or density matrices, or that the weights be nonnegative or sum to one. An empty FFF gives the zero matrix; for s=0s=0s=0, the indexing set is a singleton and its sole matrix entry is ∑S∈Fp(S)\sum_{S\in F}p(S)∑S∈F​p(S).

QAlgorithms.Papers.Independent.Extend50.P30.stabilizerMoment

For natural numbers d≠0,n,td\ne0,n,td=0,n,t, let H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n. This defines a matrix on HtH^tHt by

Md,n,t(u,v)=1∣S∣∑S∈S∏i=0t−1S(ui,vi),M_{d,n,t}(u,v)=\frac1{|\mathcal S|}\sum_{S\in\mathcal S}\prod_{i=0}^{t-1}S(u_i,v_i),Md,n,t​(u,v)=∣S∣1​S∈S∑​i=0∏t−1​S(ui​,vi​),

where S\mathcal SS is the following finite set of distinct matrices. Put ω=e2πi/d\omega=e^{2\pi\mathrm i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi\mathrm i/d}τ=(−1)deπi/d, and D=2dD=2dD=2d if ddd is even, otherwise D=dD=dD=d. Define

W(p,q)(a,b)={τ−∑j[pj][qj]ω∑j[pj][aj],a=b+q,0,otherwise,P={τcWx:0≤c<D, x∈H×H},W_{(p,q)}(a,b)= \begin{cases} \tau^{-\sum_j[p_j][q_j]}\omega^{\sum_j[p_j][a_j]},&a=b+q,\\ 0,&\text{otherwise}, \end{cases} \qquad \mathcal P=\{\tau^cW_x:0\le c<D,\ x\in H\times H\},W(p,q)​(a,b)={τ−∑j​[pj​][qj​]ω∑j​[pj​][aj​],0,​a=b+q,otherwise,​P={τcWx​:0≤c<D, x∈H×H},

using least nonnegative residue representatives. For every subset G⊆PG\subseteq\mathcal PG⊆P that contains the identity, is closed under matrix multiplication and conjugate transpose, and satisfies A∈G, A=cI⇒c=1A\in G,\ A=cI\Rightarrow c=1A∈G, A=cI⇒c=1, form

PG=∣G∣−1∑A∈GA,SG=(tr⁡PG)−1PG.P_G=|G|^{-1}\sum_{A\in G}A,\qquad S_G=(\operatorname{tr}P_G)^{-1}P_G.PG​=∣G∣−1A∈G∑​A,SG​=(trPG​)−1PG​.

The set S\mathcal SS consists of those resulting SGS_GSG​ expressible as vv†vv^\daggervv† with ∥v∥=1\|v\|=1∥v∥=1. Repeated occurrences of the same matrix are counted once. Inverses are complex inverses, with 0−1=00^{-1}=00−1=0, so the displayed average would be zero if S\mathcal SS were empty. When t=0t=0t=0, each product in the sum is 111; when n=0n=0n=0, HHH is a singleton.

QAlgorithms.Papers.Independent.Extend50.P30.stabilizerOverlap

For natural numbers d,nd,nd,n with d≠0d\ne0d=0, any complex matrix SSS indexed by H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n, and any vector v∈CHv\in\mathbb C^Hv∈CH with the Euclidean norm, the declaration defines the real number

Re⁡tr⁡(Svv†)=Re⁡∑a,b∈HS(a,b)v(b)v(a)‾.\operatorname{Re}\operatorname{tr}(Svv^\dagger) =\operatorname{Re}\sum_{a,b\in H}S(a,b)v(b)\overline{v(a)}.Retr(Svv†)=Rea,b∈H∑​S(a,b)v(b)v(a)​.

There is no requirement that SSS belong to any designated finite set, be positive, or be an effect, and there is no normalization requirement on vvv. The parameters include d=1d=1d=1 and n=0n=0n=0; in the latter case HHH is a singleton.

QAlgorithms.Papers.Independent.Extend50.P30.stabilizerSpan

For natural numbers d≠0,n,td\ne0,n,td=0,n,t, let H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n. This defines the complex linear span in CHt\mathbb C^{H^t}CHt of the functions

u⟼∏i=0t−1v(ui),u\longmapsto\prod_{i=0}^{t-1}v(u_i),u⟼i=0∏t−1​v(ui​),

where v∈CHv\in\mathbb C^Hv∈CH has Euclidean norm 111 and vv†vv^\daggervv† belongs to the following finite set S\mathcal SS. Set ω=e2πi/d\omega=e^{2\pi\mathrm i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi\mathrm i/d}τ=(−1)deπi/d, and D=2dD=2dD=2d for even ddd, otherwise D=dD=dD=d. With least nonnegative residue representatives, define

W(p,q)(a,b)={τ−∑j[pj][qj]ω∑j[pj][aj],a=b+q,0,otherwise,P={τcWx:0≤c<D, x∈H×H}.W_{(p,q)}(a,b)= \begin{cases} \tau^{-\sum_j[p_j][q_j]}\omega^{\sum_j[p_j][a_j]},&a=b+q,\\ 0,&\text{otherwise}, \end{cases} \quad \mathcal P=\{\tau^cW_x:0\le c<D,\ x\in H\times H\}.W(p,q)​(a,b)={τ−∑j​[pj​][qj​]ω∑j​[pj​][aj​],0,​a=b+q,otherwise,​P={τcWx​:0≤c<D, x∈H×H}.

For each subset G⊆PG\subseteq\mathcal PG⊆P containing the identity, closed under multiplication and conjugate transpose, and satisfying A∈G, A=cI⇒c=1A\in G,\ A=cI\Rightarrow c=1A∈G, A=cI⇒c=1, form PG=∣G∣−1∑A∈GAP_G=|G|^{-1}\sum_{A\in G}APG​=∣G∣−1∑A∈G​A. The set S\mathcal SS consists of the distinct matrices (tr⁡PG)−1PG(\operatorname{tr}P_G)^{-1}P_G(trPG​)−1PG​ that equal ww†ww^\daggerww† for some unit vector www; complex inversion sends zero to zero. For t=0t=0t=0, each generating function has the single value 111; if there are no eligible vectors, the span is the zero subspace. The case n=0n=0n=0 is also included.

QAlgorithms.Papers.Independent.Extend50.P30.stabilizerVector

For natural numbers d,nd,nd,n with d≠0d\ne0d=0 and any complex matrix SSS indexed by R=(Z/dZ)nR=(\mathbb Z/d\mathbb Z)^nR=(Z/dZ)n, this returns a classically chosen vector v∈CRv\in\mathbb C^Rv∈CR satisfying ∥v∥=1\|v\|=1∥v∥=1 and S(a,b)=v(a)v(b)‾S(a,b)=v(a)\overline{v(b)}S(a,b)=v(a)v(b)​ for every a,ba,ba,b, if such a vector exists. If none exists, it returns the zero vector. The choice specifies no particular global phase, and SSS is not required to belong to any stabilizer set. The definition includes d=1d=1d=1 and n=0n=0n=0, when RRR is a singleton.

QAlgorithms.Papers.Independent.Extend50.P30.stabilizers

For natural numbers d,nd,nd,n with d≠0d\ne0d=0, let H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n, ω=e2πi/d\omega=e^{2\pi i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi i/d}τ=(−1)deπi/d, and h=2dh=2dh=2d if ddd is even and h=dh=dh=d otherwise. Define matrices on HHH by

Wp,q(a,b)={τ−∑jpˉjqˉjω∑jpˉjaˉj,a=b+q,0,otherwise,W_{p,q}(a,b)= \begin{cases} \tau^{-\sum_j\bar p_j\bar q_j}\omega^{\sum_j\bar p_j\bar a_j},&a=b+q,\\ 0,&\text{otherwise}, \end{cases}Wp,q​(a,b)={τ−∑j​pˉ​j​qˉ​j​ω∑j​pˉ​j​aˉj​,0,​a=b+q,otherwise,​

using the standard nonnegative residue representatives and coordinatewise modular addition, and put P={τcWp,q:0≤c<h, p,q∈H}\mathcal P=\{\tau^cW_{p,q}:0\le c<h,\ p,q\in H\}P={τcWp,q​:0≤c<h, p,q∈H}. The declaration defines the finite set consisting of those matrices A=(tr⁡AG)−1AGA=(\operatorname{tr}A_G)^{-1}A_GA=(trAG​)−1AG​, with AG=∣G∣−1∑P∈GPA_G=|G|^{-1}\sum_{P\in G}PAG​=∣G∣−1∑P∈G​P, for which there exists a vector v∈CHv\in\mathbb C^Hv∈CH of Euclidean norm 111 satisfying A(a,b)=v(a)v(b)‾A(a,b)=v(a)\overline{v(b)}A(a,b)=v(a)v(b)​ for every a,b∈Ha,b\in Ha,b∈H. Here GGG ranges over subsets of P\mathcal PP containing the identity, closed under multiplication and conjugate transpose, and containing no scalar matrix cIcIcI with c≠1c\ne1c=1. The construction uses complex inverses with 0−1=00^{-1}=00−1=0, and repeated matrices are identified. Both d=1d=1d=1 and n=0n=0n=0 are included; for n=0n=0n=0, HHH is a singleton and the exponent sums are empty.

QAlgorithms.Papers.Independent.Extend50.P30.standardS3

For every permutation ppp of {0,1,2}\{0,1,2\}{0,1,2}, this defines a complex 2×22\times22×2 matrix BpB_pBp​, with row and column indices i,j∈{0,1}i,j\in\{0,1\}i,j∈{0,1}, by

(Bp)ij={1,p−1(i)=j,−1,p−1(i)=2,0,otherwise.(B_p)_{ij}= \begin{cases} 1,&p^{-1}(i)=j,\\ -1,&p^{-1}(i)=2,\\ 0,&\text{otherwise}. \end{cases}(Bp​)ij​=⎩⎨⎧​1,−1,0,​p−1(i)=j,p−1(i)=2,otherwise.​

Thus a row is (1,0)(1,0)(1,0), (0,1)(0,1)(0,1), or (−1,−1)(-1,-1)(−1,−1) according as p−1(i)p^{-1}(i)p−1(i) is 000, 111, or 222.

QAlgorithms.Papers.Independent.Extend50.P30.sumNegativity

For natural numbers d≠0d\ne0d=0 and nnn, let V=(Z/dZ)nV=(\mathbb Z/d\mathbb Z)^nV=(Z/dZ)n and let v∈CVv\in\mathbb C^Vv∈CV be any complex Euclidean vector. Put ω=exp⁡(2πi/d)\omega=\exp(2\pi i/d)ω=exp(2πi/d), τ=(−1)dexp⁡(πi/d)\tau=(-1)^d\exp(\pi i/d)τ=(−1)dexp(πi/d), and define W(u,w)(a,b)=0W_{(u,w)}(a,b)=0W(u,w)​(a,b)=0 when a≠b+wa\ne b+wa=b+w, and otherwise W(u,w)(a,b)=τ−∑jrep⁡(uj)rep⁡(wj)ω∑jrep⁡(uj)rep⁡(aj)W_{(u,w)}(a,b)=\tau^{-\sum_j\operatorname{rep}(u_j)\operatorname{rep}(w_j)}\omega^{\sum_j\operatorname{rep}(u_j)\operatorname{rep}(a_j)}W(u,w)​(a,b)=τ−∑j​rep(uj​)rep(wj​)ω∑j​rep(uj​)rep(aj​). For x=(r,s)x=(r,s)x=(r,s), put Ax=d−n∑u,w∈Vω−rep⁡(∑j(rjwj−sjuj))W(u,w)†A_x=d^{-n}\sum_{u,w\in V}\omega^{-\operatorname{rep}(\sum_j(r_jw_j-s_ju_j))}W_{(u,w)}^\daggerAx​=d−n∑u,w∈V​ω−rep(∑j​(rj​wj​−sj​uj​))W(u,w)†​, using least nonnegative residues and integer powers. The definition gives

∑x∈V×Vmax⁡ ⁣{0, −d−nRe⁡tr⁡(Axvv†)},\sum_{x\in V\times V} \max\!\left\{0,\,-d^{-n}\operatorname{Re}\operatorname{tr}(A_xvv^\dagger)\right\},x∈V×V∑​max{0,−d−nRetr(Ax​vv†)},

the finite sum of the negative parts of these real values. No normalization of vvv, primality of ddd, or oddness of ddd is required. The cases n=0n=0n=0 and d=1d=1d=1 are included and give zero.

QAlgorithms.Papers.Independent.Extend50.P30.symplecticBracket

For arbitrary natural numbers d,nd,nd,n and pairs x=(p,q)x=(p,q)x=(p,q), y=(p′,q′)y=(p',q')y=(p′,q′) of functions {0,…,n−1}→Z/dZ\{0,\ldots,n-1\}\to\mathbb Z/d\mathbb Z{0,…,n−1}→Z/dZ, this defines the residue

∑j=0n−1(pjqj′−qjpj′)∈Z/dZ.\sum_{j=0}^{n-1}(p_jq'_j-q_jp'_j)\in\mathbb Z/d\mathbb Z.j=0∑n−1​(pj​qj′​−qj​pj′​)∈Z/dZ.

All operations occur in the residue ring. No nonzero assumption on ddd is required; at d=0d=0d=0, the operations are integer operations. For n=0n=0n=0, the empty sum is zero.

QAlgorithms.Papers.Independent.Extend50.P30.tensorRelation

For natural numbers d,t,nd,t,nd,t,n with d≠0d\ne0d=0 and any Z/dZ\mathbb Z/d\mathbb ZZ/dZ-submodule T⊆(Z/dZ)t×(Z/dZ)tT\subseteq(\mathbb Z/d\mathbb Z)^t\times(\mathbb Z/d\mathbb Z)^tT⊆(Z/dZ)t×(Z/dZ)t, this defines a complex matrix indexed by arrays x,y∈((Z/dZ)n)tx,y\in((\mathbb Z/d\mathbb Z)^n)^tx,y∈((Z/dZ)n)t through

(RT(n))x,y=∏j=0n−11((xi,j)i=0t−1,(yi,j)i=0t−1)∈T.(R_T^{(n)})_{x,y} =\prod_{j=0}^{n-1} \mathbf1_{\bigl((x_{i,j})_{i=0}^{t-1},(y_{i,j})_{i=0}^{t-1}\bigr)\in T}.(RT(n)​)x,y​=j=0∏n−1​1((xi,j​)i=0t−1​,(yi,j​)i=0t−1​)∈T​.

Thus an entry is 111 exactly when the indicated pair of ttt-coordinate columns belongs to TTT at every site jjj, and is 000 otherwise. No further condition on TTT is imposed. If n=0n=0n=0, the product is empty and the sole matrix entry is 111; if t=0t=0t=0, the sole entry is also 111.

QAlgorithms.Papers.Independent.Extend50.P30.threeCopyInvolution

For natural numbers d≠0d\ne0d=0 and nnn, let H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n. This defines a complex matrix on H3H^3H3 by

Td,n(u,v)=d−n∑x∈H×H∏i=02Ax(ui,vi).T_{d,n}(u,v)=d^{-n}\sum_{x\in H\times H}\prod_{i=0}^{2}A_x(u_i,v_i).Td,n​(u,v)=d−nx∈H×H∑​i=0∏2​Ax​(ui​,vi​).

Here, writing ω=e2πi/d\omega=e^{2\pi\mathrm i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi\mathrm i/d}τ=(−1)deπi/d, and [a]∈{0,…,d−1}[a]\in\{0,\ldots,d-1\}[a]∈{0,…,d−1} for a residue’s representative, define

W(p,q)(a,b)={τ−∑j[pj][qj]ω∑j[pj][aj],a=b+q,0,otherwise,[x,y]=∑j(x1,jy2,j−x2,jy1,j)∈Z/dZ,W_{(p,q)}(a,b)= \begin{cases} \tau^{-\sum_j[p_j][q_j]}\omega^{\sum_j[p_j][a_j]},&a=b+q,\\ 0,&\text{otherwise}, \end{cases} \qquad [x,y]=\sum_j(x_{1,j}y_{2,j}-x_{2,j}y_{1,j})\in\mathbb Z/d\mathbb Z,W(p,q)​(a,b)={τ−∑j​[pj​][qj​]ω∑j​[pj​][aj​],0,​a=b+q,otherwise,​[x,y]=j∑​(x1,j​y2,j​−x2,j​y1,j​)∈Z/dZ,

and

Ax=d−n∑y∈H×Hω− [ [x,y] ]Wy†,A_x=d^{-n}\sum_{y\in H\times H}\omega^{-\,[\, [x,y]\,]}W_y^\dagger,Ax​=d−ny∈H×H∑​ω−[[x,y]]Wy†​,

where the exponent uses the representative of the bracket, negated as an integer. All matrix scalars are interpreted in C\mathbb CC. The case n=0n=0n=0 is included: all registers and phase spaces are singletons, empty products equal 111, and the resulting matrix is the scalar 111. The definition itself imposes no equation asserting that Td,nT_{d,n}Td,n​ is an involution.

QAlgorithms.Papers.Independent.Extend50.P30.threeCopyTest

For natural numbers d≠0d\ne0d=0 and nnn, put H=(Z/dZ)nH=(\mathbb Z/d\mathbb Z)^nH=(Z/dZ)n. This defines the complex matrix on H3H^3H3

Ed,n(u,v)=12(1u=v+d−n∑x∈H×H∏i=02Ax(ui,vi)).E_{d,n}(u,v)=\frac12\left(\mathbf1_{u=v} +d^{-n}\sum_{x\in H\times H}\prod_{i=0}^{2}A_x(u_i,v_i)\right).Ed,n​(u,v)=21​(1u=v​+d−nx∈H×H∑​i=0∏2​Ax​(ui​,vi​)).

To specify the matrices AxA_xAx​, let ω=e2πi/d\omega=e^{2\pi\mathrm i/d}ω=e2πi/d, τ=(−1)deπi/d\tau=(-1)^d e^{\pi\mathrm i/d}τ=(−1)deπi/d, and let [a][a][a] denote a residue’s representative in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}. For y=(p,q)y=(p,q)y=(p,q), set

Wy(a,b)={τ−∑j[pj][qj]ω∑j[pj][aj],a=b+q,0,otherwise,Ax=d−n∑y∈H×Hω− [∑j(x1,jy2,j−x2,jy1,j)]Wy†.W_y(a,b)= \begin{cases} \tau^{-\sum_j[p_j][q_j]}\omega^{\sum_j[p_j][a_j]},&a=b+q,\\ 0,&\text{otherwise}, \end{cases} \quad A_x=d^{-n}\sum_{y\in H\times H} \omega^{-\,[\sum_j(x_{1,j}y_{2,j}-x_{2,j}y_{1,j})]}W_y^\dagger.Wy​(a,b)={τ−∑j​[pj​][qj​]ω∑j​[pj​][aj​],0,​a=b+q,otherwise,​Ax​=d−ny∈H×H∑​ω−[∑j​(x1,j​y2,j​−x2,j​y1,j​)]Wy†​.

The bracketed exponent is the representative modulo ddd, negated as an integer. This includes n=0n=0n=0, when the matrix is the scalar 111. No positivity or upper bound by the identity is part of this definition.

QAlgorithms.Papers.Independent.Extend50.P30.transposeRelation

For any natural numbers d,td,td,t and any Z/dZ\mathbb Z/d\mathbb ZZ/dZ-submodule T⊆V×VT\subseteq V\times VT⊆V×V, where V=(Z/dZ)tV=(\mathbb Z/d\mathbb Z)^tV=(Z/dZ)t, this defines the submodule

{(x,y)∈V×V:(y,x)∈T}.\{(x,y)\in V\times V:(y,x)\in T\}.{(x,y)∈V×V:(y,x)∈T}.

There is no nonzero-modulus hypothesis: d=0d=0d=0, interpreted using Z/0Z=Z\mathbb Z/0\mathbb Z=\mathbb ZZ/0Z=Z, is permitted, as is t=0t=0t=0.

QAlgorithms.Papers.Independent.Extend50.P30.unitaryChoiVector

For any natural number nnn and any complex matrix UUU indexed by R=(Z/2Z)nR=(\mathbb Z/2\mathbb Z)^nR=(Z/2Z)n, this defines a vector indexed by x∈(Z/2Z)n+nx\in(\mathbb Z/2\mathbb Z)^{n+n}x∈(Z/2Z)n+n with coordinate

2−n/2 U((x0,…,xn−1),(xn,…,x2n−1)).2^{-n/2}\,U\bigl((x_0,\ldots,x_{n-1}),(x_n,\ldots,x_{2n-1})\bigr).2−n/2U((x0​,…,xn−1​),(xn​,…,x2n−1​)).

No unitarity or other condition on UUU is assumed. For n=0n=0n=0, both register indexing sets are singletons, and the resulting vector's sole coordinate is UUU's sole entry.

QAlgorithms.Papers.Independent.Extend50.P30.unitaryDistance

For every natural number nnn and arbitrary complex matrices U,VU,VU,V indexed by Rn=(Z/2Z)nR_n=(\mathbb Z/2\mathbb Z)^nRn​=(Z/2Z)n, this defines the real number

 1−∣tr⁡(U†V)2n∣2 .\sqrt{\,1-\left|\frac{\operatorname{tr}(U^\dagger V)}{2^n}\right|^2\,}.1−​2ntr(U†V)​​2​.

There is no hypothesis that either matrix is unitary. The real square root used here equals zero when its argument is negative, so the definition also covers matrices for which the squared modulus exceeds one. It includes n=0n=0n=0, when RnR_nRn​ is a singleton and the denominator is 111.

QAlgorithms.Papers.Independent.Extend50.P30.weylBellVector

For every natural number nnn and every pair x=(p,q)∈H×Hx=(p,q)\in H\times Hx=(p,q)∈H×H, where H=(Z/2Z)nH=(\mathbb Z/2\mathbb Z)^nH=(Z/2Z)n, the declaration defines a Euclidean vector Bx∈CH×HB_x\in\mathbb C^{H\times H}Bx​∈CH×H by

Bx(a,b)=2−n/2Wx(a,b),Wx(a,b)={i−∑jpˉjqˉj(−1)∑jpˉjaˉj,a=b+q,0,otherwise.B_x(a,b)=2^{-n/2}W_x(a,b),\qquad W_x(a,b)= \begin{cases} i^{-\sum_j\bar p_j\bar q_j}(-1)^{\sum_j\bar p_j\bar a_j},&a=b+q,\\ 0,&\text{otherwise}. \end{cases}Bx​(a,b)=2−n/2Wx​(a,b),Wx​(a,b)={i−∑j​pˉ​j​qˉ​j​(−1)∑j​pˉ​j​aˉj​,0,​a=b+q,otherwise.​

Each barred coordinate is its representative 000 or 111, addition in HHH is modulo 222, and the exponent of iii is an integer. The factor 2−n/22^{-n/2}2−n/2 means 1/2n1/\sqrt{2^n}1/2n​. The definition includes n=0n=0n=0: both HHH and the phase space are singletons, the exponent sums are empty, and the vector’s sole coordinate is 111.

QAlgorithms.Papers.Independent.Extend50.P30.weylPhase

For every natural number ddd, this defines the complex number (−1)dexp⁡(πi/d)(-1)^d\exp(\pi i/d)(−1)dexp(πi/d), with complex division. The definition includes d=0d=0d=0, where division by zero gives zero and the resulting value is 111.

QAlgorithms.Papers.Independent.Extend50.P30.weylRoot

For every natural number ddd, this defines the complex number exp⁡(2πi/d)\exp(2\pi i/d)exp(2πi/d), with ddd regarded as a complex number in the division. The definition includes d=0d=0d=0: division by zero is defined to be zero, so the value there is 111.

Human review
  • Endorsed by Shuze Chen · Oct 29, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Gohan · Oct 29, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me