Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Latent causal model, information-theoretic JEPA objective and action-variability assumption

Definition
IActThereforeIAm_Basic

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

causal-representation-learningidentifiabilityjepamutual-informationworld-models

Objects of Sections 2-3 and Appendices C-E of Liu, Huang and Shi (2026).

  1. Latent causal model (Eqs. 1-3). The latent state is st∈Rd\mathbf s_t\in\mathbb R^dst​∈Rd and actions lie in a measurable space AAA. The pair (st−1,at−1)(\mathbf s_{t-1},\mathbf a_{t-1})(st−1​,at−1​) has a probability law ν\nuν. Each coordinate evolves as st,i=fi(st−1,pai,at−1,ϵt,i)s_{t,i}=f_i(\mathbf s_{t-1,\mathrm{pa}_i},\mathbf a_{t-1},\epsilon_{t,i})st,i​=fi​(st−1,pai​​,at−1​,ϵt,i​) with jointly measurable mechanisms fif_ifi​, parent sets pai⊆{1,…,d}\mathrm{pa}_i\subseteq\{1,\dots,d\}pai​⊆{1,…,d}, and disturbances ϵt,1,…,ϵt,d\epsilon_{t,1},\dots,\epsilon_{t,d}ϵt,1​,…,ϵt,d​ that are independent of each other and of (st−1,at−1)(\mathbf s_{t-1},\mathbf a_{t-1})(st−1​,at−1​), with laws ηi\eta_iηi​. All statements use the resulting joint law PPP of ((st−1,at−1),st)((\mathbf s_{t-1},\mathbf a_{t-1}),\mathbf s_t)((st−1​,at−1​),st​). Observations are xt=g(st)\mathbf x_t=\mathbf g(\mathbf s_t)xt​=g(st​).
  2. Information quantities. I(X;Y)=DKL(P(X,Y) ∥ PX⊗PY)∈[0,∞]I(X;Y)=D_{\mathrm{KL}}(P_{(X,Y)}\,\|\,P_X\otimes P_Y)\in[0,\infty]I(X;Y)=DKL​(P(X,Y)​∥PX​⊗PY​)∈[0,∞], in nats. For a law μ\muμ on Rd\mathbb R^dRd with Lebesgue density fff, the differential entropy is H(μ)=−∫flog⁡fH(\mu)=-\int f\log fH(μ)=−∫flogf. It is set to −∞-\infty−∞ when μ\muμ has no density or flog⁡ff\log fflogf is not integrable. The open unit cube is (0,1)d(0,1)^d(0,1)d.
  3. Objective (Eq. 4). For an encoder h:X→(0,1)d\mathbf h:\mathcal X\to(0,1)^dh:X→(0,1)d, write zt=h(g(st))\mathbf z_t=\mathbf h(\mathbf g(\mathbf s_t))zt​=h(g(st​)) and ct=(zt−1,at−1)\mathbf c_t=(\mathbf z_{t-1},\mathbf a_{t-1})ct​=(zt−1​,at−1​). A transition model p(z∣c)p(\mathbf z\mid\mathbf c)p(z∣c) is jointly measurable and, for each c\mathbf cc, a probability density on Rd\mathbb R^dRd. The objective is
Lλ(h,p)=−E[log⁡p(zt∣ct)]−λH(zt).\mathcal L_\lambda(\mathbf h,p)=-\mathbb E[\log p(\mathbf z_t\mid\mathbf c_t)]-\lambda H(\mathbf z_t).Lλ​(h,p)=−E[logp(zt​∣ct​)]−λH(zt​).

A pair is admissible if h\mathbf hh is measurable with values in (0,1)d(0,1)^d(0,1)d, p(zt∣ct)>0p(\mathbf z_t\mid\mathbf c_t)>0p(zt​∣ct​)>0 a.s., the log-likelihood is integrable, and H(zt)>−∞H(\mathbf z_t)>-\inftyH(zt​)>−∞; on admissible pairs Lλ\mathcal L_\lambdaLλ​ is a real number. A global minimizer over a parameterized model {pϕ}ϕ∈Θ\{p_\phi\}_{\phi\in\Theta}{pϕ​}ϕ∈Θ​ is an admissible pair (h,ϕ)(\mathbf h,\phi)(h,ϕ) whose objective is at most that of every admissible pair (h′,ϕ′)(\mathbf h',\phi')(h′,ϕ′). 4. Induced transition density (Eq. 6). ppp is a version of Qh(zt∣ct)Q_{\mathbf h}(\mathbf z_t\mid\mathbf c_t)Qh​(zt​∣ct​) when the joint law of (ct,zt)(\mathbf c_t,\mathbf z_t)(ct​,zt​) equals the law of ct\mathbf c_tct​ times p(z∣c) dzp(\mathbf z\mid\mathbf c)\,d\mathbf zp(z∣c)dz. 5. Assumption 3.1. g\mathbf gg is smooth (C∞C^\inftyC∞) and injective. 6. Assumption 3.2 (Eqs. 7-8). The functions pi(u∣st−1,at−1)p_i(u\mid\mathbf s_{t-1},\mathbf a_{t-1})pi​(u∣st−1​,at−1​) are densities of the conditional laws of st,is_{t,i}st,i​. They are positive, C2C^2C2 in uuu and jointly continuous. With qi=log⁡piq_i=\log p_iqi​=logpi​,

w(st,st−1,a)=(∂q1∂st,1,…,∂qd∂st,d,∂2q1∂st,12,…,∂2qd∂st,d2)⊤.\mathbf w(\mathbf s_t,\mathbf s_{t-1},\mathbf a)=\Big(\tfrac{\partial q_1}{\partial s_{t,1}},\dots,\tfrac{\partial q_d}{\partial s_{t,d}},\tfrac{\partial^2 q_1}{\partial s_{t,1}^2},\dots,\tfrac{\partial^2 q_d}{\partial s_{t,d}^2}\Big)^\top.w(st​,st−1​,a)=(∂st,1​∂q1​​,…,∂st,d​∂qd​​,∂st,12​∂2q1​​,…,∂st,d2​∂2qd​​)⊤.

