Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Model-based RL: values, discounted state distributions, model discrepancy and policy distances

Definition
MBRLGuarantees_Basic

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

chi-square-divergencediscrepancy-boundsmarkov-decision-processesmodel-based-rlreinforcement-learning

Objects of Sections 2-4 and Appendices A, D.1 and E of Luo, Xu, Li, Tian, Darrell and Ma (arXiv:1807.03858v5).

  1. Markov decision process. States lie in a measurable space S\mathcal SS and actions in a measurable space A\mathcal AA. A policy π(⋅∣s)\pi(\cdot\mid s)π(⋅∣s) is a Markov kernel from S\mathcal SS to A\mathcal AA, and a dynamical model M(⋅∣s,a)M(\cdot\mid s,a)M(⋅∣s,a) is a Markov kernel from S×A\mathcal S\times\mathcal AS×A to S\mathcal SS; a deterministic model M(s,a)M(s,a)M(s,a) is the kernel δM(s,a)\delta_{M(s,a)}δM(s,a)​. The reward R(s,a)R(s,a)R(s,a) is known, γ\gammaγ is the discount factor, S0∼μ0S_0\sim\mu_0S0​∼μ0​, and κ=γ(1−γ)−1\kappa=\gamma(1-\gamma)^{-1}κ=γ(1−γ)−1.
  2. Transition kernels. Pπ,M(⋅∣s)=∫M(⋅∣s,a) π(da∣s)P_{\pi,M}(\cdot\mid s)=\int M(\cdot\mid s,a)\,\pi(da\mid s)Pπ,M​(⋅∣s)=∫M(⋅∣s,a)π(da∣s) is the state-to-state kernel of π\piπ on MMM, and PtP^tPt is its ttt-step kernel (P0=IdP^0=\mathrm{Id}P0=Id).
  3. Values (eq. 2.1). Vπ,M(s)=∑t≥0γt E[R(St,At)∣S0=s]V^{\pi,M}(s)=\sum_{t\ge0}\gamma^t\,\mathbb E[R(S_t,A_t)\mid S_0=s]Vπ,M(s)=∑t≥0​γtE[R(St​,At​)∣S0​=s] with At∼π(⋅∣St)A_t\sim\pi(\cdot\mid S_t)At​∼π(⋅∣St​), St+1∼M(⋅∣St,At)S_{t+1}\sim M(\cdot\mid S_t,A_t)St+1​∼M(⋅∣St​,At​), and Vπ,M=ES0∼μ0Vπ,M(S0)V^{\pi,M}=\mathbb E_{S_0\sim\mu_0}V^{\pi,M}(S_0)Vπ,M=ES0​∼μ0​​Vπ,M(S0​).
  4. Discounted state distributions. For a kernel PPP and a distribution μ\muμ, Gˉμ=(1−γ)∑t≥0γtPtμ\bar G\mu=(1-\gamma)\sum_{t\ge0}\gamma^tP^t\muGˉμ=(1−γ)∑t≥0​γtPtμ. ρπ,M=Gˉμ0\rho^{\pi,M}=\bar G\mu_0ρπ,M=Gˉμ0​ for P=Pπ,MP=P_{\pi,M}P=Pπ,M​ (Definition 2.1), and βπ=(1−γ)2∑t≥1tγt−1Ptμ0\beta^{\pi}=(1-\gamma)^2\sum_{t\ge1}t\gamma^{t-1}P^t\mu_0βπ=(1−γ)2∑t≥1​tγt−1Ptμ0​ (Definition A.1); the paper writes ρπ,βπ\rho^\pi,\beta^\piρπ,βπ for the true model M⋆M^\starM⋆.
  5. Model discrepancy (eq. 4.5). Gπ,M^(s,a)=Es^′∼M^(⋅∣s,a)Vπ,M^(s^′)−Es′∼M(⋅∣s,a)Vπ,M^(s′)G^{\pi,\widehat M}(s,a)=\mathbb E_{\hat s'\sim\widehat M(\cdot\mid s,a)}V^{\pi,\widehat M}(\hat s')-\mathbb E_{s'\sim M(\cdot\mid s,a)}V^{\pi,\widehat M}(s')Gπ,M(s,a)=Es^′∼M(⋅∣s,a)​Vπ,M(s^′)−Es′∼M(⋅∣s,a)​Vπ,M(s′) against a reference model MMM (M=M⋆M=M^\starM=M⋆ in Section 4.2), and Gπ,M^(s)=EA∼π(⋅∣s)Gπ,M^(s,A)G^{\pi,\widehat M}(s)=\mathbb E_{A\sim\pi(\cdot\mid s)}G^{\pi,\widehat M}(s,A)Gπ,M(s)=EA∼π(⋅∣s)​Gπ,M(s,A).
  6. Discrepancy bounds. ε1=ES∼ρπref∣Gπ,M^(S)∣\varepsilon_1=\mathbb E_{S\sim\rho^{\pi_{\mathrm{ref}}}}|G^{\pi,\widehat M}(S)|ε1​=ES∼ρπref​​∣Gπ,M(S)∣, εmax⁡=sup⁡S∣Gπ,M^(S)∣\varepsilon_{\max}=\sup_S|G^{\pi,\widehat M}(S)|εmax​=supS​∣Gπ,M(S)∣, ε2=ES∼βπrefGπ,M^(S)2\varepsilon_2=\mathbb E_{S\sim\beta^{\pi_{\mathrm{ref}}}}G^{\pi,\widehat M}(S)^2ε2​=ES∼βπref​​Gπ,M(S)2, and Dπref,δG(M^,π)=κε1+κ2δεmax⁡D^G_{\pi_{\mathrm{ref}},\delta}(\widehat M,\pi)=\kappa\varepsilon_1+\kappa^2\delta\varepsilon_{\max}Dπref​,δG​(M,π)=κε1​+κ2δεmax​ (eq. 4.7).
  7. Divergences. KL\mathrm{KL}KL is the Kullback-Leibler divergence. χ2(p,q)=∫(p−q)2/q\chi^2(p,q)=\int(p-q)^2/qχ2(p,q)=∫(p−q)2/q is the Neyman χ2\chi^2χ2 distance (Definition E.1), equal to +∞+\infty+∞ unless p≪qp\ll qp≪q, and χμ2(P′,P)=∫χ2(P′(⋅∣x),P(⋅∣x)) μ(dx)\chi^2_\mu(P',P)=\int\chi^2(P'(\cdot\mid x),P(\cdot\mid x))\,\mu(dx)χμ2​(P′,P)=∫χ2(P′(⋅∣x),P(⋅∣x))μ(dx) (Definition E.3). ∣ρ−ρ′∣1=sup⁡{∫f dρ−∫f dρ′:f measurable,∣f∣≤1}|\rho-\rho'|_1=\sup\{\int f\,d\rho-\int f\,d\rho' : f \text{ measurable}, |f|\le1\}∣ρ−ρ′∣1​=sup{∫fdρ−∫fdρ′:f measurable,∣f∣≤1}.
  8. Policy distances. dKL(π,πref)=ES∼ρπ[KL(π(⋅∣S),πref(⋅∣S))1/2]d^{\mathrm{KL}}(\pi,\pi_{\mathrm{ref}})=\mathbb E_{S\sim\rho^\pi}\big[\mathrm{KL}(\pi(\cdot\mid S),\pi_{\mathrm{ref}}(\cdot\mid S))^{1/2}\big]dKL(π,πref​)=ES∼ρπ​[KL(π(⋅∣S),πref​(⋅∣S))1/2] (eq. 4.3) and dχ2(π,πref)=max⁡{ES∼ρπrefχ2(π(⋅∣S),πref(⋅∣S)), ES∼βπrefχ2(π(⋅∣S),πref(⋅∣S))}d^{\chi^2}(\pi,\pi_{\mathrm{ref}})=\max\{\mathbb E_{S\sim\rho^{\pi_{\mathrm{ref}}}}\chi^2(\pi(\cdot\mid S),\pi_{\mathrm{ref}}(\cdot\mid S)),\ \mathbb E_{S\sim\beta^{\pi_{\mathrm{ref}}}}\chi^2(\pi(\cdot\mid S),\pi_{\mathrm{ref}}(\cdot\mid S))\}dχ2(π,πref​)=max{ES∼ρπref​​χ2(π(⋅∣S),πref​(⋅∣S)), ES∼βπref​​χ2(π(⋅∣S),πref​(⋅∣S))} (eq. A.1).

