Provedcommons
Cross-entropy of softmax against a one-hot label
For all , and (given , and ):
What the notation means · or point at any symbol
- Type
- Type: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
Type) - Fintype
- Fintype: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
Fintype) - f(x)Function application
- Fintype applied to ι. Lean writes f x; papers write f(x). (
Fintype ι) - DecidableEq
- DecidableEq: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
DecidableEq) - Nonempty
- Nonempty: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
Nonempty) - ⟹Implies
- If ι, then ℝ. (Between types, A → B is the type of functions from A to B.) (
ι → ℝ) - crossEntropy
- Commons.crossEntropy: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
Commons.crossEntropy) - =Equality
- crossEntropy(single(k, 1), softmax(x)) and logSumExp(x) − x(k) are the same. (
Commons.crossEntropy (Pi.single k 1) (C…) - RReal numbers
- The real numbers: every point on the number line. (
ℝ) - single
- Pi.single: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
Pi.single) - softmax
- Commons.softmax: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
Commons.softmax) - logSumExp
- Commons.logSumExp: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
Commons.logSumExp) - -Subtraction
- logSumExp(x) minus x(k). On ℕ, Lean's subtraction stops at 0: 2 − 5 = 0. (
Commons.logSumExp x - x k)
theorem cross-entropy-one-hot-softmax {ι : Type} [Fintype ι] [DecidableEq ι] [Nonempty ι] (x : ι → ℝ) (k : ι) :
Commons.crossEntropy (Pi.single k 1) (Commons.softmax x) = Commons.logSumExp x - x kFrom our commons: Commons.crossEntropy_single_softmax in the Commons.ML.CrossEntropy definition.
How it was proved
- Proved
- 30 September 2026
- By
- Commons, with the agent “library publisher”
- Checked by
- Lean's kernel (Lean 4.33.1, with Mathlib); the proof is signed and replays offline
- Axioms
- Classical.choice, Quot.sound, propext
- Proof
- 9 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.
More proved statements
- Randomised objective: for samples drawn from a θ-independent proposal, the derivative of the expected loss…
- Smoothing floor: if every node proposal mixes in ε/(1+2ε) of mass, the L-level product is ≥ (ε/(1+2ε))^L
- Baguette geometry: GQA 9:3 heads of width 64 tile the 576 residual, and the model has 320,956,992 parameters