Mathlib.Probability.Kernel.Finite­Sequence

This module bundles dependent finite transcript histories, sequential-kernel laws, their prefix and next-step identities, and exact singleton factorization.

Basic 7 core · 1 supporting This module provides dependent finite histories, their product measurable spaces, and the basic operations that restrict, extend, or split a transcript.

Finite dependent transcript histories

This module provides dependent finite histories, their product measurable spaces, and the basic operations that restrict, extend, or split a transcript.

def History reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given an output family, a history length, and evidence that the length does not exceed the horizon, a dependent history records one output at each earlier stage. It is given by the dependent function space indexed by the first k stages.

Definition (Lean source)
n :
ℕ
Z :
Fin n → Type*
k :
ℕ
hk :
k ≤ n
History Z k hk :
Type _
(j : Fin k) → Z (castLE hk j)
Causalean.Mathlib.Probability.Kernel.FiniteSequence.History · Causalean/Mathlib/Probability/Kernel/FiniteSequence/Basic.lean:17
abbrev Transcript reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given an output family, a complete dependent transcript is given by a history spanning the whole horizon.

Definition (Lean source)
n :
ℕ
Z :
Fin n → Type*
Transcript Z :
Type u_1
History Z n le_rfl
Causalean.Mathlib.Probability.Kernel.FiniteSequence.Transcript · Causalean/Mathlib/Probability/Kernel/FiniteSequence/Basic.lean:34
def take reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given a prefix bound and a complete transcript, the requested prefix history is given by retaining exactly its first coordinates.

Definition (Lean source)
n k :
ℕ
Fin n → Type*
hk :
k ≤ n
u :
take hk u :
History Z k hk
fun j => u (castLE hk j)
Causalean.Mathlib.Probability.Kernel.FiniteSequence.take · Causalean/Mathlib/Probability/Kernel/FiniteSequence/Basic.lean:38 · uses History , Transcript
def nextIndex reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given evidence that stage k + 1 lies within the horizon, the next output index is the zero-based position k, which is the position of the (k + 1)-th output.

Definition (Lean source)
n k :
ℕ
hk :
k + 1 ≤ n
nextIndex hk :
Fin n
⟨k, Nat.lt_of_succ_le hk⟩
Causalean.Mathlib.Probability.Kernel.FiniteSequence.nextIndex · Causalean/Mathlib/Probability/Kernel/FiniteSequence/Basic.lean:44
def snoc reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given a valid successor bound, a preceding history, and its next output, the extended history is given by appending that output.

Definition (Lean source)
n k :
ℕ
Fin n → Type*
hk :
k + 1 ≤ n
u :
History Z k (le_of_succ_le hk)
z :
Z (nextIndex hk)
snoc hk u z :
History Z (k + 1) hk
snoc u z
Causalean.Mathlib.Probability.Kernel.FiniteSequence.snoc · Causalean/Mathlib/Probability/Kernel/FiniteSequence/Basic.lean:50 · uses History , nextIndex
def init reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given a valid successor bound and a nonempty history, its preceding history is given by removing the final coordinate.

Definition (Lean source)
n k :
ℕ
Fin n → Type*
hk :
k + 1 ≤ n
u :
History Z (k + 1) hk
init hk u :
History Z k (le_of_succ_le hk)
Fin.init u
Causalean.Mathlib.Probability.Kernel.FiniteSequence.init · Causalean/Mathlib/Probability/Kernel/FiniteSequence/Basic.lean:57 · uses History
def last reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given a valid successor bound and a nonempty history, its final output is given by its last coordinate.

Definition (Lean source)
n k :
ℕ
Fin n → Type*
hk :
k + 1 ≤ n
u :
History Z (k + 1) hk
last hk u :
Z (nextIndex hk)
u (last k)
Causalean.Mathlib.Probability.Kernel.FiniteSequence.last · Causalean/Mathlib/Probability/Kernel/FiniteSequence/Basic.lean:63 · uses History , nextIndex
1 supporting declaration (lemmas, instances)
  • historyMeasurableSpace instance — Given measurable output spaces, a history length, and evidence that it lies within the output horizon, the measurable structure on the dependent history is given by the product σ-algebra of its coordinates.
    n :
    ℕ
    Fin n → Type*
    mZ :
    ∀ i, MeasurableSpace (Z i)
    k :
    ℕ
    hk :
    k ≤ n
    historyMeasurableSpace k hk :
    MeasurableSpace (History Z k hk)
    by unfold History letI : ∀ j : Fin k, MeasurableSpace (Z (castLE hk j)) := fun j
    => mZ _ infer_instance
    Causalean.Mathlib.Probability.Kernel.FiniteSequence.historyMeasurableSpace · Causalean/Mathlib/Probability/Kernel/FiniteSequence/Basic.lean:24
