Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

policy_gradient_baseline

Proved

by tianyipeng · May 10, 2026 · Mathlib 0df444a (Lean v4.33.1)

calculusgeometrymdpopen-problempolicy-gradientreinforcement-learning

Baseline-invariance of the policy gradient estimator: for any baseline bt(s)b_t(s)bt​(s) (independent of the action aaa),

∇θVT(s0)=∑t<T∑sρt(s)∑aπθ(a∣s) (QT−1−t(s,a)−bt(s)) ∇θlog⁡πθ(a∣s).\nabla_\theta V_T(s_0) = \sum_{t<T}\sum_s\rho_t(s)\sum_a\pi_\theta(a|s)\,\big(Q_{T-1-t}(s,a) - b_t(s)\big)\,\nabla_\theta\log\pi_\theta(a|s).∇θ​VT​(s0​)=t<T∑​s∑​ρt​(s)a∑​πθ​(a∣s)(QT−1−t​(s,a)−bt​(s))∇θ​logπθ​(a∣s).

This is the REINFORCE-with-baseline identity (Williams 1992). The most common choice bt(s)=VT−1−t(s)b_t(s) = V_{T-1-t}(s)bt​(s)=VT−1−t​(s) gives the advantage form. Follows from policy_gradient_log_form and score_zero_mean (the bt(s)b_t(s)bt​(s) term drops out because ∑aπθ(a∣s)∇log⁡πθ(a∣s)=0\sum_a\pi_\theta(a|s)\nabla\log\pi_\theta(a|s)=0∑a​πθ​(a∣s)∇logπθ​(a∣s)=0). Requires the policy normalized for all θ′\theta'θ′ near θ\thetaθ, not just at θ\thetaθ.

Preamble
import Definitions.Def_pg_mdp_core
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.Deriv.Add
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Real.Basic
Formal statement
theorem policy_gradient_baseline {S A : Type} [Fintype S] [Fintype A] [DecidableEq S]
    (P : S → A → S → ℝ) (r : S → A → ℝ) (π : ℝ → S → A → ℝ) (θ : ℝ)
    (hdiff : ∀ s a, DifferentiableAt ℝ (fun θ' => π θ' s a) θ)
    (hpos : ∀ s a, 0 < π θ s a)
    (hnorm : ∀ θ' s, ∑ a : A, π θ' s a = 1)
    (T : ℕ) (s₀ : S) (b : ℕ → S → ℝ) :
    deriv (fun θ' => pgValue P r π T θ' s₀) θ
      = ∑ t ∈ Finset.range T, ∑ s : S, pgRho P π t s₀ θ s
          * ∑ a : A, π θ s a * (pgQ P r π (T - 1 - t) θ s a - b t s)
              * deriv (fun θ' => Real.log (π θ' s a)) θ := by sorry
Source
R. J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. ML 8, 1992.

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