Definitions for Positive maps from the walled Brauer algebra
DefinitionQAlgorithms_Papers_Independent_Extend50_P12The objects the formalized statements of Positive maps from the walled Brauer algebra (arXiv:2112.12738) are stated in. Each was checked against the paper by a blind read-back and a moderator.
LocalMatrix: One-register matrix algebra, PDF p.2.ComplexNonnegative: Complex nonnegativity includes vanishing imaginary part, PDF pp.2-3.tensorMatrices: Ordered tensor product, in the fixed product basis, PDF p.2.joinWords: Join input and output basis words without changing their order, PDF p.2.inputOutputTensor: A tensor product across the cut r|m; the m-register factor is unrestricted, so it includes operators entangled across the output sites, PDF p.6, Eq.(36).productInputContraction: Unnormalized partial-trace contraction tr_inputs[P(X_1 ⊗ ... ⊗ X_r ⊗ I)], written entrywise; the input order is X_i(b_i,a_i), PDF pp.2,6, Eqs.(1),(34).PositiveMap: Positivity on all PSD inputs, without trace normalization, PDF p.2.ComplexMultilinear: Separate complex linearity, including arbitrary matrices as inputs, PDF p.2.InputOutputBlockPositive: Block positivity for 1|...|r|[r+1,...,r+m], in its equivalent PSD trace-pairing form. The whole output is one block; the complex pairing must be real, PDF pp.3,6, Eqs.(13),(36). No PSD or normalization premise is imposed on P.transposeRegisterSet: Ordinary, basis-dependent partial transpose, with zero-based site labels, PDF p.2, Eq.(4). There is no complex conjugation.embedLeading: Embed an operator on the leading s sites and identity on the remaining sites; the suffix Kronecker delta is explicit, PDF pp.8-9, Eq.(51).permutation: Physical permutation matrices, with sigma^{-1} on the word coordinates, exactly Eq.(2) and Eq.(A2), PDF pp.2,11.contractionPairs: Product of the k disjoint, partially transposed swaps in Eq.(A12), PDF p.12. Here N=a+2k and site a+j is paired with site N-1-j.walledNormalization: The normalization in Eq.(52), PDF p.9. Both dimensions are constructed: Specht dimensions are finranks of the regular Young ideals, and Schur multiplicities are finranks of the tensor Young images.walledKernel: The constructed maximal-productInputContraction-sector kernel, Eqs.(51),(52),(A11),(A12), PDF pp.8-9,11-12. The coset sum is written as the full S_(a+k) conjugation sum divided by |S_a|=a!: the core commutes with permutations of its first a sites. The P's are full character isotypic projectors from Eq.(A6), not Young images. Nothing here assumes positivity of this computed physical matrix.walledMap: Reindex the total system count as inputs plus outputs; Eq.(53)'s overloaded n is thus split into r inputs and r+m total sites, PDF p.9.WernerDensity: Density matrix premise of the tripartite section, PDF pp.2,5.bcsWitness: The qutrit witness P(1/4,-1/10), with unnormalized Bell operators obtained by partial transposition of physical swaps, PDF p.4, Eq.(25).wernerPermutations: The six permutation operators in Eq.(26), in the order id,(12),(23),(31), (123),(321); cycles follow the global Eq.(2) convention, PDF p.5.wernerBasis: R_+,R_-,R_0,R_1,R_2,R_3 as defined in Eq.(27), PDF p.5.wernerFromCoefficients: The matrix computed by Eq.(B3), PDF p.13; c has real entries ordered +, -, 0, 1, 2, 3. It is not an unrelated free density matrix.correctedPermutationCoefficients: Coefficients forced by Eq.(27). The printed alpha_2 in Eq.(B5) is corrected from c_+/6-c_minus/6-c_2/sqrt(3) to c_+/6-c_minus/6-c_1/3+c_2/sqrt(3), PDF pp.5,13.example14Kernel: The Example-14 projector constructed from the FIRST line of Eq.(56), PDF p.9, N=4,k=1,d=2. The symmetric two-site and (2,1) three-site isotypic projectors are exactly those in Eq.(55); gamma=1.example14Map: Identify the single output register with M_2, PDF p.9, Eq.(58).example14Formula: The explicitly ordered six products and three trace terms in Eq.(58), PDF p.9; transpose is ordinary matrix transpose.reshuffleSites: Reshuffling R_(ketSite,braSite) of Eq.(44), PDF p.7, with zero-based sites. Its coefficient action swaps the indicated ket and bra coordinates.reshuffleTwo: Two-site reshuffling of Eq.(6), PDF p.2: the first bra and second ket are interchanged. This is R_(2,1) in the later notation.homogeneousTensorPair: Two-factor ordered tensor product, PDF p.2.leadingInput: A single input followed by identities on n-1 sites, PDF pp.7-8.orderedReshuffles: Apply R_(n,n-1), then R_(n,n-2), down to R_(n,1), in that order, using zero-based internal labels. This is the precise ordered sequence of Eq.(46)/(C5), PDF pp.7,14. Its domain n>=2 excludes the printed site-0 endpoint.rankOneThreeOutput: The summed kernel sum_(k,l)|alpha,k,beta><k,l,l| in Eq.(45), PDF p.7.tableSubsets: The six nonempty proper subsets in Table I order 1,2,3,12,13,23, PDF p.13. Site numbers are converted to zero-based labels.permutationExpansion: Construct the matrix in Eqs.(26),(B4) from its six permutation coefficients, PDF pp.5,13. Physical matrices avoid small-d injectivity assumptions.tripartiteF: f_S from Eq.(29), with the unnormalized partial trace, PDF p.5.tripartiteG: g_S from Eq.(30), identifying the single output with M_d, PDF p.5.tableF: All six f rows of Table I, with labelled alpha coefficients and the exact product/reshuffling order retained, PDF p.13 (Example 3 is included).tableG: All six g rows of Table I, PDF p.13. Ordinary transpose and the labelled cycle contributions have exactly their printed order.
import Mathlib
import Definitions.Def_QAlgorithms_Defs_SchurWeylDecomposition
noncomputable section
open scoped BigOperators Matrix ComplexOrder
namespace QAlgorithms.Papers.Independent.Extend50.P12
attribute [local instance] Classical.propDecidable
/-!
Reuse audit (PDF pp.2,3,6): basis labels and operator types below use Mathlib's
function spaces and `Matrix` directly; matrix units use `Matrix.single`.
The indexed frozen homonyms are different objects: Claimed50.P02.contraction
is a two-wire Bell operator; Claimed50.P37.contraction is a full Fock-space
Choi contraction with a transposed input; Claimed50.P49.BlockPositive tests
CP block matrices on arbitrary coupled vectors. Dependency50.P22.tensorTwo
is qubit-only, and Dependency50.P32.partialTranspose / Frontier18.P17.partialTranspose
transpose one factor of a bipartite product index. They cannot replace the
arbitrary-d product-input contraction, multipartite separable-block test,
homogeneous pair, or arbitrary register-set transpose defined here.
-/
/-- One-register matrix algebra, PDF p.2. -/
abbrev LocalMatrix (d : ℕ) := Matrix (Fin d) (Fin d) ℂ
/-- Complex nonnegativity includes vanishing imaginary part, PDF pp.2-3. -/
def ComplexNonnegative (z : ℂ) : Prop := z.im = 0 ∧ 0 ≤ z.re
/-- Ordered tensor product, in the fixed product basis, PDF p.2. -/
def tensorMatrices {d r : ℕ} (X : Fin r → LocalMatrix d) : Matrix (Fin r → Fin d) (Fin r → Fin d) ℂ :=
fun x y => ∏ i, X i (x i) (y i)
/-- Join input and output basis words without changing their order, PDF p.2. -/
def joinWords {d r m : ℕ} (x : (Fin r → Fin d)) (y : (Fin m → Fin d)) : (Fin (r + m) → Fin d) :=
Fin.addCases x y
/-- A tensor product across the cut r|m; the m-register factor is unrestricted,
so it includes operators entangled across the output sites, PDF p.6, Eq.(36). -/
def inputOutputTensor {d r m : ℕ} (X : Fin r → LocalMatrix d)
(C : Matrix (Fin m → Fin d) (Fin m → Fin d) ℂ) : Matrix (Fin (r + m) → Fin d) (Fin (r + m) → Fin d) ℂ :=
fun x y =>
(∏ i : Fin r, X i (x (Fin.castAdd m i)) (y (Fin.castAdd m i))) *
C (fun j => x (Fin.natAdd r j)) (fun j => y (Fin.natAdd r j))
/-- Unnormalized partial-trace contraction tr_inputs[P(X_1 ⊗ ... ⊗ X_r ⊗ I)],
written entrywise; the input order is X_i(b_i,a_i), PDF pp.2,6, Eqs.(1),(34). -/
def productInputContraction {d r m : ℕ} (P : Matrix (Fin (r + m) → Fin d) (Fin (r + m) → Fin d) ℂ)
(X : Fin r → LocalMatrix d) : Matrix (Fin m → Fin d) (Fin m → Fin d) ℂ :=
fun y z => ∑ a : (Fin r → Fin d), ∑ b : (Fin r → Fin d),
P (joinWords a y) (joinWords b z) * ∏ i, X i (b i) (a i)
/-- Positivity on all PSD inputs, without trace normalization, PDF p.2. -/
def PositiveMap {d r m : ℕ} (f : (Fin r → LocalMatrix d) → Matrix (Fin m → Fin d) (Fin m → Fin d) ℂ) : Prop :=
∀ X, (∀ i, (X i).PosSemidef) → (f X).PosSemidef
/-- Separate complex linearity, including arbitrary matrices as inputs, PDF p.2. -/
def ComplexMultilinear {d r m : ℕ}
(f : (Fin r → LocalMatrix d) → Matrix (Fin m → Fin d) (Fin m → Fin d) ℂ) : Prop :=
(∀ (i : Fin r) (X : Fin r → LocalMatrix d) (A B : LocalMatrix d),
f (Function.update X i (A + B)) =
f (Function.update X i A) + f (Function.update X i B)) ∧
(∀ (i : Fin r) (X : Fin r → LocalMatrix d) (c : ℂ) (A : LocalMatrix d),
f (Function.update X i (c • A)) = c • f (Function.update X i A))
/-- Block positivity for 1|...|r|[r+1,...,r+m], in its equivalent PSD trace-pairing
form. The whole output is one block; the complex pairing must be real, PDF
pp.3,6, Eqs.(13),(36). No PSD or normalization premise is imposed on P. -/
def InputOutputBlockPositive {d r m : ℕ} (P : Matrix (Fin (r + m) → Fin d) (Fin (r + m) → Fin d) ℂ) : Prop :=
∀ X, (∀ i, (X i).PosSemidef) → ∀ C : Matrix (Fin m → Fin d) (Fin m → Fin d) ℂ, C.PosSemidef →
ComplexNonnegative (Matrix.trace (P * inputOutputTensor X C))
/-- Ordinary, basis-dependent partial transpose, with zero-based site labels,
PDF p.2, Eq.(4). There is no complex conjugation. -/
def transposeRegisterSet {d n : ℕ} (S : Finset (Fin n)) (P : Matrix (Fin n → Fin d) (Fin n → Fin d) ℂ) :
Matrix (Fin n → Fin d) (Fin n → Fin d) ℂ :=
fun x y => P (fun i => if i ∈ S then y i else x i)
(fun i => if i ∈ S then x i else y i)
/-- Embed an operator on the leading s sites and identity on the remaining
sites; the suffix Kronecker delta is explicit, PDF pp.8-9, Eq.(51). -/
def embedLeading {d s n : ℕ} (h : s ≤ n) (P : Matrix (Fin s → Fin d) (Fin s → Fin d) ℂ) : Matrix (Fin n → Fin d) (Fin n → Fin d) ℂ :=
fun x y => P (fun i => x ⟨i.val, lt_of_lt_of_le i.isLt h⟩)
(fun i => y ⟨i.val, lt_of_lt_of_le i.isLt h⟩) *
if ∀ i : Fin n, s ≤ i.val → x i = y i then 1 else 0
/-- Physical permutation matrices, with sigma^{-1} on the word coordinates,
exactly Eq.(2) and Eq.(A2), PDF pp.2,11. -/
abbrev permutation (d n : ℕ) (pi : Equiv.Perm (Fin n)) : Matrix (Fin n → Fin d) (Fin n → Fin d) ℂ :=
QAlgorithms.Schur.tensorPermutation d n pi
/-- Product of the k disjoint, partially transposed swaps in Eq.(A12), PDF p.12.
Here N=a+2k and site a+j is paired with site N-1-j. -/
def contractionPairs (d a k : ℕ) : Matrix (Fin (a + 2 * k) → Fin d) (Fin (a + 2 * k) → Fin d) ℂ :=
(List.ofFn fun j : Fin k =>
let left : Fin (a + 2 * k) := ⟨a + j.val, by omega⟩
let right : Fin (a + 2 * k) := ⟨a + 2 * k - 1 - j.val, by omega⟩
transposeRegisterSet {right} (permutation d (a + 2 * k) (Equiv.swap left right))).prod
/-- The normalization in Eq.(52), PDF p.9. Both dimensions are constructed:
Specht dimensions are finranks of the regular Young ideals, and Schur
multiplicities are finranks of the tensor Young images. -/
def walledNormalization {d a k : ℕ} (alpha : QAlgorithms.Schur.Partition d a)
(mu : QAlgorithms.Schur.Partition d (a + k)) : ℂ :=
(k.factorial : ℂ) * ((a + k).choose k : ℂ) *
(Module.finrank ℂ (QAlgorithms.Schur.schurModule mu) : ℂ) *
(Module.finrank ℂ (QAlgorithms.Schur.spechtSpace alpha) : ℂ) /
((Module.finrank ℂ (QAlgorithms.Schur.schurModule alpha) : ℂ) *
(Module.finrank ℂ (QAlgorithms.Schur.spechtSpace mu) : ℂ))
/-- The constructed maximal-productInputContraction-sector kernel, Eqs.(51),(52),(A11),(A12),
PDF pp.8-9,11-12. The coset sum is written as the full S_(a+k) conjugation sum
divided by |S_a|=a!: the core commutes with permutations of its first a sites.
The P's are full character isotypic projectors from Eq.(A6), not Young images.
Nothing here assumes positivity of this computed physical matrix. -/
def walledKernel {d : ℕ} (a k : ℕ) (alpha : QAlgorithms.Schur.Partition d a)
(mu : QAlgorithms.Schur.Partition d (a + k)) : Matrix (Fin (a + 2 * k) → Fin d) (Fin (a + 2 * k) → Fin d) ℂ :=
(walledNormalization alpha mu)⁻¹ •
(embedLeading (by omega : a + k ≤ a + 2 * k)
(QAlgorithms.Schur.isotypicProjector mu) *
((a.factorial : ℂ)⁻¹ •
∑ eta : Equiv.Perm (Fin (a + k)),
embedLeading (by omega : a + k ≤ a + 2 * k)
(permutation d (a + k) eta⁻¹) *
(embedLeading (by omega : a ≤ a + 2 * k)
(QAlgorithms.Schur.isotypicProjector alpha) * contractionPairs d a k) *
embedLeading (by omega : a + k ≤ a + 2 * k)
(permutation d (a + k) eta)))
/-- Reindex the total system count as inputs plus outputs; Eq.(53)'s overloaded
n is thus split into r inputs and r+m total sites, PDF p.9. -/
def walledMap {d a k r m : ℕ} (h : r + m = a + 2 * k)
(alpha : QAlgorithms.Schur.Partition d a)
(mu : QAlgorithms.Schur.Partition d (a + k))
(X : Fin r → LocalMatrix d) : Matrix (Fin m → Fin d) (Fin m → Fin d) ℂ :=
productInputContraction (h.symm ▸ walledKernel a k alpha mu) X
/-- Density matrix premise of the tripartite section, PDF pp.2,5. -/
def WernerDensity {d : ℕ} (rho : Matrix (Fin 3 → Fin d) (Fin 3 → Fin d) ℂ) : Prop :=
rho.PosSemidef ∧ Matrix.trace rho = 1 ∧
∀ U : Matrix.unitaryGroup (Fin d) ℂ,
let T := tensorMatrices (fun _ : Fin 3 => (U : LocalMatrix d))
T * rho * T.conjTranspose = rho
/-- The qutrit witness P(1/4,-1/10), with unnormalized Bell operators obtained
by partial transposition of physical swaps, PDF p.4, Eq.(25). -/
def bcsWitness : Matrix (Fin 3 → Fin 3) (Fin 3 → Fin 3) ℂ :=
transposeRegisterSet {1} (permutation 3 3 (Equiv.swap 0 1)) +
permutation 3 3 (Equiv.swap 0 2) + (1 / 4 : ℂ) • 1 -
(1 / 10 : ℂ) • transposeRegisterSet {1} (permutation 3 3 (Equiv.swap 1 2))
/-- The six permutation operators in Eq.(26), in the order id,(12),(23),(31),
(123),(321); cycles follow the global Eq.(2) convention, PDF p.5. -/
def wernerPermutations (d : ℕ) : Fin 6 → Matrix (Fin 3 → Fin d) (Fin 3 → Fin d) ℂ :=
![1, permutation d 3 (Equiv.swap 0 1), permutation d 3 (Equiv.swap 1 2),
permutation d 3 (Equiv.swap 0 2),
permutation d 3 (Equiv.swap 0 1 * Equiv.swap 1 2),
permutation d 3 (Equiv.swap 1 2 * Equiv.swap 0 1)]
/-- R_+,R_-,R_0,R_1,R_2,R_3 as defined in Eq.(27), PDF p.5. -/
def wernerBasis (d : ℕ) : Fin 6 → Matrix (Fin 3 → Fin d) (Fin 3 → Fin d) ℂ :=
let V := wernerPermutations d
![(1 / 6 : ℂ) • (V 0 + V 1 + V 2 + V 3 + V 4 + V 5),
(1 / 6 : ℂ) • (V 0 - V 1 - V 2 - V 3 + V 4 + V 5),
(1 / 3 : ℂ) • ((2 : ℂ) • V 0 - V 4 - V 5),
(1 / 3 : ℂ) • ((2 : ℂ) • V 2 - V 3 - V 1),
((Real.sqrt 3 : ℂ)⁻¹) • (V 1 - V 3),
(Complex.I / (Real.sqrt 3 : ℂ)) • (V 4 - V 5)]
/-- The matrix computed by Eq.(B3), PDF p.13; c has real entries ordered
+, -, 0, 1, 2, 3. It is not an unrelated free density matrix. -/
def wernerFromCoefficients (d : ℕ) (c : Fin 6 → ℝ) : Matrix (Fin 3 → Fin d) (Fin 3 → Fin d) ℂ :=
∑ j, (c j : ℂ) • wernerBasis d j
/-- Coefficients forced by Eq.(27). The printed alpha_2 in Eq.(B5) is corrected
from c_+/6-c_minus/6-c_2/sqrt(3) to
c_+/6-c_minus/6-c_1/3+c_2/sqrt(3), PDF pp.5,13. -/
def correctedPermutationCoefficients (c : Fin 6 → ℝ) : Fin 6 → ℂ :=
let p : ℂ := c 0
let q : ℂ := c 1
let z : ℂ := c 2
let x : ℂ := c 3
let y : ℂ := c 4
let t : ℂ := c 5
![p / 6 + q / 6 + 2 * z / 3,
p / 6 - q / 6 - x / 3 + y / (Real.sqrt 3 : ℂ),
p / 6 - q / 6 + 2 * x / 3,
p / 6 - q / 6 - x / 3 - y / (Real.sqrt 3 : ℂ),
p / 6 + q / 6 - z / 3 + Complex.I * t / (Real.sqrt 3 : ℂ),
p / 6 + q / 6 - z / 3 - Complex.I * t / (Real.sqrt 3 : ℂ)]
/-- The Example-14 projector constructed from the FIRST line of Eq.(56),
PDF p.9, N=4,k=1,d=2. The symmetric two-site and (2,1) three-site isotypic
projectors are exactly those in Eq.(55); gamma=1. -/
def example14Kernel : Matrix (Fin 4 → Fin 2) (Fin 4 → Fin 2) ℂ :=
let pa := (1 / 2 : ℂ) • (1 + permutation 2 4 (Equiv.swap 0 1))
let cycle := permutation 2 4 (Equiv.swap 0 1 * Equiv.swap 1 2)
let inverseCycle := permutation 2 4 (Equiv.swap 1 2 * Equiv.swap 0 1)
let pm := (1 / 3 : ℂ) • ((2 : ℂ) • 1 - cycle - inverseCycle)
let sigma := transposeRegisterSet {3} (permutation 2 4 (Equiv.swap 2 3))
let v23 := permutation 2 4 (Equiv.swap 1 2)
let v13 := permutation 2 4 (Equiv.swap 0 2)
pm * (pa * sigma + v23 * pa * sigma * v23 + v13 * pa * sigma * v13)
/-- Identify the single output register with M_2, PDF p.9, Eq.(58). -/
def example14Map (A B C : LocalMatrix 2) : LocalMatrix 2 :=
let M := productInputContraction (r := 3) (m := 1) example14Kernel ![A, B, C]
fun i j => M (fun _ => i) (fun _ => j)
/-- The explicitly ordered six products and three trace terms in Eq.(58),
PDF p.9; transpose is ordinary matrix transpose. -/
def example14Formula (A B C : LocalMatrix 2) : LocalMatrix 2 :=
(-1 / 6 : ℂ) • ((A * C * B).transpose + (B * A * C).transpose +
(C * B * A).transpose + (A * B * C).transpose +
(B * C * A).transpose + (C * A * B).transpose) +
(1 / 3 : ℂ) • ((Matrix.trace B * Matrix.trace C) • A.transpose +
(Matrix.trace A * Matrix.trace C) • B.transpose +
(Matrix.trace A * Matrix.trace B) • C.transpose)
/-- Sanity: transposing every site is ordinary transpose, without conjugation. -/
example {d n : ℕ} (P : Matrix (Fin n → Fin d) (Fin n → Fin d) ℂ) :
transposeRegisterSet Finset.univ P = P.transpose := by
funext x y
simp [transposeRegisterSet, Matrix.transpose_apply]
/-- Sanity: no contractions means the identity on the remaining sites. -/
example (d a : ℕ) : contractionPairs d a 0 = 1 := by
simp [contractionPairs]
/-- Sanity: the first permutation is the physical identity. -/
example (d : ℕ) : wernerPermutations d 0 = 1 := by
rfl
/-- Sanity: the corrected (12) coefficient includes the R_1 contribution. -/
example (c : Fin 6 → ℝ) : correctedPermutationCoefficients c 1 =
(c 0 : ℂ) / 6 - (c 1 : ℂ) / 6 - (c 3 : ℂ) / 3 +
(c 4 : ℂ) / (Real.sqrt 3 : ℂ) := by
rfl
/-- Reshuffling R_(ketSite,braSite) of Eq.(44), PDF p.7, with zero-based sites.
Its coefficient action swaps the indicated ket and bra coordinates. -/
def reshuffleSites {d n : ℕ} (ketSite braSite : Fin n) (P : Matrix (Fin n → Fin d) (Fin n → Fin d) ℂ) :
Matrix (Fin n → Fin d) (Fin n → Fin d) ℂ :=
fun x y => P (Function.update x ketSite (y braSite))
(Function.update y braSite (x ketSite))
/-- Two-site reshuffling of Eq.(6), PDF p.2: the first bra and second ket
are interchanged. This is R_(2,1) in the later notation. -/
def reshuffleTwo {d : ℕ} (P : Matrix (Fin 2 → Fin d) (Fin 2 → Fin d) ℂ) : Matrix (Fin 2 → Fin d) (Fin 2 → Fin d) ℂ :=
reshuffleSites 1 0 P
/-- Two-factor ordered tensor product, PDF p.2. -/
def homogeneousTensorPair {d : ℕ} (A B : LocalMatrix d) : Matrix (Fin 2 → Fin d) (Fin 2 → Fin d) ℂ :=
tensorMatrices ![A, B]
/-- A single input followed by identities on n-1 sites, PDF pp.7-8. -/
def leadingInput {d : ℕ} (n : ℕ) (hn : 0 < n) (A : LocalMatrix d) : Matrix (Fin n → Fin d) (Fin n → Fin d) ℂ :=
embedLeading (by omega : 1 ≤ n) (tensorMatrices ![A])
/-- Apply R_(n,n-1), then R_(n,n-2), down to R_(n,1), in that order,
using zero-based internal labels. This is the precise ordered sequence of
Eq.(46)/(C5), PDF pp.7,14. Its domain n>=2 excludes the printed site-0 endpoint. -/
def orderedReshuffles {d : ℕ} (n : ℕ) (hn : 2 ≤ n) (P : Matrix (Fin n → Fin d) (Fin n → Fin d) ℂ) :
Matrix (Fin n → Fin d) (Fin n → Fin d) ℂ :=
((List.finRange (n - 1)).reverse).foldl
(fun M j => reshuffleSites ⟨n - 1, by omega⟩ ⟨j.val, by omega⟩ M) P
/-- The summed kernel sum_(k,l)|alpha,k,beta><k,l,l| in Eq.(45), PDF p.7. -/
def rankOneThreeOutput {d : ℕ} (alpha beta : Fin d) : Matrix (Fin 3 → Fin d) (Fin 3 → Fin d) ℂ :=
fun x y => if x 0 = alpha ∧ x 2 = beta ∧ x 1 = y 0 ∧ y 1 = y 2 then 1 else 0
/-- The six nonempty proper subsets in Table I order 1,2,3,12,13,23,
PDF p.13. Site numbers are converted to zero-based labels. -/
def tableSubsets : Fin 6 → Finset (Fin 3) :=
![{0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}]
/-- Construct the matrix in Eqs.(26),(B4) from its six permutation coefficients,
PDF pp.5,13. Physical matrices avoid small-d injectivity assumptions. -/
def permutationExpansion (d : ℕ) (alpha : Fin 6 → ℂ) : Matrix (Fin 3 → Fin d) (Fin 3 → Fin d) ℂ :=
∑ j, alpha j • wernerPermutations d j
/-- f_S from Eq.(29), with the unnormalized partial trace, PDF p.5. -/
def tripartiteF {d : ℕ} (rho : Matrix (Fin 3 → Fin d) (Fin 3 → Fin d) ℂ) (S : Finset (Fin 3))
(A : LocalMatrix d) : Matrix (Fin 2 → Fin d) (Fin 2 → Fin d) ℂ :=
productInputContraction (r := 1) (m := 2) (transposeRegisterSet S rho) ![A]
/-- g_S from Eq.(30), identifying the single output with M_d, PDF p.5. -/
def tripartiteG {d : ℕ} (rho : Matrix (Fin 3 → Fin d) (Fin 3 → Fin d) ℂ) (S : Finset (Fin 3))
(A B : LocalMatrix d) : LocalMatrix d :=
let M := productInputContraction (r := 2) (m := 1) (transposeRegisterSet S rho) ![A, B]
fun i j => M (fun _ => i) (fun _ => j)
/-- All six f rows of Table I, with labelled alpha coefficients and the exact
product/reshuffling order retained, PDF p.13 (Example 3 is included). -/
def tableF {d : ℕ} (a : Fin 6 → ℂ) (A : LocalMatrix d) : Fin 6 → Matrix (Fin 2 → Fin d) (Fin 2 → Fin d) ℂ :=
let I : LocalMatrix d := 1
let II := homogeneousTensorPair I I
let R := reshuffleTwo
let T := transposeRegisterSet ({1} : Finset (Fin 2))
let Q := A.transpose
![ (a 0 * Matrix.trace A) • II + a 1 • homogeneousTensorPair Q I +
(a 2 * Matrix.trace A) • T (R II) + a 3 • homogeneousTensorPair I Q +
a 4 • T (R (homogeneousTensorPair Q I)) + a 5 • T (R (homogeneousTensorPair I A)),
(a 0 * Matrix.trace A) • II + a 1 • homogeneousTensorPair Q I +
(a 2 * Matrix.trace A) • R II + a 3 • homogeneousTensorPair I A +
a 4 • R (homogeneousTensorPair I A) + a 5 • R (homogeneousTensorPair Q I),
(a 0 * Matrix.trace A) • II + a 1 • homogeneousTensorPair A I +
(a 2 * Matrix.trace A) • R II + a 3 • homogeneousTensorPair I Q +
a 4 • R (homogeneousTensorPair A I) + a 5 • R (homogeneousTensorPair I Q),
(a 0 * Matrix.trace A) • II + a 1 • homogeneousTensorPair A I +
(a 2 * Matrix.trace A) • R II + a 3 • homogeneousTensorPair I Q +
a 4 • R (homogeneousTensorPair I Q) + a 5 • R (homogeneousTensorPair A I),
(a 0 * Matrix.trace A) • II + a 1 • homogeneousTensorPair Q I +
(a 2 * Matrix.trace A) • R II + a 3 • homogeneousTensorPair I A +
a 4 • R (homogeneousTensorPair Q I) + a 5 • R (homogeneousTensorPair I A),
(a 0 * Matrix.trace A) • II + a 1 • homogeneousTensorPair Q I +
(a 2 * Matrix.trace A) • T (R II) + a 3 • homogeneousTensorPair I Q +
a 4 • T (R (homogeneousTensorPair I A)) + a 5 • T (R (homogeneousTensorPair Q I)) ]
/-- All six g rows of Table I, PDF p.13. Ordinary transpose and the labelled
cycle contributions have exactly their printed order. -/
def tableG {d : ℕ} (a : Fin 6 → ℂ) (A B : LocalMatrix d) : Fin 6 → LocalMatrix d :=
let I : LocalMatrix d := 1
let Q := A.transpose
let Z := B.transpose
let c := (a 0 * Matrix.trace A * Matrix.trace B) • I
![c + (a 1 * Matrix.trace (Q * B)) • I +
(a 2 * Matrix.trace A) • B + (a 3 * Matrix.trace B) • Q +
a 4 • (B * Q) + a 5 • (Q * B),
c + (a 1 * Matrix.trace (A * Z)) • I +
(a 2 * Matrix.trace A) • Z + (a 3 * Matrix.trace B) • A +
a 4 • (Z * A) + a 5 • (A * Z),
c + (a 1 * Matrix.trace (A * B)) • I +
(a 2 * Matrix.trace A) • Z + (a 3 * Matrix.trace B) • Q +
a 4 • (Q * Z) + a 5 • (Z * Q),
c + (a 1 * Matrix.trace (Q * Z)) • I +
(a 2 * Matrix.trace A) • Z + (a 3 * Matrix.trace B) • Q +
a 4 • (Z * Q) + a 5 • (Q * Z),
c + (a 1 * Matrix.trace (Q * B)) • I +
(a 2 * Matrix.trace A) • Z + (a 3 * Matrix.trace B) • A +
a 4 • (A * Z) + a 5 • (Z * A),
c + (a 1 * Matrix.trace (Q * B)) • I +
(a 2 * Matrix.trace A) • B + (a 3 * Matrix.trace B) • Q +
a 4 • (Q * B) + a 5 • (B * Q)]
end QAlgorithms.Papers.Independent.Extend50.P12
Read-back
What the Lean code literally says, in plain math · gpt-6.1-sol
QAlgorithms.Papers.Independent.Extend50.P12.ComplexMultilinear
For any natural numbers and any function taking families of complex matrices to complex matrices indexed by words , where , means that both of the following hold: for every , every input family , and all complex matrices ,
and for every , every input family , every , and every complex matrix ,
Here replaces only the th matrix of by . When , both requirements are vacuous, so every function of the specified type satisfies this condition, regardless of its value on the empty family. Zero values of and are also allowed; words of length zero form a singleton, whereas positive-length words over form an empty set.
QAlgorithms.Papers.Independent.Extend50.P12.ComplexNonnegative
For any complex number , means that and . In particular, zero satisfies this condition.
QAlgorithms.Papers.Independent.Extend50.P12.InputOutputBlockPositive
For any natural numbers and any complex matrix indexed by words , where , means that for every family of positive semidefinite complex matrices and every positive semidefinite complex matrix indexed by words , the number has imaginary part zero and nonnegative real part, where
When , the family condition is vacuous and ; when , is a positive semidefinite matrix. All zero dimensions are included: the empty product is , an empty word is unique, and if and , the trace is the empty sum .
QAlgorithms.Papers.Independent.Extend50.P12.LocalMatrix
For every natural number , denotes the space of complex matrices whose rows and columns are indexed by , that is, complex matrices. The case is included and gives the unique matrix with no rows or columns.
QAlgorithms.Papers.Independent.Extend50.P12.PositiveMap
For any natural numbers and any function taking a family of complex matrices to a complex matrix indexed by words , where , means that for every such family , if every is positive semidefinite, then is positive semidefinite. When , the input family is uniquely empty, its positivity hypothesis is vacuous, and the condition requires positivity of the single resulting output. When , that output is a matrix; if and , its index set is empty.
QAlgorithms.Papers.Independent.Extend50.P12.WernerDensity
For every natural number and every complex matrix indexed by length-three words over , this predicate means that is positive semidefinite, , and, for every unitary complex matrix ,
where is the conjugate transpose. The quantifier includes ; then the length-three word set is empty, every such matrix has trace , and the trace-one requirement cannot hold.
QAlgorithms.Papers.Independent.Extend50.P12.bcsWitness
This defines a fixed complex matrix indexed by , with register positions numbered , whose entries are
Each indicator denotes the complex number or . The first and last terms arise by exchanging the row and column coordinates at register in the swap matrices for registers and , respectively.
QAlgorithms.Papers.Independent.Extend50.P12.contractionPairs
For all natural numbers , put and let , with register positions numbered from . This defines a complex matrix indexed by as the ordered product . For , set and ; the entries of its factor are
where each indicator is interpreted as the complex number or . Equivalently, is obtained from the register-swap matrix for positions by exchanging its row and column coordinates at position . The product is in increasing order of ; when , it is the identity matrix. Zero values of and are included: if , the matrix index set is empty, while for it contains the unique empty word.
QAlgorithms.Papers.Independent.Extend50.P12.correctedPermutationCoefficients
For any six real numbers , write , , , , , and , regarding these as complex numbers. This defines the ordered six-tuple of complex numbers
The entries are indexed from to , and the input real numbers have no additional restrictions.
QAlgorithms.Papers.Independent.Extend50.P12.embedLeading
For any natural numbers satisfying and any complex matrix indexed by words , where , the defined matrix is indexed by words and has entries
When , the coordinate agreement condition is vacuous and the result is . When , has one entry and the result is that scalar times the identity on the length- word space. Zero dimensions are included: for this space has one empty word, while for and it is empty.
QAlgorithms.Papers.Independent.Extend50.P12.example14Formula
For arbitrary complex matrices , this defines the complex matrix
Here products are matrix products, scalar coefficients act by scalar multiplication, and denotes transpose without complex conjugation. No positivity, Hermitian, or trace assumptions are imposed on .
QAlgorithms.Papers.Independent.Extend50.P12.example14Kernel
This defines a fixed complex matrix on words , with register positions numbered . For a permutation of these positions, let , let exchange positions , and define
Here permutation multiplication is composition with the rightmost acting first, and is the swap matrix for positions with its row and column coordinates exchanged at position . The defined matrix is
with matrix multiplication in exactly the displayed order.
QAlgorithms.Papers.Independent.Extend50.P12.example14Map
For arbitrary complex matrices , this defines a complex matrix as follows. On four-bit words, let , let exchange zero-based register positions , and set
where permutation products are compositions with the rightmost acting first, and all indicators are complex or . Form
For , the output entry is
There are no positivity, Hermiticity, or normalization hypotheses on , and their entries in this formula are not complex-conjugated.
QAlgorithms.Papers.Independent.Extend50.P12.homogeneousTensorPair
For any natural number and arbitrary complex matrices , this defines the matrix indexed by two-letter words over whose entries are
The two input matrices are unrestricted and need not be equal. The definition includes , when its output has empty index set.
QAlgorithms.Papers.Independent.Extend50.P12.inputOutputTensor
For any natural numbers , any family of complex matrices, and any complex matrix indexed by words , where , the defined matrix is indexed by words and has entries
When , the product is and this matrix is ; when , is a matrix and its sole entry multiplies the displayed product. Zero values of are included: words of positive length over do not exist, whereas there is one empty word.
QAlgorithms.Papers.Independent.Extend50.P12.joinWords
For any natural numbers and words and , where , their defined concatenation satisfies
Either word may have length zero; if both do, the result is the unique empty word. If , such input words exist only when both lengths are zero.
QAlgorithms.Papers.Independent.Extend50.P12.leadingInput
For any natural number , any positive natural number , with a supplied hypothesis , and any complex matrix , this defines the matrix indexed by -letter words over with entries
Equivalently, it places on register and the identity on every remaining register. For , the condition on the remaining coordinates is vacuous; is allowed and gives an empty index set.
QAlgorithms.Papers.Independent.Extend50.P12.orderedReshuffles
For any natural number , any natural number with a supplied hypothesis , and any complex matrix indexed by -letter words over , define by
where replacements use the original and leave all other coordinates unchanged. This definition starts with and successively applies for , in precisely that order, returning
For there is exactly one application, . No assumption is imposed on , and is permitted, yielding matrices with empty index set.
QAlgorithms.Papers.Independent.Extend50.P12.permutation
For any natural numbers and any permutation of , the defined complex matrix has rows and columns indexed by words and entries
Equivalently, its entry is exactly when for every . When , there is one empty word and this is the matrix , including when ; when and , the matrix is empty.
QAlgorithms.Papers.Independent.Extend50.P12.permutationExpansion
For every natural number and arbitrary complex coefficients , this defines the complex matrix
on triples over , where
and permutation products apply the rightmost permutation first. No positivity, normalization, or reality condition is imposed on the coefficients. The definition includes , when the matrix has an empty row and column index set.
QAlgorithms.Papers.Independent.Extend50.P12.productInputContraction
For any natural numbers , any complex matrix indexed by words , and any family of complex matrices, where , the defined matrix is indexed by words and has entries
where concatenates words with the length- word first. When , each sum has one term and the product is , so the result is . When , the result is a matrix. When and , the sums are empty and every resulting entry is zero.
QAlgorithms.Papers.Independent.Extend50.P12.rankOneThreeOutput
For every natural number and indices , this defines a complex matrix whose rows and columns are indexed by triples in , with entries
There is no requirement that and be distinct. When , there are no choices of .
QAlgorithms.Papers.Independent.Extend50.P12.reshuffleSites
For natural numbers , register positions , and any complex matrix indexed by -letter words over , this defines the matrix by
where means replacing coordinate of by and leaving every other coordinate unchanged; both replacements use the original words . The positions need not be distinct; when they coincide, their row and column coordinates are exchanged. Supplying either position requires ; is permitted, in which case the word index set is empty.
QAlgorithms.Papers.Independent.Extend50.P12.reshuffleTwo
For any natural number and any complex matrix indexed by two-letter words over , this defines the matrix by
Thus the row coordinate at position is replaced by the original column coordinate at position , and the column coordinate at position is replaced by the original row coordinate at position . No conjugation is performed and no assumption is imposed on ; is included, yielding a matrix with empty index set.
QAlgorithms.Papers.Independent.Extend50.P12.tableF
For every natural number , arbitrary complex coefficients , and arbitrary complex matrix , this defines six complex matrices indexed by pairs over . Set , , and , where the transpose does not conjugate entries. Define
and put and . The values at indices , respectively, are
All coefficients multiply matrices as scalars. The definition also includes , when all six output matrices have empty index sets.
QAlgorithms.Papers.Independent.Extend50.P12.tableG
For every natural number , arbitrary complex coefficients , and arbitrary complex matrices , this defines six complex matrices. Write , , , , , and , with ordinary transpose and no conjugation. The values at indices , respectively, are
Products of matrices retain the displayed order. The definition includes , giving six empty matrices.
QAlgorithms.Papers.Independent.Extend50.P12.tableSubsets
This defines the following function from to finite subsets of :
QAlgorithms.Papers.Independent.Extend50.P12.tensorMatrices
For any natural numbers and any family of complex matrices, where , the defined matrix has rows and columns indexed by words and entries
When , there is one empty word and the empty product is , so this is the matrix , including when . When and , there are no indexing words and the matrix is empty.
QAlgorithms.Papers.Independent.Extend50.P12.transposeRegisterSet
For any natural numbers , any finite subset , and any complex matrix indexed by words , where , the defined matrix has entries
Thus it exchanges the row and column coordinates at precisely the positions in , without complex conjugation. For it leaves unchanged, and for it gives the ordinary transpose. When , the matrix is and unchanged; when and , it is empty.
QAlgorithms.Papers.Independent.Extend50.P12.tripartiteF
For every natural number , arbitrary complex matrix indexed by triples over , subset , and arbitrary complex matrix , this defines a complex matrix indexed by pairs over . For triples , let and when , and let and otherwise. Its entries are
Thus the coordinates selected by are exchanged between the row and column arguments of before the sum is taken. The definition permits every subset , including the empty and full subsets, and includes , when the output matrix has empty index sets.
QAlgorithms.Papers.Independent.Extend50.P12.tripartiteG
For every natural number , arbitrary complex matrix indexed by triples over , subset , and arbitrary complex matrices , this defines the complex matrix with entries
where and for , while and for . Every subset , including the empty and full subsets, is allowed. The definition includes , giving an empty matrix.
QAlgorithms.Papers.Independent.Extend50.P12.walledKernel
For natural numbers , a finite downward-closed Young diagram with cells and at most rows, and another such diagram with cells, this defines a complex matrix on words of length over as follows. For any length , let denote the permutation matrix with entries . For each , with , use its fixed chosen numbering of cells by ; let and be the permutations preserving each cell’s row and column, respectively, and define
Here acts on , while acts on . Set , , let be the orthogonal projection onto , and define
For , extend a matrix on registers to registers by
For , put , , and define
The resulting matrix is precisely
The order of all matrix factors is as displayed. No relation between and beyond their stated sizes and row bounds is assumed. Zero parameters and empty diagrams are included, empty products are identities, and complex inversion and division take value at zero; in particular, if , the resulting matrix is zero.
QAlgorithms.Papers.Independent.Extend50.P12.walledMap
For natural numbers , an equality , a finite downward-closed Young diagram with cells and at most rows, a diagram with cells and at most rows, and arbitrary complex matrices , this defines a complex matrix indexed by length- words over . The matrix used in its definition is specified by the following constructions. Write , and for a permutation of positions define on length- words. For each , with , use its fixed chosen cell numbering, let preserve the row and column of every numbered cell, respectively, and put
Let and be the complex dimensions of the ranges of on and on the length- word space, respectively. With the orthogonal projection onto the former range and , define
For , define extension to the leading registers by
For , set , , and let
Form the matrix
Then, writing for concatenation of an input word and an output word , the defined output is
Thus the input entries occur with indices , without complex conjugation. No positivity or normalization condition is imposed on the . Zero values of the natural parameters are permitted subject to the equality and the existence of the diagrams; empty products are , empty sums are , and complex inversion and division are at zero.
QAlgorithms.Papers.Independent.Extend50.P12.walledNormalization
For natural numbers , let be a finite downward-closed Young diagram with cells and at most rows, and let be such a diagram with cells and at most rows. For either diagram , write , use its fixed chosen bijection from its cells to , and let consist respectively of permutations preserving the row and the column of every numbered cell. Define a matrix on and a matrix on by
Let be the complex dimension of the range of acting on , and let be the complex dimension of the range of acting on . This definition assigns the complex number
All integer factors and dimensions are embedded into . No nonzero-denominator hypothesis is imposed; division by zero has value . Empty diagrams and or are included, with ; if , the permitted diagrams must be empty.
QAlgorithms.Papers.Independent.Extend50.P12.wernerBasis
For every natural number , consider complex matrices indexed by length-three words over . For permutations of the zero-based register positions, define , let exchange positions , and set
where products of permutations are compositions with the rightmost acting first. This definition assigns the following ordered family:
All coefficients act by complex scalar multiplication. Zero is allowed, giving matrices with empty index sets; gives and .
QAlgorithms.Papers.Independent.Extend50.P12.wernerFromCoefficients
For every natural number and arbitrary real numbers , this defines a complex matrix on length-three words over . Define , let exchange zero-based register positions , and put
with the rightmost permutation acting first in each composition. The assigned matrix is
Real coefficients are embedded into , with no sign, size, or normalization restrictions. The case is included and gives a matrix with empty index set.
QAlgorithms.Papers.Independent.Extend50.P12.wernerPermutations
For every natural number , this defines an ordered six-element family of complex matrices on length-three words over . For a permutation of the three register positions, let
and let exchange positions , numbered from . The family, indexed from through , is
Permutation multiplication is composition, so the rightmost permutation acts first. The definition includes , when the matrix index set is empty, and , when all six matrices are the same one-by-one identity matrix.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.