Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Definitions for Positive maps and trace polynomials from the symmetric group

Definition
QAlgorithms_Papers_Independent_Extend50_P13

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

prove2quantum

The objects the formalized statements of Positive maps and trace polynomials from the symmetric group (arXiv:2002.12887) are stated in. Each was checked against the paper by a blind read-back and a moderator.

  • tensorFamily: Entrywise finite tensor product in the original factor order (pp.6–7).
  • tensorMatrices: Homogeneous tensor product (pp.6–9).
  • append: Append the output coordinate after the input coordinates (Eq.32).
  • contractInputs: Partial-trace contraction of an arbitrary physical operator, Eq.57, p.14. The indices compute tr_inputs[P (X_1 ⊗ ... ⊗ X_r ⊗ I)].
  • linearContraction: Linearization on the entire joint-input algebra, the first equality of Eq.53, p.13. It is independent of any factorization of the input.
  • copositiveAmplification: Amplification of Z ↦ linearContraction P Z.transpose on a single, arbitrary ancilla (p.13). Transposition is on all input factors, not on the ancilla.
  • centralProjector: Fixed normalized central Young projector, Eq.31, p.9. The partition bound is k, independent of physical d; shapes taller than d remain included. The character is computed from the accepted regular Young ideal, never supplied as a PSD certificate.
  • polarizedMap: Definition 4, Eq.32, p.9, with its original normalization.
  • verticalOperators: Vertical tensor product followed by regrouping into input/output copies of the global register, Eq.45, p.12. No factorization of the input is assumed.
  • mixedMap: Mixed tensor product of the normalized maps, Eq.45–47, p.12.
  • rankOneOperator: Arbitrary, unnormalized rank-one operator |v><w|, Eq.33, p.10.
  • RealNonnegative: Scalar nonnegativity includes reality; discarding the imaginary part alone would not express the source's scalar inequalities (pp.5,14).
  • finiteMatrixElement: Matrix element, with conjugate linearity in the bra, Eq.33.
  • FullyBlockPositive: Full multipartite block positivity, tested on all unnormalized pure product vectors; by convexity this is exactly testing all fully separable states (p.14).
  • PositiveMap: Positivity on every tuple in the positive cone, pp.6,15.
  • DiagonalUnitaryInvariant: Diagonal-unitary invariance of the physical operator, pp.14–15.
  • ConjugationEquivariant: Simultaneous-conjugation equivariance for arbitrary complex inputs, p.6 and footnote 61 on p.28.
  • TraceMonomial: A multilinear trace monomial: one open word and finitely many traced words, using each variable exactly once in total, Eq.60, p.15. Empty open word is I.
  • matrixWord: Ordered matrix-word evaluation, Eq.27, p.9.
  • TracePolynomial: Finite complex linear combination of the actual multilinear trace monomials; raw syntax is not asserted to be unique (p.15).
  • evaluateTracePolynomial: Evaluation of the syntax; scalar trace-only terms multiply I (pp.6,15).
  • IsTracePolynomial: Evaluated trace-polynomial maps, modulo all evaluation identities (p.15).
  • fillSlot: Fill one retained slot with a and the other slots with s, Eq.25, p.8.
  • partialTraceSlot: Ordinary partial trace retaining slot q, pp.8–9.
  • cycleList: Cycle written starting immediately after q and ending at q, Eq.27, p.9. Mathlib omits fixed points, so they are supplied explicitly as singleton words.
  • cycleLeaders: Canonical cycle representatives: largest element in each cycle, including fixed points. Products of their scalar traces do not require a list ordering (p.9).
  • closedCycleExpression: Full trace-word product over all canonical cycles, Eq.30.
  • openCycleExpression: Traced closed cycles times the untraced word ending at the retained slot, Eq.28, pp.8–9. Untraced words are never cyclically rotated without changing q.
  • FullySeparableDensity: Fully separable density matrices, using arbitrary finite convex combinations of product density matrices; no bipartite-only relaxation (p.14).
  • OptimalWernerWitness: The paper's optimal Werner witness: invariant, block positive, detecting some entangled state, and saturating on a separable state (p.14).
  • Saturates: The paper's saturation convention for optimal positive maps (p.15).
  • joinSubsystemCoordinates: Join reduced and complement coordinates, preserving subsystem positions (Eqs.48–51, p.12).
  • embedSubsystemIdentity: Tensor identities into the complement in its original positions (p.12).
  • transposeOn: Partial transpose on a specified set of tensor factors, p.12.
  • shadow: Shadow operator, Eq.48, p.12.
  • anti: Anticommutator used in Eq.49 (p.12).
  • bilinearExpansion: Eq.51 with the forced correction (2/3)^n, rather than printed (3/2)^n. All products are formed on the reduced register before embedding (p.12).
  • bipartiteExpansion: Explicit bipartite Eq.49, p.12.
  • reductionPolynomial: Unscaled reduction polynomial, p.10, Example 8.
  • antisymmetricThree: Unscaled three-box antisymmetric polynomial, Eq.40, p.11.
  • mixedThree: Unscaled (2,1) polynomial, p.12.
  • witnessThree: Unscaled tripartite-witness polynomial, Eq.67, p.16.
  • finePolynomial: The four literal fine-grained inequalities in Eq.54, p.13.
  • fineProjector: Four normalized physical projectors, from the two decompositions above Eq.54. The sum of either pair is P_(2,1); each displayed polynomial is six times its map.
  • motzkin: Motzkin matrix polynomial, Eq.70, p.17.
  • motzkinSquares: Exact square decomposition printed in Eq.71, p.17.
  • homogeneousMotzkin: Homogenized Motzkin formula, Eq.72, p.17. No division by a trace.
  • tableFour31: Literal Table II entry for [3,1], with trace-only terms multiplying I (PDF p.25, table introduced p.24).
  • tableFour22: Literal Table II entry for [2,2] (PDF p.25).
  • tableFour211: Literal Table II entry for [2,1,1] (PDF p.25).
  • tableFour1111: Literal Table II entry for [1,1,1,1] (PDF p.25).
  • TableProperties: The properties asserted for each Table II map in the Appendix B introduction (PDF p.24): positive, dimension-dependent vanishing, equivariant, completely copositive, and tensor-stable, with positive dimensions and arbitrary ancillas.
  • GroupCoefficients: The finite group algebra in its full coefficient-function coordinates (pp.18–21). Coefficients are constant complex numbers, independent of all inputs.
  • coefficientProduct: Group-algebra multiplication in coefficient coordinates (pp.20–21).
  • groupOperator: Fixed linear extension of the physical permutation action, pp.8,20.
  • centralCoefficients: Character-computed central idempotent coefficients, Eq.A16 and Eq.31. These are independent of the physical dimension (pp.9,24).
  • InAntisymmetricIdeal: The actual sum of isotypic ideals for shapes with more than d rows, Eq.C2, p.26. It is constructed as the sum of the central-idempotent-generated ideals, not defined as the physical representation's kernel.
  • inputSlot: First r slots are matrix inputs, last t slots are marked tensor outputs (Eqs.81–85 and C3–C5, pp.18–19,26).
  • outputSlot: Output marker in the shared input/output register (pp.18–19,26).
  • joinSlots: Ordered concatenation of input and output coordinates (pp.18–19,26).
  • gPolynomial: C1 with its last variable still present, p.26.
  • hPolynomial: All-t-output contraction with identities in the output slots (C3–C5, p.26). The coordinate formula fixes the C5 alpha/beta, k−t argument and retained-slot typos.
  • TensorTraceMonomial: Multilinear tensor-trace monomial with t ordered output words and arbitrary closed input trace words. Every input label appears once overall. Empty output words give identity factors (pp.6,18–19,25–26).
  • TensorTracePolynomial: Formal finite tensor-trace polynomials, before taking evaluation identities (pp.6,18–19,25–26).
  • evaluateTensorTrace: Ordered tensor-word evaluation; closed words supply scalar ordinary traces (pp.6,18–19).
  • IsNoncommutativePolynomial: Noncommutative polynomial functions (Definition 29, p.25); evaluation is from actual words, not an arbitrary function with a desired output certificate.
  • IsTensorPolynomial: Pure tensor-polynomial functions are the no-closed-trace subcase of the formal tensor-word evaluation (Definition 29, p.25).
  • monomialPermutation: Concrete permutation for a tensor trace monomial: close each output word with its own output marker, close the trace words, then invert the disjoint cycle product to match the paper's T convention (pp.9,18–19).
  • tensorPermutationExpansion: Constant-coefficient group-algebra expansion beta constructed from formal words, not selected separately for each evaluated input (Eqs.81,84, pp.18–19).
  • PureTraceMonomial: Scalar pure trace monomial with each input label appearing once (pp.6,18).
  • PureTracePolynomial: Scalar multilinear trace polynomials, pp.6,18.
  • evaluatePureTrace: Scalar closed-word evaluation (pp.6,18).
  • outputPermutation: Lift a fixed output permutation by its disjoint cycles onto the output markers; singleton cycles are retained in the cycle convention (p.19).
  • pureTracePermutation: Permutation representing a scalar pure-trace monomial times a fixed output permutation. The input cycle factors are inverted, the output action is not (p.19).
  • pureTraceExpansion: Constant-coefficient gamma after expanding the scalar invariant into closed trace words. This replaces the input-dependent group-algebra shorthand in Eq.83 (PDF p.19), without making that shorthand a definition.
  • FullNontrivialCycle: Full-support single nontrivial cycle (Theorem 30(i)–(iii), p.26).
  • OutputMarkedCycles: Exactly t cycles with exactly one marked output apiece and no extra input-only cycles. Output actions are required nontrivial where printed in Theorem 30(iv)–(v), p.26; empty words remain allowed in the general syntax.
  • ClosedOutputAction: A closed prescribed output permutation, with input-only remaining cycles (Theorem 30(iv), C4, p.26).
Definition code
import Mathlib
import Definitions.Def_QAlgorithms_Defs_SchurWeylDecomposition
import Definitions.Def_QAlgorithms_Defs_Information
import Definitions.Def_QAlgorithms_Papers_Independent_Gap48_P38

noncomputable section

open scoped Matrix ComplexConjugate ComplexOrder

namespace QAlgorithms.Papers.Independent.Extend50.P13

attribute [local instance] Classical.propDecidable

/-- Entrywise finite tensor product in the original factor order (pp.6–7). -/
def tensorFamily {J : Type*} [Fintype J] (dims : J → ℕ)
    (X : (j : J) → (Matrix (Fin (dims j)) (Fin (dims j)) ℂ)) : (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ) :=
  fun a b => ∏ j, X j (a j) (b j)

/-- Homogeneous tensor product (pp.6–9). -/
def tensorMatrices {I : Type*} {r : ℕ} (X : Fin r → (Matrix I I ℂ)) : (Matrix (Fin r → I) (Fin r → I) ℂ) :=
  fun a b => ∏ i, X i (a i) (b i)

/-- Append the output coordinate after the input coordinates (Eq.32). -/
def append {I : Type*} {r : ℕ} (x : Fin r → I) (a : I) : Fin (r+1) → I :=
  Fin.lastCases a x

/-- Partial-trace contraction of an arbitrary physical operator, Eq.57, p.14.
The indices compute tr_inputs[P (X_1 ⊗ ... ⊗ X_r ⊗ I)]. -/
def contractInputs {I : Type*} [Fintype I] {r : ℕ}
    (P : (Matrix (Fin (r+1) → I) (Fin (r+1) → I) ℂ)) (X : Fin r → (Matrix I I ℂ)) : (Matrix I I ℂ) :=
  fun a b => ∑ x : Fin r → I, ∑ y : Fin r → I,
    P (append x a) (append y b) * ∏ i, X i (y i) (x i)

/-- Linearization on the entire joint-input algebra, the first equality of Eq.53,
p.13. It is independent of any factorization of the input. -/
def linearContraction {I : Type*} [Fintype I] {r : ℕ}
    (P : (Matrix (Fin (r+1) → I) (Fin (r+1) → I) ℂ)) (Z : (Matrix (Fin r → I) (Fin r → I) ℂ)) : (Matrix I I ℂ) :=
  fun a b => ∑ x : Fin r → I, ∑ y : Fin r → I,
    P (append x a) (append y b) * Z y x

/-- Amplification of Z ↦ linearContraction P Z.transpose on a single, arbitrary
ancilla (p.13). Transposition is on all input factors, not on the ancilla. -/
def copositiveAmplification {I : Type*} [Fintype I] {r : ℕ}
    (P : (Matrix (Fin (r+1) → I) (Fin (r+1) → I) ℂ)) (m : ℕ)
    (Z : (Matrix ((Fin r → I) × Fin m) ((Fin r → I) × Fin m) ℂ)) : (Matrix (I × Fin m) (I × Fin m) ℂ) :=
  fun a b => ∑ x : Fin r → I, ∑ y : Fin r → I,
    P (append x a.1) (append y b.1) * Z (x,a.2) (y,b.2)

/-- Fixed normalized central Young projector, Eq.31, p.9. The partition bound is
k, independent of physical d; shapes taller than d remain included. The character
is computed from the accepted regular Young ideal, never supplied as a PSD certificate. -/
def centralProjector {k : ℕ} (d : ℕ) (lambda : QAlgorithms.Schur.Partition k k) :
    (Matrix (Fin k → Fin d) (Fin k → Fin d) ℂ) :=
  (QAlgorithms.Schur.spechtCharacter lambda 1 / (k.factorial : ℂ)) •
    ∑ pi : Equiv.Perm (Fin k), QAlgorithms.Schur.spechtCharacter lambda pi⁻¹ •
      QAlgorithms.Schur.tensorPermutation d k pi

