Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Example 6.4 (You are the Predictor): batch TD(0) gives V(A)=3/4V(A) = 3/4V(A)=3/4, batch MC gives V(A)=0V(A) = 0V(A)=0

Proved
SuttonBartoRL.BatchTD.you_are_the_predictor

by mikedeng1 · Oct 4, 2026 · Mathlib 0df444a (Lean v4.33.1)

p2o-batch-b23bp2o-gran-per-chapterp2o-plan-bookp2o-v1reinforcement-learningtemporal-difference-learning

Consider two nonterminal states AAA, BBB, no discounting (γ=1\gamma = 1γ=1), and the batch of eight episodes

A,0,B,0B,1(six times)B,0.A,0,B,0 \qquad B,1 \quad (\text{six times}) \qquad B,0 .A,0,B,0B,1(six times)B,0.

Then:

  1. the certainty-equivalence estimate is v^(A)=v^(B)=34\hat v(A) = \hat v(B) = \tfrac34v^(A)=v^(B)=43​;
  2. the sample averages of the returns are Gˉ(A)=0\bar G(A) = 0Gˉ(A)=0 and Gˉ(B)=34\bar G(B) = \tfrac34Gˉ(B)=43​;
  3. there is αˉ>0\bar\alpha > 0αˉ>0 such that for every α∈(0,αˉ)\alpha \in (0, \bar\alpha)α∈(0,αˉ) and every initial array V0V_0V0​, batch TD(0) converges to V(A)=V(B)=34V(A) = V(B) = \tfrac34V(A)=V(B)=43​, and batch constant-α\alphaα MC converges to V(A)=0V(A) = 0V(A)=0, V(B)=34V(B) = \tfrac34V(B)=43​.

The example shows the two batch answers differing on data from a single batch: the Monte Carlo answer fits the training returns exactly, while the TD answer is the one implied by the Markov model built from the data.

Formalization Note AAA and BBB are the elements 000 and 111 of Fin 2. The first episode is the list (A,0),(B,0)(A, 0), (B, 0)(A,0),(B,0): from AAA with reward 000 to BBB, then from BBB with reward 000 to the terminal state.

Preamble
import Mathlib
import Definitions.Def_SuttonBartoRL_BatchTD_Episodes
import Definitions.Def_SuttonBartoRL_BatchTD_BatchUpdating

open Filter Topology
Formal statement
namespace SuttonBartoRL.BatchTD

/-- Example 6.4 "You are the Predictor", pp. 127–128. States `A = 0`, `B = 1` of `Fin 2`, `γ = 1`,
and the eight episodes `A,0,B,0`; `B,1` (six times); `B,0`. The certainty-equivalence estimate
is `V(A) = V(B) = 3/4`, which is what batch TD(0) converges to; the sample averages of the returns
are `V(A) = 0`, `V(B) = 3/4`, which is what batch Monte Carlo converges to. -/
theorem you_are_the_predictor :
    let b : Batch (Fin 2) :=
      [[((0 : Fin 2), (0 : ℝ)), (1, 0)], [(1, 1)], [(1, 1)], [(1, 1)], [(1, 1)], [(1, 1)],
        [(1, 1)], [(1, 0)]]
    ceEstimate 1 b 0 = 3 / 4 ∧ ceEstimate 1 b 1 = 3 / 4 ∧
    mcAverage 1 b 0 = 0 ∧ mcAverage 1 b 1 = 3 / 4 ∧
    ∃ αbar : ℝ, 0 < αbar ∧ ∀ α : ℝ, 0 < α → α < αbar → ∀ V₀ : Fin 2 → ℝ,
      Tendsto (fun m : ℕ => batchTD α 1 b V₀ m 0) atTop (𝓝 (3 / 4)) ∧
      Tendsto (fun m : ℕ => batchTD α 1 b V₀ m 1) atTop (𝓝 (3 / 4)) ∧
      Tendsto (fun m : ℕ => batchMC α 1 b V₀ m 0) atTop (𝓝 0) ∧
      Tendsto (fun m : ℕ => batchMC α 1 b V₀ m 1) atTop (𝓝 (3 / 4)) := by sorry

end SuttonBartoRL.BatchTD
Source
Sutton & Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press (2018), ISBN 9780262039246, Example 6.4, pp. 127–128
Human review
  • Endorsed by Shuze Chen · Oct 5, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Oct 5, 2026

    Confirmed by the mission captain (proposal self-audit).

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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me