LeJEPA: Fisher information, mean-zero densities, covariance, probe bias/variance, characteristic-function distances
DefinitionLeJEPA_BasicObjects used by the LeJEPA mission. Throughout, carries Lebesgue measure.
- Fisher information. For a differentiable ,
- Mean-zero density. is continuously differentiable, , , and .
- Covariance. , which is the paper's for a mean-zero .
- Gaussian density. has density .
- Frobenius norm. .
- Ridge probe bias. For data , labels with , and , the estimator has bias .
- Least-squares total variance. With , it is .
- Moments. .
- Characteristic functions. The standard Gaussian has , and the empirical characteristic function of samples is .
- Characteristic-function distances. With weight ,
These are the statistics of the paper's Appendix B.12–B.13. The Epps–Pulley statistic of Section 4.2.3 is with .
Formalization Note Vectors in are functions , and gradients are written through partial derivatives. takes values in , so it is defined without any integrability assumption.
import Mathlib
/-!
Balestriero and LeCun, *LeJEPA: Provable and Scalable Self-Supervised Learning Without the Heuristics*,
arXiv:2511.08544v3 (2025). Objects used by the formal statements of the mission.
-/
open MeasureTheory Matrix
open scoped ENNReal
noncomputable section
namespace LeJEPA
variable {K N : ℕ}
/-- The `i`-th partial derivative `∂_i p(x)` of `p : ℝ^K → ℝ`. -/
def partialDeriv (p : (Fin K → ℝ) → ℝ) (i : Fin K) (x : Fin K → ℝ) : ℝ :=
fderiv ℝ p x (Pi.single i 1)
/-- Fisher-information functional `J(p) = ∫ ‖∇ log p‖² p = ∫_{p > 0} ‖∇ p‖² / p`, valued in `[0, ∞]`. -/
def fisherInfo (p : (Fin K → ℝ) → ℝ) : ℝ≥0∞ :=
∫⁻ x, if 0 < p x then ENNReal.ofReal ((∑ i, partialDeriv p i x ^ 2) / p x) else 0
/-- A mean-zero probability density on `ℝ^K` with finite second moments and continuously differentiable
(the regularity under which the score `∇ log p` and `J(p)` are defined). -/
structure IsMeanZeroDensity (p : (Fin K → ℝ) → ℝ) : Prop where
contDiff : ContDiff ℝ 1 p
nonneg : ∀ x, 0 ≤ p x
integral_eq_one : ∫ x, p x = 1
integrable_sq : Integrable (fun x => (∑ i, x i ^ 2) * p x)
mean_zero : ∀ i, ∫ x, x i * p x = 0
/-- Covariance matrix `Σ = E[X Xᵀ]` of a mean-zero density `p`. -/
def covMat (p : (Fin K → ℝ) → ℝ) : Matrix (Fin K) (Fin K) ℝ := fun i j => ∫ x, x i * x j * p x
/-- Density of the Gaussian `N(0, S)` on `ℝ^K`. -/
def gaussDensity (S : Matrix (Fin K) (Fin K) ℝ) (x : Fin K → ℝ) : ℝ :=
(2 * Real.pi) ^ (-(K : ℝ) / 2) * S.det ^ (-(1 : ℝ) / 2) * Real.exp (-(1 / 2) * (x ⬝ᵥ (S⁻¹ *ᵥ x)))
/-- Frobenius norm `‖S‖_F = (∑_{ij} S_{ij}²)^{1/2}`. -/
def frobNorm (S : Matrix (Fin K) (Fin K) ℝ) : ℝ := Real.sqrt (∑ i, ∑ j, S i j ^ 2)
/-- Bias `E[β̂] - β` of the ridge (Tikhonov) estimator `β̂ = (ZᵀZ + λI)⁻¹ Zᵀ y` when `y = Zβ + ε`, `E[ε] = 0`. -/
def ridgeBias (Z : Matrix (Fin N) (Fin K) ℝ) (lam : ℝ) (β : Fin K → ℝ) : Fin K → ℝ :=
((Zᵀ * Z + lam • (1 : Matrix (Fin K) (Fin K) ℝ))⁻¹ * (Zᵀ * Z)) *ᵥ β - β
/-- Total variance `tr Var(β̂) = σ² tr((ZᵀZ)⁻¹)` of the least-squares estimator under noise `Var(ε) = σ² I`. -/
def olsTotalVariance (Z : Matrix (Fin N) (Fin K) ℝ) (σ : ℝ) : ℝ := σ ^ 2 * ((Zᵀ * Z)⁻¹).trace
/-- The `k`-th raw moment `m_k(P) = ∫ x^k dP`. -/
def rawMoment (k : ℕ) (P : Measure ℝ) : ℝ := ∫ x, x ^ k ∂P
/-- Characteristic function of the standard Gaussian, `φ_G(t) = e^{-t²/2}`. -/
def stdGaussCF (t : ℝ) : ℂ := (Real.exp (-(t ^ 2) / 2) : ℂ)
/-- Empirical characteristic function `φ̂_N(t) = (1/N) ∑_j e^{i t z_j}`. -/
def empCF (z : Fin N → ℝ) (t : ℝ) : ℂ := (1 / (N : ℂ)) * ∑ j, Complex.exp (Complex.I * (t : ℂ) * (z j : ℂ))
/-- V-statistic `D̂_V = ∫ w_s(t) |φ̂_N(t) - φ_G(t)|² dt`, Gaussian weight `w_s(t) = e^{-s² t²}`. -/
def ecfDistance (s : ℝ) (z : Fin N → ℝ) : ℝ :=
∫ t : ℝ, Real.exp (-(s ^ 2 * t ^ 2)) * ‖empCF z t - stdGaussCF t‖ ^ 2
/-- Population distance `D(P, G) = ∫ w_s(t) |φ_P(t) - φ_G(t)|² dt`. -/
def cfDistance (s : ℝ) (P : Measure ℝ) : ℝ :=
∫ t : ℝ, Real.exp (-(s ^ 2 * t ^ 2)) * ‖charFun P t - stdGaussCF t‖ ^ 2
end LeJEPA
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Preamble context. Throughout, and are arbitrary natural numbers, and is allowed for both. means real vectors with coordinates, and is a single point. Unless stated otherwise, "" over or is the Lebesgue integral. Two conventions apply to every definition below:
- An integral written as a real number (a Bochner integral) is defined to be whenever the integrand is not integrable.
- The inverse of a square matrix is defined to be the zero matrix whenever is singular.
partialDeriv. For any function , any coordinate index , and any point , the quantity is the Fréchet derivative of at applied to the -th standard basis vector :
If is not Fréchet-differentiable at , the derivative is taken to be the zero map, so . This applies even if the one-variable partial derivative in direction happens to exist there.
fisherInfo. For any function (no assumptions whatsoever), is the extended non-negative number in given by the lower Lebesgue integral
Here is as in partialDeriv, so it is at points where is not differentiable. The integral may equal . Points where contribute nothing. When , the space is a single point of measure and the sum is empty, so .
IsMeanZeroDensity. A function satisfies this predicate exactly when all five of the following hold:
- is continuously differentiable () on .
- for every .
- . Because a non-integrable would have integral by convention, this condition also forces to be integrable.
- The function is Lebesgue-integrable.
- For every coordinate , . This is a Bochner integral; under conditions 3 and 4 the integrand is integrable.
No positivity of is required, and nothing is assumed about the covariance (in particular, it need not be non-degenerate). For , the conditions reduce to taking the value at the single point.
covMat. For any function (no assumptions), is the real matrix with entries
Any entry whose integrand is not integrable is . No mean is subtracted.
gaussDensity. For any real matrix (not assumed symmetric, positive definite, or invertible) and any ,
The power uses the real power function, which gives the following edge cases:
- If , then , so . In this case is also the zero matrix.
- If , the real power evaluates to , so again .
frobNorm. For any real matrix ,
It equals when .
ridgeBias. For any real matrix , any real number (which may be zero or negative), and any vector ,
This is a purely deterministic matrix expression. No response vector, noise, or expectation appears in it. If is singular, its inverse is the zero matrix, and . When , , so if , and for any .
olsTotalVariance. For any real matrix and any real (whose sign is irrelevant),
This is a deterministic expression with no noise model involved. If is singular, which happens in particular whenever , the inverse is the zero matrix and .
rawMoment. For any natural number and any measure on (not assumed to be a probability measure, or even finite),
The value is if is not -integrable. For the value is the total mass when that mass is finite, and when is infinite.
stdGaussCF. For real , , regarded as a complex number with zero imaginary part.
empCF. For a sample and real ,
When , both (which is by convention) and the empty sum vanish, so .
ecfDistance. For any real and sample ,
with as in empCF. Edge cases:
- The value depends on only through .
- For the weight is identically . If the resulting integrand is not integrable, the value is by convention.
- For the integrand is .
cfDistance. For any real and any measure on (not assumed to be a probability measure),
where . Edge cases:
- If has infinite total mass, then for every , by the non-integrability convention.
- If the outer integrand is not integrable, for example possibly when , the value is .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.