Exercise 10.6: the rewards have average and differential values
ProvedSuttonBartoRL.AverageReward.exercise_10_6Consider a finite MDP and a policy under which the expected reward sequence starting from a state is and starting from a state is ; that is, for all ,
Then:
- the average reward (10.6) is from both and ;
- the limit (10.7) does not exist from nor from ;
- there is no steady-state distribution: no with for all ;
- with , the differential values (10.13) are
The book leaves the answers to the reader; they are computed here. The example shows that the average reward (10.6) can be well defined when the MDP is not ergodic, and that (10.13) repairs the differential return (10.9), whose implicit limit does not exist here.
Formalization Note The book's "MDP that under any policy produces the deterministic sequence of rewards" is encoded by a hypothesis on the expected rewards of one policy, which is all the exercise uses; the statement therefore applies to every such MDP and policy. The differential value is the explicit two-limit statement of (10.13), with from below.
import Mathlib import Definitions.Def_SuttonBartoRL_AverageReward_MDP import Definitions.Def_SuttonBartoRL_AverageReward_AverageReward open Filter Topology
namespace SuttonBartoRL.AverageReward
/-- Sutton & Barto (2018), Exercise 10.6, p. 251 (answers not printed; computed here). Suppose that,
under the policy `π`, the expected reward sequence from state `A` is `+1, 0, +1, 0, …` and from
state `B` is `0, +1, 0, +1, …`. Then
1. the average reward (10.6) is `1/2` from both states;
2. the limit (10.7) does not exist from either state;
3. there is no steady-state distribution independent of `S_0`;
4. the differential values (10.13) with `r(π) = 1/2` are `v_π(A) = 1/4` and `v_π(B) = −1/4`. -/
theorem exercise_10_6 {S A : Type} [Fintype S] [DecidableEq S] [Fintype A]
(M : MDP S A) (π : SuttonBartoRL.FiniteMDP.Policy S A) (sA sB : S)
(hA : ∀ t : ℕ, M.expectedRewardAt π t sA = if Even t then 1 else 0)
(hB : ∀ t : ℕ, M.expectedRewardAt π t sB = if Even t then 0 else 1) :
Tendsto (fun h : ℕ => (1 / (h : ℝ)) * ∑ t ∈ Finset.range h, M.expectedRewardAt π t sA)
atTop (𝓝 (1 / 2)) ∧
Tendsto (fun h : ℕ => (1 / (h : ℝ)) * ∑ t ∈ Finset.range h, M.expectedRewardAt π t sB)
atTop (𝓝 (1 / 2)) ∧
(¬ ∃ L : ℝ, Tendsto (fun t : ℕ => M.expectedRewardAt π t sA) atTop (𝓝 L)) ∧
(¬ ∃ L : ℝ, Tendsto (fun t : ℕ => M.expectedRewardAt π t sB) atTop (𝓝 L)) ∧
(¬ ∃ μ : S → ℝ, ∀ s₀ s, Tendsto (fun t : ℕ => M.stateDist π s₀ t s) atTop (𝓝 (μ s))) ∧
HasDifferentialValue M π (1 / 2) sA (1 / 4) ∧
HasDifferentialValue M π (1 / 2) sB (-1 / 4) := by sorry
end SuttonBartoRL.AverageReward
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.