Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Deep linear networks and their Gaussian initialization

Definition
DLT_DeepLinearNetwork

by LG · Sep 23, 2026 · Mathlib 0df444a (Lean v4.33.1)

deep-learning-theorymachine-learningprobability

Definitions for Chapter 3 of The Principles of Deep Learning Theory (also reused by later chapters).

  1. The Kronecker delta δij\delta_{ij}δij​ (as a real number) and the four-index Wick tensor structure Δi1i2i3i4=δi1i2δi3i4+δi1i3δi2i4+δi1i4δi2i3\Delta_{i_1i_2i_3i_4} = \delta_{i_1i_2}\delta_{i_3i_4}+\delta_{i_1i_3}\delta_{i_2i_4}+\delta_{i_1i_4}\delta_{i_2i_3}Δi1​i2​i3​i4​​=δi1​i2​​δi3​i4​​+δi1​i3​​δi2​i4​​+δi1​i4​​δi2​i3​​.
  2. The normalized input inner product (eq. 3.9)
Gα1α2(0)=1n0∑j=1n0xj;α1xj;α2.G^{(0)}_{\alpha_1\alpha_2} = \frac{1}{n_0}\sum_{j=1}^{n_0} x_{j;\alpha_1}x_{j;\alpha_2}.Gα1​α2​(0)​=n0​1​j=1∑n0​​xj;α1​​xj;α2​​.
  1. Zero-bias deep linear network preactivations (eqs. 3.1–3.2): with widths n0,n1,…n_0,n_1,\dotsn0​,n1​,… and weights Wij(ℓ)W^{(\ell)}_{ij}Wij(ℓ)​,
zi(0)=xi,zi(ℓ+1)=∑j=1nℓWij(ℓ+1)zj(ℓ).z^{(0)}_i = x_i,\qquad z^{(\ell+1)}_i = \sum_{j=1}^{n_\ell} W^{(\ell+1)}_{ij} z^{(\ell)}_j .zi(0)​=xi​,zi(ℓ+1)​=j=1∑nℓ​​Wij(ℓ+1)​zj(ℓ)​.
  1. The initialization distribution (eq. 3.4): on a probability space (Ω,P)(\Omega,P)(Ω,P), the weights Wij(ℓ)W^{(\ell)}_{ij}Wij(ℓ)​ with ℓ≥1\ell\ge1ℓ≥1, 1≤i≤nℓ1\le i\le n_\ell1≤i≤nℓ​, 1≤j≤nℓ−11\le j\le n_{\ell-1}1≤j≤nℓ−1​ are mutually independent and each is a centered Gaussian of variance CW/nℓ−1C_W/n_{\ell-1}CW​/nℓ−1​, i.e. E[Wi1j1(ℓ)Wi2j2(ℓ)]=δi1i2δj1j2CW/nℓ−1\mathbb{E}[W^{(\ell)}_{i_1j_1}W^{(\ell)}_{i_2j_2}] = \delta_{i_1i_2}\delta_{j_1j_2}C_W/n_{\ell-1}E[Wi1​j1​(ℓ)​Wi2​j2​(ℓ)​]=δi1​i2​​δj1​j2​​CW​/nℓ−1​.

All statements of the mission are phrased in terms of these objects.

Formalization Note Neural and input indices start at 000. Widths are a function n : ℕ → ℕ and the weights a random field W : Ω → ℕ → ℕ → ℕ → ℝ; entries outside the ranges above are unconstrained and never used. CWC_WCW​ is a nonnegative real (ℝ≥0).

Definition code
import Mathlib

/-!
# The Principles of Deep Learning Theory — deep linear networks (§3.1)

Kronecker delta, the Wick tensor structure of four neural indices, the normalized input
inner product (eq. 3.9), zero-bias deep linear networks (eqs. 3.1–3.2), and their Gaussian
initialization distribution (eq. 3.4).
-/

open MeasureTheory ProbabilityTheory
open scoped NNReal

namespace DeepLearningTheory

/-- Kronecker delta `δ_{ij}` as a real number. -/
def kron (i j : ℕ) : ℝ := if i = j then 1 else 0