Action variability means that for all st,st−1\mathbf s_t,\mathbf s_{t-1}st​,st−1​ there are actions a(0),…,a(2d)\mathbf a^{(0)},\dots,\mathbf a^{(2d)}a(0),…,a(2d) for which the 2d2d2d vectors w(a(ℓ))−w(a(0))\mathbf w(\mathbf a^{(\ell)})-\mathbf w(\mathbf a^{(0)})w(a(ℓ))−w(a(0)) are linearly independent, i.e. the matrix L\mathbf LL is invertible. 7. Factorized model (Eq. 47). pϕ(z∣c)=∏jpϕ,j(zj∣c)p_\phi(\mathbf z\mid\mathbf c)=\prod_j p_{\phi,j}(z_j\mid\mathbf c)pϕ​(z∣c)=∏j​pϕ,j​(zj​∣c). On the encoder range, i.e. for c=(zt−1,a)\mathbf c=(\mathbf z_{t-1},\mathbf a)c=(zt−1​,a) with zt−1∈(0,1)d\mathbf z_{t-1}\in(0,1)^dzt−1​∈(0,1)d and zj∈(0,1)z_j\in(0,1)zj​∈(0,1), the factors are positive, C2C^2C2 in zjz_jzj​ and jointly continuous. Outside this range they are unrestricted. 8. Contrastive term (Eqs. 56-59). ∥v∥2=∑ivi2\|v\|^2=\sum_i v_i^2∥v∥2=∑i​vi2​. The Gaussian negative log-likelihood is ℓ(z)=∥z−m∥2/(2σ2)+d2log⁡(2πσ2)\ell(\mathbf z)=\|\mathbf z-\mathbf m\|^2/(2\sigma^2)+\tfrac d2\log(2\pi\sigma^2)ℓ(z)=∥z−m∥2/(2σ2)+2d​log(2πσ2). The Gaussian kernel is φb(x)=(2πb2)−d/2e−∥x∥2/(2b2)\varphi_b(x)=(2\pi b^2)^{-d/2}e^{-\|x\|^2/(2b^2)}φb​(x)=(2πb2)−d/2e−∥x∥2/(2b2). The contrastive term is UK=log⁡[1K∑k=1Ke−ℓ(z(k))/τ]U_K=\log\big[\tfrac1K\sum_{k=1}^K e^{-\ell(\mathbf z^{(k)})/\tau}\big]UK​=log[K1​∑k=1K​e−ℓ(z(k))/τ], and (pz∗φb)(zt)=∫φb(z−zt) dpz(z)(p_{\mathbf z}*\varphi_b)(\mathbf z_t)=\int\varphi_b(\mathbf z-\mathbf z_t)\,dp_{\mathbf z}(\mathbf z)(pz​∗φb​)(zt​)=∫φb​(z−zt​)dpz​(z).

Formalization Note The SCM is encoded by its mechanisms, noise laws and the law of (st−1,at−1)(\mathbf s_{t-1},\mathbf a_{t-1})(st−1​,at−1​); the joint law is the push-forward of ν⊗⨂iηi\nu\otimes\bigotimes_i\eta_iν⊗⨂i​ηi​. The DAG requirement holds for every choice of parent sets, because all edges go from time t−1t-1t−1 to time ttt. Mutual information uses Mathlib's InformationTheory.klDiv. The objective is real-valued and is only used on admissible pairs, where it equals the paper's value. Encoders and observation spaces are general: X\mathcal XX is a measurable space, and a real normed space in Theorem 3.3.

Definition code
import Mathlib

/-!
Liu, Huang and Shi, *I Act Therefore I Am: When Is JEPA's Action-Conditioning Enough to Learn
Causal Mechanisms?*, arXiv:2609.31161v1 (2026): the latent causal generative model of Section 2.1
(Eqs. (1)-(3)), the information-theoretic JEPA objective of Section 2.2 (Eq. (4)), the induced
transition density of Theorem 2.1 (Eq. (6)), Assumptions 3.1 and 3.2 of Section 3 (Eqs. (7)-(8)),
the factorized transition model of Appendix D (Eq. (47)), and the Gaussian contrastive term of
Appendix E (Eqs. (56)-(58)).
-/

open MeasureTheory
open scoped ENNReal ContDiff

noncomputable section

namespace IActThereforeIAm

/-- Section 2.1, Eqs. (1)-(2): a latent causal generative model. The latent state is
`s_t ∈ ℝ^d`, actions lie in `A`, and `s_{t,i} := f_i(s_{t-1,pa_i}, a_{t-1}, ε_{t,i})`, where the
disturbances `ε_{t,1}, …, ε_{t,d}` are mutually independent and independent of `(s_{t-1}, a_{t-1})`.
The observation `x_t = g(s_t)` is attached separately, as a map `g`. -/
structure LatentSCM (d : ℕ) (A : Type*) [MeasurableSpace A] where
  /-- The parent set `pa_i ⊆ {1, …, d}` of `s_{t,i}` in `s_{t-1}`. -/
  pa : Fin d → Finset (Fin d)
  /-- The mechanism `f_i(s_{t-1}, a_{t-1}, ε_{t,i})`. -/
  mech : Fin d → (Fin d → ℝ) → A → ℝ → ℝ
  /-- The law of the disturbance `ε_{t,i}`. -/
  noise : Fin d → Measure ℝ
  /-- The joint law of `(s_{t-1}, a_{t-1})`. -/
  prev : Measure ((Fin d → ℝ) × A)

