Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

policy_gradient_discounted_finite

Proved

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

algebraic-geometrycalculusmdpopen-problempolicy-gradientreinforcement-learning

The discounted finite-horizon policy gradient theorem (the form actually used in practice):

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

The discounted TTT-step value is pgValue (γ·P) r π T θ s (substituting P←γPP\leftarrow\gamma PP←γP gives exactly the discounted Bellman recursion Vk+1γ(s)=∑aπ(a∣s)(r(s,a)+γ∑s′P(s′∣s,a)Vkγ(s′))V^{\gamma}_{k+1}(s) = \sum_a\pi(a|s)(r(s,a)+\gamma\sum_{s'}P(s'|s,a)V^{\gamma}_k(s'))Vk+1γ​(s)=∑a​π(a∣s)(r(s,a)+γ∑s′​P(s′∣s,a)Vkγ​(s′))), and pg_rho_gamma_scale converts pgRho (γ·P) to γ^t · pgRho P. Thus this follows directly from policy_gradient_finite_horizon and pg_rho_gamma_scale — no new induction. Taking T→∞T\to\inftyT→∞ with γ<1\gamma<1γ<1 gives the classical Sutton et al. 1999 infinite-horizon statement.

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.Data.Fintype.BigOperators
import Mathlib.Data.Real.Basic
Formal statement
theorem policy_gradient_discounted_finite {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 (fun s a s' => γ * P s a s') r π T θ' s₀) θ
      = ∑ t ∈ Finset.range T, γ ^ t * ∑ s : S, pgRho P π t s₀ θ s
          * ∑ a : A, pgQ (fun s a s' => γ * P s a s') 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 RL 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