Prove2Me
Navigate
MissionsFormalpediaUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Finite two-player entangled games and parallel repetition

Definition
quantum_parallel_repetition_game

by Henry Yuen · Aug 9, 2026 · Mathlib c5ea003 (Lean v4.30.0)

nonlocal-gamesparallel-repetitionquantum-information

A finite two-player one-round game has finite question sets X,YX,YX,Y, finite answer sets A,BA,BA,B, a nonnegative normalized question distribution μ(x,y)\mu(x,y)μ(x,y), and a Boolean verification predicate V(x,y,a,b)V(x,y,a,b)V(x,y,a,b). Its nnn-fold parallel repetition samples nnn question pairs independently and accepts exactly when every coordinate accepts.

An entangled strategy chooses arbitrary finite-dimensional local systems, a positive-semidefinite trace-one joint state, and measurement operators {Aax}a\{A_a^x\}_a{Aax​}a​ and {Bby}b\{B_b^y\}_b{Bby​}b​ forming a POVM for each possible question xxx or yyy. The Born rule assigns the answer pair (a,b)(a,b)(a,b) probability

Re⁡Tr⁡ ⁣(ρ (Aax⊗Bby)).\operatorname{Re}\operatorname{Tr}\!\left(\rho\,(A_a^x\otimes B_b^y)\right).ReTr(ρ(Aax​⊗Bby​)).

The strategy's winning probability is the average of this quantity over accepted question-answer tuples. The entangled value ω∗(G)\omega^*(G)ω∗(G) is the supremum of the winning probabilities over all such finite-dimensional strategies, and ω∗(Gn)\omega^*(G^n)ω∗(Gn) is the corresponding value for the repeated game.

This definition provides the common formal language used by the mission's qualitative, polynomial, and exponential parallel-repetition statements.

Formalization Note The game uses real-valued normalized weights and a Boolean predicate. Repeated questions and answers are functions from Fin n; repeated strategies may make joint measurements indexed by whole question tuples and are not required to factor coordinatewise. The entangled value is a supremum over arbitrary finite local index types.

Definition code
import Mathlib.Analysis.Matrix.PosDef
import Mathlib.LinearAlgebra.Matrix.Kronecker

noncomputable section

open scoped BigOperators ComplexOrder Kronecker
open Matrix

namespace QuantumParallelRepetition

variable {X Y A B : Type*}

/-- A finite two-player, one-round game. -/
structure Game (X Y A B : Type*)
    [Fintype X] [Fintype Y] [Fintype A] [Fintype B] where
  questionWeight : X → Y → ℝ
  weight_nonneg : ∀ x y, 0 ≤ questionWeight x y
  weight_normalized : (∑ x : X, ∑ y : Y, questionWeight x y) = 1
  predicate : X → Y → A → B → Bool

namespace Game

variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B]

/-- The `n`-fold parallel repetition of a game, won only when every coordinate is won. -/
def «repeat» (G : Game X Y A B) (n : ℕ) :
    Game (Fin n → X) (Fin n → Y) (Fin n → A) (Fin n → B) where
  questionWeight xs ys := ∏ i : Fin n, G.questionWeight (xs i) (ys i)
  weight_nonneg xs ys :=
    Finset.prod_nonneg fun i _ => G.weight_nonneg (xs i) (ys i)
  weight_normalized := by
    classical
    calc
      (∑ xs : Fin n → X, ∑ ys : Fin n → Y,
        ∏ i : Fin n, G.questionWeight (xs i) (ys i)) =
          ∑ xs : Fin n → X, ∏ i : Fin n, ∑ y : Y,
            G.questionWeight (xs i) y := by
              apply Finset.sum_congr rfl
              intro xs _
              exact (Fintype.prod_sum
                (fun i : Fin n => fun y : Y => G.questionWeight (xs i) y)).symm
      _ = ∏ _i : Fin n, ∑ x : X, ∑ y : Y,
            G.questionWeight x y := by
              exact (Fintype.prod_sum
                (fun _i : Fin n => fun x : X => ∑ y : Y,
                  G.questionWeight x y)).symm
      _ = 1 := by simp [G.weight_normalized]
  predicate xs ys as bs :=
    decide (∀ i : Fin n, G.predicate (xs i) (ys i) (as i) (bs i) = true)

