Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

§3.2 — cross-entropy decomposition KL(τ∥μ)=Ex∼τ[log⁡(1/μ(x))]−H(τ)\mathrm{KL}(\tau\|\mu)=\mathbb E_{x\sim\tau}[\log(1/\mu(x))]-H(\tau)KL(τ∥μ)=Ex∼τ​[log(1/μ(x))]−H(τ)

Proved
MLManagesComplexity.cross_entropy_decomposition

by iris · Nov 12, 2026 · Mathlib 0df444a (Lean v4.33.1)

computational-complexitycryptographyinformation-theorymachine-learningp2o-gran-per-chapterp2o-plan-paperp2o-strengthenedp2o-v1

Let τ\tauτ and μ\muμ be probability distributions on a finite set Ω\OmegaΩ. Write KL(τ∥μ)=Ex∼τ[log⁡2(τ(x)/μ(x))]\mathrm{KL}(\tau\|\mu)=\mathbb E_{x\sim\tau}[\log_2(\tau(x)/\mu(x))]KL(τ∥μ)=Ex∼τ​[log2​(τ(x)/μ(x))] for the Kullback–Leibler divergence, Ex∼τ[log⁡2(1/μ(x))]\mathbb E_{x\sim\tau}[\log_2(1/\mu(x))]Ex∼τ​[log2​(1/μ(x))] for the cross-entropy, and H(τ)=∑xτ(x)log⁡2(1/τ(x))H(\tau)=\sum_x\tau(x)\log_2(1/\tau(x))H(τ)=∑x​τ(x)log2​(1/τ(x)) for the Shannon entropy, the divergence and the cross-entropy being +∞+\infty+∞ when some xxx has τ(x)>0=μ(x)\tau(x)>0=\mu(x)τ(x)>0=μ(x). Then

KL(τ∥μ)=Ex∼τ[log⁡1μ(x)]−H(τ).\mathrm{KL}(\tau\|\mu)=\mathbb E_{x\sim\tau}\Bigl[\log\frac{1}{\mu(x)}\Bigr]-H(\tau).KL(τ∥μ)=Ex∼τ​[logμ(x)1​]−H(τ).

The decomposition explains why minimising KL(D∥μ)\mathrm{KL}(D\|\mu)KL(D∥μ) over models μ\muμ is the same as minimising the cross-entropy (the training loss): H(D)H(D)H(D) does not depend on μ\muμ.

Formalization Note The identity is stated in the extended reals, so the infinite case +∞=+∞−H(τ)+\infty=+\infty-H(\tau)+∞=+∞−H(τ) is included.

Differences from the source:

  • generalization: distributions over {0,1}^n → distributions on an arbitrary finite type Ω; reason: the identity holds on every finite set; Ω = {0,1}^n is the source's case
  • encoding: KL-divergence and cross-entropy (possibly infinite, p.5: "even infinite if for some x, τ(x) > µ(x) = 0") → the published klBits/crossEntropy in EReal, ⊤ exactly on a support mismatch, logarithms base 2; reason: Lean convention; same values
Preamble
import Mathlib
import Definitions.Def_AutoregressiveCompression_Main_Information

set_option autoImplicit false

open AutoregressiveCompression.Main
Formal statement
namespace MLManagesComplexity

/-- **Cross-entropy decomposition** (Fortnow, *How Does Machine Learning Manage Complexity?*, arXiv:2604.07233 (version of 2026-10-31, sha256 4874d83f…), §3.2, printed p.4, PDF p.5: "KL(τ‖μ) =
E_{x∼τ}[log(1/μ(x))] − H(τ)"). For distributions `τ, μ` on a finite set, the KL divergence of
`τ` from `μ` equals the cross-entropy of `τ` under `μ` minus the Shannon entropy of `τ`, in bits.

**Formalization Note** `klBits`, `crossEntropy` and `entropy` are the published
`AutoregressiveCompression.Main` ones (base 2; `klBits` and `crossEntropy` are `⊤` exactly when
some `x` has `τ(x) > 0 = μ(x)`). The identity is in `EReal`, so the infinite case
(`⊤ = ⊤ − H(τ)`) is included. -/
theorem cross_entropy_decomposition {Ω : Type} [Fintype Ω] (τ μ : PMF Ω) :
    klBits τ μ = crossEntropy τ μ - (entropy τ : EReal) := by sorry

end MLManagesComplexity
Source
Fortnow, How Does Machine Learning Manage Complexity?, arXiv:2604.07233 (version of 2026-10-31, sha256 4874d83f…), §3.2, cross-entropy decomposition, p.4 (PDF p.5)
Human review
  • Endorsed by Shuze Chen · Nov 12, 2026

    Confirmed by the moderator at approval.

  • Endorsed by iris · Nov 12, 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