Mathlib.Probability.Kernel.Finite­History

This module packages reusable expectation, likelihood-weighted iteration, and stationary separated-window covariance formulas for finite trajectory laws specified directly by composition-product identities.

Expectation 1 core · 3 supporting This module derives iterated-integral identities for bounded real expectations, and a covariance bound from a uniform bound on centered kernel means, directly from composition-product laws. ★ integral_action_transition

Expectations from finite sequential kernel laws

This module derives iterated-integral identities for bounded real expectations, and a covariance bound from a uniform bound on centered kernel means, directly from composition-product laws. The results integrate over kernels rather than conditioning on positive-probability history atoms.

theorem integral_action_transition reviewed
Causalean.Mathlib.Probability.Kernel.FiniteHistory

Let μ be a probability law of histories, action a Markov kernel from histories to finitely many actions, and transition a Markov kernel from history-action pairs to a reward and one of finitely many next states. If the history-action law νA is μ composed with the action kernel and the full law ν is νA composed with the transition kernel, then for every measurable function f of history, action, reward and next state bounded in absolute value by a constant C, the integral of f under ν equals the iterated integral over histories, then actions, then reward and next state.

Formal statement
H A S :
action :
transition :
Kernel (H × A) (ℝ × S)
IsMarkovKernel transition
νA :
Measure (H × A)
hA :
νA = μ ⊗ₘ action
ν :
Measure ((H × A) × (ℝ × S))
hν :
ν = νA ⊗ₘ transition
f :
H → A → ℝ → S → ℝ
hf :
Measurable fun z : (H × A) × (ℝ × S) => f z.1.1 z.1.2 z.2.1 z.2.2
C :
ℝ
hbound :
∀ h a r s, |f h a r s| ≤ C
∫ z, f z.1.1 z.1.2 z.2.1 z.2.2 ∂ν
= ∫ h, ∫ a, ∫ rs, f h a rs.1 rs.2 ∂transition (h, a) ∂action h ∂μ
Proof (Lean source)
theorem integral_action_transition {H A S : Type*} [MeasurableSpace H] [MeasurableSpace A] [MeasurableSpace S] [Finite A] [Finite S] (μ : Measure H) [IsProbabilityMeasure μ] (action : Kernel H A) [IsMarkovKernel action] (transition : Kernel (H × A) (ℝ × S)) [IsMarkovKernel transition] (νA : Measure (H × A)) (hA : νA = μ ⊗ₘ action) (ν : Measure ((H × A) × (ℝ × S))) (hν : ν = νA ⊗ₘ transition) (f : H → A → ℝ → S → ℝ) (hf : Measurable fun z : (H × A) × (ℝ × S) => f z.1.1 z.1.2 z.2.1 z.2.2) (C : ℝ) (hbound : ∀ h a r s, |f h a r s| ≤ C) : ∫ z, f z.1.1 z.1.2 z.2.1 z.2.2 ∂ν = ∫ h, ∫ a, ∫ rs, f h a rs.1 rs.2 ∂transition (h, a) ∂action h ∂μ := by subst νA -- Apply `integral_compProd_bounded` first to `ν`, then to `νA`. -- The inner kernel integral is measurable and bounded by `C`. have hg : Measurable (fun z : H × A => ∫ rs, f z.1 z.2 rs.1 rs.2 ∂transition z) := (hf.stronglyMeasurable.integral_kernel_prod_right').measurable have hgbound : ∀ z : H × A, |∫ rs, f z.1 z.2 rs.1 rs.2 ∂transition z| ≤ C := by intro z simpa only [Real.norm_eq_abs, probReal_univ, mul_one] using (norm_integral_le_of_norm_le_const (μ := transition z) (f := fun rs : ℝ × S => f z.1 z.2 rs.1 rs.2) (C := C) (Filter.Eventually.of_forall fun rs => by simpa only [Real.norm_eq_abs] using hbound z.1 z.2 rs.1 rs.2)) calc ∫ z, f z.1.1 z.1.2 z.2.1 z.2.2 ∂ν = ∫ z : H × A, ∫ rs, f z.1 z.2 rs.1 rs.2 ∂transition z ∂(μ ⊗ₘ action) := by exact integral_compProd_bounded (μ ⊗ₘ action) transition ν hν _ hf C (fun z => hbound z.1.1 z.1.2 z.2.1 z.2.2) _ = ∫ h, ∫ a, ∫ rs, f h a rs.1 rs.2 ∂transition (h, a) ∂action h ∂μ := by exact integral_compProd_bounded μ action (μ ⊗ₘ action) rfl _ hg C hgbound
Causalean.Mathlib.Probability.Kernel.FiniteHistory.integral_action_transition · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Expectation.lean:49
3 supporting declarations (lemmas, instances)
  • integral_compProd_of_law theorem — If a joint law ν is the composition product of an s-finite base measure μ with an s-finite kernel K, then for every real function f integrable under ν, the integral of f under ν equals the integral under μ of the inner integral of f against K.
    μ :
    K :
    Kernel H B
    ν :
    Measure (H × B)
    hν :
    ν = μ ⊗ₘ K
    f :
    H × B → ℝ
    hf :
    ∫ z, f z ∂ν = ∫ h, ∫ b, f (h, b) ∂K h ∂μ
    Proof (Lean source)
    theorem integral_compProd_of_law {H B : Type*} [MeasurableSpace H] [MeasurableSpace B] (μ : Measure H) (K : Kernel H B) [SFinite μ] [IsSFiniteKernel K] (ν : Measure (H × B)) (hν : ν = μ ⊗ₘ K) (f : H × B → ℝ) (hf : Integrable f ν) : ∫ z, f z ∂ν = ∫ h, ∫ b, f (h, b) ∂K h ∂μ := by subst ν exact Measure.integral_compProd hf
    Causalean.Mathlib.Probability.Kernel.FiniteHistory.integral_compProd_of_law · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Expectation.lean:19
  • integral_compProd_bounded theorem — If a joint law ν is the composition product of a probability measure μ with a Markov kernel K, then for every measurable real function f bounded in absolute value by a constant C, the integral of f under ν equals the integral under μ of the inner integral of f against K.
    μ :
    K :
    Kernel H B
    ν :
    Measure (H × B)
    hν :
    ν = μ ⊗ₘ K
    f :
    H × B → ℝ
    hf :
    C :
    ℝ
    hbound :
    ∀ z, |f z| ≤ C
    ∫ z, f z ∂ν = ∫ h, ∫ b, f (h, b) ∂K h ∂μ
    Proof (Lean source)
    theorem integral_compProd_bounded {H B : Type*} [MeasurableSpace H] [MeasurableSpace B] (μ : Measure H) (K : Kernel H B) [IsProbabilityMeasure μ] [IsMarkovKernel K] (ν : Measure (H × B)) (hν : ν = μ ⊗ₘ K) (f : H × B → ℝ) (hf : Measurable f) (C : ℝ) (hbound : ∀ z, |f z| ≤ C) : ∫ z, f z ∂ν = ∫ h, ∫ b, f (h, b) ∂K h ∂μ := by subst ν have hfi : Integrable f (μ ⊗ₘ K) := Integrable.of_bound hf.aestronglyMeasurable C (Filter.Eventually.of_forall fun z => by simpa only [Real.norm_eq_abs] using hbound z) exact Measure.integral_compProd hfi
    Causalean.Mathlib.Probability.Kernel.FiniteHistory.integral_compProd_bounded · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Expectation.lean:32
  • covariance_compProd_of_centered_kernel_bound theorem — Let the joint law ν of a first and second window be the composition product of a probability law μ of the first window with a Markov kernel K. Let f be a measurable function of the first window bounded in absolute value by a nonnegative constant Cf, and g a measurable function of the second window bounded in absolute value by a constant Cg. If for every first window x the kernel mean of g given x differs from the overall mean of g under ν by at most a constant D, then the covariance of f and g under ν — the mean of their product minus the product of their means — is at most Cf·D in absolute value.
    ν :
    Measure (X × Y)
    hν :
    ν = μ ⊗ₘ K
    f :
    X → ℝ
    hf :
    Cf :
    ℝ
    hCf :
    0 ≤ Cf
    hf_bound :
    ∀ x, |f x| ≤ Cf
    g :
    Y → ℝ
    hg :
    Cg :
    ℝ
    hg_bound :
    ∀ y, |g y| ≤ Cg
    D :
    ℝ
    hkernel :
    ∀ x, |(∫ y, g y ∂K x) - (∫ z, g z.2 ∂ν)| ≤ D
    |(∫ z, f z.1 * g z.2 ∂ν) - (∫ x, f x ∂μ) * (∫ z, g z.2 ∂ν)| ≤ Cf * D
    Proof (Lean source)
    theorem covariance_compProd_of_centered_kernel_bound {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] (μ : Measure X) [IsProbabilityMeasure μ] (K : Kernel X Y) [IsMarkovKernel K] (ν : Measure (X × Y)) (hν : ν = μ ⊗ₘ K) (f : X → ℝ) (hf : Measurable f) (Cf : ℝ) (hCf : 0 ≤ Cf) (hf_bound : ∀ x, |f x| ≤ Cf) (g : Y → ℝ) (hg : Measurable g) (Cg : ℝ) (hg_bound : ∀ y, |g y| ≤ Cg) (D : ℝ) (hkernel : ∀ x, |(∫ y, g y ∂K x) - (∫ z, g z.2 ∂ν)| ≤ D) : |(∫ z, f z.1 * g z.2 ∂ν) - (∫ x, f x ∂μ) * (∫ z, g z.2 ∂ν)| ≤ Cf * D := by let c : ℝ := ∫ z, g z.2 ∂ν have hkg_meas : Measurable (fun x => ∫ y, g y ∂K x) := by simpa using ((hg.comp measurable_snd).stronglyMeasurable.integral_kernel_prod_right').measurable have hkg_bound : ∀ x, |∫ y, g y ∂K x| ≤ Cg := by intro x simpa only [Real.norm_eq_abs, probReal_univ, mul_one] using (norm_integral_le_of_norm_le_const (μ := K x) (f := g) (C := Cg) (Filter.Eventually.of_forall fun y => by simpa only [Real.norm_eq_abs] using hg_bound y)) have hfg_bound : ∀ z : X × Y, |f z.1 * g z.2| ≤ Cf * Cg := by intro z rw [abs_mul] exact mul_le_mul (hf_bound z.1) (hg_bound z.2) (abs_nonneg _) hCf have hfg_meas : Measurable (fun z : X × Y => f z.1 * g z.2) := (hf.comp measurable_fst).mul (hg.comp measurable_snd) have hf_int : Integrable f μ := Integrable.of_bound hf.aestronglyMeasurable Cf (Filter.Eventually.of_forall fun x => by simpa only [Real.norm_eq_abs] using hf_bound x) have hkgf_int : Integrable (fun x => f x * ∫ y, g y ∂K x) μ := by apply Integrable.of_bound ((hf.mul hkg_meas).aestronglyMeasurable) (Cf * Cg) exact Filter.Eventually.of_forall fun x => by simpa only [Pi.mul_apply, Real.norm_eq_abs, abs_mul] using mul_le_mul (hf_bound x) (hkg_bound x) (abs_nonneg _) hCf have hfg_eq : (∫ z, f z.1 * g z.2 ∂ν) = ∫ x, f x * (∫ y, g y ∂K x) ∂μ := by rw [integral_compProd_bounded μ K ν hν _ hfg_meas (Cf * Cg) hfg_bound] congr 1 funext x simpa only [fst, snd] using integral_const_mul (μ := K x) (f x) g have hcenter_eq : (∫ x, f x * ((∫ y, g y ∂K x) - c) ∂μ) = (∫ x, f x * (∫ y, g y ∂K x) ∂μ) - (∫ x, f x ∂μ) * c := by simp_rw [mul_sub] rw [integral_sub hkgf_int (hf_int.mul_const c), integral_mul_const] rw [hfg_eq] change |(∫ x, f x * (∫ y, g y ∂K x) ∂μ) - (∫ x, f x ∂μ) * c| ≤ Cf * D rw [← hcenter_eq] simpa only [Real.norm_eq_abs, probReal_univ, mul_one] using (norm_integral_le_of_norm_le_const (μ := μ) (f := fun x => f x * ((∫ y, g y ∂K x) - c)) (C := Cf * D) (Filter.Eventually.of_forall fun x => by simpa only [Real.norm_eq_abs, abs_mul] using mul_le_mul (hf_bound x) (hkernel x) (abs_nonneg _) hCf))
    Causalean.Mathlib.Probability.Kernel.FiniteHistory.covariance_compProd_of_centered_kernel_bound · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Expectation.lean:92
Stationary 2 core · 4 supporting This module turns finite stationary mass identities and ℓ¹-contractive Markov transitions into geometric covariance bounds for separated bounded windows, without positive atom assumptions. ★ separated_window_covariance

Stationary finite-state window bounds

This module turns finite stationary mass identities and ℓ¹-contractive Markov transitions into geometric covariance bounds for separated bounded windows, without positive atom assumptions.

def pointVector reviewed
Causalean.Mathlib.Probability.Kernel.FiniteHistory

The point-mass probability vector at a state s of a finite state space puts mass one on s and zero on every other state.

Definition (Lean source)
S :
s :
S
pointVector s :
S → ℝ
fun t => if t = s then 1 else 0
Causalean.Mathlib.Probability.Kernel.FiniteHistory.pointVector · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Stationary.lean:80
theorem separated_window_covariance reviewed
Causalean.Mathlib.Probability.Kernel.FiniteHistory

Let P be a row-stochastic transition matrix on a finite state space with stationary distribution π, and suppose one step of P contracts the ℓ¹ distance between probability vectors by a factor α with 0 ≤ α. Let a past window be drawn from a probability law μ whose measurable last state has distribution π, and let Q be a Markov kernel from states to future windows and future a Markov kernel from past to future windows such that for every past window x, the future kernel's mean of every measurable function bounded by one equals its Q-mean averaged over the distribution reached after gap steps from the point mass at the last state of x. If the joint law ν is μ composed with the future kernel, f is a measurable past score bounded in absolute value by Cf and g a measurable future score bounded in absolute value by Cg, then the covariance of f and g under ν is at most 2·Cf·Cg·α^gap in absolute value.

Formal statement
P :
Matrix S S ℝ
π :
S → ℝ
alpha :
ℝ
hπ :
hcontract :
ContractsL1 P alpha
halpha0 :
0 ≤ alpha
gap :
ℕ
last :
X → S
hlast_meas :
hlast :
∀ s, ((μ.map last) {s}).toReal = π s
future :
hfuture :
∀ (g : Y → ℝ)
and
(∀ y, |g y| ≤ 1)
then
∀ x,
(∫ y, g y ∂future x) = ∑ s, markovIterate P (pointVector (last x)) gap s * (∫ y, g y ∂Q s)
ν :
Measure (X × Y)
hν :
ν = μ ⊗ₘ future
f :
X → ℝ
hf :
Cf :
ℝ
hf_bound :
∀ x, |f x| ≤ Cf
g :
Y → ℝ
hg :
Cg :
ℝ
hg_bound :
∀ y, |g y| ≤ Cg
|(∫ z, f z.1 * g z.2 ∂ν) - (∫ x, f x ∂μ) * (∫ z, g z.2 ∂ν)| ≤ 2 * Cf * Cg * alpha ^ gap
Proof (Lean source)
theorem separated_window_covariance {S X Y : Type*} [Fintype S] [DecidableEq S] [MeasurableSpace S] [MeasurableSpace X] [MeasurableSpace Y] (P : Matrix S S ℝ) (π : S → ℝ) (alpha : ℝ) (hP : IsStochasticMatrix P) (hπ : IsStationary P π) (hcontract : ContractsL1 P alpha) (halpha0 : 0 ≤ alpha) (gap : ℕ) (μ : Measure X) [IsProbabilityMeasure μ] (last : X → S) (hlast_meas : Measurable last) (hlast : ∀ s, ((μ.map last) {s}).toReal = π s) (Q : Kernel S Y) [IsMarkovKernel Q] (future : Kernel X Y) [IsMarkovKernel future] (hfuture : ∀ (g : Y → ℝ), Measurable g → (∀ y, |g y| ≤ 1) → ∀ x, (∫ y, g y ∂future x) = ∑ s, markovIterate P (pointVector (last x)) gap s * (∫ y, g y ∂Q s)) (ν : Measure (X × Y)) (hν : ν = μ ⊗ₘ future) (f : X → ℝ) (hf : Measurable f) (Cf : ℝ) (hf_bound : ∀ x, |f x| ≤ Cf) (g : Y → ℝ) (hg : Measurable g) (Cg : ℝ) (hg_bound : ∀ y, |g y| ≤ Cg) : |(∫ z, f z.1 * g z.2 ∂ν) - (∫ x, f x ∂μ) * (∫ z, g z.2 ∂ν)| ≤ 2 * Cf * Cg * alpha ^ gap := by -- Probability of `μ` supplies an `x : X`; Markovness of `future x` supplies -- a `y : Y`, so the pointwise bounds give `0 ≤ Cf` and `0 ≤ Cg`. -- If `Cg = 0`, then `g = 0` pointwise and the covariance vanishes. -- Otherwise apply `hfuture` and `stationary_future_window_mean` to -- `fun y => g y / Cg`, whose absolute value is at most one. Scale both -- identities back by `Cg`; `markov_row_score_bound` bounds the centered -- conditional mean pointwise with `v s = ∫ y, g y ∂Q s` and `Cv = Cg`. -- Finish with `covariance_compProd_of_centered_kernel_bound`, taking -- `D = 2 * Cg * alpha ^ gap`. No singleton measurability or positive -- history-atom probability is required. classical obtain ⟨x₀⟩ := nonempty_of_isProbabilityMeasure μ have hCf : 0 ≤ Cf := le_trans (abs_nonneg _) (hf_bound x₀) obtain ⟨y₀⟩ := nonempty_of_isProbabilityMeasure (future x₀) have hCg : 0 ≤ Cg := le_trans (abs_nonneg _) (hg_bound y₀) by_cases hCg0 : Cg = 0 · have hg0 : ∀ y, g y = 0 := by intro y have h := hg_bound y rw [hCg0] at h exact abs_eq_zero.mp (le_antisymm h (abs_nonneg _)) simp [hg0, hCg0] have hCgpos : 0 < Cg := lt_of_le_of_ne hCg (Ne.symm hCg0) have hnorm_meas : Measurable (fun y => g y / Cg) := hg.div_const Cg have hnorm_bound : ∀ y, |g y / Cg| ≤ 1 := by intro y rw [abs_div, abs_of_pos hCgpos] exact (div_le_iff₀ hCgpos).2 (by simpa using hg_bound y) let v : S → ℝ := fun s => ∫ y, g y ∂Q s have hv : ∀ s, |v s| ≤ Cg := by intro s simpa only [v, Real.norm_eq_abs, probReal_univ, mul_one] using (norm_integral_le_of_norm_le_const (μ := Q s) (f := g) (C := Cg) (Filter.Eventually.of_forall fun y => by simpa only [Real.norm_eq_abs] using hg_bound y)) have hscale (m : Measure Y) : Cg * (∫ y, g y / Cg ∂m) = ∫ y, g y ∂m := by rw [integral_div] exact mul_div_cancel₀ _ hCg0 have hfuture_scaled (x : X) : (∫ y, g y ∂future x) = ∑ s, markovIterate P (pointVector (last x)) gap s * v s := by calc (∫ y, g y ∂future x) = Cg * (∫ y, g y / Cg ∂future x) := (hscale (future x)).symm _ = Cg * ∑ s, markovIterate P (pointVector (last x)) gap s * (∫ y, g y / Cg ∂Q s) := by rw [hfuture (fun y => g y / Cg) hnorm_meas hnorm_bound x] _ = ∑ s, markovIterate P (pointVector (last x)) gap s * v s := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro s hs rw [← mul_assoc, mul_comm Cg, mul_assoc, hscale (Q s)] have hmean : (∫ z, g z.2 ∂ν) = ∑ s, π s * v s := by calc (∫ z, g z.2 ∂ν) = Cg * (∫ z, g z.2 / Cg ∂ν) := by rw [integral_div]; exact (mul_div_cancel₀ _ hCg0).symm _ = Cg * ∑ s, π s * (∫ y, g y / Cg ∂Q s) := by rw [stationary_future_window_mean P π hπ gap μ last hlast_meas hlast Q future hfuture ν hν (fun y => g y / Cg) hnorm_meas hnorm_bound] _ = ∑ s, π s * v s := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro s hs rw [← mul_assoc, mul_comm Cg, mul_assoc, hscale (Q s)] have hkernel (x : X) : |(∫ y, g y ∂future x) - (∫ z, g z.2 ∂ν)| ≤ 2 * Cg * alpha ^ gap := by rw [hfuture_scaled x, hmean] exact markov_row_score_bound P π alpha hP hπ hcontract halpha0 gap (last x) v Cg hv convert covariance_compProd_of_centered_kernel_bound μ future ν hν f hf Cf hCf hf_bound g hg Cg hg_bound (2 * Cg * alpha ^ gap) hkernel using 1 ring
4 supporting declarations (lemmas, instances)
  • integral_finite_eq_sum_of_singleton_masses theorem — A probability law on a finite measurable space, candidate atom masses that sum to one and match the law's singleton masses, and a measurable score yield the corresponding finite weighted-sum integral.
    S :
    π :
    S → ℝ
    hπsum :
    ∑ s, π s = 1
    hπatom :
    ∀ s, (ρ {s}).toReal = π s
    v :
    S → ℝ
    hv :
    (∫ s, v s ∂ρ) = ∑ s, π s * v s
    Proof (Lean source)
    theorem integral_finite_eq_sum_of_singleton_masses {S : Type*} [Fintype S] [MeasurableSpace S] (ρ : Measure S) [IsProbabilityMeasure ρ] (π : S → ℝ) (hπsum : ∑ s, π s = 1) (hπatom : ∀ s, (ρ {s}).toReal = π s) (v : S → ℝ) (hv : Measurable v) : (∫ s, v s ∂ρ) = ∑ s, π s * v s := by classical let T (A : Set S) : Finset S := Finset.univ.filter (fun s => s ∈ A) have hbound (A : Set S) : ρ.real A ≤ ∑ s ∈ T A, π s := by have hset : A = ⋃ s ∈ T A, ({s} : Set S) := by ext s simp [T] calc ρ.real A = ρ.real (⋃ s ∈ T A, ({s} : Set S)) := congrArg ρ.real hset _ ≤ ∑ s ∈ T A, ρ.real {s} := measureReal_biUnion_finset_le _ _ _ = ∑ s ∈ T A, π s := by simp [Measure.real, hπatom] have hevent (A : Set S) (hA : MeasurableSet A) : ρ.real A = ∑ s ∈ T A, π s := by have hc := hbound Aᶜ have hs : (∑ s ∈ T A, π s) + (∑ s ∈ T Aᶜ, π s) = 1 := by simpa only [T, Set.mem_compl_iff, Finset.sum_filter_add_sum_filter_not] using hπsum have hm : ρ.real A + ρ.real Aᶜ = 1 := by simpa [probReal_univ] using (measureReal_add_measureReal_compl (μ := ρ) hA) have ha := hbound A have hreverse : (∑ s ∈ T A, π s) ≤ ρ.real A := by calc (∑ s ∈ T A, π s) = 1 - (∑ s ∈ T Aᶜ, π s) := eq_sub_of_add_eq hs _ ≤ 1 - ρ.real Aᶜ := sub_le_sub_left hc 1 _ = ρ.real A := (eq_sub_of_add_eq hm).symm exact le_antisymm ha hreverse let f : SimpleFunc S ℝ := ⟨v, (fun x => hv (measurableSet_singleton x)), Set.finite_range v⟩ have hf : (f : S → ℝ) = v := rfl have hi : Integrable (f : S → ℝ) ρ := f.integrable_of_isFiniteMeasure change (∫ s, f s ∂ρ) = ∑ s, π s * v s rw [SimpleFunc.integral_eq_sum f hi] simp only [smul_eq_mul] have hfiber (x : ℝ) : ρ.real (v ⁻¹' {x}) = ∑ s ∈ Finset.univ.filter (fun s => v s = x), π s := by simpa only [T, Set.mem_preimage, Set.mem_singleton_iff] using hevent (v ⁻¹' {x}) (hv (measurableSet_singleton x)) simp only [hf] at * simp_rw [hfiber] rw [← Finset.sum_fiberwise_of_maps_to (s := univ) (t := f.range) (g := v) (f := fun s => π s * v s) (by intro s hs exact f.mem_range_self s)] congr 1 ext x rw [Finset.sum_mul] apply Finset.sum_congr rfl intro s hs have hvs : v s = x := (Finset.mem_filter.mp hs).2 rw [hvs]
    Causalean.Mathlib.Probability.Kernel.FiniteHistory.integral_finite_eq_sum_of_singleton_masses · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Stationary.lean:19
  • markovIterate_point_stationary_bound theorem — Let P be a row-stochastic transition matrix on a finite state space with stationary distribution π, and suppose one step of P contracts the ℓ¹ distance between probability vectors by a factor α with 0 ≤ α. Then for every starting state s and every number of steps gap, the ℓ¹ distance between the distribution after gap steps from the point mass at s and π is at most 2·α^gap.
    S :
    P :
    Matrix S S ℝ
    π :
    S → ℝ
    alpha :
    ℝ
    hπ :
    hcontract :
    ContractsL1 P alpha
    halpha0 :
    0 ≤ alpha
    gap :
    ℕ
    s :
    S
    l1Distance (markovIterate P (pointVector s) gap) π ≤ 2 * alpha ^ gap
    Proof (Lean source)
    theorem markovIterate_point_stationary_bound {S : Type*} [Fintype S] [DecidableEq S] (P : Matrix S S ℝ) (π : S → ℝ) (alpha : ℝ) (hP : IsStochasticMatrix P) (hπ : IsStationary P π) (hcontract : ContractsL1 P alpha) (halpha0 : 0 ≤ alpha) (gap : ℕ) (s : S) : l1Distance (markovIterate P (pointVector s) gap) π ≤ 2 * alpha ^ gap := by have hp : IsProbabilityVector (pointVector s) := by constructor · intro t unfold pointVector split <;> norm_num · simp [pointVector] have hbase : l1Distance (pointVector s) π ≤ 2 := by unfold l1Distance calc (∑ t, |pointVector s t - π t|) ≤ ∑ t, (pointVector s t + π t) := by apply Finset.sum_le_sum intro t ht apply abs_le.mpr constructor <;> have := hp.1 t <;> have := hπ.1.1 t <;> linarith _ = 2 := by rw [Finset.sum_add_distrib, hp.2, hπ.1.2]; ring induction gap with | zero => simpa [markovIterate] using hbase | succ n ih => have hn := hP.iterate_probability hp n calc l1Distance (markovIterate P (pointVector s) (n + 1)) π = l1Distance (markovStep (markovIterate P (pointVector s) n) P) (markovStep π P) := by rw [hπ.2]; rfl _ ≤ alpha * l1Distance (markovIterate P (pointVector s) n) π := hcontract _ _ hn hπ.1 _ ≤ alpha * (2 * alpha ^ n) := mul_le_mul_of_nonneg_left ih halpha0 _ = 2 * alpha ^ (n + 1) := by rw [pow_succ]; ring
    Causalean.Mathlib.Probability.Kernel.FiniteHistory.markovIterate_point_stationary_bound · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Stationary.lean:85
  • markov_row_score_bound theorem — A finite transition matrix, stationary distribution, contraction coefficient, stochasticity certificate, stationarity certificate, ℓ¹ contraction certificate, nonnegative coefficient, step gap, starting state, and bounded score give the geometric error bound for its Markov-row mean.
    S :
    P :
    Matrix S S ℝ
    π :
    S → ℝ
    alpha :
    ℝ
    hπ :
    hcontract :
    ContractsL1 P alpha
    halpha0 :
    0 ≤ alpha
    gap :
    ℕ
    s :
    S
    v :
    S → ℝ
    Cv :
    ℝ
    hv :
    ∀ t, |v t| ≤ Cv
    |(∑ t, markovIterate P (pointVector s) gap t * v t) - (∑ t, π t * v t)|
    ≤ 2 * Cv * alpha ^ gap
    Proof (Lean source)
    theorem markov_row_score_bound {S : Type*} [Fintype S] [DecidableEq S] (P : Matrix S S ℝ) (π : S → ℝ) (alpha : ℝ) (hP : IsStochasticMatrix P) (hπ : IsStationary P π) (hcontract : ContractsL1 P alpha) (halpha0 : 0 ≤ alpha) (gap : ℕ) (s : S) (v : S → ℝ) (Cv : ℝ) (hv : ∀ t, |v t| ≤ Cv) : |(∑ t, markovIterate P (pointVector s) gap t * v t) - (∑ t, π t * v t)| ≤ 2 * Cv * alpha ^ gap := by have hCv : 0 ≤ Cv := le_trans (abs_nonneg _) (hv s) have hdist := markovIterate_point_stationary_bound P π alpha hP hπ hcontract halpha0 gap s calc |(∑ t, markovIterate P (pointVector s) gap t * v t) - (∑ t, π t * v t)| ≤ Cv * l1Distance (markovIterate P (pointVector s) gap) π := by rw [← Finset.sum_sub_distrib] calc |∑ t, (markovIterate P (pointVector s) gap t * v t - π t * v t)| = |∑ t, (markovIterate P (pointVector s) gap t - π t) * v t| := by congr 1 apply Finset.sum_congr rfl intro t ht ring _ ≤ ∑ t, |(markovIterate P (pointVector s) gap t - π t) * v t| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ t, |markovIterate P (pointVector s) gap t - π t| * Cv := by apply Finset.sum_le_sum intro t ht rw [abs_mul] exact mul_le_mul_of_nonneg_left (hv t) (abs_nonneg _) _ = Cv * l1Distance (markovIterate P (pointVector s) gap) π := by rw [l1Distance, Finset.mul_sum] apply Finset.sum_congr rfl intro t ht ring _ ≤ Cv * (2 * alpha ^ gap) := mul_le_mul_of_nonneg_left hdist hCv _ = 2 * Cv * alpha ^ gap := by ring
    Causalean.Mathlib.Probability.Kernel.FiniteHistory.markov_row_score_bound · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Stationary.lean:127
  • stationary_future_window_mean theorem — A finite transition matrix, stationary distribution, stationarity certificate, gap, probability past-window law, measurable last-state map with stationary singleton masses, stationary future kernel, conditional future kernel, their supplied gap-kernel representation, joint law satisfying the composition-product identity, and a measurable normalized future score give the stationary-mixture formula for its marginal mean.
    P :
    Matrix S S ℝ
    π :
    S → ℝ
    hπ :
    gap :
    ℕ
    last :
    X → S
    hlast_meas :
    hlast :
    ∀ s, ((μ.map last) {s}).toReal = π s
    future :
    hfuture :
    ∀ (g : Y → ℝ)
    and
    (∀ y, |g y| ≤ 1)
    then
    ∀ x,
    (∫ y, g y ∂future x) = ∑ s, markovIterate P (pointVector (last x)) gap s * (∫ y, g y ∂Q s)
    ν :
    Measure (X × Y)
    hν :
    ν = μ ⊗ₘ future
    g :
    Y → ℝ
    hg :
    hg_bound :
    ∀ y, |g y| ≤ 1
    (∫ z, g z.2 ∂ν) = ∑ s, π s * (∫ y, g y ∂Q s)
    Proof (Lean source)
    theorem stationary_future_window_mean {S X Y : Type*} [Fintype S] [DecidableEq S] [MeasurableSpace S] [MeasurableSpace X] [MeasurableSpace Y] (P : Matrix S S ℝ) (π : S → ℝ) (hπ : IsStationary P π) (gap : ℕ) (μ : Measure X) [IsProbabilityMeasure μ] (last : X → S) (hlast_meas : Measurable last) (hlast : ∀ s, ((μ.map last) {s}).toReal = π s) (Q : Kernel S Y) [IsMarkovKernel Q] (future : Kernel X Y) [IsMarkovKernel future] (hfuture : ∀ (g : Y → ℝ), Measurable g → (∀ y, |g y| ≤ 1) → ∀ x, (∫ y, g y ∂future x) = ∑ s, markovIterate P (pointVector (last x)) gap s * (∫ y, g y ∂Q s)) (ν : Measure (X × Y)) (hν : ν = μ ⊗ₘ future) (g : Y → ℝ) (hg : Measurable g) (hg_bound : ∀ y, |g y| ≤ 1) : (∫ z, g z.2 ∂ν) = ∑ s, π s * (∫ y, g y ∂Q s) := by -- The future kernel integral is measurable on `X`. Its finite fibers have -- masses determined by the outer singleton masses of `μ.map last`, even -- when the state singletons themselves are not measurable. The stationary -- identity then averages the finite Markov rows back to `π`. classical let ρ : Measure S := μ.map last have : IsProbabilityMeasure ρ := Measure.isProbabilityMeasure_map hlast_meas.aemeasurable let q : S → ℝ := fun s => ∫ y, g y ∂Q s let v : S → ℝ := fun s => ∑ t, markovIterate P (pointVector s) gap t * q t let F : X → ℝ := fun x => ∫ y, g y ∂future x have hF : Measurable F := ((hg.comp measurable_snd).stronglyMeasurable.integral_kernel_prod_right').measurable have hFv (x : X) : F x = v (last x) := hfuture g hg hg_bound x have hbound (B : Set S) : μ.real (last ⁻¹' B) ≤ ∑ s ∈ Finset.univ.filter (fun s => s ∈ B), π s := by have hset : B = ⋃ s ∈ Finset.univ.filter (fun s => s ∈ B), ({s} : Set S) := by ext s simp calc μ.real (last ⁻¹' B) ≤ ρ.real B := by exact ENNReal.toReal_mono (measure_ne_top ρ B) (Measure.le_map_apply hlast_meas.aemeasurable B) _ = ρ.real (⋃ s ∈ Finset.univ.filter (fun s => s ∈ B), ({s} : Set S)) := congrArg ρ.real hset _ ≤ ∑ s ∈ Finset.univ.filter (fun s => s ∈ B), ρ.real {s} := measureReal_biUnion_finset_le _ _ _ = ∑ s ∈ Finset.univ.filter (fun s => s ∈ B), π s := by simp [Measure.real, ρ, hlast] have hevent (B : Set S) (hB : MeasurableSet (last ⁻¹' B)) : μ.real (last ⁻¹' B) = ∑ s ∈ Finset.univ.filter (fun s => s ∈ B), π s := by have hc := hbound Bᶜ have hs : (∑ s ∈ Finset.univ.filter (fun s => s ∈ B), π s) + (∑ s ∈ Finset.univ.filter (fun s => s ∈ Bᶜ), π s) = 1 := by simpa only [Set.mem_compl_iff, Finset.sum_filter_add_sum_filter_not] using hπ.1.2 have hm : μ.real (last ⁻¹' B) + μ.real (last ⁻¹' Bᶜ) = 1 := by simpa [Set.preimage_compl, probReal_univ] using (measureReal_add_measureReal_compl (μ := μ) hB) have ha := hbound B have hr : (∑ s ∈ Finset.univ.filter (fun s => s ∈ B), π s) ≤ μ.real (last ⁻¹' B) := by calc (∑ s ∈ Finset.univ.filter (fun s => s ∈ B), π s) = 1 - (∑ s ∈ Finset.univ.filter (fun s => s ∈ Bᶜ), π s) := eq_sub_of_add_eq hs _ ≤ 1 - μ.real (last ⁻¹' Bᶜ) := by simpa only [Set.mem_compl_iff] using (sub_le_sub_left hc 1) _ = μ.real (last ⁻¹' B) := (eq_sub_of_add_eq hm).symm exact le_antisymm ha hr have hfr : (range F).Finite := (Set.finite_range v).subset (by rintro r ⟨x, rfl⟩ exact ⟨last x, (hFv x).symm⟩) let sf : SimpleFunc X ℝ := ⟨F, (fun r => hF (measurableSet_singleton r)), hfr⟩ have hfi : Integrable (sf : X → ℝ) μ := sf.integrable_of_isFiniteMeasure have hfiber (r : ℝ) : μ.real (F ⁻¹' {r}) = ∑ s ∈ Finset.univ.filter (fun s => v s = r), π s := by have hpre : F ⁻¹' {r} = last ⁻¹' {s | v s = r} := by ext x simp only [Set.mem_preimage, Set.mem_singleton_iff, Set.mem_ofPred_eq, hFv] rw [hpre] simpa only [Set.mem_ofPred_eq] using hevent {s | v s = r} (by rw [← hpre]; exact hF (measurableSet_singleton r)) have hmass : (∫ x, F x ∂μ) = ∑ s, π s * v s := by change (∫ x, sf x ∂μ) = _ rw [← SimpleFunc.integral_eq_integral sf hfi] have hsubset : {r ∈ sf.range | r ≠ 0} ⊆ Finset.univ.image v := by intro r hr obtain ⟨x, hx⟩ := (SimpleFunc.mem_range.mp (Finset.mem_filter.mp hr).1) exact Finset.mem_image.mpr ⟨last x, Finset.mem_univ _, by simpa [sf] using (hFv x).symm.trans hx⟩ rw [SimpleFunc.integral_eq_sum_of_subset hsubset] simp only [smul_eq_mul] simp_rw [show (sf : X → ℝ) = F from rfl, hfiber] rw [← Finset.sum_fiberwise_of_maps_to (s := univ) (t := Finset.univ.image v) (g := v) (f := fun s => π s * v s) (by intro s hs; exact Finset.mem_image_of_mem v hs)] congr 1 ext r rw [Finset.sum_mul] apply Finset.sum_congr rfl intro s hs rw [(Finset.mem_filter.mp hs).2] have hmix : ∀ n t, (∑ s, π s * markovIterate P (pointVector s) n t) = π t := by intro n induction n with | zero => intro t simp [markovIterate, pointVector] | succ n ih => intro t simp only [markovIterate, markovStep, Matrix.vecMul_eq_sum, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] calc (∑ s, π s * ∑ u, markovIterate P (pointVector s) n u * P u t) = ∑ u, (∑ s, π s * markovIterate P (pointVector s) n u) * P u t := by simp_rw [Finset.mul_sum] rw [Finset.sum_comm] simp_rw [← mul_assoc, ← Finset.sum_mul] _ = ∑ u, π u * P u t := by simp_rw [ih] _ = π t := by have ht := congrFun hπ.2 t simpa [markovStep, Matrix.vecMul_eq_sum] using ht have hq : Measurable q := ((hg.comp measurable_snd).stronglyMeasurable.integral_kernel_prod_right').measurable have hqmean := integral_finite_eq_sum_of_singleton_masses ρ π hπ.1.2 (by simpa [ρ] using hlast) q hq calc (∫ z, g z.2 ∂ν) = ∫ x, F x ∂μ := by exact integral_compProd_bounded μ future ν hν _ (hg.comp measurable_snd) 1 (fun z => hg_bound z.2) _ = ∑ s, π s * v s := hmass _ = ∑ t, π t * q t := by simp only [v] simp_rw [Finset.mul_sum] rw [Finset.sum_comm] simp_rw [← mul_assoc, ← Finset.sum_mul] simp_rw [hmix] _ = ∫ s, q s ∂ρ := hqmean.symm _ = ∑ s, π s * (∫ y, g y ∂Q s) := hqmean
    Causalean.Mathlib.Probability.Kernel.FiniteHistory.stationary_future_window_mean · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Stationary.lean:167
Weighted 4 core · 6 supporting This module defines zero-on-null likelihood ratios and transfers bounded weighted history scores through repeated Markov-kernel extensions to finite-state matrix expressions. ★ integral_weighted_reward_eq_matrix

Likelihood-weighted finite sequential expectations

This module defines zero-on-null likelihood ratios and transfers bounded weighted history scores through repeated Markov-kernel extensions to finite-state matrix expressions.

def actionLikelihood reviewed
Causalean.Mathlib.Probability.Kernel.FiniteHistory

A behavior kernel, target kernel, state, and action determine the zero-on-null likelihood ratio, given by zero on a behavior-null action and otherwise by the target-to-behavior atom-mass ratio.

Definition (Lean source)
behavior target :
Kernel S A
s :
S
a :
A
actionLikelihood behavior target s a :
ℝ
if (behavior s) {a} = 0 then 0 else ((target s) {a}).toReal / ((behavior s) {a}).toReal
Causalean.Mathlib.Probability.Kernel.FiniteHistory.actionLikelihood · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Weighted.lean:18
def weightedValue reviewed
Causalean.Mathlib.Probability.Kernel.FiniteHistory

A kernel, history append map, one-step weight, number of steps, and terminal score determine the iterated weighted value, given by the terminal score at zero steps and by one weighted kernel integration at each successor step.

Definition (Lean source)
K :
Kernel H B
append :
H → B → H
w :
H → B → ℝ
n :
ℕ
f :
H → ℝ
weightedValue K append w n f :
H → ℝ
match n with | 0
=> f | n + 1 => fun h => ∫ b, w h b * weightedValue K append w n f (append h b) ∂K h
Causalean.Mathlib.Probability.Kernel.FiniteHistory.weightedValue · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Weighted.lean:72
def matrixValue reviewed
Causalean.Mathlib.Probability.Kernel.FiniteHistory

A transition matrix, number of steps, and terminal reward vector determine the finite-state matrix value, given by the reward at zero steps and by one matrix multiplication at each successor step.

Definition (Lean source)
S :
Type*
P :
Matrix S S ℝ
n :
ℕ
reward :
S → ℝ
matrixValue P n reward :
S → ℝ
match n with | 0 => reward | n + 1 => fun s => ∑ t, P s t * matrixValue P n reward t
Causalean.Mathlib.Probability.Kernel.FiniteHistory.matrixValue · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Weighted.lean:81
theorem integral_weighted_reward_eq_matrix reviewed
Causalean.Mathlib.Probability.Kernel.FiniteHistory

Let K be a Markov kernel from histories to increments, with a jointly measurable map appending an increment to a history and a jointly measurable one-step weight bounded in absolute value by a constant. Let the step-indexed history laws be probability measures such that each next law is the law of the appended history when the history is drawn from the current law and the increment from K, and let the step-indexed path weights be measurable and each bounded, equal to one at step zero and multiplied by the one-step weight whenever an increment is appended. Suppose a measurable map sends each history to its current state in a finite state space and, for a matrix P indexed by states, the K-integral of the one-step weight times any function of the next state equals the P-row average of that function at the current state, for every history. Then for a reward on states bounded in absolute value by a constant and every number of steps n, the step-n expectation of the path weight times the reward at the current state equals the step-zero expectation of the n-fold application of P to the reward, evaluated at the initial state.

Formal statement
append :
H → B → H
happend :
Measurable fun z : H × B => append z.1 z.2
w :
H → B → ℝ
hw :
Measurable fun z : H × B => w z.1 z.2
Cw :
ℝ
hw_bound :
∀ h b, |w h b| ≤ Cw
μ :
ℕ → Measure H
hμprob :
∀ n, IsProbabilityMeasure (μ n)
hμ :
∀ n, μ (n + 1) = (μ n ⊗ₘ K).map (fun z => append z.1 z.2)
weight :
ℕ → H → ℝ
hweight_meas :
∀ n, Measurable (weight n)
hweight_bound :
∀ n, ∃ C : ℝ, ∀ h, |weight n h| ≤ C
hweight0 :
∀ h, weight 0 h = 1
hweight_step :
∀ n h b, weight (n + 1) (append h b) = weight n h * w h b
state :
H → S
hstate :
Measurable state
P :
Matrix S S ℝ
hweighted :
∀ (v : S → ℝ)
if
Measurable v
then
∀ h, (∫ b, w h b * v (state (append h b)) ∂K h) = ∑ s, P (state h) s * v s
reward :
S → ℝ
hreward :
Measurable reward
Cr :
ℝ
hreward_bound :
∀ s, |reward s| ≤ Cr
n :
ℕ
∫ h, weight n h * reward (state h) ∂μ n = ∫ h, matrixValue P n reward (state h) ∂μ 0
Proof (Lean source)
theorem integral_weighted_reward_eq_matrix {H B S : Type*} [MeasurableSpace H] [MeasurableSpace B] [MeasurableSpace S] [Fintype S] [MeasurableSingletonClass S] (K : Kernel H B) [IsMarkovKernel K] (append : H → B → H) (happend : Measurable fun z : H × B => append z.1 z.2) (w : H → B → ℝ) (hw : Measurable fun z : H × B => w z.1 z.2) (Cw : ℝ) (hw_bound : ∀ h b, |w h b| ≤ Cw) (μ : ℕ → Measure H) (hμprob : ∀ n, IsProbabilityMeasure (μ n)) (hμ : ∀ n, μ (n + 1) = (μ n ⊗ₘ K).map (fun z => append z.1 z.2)) (weight : ℕ → H → ℝ) (hweight_meas : ∀ n, Measurable (weight n)) (hweight_bound : ∀ n, ∃ C : ℝ, ∀ h, |weight n h| ≤ C) (hweight0 : ∀ h, weight 0 h = 1) (hweight_step : ∀ n h b, weight (n + 1) (append h b) = weight n h * w h b) (state : H → S) (hstate : Measurable state) (P : Matrix S S ℝ) (hweighted : ∀ (v : S → ℝ), Measurable v → ∀ h, (∫ b, w h b * v (state (append h b)) ∂K h) = ∑ s, P (state h) s * v s) (reward : S → ℝ) (hreward : Measurable reward) (Cr : ℝ) (hreward_bound : ∀ s, |reward s| ≤ Cr) (n : ℕ) : ∫ h, weight n h * reward (state h) ∂μ n = ∫ h, matrixValue P n reward (state h) ∂μ 0 := by -- Compose `integral_weighted_history` and `weightedValue_eq_matrixValue`. have hhist := integral_weighted_history K append happend w hw Cw hw_bound μ hμprob hμ weight hweight_meas hweight_bound hweight0 hweight_step (reward ∘ state) (hreward.comp hstate) Cr (fun h => hreward_bound (state h)) n simp only [Function.comp_apply] at hhist rw [hhist] congr 1 funext h exact weightedValue_eq_matrixValue K append w state P hweighted reward n h
Causalean.Mathlib.Probability.Kernel.FiniteHistory.integral_weighted_reward_eq_matrix · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Weighted.lean:307 · uses matrixValue
6 supporting declarations (lemmas, instances)
  • actionLikelihood_measurable theorem — The behavior kernel and target kernel make their zero-on-null likelihood ratio jointly measurable.
    Measurable fun z : S × A => actionLikelihood behavior target z.1 z.2
    Proof (Lean source)
    @[fun_prop] theorem actionLikelihood_measurable {S A : Type*} [MeasurableSpace S] [MeasurableSpace A] [MeasurableSingletonClass A] [Fintype A] (behavior target : Kernel S A) : Measurable fun z : S × A => actionLikelihood behavior target z.1 z.2 := by -- Partition the finite action space into singleton cells. For fixed `a`, -- kernel evaluation on `{a}` is measurable in the state. apply measurable_from_prod_countable_left intro a unfold actionLikelihood have hb : Measurable (fun s => (behavior s) {a}) := Kernel.measurable_coe behavior (MeasurableSet.singleton a) have ht : Measurable (fun s => (target s) {a}) := Kernel.measurable_coe target (MeasurableSet.singleton a) exact Measurable.ite (hb (measurableSet_singleton 0)) measurable_const (ht.ennreal_toReal.div hb.ennreal_toReal)
    Causalean.Mathlib.Probability.Kernel.FiniteHistory.actionLikelihood_measurable · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Weighted.lean:26
  • integral_actionLikelihood theorem — Markov behavior and target kernels with target absolute continuity relative to behavior transform the action score at the selected state into the stated likelihood-weighted expectation identity.
    behavior target :
    hAC :
    ∀ s, target s ≪ behavior s
    s :
    S
    g :
    A → ℝ
    ∫ a, actionLikelihood behavior target s a * g a ∂behavior s = ∫ a, g a ∂target s
    Proof (Lean source)
    theorem integral_actionLikelihood {S A : Type*} [MeasurableSpace S] [MeasurableSpace A] [MeasurableSingletonClass A] [Fintype A] (behavior target : Kernel S A) [IsMarkovKernel behavior] [IsMarkovKernel target] (hAC : ∀ s, target s ≪ behavior s) (s : S) (g : A → ℝ) : ∫ a, actionLikelihood behavior target s a * g a ∂behavior s = ∫ a, g a ∂target s := by -- Convert both integrals into finite sums of atom masses. On a behavior-null -- atom, `hAC s` makes the target atom null too; on other atoms cancel the -- denominator after converting finite ENNReal masses to real numbers. have hbint : Integrable (fun a => actionLikelihood behavior target s a * g a) (behavior s) := Integrable.of_finite have htint : Integrable g (target s) := Integrable.of_finite rw [integral_fintype hbint, integral_fintype htint] apply Finset.sum_congr rfl intro a _ simp only [Measure.real, smul_eq_mul] by_cases hb : (behavior s) {a} = 0 · have ht : (target s) {a} = 0 := hAC s hb simp [actionLikelihood, hb, ht] · have hb' : ((behavior s) {a}).toReal ≠ 0 := ENNReal.toReal_ne_zero.mpr ⟨hb, measure_ne_top _ _⟩ simp only [actionLikelihood, hb, if_false] field_simp
    Causalean.Mathlib.Probability.Kernel.FiniteHistory.integral_actionLikelihood · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Weighted.lean:44
  • weightedValue_measurable theorem — A Markov kernel, measurable append map, measurable weight with a uniform bound, and measurable terminal score with a uniform bound make the specified finite weighted value measurable.
    append :
    H → B → H
    happend :
    Measurable fun z : H × B => append z.1 z.2
    w :
    H → B → ℝ
    hw :
    Measurable fun z : H × B => w z.1 z.2
    Cw :
    ℝ
    hw_bound :
    ∀ h b, |w h b| ≤ Cw
    f :
    H → ℝ
    hf :
    Measurable f
    Cf :
    ℝ
    hf_bound :
    ∀ h, |f h| ≤ Cf
    n :
    ℕ
    Measurable (weightedValue K append w n f)
    Proof (Lean source)
    theorem weightedValue_measurable {H B : Type*} [MeasurableSpace H] [MeasurableSpace B] (K : Kernel H B) [IsMarkovKernel K] (append : H → B → H) (happend : Measurable fun z : H × B => append z.1 z.2) (w : H → B → ℝ) (hw : Measurable fun z : H × B => w z.1 z.2) (Cw : ℝ) (hw_bound : ∀ h b, |w h b| ≤ Cw) (f : H → ℝ) (hf : Measurable f) (Cf : ℝ) (hf_bound : ∀ h, |f h| ≤ Cf) (n : ℕ) : Measurable (weightedValue K append w n f) := by -- Induct on `n`; the bound gives integrability of each kernel section and -- Mathlib's measurable kernel integral handles the induction step. exact (weightedValue_measurable_bounded_aux K append happend w hw Cw hw_bound f hf Cf hf_bound n).1
    Causalean.Mathlib.Probability.Kernel.FiniteHistory.weightedValue_measurable · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Weighted.lean:130
  • weightedValue_bounded theorem — A Markov kernel, measurable append map, measurable weight with a uniform bound, and measurable terminal score with a uniform bound at horizon give a uniform bound for the specified finite weighted value.
    append :
    H → B → H
    happend :
    Measurable fun z : H × B => append z.1 z.2
    w :
    H → B → ℝ
    hw :
    Measurable fun z : H × B => w z.1 z.2
    Cw :
    ℝ
    hw_bound :
    ∀ h b, |w h b| ≤ Cw
    f :
    H → ℝ
    hf :
    Measurable f
    Cf :
    ℝ
    hf_bound :
    ∀ h, |f h| ≤ Cf
    n :
    ℕ
    ∃ C : ℝ, ∀ h, |weightedValue K append w n f h| ≤ C
    Proof (Lean source)
    theorem weightedValue_bounded {H B : Type*} [MeasurableSpace H] [MeasurableSpace B] (K : Kernel H B) [IsMarkovKernel K] (append : H → B → H) (happend : Measurable fun z : H × B => append z.1 z.2) (w : H → B → ℝ) (hw : Measurable fun z : H × B => w z.1 z.2) (Cw : ℝ) (hw_bound : ∀ h b, |w h b| ≤ Cw) (f : H → ℝ) (hf : Measurable f) (Cf : ℝ) (hf_bound : ∀ h, |f h| ≤ Cf) (n : ℕ) : ∃ C : ℝ, ∀ h, |weightedValue K append w n f h| ≤ C := by -- The bound `Cf * max 1 Cw ^ n` suffices; use the Markov integral bound. exact (weightedValue_measurable_bounded_aux K append happend w hw Cw hw_bound f hf Cf hf_bound n).2
    Causalean.Mathlib.Probability.Kernel.FiniteHistory.weightedValue_bounded · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Weighted.lean:145
  • integral_weighted_history theorem — A Markov kernel, measurable append map, measurable bounded weight, a probability history-law sequence satisfying its extension identity, measurable bounded path weights satisfying their initial and recursive identities, and a measurable bounded terminal score at the selected horizon identify the weighted terminal expectation.
    append :
    H → B → H
    happend :
    Measurable fun z : H × B => append z.1 z.2
    w :
    H → B → ℝ
    hw :
    Measurable fun z : H × B => w z.1 z.2
    Cw :
    ℝ
    hw_bound :
    ∀ h b, |w h b| ≤ Cw
    μ :
    ℕ → Measure H
    hμprob :
    ∀ n, IsProbabilityMeasure (μ n)
    hμ :
    ∀ n, μ (n + 1) = (μ n ⊗ₘ K).map (fun z => append z.1 z.2)
    weight :
    ℕ → H → ℝ
    hweight_meas :
    ∀ n, Measurable (weight n)
    hweight_bound :
    ∀ n, ∃ C : ℝ, ∀ h, |weight n h| ≤ C
    hweight0 :
    ∀ h, weight 0 h = 1
    hweight_step :
    ∀ n h b, weight (n + 1) (append h b) = weight n h * w h b
    f :
    H → ℝ
    hf :
    Measurable f
    Cf :
    ℝ
    hf_bound :
    ∀ h, |f h| ≤ Cf
    n :
    ℕ
    ∫ h, weight n h * f h ∂μ n = ∫ h, weightedValue K append w n f h ∂μ 0
    Proof (Lean source)
    theorem integral_weighted_history {H B : Type*} [MeasurableSpace H] [MeasurableSpace B] (K : Kernel H B) [IsMarkovKernel K] (append : H → B → H) (happend : Measurable fun z : H × B => append z.1 z.2) (w : H → B → ℝ) (hw : Measurable fun z : H × B => w z.1 z.2) (Cw : ℝ) (hw_bound : ∀ h b, |w h b| ≤ Cw) (μ : ℕ → Measure H) (hμprob : ∀ n, IsProbabilityMeasure (μ n)) (hμ : ∀ n, μ (n + 1) = (μ n ⊗ₘ K).map (fun z => append z.1 z.2)) (weight : ℕ → H → ℝ) (hweight_meas : ∀ n, Measurable (weight n)) (hweight_bound : ∀ n, ∃ C : ℝ, ∀ h, |weight n h| ≤ C) (hweight0 : ∀ h, weight 0 h = 1) (hweight_step : ∀ n h b, weight (n + 1) (append h b) = weight n h * w h b) (f : H → ℝ) (hf : Measurable f) (Cf : ℝ) (hf_bound : ∀ h, |f h| ≤ Cf) (n : ℕ) : ∫ h, weight n h * f h ∂μ n = ∫ h, weightedValue K append w n f h ∂μ 0 := by -- Prove the stronger induction statement starting at an arbitrary time `k`. -- At a successor use `integral_map` and `integral_compProd_bounded`, then -- `hweight_step`. The resulting operator is `T f := weightedValue ... 1 f`. -- Its powers satisfy `T ^ (n+1) f = T ^ n (T f)`; this semigroup fact needs -- a separate induction because `weightedValue` recurses on the left. have hmain : ∀ m k (g : H → ℝ), Measurable g → ∀ Cg : ℝ, (∀ h, |g h| ≤ Cg) → ∫ h, weight (k + m) h * g h ∂μ (k + m) = ∫ h, weight k h * weightedValue K append w m g h ∂μ k := by intro m induction m with | zero => intro k g hg Cg hg_bound simp only [Nat.add_zero, weightedValue] | succ m ih => intro k g hg Cg hg_bound obtain ⟨D, hD⟩ := weightedValue_bounded K append happend w hw Cw hw_bound g hg Cg hg_bound 1 have hgm := weightedValue_measurable K append happend w hw Cw hw_bound g hg Cg hg_bound 1 calc ∫ h, weight (k + (m + 1)) h * g h ∂μ (k + (m + 1)) = ∫ h, weight ((k + m) + 1) h * g h ∂μ ((k + m) + 1) := by rw [Nat.add_succ] _ = ∫ h, weight (k + m) h * weightedValue K append w 1 g h ∂μ (k + m) := integral_weighted_history_step K append happend w hw Cw hw_bound μ hμprob hμ weight hweight_meas hweight_bound hweight_step g hg Cg hg_bound (k + m) _ = ∫ h, weight k h * weightedValue K append w m (weightedValue K append w 1 g) h ∂μ k := ih k _ hgm D hD _ = ∫ h, weight k h * weightedValue K append w (m + 1) g h ∂μ k := by congr 1 funext h rw [weightedValue_succ_right] have hresult := hmain n 0 f hf Cf hf_bound simpa only [Nat.zero_add, hweight0, one_mul] using hresult
    Causalean.Mathlib.Probability.Kernel.FiniteHistory.integral_weighted_history · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Weighted.lean:224
  • weightedValue_eq_matrixValue theorem — A Markov kernel, append map, weight, state projection, target matrix, supplied weighted action-kernel identity, and reward identify the weighted value after the selected number of steps at the selected history with the matrix value.
    append :
    H → B → H
    w :
    H → B → ℝ
    state :
    H → S
    P :
    Matrix S S ℝ
    hweighted :
    ∀ (v : S → ℝ)
    then
    ∀ h, (∫ b, w h b * v (state (append h b)) ∂K h) = ∑ s, P (state h) s * v s
    reward :
    S → ℝ
    n :
    ℕ
    h :
    H
    weightedValue K append w n (reward ∘ state) h = matrixValue P n reward (state h)
    Proof (Lean source)
    theorem weightedValue_eq_matrixValue {H B S : Type*} [MeasurableSpace H] [MeasurableSpace B] [MeasurableSpace S] [Fintype S] [MeasurableSingletonClass S] (K : Kernel H B) [IsMarkovKernel K] (append : H → B → H) (w : H → B → ℝ) (state : H → S) (P : Matrix S S ℝ) (hweighted : ∀ (v : S → ℝ), Measurable v → ∀ h, (∫ b, w h b * v (state (append h b)) ∂K h) = ∑ s, P (state h) s * v s) (reward : S → ℝ) (n : ℕ) (h : H) : weightedValue K append w n (reward ∘ state) h = matrixValue P n reward (state h) := by -- Induct on `n`, rewrite the recursive value using the induction hypothesis, -- then apply `hweighted` to `matrixValue P n reward`. have hm : ∀ m : ℕ, Measurable (matrixValue P m reward) := by intro m exact measurable_of_finite _ induction n generalizing h with | zero => rfl | succ n ih => simp only [weightedValue, matrixValue] have heq : (fun b => w h b * weightedValue K append w n (reward ∘ state) (append h b)) = (fun b => w h b * matrixValue P n reward (state (append h b))) := by funext b rw [ih (append h b)] rw [heq] exact hweighted (matrixValue P n reward) (hm n) h
    Causalean.Mathlib.Probability.Kernel.FiniteHistory.weightedValue_eq_matrixValue · Causalean/Mathlib/Probability/Kernel/FiniteHistory/Weighted.lean:276