Formalization Note The value function is written as the discounted sum of the expected rewards at each step, computed from the ttt-step kernels; for a bounded measurable reward this equals the paper's expectation of the discounted sum over trajectories. Divergences, ∣⋅∣1|\cdot|_1∣⋅∣1​ and the policy distances take values in [0,∞][0,\infty][0,∞]. ε1\varepsilon_1ε1​ and ε2\varepsilon_2ε2​ use Gπ,M^(S)G^{\pi,\widehat M}(S)Gπ,M(S), as in the proofs of Propositions 4.4 and A.2.

Definition code
import Mathlib

/-!
Luo, Xu, Li, Tian, Darrell and Ma, *Algorithmic Framework for Model-based Deep Reinforcement
Learning with Theoretical Guarantees*, arXiv:1807.03858v5 (ICLR 2019): the value functions,
discounted state distributions, model discrepancy `G`, discrepancy bounds and policy distances of
Sections 2-4, Appendix A, Appendix D.1 and Appendix E.

States and actions live in arbitrary measurable spaces `S`, `A`. A policy `π(· | s)` is a kernel
`Kernel S A` and a dynamical model `M(· | s, a)` is a kernel `Kernel (S × A) S`; statements assume
them to be Markov kernels. The reward `R : S × A → ℝ` is known.
-/

