Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 4 (as proved): factoring a Next sub-goal followed by an Eventually sub-goal

Proved
GeneralAgentsWorldModels.lemma4_factor_next_eventually

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

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

Let the environment satisfy Assumption 1, let ψ=⟨φ1,φ2,φ3,…,φL⟩\psi=\langle\varphi_1,\varphi_2,\varphi_3,\dots,\varphi_L\rangleψ=⟨φ1​,φ2​,φ3​,…,φL​⟩ with φ1=\medcirc([S∈g1])\varphi_1=\medcirc([S\in g_1])φ1​=\medcirc([S∈g1​]) for a set of states g1⊆Sg_1\subseteq Sg1​⊆S and φ2=◊([S=sg,A=ag])\varphi_2=\Diamond([S=s_g,A=a_g])φ2​=◊([S=sg​,A=ag​]), and let μ\muμ be a deterministic stationary Markov policy such that from every state x∈g1x\in g_1x∈g1​, μ\muμ eventually reaches sgs_gsg​ and takes aga_gag​ there with probability one. Then

P(τ⊨ψ∣s0,μ)=P(S1∈g1∣s0,μ) P(τ⊨⟨φ3,…,φL⟩∣sg,μ),P(\tau\models\psi\mid s_0,\mu)=P(S_1\in g_1\mid s_0,\mu)\,P\big(\tau\models\langle\varphi_3,\dots,\varphi_L\rangle\mid s_g,\mu\big),P(τ⊨ψ∣s0​,μ)=P(S1​∈g1​∣s0​,μ)P(τ⊨⟨φ3​,…,φL​⟩∣sg​,μ),

where P(S1∈g1∣s0,μ)=∑x∈g1Ps0x(μ(s0))P(S_1\in g_1\mid s_0,\mu)=\sum_{x\in g_1}P_{s_0x}(\mu(s_0))P(S1​∈g1​∣s0​,μ)=∑x∈g1​​Ps0​x​(μ(s0​)).

Formalization Note The printed Lemma 4 assumes only that μ\muμ is deterministic and Markovian. Its proof applies Lemma 3 from each s1∈g1s_1\in g_1s1​∈g1​ (eq. (20)), which needs the reachability hypothesis added here; without it the printed identity fails (a policy that never reaches sgs_gsg​ gives 000 on the left and P(S1∈g1∣s0,μ)>0P(S_1\in g_1\mid s_0,\mu)>0P(S1​∈g1​∣s0​,μ)>0 on the right when L=2L=2L=2).

Preamble
import Mathlib
import Definitions.Def_GeneralAgentsWorldModels_Basic

open Finset
Formal statement
namespace GeneralAgentsWorldModels

theorem lemma4_factor_next_eventually {S A : Type*} [Fintype S] [DecidableEq S] [Fintype A]
    (M : CMP S A) (hM : SatisfiesAssumption1 M) (μ : S → A) (g₁ : Set S) (sg : S) (ag : A)
    (rest : SeqGoal S A) (s₀ : S)
    (hreach : ∀ x ∈ g₁, succProb M [[evVisit sg ag]] (fun _ y => μ y) x = 1) :
    succProb M [nextIn g₁ :: evVisit sg ag :: rest] (fun _ y => μ y) s₀ =
      (∑ x : S, g₁.indicator (fun y => M.P s₀ (μ s₀) y) x) *
        succProb M [rest] (fun _ y => μ y) sg := by sorry

end GeneralAgentsWorldModels
Source
Richens, Abel, Bellot and Everitt, General agents contain world models, arXiv:2506.01622v5 (ICML 2025), Appendix A.6, Lemma 4, eqs. (15)-(21), p. 15 (uses Lemma 3 at eq. (20))
Read-back

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