/-- Definition 4, Eq.32, p.9, with its original normalization. -/
def polarizedMap {d r : ℕ} (lambda : QAlgorithms.Schur.Partition (r+1) (r+1))
    (X : Fin r → (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  contractInputs (centralProjector d lambda) X

/-- Vertical tensor product followed by regrouping into input/output copies of
the global register, Eq.45, p.12. No factorization of the input is assumed. -/
def verticalOperators {n k : ℕ} (dims : Fin n → ℕ)
    (P : (j : Fin n) → (Matrix (Fin k → Fin (dims j)) (Fin k → Fin (dims j)) ℂ)) :
    (Matrix (Fin k → (∀ j, Fin (dims j))) (Fin k → (∀ j, Fin (dims j))) ℂ) :=
  fun a b => ∏ j, P j (fun i => a i j) (fun i => b i j)

/-- Mixed tensor product of the normalized maps, Eq.45–47, p.12. -/
def mixedMap {n r : ℕ} (dims : Fin n → ℕ)
    (lambda : Fin n → QAlgorithms.Schur.Partition (r+1) (r+1))
    (X : Fin r → (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ)) : (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ) :=
  contractInputs (verticalOperators dims (fun j => centralProjector (dims j) (lambda j))) X

/-- Arbitrary, unnormalized rank-one operator |v><w|, Eq.33, p.10. -/
def rankOneOperator {I : Type*} (v w : I → ℂ) : (Matrix I I ℂ) := fun a b => v a * conj (w b)

/-- Scalar nonnegativity includes reality; discarding the imaginary part alone
would not express the source's scalar inequalities (pp.5,14). -/
def RealNonnegative (z : ℂ) : Prop := z.im = 0 ∧ 0 ≤ z.re

/-- Matrix element, with conjugate linearity in the bra, Eq.33. -/
def finiteMatrixElement {I : Type*} [Fintype I] (w : I → ℂ) (A : (Matrix I I ℂ)) (v : I → ℂ) : ℂ :=
  ∑ a, ∑ b, conj (w a) * A a b * v b

/-- Full multipartite block positivity, tested on all unnormalized pure product
vectors; by convexity this is exactly testing all fully separable states (p.14). -/
def FullyBlockPositive {d k : ℕ} (P : (Matrix (Fin k → Fin d) (Fin k → Fin d) ℂ)) : Prop :=
  P.IsHermitian ∧ ∀ v : Fin k → (Fin d → ℂ),
    RealNonnegative (Matrix.trace (P * tensorMatrices (fun i => rankOneOperator (v i) (v i))))

/-- Positivity on every tuple in the positive cone, pp.6,15. -/
def PositiveMap {I : Type*} [Fintype I] {r : ℕ}
    (f : (Fin r → (Matrix I I ℂ)) → (Matrix I I ℂ)) : Prop :=
  ∀ X, (∀ i, (X i).PosSemidef) → (f X).PosSemidef

/-- Diagonal-unitary invariance of the physical operator, pp.14–15. -/
def DiagonalUnitaryInvariant {d k : ℕ} (P : (Matrix (Fin k → Fin d) (Fin k → Fin d) ℂ)) : Prop :=
  ∀ U : Matrix.unitaryGroup (Fin d) ℂ,
    tensorMatrices (fun _ : Fin k => (U : (Matrix (Fin d) (Fin d) ℂ))) * P *
      star (tensorMatrices (fun _ : Fin k => (U : (Matrix (Fin d) (Fin d) ℂ)))) = P

/-- Simultaneous-conjugation equivariance for arbitrary complex inputs, p.6 and
footnote 61 on p.28. -/
def ConjugationEquivariant {d r : ℕ} (f : (Fin r → (Matrix (Fin d) (Fin d) ℂ)) → (Matrix (Fin d) (Fin d) ℂ)) : Prop :=
  ∀ (U : Matrix.unitaryGroup (Fin d) ℂ) X,
    f (fun i => (U : (Matrix (Fin d) (Fin d) ℂ)) * X i * star (U : (Matrix (Fin d) (Fin d) ℂ))) =
      (U : (Matrix (Fin d) (Fin d) ℂ)) * f X * star (U : (Matrix (Fin d) (Fin d) ℂ))

/-- A multilinear trace monomial: one open word and finitely many traced words,
using each variable exactly once in total, Eq.60, p.15. Empty open word is I. -/
structure TraceMonomial (r : ℕ) where
  openWord : List (Fin r)
  closedWords : List (List (Fin r))
  closed_nonempty : ∀ w ∈ closedWords, w ≠ []
  labels_once : (openWord ++ closedWords.flatten).Perm (List.finRange r)

/-- Ordered matrix-word evaluation, Eq.27, p.9. -/
def matrixWord {I : Type*} [Fintype I] [DecidableEq I] {r : ℕ}
    (X : Fin r → (Matrix I I ℂ)) (w : List (Fin r)) : (Matrix I I ℂ) := (w.map X).prod

/-- Finite complex linear combination of the actual multilinear trace monomials;
raw syntax is not asserted to be unique (p.15). -/
abbrev TracePolynomial (r : ℕ) := List (ℂ × TraceMonomial r)

/-- Evaluation of the syntax; scalar trace-only terms multiply I (pp.6,15). -/
def evaluateTracePolynomial {I : Type*} [Fintype I] [DecidableEq I] {r : ℕ}
    (p : TracePolynomial r) (X : Fin r → (Matrix I I ℂ)) : (Matrix I I ℂ) :=
  (p.map fun t => (t.1 * (t.2.closedWords.map fun w => Matrix.trace (matrixWord X w)).prod) •
    matrixWord X t.2.openWord).sum

/-- Evaluated trace-polynomial maps, modulo all evaluation identities (p.15). -/
def IsTracePolynomial {d r : ℕ} (f : (Fin r → (Matrix (Fin d) (Fin d) ℂ)) → (Matrix (Fin d) (Fin d) ℂ)) : Prop :=
  ∃ p : TracePolynomial r, ∀ X, evaluateTracePolynomial p X = f X

/-- Fill one retained slot with a and the other slots with s, Eq.25, p.8. -/
def fillSlot {d k : ℕ} (q : Fin k) (a : Fin d)
    (s : {i : Fin k // i ≠ q} → Fin d) : Fin k → Fin d :=
  fun i => if h : i = q then a else s ⟨i,h⟩

/-- Ordinary partial trace retaining slot q, pp.8–9. -/
def partialTraceSlot {d k : ℕ} (q : Fin k) (M : (Matrix (Fin k → Fin d) (Fin k → Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  fun a b => ∑ s : {i : Fin k // i ≠ q} → Fin d, M (fillSlot q a s) (fillSlot q b s)

/-- Cycle written starting immediately after q and ending at q, Eq.27, p.9.
Mathlib omits fixed points, so they are supplied explicitly as singleton words. -/
def cycleList {k : ℕ} (pi : Equiv.Perm (Fin k)) (q : Fin k) : List (Fin k) :=
  if pi q = q then [q] else (pi.toList q).rotate 1

/-- Canonical cycle representatives: largest element in each cycle, including
fixed points. Products of their scalar traces do not require a list ordering (p.9). -/
def cycleLeaders {k : ℕ} (pi : Equiv.Perm (Fin k)) : Finset (Fin k) :=
  Finset.univ.filter fun q => ∀ j ∈ cycleList pi q, j ≤ q

/-- Full trace-word product over all canonical cycles, Eq.30. -/
def closedCycleExpression {d k : ℕ} (pi : Equiv.Perm (Fin k))
    (X : Fin k → (Matrix (Fin d) (Fin d) ℂ)) : ℂ :=
  ∏ q ∈ cycleLeaders pi, Matrix.trace (matrixWord X (cycleList pi q))

/-- Traced closed cycles times the untraced word ending at the retained slot,
Eq.28, pp.8–9. Untraced words are never cyclically rotated without changing q. -/
def openCycleExpression {d k : ℕ} (pi : Equiv.Perm (Fin k)) (q : Fin k)
    (X : Fin k → (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  (∏ c ∈ (cycleLeaders pi).filter (fun c => q ∉ cycleList pi c),
    Matrix.trace (matrixWord X (cycleList pi c))) • matrixWord X (cycleList pi q)

/-- Fully separable density matrices, using arbitrary finite convex combinations
of product density matrices; no bipartite-only relaxation (p.14). -/
def FullySeparableDensity {d k : ℕ} (rho : (Matrix (Fin k → Fin d) (Fin k → Fin d) ℂ)) : Prop :=
  ∃ m : ℕ, ∃ p : Fin m → ℝ, ∃ sigma : Fin m → Fin k → (Matrix (Fin d) (Fin d) ℂ),
    (∀ a, 0 ≤ p a) ∧ (∑ a, p a) = 1 ∧
    (∀ a j, QAlgorithms.IsDensityMatrix (sigma a j)) ∧
    rho = ∑ a, (p a : ℂ) • tensorMatrices (sigma a)

/-- The paper's optimal Werner witness: invariant, block positive, detecting
some entangled state, and saturating on a separable state (p.14). -/
def OptimalWernerWitness {d k : ℕ} (W : (Matrix (Fin k → Fin d) (Fin k → Fin d) ℂ)) : Prop :=
  DiagonalUnitaryInvariant W ∧ FullyBlockPositive W ∧
  (∃ rho, QAlgorithms.IsDensityMatrix rho ∧ ¬ FullySeparableDensity rho ∧ (Matrix.trace (W * rho)).re < 0) ∧
  (∃ rho, QAlgorithms.IsDensityMatrix rho ∧ FullySeparableDensity rho ∧ Matrix.trace (W * rho) = 0)

/-- The paper's saturation convention for optimal positive maps (p.15). -/
def Saturates {d r : ℕ} (f : (Fin r → (Matrix (Fin d) (Fin d) ℂ)) → (Matrix (Fin d) (Fin d) ℂ)) : Prop :=
  PositiveMap f ∧ ∃ X, (∀ i, (X i).PosSemidef ∧ X i ≠ 0) ∧
    ∃ v : Fin d → ℂ, v ≠ 0 ∧ (f X).mulVec v = 0

/-- Join reduced and complement coordinates, preserving subsystem positions
(Eqs.48–51, p.12). -/
def joinSubsystemCoordinates {J : Type*} (dims : J → ℕ) (S : Finset J)
    (a : (j : {j // j ∈ S}) → Fin (dims j.val))
    (e : (j : {j // j ∉ S}) → Fin (dims j.val)) : (∀ j, Fin (dims j)) :=
  fun j => if h : j ∈ S then a ⟨j,h⟩ else e ⟨j,h⟩

/-- Tensor identities into the complement in its original positions (p.12). -/
def embedSubsystemIdentity {J : Type*} [Fintype J] (dims : J → ℕ) (S : Finset J)
    (M : (Matrix ((j : {j // j ∈ S}) → Fin (dims j.val)) ((j : {j // j ∈ S}) → Fin (dims j.val)) ℂ)) : (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ) :=
  fun a b => if ∀ j, j ∉ S → a j = b j then
    M (fun j => a j.val) (fun j => b j.val) else 0

/-- Partial transpose on a specified set of tensor factors, p.12. -/
def transposeOn {J : Type*} (dims : J → ℕ) (T : J → Prop)
    (M : (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ)) : (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ) :=
  fun a b => M (fun j => if T j then b j else a j)
    (fun j => if T j then a j else b j)

/-- Shadow operator, Eq.48, p.12. -/
def shadow {n : ℕ} (dims : Fin n → ℕ) (T : Finset (Fin n))
    (rho : (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ)) : (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ) :=
  ∑ S : Finset (Fin n), ((-1 : ℂ) ^ (S ∩ T).card) • embedSubsystemIdentity dims S (QAlgorithms.Papers.Independent.Gap48.P38.subsystemReduction (fun j => Fin (dims j)) rho S)

/-- Anticommutator used in Eq.49 (p.12). -/
def anti {I : Type*} [Fintype I] (A B : (Matrix I I ℂ)) : (Matrix I I ℂ) := A*B+B*A

/-- Eq.51 with the forced correction (2/3)^n, rather than printed (3/2)^n.
All products are formed on the reduced register before embedding (p.12). -/
def bilinearExpansion {n : ℕ} (dims : Fin n → ℕ)
    (rho mu : (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ)) : (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ) :=
  ((2/3 : ℂ)^n) • ∑ S : Finset (Fin n), ∑ A ∈ S.powerset,
    ((-1/2 : ℂ)^S.card) • embedSubsystemIdentity dims S
      (transposeOn (fun j : {j // j ∈ S} => dims j.val) (fun j => j.val ∈ A)
        (transposeOn (fun j : {j // j ∈ S} => dims j.val) (fun j => j.val ∈ A)
          (QAlgorithms.Papers.Independent.Gap48.P38.subsystemReduction (fun j => Fin (dims j)) rho S) *
         transposeOn (fun j : {j // j ∈ S} => dims j.val) (fun j => j.val ∈ A)
          (QAlgorithms.Papers.Independent.Gap48.P38.subsystemReduction (fun j => Fin (dims j)) mu S)))

/-- Explicit bipartite Eq.49, p.12. -/
def bipartiteExpansion (dims : Fin 2 → ℕ) (rho mu : (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ)) :
    (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ) :=
  (1/9 : ℂ) • ((4 : ℂ) • (1 : (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ)) +
    transposeOn dims (fun j => j = 0)
      (transposeOn dims (fun j => j = 0) rho * transposeOn dims (fun j => j = 0) mu) +
    transposeOn dims (fun j => j = 1)
      (transposeOn dims (fun j => j = 1) rho * transposeOn dims (fun j => j = 1) mu) -
    (2 : ℂ) • (embedSubsystemIdentity dims {0} (anti (QAlgorithms.Papers.Independent.Gap48.P38.subsystemReduction (fun j => Fin (dims j)) rho {0}) (QAlgorithms.Papers.Independent.Gap48.P38.subsystemReduction (fun j => Fin (dims j)) mu {0})) +
      embedSubsystemIdentity dims {1} (anti (QAlgorithms.Papers.Independent.Gap48.P38.subsystemReduction (fun j => Fin (dims j)) rho {1}) (QAlgorithms.Papers.Independent.Gap48.P38.subsystemReduction (fun j => Fin (dims j)) mu {1}))) + anti rho mu)

/-- Unscaled reduction polynomial, p.10, Example 8. -/
def reductionPolynomial {d : ℕ} (X : (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  Matrix.trace X • (1 : (Matrix (Fin d) (Fin d) ℂ)) - X

/-- Unscaled three-box antisymmetric polynomial, Eq.40, p.11. -/
def antisymmetricThree {d : ℕ} (X Y : (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  (Matrix.trace X * Matrix.trace Y - Matrix.trace (X*Y)) • (1 : (Matrix (Fin d) (Fin d) ℂ)) -
    Matrix.trace X • Y - Matrix.trace Y • X + X*Y + Y*X

/-- Unscaled (2,1) polynomial, p.12. -/
def mixedThree {d : ℕ} (X Y : (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  (2 * Matrix.trace X * Matrix.trace Y) • (1 : (Matrix (Fin d) (Fin d) ℂ)) - X*Y-Y*X

/-- Unscaled tripartite-witness polynomial, Eq.67, p.16. -/
def witnessThree {d : ℕ} (X Y : (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  Matrix.trace (X*Y) • (1 : (Matrix (Fin d) (Fin d) ℂ)) + Matrix.trace X • Y +
    Matrix.trace Y • X-X*Y-Y*X

/-- The four literal fine-grained inequalities in Eq.54, p.13. -/
def finePolynomial {d : ℕ} (i : Fin 4) (X Y : (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  if i = 0 then
    (2*Matrix.trace X*Matrix.trace Y+2*Matrix.trace (X*Y)) • (1 : (Matrix (Fin d) (Fin d) ℂ)) -
      Matrix.trace X • Y-Matrix.trace Y • X-X*Y-Y*X
  else if i = 1 then
    (2*Matrix.trace X*Matrix.trace Y-2*Matrix.trace (X*Y)) • (1 : (Matrix (Fin d) (Fin d) ℂ)) +
      Matrix.trace X • Y+Matrix.trace Y • X-X*Y-Y*X
  else if i = 2 then
    (2*Matrix.trace X*Matrix.trace Y-Matrix.trace (X*Y)) • (1 : (Matrix (Fin d) (Fin d) ℂ)) +
      (2*Matrix.trace X) • Y-Matrix.trace Y • X-X*Y-Y*X
  else
    (2*Matrix.trace X*Matrix.trace Y+Matrix.trace (X*Y)) • (1 : (Matrix (Fin d) (Fin d) ℂ)) -
      (2*Matrix.trace X) • Y+Matrix.trace Y • X-X*Y-Y*X

/-- Four normalized physical projectors, from the two decompositions above Eq.54.
The sum of either pair is P_(2,1); each displayed polynomial is six times its map. -/
def fineProjector (d : ℕ) (i : Fin 4) : (Matrix (Fin 3 → Fin d) (Fin 3 → Fin d) ℂ) :=
  let T := QAlgorithms.Schur.tensorPermutation d 3
  let c : Equiv.Perm (Fin 3) := (List.finRange 3).formPerm
  let s : Equiv.Perm (Fin 3) := if i.val < 2 then Equiv.swap 0 1 else Equiv.swap 1 2
  let e : ℂ := if i.val % 2 = 0 then 1 else -1
  (1/6 : ℂ) • ((2 : ℂ) • (1 : (Matrix (Fin 3 → Fin d) (Fin 3 → Fin d) ℂ)) +
    e • ((3 : ℂ) • T s - (T (Equiv.swap 0 1)+T (Equiv.swap 0 2)+T (Equiv.swap 1 2))) -
    T c-T c⁻¹)

/-- Motzkin matrix polynomial, Eq.70, p.17. -/
def motzkin {d : ℕ} (A B : (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  A*B^4*A+A^2*B^2*A^2-(3 : ℂ) • (A*B^2*A)+1

/-- Exact square decomposition printed in Eq.71, p.17. -/
def motzkinSquares {d : ℕ} (A B : (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  (A^2-A)*B^2*(A^2-A) +
    (A*B^2+A^2-(2 : ℂ) • A)*(B^2*A+A^2-(2 : ℂ) • A) +
    (1-A)*(1+(2 : ℂ) • A-A^2)*(1-A)

/-- Homogenized Motzkin formula, Eq.72, p.17. No division by a trace. -/
def homogeneousMotzkin {d : ℕ} (A B : (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  (Matrix.trace A)^2 • (A*B^4*A) + (Matrix.trace B)^2 • (A^2*B^2*A^2) -
    (3*(Matrix.trace A)^2*(Matrix.trace B)^2) • (A*B^2*A) +
    ((Matrix.trace A)^4*(Matrix.trace B)^4) • (1 : (Matrix (Fin d) (Fin d) ℂ))

/-- Empty words and zero inputs retain their literal algebraic meanings. -/
example {d r : ℕ} (X : Fin r → (Matrix (Fin d) (Fin d) ℂ)) : matrixWord X [] = 1 := rfl

example {d : ℕ} (B : (Matrix (Fin d) (Fin d) ℂ)) : motzkin (0 : (Matrix (Fin d) (Fin d) ℂ)) B = 1 := by
  simp [motzkin]

example {d : ℕ} (B : (Matrix (Fin d) (Fin d) ℂ)) : homogeneousMotzkin (0 : (Matrix (Fin d) (Fin d) ℂ)) B = 0 := by
  simp [homogeneousMotzkin]

example {k : ℕ} (q : Fin k) : cycleList (1 : Equiv.Perm (Fin k)) q = [q] := by
  simp [cycleList]

/-- Literal Table II entry for [3,1], with trace-only terms multiplying I
(PDF p.25, table introduced p.24). -/
def tableFour31 {d : ℕ} (A B C : (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  (3*Matrix.trace A*Matrix.trace B*Matrix.trace C + Matrix.trace A*Matrix.trace (C*B) +
    Matrix.trace (B*A)*Matrix.trace C + Matrix.trace (C*A)*Matrix.trace B) •
      (1 : (Matrix (Fin d) (Fin d) ℂ)) +
    (Matrix.trace A*Matrix.trace B) • C + (Matrix.trace C*Matrix.trace A) • B -
    Matrix.trace (B*A) • C-C*B*A-B*A*C-C*A*B -
    Matrix.trace (C*A) • B-B*C*A-A*B*C +
    (Matrix.trace B*Matrix.trace C) • A-A*C*B-Matrix.trace (C*B) • A

/-- Literal Table II entry for [2,2] (PDF p.25). -/
def tableFour22 {d : ℕ} (A B C : (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  (2*Matrix.trace A*Matrix.trace B*Matrix.trace C-Matrix.trace (C*B*A)-
    Matrix.trace (B*C*A)) • (1 : (Matrix (Fin d) (Fin d) ℂ)) -
    Matrix.trace A • (C*B)-Matrix.trace A • (B*C) +
    (2*Matrix.trace (B*A)) • C-Matrix.trace C • (B*A)-Matrix.trace B • (C*A) +
    (2*Matrix.trace (C*A)) • B-Matrix.trace C • (A*B)-Matrix.trace B • (A*C) +
    (2*Matrix.trace (C*B)) • A

/-- Literal Table II entry for [2,1,1] (PDF p.25). -/
def tableFour211 {d : ℕ} (A B C : (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  (3*Matrix.trace A*Matrix.trace B*Matrix.trace C-Matrix.trace A*Matrix.trace (C*B)-
    Matrix.trace (B*A)*Matrix.trace C-Matrix.trace (C*A)*Matrix.trace B) •
      (1 : (Matrix (Fin d) (Fin d) ℂ)) -
    (Matrix.trace A*Matrix.trace B) • C-(Matrix.trace C*Matrix.trace A) • B -
    Matrix.trace (B*A) • C+C*B*A+B*A*C+C*A*B -
    Matrix.trace (C*A) • B+B*C*A+A*B*C -
    (Matrix.trace B*Matrix.trace C) • A+A*C*B-Matrix.trace (C*B) • A

/-- Literal Table II entry for [1,1,1,1] (PDF p.25). -/
def tableFour1111 {d : ℕ} (A B C : (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  (Matrix.trace A*Matrix.trace B*Matrix.trace C-Matrix.trace A*Matrix.trace (C*B)-
    Matrix.trace (B*A)*Matrix.trace C+Matrix.trace (C*B*A)+Matrix.trace (B*C*A)-
    Matrix.trace (C*A)*Matrix.trace B) • (1 : (Matrix (Fin d) (Fin d) ℂ)) -
    (Matrix.trace A*Matrix.trace B) • C + Matrix.trace A • (C*B) +
    Matrix.trace A • (B*C)-(Matrix.trace C*Matrix.trace A) • B +
    Matrix.trace (B*A) • C-C*B*A-B*A*C+Matrix.trace C • (B*A)-C*A*B +
    Matrix.trace B • (C*A)+Matrix.trace (C*A) • B-B*C*A-A*B*C +
    Matrix.trace C • (A*B)+Matrix.trace B • (A*C) -
    (Matrix.trace B*Matrix.trace C) • A-A*C*B+Matrix.trace (C*B) • A

/-- The properties asserted for each Table II map in the Appendix B introduction
(PDF p.24): positive, dimension-dependent vanishing, equivariant, completely
copositive, and tensor-stable, with positive dimensions and arbitrary ancillas. -/
def TableProperties {r : ℕ} (lambda : QAlgorithms.Schur.Partition (r+1) (r+1)) : Prop :=
  (∀ (d : ℕ), 0 < d →
    PositiveMap (polarizedMap (d := d) lambda) ∧
    (d < lambda.val.colLen 0 → ∀ X : Fin r → (Matrix (Fin d) (Fin d) ℂ), polarizedMap lambda X = 0) ∧
    ConjugationEquivariant (polarizedMap (d := d) lambda) ∧
    (∀ (m : ℕ), 0 < m → ∀ Z : (Matrix ((Fin r → Fin d) × Fin m) ((Fin r → Fin d) × Fin m) ℂ), Z.PosSemidef →
      (copositiveAmplification (centralProjector d lambda) m Z).PosSemidef)) ∧
  (∀ (n : ℕ) (dims : Fin n → ℕ), (∀ j, 0 < dims j) →
    PositiveMap (mixedMap dims (fun _ => lambda)))

/-- The finite group algebra in its full coefficient-function coordinates
(pp.18–21). Coefficients are constant complex numbers, independent of all inputs. -/
abbrev GroupCoefficients (k : ℕ) := Equiv.Perm (Fin k) → ℂ

/-- Group-algebra multiplication in coefficient coordinates (pp.20–21). -/
def coefficientProduct {k : ℕ} (a b : GroupCoefficients k) : GroupCoefficients k :=
  fun pi => ∑ sigma : Equiv.Perm (Fin k), a sigma*b (sigma⁻¹*pi)

/-- Fixed linear extension of the physical permutation action, pp.8,20. -/
def groupOperator {k : ℕ} (d : ℕ) (a : GroupCoefficients k) : (Matrix (Fin k → Fin d) (Fin k → Fin d) ℂ) :=
  ∑ pi : Equiv.Perm (Fin k), a pi • QAlgorithms.Schur.tensorPermutation d k pi

/-- Character-computed central idempotent coefficients, Eq.A16 and Eq.31.
These are independent of the physical dimension (pp.9,24). -/
def centralCoefficients {k : ℕ} (lambda : QAlgorithms.Schur.Partition k k) :
    GroupCoefficients k :=
  fun pi => QAlgorithms.Schur.spechtCharacter lambda 1 / (k.factorial : ℂ) *
    QAlgorithms.Schur.spechtCharacter lambda pi⁻¹

/-- The actual sum of isotypic ideals for shapes with more than d rows, Eq.C2,
p.26. It is constructed as the sum of the central-idempotent-generated ideals,
not defined as the physical representation's kernel. -/
def InAntisymmetricIdeal {k : ℕ} (d : ℕ) (a : GroupCoefficients k) : Prop :=
  ∃ b : QAlgorithms.Schur.Partition k k → GroupCoefficients k,
    ∀ pi, a pi = ∑ lambda : QAlgorithms.Schur.Partition k k,
      if d < lambda.val.colLen 0 then
        coefficientProduct (centralCoefficients lambda) (b lambda) pi else 0

/-- First r slots are matrix inputs, last t slots are marked tensor outputs
(Eqs.81–85 and C3–C5, pp.18–19,26). -/
def inputSlot {r t : ℕ} (i : Fin r) : Fin (r+t) := ⟨i.val, by omega⟩

/-- Output marker in the shared input/output register (pp.18–19,26). -/
def outputSlot {r t : ℕ} (j : Fin t) : Fin (r+t) := ⟨r+j.val, by omega⟩

/-- Ordered concatenation of input and output coordinates (pp.18–19,26). -/
def joinSlots {I : Type*} {r t : ℕ} (x : Fin r → I) (a : Fin t → I) : Fin (r+t) → I :=
  fun i => if h : i.val < r then x ⟨i.val,h⟩ else a ⟨i.val-r,by omega⟩

/-- C1 with its last variable still present, p.26. -/
def gPolynomial {d r : ℕ} (a : GroupCoefficients (r+1))
    (X : Fin (r+1) → (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin d) (Fin d) ℂ) :=
  partialTraceSlot (Fin.last r) (groupOperator d a * tensorMatrices X)

/-- All-t-output contraction with identities in the output slots (C3–C5, p.26).
The coordinate formula fixes the C5 alpha/beta, k−t argument and retained-slot typos. -/
def hPolynomial {d r t : ℕ} (a : GroupCoefficients (r+t))
    (X : Fin r → (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin t → Fin d) (Fin t → Fin d) ℂ) :=
  fun u v => ∑ x : Fin r → Fin d, ∑ y : Fin r → Fin d,
    groupOperator d a (joinSlots x u) (joinSlots y v) * ∏ i, X i (y i) (x i)

/-- Multilinear tensor-trace monomial with t ordered output words and arbitrary
closed input trace words. Every input label appears once overall. Empty output
words give identity factors (pp.6,18–19,25–26). -/
structure TensorTraceMonomial (r t : ℕ) where
  outputWords : Fin t → List (Fin r)
  closedWords : List (List (Fin r))
  closed_nonempty : ∀ w ∈ closedWords, w ≠ []
  labels_once : ((List.ofFn outputWords).flatten ++ closedWords.flatten).Perm (List.finRange r)

/-- Formal finite tensor-trace polynomials, before taking evaluation identities
(pp.6,18–19,25–26). -/
abbrev TensorTracePolynomial (r t : ℕ) := List (ℂ × TensorTraceMonomial r t)

/-- Ordered tensor-word evaluation; closed words supply scalar ordinary traces
(pp.6,18–19). -/
def evaluateTensorTrace {d r t : ℕ} (p : TensorTracePolynomial r t)
    (X : Fin r → (Matrix (Fin d) (Fin d) ℂ)) : (Matrix (Fin t → Fin d) (Fin t → Fin d) ℂ) :=
  (p.map fun term =>
    (term.1 * (term.2.closedWords.map fun w => Matrix.trace (matrixWord X w)).prod) •
      tensorMatrices (fun j => matrixWord X (term.2.outputWords j))).sum

/-- Noncommutative polynomial functions (Definition 29, p.25); evaluation is
from actual words, not an arbitrary function with a desired output certificate. -/
def IsNoncommutativePolynomial {d r : ℕ} (f : (Fin r → (Matrix (Fin d) (Fin d) ℂ)) → (Matrix (Fin d) (Fin d) ℂ)) : Prop :=
  ∃ p : List (ℂ × List (Fin r)),
    ∀ X, (p.map fun term => term.1 • matrixWord X term.2).sum = f X

/-- Pure tensor-polynomial functions are the no-closed-trace subcase of the
formal tensor-word evaluation (Definition 29, p.25). -/
def IsTensorPolynomial {d r t : ℕ}
    (f : (Fin r → (Matrix (Fin d) (Fin d) ℂ)) → (Matrix (Fin t → Fin d) (Fin t → Fin d) ℂ)) : Prop :=
  ∃ p : TensorTracePolynomial r t,
    (∀ term ∈ p, term.2.closedWords = []) ∧ ∀ X, evaluateTensorTrace p X = f X

/-- Concrete permutation for a tensor trace monomial: close each output word
with its own output marker, close the trace words, then invert the disjoint cycle
product to match the paper's T convention (pp.9,18–19). -/
def monomialPermutation {r t : ℕ} (term : TensorTraceMonomial r t) :
    Equiv.Perm (Fin (r+t)) :=
  (((List.ofFn fun j : Fin t =>
      ((term.outputWords j).map (inputSlot (t := t)) ++ [outputSlot (r := r) j]).formPerm).prod) *
    ((term.closedWords.map fun w => (w.map (inputSlot (t := t))).formPerm).prod))⁻¹

/-- Constant-coefficient group-algebra expansion beta constructed from formal
words, not selected separately for each evaluated input (Eqs.81,84, pp.18–19). -/
def tensorPermutationExpansion {r t : ℕ} (p : TensorTracePolynomial r t) :
    GroupCoefficients (r+t) :=
  fun pi => (p.map fun term => if pi = monomialPermutation term.2 then term.1 else 0).sum

/-- Scalar pure trace monomial with each input label appearing once (pp.6,18). -/
structure PureTraceMonomial (r : ℕ) where
  closedWords : List (List (Fin r))
  closed_nonempty : ∀ w ∈ closedWords, w ≠ []
  labels_once : closedWords.flatten.Perm (List.finRange r)

/-- Scalar multilinear trace polynomials, pp.6,18. -/
abbrev PureTracePolynomial (r : ℕ) := List (ℂ × PureTraceMonomial r)

/-- Scalar closed-word evaluation (pp.6,18). -/
def evaluatePureTrace {d r : ℕ} (p : PureTracePolynomial r)
    (X : Fin r → (Matrix (Fin d) (Fin d) ℂ)) : ℂ :=
  (p.map fun term => term.1 * (term.2.closedWords.map fun w => Matrix.trace (matrixWord X w)).prod).sum

/-- Lift a fixed output permutation by its disjoint cycles onto the output
markers; singleton cycles are retained in the cycle convention (p.19). -/
def outputPermutation {r t : ℕ} (rho : Equiv.Perm (Fin t)) : Equiv.Perm (Fin (r+t)) :=
  (List.ofFn fun j : Fin t => if j ∈ cycleLeaders rho then
    ((cycleList rho j).map (outputSlot (r := r))).formPerm else 1).prod

/-- Permutation representing a scalar pure-trace monomial times a fixed output
permutation. The input cycle factors are inverted, the output action is not (p.19). -/
def pureTracePermutation {r t : ℕ} (term : PureTraceMonomial r)
    (rho : Equiv.Perm (Fin t)) : Equiv.Perm (Fin (r+t)) :=
  ((term.closedWords.map fun w => (w.map (inputSlot (t := t))).formPerm).prod)⁻¹ *
    outputPermutation rho

/-- Constant-coefficient gamma after expanding the scalar invariant into closed
trace words. This replaces the input-dependent group-algebra shorthand in Eq.83
(PDF p.19), without making that shorthand a definition. -/
def pureTraceExpansion {r t : ℕ} (p : PureTracePolynomial r)
    (rho : Equiv.Perm (Fin t)) : GroupCoefficients (r+t) :=
  fun pi => (p.map fun term => if pi = pureTracePermutation term.2 rho then term.1 else 0).sum

/-- Full-support single nontrivial cycle (Theorem 30(i)–(iii), p.26). -/
def FullNontrivialCycle {k : ℕ} (pi : Equiv.Perm (Fin k)) : Prop :=
  (∀ i, pi i ≠ i) ∧ ∀ i j : Fin k, j ∈ cycleList pi i

/-- Exactly t cycles with exactly one marked output apiece and no extra
input-only cycles. Output actions are required nontrivial where printed in
Theorem 30(iv)–(v), p.26; empty words remain allowed in the general syntax. -/
def OutputMarkedCycles {r t : ℕ} (pi : Equiv.Perm (Fin (r+t))) : Prop :=
  (∀ j : Fin t, pi (outputSlot j) ≠ outputSlot j) ∧
  (∀ j l : Fin t, outputSlot l ∈ cycleList pi (outputSlot j) ↔ l = j) ∧
  (∀ i : Fin (r+t), ∃ j : Fin t, i ∈ cycleList pi (outputSlot j))

/-- A closed prescribed output permutation, with input-only remaining cycles
(Theorem 30(iv), C4, p.26). -/
def ClosedOutputAction {r t : ℕ} (rho : Equiv.Perm (Fin t))
    (pi : Equiv.Perm (Fin (r+t))) : Prop :=
  ∀ j : Fin t, pi (outputSlot j) = outputSlot (rho j)

/-- Empty formal sums evaluate to zero, without introducing phantom terms. -/
example {d r t : ℕ} (X : Fin r → (Matrix (Fin d) (Fin d) ℂ)) :
    evaluateTensorTrace ([] : TensorTracePolynomial r t) X = 0 := rfl

example {r t : ℕ} : tensorPermutationExpansion ([] : TensorTracePolynomial r t) = 0 := rfl

/-- Empty-family tensor conventions, pp.6,12. -/
example (dims : Fin 0 → ℕ) (X : (j : Fin 0) → (Matrix (Fin (dims j)) (Fin (dims j)) ℂ))
    (a b : (∀ j, Fin (dims j))) : tensorFamily dims X a b = 1 := by
  simp [tensorFamily]

example {k : ℕ} (dims : Fin 0 → ℕ)
    (P : (j : Fin 0) → (Matrix (Fin k → Fin (dims j)) (Fin k → Fin (dims j)) ℂ))
    (a b : Fin k → (∀ j, Fin (dims j))) : verticalOperators dims P a b = 1 := by
  simp [verticalOperators]

example {k : ℕ} (d : ℕ) : groupOperator d (0 : GroupCoefficients k) = 0 := by
  simp [groupOperator]

/-- Product-input specialization of the full linear extension, Eq.53, p.13. -/
example {I : Type*} [Fintype I] {r : ℕ}
    (P : (Matrix (Fin (r+1) → I) (Fin (r+1) → I) ℂ)) (X : Fin r → (Matrix I I ℂ)) :
    linearContraction P (tensorMatrices X) = contractInputs P X := rfl

example {I : Type*} [Fintype I] {r : ℕ} (X : Fin r → (Matrix I I ℂ)) :
    contractInputs (0 : (Matrix (Fin (r+1) → I) (Fin (r+1) → I) ℂ)) X = 0 := by
  ext a b
  simp [contractInputs]

example {J : Type*} (dims : J → ℕ) (M : (Matrix ((∀ j, Fin (dims j))) ((∀ j, Fin (dims j))) ℂ)) :
    transposeOn dims (fun _ => False) M = M := by
  ext a b
  simp [transposeOn]

end QAlgorithms.Papers.Independent.Extend50.P13
Source
Positive maps and trace polynomials from the symmetric group, arXiv:2002.12887v2, https://arxiv.org/abs/2002.12887v2
Read-back

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

QAlgorithms.Papers.Independent.Extend50.P13.ClosedOutputAction

For arbitrary natural numbers r,tr,tr,t, a permutation ρ\rhoρ of the ttt output labels, and a permutation π\piπ of all r+tr+tr+t slots, this predicate means exactly that

π(r+j)=r+ρ(j)(0≤j<t).\pi(r+j)=r+\rho(j)\qquad(0\le j<t).π(r+j)=r+ρ(j)(0≤j<t).

There are no additional conditions on the input slots beyond those imposed by π\piπ being a permutation; in particular, they necessarily permute among themselves. Fixed output slots are permitted whenever ρ\rhoρ fixes the corresponding labels. When t=0t=0t=0, the requirement is vacuous.

QAlgorithms.Papers.Independent.Extend50.P13.ConjugationEquivariant

For any natural numbers d,rd,rd,r and any function fff taking an rrr-indexed family of complex d×dd\times dd×d matrices to a complex d×dd\times dd×d matrix, this predicate means that, for every unitary complex d×dd\times dd×d matrix UUU and every input family XXX, f((UXiU†)i=0r−1)=Uf(X)U†f((UX_iU^\dagger)_{i=0}^{r-1})=Uf(X)U^\daggerf((UXi​U†)i=0r−1​)=Uf(X)U†, where †\dagger† denotes conjugate transpose. The inputs are arbitrary matrices, and no linearity or positivity is assumed. When r=0r=0r=0, this requires the output on the unique empty family to be invariant under every unitary conjugation. When d=0d=0d=0, the predicate holds automatically.

QAlgorithms.Papers.Independent.Extend50.P13.DiagonalUnitaryInvariant

For any natural numbers d,kd,kd,k and any complex matrix PPP indexed by functions {0,…,k−1}→{0,…,d−1}\{0,\ldots,k-1\}\to\{0,\ldots,d-1\}{0,…,k−1}→{0,…,d−1}, this predicate means that TUPTU†=PT_U P T_U^\dagger=PTU​PTU†​=P for every unitary complex d×dd\times dd×d matrix UUU, where (TU)xy=∏i=0k−1Uxiyi(T_U)_{xy}=\prod_{i=0}^{k-1}U_{x_i y_i}(TU​)xy​=∏i=0k−1​Uxi​yi​​ and †\dagger† denotes conjugate transpose. Thus the same arbitrary unitary is used in every factor. No Hermitian or positivity condition is imposed on PPP. For k=0k=0k=0, TU=[1]T_U=[1]TU​=[1], so every PPP satisfies the predicate; for d=0<kd=0<kd=0<k, PPP is the unique matrix on an empty index set and also satisfies it.

QAlgorithms.Papers.Independent.Extend50.P13.FullNontrivialCycle

For every natural number kkk and every permutation π\piπ of 0,…,k−10,\ldots,k-10,…,k−1, this predicate requires both that π(i)≠i\pi(i)\ne iπ(i)=i for every index iii, and that every index jjj belongs to the cycle list of every index iii. The cycle list at a fixed index is its singleton; at a nonfixed index it is the ordered list of that permutation cycle, rotated left by one position. Consequently, for k>0k>0k>0 the predicate says that all indices form one cycle and none is fixed, so it is impossible when k=1k=1k=1; when k=0k=0k=0, both requirements are vacuous and the predicate holds.

QAlgorithms.Papers.Independent.Extend50.P13.FullyBlockPositive

For any natural numbers d,kd,kd,k, including zero, and any complex matrix PPP indexed by the functions {0,…,k−1}→{0,…,d−1}\{0,\ldots,k-1\}\to\{0,\ldots,d-1\}{0,…,k−1}→{0,…,d−1}, this predicate means that PPP is Hermitian and that, for every family of vectors vi:{0,…,d−1}→Cv_i:\{0,\ldots,d-1\}\to\mathbb Cvi​:{0,…,d−1}→C, the complex number tr⁡(PTv)\operatorname{tr}(PT_v)tr(PTv​) has imaginary part zero and nonnegative real part, where (Tv)xy=∏i=0k−1vi(xi)vi(yi)‾(T_v)_{xy}=\prod_{i=0}^{k-1}v_i(x_i)\overline{v_i(y_i)}(Tv​)xy​=∏i=0k−1​vi​(xi​)vi​(yi​)​. The vectors may be zero and need not be normalized. If k=0k=0k=0, the index set contains one empty function, Tv=[1]T_v=[1]Tv​=[1], and the condition requires the sole entry of PPP to be real and nonnegative. If d=0<kd=0<kd=0<k, the matrix index set is empty and the predicate holds for its unique matrix.

QAlgorithms.Papers.Independent.Extend50.P13.FullySeparableDensity

For arbitrary natural numbers d,kd,kd,k and a complex matrix ρ\rhoρ indexed by functions {0,…,k−1}→{0,…,d−1}\{0,\ldots,k-1\}\to\{0,\ldots,d-1\}{0,…,k−1}→{0,…,d−1}, this predicate means that there exist a natural number mmm, real weights (pa)a<m(p_a)_{a<m}(pa​)a<m​, and complex d×dd\times dd×d matrices σa,j\sigma_{a,j}σa,j​ for a<ma<ma<m and j<kj<kj<k, such that every pa≥0p_a\ge0pa​≥0, ∑apa=1\sum_a p_a=1∑a​pa​=1, every σa,j\sigma_{a,j}σa,j​ is positive semidefinite with trace 111, and ρ(x,y)=∑a<mpa∏j<kσa,j(xj,yj)\rho(x,y)=\sum_{a<m}p_a\prod_{j<k}\sigma_{a,j}(x_j,y_j)ρ(x,y)=∑a<m​pa​∏j<k​σa,j​(xj​,yj​) for all indices x,yx,yx,y. Zero weights are allowed, but m=0m=0m=0 cannot satisfy the weight sum. When k=0k=0k=0, the local matrix conditions are vacuous and this requires the sole entry of ρ\rhoρ to equal 111. When d=0d=0d=0 and k>0k>0k>0, the predicate cannot hold because a local empty matrix cannot have trace 111.

QAlgorithms.Papers.Independent.Extend50.P13.GroupCoefficients

For every natural number kkk, this denotes the type of all functions a:Sk→Ca:S_k\to\mathbb Ca:Sk​→C, where SkS_kSk​ is the group of permutations of {0,…,k−1}\{0,\ldots,k-1\}{0,…,k−1}. There are no restrictions on the coefficients. When k=0k=0k=0, the permutation group has one element, so a coefficient function consists of one arbitrary complex number.

QAlgorithms.Papers.Independent.Extend50.P13.InAntisymmetricIdeal

For natural numbers k,dk,dk,d and an arbitrary function a:Sk→Ca:S_k\to\mathbb Ca:Sk​→C, this predicate says that there exists a family of arbitrary complex coefficient functions bλ:Sk→Cb_\lambda:S_k\to\mathbb Cbλ​:Sk​→C, indexed by all Young diagrams λ\lambdaλ with kkk boxes and first-column length at most kkk, such that

a(π)=∑λ:∣λ∣=kcolLen⁡λ(0)≤kd<colLen⁡λ(0) ∑σ∈Skcλ(σ)bλ(σ−1π)for every π∈Sk.a(\pi)= \sum_{\substack{\lambda:\,|\lambda|=k\\ \operatorname{colLen}_\lambda(0)\le k\\ d<\operatorname{colLen}_\lambda(0)}} \ \sum_{\sigma\in S_k} c_\lambda(\sigma)b_\lambda(\sigma^{-1}\pi) \qquad\text{for every }\pi\in S_k.a(π)=λ:∣λ∣=kcolLenλ​(0)≤kd<colLenλ​(0)​∑​ σ∈Sk​∑​cλ​(σ)bλ​(σ−1π)for every π∈Sk​.

Here the coefficients cλc_\lambdacλ​ are specified as follows: number the boxes using the fixed cardinality-based bijection with [k][k][k]; let Rλ,CλR_\lambda,C_\lambdaRλ​,Cλ​ preserve their rows and columns; form

Yλ(g,h)=∑u∈Rλ∑v∈Cλsgn⁡(v)1{g=huv};Y_\lambda(g,h)=\sum_{u\in R_\lambda}\sum_{v\in C_\lambda} \operatorname{sgn}(v)\mathbf1_{\{g=huv\}};Yλ​(g,h)=u∈Rλ​∑​v∈Cλ​∑​sgn(v)1{g=huv}​;

let QλQ_\lambdaQλ​ be the orthogonal projection onto its range; and set

Lτ(g,h)=1{g=τh},χλ(τ)=tr⁡(LτQλ),cλ(σ)=χλ(1)k!χλ(σ−1).L_\tau(g,h)=\mathbf1_{\{g=\tau h\}},\quad \chi_\lambda(\tau)=\operatorname{tr}(L_\tau Q_\lambda),\quad c_\lambda(\sigma)=\frac{\chi_\lambda(1)}{k!}\chi_\lambda(\sigma^{-1}).Lτ​(g,h)=1{g=τh}​,χλ​(τ)=tr(Lτ​Qλ​),cλ​(σ)=k!χλ​(1)​χλ​(σ−1).

The inequality selecting diagrams is strict. No positivity condition is imposed on aaa or bλb_\lambdabλ​. If d≥kd\ge kd≥k, including k=0k=0k=0, the selected-diagram sum is empty, so the predicate holds exactly when aaa is identically zero.

QAlgorithms.Papers.Independent.Extend50.P13.IsNoncommutativePolynomial

For arbitrary natural numbers d,rd,rd,r and any function fff from rrr-tuples of complex d×dd\times dd×d matrices to complex d×dd\times dd×d matrices, this predicate means that there exists a finite list of pairs (c,w)(c,w)(c,w), with c∈Cc\in\mathbb Cc∈C and www an arbitrary finite word in the labels 0,…,r−10,\ldots,r-10,…,r−1, such that, for every tuple XXX,

f(X)=∑(c,[i1,…,iℓ]) in the listc Xi1⋯Xiℓ.f(X)=\sum_{(c,[i_1,\ldots,i_\ell])\text{ in the list}} c\,X_{i_1}\cdots X_{i_\ell}.f(X)=(c,[i1​,…,iℓ​]) in the list∑​cXi1​​⋯Xiℓ​​.

An empty word contributes cIdcI_dcId​, and an empty representing list contributes zero. Words may repeat or omit labels, repeat labels internally, and have different lengths; no multilinearity or homogeneity condition is imposed. The parameters may be zero; for r=0r=0r=0, only empty words are available, so the represented function is a scalar multiple of IdI_dId​.

QAlgorithms.Papers.Independent.Extend50.P13.IsTensorPolynomial

For arbitrary natural numbers d,r,td,r,td,r,t and a function fff from rrr-tuples of complex d×dd\times dd×d matrices to matrices indexed by functions {0,…,t−1}→{0,…,d−1}\{0,\ldots,t-1\}\to\{0,\ldots,d-1\}{0,…,t−1}→{0,…,d−1}, this predicate means that there exists a finite list of terms, each with a complex coefficient and ttt ordered output words, such that every input label 0,…,r−10,\ldots,r-10,…,r−1 occurs exactly once across those output words, every term has no closed words, and, for every tuple XXX,

f(X)u,v=∑terms (c,w)c∏j=0t−1(Xwj)u(j),v(j),X[i1,…,iℓ]=Xi1⋯Xiℓ,X[]=Id.f(X)_{u,v} =\sum_{\text{terms }(c,w)} c\prod_{j=0}^{t-1}(X_{w_j})_{u(j),v(j)}, \qquad X_{[i_1,\ldots,i_\ell]}=X_{i_1}\cdots X_{i_\ell}, \quad X_{[]}=I_d.f(X)u,v​=terms (c,w)∑​cj=0∏t−1​(Xwj​​)u(j),v(j)​,X[i1​,…,iℓ​]​=Xi1​​⋯Xiℓ​​,X[]​=Id​.

The representing list may be empty and output words may be empty. All parameters may be zero. In particular, if t=0<rt=0<rt=0<r, no individual term can satisfy the label requirement, so only the empty list is available and fff must be zero; if r=0r=0r=0, every term has only empty output words.

QAlgorithms.Papers.Independent.Extend50.P13.IsTracePolynomial

For any natural numbers d,rd,rd,r and any function fff from rrr-indexed families of complex d×dd\times dd×d matrices to complex d×dd\times dd×d matrices, this predicate means that there exists a finite list of terms representing fff on every input family XXX, each term having the form c(∏w∈Wtr⁡(Xw))Xoc\bigl(\prod_{w\in\mathcal W}\operatorname{tr}(X_w)\bigr)X_oc(∏w∈W​tr(Xw​))Xo​. Here c∈Cc\in\mathbb Cc∈C, each XwX_wXw​ is the ordered product of matrices whose labels occur in the word www, every closed word in W\mathcal WW is nonempty, the open word ooo may be empty, and every label 0,…,r−10,\ldots,r-10,…,r−1 occurs exactly once across that term’s words. Empty word products are identities, empty scalar products are 111, and an empty term list represents zero. For r=0r=0r=0, this requires the output on the unique empty input family to be a complex scalar multiple of the identity. For d=0d=0d=0, every such function satisfies the predicate.

QAlgorithms.Papers.Independent.Extend50.P13.OptimalWernerWitness

For arbitrary natural numbers d,kd,kd,k and a complex matrix WWW indexed by functions {0,…,k−1}→{0,…,d−1}\{0,\ldots,k-1\}\to\{0,\ldots,d-1\}{0,…,k−1}→{0,…,d−1}, this predicate requires all of the following: for every unitary complex d×dd\times dd×d matrix UUU, the matrix VVV with entries V(x,y)=∏j<kU(xj,yj)V(x,y)=\prod_{j<k}U(x_j,y_j)V(x,y)=∏j<k​U(xj​,yj​) satisfies VWV†=WVWV^\dagger=WVWV†=W; WWW is Hermitian, and for every family of vectors vj∈Cdv_j\in\mathbb C^dvj​∈Cd, setting u(x)=∏j<kvj(xj)u(x)=\prod_{j<k}v_j(x_j)u(x)=∏j<k​vj​(xj​) makes tr⁡(Wuu†)\operatorname{tr}(Wuu^\dagger)tr(Wuu†) have zero imaginary part and nonnegative real part; there exists a positive semidefinite trace-one matrix ρ\rhoρ that has no representation as a finite convex combination of matrices with entries ∏jσa,j(xj,yj)\prod_j\sigma_{a,j}(x_j,y_j)∏j​σa,j​(xj​,yj​), where all local σa,j\sigma_{a,j}σa,j​ are positive semidefinite of trace 111, and for which Re⁡tr⁡(Wρ)<0\operatorname{Re}\operatorname{tr}(W\rho)<0Retr(Wρ)<0; and there exists another positive semidefinite trace-one matrix admitting such a representation for which the complex trace tr⁡(Wρ)\operatorname{tr}(W\rho)tr(Wρ) equals 000. The product-vector condition includes zero vectors. The predicate cannot hold for k=0k=0k=0, when every density matrix is the scalar 111 and has the required convex representation, or for d=0d=0d=0 and k>0k>0k>0, when no density matrix exists.

QAlgorithms.Papers.Independent.Extend50.P13.OutputMarkedCycles

For arbitrary natural numbers r,tr,tr,t and a permutation π\piπ of 0,…,r+t−10,\ldots,r+t-10,…,r+t−1, call r+jr+jr+j the output slot corresponding to j∈{0,…,t−1}j\in\{0,\ldots,t-1\}j∈{0,…,t−1}. This predicate requires that every output slot is moved by π\piπ; that, for every pair j,lj,lj,l of output labels, the output slot r+lr+lr+l belongs to the cycle list of r+jr+jr+j if and only if l=jl=jl=j; and that every slot belongs to the cycle list of some output slot. A cycle list is the singleton at a fixed slot and otherwise the ordered list of its permutation cycle rotated left once. Thus every cycle must contain exactly one output slot, and that cycle must also contain at least one input slot. The definition includes r=0r=0r=0 and t=0t=0t=0: with no output slots, the covering requirement holds only when there are no slots at all, and with t>rt>rt>r the requirements cannot be satisfied.

QAlgorithms.Papers.Independent.Extend50.P13.PositiveMap

For any finite type III, any natural number rrr, and any function fff taking an rrr-indexed family of complex I×II\times II×I matrices to a complex I×II\times II×I matrix, this predicate means that f(X)f(X)f(X) is positive semidefinite whenever every input matrix XiX_iXi​, for 0≤i<r0\le i<r0≤i<r, is positive semidefinite. No linearity or multilinearity is required. When r=0r=0r=0, there is one empty input family, its hypothesis is vacuous, and the predicate requires its output to be positive semidefinite. If III is empty, the predicate holds automatically.

QAlgorithms.Papers.Independent.Extend50.P13.PureTraceMonomial

For any natural number rrr, a pure trace monomial consists of a finite ordered list of nonempty words in the labels {0,…,r−1}\{0,\ldots,r-1\}{0,…,r−1}, together with the requirement that concatenating those words gives a rearrangement of the list 0,…,r−10,\ldots,r-10,…,r−1. Consequently, every input label occurs exactly once across the words. The list of words may be empty, and for r=0r=0r=0 it must be empty.

QAlgorithms.Papers.Independent.Extend50.P13.PureTracePolynomial

For any natural number rrr, a pure trace polynomial is a finite ordered list of pairs (c,τ)(c,\tau)(c,τ), where c∈Cc\in\mathbb Cc∈C and τ\tauτ is a finite ordered list of nonempty words in 0,…,r−10,\ldots,r-10,…,r−1 whose concatenation contains every input label exactly once. The polynomial list may be empty, coefficients may be zero, and monomials may repeat. When r=0r=0r=0, each monomial’s word list is empty.

QAlgorithms.Papers.Independent.Extend50.P13.RealNonnegative

For any complex number zzz, this defines the proposition that its imaginary part is zero and its real part is nonnegative:

Im⁡z=0and0≤Re⁡z.\operatorname{Im}z=0\quad\text{and}\quad 0\le\operatorname{Re}z.Imz=0and0≤Rez.

The value z=0z=0z=0 is included.

QAlgorithms.Papers.Independent.Extend50.P13.Saturates

For arbitrary natural numbers d,rd,rd,r and a function fff from rrr-tuples of complex d×dd\times dd×d matrices to complex d×dd\times dd×d matrices, this predicate means that f(X)f(X)f(X) is positive semidefinite whenever every input matrix XiX_iXi​ is positive semidefinite, and that there exist inputs XiX_iXi​ that are each positive semidefinite and nonzero, together with a nonzero vector v∈Cdv\in\mathbb C^dv∈Cd, such that f(X)v=0f(X)v=0f(X)v=0. No linearity or multilinearity of fff is required. For r=0r=0r=0, the conditions on individual input matrices are vacuous, and the predicate requires the value on the empty tuple to be positive semidefinite with a nonzero kernel vector. For d=0d=0d=0, no such vector exists.

QAlgorithms.Papers.Independent.Extend50.P13.TableProperties

Let rrr be any natural number, put k=r+1k=r+1k=r+1, and let λ\lambdaλ be a Young diagram with kkk boxes and first-column length at most kkk. The following constructions specify the predicate being defined. Number the boxes of λ\lambdaλ by the fixed bijection with [k]={0,…,k−1}[k]=\{0,\ldots,k-1\}[k]={0,…,k−1} selected from their equal cardinalities; let Rλ,Cλ⊆SkR_\lambda,C_\lambda\subseteq S_kRλ​,Cλ​⊆Sk​ be the permutations preserving, respectively, the row and column of each numbered box. On the complex Euclidean space indexed by SkS_kSk​, define

Yλ(g,h)=∑a∈Rλ∑b∈Cλsgn⁡(b) 1{g=hab},Y_\lambda(g,h)= \sum_{a\in R_\lambda}\sum_{b\in C_\lambda} \operatorname{sgn}(b)\,\mathbf1_{\{g=hab\}},Yλ​(g,h)=a∈Rλ​∑​b∈Cλ​∑​sgn(b)1{g=hab}​,

let QλQ_\lambdaQλ​ be the orthogonal projection onto the range of YλY_\lambdaYλ​, and set

Lπ(g,h)=1{g=πh},χλ(π)=tr⁡(LπQλ).L_\pi(g,h)=\mathbf1_{\{g=\pi h\}},\qquad \chi_\lambda(\pi)=\operatorname{tr}(L_\pi Q_\lambda).Lπ​(g,h)=1{g=πh}​,χλ​(π)=tr(Lπ​Qλ​).

For every natural number ddd, define matrices indexed by [d]k[d]^k[d]k by

Td(π)u,v=1{u=v∘π−1},Pλ,d=χλ(1)k!∑π∈Skχλ(π−1)Td(π).T_d(\pi)_{u,v}=\mathbf1_{\{u=v\circ\pi^{-1}\}},\qquad P_{\lambda,d}=\frac{\chi_\lambda(1)}{k!} \sum_{\pi\in S_k}\chi_\lambda(\pi^{-1})T_d(\pi).Td​(π)u,v​=1{u=v∘π−1}​,Pλ,d​=k!χλ​(1)​π∈Sk​∑​χλ​(π−1)Td​(π).

For a finite index set JJJ, a matrix KKK indexed by Jr+1J^{r+1}Jr+1, and rrr matrices XiX_iXi​ indexed by JJJ, define the contraction and its indicated amplification by

CK(X)a,b=∑x,y∈JrK(x,a),(y,b)∏i=0r−1(Xi)yi,xi,AK,m(Z)(a,u),(b,v)=∑x,y∈JrK(x,a),(y,b)Z(x,u),(y,v),\begin{aligned} \mathcal C_K(X)_{a,b} &=\sum_{x,y\in J^r}K_{(x,a),(y,b)} \prod_{i=0}^{r-1}(X_i)_{y_i,x_i},\\ \mathcal A_{K,m}(Z)_{(a,u),(b,v)} &=\sum_{x,y\in J^r}K_{(x,a),(y,b)} Z_{(x,u),(y,v)}, \end{aligned}CK​(X)a,b​AK,m​(Z)(a,u),(b,v)​​=x,y∈Jr∑​K(x,a),(y,b)​i=0∏r−1​(Xi​)yi​,xi​​,=x,y∈Jr∑​K(x,a),(y,b)​Z(x,u),(y,v)​,​

where (x,a)(x,a)(x,a) appends aaa as the final coordinate and u,v∈[m]u,v\in[m]u,v∈[m]. The predicate asserts that, for every d>0d>0d>0, all four statements hold: CPλ,d(X)\mathcal C_{P_{\lambda,d}}(X)CPλ,d​​(X) is positive semidefinite whenever every XiX_iXi​ is positive semidefinite; if ddd is smaller than the first-column length of λ\lambdaλ, then this contraction is zero for every complex matrix tuple XXX; for every unitary UUU and every complex matrix tuple XXX,

CPλ,d((UXiU∗)i)=UCPλ,d(X)U∗;\mathcal C_{P_{\lambda,d}}\bigl((UX_iU^*)_i\bigr) =U\mathcal C_{P_{\lambda,d}}(X)U^*;CPλ,d​​((UXi​U∗)i​)=UCPλ,d​​(X)U∗;

and, for every m>0m>0m>0 and every positive semidefinite ZZZ indexed by [d]r×[m][d]^r\times[m][d]r×[m], the matrix APλ,d,m(Z)\mathcal A_{P_{\lambda,d},m}(Z)APλ,d​,m​(Z) is positive semidefinite. It additionally asserts that for every natural number nnn and every tuple of positive natural dimensions d0,…,dn−1d_0,\ldots,d_{n-1}d0​,…,dn−1​, the contraction CK\mathcal C_KCK​ is positive on tuples of positive semidefinite matrices on J=∏j=0n−1[dj]J=\prod_{j=0}^{n-1}[d_j]J=∏j=0n−1​[dj​], where

Ku,v=∏j=0n−1(Pλ,dj)(ui(j))i=0r,(vi(j))i=0r.K_{u,v}=\prod_{j=0}^{n-1} (P_{\lambda,d_j})_{(u_i(j))_{i=0}^{r},(v_i(j))_{i=0}^{r}}.Ku,v​=j=0∏n−1​(Pλ,dj​​)(ui​(j))i=0r​,(vi​(j))i=0r​​.

The quantifiers include r=0r=0r=0, with no input matrices, and n=0n=0n=0, with singleton product registers; empty products equal 111.

QAlgorithms.Papers.Independent.Extend50.P13.TensorTraceMonomial

For any natural numbers r,tr,tr,t, a tensor trace monomial consists of an ordered word wjw_jwj​ in the labels {0,…,r−1}\{0,\ldots,r-1\}{0,…,r−1} for each output index j∈{0,…,t−1}j\in\{0,\ldots,t-1\}j∈{0,…,t−1}, together with an ordered finite list of closed words in the same labels. Every closed word must be nonempty. Concatenating the output words in increasing output-index order and then concatenating the closed words must give a rearrangement of the list 0,…,r−10,\ldots,r-10,…,r−1; thus every input label occurs exactly once across all words. Output words may be empty. When r=0r=0r=0, every output word and the list of closed words are empty; when t=0t=0t=0, all input labels must occur in the closed words.

QAlgorithms.Papers.Independent.Extend50.P13.TensorTracePolynomial

For any natural numbers r,tr,tr,t, a tensor trace polynomial is a finite ordered list of pairs (c,τ)(c,\tau)(c,τ), where c∈Cc\in\mathbb Cc∈C and τ\tauτ consists of ttt output words and a finite ordered list of nonempty closed words in the input labels 0,…,r−10,\ldots,r-10,…,r−1, with every input label occurring exactly once across these words. The polynomial list may be empty, coefficients may be zero, and monomials may repeat. Output words may be empty; in particular, for r=0r=0r=0 all output words and every monomial’s closed-word list are empty.

QAlgorithms.Papers.Independent.Extend50.P13.TraceMonomial

For a natural number rrr, this structure consists of an ordered list called the open word, whose entries lie in {0,…,r−1}\{0,\ldots,r-1\}{0,…,r−1}, and an ordered list of closed words, each itself a list of such entries, together with the requirements that every closed word is nonempty and that concatenating the open word with all the closed words gives a permutation of the list 0,1,…,r−10,1,\ldots,r-10,1,…,r−1. Consequently, every label occurs exactly once across all words. The open word and the list of closed words may each be empty. When r=0r=0r=0, both must be empty. No identification under cyclic rotation or rearrangement of words is part of this structure.

QAlgorithms.Papers.Independent.Extend50.P13.TracePolynomial

For a natural number rrr, this is an abbreviation for a finite ordered list of pairs consisting of a complex coefficient and the following word data: one possibly empty open word and a list of nonempty closed words, all using labels in {0,…,r−1}\{0,\ldots,r-1\}{0,…,r−1}, with each label appearing exactly once across their concatenation. The coefficient list may be empty, coefficients may be zero, and repeated terms are permitted. This is a list representation, with no quotient identifying different lists that evaluate to the same function. For r=0r=0r=0, each term has empty open and closed word lists.

QAlgorithms.Papers.Independent.Extend50.P13.anti

For any finite type III equipped with an enumeration and any two complex matrices A,BA,BA,B indexed by III, this defines their anticommutator AB+BAAB+BAAB+BA, whose (i,j)(i,j)(i,j) entry is ∑ℓ∈I(AiℓBℓj+BiℓAℓj)\sum_{\ell\in I}\bigl(A_{i\ell}B_{\ell j}+B_{i\ell}A_{\ell j}\bigr)∑ℓ∈I​(Aiℓ​Bℓj​+Biℓ​Aℓj​). No Hermiticity, positivity, or commutation assumption is imposed. The type III may be empty, in which case the result is the unique empty matrix.

QAlgorithms.Papers.Independent.Extend50.P13.antisymmetricThree

For every natural number ddd, including zero, and arbitrary complex d×dd\times dd×d matrices X,YX,YX,Y, this defines

(tr⁡(X)tr⁡(Y)−tr⁡(XY))Id−tr⁡(X)Y−tr⁡(Y)X+XY+YX.\bigl(\operatorname{tr}(X)\operatorname{tr}(Y)-\operatorname{tr}(XY)\bigr)I_d -\operatorname{tr}(X)Y-\operatorname{tr}(Y)X+XY+YX.(tr(X)tr(Y)−tr(XY))Id​−tr(X)Y−tr(Y)X+XY+YX.

All products of matrices occur in the displayed order.

QAlgorithms.Papers.Independent.Extend50.P13.append

For any type III, any natural number rrr, any function x:{0,…,r−1}→Ix:\{0,\ldots,r-1\}\to Ix:{0,…,r−1}→I, and any element a∈Ia\in Ia∈I, this defines the function obtained by placing aaa after the entries of xxx:

append⁡(x,a)i={xi,0≤i<r,a,i=r.\operatorname{append}(x,a)_i= \begin{cases} x_i,&0\le i<r,\\ a,&i=r. \end{cases}append(x,a)i​={xi​,a,​0≤i<r,i=r.​

Its domain is {0,…,r}\{0,\ldots,r\}{0,…,r}. In particular, when r=0r=0r=0, the resulting function has the single value aaa; supplying these arguments is impossible if III is empty.

QAlgorithms.Papers.Independent.Extend50.P13.bilinearExpansion

For any natural number nnn, dimensions dj∈Nd_j\in\mathbb Ndj​∈N for j=0,…,n−1j=0,\ldots,n-1j=0,…,n−1, and arbitrary complex matrices ρ,μ\rho,\muρ,μ indexed by H=∏j{0,…,dj−1}H=\prod_j\{0,\ldots,d_j-1\}H=∏j​{0,…,dj​−1}, this defines the matrix

(23)n∑S⊆{0,…,n−1} ∑A⊆S(−12)∣S∣ES ⁣(TA ⁣(TA(ρS) TA(μS))).\left(\frac23\right)^n \sum_{S\subseteq\{0,\ldots,n-1\}}\ \sum_{A\subseteq S} \left(-\frac12\right)^{|S|} E_S\!\left(T_A\!\left(T_A(\rho_S)\,T_A(\mu_S)\right)\right).(32​)nS⊆{0,…,n−1}∑​ A⊆S∑​(−21​)∣S∣ES​(TA​(TA​(ρS​)TA​(μS​))).

Here ρS(x,y)=∑zρ(x∪z,y∪z)\rho_S(x,y)=\sum_z\rho(x\cup z,y\cup z)ρS​(x,y)=∑z​ρ(x∪z,y∪z), where x,yx,yx,y specify the coordinates in SSS and zzz ranges over all coordinates outside SSS; μS\mu_SμS​ is defined identically. The operation TAT_ATA​ interchanges the row and column coordinates belonging to AAA, leaving the other coordinates unchanged. The embedding ES(M)E_S(M)ES​(M) has entry M(u∣S,v∣S)M(u|_S,v|_S)M(u∣S​,v∣S​) when uj=vju_j=v_juj​=vj​ for every j∉Sj\notin Sj∈/S, and entry zero otherwise. Both sums include the empty subset. Zero dimensions and n=0n=0n=0 are allowed; products over no coordinates have one possible index, and empty products equal 111.

QAlgorithms.Papers.Independent.Extend50.P13.bipartiteExpansion

For any two natural dimensions d0,d1d_0,d_1d0​,d1​, including zero, and arbitrary complex matrices ρ,μ\rho,\muρ,μ indexed by H={0,…,d0−1}×{0,…,d1−1}H=\{0,\ldots,d_0-1\}\times\{0,\ldots,d_1-1\}H={0,…,d0​−1}×{0,…,d1​−1}, this defines

19(4IH+T0 ⁣(T0(ρ)T0(μ))+T1 ⁣(T1(ρ)T1(μ))−2[E0(ρ0μ0+μ0ρ0)+E1(ρ1μ1+μ1ρ1)]+ρμ+μρ).\frac19\Bigl( 4I_H+ T_0\!\left(T_0(\rho)T_0(\mu)\right)+ T_1\!\left(T_1(\rho)T_1(\mu)\right) -2\bigl[ E_0(\rho_0\mu_0+\mu_0\rho_0)+ E_1(\rho_1\mu_1+\mu_1\rho_1) \bigr] +\rho\mu+\mu\rho \Bigr).91​(4IH​+T0​(T0​(ρ)T0​(μ))+T1​(T1​(ρ)T1​(μ))−2[E0​(ρ0​μ0​+μ0​ρ0​)+E1​(ρ1​μ1​+μ1​ρ1​)]+ρμ+μρ).

Here TjT_jTj​ swaps the row and column coordinates of subsystem jjj; ρj\rho_jρj​ and μj\mu_jμj​ are obtained by summing diagonal entries over the other subsystem, for example (ρ0)a,b=∑zρ(a,z),(b,z)(\rho_0)_{a,b}=\sum_z\rho_{(a,z),(b,z)}(ρ0​)a,b​=∑z​ρ(a,z),(b,z)​; and Ej(M)E_j(M)Ej​(M) embeds MMM by multiplying its entries by the identity entries on the other subsystem. The factor 1/91/91/9 multiplies the entire displayed expression.

QAlgorithms.Papers.Independent.Extend50.P13.centralCoefficients

For every natural number kkk and Young diagram λ\lambdaλ with kkk boxes and first-column length at most kkk, this defines a complex coefficient function on SkS_kSk​. Its construction uses the fixed bijection between the boxes of λ\lambdaλ and [k]={0,…,k−1}[k]=\{0,\ldots,k-1\}[k]={0,…,k−1} selected from their equal cardinalities. Let RλR_\lambdaRλ​ and CλC_\lambdaCλ​ be the permutations preserving the row and column, respectively, of every numbered box, and define the matrix on SkS_kSk​ by

Yλ(g,h)=∑a∈Rλ∑b∈Cλsgn⁡(b) 1{g=hab}.Y_\lambda(g,h)= \sum_{a\in R_\lambda}\sum_{b\in C_\lambda} \operatorname{sgn}(b)\,\mathbf1_{\{g=hab\}}.Yλ​(g,h)=a∈Rλ​∑​b∈Cλ​∑​sgn(b)1{g=hab}​.

Let QλQ_\lambdaQλ​ be the orthogonal projection onto the range of YλY_\lambdaYλ​ in the complex Euclidean space indexed by SkS_kSk​, and define

Lπ(g,h)=1{g=πh},χλ(π)=tr⁡(LπQλ).L_\pi(g,h)=\mathbf1_{\{g=\pi h\}},\qquad \chi_\lambda(\pi)=\operatorname{tr}(L_\pi Q_\lambda).Lπ​(g,h)=1{g=πh}​,χλ​(π)=tr(Lπ​Qλ​).

The resulting coefficient function is

cλ(π)=χλ(1)k! χλ(π−1)(π∈Sk),c_\lambda(\pi)=\frac{\chi_\lambda(1)}{k!}\, \chi_\lambda(\pi^{-1}) \qquad(\pi\in S_k),cλ​(π)=k!χλ​(1)​χλ​(π−1)(π∈Sk​),

with the factorial regarded as a complex scalar. The definition includes k=0k=0k=0, for which 0!=10!=10!=1, so this denominator is never zero.

QAlgorithms.Papers.Independent.Extend50.P13.centralProjector

For natural numbers k,dk,dk,d and a Young diagram λ\lambdaλ having exactly kkk cells and first-column length at most kkk, this defines a complex matrix indexed by functions x,y:{0,…,k−1}→{0,…,d−1}x,y:\{0,\ldots,k-1\}\to\{0,\ldots,d-1\}x,y:{0,…,k−1}→{0,…,d−1}, with entries

(Cd,λ)y,x=χλ(1)k!∑π∈Skχλ(π−1){1,y=x∘π−1,0,otherwise.(C_{d,\lambda})_{y,x} =\frac{\chi_\lambda(1)}{k!} \sum_{\pi\in S_k}\chi_\lambda(\pi^{-1}) \begin{cases} 1,&y=x\circ\pi^{-1},\\ 0,&\text{otherwise}. \end{cases}(Cd,λ​)y,x​=k!χλ​(1)​π∈Sk​∑​χλ​(π−1){1,0,​y=x∘π−1,otherwise.​

Here SkS_kSk​ is the permutation group on {0,…,k−1}\{0,\ldots,k-1\}{0,…,k−1}, and χλ\chi_\lambdaχλ​ is defined as follows: choose the definition’s fixed bijection from the cells of λ\lambdaλ to these labels; let RλR_\lambdaRλ​ and KλK_\lambdaKλ​ consist respectively of permutations preserving each label’s cell row and cell column; form the matrix YYY, indexed by g,h∈Skg,h\in S_kg,h∈Sk​, whose entry is ∑a∈Rλ∑b∈Kλsgn⁡(b)1{g=hab}\sum_{a\in R_\lambda}\sum_{b\in K_\lambda}\operatorname{sgn}(b)\mathbf 1_{\{g=hab\}}∑a∈Rλ​​∑b∈Kλ​​sgn(b)1{g=hab}​; let Πλ\Pi_\lambdaΠλ​ be the orthogonal projection in CSk\mathbb C^{S_k}CSk​ onto the range of YYY; and set χλ(π)=tr⁡(LπΠλ)\chi_\lambda(\pi)=\operatorname{tr}(L_\pi\Pi_\lambda)χλ​(π)=tr(Lπ​Πλ​), where (Lπ)g,h=1{g=πh}(L_\pi)_{g,h}=\mathbf 1_{\{g=\pi h\}}(Lπ​)g,h​=1{g=πh}​. All coefficients are interpreted in C\mathbb CC. The definition includes k=0k=0k=0, when λ\lambdaλ is empty and the resulting matrix has its sole entry 111, and d=0d=0d=0, when its index set is empty unless k=0k=0k=0.

QAlgorithms.Papers.Independent.Extend50.P13.closedCycleExpression

For arbitrary natural numbers d,kd,kd,k, a permutation π\piπ of {0,…,k−1}\{0,\ldots,k-1\}{0,…,k−1}, and a family of complex d×dd\times dd×d matrices (Xi)i<k(X_i)_{i<k}(Xi​)i<k​, this defines the complex number ∏qtr⁡(Xi1⋯Xiℓ)\prod_q\operatorname{tr}(X_{i_1}\cdots X_{i_\ell})∏q​tr(Xi1​​⋯Xiℓ​​), where qqq ranges over the largest index of each cycle of π\piπ, and [i1,…,iℓ][i_1,\ldots,i_\ell][i1​,…,iℓ​] is [q][q][q] for a fixed point and otherwise the permutation’s cycle list based at qqq, rotated one position to the left. Matrix factors are multiplied in the displayed list order. No positivity or normalization of the matrices is assumed. For k=0k=0k=0, the product is empty and equals 111; d=0d=0d=0 is also allowed, with traces of empty matrices equal to 000.

QAlgorithms.Papers.Independent.Extend50.P13.coefficientProduct

For every natural number kkk and arbitrary coefficient functions a,b:Sk→Ca,b:S_k\to\mathbb Ca,b:Sk​→C, this defines their product to be the coefficient function

(a∗b)(π)=∑σ∈Ska(σ) b(σ−1π)(π∈Sk).(a*b)(\pi)=\sum_{\sigma\in S_k}a(\sigma)\,b(\sigma^{-1}\pi) \qquad(\pi\in S_k).(a∗b)(π)=σ∈Sk​∑​a(σ)b(σ−1π)(π∈Sk​).

The order σ−1π\sigma^{-1}\piσ−1π is part of the definition. For k=0k=0k=0, this is ordinary multiplication of the two coefficients at the unique permutation.

QAlgorithms.Papers.Independent.Extend50.P13.contractInputs

For any type III equipped with a finite enumeration, any natural number rrr, any complex matrix PPP indexed by functions {0,…,r}→I\{0,\ldots,r\}\to I{0,…,r}→I, and any family of complex matrices X0,…,Xr−1X_0,\ldots,X_{r-1}X0​,…,Xr−1​ indexed by III, this defines the matrix indexed by a,b∈Ia,b\in Ia,b∈I with entries

(contractInputs⁡(P,X))a,b=∑x:{0,…,r−1}→I∑y:{0,…,r−1}→IP(x,a),(y,b)∏i=0r−1(Xi)yi,xi,\bigl(\operatorname{contractInputs}(P,X)\bigr)_{a,b} =\sum_{x:\{0,\ldots,r-1\}\to I} \sum_{y:\{0,\ldots,r-1\}\to I} P_{(x,a),(y,b)} \prod_{i=0}^{r-1}(X_i)_{y_i,x_i},(contractInputs(P,X))a,b​=x:{0,…,r−1}→I∑​y:{0,…,r−1}→I∑​P(x,a),(y,b)​i=0∏r−1​(Xi​)yi​,xi​​,

where (x,a)(x,a)(x,a) denotes the function agreeing with xxx at positions below rrr and taking value aaa at position rrr, and likewise for (y,b)(y,b)(y,b). No positivity or symmetry conditions are imposed. When r=0r=0r=0, both sums have one term and the product is 111, so the entry is P(a),(b)P_{(a),(b)}P(a),(b)​; when III is empty, the output matrix has no entries.

QAlgorithms.Papers.Independent.Extend50.P13.copositiveAmplification

For any type III equipped with a finite enumeration, natural numbers r,mr,mr,m, any complex matrix PPP indexed by functions {0,…,r}→I\{0,\ldots,r\}\to I{0,…,r}→I, and any complex matrix ZZZ indexed by pairs consisting of a function {0,…,r−1}→I\{0,\ldots,r-1\}\to I{0,…,r−1}→I and an element of {0,…,m−1}\{0,\ldots,m-1\}{0,…,m−1}, this defines the matrix indexed by (a,α),(b,β)∈I×{0,…,m−1}(a,\alpha),(b,\beta)\in I\times\{0,\ldots,m-1\}(a,α),(b,β)∈I×{0,…,m−1} with entries

(copositiveAmplification⁡(P,m,Z))(a,α),(b,β)=∑x∑yP(x,a),(y,b)Z(x,α),(y,β),\bigl(\operatorname{copositiveAmplification}(P,m,Z)\bigr)_{(a,\alpha),(b,\beta)} =\sum_x\sum_y P_{(x,a),(y,b)}Z_{(x,\alpha),(y,\beta)},(copositiveAmplification(P,m,Z))(a,α),(b,β)​=x∑​y∑​P(x,a),(y,b)​Z(x,α),(y,β)​,

where both sums range over all functions {0,…,r−1}→I\{0,\ldots,r-1\}\to I{0,…,r−1}→I, and (x,a)(x,a)(x,a) appends aaa at position rrr. No positivity condition is assumed or asserted. For r=0r=0r=0, the entry is P(a),(b)Z(∅,α),(∅,β)P_{(a),(b)}Z_{(\varnothing,\alpha),(\varnothing,\beta)}P(a),(b)​Z(∅,α),(∅,β)​; if m=0m=0m=0 or III is empty, the output matrix has no entries.

QAlgorithms.Papers.Independent.Extend50.P13.cycleLeaders

For every natural number kkk and permutation π\piπ of {0,…,k−1}\{0,\ldots,k-1\}{0,…,k−1}, this defines the finite set of indices qqq such that every entry jjj of the following list satisfies j≤qj\le qj≤q: use [q][q][q] if π(q)=q\pi(q)=qπ(q)=q, and otherwise use the permutation’s cycle list based at qqq, rotated one position to the left. Thus the set selects the largest index in each cycle, including every fixed point. When k=0k=0k=0, the set is empty.

QAlgorithms.Papers.Independent.Extend50.P13.cycleList

For every natural number kkk, permutation π\piπ of {0,…,k−1}\{0,\ldots,k-1\}{0,…,k−1}, and index qqq in that set, this defines a list as follows: if π(q)=q\pi(q)=qπ(q)=q, the list is [q][q][q]; otherwise, take the permutation’s cycle list based at qqq and rotate it one position to the left, moving its first entry to the end. There is no possible argument qqq when k=0k=0k=0.

QAlgorithms.Papers.Independent.Extend50.P13.embedSubsystemIdentity

For any finite type JJJ equipped with an enumeration, natural dimensions (dj)j∈J(d_j)_{j\in J}(dj​)j∈J​, a finite subset S⊆JS\subseteq JS⊆J, and a complex matrix MMM indexed by coordinate assignments on SSS, this defines a matrix on full coordinate assignments by E(a,b)=M(a∣S,b∣S)E(a,b)=M(a|_S,b|_S)E(a,b)=M(a∣S​,b∣S​) if aj=bja_j=b_jaj​=bj​ for every j∉Sj\notin Sj∈/S, and E(a,b)=0E(a,b)=0E(a,b)=0 otherwise. No positivity, Hermiticity, or normalization of MMM is assumed. For S=∅S=\varnothingS=∅, MMM has a single scalar entry and EEE is that scalar times the identity; for S=JS=JS=J, the outside-coordinate condition is vacuous. Zero dimensions and an empty JJJ are allowed.

QAlgorithms.Papers.Independent.Extend50.P13.evaluatePureTrace

For arbitrary natural numbers d,rd,rd,r, a pure trace polynomial ppp, and complex d×dd\times dd×d matrices X0,…,Xr−1X_0,\ldots,X_{r-1}X0​,…,Xr−1​, this definition returns the complex number

∑(c,C) in pc∏[i1,…,iℓ] in Ctr⁡(Xi1⋯Xiℓ).\sum_{(c,C)\text{ in }p} c\prod_{[i_1,\ldots,i_\ell]\text{ in }C} \operatorname{tr}(X_{i_1}\cdots X_{i_\ell}).(c,C) in p∑​c[i1​,…,iℓ​] in C∏​tr(Xi1​​⋯Xiℓ​​).

Here each CCC is an ordered list of nonempty words, with every input label 0,…,r−10,\ldots,r-10,…,r−1 occurring exactly once across those words, and matrix multiplication follows each word’s order. Every occurrence in the polynomial list contributes separately. The empty polynomial evaluates to zero, and an empty word list contributes the scalar 111; hence for r=0r=0r=0 the value is the sum of the polynomial’s coefficients. The dimension d=0d=0d=0 is also allowed, with traces taken over the empty index set.

QAlgorithms.Papers.Independent.Extend50.P13.evaluateTensorTrace

For arbitrary natural numbers d,r,td,r,td,r,t, a tensor trace polynomial ppp, and complex d×dd\times dd×d matrices X0,…,Xr−1X_0,\ldots,X_{r-1}X0​,…,Xr−1​, this definition returns a matrix indexed by functions u,v:{0,…,t−1}→{0,…,d−1}u,v:\{0,\ldots,t-1\}\to\{0,\ldots,d-1\}u,v:{0,…,t−1}→{0,…,d−1}. Each list entry of ppp has a coefficient ccc, output words w0,…,wt−1w_0,\ldots,w_{t-1}w0​,…,wt−1​, and a list CCC of nonempty closed words, with every input label occurring exactly once across those words. Writing Xw=Xi1⋯XiℓX_w=X_{i_1}\cdots X_{i_\ell}Xw​=Xi1​​⋯Xiℓ​​ for a word w=[i1,…,iℓ]w=[i_1,\ldots,i_\ell]w=[i1​,…,iℓ​], with X[]=IdX_{[]}=I_dX[]​=Id​, the returned matrix has entries

∑(c,(w,C)) in pc(∏v in Ctr⁡(Xv))∏j=0t−1(Xwj)u(j),v(j).\sum_{(c,(w,C))\text{ in }p} c\left(\prod_{v\text{ in }C}\operatorname{tr}(X_v)\right) \prod_{j=0}^{t-1}(X_{w_j})_{u(j),v(j)}.(c,(w,C)) in p∑​c(v in C∏​tr(Xv​))j=0∏t−1​(Xwj​​)u(j),v(j)​.

Every list occurrence contributes separately. An empty polynomial evaluates to the zero matrix, and an empty closed-word list contributes the scalar 111. Zero dimensions and zero input or output counts are allowed; when t=0t=0t=0, the result is a matrix with a single entry.

QAlgorithms.Papers.Independent.Extend50.P13.evaluateTracePolynomial

For any finite type III equipped with decidable equality, any natural number rrr, any finite list ppp of complex coefficients paired with word data, and any family X0,…,Xr−1X_0,\ldots,X_{r-1}X0​,…,Xr−1​ of complex I×II\times II×I matrices, this defines ∑(c,o,W)∈pc(∏w∈Wtr⁡(Xw))Xo\sum_{(c,o,\mathcal W)\in p}c\bigl(\prod_{w\in\mathcal W}\operatorname{tr}(X_w)\bigr)X_o∑(c,o,W)∈p​c(∏w∈W​tr(Xw​))Xo​, counting every list occurrence. Here X[i1,…,iℓ]=Xi1⋯XiℓX_{[i_1,\ldots,i_\ell]}=X_{i_1}\cdots X_{i_\ell}X[i1​,…,iℓ​]​=Xi1​​⋯Xiℓ​​, with the empty word giving the identity; each closed word in W\mathcal WW is nonempty, and the open word ooo together with the closed words uses every label exactly once. An empty list of closed words gives scalar factor 111, and an empty polynomial list gives the zero matrix. For r=0r=0r=0, the result is the sum of the listed coefficients times the identity. The type III may be empty.

QAlgorithms.Papers.Independent.Extend50.P13.fillSlot

For natural numbers d,kd,kd,k, a distinguished index q∈{0,…,k−1}q\in\{0,\ldots,k-1\}q∈{0,…,k−1}, a value a∈{0,…,d−1}a\in\{0,\ldots,d-1\}a∈{0,…,d−1}, and an assignment sss of values in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1} to every index other than qqq, this defines the full assignment whose value at qqq is aaa and whose value at each i≠qi\ne qi=q is s(i)s(i)s(i). Supplying qqq and aaa requires k>0k>0k>0 and d>0d>0d>0; there are no such arguments when either relevant index set is empty.

QAlgorithms.Papers.Independent.Extend50.P13.finePolynomial

For every natural number ddd, including zero, an index i∈{0,1,2,3}i\in\{0,1,2,3\}i∈{0,1,2,3}, and arbitrary complex d×dd\times dd×d matrices X,YX,YX,Y, put a=tr⁡(X)a=\operatorname{tr}(X)a=tr(X), b=tr⁡(Y)b=\operatorname{tr}(Y)b=tr(Y), and c=tr⁡(XY)c=\operatorname{tr}(XY)c=tr(XY). This defines the matrix

{(2ab+2c)Id−aY−bX−XY−YX,i=0,(2ab−2c)Id+aY+bX−XY−YX,i=1,(2ab−c)Id+2aY−bX−XY−YX,i=2,(2ab+c)Id−2aY+bX−XY−YX,i=3.\begin{cases} (2ab+2c)I_d-aY-bX-XY-YX,&i=0,\\ (2ab-2c)I_d+aY+bX-XY-YX,&i=1,\\ (2ab-c)I_d+2aY-bX-XY-YX,&i=2,\\ (2ab+c)I_d-2aY+bX-XY-YX,&i=3. \end{cases}⎩⎨⎧​(2ab+2c)Id​−aY−bX−XY−YX,(2ab−2c)Id​+aY+bX−XY−YX,(2ab−c)Id​+2aY−bX−XY−YX,(2ab+c)Id​−2aY+bX−XY−YX,​i=0,i=1,i=2,i=3.​

QAlgorithms.Papers.Independent.Extend50.P13.fineProjector

For any natural number ddd, including zero, and i∈{0,1,2,3}i\in\{0,1,2,3\}i∈{0,1,2,3}, this defines a complex matrix indexed by triples with entries in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1} as

16(2I+εi[3Tsi−(T(01)+T(02)+T(12))]−Tc−Tc−1).\frac16\left( 2I+\varepsilon_i\left[3T_{s_i}- \bigl(T_{(01)}+T_{(02)}+T_{(12)}\bigr)\right] -T_c-T_{c^{-1}} \right).61​(2I+εi​[3Tsi​​−(T(01)​+T(02)​+T(12)​)]−Tc​−Tc−1​).

Here si=(01)s_i=(01)si​=(01) for i=0,1i=0,1i=0,1 and si=(12)s_i=(12)si​=(12) for i=2,3i=2,3i=2,3; εi=1\varepsilon_i=1εi​=1 for i=0,2i=0,2i=0,2 and εi=−1\varepsilon_i=-1εi​=−1 for i=1,3i=1,3i=1,3; ccc is the cyclic permutation formed from the ordered list 0,1,20,1,20,1,2; and III is the identity matrix on the triple index set. For every permutation π\piπ of the three positions, the matrix TπT_\piTπ​ has entry 111 at (y,x)(y,x)(y,x) exactly when yj=xπ−1(j)y_j=x_{\pi^{-1}(j)}yj​=xπ−1(j)​ for every position jjj, and entry 000 otherwise.

QAlgorithms.Papers.Independent.Extend50.P13.finiteMatrixElement

For any finite type III, any functions w,v:I→Cw,v:I\to\mathbb Cw,v:I→C, and any complex matrix AAA indexed by I×II\times II×I, this defines the complex number ∑a∈I∑b∈Iw(a)‾Aabv(b)\sum_{a\in I}\sum_{b\in I}\overline{w(a)}A_{ab}v(b)∑a∈I​∑b∈I​w(a)​Aab​v(b). Neither vector is required to be normalized, and AAA has no assumed properties. If III is empty, the value is 000.

QAlgorithms.Papers.Independent.Extend50.P13.gPolynomial

For any natural numbers d,rd,rd,r, arbitrary complex coefficient function a:Sr+1→Ca:S_{r+1}\to\mathbb Ca:Sr+1​→C, and tuple X0,…,XrX_0,\ldots,X_rX0​,…,Xr​ of arbitrary complex d×dd\times dd×d matrices, this defines a complex d×dd\times dd×d matrix as follows. On the index set [d]r+1[d]^{r+1}[d]r+1, put

Gu,v=∑π∈Sr+1a(π)1{u=v∘π−1},Tu,v=∏i=0r(Xi)ui,vi.G_{u,v}=\sum_{\pi\in S_{r+1}}a(\pi)\mathbf1_{\{u=v\circ\pi^{-1}\}}, \qquad T_{u,v}=\prod_{i=0}^{r}(X_i)_{u_i,v_i}.Gu,v​=π∈Sr+1​∑​a(π)1{u=v∘π−1}​,Tu,v​=i=0∏r​(Xi​)ui​,vi​​.

Multiply these matrices in the order GTGTGT, and sum over equal row and column coordinates in all positions except the final position rrr. Explicitly, if s⊕ps\oplus ps⊕p denotes s:[r]→[d]s:[r]\to[d]s:[r]→[d] with p∈[d]p\in[d]p∈[d] appended as its final coordinate, the result has entries

ga(X)p,q=∑s∈[d]r(GT)s⊕p,s⊕q=∑s∈[d]r∑y∈[d]r+1∑π∈Sr+1a(π)1{s⊕p=y∘π−1}∏i=0r(Xi)yi,(s⊕q)i.g_a(X)_{p,q} =\sum_{s\in[d]^r}(GT)_{s\oplus p,s\oplus q} =\sum_{s\in[d]^r}\sum_{y\in[d]^{r+1}} \sum_{\pi\in S_{r+1}} a(\pi)\mathbf1_{\{s\oplus p=y\circ\pi^{-1}\}} \prod_{i=0}^{r}(X_i)_{y_i,(s\oplus q)_i}.ga​(X)p,q​=s∈[d]r∑​(GT)s⊕p,s⊕q​=s∈[d]r∑​y∈[d]r+1∑​π∈Sr+1​∑​a(π)1{s⊕p=y∘π−1}​i=0∏r​(Xi​)yi​,(s⊕q)i​​.

No positivity or Hermitian assumptions are imposed. For r=0r=0r=0, there are no coordinates to trace out and the result is a(1)X0a(1)X_0a(1)X0​; for d=0d=0d=0, the result has empty row and column index sets.

QAlgorithms.Papers.Independent.Extend50.P13.groupOperator

For any natural numbers k,dk,dk,d and arbitrary coefficient function a:Sk→Ca:S_k\to\mathbb Ca:Sk​→C, this defines a complex matrix whose rows and columns are functions from [k]={0,…,k−1}[k]=\{0,\ldots,k-1\}[k]={0,…,k−1} to [d][d][d], with entries

Gd(a)y,x=∑π∈Ska(π) 1{y=x∘π−1}.G_d(a)_{y,x} =\sum_{\pi\in S_k}a(\pi)\, \mathbf1_{\{y=x\circ\pi^{-1}\}}.Gd​(a)y,x​=π∈Sk​∑​a(π)1{y=x∘π−1}​.

Equivalently, it is the sum of the permutation matrices for these coordinate permutations, weighted by a(π)a(\pi)a(π). No positivity or symmetry condition is imposed on aaa. When k=0k=0k=0, the matrix has one entry, a(1)a(1)a(1), for every ddd; when d=0d=0d=0 and k>0k>0k>0, its row and column index sets are empty.

QAlgorithms.Papers.Independent.Extend50.P13.hPolynomial

For arbitrary natural numbers d,r,td,r,td,r,t, let [k]={0,…,k−1}[k]=\{0,\ldots,k-1\}[k]={0,…,k−1}, let aaa assign a complex coefficient aπa_\piaπ​ to every permutation π\piπ of [r+t][r+t][r+t], and let X0,…,Xr−1X_0,\ldots,X_{r-1}X0​,…,Xr−1​ be complex d×dd\times dd×d matrices. This definition produces a matrix HHH indexed by functions u,v:[t]→[d]u,v:[t]\to[d]u,v:[t]→[d], with entries

Hu,v=∑x:[r]→[d]∑y:[r]→[d](∑π∈Sym⁡([r+t])aπ 1  x∥u=(y∥v)∘π−1)∏i=0r−1(Xi)y(i),x(i),H_{u,v}= \sum_{x:[r]\to[d]}\sum_{y:[r]\to[d]} \left(\sum_{\pi\in\operatorname{Sym}([r+t])} a_\pi\,\mathbf 1_{\;x\mathbin{\|}u=(y\mathbin{\|}v)\circ\pi^{-1}}\right) \prod_{i=0}^{r-1}(X_i)_{y(i),x(i)},Hu,v​=x:[r]→[d]∑​y:[r]→[d]∑​​π∈Sym([r+t])∑​aπ​1x∥u=(y∥v)∘π−1​​i=0∏r−1​(Xi​)y(i),x(i)​,

where x∥ux\mathbin{\|}ux∥u is the function on [r+t][r+t][r+t] whose first rrr coordinates are xxx and whose last ttt coordinates are uuu, and 1P\mathbf 1_P1P​ is 111 when PPP holds and 000 otherwise. No positivity, normalization, or symmetry is required of aaa or the matrices. Zero values of all three parameters are allowed; empty products are 111, empty sums are 000, and there is exactly one function with empty domain.

QAlgorithms.Papers.Independent.Extend50.P13.homogeneousMotzkin

For every natural number ddd, including zero, and arbitrary complex d×dd\times dd×d matrices A,BA,BA,B, this defines

(tr⁡A)2AB4A+(tr⁡B)2A2B2A2−3(tr⁡A)2(tr⁡B)2AB2A+(tr⁡A)4(tr⁡B)4Id.\bigl(\operatorname{tr}A\bigr)^2AB^4A +\bigl(\operatorname{tr}B\bigr)^2A^2B^2A^2 -3\bigl(\operatorname{tr}A\bigr)^2\bigl(\operatorname{tr}B\bigr)^2AB^2A +\bigl(\operatorname{tr}A\bigr)^4\bigl(\operatorname{tr}B\bigr)^4I_d.(trA)2AB4A+(trB)2A2B2A2−3(trA)2(trB)2AB2A+(trA)4(trB)4Id​.

The traces and their powers are complex scalars multiplying the indicated matrices.

QAlgorithms.Papers.Independent.Extend50.P13.inputSlot

For any natural numbers r,tr,tr,t and any index i∈{0,…,r−1}i\in\{0,\ldots,r-1\}i∈{0,…,r−1}, this defines its input position in {0,…,r+t−1}\{0,\ldots,r+t-1\}{0,…,r+t−1} to be the index with the same numerical value iii. If r=0r=0r=0, there is no index iii to supply; if t=0t=0t=0, this map is the identity on the rrr indices.

QAlgorithms.Papers.Independent.Extend50.P13.joinSlots

For any type III, natural numbers r,tr,tr,t, function x:{0,…,r−1}→Ix:\{0,\ldots,r-1\}\to Ix:{0,…,r−1}→I, and function a:{0,…,t−1}→Ia:\{0,\ldots,t-1\}\to Ia:{0,…,t−1}→I, this defines the joined function on {0,…,r+t−1}\{0,\ldots,r+t-1\}{0,…,r+t−1} by

join⁡(x,a)(i)={x(i),i<r,a(i−r),r≤i.\operatorname{join}(x,a)(i)= \begin{cases} x(i),&i<r,\\ a(i-r),&r\le i. \end{cases}join(x,a)(i)={x(i),a(i−r),​i<r,r≤i.​

The subtraction is natural-number subtraction, used here only when i≥ri\ge ri≥r, and then i−r<ti-r<ti−r<t. No finiteness or nonemptiness assumption is imposed on III. The definition allows r=0r=0r=0 or t=0t=0t=0, yielding the other supplied function, and when both are zero the result is the unique function with empty domain.

QAlgorithms.Papers.Independent.Extend50.P13.joinSubsystemCoordinates

For any type JJJ, a family of natural numbers (dj)j∈J(d_j)_{j\in J}(dj​)j∈J​, a finite subset S⊆JS\subseteq JS⊆J, coordinates aj∈{0,…,dj−1}a_j\in\{0,\ldots,d_j-1\}aj​∈{0,…,dj​−1} for j∈Sj\in Sj∈S, and coordinates eje_jej​ in the same respective sets for j∉Sj\notin Sj∈/S, this defines the full coordinate assignment xxx by xj=ajx_j=a_jxj​=aj​ on SSS and xj=ejx_j=e_jxj​=ej​ outside SSS. The type JJJ need not be finite. Zero dimensions are permitted, although a coordinate assignment on any collection containing an index of dimension zero cannot exist; assignments on an empty collection are unique.

QAlgorithms.Papers.Independent.Extend50.P13.linearContraction

For any type III equipped with a finite enumeration, any natural number rrr, any complex matrix PPP indexed by functions {0,…,r}→I\{0,\ldots,r\}\to I{0,…,r}→I, and any complex matrix ZZZ indexed by functions {0,…,r−1}→I\{0,\ldots,r-1\}\to I{0,…,r−1}→I, this defines the matrix indexed by a,b∈Ia,b\in Ia,b∈I with entries

(linearContraction⁡(P,Z))a,b=∑x:{0,…,r−1}→I∑y:{0,…,r−1}→IP(x,a),(y,b)Zy,x,\bigl(\operatorname{linearContraction}(P,Z)\bigr)_{a,b} =\sum_{x:\{0,\ldots,r-1\}\to I} \sum_{y:\{0,\ldots,r-1\}\to I} P_{(x,a),(y,b)}Z_{y,x},(linearContraction(P,Z))a,b​=x:{0,…,r−1}→I∑​y:{0,…,r−1}→I∑​P(x,a),(y,b)​Zy,x​,

where (x,a)(x,a)(x,a) appends aaa as the last coordinate of xxx. Neither matrix is subject to further assumptions. When r=0r=0r=0, writing ∅\varnothing∅ for the unique empty function, the entry is P(a),(b)Z∅,∅P_{(a),(b)}Z_{\varnothing,\varnothing}P(a),(b)​Z∅,∅​. If III is empty, the output matrix has no entries.

QAlgorithms.Papers.Independent.Extend50.P13.matrixWord

For any finite type III equipped with decidable equality, any natural number rrr, any family X0,…,Xr−1X_0,\ldots,X_{r-1}X0​,…,Xr−1​ of complex I×II\times II×I matrices, and any finite list w=[i1,…,iℓ]w=[i_1,\ldots,i_\ell]w=[i1​,…,iℓ​] of labels from {0,…,r−1}\{0,\ldots,r-1\}{0,…,r−1}, this defines the ordered matrix product Xi1⋯XiℓX_{i_1}\cdots X_{i_\ell}Xi1​​⋯Xiℓ​​. Labels may repeat or be omitted. The empty word evaluates to the identity matrix; in particular, when r=0r=0r=0, the only possible word is empty. The type III may also be empty.

QAlgorithms.Papers.Independent.Extend50.P13.mixedMap

For natural numbers n,rn,rn,r, dimensions dj∈Nd_j\in\mathbb Ndj​∈N for j<nj<nj<n, Young diagrams λj\lambda_jλj​ each having k=r+1k=r+1k=r+1 cells and first-column length at most kkk, and arbitrary complex matrices X0,…,Xr−1X_0,\ldots,X_{r-1}X0​,…,Xr−1​ indexed by H=∏j<n{0,…,dj−1}H=\prod_{j<n}\{0,\ldots,d_j-1\}H=∏j<n​{0,…,dj​−1}, this defines the matrix indexed by a,b∈Ha,b\in Ha,b∈H with entries

(mixedMap⁡(d,λ,X))a,b=∑x,y:{0,…,r−1}→H(∏j<n(Cdj,λj)(x0,j,…,xr−1,j,aj),(y0,j,…,yr−1,j,bj))∏i<r(Xi)yi,xi,(Cd,λ)u,v=χλ(1)k!∑π∈Skχλ(π−1)1{u=v∘π−1}.\bigl(\operatorname{mixedMap}(d,\lambda,X)\bigr)_{a,b} =\sum_{x,y:\{0,\ldots,r-1\}\to H} \left(\prod_{j<n} (C_{d_j,\lambda_j})_{(x_{0,j},\ldots,x_{r-1,j},a_j), (y_{0,j},\ldots,y_{r-1,j},b_j)}\right) \prod_{i<r}(X_i)_{y_i,x_i}, \qquad (C_{d,\lambda})_{u,v} =\frac{\chi_\lambda(1)}{k!} \sum_{\pi\in S_k}\chi_\lambda(\pi^{-1})\mathbf 1_{\{u=v\circ\pi^{-1}\}}.(mixedMap(d,λ,X))a,b​=x,y:{0,…,r−1}→H∑​(j<n∏​(Cdj​,λj​​)(x0,j​,…,xr−1,j​,aj​),(y0,j​,…,yr−1,j​,bj​)​)i<r∏​(Xi​)yi​,xi​​,(Cd,λ​)u,v​=k!χλ​(1)​π∈Sk​∑​χλ​(π−1)1{u=v∘π−1}​.

For each λ\lambdaλ, its character here is defined using the definition’s fixed numbering of its cells by {0,…,k−1}\{0,\ldots,k-1\}{0,…,k−1}: take the row-preserving and column-preserving permutation sets Rλ,KλR_\lambda,K_\lambdaRλ​,Kλ​, form Yg,h=∑α∈Rλ∑β∈Kλsgn⁡(β)1{g=hαβ}Y_{g,h}=\sum_{\alpha\in R_\lambda}\sum_{\beta\in K_\lambda}\operatorname{sgn}(\beta)\mathbf 1_{\{g=h\alpha\beta\}}Yg,h​=∑α∈Rλ​​∑β∈Kλ​​sgn(β)1{g=hαβ}​, let Πλ\Pi_\lambdaΠλ​ be the orthogonal projection onto the range of YYY in CSk\mathbb C^{S_k}CSk​, and set χλ(π)=tr⁡(LπΠλ)\chi_\lambda(\pi)=\operatorname{tr}(L_\pi\Pi_\lambda)χλ​(π)=tr(Lπ​Πλ​), where (Lπ)g,h=1{g=πh}(L_\pi)_{g,h}=\mathbf 1_{\{g=\pi h\}}(Lπ​)g,h​=1{g=πh}​. No positivity conditions are imposed. When r=0r=0r=0, the sums each have one term and the final product is 111; when n=0n=0n=0, HHH is a singleton and the sole output entry is the product of the sole entries of the XiX_iXi​; if any dj=0d_j=0dj​=0, HHH is empty and the output matrix has no entries.

QAlgorithms.Papers.Independent.Extend50.P13.mixedThree

For every natural number ddd, including zero, and arbitrary complex d×dd\times dd×d matrices X,YX,YX,Y, this defines

2tr⁡(X)tr⁡(Y)Id−XY−YX,2\operatorname{tr}(X)\operatorname{tr}(Y)I_d-XY-YX,2tr(X)tr(Y)Id​−XY−YX,

where IdI_dId​ is the identity matrix.

QAlgorithms.Papers.Independent.Extend50.P13.monomialPermutation

For arbitrary natural numbers r,tr,tr,t, take a tensor trace monomial whose output words are wjw_jwj​, 0≤j<t0\le j<t0≤j<t, and whose closed-word list is CCC, where closed words are nonempty and every input label 0,…,r−10,\ldots,r-10,…,r−1 occurs exactly once across all words. Regard input label iii as position iii in {0,…,r+t−1}\{0,\ldots,r+t-1\}{0,…,r+t−1}, and output label jjj as position r+jr+jr+j. For each output word wj=[i1,…,iℓ]w_j=[i_1,\ldots,i_\ell]wj​=[i1​,…,iℓ​], form the cycle (i1 ⋯ iℓ r+j)(i_1\,\cdots\,i_\ell\,r+j)(i1​⋯iℓ​r+j); for each closed word [i1,…,iℓ][i_1,\ldots,i_\ell][i1​,…,iℓ​], form the cycle (i1 ⋯ iℓ)(i_1\,\cdots\,i_\ell)(i1​⋯iℓ​). This definition returns the inverse of the product of the output cycles in increasing jjj, followed by the closed cycles in their list order. A singleton cycle and an empty product are identities. The label condition makes these cycles disjoint; empty output words simply give fixed output positions. Zero input and output counts are allowed.

QAlgorithms.Papers.Independent.Extend50.P13.motzkin

For every natural number ddd, including zero, and arbitrary complex d×dd\times dd×d matrices A,BA,BA,B, this defines

AB4A+A2B2A2−3AB2A+Id.AB^4A+A^2B^2A^2-3AB^2A+I_d.AB4A+A2B2A2−3AB2A+Id​.

Powers and products are matrix powers and matrix products in the displayed order.

QAlgorithms.Papers.Independent.Extend50.P13.motzkinSquares

For every natural number ddd, including zero, and arbitrary complex d×dd\times dd×d matrices A,BA,BA,B, this defines

(A2−A)B2(A2−A)+(AB2+A2−2A)(B2A+A2−2A)+(Id−A)(Id+2A−A2)(Id−A).(A^2-A)B^2(A^2-A) +(AB^2+A^2-2A)(B^2A+A^2-2A) +(I_d-A)(I_d+2A-A^2)(I_d-A).(A2−A)B2(A2−A)+(AB2+A2−2A)(B2A+A2−2A)+(Id​−A)(Id​+2A−A2)(Id​−A).

Every IdI_dId​ denotes the d×dd\times dd×d identity, and all products retain the displayed order.

QAlgorithms.Papers.Independent.Extend50.P13.openCycleExpression

For arbitrary natural numbers d,kd,kd,k, a permutation π\piπ of {0,…,k−1}\{0,\ldots,k-1\}{0,…,k−1}, an index q<kq<kq<k, and complex d×dd\times dd×d matrices (Xi)i<k(X_i)_{i<k}(Xi​)i<k​, define L(c)L(c)L(c) to be [c][c][c] if π(c)=c\pi(c)=cπ(c)=c, and otherwise the permutation’s cycle list based at ccc, rotated one position to the left; for a list [i1,…,iℓ][i_1,\ldots,i_\ell][i1​,…,iℓ​], write XL=Xi1⋯XiℓX_L=X_{i_1}\cdots X_{i_\ell}XL​=Xi1​​⋯Xiℓ​​ in that order. This declaration defines the matrix (∏ctr⁡(XL(c)))XL(q)\left(\prod_c\operatorname{tr}(X_{L(c)})\right)X_{L(q)}(∏c​tr(XL(c)​))XL(q)​, where ccc ranges over the largest indices of those cycles whose lists do not contain qqq. The scalar product is 111 when there are no such cycles. No positivity or normalization is assumed, d=0d=0d=0 is permitted, and k=0k=0k=0 admits no argument qqq.

QAlgorithms.Papers.Independent.Extend50.P13.outputPermutation

For arbitrary natural numbers r,tr,tr,t and a permutation ρ\rhoρ of {0,…,t−1}\{0,\ldots,t-1\}{0,…,t−1}, this definition constructs a permutation of {0,…,r+t−1}\{0,\ldots,r+t-1\}{0,…,r+t−1} using the cycles of ρ\rhoρ. For a fixed point jjj, its cycle list is [j][j][j]; otherwise the cycle traversal list based at jjj is rotated one position to the left. An index jjj is selected precisely when every element in its cycle list is at most jjj, so the selected index is the largest element of its cycle. For each selected jjj, replace every label iii in that cycle list by r+ir+ir+i and form the corresponding cyclic permutation; for each unselected jjj, use the identity. Multiply these permutations in increasing jjj. Thus input positions 0,…,r−10,\ldots,r-10,…,r−1 are fixed and the output positions carry the cycles of ρ\rhoρ. Singleton cycles are identities, and t=0t=0t=0 gives the identity permutation.

QAlgorithms.Papers.Independent.Extend50.P13.outputSlot

For any natural numbers r,tr,tr,t and any index j∈{0,…,t−1}j\in\{0,\ldots,t-1\}j∈{0,…,t−1}, this defines its output position in {0,…,r+t−1}\{0,\ldots,r+t-1\}{0,…,r+t−1} to be r+jr+jr+j. Thus the output positions follow the first rrr positions. If t=0t=0t=0, there is no index jjj to supply; if r=0r=0r=0, the map preserves the numerical value of each index.

QAlgorithms.Papers.Independent.Extend50.P13.partialTraceSlot

For natural numbers d,kd,kd,k, an index q∈{0,…,k−1}q\in\{0,\ldots,k-1\}q∈{0,…,k−1}, and any complex matrix MMM indexed by assignments {0,…,k−1}→{0,…,d−1}\{0,\ldots,k-1\}\to\{0,\ldots,d-1\}{0,…,k−1}→{0,…,d−1}, this defines the complex d×dd\times dd×d matrix with entry ∑sMxa,s,xb,s\sum_s M_{x^{a,s},x^{b,s}}∑s​Mxa,s,xb,s​ at a,b∈{0,…,d−1}a,b\in\{0,\ldots,d-1\}a,b∈{0,…,d−1}. The sum runs over every assignment sss to all slots other than qqq, and xa,sx^{a,s}xa,s fills slot qqq with aaa and every other slot with its value from sss. No positivity or normalization is assumed. The argument qqq requires k>0k>0k>0. When k=1k=1k=1, the sum contains the single empty assignment; when d=0d=0d=0, the output matrix has no entries.

QAlgorithms.Papers.Independent.Extend50.P13.polarizedMap

For natural numbers d,rd,rd,r, a Young diagram λ\lambdaλ having k=r+1k=r+1k=r+1 cells and first-column length at most kkk, and arbitrary complex d×dd\times dd×d matrices X0,…,Xr−1X_0,\ldots,X_{r-1}X0​,…,Xr−1​, this defines the complex d×dd\times dd×d matrix

(polarizedMap⁡(λ,X))a,b=∑x,y:{0,…,r−1}→{0,…,d−1}(Cd,λ)(x,a),(y,b)∏i=0r−1(Xi)yi,xi,\bigl(\operatorname{polarizedMap}(\lambda,X)\bigr)_{a,b} =\sum_{x,y:\{0,\ldots,r-1\}\to\{0,\ldots,d-1\}} (C_{d,\lambda})_{(x,a),(y,b)} \prod_{i=0}^{r-1}(X_i)_{y_i,x_i},(polarizedMap(λ,X))a,b​=x,y:{0,…,r−1}→{0,…,d−1}∑​(Cd,λ​)(x,a),(y,b)​i=0∏r−1​(Xi​)yi​,xi​​,

where (x,a)(x,a)(x,a) appends aaa at position rrr, and

(Cd,λ)u,v=χλ(1)k!∑π∈Skχλ(π−1)1{u=v∘π−1}.(C_{d,\lambda})_{u,v} =\frac{\chi_\lambda(1)}{k!} \sum_{\pi\in S_k}\chi_\lambda(\pi^{-1})\mathbf 1_{\{u=v\circ\pi^{-1}\}}.(Cd,λ​)u,v​=k!χλ​(1)​π∈Sk​∑​χλ​(π−1)1{u=v∘π−1}​.

To define χλ\chi_\lambdaχλ​, use the definition’s fixed bijection between the cells of λ\lambdaλ and {0,…,k−1}\{0,\ldots,k-1\}{0,…,k−1}; let Rλ,Kλ⊆SkR_\lambda,K_\lambda\subseteq S_kRλ​,Kλ​⊆Sk​ be the permutations preserving cell rows and columns respectively, form Yg,h=∑a′∈Rλ∑b′∈Kλsgn⁡(b′)1{g=ha′b′}Y_{g,h}=\sum_{a'\in R_\lambda}\sum_{b'\in K_\lambda}\operatorname{sgn}(b')\mathbf 1_{\{g=ha'b'\}}Yg,h​=∑a′∈Rλ​​∑b′∈Kλ​​sgn(b′)1{g=ha′b′}​, let Πλ\Pi_\lambdaΠλ​ be the orthogonal projection onto the range of YYY in CSk\mathbb C^{S_k}CSk​, and put χλ(π)=tr⁡(LπΠλ)\chi_\lambda(\pi)=\operatorname{tr}(L_\pi\Pi_\lambda)χλ​(π)=tr(Lπ​Πλ​), with (Lπ)g,h=1{g=πh}(L_\pi)_{g,h}=\mathbf 1_{\{g=\pi h\}}(Lπ​)g,h​=1{g=πh}​. No positivity assumptions are imposed on the inputs. For r=0r=0r=0, the sums each range over the unique empty function and the product is 111; for d=0d=0d=0, the output matrix has no entries.

QAlgorithms.Papers.Independent.Extend50.P13.pureTraceExpansion

For arbitrary natural numbers r,tr,tr,t, let ppp be a finite list of pairs (z,τ)(z,\tau)(z,τ), where z∈Cz\in\mathbb Cz∈C and τ\tauτ is an ordered list of nonempty closed words whose concatenation contains every input label 0,…,r−10,\ldots,r-10,…,r−1 exactly once, and let ρ\rhoρ permute the ttt output labels. The definition assigns a complex coefficient to every permutation π\piπ of r+tr+tr+t slots: its coefficient is the sum of the coefficients zzz of precisely those list entries for which π\piπ equals the following permutation. Embed the input labels in the first rrr slots, form the product of the cyclic permutations given by τ\tauτ’s closed words, invert this product, and multiply it on the right by the output permutation constructed from ρ\rhoρ: choose the greatest label in each ρ\rhoρ-cycle, form the cycle on the corresponding shifted output slots r+jr+jr+j, and multiply these cycles. The cycle list used for a fixed label is its singleton; otherwise it is the ordered permutation-cycle list rotated left once. Thus repeated list entries or distinct entries producing the same permutation contribute additively, coefficients may be arbitrary complex numbers, and the empty polynomial list gives the zero coefficient function. Empty permutation products are identities, including when r=0r=0r=0 or t=0t=0t=0.

QAlgorithms.Papers.Independent.Extend50.P13.pureTracePermutation

For arbitrary natural numbers r,tr,tr,t, let a pure trace monomial consist of an ordered list of nonempty words in the input labels 0,…,r−10,\ldots,r-10,…,r−1, such that concatenating the words gives each input label exactly once, in some order, and let ρ\rhoρ be a permutation of 0,…,t−10,\ldots,t-10,…,t−1. This definition produces a permutation of 0,…,r+t−10,\ldots,r+t-10,…,r+t−1 as follows. Embed every input label iii as iii, turn each closed word into its cyclic permutation, multiply these permutations in their listed order, and invert the product. Multiply this inverse on the right by the following permutation of the output slots r,…,r+t−1r,\ldots,r+t-1r,…,r+t−1: for each cycle of ρ\rhoρ, choose its greatest label, take that label’s cycle list, replace each output label jjj by r+jr+jr+j, and form the corresponding cyclic permutation; multiply these permutations in increasing order of the chosen labels. Here a cycle list is [j][j][j] when ρ(j)=j\rho(j)=jρ(j)=j, and otherwise is the permutation’s ordered cycle list at jjj, rotated left by one position. Permutation multiplication means composition with the right factor acting first, and an empty product is the identity. In particular, r=0r=0r=0 permits no closed words, and t=0t=0t=0 contributes the identity output permutation.

QAlgorithms.Papers.Independent.Extend50.P13.rankOneOperator

For any type III and arbitrary functions v,w:I→Cv,w:I\to\mathbb Cv,w:I→C, this defines the complex matrix indexed by III with entries

(rankOneOperator⁡(v,w))a,b=vawb‾.\bigl(\operatorname{rankOneOperator}(v,w)\bigr)_{a,b} =v_a\overline{w_b}.(rankOneOperator(v,w))a,b​=va​wb​​.

No finiteness, normalization, or nonzero assumption is required. In particular, if either function is zero, the matrix is zero; if III is empty, it has no entries.

QAlgorithms.Papers.Independent.Extend50.P13.reductionPolynomial

For every natural number ddd, including d=0d=0d=0, and every complex d×dd\times dd×d matrix XXX, this defines the complex d×dd\times dd×d matrix

tr⁡(X)Id−X,\operatorname{tr}(X)I_d-X,tr(X)Id​−X,

where IdI_dId​ is the identity matrix and the trace is the sum of diagonal entries.

QAlgorithms.Papers.Independent.Extend50.P13.shadow

For any natural number nnn, natural dimensions (dj)j<n(d_j)_{j<n}(dj​)j<n​, a finite subset T⊆{0,…,n−1}T\subseteq\{0,\ldots,n-1\}T⊆{0,…,n−1}, and a complex matrix ρ\rhoρ indexed by full coordinate assignments, this defines the matrix ∑S⊆{0,…,n−1}(−1)∣S∩T∣ES\sum_{S\subseteq\{0,\ldots,n-1\}}(-1)^{|S\cap T|}E_S∑S⊆{0,…,n−1}​(−1)∣S∩T∣ES​ as follows: first form the matrix ρS(x,y)=∑zρ(x⊔z,y⊔z)\rho_S(x,y)=\sum_z\rho(x\sqcup z,y\sqcup z)ρS​(x,y)=∑z​ρ(x⊔z,y⊔z), where x,yx,yx,y assign coordinates on SSS, zzz assigns coordinates on its complement, and ⊔\sqcup⊔ joins these assignments; then set ES(a,b)=ρS(a∣S,b∣S)E_S(a,b)=\rho_S(a|_S,b|_S)ES​(a,b)=ρS​(a∣S​,b∣S​) when aaa and bbb agree outside SSS, and ES(a,b)=0E_S(a,b)=0ES​(a,b)=0 otherwise. The sum includes both the empty and full subsets. No density, positivity, or normalization condition is imposed on ρ\rhoρ. Empty coordinate products have one assignment, so for n=0n=0n=0 the result is ρ\rhoρ; zero local dimensions are also permitted.

QAlgorithms.Papers.Independent.Extend50.P13.tableFour1111

For every natural number ddd, including d=0d=0d=0, and arbitrary complex d×dd\times dd×d matrices A,B,CA,B,CA,B,C, this defines a complex d×dd\times dd×d matrix as follows. Write α=tr⁡A\alpha=\operatorname{tr}Aα=trA, β=tr⁡B\beta=\operatorname{tr}Bβ=trB, γ=tr⁡C\gamma=\operatorname{tr}Cγ=trC, and

Σ=ABC+ACB+BAC+BCA+CAB+CBA.\Sigma=ABC+ACB+BAC+BCA+CAB+CBA.Σ=ABC+ACB+BAC+BCA+CAB+CBA.

The defined matrix is

(αβγ−αtr⁡(CB)−tr⁡(BA)γ+tr⁡(CBA)+tr⁡(BCA)−tr⁡(CA)β)Id+(tr⁡(BA)−αβ)C+(tr⁡(CA)−γα)B+(tr⁡(CB)−βγ)A+α(CB+BC)+γ(BA+AB)+β(CA+AC)−Σ.\begin{aligned} &\bigl(\alpha\beta\gamma-\alpha\operatorname{tr}(CB) -\operatorname{tr}(BA)\gamma+\operatorname{tr}(CBA) +\operatorname{tr}(BCA)-\operatorname{tr}(CA)\beta\bigr)I_d\\ &\quad+\bigl(\operatorname{tr}(BA)-\alpha\beta\bigr)C +\bigl(\operatorname{tr}(CA)-\gamma\alpha\bigr)B +\bigl(\operatorname{tr}(CB)-\beta\gamma\bigr)A\\ &\quad+\alpha(CB+BC)+\gamma(BA+AB)+\beta(CA+AC)-\Sigma. \end{aligned}​(αβγ−αtr(CB)−tr(BA)γ+tr(CBA)+tr(BCA)−tr(CA)β)Id​+(tr(BA)−αβ)C+(tr(CA)−γα)B+(tr(CB)−βγ)A+α(CB+BC)+γ(BA+AB)+β(CA+AC)−Σ.​

No positivity or Hermitian assumptions are imposed on A,B,CA,B,CA,B,C; when d=0d=0d=0, the result is the unique matrix with empty row and column index sets.

QAlgorithms.Papers.Independent.Extend50.P13.tableFour211

For every natural number ddd, including d=0d=0d=0, and arbitrary complex d×dd\times dd×d matrices A,B,CA,B,CA,B,C, this declaration defines the complex d×dd\times dd×d matrix

(3Tr⁡ATr⁡BTr⁡C−Tr⁡ATr⁡(CB)−Tr⁡(BA)Tr⁡C−Tr⁡(CA)Tr⁡B)I−(Tr⁡ATr⁡B)C−(Tr⁡CTr⁡A)B−Tr⁡(BA)C+CBA+BAC+CAB−Tr⁡(CA)B+BCA+ABC−(Tr⁡BTr⁡C)A+ACB−Tr⁡(CB)A.\begin{aligned} &\left( 3\operatorname{Tr}A\operatorname{Tr}B\operatorname{Tr}C -\operatorname{Tr}A\operatorname{Tr}(CB) -\operatorname{Tr}(BA)\operatorname{Tr}C -\operatorname{Tr}(CA)\operatorname{Tr}B \right)I\\ &\quad-(\operatorname{Tr}A\operatorname{Tr}B)C -(\operatorname{Tr}C\operatorname{Tr}A)B -\operatorname{Tr}(BA)C+CBA+BAC+CAB\\ &\quad-\operatorname{Tr}(CA)B+BCA+ABC -(\operatorname{Tr}B\operatorname{Tr}C)A+ACB-\operatorname{Tr}(CB)A. \end{aligned}​(3TrATrBTrC−TrATr(CB)−Tr(BA)TrC−Tr(CA)TrB)I−(TrATrB)C−(TrCTrA)B−Tr(BA)C+CBA+BAC+CAB−Tr(CA)B+BCA+ABC−(TrBTrC)A+ACB−Tr(CB)A.​

Here III is the d×dd\times dd×d identity, all traces are complex, and matrix products have precisely the displayed order; no Hermitian or positivity assumptions are imposed.

QAlgorithms.Papers.Independent.Extend50.P13.tableFour22

For every natural number ddd, including d=0d=0d=0, and arbitrary complex d×dd\times dd×d matrices A,B,CA,B,CA,B,C, this declaration defines the complex d×dd\times dd×d matrix

(2Tr⁡ATr⁡BTr⁡C−Tr⁡(CBA)−Tr⁡(BCA))I−Tr⁡A (CB)−Tr⁡A (BC)+2Tr⁡(BA)C−Tr⁡C (BA)−Tr⁡B (CA)+2Tr⁡(CA)B−Tr⁡C (AB)−Tr⁡B (AC)+2Tr⁡(CB)A.\begin{aligned} &\left( 2\operatorname{Tr}A\operatorname{Tr}B\operatorname{Tr}C -\operatorname{Tr}(CBA)-\operatorname{Tr}(BCA) \right)I\\ &\quad-\operatorname{Tr}A\,(CB)-\operatorname{Tr}A\,(BC) +2\operatorname{Tr}(BA)C-\operatorname{Tr}C\,(BA)-\operatorname{Tr}B\,(CA)\\ &\quad+2\operatorname{Tr}(CA)B-\operatorname{Tr}C\,(AB)-\operatorname{Tr}B\,(AC) +2\operatorname{Tr}(CB)A. \end{aligned}​(2TrATrBTrC−Tr(CBA)−Tr(BCA))I−TrA(CB)−TrA(BC)+2Tr(BA)C−TrC(BA)−TrB(CA)+2Tr(CA)B−TrC(AB)−TrB(AC)+2Tr(CB)A.​

Here III is the d×dd\times dd×d identity and all traces are complex; no Hermitian or positivity assumptions are imposed.

QAlgorithms.Papers.Independent.Extend50.P13.tableFour31

For every natural number ddd, including d=0d=0d=0, and arbitrary complex d×dd\times dd×d matrices A,B,CA,B,CA,B,C, this declaration defines the complex d×dd\times dd×d matrix

(3Tr⁡ATr⁡BTr⁡C+Tr⁡ATr⁡(CB)+Tr⁡(BA)Tr⁡C+Tr⁡(CA)Tr⁡B)I+(Tr⁡ATr⁡B)C+(Tr⁡CTr⁡A)B−Tr⁡(BA)C−CBA−BAC−CAB−Tr⁡(CA)B−BCA−ABC+(Tr⁡BTr⁡C)A−ACB−Tr⁡(CB)A.\begin{aligned} &\left( 3\operatorname{Tr}A\operatorname{Tr}B\operatorname{Tr}C +\operatorname{Tr}A\operatorname{Tr}(CB) +\operatorname{Tr}(BA)\operatorname{Tr}C +\operatorname{Tr}(CA)\operatorname{Tr}B \right)I\\ &\quad+(\operatorname{Tr}A\operatorname{Tr}B)C +(\operatorname{Tr}C\operatorname{Tr}A)B -\operatorname{Tr}(BA)C-CBA-BAC-CAB\\ &\quad-\operatorname{Tr}(CA)B-BCA-ABC +(\operatorname{Tr}B\operatorname{Tr}C)A-ACB-\operatorname{Tr}(CB)A. \end{aligned}​(3TrATrBTrC+TrATr(CB)+Tr(BA)TrC+Tr(CA)TrB)I+(TrATrB)C+(TrCTrA)B−Tr(BA)C−CBA−BAC−CAB−Tr(CA)B−BCA−ABC+(TrBTrC)A−ACB−Tr(CB)A.​

Here III is the d×dd\times dd×d identity, all traces are complex, scalar juxtaposition denotes scalar multiplication when appropriate, and matrix products retain the displayed order; there are no Hermitian or positivity assumptions.

QAlgorithms.Papers.Independent.Extend50.P13.tensorFamily

For any type JJJ equipped with a finite enumeration, any dimensions dj∈Nd_j\in\mathbb Ndj​∈N, and any family of complex matrices XjX_jXj​ indexed by {0,…,dj−1}\{0,\ldots,d_j-1\}{0,…,dj​−1}, this defines a complex matrix whose rows and columns are indexed by tuples a,b∈∏j∈J{0,…,dj−1}a,b\in\prod_{j\in J}\{0,\ldots,d_j-1\}a,b∈∏j∈J​{0,…,dj​−1}, with entry

(tensorFamily⁡(d,X))a,b=∏j∈J(Xj)aj,bj.\bigl(\operatorname{tensorFamily}(d,X)\bigr)_{a,b} =\prod_{j\in J}(X_j)_{a_j,b_j}.(tensorFamily(d,X))a,b​=j∈J∏​(Xj​)aj​,bj​​.

There are no assumptions on the matrices. If JJJ is empty, the tuple index set is a singleton and the resulting matrix has its sole entry equal to 111; if some dj=0d_j=0dj​=0, the tuple index set is empty and the resulting matrix has no entries.

QAlgorithms.Papers.Independent.Extend50.P13.tensorMatrices

For any type III, any natural number rrr, and any family of complex matrices X0,…,Xr−1X_0,\ldots,X_{r-1}X0​,…,Xr−1​ with rows and columns indexed by III, this defines a complex matrix indexed by functions a,b:{0,…,r−1}→Ia,b:\{0,\ldots,r-1\}\to Ia,b:{0,…,r−1}→I, with entry

(tensorMatrices⁡(X))a,b=∏i=0r−1(Xi)ai,bi.\bigl(\operatorname{tensorMatrices}(X)\bigr)_{a,b} =\prod_{i=0}^{r-1}(X_i)_{a_i,b_i}.(tensorMatrices(X))a,b​=i=0∏r−1​(Xi​)ai​,bi​​.

No finiteness assumption on III and no conditions on the matrices are required. For r=0r=0r=0, there is exactly one indexing function, even when III is empty, and the resulting matrix has its sole entry equal to 111. If III is empty and r>0r>0r>0, the resulting matrix has no entries.

QAlgorithms.Papers.Independent.Extend50.P13.tensorPermutationExpansion

For arbitrary natural numbers r,tr,tr,t and a tensor trace polynomial ppp, this definition assigns a complex coefficient to each permutation π\piπ of {0,…,r+t−1}\{0,\ldots,r+t-1\}{0,…,r+t−1}. A term of ppp has coefficient ccc, output words wjw_jwj​, and nonempty closed words, with every input label 0,…,r−10,\ldots,r-10,…,r−1 occurring exactly once across all words. Associate to the term the inverse of the product of the cycles obtained by appending output position r+jr+jr+j to wjw_jwj​ and turning each resulting word and each closed word into a cycle. The coefficient assigned to π\piπ is the sum of ccc over all list entries whose associated permutation equals π\piπ, with every other entry contributing zero. Repeated entries contribute repeatedly and their coefficients may cancel. The empty polynomial gives zero coefficients everywhere; singleton cycles and empty products are identities, including when parameters are zero.

QAlgorithms.Papers.Independent.Extend50.P13.transposeOn

For any type JJJ, natural dimensions (dj)j∈J(d_j)_{j\in J}(dj​)j∈J​, a predicate TTT on JJJ, and a complex matrix MMM indexed by full coordinate assignments, this defines a matrix NNN by N(a,b)=M(c,e)N(a,b)=M(c,e)N(a,b)=M(c,e), where cj=bjc_j=b_jcj​=bj​ and ej=aje_j=a_jej​=aj​ when T(j)T(j)T(j) holds, while cj=ajc_j=a_jcj​=aj​ and ej=bje_j=b_jej​=bj​ otherwise. No finiteness of JJJ or positivity of MMM is required, and no complex conjugation is performed. If TTT is everywhere false this returns MMM; if it is everywhere true this returns its transpose. Zero dimensions are allowed.

QAlgorithms.Papers.Independent.Extend50.P13.verticalOperators

For natural numbers n,kn,kn,k, dimensions dj∈Nd_j\in\mathbb Ndj​∈N for 0≤j<n0\le j<n0≤j<n, and complex matrices PjP_jPj​ indexed by functions {0,…,k−1}→{0,…,dj−1}\{0,\ldots,k-1\}\to\{0,\ldots,d_j-1\}{0,…,k−1}→{0,…,dj​−1}, this defines a complex matrix indexed by functions a,ba,ba,b assigning to each i<ki<ki<k a tuple in ∏j<n{0,…,dj−1}\prod_{j<n}\{0,\ldots,d_j-1\}∏j<n​{0,…,dj​−1}, with entries

(verticalOperators⁡(d,P))a,b=∏j=0n−1(Pj)(ai,j)i<k,(bi,j)i<k.\bigl(\operatorname{verticalOperators}(d,P)\bigr)_{a,b} =\prod_{j=0}^{n-1}(P_j)_{(a_{i,j})_{i<k},(b_{i,j})_{i<k}}.(verticalOperators(d,P))a,b​=j=0∏n−1​(Pj​)(ai,j​)i<k​,(bi,j​)i<k​​.

There are no conditions on the matrices. If n=0n=0n=0, the resulting matrix has its sole entry 111. If k=0k=0k=0, it has one entry equal to the product of the sole entries of the PjP_jPj​. If k>0k>0k>0 and some dj=0d_j=0dj​=0, its index set is empty.

QAlgorithms.Papers.Independent.Extend50.P13.witnessThree

For every natural number ddd, including zero, and arbitrary complex d×dd\times dd×d matrices X,YX,YX,Y, this defines

tr⁡(XY)Id+tr⁡(X)Y+tr⁡(Y)X−XY−YX,\operatorname{tr}(XY)I_d+\operatorname{tr}(X)Y+\operatorname{tr}(Y)X-XY-YX,tr(XY)Id​+tr(X)Y+tr(Y)X−XY−YX,

where IdI_dId​ is the identity matrix.

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