Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma B.4 (as proved): returns bound, branched rollout

Proved
WhenToTrustYourModel.branched_returns_bound

by Xeroth · Nov 24, 2026 · Mathlib 0df444a (Lean v4.33.1)

markov-decision-processmodel-based-rlreinforcement-learningtotal-variation

Consider a discounted Markov decision process with finite state and action sets, discount γ∈(0,1)\gamma\in(0,1)γ∈(0,1), a reward with ∣r(s,a)∣≤rmax⁡|r(s,a)|\le r_{\max}∣r(s,a)∣≤rmax​ and an initial distribution ρ0\rho_0ρ0​. Fix a branch length k≥0k\ge0k≥0. For i=1,2i=1,2i=1,2, process iii starts from ρ0\rho_0ρ0​, uses the post-branch policy πipost\pi_i^{\mathrm{post}}πipost​ and dynamics pipostp_i^{\mathrm{post}}pipost​ at the kkk branch steps t<kt<kt<k, and the pre-branch policy πipre\pi_i^{\mathrm{pre}}πipre​ and dynamics piprep_i^{\mathrm{pre}}pipre​ at the steps t≥kt\ge kt≥k; ηi\eta_iηi​ is its return and p1tp_1^tp1t​ is the state marginal of process 1. Suppose

  1. Es∼p1t, a∼π1pre[DTV(p1pre(⋅∣s,a)∥p2pre(⋅∣s,a))]≤ϵmpreE_{s\sim p_1^t,\,a\sim\pi_1^{\mathrm{pre}}}\big[D_{TV}(p_1^{\mathrm{pre}}(\cdot\mid s,a)\|p_2^{\mathrm{pre}}(\cdot\mid s,a))\big]\le\epsilon_m^{\mathrm{pre}}Es∼p1t​,a∼π1pre​​[DTV​(p1pre​(⋅∣s,a)∥p2pre​(⋅∣s,a))]≤ϵmpre​ for every t≥kt\ge kt≥k;
  2. Es∼p1t, a∼π1post[DTV(p1post(⋅∣s,a)∥p2post(⋅∣s,a))]≤ϵmpostE_{s\sim p_1^t,\,a\sim\pi_1^{\mathrm{post}}}\big[D_{TV}(p_1^{\mathrm{post}}(\cdot\mid s,a)\|p_2^{\mathrm{post}}(\cdot\mid s,a))\big]\le\epsilon_m^{\mathrm{post}}Es∼p1t​,a∼π1post​​[DTV​(p1post​(⋅∣s,a)∥p2post​(⋅∣s,a))]≤ϵmpost​ for every t<kt<kt<k;
  3. max⁡sDTV(π1pre(⋅∣s)∥π2pre(⋅∣s))≤ϵπpre\max_s D_{TV}(\pi_1^{\mathrm{pre}}(\cdot\mid s)\|\pi_2^{\mathrm{pre}}(\cdot\mid s))\le\epsilon_\pi^{\mathrm{pre}}maxs​DTV​(π1pre​(⋅∣s)∥π2pre​(⋅∣s))≤ϵπpre​ and max⁡sDTV(π1post(⋅∣s)∥π2post(⋅∣s))≤ϵπpost\max_s D_{TV}(\pi_1^{\mathrm{post}}(\cdot\mid s)\|\pi_2^{\mathrm{post}}(\cdot\mid s))\le\epsilon_\pi^{\mathrm{post}}maxs​DTV​(π1post​(⋅∣s)∥π2post​(⋅∣s))≤ϵπpost​.

Then