Construction 3 core · 2 supporting This module recursively constructs laws of dependent finite output histories from kernels that may depend on the current input and all preceding private outputs. ★ isProbabilityMeasure_prefixLaw

Construction of finite sequential laws

This module recursively constructs laws of dependent finite output histories from kernels that may depend on the current input and all preceding private outputs.

abbrev KernelFamily reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given an input space and an output family, a sequential kernel family is given by one kernel at each stage from the current input and preceding private history to the current output.

Definition (Lean source)
n :
ℕ
shared
X :
Z :
Fin n → Type*
∀ i, MeasurableSpace (Z i)
KernelFamily X Z :
Type (max u_4 u_4 u_3)
(i : Fin n) → Kernel (X × History Z i.val (le_of_lt i.isLt)) (Z i)
Causalean.Mathlib.Probability.Kernel.FiniteSequence.KernelFamily · Causalean/Mathlib/Probability/Kernel/FiniteSequence/Construction.lean:21
def prefixLaw reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given a sequential kernel family, a fixed input vector, a prefix length, and evidence that the prefix lies within the horizon, the law of the first outputs is given by iterated composition from the unique empty history.

Definition (Lean source)
n :
ℕ
shared
X :
Type u_1
shared
Z :
Fin n → Type u_2
shared
Q :
x :
Fin n → X
k :
ℕ
hk :
k ≤ n
prefixLaw Q x k hk :
Measure (History Z k hk)
Nat.rec (motive := fun j => (hj : j ≤ n) → Measure (History Z j hj)) (fun _ => Measure.dirac (fun j : Fin 0 => j.elim0)) (fun j prev hj => let hprev : j ≤ n := Nat.le_of_succ_le hj let idx : Fin n := nextIndex hj let K : Kernel (History Z j hprev) (Z idx) := (Q idx).comap (fun u => (x idx, u)) (by fun_prop) (prev hprev ⊗ₘ K).map (fun p => snoc hj p.1 p.2)) k hk
theorem isProbabilityMeasure_prefixLaw reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given a sequential kernel family, the condition that every stage kernel is Markov, a fixed input vector, a prefix length, and evidence that the prefix lies within the horizon, the prefix law has total mass one.

Formal statement
n :
ℕ
shared
X :
Type u_1
shared
Z :
Fin n → Type u_2
shared
Q :
hQ :
∀ i, IsMarkovKernel (Q i)
x :
Fin n → X
k :
ℕ
hk :
k ≤ n
Proof (Lean source)
theorem isProbabilityMeasure_prefixLaw (Q : KernelFamily X Z) (hQ : ∀ i, IsMarkovKernel (Q i)) (x : Fin n → X) (k : ℕ) (hk : k ≤ n) : IsProbabilityMeasure (prefixLaw Q x k hk) := by induction k with | zero => change IsProbabilityMeasure (Measure.dirac (fun j : Fin 0 => j.elim0)) exact ⟨by simp⟩ | succ j ih => let hprev : j ≤ n := Nat.le_of_succ_le hk let idx : Fin n := nextIndex hk let K : Kernel (History Z j hprev) (Z idx) := (Q idx).comap (fun u => (x idx, u)) (by fun_prop) haveI : IsProbabilityMeasure (prefixLaw Q x j hprev) := ih hprev haveI : IsMarkovKernel (Q idx) := hQ idx haveI : IsMarkovKernel K := Kernel.IsMarkovKernel.comap _ (by fun_prop) haveI : IsProbabilityMeasure (prefixLaw Q x j hprev ⊗ₘ K) := ⟨by simp⟩ change IsProbabilityMeasure ((prefixLaw Q x j hprev ⊗ₘ K).map (fun p => snoc hk p.1 p.2)) exact Measure.isProbabilityMeasure_map (measurable_snoc hk).aemeasurable
Causalean.Mathlib.Probability.Kernel.FiniteSequence.isProbabilityMeasure_prefixLaw · Causalean/Mathlib/Probability/Kernel/FiniteSequence/Construction.lean:80 · uses History , KernelFamily , historyMeasurableSpace , prefixLaw
2 supporting declarations (lemmas, instances)
Restriction 2 core · 3 supporting This module provides measurable maps which forget later coordinates of dependent finite histories and records their basic compatibility with transcript prefixes. ★ restrictHistory_succ