/-- Section 2.1: the standing conditions on a latent causal model. The laws of `(s_{t-1}, a_{t-1})`
and of each disturbance are probability measures, each mechanism is jointly measurable, and
`f_i` depends on `s_{t-1}` only through its parents `s_{t-1,pa_i}`. -/
def LatentSCM.IsValid {d : ℕ} {A : Type*} [MeasurableSpace A] (M : LatentSCM d A) : Prop :=
  IsProbabilityMeasure M.prev ∧ (∀ i, IsProbabilityMeasure (M.noise i)) ∧
  (∀ i, Measurable (fun x : ((Fin d → ℝ) × A) × ℝ => M.mech i x.1.1 x.1.2 x.2)) ∧
  (∀ i (s s' : Fin d → ℝ) (a : A) (e : ℝ), (∀ j ∈ M.pa i, s j = s' j) →
    M.mech i s a e = M.mech i s' a e)

/-- Section 2.1, Eqs. (1) and (3): the joint law of `((s_{t-1}, a_{t-1}), s_t)`, obtained by drawing
`(s_{t-1}, a_{t-1})` and independent disturbances `ε_{t,i}` and applying the mechanisms. -/
def LatentSCM.jointLaw {d : ℕ} {A : Type*} [MeasurableSpace A] (M : LatentSCM d A) :
    Measure (((Fin d → ℝ) × A) × (Fin d → ℝ)) :=
  (M.prev.prod (Measure.pi M.noise)).map
    (fun x => (x.1, fun i => M.mech i x.1.1 x.1.2 (x.2 i)))

/-- Section 2.2: the mutual information `I(X; Y)` of random variables `X`, `Y` on `(Ω, P)`, the
Kullback-Leibler divergence of their joint law from the product of their laws (in nats, valued
in `[0, ∞]`). -/
def mutualInfo {Ω α β : Type*} [MeasurableSpace Ω] [MeasurableSpace α] [MeasurableSpace β]
    (P : Measure Ω) (X : Ω → α) (Y : Ω → β) : ℝ≥0∞ :=
  InformationTheory.klDiv (P.map fun w => (X w, Y w)) ((P.map X).prod (P.map Y))

/-- Theorem 2.1, Eq. (5): `I(s_t; s_{t-1}, a_{t-1})` under the latent model. -/
def latentInfo {d : ℕ} {A : Type*} [MeasurableSpace A] (M : LatentSCM d A) : ℝ≥0∞ :=
  mutualInfo M.jointLaw (fun w => w.2) (fun w => w.1)

/-- Theorem 2.1, Eq. (5): `I(z_t; z_{t-1}, a_{t-1})` for the representation `z = h(g(s))`. -/
def reprInfo {d : ℕ} {A X : Type*} [MeasurableSpace A] [MeasurableSpace X] (M : LatentSCM d A)
    (g : (Fin d → ℝ) → X) (h : X → Fin d → ℝ) : ℝ≥0∞ :=
  mutualInfo M.jointLaw (fun w => h (g w.2)) (fun w => (h (g w.1.1), w.1.2))

/-- Section 2.2: the law of the representation `z_t = h(x_t) = h(g(s_t))`. -/
def reprLaw {d : ℕ} {A X : Type*} [MeasurableSpace A] [MeasurableSpace X] (M : LatentSCM d A)
    (g : (Fin d → ℝ) → X) (h : X → Fin d → ℝ) : Measure (Fin d → ℝ) :=
  M.jointLaw.map fun w => h (g w.2)

/-- Theorem 2.1: the open unit cube `(0, 1)^d`, the range of the encoder. -/
def unitCube (d : ℕ) : Set (Fin d → ℝ) :=
  Set.pi Set.univ fun _ => Set.Ioo (0 : ℝ) 1

open Classical in
/-- Section 2.2, Eq. (4): the differential entropy `H(μ) = -∫ f log f` of a law `μ` on `ℝ^d` with
Lebesgue density `f`. It is `-∞` (`⊥`) when `μ` has no density or `f log f` is not integrable;
for laws carried by a bounded set, such as `(0,1)^d`, this is the standard value. -/
def diffEntropy {d : ℕ} (μ : Measure (Fin d → ℝ)) : EReal :=
  if μ ≪ volume ∧ Integrable (fun z => Real.negMulLog (μ.rnDeriv volume z).toReal) volume then
    ((∫ z, Real.negMulLog (μ.rnDeriv volume z).toReal : ℝ) : EReal)
  else ⊥

/-- Section 2.2: `p(z_t | z_{t-1}, a_{t-1})` is an action-conditioned transition model on `ℝ^d`:
jointly measurable and, for each context `c = (z_{t-1}, a_{t-1})`, a probability density. -/
def IsTransitionModel {d : ℕ} {A : Type*} [MeasurableSpace A]
    (p : (Fin d → ℝ) × A → (Fin d → ℝ) → ℝ) : Prop :=
  Measurable (fun x : ((Fin d → ℝ) × A) × (Fin d → ℝ) => p x.1 x.2) ∧ (∀ c z, 0 ≤ p c z) ∧
    ∀ c, ∫ z, p c z = 1

/-- Section 2.2, Eq. (4): the objective
`L_λ(h, φ) = -E[log p_φ(z_t | z_{t-1}, a_{t-1})] - λ H(z_t)` with `z = h(g(s))`. It is the
paper's (finite) value on admissible pairs (`IsAdmissible`). -/
def objective {d : ℕ} {A X : Type*} [MeasurableSpace A] [MeasurableSpace X] (M : LatentSCM d A)
    (g : (Fin d → ℝ) → X) (lam : ℝ) (h : X → Fin d → ℝ)
    (p : (Fin d → ℝ) × A → (Fin d → ℝ) → ℝ) : ℝ :=
  -(∫ w, Real.log (p (h (g w.1.1), w.1.2) (h (g w.2))) ∂M.jointLaw) -
    lam * (diffEntropy (reprLaw M g h)).toReal

/-- Theorem 2.1: an admissible pair `(h, p_φ)`. The encoder `h : X → (0,1)^d` is measurable, `p_φ`
is a transition model, and both terms of Eq. (4) are finite: the log-likelihood is a.s. defined
(`p_φ > 0`) and integrable, and `z_t` has finite differential entropy. -/
def IsAdmissible {d : ℕ} {A X : Type*} [MeasurableSpace A] [MeasurableSpace X]
    (M : LatentSCM d A) (g : (Fin d → ℝ) → X) (h : X → Fin d → ℝ)
    (p : (Fin d → ℝ) × A → (Fin d → ℝ) → ℝ) : Prop :=
  Measurable h ∧ (∀ x i, h x i ∈ Set.Ioo (0 : ℝ) 1) ∧ IsTransitionModel p ∧
    (∀ᵐ w ∂M.jointLaw, 0 < p (h (g w.1.1), w.1.2) (h (g w.2))) ∧
    Integrable (fun w => Real.log (p (h (g w.1.1), w.1.2) (h (g w.2)))) M.jointLaw ∧
    diffEntropy (reprLaw M g h) ≠ ⊥

/-- Theorems 2.1 and 3.3: `(h, φ)` is a global minimizer of Eq. (4) over all admissible pairs of an
encoder and a parameter `φ` of the transition model `model φ`. -/
def IsGlobalMin {d : ℕ} {A X Θ : Type*} [MeasurableSpace A] [MeasurableSpace X]
    (M : LatentSCM d A) (g : (Fin d → ℝ) → X) (lam : ℝ)
    (model : Θ → (Fin d → ℝ) × A → (Fin d → ℝ) → ℝ) (h : X → Fin d → ℝ) (φ : Θ) : Prop :=
  IsAdmissible M g h (model φ) ∧
    ∀ (h' : X → Fin d → ℝ) (φ' : Θ), IsAdmissible M g h' (model φ') →
      objective M g lam h (model φ) ≤ objective M g lam h' (model φ')

/-- Theorem 2.1, Eq. (6): `p(z_t | z_{t-1}, a_{t-1}) = Q_h(z_t | z_{t-1}, a_{t-1})` a.e., i.e. `p` is a
version of the transition density induced by `h`: the joint law of `(c_t, z_t)`, with
`c_t = (z_{t-1}, a_{t-1})`, is the law of `c_t` times `p(z | c) dz`. -/
def IsReprTransitionDensity {d : ℕ} {A X : Type*} [MeasurableSpace A] [MeasurableSpace X]
    (M : LatentSCM d A) (g : (Fin d → ℝ) → X) (h : X → Fin d → ℝ)
    (p : (Fin d → ℝ) × A → (Fin d → ℝ) → ℝ) : Prop :=
  M.jointLaw.map (fun w => ((h (g w.1.1), w.1.2), h (g w.2))) =
    ((M.jointLaw.map fun w => (h (g w.1.1), w.1.2)).prod volume).withDensity
      (fun x => ENNReal.ofReal (p x.1 x.2))

/-- Assumption 3.1: the observation mapping `g` is smooth and invertible (injective). -/
def ObsRegular {d : ℕ} {X : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X]
    (g : (Fin d → ℝ) → X) : Prop :=
  ContDiff ℝ ∞ g ∧ Function.Injective g

