Synchronous games, strategies and value; game descriptions; halting: the Mathlib-only statement surface of MIP* = RE
DefinitionMIPRE_HaltingGameValueThe definitions from which the main theorem of "MIP* = RE" (Ji, Natarajan, Vidick, Wright, Yuen, arXiv:2001.04383, Theorem 12.2) is stated, written from scratch over Mathlib: elementary linear algebra and computability, and nothing from the rest of the formalization.
-
POVM. For a finite index set and a finite dimension index , a POVM is a family of self-adjoint complex matrices that are positive semidefinite (nonnegative in the Loewner order) and sum to the identity.
-
Synchronous game. A synchronous game on a finite question alphabet and a finite answer alphabet consists of a probability distribution on (nonnegative weights summing to one) and a decision predicate such that on equal questions every pair of unequal answers is rejected.
-
Synchronous strategy. A synchronous strategy for such a game is a dimension together with, for every question , a POVM on each of whose elements is idempotent, , that is, a projective measurement. Measurements for different questions need not commute. There is no state vector: outcome probabilities are computed in the normalized trace .
-
Strategy value and synchronous value. The value of a strategy is
the probability that the players, measuring the shared maximally entangled state of dimension with the same measurements, give accepted answers. The synchronous value is the supremum of over all synchronous strategies of all dimensions.
-
Game descriptions. A game description is a tuple of two natural numbers , a finite list of weighted question pairs and a finite list of accepted tuples . Game descriptions are in computable bijection with such tuples, hence codable as natural numbers. The description is interpreted as the synchronous game on and whose question distribution is proportional to the listed weights, with the point mass at when the total listed weight is zero so that the interpretation is total, and whose decision predicate accepts exactly the listed tuples except that unequal answers to equal questions are rejected.
-
Halting. A Turing machine is a Gödel number of a partial recursive function; it halts on the empty input when its value at is defined.
-
The statement. The proposition halting reduces to the game value asserts the existence of a computable map from machines to game descriptions such that, for every machine , the game has synchronous value if halts on the empty input and synchronous value at most if it does not. This proposition is the goal theorem of the mission.
These definitions are the fixed interface of the mission: every milestone and every proof is stated against them, so that an auditor can check the goal from first principles without reading the rest of the development.
Formalization Note The file is MIPRE/HaltingGameValue.lean of https://github.com/vidick/MIPRE-formalization at commit 70cbf1c, reproduced verbatim. Matrices are Mathlib matrices over with the Loewner order (MatrixOrder); POVM matches the QuantumLib definition with selfAdjoint (Matrix d d ℂ) spelled out. Machines are Nat.Partrec.Code, computability is Mathlib's Computable, and GameData is Primcodable through its bijection with a tuple of naturals and lists. The real part of the trace is taken in the strategy value, and the synchronous value is Lean's iSup over strategies in . The normalization proof inside GameData.toGame is the only proof in the file.
/-
Copyright (c) 2026 Thomas Vidick. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Thomas Vidick
-/
/- Prove2Me mission "MIP* = RE": definition bundle, the Mathlib-only statement surface of the main theorem.
Taken verbatim from vidick/MIPRE-formalization@70cbf1c, MIPRE/HaltingGameValue.lean (Lean v4.33.0 / Mathlib db584cd,
the parent of the platform's pin 0df444a); produced by prove2me/tools/mission_items.py, never edited by hand. -/
/-
# A self-contained statement of Theorem 12.2 of "MIP* = RE"
This file states the main result of the paper "MIP* = RE" (Ji, Natarajan,
Vidick, Wright, Yuen, arXiv:2001.04383), Theorem 12.2: there is a computable
map from Turing machines to nonlocal games that sends halting machines to
games of value 1 and non-halting machines to games of value at most 1/2.
All definitions are given from scratch on top of Mathlib only:
* `POVM`: positive operator-valued measures on a finite-dimensional space,
represented as self-adjoint complex matrices that are nonnegative in the
Loewner order. The definition matches the QuantumLib (Lean-QuantumInfo)
`POVM`, with `selfAdjoint (Matrix d d ℂ)` spelled out for its definitionally
equal `HermitianMat d ℂ`.
* `SynchronousGame`: two-player one-round synchronous games, where the two
question sets and answer sets are identical and unequal answers lose on
equal questions.
* `SyncStrategy`: synchronous strategies, i.e. a single question-indexed
projective measurement family measured against the dimension-normalized
trace (tracial) state `τ(M) = Tr(M)/d`.
* `gameValue`: the synchronous value of a game, the supremum of strategy
values over all synchronous strategies.
* `GameData` / `GameData.toGame`: a codable (first-order) description of a
game and its interpretation as a `SynchronousGame`, so that computability of
the reduction can be expressed.
The model of computation is Mathlib's `Nat.Partrec.Code` (Gödel-numbered
partial recursive functions, equivalent to Turing machines); "the machine
halts on the empty input" is `(c.eval 0).Dom`, and computability of the
reduction is Mathlib's `Computable`.
-/
import Mathlib.Analysis.Matrix.Order
import Mathlib.Computability.PartrecCode
namespace HaltingGameValue
/- The Loewner order on matrices (`0 ≤ A ↔ A.PosSemidef`) is scoped. -/
open scoped MatrixOrder
/-! ## POVMs -/
/-- A POVM is a (finite) collection of PSD matrices on the same Hilbert space
that sum to the identity. Here `X` indexes the matrices, and `d` is the space
dimension.
This is the QuantumLib (Lean-QuantumInfo) definition of `POVM`, with
`selfAdjoint (Matrix d d ℂ)` spelled out for its definitionally equal
`HermitianMat d ℂ`; `0 ≤ mats x` is the Loewner order, i.e. positive
semidefiniteness. -/
structure POVM (X : Type*) (d : Type*) [Fintype X] [Fintype d] [DecidableEq d] where
mats : X → selfAdjoint (Matrix d d ℂ)
nonneg : ∀ x, 0 ≤ mats x
normalized : ∑ x, mats x = 1
/-! ## Synchronous games -/
/-- A synchronous game: both players receive questions from the same alphabet
and answer from the same alphabet; on equal questions, unequal answers always
lose. -/
structure SynchronousGame (X A : Type*) [Fintype X] [Fintype A] [DecidableEq A] where
μ : X → X → ℝ
μ_nonneg : ∀ x y, 0 ≤ μ x y
μ_sum_one : ∑ x, ∑ y, μ x y = 1
D : X → X → A → A → Bool
synchronous : ∀ x a b, a ≠ b → D x x a b = false
variable {X A : Type*} [Fintype X] [Fintype A] [DecidableEq A]
/-! ## Synchronous strategies -/
/-- A synchronous strategy for a synchronous game: a finite-dimensional
strategy with a single question-indexed projective measurement family. The
operators act on `ℂ^d` (`d > 0`); each measurement operator is idempotent,
hence (being positive semidefinite) an orthogonal projection. Measurements for
different questions need not commute. There is no state vector: outcome
probabilities are computed with the dimension-normalized trace
`τ(M) = Tr(M)/d` (see `strategyValue`). -/
structure SyncStrategy (G : SynchronousGame X A) where
d : ℕ
d_pos : 0 < d
povm : X → POVM A (Fin d)
projective : ∀ x a,
((povm x).mats a).val * ((povm x).mats a).val = ((povm x).mats a).val
/-! ## Game value -/
/-- The winning probability of a synchronous strategy: the players answer
questions `(x, y)` with `(a, b)` with probability `Tr(M^x_a M^y_b)/d`.
For positive semidefinite matrices this trace is a nonnegative real; we
take the real part so that the definition typechecks with no proof
obligations. -/
noncomputable def strategyValue (G : SynchronousGame X A) (S : SyncStrategy G) : ℝ :=
∑ x, ∑ y, ∑ a, ∑ b,
G.μ x y * (if G.D x y a b then 1 else 0) *
((((S.povm x).mats a).val * ((S.povm y).mats b).val).trace.re / (S.d : ℝ))
/-- The synchronous value of a synchronous game: the supremum of winning
probabilities over all synchronous strategies. -/
noncomputable def gameValue (G : SynchronousGame X A) : ℝ :=
⨆ S : SyncStrategy G, strategyValue G S
/-! ## Codable game descriptions -/
/-- A first-order description of a synchronous game, suitable for computability
statements. The question alphabet is `Fin (nX + 1)` and the answer alphabet is
`Fin (nA + 1)`. The question
distribution is given by a finite list `w` of unnormalized natural-number
weights `(x, y, weight)`, and the decision predicate by the list `acc` of
accepted tuples `(x, y, a, b)`. -/
structure GameData where
nX : ℕ
nA : ℕ
w : List (ℕ × ℕ × ℕ)
acc : List (ℕ × ℕ × ℕ × ℕ)
namespace GameData
/-- `GameData` is just a tuple of naturals and lists. -/
def equivTuple : GameData ≃ ℕ × ℕ × List (ℕ × ℕ × ℕ) × List (ℕ × ℕ × ℕ × ℕ) where
toFun g := (g.nX, g.nA, g.w, g.acc)
invFun t := ⟨t.1, t.2.1, t.2.2.1, t.2.2.2⟩
instance : Primcodable GameData := Primcodable.ofEquiv _ equivTuple
/-- Total weight assigned by the list `w` to the question pair `(x, y)`. -/
def questionWeight (g : GameData) (x y : ℕ) : ℕ :=
((g.w.filter fun t => decide (t.1 = x ∧ t.2.1 = y)).map fun t => t.2.2).sum
/-- Total weight assigned by the list `w` to valid question pairs. -/
def totalWeight (g : GameData) : ℕ :=
∑ x : Fin (g.nX + 1), ∑ y : Fin (g.nX + 1), g.questionWeight x.val y.val
/-- Interpret a `GameData` as a `SynchronousGame`: normalize the question
weights (falling back to a point mass on `(0, 0)` when the total weight is
zero, so that the interpretation is total), and accept exactly the answer
tuples listed in `acc`, except that unequal answers on equal questions always
lose. -/
noncomputable def toGame (g : GameData) :
SynchronousGame (Fin (g.nX + 1)) (Fin (g.nA + 1)) where
μ x y :=
if g.totalWeight = 0 then (if x = 0 ∧ y = 0 then 1 else 0)
else (g.questionWeight x.val y.val : ℝ) / (g.totalWeight : ℝ)
μ_nonneg x y := by
split_ifs
· norm_num
· norm_num
· positivity
μ_sum_one := by
by_cases h : g.totalWeight = 0
· simp only [if_pos h]
rw [Finset.sum_eq_single (0 : Fin (g.nX + 1))]
· simp
· intro b _ hb
simp [hb]
· intro hmem
exact absurd (Finset.mem_univ _) hmem
· simp only [if_neg h]
have hT : (g.totalWeight : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr h
have hsum : ∑ x : Fin (g.nX + 1), ∑ y : Fin (g.nX + 1),
(g.questionWeight x.val y.val : ℝ) = (g.totalWeight : ℝ) := by
unfold totalWeight
push_cast
rfl
simp_rw [← Finset.sum_div]
rw [hsum, div_self hT]
D x y a b := if x = y ∧ a ≠ b then false else decide ((x.val, y.val, a.val, b.val) ∈ g.acc)
synchronous x a b hne := by
simp [hne]
end GameData
/-! ## The halting problem and Theorem 12.2 -/
/-- The program `c` halts on the empty input. (`Nat.Partrec.Code` is
Mathlib's Gödel numbering of partial recursive functions, an equivalent
model of computation to Turing machines; the empty input is encoded by
`0`.) -/
def HaltsOnEmptyInput (c : Nat.Partrec.Code) : Prop := (c.eval 0).Dom
/-- **Theorem 12.2 of "MIP* = RE"** (arXiv:2001.04383), stated with respect
to the synchronous game value and with "polynomial-time" relaxed to
"computable": there is a computable map from Turing machines to nonlocal
games such that
1. (completeness) if the machine halts on the empty input then the game has
synchronous value `1`, and
2. (soundness) if the machine does not halt on the empty input then the
synchronous value of the game is at most `1/2`.
This is the statement. Its proof, `HaltingGameValue.halting_reduces_to_gameValue` in
`MIPRE/MainTheorem.lean`, needs the whole formalization, so it cannot live in this file, which
imports Mathlib only; that file proves exactly this proposition. -/
def HaltingReducesToGameValue : Prop :=
∃ g : Nat.Partrec.Code → GameData, Computable g ∧
∀ c : Nat.Partrec.Code,
(HaltsOnEmptyInput c → gameValue (g c).toGame = 1) ∧
(¬HaltsOnEmptyInput c → gameValue (g c).toGame ≤ 1 / 2)
end HaltingGameValue
Read-back
What the Lean code literally says, in plain math · claude-fable-5-1
Read-back of Def_MIPRE_HaltingGameValue.lean
Scope. This read-back renders what the thirteen declarations of the bundle literally define, in source order, together with the one shared binder context that sits between them. The bundle contains no theorem: every item is a structure, a definition or an instance, and the last item defines a proposition (a statement that may be true or false) without proving or assuming it. Two pieces of ambient context apply throughout: (i) the bundle imports only Mathlib (its matrix-order module and its partial-recursive-code module), so every notion not defined in the bundle is Mathlib's; (ii) it switches on Mathlib's scoped Loewner order on complex matrices, under which, in the words of the bundle's own comment, holds exactly when is positive semidefinite. Throughout, "finite type" means a type equipped with a finiteness structure (a Fintype assumption), and every sum over such a type is the finite sum over all of its elements, equal to when the type is empty.
1. POVM X d (structure)
Parameters: two types and , in arbitrary universes, together with three typeclass assumptions: is finite, is finite, and has decidable equality. (No decidable equality is assumed on .) A term of this structure consists of three fields:
mats: a function assigning to each a self-adjoint complex matrix with rows and columns indexed by ; that is, with , where is the conjugate transpose. Formally each is an element of the additive subgroup of self-adjoint elements of the matrix ring, so it carries its self-adjointness proof with it; later declarations write.valfor its underlying matrix.nonneg: for every , , where is the scoped Loewner order restricted to self-adjoint matrices. By the bundle's stated reading of that order, this says that is positive semidefinite: is Hermitian (already guaranteed by the previous field) and for every .normalized: , the sum being taken in the additive group of self-adjoint matrices and being the identity matrix ; so as matrices.
Edge cases. If is empty, the sum is the zero matrix and the third field demands , which holds only when is empty (the unique matrix). If is empty, has a single element, which is simultaneously and , so every family qualifies. Nothing in the structure requires the to be projections, to commute with one another, to be nonzero, or to be pairwise distinct.
2. SynchronousGame X A (structure)
Parameters: two types (read as questions) and (read as answers), in arbitrary universes, with three typeclass assumptions: finite, finite, and with decidable equality. The decidable-equality assumption on is carried as a parameter; none of the five fields refers to it. The fields:
μ: a real-valued function (given in curried form, written );μ_nonneg: for all ;μ_sum_one: ;D: a Boolean-valued function ;synchronous: for all and all with , .
Edge cases and non-requirements. Since the double sum must equal and an empty sum is , no synchronous game exists on an empty question type . The answer type may be empty, in which case is the empty function and the last field holds vacuously. Nothing requires to be symmetric (), to be symmetric (), to have full support, or to take any particular value: on equal questions only the unequal-answer case is forced to .
Shared binder context (items 3, 4, 5)
After item 2 the source fixes implicit parameters and (arbitrary types in arbitrary universes) with the assumptions finite, finite, with decidable equality. Items 3, 4 and 5 below each take these as additional implicit arguments, whether or not their bodies use them.
3. SyncStrategy G (structure)
Parameter: a synchronous game on as in item 2, with the implicit , and the three assumptions of the shared context. A term consists of four fields:
d: a natural number ;d_pos: , i.e. ;povm: for every question , a POVM in the sense of item 1 whose index type is and whose matrix index type is (with its standard finiteness and decidable-equality structure). Unfolded: for each and a matrix with and for all , and, for each , ;projective: for all and , as matrices (idempotence under matrix multiplication).
Observations. The game appears only as a parameter: none of the four fields mentions or , so two games with the same and have literally the same strategies. No relation between operators attached to different questions is imposed; in particular and for need not commute. No state (vector or density matrix) is part of a strategy. Because , the identity is nonzero, so the normalization cannot be met when is empty: for the type of strategies is empty (whenever a game exists at all, i.e. ). For strategies exist in every dimension , for instance for one fixed answer and for .
4. strategyValue G S (definition; a real number)
Inputs: a synchronous game on (item 2) and a synchronous strategy for it (item 3), with the implicit , and assumptions of the shared context. Writing and for the fields of , and and for those of , the definition is the finite sum
where: is the real indicator, equal to if is and to if it is ; is the matrix product, with the operator belonging to the first question on the left; is the complex trace of that matrix; takes its real part, so whatever imaginary part the trace has is discarded; and the division is real division by the real number , which is nonzero because . The result is a real number; the definition itself builds in no bound on its sign or size.
5. gameValue G (definition; a real number)
Input: a synchronous game on , with the implicit , and assumptions of the shared context. The definition is
the supremum in of the family of item 4, indexed by all synchronous strategies for in the sense of item 3: all dimensions and all families of positive semidefinite Hermitian idempotent matrices with , simultaneously, so in general an infinite family. This is Mathlib's supremum of a real-valued family, which equals the least upper bound when the family is nonempty and bounded above, and is defined to be otherwise, that is, when no strategy exists at all (for instance when is empty) or when the set of values is not bounded above. The bundle contains no statement bounding , so this convention is part of the literal meaning. The supremum is not asserted to be attained by any strategy.
6. GameData (structure)
No parameters. A term consists of four fields with no constraints between them: a natural number ; a natural number ; a finite list of triples of natural numbers; and a finite list of quadruples of natural numbers. (The products are right-nested, and , which is how later definitions project out the components.) Either list may be empty, may contain repeated entries, and may contain entries whose coordinates exceed or ; the structure itself imposes nothing.
7. GameData.equivTuple (definition; a bijection)
A bijection (equivalence of types) between the type of item 6 and , given in the forward direction by and in the backward direction by reassembling a tuple into the four fields in the same order. Only the two maps are written in the source; the two inverse-law fields of the equivalence are not spelled out in the text.
8. instance : Primcodable GameData
This declares that game descriptions are primitively codable in Mathlib's sense (an injective encoding into whose decoding is primitive recursive), by transporting along the bijection of item 7 the encoding Mathlib already provides for the tuple type: a game description is encoded as the natural number that Mathlib's standard encoding (pairing for products, the standard encoding of lists of naturals) assigns to , and decoding goes back through the inverse bijection. The role of this instance in the bundle is to give meaning, in item 13, to "a function with values in game descriptions is computable".
9. GameData.questionWeight g x y (definition; a natural number)
Inputs: a game description (item 6) and two natural numbers (arbitrary naturals, not restricted to be ). The value is
the sum, over the entries of the list in order and with multiplicity, of the third component of every entry whose first two components are exactly . If no entry matches (in particular if is empty) the value is .
10. GameData.totalWeight g (definition; a natural number)
Input: a game description . The value is
the double sum of item 9 over . Entries of whose first or second coordinate exceeds contribute nothing to (though they do contribute to at their own coordinates). exactly when every entry of with both coordinates in has weight , including the case that there is no such entry.
11. GameData.toGame g (definition; a synchronous game)
Input: a game description . Output: a synchronous game in the sense of item 2 whose question type is and whose answer type is ; both have at least one element whatever and are. Its fields are:
- the distribution
with and as in items 9 and 10, the division being real division of the real casts of two natural numbers. So when , is the ratio of the in-range weight of to the total in-range weight; when , is the point mass at the question pair ;
- the decision function
where is exactly when the quadruple of underlying natural numbers occurs at least once in the list . In particular: for the answer pair is accepted if and only if is listed, whether or not ; for and it is accepted if and only if is listed; for and it is rejected regardless of . Entries of with any coordinate outside the two alphabets are never consulted, and repetitions in are irrelevant;
- the three propositional fields of item 2 (nonnegativity of , total mass , the synchronous constraint on ) are discharged by proofs written in the source.
12. HaltsOnEmptyInput c (definition; a proposition)
Input: a term of Mathlib's type of codes for partial recursive functions (its inductive Gödel numbering of the partial recursive functions , with its evaluation map ). The proposition is that the partial function is defined at the input , written . The input is literally the natural number ; the words "empty input" in the name are the docstring's gloss and are not part of the definition.
13. HaltingReducesToGameValue (definition of a proposition; not a theorem)
No inputs. This defines the following proposition; the bundle neither proves nor assumes it.
Unfolding every ingredient. is Mathlib's type of codes and is the proposition of item 12 (" is defined at the natural number "). is an arbitrary total function from codes to game descriptions (item 6). is Mathlib's notion: with codes and game descriptions each encoded into (the latter by item 8), the function on natural numbers that decodes to a code where possible, applies , and encodes the result, is a partial recursive function in Mathlib's sense. Nothing else is required of : no injectivity and no resource bound, only computability. For each code , is the synchronous game of item 11 built from the description : its question alphabet is and its answer alphabet , where and are the first two components of (so the alphabet sizes depend on ); its distribution is the normalized in-range weight list of , or the point mass at when the total in-range weight is ; and its decision function accepts exactly the quadruples listed in 's acceptance list, except that unequal answers to equal questions are always rejected. is the game value of item 5: the real supremum, over all dimensions and all families of Hermitian, positive semidefinite, idempotent complex matrices with for every , of the quantity of item 4, with Mathlib's convention that the supremum of an empty or not-bounded-above family is . For the games produced by item 11 the indexing family is nonempty (both alphabets are nonempty, so the one-dimensional strategy , for exists for every such game); the bundle contains no statement that the family of values is bounded above, and under the convention a not-bounded-above family would have supremum .
The two conclusions are stated as implications, not as biconditionals. "" is an equality of real numbers between the supremum and ; it does not assert that any strategy attains the value . "" is a non-strict inequality in , where is the real number one half (real division , not integer division). Since, classically, every code either satisfies or does not, the two implications together say something about every code.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.