Restriction maps for finite dependent histories

This module provides measurable maps which forget later coordinates of dependent finite histories and records their basic compatibility with transcript prefixes.

def restrictHistory reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given a target prefix bound, a source prefix bound, an ordering of the two lengths, and a source history, the restricted history is given by retaining its first coordinates.

Definition (Lean source)
n :
ℕ
Fin n → Type u_1
shared
k l :
ℕ
hk :
k ≤ n
hl :
l ≤ n
hkl :
k ≤ l
u :
History Z l hl
restrictHistory hk hl hkl u :
History Z k hk
fun i => u (castLE hkl i)
Causalean.Mathlib.Probability.Kernel.FiniteSequence.restrictHistory · Causalean/Mathlib/Probability/Kernel/FiniteSequence/Restriction.lean:18 · uses History
theorem restrictHistory_succ reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given a target prefix bound, a successor source bound, an ordering of the target and preceding source lengths, and a successor history, restricting it factors through removal of the final coordinate.

Formal statement
n :
ℕ
Fin n → Type u_1
shared
k l :
ℕ
hk :
k ≤ n
hs :
l + 1 ≤ n
hkl :
k ≤ l
u :
History Z (l + 1) hs
restrictHistory hk hs (le_trans hkl (le_succ l)) u
= restrictHistory hk (le_of_succ_le hs) hkl (init hs u)
Proof (Lean source)
theorem restrictHistory_succ {k l : ℕ} (hk : k ≤ n) (hs : l + 1 ≤ n) (hkl : k ≤ l) (u : History Z (l + 1) hs) : restrictHistory hk hs (le_trans hkl (le_succ l)) u = restrictHistory hk (le_of_succ_le hs) hkl (init hs u) := by funext i rfl
Causalean.Mathlib.Probability.Kernel.FiniteSequence.restrictHistory_succ · Causalean/Mathlib/Probability/Kernel/FiniteSequence/Restriction.lean:40 · uses History , init , restrictHistory
3 supporting declarations (lemmas, instances)
Law 2 core · 6 supporting This module identifies every finite prefix marginal and every prefix-plus-next-output law of the recursively constructed transcript measure. ★ transcriptLaw_map_take_next

Prefix and next-step identities for finite sequential laws

This module identifies every finite prefix marginal and every prefix-plus-next-output law of the recursively constructed transcript measure.

abbrev transcriptLaw reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given a sequential kernel family and a fixed input vector, the complete dependent transcript law is given by the final prefix law.

Definition (Lean source)
n :
ℕ
shared
X :
Type u_1
shared
Z :
Fin n → Type u_2
shared
Q :
x :
Fin n → X
transcriptLaw Q x :
Causalean.Mathlib.Probability.Kernel.FiniteSequence.transcriptLaw · Causalean/Mathlib/Probability/Kernel/FiniteSequence/Law.lean:80 · uses KernelFamily , Transcript , historyMeasurableSpace
theorem transcriptLaw_map_take_next reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given a sequential kernel family, the condition that every stage kernel is Markov, a fixed input vector, a prefix length, and a successor bound, under the complete transcript law, the joint law of the prefix of that length and the next output is the composition-product of the prefix law with the next-stage kernel evaluated at the next input coordinate.

