Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

The score function has zero mean: ∫pθ ∂θlog⁡pθ dμ=0\int p_\theta \, \partial_\theta \log p_\theta \, d\mu = 0∫pθ​∂θ​logpθ​dμ=0

Proved
ScoreFunction.score_zero_mean

by Cody Wang · Sep 5, 2026 · Mathlib 0df444a (Lean v4.33.1)

analysiscalculusinformation-geometrymeasure-theorypolicy-gradientprobabilityreinforcement-learningstatistics

The score function has mean zero: the measure-theoretic analogue of score_zero_mean, which is already on the platform in the finite-sum setting.

Let (X,A,μ)(\mathcal X,\mathcal A,\mu)(X,A,μ) be a measure space and let pθp_\thetapθ​ be a family of probability densities with respect to μ\muμ, so that

∫Xpt(x) dμ(x)  =  1for every t in a neighbourhood of θ.\int_{\mathcal X} p_t(x)\, d\mu(x) \;=\; 1 \qquad \text{for every } t \text{ in a neighbourhood of } \theta .∫X​pt​(x)dμ(x)=1for every t in a neighbourhood of θ.

The score at θ\thetaθ is ∂θlog⁡pθ\partial_\theta \log p_\theta∂θ​logpθ​. Then, under the standard conditions for differentiating under the integral sign,

Epθ ⁣[∂θlog⁡pθ]  =  ∫Xpθ(x) ∂∂θlog⁡pθ(x)  dμ(x)  =  0.\mathbb E_{p_\theta}\!\left[\partial_\theta \log p_\theta\right] \;=\; \int_{\mathcal X} p_\theta(x)\, \frac{\partial}{\partial\theta}\log p_\theta(x)\; d\mu(x) \;=\; 0 .Epθ​​[∂θ​logpθ​]=∫X​pθ​(x)∂θ∂​logpθ​(x)dμ(x)=0.

The identity is what makes the Fisher information the variance of the score rather than a second moment about an unknown mean, and it is the reason an arbitrary θ\thetaθ-independent baseline may be subtracted from the reward in a policy-gradient estimator without introducing bias.

Note that normalization is required on a whole neighbourhood of θ\thetaθ, not merely at θ\thetaθ itself: the proof differentiates the constant function t↦∫pt dμt \mapsto \int p_t \, d\mut↦∫pt​dμ, and a family normalized only at the single point θ\thetaθ carries no information about that derivative. The remaining hypotheses are the dominated-derivative conditions: almost-everywhere positivity of pθp_\thetapθ​, measurability of ptp_tpt​ near θ\thetaθ and integrability at θ\thetaθ, differentiability of t↦pt(x)t \mapsto p_t(x)t↦pt​(x) on a neighbourhood sss of θ\thetaθ with derivative pt′(x)p'_t(x)pt′​(x), and an integrable bound on ∣pt′∣|p'_t|∣pt′​∣ uniform over t∈st \in st∈s.

Formalization Note As in the general identity, the parameter derivative is supplied explicitly as p' through HasDerivAt, while the conclusion is stated with deriv (fun t => Real.log (p t x)) θ so that the score appears as a logarithmic derivative. This statement is the f≡1f \equiv 1f≡1 specialization of the measure-theoretic log-derivative trick combined with the normalization hypothesis.

Preamble
import Mathlib.Analysis.Calculus.ParametricIntegral
import Mathlib.Analysis.SpecialFunctions.Log.Deriv

open MeasureTheory Filter
open scoped Topology
Formal statement
namespace ScoreFunction
theorem score_zero_mean
    {X : Type*} [MeasurableSpace X] {μ : Measure X}
    {p p' : ℝ → X → ℝ} {bound : X → ℝ} {θ : ℝ} {s : Set ℝ}
    (hs : s ∈ 𝓝 θ)
    (hp_pos : ∀ᵐ x ∂μ, 0 < p θ x)
    (hp_meas : ∀ᶠ t in 𝓝 θ, AEStronglyMeasurable (p t) μ)
    (hp_int : Integrable (p θ) μ)
    (hp'_meas : AEStronglyMeasurable (p' θ) μ)
    (h_bound : ∀ᵐ x ∂μ, ∀ t ∈ s, |p' t x| ≤ bound x)
    (h_bound_int : Integrable bound μ)
    (h_diff : ∀ᵐ x ∂μ, ∀ t ∈ s, HasDerivAt (fun u => p u x) (p' t x) t)
    (h_norm : ∀ t ∈ s, ∫ x, p t x ∂μ = 1) :
    ∫ x, p θ x * deriv (fun t => Real.log (p t x)) θ ∂μ = 0 := by sorry
end ScoreFunction
Source
Measure-theoretic (continuous) form of the score-function / likelihood-ratio gradient identity, a.k.a. the log-derivative trick. Identity as stated in A. C. Jones, 'The log-derivative trick', https://andrewcharlesjones.github.io/journal/log-derivative.html : grad_theta E_{p(x;theta)}[f(x)] = E_{p(x;theta)}[grad_theta log p(x;theta) * f(x)]. Standard references: P. W. Glynn, 'Likelihood ratio gradient estimation for stochastic systems', Communications of the ACM 33(10):75-84, 1990, https://doi.org/10.1145/84537.84552 ; S. Mohamed, M. Rosca, M. Figurnov, A. Mnih, 'Monte Carlo Gradient Estimation in Machine Learning', JMLR 21(132):1-62, 2020, https://arxiv.org/abs/1906.10652 (score-function estimators). The interchange-of-derivative-and-integral hypotheses are the standard dominated-derivative conditions, matching Mathlib's hasDerivAt_integral_of_dominated_loc_of_deriv_le. Discrete counterparts already on Prove2Me: likelihood_ratio_gradient and score_zero_mean (R. J. Williams, Machine Learning 8, 1992, REINFORCE).

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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me