Same-state pairs: hard-whitening objective, world kernel, scene-explained fraction, same-state operator and Procrustes objects
DefinitionSameStatePairs_BasicObjects of Sections 2–4 and Appendix A of Li (2026), arXiv:2611.16182.
- Encoders, centring, whitening. On a finite set carrying a law , an encoder is , with . It is centred if and whitened if . An orthogonal acts by .
- Hard-whitening objective (Section 2.1). For a law of positive pairs on , the prediction term is . The hard anti-collapse term is if is centred and whitened and otherwise. A global minimiser is a centred, whitened with for every centred, whitened . The span of is the span of its coordinate functions . The centred function space is .
- World (Section 2.1). is a finite world with , , . The same-state law is : and for . The world kernel is and the Markov operator is , with , . The squared residual of state functions under is .
- Scene-explained fraction (Section 3). An observation of state is with a nuisance independent of , and an encoder is written . is the covariance under of , and . The bound of eq. (2) is . The paired residual is .
- Same-state operator (Section 4.1). A channel maps the world to a finite observation space , with . The same-state pair law is , and the mixture is . The operator is , with matrix , and is the quadratic term of eq. (3).
- Spectrum of . are the eigenvalues of with multiplicity. belongs to the constant function, and are the eigenvalues on the centred subspace. on the centred subspace is the matrix rank of minus one. The top eigenspace is the span of the centred eigenfunctions with eigenvalue . The positive eigenspace and are also taken within the centred subspace.
- Pairing (Section 4.2). For pairs in , the orthogonal Procrustes objective is over . The exact solutions are the with for all . is block-diagonal with on the first coordinates.
Formalization Note The eigenvalues are the roots of the characteristic polynomial of the matrix , sorted in decreasing order. Index is the constant eigenfunction's eigenvalue , which is the largest, so index is the paper's on the centred subspace. is the sum of the square roots of the eigenvalues of . The observation-level objects are for a finite world and a finite observation space.
import Mathlib
/-!
Xin Li, *Same-State Pairs Make One JEPA Proof of the Platonic Representation Hypothesis Vacuous:
A Correction and a Gauge Ledger*, arXiv:2611.16182v1 (2026): the finite world, positive-pair
laws, world kernel and hard-whitening objective of Section 2.1, the scene-explained fraction of
Section 3, the same-state pair operator `T_s` and its spectrum of Section 4.1 and Appendix A.1, and
the orthogonal Procrustes objects of Section 4.2 and Appendix A.2.
-/
noncomputable section
namespace SameStatePairs
/-- Section 2.1: the squared Euclidean norm `‖v‖² = ∑ᵢ vᵢ²` of an embedding `v ∈ ℝ^k`. -/
def sqNorm {k : ℕ} (v : Fin k → ℝ) : ℝ := ∑ i, v i ^ 2
/-- Section 2.1: the action `v ↦ Q v` of an orthogonal matrix `Q ∈ O(k)` on `ℝ^k`. -/
def rot {k : ℕ} (Q : Matrix.orthogonalGroup (Fin k) ℝ) (v : Fin k → ℝ) : Fin k → ℝ :=
(Q : Matrix (Fin k) (Fin k) ℝ).mulVec v
section Encoders
variable {α : Type*} [Fintype α] {k : ℕ}
/-- Section 2.1 (Notation): an encoder `h : α → ℝ^k` on a finite set `α` carrying the law `w` is
centred if `E h = ∑ₐ w(a) h(a) = 0`. -/
def IsCentered (w : α → ℝ) (h : α → Fin k → ℝ) : Prop :=
∀ i, ∑ a, w a * h a i = 0
/-- Section 2.1 (Notation): an encoder `h` is whitened under `w` if
`E h hᵀ = ∑ₐ w(a) h(a) h(a)ᵀ = I_k`. -/
def IsWhitened (w : α → ℝ) (h : α → Fin k → ℝ) : Prop :=
∀ i j, ∑ a, w a * h a i * h a j = if i = j then 1 else 0
/-- Section 2.1: the prediction term `L_π(h) = E_{(a,a')∼π} ‖h(a) - h(a')‖²` for a law `π` of
positive pairs on `α`. -/
def pairLoss (π : α → α → ℝ) (h : α → Fin k → ℝ) : ℝ :=
∑ a, ∑ a', π a a' * sqNorm (h a - h a')
open Classical in
/-- Section 2.1: the hard anti-collapse term `Ω ∈ {0, ∞}` of the hard-whitening objective:
`Ω(h) = 0` if `h` is centred and whitened under `w`, and `Ω(h) = +∞` otherwise. -/
def hardOmega (w : α → ℝ) (h : α → Fin k → ℝ) : EReal :=
if IsCentered w h ∧ IsWhitened w h then 0 else ⊤
/-- Section 2.1: `h` is a global minimiser of the hard-whitening population objective, i.e. of the
prediction term `L_π` subject to `Ω(h) = 0`: `h` is centred and whitened under `w`, and
`L_π(h) ≤ L_π(h')` for every centred, whitened `h'`. -/
def IsGlobalMin (w : α → ℝ) (π : α → α → ℝ) (h : α → Fin k → ℝ) : Prop :=
IsCentered w h ∧ IsWhitened w h ∧
∀ h' : α → Fin k → ℝ, IsCentered w h' → IsWhitened w h' → pairLoss π h ≤ pairLoss π h'
/-- Lemma 1 and Theorem 1: the span of an encoder `h`, i.e. the span of its coordinate functions
`h_1, …, h_k : α → ℝ` in the function space. -/
def coordSpan (h : α → Fin k → ℝ) : Submodule ℝ (α → ℝ) :=
Submodule.span ℝ (Set.range fun i a => h a i)
/-- Lemma 1 and Section 4.1: the centred function space `{φ : α → ℝ | ∑ₐ w(a) φ(a) = 0}`. -/
def centeredSpace (w : α → ℝ) : Submodule ℝ (α → ℝ) :=
LinearMap.ker (dotProductBilin ℝ ℝ w)
end Encoders
section StateLevel
variable {Z : Type*} [Fintype Z]
/-- Section 2.1, Lemma 1: the same-state positive-pair law `π = diag(p)`:
`π(z, z') = p(z)` if `z = z'` and `0` otherwise. -/
def sameStateLaw [DecidableEq Z] (p : Z → ℝ) (z z' : Z) : ℝ :=
if z = z' then p z else 0
/-- Section 2.1 (Notation): the world kernel `K_π = D^{-1/2} Π D^{-1/2}` with `D = diag(p)` and
`Π_{zz'} = π(z, z')`. -/
def worldKernel (p : Z → ℝ) (π : Z → Z → ℝ) : Matrix Z Z ℝ :=
fun z z' => π z z' / Real.sqrt (p z * p z')
/-- Section 2.1 (Notation): the Markov operator `T_π = D^{-1} Π` on state functions. -/
def markovOp (p : Z → ℝ) (π : Z → Z → ℝ) : Matrix Z Z ℝ :=
fun z z' => π z z' / p z
/-- Proposition 1, eq. (1): the squared residual `E‖f - Q g‖² = ∑_z p(z) ‖f(z) - Q g(z)‖²` of two
state functions `f, g : Z → ℝ^k` under a rotation `Q ∈ O(k)`. -/
def rotResidual {k : ℕ} (p : Z → ℝ) (f g : Z → Fin k → ℝ)
(Q : Matrix.orthogonalGroup (Fin k) ℝ) : ℝ :=
∑ z, p z * sqNorm (f z - rot Q (g z))
end StateLevel
section Nuisance
variable {Z N : Type*} [Fintype Z] [Fintype N] {k : ℕ}
/-- Section 3 and Appendix A.3: an encoder `f` of observations `X = (z, ν)` of world state `z`
with a nuisance `ν ∼ q` independent of `z` is written `e(z, ν) = f(X)`; this is
`E[f(X) | Z = z] = ∑_ν q(ν) e(z, ν)`. -/
def condMean (q : N → ℝ) (e : Z → N → Fin k → ℝ) (z : Z) : Fin k → ℝ :=
fun i => ∑ ν, q ν * e z ν i
/-- Section 3: `C_f = Cov(E[f(X) | Z])`, the covariance under `z ∼ p` of the scene-related part
of `f`. -/
def sceneCov (p : Z → ℝ) (q : N → ℝ) (e : Z → N → Fin k → ℝ) : Matrix (Fin k) (Fin k) ℝ :=
fun i j => ∑ z, p z * (condMean q e z i - ∑ z', p z' * condMean q e z' i) *
(condMean q e z j - ∑ z', p z' * condMean q e z' j)
/-- Section 3: the scene-explained fraction `ρ(f) = tr(C_f^{1/2}) / k`, where `tr(C_f^{1/2})` is the
sum of the square roots of the eigenvalues of `C_f` (the roots of its characteristic polynomial,
with multiplicity). -/
def sceneFraction (p : Z → ℝ) (q : N → ℝ) (e : Z → N → Fin k → ℝ) : ℝ :=
((sceneCov p q e).charpoly.roots.map Real.sqrt).sum / k
/-- Section 3, eq. (2): the lower bound `2k (1 - min(ρ₁, ρ₂))` on the aligned error. -/
def survivorBound (k : ℕ) (ρ₁ ρ₂ : ℝ) : ℝ :=
2 * k * (1 - min ρ₁ ρ₂)
/-- Section 3, eq. (2), and Proposition 2: `E‖f₁(X₁) - Q f₂(X₂)‖²` over paired observations
`X₁ = (z, ν₁)`, `X₂ = (z, ν₂)` of one state `z ∼ p` with independent nuisances `ν₁ ∼ q₁`,
`ν₂ ∼ q₂`. -/
def pairedResidual {N₁ N₂ : Type*} [Fintype N₁] [Fintype N₂] (p : Z → ℝ) (q₁ : N₁ → ℝ)
(q₂ : N₂ → ℝ) (e₁ : Z → N₁ → Fin k → ℝ) (e₂ : Z → N₂ → Fin k → ℝ)
(Q : Matrix.orthogonalGroup (Fin k) ℝ) : ℝ :=
∑ z, ∑ ν₁, ∑ ν₂, p z * q₁ ν₁ * q₂ ν₂ * sqNorm (e₁ z ν₁ - rot Q (e₂ z ν₂))
end Nuisance
section Observation
variable {Z X : Type*} [Fintype Z] [Fintype X] [DecidableEq X] {k : ℕ}
/-- Section 4.1: `κ(z, x) = P_{X|Z}(x | z)` is an observation channel from the finite world `Z` to
the finite observation space `X`. -/
def IsChannel (κ : Z → X → ℝ) : Prop :=
(∀ z x, 0 ≤ κ z x) ∧ ∀ z, ∑ x, κ z x = 1
/-- Section 4.1: the observation law `P_X(x) = ∑_z p(z) κ(z, x)`. -/
def obsLaw (p : Z → ℝ) (κ : Z → X → ℝ) (x : X) : ℝ :=
∑ z, p z * κ z x
/-- Section 4.1: the same-state pair law `P_s`: given `Z = z`, the two views are conditionally
independent with common law `κ(z, ·)`, so `P_s(x, x') = ∑_z p(z) κ(z, x) κ(z, x')`. -/
def sameStatePairLaw (p : Z → ℝ) (κ : Z → X → ℝ) (x x' : X) : ℝ :=
∑ z, p z * κ z x * κ z x'
/-- Section 4.1: the positive-pair mixture `P_+^ε = ε P_s + (1 - ε) P_X ⊗ P_X`. -/
def mixPairLaw (p : Z → ℝ) (κ : Z → X → ℝ) (ε : ℝ) (x x' : X) : ℝ :=
ε * sameStatePairLaw p κ x x' + (1 - ε) * (obsLaw p κ x * obsLaw p κ x')
/-- Section 4.1: the operator `T_s = A A*` on functions of the observation, with
`(A φ)(x) = E[φ(Z) | X = x]` and `(A* f)(z) = E[f(X) | Z = z]`; as a matrix,
`T_s(x, x') = ∑_z p(z) κ(z, x) κ(z, x') / P_X(x)`. -/
def sameStateOp (p : Z → ℝ) (κ : Z → X → ℝ) : Matrix X X ℝ :=
fun x x' => sameStatePairLaw p κ x x' / obsLaw p κ x
/-- Section 4.1, eq. (3): `∑_{j=1}^k ⟨f_j, T_s f_j⟩_{L²(P_X)}`. -/
def topQuad (p : Z → ℝ) (κ : Z → X → ℝ) (f : X → Fin k → ℝ) : ℝ :=
∑ j, ∑ x, obsLaw p κ x * f x j * (sameStateOp p κ).mulVec (fun x' => f x' j) x
/-- Section 4.1 and Appendix A.1: the eigenvalues of `T_s`, with multiplicity, as the roots of its
characteristic polynomial sorted in decreasing order. Index `0` is the eigenvalue `1` of the
constant function; for `1 ≤ i ≤ |X| - 1`, `obsEig p κ i` is `λ_i`, the `i`-th eigenvalue of `T_s` on
the centred subspace (`0` for `i ≥ |X|`; statements do not use those values). -/
def obsEig (p : Z → ℝ) (κ : Z → X → ℝ) (i : ℕ) : ℝ :=
((sameStateOp p κ).charpoly.roots.sort (· ≥ ·)).getD i 0
/-- Theorem 1: `rank(T_s)` on the centred subspace, i.e. the rank of the matrix `T_s` minus the
contribution `1` of the constant function. -/
def obsRank (p : Z → ℝ) (κ : Z → X → ℝ) : ℕ :=
(sameStateOp p κ).rank - 1
/-- Theorem 1: the top eigenspace of `T_s`, the span of the centred eigenfunctions of `T_s` with
eigenvalue at least `λ_k`. -/
def topSpace (p : Z → ℝ) (κ : Z → X → ℝ) (k : ℕ) : Submodule ℝ (X → ℝ) :=
(⨆ (μ : ℝ) (_ : obsEig p κ k ≤ μ), Module.End.eigenspace (Matrix.toLin' (sameStateOp p κ)) μ) ⊓
centeredSpace (obsLaw p κ)
/-- Theorem 1: the span of the centred eigenfunctions of `T_s` with eigenvalue greater than
`λ_k`. -/
def strictTopSpace (p : Z → ℝ) (κ : Z → X → ℝ) (k : ℕ) : Submodule ℝ (X → ℝ) :=
(⨆ (μ : ℝ) (_ : obsEig p κ k < μ), Module.End.eigenspace (Matrix.toLin' (sameStateOp p κ)) μ) ⊓
centeredSpace (obsLaw p κ)
/-- Theorem 1: the positive eigenspace of `T_s` on the centred subspace. -/
def posSpace (p : Z → ℝ) (κ : Z → X → ℝ) : Submodule ℝ (X → ℝ) :=
(⨆ (μ : ℝ) (_ : 0 < μ), Module.End.eigenspace (Matrix.toLin' (sameStateOp p κ)) μ) ⊓
centeredSpace (obsLaw p κ)
/-- Theorem 1: `ker T_s` on the centred subspace. -/
def obsKerSpace (p : Z → ℝ) (κ : Z → X → ℝ) : Submodule ℝ (X → ℝ) :=
LinearMap.ker (Matrix.toLin' (sameStateOp p κ)) ⊓ centeredSpace (obsLaw p κ)
end Observation
section Pairing
variable {m k : ℕ}
/-- Section 4.2: the orthogonal Procrustes objective `∑_i ‖y_i - R x_i‖²` of `m` synchronized
pairs `(x_i, y_i)` in whitened coordinates, for `R ∈ O(k)`. -/
def procrustesObj (x y : Fin m → Fin k → ℝ) (R : Matrix.orthogonalGroup (Fin k) ℝ) : ℝ :=
∑ i, sqNorm (y i - rot R (x i))
/-- Section 4.2 and Appendix A.2: the exact solutions `{R ∈ O(k) : 𝐗 Rᵀ = 𝐘}`, i.e. `R x_i = y_i`
for every pair. -/
def pairSolutions (x y : Fin m → Fin k → ℝ) : Set (Matrix.orthogonalGroup (Fin k) ℝ) :=
{R | ∀ i, rot R (x i) = y i}
/-- Section 4.2, Theorem 2: the block-diagonal matrix `I_r ⊕ S` on `ℝ^k`, with `I_r` on the first
`r` coordinates and the `(k - r) × (k - r)` block `S` on the remaining ones. -/
def blockEmbed (r : ℕ) (S : Matrix (Fin (k - r)) (Fin (k - r)) ℝ) : Matrix (Fin k) (Fin k) ℝ :=
fun i j =>
if hij : r ≤ i.val ∧ r ≤ j.val then
S ⟨i.val - r, by have := i.isLt; omega⟩ ⟨j.val - r, by have := j.isLt; omega⟩
else if i = j then 1 else 0
end Pairing
end SameStatePairs
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
sqNorm. For a natural number and a vector , the squared Euclidean norm is
When this is the empty sum, .
rot. For , a real orthogonal matrix (so ), and , this is the matrix–vector product , with .
IsCentered. The setting is:
- is any finite type, possibly empty.
- .
- is an arbitrary real function. It is not required to be nonnegative or to sum to .
- , with coordinates .
is centred under if, for every coordinate ,
This holds automatically when , when is empty, or when .
IsWhitened. With as above (no conditions on ), is whitened under if, for all ,
This is vacuously true when . It is impossible when and is empty or . More generally, it is impossible whenever exceeds the number of points with , because the left-hand matrix has rank at most that number.
pairLoss. For an arbitrary real function (not required to be a probability law) and ,
where is the sum of squared coordinates.
hardOmega. For and , this is an extended-real value :
- if is both centred and whitened under (in the senses above);
- otherwise.
IsGlobalMin. For , and , the statement " is a global minimiser" means all three of the following hold:
- is centred under ;
- is whitened under ;
- for every that is centred and whitened under , .
The definition does not refer to directly. If no centred whitened encoder exists (see the impossibility cases above), the predicate is false for every .
coordSpan. For , this is the real linear span, inside the space of all functions , of the coordinate functions (where is the -th coordinate of ). When it is the zero subspace.
centeredSpace. For , this is the linear subspace
the kernel of the linear functional . If , it is the whole space .
sameStateLaw. For a finite type with decidable equality and an arbitrary , this is the function on given by
that is, the diagonal matrix . No positivity or normalisation of is assumed.
worldKernel. For arbitrary and , this is the real matrix
It follows these conventions:
- The square root is of the product .
- The square root of a negative number is taken to be .
- Division by yields .
So whenever . When and are both negative, the product is positive and the entry is .
markovOp. For arbitrary and , this is the matrix
with the entry set to whenever .
rotResidual. For arbitrary , functions and ,
condMean. The setting is:
- and are finite types.
- is arbitrary (not required to be a probability law).
- .
For , this is the vector with coordinates
sceneCov. For arbitrary , and , let be as in condMean and let . This is the matrix
It is symmetric. It is a genuine covariance only if is a probability law, which is not assumed.
sceneFraction. With as in sceneCov, this is
where ranges over the real roots of the characteristic polynomial of , counted with multiplicity. Because is symmetric, these are all of its eigenvalues. The definition uses these conventions:
- The square root of a negative eigenvalue is taken to be . Negative eigenvalues can occur, since may take negative values.
- When , the division by gives .
survivorBound. For and real numbers , this is the real number
pairedResidual. The setting is:
- , , are finite types.
- , , are arbitrary real functions.
- and .
- .
The quantity is
IsChannel. For finite types and (with having decidable equality), is a channel if both of the following hold:
- for all ;
- for every .
If is empty this holds for every . If is nonempty and is empty it is impossible.
obsLaw. For arbitrary and (neither assumed to be a law or a channel here), this is the function on given by
sameStatePairLaw. For arbitrary and , this is the function on given by
mixPairLaw. For arbitrary , and an arbitrary real (not restricted to ), this is the function on given by
sameStateOp. For arbitrary and , this is the matrix
with the entry set to whenever . It acts on functions by
topQuad. For arbitrary , and with coordinate functions , this is
It equals when .
obsEig. For arbitrary , and , the construction is:
- Take the real roots of the characteristic polynomial of the matrix , counted with multiplicity. Any non-real complex roots are omitted, and is not assumed symmetric.
- Sort these real roots in decreasing order, indexed from .
- is the entry at position , or if is at least the number of real roots.
So is the largest real eigenvalue of , whatever its value. The value arises both as a genuine eigenvalue and as padding beyond the end of the list.
obsRank. For arbitrary and , this is the natural number , using truncated subtraction. It is when .
topSpace. For arbitrary , and , let be the position- entry from obsEig (0-indexed, so this is the -th largest real root, or if there are at most real roots). This is the subspace of given by
Here:
- is the eigenspace of the linear map . It is if is not an eigenvalue.
- The sum is the span of the union of these eigenspaces.
strictTopSpace. This is the same as topSpace, except that the eigenspaces summed are those with (strict inequality):
posSpace. For arbitrary and , this is
the span of all eigenvectors of with strictly positive real eigenvalue, intersected with the -centred functions.
obsKerSpace. For arbitrary and , this is
procrustesObj. For , families and in , and , this is
It equals when .
pairSolutions. For and in , this is the set
When this is all of . It may be empty.
blockEmbed. For and an arbitrary real matrix (with truncated at ; is not required to be orthogonal), this is the matrix with rows and columns indexed and entries
That is, . When , is the empty matrix and .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.