Let SSS be a finite, nonempty-or-empty set of states with decidable equality, and AAA a finite set of actions. Let MMM be a controlled Markov process on SSS with actions AAA. It is given by transition probabilities Pss′(a)≥0P_{ss'}(a) \ge 0Pss′​(a)≥0, with ∑s′Pss′(a)=1\sum_{s'} P_{ss'}(a) = 1∑s′​Pss′​(a)=1 for every s∈Ss \in Ss∈S and a∈Aa \in Aa∈A, and these do not depend on time.

Assume MMM satisfies Assumption 1:

  • AAA has at least two elements.
  • MMM is communicating: for any two distinct states s≠s′s \ne s's=s′ there is a finite chain s=x0,x1,…,xk=s′s = x_0, x_1, \dots, x_k = s's=x0​,x1​,…,xk​=s′ with k≥1k \ge 1k≥1 such that each step has Pxixi+1(a)>0P_{x_{i}x_{i+1}}(a) > 0Pxi​xi+1​​(a)>0 for some action aaa.

Further, fix:

  • a map μ:S→A\mu : S \to Aμ:S→A, used as the deterministic stationary policy that plays μ(s)\mu(s)μ(s) in state sss, ignoring all history;
  • a set g1⊆Sg_1 \subseteq Sg1​⊆S;
  • a state sg∈Ss_g \in Ssg​∈S and an action ag∈Aa_g \in Aag​∈A;
  • a finite, possibly empty, list ρ=⟨φ1,…,φL⟩\rho = \langle \varphi_1, \dots, \varphi_L \rangleρ=⟨φ1​,…,φL​⟩ of sub-goals;
  • an initial state s0∈Ss_0 \in Ss0​∈S.

Goals and satisfaction. A sub-goal is a pair (O,g)(O, g)(O,g) with O∈{⊤,◯,◊}O \in \{\top, \bigcirc, \Diamond\}O∈{⊤,◯,◊} (Now, Next, Eventually) and g⊆S×Ag \subseteq S \times Ag⊆S×A. Let τ=((s0,a0),(s1,a1),… )\tau = ((s_0,a_0),(s_1,a_1),\dots)τ=((s0​,a0​),(s1​,a1​),…) be an infinite trajectory. A list of sub-goals is evaluated at time ttt as follows:

  • The empty list holds.
  • ⟨(⊤,g),… ⟩\langle (\top,g), \dots\rangle⟨(⊤,g),…⟩ holds at ttt iff (st,at)∈g(s_t,a_t) \in g(st​,at​)∈g and the remainder holds at ttt.
  • ⟨(◯,g),… ⟩\langle (\bigcirc,g), \dots\rangle⟨(◯,g),…⟩ holds at ttt iff (st+1,at+1)∈g(s_{t+1},a_{t+1}) \in g(st+1​,at+1​)∈g and the remainder holds at t+1t+1t+1.
  • ⟨(◊,g),… ⟩\langle (\Diamond,g), \dots\rangle⟨(◊,g),…⟩ holds at ttt iff there is a u≥tu \ge tu≥t such that (sv,av)∉g(s_v,a_v)\notin g(sv​,av​)∈/g for t≤v<ut \le v < ut≤v<u, (su,au)∈g(s_u,a_u) \in g(su​,au​)∈g, and the remainder holds at uuu. Here uuu is the first time at or after ttt that ggg is hit.

A composite goal, given as a list of sequential goals, is satisfied by τ\tauτ iff some member holds at time 000. Writing [ψ][\psi][ψ] for the composite goal consisting of the single sequential goal ψ\psiψ, this theorem uses:

  • ◯[S∈g1]=(◯,{(s,a):s∈g1})\bigcirc[S \in g_1] = (\bigcirc, \{(s,a) : s \in g_1\})◯[S∈g1​]=(◯,{(s,a):s∈g1​});
  • ◊[S=sg,A=ag]=(◊,{(sg,ag)})\Diamond[S=s_g, A=a_g] = (\Diamond, \{(s_g,a_g)\})◊[S=sg​,A=ag​]=(◊,{(sg​,ag​)}).

Success probability. For a composite goal Ψ\PsiΨ and a start state sss, define

Pr⁡μ,s(τ⊨Ψ)=sup⁡T∈N∑(s1,…,sT)∈ST(∏i=1TPsi−1si(μ(si−1)))⋅1[the prefix ((s0′,μ(s0′)),…,(sT,μ(sT))) decides Ψ],\Pr_{\mu,s}(\tau \models \Psi) = \sup_{T \in \mathbb N} \sum_{(s_1,\dots,s_T)\in S^T} \Big(\prod_{i=1}^{T} P_{s_{i-1}s_i}(\mu(s_{i-1}))\Big)\cdot \mathbf 1\big[\text{the prefix } ((s_0',\mu(s_0')),\dots,(s_T,\mu(s_T))) \text{ decides } \Psi\big],μ,sPr​(τ⊨Ψ)=T∈Nsup​(s1​,…,sT​)∈ST∑​(i=1∏T​Psi−1​si​​(μ(si−1​)))⋅1[the prefix ((s0′​,μ(s0′​)),…,(sT​,μ(sT​))) decides Ψ],

