Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma B.3 (as proved): returns bound

Proved
WhenToTrustYourModel.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​. Let η1\eta_1η1​ be the return of policy π1\pi_1π1​ under dynamics p1p_1p1​, and η2\eta_2η2​ the return of policy π2\pi_2π2​ under dynamics p2p_2p2​, both started from ρ0\rho_0ρ0​, and let p1tp_1^tp1t​ be the state marginal at time ttt of the first process. Suppose

max⁡tEs∼p1t, a∼π1(⋅∣s)[DTV(p1(⋅∣s,a)∥p2(⋅∣s,a))]≤ϵm,max⁡sDTV(π1(⋅∣s)∥π2(⋅∣s))≤ϵπ.\max_t E_{s\sim p_1^t,\,a\sim\pi_1(\cdot\mid s)}\big[D_{TV}\big(p_1(\cdot\mid s,a)\|p_2(\cdot\mid s,a)\big)\big]\le\epsilon_m,\qquad \max_s D_{TV}\big(\pi_1(\cdot\mid s)\|\pi_2(\cdot\mid s)\big)\le\epsilon_\pi .tmax​Es∼p1t​,a∼π1​(⋅∣s)​[DTV​(p1​(⋅∣s,a)∥p2​(⋅∣s,a))]≤ϵm​,smax​DTV​(π1​(⋅∣s)∥π2​(⋅∣s))≤ϵπ​.

Then

∣η1−η2∣≤2rmax⁡γ(ϵπ+ϵm)(1−γ)2+2rmax⁡ϵπ1−γ.|\eta_1-\eta_2|\le\frac{2r_{\max}\gamma(\epsilon_\pi+\epsilon_m)}{(1-\gamma)^2}+\frac{2r_{\max}\epsilon_\pi}{1-\gamma}.∣η1​−η2​∣≤(1−γ)22rmax​γ(ϵπ​+ϵm​)​+1−γ2rmax​ϵπ​​.

This is the basic simulation bound from which Theorem 4.1 is assembled.

Formalization Note The paper's statement assumes a bound on an expected KL divergence of pi(s′,a∣s)p_i(s',a\mid s)pi​(s′,a∣s), but the proof uses the total variation of the dynamics, through Lemma B.2 with δ=ϵm+ϵπ\delta=\epsilon_m+\epsilon_\piδ=ϵm​+ϵπ​, and that is how the lemma is applied in Theorem A.1. With the KL hypothesis the statement is false. The Lean statement uses the total variation of the dynamics, averaged over s∼p1ts\sim p_1^ts∼p1t​ and a∼π1(⋅∣s)a\sim\pi_1(\cdot\mid s)a∼π1​(⋅∣s), as proved. The paper's constant RRR is rmax⁡r_{\max}rmax​.

Preamble
import Mathlib
import Definitions.Def_WhenToTrustYourModel_Basic

open Finset
Formal statement
namespace WhenToTrustYourModel

theorem 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 ρ₀)
    (π₁ π₂ : S → A → ℝ) (hπ₁ : IsPolicy π₁) (hπ₂ : IsPolicy π₂)
    (P₁ P₂ : S → A → S → ℝ) (hP₁ : IsDynamics P₁) (hP₂ : IsDynamics P₂)
    (εm επ : ℝ)
    (hm : ∀ t, expectedTV (stateDist ρ₀ (fun _ => π₁) (fun _ => P₁) t) π₁ P₁ P₂ ≤ εm)
    (hπ : ∀ s, tvDist (π₁ s) (π₂ s) ≤ επ) :
    |policyReturn γ r ρ₀ π₁ P₁ - policyReturn γ r ρ₀ π₂ P₂| ≤
      2 * rmax * γ * (επ + εm) / (1 - γ) ^ 2 + 2 * rmax * επ / (1 - γ) := 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.3, p. 16
Read-back

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

Fix finite sets SSS (states) and AAA (actions). 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 every xxx and ∑x∈Xμ(x)=1\sum_{x \in X} \mu(x) = 1∑x∈X​μ(x)=1. The total variation distance between any two real functions μ,ν\mu, \nuμ,ν on XXX is

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

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 state sss. 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).

For a policy π\piπ, a dynamics PPP and an initial function ρ0\rho_0ρ0​, the state marginals dπ,Ptd^t_{\pi,P}dπ,Pt​ for t=0,1,2,…t = 0, 1, 2, \dotst=0,1,2,… are defined recursively:

dπ,P0=ρ0,dπ,Pt+1(s′)=∑s∈Sdπ,Pt(s)∑a∈Aπ(a∣s) P(s′∣s,a).d^0_{\pi,P} = \rho_0, \qquad d^{t+1}_{\pi,P}(s') = \sum_{s \in S} d^t_{\pi,P}(s) \sum_{a \in A} \pi(a \mid s)\, P(s' \mid s, a).dπ,P0​=ρ0​,dπ,Pt+1​(s′)=s∈S∑​dπ,Pt​(s)a∈A∑​π(a∣s)P(s′∣s,a).

The return of π\piπ under PPP, with discount γ\gammaγ and reward r:S×A→Rr : S \times A \to \mathbb{R}r:S×A→R, is the infinite series

ηP[π]=∑t=0∞γt∑s∈S∑a∈Adπ,Pt(s) π(a∣s) r(s,a).\eta_P[\pi] = \sum_{t=0}^{\infty} \gamma^t \sum_{s \in S} \sum_{a \in A} d^t_{\pi,P}(s)\, \pi(a \mid s)\, r(s,a).ηP​[π]=t=0∑∞​γts∈S∑​a∈A∑​dπ,Pt​(s)π(a∣s)r(s,a).

This series is taken with the convention that a non-summable series is assigned the value 000.

Hypotheses. The theorem takes the following data and assumptions:

  • a real number γ\gammaγ with 0<γ<10 < \gamma < 10<γ<1;
  • a reward function 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 (nonnegativity of rmax⁡r_{\max}rmax​ is not assumed separately);
  • a distribution ρ0\rho_0ρ0​ on SSS;
  • two policies π1,π2\pi_1, \pi_2π1​,π2​;
  • two dynamics P1,P2P_1, P_2P1​,P2​;
  • real numbers εm,επ\varepsilon_m, \varepsilon_\piεm​,επ​ satisfying the two conditions below.

The model-error condition must hold for every time t∈Nt \in \mathbb{N}t∈N:

∑s∈Sdπ1,P1t(s)∑a∈Aπ1(a∣s) DTV(P1(⋅∣s,a) ∥ P2(⋅∣s,a))≤εm.\sum_{s \in S} d^t_{\pi_1,P_1}(s) \sum_{a \in A} \pi_1(a \mid s)\, D_{\mathrm{TV}}\big(P_1(\cdot \mid s,a) \,\|\, P_2(\cdot \mid s,a)\big) \le \varepsilon_m.s∈S∑​dπ1​,P1​t​(s)a∈A∑​π1​(a∣s)DTV​(P1​(⋅∣s,a)∥P2​(⋅∣s,a))≤εm​.

Here the expectation is taken only over the state marginals of the process run with π1\pi_1π1​ and P1P_1P1​, with actions drawn from π1\pi_1π1​. It is not a worst case over states.

The policy-divergence condition must hold uniformly over every state s∈Ss \in Ss∈S:

DTV(π1(⋅∣s) ∥ π2(⋅∣s))≤επ.D_{\mathrm{TV}}\big(\pi_1(\cdot \mid s) \,\|\, \pi_2(\cdot \mid s)\big) \le \varepsilon_\pi.DTV​(π1​(⋅∣s)∥π2​(⋅∣s))≤επ​.

Edge cases. The total mass condition on ρ0\rho_0ρ0​ cannot hold if SSS is empty, and the policy condition cannot hold if AAA is empty while SSS is nonempty. So the hypotheses force SSS and AAA to be nonempty. That in turn forces rmax⁡≥0r_{\max} \ge 0rmax​≥0. The two conditions above also force εm≥0\varepsilon_m \ge 0εm​≥0 and επ≥0\varepsilon_\pi \ge 0επ​≥0.

Conclusion. The theorem asserts

∣ηP1[π1]−ηP2[π2]∣≤2rmax⁡γ(επ+εm)(1−γ)2+2rmax⁡επ1−γ.\big|\eta_{P_1}[\pi_1] - \eta_{P_2}[\pi_2]\big| \le \frac{2 r_{\max} \gamma (\varepsilon_\pi + \varepsilon_m)}{(1-\gamma)^2} + \frac{2 r_{\max} \varepsilon_\pi}{1-\gamma}.​ηP1​​[π1​]−ηP2​​[π2​]​≤(1−γ)22rmax​γ(επ​+εm​)​+1−γ2rmax​επ​​.
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