open MeasureTheory ProbabilityTheory InformationTheory
open scoped ENNReal

noncomputable section

namespace MBRLGuarantees

variable {S A : Type*} [MeasurableSpace S] [MeasurableSpace A]

/-- Section 2: `κ = γ (1 - γ)⁻¹`, the constant the paper fixes "throughout the paper". -/
def kappa (γ : ℝ) : ℝ := γ / (1 - γ)

/-- Section 2: the state-to-state transition kernel of a policy `π` on a model `M`,
`s ↦ ∫ M(· | s, a) π(da | s)`, the law of `S_{t+1}` given `S_t = s`
(Appendix D.1 calls it "the transition kernel induced by some policy `π`"). -/
def stateKernel (pi : Kernel S A) (M : Kernel (S × A) S) : Kernel S S :=
  Kernel.snd (pi ⊗ₖ M)

/-- The `t`-step kernel `P^t` of a transition kernel `P` on the state space (`P^0 = Id`);
`P^t(· | s)` is the law of `S_t` given `S_0 = s` (Section 2, Appendix D.1). -/
def iterKernel (P : Kernel S S) : ℕ → Kernel S S
  | 0 => Kernel.id
  | n + 1 => P ∘ₖ iterKernel P n

/-- Appendix D.1: `Ḡμ = (1 - γ) ∑_{t ≥ 0} γ^t P^t μ`, the discounted distribution of the states
visited by the Markov chain with transition kernel `P` started from the distribution `μ`. -/
def discOcc (γ : ℝ) (P : Kernel S S) (μ : Measure S) : Measure S :=
  ENNReal.ofReal (1 - γ) • Measure.sum fun t : ℕ => ENNReal.ofReal (γ ^ t) • μ.bind (iterKernel P t)

/-- Definition A.1 (written for a general chain): `(1 - γ)² ∑_{t ≥ 1} t γ^{t-1} P^t μ`. -/
def reweightedOcc (γ : ℝ) (P : Kernel S S) (μ : Measure S) : Measure S :=
  ENNReal.ofReal ((1 - γ) ^ 2) • Measure.sum fun t : ℕ =>
    ENNReal.ofReal (((t : ℝ) + 1) * γ ^ t) • μ.bind (iterKernel P (t + 1))

/-- Section 2: the expected one-step reward `E_{a ∼ π(·|s)} R(s, a)` of policy `π` at state `s`. -/
def expReward (R : S × A → ℝ) (pi : Kernel S A) (s : S) : ℝ :=
  ∫ a, R (s, a) ∂(pi s)

/-- Section 2, eq. (2.1): the value function
`V^{π,M}(s) = E[∑_{t ≥ 0} γ^t R(S_t, A_t) | S_0 = s]` with `A_t ∼ π(· | S_t)` and
`S_{t+1} ∼ M(· | S_t, A_t)`, written as `∑_t γ^t E[R(S_t, A_t) | S_0 = s]`. -/
def stateValue (γ : ℝ) (R : S × A → ℝ) (pi : Kernel S A) (M : Kernel (S × A) S) (s : S) : ℝ :=
  ∑' t : ℕ, γ ^ t * ∫ s', expReward R pi s' ∂(iterKernel (stateKernel pi M) t s)

/-- Section 2: `V^{π,M} = E[V^{π,M}(S_0)]`, the expected reward-to-go averaged over the initial
state `S_0 ∼ μ₀`. -/
def value (γ : ℝ) (R : S × A → ℝ) (μ₀ : Measure S) (pi : Kernel S A) (M : Kernel (S × A) S) : ℝ :=
  ∫ s, stateValue γ R pi M s ∂μ₀

/-- Definition 2.1: `ρ^{π,M} = (1 - γ) ∑_{t ≥ 0} γ^t p_{S_t^{π,M}}`, the discounted distribution
of the states visited by `π` on `M` from `S_0 ∼ μ₀`; `ρ^π` is `ρ^{π,M⋆}`. -/
def occ (γ : ℝ) (μ₀ : Measure S) (pi : Kernel S A) (M : Kernel (S × A) S) : Measure S :=
  discOcc γ (stateKernel pi M) μ₀

/-- Definition A.1: `β^{π} = (1 - γ)² ∑_{t ≥ 1} t γ^{t-1} p_{S_t^π}`, the re-weighted discounted
state distribution of `π` on the model `M` (the paper takes `M = M⋆`). -/
def beta (γ : ℝ) (μ₀ : Measure S) (pi : Kernel S A) (M : Kernel (S × A) S) : Measure S :=
  reweightedOcc γ (stateKernel pi M) μ₀

