Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Cross-entropy and symmetric losses on the sphere, simplex ETFs, and the relaxed energy

Definition
NeuralCollapseCE_Basic

by Xeroth · Nov 23, 2026 · Mathlib 0df444a (Lean v4.33.1)

cross-entropyjensen-inequalityneural-collapsesimplex-etfuniform-distribution-on-sphere

Objects of Section 1 of Lu and Steinerberger, Neural collapse with cross-entropy loss (arXiv:2012.08465).

  1. Configurations. Points u1,…,un∈Rdu_1,\dots,u_n\in\mathbb{R}^du1​,…,un​∈Rd with the Euclidean norm ∥⋅∥\|\cdot\|∥⋅∥ and inner product ⟨⋅,⋅⟩\langle\cdot,\cdot\rangle⟨⋅,⋅⟩. A configuration is admissible if ∥ui∥=1\|u_i\|=1∥ui​∥=1 for every iii. The unit sphere of Rd\mathbb{R}^dRd is written Sd\mathbb{S}^dSd, as in the paper.
  2. Symmetric loss (eq. 1). For α∈R\alpha\in\mathbb{R}α∈R,
Lα(u)=∑i=1nlog⁡(1+∑j≠ieα(⟨uj,ui⟩−1)).\mathcal{L}_\alpha(u)=\sum_{i=1}^n\log\Big(1+\sum_{j\ne i}e^{\alpha(\langle u_j,u_i\rangle-1)}\Big).Lα​(u)=i=1∑n​log(1+j=i∑​eα(⟨uj​,ui​⟩−1)).
  1. Cross-entropy loss (eq. 2).
L(u,v)=∑i=1nlog⁡∑j=1ne⟨vj,ui⟩e⟨vi,ui⟩.\mathcal{L}(u,v)=\sum_{i=1}^n\log\frac{\sum_{j=1}^n e^{\langle v_j,u_i\rangle}}{e^{\langle v_i,u_i\rangle}}.L(u,v)=i=1∑n​loge⟨vi​,ui​⟩∑j=1n​e⟨vj​,ui​⟩​.
  1. Global minimisers. uuu is a global minimiser of Lα\mathcal{L}_\alphaLα​ if it is admissible and Lα(u)≤Lα(w)\mathcal{L}_\alpha(u)\le\mathcal{L}_\alpha(w)Lα​(u)≤Lα​(w) for every admissible www. (u,v)(u,v)(u,v) is a global minimiser of L\mathcal{L}L if uuu and vvv are admissible and L(u,v)≤L(u′,v′)\mathcal{L}(u,v)\le\mathcal{L}(u',v')L(u,v)≤L(u′,v′) for all admissible u′,v′u',v'u′,v′.
  2. Simplex equiangular tight frame. Unit vectors u1,…,unu_1,\dots,u_nu1​,…,un​ with ⟨ui,uj⟩=−1n−1\langle u_i,u_j\rangle=-\frac{1}{n-1}⟨ui​,uj​⟩=−n−11​ for all i≠ji\ne ji=j.
  3. Uniform measure and empirical measures. σd\sigma_dσd​ is the surface measure of Sd\mathbb{S}^dSd normalised to total mass 111. For points u1,…,un∈Sdu_1,\dots,u_n\in\mathbb{S}^du1​,…,un​∈Sd, μn=1n∑i=1nδui\mu_n=\frac1n\sum_{i=1}^n\delta_{u_i}μn​=n1​∑i=1n​δui​​.
  4. Relaxed energy (eq. 3). For a measure μ\muμ on Sd\mathbb{S}^dSd,
Lα(μ)=∫Sdlog⁡(∫Sdeα(⟨x,y⟩−1) μ(dy)) μ(dx).\mathcal{L}_\alpha(\mu)=\int_{\mathbb{S}^d}\log\Big(\int_{\mathbb{S}^d}e^{\alpha(\langle x,y\rangle-1)}\,\mu(dy)\Big)\,\mu(dx).Lα​(μ)=∫Sd​log(∫Sd​eα(⟨x,y⟩−1)μ(dy))μ(dx).