where the product's starting state is s0′=ss_0' = ss0′​=s. A finite prefix "decides" Ψ\PsiΨ if every infinite sequence of state–action pairs extending it satisfies Ψ\PsiΨ. These extensions are arbitrary and need not be consistent with MMM or μ\muμ.

Hypothesis. For every x∈g1x \in g_1x∈g1​,

Pr⁡μ,x(τ⊨[⟨◊[S=sg,A=ag]⟩])=1.\Pr_{\mu,x}\big(\tau \models [\langle \Diamond[S=s_g, A=a_g]\rangle]\big) = 1.μ,xPr​(τ⊨[⟨◊[S=sg​,A=ag​]⟩])=1.

That is, started from xxx, the pair (sg,ag)(s_g,a_g)(sg​,ag​) is reached at some time ≥0\ge 0≥0 with probability 111; time 000 counts. Two consequences:

  • Under μ\muμ the pair at any visit to sgs_gsg​ is (sg,μ(sg))(s_g,\mu(s_g))(sg​,μ(sg​)). So if μ(sg)≠ag\mu(s_g) \ne a_gμ(sg​)=ag​, this hypothesis can only hold when g1=∅g_1 = \varnothingg1​=∅.
  • If g1=∅g_1 = \varnothingg1​=∅, the hypothesis holds vacuously.

Conclusion.

Pr⁡μ,s0(τ⊨[⟨◯[S∈g1], ◊[S=sg,A=ag], φ1,…,φL⟩])=(∑x∈g1Ps0x(μ(s0)))⋅Pr⁡μ,sg(τ⊨[ρ]).\Pr_{\mu,s_0}\big(\tau \models [\langle \bigcirc[S\in g_1],\ \Diamond[S=s_g,A=a_g],\ \varphi_1,\dots,\varphi_L\rangle]\big) = \Big(\sum_{x \in g_1} P_{s_0x}(\mu(s_0))\Big)\cdot \Pr_{\mu,s_g}\big(\tau \models [\rho]\big).μ,s0​Pr​(τ⊨[⟨◯[S∈g1​], ◊[S=sg​,A=ag​], φ1​,…,φL​⟩])=(x∈g1​∑​Ps0​x​(μ(s0​)))⋅μ,sg​Pr​(τ⊨[ρ]).

Here ∑x∈g1Ps0x(μ(s0))\sum_{x\in g_1}P_{s_0x}(\mu(s_0))∑x∈g1​​Ps0​x​(μ(s0​)) is the probability that the first transition from s0s_0s0​ under action μ(s0)\mu(s_0)μ(s0​) lands in g1g_1g1​.

On the right, ρ\rhoρ is evaluated on a fresh trajectory started at sgs_gsg​ at time 000, whose first pair is (sg,μ(sg))(s_g,\mu(s_g))(sg​,μ(sg​)). On the left, the remaining sub-goals φ1,…,φL\varphi_1,\dots,\varphi_Lφ1​,…,φL​ are evaluated from the first time u≥1u \ge 1u≥1 at which (su,au)=(sg,ag)(s_u,a_u) = (s_g,a_g)(su​,au​)=(sg​,ag​).

When ρ\rhoρ is empty, the composite goal [⟨⟩][\langle\rangle][⟨⟩] is satisfied by every trajectory, and the right-hand factor Pr⁡μ,sg([⟨⟩])\Pr_{\mu,s_g}([\langle\rangle])Prμ,sg​​([⟨⟩]) equals 111.

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