Documentation

CslibFrontier.Probability.Product.Split

Splitting the coordinates of a finite product #

Split the coordinates of an independent product by a predicate P, along Mathlib's Equiv.piEquivPiSubtypeProd. The coordinates satisfying P and the remaining coordinates form two independent products. In particular, the restriction of an independent product to some of its coordinates, or its composition with an injection of index types, is again an independent product. An independent product over a sum of index types splits the same way into its two summands. Conditioning a uniform tuple on the value of one coordinate splits that coordinate off: it becomes constant, and the other coordinates stay uniform.

Main results #

theorem Cslib.Probability.PMF.pi_map_piEquivPiSubtypeProd {ι : Type u_1} [Fintype ι] {α : ι → Type u_2} [∀ (i : ι), Finite (α i)] (P : ι → Prop) [DecidablePred P] (p : (i : ι) → PMF (α i)) :
PMF.map (⇑(Equiv.piEquivPiSubtypeProd P α)) (pi p) = (pi fun (i : { i : ι // P i }) => p ↑i).bind fun (a : (i : { i : ι // P i }) → α ↑i) => PMF.map (fun (x : (i : { i : ι // ¬P i }) → α ↑i) => (a, x)) (pi fun (i : { i : ι // ¬P i }) => p ↑i)

Splitting the coordinates of an independent product by a predicate P gives two independent products: one over the coordinates satisfying P, one over the rest.

theorem Cslib.Probability.PMF.pi_map_restrict {ι : Type u_1} [Fintype ι] {α : ι → Type u_2} [∀ (i : ι), Finite (α i)] (P : ι → Prop) [DecidablePred P] (p : (i : ι) → PMF (α i)) :
PMF.map (fun (a : (i : ι) → α i) (i : { i : ι // P i }) => a ↑i) (pi p) = pi fun (i : { i : ι // P i }) => p ↑i

Restricting an independent product to the coordinates satisfying P gives the independent product of those coordinates.

theorem Cslib.Probability.PMF.pi_map_comp_subtypeEquiv {ι : Type u_1} [Fintype ι] {α : ι → Type u_2} [∀ (i : ι), Finite (α i)] {κ : Type u_3} [Fintype κ] (P : ι → Prop) (p : (i : ι) → PMF (α i)) (e : κ ≃ { i : ι // P i }) :
PMF.map (fun (a : (i : ι) → α i) (k : κ) => a ↑(e k)) (pi p) = pi fun (k : κ) => p ↑(e k)

Reading an independent product along an equivalence e onto the coordinates satisfying P gives the independent product of the factors along e.

theorem Cslib.Probability.PMF.pi_map_comp_injective {ι : Type u_1} [Fintype ι] {α : ι → Type u_2} [∀ (i : ι), Finite (α i)] {κ : Type u_3} [Fintype κ] (p : (i : ι) → PMF (α i)) {e : κ → ι} (he : Function.Injective e) :
PMF.map (fun (a : (i : ι) → α i) (k : κ) => a (e k)) (pi p) = pi fun (k : κ) => p (e k)

Reading an independent product along an injection e of index types gives the independent product of the factors along e: the coordinates a (e k) are independent with laws p (e k).

theorem Cslib.Probability.PMF.pi_map_sumPiEquivProdPi {ι : Type u_3} {κ : Type u_4} [Fintype ι] [Fintype κ] {β : ι ⊕ κ → Type u_5} [∀ (i : ι ⊕ κ), Finite (β i)] (p : (i : ι ⊕ κ) → PMF (β i)) :
PMF.map (⇑(Equiv.sumPiEquivProdPi β)) (pi p) = (pi fun (i : ι) => p (Sum.inl i)).bind fun (a : (i : ι) → β (Sum.inl i)) => PMF.map (fun (x : (i : κ) → β (Sum.inr i)) => (a, x)) (pi fun (j : κ) => p (Sum.inr j))

An independent product over ι ⊕ κ splits, along Mathlib's Equiv.sumPiEquivProdPi, into independent products over ι and over κ.

theorem Cslib.Probability.PMF.bind_pi_sum {ι : Type u_3} {κ : Type u_4} [Fintype ι] [Fintype κ] {β : ι ⊕ κ → Type u_5} [∀ (i : ι ⊕ κ), Finite (β i)] {γ : Type u_6} (p : (i : ι ⊕ κ) → PMF (β i)) (F : ((i : ι) → β (Sum.inl i)) → ((j : κ) → β (Sum.inr j)) → PMF γ) :
((pi p).bind fun (f : (i : ι ⊕ κ) → β i) => F (fun (i : ι) => f (Sum.inl i)) fun (j : κ) => f (Sum.inr j)) = (pi fun (i : ι) => p (Sum.inl i)).bind fun (a : (i : ι) → β (Sum.inl i)) => (pi fun (j : κ) => p (Sum.inr j)).bind fun (b : (i : κ) → β (Sum.inr i)) => F a b

An experiment reading the two halves of an independent product over ι ⊕ κ samples each half independently.

theorem Cslib.Probability.PMF.filter_uniformOfFintype_eval_eq {ι : Type u_1} [Fintype ι] [DecidableEq ι] {γ : Type u_3} [Fintype γ] [Nonempty γ] (j : ι) (c : γ) (h : ∃ d ∈ {d : ι → γ | d j = c}, d ∈ (uniformOfFintype (ι → γ)).support) :
(uniformOfFintype (ι → γ)).filter {d : ι → γ | d j = c} h = PMF.map (fun (x : ι → γ) => Function.update x j c) (uniformOfFintype (ι → γ))

Conditioning a uniform tuple on the value c of its coordinate j sets that coordinate to c and keeps the other coordinates uniform.

theorem Cslib.Probability.PMF.uniformOfFintype_map_comp_dep {S : Type u_3} {Q : Type u_4} [Fintype S] [DecidableEq S] [Fintype Q] [DecidableEq Q] {R : Q → Type u_5} [(q : Q) → Fintype (R q)] [∀ (q : Q), Nonempty (R q)] {g : S → Q} (hg : Function.Injective g) :
PMF.map (fun (f : (q : Q) → R q) (s : S) => f (g s)) (uniformOfFintype ((q : Q) → R q)) = uniformOfFintype ((s : S) → R (g s))

A uniform dependent function read through an injection g of index types is uniform.