Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Finite MDPs, bisimulation metrics, aggregation and causal ancestors (Deep Bisimulation for Control)

Definition
DeepBisimulationControl_Basic

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

bisimulation-metricmarkov-decision-processreinforcement-learningstate-aggregationwasserstein-distance

Objects of Sections 3-5 and Appendix A of Zhang, McAllister, Calandra, Gal and Levine (2021), on finite Markov decision processes.

  1. MDP. A finite state space S\mathcal SS, a finite nonempty action space A\mathcal AA, transition probabilities P(s′∣s,a)≥0\mathcal P(s'\mid s,a)\ge0P(s′∣s,a)≥0 with ∑s′P(s′∣s,a)=1\sum_{s'}\mathcal P(s'\mid s,a)=1∑s′​P(s′∣s,a)=1, rewards R(s,a)∈R\mathcal R(s,a)\in\mathbb RR(s,a)∈R and a discount factor γ∈[0,1)\gamma\in[0,1)γ∈[0,1).
  2. Policies and values. A policy π(a∣s)\pi(a\mid s)π(a∣s) is a probability distribution on actions for each state; a deterministic policy σ:S→A\sigma:\mathcal S\to\mathcal Aσ:S→A plays σ(s)\sigma(s)σ(s) with probability one. With rsπ=∑aπ(a∣s)R(s,a)r^\pi_s=\sum_a\pi(a\mid s)\mathcal R(s,a)rsπ​=∑a​π(a∣s)R(s,a) and Psπ(s′)=∑aπ(a∣s)P(s′∣s,a)\mathcal P^\pi_s(s')=\sum_a\pi(a\mid s)\mathcal P(s'\mid s,a)Psπ​(s′)=∑a​π(a∣s)P(s′∣s,a), the value of π\piπ is Vπ=∑n≥0γn(Pπ)nrπV^\pi=\sum_{n\ge0}\gamma^n(\mathcal P^\pi)^n r^\piVπ=∑n≥0​γn(Pπ)nrπ, the optimal value is V∗(s)=sup⁡πVπ(s)V^*(s)=\sup_\pi V^\pi(s)V∗(s)=supπ​Vπ(s), and π\piπ is optimal if Vπ=V∗V^\pi=V^*Vπ=V∗. The action value is Qπ(s,a)=R(s,a)+γ∑s′P(s′∣s,a)Vπ(s′)Q^\pi(s,a)=\mathcal R(s,a)+\gamma\sum_{s'}\mathcal P(s'\mid s,a)V^\pi(s')Qπ(s,a)=R(s,a)+γ∑s′​P(s′∣s,a)Vπ(s′).
  3. Policy iteration. A sequence of deterministic policies σ0,σ1,…\sigma_0,\sigma_1,\dotsσ0​,σ1​,… with σk+1(s)∈arg⁡max⁡aQσk(s,a)\sigma_{k+1}(s)\in\arg\max_aQ^{\sigma_k}(s,a)σk+1​(s)∈argmaxa​Qσk​(s,a), keeping σk+1(s)=σk(s)\sigma_{k+1}(s)=\sigma_k(s)σk+1​(s)=σk​(s) whenever σk(s)\sigma_k(s)σk​(s) is a maximiser.
  4. Wasserstein distance. For distributions μ,ν\mu,\nuμ,ν on S\mathcal SS and a cost ddd, W1(μ,ν;d)=inf⁡γ′∈Γ(μ,ν)∑x,yγ′(x,y)d(x,y)W_1(\mu,\nu;d)=\inf_{\gamma'\in\Gamma(\mu,\nu)}\sum_{x,y}\gamma'(x,y)d(x,y)W1​(μ,ν;d)=infγ′∈Γ(μ,ν)​∑x,y​γ′(x,y)d(x,y), the infimum over couplings. A pseudometric is a nonnegative symmetric function with d(s,s)=0d(s,s)=0d(s,s)=0 satisfying the triangle inequality.
  5. Bisimulation metric (Definition 2). For c∈[0,1)c\in[0,1)c∈[0,1), F(d)(si,sj)=max⁡a(1−c)∣R(si,a)−R(sj,a)∣+c W1(P(⋅∣si,a),P(⋅∣sj,a);d)F(d)(s_i,s_j)=\max_a(1-c)|\mathcal R(s_i,a)-\mathcal R(s_j,a)|+c\,W_1(\mathcal P(\cdot\mid s_i,a),\mathcal P(\cdot\mid s_j,a);d)F(d)(si​,sj​)=maxa​(1−c)∣R(si​,a)−R(sj​,a)∣+cW1​(P(⋅∣si​,a),P(⋅∣sj​,a);d), and the bisimulation metric is d~=sup⁡nFn(0)\tilde d=\sup_nF^n(0)d~=supn​Fn(0).
  6. On-policy metric (Theorem 1). F(d,π)(si,sj)=(1−c)∣rsiπ−rsjπ∣+c W1(Psiπ,Psjπ;d)F(d,\pi)(s_i,s_j)=(1-c)|r^\pi_{s_i}-r^\pi_{s_j}|+c\,W_1(\mathcal P^\pi_{s_i},\mathcal P^\pi_{s_j};d)F(d,π)(si​,sj​)=(1−c)∣rsi​π​−rsj​π​∣+cW1​(Psi​π​,Psj​π​;d) and the π\piπ-bisimulation metric is sup⁡nF(⋅,π)n(0)\sup_nF(\cdot,\pi)^n(0)supn​F(⋅,π)n(0). Along policy iteration the metric iterates are d0=0d_0=0d0​=0, dn+1=F(dn,σn)d_{n+1}=F(d_n,\sigma_n)dn+1​=F(dn​,σn​).
  7. Aggregation (Theorem 2). A map ϕ:S→C\phi:\mathcal S\to Cϕ:S→C onto a finite set of clusters defines the aggregated MDP with averaged transitions Pˉ(k′∣k,a)=1∣k∣∑s∈k∑s′∈k′P(s′∣s,a)\bar{\mathcal P}(k'\mid k,a)=\frac1{|k|}\sum_{s\in k}\sum_{s'\in k'}\mathcal P(s'\mid s,a)Pˉ(k′∣k,a)=∣k∣1​∑s∈k​∑s′∈k′​P(s′∣s,a) and averaged rewards Rˉ(k,a)=1∣k∣∑s∈kR(s,a)\bar{\mathcal R}(k,a)=\frac1{|k|}\sum_{s\in k}\mathcal R(s,a)Rˉ(k,a)=∣k∣1​∑s∈k​R(s,a). The average in-cluster distance is g(s,d)=1∣ϕ(s)∣∑s′∈ϕ(s)d(s,s′)g(s,d)=\frac1{|\phi(s)|}\sum_{s'\in\phi(s)}d(s,s')g(s,d)=∣ϕ(s)∣1​∑s′∈ϕ(s)​d(s,s′). The aggregation is an ε\varepsilonε-aggregation for ddd if every cluster lies within distance ε\varepsilonε of some state.
  8. Representations. ∥x−y∥1=∑i∣xi−yi∣\|x-y\|_1=\sum_i|x_i-y_i|∥x−y∥1​=∑i​∣xi​−yi​∣ on Rm\mathbb R^mRm; the learning error of an encoder ψ:S→Rm\psi:\mathcal S\to\mathbb R^mψ:S→Rm is L=sup⁡si,sj∣∥ψ(si)−ψ(sj)∥1−d~(si,sj)∣\mathcal L=\sup_{s_i,s_j}\big|\|\psi(s_i)-\psi(s_j)\|_1-\tilde d(s_i,s_j)\big|L=supsi​,sj​​​∥ψ(si​)−ψ(sj​)∥1​−d~(si​,sj​)​.
  9. Factored MDPs and causal ancestors (Definition 3, Theorem 4). The state is s=(si)i∈Is=(s^i)_{i\in I}s=(si)i∈I​ with finite factors, and P(s′∣s,a)=∏iTi(s′i∣s,a)\mathcal P(s'\mid s,a)=\prod_iT_i(s'^i\mid s,a)P(s′∣s,a)=∏i​Ti​(s′i∣s,a). The causal graph has an edge from each factor in pa(i)\mathrm{pa}(i)pa(i) to factor iii and from each factor in pa(R)\mathrm{pa}(R)pa(R) to the reward. AN(R)AN(R)AN(R) is the set of factors with a directed path to the reward.

Formalization Note Policies are stationary Markov policies; in a finite discounted MDP the supremum over them equals the optimum over all policies. The metrics are defined as suprema of iterates from the zero function, as in Ferns, Panangaden and Precup (2004), Theorem 4.5, so that each is a definite function of the data; that they solve their fixed-point equations is part of the statements. Values of the aggregated MDP are only used for surjective ϕ\phiϕ, so no cluster is empty.

Definition code
import Mathlib

/-!
Zhang, McAllister, Calandra, Gal and Levine, *Learning Invariant Representations for Reinforcement
Learning without Reconstruction*, arXiv:2006.10742v2 (ICLR 2021): finite Markov decision processes,
policies and value functions (Section 3), the 1-Wasserstein distance and the bisimulation metric
(Section 3, Definition 2), the on-policy bisimulation operator and policy iteration (Section 5,
Theorem 1, Appendix A), the aggregated MDP of Theorem 2 (following Ferns, Panangaden and Precup,
UAI 2004, Section 5), the learning error of Section 5, and factored MDPs with causal ancestors
(Section 5, Definition 3, Theorem 4 and its proof in Appendix A).
-/

open Finset

noncomputable section

namespace DeepBisimulationControl

section MDP

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

/-- Section 3: `P s a` is a probability distribution `P(· | s, a)` on the finite state space. -/
def IsKernel (P : S → A → S → ℝ) : Prop :=
  (∀ s a s', 0 ≤ P s a s') ∧ ∀ s a, ∑ s', P s a s' = 1

/-- Section 3: a (stationary, stochastic) policy `a ∼ π(s)`: `pi s` is a probability
distribution on actions. -/
def IsPolicy (pi : S → A → ℝ) : Prop :=
  (∀ s a, 0 ≤ pi s a) ∧ ∀ s, ∑ a, pi s a = 1

/-- The deterministic policy that plays `sigma s` in state `s` (Appendix A, proof of Theorem 1:
the policies `π_k(s) = argmax_a …` of policy iteration). -/
def detPolicy [DecidableEq A] (sigma : S → A) : S → A → ℝ :=
  fun s a => if a = sigma s then 1 else 0

/-- Section 5, Theorem 1: the on-policy reward `r^π_s = ∑_a π(a|s) R(s,a)`. -/
def policyReward (R : S → A → ℝ) (pi : S → A → ℝ) (s : S) : ℝ :=
  ∑ a, pi s a * R s a

/-- Section 5, Theorem 1: the on-policy transition distribution
`P^π_s(s') = ∑_a π(a|s) P(s'|s,a)`. -/
def policyKernel (P : S → A → S → ℝ) (pi : S → A → ℝ) (s s' : S) : ℝ :=
  ∑ a, pi s a * P s a s'

/-- Section 3: the value of policy `π`, the expected discounted return
`V^π(s) = E[∑_t γ^t R(s_t, a_t) | s_0 = s] = ∑_n γ^n ((P^π)^n r^π)(s)`. -/
def policyValue [DecidableEq S] (P : S → A → S → ℝ) (R : S → A → ℝ) (gamma : ℝ)
    (pi : S → A → ℝ) (s : S) : ℝ :=
  ∑' n : ℕ, gamma ^ n * (((Matrix.of (policyKernel P pi)) ^ n).mulVec (policyReward R pi)) s

/-- Section 3: the optimal value function `V*(s) = max_π E[∑_t γ^t R(s_t, a_t)]`, the supremum
of `V^π(s)` over stationary stochastic policies. -/
def optValue [DecidableEq S] (P : S → A → S → ℝ) (R : S → A → ℝ) (gamma : ℝ) (s : S) : ℝ :=
  ⨆ pi : {pi : S → A → ℝ // IsPolicy pi}, policyValue P R gamma pi.1 s

/-- Section 5, Theorems 1 and 5: `π*` is an optimal policy, `V^{π*} = V*`. -/
def IsOptimalPolicy [DecidableEq S] (P : S → A → S → ℝ) (R : S → A → ℝ) (gamma : ℝ)
    (pi : S → A → ℝ) : Prop :=
  IsPolicy pi ∧ ∀ s, policyValue P R gamma pi s = optValue P R gamma s

/-- Appendix A, proof of Theorem 1: the action value
`Q^π(s,a) = R(s,a) + γ ∑_{s'} P(s'|s,a) V^π(s')` maximised by policy iteration. -/
def qValue [DecidableEq S] (P : S → A → S → ℝ) (R : S → A → ℝ) (gamma : ℝ)
    (pi : S → A → ℝ) (s : S) (a : A) : ℝ :=
  R s a + gamma * ∑ s', P s a s' * policyValue P R gamma pi s'

/-- Appendix A, proof of Theorem 1, eqs. (10)-(11): `σ_0, σ_1, …` is a run of policy iteration,
`σ_{k+1}(s) ∈ argmax_a Q^{σ_k}(s,a)`, with the standard tie-breaking rule that
`σ_{k+1}(s) = σ_k(s)` whenever `σ_k(s)` is itself a maximiser. -/
def IsPolicyIteration [DecidableEq S] [DecidableEq A] (P : S → A → S → ℝ) (R : S → A → ℝ)
    (gamma : ℝ) (sigma : ℕ → S → A) : Prop :=
  ∀ k s,
    (∀ a, qValue P R gamma (detPolicy (sigma k)) s a ≤
      qValue P R gamma (detPolicy (sigma k)) s (sigma (k + 1) s)) ∧
    ((∀ a, qValue P R gamma (detPolicy (sigma k)) s a ≤
      qValue P R gamma (detPolicy (sigma k)) s (sigma k s)) → sigma (k + 1) s = sigma k s)

/-- Section 3, footnote 1: `d` is a pseudometric on the states (distinct states may be at
distance `0`). -/
def IsPseudometric (d : S → S → ℝ) : Prop :=
  (∀ s, d s s = 0) ∧ (∀ s t, 0 ≤ d s t) ∧ (∀ s t, d s t = d t s) ∧
    ∀ s t u, d s u ≤ d s t + d t u

/-- Section 3: `g` is a coupling of the distributions `mu` and `nu` on the states,
`g ∈ Γ(mu, nu)`. -/
def IsCoupling (mu nu : S → ℝ) (g : S → S → ℝ) : Prop :=
  (∀ x y, 0 ≤ g x y) ∧ (∀ x, ∑ y, g x y = mu x) ∧ ∀ y, ∑ x, g x y = nu y

/-- Section 3: the 1-Wasserstein distance with ground cost `d`,
`W_1(mu, nu; d) = inf_{g ∈ Γ(mu, nu)} ∑_{x,y} g(x,y) d(x,y)`. -/
def wasserstein1 (d : S → S → ℝ) (mu nu : S → ℝ) : ℝ :=
  sInf ((fun g : S → S → ℝ => ∑ x, ∑ y, g x y * d x y) '' {g | IsCoupling mu nu g})

/-- Section 3, Definition 2, eq. (3): the bisimulation operator
`F(d)(s_i,s_j) = max_a (1-c)|R(s_i,a) - R(s_j,a)| + c W_1(P(·|s_i,a), P(·|s_j,a); d)`. -/
def bisimOperator (P : S → A → S → ℝ) (R : S → A → ℝ) (c : ℝ) (d : S → S → ℝ) :
    S → S → ℝ :=
  fun s t => ⨆ a, (1 - c) * |R s a - R t a| + c * wasserstein1 d (P s a) (P t a)

/-- Section 3, Definition 2 (from Ferns et al.): the bisimulation metric, the solution of eq. (3),
constructed as in Ferns, Panangaden and Precup (2004), Theorem 4.5: `d̃ = sup_n F^n(0)`. -/
def bisimMetric (P : S → A → S → ℝ) (R : S → A → ℝ) (c : ℝ) : S → S → ℝ :=
  fun s t => ⨆ n : ℕ, ((bisimOperator P R c)^[n] 0) s t

/-- Section 5, Theorem 1, eq. (5): the on-policy bisimulation operator
`F(d, π)(s_i,s_j) = (1-c)|r^π_{s_i} - r^π_{s_j}| + c W_1(P^π_{s_i}, P^π_{s_j}; d)`. -/
def piBisimOperator (P : S → A → S → ℝ) (R : S → A → ℝ) (c : ℝ) (pi : S → A → ℝ)
    (d : S → S → ℝ) : S → S → ℝ :=
  fun s t => (1 - c) * |policyReward R pi s - policyReward R pi t| +
    c * wasserstein1 d (policyKernel P pi s) (policyKernel P pi t)

/-- Section 5, Theorems 1 and 5: the `π`-bisimulation metric `sup_n F(·, π)^n(0)`, the iterates
of the on-policy operator started at the bottom element `⊥ = 0`. -/
def piBisimMetric (P : S → A → S → ℝ) (R : S → A → ℝ) (c : ℝ) (pi : S → A → ℝ) :
    S → S → ℝ :=
  fun s t => ⨆ n : ℕ, ((piBisimOperator P R c pi)^[n] 0) s t

/-- Section 5, Theorem 1 and Appendix A: the metric iterates run alongside policy iteration,
`d_0 = ⊥ = 0`, `d_{n+1} = F(d_n, σ_n)`. -/
def policyIterationMetric [DecidableEq A] (P : S → A → S → ℝ) (R : S → A → ℝ) (c : ℝ)
    (sigma : ℕ → S → A) : ℕ → S → S → ℝ
  | 0 => 0
  | n + 1 => piBisimOperator P R c (detPolicy (sigma n)) (policyIterationMetric P R c sigma n)

section Aggregation

variable {C : Type*} [Fintype C] [DecidableEq C]

/-- Section 5, Theorem 2 (aggregated MDP `M̄`, as in Ferns et al. 2004, Section 5): the members
`{s | φ(s) = k}` of cluster `k`. -/
def cluster (phi : S → C) (k : C) : Finset S :=
  univ.filter fun s => phi s = k

/-- Section 5, Theorem 2: transitions of the aggregated MDP, averaged over the cluster,
`P̄(k' | k, a) = (1/|k|) ∑_{s ∈ k} ∑_{s' ∈ k'} P(s'|s,a)`. -/
def aggKernel (P : S → A → S → ℝ) (phi : S → C) (k : C) (a : A) (k' : C) : ℝ :=
  (∑ s ∈ cluster phi k, ∑ s' ∈ cluster phi k', P s a s') / (cluster phi k).card

/-- Section 5, Theorem 2: rewards of the aggregated MDP, averaged over the cluster,
`R̄(k, a) = (1/|k|) ∑_{s ∈ k} R(s,a)`. -/
def aggReward (R : S → A → ℝ) (phi : S → C) (k : C) (a : A) : ℝ :=
  (∑ s ∈ cluster phi k, R s a) / (cluster phi k).card

/-- Appendix A, proof of Theorem 2: `g(s, d)`, the average `d`-distance from `s` to the states of
its own cluster. -/
def avgClusterDist (d : S → S → ℝ) (phi : S → C) (s : S) : ℝ :=
  (∑ s' ∈ cluster phi (phi s), d s s') / (cluster phi (phi s)).card

/-- Section 5, Theorem 2: every cluster of `φ` lies in an `ε`-neighborhood of some state for the
distance `d`. -/
def IsEpsAggregation (d : S → S → ℝ) (phi : S → C) (eps : ℝ) : Prop :=
  ∀ k, ∃ s0 : S, ∀ s, phi s = k → d s0 s ≤ eps

end Aggregation

/-- Section 4: the `ℓ_1` distance `‖x - y‖_1` between two representations in `ℝ^m`. -/
def l1Dist {m : ℕ} (x y : Fin m → ℝ) : ℝ :=
  ∑ i, |x i - y i|

/-- Section 5, after Theorem 2: the learning error of an encoder `ψ`,
`L = sup_{s_i, s_j} |‖ψ(s_i) - ψ(s_j)‖_1 - d̃(s_i, s_j)|`. -/
def learningError {m : ℕ} (d : S → S → ℝ) (psi : S → Fin m → ℝ) : ℝ :=
  ⨆ st : S × S, |l1Dist (psi st.1) (psi st.2) - d st.1 st.2|

end MDP

section Factored

variable {I A : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} [∀ i, Fintype (X i)]

/-- Appendix A, proof of Theorem 4: the transition of a factored MDP with state space
`S = ∏_i S^i` and one-step causal dynamics,
`P(s' | s, a) = ∏_i T_i(s'^i | s, a)`. -/
def factoredKernel (T : ∀ i, (∀ j, X j) → A → X i → ℝ) (s : ∀ j, X j) (a : A)
    (s' : ∀ j, X j) : ℝ :=
  ∏ i, T i s a (s' i)

/-- Appendix A, proof of Theorem 4: `f` depends on the state only through the factors in `J`. -/
def DependsOnlyOn {β : Type*} (f : (∀ j, X j) → β) (J : Set I) : Prop :=
  ∀ s s' : ∀ j, X j, (∀ j ∈ J, s j = s' j) → f s = f s'

/-- Section 5, Definition 3: the causal ancestors `AN(R)` of the reward in the causal graph whose
edges go from each factor in `pa i` to factor `i` and from each factor in `paR` to the reward:
the factors with a directed path to the reward. -/
def causalAncestors (pa : I → Set I) (paR : Set I) : Set I :=
  {j | ∃ i ∈ paR, Relation.ReflTransGen (fun x y => x ∈ pa y) j i}

end Factored

end DeepBisimulationControl
Source
Zhang, McAllister, Calandra, Gal and Levine, Learning Invariant Representations for Reinforcement Learning without Reconstruction, arXiv:2006.10742v2 (ICLR 2021), Section 3 (MDP, Definition 2, eq. (3)), Section 4 (l1 representation distance), Section 5 (Theorem 1 eq. (5), Theorem 2, learning error, Definition 3), Appendix A (proofs of Theorems 1, 2, 4); aggregated MDP from Ferns, Panangaden and Precup, UAI 2004, Section 5
Read-back

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

Throughout, SSS (states) and AAA (actions) are arbitrary finite types, either of which may be empty. All functions below are real-valued. Sums over SSS, AAA, etc. are finite sums over the whole type. Wherever a supremum or infimum of reals is used, the following conventions apply:

  • the supremum or infimum of an empty family is 000;
  • a supremum of a family that is not bounded above is 000;
  • an infimum of a set that is not bounded below is 000;
  • division by zero yields 000.

IsKernel. For 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), IsKernel(P)\mathrm{IsKernel}(P)IsKernel(P) holds iff:

  • P(s′∣s,a)≥0P(s' \mid s,a) \ge 0P(s′∣s,a)≥0 for all s,a,s′s, a, s's,a,s′, and
  • ∑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.

If SSS or AAA is empty, the second condition is vacuous.

IsPolicy. For π:S×A→R\pi : S \times A \to \mathbb{R}π:S×A→R, written π(a∣s)\pi(a \mid s)π(a∣s), IsPolicy(π)\mathrm{IsPolicy}(\pi)IsPolicy(π) holds iff:

  • π(a∣s)≥0\pi(a \mid s) \ge 0π(a∣s)≥0 for all s,as, as,a, and
  • ∑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.

If SSS is nonempty and AAA is empty, no such π\piπ exists. If SSS is empty, every π\piπ qualifies.

detPolicy. Given a map σ:S→A\sigma : S \to Aσ:S→A (with AAA having decidable equality), δσ(a∣s)=1\delta_\sigma(a \mid s) = 1δσ​(a∣s)=1 if a=σ(s)a = \sigma(s)a=σ(s) and 000 otherwise.

policyReward. For any R:S×A→RR : S \times A \to \mathbb{R}R:S×A→R and any π:S×A→R\pi : S \times A \to \mathbb{R}π:S×A→R (not required to be a policy),

rπ(s)=∑a∈Aπ(a∣s) R(s,a).r^\pi(s) = \sum_{a \in A} \pi(a \mid s)\, R(s,a).rπ(s)=a∈A∑​π(a∣s)R(s,a).

policyKernel. For any PPP and any π\piπ (neither required to be normalized),

Pπ(s′∣s)=∑a∈Aπ(a∣s) P(s′∣s,a).P^\pi(s' \mid s) = \sum_{a \in A} \pi(a \mid s)\, P(s' \mid s,a).Pπ(s′∣s)=a∈A∑​π(a∣s)P(s′∣s,a).

policyValue. For any PPP, RRR, any real γ\gammaγ (no range restriction) and any π\piπ, Vπ(s)V^\pi(s)Vπ(s) is the infinite series

Vπ(s)=∑n=0∞γn((Pπ)n rπ)(s).V^\pi(s) = \sum_{n=0}^{\infty} \gamma^n \big( (P^\pi)^n\, r^\pi \big)(s).Vπ(s)=n=0∑∞​γn((Pπ)nrπ)(s).
  • Here PπP^\piPπ is the S×SS \times SS×S matrix with entries Pπ(s′∣s)P^\pi(s' \mid s)Pπ(s′∣s), (Pπ)n(P^\pi)^n(Pπ)n is its nnn-th matrix power (with (Pπ)0=I(P^\pi)^0 = I(Pπ)0=I), and rπr^\pirπ is treated as a column vector.
  • The sum is taken in the sense of unconditional summability. If the series is not summable, Vπ(s)V^\pi(s)Vπ(s) is defined to be 000.

optValue. The quantity is

V∗(s)=sup⁡{Vπ(s):π satisfies IsPolicy(π)}.V^*(s) = \sup \{ V^\pi(s) : \pi \text{ satisfies } \mathrm{IsPolicy}(\pi) \}.V∗(s)=sup{Vπ(s):π satisfies IsPolicy(π)}.
  • The supremum ranges over all real functions π\piπ that are nonnegative and sum to 111 in aaa for each sss.
  • No condition is placed on PPP, RRR or γ\gammaγ.
  • By the conventions above, V∗(s)=0V^*(s) = 0V∗(s)=0 if no policies exist (e.g. SSS nonempty and AAA empty) or if the values Vπ(s)V^\pi(s)Vπ(s) are unbounded above.

IsOptimalPolicy. π\piπ is optimal iff IsPolicy(π)\mathrm{IsPolicy}(\pi)IsPolicy(π) holds and Vπ(s)=V∗(s)V^\pi(s) = V^*(s)Vπ(s)=V∗(s) for every s∈Ss \in Ss∈S, with VπV^\piVπ and V∗V^*V∗ as above (including their junk conventions).

qValue. For any PPP, RRR, γ\gammaγ, π\piπ,

Qπ(s,a)=R(s,a)+γ∑s′∈SP(s′∣s,a) Vπ(s′).Q^\pi(s,a) = R(s,a) + \gamma \sum_{s' \in S} P(s' \mid s,a)\, V^\pi(s').Qπ(s,a)=R(s,a)+γs′∈S∑​P(s′∣s,a)Vπ(s′).

IsPolicyIteration. A sequence of deterministic maps σ0,σ1,⋯:S→A\sigma_0, \sigma_1, \dots : S \to Aσ0​,σ1​,⋯:S→A satisfies this iff for every k∈Nk \in \mathbb{N}k∈N and every s∈Ss \in Ss∈S the following two conditions hold, where QkQ_kQk​ denotes QδσkQ^{\delta_{\sigma_k}}Qδσk​​:

  1. The next action is a maximizer:
Qk(s,a)≤Qk(s,σk+1(s))for all a∈A.Q_k(s,a) \le Q_k(s, \sigma_{k+1}(s)) \quad \text{for all } a \in A.Qk​(s,a)≤Qk​(s,σk+1​(s))for all a∈A.
  1. Tie-breaking: if Qk(s,a)≤Qk(s,σk(s))Q_k(s,a) \le Q_k(s, \sigma_k(s))Qk​(s,a)≤Qk​(s,σk​(s)) for all aaa, then σk+1(s)=σk(s)\sigma_{k+1}(s) = \sigma_k(s)σk+1​(s)=σk​(s).

σ0\sigma_0σ0​ is unconstrained. No condition on PPP, RRR or γ\gammaγ is imposed.

IsPseudometric. d:S×S→Rd : S \times S \to \mathbb{R}d:S×S→R is a pseudometric iff, for all s,t,u∈Ss, t, u \in Ss,t,u∈S:

  • d(s,s)=0d(s,s) = 0d(s,s)=0,
  • d(s,t)≥0d(s,t) \ge 0d(s,t)≥0,
  • d(s,t)=d(t,s)d(s,t) = d(t,s)d(s,t)=d(t,s), and
  • d(s,u)≤d(s,t)+d(t,u)d(s,u) \le d(s,t) + d(t,u)d(s,u)≤d(s,t)+d(t,u).

Distinct points may be at distance 000.

IsCoupling. For arbitrary μ,ν:S→R\mu, \nu : S \to \mathbb{R}μ,ν:S→R (not required to be nonnegative or to sum to 111), g:S×S→Rg : S \times S \to \mathbb{R}g:S×S→R is a coupling iff:

  • g(x,y)≥0g(x,y) \ge 0g(x,y)≥0 for all x,yx, yx,y,
  • ∑yg(x,y)=μ(x)\sum_{y} g(x,y) = \mu(x)∑y​g(x,y)=μ(x) for every xxx, and
  • ∑xg(x,y)=ν(y)\sum_{x} g(x,y) = \nu(y)∑x​g(x,y)=ν(y) for every yyy.

If μ\muμ or ν\nuν has a negative entry, or if ∑μ≠∑ν\sum \mu \ne \sum \nu∑μ=∑ν, no coupling exists.

wasserstein1. For any d:S×S→Rd : S \times S \to \mathbb{R}d:S×S→R (not required to be a pseudometric) and any μ,ν\mu, \nuμ,ν,

W1(μ,ν;d)=inf⁡{∑x,y∈Sg(x,y) d(x,y)  :  g is a coupling of μ,ν}.W_1(\mu,\nu; d) = \inf \Big\{ \sum_{x,y \in S} g(x,y)\, d(x,y) \;:\; g \text{ is a coupling of } \mu, \nu \Big\}.W1​(μ,ν;d)=inf{x,y∈S∑​g(x,y)d(x,y):g is a coupling of μ,ν}.

This equals 000 when no coupling exists (e.g. unequal total masses), or when the set of costs is unbounded below.

bisimOperator. For any PPP, RRR, any real ccc (no restriction to [0,1)[0,1)[0,1)) and any ddd,

F(d)(s,t)=sup⁡a∈A[(1−c) ∣R(s,a)−R(t,a)∣+c W1(P(⋅∣s,a),P(⋅∣t,a);d)].F(d)(s,t) = \sup_{a \in A} \Big[ (1-c)\,|R(s,a) - R(t,a)| + c\, W_1\big(P(\cdot \mid s,a), P(\cdot \mid t,a); d\big) \Big].F(d)(s,t)=a∈Asup​[(1−c)∣R(s,a)−R(t,a)∣+cW1​(P(⋅∣s,a),P(⋅∣t,a);d)].

This is a maximum over the finite set AAA when AAA is nonempty, and 000 when AAA is empty.

bisimMetric. The quantity is

d~(s,t)=sup⁡n∈NFn(0)(s,t),\tilde d(s,t) = \sup_{n \in \mathbb{N}} F^n(0)(s,t),d~(s,t)=n∈Nsup​Fn(0)(s,t),

where FnF^nFn is the nnn-fold iterate of the operator above applied to the identically-zero function, and F0(0)=0F^0(0) = 0F0(0)=0 is included.

  • It is 000 at any pair (s,t)(s,t)(s,t) for which these values are unbounded above.
  • Nothing asserts that d~\tilde dd~ is a fixed point of FFF or a pseudometric.

piBisimOperator. For any PPP, RRR, ccc, π\piπ and ddd,

F(d,π)(s,t)=(1−c) ∣rπ(s)−rπ(t)∣+c W1(Pπ(⋅∣s),Pπ(⋅∣t);d).F(d,\pi)(s,t) = (1-c)\,|r^\pi(s) - r^\pi(t)| + c\, W_1\big(P^\pi(\cdot \mid s), P^\pi(\cdot \mid t); d\big).F(d,π)(s,t)=(1−c)∣rπ(s)−rπ(t)∣+cW1​(Pπ(⋅∣s),Pπ(⋅∣t);d).

There is no maximum over actions.

piBisimMetric. The quantity is

dπ(s,t)=sup⁡n∈NF(⋅,π)n(0)(s,t),d^\pi(s,t) = \sup_{n \in \mathbb{N}} F(\cdot,\pi)^n(0)(s,t),dπ(s,t)=n∈Nsup​F(⋅,π)n(0)(s,t),

with F(⋅,π)0(0)=0F(\cdot,\pi)^0(0) = 0F(⋅,π)0(0)=0 included. It is 000 where the iterates are unbounded above.

policyIterationMetric. For a sequence σ0,σ1,⋯:S→A\sigma_0, \sigma_1, \dots : S \to Aσ0​,σ1​,⋯:S→A, the sequence of functions dn:S×S→Rd_n : S \times S \to \mathbb{R}dn​:S×S→R is defined by

d0=0,dn+1=F(dn,δσn).d_0 = 0, \qquad d_{n+1} = F(d_n, \delta_{\sigma_n}).d0​=0,dn+1​=F(dn​,δσn​​).

No requirement that σ\sigmaσ is a policy-iteration run is built in.

cluster. For a finite type CCC of cluster labels and φ:S→C\varphi : S \to Cφ:S→C,

cl(k)={s∈S:φ(s)=k}.\mathrm{cl}(k) = \{ s \in S : \varphi(s) = k \}.cl(k)={s∈S:φ(s)=k}.

This may be empty.

aggKernel. The aggregated transition is

Pˉ(k′∣k,a)=1∣cl(k)∣∑s∈cl(k)∑s′∈cl(k′)P(s′∣s,a).\bar P(k' \mid k, a) = \frac{1}{|\mathrm{cl}(k)|} \sum_{s \in \mathrm{cl}(k)} \sum_{s' \in \mathrm{cl}(k')} P(s' \mid s,a).Pˉ(k′∣k,a)=∣cl(k)∣1​s∈cl(k)∑​s′∈cl(k′)∑​P(s′∣s,a).

It equals 000 when cl(k)\mathrm{cl}(k)cl(k) is empty.

aggReward. The aggregated reward is

Rˉ(k,a)=1∣cl(k)∣∑s∈cl(k)R(s,a).\bar R(k,a) = \frac{1}{|\mathrm{cl}(k)|} \sum_{s \in \mathrm{cl}(k)} R(s,a).Rˉ(k,a)=∣cl(k)∣1​s∈cl(k)∑​R(s,a).

It equals 000 when cl(k)\mathrm{cl}(k)cl(k) is empty.

avgClusterDist. For any ddd and φ\varphiφ,

g(s,d)=1∣cl(φ(s))∣∑s′∈cl(φ(s))d(s,s′).g(s,d) = \frac{1}{|\mathrm{cl}(\varphi(s))|} \sum_{s' \in \mathrm{cl}(\varphi(s))} d(s,s').g(s,d)=∣cl(φ(s))∣1​s′∈cl(φ(s))∑​d(s,s′).

The cluster always contains sss, so the denominator is at least 111.

IsEpsAggregation. For any ddd, φ:S→C\varphi : S \to Cφ:S→C and real ε\varepsilonε, this holds iff

for every label k∈C there is a state s0∈S such that d(s0,s)≤ε for every s with φ(s)=k.\text{for every label } k \in C \text{ there is a state } s_0 \in S \text{ such that } d(s_0, s) \le \varepsilon \text{ for every } s \text{ with } \varphi(s) = k.for every label k∈C there is a state s0​∈S such that d(s0​,s)≤ε for every s with φ(s)=k.
  • s0s_0s0​ need not lie in the cluster cl(k)\mathrm{cl}(k)cl(k).
  • The distance is taken in the order d(s0,s)d(s_0, s)d(s0​,s).
  • For an empty cluster, the condition only requires SSS to be nonempty.
  • The condition is vacuously true if CCC is empty, and false if SSS is empty but CCC is not.

l1Dist. For x,y∈Rmx, y \in \mathbb{R}^mx,y∈Rm,

∥x−y∥1=∑i=1m∣xi−yi∣.\|x - y\|_1 = \sum_{i=1}^m |x_i - y_i|.∥x−y∥1​=i=1∑m​∣xi​−yi​∣.

For m=0m = 0m=0 this is 000.

learningError. For any d:S×S→Rd : S \times S \to \mathbb{R}d:S×S→R (not required to be the bisimulation metric) and an encoder ψ:S→Rm\psi : S \to \mathbb{R}^mψ:S→Rm,

L=sup⁡(si,sj)∈S×S∣ ∥ψ(si)−ψ(sj)∥1−d(si,sj)∣.L = \sup_{(s_i, s_j) \in S \times S} \Big|\, \|\psi(s_i) - \psi(s_j)\|_1 - d(s_i, s_j) \Big|.L=(si​,sj​)∈S×Ssup​​∥ψ(si​)−ψ(sj​)∥1​−d(si​,sj​)​.

This is a maximum over the finite set S×SS \times SS×S, and equals 000 if SSS is empty.

factoredKernel. Let III be a finite index set of factors and XiX_iXi​ a finite type for each i∈Ii \in Ii∈I. A state is s=(si)i∈I∈∏iXis = (s^i)_{i \in I} \in \prod_i X_is=(si)i∈I​∈∏i​Xi​. Given arbitrary real functions Ti(x∣s,a)T_i(x \mid s, a)Ti​(x∣s,a) for x∈Xix \in X_ix∈Xi​ (not required to be nonnegative or normalized), the factored transition is

P(s′∣s,a)=∏i∈ITi(s′i∣s,a).P(s' \mid s, a) = \prod_{i \in I} T_i(s'^i \mid s, a).P(s′∣s,a)=i∈I∏​Ti​(s′i∣s,a).

It equals 111 if III is empty.

DependsOnlyOn. A function fff on ∏jXj\prod_j X_j∏j​Xj​ depends only on J⊆IJ \subseteq IJ⊆I iff

f(s)=f(s′)whenever sj=s′j for all j∈J.f(s) = f(s') \quad \text{whenever } s^j = s'^j \text{ for all } j \in J.f(s)=f(s′)whenever sj=s′j for all j∈J.

causalAncestors. Let pa:I→P(I)\mathrm{pa} : I \to \mathcal{P}(I)pa:I→P(I) assign parents to each factor, and let paR⊆I\mathrm{pa}_R \subseteq IpaR​⊆I be the reward's parents. Then AN(R)\mathrm{AN}(R)AN(R) is the set of j∈Ij \in Ij∈I such that, for some i∈paRi \in \mathrm{pa}_Ri∈paR​, there is a finite chain

j=x0,x1,…,xm=i(m≥0)with xℓ∈pa(xℓ+1) for each ℓ.j = x_0, x_1, \dots, x_m = i \quad (m \ge 0) \quad \text{with } x_\ell \in \mathrm{pa}(x_{\ell+1}) \text{ for each } \ell.j=x0​,x1​,…,xm​=i(m≥0)with xℓ​∈pa(xℓ+1​) for each ℓ.

Because m=0m = 0m=0 is allowed, paR⊆AN(R)\mathrm{pa}_R \subseteq \mathrm{AN}(R)paR​⊆AN(R).

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