Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Finite MDP models, Bellman operators and value equivalence

Definition
ValueEquivalence_Basic

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

bellman-operatorlinear-algebramodel-based-rlreinforcement-learningvalue-equivalence

Objects of Sections 2–4 and Appendix A.1.1 of Grimm, Barreto, Singh and Silver (2020), for finite state and action spaces.

  1. Policies and kernels. SSS and AAA are finite sets. A policy is a map π:S→P(A)\pi:S\to\mathcal P(A)π:S→P(A), written π(a∣s)≥0\pi(a\mid s)\ge0π(a∣s)≥0 with ∑aπ(a∣s)=1\sum_a\pi(a\mid s)=1∑a​π(a∣s)=1, and Π\boldsymbol\PiΠ is the set of all policies. A transition kernel is p(s′∣s,a)≥0p(s'\mid s,a)\ge0p(s′∣s,a)≥0 with ∑s′p(s′∣s,a)=1\sum_{s'}p(s'\mid s,a)=1∑s′​p(s′∣s,a)=1.
  2. Models and Bellman operators (eq. 2). A model is a pair m=(r,p)m=(r,p)m=(r,p) of an expected reward r(s,a)∈Rr(s,a)\in\mathbb Rr(s,a)∈R and a transition kernel ppp. With a discount γ\gammaγ, the Bellman operator of a policy π\piπ induced by mmm acts on v:S→Rv:S\to\mathbb Rv:S→R by
Tπm[v](s)=∑aπ(a∣s)(r(s,a)+γ∑s′p(s′∣s,a) v(s′)).T^m_\pi[v](s)=\sum_a\pi(a\mid s)\Big(r(s,a)+\gamma\sum_{s'}p(s'\mid s,a)\,v(s')\Big).Tπm​[v](s)=a∑​π(a∣s)(r(s,a)+γs′∑​p(s′∣s,a)v(s′)).

The greedy Bellman operator of Appendix A.1.1 is Tmv(s)=max⁡a(r(s,a)+γ∑s′p(s′∣s,a)v(s′))T^m v(s)=\max_a\big(r(s,a)+\gamma\sum_{s'}p(s'\mid s,a)v(s')\big)Tmv(s)=maxa​(r(s,a)+γ∑s′​p(s′∣s,a)v(s′)). 3. Value equivalence (Definitions 1, 2). For a set of policies Π\PiΠ and a set of functions V⊆V={v:S→R}\mathcal V\subseteq\mathbb V=\{v:S\to\mathbb R\}V⊆V={v:S→R}, models m,m~m,\tilde mm,m~ are value equivalent with respect to Π,V\Pi,\mathcal VΠ,V if Tπmv=Tπm~vT^m_\pi v=T^{\tilde m}_\pi vTπm​v=Tπm~​v for all π∈Π\pi\in\Piπ∈Π, v∈Vv\in\mathcal Vv∈V. For a set of models M\mathcal MM and the true model m∗m^*m∗, M(Π,V)\mathcal M(\Pi,\mathcal V)M(Π,V) is the set of models in M\mathcal MM value equivalent to m∗m^*m∗. 4. Pointwise span (eq. 3). For a set H\mathcal HH of functions on XXX with values in a vector space, g∈p-span(H)g\in p\text{-span}(\mathcal H)g∈p-span(H) iff g(x)∈span⁡{h(x):h∈H}g(x)\in\operatorname{span}\{h(x):h\in\mathcal H\}g(x)∈span{h(x):h∈H} for every xxx. For policies, x=sx=sx=s and h(x)=π(⋅∣s)∈RAh(x)=\pi(\cdot\mid s)\in\mathbb R^Ah(x)=π(⋅∣s)∈RA. 5. Value-equivalent kernels. With the reward r∗r^*r∗ of m∗m^*m∗ known, P(Π,V)\mathcal P(\Pi,\mathcal V)P(Π,V) is the set of kernels p~\tilde pp~​ in a class P\mathcal PP such that (r∗,p~)(r^*,\tilde p)(r∗,p~​) is value equivalent to m∗m^*m∗; P(Π,V)\mathbb P(\Pi,\mathcal V)P(Π,V) is the case where P\mathcal PP is the set of all kernels. 6. Dimension of a set (Section 3.2). For a subset X\mathcal XX of a finite-dimensional real vector space, dim⁡[X]=min⁡{dim⁡W:W a subspace, X+c⊆W for some c}\dim[\mathcal X]=\min\{\dim\mathcal W:\mathcal W\text{ a subspace},\ \mathcal X+c\subseteq\mathcal W\text{ for some }c\}dim[X]=min{dimW:W a subspace, X+c⊆W for some c}. For matrices A∈Rk×n\boldsymbol A\in\mathbb R^{k\times n}A∈Rk×n, C∈Rm×ℓ\boldsymbol C\in\mathbb R^{m\times\ell}C∈Rm×ℓ, B={B∈Rn×m:ABC=0}\mathcal B=\{\boldsymbol B\in\mathbb R^{n\times m}:\boldsymbol A\boldsymbol B\boldsymbol C=0\}B={B∈Rn×m:ABC=0} is the space of Lemma 1. 7. Maximum-likelihood loss (eq. 5). For a distribution DDD on S×AS\times AS×A, ℓp,D(p,p~)=∑s,aD(s,a) DKL(p(⋅∣s,a) ∥ p~(⋅∣s,a))\ell_{p,D}(p,\tilde p)=\sum_{s,a}D(s,a)\,D_{\mathrm{KL}}\big(p(\cdot\mid s,a)\,\|\,\tilde p(\cdot\mid s,a)\big)ℓp,D​(p,p~​)=∑s,a​D(s,a)DKL​(p(⋅∣s,a)∥p~​(⋅∣s,a)), with DKL(q∥q′)=∑s′q(s′)log⁡q(s′)q′(s′)D_{\mathrm{KL}}(q\|q')=\sum_{s'}q(s')\log\frac{q(s')}{q'(s')}DKL​(q∥q′)=∑s′​q(s′)logq′(s′)q(s′)​, terms with q(s′)=0q(s')=0q(s′)=0 equal to 000, and value +∞+\infty+∞ if q′(s′)=0<q(s′)q'(s')=0<q(s')q′(s′)=0<q(s′) for some s′s's′.

Formalization Note The paper states Sections 2–3.1 for general state and action spaces; here SSS and AAA are finite types, as in the paper's Section 3.2 from Proposition 2 on. A model carries the proof that ppp is a transition kernel. The Bellman operator is defined for any π:S×A→R\pi:S\times A\to\mathbb Rπ:S×A→R, so that it can be evaluated on pointwise combinations of policies. The dimension uses finrank⁡\operatorname{finrank}finrank of subspaces, which is the Hamel dimension in finite dimensions. The loss takes values in the extended reals.

Definition code
import Mathlib

/-!
Grimm, Barreto, Singh and Silver, *The Value Equivalence Principle for Model-Based Reinforcement
Learning*, arXiv:2011.03506v1 (NeurIPS 2020): finite Markov decision processes, models and their
Bellman operators (Section 2), value equivalence and spaces of value-equivalent models
(Section 3, Definitions 1 and 2), pointwise span (eq. (3)), the dimension `dim[·]` of a set of
transition matrices (Section 3.1), the maximum-likelihood loss (eq. (5)) and the greedy Bellman
operator of Appendix A.1.1. State and action spaces are finite, as in Section 3.1 from
Proposition 2 on.
-/

noncomputable section

namespace ValueEquivalence

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

/-- Section 2, p. 2: `p` is a transition kernel, i.e. `p(·|s,a)` (written `p s a`) is a
probability distribution on the finite state space `S` for every state `s` and action `a`. -/
def IsTransitionKernel (p : S → A → S → ℝ) : Prop :=
  (∀ s a s', 0 ≤ p s a s') ∧ ∀ s a, ∑ s', p s a s' = 1

/-- Section 2, p. 2: a policy `π : S → 𝒫(A)`, written `π s a = π(a|s)`. -/
def IsPolicy (π : S → A → ℝ) : Prop :=
  (∀ s a, 0 ≤ π s a) ∧ ∀ s, ∑ a, π s a = 1

/-- Section 2, p. 2: the set `𝚷` of all policies. -/
def policies : Set (S → A → ℝ) := {π | IsPolicy π}

/-- Section 3, p. 3 (and Section 3.1, p. 5, for finite `S`, `A`): a model `m = (r, p)`, an
expected reward `r(s,a)` together with a transition kernel `p(s'|s,a)`. -/
structure Model (S A : Type*) [Fintype S] where
  /-- the expected reward `r(s,a)` -/
  r : S → A → ℝ
  /-- the transition kernel, `p s a s' = p(s'|s,a)` -/
  p : S → A → S → ℝ
  /-- `p` is a transition kernel -/
  isKernel : IsTransitionKernel p

/-- Eq. (2), p. 2: the Bellman operator of policy `π` induced by model `m` and discount `γ`,
`T_π[v](s) = E_{A∼π(·|s), S'∼p(·|s,A)}[r(s,A) + γ v(S')]`. -/
def bellman (m : Model S A) (γ : ℝ) (π : S → A → ℝ) (v : S → ℝ) : S → ℝ :=
  fun s => ∑ a, π s a * (m.r s a + γ * ∑ s', m.p s a s' * v s')

/-- Definition 1, p. 3: models `m` and `m'` are value equivalent with respect to a set of policies
`Pol` and a set of functions `V` if `T_π v = T'_π v` for all `π ∈ Pol` and all `v ∈ V`. -/
def IsValueEquivalent (γ : ℝ) (Pol : Set (S → A → ℝ)) (V : Set (S → ℝ)) (m m' : Model S A) :
    Prop :=
  ∀ π ∈ Pol, ∀ v ∈ V, bellman m γ π v = bellman m' γ π v

/-- Definition 2, p. 3: the space `M_m(Pol, V) ⊆ M` of models in `M` that are value equivalent to
`m` with respect to `Pol` and `V`. With `m = m*` the true model this is `M(Pol, V)`. -/
def veSpace (γ : ℝ) (M : Set (Model S A)) (m : Model S A) (Pol : Set (S → A → ℝ))
    (V : Set (S → ℝ)) : Set (Model S A) :=
  {m' | m' ∈ M ∧ IsValueEquivalent γ Pol V m m'}

/-- Eq. (3), p. 4: the pointwise span of a set `H` of functions on `X`, in the equivalent form
stated right after eq. (3): `g ∈ p-span(H)` iff `g(x) ∈ span {h(x) : h ∈ H}` for every `x`.
For policies, `X = S` and `h(x) = π(·|s) ∈ ℝ^A`. -/
def pspan {X W : Type*} [AddCommGroup W] [Module ℝ W] (H : Set (X → W)) : Set (X → W) :=
  {g | ∀ x, g x ∈ Submodule.span ℝ ((fun h => h x) '' H)}

/-- Section 3.1, p. 5: the set `ℙ(Pol, V)` (for `PP` the set of all transition kernels) or
`𝒫(Pol, V)` (Section 4, p. 5, for a class `PP` of kernels) of transition kernels in `PP` that,
with the known reward `r*` of the true model `m*`, are value equivalent to `m*`. -/
def veKernels (γ : ℝ) (mstar : Model S A) (PP : Set (S → A → S → ℝ)) (Pol : Set (S → A → ℝ))
    (V : Set (S → ℝ)) : Set (S → A → S → ℝ) :=
  Model.p '' veSpace γ {m | m.r = mstar.r ∧ m.p ∈ PP} mstar Pol V

/-- Section 3.1, p. 5: the dimension of a set `X`, the least Hamel dimension of a vector space
`W` containing a translate `X + c`: `dim[X] = min_{(W, c) : X + c ⊆ W} H-dim[W]`. Used on
finite-dimensional real spaces, where the Hamel dimension is `Module.finrank`. -/
def setDim {E : Type*} [AddCommGroup E] [Module ℝ E] [FiniteDimensional ℝ E] (X : Set E) : ℕ :=
  sInf {d | ∃ (W : Submodule ℝ E) (c : E),
    (fun x => x + c) '' X ⊆ (W : Set E) ∧ Module.finrank ℝ W = d}

/-- Lemma 1, p. 14: for `A ∈ ℝ^{k×n}` and `C ∈ ℝ^{m×l}`, the vector space
`𝓑 = {B ∈ ℝ^{n×m} : A B C = 0}`. -/
def twoSidedKernel {k n m l : ℕ} (A : Matrix (Fin k) (Fin n) ℝ) (C : Matrix (Fin m) (Fin l) ℝ) :
    Submodule ℝ (Matrix (Fin n) (Fin m) ℝ) where
  carrier := {B | A * B * C = 0}
  add_mem' := by
    intro B B' hB hB'
    change A * B * C = 0 at hB
    change A * B' * C = 0 at hB'
    show A * (B + B') * C = 0
    rw [Matrix.mul_add, Matrix.add_mul, hB, hB', add_zero]
  zero_mem' := by simp
  smul_mem' := by
    intro c B hB
    change A * B * C = 0 at hB
    show A * (c • B) * C = 0
    rw [Matrix.mul_smul, Matrix.smul_mul, hB, smul_zero]

/-- Eq. (5), p. 5: the Kullback–Leibler divergence `D_KL(q ‖ q')` of two distributions on the
finite set `S`, `∑_s q(s) log (q(s)/q'(s))`, with `0 log(0/·) = 0` and value `+∞` when
`q'(s) = 0 < q(s)` for some `s`. -/
def klDivFin (q q' : S → ℝ) : EReal :=
  ∑ s, if q s = 0 then 0 else if q' s = 0 then ⊤ else ((q s * Real.log (q s / q' s) : ℝ) : EReal)

/-- Eq. (5), p. 5: the maximum-likelihood loss
`ℓ_{p,D}(p, p') = E_{(S,A)∼D}[D_KL(p(·|S,A) ‖ p'(·|S,A))]` for a distribution `D` on `S × A`. -/
def mleLoss (D : S → A → ℝ) (p p' : S → A → S → ℝ) : EReal :=
  ∑ s, ∑ a, ((D s a : ℝ) : EReal) * klDivFin (p s a) (p' s a)

/-- Appendix A.1.1, proof of Proposition 4, p. 16: the greedy Bellman operator
`T v = max_a T_a v` of model `m`, where `T_a` is the Bellman operator of the policy that always
selects action `a` (meaningful for nonempty `A`). -/
def bellmanOpt (m : Model S A) (γ : ℝ) (v : S → ℝ) : S → ℝ :=
  fun s => ⨆ a, (m.r s a + γ * ∑ s', m.p s a s' * v s')

end ValueEquivalence
Source
Grimm, Barreto, Singh and Silver, The Value Equivalence Principle for Model-Based Reinforcement Learning, arXiv:2011.03506v1 (2020), Sections 2, 3 (Definitions 1-2, eq. (3), Section 3.2), 4 (eq. (5)) and Appendix A.1.1
Read-back

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

Common setting. Throughout, SSS (states) and AAA (actions) are arbitrary finite sets. Either may be empty. All functions below are real-valued unless stated otherwise.


IsTransitionKernel (transition kernel). Let p:S×A×S→Rp : S \times A \times S \to \mathbb{R}p:S×A×S→R, with p(s,a,s′)p(s,a,s')p(s,a,s′) written p(s′∣s,a)p(s' \mid s,a)p(s′∣s,a). Then ppp is a transition kernel exactly when both of these hold:

  • p(s′∣s,a)≥0p(s' \mid s,a) \ge 0p(s′∣s,a)≥0 for all s,s′∈Ss, s' \in Ss,s′∈S and a∈Aa \in Aa∈A;
  • ∑s′∈Sp(s′∣s,a)=1\sum_{s' \in S} p(s' \mid s,a) = 1∑s′∈S​p(s′∣s,a)=1 for every s∈Ss \in Ss∈S and a∈Aa \in Aa∈A.

Edge cases: if SSS is empty or AAA is empty, both conditions are vacuous, so every such ppp qualifies.


IsPolicy (policy). Let π:S×A→R\pi : S \times A \to \mathbb{R}π:S×A→R, with π(s,a)\pi(s,a)π(s,a) written π(a∣s)\pi(a \mid s)π(a∣s). Then π\piπ is a policy exactly when both of these hold:

  • π(a∣s)≥0\pi(a \mid s) \ge 0π(a∣s)≥0 for all s∈Ss \in Ss∈S and a∈Aa \in Aa∈A;
  • ∑a∈Aπ(a∣s)=1\sum_{a \in A} \pi(a \mid s) = 1∑a∈A​π(a∣s)=1 for every s∈Ss \in Ss∈S.

Edge cases:

  • If SSS is empty, the unique (empty) function is a policy.
  • If SSS is nonempty and AAA is empty, the sum is 0≠10 \neq 10=1, so no policy exists.

policies (the set Π\PiΠ). Π\PiΠ is the set of all functions π:S×A→R\pi : S \times A \to \mathbb{R}π:S×A→R that are policies in the above sense:

Π={π∣π(a∣s)≥0 ∀s,a,  ∑aπ(a∣s)=1 ∀s}.\Pi = \{\pi \mid \pi(a\mid s)\ge 0\ \forall s,a,\ \ \textstyle\sum_{a}\pi(a\mid s)=1\ \forall s\}.Π={π∣π(a∣s)≥0 ∀s,a,  ∑a​π(a∣s)=1 ∀s}.

Model (a model m=(r,p)m = (r,p)m=(r,p)). A model consists of three pieces of data:

  • a reward function r:S×A→Rr : S \times A \to \mathbb{R}r:S×A→R, which is arbitrary (no boundedness or sign condition);
  • a function p:S×A×S→Rp : S \times A \times S \to \mathbb{R}p:S×A×S→R, written p(s′∣s,a)p(s' \mid s,a)p(s′∣s,a);
  • a proof that ppp is a transition kernel, meaning it is nonnegative and ∑s′p(s′∣s,a)=1\sum_{s'} p(s' \mid s,a) = 1∑s′​p(s′∣s,a)=1 for all s,as, as,a.

No other constraint is imposed.


bellman (Bellman operator TπmT^m_\piTπm​). The inputs are:

  • a model m=(r,p)m = (r,p)m=(r,p);
  • a real number γ\gammaγ, which is arbitrary: it is not restricted to [0,1)[0,1)[0,1) and may be negative or ≥1\ge 1≥1;
  • a function π:S×A→R\pi : S \times A \to \mathbb{R}π:S×A→R, which is not required to be a policy;
  • a function v:S→Rv : S \to \mathbb{R}v:S→R.

The output is the function Tπmv:S→RT^m_\pi v : S \to \mathbb{R}Tπm​v:S→R given by

(Tπmv)(s)=∑a∈Aπ(a∣s)(r(s,a)+γ∑s′∈Sp(s′∣s,a) v(s′)).(T^m_\pi v)(s) = \sum_{a \in A} \pi(a\mid s)\Big( r(s,a) + \gamma \sum_{s' \in S} p(s'\mid s,a)\, v(s') \Big).(Tπm​v)(s)=a∈A∑​π(a∣s)(r(s,a)+γs′∈S∑​p(s′∣s,a)v(s′)).

If AAA is empty, this is 000 at every state.


IsValueEquivalent (value equivalence). The inputs are:

  • a real number γ\gammaγ (arbitrary);
  • a set P\mathcal{P}P of functions S×A→RS \times A \to \mathbb{R}S×A→R, which need not be policies;
  • a set V\mathcal{V}V of functions S→RS \to \mathbb{R}S→R;
  • two models m=(r,p)m = (r,p)m=(r,p) and m′=(r′,p′)m' = (r',p')m′=(r′,p′).

Then mmm and m′m'm′ are value equivalent when

Tπmv=Tπm′v(as functions on S) for every π∈P and every v∈V.T^{m}_\pi v = T^{m'}_\pi v \quad \text{(as functions on } S\text{) for every } \pi \in \mathcal{P} \text{ and every } v \in \mathcal{V}.Tπm​v=Tπm′​v(as functions on S) for every π∈P and every v∈V.

Here TTT is the Bellman operator above with the same γ\gammaγ, so the condition reads, for all sss:

∑aπ(a∣s)(r(s,a)+γ∑s′p(s′∣s,a)v(s′))=∑aπ(a∣s)(r′(s,a)+γ∑s′p′(s′∣s,a)v(s′)).\sum_a \pi(a\mid s)\big(r(s,a)+\gamma\sum_{s'}p(s'\mid s,a)v(s')\big) = \sum_a \pi(a\mid s)\big(r'(s,a)+\gamma\sum_{s'}p'(s'\mid s,a)v(s')\big).a∑​π(a∣s)(r(s,a)+γs′∑​p(s′∣s,a)v(s′))=a∑​π(a∣s)(r′(s,a)+γs′∑​p′(s′∣s,a)v(s′)).

If P\mathcal{P}P or V\mathcal{V}V is empty, the condition holds vacuously for any two models.


veSpace (space Mm(P,V)\mathcal{M}_m(\mathcal{P},\mathcal{V})Mm​(P,V)). The inputs are:

  • a real γ\gammaγ;
  • a set M\mathcal{M}M of models;
  • a reference model mmm;
  • a set P\mathcal{P}P of functions S×A→RS\times A\to\mathbb{R}S×A→R;
  • a set V\mathcal{V}V of functions S→RS\to\mathbb{R}S→R.

The space is

Mm(P,V)={ m′∈M  :  Tπmv=Tπm′v for all π∈P, v∈V }.\mathcal{M}_m(\mathcal{P},\mathcal{V}) = \{\, m' \in \mathcal{M} \;:\; T^{m}_\pi v = T^{m'}_\pi v \text{ for all } \pi\in\mathcal{P},\ v\in\mathcal{V} \,\}.Mm​(P,V)={m′∈M:Tπm​v=Tπm′​v for all π∈P, v∈V}.

The Bellman operators use the given γ\gammaγ. The reference model mmm itself need not belong to M\mathcal{M}M. If P\mathcal{P}P or V\mathcal{V}V is empty, the space equals M\mathcal{M}M.


pspan (pointwise span). Let XXX be any set and WWW any real vector space. For a set HHH of functions X→WX \to WX→W, the pointwise span is

p-span⁡(H)={ g:X→W  :  g(x)∈span⁡R{h(x):h∈H} for every x∈X }.\operatorname{p\text{-}span}(H) = \{\, g : X \to W \;:\; g(x) \in \operatorname{span}_{\mathbb{R}}\{h(x) : h \in H\} \text{ for every } x \in X \,\}.p-span(H)={g:X→W:g(x)∈spanR​{h(x):h∈H} for every x∈X}.

Here span⁡R\operatorname{span}_{\mathbb{R}}spanR​ denotes finite real linear combinations. The combination may depend on xxx; there is no single choice of coefficients for all xxx.

Edge cases:

  • If HHH is empty, each pointwise span is {0}\{0\}{0}, so only the zero function belongs.
  • If XXX is empty, every function (the empty one) belongs.

veKernels (value-equivalent kernels P(P,V)\mathbb{P}(\mathcal{P},\mathcal{V})P(P,V)). The inputs are:

  • a real γ\gammaγ;
  • a reference model m∗=(r∗,p∗)m^* = (r^*, p^*)m∗=(r∗,p∗);
  • a set K\mathcal{K}K of functions S×A×S→RS\times A\times S\to\mathbb{R}S×A×S→R, which need not consist of kernels;
  • a set P\mathcal{P}P of functions S×A→RS\times A\to\mathbb{R}S×A→R;
  • a set V\mathcal{V}V of functions S→RS\to\mathbb{R}S→R.

The output is the set of p:S×A×S→Rp : S\times A\times S\to\mathbb{R}p:S×A×S→R satisfying all three of:

  1. p∈Kp \in \mathcal{K}p∈K;
  2. ppp is a transition kernel (nonnegative, with ∑s′p(s′∣s,a)=1\sum_{s'}p(s'\mid s,a)=1∑s′​p(s′∣s,a)=1 for all s,as,as,a);
  3. the model (r∗,p)(r^*, p)(r∗,p) is value equivalent to m∗m^*m∗, meaning for all π∈P\pi\in\mathcal{P}π∈P, v∈Vv\in\mathcal{V}v∈V and s∈Ss\in Ss∈S:
∑aπ(a∣s) γ∑s′p(s′∣s,a) v(s′)=∑aπ(a∣s) γ∑s′p∗(s′∣s,a) v(s′).\sum_a \pi(a\mid s)\,\gamma\sum_{s'}p(s'\mid s,a)\,v(s') = \sum_a \pi(a\mid s)\,\gamma\sum_{s'}p^*(s'\mid s,a)\,v(s').a∑​π(a∣s)γs′∑​p(s′∣s,a)v(s′)=a∑​π(a∣s)γs′∑​p∗(s′∣s,a)v(s′).

The reward terms cancel because both models use r∗r^*r∗. Elements of K\mathcal{K}K that are not transition kernels are excluded. If γ=0\gamma = 0γ=0, condition 3 holds automatically.


setDim (dimension dim⁡[X]\dim[X]dim[X]). Let EEE be a finite-dimensional real vector space and X⊆EX \subseteq EX⊆E. Then dim⁡[X]\dim[X]dim[X] is the natural number

dim⁡[X]=min⁡{ dim⁡W  :  W a linear subspace of E, c∈E, X+c⊆W },X+c={x+c:x∈X}.\dim[X] = \min\{\, \dim W \;:\; W \text{ a linear subspace of } E,\ c \in E,\ X + c \subseteq W \,\}, \qquad X + c = \{x + c : x\in X\}.dim[X]=min{dimW:W a linear subspace of E, c∈E, X+c⊆W},X+c={x+c:x∈X}.

The defining set always contains dim⁡E\dim EdimE (take W=EW = EW=E, c=0c = 0c=0), so the minimum is attained. If XXX is empty, or a single point, then dim⁡[X]=0\dim[X] = 0dim[X]=0.


twoSidedKernel (the space B\mathcal{B}B). Fix natural numbers k,n,m,lk,n,m,lk,n,m,l, any of which may be 000. Let AAA be a real k×nk\times nk×n matrix; this AAA is unrelated to the action set. Let CCC be a real m×lm\times lm×l matrix. Then

B={ B∈Rn×m  :  A B C=0∈Rk×l },\mathcal{B} = \{\, B \in \mathbb{R}^{n\times m} \;:\; A\,B\,C = 0 \in \mathbb{R}^{k\times l} \,\},B={B∈Rn×m:ABC=0∈Rk×l},

regarded as a linear subspace of Rn×m\mathbb{R}^{n\times m}Rn×m. It contains 000 and is closed under addition and real scalar multiplication.


klDivFin (KL divergence DKL(q ∥ q′)D_{\mathrm{KL}}(q\,\|\,q')DKL​(q∥q′)). Let q,q′:S→Rq, q' : S\to\mathbb{R}q,q′:S→R be arbitrary functions. They are not required to be nonnegative or to sum to 111. The value lies in the extended reals [−∞,+∞][-\infty,+\infty][−∞,+∞]:

DKL(q ∥ q′)=∑s∈S{0if q(s)=0,+∞if q(s)≠0 and q′(s)=0,q(s) log⁡ ⁣(q(s)/q′(s))otherwise.D_{\mathrm{KL}}(q\,\|\,q') = \sum_{s\in S} \begin{cases} 0 & \text{if } q(s) = 0,\\ +\infty & \text{if } q(s)\neq 0 \text{ and } q'(s)=0,\\ q(s)\,\log\!\big(q(s)/q'(s)\big) & \text{otherwise.}\end{cases}DKL​(q∥q′)=s∈S∑​⎩⎨⎧​0+∞q(s)log(q(s)/q′(s))​if q(s)=0,if q(s)=0 and q′(s)=0,otherwise.​

Edge cases:

  • The +∞+\infty+∞ case is triggered by q(s)≠0q(s)\neq 0q(s)=0, which includes negative q(s)q(s)q(s), not only q(s)>0q(s) > 0q(s)>0.
  • The logarithm is the total real function log⁡x=log⁡∣x∣\log x = \log|x|logx=log∣x∣ for x≠0x\neq 0x=0. So if q(s)/q′(s)<0q(s)/q'(s) < 0q(s)/q′(s)<0, the term is q(s)log⁡∣q(s)/q′(s)∣q(s)\log|q(s)/q'(s)|q(s)log∣q(s)/q′(s)∣.
  • No term is −∞-\infty−∞. Hence the sum is +∞+\infty+∞ if any term is +∞+\infty+∞, and is the finite real sum otherwise.
  • If SSS is empty, the value is 000.

mleLoss (maximum-likelihood loss ℓD(p,p′)\ell_D(p,p')ℓD​(p,p′)). The inputs are:

  • a function D:S×A→RD : S\times A\to\mathbb{R}D:S×A→R, which is not required to be nonnegative or to sum to 111;
  • two functions p,p′:S×A×S→Rp, p' : S\times A\times S\to\mathbb{R}p,p′:S×A×S→R, which are not required to be transition kernels.

The loss is the extended real

ℓD(p,p′)=∑s∈S∑a∈AD(s,a)⋅DKL(p(⋅∣s,a) ∥ p′(⋅∣s,a)).\ell_D(p,p') = \sum_{s\in S}\sum_{a\in A} D(s,a)\cdot D_{\mathrm{KL}}\big(p(\cdot\mid s,a)\,\big\|\,p'(\cdot\mid s,a)\big).ℓD​(p,p′)=s∈S∑​a∈A∑​D(s,a)⋅DKL​(p(⋅∣s,a)​p′(⋅∣s,a)).

Here DKLD_{\mathrm{KL}}DKL​ is the divergence defined above, applied to s′↦p(s′∣s,a)s' \mapsto p(s'\mid s,a)s′↦p(s′∣s,a) and s′↦p′(s′∣s,a)s'\mapsto p'(s'\mid s,a)s′↦p′(s′∣s,a). Arithmetic is in [−∞,+∞][-\infty,+\infty][−∞,+∞] with these conventions:

  • 0⋅(+∞)=00\cdot(+\infty) = 00⋅(+∞)=0, so pairs with D(s,a)=0D(s,a)=0D(s,a)=0 contribute 000 even when their divergence is infinite;
  • a negative D(s,a)D(s,a)D(s,a) times +∞+\infty+∞ gives −∞-\infty−∞;
  • in the sum, −∞-\infty−∞ absorbs everything, including (+∞)+(−∞)=−∞(+\infty) + (-\infty) = -\infty(+∞)+(−∞)=−∞.

If SSS or AAA is empty, the loss is 000.


bellmanOpt (greedy Bellman operator TmT^mTm). The inputs are a model m=(r,p)m=(r,p)m=(r,p), a real γ\gammaγ (arbitrary), and v:S→Rv : S\to\mathbb{R}v:S→R. The output is

(Tmv)(s)=sup⁡a∈A(r(s,a)+γ∑s′∈Sp(s′∣s,a) v(s′)),(T^m v)(s) = \sup_{a\in A}\Big( r(s,a) + \gamma \sum_{s'\in S} p(s'\mid s,a)\, v(s') \Big),(Tmv)(s)=a∈Asup​(r(s,a)+γs′∈S∑​p(s′∣s,a)v(s′)),

where the supremum is taken in the real numbers. Since AAA is finite, this is the maximum over aaa when AAA is nonempty. When AAA is empty, the real supremum of the empty family is by convention 000, so (Tmv)(s)=0(T^m v)(s) = 0(Tmv)(s)=0 for every sss.

Human review
  • Endorsed by Shuze Chen · Nov 23, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Xeroth · Nov 23, 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