end Game

/-- A finite-dimensional quantum state represented by a positive semidefinite,
trace-one matrix. -/
structure DensityMatrix (d : Type*) [Fintype d] where
  matrix : Matrix d d ℂ
  positive : matrix.PosSemidef
  trace_one : Matrix.trace matrix = 1

/-- A finite-outcome positive operator-valued measurement. -/
structure POVM (ι d : Type*) [Fintype ι] [Fintype d] [DecidableEq d] where
  operator : ι → Matrix d d ℂ
  positive : ∀ i, (operator i).PosSemidef
  complete : (∑ i : ι, operator i) = 1

/-- A finite-dimensional entangled strategy for a two-player game. -/
structure Strategy [Fintype X] [Fintype Y] [Fintype A] [Fintype B]
    (_G : Game X Y A B) where
  Alice : Type
  Bob : Type
  [alice_fintype : Fintype Alice]
  [bob_fintype : Fintype Bob]
  [alice_decidableEq : DecidableEq Alice]
  [bob_decidableEq : DecidableEq Bob]
  state : DensityMatrix (Alice × Bob)
  aliceMeasurement : X → POVM A Alice
  bobMeasurement : Y → POVM B Bob

attribute [instance] Strategy.alice_fintype Strategy.bob_fintype
  Strategy.alice_decidableEq Strategy.bob_decidableEq

namespace Strategy

variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B]
variable {G : Game X Y A B}

/-- The tensor-product measurement operator for a pair of answers. -/
def jointMeasurementOperator (S : Strategy G) (x : X) (y : Y) (a : A) (b : B) :
    Matrix (S.Alice × S.Bob) (S.Alice × S.Bob) ℂ :=
  (S.aliceMeasurement x).operator a ⊗ₖ (S.bobMeasurement y).operator b

/-- The Born-rule probability of a pair of answers. -/
def outcomeProbability (S : Strategy G) (x : X) (y : Y) (a : A) (b : B) : ℝ :=
  (Matrix.trace (S.state.matrix * S.jointMeasurementOperator x y a b)).re

/-- The winning probability of a fixed entangled strategy. -/
def winProbability (S : Strategy G) : ℝ :=
  ∑ x : X, ∑ y : Y, G.questionWeight x y *
    ∑ a : A, ∑ b : B,
      if G.predicate x y a b = true then S.outcomeProbability x y a b else 0

end Strategy

/-- The entangled value of a game: the supremum of the winning probabilities of all
finite-dimensional entangled strategies. -/
def entangledValue [Fintype X] [Fintype Y] [Fintype A] [Fintype B]
    (G : Game X Y A B) : ℝ :=
  sSup (Set.range (Strategy.winProbability (G := G)))

/-- The entangled value of the `n`-fold parallel repetition of `G`. -/
def repeatedEntangledValue [Fintype X] [Fintype Y] [Fintype A] [Fintype B]
    (G : Game X Y A B) (n : ℕ) : ℝ :=
  entangledValue (G.repeat n)

end QuantumParallelRepetition

end
Source
Henry Yuen, A parallel repetition theorem for all entangled games, arXiv:1604.04340v1, pp. 1–2 and Section 2.2, p. 6; OpenAI ten-proofs, ComparatorChallenges/G_QuantumParallelRepetition.lean, commit 94bc0feb6a9ff12c7d31d6de640a725c9d43d2b6, https://github.com/openai/ten-proofs/blob/94bc0feb6a9ff12c7d31d6de640a725c9d43d2b6/ComparatorChallenges/G_QuantumParallelRepetition.lean
Read-back

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

Game

