Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Later ratio factors drop out: E[ρt:T−1Rt+k]=E[ρt:t+k−1Rt+k]\mathbb E[\rho_{t:T-1}R_{t+k}] = \mathbb E[\rho_{t:t+k-1}R_{t+k}]E[ρt:T−1​Rt+k​]=E[ρt:t+k−1​Rt+k​] (5.14)

Proved
SuttonBartoRL.ImportanceSampling.per_decision_reward_term

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

importance-samplingp2o-batch-b23bp2o-gran-per-chapterp2o-plan-bookp2o-v1reinforcement-learning

Let bbb cover π\piπ, start episodes at S0=sS_0 = sS0​=s and generate them with bbb, and assume that under bbb every episode from sss terminates within HHH steps with probability one. Then for every k≥1k \ge 1k≥1,

Eb[ρ0:T−1Rk∣S0=s]=Eb[ρ0:k−1Rk∣S0=s],\mathbb E_b\bigl[\rho_{0:T-1} R_k \mid S_0 = s\bigr] = \mathbb E_b\bigl[\rho_{0:k-1} R_k \mid S_0 = s\bigr],Eb​[ρ0:T−1​Rk​∣S0​=s]=Eb​[ρ0:k−1​Rk​∣S0​=s],

where RkR_kRk​ is taken to be 000 if the episode has terminated before time kkk. For k=1k = 1k=1 this is (5.14): only the first factor π(A0∣S0)/b(A0∣S0)\pi(A_0 \mid S_0)/b(A_0 \mid S_0)π(A0​∣S0​)/b(A0​∣S0​) of the ratio matters for the first reward.

The identity is the key step towards per-decision importance sampling: the factors of the ratio for decisions made after a reward are irrelevant in expectation.

Formalization Note The book writes the identity for a general time ttt with E\mathbb EE over trajectories under bbb; here t=0t = 0t=0 and the expectation is conditional on S0=sS_0 = sS0​=s (the Markov property makes the two equivalent). The book does not state a termination assumption; the bounded-horizon hypothesis (Pr⁡b{T≤H∣S0=s}=1\Pr_b\{T \le H \mid S_0 = s\} = 1Prb​{T≤H∣S0​=s}=1) makes every expectation a finite sum and is a restriction relative to the book's episodic setting.

Preamble
import Mathlib
import Definitions.Def_SuttonBartoRL_ImportanceSampling_Episodes
Formal statement
namespace SuttonBartoRL.ImportanceSampling

/-- Sutton & Barto (2018), §5.9, p. 114, Eq. (5.14) (`k = 1`) and its `k`-th form:
`E_b[ρ_{t:T-1} R_{t+k}] = E_b[ρ_{t:t+k-1} R_{t+k}]`, with `t = 0` and `S_0 = s`, where the reward
`R_k` is `0` if the episode has terminated before time `k`. Hypotheses: coverage, and termination of
every episode from `s` under `b` within `H` steps with probability one. -/
theorem per_decision_reward_term {S A : Type} [Fintype S] [DecidableEq S] [Fintype A]
    (M : MDP S A) (term : Finset S) (π b : SuttonBartoRL.FiniteMDP.Policy S A) (hcov : Coverage π b) (s : S) (H : ℕ)
    (hH : ∑ n ∈ Finset.range (H + 1), ∑ e : Episode M n, episodeProb M term b s e = 1)
    (k : ℕ) (hk : 1 ≤ k) :
    expectation M term b s (fun n e => e.isRatio π b n * e.rewardAt (k - 1)) =
      expectation M term b s (fun _ e => e.isRatio π b k * e.rewardAt (k - 1)) := by sorry

end SuttonBartoRL.ImportanceSampling
Source
Sutton & Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press (2018), ISBN 9780262039246, §5.9, Eq. (5.14) and the k-th sub-term display, p. 114; Exercise 5.13, p. 115
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