Formalization Note Rd\mathbb{R}^dRd is EuclideanSpace ℝ (Fin d) and Sd\mathbb{S}^dSd is its unit sphere Metric.sphere 0 1, so Sd\mathbb{S}^dSd here is the sphere of dimension d−1d-1d−1 (the paper's own notation). The uniform measure is Mathlib's Measure.toSphere of Lebesgue measure divided by its total mass. The simplex ETF is defined by unit norms and the pairwise inner products −1/(n−1)-1/(n-1)−1/(n−1), which is the characterisation the paper's proofs use; the formula is meant for n≥2n\ge2n≥2, and every statement using it assumes n≥2n\ge2n≥2.

Definition code
import Mathlib

/-!
Lu and Steinerberger, *Neural collapse with cross-entropy loss*, arXiv:2012.08465v2 (2021):
the unit-sphere configurations, the symmetric loss `L_α` (eq. (1)), the cross-entropy loss `L`
(eq. (2)), their constrained global minimisers (Theorems 1 and 2), the simplex equiangular tight
frame, the uniform probability measure on the sphere, the empirical measure of a configuration
(Theorem 3) and the relaxed energy `L_α(μ)` on probability measures (eq. (3), Proposition 4),
all from Section 1.
-/

open MeasureTheory

noncomputable section

namespace NeuralCollapseCE

/-- Section 1.1, p. 1: the feature space `ℝ^d` with the Euclidean norm `‖·‖` and inner
product `⟨·,·⟩`. -/
abbrev Vec (d : ℕ) : Type := EuclideanSpace ℝ (Fin d)

/-- Section 1.3, Theorem 3, p. 3: the unit sphere `S^d = {x ∈ ℝ^d : ‖x‖ = 1}` (the paper writes
`S^d` for the unit sphere of `ℝ^d`, on which the points `u_i ∈ ℝ^d`, `‖u_i‖ = 1` lie). -/
abbrev Sph (d : ℕ) : Type := Metric.sphere (0 : Vec d) 1

/-- Section 1.1, eqs. (1)-(2), p. 1, and Theorems 1-3: the constraint `‖u_i‖ = 1` for
`i = 1, …, n`. -/
def IsUnitConfig {n d : ℕ} (u : Fin n → Vec d) : Prop :=
  ∀ i, ‖u i‖ = 1

/-- Eq. (1), p. 1: the symmetric loss
`L_α(u) = ∑_{i=1}^n log (1 + ∑_{j ≠ i} exp (α (⟨u_j, u_i⟩ - 1)))`. -/
def symLoss {n d : ℕ} (α : ℝ) (u : Fin n → Vec d) : ℝ :=
  ∑ i, Real.log (1 + ∑ j ∈ Finset.univ.erase i, Real.exp (α * (inner ℝ (u j) (u i) - 1)))

/-- Eq. (2), p. 1: the cross-entropy loss
`L(u, v) = ∑_{i=1}^n log ((∑_{j=1}^n exp ⟨v_j, u_i⟩) / exp ⟨v_i, u_i⟩)`. -/
def ceLoss {n d : ℕ} (u v : Fin n → Vec d) : ℝ :=
  ∑ i, Real.log ((∑ j, Real.exp (inner ℝ (v j) (u i))) / Real.exp (inner ℝ (v i) (u i)))

/-- Theorem 2, p. 2 (and Theorem 3, p. 3): `u` is a global minimiser of `L_α(u)` subject to
`u_i ∈ ℝ^d`, `‖u_i‖ = 1`, `i = 1, …, n`. -/
def IsSymMinimizer {n d : ℕ} (α : ℝ) (u : Fin n → Vec d) : Prop :=
  IsUnitConfig u ∧ ∀ w : Fin n → Vec d, IsUnitConfig w → symLoss α u ≤ symLoss α w

/-- Theorem 1, p. 2: `(u, v)` is a global minimiser of `L(u, v)` subject to `u_i, v_i ∈ ℝ^d`,
`‖u_i‖ = ‖v_i‖ = 1`, `i = 1, …, n`. -/
def IsCEMinimizer {n d : ℕ} (u v : Fin n → Vec d) : Prop :=
  IsUnitConfig u ∧ IsUnitConfig v ∧
    ∀ u' v' : Fin n → Vec d, IsUnitConfig u' → IsUnitConfig v' → ceLoss u v ≤ ceLoss u' v'

/-- Theorems 1 and 2, p. 2: `{u_i}_{i=1}^n` form a simplex equiangular tight frame, i.e. unit
vectors with `⟨u_i, u_j⟩ = -1/(n-1)` for `i ≠ j` (the characterisation used at the end of the
proofs of Theorem 2, p. 6, and Theorem 1, p. 8; meaningful for `n ≥ 2`). -/
def IsSimplexETF {n d : ℕ} (u : Fin n → Vec d) : Prop :=
  (∀ i, ‖u i‖ = 1) ∧ ∀ i j, i ≠ j → inner ℝ (u i) (u j) = -1 / ((n : ℝ) - 1)

/-- Theorem 3 and Proposition 4, p. 3: the uniform probability measure on `S^d`, i.e. the surface
measure (Mathlib's `Measure.toSphere` of Lebesgue measure) normalised to total mass one. -/
def uniformSphere (d : ℕ) : Measure (Sph d) :=
  ((volume : Measure (Vec d)).toSphere Set.univ)⁻¹ • (volume : Measure (Vec d)).toSphere

/-- Theorem 3, p. 3: the probability measure `μ_n = (1/n) ∑_{i=1}^n δ_{u_i}` generated by a
configuration of `n` points of `S^d`. -/
def empiricalMeasure {n d : ℕ} (u : Fin n → Sph d) : Measure (Sph d) :=
  ((n : ENNReal)⁻¹) • ∑ i, Measure.dirac (u i)

/-- Eq. (3), p. 3: the relaxed energy of a measure `μ` on `S^d`,
`L_α(μ) = ∫ log (∫ exp (α (⟨x, y⟩ - 1)) μ(dy)) μ(dx)`. -/
def measureEnergy {d : ℕ} (α : ℝ) (μ : Measure (Sph d)) : ℝ :=
  ∫ x, Real.log (∫ y, Real.exp (α * (inner ℝ (x : Vec d) (y : Vec d) - 1)) ∂μ) ∂μ

end NeuralCollapseCE
Source
Lu and Steinerberger, Neural collapse with cross-entropy loss, arXiv:2012.08465v2 (2021), Section 1.1 eqs. (1)-(2) p. 1, Section 1.2 Theorems 1-2 p. 2, Section 1.3 Theorem 3, eq. (3), Proposition 4 p. 3; simplex ETF characterisation in Sections 2-3, pp. 6, 8
Read-back

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

Feature space Rd\mathbb{R}^dRd. For a natural number ddd, Rd\mathbb{R}^dRd denotes ddd-dimensional real Euclidean space: vectors x=(x1,…,xd)x = (x_1,\dots,x_d)x=(x1​,…,xd​) with the standard inner product and norm

⟨x,y⟩=∑k=1dxkyk,∥x∥=⟨x,x⟩.\langle x, y\rangle = \sum_{k=1}^d x_k y_k, \qquad \|x\| = \sqrt{\langle x, x\rangle}.⟨x,y⟩=k=1∑d​xk​yk​,∥x∥=⟨x,x⟩​.

The case d=0d = 0d=0 is allowed. Then R0={0}\mathbb{R}^0 = \{0\}R0={0} is the one-point space.

Unit sphere SdS_dSd​. For a natural number ddd, SdS_dSd​ is the set of vectors of norm exactly 111:

Sd={x∈Rd:∥x∥=1},S_d = \{x \in \mathbb{R}^d : \|x\| = 1\},Sd​={x∈Rd:∥x∥=1},

with its subspace (Borel) structure. Conventionally this is the (d−1)(d-1)(d−1)-dimensional sphere sitting in Rd\mathbb{R}^dRd. Degenerate cases:

  • d=0d = 0d=0: S0S_0S0​ is empty.
  • d=1d = 1d=1: S1={−1,+1}S_1 = \{-1, +1\}S1​={−1,+1}.

Unit configuration. A family u=(u1,…,un)u = (u_1,\dots,u_n)u=(u1​,…,un​) of nnn vectors in Rd\mathbb{R}^dRd (indexed by nnn indices, n≥0n \ge 0n≥0) is a unit configuration if ∥ui∥=1\|u_i\| = 1∥ui​∥=1 for every index iii. Edge cases:

  • n=0n = 0n=0: the condition holds vacuously for the empty family.
  • d=0d = 0d=0 and n≥1n \ge 1n≥1: no unit configuration exists.

Symmetric loss LαL_\alphaLα​. For any real number α\alphaα (positive, zero or negative) and any family u=(u1,…,un)u = (u_1,\dots,u_n)u=(u1​,…,un​) of vectors in Rd\mathbb{R}^dRd, not required to have unit norm,

Lα(u)=∑i=1nlog⁡(1+∑j=1j≠inexp⁡(α(⟨uj,ui⟩−1))),L_\alpha(u) = \sum_{i=1}^n \log\Big(1 + \sum_{\substack{j=1 \\ j \ne i}}^n \exp\big(\alpha(\langle u_j, u_i\rangle - 1)\big)\Big),Lα​(u)=i=1∑n​log(1+j=1j=i​∑n​exp(α(⟨uj​,ui​⟩−1))),

where log⁡\loglog is the natural logarithm. Each logarithm's argument is at least 111, so no junk values of log⁡\loglog arise. When n=0n = 0n=0, Lα(u)=0L_\alpha(u) = 0Lα​(u)=0. When n=1n = 1n=1, the inner sum is empty and Lα(u)=log⁡1=0L_\alpha(u) = \log 1 = 0Lα​(u)=log1=0.

Cross-entropy loss LLL. For two families u=(u1,…,un)u = (u_1,\dots,u_n)u=(u1​,…,un​) and v=(v1,…,vn)v = (v_1,\dots,v_n)v=(v1​,…,vn​) of vectors in Rd\mathbb{R}^dRd, not required to have unit norm,

L(u,v)=∑i=1nlog⁡(∑j=1nexp⁡⟨vj,ui⟩exp⁡⟨vi,ui⟩).L(u, v) = \sum_{i=1}^n \log\left(\frac{\sum_{j=1}^n \exp\langle v_j, u_i\rangle}{\exp\langle v_i, u_i\rangle}\right).L(u,v)=i=1∑n​log(exp⟨vi​,ui​⟩∑j=1n​exp⟨vj​,ui​⟩​).

There is no temperature, scaling or bias parameter. Each argument of log⁡\loglog is positive and at least 111. When n=0n = 0n=0, L(u,v)=0L(u, v) = 0L(u,v)=0.

Global minimiser of LαL_\alphaLα​. For a real α\alphaα, a family u=(u1,…,un)u = (u_1,\dots,u_n)u=(u1​,…,un​) in Rd\mathbb{R}^dRd is a minimiser of LαL_\alphaLα​ if both of the following hold:

  • uuu is a unit configuration;
  • Lα(u)≤Lα(w)L_\alpha(u) \le L_\alpha(w)Lα​(u)≤Lα​(w) for every unit configuration w=(w1,…,wn)w = (w_1,\dots,w_n)w=(w1​,…,wn​) in Rd\mathbb{R}^dRd with the same nnn and ddd.

This is a global (not local) minimality condition, with non-strict inequality, so ties are allowed and minimisers need not be unique. Edge cases:

  • d=0d = 0d=0 and n≥1n \ge 1n≥1: no minimiser exists, since there are no unit configurations.
  • n=0n = 0n=0: the empty family is a minimiser.

Global minimiser of LLL. A pair of families u=(u1,…,un)u = (u_1,\dots,u_n)u=(u1​,…,un​), v=(v1,…,vn)v = (v_1,\dots,v_n)v=(v1​,…,vn​) in Rd\mathbb{R}^dRd is a minimiser of the cross-entropy loss if all of the following hold:

  • uuu is a unit configuration;
  • vvv is a unit configuration;
  • L(u,v)≤L(u′,v′)L(u, v) \le L(u', v')L(u,v)≤L(u′,v′) for every pair of unit configurations u′,v′u', v'u′,v′ in Rd\mathbb{R}^dRd of the same length nnn.

The minimisation is joint over both families, with non-strict inequality, so ties are allowed. Edge cases:

  • d=0d = 0d=0 and n≥1n \ge 1n≥1: no minimiser exists.
  • n=0n = 0n=0: the pair of empty families is a minimiser.

Simplex equiangular tight frame. A family u=(u1,…,un)u = (u_1,\dots,u_n)u=(u1​,…,un​) in Rd\mathbb{R}^dRd is called a simplex ETF if both of the following hold:

  • ∥ui∥=1\|u_i\| = 1∥ui​∥=1 for every iii;
  • for every pair of distinct indices i≠ji \ne ji=j,
⟨ui,uj⟩=−1n−1,\langle u_i, u_j\rangle = \frac{-1}{n-1},⟨ui​,uj​⟩=n−1−1​,

where n−1n - 1n−1 is computed as a real number.

No further condition (spanning, tightness, or a relation to ddd) is imposed beyond these Gram-matrix entries. Edge cases:

  • n=0n = 0n=0: every family qualifies vacuously.
  • n=1n = 1n=1: there are no distinct pairs, so the only requirement is ∥u1∥=1\|u_1\| = 1∥u1​∥=1. The would-be division by zero never occurs.
  • n≥2n \ge 2n≥2 and d<n−1d < n-1d<n−1: no such family exists, because the prescribed Gram matrix has rank n−1n-1n−1.

Uniform measure on the sphere σd\sigma_dσd​. Let λ\lambdaλ be Lebesgue measure on Rd\mathbb{R}^dRd. Let σ~\tilde\sigmaσ~ be the induced surface measure on SdS_dSd​, defined for measurable A⊆SdA \subseteq S_dA⊆Sd​ by

σ~(A)=d⋅λ({ra:0<r<1, a∈A}).\tilde\sigma(A) = d \cdot \lambda\big(\{ r a : 0 < r < 1,\ a \in A\}\big).σ~(A)=d⋅λ({ra:0<r<1, a∈A}).

The measure is then normalised by its total mass:

σd=σ~(Sd)−1⋅σ~,\sigma_d = \tilde\sigma(S_d)^{-1} \cdot \tilde\sigma,σd​=σ~(Sd​)−1⋅σ~,

with the inverse taken in [0,∞][0, \infty][0,∞].

  • d≥1d \ge 1d≥1: the total mass is finite and positive, so σd\sigma_dσd​ is a rotation-invariant probability measure on SdS_dSd​. For d=1d = 1d=1 it gives mass 12\tfrac1221​ to each of ±1\pm 1±1.
  • d=0d = 0d=0: S0S_0S0​ is empty, the total mass is 000, and the convention ∞⋅0=0\infty \cdot 0 = 0∞⋅0=0 makes σ0\sigma_0σ0​ the zero measure, not a probability measure.

Empirical measure μn\mu_nμn​. For a family u=(u1,…,un)u = (u_1,\dots,u_n)u=(u1​,…,un​) of points of the unit sphere SdS_dSd​,

μn=1n∑i=1nδui,\mu_n = \frac{1}{n} \sum_{i=1}^n \delta_{u_i},μn​=n1​i=1∑n​δui​​,

where δui\delta_{u_i}δui​​ is the Dirac point mass at uiu_iui​. Repeated points are counted with multiplicity. The factor 1n\frac1nn1​ is computed in [0,∞][0, \infty][0,∞].

  • n≥1n \ge 1n≥1: μn\mu_nμn​ is a probability measure on SdS_dSd​.
  • n=0n = 0n=0: 10=∞\frac10 = \infty01​=∞ multiplies the empty sum 000, giving the zero measure.

Relaxed energy Lα(μ)L_\alpha(\mu)Lα​(μ). For a real α\alphaα and an arbitrary measure μ\muμ on SdS_dSd​ (not required to be a probability measure, or even finite),

Lα(μ)=∫Sdlog⁡(∫Sdexp⁡(α(⟨x,y⟩−1)) μ(dy))μ(dx).L_\alpha(\mu) = \int_{S_d} \log\left(\int_{S_d} \exp\big(\alpha(\langle x, y\rangle - 1)\big)\, \mu(dy)\right) \mu(dx).Lα​(μ)=∫Sd​​log(∫Sd​​exp(α(⟨x,y⟩−1))μ(dy))μ(dx).

Integrals here follow these conventions:

  • An integral whose integrand is not integrable is assigned the value 000.
  • The logarithm satisfies log⁡0=0\log 0 = 0log0=0 and log⁡t=log⁡∣t∣\log t = \log|t|logt=log∣t∣ for t<0t < 0t<0; the inner integral is never negative, so only log⁡0=0\log 0 = 0log0=0 can actually come into play.

Consequences:

  • If μ\muμ is the zero measure, Lα(μ)=0L_\alpha(\mu) = 0Lα​(μ)=0.
  • If μ\muμ is not finite, the inner integral may be non-integrable and is then replaced by 000.
Human review
  • Endorsed by Shuze Chen · Nov 23, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Xeroth · Nov 23, 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