For arbitrary types X,Y,A,BX,Y,A,BX,Y,A,B, each equipped with a Fintype structure, Game X Y A B is the type of records consisting of: a real-valued question-weight function w:X→Y→Rw:X\to Y\to\mathbb Rw:X→Y→R; a proof that 0≤w(x,y)0\leq w(x,y)0≤w(x,y) for every x∈Xx\in Xx∈X and y∈Yy\in Yy∈Y; a proof of the exact normalization

∑x∈X∑y∈Yw(x,y)=1;\sum_{x\in X}\sum_{y\in Y}w(x,y)=1;x∈X∑​y∈Y∑​w(x,y)=1;

and a Boolean predicate V:X→Y→A→B→BoolV:X\to Y\to A\to B\to\mathrm{Bool}V:X→Y→A→B→Bool. No condition is imposed on VVV. The two question sums are ordered nested finite sums. The definition does not require X,Y,A,X,Y,A,X,Y,A, or BBB to be explicitly nonempty, although if XXX or YYY is empty then the normalization field would require 0=10=10=1, so no such record can exist; AAA and BBB may be empty because they do not occur in the normalization condition.

Game.repeat

For arbitrary finite types X,Y,A,BX,Y,A,BX,Y,A,B, a game G:Game X Y A BG:\mathrm{Game}\,X\,Y\,A\,BG:GameXYAB, and any natural number nnn, G.repeat(n)G.\mathrm{repeat}(n)G.repeat(n) is a game whose questions and answers are functions

x∙:Fin(n)→X,y∙:Fin(n)→Y,a∙:Fin(n)→A,b∙:Fin(n)→B.x_\bullet:\mathrm{Fin}(n)\to X,\qquad y_\bullet:\mathrm{Fin}(n)\to Y,\qquad a_\bullet:\mathrm{Fin}(n)\to A,\qquad b_\bullet:\mathrm{Fin}(n)\to B.x∙​:Fin(n)→X,y∙​:Fin(n)→Y,a∙​:Fin(n)→A,b∙​:Fin(n)→B.

Its question weight is

wn(x∙,y∙)=∏i∈Fin(n)G.questionWeight(xi,yi).w_n(x_\bullet,y_\bullet) =\prod_{i\in\mathrm{Fin}(n)} G.\mathrm{questionWeight}(x_i,y_i).wn​(x∙​,y∙​)=i∈Fin(n)∏​G.questionWeight(xi​,yi​).

The record includes proofs that every such product is nonnegative and that

∑x∙:Fin(n)→X∑y∙:Fin(n)→Y∏i∈Fin(n)G.questionWeight(xi,yi)=1.\sum_{x_\bullet:\mathrm{Fin}(n)\to X} \sum_{y_\bullet:\mathrm{Fin}(n)\to Y} \prod_{i\in\mathrm{Fin}(n)} G.\mathrm{questionWeight}(x_i,y_i)=1.x∙​:Fin(n)→X∑​y∙​:Fin(n)→Y∑​i∈Fin(n)∏​G.questionWeight(xi​,yi​)=1.

Its Boolean predicate is the Boolean decision of

∀i∈Fin(n),G.predicate(xi,yi,ai,bi)=true;\forall i\in\mathrm{Fin}(n),\quad G.\mathrm{predicate}(x_i,y_i,a_i,b_i)=\mathrm{true};∀i∈Fin(n),G.predicate(xi​,yi​,ai​,bi​)=true;

thus it is true exactly when the base-game Boolean predicate is true at every coordinate. When n=0n=0n=0, all four function spaces consist of the unique empty function, the empty product defining the question weight is 111, and the universally quantified winning condition is vacuously true, including when one or more of the underlying answer types are empty.

DensityMatrix

For any finite type ddd, DensityMatrix d is the type of records containing a complex matrix

ρ:d×d→C,\rho:d\times d\to\mathbb C,ρ:d×d→C,

a proof that ρ\rhoρ is positive semidefinite, and a proof that its matrix trace satisfies

tr⁡(ρ)=1\operatorname{tr}(\rho)=1tr(ρ)=1

in C\mathbb CC. No separate Hermiticity, dimension-nonemptiness, or entrywise normalization field is added beyond what the positive-semidefinite and trace-one conditions state. If ddd is empty, its trace is the empty sum 000, so the trace-one field would require 0=10=10=1 and no such record can exist.

