If the greedy policy is no better, both policies are optimal
ProvedSuttonBartoRL.DP.greedy_no_improvement_optimaldynamic-programmingp2o-batch-b23bp2o-gran-per-chapterp2o-plan-bookp2o-v1reinforcement-learning
Let be a deterministic policy of a finite MDP with discount , and let be a deterministic policy greedy with respect to (4.9). Suppose is as good as, but not better than, , i.e. . Then
- satisfies the Bellman optimality equation (4.1): for all ,
- , the optimal value function;
- both and are optimal policies.
Consequently policy improvement yields a strictly better policy unless the original policy is already optimal.
Formalization Note Optimality is with respect to all stochastic policies, and is the supremum of over all stochastic policies.
Preamble
import Mathlib import Definitions.Def_SuttonBartoRL_DP_MDP import Definitions.Def_SuttonBartoRL_DP_ValueFunctions
Formal statement
namespace SuttonBartoRL.DP
/-- Sutton & Barto (2018), p. 79: if the deterministic policy `π'` is greedy with respect to
`q_π` and is as good as, but not better than, the deterministic policy `π` (`v_{π'} = v_π`),
then `v_{π'}` satisfies the Bellman optimality equation (4.1),
`v_{π'}(s) = max_a Σ_{s', r} p(s', r | s, a) [r + γ v_{π'}(s')]`, `v_{π'} = v_*`, and both `π` and
`π'` are optimal policies. -/
theorem greedy_no_improvement_optimal {S A : Type} [Fintype S] [DecidableEq S] [Fintype A]
[DecidableEq A] [Nonempty A] (M : MDP S A) (γ : ℝ) (hγ0 : 0 ≤ γ) (hγ1 : γ < 1)
(π π' : S → A) (hgreedy : IsGreedy M γ (Policy.ofDet π) π')
(heq : ∀ s, stateValue M γ (Policy.ofDet π') s = stateValue M γ (Policy.ofDet π) s) :
(∀ s, stateValue M γ (Policy.ofDet π') s =
Finset.univ.sup' Finset.univ_nonempty (fun a : A =>
∑ s', ∑ r ∈ M.R, M.p s a s' r * (r + γ * stateValue M γ (Policy.ofDet π') s'))) ∧
(∀ s, stateValue M γ (Policy.ofDet π') s = optimalValue M γ s) ∧
IsOptimalPolicy M γ (Policy.ofDet π) ∧ IsOptimalPolicy M γ (Policy.ofDet π') := by sorry
end SuttonBartoRL.DP
Source
Sutton & Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press (2018), ISBN 9780262039246, §4.2, p. 79 (paragraph after (4.9))
Human review
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.