/-- The tensor structure `δ_{i₁i₂}δ_{i₃i₄} + δ_{i₁i₃}δ_{i₂i₄} + δ_{i₁i₄}δ_{i₂i₃}`. -/
def wickDelta4 (i₁ i₂ i₃ i₄ : ℕ) : ℝ :=
  kron i₁ i₂ * kron i₃ i₄ + kron i₁ i₃ * kron i₂ i₄ + kron i₁ i₄ * kron i₂ i₃

/-- Normalized inner product of two inputs,
`G⁽⁰⁾_{α₁α₂} = (1/n₀) ∑_{j=1}^{n₀} x_{j;α₁} x_{j;α₂}` (eq. 3.9).
Input components are indexed `0, …, n₀ - 1`. -/
noncomputable def inputKernel (n₀ : ℕ) (x₁ x₂ : ℕ → ℝ) : ℝ :=
  (1 / (n₀ : ℝ)) * ∑ j ∈ Finset.range n₀, x₁ j * x₂ j

/-- Preactivations of a zero-bias deep linear network (eqs. 3.1–3.2).
`n ℓ` is the width of layer `ℓ` (`n 0` is the input dimension), `W ℓ i j` is the weight
`W^{(ℓ)}_{ij}` (used for `ℓ ≥ 1`), and `x` is the input. Then
`linearPreact n W x ℓ i = z^{(ℓ)}_i(x)` with `z^{(0)} = x` and
`z^{(ℓ+1)}_i = ∑_{j < n_ℓ} W^{(ℓ+1)}_{ij} z^{(ℓ)}_j`. Neural indices are `0, …, n_ℓ - 1`. -/
def linearPreact (n : ℕ → ℕ) (W : ℕ → ℕ → ℕ → ℝ) (x : ℕ → ℝ) : ℕ → ℕ → ℝ
  | 0, i => x i
  | ℓ + 1, i => ∑ j ∈ Finset.range (n ℓ), W (ℓ + 1) i j * linearPreact n W x ℓ j