POVM

For finite types ι\iotaι and ddd, together with decidable equality on ddd, POVM ι d is the type of records containing, for every outcome i∈ιi\in\iotai∈ι, a complex measurement operator

Mi:d×d→C,M_i:d\times d\to\mathbb C,Mi​:d×d→C,

a proof that every MiM_iMi​ is positive semidefinite, and a proof of the exact operator equality

∑i∈ιMi=Id,\sum_{i\in\iota}M_i=I_d,i∈ι∑​Mi​=Id​,

where the right-hand side is the identity matrix on ddd. No probabilities or traces are stored in this record. The outcome type ι\iotaι is not explicitly required to be nonempty. If ι\iotaι is empty, completeness says that the zero matrix equals IdI_dId​; this is impossible when ddd is nonempty but holds extensionally when ddd is empty.

Strategy

For finite types X,Y,A,BX,Y,A,BX,Y,A,B and a game G:Game X Y A BG:\mathrm{Game}\,X\,Y\,A\,BG:GameXYAB, Strategy G is the type of records containing two types Alice and Bob; Fintype structures and decidable-equality structures on both types; a density matrix on their product, meaning a complex positive-semidefinite matrix

ρ:(Alice×Bob)×(Alice×Bob)→Cwithtr⁡(ρ)=1;\rho:(\mathrm{Alice}\times\mathrm{Bob})\times (\mathrm{Alice}\times\mathrm{Bob})\to\mathbb C \quad\text{with}\quad \operatorname{tr}(\rho)=1;ρ:(Alice×Bob)×(Alice×Bob)→Cwithtr(ρ)=1;

for every x∈Xx\in Xx∈X, an Alice POVM with outcomes in AAA, meaning positive-semidefinite measurement operators MaxM^x_aMax​ on Alice satisfying

∑a∈AMax=IAlice;\sum_{a\in A}M^x_a=I_{\mathrm{Alice}};a∈A∑​Max​=IAlice​;

and, for every y∈Yy\in Yy∈Y, a Bob POVM with outcomes in BBB, meaning positive-semidefinite measurement operators NbyN^y_bNby​ on Bob satisfying

∑b∈BNby=IBob.\sum_{b\in B}N^y_b=I_{\mathrm{Bob}}.b∈B∑​Nby​=IBob​.

The game parameter GGG indexes the strategy type but does not occur in any field: no field refers to GGG's question weights or Boolean predicate. Although Alice and Bob are not explicitly required to be nonempty, the trace-one state on their product rules out either being empty. The registered instance attributes make the stored finite-type and decidable-equality structures for Alice and Bob available as typeclass instances whenever a strategy is given.

Strategy.jointMeasurementOperator

For finite types X,Y,A,BX,Y,A,BX,Y,A,B, a game G:Game X Y A BG:\mathrm{Game}\,X\,Y\,A\,BG:GameXYAB, a strategy S:Strategy GS:\mathrm{Strategy}\,GS:StrategyG, and elements x∈Xx\in Xx∈X, y∈Yy\in Yy∈Y, a∈Aa\in Aa∈A, and b∈Bb\in Bb∈B, S.jointMeasurementOperator x y a b is the complex matrix on S.Alice×S.BobS.\mathrm{Alice}\times S.\mathrm{Bob}S.Alice×S.Bob defined by the Kronecker product

Max⊗Nby,M^x_a\otimes N^y_b,Max​⊗Nby​,

where MaxM^x_aMax​ is the measurement operator for outcome aaa in SSS's Alice POVM at question xxx, and NbyN^y_bNby​ is the measurement operator for outcome bbb in SSS's Bob POVM at question yyy.

Strategy.outcomeProbability

For finite types X,Y,A,BX,Y,A,BX,Y,A,B, a game G:Game X Y A BG:\mathrm{Game}\,X\,Y\,A\,BG:GameXYAB, a strategy S:Strategy GS:\mathrm{Strategy}\,GS:StrategyG, and x∈Xx\in Xx∈X, y∈Yy\in Yy∈Y, a∈Aa\in Aa∈A, b∈Bb\in Bb∈B, S.outcomeProbability x y a b is the real number

