Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Definitions for Efficient quantum tomography II

Definition
QAlgorithms_Papers_Independent_Extend50_P32

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

prove2quantum

The objects the formalized statements of Efficient quantum tomography II (arXiv:1612.00034) are stated in. Each was checked against the paper by a blind read-back and a moderator.

  • insertRow: Bump the first strictly greater letter, retaining original occurrence IDs; equality does not bump (PDF pp.2,28-29).
  • insertRows: Propagate insertion. Each log entry records row exited, input time, and bumped occurrence (PDF pp.4,28-29).
  • rskRun: Execute actual RSK from the empty tableau; bump logs are chronological and carry original occurrence identities (PDF pp.2,4,28).
  • shape: Computed Young row list, padded by zero via row (PDF p.2).
  • row: Zero-padded real row length (PDF p.2).
  • rowPrefix: First k row total (PDF p.11).
  • WeakDominates: Prefix comparison of sorted Young rows, not containment (PDF p.4).
  • shapeDominates: Dominance includes equal total size (PDF p.4).
  • bumpedTokens: Chronological occurrences bumped out of zero-based row j (PDF pp.4,28).
  • bumpedWord: Bump-order word, forgetting IDs after selection (PDF pp.4,28).
  • originalBumpedWord: Stable original-word restriction to bumped occurrence IDs; equal values are never conflated (PDF pp.4,28).
  • wordMean: Finite iid expectation, including the unique empty word (PDF p.2).
  • swMean: Combinatorial SW expectation: pushforward of iid words by computed RSK, independent of physical weak-Schur probabilities (PDF p.2).
  • swMeanExt: Extended SW expectation; zero-weight impossible words contribute zero even if their loss is infinite (PDF pp.2,12).
  • iidWordEventProbability: Finite word-event probability (PDF pp.2,19).
  • prefixMass: Prefix mass without renormalization (PDF p.11).
  • tail: Mass strictly after the first k entries (PDF pp.7,11).
  • normalizedShapeRows: Normalized padded rows; all normalized-diagram statements require n>0 (PDF pp.3-4).
  • h2: Truncated classical Hellinger squared, no factor 1/2 (PDF p.12).
  • l2: Truncated squared Euclidean loss (PDF p.12).
  • chiTerm: Chi-squared summand: 0/0 contributes zero; a positive estimate at zero true probability contributes infinity (PDF p.12).
  • chi2: Truncated chi-squared, estimate first and truth second (PDF p.12).
  • kl: KL in nats: support violations give infinity and zero estimated mass gives zero. Signed summands are summed BEFORE conversion, not individually clipped (PDF p.12).
  • FullMetric: Full loss choices (PDF pp.4,6).
  • fullLoss: Source full losses, with their specified argument order (PDF p.12).
  • WeightedMetric: Weighted truncated loss choices (PDF pp.4,7).
  • weightedLoss: Already-truncated weighted loss (PDF p.4).
  • truncatedTV: Truncated TV: half the first-k absolute differences, no tail bin. OW16, arXiv:1508.01907v2 PDF p.3, Theorem 1.7 explicitly defines this convention; this paper's PDF p.4 uses it by reference.
  • prefixExcess: Unnormalized expected prefix excess (PDF pp.5,11,13).
  • normalizedExcess: Normalized expected prefix excess (PDF p.22).
  • spectralPrefixExcessLimit: Excess is infinite at any tied cutoff, including tied zero, following the p.15 proof. The sum is empty at k=d (PDF pp.14-15).
  • rowScale: Uniform row scale nu_k (PDF p.3).
  • rowMSE: Unnormalized row mean squared error (PDF pp.3,20).
  • rowVariance: Variance about the row's own mean (PDF p.19).
  • histogram: Word histogram (PDF pp.13-14).
  • modifiedDensity: Relative SIGNED density phi, with alpha_j cancelled before evaluation at zero last mass. Used only with n>0 and distinct probabilities (PDF pp.13-15).
  • modifiedMean: Modified multinomial signed expectation, not a probability measure (PDF p.14).
  • prefixWord: Stable word restriction to the first k letters (PDF p.16).
  • suffixWord: Stable word restriction to source letters >=k (PDF p.16).
  • quantumH2: Quantum Hellinger squared for PSD matrices, including subnormalized reports, with no factor 1/2 (PDF pp.13,25).
  • affinity: Quantum affinity, distinct from root fidelity (PDF p.13).
  • truncatedReport: Rank-k Keyl report, WITHOUT renormalizing the truncated rows (PDF pp.22,25).
  • keylRisk: Extended Hellinger risk under the concrete Keyl joint Born law, not Haar alone or a law chosen for accuracy (PDF pp.22-27).
  • keylSuccess: Success under the same public Keyl decoder (PDF pp.6-7).
  • copyBudget: Integer copy budget, rounding a real bound upward (PDF pp.6-7).
  • InducedPermutation: Any measurable Birkhoff decomposition of |V_(a,i)|^2, with pi(i)=a. No accuracy property is assumed; the theorem is independent of the choice (PDF p.23).
  • keylMean: Keyl real expectation. All uses below are bounded continuous statistics or bounded measurable permutation mixtures, hence integrable (PDF p.23).
  • permutationMean: Conditional permutation expectation in eigenbasis B; weights use B dagger V, rather than a unitary in an unrelated basis (PDF pp.23,25).
  • eydRisk: Physical EYD risk; weak-Schur projectors and decoder are fixed before the unknown state. The law depends only on its spectrum (PDF pp.5-6).
  • eydSuccess: Success event for the same physical EYD experiment (PDF pp.6-7).
  • ProperIncreasingCurve: Proper increasing graphs; no smoothness restriction (PDF p.30).
  • wordPoints: Original-word graph points (PDF p.29).
  • firstBumpPoints: Black skeleton points keep the input TIME of the bump as horizontal coordinate, rather than being reindexed in the shorter word (PDF p.29). This coordinate differs from the bumped occurrence's own original position.
  • IsChains: Disjoint increasing chains as sets of occurrence indices; empty chains and the empty family are allowed (PDF pp.2,28).
  • CurvesThrough: Proper graphs pass through every selected occurrence and are pairwise disjoint on the whole real line (PDF p.30).
  • AdmissibleChains: Full admissibility invariant (19): chains are admissible and every inadmissible point is strictly southeast of the southeasternmost curve. No output-existence certificate is built into this predicate (PDF pp.28-30).
  • adjacentProbabilityMultiplier: Adjacent multiplier in Lemmas 5.3-5.4; defined only for an actual pair of consecutive indices (PDF p.24).
  • flooredEntry: Floored list from the proof of Corollary 5.5; its first k entries stay unchanged and the next entry is zeta under the cutoff assumptions (PDF p.25).
Definition code
import Mathlib
import Definitions.Def_QAlgorithms_Defs_Learning
import Definitions.Def_QAlgorithms_Defs_QuantumInformation
import Definitions.Def_QAlgorithms_Defs_KeylTomography
import Definitions.Def_QAlgorithms_Defs_SchurWeylMeasurements
import Definitions.Def_QAlgorithms_Papers_Independent_Support50_P38
import Definitions.Def_QAlgorithms_Papers_Independent_Gap20_P17

/-! O'Donnell--Wright, Efficient quantum tomography II, arXiv:1612.00034v1.
All citations use PDF pages. Internal letter/row indices are zero based;
a prefix parameter k counts k entries. New definitions belong only to this paper. -/

noncomputable section

open MeasureTheory Filter
open scoped BigOperators ENNReal Matrix ComplexOrder Topology

namespace QAlgorithms.Papers.Independent.Extend50.P32

-- Reuse exact iid product mass and half-l1 TV from the pinned accepted library.
open QAlgorithms.Papers.Independent.Support50.P38 (wordMass tv)

-- For the density matrices below, the characteristic-polynomial identity
-- preserves all eigenvalues with multiplicity and is equivalent to unitary
-- diagonalization with these real eigenvalues. No accuracy is assumed.
open QAlgorithms.Papers.Independent.Gap20.P17 (HasSpectrum)

/-- Bump the first strictly greater letter, retaining original occurrence IDs;
equality does not bump (PDF pp.2,28-29). -/
def insertRow {A : Type*} [LinearOrder A] (a : A × ℕ) :
    List (A × ℕ) → List (A × ℕ) × Option (A × ℕ)
  | [] => ([a], none)
  | b :: row => if a.1 < b.1 then (a :: row, some b)
    else let r := insertRow a row; (b :: r.1, r.2)

/-- Propagate insertion. Each log entry records row exited, input time,
and bumped occurrence (PDF pp.4,28-29). -/
def insertRows {A : Type*} [LinearOrder A] (j t : ℕ) (a : A × ℕ) :
    List (List (A × ℕ)) → List (List (A × ℕ)) × List (ℕ × ℕ × (A × ℕ))
  | [] => ([[a]], [])
  | row :: rows =>
    let r := insertRow a row
    match r.2 with
    | none => (r.1 :: rows, [])
    | some b =>
      let s := insertRows (j + 1) t b rows
      (r.1 :: s.1, (j, t, b) :: s.2)

/-- Execute actual RSK from the empty tableau; bump logs are chronological
and carry original occurrence identities (PDF pp.2,4,28). -/
def rskRun {A : Type*} [LinearOrder A] (w : List A) :
    List (List (A × ℕ)) × List (ℕ × ℕ × (A × ℕ)) :=
  w.zipIdx.foldl (fun st a =>
    let r := insertRows 0 a.2 a st.1
    (r.1, st.2 ++ r.2)) ([], [])

/-- Computed Young row list, padded by zero via `row` (PDF p.2). -/
def shape {A : Type*} [LinearOrder A] (w : List A) : List ℕ :=
  (rskRun w).1.map List.length

/-- Zero-padded real row length (PDF p.2). -/
def row (s : List ℕ) (i : ℕ) : ℝ := ((s[i]?).getD 0 : ℕ)

/-- First k row total (PDF p.11). -/
def rowPrefix (s : List ℕ) (k : ℕ) : ℝ := (s.take k).sum

/-- Prefix comparison of sorted Young rows, not containment (PDF p.4). -/
def WeakDominates (s t : List ℕ) : Prop := ∀ k : ℕ, (t.take k).sum ≤ (s.take k).sum

/-- Dominance includes equal total size (PDF p.4). -/
def shapeDominates (s t : List ℕ) : Prop := s.sum = t.sum ∧ WeakDominates s t

/-- Chronological occurrences bumped out of zero-based row j (PDF pp.4,28). -/
def bumpedTokens {A : Type*} [LinearOrder A] (w : List A) (j : ℕ) : List (A × ℕ) :=
  ((rskRun w).2.filter (fun e => e.1 = j)).map (fun e => e.2.2)

/-- Bump-order word, forgetting IDs after selection (PDF pp.4,28). -/
def bumpedWord {A : Type*} [LinearOrder A] (w : List A) (j : ℕ) : List A :=
  (bumpedTokens w j).map Prod.fst

/-- Stable original-word restriction to bumped occurrence IDs; equal values
are never conflated (PDF pp.4,28). -/
def originalBumpedWord {A : Type*} [LinearOrder A] (w : List A) (j : ℕ) : List A :=
  (w.zipIdx.filter (fun a => a.2 ∈ (bumpedTokens w j).map Prod.snd)).map Prod.fst

/-- Finite iid expectation, including the unique empty word (PDF p.2). -/
def wordMean {d : ℕ} (alpha : Fin d → ℝ) (n : ℕ) (F : List (Fin d) → ℝ) : ℝ :=
  ∑ w : Fin n → Fin d, wordMass alpha w * F (List.ofFn w)