∣η1−η2∣≤2rmax⁡[γk+1(1−γ)2(ϵmpre+ϵπpre)+k1−γ(ϵmpost+ϵπpost)+γk1−γϵπpre+11−γϵπpost].|\eta_1-\eta_2|\le2r_{\max}\left[\frac{\gamma^{k+1}}{(1-\gamma)^2}(\epsilon_m^{\mathrm{pre}}+\epsilon_\pi^{\mathrm{pre}})+\frac{k}{1-\gamma}(\epsilon_m^{\mathrm{post}}+\epsilon_\pi^{\mathrm{post}})+\frac{\gamma^k}{1-\gamma}\epsilon_\pi^{\mathrm{pre}}+\frac{1}{1-\gamma}\epsilon_\pi^{\mathrm{post}}\right].∣η1​−η2​∣≤2rmax​[(1−γ)2γk+1​(ϵmpre​+ϵπpre​)+1−γk​(ϵmpost​+ϵπpost​)+1−γγk​ϵπpre​+1−γ1​ϵπpost​].

This is the returns bound from which Theorems 4.2 and 4.3 are assembled.

Formalization Note The paper does not define the branched rollout formally. Its proof bounds the state-action marginals at the times t≤kt\le kt≤k by the post-branch errors alone and at the times t≥kt\ge kt≥k by (t−k)(t-k)(t−k) pre-branch errors plus kkk post-branch errors, so the branch segment is the first kkk time steps; the Lean statement uses that ordering. If instead the pre-branch segment comes first, as the text of Section 4.2 suggests, the statement is false: with one state, rewards ±1\pm1±1, γ=1/2\gamma=1/2γ=1/2, k=10k=10k=10 and pre-branch policies at total variation 111 used only at times t=0t=0t=0 and t≥11t\ge11t≥11, the returns differ by about 2.0022.0022.002 while the bound is 0.00780.00780.0078. The paper writes the model error as an expected KL divergence of pi(s′,a∣s)p_i(s',a\mid s)pi​(s′,a∣s); as in Lemma B.3, the proof uses the total variation of the dynamics. The pre-branch and post-branch model errors are required at the pre-branch and post-branch times respectively.

Preamble
import Mathlib
import Definitions.Def_WhenToTrustYourModel_Basic

open Finset
Formal statement
namespace WhenToTrustYourModel

theorem branched_returns_bound {S A : Type*} [Fintype S] [Fintype A]
    (γ : ℝ) (hγ₀ : 0 < γ) (hγ₁ : γ < 1)
    (r : S → A → ℝ) (rmax : ℝ) (hr : ∀ s a, |r s a| ≤ rmax)
    (ρ₀ : S → ℝ) (hρ₀ : IsDist ρ₀) (k : ℕ)
    (π₁pre π₂pre π₁post π₂post : S → A → ℝ)
    (hπ₁pre : IsPolicy π₁pre) (hπ₂pre : IsPolicy π₂pre)
    (hπ₁post : IsPolicy π₁post) (hπ₂post : IsPolicy π₂post)
    (P₁pre P₂pre P₁post P₂post : S → A → S → ℝ)
    (hP₁pre : IsDynamics P₁pre) (hP₂pre : IsDynamics P₂pre)
    (hP₁post : IsDynamics P₁post) (hP₂post : IsDynamics P₂post)
    (εmpre εmpost επpre επpost : ℝ)
    (hmpre : ∀ t, k ≤ t →
      expectedTV (stateDist ρ₀ (phase k π₁post π₁pre) (phase k P₁post P₁pre) t)
        π₁pre P₁pre P₂pre ≤ εmpre)
    (hmpost : ∀ t, t < k →
      expectedTV (stateDist ρ₀ (phase k π₁post π₁pre) (phase k P₁post P₁pre) t)
        π₁post P₁post P₂post ≤ εmpost)
    (hπpre : ∀ s, tvDist (π₁pre s) (π₂pre s) ≤ επpre)
    (hπpost : ∀ s, tvDist (π₁post s) (π₂post s) ≤ επpost) :
    |branchedReturn γ r ρ₀ k π₁post P₁post π₁pre P₁pre -
        branchedReturn γ r ρ₀ k π₂post P₂post π₂pre P₂pre| ≤
      2 * rmax * (γ ^ (k + 1) / (1 - γ) ^ 2 * (εmpre + επpre) + k / (1 - γ) * (εmpost + επpost)
        + γ ^ k / (1 - γ) * επpre + 1 / (1 - γ) * επpost) := by sorry

end WhenToTrustYourModel
Source
Janner, Fu, Zhang and Levine, When to Trust Your Model: Model-Based Policy Optimization, arXiv:1906.08253v3 (NeurIPS 2019), Appendix B, Lemma B.4, p. 17
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

Setting. Let SSS (states) and AAA (actions) be arbitrary finite sets. A distribution on a finite set XXX is a function μ:X→R\mu : X \to \mathbb{R}μ:X→R with μ(x)≥0\mu(x) \ge 0μ(x)≥0 for all xxx and ∑xμ(x)=1\sum_{x} \mu(x) = 1∑x​μ(x)=1. A policy is a function π(a∣s)\pi(a \mid s)π(a∣s) such that π(⋅∣s)\pi(\cdot \mid s)π(⋅∣s) is a distribution on AAA for every s∈Ss \in Ss∈S. A dynamics is a function P(s′∣s,a)P(s' \mid s, a)P(s′∣s,a) such that P(⋅∣s,a)P(\cdot \mid s, a)P(⋅∣s,a) is a distribution on SSS for every pair (s,a)(s, a)(s,a).

The total variation distance between two functions μ,ν:X→R\mu, \nu : X \to \mathbb{R}μ,ν:X→R is

DTV(μ ∥ ν)=12∑x∣μ(x)−ν(x)∣.D_{TV}(\mu \,\|\, \nu) = \tfrac12 \sum_{x} |\mu(x) - \nu(x)|.DTV​(μ∥ν)=21​x∑​∣μ(x)−ν(x)∣.

Two-phase schedules. For k∈Nk \in \mathbb{N}k∈N, the phase schedule selects a "post" object at the early times t<kt < kt<k and a "pre" object at all times t≥kt \ge kt≥k:

phasek(post,pre)(t)={postt<kpret≥k.\mathrm{phase}_k(\text{post}, \text{pre})(t) = \begin{cases} \text{post} & t < k \\ \text{pre} & t \ge k. \end{cases}phasek​(post,pre)(t)={postpre​t<kt≥k.​

Processes and returns. Take a time-indexed policy sequence (πt)(\pi_t)(πt​), a dynamics sequence (Pt)(P_t)(Pt​), and an initial function ρ0\rho_0ρ0​. The state marginals are defined recursively:

p0=ρ0,pt+1(s′)=∑spt(s)∑aπt(a∣s) Pt(s′∣s,a).p^0 = \rho_0, \qquad p^{t+1}(s') = \sum_{s} p^t(s) \sum_{a} \pi_t(a \mid s)\, P_t(s' \mid s, a).p0=ρ0​,pt+1(s′)=s∑​pt(s)a∑​πt​(a∣s)Pt​(s′∣s,a).

The expected reward at time ttt is

Rt=∑s∑apt(s) πt(a∣s) r(s,a),R_t = \sum_{s}\sum_{a} p^t(s)\, \pi_t(a \mid s)\, r(s,a),Rt​=s∑​a∑​pt(s)πt​(a∣s)r(s,a),

and the discounted return is the series ∑t=0∞γtRt\sum_{t=0}^{\infty} \gamma^t R_t∑t=0∞​γtRt​. This series is assigned the value 000 if it is not summable.

The branched return ηkbr(πpost,Ppost,πpre,Ppre)\eta^{\mathrm{br}}_k(\pi^{\mathrm{post}}, P^{\mathrm{post}}, \pi^{\mathrm{pre}}, P^{\mathrm{pre}})ηkbr​(πpost,Ppost,πpre,Ppre) is the discounted return of the process that, at time ttt:

  • uses policy πpost\pi^{\mathrm{post}}πpost and dynamics PpostP^{\mathrm{post}}Ppost for t<kt < kt<k;
  • uses πpre\pi^{\mathrm{pre}}πpre and PpreP^{\mathrm{pre}}Ppre for t≥kt \ge kt≥k.

Both the reward at time ttt and the transition from ttt to t+1t+1t+1 use the time-ttt policy and dynamics. Let p1tp_1^tp1t​ denote the state marginals of the process built from π1post,P1post,π1pre,P1pre\pi_1^{\mathrm{post}}, P_1^{\mathrm{post}}, \pi_1^{\mathrm{pre}}, P_1^{\mathrm{pre}}π1post​,P1post​,π1pre​,P1pre​, scheduled this way from ρ0\rho_0ρ0​.

Hypotheses. The theorem quantifies over the following data:

  • a discount factor γ\gammaγ with 0<γ<10 < \gamma < 10<γ<1;
  • a reward r:S×A→Rr : S \times A \to \mathbb{R}r:S×A→R and a real number rmax⁡r_{\max}rmax​ with ∣r(s,a)∣≤rmax⁡|r(s,a)| \le r_{\max}∣r(s,a)∣≤rmax​ for all s,as, as,a;
  • a distribution ρ0\rho_0ρ0​ on SSS;
  • a natural number kkk, which may be 000;
  • four policies π1pre,π2pre,π1post,π2post\pi_1^{\mathrm{pre}}, \pi_2^{\mathrm{pre}}, \pi_1^{\mathrm{post}}, \pi_2^{\mathrm{post}}π1pre​,π2pre​,π1post​,π2post​;
  • four dynamics P1pre,P2pre,P1post,P2postP_1^{\mathrm{pre}}, P_2^{\mathrm{pre}}, P_1^{\mathrm{post}}, P_2^{\mathrm{post}}P1pre​,P2pre​,P1post​,P2post​;
  • four real numbers ϵmpre,ϵmpost,ϵπpre,ϵπpost\epsilon_m^{\mathrm{pre}}, \epsilon_m^{\mathrm{post}}, \epsilon_\pi^{\mathrm{pre}}, \epsilon_\pi^{\mathrm{post}}ϵmpre​,ϵmpost​,ϵπpre​,ϵπpost​, which are not explicitly required to be nonnegative.

These must satisfy the following conditions:

  1. Pre-phase model error. For every time t≥kt \ge kt≥k:
∑sp1t(s)∑aπ1pre(a∣s) DTV(P1pre(⋅∣s,a) ∥ P2pre(⋅∣s,a))≤ϵmpre.\sum_{s} p_1^t(s) \sum_{a} \pi_1^{\mathrm{pre}}(a \mid s)\, D_{TV}\big(P_1^{\mathrm{pre}}(\cdot \mid s,a) \,\|\, P_2^{\mathrm{pre}}(\cdot \mid s,a)\big) \le \epsilon_m^{\mathrm{pre}}.s∑​p1t​(s)a∑​π1pre​(a∣s)DTV​(P1pre​(⋅∣s,a)∥P2pre​(⋅∣s,a))≤ϵmpre​.
  1. Post-phase model error. For every time t<kt < kt<k:
∑sp1t(s)∑aπ1post(a∣s) DTV(P1post(⋅∣s,a) ∥ P2post(⋅∣s,a))≤ϵmpost.\sum_{s} p_1^t(s) \sum_{a} \pi_1^{\mathrm{post}}(a \mid s)\, D_{TV}\big(P_1^{\mathrm{post}}(\cdot \mid s,a) \,\|\, P_2^{\mathrm{post}}(\cdot \mid s,a)\big) \le \epsilon_m^{\mathrm{post}}.s∑​p1t​(s)a∑​π1post​(a∣s)DTV​(P1post​(⋅∣s,a)∥P2post​(⋅∣s,a))≤ϵmpost​.

This condition is vacuous when k=0k = 0k=0.

  1. Pre-phase policy divergence. For every state sss (a worst-case bound, not an average):
DTV(π1pre(⋅∣s) ∥ π2pre(⋅∣s))≤ϵπpre.D_{TV}\big(\pi_1^{\mathrm{pre}}(\cdot \mid s) \,\|\, \pi_2^{\mathrm{pre}}(\cdot \mid s)\big) \le \epsilon_\pi^{\mathrm{pre}}.DTV​(π1pre​(⋅∣s)∥π2pre​(⋅∣s))≤ϵπpre​.
  1. Post-phase policy divergence. For every state sss:
DTV(π1post(⋅∣s) ∥ π2post(⋅∣s))≤ϵπpost.D_{TV}\big(\pi_1^{\mathrm{post}}(\cdot \mid s) \,\|\, \pi_2^{\mathrm{post}}(\cdot \mid s)\big) \le \epsilon_\pi^{\mathrm{post}}.DTV​(π1post​(⋅∣s)∥π2post​(⋅∣s))≤ϵπpost​.

In conditions 1 and 2, the state weights are always those of process 1, and the actions are always weighted by process 1's policies.

Conclusion. The difference between the two branched returns satisfies

∣ηkbr(π1post,P1post,π1pre,P1pre)−ηkbr(π2post,P2post,π2pre,P2pre)∣≤2rmax⁡[γk+1(1−γ)2(ϵmpre+ϵπpre)+k1−γ(ϵmpost+ϵπpost)+γk1−γ ϵπpre+11−γ ϵπpost].\Big|\eta^{\mathrm{br}}_k(\pi_1^{\mathrm{post}}, P_1^{\mathrm{post}}, \pi_1^{\mathrm{pre}}, P_1^{\mathrm{pre}}) - \eta^{\mathrm{br}}_k(\pi_2^{\mathrm{post}}, P_2^{\mathrm{post}}, \pi_2^{\mathrm{pre}}, P_2^{\mathrm{pre}})\Big| \le 2 r_{\max}\left[\frac{\gamma^{k+1}}{(1-\gamma)^2}(\epsilon_m^{\mathrm{pre}} + \epsilon_\pi^{\mathrm{pre}}) + \frac{k}{1-\gamma}(\epsilon_m^{\mathrm{post}} + \epsilon_\pi^{\mathrm{post}}) + \frac{\gamma^k}{1-\gamma}\,\epsilon_\pi^{\mathrm{pre}} + \frac{1}{1-\gamma}\,\epsilon_\pi^{\mathrm{post}}\right].​ηkbr​(π1post​,P1post​,π1pre​,P1pre​)−ηkbr​(π2post​,P2post​,π2pre​,P2pre​)​≤2rmax​[(1−γ)2γk+1​(ϵmpre​+ϵπpre​)+1−γk​(ϵmpost​+ϵπpost​)+1−γγk​ϵπpre​+1−γ1​ϵπpost​].

Edge cases.

  • Nonempty spaces. Because ρ0\rho_0ρ0​ must have total mass 111, SSS is nonempty. Because each policy must be a distribution on AAA at every state, AAA is nonempty. Consequently rmax⁡≥0r_{\max} \ge 0rmax​≥0, ϵπpre,ϵπpost≥0\epsilon_\pi^{\mathrm{pre}}, \epsilon_\pi^{\mathrm{post}} \ge 0ϵπpre​,ϵπpost​≥0, and ϵmpre≥0\epsilon_m^{\mathrm{pre}} \ge 0ϵmpre​≥0.
  • The case k=0k = 0k=0. The "post" objects never appear in either return. Condition 2 is vacuous, so ϵmpost\epsilon_m^{\mathrm{post}}ϵmpost​ is unconstrained, but its term is multiplied by k=0k = 0k=0. The term 11−γϵπpost\frac{1}{1-\gamma}\epsilon_\pi^{\mathrm{post}}1−γ1​ϵπpost​ still appears in the bound.
  • Summability. Under the hypotheses, every p1tp_1^tp1t​ (and likewise process 2's marginals) is a distribution. Hence ∣Rt∣≤rmax⁡|R_t| \le r_{\max}∣Rt​∣≤rmax​ for every ttt, and both return series converge.
Human review
  • Endorsed by Shuze Chen · Nov 24, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Xeroth · Nov 24, 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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me