Multivariable Gaussian density, Gaussian expectation, and pairings
DefinitionDLT_GaussianIntegralsDefinitions for §1.1 of The Principles of Deep Learning Theory.
Let be a real matrix with inverse (written ).
- The quadratic form for (eq. 1.28).
- The zero-mean Gaussian density with covariance (eq. 1.31):
- The Gaussian expectation of an observable (eqs. 1.36, 1.46):
- The set of pairings of labels: permutations of with and no fixed point; pairs each label with .
These are the objects in which Wick's theorem (eq. 1.45) and its special cases are stated.
Formalization Note Vectors are functions Fin N → ℝ integrated against Lebesgue measure. The definitions make sense for any matrix; the theorems of the mission assume positive definite, as in the book.
import Mathlib
/-!
# The Principles of Deep Learning Theory — Gaussian integrals (§1.1)
Zero-mean multivariable Gaussian distribution with covariance `K` (eq. 1.31/1.34),
Gaussian expectations (eq. 1.36), and the set of pairings used in Wick's theorem (eq. 1.45).
-/
open MeasureTheory
namespace DeepLearningTheory
/-- The Gaussian quadratic form `∑_{μ,ν} z_μ (K⁻¹)_{μν} z_ν` (eq. 1.28). -/
noncomputable def gaussQuadForm {N : ℕ} (K : Matrix (Fin N) (Fin N) ℝ) (z : Fin N → ℝ) : ℝ :=
∑ μ : Fin N, ∑ ν : Fin N, z μ * K⁻¹ μ ν * z ν
/-- Zero-mean multivariable Gaussian density with covariance `K` (eq. 1.31):
`p(z) = |2πK|^{-1/2} exp(-½ ∑ z_μ (K⁻¹)_{μν} z_ν)`, where `|2πK| = det(2πK) = (2π)^N det K`. -/
noncomputable def gaussianDensity {N : ℕ} (K : Matrix (Fin N) (Fin N) ℝ) (z : Fin N → ℝ) : ℝ :=
(Real.sqrt ((2 * Real.pi) ^ N * K.det))⁻¹ * Real.exp (-(1 / 2) * gaussQuadForm K z)
/-- Expectation `E[F(z)] = ∫ dᴺz p(z) F(z)` under the zero-mean Gaussian with covariance `K`
(eqs. 1.36, 1.46), with respect to Lebesgue measure on `ℝᴺ`. -/
noncomputable def gaussExpect {N : ℕ} (K : Matrix (Fin N) (Fin N) ℝ) (F : (Fin N → ℝ) → ℝ) : ℝ :=
∫ z, gaussianDensity K z * F z
/-- The pairings of `M` labels: fixed-point-free involutions of `{0, …, M-1}`.
A pairing `σ` pairs each label `a` with `σ a`. -/
def pairings (M : ℕ) : Finset (Equiv.Perm (Fin M)) :=
Finset.univ.filter (fun σ => σ * σ = 1 ∧ ∀ a, σ a ≠ a)
end DeepLearningTheory
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, four objects.
- For , a real matrix indexed by and : , where is Mathlib's matrix inverse (which equals the zero matrix when ).
- . Here is the real square root (equal to on negative arguments) and , so if the density is identically .
- over with Lebesgue (product) measure, as a Bochner integral: it is if is not integrable.
- For ,
pairings Mis the finite set of permutations of satisfying and for every . For odd this set is empty; for it contains exactly the identity of the empty set.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.