Formal statement
n :
ℕ
shared
X :
Type u_1
shared
Z :
Fin n → Type u_2
shared
Q :
hQ :
∀ i, IsMarkovKernel (Q i)
x :
Fin n → X
k :
ℕ
hk :
k + 1 ≤ n
(transcriptLaw Q x).map (fun t => (take (le_of_succ_le hk) t, t (nextIndex hk)))
= (prefixLaw Q x k (le_of_succ_le hk)) ⊗ₘ (Q (nextIndex hk)).comap (fun u => (x (nextIndex hk), u)) (by fun_prop)
Proof (Lean source)
theorem transcriptLaw_map_take_next (Q : KernelFamily X Z) (hQ : ∀ i, IsMarkovKernel (Q i)) (x : Fin n → X) (k : ℕ) (hk : k + 1 ≤ n) : (transcriptLaw Q x).map (fun t => (take (le_of_succ_le hk) t, t (nextIndex hk))) = (prefixLaw Q x k (le_of_succ_le hk)) ⊗ₘ (Q (nextIndex hk)).comap (fun u => (x (nextIndex hk), u)) (by fun_prop) := by have hmeas : Measurable (take hk : Transcript Z → History Z (k + 1) hk) := by have hfun : (take hk : Transcript Z → History Z (k + 1) hk) = restrictHistory hk le_rfl hk := by funext u exact (restrictHistory_transcript hk u).symm rw [hfun] exact measurable_restrictHistory hk le_rfl hk have hfun : (fun t : Transcript Z => (take (le_of_succ_le hk) t, t (nextIndex hk))) = (fun u : History Z (k + 1) hk => (init hk u, last hk u)) ∘ take hk := by funext t apply Prod.ext · funext i rfl · rfl rw [hfun, ← Measure.map_map (measurable_init_last hk) hmeas, transcriptLaw_map_prefix Q hQ x (k + 1) hk, prefixLaw_succ_map_init_last Q x k hk]
6 supporting declarations (lemmas, instances)
Factorization 1 core · 2 supporting This module evaluates atoms of dependent finite transcript laws as products of their stagewise conditional singleton probabilities. ★ transcriptLaw_singleton

Exact cylinder probabilities for finite sequential kernels

This module evaluates atoms of dependent finite transcript laws as products of their stagewise conditional singleton probabilities.

theorem transcriptLaw_singleton reviewed
Causalean.Mathlib.Probability.Kernel.FiniteSequence

Given a sequential kernel family, the condition that every stage kernel is Markov, a fixed input vector, and a complete transcript, the transcript atom probability is the finite product of its stagewise conditional singleton probabilities.

Formal statement
n :
ℕ
shared
X :
Type u_1
shared
Z :
Fin n → Type u_2
shared
Q :
hQ :
∀ i, IsMarkovKernel (Q i)
x :
Fin n → X
t :
transcriptLaw Q x {t} = ∏ i : Fin n, (Q i) (x i, take (le_of_lt i.isLt) t) {t i}
Proof (Lean source)
theorem transcriptLaw_singleton (Q : KernelFamily X Z) (hQ : ∀ i, IsMarkovKernel (Q i)) (x : Fin n → X) (t : Transcript Z) : transcriptLaw Q x {t} = ∏ i : Fin n, (Q i) (x i, take (le_of_lt i.isLt) t) {t i} := by have h (k : ℕ) (hk : k ≤ n) : prefixLaw Q x k hk {take hk t} = ∏ i : Fin k, (Q (castLE hk i)) (x (castLE hk i), take (le_of_lt (castLE hk i).isLt) t) {t (castLE hk i)} := by induction k with | zero => have he : ({take hk t} : Set (History Z 0 hk)) = univ := by ext v have hv : v = take hk t := by funext i; exact i.elim0 simp [hv] change (Measure.dirac (fun j : Fin 0 => j.elim0)) ({take hk t} : Set ((j : Fin 0) → Z (castLE hk j))) = _ have hm := congrArg (fun s : Set (History Z 0 hk) => (Measure.dirac (fun j : Fin 0 => j.elim0)) s) he change (Measure.dirac (fun j : Fin 0 => j.elim0)) ({take hk t} : Set ((j : Fin 0) → Z (castLE hk j))) = 1 haveI : IsProbabilityMeasure (prefixLaw Q x 0 hk) := isProbabilityMeasure_prefixLaw Q hQ x 0 hk exact hm.trans (by change (prefixLaw Q x 0 hk) univ = 1; exact measure_univ) | succ j ih => let hj : j ≤ n := Nat.le_of_succ_le hk have ht : take hk t = snoc hk (take hj t) (t (nextIndex hk)) := by funext i refine Fin.lastCases ?_ (fun a => ?_) i · simp [take, snoc, nextIndex, snoc, castLE] · simp [take, snoc, nextIndex, snoc, castLE] rw [ht, prefixLaw_succ_singleton Q hQ x j hk] rw [ih hj, Fin.prod_univ_castSucc] rfl have ht : take le_rfl t = t := by funext i; rfl simpa only [transcriptLaw, ht, Fin.castLE_refl] using h n le_rfl
2 supporting declarations (lemmas, instances)