/-- Section 2.1, Eq. (3): `dens i s' a` is a density of `p(s_{t,i} | s_{t-1,pa_i} = s'_{pa_i},
a_{t-1} = a)`, the law of `f_i(s', a, ε_{t,i})`. -/
def HasTransitionDensities {d : ℕ} {A : Type*} [MeasurableSpace A] (M : LatentSCM d A)
    (dens : Fin d → (Fin d → ℝ) → A → ℝ → ℝ) : Prop :=
  ∀ i (s' : Fin d → ℝ) (a : A), (M.noise i).map (fun e => M.mech i s' a e) =
    volume.withDensity (fun u => ENNReal.ofReal (dens i s' a u))

/-- Assumption 3.2 (regularity it presupposes): every conditional density is positive, twice
continuously differentiable in `s_{t,i}`, and jointly continuous in `(s_{t-1}, a_{t-1}, s_{t,i})`. -/
def IsRegularDensity {d : ℕ} {A : Type*} [TopologicalSpace A]
    (dens : Fin d → (Fin d → ℝ) → A → ℝ → ℝ) : Prop :=
  ∀ i, (∀ s' a u, 0 < dens i s' a u) ∧ (∀ s' a, ContDiff ℝ 2 (dens i s' a)) ∧
    Continuous (fun x : ((Fin d → ℝ) × A) × ℝ => dens i x.1.1 x.1.2 x.2)

/-- Assumption 3.2, Eq. (8): `w(s_t, s_{t-1}, a_{t-1}) = (∂q_1/∂s_{t,1}, …, ∂q_d/∂s_{t,d},
∂²q_1/∂s_{t,1}², …, ∂²q_d/∂s_{t,d}²)` with `q_i = log p(s_{t,i} | s_{t-1,pa_i}, a_{t-1})`; the first
block is indexed by `Sum.inl i`, the second by `Sum.inr i`. -/
def scoreVec {d : ℕ} {A : Type*} (dens : Fin d → (Fin d → ℝ) → A → ℝ → ℝ)
    (s s' : Fin d → ℝ) (a : A) : Fin d ⊕ Fin d → ℝ :=
  Sum.elim (fun i => deriv (fun u => Real.log (dens i s' a u)) (s i))
    (fun i => deriv (deriv fun u => Real.log (dens i s' a u)) (s i))

/-- Assumption 3.2, Eq. (7): for all `s_t, s_{t-1}` there are `2d + 1` actions `a^{(0)}, …, a^{(2d)}`
such that the `2d × 2d` matrix `L` with columns `w(a^{(ℓ)}) - w(a^{(0)})`, `ℓ = 1, …, 2d`, is
invertible (its columns are linearly independent). -/
def ActionVariability {d : ℕ} {A : Type*} (dens : Fin d → (Fin d → ℝ) → A → ℝ → ℝ) : Prop :=
  ∀ s s' : Fin d → ℝ, ∃ acts : Fin (2 * d + 1) → A,
    LinearIndependent ℝ (fun l : Fin (2 * d) =>
      scoreVec dens s s' (acts l.succ) - scoreVec dens s s' (acts 0))

/-- Appendix D, Eq. (47): the transition model factorizes across representation components,
`p_φ(z_t | z_{t-1}, a_{t-1}) = ∏_j p_{φ,j}(z_{t,j} | z_{t-1}, a_{t-1})`. On the encoder range
(`z_{t-1} ∈ (0,1)^d`, `z_{t,j} ∈ (0,1)`), where the proof evaluates it, each factor is positive, twice
continuously differentiable in `z_{t,j}`, and jointly continuous. Outside the range the factors are
unrestricted (an optimal model equals `Q_h` a.e. and so vanishes a.e. off `(0,1)^d`). -/
def IsRegularFactorizedModel {d : ℕ} {A : Type*} [TopologicalSpace A]
    (p : (Fin d → ℝ) × A → (Fin d → ℝ) → ℝ) : Prop :=
  ∃ pj : Fin d → (Fin d → ℝ) × A → ℝ → ℝ, (∀ c z, p c z = ∏ j, pj j c (z j)) ∧
    (∀ j c v, c.1 ∈ unitCube d → v ∈ Set.Ioo (0 : ℝ) 1 → 0 < pj j c v) ∧
    (∀ j c, c.1 ∈ unitCube d → ContDiffOn ℝ 2 (pj j c) (Set.Ioo 0 1)) ∧
    ∀ j, ContinuousOn (fun x : ((Fin d → ℝ) × A) × ℝ => pj j x.1 x.2)
      {x | x.1.1 ∈ unitCube d ∧ x.2 ∈ Set.Ioo (0 : ℝ) 1}

/-- Appendix E: the squared Euclidean norm `‖v‖₂² = ∑_i v_i²` on `ℝ^d`. -/
def sqNorm {d : ℕ} (v : Fin d → ℝ) : ℝ := ∑ i, v i ^ 2

/-- Appendix E, Eq. (57): the negative log-likelihood of `z` under `N(m, σ² I)`,
`ℓ_φ(z) = ‖z - m‖² / (2σ²) + (d/2) log(2πσ²)`. -/
def gaussNLL {d : ℕ} (σ : ℝ) (m z : Fin d → ℝ) : ℝ :=
  sqNorm (z - m) / (2 * σ ^ 2) + (d : ℝ) / 2 * Real.log (2 * Real.pi * σ ^ 2)

/-- Appendix E: the Gaussian kernel with bandwidth `b`,
`φ_b(x) = (2π b²)^{-d/2} exp(-‖x‖² / (2b²))`. -/
def gaussKernel {d : ℕ} (b : ℝ) (x : Fin d → ℝ) : ℝ :=
  (2 * Real.pi * b ^ 2) ^ (-(d : ℝ) / 2) * Real.exp (-sqNorm x / (2 * b ^ 2))

/-- Appendix E, Eq. (58): `U_K = log[(1/K) ∑_{k=1}^K exp(-ℓ_φ(z^{(k)}) / τ)]` for the predicted mean
`m = μ_φ(z_{t-1}, a_{t-1})` and the first `K` samples of the sequence `zs`. -/
def contrastiveU {d : ℕ} (σ τ : ℝ) (m : Fin d → ℝ) (zs : ℕ → Fin d → ℝ) (K : ℕ) : ℝ :=
  Real.log ((1 / (K : ℝ)) * ∑ k ∈ Finset.range K, Real.exp (-gaussNLL σ m (zs k) / τ))

/-- Appendix E, Eq. (59): `(p_z * φ_b)(z_t) = ∫ φ_b(z - z_t) dp_z(z)`. -/
def kernelSmoothed {d : ℕ} (μ : Measure (Fin d → ℝ)) (b : ℝ) (zt : Fin d → ℝ) : ℝ :=
  ∫ z, gaussKernel b (z - zt) ∂μ

end IActThereforeIAm
Source
Liu, Huang and Shi, I Act Therefore I Am: When Is JEPA's Action-Conditioning Enough to Learn Causal Mechanisms?, arXiv:2609.31161v1 (2026), Section 2.1 (Eqs. 1-3, p. 2-3), Section 2.2 (Eq. 4, Theorem 2.1, p. 3), Section 3 (Assumptions 3.1-3.2, Eqs. 7-8, p. 4), Appendix D (Eq. 47, p. 21), Appendix E (Eqs. 56-59, p. 22)
Read-back

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

LatentSCM d A (a data structure; it asserts nothing). Here d≥0d \ge 0d≥0 is a natural number and AAA is any set with a σ-algebra. An object MMM of this type consists of four pieces of data, with no constraints attached:

  • a parent set pai⊆{1,…,d}\mathrm{pa}_i \subseteq \{1,\dots,d\}pai​⊆{1,…,d} for each index i∈{1,…,d}i \in \{1,\dots,d\}i∈{1,…,d};
  • a mechanism fi:Rd×A×R→Rf_i : \mathbb{R}^d \times A \times \mathbb{R} \to \mathbb{R}fi​:Rd×A×R→R for each iii. It takes the entire previous state s∈Rds \in \mathbb{R}^ds∈Rd, not only the parent coordinates;
  • a noise measure νi\nu_iνi​ on R\mathbb{R}R for each iii. It may be any measure, not necessarily a probability measure;
  • a measure π\piπ on Rd×A\mathbb{R}^d \times ARd×A, playing the role of the law of (st−1,at−1)(s_{t-1}, a_{t-1})(st−1​,at−1​). It also may be any measure.

Nothing in the structure links pai\mathrm{pa}_ipai​ to fif_ifi​, requires measurability, or mentions an observation map. When d=0d = 0d=0 there are no components at all.


LatentSCM.IsValid M holds exactly when all four of the following are true:

  1. π\piπ is a probability measure on Rd×A\mathbb{R}^d \times ARd×A.
  2. Every νi\nu_iνi​ is a probability measure on R\mathbb{R}R.
  3. For every iii, the map (s,a,e)↦fi(s,a,e)(s, a, e) \mapsto f_i(s, a, e)(s,a,e)↦fi​(s,a,e) is measurable for the product σ-algebra on (Rd×A)×R(\mathbb{R}^d \times A) \times \mathbb{R}(Rd×A)×R.
  4. For every iii, all s,s′∈Rds, s' \in \mathbb{R}^ds,s′∈Rd, all a∈Aa \in Aa∈A and all e∈Re \in \mathbb{R}e∈R:
(sj=sj′ for all j∈pai)  ⟹  fi(s,a,e)=fi(s′,a,e).\big(s_j = s'_j \text{ for all } j \in \mathrm{pa}_i\big) \;\Longrightarrow\; f_i(s, a, e) = f_i(s', a, e).(sj​=sj′​ for all j∈pai​)⟹fi​(s,a,e)=fi​(s′,a,e).

In words, fif_ifi​ depends on sss only through the coordinates in pai\mathrm{pa}_ipai​.

If pai=∅\mathrm{pa}_i = \varnothingpai​=∅, then fif_ifi​ depends only on (a,e)(a, e)(a,e). No independence statement appears here, and no condition on the graph is imposed.


LatentSCM.jointLaw M is a measure on (Rd×A)×Rd(\mathbb{R}^d \times A) \times \mathbb{R}^d(Rd×A)×Rd. It is the pushforward of the product measure π⊗⨂i=1dνi\pi \otimes \bigotimes_{i=1}^d \nu_iπ⊗⨂i=1d​νi​ on (Rd×A)×Rd(\mathbb{R}^d \times A) \times \mathbb{R}^d(Rd×A)×Rd under the map

((s,a),(ε1,…,εd))  ⟼  ((s,a),  (f1(s,a,ε1),…,fd(s,a,εd))).\big((s, a), (\varepsilon_1, \dots, \varepsilon_d)\big) \;\longmapsto\; \Big((s, a),\; \big(f_1(s, a, \varepsilon_1), \dots, f_d(s, a, \varepsilon_d)\big)\Big).((s,a),(ε1​,…,εd​))⟼((s,a),(f1​(s,a,ε1​),…,fd​(s,a,εd​))).

I write a generic point of the result as w=((st−1,at−1),st)w = ((s_{t-1}, a_{t-1}), s_t)w=((st−1​,at−1​),st​).

  • The independence of the εi\varepsilon_iεi​ from each other and from (s,a)(s, a)(s,a) comes only from using the product measure.
  • The definition makes sense whether or not IsValid holds.
  • By the library convention, if this map is not almost-everywhere measurable, the pushforward is the zero measure.

mutualInfo P X Y. Here (Ω,P)(\Omega, P)(Ω,P) is any measure space (no normalisation assumed), and X:Ω→αX : \Omega \to \alphaX:Ω→α, Y:Ω→βY : \Omega \to \betaY:Ω→β are arbitrary functions (no measurability assumed). The value, in [0,∞][0, \infty][0,∞], is the Kullback–Leibler divergence

I(X;Y)=KL(P(X,Y) ∥ PX⊗PY),I(X;Y) = \mathrm{KL}\big(P_{(X,Y)} \,\big\|\, P_X \otimes P_Y\big),I(X;Y)=KL(P(X,Y)​​PX​⊗PY​),

where P(X,Y)P_{(X,Y)}P(X,Y)​, PXP_XPX​, PYP_YPY​ are the pushforward laws. The library's divergence works as follows:

  • It equals +∞+\infty+∞ unless P(X,Y)≪PX⊗PYP_{(X,Y)} \ll P_X \otimes P_YP(X,Y)​≪PX​⊗PY​ and the log-likelihood ratio is integrable.
  • Otherwise it equals max⁡ ⁣(0, ∫log⁡dP(X,Y)d(PX⊗PY) dP(X,Y)+(PX⊗PY)(whole space)−P(X,Y)(whole space))\max\!\big(0,\ \int \log \frac{dP_{(X,Y)}}{d(P_X \otimes P_Y)}\, dP_{(X,Y)} + (P_X \otimes P_Y)(\text{whole space}) - P_{(X,Y)}(\text{whole space})\big)max(0, ∫logd(PX​⊗PY​)dP(X,Y)​​dP(X,Y)​+(PX​⊗PY​)(whole space)−P(X,Y)​(whole space)), with natural logarithm.
  • For probability measures the two mass terms cancel and this is the usual KL divergence in nats.
  • Non-measurable XXX or YYY produce zero-measure laws by convention.

latentInfo M is the mutual information, computed under jointLaw(M)\mathrm{jointLaw}(M)jointLaw(M) as defined above, between two random variables:

  • the second component st∈Rds_t \in \mathbb{R}^dst​∈Rd, and
  • the first component (st−1,at−1)∈Rd×A(s_{t-1}, a_{t-1}) \in \mathbb{R}^d \times A(st−1​,at−1​)∈Rd×A.

That is,

I(st; (st−1,at−1))∈[0,∞].I\big(s_t;\, (s_{t-1}, a_{t-1})\big) \in [0, \infty].I(st​;(st−1​,at−1​))∈[0,∞].

reprInfo M g h. Here g:Rd→Xg : \mathbb{R}^d \to Xg:Rd→X and h:X→Rdh : X \to \mathbb{R}^dh:X→Rd are arbitrary functions; neither is assumed measurable or injective. The value is the mutual information under jointLaw(M)\mathrm{jointLaw}(M)jointLaw(M) between

zt=h(g(st))and(zt−1,at−1)=(h(g(st−1)), at−1).z_t = h(g(s_t)) \qquad\text{and}\qquad \big(z_{t-1}, a_{t-1}\big) = \big(h(g(s_{t-1})),\, a_{t-1}\big).zt​=h(g(st​))and(zt−1​,at−1​)=(h(g(st−1​)),at−1​).

The value lies in [0,∞][0, \infty][0,∞].


reprLaw M g h is the measure on Rd\mathbb{R}^dRd obtained by pushing jointLaw(M)\mathrm{jointLaw}(M)jointLaw(M) forward along w↦h(g(st))w \mapsto h(g(s_t))w↦h(g(st​)). It is the law of ztz_tzt​; it is the zero measure if this map is not almost-everywhere measurable.


unitCube d is the open cube

(0,1)d={z∈Rd:0<zi<1 for every i}.(0,1)^d = \{ z \in \mathbb{R}^d : 0 < z_i < 1 \text{ for every } i \}.(0,1)d={z∈Rd:0<zi​<1 for every i}.

For d=0d = 0d=0 it is the whole one-point space R0\mathbb{R}^0R0.


diffEntropy μ. Let μ\muμ be any measure on Rd\mathbb{R}^dRd, and let f=dμ/dλf = d\mu / d\lambdaf=dμ/dλ be its Radon–Nikodym derivative with respect to Lebesgue measure λ\lambdaλ, read as a real number (an infinite value is read as 000). The value is an extended real number defined by cases:

H(μ)={−∫Rdf(z)log⁡f(z) dzif μ≪λ and z↦−f(z)log⁡f(z) is Lebesgue-integrable,−∞otherwise.H(\mu) = \begin{cases} -\displaystyle\int_{\mathbb{R}^d} f(z) \log f(z)\, dz & \text{if } \mu \ll \lambda \text{ and } z \mapsto -f(z)\log f(z) \text{ is Lebesgue-integrable,} \\[1ex] -\infty & \text{otherwise.} \end{cases}H(μ)=⎩⎨⎧​−∫Rd​f(z)logf(z)dz−∞​if μ≪λ and z↦−f(z)logf(z) is Lebesgue-integrable,otherwise.​
  • The integrand uses the convention 0log⁡0=00 \log 0 = 00log0=0.
  • In the first case the value is always a finite real.
  • Every case not covered — no density, or flog⁡ff\log fflogf not integrable — is assigned −∞-\infty−∞. This includes laws whose entropy would classically be +∞+\infty+∞.
  • μ\muμ is not required to be a probability measure. For example, the zero measure has entropy 000.
  • For d=0d = 0d=0, "Lebesgue measure" is the unit point mass, so every μ\muμ is absolutely continuous.

IsTransitionModel p. Here ppp assigns to each context c=(zt−1,at−1)∈Rd×Ac = (z_{t-1}, a_{t-1}) \in \mathbb{R}^d \times Ac=(zt−1​,at−1​)∈Rd×A and each z∈Rdz \in \mathbb{R}^dz∈Rd a real number p(z∣c)p(z \mid c)p(z∣c). The predicate holds exactly when:

  1. (c,z)↦p(z∣c)(c, z) \mapsto p(z \mid c)(c,z)↦p(z∣c) is jointly measurable;
  2. p(z∣c)≥0p(z \mid c) \ge 0p(z∣c)≥0 for every ccc and zzz;
  3. for every context ccc (not merely almost every), ∫Rdp(z∣c) dz=1\int_{\mathbb{R}^d} p(z \mid c)\, dz = 1∫Rd​p(z∣c)dz=1.

Since a non-integrable function is assigned integral 000, condition 3 forces integrability. So for each ccc, p(⋅∣c)p(\cdot \mid c)p(⋅∣c) is a genuine Lebesgue probability density on Rd\mathbb{R}^dRd.


objective M g λ h p. The inputs are the model MMM, an observation map g:Rd→Xg : \mathbb{R}^d \to Xg:Rd→X, a real number λ\lambdaλ (any sign allowed), an encoder h:X→Rdh : X \to \mathbb{R}^dh:X→Rd, and a function p(z∣c)p(z \mid c)p(z∣c) as above. The real number returned is

Lλ(h,p)=−∫log⁡p(h(g(st)) ∣ (h(g(st−1)),at−1)) d jointLaw(M)  −  λ⋅H(reprLaw(M,g,h)).L_\lambda(h, p) = -\int \log p\big(h(g(s_t)) \,\big|\, (h(g(s_{t-1})), a_{t-1})\big)\, d\,\mathrm{jointLaw}(M) \;-\; \lambda \cdot H\big(\mathrm{reprLaw}(M, g, h)\big).Lλ​(h,p)=−∫logp(h(g(st​))​(h(g(st−1​)),at−1​))djointLaw(M)−λ⋅H(reprLaw(M,g,h)).

Junk-value conventions apply:

  • log⁡0=0\log 0 = 0log0=0 and log⁡x=log⁡∣x∣\log x = \log|x|logx=log∣x∣ for x<0x < 0x<0.
  • The integral is 000 if the integrand is not integrable.
  • An entropy of −∞-\infty−∞ is replaced by 000, so the λ\lambdaλ-term vanishes in that case.

No admissibility is assumed by this definition itself.


IsAdmissible M g h p holds exactly when all of the following are true:

  1. h:X→Rdh : X \to \mathbb{R}^dh:X→Rd is measurable.
  2. For every x∈Xx \in Xx∈X (not just those in the image of ggg) and every iii, h(x)i∈(0,1)h(x)_i \in (0,1)h(x)i​∈(0,1). So hhh maps into (0,1)d(0,1)^d(0,1)d.
  3. ppp satisfies IsTransitionModel: jointly measurable, nonnegative, and integrating to 111 in zzz for every context.
  4. For jointLaw(M)\mathrm{jointLaw}(M)jointLaw(M)-almost every www:
p(h(g(st)) ∣ (h(g(st−1)),at−1))>0.p\big(h(g(s_t)) \,\big|\, (h(g(s_{t-1})), a_{t-1})\big) > 0.p(h(g(st​))​(h(g(st−1​)),at−1​))>0.
  1. The function w↦log⁡p(h(g(st))∣(h(g(st−1)),at−1))w \mapsto \log p\big(h(g(s_t)) \mid (h(g(s_{t-1})), a_{t-1})\big)w↦logp(h(g(st​))∣(h(g(st−1​)),at−1​)) is integrable with respect to jointLaw(M)\mathrm{jointLaw}(M)jointLaw(M).
  2. H(reprLaw(M,g,h))≠−∞H(\mathrm{reprLaw}(M, g, h)) \neq -\inftyH(reprLaw(M,g,h))=−∞. Equivalently, the law of ztz_tzt​ is absolutely continuous with respect to Lebesgue measure and flog⁡ff \log fflogf is integrable, so the entropy is a finite real.

No measurability, injectivity or smoothness of ggg is required, and no validity of MMM is required.


IsGlobalMin M g λ model h φ. Here Θ\ThetaΘ is any set of parameters and model\mathrm{model}model assigns to each θ∈Θ\theta \in \Thetaθ∈Θ a function pθ(z∣c)p_\theta(z \mid c)pθ​(z∣c). The predicate holds exactly when both of the following are true:

  1. (h,pφ)(h, p_\varphi)(h,pφ​) is admissible, in the sense of IsAdmissible above.
  2. For every function h′:X→Rdh' : X \to \mathbb{R}^dh′:X→Rd and every φ′∈Θ\varphi' \in \Thetaφ′∈Θ such that (h′,pφ′)(h', p_{\varphi'})(h′,pφ′​) is admissible,
Lλ(h,pφ)  ≤  Lλ(h′,pφ′).L_\lambda(h, p_\varphi) \;\le\; L_\lambda(h', p_{\varphi'}).Lλ​(h,pφ​)≤Lλ​(h′,pφ′​).

The comparison class consists only of admissible pairs whose second component lies in the family {pθ:θ∈Θ}\{p_\theta : \theta \in \Theta\}{pθ​:θ∈Θ}. The inequality is non-strict, so minimisers need not be unique. λ\lambdaλ is an arbitrary real.


IsReprTransitionDensity M g h p. Write ct=(h(g(st−1)),at−1)c_t = (h(g(s_{t-1})), a_{t-1})ct​=(h(g(st−1​)),at−1​) and zt=h(g(st))z_t = h(g(s_t))zt​=h(g(st​)). The predicate asserts an equality of measures on (Rd×A)×Rd(\mathbb{R}^d \times A) \times \mathbb{R}^d(Rd×A)×Rd:

law of (ct,zt) under jointLaw(M)  =  (law of ct)⊗λd with density (c,z)↦max⁡(p(z∣c), 0).\text{law of } (c_t, z_t) \text{ under } \mathrm{jointLaw}(M) \;=\; \big(\text{law of } c_t\big) \otimes \lambda^d \text{ with density } (c, z) \mapsto \max\big(p(z \mid c),\, 0\big).law of (ct​,zt​) under jointLaw(M)=(law of ct​)⊗λd with density (c,z)↦max(p(z∣c),0).

Here λd\lambda^dλd is Lebesgue measure on Rd\mathbb{R}^dRd. In words, ppp is a version of the conditional density of ztz_tzt​ given ctc_tct​, after negative values are clipped to 000. Nothing requires ppp to be measurable or to be a transition model.


ObsRegular g. Here XXX is a real normed vector space. The predicate states that g:Rd→Xg : \mathbb{R}^d \to Xg:Rd→X:

  • is infinitely differentiable (C∞C^\inftyC∞), and
  • is injective.

Nothing is assumed about its inverse: it need not be smooth or continuous on the image, and ggg need not be an immersion or an embedding. No relation between this norm structure and any σ-algebra on XXX is stated.


HasTransitionDensities M dens. Here densi(s′,a,u)\mathrm{dens}_i(s', a, u)densi​(s′,a,u) is a real number for each iii, s′∈Rds' \in \mathbb{R}^ds′∈Rd, a∈Aa \in Aa∈A and u∈Ru \in \mathbb{R}u∈R. The predicate states that for every iii, every s′∈Rds' \in \mathbb{R}^ds′∈Rd (the full vector) and every a∈Aa \in Aa∈A (not merely almost every), the following two measures on R\mathbb{R}R coincide:

  • the pushforward of νi\nu_iνi​ under e↦fi(s′,a,e)e \mapsto f_i(s', a, e)e↦fi​(s′,a,e);
  • Lebesgue measure with density u↦max⁡(densi(s′,a,u),0)u \mapsto \max(\mathrm{dens}_i(s', a, u), 0)u↦max(densi​(s′,a,u),0).

In particular, each such law is absolutely continuous with respect to Lebesgue measure. Its total mass equals that of νi\nu_iνi​, and nothing here requires νi\nu_iνi​ to be a probability measure.


IsRegularDensity dens. Here AAA carries a topology. The predicate states that for every iii all three of the following hold:

  1. densi(s′,a,u)>0\mathrm{dens}_i(s', a, u) > 0densi​(s′,a,u)>0 for all s′s's′, aaa and uuu.
  2. For each fixed (s′,a)(s', a)(s′,a), the map u↦densi(s′,a,u)u \mapsto \mathrm{dens}_i(s', a, u)u↦densi​(s′,a,u) is twice continuously differentiable on all of R\mathbb{R}R.
  3. (s′,a,u)↦densi(s′,a,u)(s', a, u) \mapsto \mathrm{dens}_i(s', a, u)(s′,a,u)↦densi​(s′,a,u) is jointly continuous on Rd×A×R\mathbb{R}^d \times A \times \mathbb{R}Rd×A×R.

Nothing ties dens\mathrm{dens}dens to any model MMM, and nothing requires it to integrate to 111.


scoreVec dens s s' a. For a current state s∈Rds \in \mathbb{R}^ds∈Rd, a previous state s′∈Rds' \in \mathbb{R}^ds′∈Rd and an action aaa, write qi(u)=log⁡densi(s′,a,u)q_i(u) = \log \mathrm{dens}_i(s', a, u)qi​(u)=logdensi​(s′,a,u). This is a vector w(s,s′,a)w(s, s', a)w(s,s′,a) with 2d2d2d entries, indexed by two disjoint copies of {1,…,d}\{1,\dots,d\}{1,…,d}:

w(s,s′,a)=(q1′(s1),…,qd′(sd),  q1′′(s1),…,qd′′(sd)).w(s, s', a) = \big(q_1'(s_1), \dots, q_d'(s_d),\; q_1''(s_1), \dots, q_d''(s_d)\big).w(s,s′,a)=(q1′​(s1​),…,qd′​(sd​),q1′′​(s1​),…,qd′′​(sd​)).
  • The second derivative is computed as the derivative of the derivative function.
  • Any derivative that does not exist is taken to be 000.
  • log⁡\loglog follows the conventions log⁡0=0\log 0 = 0log0=0 and log⁡x=log⁡∣x∣\log x = \log|x|logx=log∣x∣.

ActionVariability dens. The predicate states that for all s,s′∈Rds, s' \in \mathbb{R}^ds,s′∈Rd there exist 2d+12d + 12d+1 actions a(0),a(1),…,a(2d)∈Aa^{(0)}, a^{(1)}, \dots, a^{(2d)} \in Aa(0),a(1),…,a(2d)∈A (repetitions allowed, depending on sss and s′s's′) such that the 2d2d2d vectors

w(s,s′,a(ℓ))−w(s,s′,a(0)),ℓ=1,…,2d,w(s, s', a^{(\ell)}) - w(s, s', a^{(0)}), \qquad \ell = 1, \dots, 2d,w(s,s′,a(ℓ))−w(s,s′,a(0)),ℓ=1,…,2d,

are linearly independent over R\mathbb{R}R in R2d\mathbb{R}^{2d}R2d, with www the score vector defined above. Equivalently, the 2d×2d2d \times 2d2d×2d matrix with these columns is invertible.

  • The quantification is over all of Rd×Rd\mathbb{R}^d \times \mathbb{R}^dRd×Rd.
  • For d=0d = 0d=0 the family is empty, so the condition reduces to "AAA is nonempty".
  • If AAA is empty, the condition fails for every ddd.

IsRegularFactorizedModel p. Here AAA carries a topology. The predicate asserts that there exist functions pj(v∣c)p_j(v \mid c)pj​(v∣c), for j=1,…,dj = 1,\dots,dj=1,…,d, contexts c=(zt−1,a)∈Rd×Ac = (z_{t-1}, a) \in \mathbb{R}^d \times Ac=(zt−1​,a)∈Rd×A and v∈Rv \in \mathbb{R}v∈R, such that all four of the following hold:

  1. For all ccc and z∈Rdz \in \mathbb{R}^dz∈Rd,
p(z∣c)=∏j=1dpj(zj∣c).p(z \mid c) = \prod_{j=1}^d p_j(z_j \mid c).p(z∣c)=j=1∏d​pj​(zj​∣c).
  1. pj(v∣c)>0p_j(v \mid c) > 0pj​(v∣c)>0 whenever zt−1∈(0,1)dz_{t-1} \in (0,1)^dzt−1​∈(0,1)d and v∈(0,1)v \in (0,1)v∈(0,1).
  2. For each jjj and each ccc with zt−1∈(0,1)dz_{t-1} \in (0,1)^dzt−1​∈(0,1)d, the map v↦pj(v∣c)v \mapsto p_j(v \mid c)v↦pj​(v∣c) is twice continuously differentiable on (0,1)(0,1)(0,1).
  3. For each jjj, (c,v)↦pj(v∣c)(c, v) \mapsto p_j(v \mid c)(c,v)↦pj​(v∣c) is continuous on the set where zt−1∈(0,1)dz_{t-1} \in (0,1)^dzt−1​∈(0,1)d and v∈(0,1)v \in (0,1)v∈(0,1).

Each factor may depend on the whole context but only on its own coordinate zjz_jzj​. The action component is unrestricted throughout. Outside the cube the factors are arbitrary. The factors need not be densities. For d=0d = 0d=0 the product is empty and the predicate says p≡1p \equiv 1p≡1.


sqNorm v is the squared Euclidean norm

∥v∥2=∑i=1dvi2for v∈Rd.\|v\|^2 = \sum_{i=1}^d v_i^2 \quad\text{for } v \in \mathbb{R}^d.∥v∥2=i=1∑d​vi2​for v∈Rd.

It equals 000 when d=0d = 0d=0.


gaussNLL σ m z is the real number

ℓ(z)=∥z−m∥22σ2+d2log⁡(2πσ2),\ell(z) = \frac{\|z - m\|^2}{2\sigma^2} + \frac{d}{2}\log(2\pi\sigma^2),ℓ(z)=2σ2∥z−m∥2​+2d​log(2πσ2),

for any real σ\sigmaσ and any m,z∈Rdm, z \in \mathbb{R}^dm,z∈Rd.

  • Only σ2\sigma^2σ2 enters, so negative σ\sigmaσ behaves like ∣σ∣|\sigma|∣σ∣.
  • For σ=0\sigma = 0σ=0, division by zero and log⁡0\log 0log0 are both taken to be 000, so ℓ(z)=0\ell(z) = 0ℓ(z)=0.

gaussKernel b x is the real number

φb(x)=(2πb2)−d/2exp⁡ ⁣(−∥x∥22b2),\varphi_b(x) = (2\pi b^2)^{-d/2} \exp\!\Big(-\frac{\|x\|^2}{2b^2}\Big),φb​(x)=(2πb2)−d/2exp(−2b2∥x∥2​),

for any real bbb and any x∈Rdx \in \mathbb{R}^dx∈Rd. The power is a real power with these conventions: 0r=00^r = 00r=0 for r≠0r \neq 0r=0, 00=10^0 = 100=1, and division by zero gives 000. Consequently, at b=0b = 0b=0 the kernel is identically 000 when d≥1d \ge 1d≥1 and identically 111 when d=0d = 0d=0.


contrastiveU σ τ m zs K. Here zs=(z(0),z(1),… )zs = (z^{(0)}, z^{(1)}, \dots)zs=(z(0),z(1),…) is an infinite sequence in Rd\mathbb{R}^dRd and K≥0K \ge 0K≥0 is a natural number. Only the samples z(0),…,z(K−1)z^{(0)}, \dots, z^{(K-1)}z(0),…,z(K−1) are used. The value is

UK=log⁡(1K∑k=0K−1exp⁡(−ℓ(z(k))/τ)),U_K = \log\Big(\frac{1}{K}\sum_{k=0}^{K-1} \exp\big(-\ell(z^{(k)})/\tau\big)\Big),UK​=log(K1​k=0∑K−1​exp(−ℓ(z(k))/τ)),

where ℓ\ellℓ is the Gaussian negative log-likelihood with parameters σ\sigmaσ and mmm, as defined above.

  • For K=0K = 0K=0, 1/0=01/0 = 01/0=0 and log⁡0=0\log 0 = 0log0=0, so U0=0U_0 = 0U0​=0.
  • For τ=0\tau = 0τ=0, every exponent is 000, so UK=0U_K = 0UK​=0 for K≥1K \ge 1K≥1.

kernelSmoothed μ b z_t. Here μ\muμ is any measure on Rd\mathbb{R}^dRd, bbb is real and zt∈Rdz_t \in \mathbb{R}^dzt​∈Rd. The value is the real number

(μ∗φb)(zt)=∫Rdφb(z−zt) dμ(z),(\mu * \varphi_b)(z_t) = \int_{\mathbb{R}^d} \varphi_b(z - z_t)\, d\mu(z),(μ∗φb​)(zt​)=∫Rd​φb​(z−zt​)dμ(z),

with φb\varphi_bφb​ the Gaussian kernel defined above. The integral is taken to be 000 if the integrand is not μ\muμ-integrable, for example for some infinite measures μ\muμ.

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