/-- Section 4.1, eq. (4.5): `G^{π,M̂}(s, a) = E_{ŝ' ∼ M̂(·|s,a)} V^{π,M̂}(ŝ') - E_{s' ∼ M(·|s,a)} V^{π,M̂}(s')`,
the one-step discrepancy of the model `M̂` against the reference model `M` (the paper's `M = M⋆`;
Lemma 4.3 uses a general `M`). -/
def gapFn (γ : ℝ) (R : S × A → ℝ) (pi : Kernel S A) (Mhat M : Kernel (S × A) S) (s : S) (a : A) :
    ℝ :=
  (∫ s', stateValue γ R pi Mhat s' ∂(Mhat (s, a))) - ∫ s', stateValue γ R pi Mhat s' ∂(M (s, a))

/-- Section 4.2: `G^{π,M̂}(s) = E_{A ∼ π(·|s)} G^{π,M̂}(s, A)`. -/
def gapState (γ : ℝ) (R : S × A → ℝ) (pi : Kernel S A) (Mhat M : Kernel (S × A) S) (s : S) : ℝ :=
  ∫ a, gapFn γ R pi Mhat M s a ∂(pi s)

/-- Section 4.2, display before eq. (4.7): `ε₁ = E_{S ∼ ρ^{π_ref}} |G^{π,M̂}(S)|` (the form used in the proof of
Proposition 4.4, Appendix C.1). -/
def epsOne (γ : ℝ) (R : S × A → ℝ) (μ₀ : Measure S) (Mstar : Kernel (S × A) S)
    (piref pi : Kernel S A) (Mhat : Kernel (S × A) S) : ℝ :=
  ∫ s, |gapState γ R pi Mhat Mstar s| ∂(occ γ μ₀ piref Mstar)

/-- Section 4.2, display before eq. (4.7): `ε_max = max_S |G^{π,M̂}(S)|`. -/
def epsMax (γ : ℝ) (R : S × A → ℝ) (Mstar : Kernel (S × A) S) (pi : Kernel S A)
    (Mhat : Kernel (S × A) S) : ℝ :=
  ⨆ s, |gapState γ R pi Mhat Mstar s|

/-- Appendix A, after eq. (A.2): `ε₂ = E_{S ∼ β^{π_ref}} [G^{π,M̂}(S)²]` (the form used in the
proof of Proposition A.2, Appendix C.2). -/
def epsTwo (γ : ℝ) (R : S × A → ℝ) (μ₀ : Measure S) (Mstar : Kernel (S × A) S)
    (piref pi : Kernel S A) (Mhat : Kernel (S × A) S) : ℝ :=
  ∫ s, gapState γ R pi Mhat Mstar s ^ 2 ∂(beta γ μ₀ piref Mstar)

/-- Section 4.2, eq. (4.7): `D^G_{π_ref,δ}(M̂, π) = κ ε₁ + κ² δ ε_max`. -/
def discG (γ : ℝ) (R : S × A → ℝ) (μ₀ : Measure S) (Mstar : Kernel (S × A) S) (δ : ℝ)
    (piref : Kernel S A) (Mhat : Kernel (S × A) S) (pi : Kernel S A) : ℝ :=
  kappa γ * epsOne γ R μ₀ Mstar piref pi Mhat + kappa γ ^ 2 * δ * epsMax γ R Mstar pi Mhat

/-- Section 4.1, eq. (4.3): `d^{KL}(π, π_ref) = E_{S ∼ ρ^π} [KL(π(·|S), π_ref(·|S))^{1/2}]`,
with `ρ^π` the discounted state distribution of `π` on the true model `M⋆`. -/
def dKL (γ : ℝ) (μ₀ : Measure S) (Mstar : Kernel (S × A) S) (pi piref : Kernel S A) : ℝ≥0∞ :=
  ∫⁻ s, klDiv (pi s) (piref s) ^ (1 / 2 : ℝ) ∂(occ γ μ₀ pi Mstar)

open Classical in
/-- Definition E.1: the Neyman `χ²` distance `χ²(p, q) = ∫ (p(x) - q(x))² / q(x) dx`, equal to
`∫ (dp/dq - 1)² dq` when `p ≪ q` and to `+∞` otherwise. -/
def chiSq {X : Type*} [MeasurableSpace X] (p q : Measure X) : ℝ≥0∞ :=
  if p ≪ q then ∫⁻ x, ENNReal.ofReal (((p.rnDeriv q x).toReal - 1) ^ 2) ∂q else ∞

