The unrolled gradient
ProvedSuttonBartoRL.PolicyGradient.grad_stateValue_unrolledp2o-batch-b23bp2o-gran-per-chapterp2o-plan-bookp2o-v1policy-gradientreinforcement-learning
Let a finite episodic MDP and a differentiable policy parameterization be given, and let episodes terminate under . Then for every nonterminal state the map is differentiable at and
where is the probability of transitioning from to in steps under and all gradients are taken at .
This is the identity "after repeated unrolling" in the proof box; the policy gradient theorem is its case .
Formalization Note is the entry of . The result is stated for every start state, not only , as in the book.
Preamble
import Mathlib import Definitions.Def_SuttonBartoRL_PolicyGradient_Model import Definitions.Def_SuttonBartoRL_PolicyGradient_EpisodicValues
Formal statement
namespace SuttonBartoRL.PolicyGradient
/-- Box "Proof of the Policy Gradient Theorem (episodic case)", p. 325, "after repeated unrolling":
if episodes terminate under `π_{θ₀}`, then for every state `s`
`∇v_π(s) = Σ_{x ∈ S} Σ_{k=0}^{∞} Pr(s → x, k, π) Σ_a ∇π(a|x) q_π(x, a)`, where
`Pr(s → x, k, π) = (P_θ^k)(s, x)`. -/
theorem grad_stateValue_unrolled {S A : Type} [Fintype S] [DecidableEq S] [Fintype A] {d : ℕ}
(M : EpisodicMDP S A) (π : ParamPolicy S A d) (θ₀ : EuclideanSpace ℝ (Fin d))
(hT : M.Terminates π θ₀) (s : S) :
HasGradientAt (fun θ => M.stateValue π θ s)
(∑ x, (∑' k : ℕ, (M.policyTrans π θ₀ ^ k) s x) •
∑ a, M.actionValue π θ₀ x a • gradient (fun θ => π.prob θ x a) θ₀)
θ₀ := by sorry
end SuttonBartoRL.PolicyGradient
Source
Sutton & Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press (2018), ISBN 9780262039246, box "Proof of the Policy Gradient Theorem (episodic case)", p. 325
Human review
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.