/-- Combinatorial SW expectation: pushforward of iid words by computed RSK,
independent of physical weak-Schur probabilities (PDF p.2). -/
def swMean {d : ℕ} (alpha : Fin d → ℝ) (n : ℕ) (F : List ℕ → ℝ) : ℝ :=
  wordMean alpha n (fun w => F (shape w))

/-- Extended SW expectation; zero-weight impossible words contribute zero
even if their loss is infinite (PDF pp.2,12). -/
def swMeanExt {d : ℕ} (alpha : Fin d → ℝ) (n : ℕ) (F : List ℕ → ℝ≥0∞) : ℝ≥0∞ :=
  ∑ w : Fin n → Fin d, ENNReal.ofReal (wordMass alpha w) * F (shape (List.ofFn w))

/-- Finite word-event probability (PDF pp.2,19). -/
def iidWordEventProbability {d : ℕ} (alpha : Fin d → ℝ) (n : ℕ) (P : List (Fin d) → Prop) : ℝ := by
  classical
  exact wordMean alpha n (fun w => if P w then 1 else 0)

/-- Prefix mass without renormalization (PDF p.11). -/
def prefixMass {d : ℕ} (alpha : Fin d → ℝ) (k : ℕ) : ℝ :=
  ∑ i, if i.val < k then alpha i else 0

/-- Mass strictly after the first k entries (PDF pp.7,11). -/
def tail {d : ℕ} (alpha : Fin d → ℝ) (k : ℕ) : ℝ :=
  ∑ i, if k ≤ i.val then alpha i else 0

/-- Normalized padded rows; all normalized-diagram statements require n>0 (PDF pp.3-4). -/
def normalizedShapeRows {d : ℕ} (n : ℕ) (s : List ℕ) : Fin d → ℝ := fun i => row s i.val / n

/-- Truncated classical Hellinger squared, no factor 1/2 (PDF p.12). -/
def h2 {d : ℕ} (k : ℕ) (a b : Fin d → ℝ) : ℝ :=
  ∑ i, if i.val < k then (Real.sqrt (a i) - Real.sqrt (b i)) ^ 2 else 0

/-- Truncated squared Euclidean loss (PDF p.12). -/
def l2 {d : ℕ} (k : ℕ) (a b : Fin d → ℝ) : ℝ :=
  ∑ i, if i.val < k then (a i - b i) ^ 2 else 0

/-- Chi-squared summand: 0/0 contributes zero; a positive estimate at zero
true probability contributes infinity (PDF p.12). -/
def chiTerm (a b : ℝ) : ℝ≥0∞ :=
  if b = 0 then (if a = 0 then 0 else ⊤) else ENNReal.ofReal ((a - b) ^ 2 / b)

/-- Truncated chi-squared, estimate first and truth second (PDF p.12). -/
def chi2 {d : ℕ} (k : ℕ) (a b : Fin d → ℝ) : ℝ≥0∞ :=
  ∑ i, if i.val < k then chiTerm (a i) (b i) else 0

/-- KL in nats: support violations give infinity and zero estimated mass gives
zero. Signed summands are summed BEFORE conversion, not individually clipped (PDF p.12). -/
def kl {d : ℕ} (a b : Fin d → ℝ) : ℝ≥0∞ := by
  classical
  exact if ∃ i, a i ≠ 0 ∧ b i = 0 then ⊤ else ENNReal.ofReal
    (∑ i, if a i = 0 then 0 else a i * Real.log (a i / b i))

/-- Full loss choices (PDF pp.4,6). -/
inductive FullMetric where
  | hellinger | kullbackLeibler | chiSquared
  deriving DecidableEq

/-- Source full losses, with their specified argument order (PDF p.12). -/
def fullLoss {d : ℕ} (metric : FullMetric) (a b : Fin d → ℝ) : ℝ≥0∞ :=
  match metric with
  | .hellinger => ENNReal.ofReal (h2 d a b)
  | .kullbackLeibler => kl a b
  | .chiSquared => chi2 d a b

/-- Weighted truncated loss choices (PDF pp.4,7). -/
inductive WeightedMetric where
  | hellinger | chiSquared
  deriving DecidableEq

/-- Already-truncated weighted loss (PDF p.4). -/
def weightedLoss {d : ℕ} (metric : WeightedMetric) (k : ℕ) (a b : Fin d → ℝ) : ℝ≥0∞ :=
  match metric with
  | .hellinger => ENNReal.ofReal (h2 k a b)
  | .chiSquared => chi2 k a b

/-- Truncated TV: half the first-k absolute differences, no tail bin.
OW16, arXiv:1508.01907v2 PDF p.3, Theorem 1.7 explicitly defines this
convention; this paper's PDF p.4 uses it by reference. -/
def truncatedTV {d : ℕ} (k : ℕ) (a b : Fin d → ℝ) : ℝ :=
  (∑ i, if i.val < k then |a i - b i| else 0) / 2

/-- Unnormalized expected prefix excess (PDF pp.5,11,13). -/
def prefixExcess {d : ℕ} (alpha : Fin d → ℝ) (k n : ℕ) : ℝ :=
  swMean alpha n (fun s => rowPrefix s k) - prefixMass alpha k * n

/-- Normalized expected prefix excess (PDF p.22). -/
def normalizedExcess {d : ℕ} (alpha : Fin d → ℝ) (k n : ℕ) : ℝ := prefixExcess alpha k n / n

/-- Excess is infinite at any tied cutoff, including tied zero, following
the p.15 proof. The sum is empty at k=d (PDF pp.14-15). -/
def spectralPrefixExcessLimit {d : ℕ} (alpha : Fin d → ℝ) (k : ℕ) : ℝ≥0∞ :=
  ∑ i, ∑ j, if i.val < k ∧ k ≤ j.val then
    (if alpha i = alpha j then ⊤ else ENNReal.ofReal (alpha j / (alpha i - alpha j))) else 0

/-- Uniform row scale nu_k (PDF p.3). -/
def rowScale {d : ℕ} (alpha : Fin d → ℝ) (k : Fin d) : ℝ := min 1 (alpha k * d)

/-- Unnormalized row mean squared error (PDF pp.3,20). -/
def rowMSE {d : ℕ} (alpha : Fin d → ℝ) (n : ℕ) (k : Fin d) : ℝ :=
  swMean alpha n (fun s => (row s k.val - alpha k * n) ^ 2)

/-- Variance about the row's own mean (PDF p.19). -/
def rowVariance {d : ℕ} (alpha : Fin d → ℝ) (n : ℕ) (k : Fin d) : ℝ :=
  swMean alpha n (fun s => (row s k.val - swMean alpha n (fun t => row t k.val)) ^ 2)

/-- Word histogram (PDF pp.13-14). -/
def histogram {d : ℕ} (w : List (Fin d)) : Fin d → ℝ := fun i => (w.count i : ℕ)

/-- Relative SIGNED density phi, with alpha_j cancelled before evaluation at
zero last mass. Used only with n>0 and distinct probabilities (PDF pp.13-15). -/
def modifiedDensity {d : ℕ} (alpha : Fin d → ℝ) (n : ℕ) (h : Fin d → ℝ) : ℝ :=
  1 + ∑ i, ∑ j, if i < j then
    (alpha j * h i / alpha i - h j) / ((alpha i - alpha j) * n) else 0

/-- Modified multinomial signed expectation, not a probability measure (PDF p.14). -/
def modifiedMean {d : ℕ} (alpha : Fin d → ℝ) (n : ℕ) (F : (Fin d → ℝ) → ℝ) : ℝ :=
  wordMean alpha n (fun w => modifiedDensity alpha n (histogram w) * F (histogram w))

/-- Stable word restriction to the first k letters (PDF p.16). -/
def prefixWord {d : ℕ} (w : List (Fin d)) (k : ℕ) : List (Fin d) := w.filter (fun a => a.val < k)

/-- Stable word restriction to source letters >=k (PDF p.16). -/
def suffixWord {d : ℕ} (w : List (Fin d)) (k : ℕ) : List (Fin d) := w.filter (fun a => k - 1 ≤ a.val)

/-- Quantum Hellinger squared for PSD matrices, including subnormalized
reports, with no factor 1/2 (PDF pp.13,25). -/
def quantumH2 {d : ℕ} (rho sigma : Matrix (Fin d) (Fin d) ℂ) : ℝ :=
  ((cfc Real.sqrt rho - cfc Real.sqrt sigma) ^ 2).trace.re

/-- Quantum affinity, distinct from root fidelity (PDF p.13). -/
def affinity {d : ℕ} (rho sigma : Matrix (Fin d) (Fin d) ℂ) : ℝ :=
  (cfc Real.sqrt rho * cfc Real.sqrt sigma).trace.re

/-- Rank-k Keyl report, WITHOUT renormalizing the truncated rows (PDF pp.22,25). -/
def truncatedReport {d n : ℕ} (hd : 0 < d) (hn : 0 < n) (k : ℕ)
    (s : Schur.Partition d n) (U : Matrix.unitaryGroup (Fin d) ℂ) : Matrix (Fin d) (Fin d) ℂ :=
  (U : Matrix _ _ ℂ) * Matrix.diagonal (fun i =>
    if i.val < k then (Schur.normalizedRows hd hn s i : ℂ) else 0) * star (U : Matrix _ _ ℂ)

/-- Extended Hellinger risk under the concrete Keyl joint Born law, not Haar
alone or a law chosen for accuracy (PDF pp.22-27). -/
def keylRisk {d n : ℕ} (hd : 0 < d) (hn : 0 < n) (k : ℕ)
    (rho : Matrix (Fin d) (Fin d) ℂ) (hRho : IsDensityMatrix rho) : ℝ≥0∞ :=
  ∫⁻ o, ENNReal.ofReal (quantumH2 (truncatedReport hd hn k o.1 o.2) rho)
    ∂Tomography.keylJointLaw hd hn rho hRho

/-- Success under the same public Keyl decoder (PDF pp.6-7). -/
def keylSuccess {d n : ℕ} (hd : 0 < d) (hn : 0 < n) (k : ℕ)
    (rho : Matrix (Fin d) (Fin d) ℂ) (hRho : IsDensityMatrix rho) (epsilon : ℝ) : ℝ≥0∞ :=
  Tomography.keylJointLaw hd hn rho hRho
    {o | quantumH2 (truncatedReport hd hn k o.1 o.2) rho ≤ epsilon}

/-- Integer copy budget, rounding a real bound upward (PDF pp.6-7). -/
def copyBudget (C rate : ℝ) : ℕ := ⌈C * rate⌉₊

/-- Any measurable Birkhoff decomposition of |V_(a,i)|^2, with pi(i)=a.
No accuracy property is assumed; the theorem is independent of the choice (PDF p.23). -/
structure InducedPermutation (d : ℕ) where
  weight : Matrix.unitaryGroup (Fin d) ℂ → Equiv.Perm (Fin d) → ℝ
  nonneg : ∀ U pi, 0 ≤ weight U pi
  total : ∀ U, ∑ pi, weight U pi = 1
  measurable : ∀ pi, Measurable (fun U => weight U pi)
  marginal : ∀ U i a, (∑ pi, if pi i = a then weight U pi else 0) =
    Complex.normSq ((U : Matrix _ _ ℂ) a i)

/-- Keyl real expectation. All uses below are bounded continuous statistics
or bounded measurable permutation mixtures, hence integrable (PDF p.23). -/
def keylMean {d n : ℕ} (hd : 0 < d) (hn : 0 < n)
    (rho : Matrix (Fin d) (Fin d) ℂ) (hRho : IsDensityMatrix rho)
    (F : Matrix.unitaryGroup (Fin d) ℂ → ℝ) : ℝ :=
  ∫ o, F o.2 ∂Tomography.keylJointLaw hd hn rho hRho