/-- Index set of the weights of a network with widths `n`: triples `(ℓ, i, j)` with
`ℓ ≥ 1`, `i < n ℓ`, `j < n (ℓ - 1)`. -/
def WeightIndex (n : ℕ → ℕ) : Type :=
  {p : ℕ × ℕ × ℕ // 1 ≤ p.1 ∧ p.2.1 < n p.1 ∧ p.2.2 < n (p.1 - 1)}

/-- Initialization distribution of a zero-bias deep linear network (eq. 3.4), with
`C_W^{(ℓ)} = C_W` in every layer: all weights `W^{(ℓ)}_{ij}` (`ℓ ≥ 1`, `i < n_ℓ`,
`j < n_{ℓ-1}`) are mutually independent random variables on `(Ω, P)`, and each is a centered
Gaussian with variance `C_W / n_{ℓ-1}`. -/
def IsLinearNetInit {Ω : Type*} [MeasurableSpace Ω] (P : Measure Ω) (n : ℕ → ℕ) (CW : ℝ≥0)
    (W : Ω → ℕ → ℕ → ℕ → ℝ) : Prop :=
  iIndepFun (fun (p : WeightIndex n) (ω : Ω) => W ω p.1.1 p.1.2.1 p.1.2.2) P ∧
  ∀ ℓ i j, 1 ≤ ℓ → i < n ℓ → j < n (ℓ - 1) →
    P.map (fun ω => W ω ℓ i j) = gaussianReal 0 (CW / (n (ℓ - 1) : ℝ≥0))

end DeepLearningTheory
Source
Daniel A. Roberts and Sho Yaida (with Boris Hanin), *The Principles of Deep Learning Theory*, arXiv:2106.10165v2, https://arxiv.org/abs/2106.10165, §3.1–3.2, pp. 54–56, eqs. (3.1), (3.2), (3.4), (3.9), (3.21) (page numbers are the book's printed page numbers)
Read-back

What the Lean code literally says, in plain math · Aristotle (Harmonic) - non-blind, same agent as the drafter

Non-blind read-back. This read-back was written by the same agent that drafted the Lean statement, with full knowledge of the source text and of the intended meaning. It is not independent testimony and must not be mistaken for a blind audit; reviewers should compare the Lean code against the source themselves.

The file defines, in namespace DeepLearningTheory:

  1. δij∈{0,1}\delta_{ij}\in\{0,1\}δij​∈{0,1} for natural numbers i,ji,ji,j (111 iff i=ji=ji=j), and Δi1i2i3i4=δi1i2δi3i4+δi1i3δi2i4+δi1i4δi2i3\Delta_{i_1i_2i_3i_4}=\delta_{i_1i_2}\delta_{i_3i_4}+\delta_{i_1i_3}\delta_{i_2i_4}+\delta_{i_1i_4}\delta_{i_2i_3}Δi1​i2​i3​i4​​=δi1​i2​​δi3​i4​​+δi1​i3​​δi2​i4​​+δi1​i4​​δi2​i3​​.
  2. For n0∈Nn_0\in\mathbb{N}n0​∈N and sequences x1,x2:N→Rx_1,x_2:\mathbb{N}\to\mathbb{R}x1​,x2​:N→R: G(0)(x1,x2)=1n0∑j=0n0−1x1(j)x2(j)G^{(0)}(x_1,x_2)=\frac{1}{n_0}\sum_{j=0}^{n_0-1}x_1(j)x_2(j)G(0)(x1​,x2​)=n0​1​∑j=0n0​−1​x1​(j)x2​(j); when n0=0n_0=0n0​=0 this is 000 (division by zero gives 000, and the sum is empty).
  3. For widths n:N→Nn:\mathbb{N}\to\mathbb{N}n:N→N, weights W:N→N→N→RW:\mathbb{N}\to\mathbb{N}\to\mathbb{N}\to\mathbb{R}W:N→N→N→R and input x:N→Rx:\mathbb{N}\to\mathbb{R}x:N→R: zi(0)=xiz^{(0)}_i=x_izi(0)​=xi​ and zi(ℓ+1)=∑j=0nℓ−1Wij(ℓ+1)zj(ℓ)z^{(\ell+1)}_i=\sum_{j=0}^{n_\ell-1}W^{(\ell+1)}_{ij}z^{(\ell)}_jzi(ℓ+1)​=∑j=0nℓ​−1​Wij(ℓ+1)​zj(ℓ)​, defined for every natural iii (including i≥nℓ+1i\ge n_{\ell+1}i≥nℓ+1​).
  4. The type of weight indices: triples (ℓ,i,j)(\ell,i,j)(ℓ,i,j) with ℓ≥1\ell\ge1ℓ≥1, i<nℓi<n_\elli<nℓ​, j<nℓ−1j<n_{\ell-1}j<nℓ−1​.
  5. IsLinearNetInit P n C_W W, for a measure PPP on Ω\OmegaΩ, CW≥0C_W\ge0CW​≥0 and a random field W:Ω→(N→N→N→R)W:\Omega\to(\mathbb{N}\to\mathbb{N}\to\mathbb{N}\to\mathbb{R})W:Ω→(N→N→N→R), holds iff (a) the family of real random variables ω↦W(ω)ij(ℓ)\omega\mapsto W(\omega)^{(\ell)}_{ij}ω↦W(ω)ij(ℓ)​, indexed by the weight indices of item 4, is mutually independent under PPP, and (b) for each such index the pushforward of PPP under ω↦W(ω)ij(ℓ)\omega\mapsto W(\omega)^{(\ell)}_{ij}ω↦W(ω)ij(ℓ)​ equals the centered Gaussian on R\mathbb{R}R with variance CW/nℓ−1C_W/n_{\ell-1}CW​/nℓ−1​ (computed in R≥0\mathbb{R}_{\ge0}R≥0​, so it is 000, a Dirac mass at 000, if nℓ−1=0n_{\ell-1}=0nℓ−1​=0 or CW=0C_W=0CW​=0). Condition (b) forces each such weight to be almost-everywhere measurable when PPP is a probability measure. Nothing is required of PPP itself by this definition.
Human review
  • Endorsed by Shuze Chen · Sep 24, 2026

    Confirmed by the moderator at approval.

  • Endorsed by LG · Sep 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