Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Controlled Markov processes, LTL goals and bounded goal-conditioned agents

Definition
GeneralAgentsWorldModels_Basic

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

controlled-markov-processesgoal-conditioned-agentslinear-temporal-logicregret-boundsworld-models

Objects of Sections 2-3 and Appendices A-B of Richens, Abel, Bellot and Everitt (2025).

  1. Environment (Definition 1, Assumption 1). A controlled Markov process on a finite state set SSS and a finite action set AAA is a transition function Pss′(a)=P(St+1=s′∣At=a,St=s)P_{ss'}(a)=P(S_{t+1}=s'\mid A_t=a,S_t=s)Pss′​(a)=P(St+1​=s′∣At​=a,St​=s), with Pss′(a)≥0P_{ss'}(a)\ge0Pss′​(a)≥0 and ∑s′Pss′(a)=1\sum_{s'}P_{ss'}(a)=1∑s′​Pss′​(a)=1; it does not depend on ttt (stationarity). It is communicating if for all s≠s′s\ne s's=s′ there are states s=x0,x1,…,xm=s′s=x_0,x_1,\dots,x_m=s's=x0​,x1​,…,xm​=s′ (m≥1m\ge1m≥1) and actions bib_ibi​ with Pxixi+1(bi)>0P_{x_ix_{i+1}}(b_i)>0Pxi​xi+1​​(bi​)>0. Assumption 1: the process is communicating and ∣A∣≥2|A|\ge2∣A∣≥2.
  2. Goals (Definition 2). A sub-goal is φ=O([(s,a)∈g])\varphi=\mathcal O([(s,a)\in g])φ=O([(s,a)∈g]) with g⊆S×Ag\subseteq S\times Ag⊆S×A and O∈{⊤,\medcirc,◊}\mathcal O\in\{\top,\medcirc,\Diamond\}O∈{⊤,\medcirc,◊} (Now, Next, Eventually).
  3. Sequential and composite goals (Definitions 3, 6, eq. (4)). A sequential goal ⟨φ1,…,φL⟩\langle\varphi_1,\dots,\varphi_L\rangle⟨φ1​,…,φL​⟩ is satisfied by a trajectory τ=((s0,a0),(s1,a1),… )\tau=((s_0,a_0),(s_1,a_1),\dots)τ=((s0​,a0​),(s1​,a1​),…) from time ttt according to the recursion (4): for O1=⊤\mathcal O_1=\topO1​=⊤, (st,at)∈g1(s_t,a_t)\in g_1(st​,at​)∈g1​ and ⟨φ2,… ⟩\langle\varphi_2,\dots\rangle⟨φ2​,…⟩ holds from ttt; for O1=\medcirc\mathcal O_1=\medcircO1​=\medcirc, (st+1,at+1)∈g1(s_{t+1},a_{t+1})\in g_1(st+1​,at+1​)∈g1​ and ⟨φ2,… ⟩\langle\varphi_2,\dots\rangle⟨φ2​,…⟩ holds from t+1t+1t+1; for O1=◊\mathcal O_1=\DiamondO1​=◊, there is u≥tu\ge tu≥t with (sv,av)∉g1(s_v,a_v)\notin g_1(sv​,av​)∈/g1​ for t≤v<ut\le v<ut≤v<u, (su,au)∈g1(s_u,a_u)\in g_1(su​,au​)∈g1​, and ⟨φ2,… ⟩\langle\varphi_2,\dots\rangle⟨φ2​,…⟩ holds from uuu (strong until). The empty sequence is always satisfied. A composite goal is a disjunction of sequential goals, evaluated from t=0t=0t=0. Ψn\Psi_nΨn​ is the set of composite goals with at least one disjunct, each disjunct having between 111 and nnn sub-goals.
  4. Policies and success probability (eq. (5)). A deterministic policy maps a history ht=(s0,a0,…,st)h_t=(s_0,a_0,\dots,s_t)ht​=(s0​,a0​,…,st​) to an action ata_tat​; a goal-conditioned policy π(⋅;ψ)\pi(\cdot;\psi)π(⋅;ψ) is a policy for each composite goal ψ\psiψ. P(τ⊨ψ∣π,s0)P(\tau\models\psi\mid\pi,s_0)P(τ⊨ψ∣π,s0​) is the probability that the trajectory generated by π\piπ from s0s_0s0​ satisfies ψ\psiψ; max⁡πP(τ⊨ψ∣π,s0)\max_\pi P(\tau\models\psi\mid\pi,s_0)maxπ​P(τ⊨ψ∣π,s0​) is the supremum over deterministic history-dependent policies.
  5. Agents (Definitions 4, 5). π\piπ is optimal for a set of goals Ψ\PsiΨ if P(τ⊨ψ∣π(⋅;ψ),s0)=max⁡π′P(τ⊨ψ∣π′,s0)P(\tau\models\psi\mid\pi(\cdot;\psi),s_0)=\max_{\pi'}P(\tau\models\psi\mid\pi',s_0)P(τ⊨ψ∣π(⋅;ψ),s0​)=maxπ′​P(τ⊨ψ∣π′,s0​) for all ψ∈Ψ\psi\in\Psiψ∈Ψ and all s0s_0s0​. π\piπ is a bounded agent with failure rate δ∈[0,1]\delta\in[0,1]δ∈[0,1] and maximum depth nnn if P(τ⊨ψ∣π(⋅;ψ),s0)≥(1−δ)max⁡π′P(τ⊨ψ∣π′,s0)P(\tau\models\psi\mid\pi(\cdot;\psi),s_0)\ge(1-\delta)\max_{\pi'}P(\tau\models\psi\mid\pi',s_0)P(τ⊨ψ∣π(⋅;ψ),s0​)≥(1−δ)maxπ′​P(τ⊨ψ∣π′,s0​) for all ψ∈Ψn\psi\in\Psi_nψ∈Ψn​ and all s0s_0s0​. Ψmyopic\Psi_{\text{myopic}}Ψmyopic​ is the set of goals in Ψ1\Psi_1Ψ1​ all of whose sub-goals use \medcirc\medcirc\medcirc.
  6. Goal families of Lemma 6 and Theorem 1. For an outcome pattern o∈{0,1}mo\in\{0,1\}^mo∈{0,1}m, the sequential goal ⟨[A=b],◊[S=s,A=a],O1,…,◊[S=s,A=a],Om⟩\langle[A=b],\Diamond[S=s,A=a],\mathcal O_1,\dots,\Diamond[S=s,A=a],\mathcal O_m\rangle⟨[A=b],◊[S=s,A=a],O1​,…,◊[S=s,A=a],Om​⟩ has Oi=\medcirc[S=s′]\mathcal O_i=\medcirc[S=s']Oi​=\medcirc[S=s′] if oi=1o_i=1oi​=1 and Oi=\medcirc[S≠s′]\mathcal O_i=\medcirc[S\ne s']Oi​=\medcirc[S=s′] if oi=0o_i=0oi​=0. Lemma 6's ψ(r,n)\psi(r,n)ψ(r,n) is the disjunction over all o∈{0,1}no\in\{0,1\}^no∈{0,1}n with rrr ones. In the proof of Theorem 1, ψa(k,m)\psi_a(k,m)ψa​(k,m) starts with [A=a][A=a][A=a] and ranges over patterns with at most kkk ones, ψb(k,m)\psi_b(k,m)ψb​(k,m) starts with [A=b][A=b][A=b] and ranges over patterns with more than kkk ones, and ψa,b(k,m)=ψa(k,m)∨ψb(k,m)\psi_{a,b}(k,m)=\psi_a(k,m)\vee\psi_b(k,m)ψa,b​(k,m)=ψa​(k,m)∨ψb​(k,m); its depth is 2m+12m+12m+1.
  7. Binomial quantities (eqs. (36)-(38)). Pm(X=r)=(mr)pr(1−p)m−rP_m(X=r)=\binom mr p^r(1-p)^{m-r}Pm​(X=r)=(rm​)pr(1−p)m−r, Pm(X≤k)=∑r≤kPm(X=r)P_m(X\le k)=\sum_{r\le k}P_m(X=r)Pm​(X≤k)=∑r≤k​Pm​(X=r), Pm(X≥k)=∑r=kmPm(X=r)P_m(X\ge k)=\sum_{r=k}^mP_m(X=r)Pm​(X≥k)=∑r=km​Pm​(X=r).
  8. Extended action space (Lemma 2). A′=A∪{aˉ}A'=A\cup\{\bar a\}A′=A∪{aˉ} is the type of optional actions, and a goal over AAA is read over A′A'A′ through the inclusion A⊆A′A\subseteq A'A⊆A′.

Formalization Note The temporal operators are encoded as the three elements of Fin 3\mathrm{Fin}\,3Fin3. A history is the list of past pairs (si,ai)(s_i,a_i)(si​,ai​) together with the current state. Every goal built from ⊤,\medcirc,◊\top,\medcirc,\Diamond⊤,\medcirc,◊ is satisfied at a finite time, so the event τ⊨ψ\tau\models\psiτ⊨ψ is the increasing union over TTT of the events "the first T+1T+1T+1 steps of τ\tauτ already force ψ\psiψ"; P(τ⊨ψ∣π,s0)P(\tau\models\psi\mid\pi,s_0)P(τ⊨ψ∣π,s0​) is defined as the supremum over TTT of the probabilities of these events, each a finite sum over state paths. The paper's initial-state condition P(s0)>0P(s_0)>0P(s0​)>0 in Definition 4 refers to no specified initial distribution and is read as "for every initial state s0s_0s0​"; Definition 5 is read the same way.

Definition code
import Mathlib

/-!
Richens, Abel, Bellot and Everitt, *General agents contain world models*, arXiv:2506.01622v5
(ICML 2025): controlled Markov processes and Assumption 1 (Section 2.2, Appendix A.2), goals,
sequential goals and composite goals (Definitions 2, 3, 6 and eq. (4)), the probability that a
policy achieves a goal (eq. (5)), optimal and bounded goal-conditioned agents (Definitions 4, 5,
eqs. (1), (2)), myopic goals (Theorem 2), and the goal families and binomial quantities used in
Lemma 6 and in the proof of Theorem 1 (Appendix A.6, eqs. (25), (33)-(42)).
-/

noncomputable section

namespace GeneralAgentsWorldModels

/-- Definition 1 (p. 2, p. 10): a controlled Markov process with state set `S` and action set `A`,
given by its transition function `P s a s' = P(S_{t+1} = s' | A_t = a, S_t = s)`; each `P s a` is a
probability distribution on `S`. Stationarity (Assumption 1) is built in: `P` does not depend on
the time step. -/
structure CMP (S A : Type*) [Fintype S] where
  /-- The transition function `P_{ss'}(a)`. -/
  P : S → A → S → ℝ
  nonneg : ∀ s a s', 0 ≤ P s a s'
  sum_one : ∀ s a, ∑ s', P s a s' = 1

/-- Assumption 1 (p. 2, Section 2.2; proof of Lemma 1, p. 13): the cMP is communicating, i.e. every
state `s'` is reachable from every other state `s` by a finite sequence of transitions, each of
which has positive probability under some action. -/
def CMP.IsCommunicating {S A : Type*} [Fintype S] (M : CMP S A) : Prop :=
  ∀ s s' : S, s ≠ s' → Relation.TransGen (fun x y => ∃ a, 0 < M.P x a y) s s'

/-- Assumption 1 (p. 2, p. 10): the environment is a communicating, stationary, finite controlled
Markov process with at least two actions. Finiteness is the `Fintype` instances on `S` and `A`;
stationarity is built into `CMP`. -/
def SatisfiesAssumption1 {S A : Type*} [Fintype S] [Fintype A] (M : CMP S A) : Prop :=
  M.IsCommunicating ∧ 2 ≤ Fintype.card A

/-- Definition 2 (p. 3, p. 10): the temporal operators `O ∈ {⊤, ◯, ◇}` (Now, Next, Eventually),
encoded as `Fin 3` with the names `opNow`, `opNext`, `opEventually`. -/
abbrev TempOp := Fin 3

/-- Definition 2: the operator Now, `⊤`. -/
def opNow : TempOp := 0

/-- Definition 2: the operator Next, `◯`. -/
def opNext : TempOp := 1

/-- Definition 2: the operator Eventually, `◇`. -/
def opEventually : TempOp := 2

/-- Definition 2 (p. 3, p. 10): a goal `φ = O([(s, a) ∈ g])`, with a temporal operator `O` and a set
`g ⊆ S × A` of goal states of the environment-agent system. -/
structure SubGoal (S A : Type*) where
  /-- The temporal operator `O`. -/
  op : TempOp
  /-- The set of goal states `g`. -/
  g : Set (S × A)

/-- Definitions 3 and 6 (p. 3, p. 11): a sequential goal `⟨φ₁, …, φ_L⟩`, the list of its sub-goals;
its depth is the length of the list. -/
abbrev SeqGoal (S A : Type*) := List (SubGoal S A)

/-- Definition 3 (p. 3, p. 12): a composite goal `ψ₁ ∨ ⋯ ∨ ψ_m`, the list of its disjuncts. -/
abbrev CompGoal (S A : Type*) := List (SeqGoal S A)

/-- Eq. (4) (Definition 6, p. 11): `τ, t ⊨ ⟨φ₁, …, φ_L⟩` for a trajectory
`τ = ((s₀, a₀), (s₁, a₁), …)` evaluated from time `t`:
`⊤`: `[(s_t, a_t) ∈ g₁] ∧ ⟨φ₂, …⟩` at `t`; `◯`: `[(s_{t+1}, a_{t+1}) ∈ g₁] ∧ ⟨φ₂, …⟩` at `t + 1`;
`◇`: `[(s, a) ∉ g₁] U ([(s, a) ∈ g₁] ∧ ⟨φ₂, …⟩)` (strong until). The empty sequence is `True`,
so that `⟨φ⟩ = φ`. -/
def seqSat {S A : Type*} (τ : ℕ → S × A) : SeqGoal S A → ℕ → Prop
  | [], _ => True
  | φ :: rest, t =>
    if φ.op = opNow then τ t ∈ φ.g ∧ seqSat τ rest t
    else if φ.op = opNext then τ (t + 1) ∈ φ.g ∧ seqSat τ rest (t + 1)
    else ∃ u, t ≤ u ∧ (∀ v, t ≤ v → v < u → τ v ∉ φ.g) ∧ τ u ∈ φ.g ∧ seqSat τ rest u

/-- Definition 3: `τ ⊨ ψ₁ ∨ ⋯ ∨ ψ_m`, evaluation beginning at `t = 0` (Appendix A.3, p. 10). -/
def compSat {S A : Type*} (ψ : CompGoal S A) (τ : ℕ → S × A) : Prop :=
  ∃ φ ∈ ψ, seqSat τ φ 0

/-- Definition 3 (p. 3): `Ψ_n`, the composite goals of depth at most `n`: a disjunction of one or
more sequential goals, each with between `1` and `n` sub-goals. -/
def InPsi {S A : Type*} (n : ℕ) (ψ : CompGoal S A) : Prop :=
  ψ ≠ [] ∧ ∀ φ ∈ ψ, φ ≠ [] ∧ φ.length ≤ n

/-- Section 2.4 (p. 3), Appendix A.4: a deterministic policy, mapping the history
`h_t = (s₀, a₀, …, s_t)`, given as the list of past pairs `(s_i, a_i)`, `i < t`, and the current
state `s_t`, to the action `a_t`. -/
abbrev Policy (S A : Type*) := List (S × A) → S → A

/-- Section 2.4 (p. 3): a deterministic goal-conditioned policy `π(a_t | h_t; ψ)`. -/
abbrev GCPolicy (S A : Type*) := CompGoal S A → Policy S A

/-- The probability that, from history `h` and current state `s`, the policy `π` produces the next
states `s'₁, …, s'_m` (the list `ss`): `∏ P_{s_i s_{i+1}}(π(h_i))`. -/
def pathWeight {S A : Type*} [Fintype S] (M : CMP S A) (π : Policy S A) :
    List (S × A) → S → List S → ℝ
  | _, _, [] => 1
  | h, s, s' :: ss => M.P s (π h s) s' * pathWeight M π (h ++ [(s, π h s)]) s' ss

/-- The finite trajectory `(s₀, a₀, …, s_m, a_m)` produced by the deterministic policy `π` from
history `h` and current state `s` when the next states are `ss`. -/
def pathPrefix {S A : Type*} (π : Policy S A) : List (S × A) → S → List S → List (S × A)
  | h, s, [] => h ++ [(s, π h s)]
  | h, s, s' :: ss => pathPrefix π (h ++ [(s, π h s)]) s' ss

/-- A finite trajectory `pre` already guarantees `ψ`: every infinite trajectory beginning with
`pre` satisfies `ψ`. -/
def Decides {S A : Type*} (ψ : CompGoal S A) (pre : List (S × A)) : Prop :=
  ∀ τ : ℕ → S × A, (∀ i (hi : i < pre.length), τ i = pre[i]) → compSat ψ τ

open Classical in
/-- The probability that the first `T + 1` steps of the trajectory of `π` from `s₀` already
guarantee `ψ`. -/
def succProbUpTo {S A : Type*} [Fintype S] (M : CMP S A) (ψ : CompGoal S A) (π : Policy S A)
    (s₀ : S) (T : ℕ) : ℝ :=
  ∑ ss : Fin T → S, pathWeight M π [] s₀ (List.ofFn ss) *
    if Decides ψ (pathPrefix π [] s₀ (List.ofFn ss)) then 1 else 0

/-- Eq. (5) (p. 12): `P(τ ⊨ ψ | π, s₀)`, the probability that the trajectory generated by `π` from
`s₀` satisfies `ψ`. Every goal built from `⊤`, `◯`, `◇` is satisfied only at a finite time, so the
event `τ ⊨ ψ` is the increasing union over `T` of the events decided by the first `T + 1` steps, and
its probability is the supremum of their probabilities. -/
def succProb {S A : Type*} [Fintype S] (M : CMP S A) (ψ : CompGoal S A) (π : Policy S A)
    (s₀ : S) : ℝ :=
  ⨆ T : ℕ, succProbUpTo M ψ π s₀ T

/-- Eqs. (1), (2): `max_π P(τ ⊨ ψ | π, s₀)`, the supremum over deterministic history-dependent
policies. -/
def optProb {S A : Type*} [Fintype S] (M : CMP S A) (ψ : CompGoal S A) (s₀ : S) : ℝ :=
  ⨆ π : Policy S A, succProb M ψ π s₀

/-- Definition 4 (p. 3, p. 12), eq. (1): `π` is an optimal goal-conditioned agent for the set of
goals `Ψ`: for every `ψ ∈ Ψ` and every initial state `s₀`, `π(· ; ψ)` attains
`max_π P(τ ⊨ ψ | π, s₀)`. -/
def IsOptimalAgent {S A : Type*} [Fintype S] (M : CMP S A) (Ψ : Set (CompGoal S A))
    (π : GCPolicy S A) : Prop :=
  ∀ ψ ∈ Ψ, ∀ s₀ : S, succProb M ψ (π ψ) s₀ = optProb M ψ s₀

/-- Definition 5 (p. 4, p. 13), eq. (2): `π` is a bounded goal-conditioned agent with failure rate
`δ ∈ [0, 1]` and maximum goal depth `n`: for all `ψ ∈ Ψ_n` and all initial states `s₀`,
`P(τ ⊨ ψ | π, s₀) ≥ max_π P(τ ⊨ ψ | π, s₀) (1 - δ)`. -/
def IsBoundedAgent {S A : Type*} [Fintype S] (M : CMP S A) (π : GCPolicy S A) (δ : ℝ) (n : ℕ) :
    Prop :=
  0 ≤ δ ∧ δ ≤ 1 ∧ ∀ ψ : CompGoal S A, InPsi n ψ → ∀ s₀ : S,
    optProb M ψ s₀ * (1 - δ) ≤ succProb M ψ (π ψ) s₀

/-- Theorem 2 (p. 5): `Ψ_myopic`, the depth-1 composite goals all of whose sub-goals have the form
`◯[(s, a) ∈ g]`. -/
def PsiMyopic {S A : Type*} : Set (CompGoal S A) :=
  {ψ | InPsi 1 ψ ∧ ∀ φ ∈ ψ, ∀ x ∈ φ, x.op = opNext}

/-- The sub-goal `⊤([A = a])`: take action `a` now. -/
def nowAct {S A : Type*} (a : A) : SubGoal S A := ⟨opNow, {x | x.2 = a}⟩

/-- The sub-goal `◇([S = s, A = a])`: eventually be in state `s` and take action `a`. -/
def evVisit {S A : Type*} (s : S) (a : A) : SubGoal S A := ⟨opEventually, {(s, a)}⟩

/-- The sub-goal `◇([S = s'])`: eventually reach state `s'` (Lemma 1). -/
def evState {S A : Type*} (s' : S) : SubGoal S A := ⟨opEventually, {x | x.1 = s'}⟩

/-- The sub-goal `◯([S ∈ Y])`: the next state lies in `Y`. -/
def nextIn {S A : Type*} (Y : Set S) : SubGoal S A := ⟨opNext, {x | x.1 ∈ Y}⟩

/-- Lemma 6 (p. 16), eq. (33): the sequential goal `⟨[A = b], ◇[S = s, A = a], O₁, …,
◇[S = s, A = a], O_m⟩` with `O_i = ◯[S = s']` if `o_i` is true and `O_i = ◯[S ≠ s']` otherwise. -/
def trialSeq {S A : Type*} (b : A) (s : S) (a : A) (s' : S) (o : List Bool) : SeqGoal S A :=
  nowAct b :: o.flatMap fun c => [evVisit s a, nextIn (if c then {s'} else {s'}ᶜ)]

open Classical in
/-- Lemma 6 (p. 16) and the proof of Theorem 1 (pp. 17-18): the disjunction of the sequential goals
`trialSeq b s a s' o` over all outcome patterns `o ∈ {0,1}^m` whose number of successes satisfies
`R`. Lemma 6's `ψ(r, n)` is `R = (· = r)`. -/
def binGoal {S A : Type*} (b : A) (s : S) (a : A) (s' : S) (m : ℕ) (R : ℕ → Prop) :
    CompGoal S A :=
  ((Finset.univ.filter fun o : Fin m → Bool =>
      R (Finset.univ.filter fun i => o i = true).card).toList).map
    fun o => trialSeq b s a s' (List.ofFn o)

/-- Proof of Theorem 1 (pp. 17-18), eq. (34): `ψ_{a,b}(k, m) = ψ_a(k, m) ∨ ψ_b(k, m)`, where
`ψ_a(k, m)` starts with action `a` and asks for at most `k` transitions `(s, a) → s'` in `m`
attempts, and `ψ_b(k, m)` starts with action `b` and asks for more than `k`. -/
def abGoal {S A : Type*} (a b : A) (s s' : S) (m k : ℕ) : CompGoal S A :=
  binGoal a s a s' m (· ≤ k) ++ binGoal b s a s' m (k < ·)

/-- Eq. (37) (p. 18): the binomial probability mass function
`P_m(X = r) = C(m, r) p^r (1 - p)^{m - r}`. -/
def binPmf (m : ℕ) (p : ℝ) (r : ℕ) : ℝ := (m.choose r : ℝ) * p ^ r * (1 - p) ^ (m - r)

/-- Eq. (36) (p. 18): `P_m(X ≤ k) = ∑_{r = 0}^{k} P_m(X = r)`. -/
def binLE (m : ℕ) (p : ℝ) (k : ℕ) : ℝ := ∑ r ∈ Finset.range (k + 1), binPmf m p r

/-- Eqs. (38), (42) (pp. 18-19): `P_m(X ≥ k) = ∑_{r = k}^{m} P_m(X = r)`; `P_m(X > k)` is
`binGE m p (k + 1)`. -/
def binGE (m : ℕ) (p : ℝ) (k : ℕ) : ℝ := ∑ r ∈ Finset.Icc k m, binPmf m p r

/-- Lemma 2 (p. 14): a goal of the environment with action set `A`, read in the environment with the
extended action set `A' = A ∪ {ā}` (`Option A`, with `ā = none`). -/
def liftGoal {S A : Type*} (ψ : CompGoal S A) : CompGoal S (Option A) :=
  ψ.map (List.map fun φ => ⟨φ.op, (fun x : S × A => (x.1, some x.2)) '' φ.g⟩)

end GeneralAgentsWorldModels
Source
Richens, Abel, Bellot and Everitt, General agents contain world models, arXiv:2506.01622v5 (ICML 2025), Sections 2.2-2.4 (Definitions 1-5, Assumption 1, pp. 2-4), Appendix A.2-A.4 (Definition 6, eqs. (4), (5), pp. 10-13), Appendix A.6 (Lemmas 2, 6, eqs. (33)-(42), pp. 14-19), Theorem 2 (p. 5)
Read-back

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

Controlled Markov process (CMP). Let SSS be a finite type of states and AAA any type of actions. AAA may be infinite or empty, and no finiteness is required of it here. A controlled Markov process MMM on (S,A)(S, A)(S,A) consists of a real-valued function PPP, written Pss′(a)P_{ss'}(a)Pss′​(a) for s,s′∈Ss, s' \in Ss,s′∈S and a∈Aa \in Aa∈A, satisfying:

  • Pss′(a)≥0P_{ss'}(a) \ge 0Pss′​(a)≥0 for all s,a,s′s, a, s's,a,s′;
  • ∑s′∈SPss′(a)=1\sum_{s' \in S} P_{ss'}(a) = 1∑s′∈S​Pss′​(a)=1 for all s,as, as,a.

PPP has no time argument. No other data are part of the structure: there is no initial distribution and no reward. If AAA is empty, both conditions hold vacuously.

Communicating (CMP.IsCommunicating). MMM is communicating when, for every pair of distinct states s≠s′s \neq s's=s′, there is a finite chain

s=x0,x1,…,xk=s′(k≥1)s = x_0, x_1, \dots, x_k = s' \qquad (k \ge 1)s=x0​,x1​,…,xk​=s′(k≥1)

such that each step has positive probability under some action:

for each i<k there is ai∈A with Pxixi+1(ai)>0.\text{for each } i < k \text{ there is } a_i \in A \text{ with } P_{x_i x_{i+1}}(a_i) > 0.for each i<k there is ai​∈A with Pxi​xi+1​​(ai​)>0.

The actions aia_iai​ may differ from step to step. Nothing is required for s=s′s = s's=s′. If SSS has at most one element, the condition holds vacuously.

Assumption 1 (SatisfiesAssumption1). Here both SSS and AAA are finite. MMM satisfies the assumption iff:

  • MMM is communicating in the sense above; and
  • AAA has at least 222 elements.

Temporal operators (TempOp, opNow, opNext, opEventually). A temporal operator is one of three values 0,1,20, 1, 20,1,2:

  • ⊤\top⊤ ("Now") is 000;
  • ◯\bigcirc◯ ("Next") is 111;
  • ◊\Diamond◊ ("Eventually") is 222.

Sub-goal (SubGoal). A sub-goal φ\varphiφ is a pair (O,g)(O, g)(O,g), where OOO is one of the three operators and g⊆S×Ag \subseteq S \times Ag⊆S×A is an arbitrary set of state–action pairs. The set ggg may be empty or all of S×AS \times AS×A.

Sequential goal (SeqGoal). A sequential goal is a finite list ⟨φ1,…,φL⟩\langle \varphi_1, \dots, \varphi_L \rangle⟨φ1​,…,φL​⟩ of sub-goals. The empty list (L=0L = 0L=0) is allowed.

Composite goal (CompGoal). A composite goal is a finite list ψ=(ψ1,…,ψm)\psi = (\psi_1, \dots, \psi_m)ψ=(ψ1​,…,ψm​) of sequential goals, read as the disjunction ψ1∨⋯∨ψm\psi_1 \vee \cdots \vee \psi_mψ1​∨⋯∨ψm​. The empty list (m=0m = 0m=0) is allowed, and any ψj\psi_jψj​ may be the empty sequence.

Satisfaction of a sequential goal (seqSat). Let τ:N→S×A\tau : \mathbb{N} \to S \times Aτ:N→S×A be an arbitrary infinite sequence of state–action pairs; it need not be compatible with any process. Satisfaction "τ,t⊨⟨φ1,…,φL⟩\tau, t \models \langle \varphi_1, \dots, \varphi_L\rangleτ,t⊨⟨φ1​,…,φL​⟩" is defined recursively on the list, with φ1=(O,g)\varphi_1 = (O, g)φ1​=(O,g):

  • Empty list: always true, at every ttt.
  • O=⊤O = \topO=⊤: τ(t)∈g\tau(t) \in gτ(t)∈g and τ,t⊨⟨φ2,… ⟩\tau, t \models \langle \varphi_2, \dots \rangleτ,t⊨⟨φ2​,…⟩.
  • O=◯O = \bigcircO=◯: τ(t+1)∈g\tau(t+1) \in gτ(t+1)∈g and τ,t+1⊨⟨φ2,… ⟩\tau, t+1 \models \langle \varphi_2, \dots \rangleτ,t+1⊨⟨φ2​,…⟩.
  • O=◊O = \DiamondO=◊: there exists u≥tu \ge tu≥t such that
τ(v)∉g for all t≤v<u,τ(u)∈g,τ,u⊨⟨φ2,… ⟩.\tau(v) \notin g \text{ for all } t \le v < u, \qquad \tau(u) \in g, \qquad \tau, u \models \langle \varphi_2, \dots\rangle.τ(v)∈/g for all t≤v<u,τ(u)∈g,τ,u⊨⟨φ2​,…⟩.

In the ◊\Diamond◊ case, uuu is therefore the first time ≥t\ge t≥t at which ggg is hit. The remaining goals are evaluated starting at that same time uuu, not at u+1u+1u+1, so a following ⊤\top⊤ sub-goal refers to τ(u)\tau(u)τ(u) itself. If g=∅g = \emptysetg=∅, the ⊤\top⊤, ◯\bigcirc◯ and ◊\Diamond◊ clauses are all false.

Satisfaction of a composite goal (compSat). τ⊨ψ\tau \models \psiτ⊨ψ means that some listed sequential goal ψj\psi_jψj​ satisfies τ,0⊨ψj\tau, 0 \models \psi_jτ,0⊨ψj​. Two edge cases follow:

  • If ψ\psiψ is the empty list, no τ\tauτ satisfies it.
  • If some ψj\psi_jψj​ is the empty sequence, every τ\tauτ satisfies ψ\psiψ.

Goals of depth at most nnn (InPsi). ψ∈Ψn\psi \in \Psi_nψ∈Ψn​ means:

  • ψ\psiψ is a nonempty list; and
  • every ψj\psi_jψj​ in it is a nonempty sequence of length at most nnn.

For n=0n = 0n=0 no ψ\psiψ qualifies.

Policy (Policy). A policy π\piπ is a deterministic function assigning an action π(h,s)∈A\pi(h, s) \in Aπ(h,s)∈A to every finite list hhh of state–action pairs and every state sss. It is defined on all such lists, not only on histories that can actually occur. If AAA is empty and SSS is nonempty, no policy exists.

Goal-conditioned policy (GCPolicy). A goal-conditioned policy assigns a policy π(⋅ ;ψ)\pi(\cdot\,;\psi)π(⋅;ψ) to every composite goal ψ\psiψ.

Path weight (pathWeight). Fix a history hhh, a current state sss, and a list of next states s1′,…,sm′s'_1, \dots, s'_ms1′​,…,sm′​. Set

s0=s,h0=h,ai=π(hi,si),hi+1=hi⋅(si,ai),si+1=si+1′.s_0 = s,\quad h_0 = h,\quad a_i = \pi(h_i, s_i),\quad h_{i+1} = h_i \cdot (s_i, a_i),\quad s_{i+1} = s'_{i+1}.s0​=s,h0​=h,ai​=π(hi​,si​),hi+1​=hi​⋅(si​,ai​),si+1​=si+1′​.

The weight is

wπ(h,s;s1′,…,sm′)=∏i=0m−1Psisi+1(ai).w_\pi(h, s; s'_1, \dots, s'_m) = \prod_{i=0}^{m-1} P_{s_i s_{i+1}}(a_i).wπ​(h,s;s1′​,…,sm′​)=i=0∏m−1​Psi​si+1​​(ai​).

For m=0m = 0m=0 the weight is 111.

Path prefix (pathPrefix). With the same notation, the prefix is the finite list

h⋅((s0,a0),(s1,a1),…,(sm,am)).h \cdot \big((s_0, a_0), (s_1, a_1), \dots, (s_m, a_m)\big).h⋅((s0​,a0​),(s1​,a1​),…,(sm​,am​)).

It begins with the given history hhh and has length ∣h∣+m+1|h| + m + 1∣h∣+m+1. In particular it includes the action ama_mam​ taken at the last state.

Decides (Decides). A finite list p=(p0,…,pℓ−1)p = (p_0, \dots, p_{\ell-1})p=(p0​,…,pℓ−1​) of state–action pairs decides ψ\psiψ iff every infinite sequence τ:N→S×A\tau : \mathbb{N} \to S \times Aτ:N→S×A with τ(i)=pi\tau(i) = p_iτ(i)=pi​ for all i<ℓi < \elli<ℓ satisfies τ⊨ψ\tau \models \psiτ⊨ψ. The quantification ranges over all continuations τ\tauτ, including continuations that no policy or transition kernel could produce.

Success probability up to TTT (succProbUpTo). For a goal ψ\psiψ, a policy π\piπ, an initial state s0s_0s0​ and T∈NT \in \mathbb{N}T∈N:

SuccT(ψ,π,s0)=∑(s1,…,sT)∈STwπ(∅,s0;s1,…,sT)⋅1[ (s0,a0,…,sT,aT) decides ψ ].\mathrm{Succ}_T(\psi, \pi, s_0) = \sum_{(s_1, \dots, s_T) \in S^T} w_\pi(\emptyset, s_0; s_1, \dots, s_T)\cdot \mathbf{1}\big[\,(s_0, a_0, \dots, s_T, a_T) \text{ decides } \psi\,\big].SuccT​(ψ,π,s0​)=(s1​,…,sT​)∈ST∑​wπ​(∅,s0​;s1​,…,sT​)⋅1[(s0​,a0​,…,sT​,aT​) decides ψ].

Here the trajectory is generated from the empty history. For T=0T = 0T=0 the value is 111 if the single pair (s0,π(∅,s0))(s_0, \pi(\emptyset, s_0))(s0​,π(∅,s0​)) decides ψ\psiψ, and 000 otherwise.

Success probability (succProb). The success probability is

P(τ⊨ψ∣π,s0)=sup⁡T∈NSuccT(ψ,π,s0).P(\tau \models \psi \mid \pi, s_0) = \sup_{T \in \mathbb{N}} \mathrm{Succ}_T(\psi, \pi, s_0).P(τ⊨ψ∣π,s0​)=T∈Nsup​SuccT​(ψ,π,s0​).

This is a supremum of real numbers. It uses the convention that a set of reals not bounded above has supremum 000. No measure on infinite trajectories is constructed; the quantity is defined only through this supremum.

Optimal success probability (optProb). The optimal success probability is

Opt(ψ,s0)=sup⁡πP(τ⊨ψ∣π,s0),\mathrm{Opt}(\psi, s_0) = \sup_{\pi} P(\tau \models \psi \mid \pi, s_0),Opt(ψ,s0​)=πsup​P(τ⊨ψ∣π,s0​),

taken over all deterministic, history-dependent policies π\piπ. It uses the same real-supremum conventions:

  • If the set of values is not bounded above, the result is 000.
  • If there are no policies at all (AAA empty, SSS nonempty), the supremum is over an empty set and is also 000.

Optimal agent (IsOptimalAgent). Given a set Ψ\PsiΨ of composite goals, a goal-conditioned policy π\piπ is optimal for Ψ\PsiΨ iff, for every ψ∈Ψ\psi \in \Psiψ∈Ψ and every s0∈Ss_0 \in Ss0​∈S,

P(τ⊨ψ∣π(⋅ ;ψ),s0)=Opt(ψ,s0).P(\tau \models \psi \mid \pi(\cdot\,;\psi), s_0) = \mathrm{Opt}(\psi, s_0).P(τ⊨ψ∣π(⋅;ψ),s0​)=Opt(ψ,s0​).

The condition is equality, not merely "≥\ge≥". If Ψ\PsiΨ is empty, every π\piπ qualifies.

Bounded agent (IsBoundedAgent). For a real δ\deltaδ and n∈Nn \in \mathbb{N}n∈N, π\piπ is a bounded agent with failure rate δ\deltaδ and depth nnn iff 0≤δ≤10 \le \delta \le 10≤δ≤1 and, for every ψ∈Ψn\psi \in \Psi_nψ∈Ψn​ and every s0∈Ss_0 \in Ss0​∈S,

Opt(ψ,s0) (1−δ)  ≤  P(τ⊨ψ∣π(⋅ ;ψ),s0).\mathrm{Opt}(\psi, s_0)\,(1 - \delta) \;\le\; P(\tau \models \psi \mid \pi(\cdot\,;\psi), s_0).Opt(ψ,s0​)(1−δ)≤P(τ⊨ψ∣π(⋅;ψ),s0​).

Two degenerate cases:

  • For n=0n = 0n=0, Ψ0\Psi_0Ψ0​ is empty, so the condition reduces to 0≤δ≤10 \le \delta \le 10≤δ≤1.
  • For δ=1\delta = 1δ=1, the inequality reads 0≤P(τ⊨ψ∣π(⋅ ;ψ),s0)0 \le P(\tau \models \psi \mid \pi(\cdot\,;\psi), s_0)0≤P(τ⊨ψ∣π(⋅;ψ),s0​).

Myopic goals (PsiMyopic). Ψmyopic\Psi_{\text{myopic}}Ψmyopic​ is the set of ψ∈Ψ1\psi \in \Psi_1ψ∈Ψ1​ all of whose sub-goals use the operator ◯\bigcirc◯. Equivalently, ψ\psiψ is a nonempty list of one-element sequences ⟨◯gj⟩\langle \bigcirc g_j \rangle⟨◯gj​⟩, read as

◯g1∨⋯∨◯gm(m≥1),\bigcirc g_1 \vee \cdots \vee \bigcirc g_m \qquad (m \ge 1),◯g1​∨⋯∨◯gm​(m≥1),

where the sets gj⊆S×Ag_j \subseteq S \times Agj​⊆S×A are arbitrary.

Named sub-goals (nowAct, evVisit, evState, nextIn).

  • nowAct(a)=(⊤, {(x,y):y=a})\mathrm{nowAct}(a) = \big(\top,\ \{(x, y) : y = a\}\big)nowAct(a)=(⊤, {(x,y):y=a}).
  • evVisit(s,a)=(◊, {(s,a)})\mathrm{evVisit}(s, a) = \big(\Diamond,\ \{(s, a)\}\big)evVisit(s,a)=(◊, {(s,a)}).
  • evState(s′)=(◊, {(x,y):x=s′})\mathrm{evState}(s') = \big(\Diamond,\ \{(x, y) : x = s'\}\big)evState(s′)=(◊, {(x,y):x=s′}).
  • nextIn(Y)=(◯, {(x,y):x∈Y})\mathrm{nextIn}(Y) = \big(\bigcirc,\ \{(x, y) : x \in Y\}\big)nextIn(Y)=(◯, {(x,y):x∈Y}) for any Y⊆SY \subseteq SY⊆S.

Trial sequence (trialSeq). For actions b,ab, ab,a, states s,s′s, s's,s′, and a finite Boolean list o=(o1,…,om)o = (o_1, \dots, o_m)o=(o1​,…,om​), the trial sequence is the sequential goal

⟨nowAct(b), evVisit(s,a), O1, evVisit(s,a), O2, …, evVisit(s,a), Om⟩,\big\langle \mathrm{nowAct}(b),\ \mathrm{evVisit}(s,a),\ O_1,\ \mathrm{evVisit}(s,a),\ O_2,\ \dots,\ \mathrm{evVisit}(s,a),\ O_m \big\rangle,⟨nowAct(b), evVisit(s,a), O1​, evVisit(s,a), O2​, …, evVisit(s,a), Om​⟩,

where

Oi={nextIn({s′})if oi is true,nextIn(S∖{s′})otherwise.O_i = \begin{cases} \mathrm{nextIn}(\{s'\}) & \text{if } o_i \text{ is true}, \\ \mathrm{nextIn}(S \setminus \{s'\}) & \text{otherwise.} \end{cases}Oi​={nextIn({s′})nextIn(S∖{s′})​if oi​ is true,otherwise.​

Its length is 1+2m1 + 2m1+2m. For m=0m = 0m=0 it is just ⟨nowAct(b)⟩\langle \mathrm{nowAct}(b)\rangle⟨nowAct(b)⟩. The actions aaa and bbb are not required to differ.

Binomial goal (binGoal). For actions b,ab, ab,a, states s,s′s, s's,s′, m∈Nm \in \mathbb{N}m∈N, and an arbitrary predicate RRR on N\mathbb{N}N, the binomial goal is the composite goal listing trialSeq(b,s,a,s′,o)\mathrm{trialSeq}(b, s, a, s', o)trialSeq(b,s,a,s′,o) once for each o∈{true,false}mo \in \{\text{true}, \text{false}\}^mo∈{true,false}m such that

R(#{i:oi=true})R\big(\#\{i : o_i = \text{true}\}\big)R(#{i:oi​=true})

holds. The order of the disjuncts is unspecified. If no pattern satisfies RRR, the list is empty and no trajectory satisfies the goal.

Two-action goal (abGoal). For actions a,ba, ba,b, states s,s′s, s's,s′, and m,k∈Nm, k \in \mathbb{N}m,k∈N, the two-action goal is the concatenation of two binomial goals:

ψa,b(k,m)=binGoal(a,s,a,s′,m, r≤k)  ∨  binGoal(b,s,a,s′,m, r>k).\psi_{a,b}(k, m) = \mathrm{binGoal}\big(a, s, a, s', m,\ r \le k\big) \;\vee\; \mathrm{binGoal}\big(b, s, a, s', m,\ r > k\big).ψa,b​(k,m)=binGoal(a,s,a,s′,m, r≤k)∨binGoal(b,s,a,s′,m, r>k).
  • The first part starts with action aaa and has at most kkk true outcomes.
  • The second part starts with action bbb and has more than kkk true outcomes.
  • Both parts use visits to the pair (s,a)(s, a)(s,a).

Binomial mass function (binPmf). For m,r∈Nm, r \in \mathbb{N}m,r∈N and any real ppp (not restricted to [0,1][0,1][0,1]):

binPmf(m,p,r)=(mr)pr(1−p)m−r.\mathrm{binPmf}(m, p, r) = \binom{m}{r} p^r (1-p)^{m - r}.binPmf(m,p,r)=(rm​)pr(1−p)m−r.

Here m−rm - rm−r is truncated at 000 and 00=10^0 = 100=1. For r>mr > mr>m the value is 000 because (mr)=0\binom{m}{r} = 0(rm​)=0.

Lower tail (binLE). For k∈Nk \in \mathbb{N}k∈N:

binLE(m,p,k)=∑r=0kbinPmf(m,p,r).\mathrm{binLE}(m, p, k) = \sum_{r=0}^{k} \mathrm{binPmf}(m, p, r).binLE(m,p,k)=r=0∑k​binPmf(m,p,r).

kkk may exceed mmm; the extra terms are 000.

Upper tail (binGE). For k∈Nk \in \mathbb{N}k∈N:

binGE(m,p,k)=∑r=kmbinPmf(m,p,r).\mathrm{binGE}(m, p, k) = \sum_{r=k}^{m} \mathrm{binPmf}(m, p, r).binGE(m,p,k)=r=k∑m​binPmf(m,p,r).

This is 000 when k>mk > mk>m.

Lifted goal (liftGoal). Given a composite goal ψ\psiψ over S×AS \times AS×A, its lift is a composite goal over S×A′S \times A'S×A′, where A′=A∪{aˉ}A' = A \cup \{\bar a\}A′=A∪{aˉ} adds one new action aˉ\bar aaˉ. The lift has the same list structure and the same operators. Each goal set ggg is replaced by

{(x,y):(x,y)∈g}⊆S×A′,\{(x, y) : (x, y) \in g\} \subseteq S \times A',{(x,y):(x,y)∈g}⊆S×A′,

so the new action aˉ\bar aaˉ appears in no goal set.

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