/-- Conditional permutation expectation in eigenbasis B; weights use
B dagger V, rather than a unitary in an unrelated basis (PDF pp.23,25). -/
def permutationMean {d n : ℕ} (hd : 0 < d) (hn : 0 < n)
    (rho : Matrix (Fin d) (Fin d) ℂ) (hRho : IsDensityMatrix rho)
    (B : Matrix.unitaryGroup (Fin d) ℂ) (P : InducedPermutation d)
    (F : Equiv.Perm (Fin d) → ℝ) : ℝ :=
  keylMean hd hn rho hRho (fun V => ∑ pi, P.weight (star B * V) pi * F pi)

/-- Physical EYD risk; weak-Schur projectors and decoder are fixed before
the unknown state. The law depends only on its spectrum (PDF pp.5-6). -/
def eydRisk {d n : ℕ} (hd : 0 < d) (hn : 0 < n) (alpha : Fin d → ℝ)
    (hAlpha : Learning.IsDistribution alpha) (hSorted : Antitone alpha)
    (loss : (Fin d → ℝ) → (Fin d → ℝ) → ℝ≥0∞) : ℝ≥0∞ :=
  ∫⁻ s, loss (Schur.normalizedRows hd hn s) alpha
    ∂Schur.weakSamplingLaw hd hn alpha hAlpha hSorted

/-- Success event for the same physical EYD experiment (PDF pp.6-7). -/
def eydSuccess {d n : ℕ} (hd : 0 < d) (hn : 0 < n) (alpha : Fin d → ℝ)
    (hAlpha : Learning.IsDistribution alpha) (hSorted : Antitone alpha)
    (loss : (Fin d → ℝ) → (Fin d → ℝ) → ℝ≥0∞) (epsilon : ℝ) : ℝ≥0∞ :=
  Schur.weakSamplingLaw hd hn alpha hAlpha hSorted
    {s | loss (Schur.normalizedRows hd hn s) alpha ≤ ENNReal.ofReal epsilon}

/-- Proper increasing graphs; no smoothness restriction (PDF p.30). -/
def ProperIncreasingCurve (f : ℝ → ℝ) : Prop :=
  Continuous f ∧ StrictMono f ∧ Tendsto f atTop atTop ∧ Tendsto f atBot atBot

/-- Original-word graph points (PDF p.29). -/
def wordPoints {A : Type*} (w : List A) : List (ℝ × A) :=
  w.zipIdx.map (fun a => ((a.2 : ℝ), a.1))

/-- Black skeleton points keep the input TIME of the bump as horizontal
coordinate, rather than being reindexed in the shorter word (PDF p.29).
This coordinate differs from the bumped occurrence's own original position. -/
def firstBumpPoints {A : Type*} [LinearOrder A] (w : List A) : List (ℝ × A) :=
  ((rskRun w).2.filter (fun e => e.1 = 0)).map (fun e => ((e.2.1 : ℝ), e.2.2.1))

/-- Disjoint increasing chains as sets of occurrence indices; empty chains
and the empty family are allowed (PDF pp.2,28). -/
def IsChains {A : Type*} [LinearOrder A] (w : List (ℝ × A)) {c : ℕ}
    (I : Fin c → Finset (Fin w.length)) : Prop :=
  (∀ j, ∀ u ∈ I j, ∀ v ∈ I j, u < v → (w.get u).2 ≤ (w.get v).2) ∧
    ∀ i j, i ≠ j → Disjoint (I i) (I j)

/-- Proper graphs pass through every selected occurrence and are pairwise
disjoint on the whole real line (PDF p.30). -/
def CurvesThrough {A : Type*} (e : A → ℝ) (w : List (ℝ × A)) {c : ℕ}
    (I : Fin c → Finset (Fin w.length)) (f : Fin c → ℝ → ℝ) : Prop :=
  (∀ j, ProperIncreasingCurve (f j)) ∧
    (∀ j, ∀ u ∈ I j, f j (w.get u).1 = e (w.get u).2) ∧
    ∀ i j, i ≠ j → ∀ x, f i x ≠ f j x

/-- Full admissibility invariant (19): chains are admissible and every
inadmissible point is strictly southeast of the southeasternmost curve.
No output-existence certificate is built into this predicate (PDF pp.28-30). -/
def AdmissibleChains {A : Type*} [LinearOrder A] (e : A → ℝ)
    (w : List (ℝ × A)) (admissible : Finset A) {c : ℕ}
    (I : Fin c → Finset (Fin w.length)) : Prop :=
  IsChains w I ∧ (∀ j, ∀ u ∈ I j, (w.get u).2 ∈ admissible) ∧
    ∃ f : Fin c → ℝ → ℝ, CurvesThrough e w I f ∧
      ∃ first : Fin c, (∀ j x, f first x ≤ f j x) ∧
        ∀ u : Fin w.length, (w.get u).2 ∉ admissible → e (w.get u).2 < f first (w.get u).1

/-! Sanity examples pin definitions, rather than proving the paper's results. -/

example : shape ([] : List ℕ) = [] := by rfl

example : shape ([1, 1] : List ℕ) = [2] := by rfl

example : bumpedWord ([2, 1] : List ℕ) 0 = [2] := by rfl

example : originalBumpedWord ([2, 1] : List ℕ) 0 = [2] := by rfl

example : firstBumpPoints ([2, 1] : List ℕ) = [(1, 2)] := by
  norm_num [firstBumpPoints, rskRun, insertRows, insertRow]

example : bumpedWord ([2, 3, 1, 0, 2] : List ℕ) 0 = [2, 1, 3] := by rfl

example : originalBumpedWord ([2, 3, 1, 0, 2] : List ℕ) 0 = [2, 3, 1] := by rfl

example {d : ℕ} (alpha : Fin d → ℝ) (F : List ℕ → ℝ) :
    swMean alpha 0 F = F [] := by
  simp [swMean, wordMean, wordMass, shape, rskRun]

example {d : ℕ} (a : Fin d → ℝ) : l2 d a a = 0 := by simp [l2]

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

example : row [] 0 = 0 := by simp [row]

example : chiTerm 0 0 = 0 := by simp [chiTerm]

example : chiTerm 1 0 = ⊤ := by simp [chiTerm]

example {d : ℕ} (a : Fin d → ℝ) : h2 0 a a = 0 := by simp [h2]

example {d : ℕ} (a : Fin d → ℝ) : spectralPrefixExcessLimit a d = 0 := by simp [spectralPrefixExcessLimit]

example : ProperIncreasingCurve (fun x : ℝ => x) :=
  ⟨continuous_id, strictMono_id, tendsto_id, tendsto_id⟩

example {d n : ℕ} (hd : 0 < d) (hn : 0 < n) (s : Schur.Partition d n)
    (U : Matrix.unitaryGroup (Fin d) ℂ) :
    truncatedReport hd hn d s U = Schur.estimate hd hn s U := by
  simp [truncatedReport, Schur.estimate, Schur.normalizedDiagram]

example {d n : ℕ} (hd : 0 < d) (hn : 0 < n) (s : Schur.Partition d n)
    (U : Matrix.unitaryGroup (Fin d) ℂ) : truncatedReport hd hn 0 s U = 0 := by
  simp [truncatedReport]

/-- Adjacent multiplier in Lemmas 5.3-5.4; defined only for an actual pair
of consecutive indices (PDF p.24). -/
def adjacentProbabilityMultiplier {d : ℕ} (alpha : Fin d → ℝ) (j : Fin (d - 1)) : ℝ :=
  (alpha ⟨j.val, by omega⟩ - alpha ⟨j.val + 1, by omega⟩) / alpha ⟨j.val, by omega⟩

/-- Floored list from the proof of Corollary 5.5; its first k entries stay
unchanged and the next entry is zeta under the cutoff assumptions (PDF p.25). -/
def flooredEntry {d : ℕ} (alpha : Fin d → ℝ) (zeta : ℝ) (j : ℕ) : ℝ :=
  if h : j < d then max (alpha ⟨j, h⟩) zeta else zeta

end QAlgorithms.Papers.Independent.Extend50.P32
Source
Efficient quantum tomography II, arXiv:1612.00034v1, https://arxiv.org/abs/1612.00034v1
Read-back

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

QAlgorithms.Papers.Independent.Extend50.P32.AdmissibleChains

For any linearly ordered type AAA, function e:A→Re:A\to\mathbb Re:A→R, list w=[(xu,au)]u<Nw=[(x_u,a_u)]_{u<N}w=[(xu​,au​)]u<N​, finite set S⊆AS\subseteq AS⊆A, natural number ccc, and finite index sets Ij⊆{0,…,N−1}I_j\subseteq\{0,\ldots,N-1\}Ij​⊆{0,…,N−1} indexed by j<cj<cj<c, this predicate means that the sets IjI_jIj​ are pairwise disjoint, that au≤ava_u\le a_vau​≤av​ whenever u,v∈Iju,v\in I_ju,v∈Ij​ and u<vu<vu<v, and that every selected label aua_uau​, u∈Iju\in I_ju∈Ij​, belongs to SSS. It further requires functions fj:R→Rf_j:\mathbb R\to\mathbb Rfj​:R→R, each continuous and strictly increasing with limits −∞-\infty−∞ and +∞+\infty+∞ at the respective ends of the real line, such that fj(xu)=e(au)f_j(x_u)=e(a_u)fj​(xu​)=e(au​) on IjI_jIj​ and fi(x)≠fj(x)f_i(x)\ne f_j(x)fi​(x)=fj​(x) for every real xxx whenever i≠ji\ne ji=j. There must also be an index j0<cj_0<cj0​<c with fj0(x)≤fj(x)f_{j_0}(x)\le f_j(x)fj0​​(x)≤fj​(x) for every j<cj<cj<c and real xxx, and every list entry whose label is outside SSS must satisfy e(au)<fj0(xu)e(a_u)<f_{j_0}(x_u)e(au​)<fj0​​(xu​). Entries with labels in SSS need not be selected; the index sets may be empty. The required index j0j_0j0​ makes this predicate impossible when c=0c=0c=0, including for an empty list.

QAlgorithms.Papers.Independent.Extend50.P32.CurvesThrough

For any type AAA, function e:A→Re:A\to\mathbb Re:A→R, list w=[(xu,au)]u<Nw=[(x_u,a_u)]_{u<N}w=[(xu​,au​)]u<N​, natural number ccc, finite index sets Ij⊆{0,…,N−1}I_j\subseteq\{0,\ldots,N-1\}Ij​⊆{0,…,N−1}, and functions fj:R→Rf_j:\mathbb R\to\mathbb Rfj​:R→R indexed by j<cj<cj<c, this predicate means that every fjf_jfj​ is continuous and strictly increasing, tends to +∞+\infty+∞ at +∞+\infty+∞ and to −∞-\infty−∞ at −∞-\infty−∞, satisfies fj(xu)=e(au)f_j(x_u)=e(a_u)fj​(xu​)=e(au​) for every u∈Iju\in I_ju∈Ij​, and satisfies fi(x)≠fj(x)f_i(x)\ne f_j(x)fi​(x)=fj​(x) for every real xxx whenever i≠ji\ne ji=j. No ordering or injectivity assumption is imposed on eee, and no disjointness condition is directly imposed on the sets IjI_jIj​. Empty sets impose no interpolation requirements, and for c=0c=0c=0 the entire predicate is vacuous.

QAlgorithms.Papers.Independent.Extend50.P32.FullMetric

This declares a type with exactly three distinct values, named hellinger, kullbackLeibler, and chiSquared, and supplies decidable equality between its values. The declaration itself assigns no numerical formula to these values.

QAlgorithms.Papers.Independent.Extend50.P32.InducedPermutation

