Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Linear BYOL/SimSiam model: objective, augmentation moments, gradient flows and reduced dynamics

Definition
SSLWithoutPairs_Basic

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

byoleigenspace-alignmentgradient-flowlinear-networksself-supervised-learning

Objects of Sections 2 and 3 and Appendices A and B of Tian, Chen and Ganguli (2021), for the bias-free linear BYOL/SimSiam model.

  1. Norms and eigenvalues. ∥v∥22=∑ivi2\|v\|_2^2=\sum_i v_i^2∥v∥22​=∑i​vi2​; ∥A∥F=(∑i,jAij2)1/2\|A\|_F=(\sum_{i,j}A_{ij}^2)^{1/2}∥A∥F​=(∑i,j​Aij2​)1/2; λmin⁡(A)\lambda_{\min}(A)λmin​(A) is the least real root of the characteristic polynomial of a square real matrix AAA (used only for symmetric AAA).
  2. Trajectories. A matrix trajectory A(t)A(t)A(t), t≥0t\ge0t≥0, has derivative A˙(t)=A′(t)\dot A(t)=A'(t)A˙(t)=A′(t) if every entry has that derivative within [0,∞)[0,\infty)[0,∞) at every t≥0t\ge0t≥0 (one-sided at t=0t=0t=0).
  3. Data and augmentation (Section 2). The data x∈Rn1x\in\mathbb R^{n_1}x∈Rn1​ has law μ=p(x)\mu=p(x)μ=p(x) and the augmentation is a Markov kernel κ=paug(⋅∣x)\kappa=p_{\mathrm{aug}}(\cdot\mid x)κ=paug​(⋅∣x). Then xˉ(x)=Ex′∼κ(x)[x′]\bar x(x)=\mathbb E_{x'\sim\kappa(x)}[x']xˉ(x)=Ex′∼κ(x)​[x′], X=Ex[xˉxˉ⊤]X=\mathbb E_x[\bar x\bar x^\top]X=Ex​[xˉxˉ⊤] and X′=Ex[Var⁡x′∣x[x′]]X'=\mathbb E_x[\operatorname{Var}_{x'\mid x}[x']]X′=Ex​[Varx′∣x​[x′]].
  4. Objective (eq. 1). For W,Wa∈Rn2×n1W,W_a\in\mathbb R^{n_2\times n_1}W,Wa​∈Rn2​×n1​ and Wp∈Rn2×n2W_p\in\mathbb R^{n_2\times n_2}Wp​∈Rn2​×n2​, J(W,Wp;Wa)=12E∥WpWx1−Wax2∥22J(W,W_p;W_a)=\tfrac12\mathbb E\|W_pWx_1-W_ax_2\|_2^2J(W,Wp​;Wa​)=21​E∥Wp​Wx1​−Wa​x2​∥22​, where x∼μx\sim\mux∼μ and x1,x2∼κ(x)x_1,x_2\sim\kappa(x)x1​,x2​∼κ(x) are independent given xxx. The target weight WaW_aWa​ is a separate argument, which encodes the stop-gradient.
  5. Flows (eqs. 2, 3). W˙p=αp(−WpW(X+X′)+WaX)W⊤−ηWp\dot W_p=\alpha_p(-W_pW(X+X')+W_aX)W^\top-\eta W_pW˙p​=αp​(−Wp​W(X+X′)+Wa​X)W⊤−ηWp​ and W˙=Wp⊤(−WpW(X+X′)+WaX)−ηW\dot W=W_p^\top(-W_pW(X+X')+W_aX)-\eta WW˙=Wp⊤​(−Wp​W(X+X′)+Wa​X)−ηW.
  6. No-stop-gradient matrix (Theorem 2). H=X′⊗(Wp⊤Wp+In2)+X⊗W~p⊤W~p+ηIn1n2H=X'\otimes(W_p^\top W_p+I_{n_2})+X\otimes\tilde W_p^\top\tilde W_p+\eta I_{n_1n_2}H=X′⊗(Wp⊤​Wp​+In2​​)+X⊗W~p⊤​W~p​+ηIn1​n2​​ with W~p=Wp−In2\tilde W_p=W_p-I_{n_2}W~p​=Wp​−In2​​, acting on vec⁡(W)\operatorname{vec}(W)vec(W) (columns stacked).
  7. Reduced flows (Section 3). Under Assumptions 1 and 2 (Wa=τWW_a=\tau WWa​=τW, X=IX=IX=I, X′=σ2IX'=\sigma^2IX′=σ2I, F=WW⊤F=WW^\topF=WW⊤) the predictor flow is W˙p=−αp(1+σ2)WpF+αpτF−ηWp\dot W_p=-\alpha_p(1+\sigma^2)W_pF+\alpha_p\tau F-\eta W_pW˙p​=−αp​(1+σ2)Wp​F+αp​τF−ηWp​ (eq. 62). The symmetrised flow (eq. 7) is W˙p=−αp2(1+σ2){Wp,F}+αpτF−ηWp\dot W_p=-\frac{\alpha_p}2(1+\sigma^2)\{W_p,F\}+\alpha_p\tau F-\eta W_pW˙p​=−2αp​​(1+σ2){Wp​,F}+αp​τF−ηWp​, F˙=−(1+σ2){Wp2,F}+τ{Wp,F}−2ηF\dot F=-(1+\sigma^2)\{W_p^2,F\}+\tau\{W_p,F\}-2\eta FF˙=−(1+σ2){Wp2​,F}+τ{Wp​,F}−2ηF, with {A,B}=AB+BA\{A,B\}=AB+BA{A,B}=AB+BA. The commutator is [F,Wp]=FWp−WpF[F,W_p]=FW_p-W_pF[F,Wp​]=FWp​−Wp​F, and
K=(1+σ2)[αp2F+Wp2−τ1+σ2Wp]+32ηI(eq. 9).K=(1+\sigma^2)\Big[\frac{\alpha_p}2F+W_p^2-\frac{\tau}{1+\sigma^2}W_p\Big]+\frac32\eta I\quad\text{(eq. 9)}.K=(1+σ2)[2αp​​F+Wp2​−1+σ2τ​Wp​]+23​ηI(eq. 9).
  1. Modes (Section 3.2). The right sides of eqs. (11), (12), (16) are αps[τ−(1+σ2)p]−ηp\alpha_ps[\tau-(1+\sigma^2)p]-\eta pαp​s[τ−(1+σ2)p]−ηp, 2ps[τ−(1+σ2)p]−2ηs2ps[\tau-(1+\sigma^2)p]-2\eta s2ps[τ−(1+σ2)p]−2ηs and p2[τ−(1+σ2)p]−ηpp^2[\tau-(1+\sigma^2)p]-\eta pp2[τ−(1+σ2)p]−ηp. The fixed points are p±∗=(τ±τ2−4η(1+σ2))/(2(1+σ2))p^*_\pm=\big(\tau\pm\sqrt{\tau^2-4\eta(1+\sigma^2)}\big)/(2(1+\sigma^2))p±∗​=(τ±τ2−4η(1+σ2)​)/(2(1+σ2)), and Δ=p[τ−(1+σ2)p]−η\Delta=p[\tau-(1+\sigma^2)p]-\etaΔ=p[τ−(1+σ2)p]−η.

Formalization Note Vectors of Rn\mathbb R^nRn are functions Fin n→R\mathrm{Fin}\,n\to\mathbb RFinn→R, and the Euclidean norm is written out, since Lean's default norm on this type is the sup norm. Derivatives of matrix trajectories are taken entrywise. JJJ is a Bochner integral against μ⊗(κ×κ)\mu\otimes(\kappa\times\kappa)μ⊗(κ×κ). Statements that use JJJ assume finite second moments, so that this integral is not a junk value.

Definition code
import Mathlib

/-!
Tian, Chen and Ganguli, *Understanding Self-Supervised Learning Dynamics without Contrastive
Pairs*, arXiv:2102.06810v4 (ICML 2021): the bias-free linear BYOL/SimSiam model of Section 2
and Appendix A (objective, augmentation moments `X`, `X'`, gradient flows), the reduced dynamics
of Section 3 and Appendix B under Assumptions 1-3 (eqs. (7), (9), (11)-(13), (16), (17), (62)),
and the norms and minimal eigenvalue used in Theorems 2 and 3 and Lemma 2.
-/

open MeasureTheory ProbabilityTheory Matrix

noncomputable section

namespace SSLWithoutPairs

/-- Squared Euclidean norm `‖v‖₂²` of a vector of `ℝⁿ` (Section 2, eq. (1)). -/
def sqNorm {ι : Type*} [Fintype ι] (v : ι → ℝ) : ℝ := ∑ i, v i ^ 2

/-- Euclidean norm `‖v‖₂` of a vector (Lemma 2, Appendix A, p. 14). -/
def l2Norm {ι : Type*} [Fintype ι] (v : ι → ℝ) : ℝ := Real.sqrt (sqNorm v)

/-- Frobenius norm `‖A‖_F` of a real matrix (Theorem 3, eq. (10), p. 5). -/
def frobNorm {m n : Type*} [Fintype m] [Fintype n] (A : Matrix m n ℝ) : ℝ :=
  Real.sqrt (∑ i, ∑ j, A i j ^ 2)

/-- The minimal eigenvalue `λ_min(A)` of a square real matrix (Theorems 2 and 3, Lemma 2):
the least real root of its characteristic polynomial. It is only applied to symmetric matrices,
whose eigenvalues are all real. -/
def minEig {n : Type*} [Fintype n] [DecidableEq n] (A : Matrix n n ℝ) : ℝ :=
  sInf {μ : ℝ | A.charpoly.IsRoot μ}

/-- A matrix-valued trajectory `A(t)`, `t ≥ 0`, has time derivative `Ȧ(t) = A'(t)` for every
`t ≥ 0` (one-sided at `t = 0`), entrywise. This is how the gradient flows of Section 2 and the
reduced flows of Section 3 are read. -/
def HasMatDerivOn {m n : Type*} (A A' : ℝ → Matrix m n ℝ) : Prop :=
  ∀ t : ℝ, 0 ≤ t → ∀ i j, HasDerivWithinAt (fun s => A s i j) (A' t i j) (Set.Ici 0) t

section Moments

variable {n : ℕ}

/-- Section 2, p. 3: the average augmented view `x̄(x) = E_{x' ∼ p_aug(·|x)}[x']` of a data
point `x`, for the augmentation kernel `κ = p_aug`. -/
def augMean (κ : Kernel (Fin n → ℝ) (Fin n → ℝ)) (x : Fin n → ℝ) : Fin n → ℝ :=
  fun i => ∫ y, y i ∂(κ x)

/-- Section 2, p. 3: `X = E_x[x̄(x) x̄(x)ᵀ]`, for the data distribution `μ = p(x)`. -/
def augMeanCorr (μ : Measure (Fin n → ℝ)) (κ : Kernel (Fin n → ℝ) (Fin n → ℝ)) :
    Matrix (Fin n) (Fin n) ℝ :=
  fun i j => ∫ x, augMean κ x i * augMean κ x j ∂μ

/-- Section 2, p. 3: `X' = E_x[Var_{x'|x}[x']]`, the covariance of the augmented views of `x`,
averaged over the data. -/
def augCov (μ : Measure (Fin n → ℝ)) (κ : Kernel (Fin n → ℝ) (Fin n → ℝ)) :
    Matrix (Fin n) (Fin n) ℝ :=
  fun i j => ∫ x, (∫ y, (y i - augMean κ x i) * (y j - augMean κ x j) ∂(κ x)) ∂μ

end Moments

/-- Eq. (1) (Appendix A, eq. (20)): the BYOL objective
`J = ½ E_{x ∼ p, x₁, x₂ ∼ p_aug(·|x)} ‖W_p W x₁ - W_a x₂‖²`, with the two views drawn
independently given `x`. The target weight `W_a` is a separate argument: the stop-gradient means
that `J` is differentiated in `W` and `W_p` with `W_a` held fixed (for SimSiam `W_a = W`). -/
def byolLoss {n₁ n₂ : ℕ} (μ : Measure (Fin n₁ → ℝ)) (κ : Kernel (Fin n₁ → ℝ) (Fin n₁ → ℝ))
    [IsSFiniteKernel κ] (Wp : Matrix (Fin n₂) (Fin n₂) ℝ) (W Wa : Matrix (Fin n₂) (Fin n₁) ℝ) :
    ℝ :=
  (1 / 2 : ℝ) * ∫ q, sqNorm (Wp *ᵥ (W *ᵥ q.2.1) - Wa *ᵥ q.2.2) ∂(μ ⊗ₘ (κ ×ₖ κ))

/-- Eq. (2): the right side of the predictor flow
`Ẇ_p = α_p (-W_p W (X + X') + W_a X) Wᵀ - η W_p`. -/
def byolFlowWp {n₁ n₂ : ℕ} (αp η : ℝ) (X X' : Matrix (Fin n₁) (Fin n₁) ℝ)
    (Wp : Matrix (Fin n₂) (Fin n₂) ℝ) (W Wa : Matrix (Fin n₂) (Fin n₁) ℝ) :
    Matrix (Fin n₂) (Fin n₂) ℝ :=
  αp • ((-(Wp * W * (X + X')) + Wa * X) * Wᵀ) - η • Wp

/-- Eq. (3): the right side of the online flow `Ẇ = W_pᵀ (-W_p W (X + X') + W_a X) - η W`. -/
def byolFlowW {n₁ n₂ : ℕ} (η : ℝ) (X X' : Matrix (Fin n₁) (Fin n₁) ℝ)
    (Wp : Matrix (Fin n₂) (Fin n₂) ℝ) (W Wa : Matrix (Fin n₂) (Fin n₁) ℝ) :
    Matrix (Fin n₂) (Fin n₁) ℝ :=
  Wpᵀ * (-(Wp * W * (X + X')) + Wa * X) - η • W

/-- Theorem 2, p. 3: `H = X' ⊗ (W_pᵀ W_p + I_{n₂}) + X ⊗ W̃_pᵀ W̃_p + η I_{n₁ n₂}` with
`W̃_p = W_p - I_{n₂}` and `⊗` the Kronecker product, indexed so that it acts on
`vec(W)` (`Matrix.vec`, columns stacked). -/
def noStopH {n₁ n₂ : ℕ} (X X' : Matrix (Fin n₁) (Fin n₁) ℝ) (η : ℝ)
    (Wp : Matrix (Fin n₂) (Fin n₂) ℝ) : Matrix (Fin n₁ × Fin n₂) (Fin n₁ × Fin n₂) ℝ :=
  Matrix.kronecker X' (Wpᵀ * Wp + 1) + Matrix.kronecker X ((Wp - 1)ᵀ * (Wp - 1)) + η • 1

/-- Eq. (62) (Appendix B, p. 15): the predictor flow of eq. (2) under Assumptions 1 and 2
(`W_a = τ W`, `X = I`, `X' = σ² I`, `F = W Wᵀ`):
`Ẇ_p = -α_p (1 + σ²) W_p F + α_p τ F - η W_p`. -/
def isoFlowWp {d : ℕ} (αp σ η τ : ℝ) (Wp F : Matrix (Fin d) (Fin d) ℝ) :
    Matrix (Fin d) (Fin d) ℝ :=
  -(αp * (1 + σ ^ 2)) • (Wp * F) + (αp * τ) • F - η • Wp

/-- Eq. (7), first line: the symmetrised predictor flow
`Ẇ_p = -(α_p/2)(1 + σ²){W_p, F} + α_p τ F - η W_p`, `{A, B} = AB + BA`. -/
def symFlowWp {d : ℕ} (αp σ η τ : ℝ) (Wp F : Matrix (Fin d) (Fin d) ℝ) :
    Matrix (Fin d) (Fin d) ℝ :=
  -(αp / 2 * (1 + σ ^ 2)) • (Wp * F + F * Wp) + (αp * τ) • F - η • Wp

/-- Eq. (7), second line: `Ḟ = -(1 + σ²){W_p², F} + τ{W_p, F} - 2η F`. -/
def symFlowF {d : ℕ} (σ η τ : ℝ) (Wp F : Matrix (Fin d) (Fin d) ℝ) :
    Matrix (Fin d) (Fin d) ℝ :=
  -(1 + σ ^ 2) • (Wp * Wp * F + F * (Wp * Wp)) + τ • (Wp * F + F * Wp) - (2 * η) • F

/-- Theorem 3: the commutator `[F, W_p] = F W_p - W_p F`. -/
def commutator {d : ℕ} (F Wp : Matrix (Fin d) (Fin d) ℝ) : Matrix (Fin d) (Fin d) ℝ :=
  F * Wp - Wp * F

/-- Eq. (9): `K = (1 + σ²)[(α_p/2) F + W_p² - τ/(1 + σ²) W_p] + (3/2) η I`. -/
def alignK {d : ℕ} (αp σ η τ : ℝ) (F Wp : Matrix (Fin d) (Fin d) ℝ) :
    Matrix (Fin d) (Fin d) ℝ :=
  (1 + σ ^ 2) • ((αp / 2) • F + Wp * Wp - (τ / (1 + σ ^ 2)) • Wp) + ((3 / 2 : ℝ) * η) • 1

/-- Eq. (11): the decoupled predictor mode `ṗ_j = α_p s_j [τ - (1 + σ²) p_j] - η p_j`. -/
def modeFlowP (αp σ η τ p s : ℝ) : ℝ := αp * s * (τ - (1 + σ ^ 2) * p) - η * p

/-- Eq. (12): the decoupled online mode `ṡ_j = 2 p_j s_j [τ - (1 + σ²) p_j] - 2η s_j`. -/
def modeFlowS (σ η τ p s : ℝ) : ℝ := 2 * p * s * (τ - (1 + σ ^ 2) * p) - 2 * η * s

/-- Eq. (16): the predictor mode on the invariant parabola `s_j = α_p⁻¹ p_j²`, at fixed `τ`:
`ṗ_j = p_j² [τ - (1 + σ²) p_j] - η p_j`. -/
def parabolaFlowP (σ η τ p : ℝ) : ℝ := p ^ 2 * (τ - (1 + σ ^ 2) * p) - η * p

/-- Section 3.2, p. 6: the fixed point `p*_{j-} = (τ - √(τ² - 4η(1 + σ²))) / (2(1 + σ²))`
of eq. (16). -/
def fixedPointMinus (σ η τ : ℝ) : ℝ :=
  (τ - Real.sqrt (τ ^ 2 - 4 * η * (1 + σ ^ 2))) / (2 * (1 + σ ^ 2))

/-- Section 3.2, p. 6: the fixed point `p*_{j+} = (τ + √(τ² - 4η(1 + σ²))) / (2(1 + σ²))`
of eq. (16). -/
def fixedPointPlus (σ η τ : ℝ) : ℝ :=
  (τ + Real.sqrt (τ ^ 2 - 4 * η * (1 + σ ^ 2))) / (2 * (1 + σ ^ 2))

/-- Section 3.2, p. 6: `Δ_j = p_j [τ - (1 + σ²) p_j] - η`. -/
def modeDelta (σ η τ p : ℝ) : ℝ := p * (τ - (1 + σ ^ 2) * p) - η

end SSLWithoutPairs
Source
Tian, Chen and Ganguli, Understanding Self-Supervised Learning Dynamics without Contrastive Pairs, arXiv:2102.06810v4 (2021), Sections 2, 3, 3.1, 3.2 and Appendices A, B
Read-back

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

Squared norm sqNorm. For a vector vvv with real entries indexed by an arbitrary finite index set ι\iotaι, this is

∥v∥22:=∑i∈ιvi2.\|v\|_2^2 := \sum_{i \in \iota} v_i^2 .∥v∥22​:=i∈ι∑​vi2​.

If ι\iotaι is empty, the value is 000.


Euclidean norm l2Norm. For a real vector vvv indexed by a finite set ι\iotaι, this is ∥v∥2:=∑i∈ιvi2\|v\|_2 := \sqrt{\sum_{i\in\iota} v_i^2}∥v∥2​:=∑i∈ι​vi2​​, the non-negative square root of the squared norm above. It is 000 when ι\iotaι is empty.


Frobenius norm frobNorm. For a real matrix AAA with rows indexed by a finite set mmm and columns by a finite set nnn, this is

∥A∥F:=∑i∈m∑j∈nAij2.\|A\|_F := \sqrt{\sum_{i\in m}\sum_{j \in n} A_{ij}^2 } .∥A∥F​:=i∈m∑​j∈n∑​Aij2​​.

It is 000 if either index set is empty.


Minimal eigenvalue minEig. For a square real matrix AAA indexed by a finite set nnn (with decidable equality on indices), let χA(μ)=det⁡(μI−A)\chi_A(\mu)=\det(\mu I - A)χA​(μ)=det(μI−A) be its characteristic polynomial. The definition is

λmin⁡(A):=inf⁡{μ∈R:χA(μ)=0},\lambda_{\min}(A) := \inf\{\mu \in \mathbb{R} : \chi_A(\mu) = 0\},λmin​(A):=inf{μ∈R:χA​(μ)=0},

the infimum of the set of real roots of χA\chi_AχA​. Points to note:

  • χA\chi_AχA​ is monic, so this set is finite. When it is nonempty, the infimum is the least real eigenvalue of AAA, and no symmetry of AAA is assumed.
  • If AAA has no real eigenvalues, the set is empty. This can happen for non-symmetric AAA, and always happens when nnn is empty, where χA=1\chi_A = 1χA​=1. In that case the real infimum of the empty set is taken by convention to be 000, so λmin⁡(A)=0\lambda_{\min}(A) = 0λmin​(A)=0.
  • Complex eigenvalues are ignored entirely.

Derivative of a matrix trajectory HasMatDerivOn. Let A,A′A, A'A,A′ be functions from R\mathbb{R}R to m×nm\times nm×n real matrices, with arbitrary index sets m,nm, nm,n. The proposition asserts:

  • for every t≥0t \ge 0t≥0 and every pair of indices (i,j)(i,j)(i,j), the scalar function s↦A(s)ijs \mapsto A(s)_{ij}s↦A(s)ij​ has derivative A′(t)ijA'(t)_{ij}A′(t)ij​ at ttt, taken within the half-line [0,∞)[0,\infty)[0,∞).

For t>0t>0t>0 this is the ordinary two-sided derivative. At t=0t=0t=0 it is the right derivative. The condition says nothing about A(s)A(s)A(s) or A′(s)A'(s)A′(s) for s<0s<0s<0, beyond what is needed to evaluate derivatives inside [0,∞)[0,\infty)[0,∞).


Average augmented view augMean. Here nnn is any natural number, possibly 000, and κ\kappaκ is a measurable kernel assigning to each x∈Rnx \in \mathbb{R}^nx∈Rn a measure κx\kappa_xκx​ on Rn\mathbb{R}^nRn. For x∈Rnx\in\mathbb{R}^nx∈Rn, xˉ(x)\bar x(x)xˉ(x) is the vector with components

xˉ(x)i:=∫Rnyi dκx(y),i=1,…,n.\bar x(x)_i := \int_{\mathbb{R}^n} y_i \, d\kappa_x(y), \qquad i = 1,\dots,n .xˉ(x)i​:=∫Rn​yi​dκx​(y),i=1,…,n.

Points to note:

  • κx\kappa_xκx​ is not required to be a probability measure, so this is an expectation only when κx\kappa_xκx​ has total mass 111.
  • If y↦yiy\mapsto y_iy↦yi​ is not κx\kappa_xκx​-integrable, the component is 000 by convention.

Moment matrix XXX, augMeanCorr. For a measure μ\muμ on Rn\mathbb{R}^nRn (not required to be a probability measure) and a kernel κ\kappaκ as above, XXX is the n×nn\times nn×n matrix with entries

Xij:=∫Rnxˉ(x)i xˉ(x)j dμ(x).X_{ij} := \int_{\mathbb{R}^n} \bar x(x)_i\, \bar x(x)_j \, d\mu(x).Xij​:=∫Rn​xˉ(x)i​xˉ(x)j​dμ(x).

Here xˉ\bar xxˉ is the average augmented view defined above. Any entry whose integrand is not μ\muμ-integrable is 000 by convention.


Moment matrix X′X'X′, augCov. For μ\muμ and κ\kappaκ as above, X′X'X′ is the n×nn\times nn×n matrix with entries

Xij′:=∫Rn(∫Rn(yi−xˉ(x)i)(yj−xˉ(x)j) dκx(y))dμ(x).X'_{ij} := \int_{\mathbb{R}^n} \left( \int_{\mathbb{R}^n} \big(y_i - \bar x(x)_i\big)\big(y_j - \bar x(x)_j\big)\, d\kappa_x(y) \right) d\mu(x).Xij′​:=∫Rn​(∫Rn​(yi​−xˉ(x)i​)(yj​−xˉ(x)j​)dκx​(y))dμ(x).

Points to note:

  • Neither μ\muμ nor κx\kappa_xκx​ is required to be a probability measure. So the inner integral is a covariance of κx\kappa_xκx​, and the outer one an average over μ\muμ, only when both have total mass 111.
  • Non-integrable inner or outer integrals are replaced by 000.

BYOL objective byolLoss. The inputs are:

  • natural numbers n1,n2n_1, n_2n1​,n2​;
  • a measure μ\muμ on Rn1\mathbb{R}^{n_1}Rn1​;
  • an s-finite kernel κ\kappaκ from Rn1\mathbb{R}^{n_1}Rn1​ to Rn1\mathbb{R}^{n_1}Rn1​;
  • an n2×n2n_2\times n_2n2​×n2​ real matrix WpW_pWp​;
  • two n2×n1n_2\times n_1n2​×n1​ real matrices WWW and WaW_aWa​.

The value is

J(Wp,W,Wa):=12∫∥WpWx1−Wax2∥22  d(μ⊗(κ×κ))(x,x1,x2).J(W_p, W, W_a) := \frac12 \int \big\| W_p W x_1 - W_a x_2 \big\|_2^2 \; d\big(\mu \otimes (\kappa\times\kappa)\big)(x, x_1, x_2).J(Wp​,W,Wa​):=21​∫​Wp​Wx1​−Wa​x2​​22​d(μ⊗(κ×κ))(x,x1​,x2​).

The integration measure is defined as follows. First draw xxx according to μ\muμ. Then, given xxx, draw the pair (x1,x2)(x_1, x_2)(x1​,x2​) according to the product measure κx⊗κx\kappa_x \otimes \kappa_xκx​⊗κx​, so the two views are independent given xxx. The integrand depends only on x1x_1x1​ and x2x_2x2​, not directly on xxx.

Points to note:

  • The value is a plain integral. No normalization is applied, and μ\muμ and κx\kappa_xκx​ need not be probability measures.
  • If the integrand is not integrable, the value is 000 by convention.
  • The definition only gives the value of JJJ at the given matrices. It encodes no differentiation and no relation between WaW_aWa​ and WWW.

Predictor flow field byolFlowWp. For real numbers αp,η\alpha_p, \etaαp​,η, arbitrary n1×n1n_1\times n_1n1​×n1​ real matrices X,X′X, X'X,X′, an n2×n2n_2\times n_2n2​×n2​ matrix WpW_pWp​, and n2×n1n_2\times n_1n2​×n1​ matrices W,WaW, W_aW,Wa​, this is the n2×n2n_2\times n_2n2​×n2​ matrix

αp(−WpW(X+X′)+WaX)W⊤−η Wp.\alpha_p\big(-W_p W (X + X') + W_a X\big) W^\top - \eta\, W_p .αp​(−Wp​W(X+X′)+Wa​X)W⊤−ηWp​.

Here X,X′X, X'X,X′ are free matrix arguments. They are not tied to the moment matrices defined above. No sign or positivity is assumed for αp\alpha_pαp​ or η\etaη.


Online flow field byolFlowW. For a real number η\etaη, arbitrary n1×n1n_1\times n_1n1​×n1​ real matrices X,X′X, X'X,X′, an n2×n2n_2\times n_2n2​×n2​ matrix WpW_pWp​, and n2×n1n_2\times n_1n2​×n1​ matrices W,WaW, W_aW,Wa​, this is the n2×n1n_2\times n_1n2​×n1​ matrix

Wp⊤(−WpW(X+X′)+WaX)−η W.W_p^\top\big(-W_p W (X + X') + W_a X\big) - \eta\, W .Wp⊤​(−Wp​W(X+X′)+Wa​X)−ηW.

No learning-rate factor multiplies the first term. Again, X,X′X, X'X,X′ are arbitrary and η\etaη is unrestricted.


Matrix HHH, noStopH. The inputs are n1×n1n_1\times n_1n1​×n1​ real matrices X,X′X, X'X,X′, a real number η\etaη, and an n2×n2n_2\times n_2n2​×n2​ real matrix WpW_pWp​. Write W~p:=Wp−In2\widetilde W_p := W_p - I_{n_2}Wp​:=Wp​−In2​​. HHH is the square matrix indexed by pairs (i,k)(i,k)(i,k) with i∈{1,…,n1}i\in\{1,\dots,n_1\}i∈{1,…,n1​} and k∈{1,…,n2}k\in\{1,\dots,n_2\}k∈{1,…,n2​}:

H:=X′⊗(Wp⊤Wp+In2)+X⊗W~p⊤W~p+η In1n2,H := X' \otimes \big(W_p^\top W_p + I_{n_2}\big) + X \otimes \widetilde W_p^\top \widetilde W_p + \eta\, I_{n_1 n_2},H:=X′⊗(Wp⊤​Wp​+In2​​)+X⊗Wp⊤​Wp​+ηIn1​n2​​,

where ⊗\otimes⊗ is the Kronecker product. Entrywise,

H(i,k),(j,l)=Xij′ (Wp⊤Wp+I)kl+Xij (W~p⊤W~p)kl+η δijδkl.H_{(i,k),(j,l)} = X'_{ij}\,\big(W_p^\top W_p + I\big)_{kl} + X_{ij}\,\big(\widetilde W_p^\top \widetilde W_p\big)_{kl} + \eta\,\delta_{ij}\delta_{kl}.H(i,k),(j,l)​=Xij′​(Wp⊤​Wp​+I)kl​+Xij​(Wp⊤​Wp​)kl​+ηδij​δkl​.

The first component of each index pair ranges over the n1n_1n1​-indices. The definition only specifies this matrix and does not itself connect it to any flow or vectorization. X,X′X, X'X,X′ are arbitrary and η\etaη is unrestricted.


Isotropic predictor flow field isoFlowWp. For a natural number ddd, real numbers αp,σ,η,τ\alpha_p, \sigma, \eta, \tauαp​,σ,η,τ, and d×dd\times dd×d real matrices Wp,FW_p, FWp​,F, this is

−αp(1+σ2) WpF+αpτ F−η Wp.-\alpha_p(1+\sigma^2)\, W_p F + \alpha_p \tau\, F - \eta\, W_p .−αp​(1+σ2)Wp​F+αp​τF−ηWp​.

FFF is an arbitrary matrix: it is not required to equal WW⊤W W^\topWW⊤, nor to be symmetric. σ\sigmaσ enters only through σ2\sigma^2σ2.


Symmetrized predictor flow field symFlowWp. For a natural number ddd, real numbers αp,σ,η,τ\alpha_p, \sigma, \eta, \tauαp​,σ,η,τ, and arbitrary d×dd\times dd×d real matrices Wp,FW_p, FWp​,F, this is

−αp2(1+σ2) (WpF+FWp)+αpτ F−η Wp.-\frac{\alpha_p}{2}(1+\sigma^2)\,\big(W_p F + F W_p\big) + \alpha_p \tau\, F - \eta\, W_p .−2αp​​(1+σ2)(Wp​F+FWp​)+αp​τF−ηWp​.

Symmetrized FFF flow field symFlowF. For a natural number ddd, real numbers σ,η,τ\sigma, \eta, \tauσ,η,τ, and arbitrary d×dd\times dd×d real matrices Wp,FW_p, FWp​,F, this is

−(1+σ2) (Wp2F+FWp2)+τ (WpF+FWp)−2η F.-(1+\sigma^2)\,\big(W_p^2 F + F W_p^2\big) + \tau\,\big(W_p F + F W_p\big) - 2\eta\, F .−(1+σ2)(Wp2​F+FWp2​)+τ(Wp​F+FWp​)−2ηF.

No αp\alpha_pαp​ appears in it.


Commutator commutator. For d×dd\times dd×d real matrices F,WpF, W_pF,Wp​, this is

[F,Wp]:=FWp−WpF.[F, W_p] := F W_p - W_p F .[F,Wp​]:=FWp​−Wp​F.

Matrix KKK, alignK. For a natural number ddd, real numbers αp,σ,η,τ\alpha_p, \sigma, \eta, \tauαp​,σ,η,τ, and arbitrary d×dd\times dd×d real matrices F,WpF, W_pF,Wp​, this is

K:=(1+σ2)[αp2F+Wp2−τ1+σ2Wp]+32η Id.K := (1+\sigma^2)\left[\frac{\alpha_p}{2} F + W_p^2 - \frac{\tau}{1+\sigma^2} W_p\right] + \frac32 \eta\, I_d .K:=(1+σ2)[2αp​​F+Wp2​−1+σ2τ​Wp​]+23​ηId​.

Since 1+σ2≥11+\sigma^2 \ge 11+σ2≥1, there is no division by zero. The expression equals αp2(1+σ2)F+(1+σ2)Wp2−τWp+32ηId\tfrac{\alpha_p}{2}(1+\sigma^2)F + (1+\sigma^2)W_p^2 - \tau W_p + \tfrac32\eta I_d2αp​​(1+σ2)F+(1+σ2)Wp2​−τWp​+23​ηId​.


Predictor mode field modeFlowP. For real numbers αp,σ,η,τ,p,s\alpha_p, \sigma, \eta, \tau, p, sαp​,σ,η,τ,p,s, this is the real number

αp s [τ−(1+σ2)p]−η p.\alpha_p\, s\,\big[\tau - (1+\sigma^2)p\big] - \eta\, p .αp​s[τ−(1+σ2)p]−ηp.

Online mode field modeFlowS. For real numbers σ,η,τ,p,s\sigma, \eta, \tau, p, sσ,η,τ,p,s, this is the real number

2 p s [τ−(1+σ2)p]−2η s.2\,p\, s\,\big[\tau - (1+\sigma^2)p\big] - 2\eta\, s .2ps[τ−(1+σ2)p]−2ηs.

No αp\alpha_pαp​ appears in it.


Parabola predictor field parabolaFlowP. For real numbers σ,η,τ,p\sigma, \eta, \tau, pσ,η,τ,p, this is the real number

p2[τ−(1+σ2)p]−η p.p^2\big[\tau - (1+\sigma^2)p\big] - \eta\, p .p2[τ−(1+σ2)p]−ηp.

It does not involve αp\alpha_pαp​ or sss. The definition encodes no relation of the form s=p2/αps = p^2/\alpha_ps=p2/αp​. It is simply this cubic expression in ppp.


Lower fixed point fixedPointMinus. For real numbers σ,η,τ\sigma, \eta, \tauσ,η,τ, this is

p−∗:=τ−τ2−4η(1+σ2)2(1+σ2).p^*_{-} := \frac{\tau - \sqrt{\tau^2 - 4\eta(1+\sigma^2)}}{2(1+\sigma^2)} .p−∗​:=2(1+σ2)τ−τ2−4η(1+σ2)​​.

Here ⋅\sqrt{\cdot}⋅​ is the real square root, which returns 000 for negative arguments. So when τ2<4η(1+σ2)\tau^2 < 4\eta(1+\sigma^2)τ2<4η(1+σ2), the value is τ/(2(1+σ2))\tau/(2(1+\sigma^2))τ/(2(1+σ2)); no complex root and no undefined value occurs. The denominator is always at least 222. No sign conditions are imposed on η\etaη or τ\tauτ.


Upper fixed point fixedPointPlus. For real numbers σ,η,τ\sigma, \eta, \tauσ,η,τ, this is

p+∗:=τ+τ2−4η(1+σ2)2(1+σ2).p^*_{+} := \frac{\tau + \sqrt{\tau^2 - 4\eta(1+\sigma^2)}}{2(1+\sigma^2)} .p+∗​:=2(1+σ2)τ+τ2−4η(1+σ2)​​.

The same conventions apply as for the lower fixed point. In particular, when τ2<4η(1+σ2)\tau^2 < 4\eta(1+\sigma^2)τ2<4η(1+σ2), the value is τ/(2(1+σ2))\tau/(2(1+\sigma^2))τ/(2(1+σ2)), which coincides with p−∗p^*_-p−∗​.


Mode quantity Δ\DeltaΔ, modeDelta. For real numbers σ,η,τ,p\sigma, \eta, \tau, pσ,η,τ,p, this is the real number

Δ:=p[τ−(1+σ2)p]−η.\Delta := p\big[\tau - (1+\sigma^2)p\big] - \eta .Δ:=p[τ−(1+σ2)p]−η.
Human review
  • Endorsed by Shuze Chen · Nov 24, 2026

    Confirmed by the moderator at approval.

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