Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

policy_gradient_finite_horizon

Proved

by tianyipeng · May 10, 2026 · Mathlib 777aaa6 (Lean v4.29.0-rc3)

algebraalgebraic-geometrycalculusmdpopen-problempolicy-gradientreinforcement-learningtopology

The finite-horizon policy gradient theorem (Sutton, McAllester, Singh, Mansour 1999; finite-horizon, finite-state/action, scalar-parameter form). For a finite MDP with transition kernel PPP, reward rrr, policy πθ\pi_\thetaπθ​ differentiable in a scalar parameter θ\thetaθ, start state s0s_0s0​, and horizon TTT:

∇θVTπθ(s0)=∑t=0T−1∑sρtπθ(s ∣ s0)∑aQT−1−tπθ(s,a) ∇θπθ(a∣s),\nabla_\theta V_T^{\pi_\theta}(s_0) = \sum_{t=0}^{T-1}\sum_s \rho_t^{\pi_\theta}(s\,|\,s_0)\sum_a Q_{T-1-t}^{\pi_\theta}(s,a)\,\nabla_\theta\pi_\theta(a|s),∇θ​VTπθ​​(s0​)=t=0∑T−1​s∑​ρtπθ​​(s∣s0​)a∑​QT−1−tπθ​​(s,a)∇θ​πθ​(a∣s),

where ρt\rho_tρt​ is the time-ttt state visitation probability and QkQ_kQk​ the kkk-steps-remaining action value. Proof: induction on TTT, unrolling pg_bellman_step; the inner ∑aπ∑s′P⋅∇Vk\sum_a\pi\sum_{s'}P\cdot\nabla V_k∑a​π∑s′​P⋅∇Vk​ term becomes the t≥1t\geq1t≥1 slice of the sum via the first-step recursion for ρ\rhoρ. Note no probability axioms on P,πP,\piP,π are needed for the identity itself; they make ρ\rhoρ and VVV probabilistically meaningful but the algebra holds regardless.

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_finite_horizon {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) θ)
    (T : ℕ) (s₀ : S) :
    deriv (fun θ' => pgValue P r π T θ' s₀) θ
      = ∑ t ∈ Finset.range T, ∑ s : S, pgRho P π t s₀ θ s
          * ∑ a : A, pgQ P r π (T - 1 - t) θ s a * deriv (fun θ' => π θ' s a) θ := by sorry
Source
R. Sutton, D. McAllester, S. Singh, Y. Mansour. Policy Gradient Methods for Reinforcement Learning with Function Approximation. NeurIPS 1999.

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