/-- Definition E.3: `χ²_μ(P', P) = ∫ μ(x) χ²(P'(·|x), P(·|x)) dx`, the `χ²` distance between two
transition kernels measured with respect to the distribution `μ`. -/
def chiSqTrans {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] (μ : Measure X)
    (P' P : Kernel X Y) : ℝ≥0∞ :=
  ∫⁻ x, chiSq (P' x) (P x) ∂μ

/-- Appendix A, eq. (A.1): `d^{χ²}(π, π_ref) = max { E_{S ∼ ρ^{π_ref}} χ²(π(·|S), π_ref(·|S)),
E_{S ∼ β^{π_ref}} χ²(π(·|S), π_ref(·|S)) }`, with `ρ^{π_ref}`, `β^{π_ref}` taken on `M⋆`. -/
def dChi (γ : ℝ) (μ₀ : Measure S) (Mstar : Kernel (S × A) S) (pi piref : Kernel S A) : ℝ≥0∞ :=
  max (chiSqTrans (occ γ μ₀ piref Mstar) pi piref) (chiSqTrans (beta γ μ₀ piref Mstar) pi piref)

/-- The `ℓ₁` distance `|ρ - ρ'|₁` between two finite measures (Appendix C.3, Claim E.6,
Corollary E.7), in its dual form `sup { ∫ f dρ - ∫ f dρ' : f measurable, |f| ≤ 1 }`. -/
def lOneDist {X : Type*} [MeasurableSpace X] (ρ ρ' : Measure X) : ℝ≥0∞ :=
  ⨆ (f : X → ℝ) (_ : Measurable f) (_ : ∀ x, |f x| ≤ 1),
    ENNReal.ofReal ((∫ x, f x ∂ρ) - ∫ x, f x ∂ρ')

end MBRLGuarantees
Source
Luo, Xu, Li, Tian, Darrell and Ma, Algorithmic Framework for Model-based Deep Reinforcement Learning with Theoretical Guarantees, arXiv:1807.03858v5 (ICLR 2019), Section 2 (eq. (2.1), Definition 2.1), Section 4 (eqs. (4.3), (4.5), (4.7)), Appendix A (Definition A.1, eqs. (A.1)-(A.2)), Appendix D.1, Appendix E (Definitions E.1, E.3)
Read-back

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

Throughout, SSS (states) and AAA (actions) are arbitrary measurable spaces. A policy π\piπ is a measurable kernel from SSS to AAA, written π(⋅∣s)\pi(\cdot\mid s)π(⋅∣s). A model MMM is a measurable kernel from S×AS\times AS×A to SSS, written M(⋅∣s,a)M(\cdot\mid s,a)M(⋅∣s,a). A reward R:S×A→RR:S\times A\to\mathbb RR:S×A→R is an arbitrary real function. None of the definitions below assume any of the following:

  • that kernels are Markov (probability-valued), or even finite;
  • that RRR is measurable, bounded or integrable;
  • that the initial measure μ0\mu_0μ0​ on SSS is a probability measure;
  • that the discount γ∈R\gamma\in\mathbb Rγ∈R lies in [0,1)[0,1)[0,1).

Two junk-value conventions recur below:

  • A real-valued (Bochner) integral of a non-integrable function is 000.
  • A real infinite series ∑t\sum_t∑t​ that is not unconditionally summable is 000.

kappa. For a real number γ\gammaγ,

κ(γ)=γ1−γ,\kappa(\gamma)=\frac{\gamma}{1-\gamma},κ(γ)=1−γγ​,

with real division, so at γ=1\gamma=1γ=1 the value is 000 (division by zero gives 000).


stateKernel. Given a policy π\piπ and a model MMM, this is the kernel Pπ,MP_{\pi,M}Pπ,M​ from SSS to SSS defined by

Pπ,M(B∣s)=∫AM(B∣s,a) π(da∣s).P_{\pi,M}(B\mid s)=\int_A M(B\mid s,a)\,\pi(da\mid s).Pπ,M​(B∣s)=∫A​M(B∣s,a)π(da∣s).

It is formed as the SSS-marginal of the composition-product of π\piπ and MMM. In the underlying library, the composition-product is defined to be the zero kernel unless both π\piπ and MMM are s-finite kernels, in which case Pπ,MP_{\pi,M}Pπ,M​ is identically the zero measure.


iterKernel. For a kernel PPP from SSS to SSS and t∈Nt\in\mathbb Nt∈N, PtP^tPt is defined recursively:

  • P0(⋅∣s)=δsP^0(\cdot\mid s)=\delta_sP0(⋅∣s)=δs​, the Dirac mass at sss;
  • Pt+1(B∣s)=∫SP(B∣s′) Pt(ds′∣s)P^{t+1}(B\mid s)=\int_S P(B\mid s')\,P^t(ds'\mid s)Pt+1(B∣s)=∫S​P(B∣s′)Pt(ds′∣s), that is, first apply PtP^tPt and then one more step of PPP.

discOcc. For γ∈R\gamma\in\mathbb Rγ∈R, a kernel PPP on SSS and a measure μ\muμ on SSS, this is the measure

Gˉγ,P μ=(1−γ)+∑t=0∞(γt)+ (μPt),(μPt)(B)=∫SPt(B∣s) μ(ds).\bar G_{\gamma,P}\,\mu=(1-\gamma)^+\sum_{t=0}^{\infty}(\gamma^t)^+\,(\mu P^t),\qquad (\mu P^t)(B)=\int_S P^t(B\mid s)\,\mu(ds).Gˉγ,P​μ=(1−γ)+t=0∑∞​(γt)+(μPt),(μPt)(B)=∫S​Pt(B∣s)μ(ds).

Here x+=max⁡(x,0)x^+=\max(x,0)x+=max(x,0), since the real coefficients are converted to nonnegative extended reals by truncating negatives to 000. The sum is a countable sum of measures and may assign infinite mass. Edge cases:

  • If γ≥1\gamma\ge 1γ≥1, the prefactor is 000 and the result is the zero measure.
  • If γ<0\gamma<0γ<0, every odd-ttt term is dropped.
  • If γ=0\gamma=0γ=0, the result is μP0=μ\mu P^0=\muμP0=μ, using 00=10^0=100=1.

reweightedOcc. For γ,P,μ\gamma,P,\muγ,P,μ as above,

βγ,P μ=(1−γ)2∑t=0∞((t+1)γt)+ (μPt+1),\beta_{\gamma,P}\,\mu=(1-\gamma)^2\sum_{t=0}^{\infty}\big((t+1)\gamma^t\big)^+\,(\mu P^{t+1}),βγ,P​μ=(1−γ)2t=0∑∞​((t+1)γt)+(μPt+1),

equivalently (1−γ)2∑t≥1(tγt−1)+ μPt(1-\gamma)^2\sum_{t\ge1}(t\gamma^{t-1})^+\,\mu P^t(1−γ)2∑t≥1​(tγt−1)+μPt. Edge cases:

  • The prefactor (1−γ)2(1-\gamma)^2(1−γ)2 is always nonnegative, so it is not truncated. For γ=1\gamma=1γ=1 the result is the zero measure. For γ>1\gamma>1γ>1 it is a positive multiple of a sum with growing coefficients, which may be infinite.
  • For γ<0\gamma<0γ<0, terms with odd ttt are dropped.

expReward. For RRR, π\piπ and s∈Ss\in Ss∈S,

rπ(s)=∫AR(s,a) π(da∣s),r_\pi(s)=\int_A R(s,a)\,\pi(da\mid s),rπ​(s)=∫A​R(s,a)π(da∣s),

which is 000 if a↦R(s,a)a\mapsto R(s,a)a↦R(s,a) is not π(⋅∣s)\pi(\cdot\mid s)π(⋅∣s)-integrable.


stateValue. For γ,R,π,M\gamma,R,\pi,Mγ,R,π,M and s∈Ss\in Ss∈S,

Vπ,M(s)=∑t=0∞γt∫Srπ(s′) Pπ,Mt(ds′∣s).V^{\pi,M}(s)=\sum_{t=0}^{\infty}\gamma^t\int_S r_\pi(s')\,P_{\pi,M}^t(ds'\mid s).Vπ,M(s)=t=0∑∞​γt∫S​rπ​(s′)Pπ,Mt​(ds′∣s).

Here rπr_\pirπ​ is expReward and Pπ,MtP_{\pi,M}^tPπ,Mt​ is the ttt-step iterate of stateKernel. Each integral is 000 if not integrable. The whole series is 000 if it is not unconditionally summable.


value. For an initial measure μ0\mu_0μ0​ on SSS,

Vπ,M=∫SVπ,M(s) μ0(ds),V^{\pi,M}=\int_S V^{\pi,M}(s)\,\mu_0(ds),Vπ,M=∫S​Vπ,M(s)μ0​(ds),

which is 000 if Vπ,MV^{\pi,M}Vπ,M is not μ0\mu_0μ0​-integrable. μ0\mu_0μ0​ is any measure, not necessarily a probability.


occ. The measure on SSS given by

ρπ,M=Gˉγ,Pπ,M μ0=(1−γ)+∑t≥0(γt)+ μ0Pπ,Mt,\rho^{\pi,M}=\bar G_{\gamma,P_{\pi,M}}\,\mu_0=(1-\gamma)^+\sum_{t\ge0}(\gamma^t)^+\,\mu_0P_{\pi,M}^t,ρπ,M=Gˉγ,Pπ,M​​μ0​=(1−γ)+t≥0∑​(γt)+μ0​Pπ,Mt​,

with all the edge cases of discOcc.


beta. The measure on SSS given by

βπ,M=βγ,Pπ,M μ0=(1−γ)2∑t≥0((t+1)γt)+ μ0Pπ,Mt+1,\beta^{\pi,M}=\beta_{\gamma,P_{\pi,M}}\,\mu_0=(1-\gamma)^2\sum_{t\ge0}\big((t+1)\gamma^t\big)^+\,\mu_0P_{\pi,M}^{t+1},βπ,M=βγ,Pπ,M​​μ0​=(1−γ)2t≥0∑​((t+1)γt)+μ0​Pπ,Mt+1​,

with all the edge cases of reweightedOcc. Here MMM is an arbitrary model.


gapFn. For a policy π\piπ, two models M^\hat MM^ and MMM, s∈Ss\in Ss∈S and a∈Aa\in Aa∈A,

GMπ,M^(s,a)=∫SVπ,M^(s′) M^(ds′∣s,a)−∫SVπ,M^(s′) M(ds′∣s,a).G^{\pi,\hat M}_M(s,a)=\int_S V^{\pi,\hat M}(s')\,\hat M(ds'\mid s,a)-\int_S V^{\pi,\hat M}(s')\,M(ds'\mid s,a).GMπ,M^​(s,a)=∫S​Vπ,M^(s′)M^(ds′∣s,a)−∫S​Vπ,M^(s′)M(ds′∣s,a).

In both integrals the integrand is the value function computed in the model M^\hat MM^; only the integrating measure differs. Each integral is 000 if not integrable.


gapState. The policy average of gapFn:

GMπ,M^(s)=∫AGMπ,M^(s,a) π(da∣s),G^{\pi,\hat M}_M(s)=\int_A G^{\pi,\hat M}_M(s,a)\,\pi(da\mid s),GMπ,M^​(s)=∫A​GMπ,M^​(s,a)π(da∣s),

which is 000 if not integrable.


epsOne. Given a "true" model M⋆M^\starM⋆, a reference policy πref\pi_{\mathrm{ref}}πref​, a policy π\piπ and a model M^\hat MM^,

ε1=∫S∣GM⋆π,M^(s)∣ ρπref,M⋆(ds).\varepsilon_1=\int_S\big|G^{\pi,\hat M}_{M^\star}(s)\big|\,\rho^{\pi_{\mathrm{ref}},M^\star}(ds).ε1​=∫S​​GM⋆π,M^​(s)​ρπref​,M⋆(ds).

This is a real-valued integral, equal to 000 if not integrable. It is also 000 whenever ρπref,M⋆\rho^{\pi_{\mathrm{ref}},M^\star}ρπref​,M⋆ is the zero measure, for example when γ≥1\gamma\ge1γ≥1.


epsMax. The real supremum

εmax⁡=sup⁡s∈S∣GM⋆π,M^(s)∣.\varepsilon_{\max}=\sup_{s\in S}\big|G^{\pi,\hat M}_{M^\star}(s)\big|.εmax​=s∈Ssup​​GM⋆π,M^​(s)​.

It is a supremum, not an attained maximum. By the library's convention for real suprema, it equals 000 if these values are unbounded above or if SSS is empty.


epsTwo. The real-valued integral

ε2=∫S(GM⋆π,M^(s))2 βπref,M⋆(ds),\varepsilon_2=\int_S\big(G^{\pi,\hat M}_{M^\star}(s)\big)^2\,\beta^{\pi_{\mathrm{ref}},M^\star}(ds),ε2​=∫S​(GM⋆π,M^​(s))2βπref​,M⋆(ds),

which is 000 if not integrable.


discG. For an additional real parameter δ\deltaδ, which is unrestricted in sign,

Dπref,δG(M^,π)=κ(γ) ε1+κ(γ)2 δ εmax⁡.D^G_{\pi_{\mathrm{ref}},\delta}(\hat M,\pi)=\kappa(\gamma)\,\varepsilon_1+\kappa(\gamma)^2\,\delta\,\varepsilon_{\max}.Dπref​,δG​(M^,π)=κ(γ)ε1​+κ(γ)2δεmax​.

Here ε1\varepsilon_1ε1​ is computed with (μ0,M⋆,πref,π,M^)(\mu_0,M^\star,\pi_{\mathrm{ref}},\pi,\hat M)(μ0​,M⋆,πref​,π,M^) and εmax⁡\varepsilon_{\max}εmax​ with (M⋆,π,M^)(M^\star,\pi,\hat M)(M⋆,π,M^).


dKL. The extended-nonnegative quantity

dKL(π,πref)=∫SKL(π(⋅∣s) ∥ πref(⋅∣s))1/2 ρπ,M⋆(ds)∈[0,∞].d^{KL}(\pi,\pi_{\mathrm{ref}})=\int_S \mathrm{KL}\big(\pi(\cdot\mid s)\,\|\,\pi_{\mathrm{ref}}(\cdot\mid s)\big)^{1/2}\,\rho^{\pi,M^\star}(ds)\in[0,\infty].dKL(π,πref​)=∫S​KL(π(⋅∣s)∥πref​(⋅∣s))1/2ρπ,M⋆(ds)∈[0,∞].

Points to note:

  • The state distribution is the occupancy of π\piπ itself, not of πref\pi_{\mathrm{ref}}πref​, on M⋆M^\starM⋆.
  • KL(p∥q)\mathrm{KL}(p\|q)KL(p∥q) is the library's divergence. It equals +∞+\infty+∞ unless p≪qp\ll qp≪q and the log-likelihood ratio log⁡dpdq\log\frac{dp}{dq}logdqdp​ is ppp-integrable. Otherwise it equals ∫log⁡dpdq dp+q(A)−p(A)\int\log\frac{dp}{dq}\,dp+q(A)-p(A)∫logdqdp​dp+q(A)−p(A), clipped at 000, which is the usual KL divergence for probability measures.
  • The square root of ∞\infty∞ is ∞\infty∞.

chiSq. For measures p,qp,qp,q on a measurable space XXX:

χ2(p,q)={∫X(dpdq(x)−1)2 q(dx)if p≪q,+∞otherwise.\chi^2(p,q)=\begin{cases}\displaystyle\int_X\Big(\tfrac{dp}{dq}(x)-1\Big)^2\,q(dx) & \text{if } p\ll q,\\[1ex] +\infty & \text{otherwise.}\end{cases}χ2(p,q)=⎩⎨⎧​∫X​(dqdp​(x)−1)2q(dx)+∞​if p≪q,otherwise.​

Three details:

  • The integral is taken against qqq, not normalised, and p,qp,qp,q need not be probability measures.
  • At points where the Radon–Nikodym derivative is +∞+\infty+∞ it is read as 000, so the integrand there is 111.
  • The library's Radon–Nikodym derivative is the zero function when ppp has no Lebesgue decomposition with respect to qqq, for instance in non-σ-finite situations.

chiSqTrans. For a measure μ\muμ on XXX and kernels P′,PP',PP′,P from XXX to YYY,

χμ2(P′,P)=∫Xχ2(P′(⋅∣x),P(⋅∣x)) μ(dx)∈[0,∞].\chi^2_\mu(P',P)=\int_X\chi^2\big(P'(\cdot\mid x),P(\cdot\mid x)\big)\,\mu(dx)\in[0,\infty].χμ2​(P′,P)=∫X​χ2(P′(⋅∣x),P(⋅∣x))μ(dx)∈[0,∞].

dChi. The quantity

dχ2(π,πref)=max⁡{χρπref,M⋆2(π,πref),  χβπref,M⋆2(π,πref)}∈[0,∞].d^{\chi^2}(\pi,\pi_{\mathrm{ref}})=\max\Big\{\chi^2_{\rho^{\pi_{\mathrm{ref}},M^\star}}(\pi,\pi_{\mathrm{ref}}),\;\chi^2_{\beta^{\pi_{\mathrm{ref}},M^\star}}(\pi,\pi_{\mathrm{ref}})\Big\}\in[0,\infty].dχ2(π,πref​)=max{χρπref​,M⋆2​(π,πref​),χβπref​,M⋆2​(π,πref​)}∈[0,∞].

Both state distributions are those of πref\pi_{\mathrm{ref}}πref​ on M⋆M^\starM⋆.


lOneDist. For measures ρ,ρ′\rho,\rho'ρ,ρ′ on XXX, which are not assumed finite,

∣ρ−ρ′∣1=sup⁡{(∫Xf dρ−∫Xf dρ′)+  :  f:X→R measurable, ∣f(x)∣≤1 for all x}∈[0,∞].|\rho-\rho'|_1=\sup\Big\{\Big(\int_X f\,d\rho-\int_X f\,d\rho'\Big)^+ \;:\; f:X\to\mathbb R \text{ measurable},\ |f(x)|\le1\ \text{for all } x\Big\}\in[0,\infty].∣ρ−ρ′∣1​=sup{(∫X​fdρ−∫X​fdρ′)+:f:X→R measurable, ∣f(x)∣≤1 for all x}∈[0,∞].

Each integral is a real integral, equal to 000 if not integrable, which can happen when ρ\rhoρ or ρ′\rho'ρ′ has infinite mass. Since f=0f=0f=0 is admissible, the supremum is always at least 000.

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