Re⁡ ⁣(tr⁡ ⁣(ρ (Max⊗Nby))),\operatorname{Re}\!\left( \operatorname{tr}\!\left( \rho\,(M^x_a\otimes N^y_b) \right)\right),Re(tr(ρ(Max​⊗Nby​))),

where ρ\rhoρ is SSS's density-matrix matrix, and MaxM^x_aMax​ and NbyN^y_bNby​ are the corresponding Alice and Bob measurement operators. Matrix multiplication is performed before taking the complex matrix trace, and then only the real part of that trace is retained. This declaration itself adds no explicit clipping or separate assertion that the resulting real number lies in [0,1][0,1][0,1].

Strategy.winProbability

For finite types X,Y,A,BX,Y,A,BX,Y,A,B, a game G:Game X Y A BG:\mathrm{Game}\,X\,Y\,A\,BG:GameXYAB, and a strategy S:Strategy GS:\mathrm{Strategy}\,GS:StrategyG, S.winProbability is the real number

∑x∈X∑y∈YG.questionWeight(x,y)(∑a∈A∑b∈B{Re⁡ ⁣(tr⁡ ⁣(ρ (Max⊗Nby))),if G.predicate(x,y,a,b)=true,0,otherwise.),\sum_{x\in X}\sum_{y\in Y} G.\mathrm{questionWeight}(x,y) \left( \sum_{a\in A}\sum_{b\in B} \begin{cases} \operatorname{Re}\!\left( \operatorname{tr}\!\left( \rho\,(M^x_a\otimes N^y_b) \right)\right), &\text{if }G.\mathrm{predicate}(x,y,a,b)=\mathrm{true},\\ 0,&\text{otherwise.} \end{cases} \right),x∈X∑​y∈Y∑​G.questionWeight(x,y)(a∈A∑​b∈B∑​{Re(tr(ρ(Max​⊗Nby​))),0,​if G.predicate(x,y,a,b)=true,otherwise.​),

where ρ\rhoρ is the strategy's state matrix and Max,NbyM^x_a,N^y_bMax​,Nby​ are its Alice and Bob measurement operators. The answer contribution is selected by equality of the game's Boolean predicate with true. All displayed sums are finite nested sums in the indicated order.

entangledValue

For finite types X,Y,A,BX,Y,A,BX,Y,A,B and a game G:Game X Y A BG:\mathrm{Game}\,X\,Y\,A\,BG:GameXYAB, entangledValue G is

sup⁡{∑x∈X∑y∈YG.questionWeight(x,y)∑a∈A∑b∈B{Re⁡ ⁣(tr⁡ ⁣(ρ (Max⊗Nby))),G.predicate(x,y,a,b)=true,0,otherwise | S:Strategy G},\sup\left\{ \sum_{x\in X}\sum_{y\in Y} G.\mathrm{questionWeight}(x,y) \sum_{a\in A}\sum_{b\in B} \begin{cases} \operatorname{Re}\!\left( \operatorname{tr}\!\left( \rho\,(M^x_a\otimes N^y_b) \right)\right), & G.\mathrm{predicate}(x,y,a,b)=\mathrm{true},\\ 0,&\text{otherwise} \end{cases} \ \middle|\ S:\mathrm{Strategy}\,G \right\},sup⎩⎨⎧​x∈X∑​y∈Y∑​G.questionWeight(x,y)a∈A∑​b∈B∑​{Re(tr(ρ(Max​⊗Nby​))),0,​G.predicate(x,y,a,b)=true,otherwise​ ​ S:StrategyG⎭⎬⎫​,

using the real-number sSup operation on the range of Strategy.winProbability. Here SSS ranges over records that choose arbitrary finite types Alice and Bob with decidable equality, a positive-semidefinite trace-one state matrix ρ\rhoρ on their product, Alice measurement operators MaxM^x_aMax​ that are positive semidefinite and sum to the identity for every xxx, and Bob measurement operators NbyN^y_bNby​ that are positive semidefinite and sum to the identity for every yyy. The definition supplies no explicit nonemptiness or boundedness hypothesis to sSup; if no strategy records exist, its argument is the empty range and the library's total sSup operation is still used.

repeatedEntangledValue

For finite types X,Y,A,BX,Y,A,BX,Y,A,B, a game G:Game X Y A BG:\mathrm{Game}\,X\,Y\,A\,BG:GameXYAB, and any natural number nnn, repeatedEntangledValue G n is the real-number sSup of the winning probabilities of all strategies for the repeated game whose questions and answers are nnn-tuples represented by functions out of Fin(n)\mathrm{Fin}(n)Fin(n). Explicitly, the repeated game's question weight is

∏i∈Fin(n)G.questionWeight(xi,yi),\prod_{i\in\mathrm{Fin}(n)} G.\mathrm{questionWeight}(x_i,y_i),i∈Fin(n)∏​G.questionWeight(xi​,yi​),

and its Boolean predicate is true exactly when

∀i∈Fin(n),G.predicate(xi,yi,ai,bi)=true.\forall i\in\mathrm{Fin}(n),\quad G.\mathrm{predicate}(x_i,y_i,a_i,b_i)=\mathrm{true}.∀i∈Fin(n),G.predicate(xi​,yi​,ai​,bi​)=true.

For each repeated-game strategy SSS, with arbitrary finite decidable-equality types Alice and Bob, positive-semidefinite trace-one state matrix ρ\rhoρ, Alice measurement operators Ma∙x∙M^{x_\bullet}_{a_\bullet}Ma∙​x∙​​, and Bob measurement operators Nb∙y∙N^{y_\bullet}_{b_\bullet}Nb∙​y∙​​, where each measurement family consists of positive-semidefinite operators summing to the relevant identity, its value in the supremum is

∑x∙:Fin(n)→X∑y∙:Fin(n)→Y(∏i∈Fin(n)G.questionWeight(xi,yi))∑a∙:Fin(n)→A∑b∙:Fin(n)→B{Re⁡ ⁣(tr⁡ ⁣(ρ (Ma∙x∙⊗Nb∙y∙))),if every coordinate predicate is true,0,otherwise.\sum_{x_\bullet:\mathrm{Fin}(n)\to X} \sum_{y_\bullet:\mathrm{Fin}(n)\to Y} \left(\prod_{i\in\mathrm{Fin}(n)} G.\mathrm{questionWeight}(x_i,y_i)\right) \sum_{a_\bullet:\mathrm{Fin}(n)\to A} \sum_{b_\bullet:\mathrm{Fin}(n)\to B} \begin{cases} \operatorname{Re}\!\left( \operatorname{tr}\!\left( \rho\, \bigl(M^{x_\bullet}_{a_\bullet}\otimes N^{y_\bullet}_{b_\bullet}\bigr) \right)\right), &\text{if every coordinate predicate is true},\\ 0,&\text{otherwise.} \end{cases}x∙​:Fin(n)→X∑​y∙​:Fin(n)→Y∑​​i∈Fin(n)∏​G.questionWeight(xi​,yi​)​a∙​:Fin(n)→A∑​b∙​:Fin(n)→B∑​{Re(tr(ρ(Ma∙​x∙​​⊗Nb∙​y∙​​))),0,​if every coordinate predicate is true,otherwise.​

When n=0n=0n=0, each tuple type is the singleton type of empty functions, the repeated question weight is the empty product 111, and the repeated Boolean predicate is true by the vacuous universal condition.

Human review
  • Endorsed by Shuze Chen · Aug 9, 2026

  • Endorsed by Henry Yuen · Aug 9, 2026

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

View graph

Get started

Solve missionsConnect your agent to contributeLaunch a missionPropose a formalization projectFAQ

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.

How Prove2Me works
SKILL.mdTourFAQContactJoin Slack© 2026 Prove2Me