For any natural number ddd, this structure consists of real weights w(U,π)w(U,\pi)w(U,π), indexed by complex unitary d×dd\times dd×d matrices UUU and permutations π\piπ of {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, together with the requirements that w(U,π)≥0w(U,\pi)\ge0w(U,π)≥0, ∑πw(U,π)=1\sum_\pi w(U,\pi)=1∑π​w(U,π)=1 for every UUU, and U↦w(U,π)U\mapsto w(U,\pi)U↦w(U,π) is measurable for every fixed π\piπ. For every UUU and indices i,ai,ai,a, it additionally requires

∑π: π(i)=aw(U,π)=∣Uai∣2.\sum_{\pi:\,\pi(i)=a}w(U,\pi)=|U_{a i}|^2.π:π(i)=a∑​w(U,π)=∣Uai​∣2.

No uniqueness of these weights is required. The case d=0d=0d=0 is included: the unique empty permutation has weight one, and the marginal requirements have no indices to check.

QAlgorithms.Papers.Independent.Extend50.P32.IsChains

For any linearly ordered type AAA, any list w=[(xu,au)]u<Nw=[(x_u,a_u)]_{u<N}w=[(xu​,au​)]u<N​ in R×A\mathbb R\times AR×A, any natural number ccc, and finite sets Ij⊆{0,…,N−1}I_j\subseteq\{0,\ldots,N-1\}Ij​⊆{0,…,N−1} indexed by j<cj<cj<c, this predicate means that au≤ava_u\le a_vau​≤av​ whenever u,v∈Iju,v\in I_ju,v∈Ij​ and u<vu<vu<v, and that Ii∩Ij=∅I_i\cap I_j=\varnothingIi​∩Ij​=∅ whenever i≠ji\ne ji=j. The ordering condition uses list positions, with no condition on the real coordinates xux_uxu​. The sets may be empty, need not cover the list, and all conditions are vacuous when c=0c=0c=0.

QAlgorithms.Papers.Independent.Extend50.P32.ProperIncreasingCurve

For any function f:R→Rf:\mathbb R\to\mathbb Rf:R→R, this predicate means that fff is continuous, strictly increasing—x<yx<yx<y implies f(x)<f(y)f(x)<f(y)f(x)<f(y)—and satisfies f(x)→+∞f(x)\to+\inftyf(x)→+∞ as x→+∞x\to+\inftyx→+∞ and f(x)→−∞f(x)\to-\inftyf(x)→−∞ as x→−∞x\to-\inftyx→−∞.

QAlgorithms.Papers.Independent.Extend50.P32.WeakDominates

For arbitrary finite lists s,ts,ts,t of natural numbers, this predicate means that, for every k∈Nk\in\mathbb Nk∈N, the sum of the first kkk entries of ttt is at most the sum of the first kkk entries of sss, taking the entire list whenever kkk exceeds its length. The condition at k=0k=0k=0 is 0≤00\leq00≤0, and indices beyond both lengths require ∑t≤∑s\sum t\leq\sum s∑t≤∑s. No sorting, equal-length, or equal-total assumption is imposed, and either list may be empty.

QAlgorithms.Papers.Independent.Extend50.P32.WeightedMetric

This defines a type with exactly two distinct choices, named hellinger and chiSquared, and supplies a decision procedure for equality between its elements.

QAlgorithms.Papers.Independent.Extend50.P32.adjacentProbabilityMultiplier

For every natural number ddd, every real-valued sequence α\alphaα indexed by {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, and every j∈{0,…,d−2}j\in\{0,\ldots,d-2\}j∈{0,…,d−2}, this defines the real number

αj−αj+1αj.\frac{\alpha_j-\alpha_{j+1}}{\alpha_j}.αj​αj​−αj+1​​.

No positivity, ordering, or normalization of α\alphaα is required. Division by zero has value 000, so the defined number is 000 when αj=0\alpha_j=0αj​=0. The index set has size max⁡{d−1,0}\max\{d-1,0\}max{d−1,0}; consequently there are no admissible jjj when d=0d=0d=0 or d=1d=1d=1.

QAlgorithms.Papers.Independent.Extend50.P32.affinity

For every natural number ddd and arbitrary complex d×dd\times dd×d matrices ρ,σ\rho,\sigmaρ,σ, this defines

Re⁡Tr⁡(S(ρ)S(σ)),S(A)=cfc⁡(⋅,A).\operatorname{Re}\operatorname{Tr}\bigl(S(\rho)S(\sigma)\bigr), \qquad S(A)=\operatorname{cfc}(\sqrt{\cdot},A).ReTr(S(ρ)S(σ)),S(A)=cfc(⋅​,A).

Here the real continuous functional calculus replaces each eigenvalue ttt of a Hermitian matrix by t\sqrt tt​, with t=0\sqrt t=0t​=0 for t≤0t\le0t≤0, and takes value zero on non-Hermitian matrices. No positivity or trace normalization is assumed. The product has the displayed order, and d=0d=0d=0 gives zero.

QAlgorithms.Papers.Independent.Extend50.P32.bumpedTokens

For any linearly ordered type AAA, finite word www over AAA, and row index j∈Nj\in\mathbb Nj∈N, this function returns the tagged tokens displaced from row jjj in the following procedure, preserving their event order. Tag the letters of www by their original positions starting at 000, and process them from left to right into initially empty rows. Insert each token into row 000, replacing the first token with strictly greater letter and passing that displaced token to the next row; append and stop if no such token exists, creating a singleton row if needed. Record every displacement with its row index, insertion position, and displaced token. Retain precisely the events whose row index is jjj and return their displaced tokens, including their original-position labels. If no displacement occurs from that row, including when www is empty, the result is empty.

QAlgorithms.Papers.Independent.Extend50.P32.bumpedWord

For any linearly ordered type AAA, finite word www over AAA, and row index j∈Nj\in\mathbb Nj∈N, this function returns the letters displaced from row jjj, in displacement order, with their original-position labels removed. The procedure tags each input letter by its position starting at 000 and inserts the tokens in word order into initially empty rows: in each row, replace the first token with strictly greater letter and pass it to the next row, or append and stop if there is no such token, creating a singleton row when necessary. Only displacements from row jjj contribute to the output; repeated letters are retained with their multiplicities. If there are no such displacements, the output is empty.

QAlgorithms.Papers.Independent.Extend50.P32.chi2

For every natural number ddd, natural number kkk, and arbitrary functions a,b:{0,…,d−1}→Ra,b:\{0,\ldots,d-1\}\to\mathbb Ra,b:{0,…,d−1}→R, this defines the sum in [0,∞][0,\infty][0,∞] over coordinates i<ki<ki<k of the following quantity: 000 if ai=bi=0a_i=b_i=0ai​=bi​=0, +∞+\infty+∞ if bi=0≠aib_i=0\ne a_ibi​=0=ai​, and max⁡{(ai−bi)2/bi,0}\max\{(a_i-b_i)^2/b_i,0\}max{(ai​−bi​)2/bi​,0} if bi≠0b_i\ne0bi​=0. No positivity or normalization is assumed; a negative bib_ibi​ contributes 000. The sum is 000 if k=0k=0k=0 or d=0d=0d=0, and includes every coordinate if k≥dk\ge dk≥d.

QAlgorithms.Papers.Independent.Extend50.P32.chiTerm

For arbitrary real numbers a,ba,ba,b, this defines an extended nonnegative real number by

{0,b=0 and a=0,+∞,b=0 and a≠0,max⁡{(a−b)2/b,0},b≠0.\begin{cases} 0,&b=0\text{ and }a=0,\\ +\infty,&b=0\text{ and }a\ne0,\\ \max\{(a-b)^2/b,0\},&b\ne0. \end{cases}⎩⎨⎧​0,+∞,max{(a−b)2/b,0},​b=0 and a=0,b=0 and a=0,b=0.​

In particular, negative bbb is permitted and gives value 000.

QAlgorithms.Papers.Independent.Extend50.P32.copyBudget

For arbitrary real numbers CCC and rate\mathrm{rate}rate, this defines the natural-number ceiling ⌈C rate⌉N\lceil C\,\mathrm{rate}\rceil_{\mathbb N}⌈Crate⌉N​: the least natural number at least C rateC\,\mathrm{rate}Crate. In particular, it is zero whenever C rate≤0C\,\mathrm{rate}\le0Crate≤0. Neither argument is assumed nonnegative.

QAlgorithms.Papers.Independent.Extend50.P32.eydRisk

For positive natural numbers d,nd,nd,n, let α=(α0,…,αd−1)\alpha=(\alpha_0,\ldots,\alpha_{d-1})α=(α0​,…,αd−1​) be a nonincreasing real vector with αi≥0\alpha_i\ge0αi​≥0 and ∑iαi=1\sum_i\alpha_i=1∑i​αi​=1, and let ℓ:(Rd)2→[0,∞]\ell:(\mathbb R^d)^2\to[0,\infty]ℓ:(Rd)2→[0,∞] be any function. This definition returns ∫−ℓ(r(λ),α) dμα(λ)\int^- \ell(r(\lambda),\alpha)\,d\mu_\alpha(\lambda)∫−ℓ(r(λ),α)dμα​(λ), where λ\lambdaλ ranges over Young diagrams with nnn cells and at most ddd rows, and r(λ)i=λi/nr(\lambda)_i=\lambda_i/nr(λ)i​=λi​/n, with λi\lambda_iλi​ the length of row iii, including zero lengths for absent rows. The measure is counting measure weighted at λ\lambdaλ by max⁡{Re⁡tr⁡(PλDα⊗n),0}\max\{\operatorname{Re}\operatorname{tr}(P_\lambda D_\alpha^{\otimes n}),0\}max{Retr(Pλ​Dα⊗n​),0}, where Dα=diag⁡(α)D_\alpha=\operatorname{diag}(\alpha)Dα​=diag(α), (Dα⊗n)x,y=∏i(Dα)xi,yi(D_\alpha^{\otimes n})_{x,y}=\prod_i(D_\alpha)_{x_i,y_i}(Dα⊗n​)x,y​=∏i​(Dα​)xi​,yi​​, and

Pλ=dim⁡Sλn!∑π∈Snχλ(π−1)Tπ,(Tπ)y,x=1{y=x∘π−1}.P_\lambda=\frac{\dim S_\lambda}{n!}\sum_{\pi\in S_n}\chi_\lambda(\pi^{-1})T_\pi, \qquad (T_\pi)_{y,x}=\mathbf1_{\{y=x\circ\pi^{-1}\}}.Pλ​=n!dimSλ​​π∈Sn​∑​χλ​(π−1)Tπ​,(Tπ​)y,x​=1{y=x∘π−1}​.

Here Sλ⊆CSnS_\lambda\subseteq\mathbb C^{S_n}Sλ​⊆CSn​ is the range of the matrix YλY_\lambdaYλ​ with entries (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}​; Rλ,CλR_\lambda,C_\lambdaRλ​,Cλ​ are the permutations preserving, respectively, the row and column of every cell under the fixed cell numbering used by the definition. Finally, χλ(π)=tr⁡(LπQλ)\chi_\lambda(\pi)=\operatorname{tr}(L_\pi Q_\lambda)χλ​(π)=tr(Lπ​Qλ​), where (Lπ)g,h=1{g=πh}(L_\pi)_{g,h}=\mathbf1_{\{g=\pi h\}}(Lπ​)g,h​=1{g=πh}​ and QλQ_\lambdaQλ​ is orthogonal projection onto SλS_\lambdaSλ​. The integral is the nonnegative extended integral and may equal +∞+\infty+∞; no measurability, finiteness, or other condition is imposed on ℓ\ellℓ.

QAlgorithms.Papers.Independent.Extend50.P32.eydSuccess

For positive natural numbers d,nd,nd,n, a nonincreasing real vector α∈Rd\alpha\in\mathbb R^dα∈Rd satisfying αi≥0\alpha_i\ge0αi​≥0 and ∑iαi=1\sum_i\alpha_i=1∑i​αi​=1, any function ℓ:(Rd)2→[0,∞]\ell:(\mathbb R^d)^2\to[0,\infty]ℓ:(Rd)2→[0,∞], and any real ϵ\epsilonϵ, this definition returns

μα{λ:ℓ((λi/n)i<d,α)≤max⁡(ϵ,0)}.\mu_\alpha\{\lambda:\ell((\lambda_i/n)_{i<d},\alpha)\le\max(\epsilon,0)\}.μα​{λ:ℓ((λi​/n)i<d​,α)≤max(ϵ,0)}.

Here λ\lambdaλ ranges over Young diagrams with nnn cells and at most ddd rows, with absent rows assigned length zero, and μα\mu_\alphaμα​ is counting measure weighted at λ\lambdaλ by max⁡{Re⁡tr⁡(PλDα⊗n),0}\max\{\operatorname{Re}\operatorname{tr}(P_\lambda D_\alpha^{\otimes n}),0\}max{Retr(Pλ​Dα⊗n​),0}, where Dα=diag⁡(α)D_\alpha=\operatorname{diag}(\alpha)Dα​=diag(α) and the tensor matrix has entries ∏i(Dα)xi,yi\prod_i(D_\alpha)_{x_i,y_i}∏i​(Dα​)xi​,yi​​. Explicitly, Pλ=(dim⁡Sλ/n!)∑π∈Snχλ(π−1)TπP_\lambda=(\dim S_\lambda/n!)\sum_{\pi\in S_n}\chi_\lambda(\pi^{-1})T_\piPλ​=(dimSλ​/n!)∑π∈Sn​​χλ​(π−1)Tπ​, with (Tπ)y,x=1{y=x∘π−1}(T_\pi)_{y,x}=\mathbf1_{\{y=x\circ\pi^{-1}\}}(Tπ​)y,x​=1{y=x∘π−1}​. To define SλS_\lambdaSλ​, fix the cell numbering used in the code, let Rλ,CλR_\lambda,C_\lambdaRλ​,Cλ​ be the permutations preserving each cell’s row and column respectively, and take the range in CSn\mathbb C^{S_n}CSn​ of the matrix with entries ∑a∈Rλ,b∈Cλsgn⁡(b)1{g=hab}\sum_{a\in R_\lambda,b\in C_\lambda}\operatorname{sgn}(b)\mathbf1_{\{g=hab\}}∑a∈Rλ​,b∈Cλ​​sgn(b)1{g=hab}​. Then χλ(π)=tr⁡(LπQλ)\chi_\lambda(\pi)=\operatorname{tr}(L_\pi Q_\lambda)χλ​(π)=tr(Lπ​Qλ​), where (Lπ)g,h=1{g=πh}(L_\pi)_{g,h}=\mathbf1_{\{g=\pi h\}}(Lπ​)g,h​=1{g=πh}​ and QλQ_\lambdaQλ​ projects orthogonally onto SλS_\lambdaSλ​. In particular, a negative ϵ\epsilonϵ still selects outcomes with loss zero; it does not automatically give an empty event.

QAlgorithms.Papers.Independent.Extend50.P32.firstBumpPoints

For any linearly ordered type AAA and finite word w=[w0,…,wN−1]w=[w_0,\ldots,w_{N-1}]w=[w0​,…,wN−1​], process the tagged letters (wt,t)(w_t,t)(wt​,t) in increasing order of ttt, starting with no rows. To insert a tagged letter into a row, replace the first entry whose letter is strictly greater than the incoming letter, passing the displaced tagged entry to the next row; if no such entry exists, append the incoming entry and stop, and if no row exists, create a singleton row. Each displacement from row jjj records (j,t,b)(j,t,b)(j,t,b), where ttt is the current input position and bbb is the displaced tagged entry; records are accumulated in insertion order, with the current displacement preceding any displacement it causes in later rows. This definition retains exactly the records with j=0j=0j=0 and returns, in their recorded order, the pairs (t,bletter)(t,b_{\mathrm{letter}})(t,bletter​), with ttt regarded as real. Thus the first coordinate is the input position that caused the displacement, while the second is the displaced letter; the displaced token’s original position is discarded. The result is empty when no displacement from row zero occurs.

QAlgorithms.Papers.Independent.Extend50.P32.flooredEntry

For every natural number ddd, every real-valued sequence α\alphaα indexed by {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, every real ζ\zetaζ, and every natural number jjj, this defines

flooredEntry⁡(α,ζ,j)={max⁡{αj,ζ},j<d,ζ,j≥d.\operatorname{flooredEntry}(\alpha,\zeta,j) = \begin{cases} \max\{\alpha_j,\zeta\},&j<d,\\ \zeta,&j\ge d. \end{cases}flooredEntry(α,ζ,j)={max{αj​,ζ},ζ,​j<d,j≥d.​

There are no positivity, ordering, or normalization assumptions on α\alphaα or ζ\zetaζ. Out-of-range indices return ζ\zetaζ; in particular, when d=0d=0d=0, every index returns ζ\zetaζ.

QAlgorithms.Papers.Independent.Extend50.P32.fullLoss

For every natural number ddd, choice of metric among Hellinger, Kullback–Leibler, and chi-squared, and arbitrary real vectors a,ba,ba,b indexed by 0,…,d−10,\ldots,d-10,…,d−1, this defines a value in [0,∞][0,\infty][0,∞]. Write [x]+=max⁡(x,0)[x]_+=\max(x,0)[x]+​=max(x,0), regarded as an extended nonnegative real. The Hellinger choice gives [∑i<d(ai−bi)2]+\bigl[\sum_{i<d}(\sqrt{a_i}-\sqrt{b_i})^2\bigr]_+[∑i<d​(ai​​−bi​​)2]+​. The Kullback–Leibler choice gives ∞\infty∞ if some i<di<di<d has ai≠0a_i\ne0ai​=0 and bi=0b_i=0bi​=0; otherwise it gives [∑i<d, ai≠0ailog⁡(ai/bi)]+\bigl[\sum_{i<d,\ a_i\ne0}a_i\log(a_i/b_i)\bigr]_+[∑i<d, ai​=0​ai​log(ai​/bi​)]+​. The chi-squared choice gives ∑i<dc(ai,bi)\sum_{i<d}c(a_i,b_i)∑i<d​c(ai​,bi​), where c(u,0)=0c(u,0)=0c(u,0)=0 when u=0u=0u=0, c(u,0)=∞c(u,0)=\inftyc(u,0)=∞ when u≠0u\ne0u=0, and c(u,v)=[(u−v)2/v]+c(u,v)=[(u-v)^2/v]_+c(u,v)=[(u−v)2/v]+​ when v≠0v\ne0v=0. No nonnegativity or normalization assumptions are imposed on either vector: real square roots of negative numbers are 000, and the real logarithm uses log⁡0=0\log0=0log0=0 and log⁡x=log⁡∣x∣\log x=\log|x|logx=log∣x∣ for x<0x<0x<0. When d=0d=0d=0, every choice gives 000.

QAlgorithms.Papers.Independent.Extend50.P32.h2

For every natural number ddd, natural number kkk, and arbitrary functions a,b:{0,…,d−1}→Ra,b:\{0,\ldots,d-1\}\to\mathbb Ra,b:{0,…,d−1}→R, this defines

∑0≤i<di<k(ai−bi)2.\sum_{\substack{0\le i<d\\ i<k}} \left(\sqrt{a_i}-\sqrt{b_i}\right)^2.0≤i<di<k​∑​(ai​​−bi​​)2.

No positivity or normalization is assumed; the real square-root function used here is 000 on negative arguments. The sum is 000 if k=0k=0k=0 or d=0d=0d=0, and includes every coordinate if k≥dk\ge dk≥d.

QAlgorithms.Papers.Independent.Extend50.P32.histogram

For every natural number ddd and finite list www of elements of {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, this defines the real vector whose coordinate iii is the number of occurrences of iii in www, converted from a natural number to a real number. These are counts without normalization by the list length. The empty list gives the zero vector; when d=0d=0d=0, the list must be empty and the resulting vector has no coordinates.

QAlgorithms.Papers.Independent.Extend50.P32.iidWordEventProbability

For every natural number ddd, arbitrary α:{0,…,d−1}→R\alpha:\{0,\ldots,d-1\}\to\mathbb Rα:{0,…,d−1}→R, natural number nnn, and predicate PPP on finite lists of elements of {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, this defines the real number

∑w:{0,…,n−1}→{0,…,d−1}(∏i=0n−1α(wi))1{P([w0,…,wn−1])}.\sum_{w:\{0,\ldots,n-1\}\to\{0,\ldots,d-1\}} \left(\prod_{i=0}^{n-1}\alpha(w_i)\right) \mathbf 1_{\{P([w_0,\ldots,w_{n-1}])\}}.w:{0,…,n−1}→{0,…,d−1}∑​(i=0∏n−1​α(wi​))1{P([w0​,…,wn−1​])}​.

There are no nonnegativity or normalization assumptions on α\alphaα, and no additional assumption on PPP. For n=0n=0n=0, this is 111 if P([])P([])P([]) holds and 000 otherwise; for d=0<nd=0<nd=0<n, it is 000.

QAlgorithms.Papers.Independent.Extend50.P32.insertRow

For any linearly ordered type AAA, token a=(x,ℓ)∈A×Na=(x,\ell)\in A\times\mathbb Na=(x,ℓ)∈A×N, and finite list of tokens, this function scans the list from left to right, comparing only the AAA components. It replaces the first token bbb whose AAA component is strictly greater than xxx by aaa, leaves all other tokens in their original order, and returns the resulting list together with bbb as the displaced token. If no such token exists, it appends aaa and returns no displaced token; in particular, the empty list becomes [a][a][a]. Equal AAA components do not cause displacement. The natural-number labels are carried along without comparison, and the input list need not be sorted.

QAlgorithms.Papers.Independent.Extend50.P32.insertRows

For any linearly ordered type AAA, natural numbers j,tj,tj,t, token a∈A×Na\in A\times\mathbb Na∈A×N, and finite list of token lists, this function inserts aaa into the first list by replacing its first token with strictly greater AAA component, or appending aaa if no such token exists. If insertion appends, it returns that updated first list followed by the unchanged remaining lists, together with an empty event list. If a token bbb is displaced, it recursively inserts bbb into the remaining lists with row counter j+1j+1j+1 and unchanged ttt, and prepends the event (j,t,b)(j,t,b)(j,t,b) to the recursively produced events. If there are no lists, it creates the single list [a][a][a] and records no event. Thus events describe displacements in successive lists, including the full displaced token; neither sorting nor any relationship between j,tj,tj,t and the token labels is required.

QAlgorithms.Papers.Independent.Extend50.P32.keylMean

For natural numbers d,n>0d,n>0d,n>0, a complex d×dd\times dd×d positive semidefinite matrix ρ\rhoρ of trace one, and any real-valued function FFF on the unitary d×dd\times dd×d matrices, this defines the real integral

∫F(U) dνρ(s,U).\int F(U)\,d\nu_\rho(s,U).∫F(U)dνρ​(s,U).

The measure is on pairs consisting of a Young diagram sss with nnn cells and at most ddd rows and a unitary matrix UUU. Relative to diagram counting measure times normalized unitary Haar measure, its density is

max⁡ ⁣{0, fscsRe⁡∏r=0d−1det⁡ ⁣((U†ρU)0:r, 0:r)ℓr(s)−ℓr+1(s)},\max\!\left\{0,\, f_s c_s\operatorname{Re} \prod_{r=0}^{d-1} \det\!\bigl((U^\dagger\rho U)_{0:r,\,0:r}\bigr)^{\ell_r(s)-\ell_{r+1}(s)} \right\},max{0,fs​cs​Rer=0∏d−1​det((U†ρU)0:r,0:r​)ℓr​(s)−ℓr+1​(s)},

where ℓr(s)\ell_r(s)ℓr​(s) is row rrr's length and 0:r0:r0:r denotes the first r+1r+1r+1 indices. The number csc_scs​ counts fillings by 0,…,d−10,\ldots,d-10,…,d−1 weakly increasing along rows and strictly increasing down columns; fsf_sfs​ is the rank of the matrix indexed by cell permutations g,hg,hg,h with entry ∑a,bsgn⁡(b)1g=hab\sum_{a,b}\operatorname{sgn}(b)\mathbf1_{g=hab}∑a,b​sgn(b)1g=hab​, where aaa preserves rows and bbb preserves columns under the fixed numbering used in the definition. No measurability or integrability hypothesis on FFF is supplied; this is the total real-valued integral, which is zero when its integrand is not integrable.

QAlgorithms.Papers.Independent.Extend50.P32.keylRisk

For natural numbers d,n>0d,n>0d,n>0, any natural number kkk, and a complex d×dd\times dd×d matrix ρ\rhoρ assumed positive semidefinite with trace one, this defines the extended nonnegative integral

∫max⁡ ⁣{0,Re⁡Tr⁡((Rk(s,U)−ρ)2)} dνρ(s,U),Rk(s,U)=Udiag⁡(1i<kℓi(s)/n)U†.\int \max\!\left\{0,\operatorname{Re}\operatorname{Tr} \bigl((\sqrt{R_k(s,U)}-\sqrt\rho)^2\bigr)\right\}\,d\nu_\rho(s,U), \quad R_k(s,U)=U\operatorname{diag}\bigl(\mathbf1_{i<k}\ell_i(s)/n\bigr)U^\dagger.∫max{0,ReTr((Rk​(s,U)​−ρ​)2)}dνρ​(s,U),Rk​(s,U)=Udiag(1i<k​ℓi​(s)/n)U†.

The outcomes are Young diagrams sss with nnn cells and at most ddd rows, together with unitary d×dd\times dd×d matrices UUU. Relative to counting measure on these diagrams times normalized Haar measure on the unitary group, νρ\nu_\rhoνρ​ has density

max⁡ ⁣{0, fscsRe⁡∏r=0d−1det⁡ ⁣((U†ρU)0:r, 0:r)ℓr(s)−ℓr+1(s)}.\max\!\left\{0,\, f_s c_s\operatorname{Re} \prod_{r=0}^{d-1} \det\!\bigl((U^\dagger\rho U)_{0:r,\,0:r}\bigr)^{\ell_r(s)-\ell_{r+1}(s)} \right\}.max{0,fs​cs​Rer=0∏d−1​det((U†ρU)0:r,0:r​)ℓr​(s)−ℓr+1​(s)}.

Here 0:r0:r0:r denotes the first r+1r+1r+1 indices, csc_scs​ counts fillings of the cells by 0,…,d−10,\ldots,d-10,…,d−1 that are weakly increasing along rows and strictly increasing down columns, and fsf_sfs​ is the rank of the matrix indexed by permutations g,hg,hg,h of the nnn cells whose entry is ∑a,bsgn⁡(b)1g=hab\sum_{a,b}\operatorname{sgn}(b)\mathbf1_{g=hab}∑a,b​sgn(b)1g=hab​, where aaa preserves rows and bbb preserves columns under the fixed cell numbering used by the definition. Matrix square roots use the real continuous functional calculus. The result may be +∞+\infty+∞; k=0k=0k=0 and k≥dk\ge dk≥d are included.

QAlgorithms.Papers.Independent.Extend50.P32.keylSuccess

For natural numbers d,n>0d,n>0d,n>0, any natural number kkk, a complex d×dd\times dd×d positive semidefinite matrix ρ\rhoρ of trace one, and any real ϵ\epsilonϵ, this defines

νρ ⁣{(s,U):Re⁡Tr⁡((Rk(s,U)−ρ)2)≤ϵ},Rk(s,U)=Udiag⁡(1i<kℓi(s)/n)U†.\nu_\rho\!\left\{(s,U): \operatorname{Re}\operatorname{Tr} \bigl((\sqrt{R_k(s,U)}-\sqrt\rho)^2\bigr)\le\epsilon \right\}, \quad R_k(s,U)=U\operatorname{diag}\bigl(\mathbf1_{i<k}\ell_i(s)/n\bigr)U^\dagger.νρ​{(s,U):ReTr((Rk​(s,U)​−ρ​)2)≤ϵ},Rk​(s,U)=Udiag(1i<k​ℓi​(s)/n)U†.

Here sss ranges over Young diagrams with nnn cells and at most ddd rows, ℓi(s)\ell_i(s)ℓi​(s) is row iii's length, and UUU ranges over unitary d×dd\times dd×d matrices. The measure νρ\nu_\rhoνρ​, relative to diagram counting measure times normalized unitary Haar measure, has density

max⁡ ⁣{0, fscsRe⁡∏r=0d−1det⁡ ⁣((U†ρU)0:r, 0:r)ℓr(s)−ℓr+1(s)}.\max\!\left\{0,\, f_s c_s\operatorname{Re} \prod_{r=0}^{d-1} \det\!\bigl((U^\dagger\rho U)_{0:r,\,0:r}\bigr)^{\ell_r(s)-\ell_{r+1}(s)} \right\}.max{0,fs​cs​Rer=0∏d−1​det((U†ρU)0:r,0:r​)ℓr​(s)−ℓr+1​(s)}.

The submatrix 0:r0:r0:r uses the first r+1r+1r+1 indices; csc_scs​ counts cell fillings by 0,…,d−10,\ldots,d-10,…,d−1 weakly increasing along rows and strictly increasing down columns; and fsf_sfs​ is the rank of the permutation-indexed matrix with entry ∑a,bsgn⁡(b)1g=hab\sum_{a,b}\operatorname{sgn}(b)\mathbf1_{g=hab}∑a,b​sgn(b)1g=hab​ at (g,h)(g,h)(g,h), with aaa row preserving and bbb column preserving under the definition's fixed cell numbering. Square roots use the real continuous functional calculus. The result lies in [0,+∞][0,+\infty][0,+∞], the event uses a non-strict inequality, and no restriction is imposed on ϵ\epsilonϵ or on kkk.

QAlgorithms.Papers.Independent.Extend50.P32.kl

For every natural number ddd and arbitrary functions a,b:{0,…,d−1}→Ra,b:\{0,\ldots,d-1\}\to\mathbb Ra,b:{0,…,d−1}→R, this defines +∞+\infty+∞ if some coordinate satisfies ai≠0a_i\ne0ai​=0 and bi=0b_i=0bi​=0; otherwise it defines

max⁡ ⁣{∑i=0d−1{0,ai=0,ailog⁡(ai/bi),ai≠0, 0}\max\!\left\{ \sum_{i=0}^{d-1} \begin{cases} 0,&a_i=0,\\ a_i\log(a_i/b_i),&a_i\ne0, \end{cases} \,0\right\}max{i=0∑d−1​{0,ai​log(ai​/bi​),​ai​=0,ai​=0,​0}

as an extended nonnegative real number. No positivity or normalization is assumed. The logarithm is the total real natural logarithm, which equals log⁡∣x∣\log|x|log∣x∣ for nonzero negative xxx and is 000 at zero; clipping at zero applies to the entire sum. For d=0d=0d=0, the value is 000.

QAlgorithms.Papers.Independent.Extend50.P32.l2

For every natural number ddd, natural number kkk, and arbitrary functions a,b:{0,…,d−1}→Ra,b:\{0,\ldots,d-1\}\to\mathbb Ra,b:{0,…,d−1}→R, this defines ∑0≤i<d, i<k(ai−bi)2\sum_{0\le i<d,\ i<k}(a_i-b_i)^2∑0≤i<d, i<k​(ai​−bi​)2. No positivity or normalization is assumed. The sum is 000 if k=0k=0k=0 or d=0d=0d=0, and includes every coordinate if k≥dk\ge dk≥d.

QAlgorithms.Papers.Independent.Extend50.P32.modifiedDensity

For every natural number ddd, arbitrary real vectors α,h\alpha,hα,h indexed by 0,…,d−10,\ldots,d-10,…,d−1, and natural number nnn, this defines the real number

1+∑0≤i<j<dαjhi/αi−hj(αi−αj)n.1+\sum_{0\le i<j<d} \frac{\alpha_jh_i/\alpha_i-h_j}{(\alpha_i-\alpha_j)n}.1+0≤i<j<d∑​(αi​−αj​)nαj​hi​/αi​−hj​​.

There are no positivity, normalization, ordering, distinctness, or nonzero-coordinate assumptions on α\alphaα, and no restrictions on hhh. All divisions use the total real-field convention that division by zero equals 000: thus a pair with αi=αj\alpha_i=\alpha_jαi​=αj​ contributes 000, and αi=0\alpha_i=0αi​=0 makes the inner quotient αjhi/αi\alpha_jh_i/\alpha_iαj​hi​/αi​ equal to 000. The value is 111 when n=0n=0n=0 or d≤1d\le1d≤1, and no nonnegativity of the result is asserted.

QAlgorithms.Papers.Independent.Extend50.P32.modifiedMean

For any natural numbers d,nd,nd,n, any function α:{0,…,d−1}→R\alpha:\{0,\ldots,d-1\}\to\mathbb Rα:{0,…,d−1}→R, and any function F:Rd→RF:\mathbb R^d\to\mathbb RF:Rd→R, this defines

∑x:{0,…,n−1}→{0,…,d−1}(∏t=0n−1αxt)(1+∑0≤i<j<dαjhi(x)/αi−hj(x)(αi−αj)n)F(h(x)),\sum_{x:\{0,\ldots,n-1\}\to\{0,\ldots,d-1\}} \left(\prod_{t=0}^{n-1}\alpha_{x_t}\right) \left(1+\sum_{0\le i<j<d} \frac{\alpha_j h_i(x)/\alpha_i-h_j(x)} {(\alpha_i-\alpha_j)n}\right)F(h(x)),x:{0,…,n−1}→{0,…,d−1}∑​(t=0∏n−1​αxt​​)​1+0≤i<j<d∑​(αi​−αj​)nαj​hi​(x)/αi​−hj​(x)​​F(h(x)),

where hi(x)h_i(x)hi​(x) is the number of positions of xxx containing iii. No positivity, normalization, or distinctness assumptions are imposed on α\alphaα. Every division is total, with division by zero equal to zero; in particular, a summand whose displayed denominator vanishes contributes zero. When n=0n=0n=0, the value is F(0)F(0)F(0), using the unique empty word and empty product 111; when d=0<nd=0<nd=0<n, the sum is empty and equals zero.

QAlgorithms.Papers.Independent.Extend50.P32.normalizedExcess

For every natural number ddd, arbitrary real vector α\alphaα indexed by 0,…,d−10,\ldots,d-10,…,d−1, and natural numbers k,nk,nk,n, this defines

∑w:{0,…,n−1}→{0,…,d−1}(∏t<nαwt)∑j<kSj(w)−n∑i<d, i<kαin.\frac{ \displaystyle\sum_{w:\{0,\ldots,n-1\}\to\{0,\ldots,d-1\}} \left(\prod_{t<n}\alpha_{w_t}\right)\sum_{j<k}S_j(w) - n\displaystyle\sum_{i<d,\ i<k}\alpha_i }{n}.nw:{0,…,n−1}→{0,…,d−1}∑​(t<n∏​αwt​​)j<k∑​Sj​(w)−ni<d, i<k∑​αi​​.

The list S(w)S(w)S(w) consists of row lengths produced from the letters of www in order: insertion into a row replaces its first strictly larger letter and passes that displaced letter to the next row; if no strictly larger letter exists, insertion appends the letter and stops, creating a row when needed. Only existing rows among the first kkk are summed. The vector α\alphaα need not be nonnegative, normalized, or sorted. Division is total, with division by zero equal to 000, so the defined value at n=0n=0n=0 is 000; it is also 000 when k=0k=0k=0 or d=0d=0d=0.

QAlgorithms.Papers.Independent.Extend50.P32.normalizedShapeRows

For every natural number ddd, natural number nnn, and arbitrary finite list sss of natural numbers, this defines a function on {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1} whose value at iii is si/ns_i/nsi​/n, with sis_isi​ interpreted as 000 when the list has no entry at index iii, and with numerator and denominator interpreted as real numbers. No condition requires sss to be a partition or to sum to nnn. When n=0n=0n=0, every value is 000 under the total real-division convention; when d=0d=0d=0, the resulting function has empty domain.

QAlgorithms.Papers.Independent.Extend50.P32.originalBumpedWord

For any linearly ordered type AAA, finite word www over AAA, and row index j∈Nj\in\mathbb Nj∈N, this function selects the original positions of tokens displaced from row jjj and returns the letters at those positions in their original order in www. To determine these positions, tag letters by their positions starting at 000 and insert them in word order into initially empty rows: replace the first token with strictly greater letter in each row and pass the displaced token to the next row, or append and stop if no such token exists, creating a singleton row if needed. Collect the original-position labels of tokens displaced from row jjj, then filter the original tagged word by membership in that collection and remove the labels. Each original position is retained at most once, regardless of its multiplicity in the collected labels; the empty word or an empty collection gives an empty output.

QAlgorithms.Papers.Independent.Extend50.P32.permutationMean

For natural numbers d,n>0d,n>0d,n>0, a complex d×dd\times dd×d positive semidefinite matrix ρ\rhoρ of trace one, a unitary d×dd\times dd×d matrix BBB, an induced-permutation structure PPP, and any real-valued function FFF on permutations of {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, this defines

∫∑πwP(B†V,π)F(π) dνρ(s,V).\int\sum_\pi w_P(B^\dagger V,\pi)F(\pi)\,d\nu_\rho(s,V).∫π∑​wP​(B†V,π)F(π)dνρ​(s,V).

The supplied structure PPP assigns nonnegative weights summing to one for each unitary argument, each weight is measurable in that argument, and ∑π:π(i)=awP(U,π)=∣Uai∣2\sum_{\pi:\pi(i)=a}w_P(U,\pi)=|U_{ai}|^2∑π:π(i)=a​wP​(U,π)=∣Uai​∣2 for every U,i,aU,i,aU,i,a. The measure νρ\nu_\rhoνρ​ is on diagrams sss with nnn cells and at most ddd rows and unitary matrices VVV; relative to diagram counting measure times normalized unitary Haar measure, its density is

max⁡ ⁣{0, fscsRe⁡∏r=0d−1det⁡ ⁣((V†ρV)0:r, 0:r)ℓr(s)−ℓr+1(s)}.\max\!\left\{0,\, f_s c_s\operatorname{Re} \prod_{r=0}^{d-1} \det\!\bigl((V^\dagger\rho V)_{0:r,\,0:r}\bigr)^{\ell_r(s)-\ell_{r+1}(s)} \right\}.max{0,fs​cs​Rer=0∏d−1​det((V†ρV)0:r,0:r​)ℓr​(s)−ℓr+1​(s)}.

Here ℓr(s)\ell_r(s)ℓr​(s) is row rrr's length, 0:r0:r0:r denotes the first r+1r+1r+1 indices, csc_scs​ counts fillings by 0,…,d−10,\ldots,d-10,…,d−1 weakly increasing along rows and strictly increasing down columns, and fsf_sfs​ is the rank of the cell-permutation matrix with entry ∑a,bsgn⁡(b)1g=hab\sum_{a,b}\operatorname{sgn}(b)\mathbf1_{g=hab}∑a,b​sgn(b)1g=hab​ at (g,h)(g,h)(g,h), using row-preserving aaa, column-preserving bbb, and the definition's fixed cell numbering.

QAlgorithms.Papers.Independent.Extend50.P32.prefixExcess

For every natural number ddd, arbitrary real vector α\alphaα indexed by 0,…,d−10,\ldots,d-10,…,d−1, and natural numbers k,nk,nk,n, this defines

∑w:{0,…,n−1}→{0,…,d−1}(∏t<nαwt)(∑j<kSj(w))−n∑i<d, i<kαi.\sum_{w:\{0,\ldots,n-1\}\to\{0,\ldots,d-1\}} \left(\prod_{t<n}\alpha_{w_t}\right) \left(\sum_{j<k}S_j(w)\right) - n\sum_{i<d,\ i<k}\alpha_i.w:{0,…,n−1}→{0,…,d−1}∑​(t<n∏​αwt​​)​j<k∑​Sj​(w)​−ni<d, i<k∑​αi​.

Here S(w)S(w)S(w) is the list of row lengths obtained by processing w0,…,wn−1w_0,\ldots,w_{n-1}w0​,…,wn−1​ in order, starting with no rows: insert a letter into the first row by replacing its first strictly larger letter and inserting the displaced letter into the next row by the same rule; if there is no strictly larger letter, append the inserted letter and stop, creating a row if necessary. The sum over j<kj<kj<k means the sum of the first kkk existing row lengths, so missing rows contribute 000. No nonnegativity, normalization, or ordering assumption is imposed on α\alphaα; the displayed sum is therefore a weighted sum without any assertion that its weights form a probability law. The value is 000 if k=0k=0k=0, n=0n=0n=0, or d=0d=0d=0.

QAlgorithms.Papers.Independent.Extend50.P32.prefixMass

For every natural number ddd, arbitrary α:{0,…,d−1}→R\alpha:\{0,\ldots,d-1\}\to\mathbb Rα:{0,…,d−1}→R, and natural number kkk, this defines ∑0≤i<d, i<kαi\sum_{0\le i<d,\ i<k}\alpha_i∑0≤i<d, i<k​αi​. No nonnegativity or normalization is assumed. The value is 000 when k=0k=0k=0 or d=0d=0d=0, and is the sum of all entries when k≥dk\ge dk≥d.

QAlgorithms.Papers.Independent.Extend50.P32.prefixWord

For every natural number ddd, every finite list www with entries in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, and every natural number kkk, this defines the list obtained by retaining exactly those entries of www whose numerical values are strictly less than kkk, preserving their order and repetitions. For k=0k=0k=0 the result is empty, and for k≥dk\ge dk≥d it is www; d=0d=0d=0 is allowed, in which case www is necessarily empty.

QAlgorithms.Papers.Independent.Extend50.P32.quantumH2

For every natural number ddd and arbitrary complex d×dd\times dd×d matrices ρ,σ\rho,\sigmaρ,σ, this defines the real number

Re⁡Tr⁡((S(ρ)−S(σ))2),S(A)=cfc⁡(⋅,A),\operatorname{Re}\operatorname{Tr}\bigl((S(\rho)-S(\sigma))^2\bigr), \qquad S(A)=\operatorname{cfc}(\sqrt{\cdot},A),ReTr((S(ρ)−S(σ))2),S(A)=cfc(⋅​,A),

where SSS uses the real continuous functional calculus. For Hermitian AAA, it replaces each eigenvalue ttt by the real square root t\sqrt tt​, which is zero for t≤0t\le0t≤0; for a non-Hermitian matrix the functional calculus takes its totalized value zero. There are no assumptions that the matrices are positive semidefinite or have trace one. The square is matrix multiplication, and the value is zero when d=0d=0d=0.

QAlgorithms.Papers.Independent.Extend50.P32.row

For any finite list sss of natural numbers and any natural-number index iii, this function returns the entry at position iii, counting from 000, as a real number. If iii is at least the length of sss, it returns 000; consequently, every index gives 000 for the empty list.

QAlgorithms.Papers.Independent.Extend50.P32.rowMSE

For every natural number ddd, arbitrary real vector α\alphaα indexed by 0,…,d−10,\ldots,d-10,…,d−1, natural number nnn, and index kkk with 0≤k<d0\le k<d0≤k<d, this defines

∑w:{0,…,n−1}→{0,…,d−1}(∏t<nαwt)(Sk(w)−nαk)2.\sum_{w:\{0,\ldots,n-1\}\to\{0,\ldots,d-1\}} \left(\prod_{t<n}\alpha_{w_t}\right) \bigl(S_k(w)-n\alpha_k\bigr)^2.w:{0,…,n−1}→{0,…,d−1}∑​(t<n∏​αwt​​)(Sk​(w)−nαk​)2.

Here Sk(w)S_k(w)Sk​(w) is the length of row kkk, counting from 000, and is 000 if that row is absent. The rows are built by processing the letters of www in order: insertion replaces the first strictly larger letter in the current row and passes the displaced letter to the next row; if none exists, it appends the letter and stops, creating a row if necessary. No nonnegativity, normalization, or sorting assumption is imposed on α\alphaα, so the weighted sum is not asserted to be nonnegative or to be an expectation under a probability law. For n=0n=0n=0 it equals 000; for d=0d=0d=0 no index kkk exists.

QAlgorithms.Papers.Independent.Extend50.P32.rowPrefix

For any finite list sss of natural numbers and any k∈Nk\in\mathbb Nk∈N, this function returns, as a real number, the sum of the first min⁡(k,length⁡(s))\min(k,\operatorname{length}(s))min(k,length(s)) entries of sss. It returns 000 when k=0k=0k=0 or sss is empty, and the sum of the entire list when kkk exceeds its length.

QAlgorithms.Papers.Independent.Extend50.P32.rowScale

For every natural number ddd, arbitrary real vector α\alphaα indexed by 0,…,d−10,\ldots,d-10,…,d−1, and index kkk with 0≤k<d0\le k<d0≤k<d, this defines min⁡(1,dαk)\min(1,d\alpha_k)min(1,dαk​). No positivity or normalization assumption is imposed on α\alphaα, so the value may be negative. The index argument cannot exist when d=0d=0d=0.

QAlgorithms.Papers.Independent.Extend50.P32.rowVariance

For every natural number ddd, arbitrary real vector α\alphaα indexed by 0,…,d−10,\ldots,d-10,…,d−1, natural number nnn, and index kkk with 0≤k<d0\le k<d0≤k<d, let

m=∑w:{0,…,n−1}→{0,…,d−1}(∏t<nαwt)Sk(w).m=\sum_{w:\{0,\ldots,n-1\}\to\{0,\ldots,d-1\}} \left(\prod_{t<n}\alpha_{w_t}\right)S_k(w).m=w:{0,…,n−1}→{0,…,d−1}∑​(t<n∏​αwt​​)Sk​(w).

This defines ∑w(∏t<nαwt)(Sk(w)−m)2\sum_w(\prod_{t<n}\alpha_{w_t})(S_k(w)-m)^2∑w​(∏t<n​αwt​​)(Sk​(w)−m)2. Here Sk(w)S_k(w)Sk​(w) is the length of row kkk, counting from 000, with absent rows assigned length 000. To build the rows, process www in order: replace the first strictly larger letter in a row and insert the displaced letter into the next row, or append and stop if no strictly larger letter exists, creating rows as needed. Neither the center mmm nor the outer sum is divided by the total weight. No nonnegativity, normalization, or sorting assumption is imposed on α\alphaα, so the value is not asserted to be a probability variance or to be nonnegative. It is 000 at n=0n=0n=0, and no index kkk exists at d=0d=0d=0.

QAlgorithms.Papers.Independent.Extend50.P32.rskRun

For any linearly ordered type AAA and finite word www over AAA, this function processes its letters from left to right, tagging each letter with its original position, starting at 000. It starts with no rows and no events. At position ttt, it inserts the tagged letter into row 000: within each row, it replaces the first token whose letter is strictly greater than the incoming letter, passing the displaced token to the next row, or appends the incoming token and stops if no such token exists. Reaching beyond the existing rows creates a new singleton row. Each displacement from row jjj records (j,t,b)(j,t,b)(j,t,b), where bbb is the displaced tagged token. Events are retained in processing order, with successive displacements from one insertion recorded in increasing row order. The result is the final list of token rows and the complete event list; the empty word produces two empty lists.

QAlgorithms.Papers.Independent.Extend50.P32.shape

For any linearly ordered type AAA and finite word www over AAA, this function returns the list of row lengths obtained by the following procedure. Tag each letter by its original position, starting at 000, and insert the tagged letters in word order into initially empty rows. In each row, replace the first token whose letter is strictly greater than the incoming letter and insert the displaced token into the next row; if no such token exists, append the incoming token and stop, creating a singleton row if necessary. The output lists the lengths of the final rows in their existing order, discarding token contents and displacement events. The empty word gives the empty list.

QAlgorithms.Papers.Independent.Extend50.P32.shapeDominates

For arbitrary finite lists s,ts,ts,t of natural numbers, this predicate means both that their total sums are equal and that, for every k∈Nk\in\mathbb Nk∈N, the sum of the first kkk entries of ttt is at most the sum of the first kkk entries of sss. A prefix extending beyond a list contains the whole list. Empty lists and k=0k=0k=0 are included; no sorting or equality of list lengths is required.

QAlgorithms.Papers.Independent.Extend50.P32.spectralPrefixExcessLimit

For every natural number ddd, arbitrary real vector α\alphaα indexed by 0,…,d−10,\ldots,d-10,…,d−1, and natural number kkk, this defines the extended nonnegative sum

∑i,j<di<k≤j{∞,αi=αj,max⁡ ⁣(αjαi−αj,0),αi≠αj,\sum_{\substack{i,j<d\\i<k\le j}} \begin{cases} \infty,&\alpha_i=\alpha_j,\\ \max\!\left(\dfrac{\alpha_j}{\alpha_i-\alpha_j},0\right),&\alpha_i\ne\alpha_j, \end{cases}i,j<di<k≤j​∑​⎩⎨⎧​∞,max(αi​−αj​αj​​,0),​αi​=αj​,αi​=αj​,​

where finite terms are embedded into [0,∞][0,\infty][0,∞]. There are no positivity, normalization, or sorting assumptions on α\alphaα. In particular, an included pair with both entries zero contributes ∞\infty∞, while a negative quotient contributes 000. The sum is 000 when k=0k=0k=0, k≥dk\ge dk≥d, or d=0d=0d=0.

QAlgorithms.Papers.Independent.Extend50.P32.suffixWord

For every natural number ddd, every finite list www with entries in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, and every natural number kkk, this defines the list obtained by retaining exactly those entries whose numerical values are at least max⁡(k−1,0)\max(k-1,0)max(k−1,0), preserving their order and repetitions. The subtraction is natural-number subtraction, so both k=0k=0k=0 and k=1k=1k=1 retain all entries; if k>dk>dk>d, the result is empty. The case d=0d=0d=0, where www is empty, is included.

QAlgorithms.Papers.Independent.Extend50.P32.swMean

For every natural number ddd, arbitrary function α:{0,…,d−1}→R\alpha:\{0,\ldots,d-1\}\to\mathbb Rα:{0,…,d−1}→R, natural number nnn, and function FFF from finite lists of natural numbers to R\mathbb RR, this defines

∑w:{0,…,n−1}→{0,…,d−1}(∏i=0n−1α(wi))F(shape⁡(w)).\sum_{w:\{0,\ldots,n-1\}\to\{0,\ldots,d-1\}} \left(\prod_{i=0}^{n-1}\alpha(w_i)\right)F(\operatorname{shape}(w)).w:{0,…,n−1}→{0,…,d−1}∑​(i=0∏n−1​α(wi​))F(shape(w)).

Here shape⁡(w)\operatorname{shape}(w)shape(w) is the list of row lengths obtained by processing w0,…,wn−1w_0,\ldots,w_{n-1}w0​,…,wn−1​ in order, starting with no rows: insert a letter into the first row by replacing its first strictly greater letter and inserting the displaced letter into the next row recursively; if there is no strictly greater letter, append the inserted letter to that row, creating a row if necessary. Letters carry their original position labels, which do not affect comparisons. No nonnegativity or normalization is required of α\alphaα. For n=0n=0n=0, the value is F([])F([])F([]); for d=0<nd=0<nd=0<n, it is 000.

QAlgorithms.Papers.Independent.Extend50.P32.swMeanExt

For every natural number ddd, arbitrary α:{0,…,d−1}→R\alpha:\{0,\ldots,d-1\}\to\mathbb Rα:{0,…,d−1}→R, natural number nnn, and function FFF from finite lists of natural numbers to [0,∞][0,\infty][0,∞], this defines

∑w:{0,…,n−1}→{0,…,d−1}max⁡ ⁣{∏i=0n−1α(wi),0}F(shape⁡(w))\sum_{w:\{0,\ldots,n-1\}\to\{0,\ldots,d-1\}} \max\!\left\{\prod_{i=0}^{n-1}\alpha(w_i),0\right\} F(\operatorname{shape}(w))w:{0,…,n−1}→{0,…,d−1}∑​max{i=0∏n−1​α(wi​),0}F(shape(w))

in the extended nonnegative reals. To obtain shape⁡(w)\operatorname{shape}(w)shape(w), process the letters in order, initially with no rows: replace the first strictly greater letter in a row and insert that displaced letter into the next row recursively, or append if no strictly greater letter exists; record the resulting row lengths. Letters carry their original position labels, but comparisons use only the letters. The entire product of weights is clipped at zero; individual weights need not be nonnegative or sum to one. Extended multiplication uses 0⋅∞=00\cdot\infty=00⋅∞=0. For n=0n=0n=0, the value is F([])F([])F([]); for d=0<nd=0<nd=0<n, it is 000.

QAlgorithms.Papers.Independent.Extend50.P32.tail

For every natural number ddd, arbitrary α:{0,…,d−1}→R\alpha:\{0,\ldots,d-1\}\to\mathbb Rα:{0,…,d−1}→R, and natural number kkk, this defines ∑0≤i<d, k≤iαi\sum_{0\le i<d,\ k\le i}\alpha_i∑0≤i<d, k≤i​αi​. No nonnegativity or normalization is assumed. For k=0k=0k=0 it sums all entries, and for k≥dk\ge dk≥d, including d=0d=0d=0, it is 000.

QAlgorithms.Papers.Independent.Extend50.P32.truncatedReport

For natural numbers d,nd,nd,n with supplied hypotheses d>0d>0d>0 and n>0n>0n>0, any natural number kkk, any Young diagram sss having exactly nnn cells and at most ddd rows, and any complex unitary d×dd\times dd×d matrix UUU, this defines

U diag⁡({ℓi(s)/n,i<k,0,i≥k)i=0d−1U†,U\,\operatorname{diag}\left( \begin{cases} \ell_i(s)/n,&i<k,\\ 0,&i\ge k \end{cases} \right)_{i=0}^{d-1}U^\dagger,Udiag({ℓi​(s)/n,0,​i<k,i≥k​)i=0d−1​U†,

where ℓi(s)\ell_i(s)ℓi​(s) is the length of row iii, with rows indexed from zero. The parameter kkk need not be positive or bounded by ddd: k=0k=0k=0 gives the zero matrix, and k≥dk\ge dk≥d retains every indexed row.

QAlgorithms.Papers.Independent.Extend50.P32.truncatedTV

For every natural number ddd, natural number kkk, and arbitrary real vectors a,ba,ba,b indexed by 0,…,d−10,\ldots,d-10,…,d−1, this defines the real number 12∑i<d, i<k∣ai−bi∣\frac12\sum_{i<d,\ i<k}|a_i-b_i|21​∑i<d, i<k​∣ai​−bi​∣. No probability-distribution assumptions are imposed. The value is 000 when k=0k=0k=0 or d=0d=0d=0, and all coordinates are included when k≥dk\ge dk≥d.

QAlgorithms.Papers.Independent.Extend50.P32.weightedLoss

For every natural number ddd, choice of metric among hellinger and chiSquared, natural number kkk, and arbitrary real vectors a,ba,ba,b indexed by 0,…,d−10,\ldots,d-10,…,d−1, this defines an extended nonnegative loss using only indices i<ki<ki<k. The Hellinger choice gives ∑i<d, i<k(ai−bi)2\sum_{i<d,\ i<k}(\sqrt{a_i}-\sqrt{b_i})^2∑i<d, i<k​(ai​​−bi​​)2. The chi-squared choice gives ∑i<d, i<kc(ai,bi)\sum_{i<d,\ i<k}c(a_i,b_i)∑i<d, i<k​c(ai​,bi​), where c(u,0)=0c(u,0)=0c(u,0)=0 for u=0u=0u=0, c(u,0)=∞c(u,0)=\inftyc(u,0)=∞ for u≠0u\ne0u=0, and c(u,v)=max⁡((u−v)2/v,0)c(u,v)=\max((u-v)^2/v,0)c(u,v)=max((u−v)2/v,0) for v≠0v\ne0v=0, with finite values embedded into [0,∞][0,\infty][0,∞]. Neither vector is required to be nonnegative or normalized, and square roots of negative reals are 000. If k=0k=0k=0 or d=0d=0d=0, the loss is 000; if k≥dk\ge dk≥d, all coordinates are included.

QAlgorithms.Papers.Independent.Extend50.P32.wordMean

For any natural numbers d,nd,nd,n, arbitrary real weights α0,…,αd−1\alpha_0,\ldots,\alpha_{d-1}α0​,…,αd−1​, and real-valued function FFF on finite lists with entries in {0,…,d−1}\{0,\ldots,d-1\}{0,…,d−1}, this function is the finite weighted sum

∑w:{0,…,n−1}→{0,…,d−1}(∏i=0n−1αw(i))F([w(0),…,w(n−1)]).\sum_{w:\{0,\ldots,n-1\}\to\{0,\ldots,d-1\}} \left(\prod_{i=0}^{n-1}\alpha_{w(i)}\right) F([w(0),\ldots,w(n-1)]).w:{0,…,n−1}→{0,…,d−1}∑​(i=0∏n−1​αw(i)​)F([w(0),…,w(n−1)]).

No nonnegativity or normalization assumption is imposed on α\alphaα. When n=0n=0n=0, the unique empty word has empty-product weight 111, so the value is F([])F([])F([]), including when d=0d=0d=0; when d=0d=0d=0 and n>0n>0n>0, there are no words and the value is 000.

QAlgorithms.Papers.Independent.Extend50.P32.wordPoints

For any type AAA and finite list w=[w0,…,wN−1]w=[w_0,\ldots,w_{N-1}]w=[w0​,…,wN−1​] of elements of AAA, this definition returns the list [(0,w0),(1,w1),…,(N−1,wN−1)][(0,w_0),(1,w_1),\ldots,(N-1,w_{N-1})][(0,w0​),(1,w1​),…,(N−1,wN−1​)], with the indices regarded as real numbers and the original list order preserved. For an empty input list, the result is empty.

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