Documentation

CslibFrontier.Probability.MutualInformation.KLBridge

Conditional Mutual Information, KL Divergence in Bits, and TVD Bridges #

General discrete information-theoretic and statistical-distance lemmas for finite probability mass functions (PMF), bridging Cslib.Probability.MutualInformation, Cslib.Probability.Entropy, and total variation distance (dist):

Main definitions #

Main results #

Conditional laws and KL divergence in bits #

noncomputable def Cslib.Probability.MutualInformation.condLaw {Ω : Type u_1} {α : Type u_2} {γ : Type u_4} (ν : PMF Ω) (C : Ω → γ) (A : Ω → α) (c : γ) :
PMF α

The conditional distribution of observable A given C = c under ν : PMF Ω, defaulting to the marginal of A when (ν.map C) c = 0.

noncomputable def Cslib.Probability.MutualInformation.klDivBits {α : Type u_2} (p q : PMF α) :

Kullback–Leibler divergence in bits (log₂) for probability mass functions, defined via Mathlib's InformationTheory.klDiv divided by Real.log 2. Equals ⊤ whenever p.support is not contained in q.support.

def Cslib.Probability.MutualInformation.CondIndep {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [Finite γ] [Finite α] [Finite β] (ν : PMF Ω) (A : Ω → α) (B : Ω → β) (C : Ω → γ) :

Conditional independence A ⊥ B | C under ν : PMF Ω, expressed as vanishing conditional mutual information I(A; B | C) = 0.

theorem Cslib.Probability.MutualInformation.condIndep_iff {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [Finite γ] [Finite α] [Finite β] (ν : PMF Ω) (A : Ω → α) (B : Ω → β) (C : Ω → γ) :
CondIndep ν A B C ↔ PMF.condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) ν) = 0

Conditional independence A ⊥ B | C holds iff I(A; B | C) = 0.

klDivBits p q is finite iff p.support ⊆ q.support.

klDivBits p q = ⊤ when p.support is not contained in q.support.

The KL divergence in bits of a PMF from itself is zero.

theorem Cslib.Probability.MutualInformation.toReal_klDivBits_eq_sum {α : Type u_2} [Fintype α] {p q : PMF α} (h : p.support ⊆ q.support) :
(klDivBits p q).toReal = ∑ a : α, (p a).toReal * Real.logb 2 ((p a).toReal / (q a).toReal)

Finite-sum formula for (klDivBits p q).toReal in bits (Real.logb 2).

Unconditional ℝ≥0∞-valued Pinsker inequality in bits: ENNReal.ofReal (2 * dist p q ^ 2) ≤ klDivBits p q.

theorem Cslib.Probability.MutualInformation.pinsker_bits {α : Type u_2} [Fintype α] {p q : PMF α} (h : p.support ⊆ q.support) :
dist p q ≤ √((klDivBits p q).toReal / 2)

Pinsker's inequality in bits: dist p q ≤ √((klDivBits p q).toReal / 2).

Conditional law helpers #

theorem Cslib.Probability.MutualInformation.condLaw_eq_conditionalSnd {Ω : Type u_1} {α : Type u_2} {γ : Type u_4} (ν : PMF Ω) (C : Ω → γ) (A : Ω → α) (c : γ) :
condLaw ν C A c = PMF.conditionalSnd (PMF.map (fun (ω : Ω) => (C ω, A ω)) ν) c

Unfolding of condLaw in terms of conditionalSnd.

theorem Cslib.Probability.MutualInformation.condLaw_apply {Ω : Type u_1} {α : Type u_2} {γ : Type u_4} (ν : PMF Ω) (C : Ω → γ) (A : Ω → α) {c : γ} (hc : c ∈ (PMF.map C ν).support) (a : α) :
(condLaw ν C A c) a = (PMF.map (fun (ω : Ω) => (C ω, A ω)) ν) (c, a) / (PMF.map C ν) c

On a supported conditioning value c, condLaw ν C A c a is the normalized joint mass.

theorem Cslib.Probability.MutualInformation.marginal_mul_condLaw {Ω : Type u_1} {α : Type u_2} {γ : Type u_4} (ν : PMF Ω) (C : Ω → γ) (A : Ω → α) (c : γ) (a : α) :
(PMF.map C ν) c * (condLaw ν C A c) a = (PMF.map (fun (ω : Ω) => (C ω, A ω)) ν) (c, a)

Multiplying the marginal of C by condLaw ν C A recovers the joint mass of (C, A).

theorem Cslib.Probability.MutualInformation.support_condLaw_subset {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} (ν : PMF Ω) (C : Ω → γ) (B : Ω → β) (A : Ω → α) {c : γ} {b : β} (hcb : (c, b) ∈ (PMF.map (fun (ω : Ω) => (C ω, B ω)) ν).support) :
(condLaw ν (fun (ω : Ω) => (C ω, B ω)) A (c, b)).support ⊆ (condLaw ν C A c).support

Conditioning on an additional observable (C, B) can only shrink the support of condLaw.

theorem Cslib.Probability.MutualInformation.condLaw_eq_map_conditionalSnd {Ω : Type u_1} {α : Type u_2} {γ : Type u_4} (ν : PMF Ω) (C : Ω → γ) (A : Ω → α) {c : γ} (hc : c ∈ (PMF.map C ν).support) :
condLaw ν C A c = PMF.map A (PMF.conditionalSnd (PMF.map (fun (ω : Ω) => (C ω, ω)) ν) c)

On a supported conditioning value c, condLaw ν C A c is the pushforward of the posterior distribution on Ω.

theorem Cslib.Probability.MutualInformation.condLaw_bind_pair {α : Type u_2} {γ : Type u_4} (p : PMF γ) (K : γ → PMF α) {c : γ} (hc : c ∈ p.support) :
condLaw (p.bind fun (x : γ) => PMF.map (fun (x_1 : α) => (x, x_1)) (K x)) Prod.fst Prod.snd c = K c

Conditioning a pairing bind on a supported first coordinate recovers its kernel.

Entropy, Mutual Information, and KL Divergence Identities #

theorem Cslib.Probability.MutualInformation.condMutualInfo_le_entropy_snd_obs {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [Finite γ] [Finite α] [Finite β] (ν : PMF Ω) (A : Ω → α) (B : Ω → β) (C : Ω → γ) :
PMF.condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) ν) ≤ PMF.entropy (PMF.map B ν)

Conditional mutual information is bounded above by the entropy of the second variable.

theorem Cslib.Probability.MutualInformation.condMutualInfo_le_of_condIndep_left {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} {δ : Type u_5} [Finite γ] [Finite α] [Finite β] [Finite δ] (ν : PMF Ω) (A : Ω → α) (B : Ω → β) (C : Ω → γ) (D : Ω → δ) (hind : CondIndep ν A D C) :
PMF.condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) ν) ≤ PMF.condMutualInfo (PMF.map (fun (ω : Ω) => ((C ω, D ω), A ω, B ω)) ν)

Conditioning on a conditionally independent variable D (A ⊥ D | C) cannot decrease mutual information: I(A; B | C) ≤ I(A; B | C, D).

theorem Cslib.Probability.MutualInformation.condMutualInfo_le_of_condIndep_right {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} {δ : Type u_5} [Finite γ] [Finite α] [Finite β] [Finite δ] (ν : PMF Ω) (A : Ω → α) (B : Ω → β) (C : Ω → γ) (D : Ω → δ) (hind : CondIndep ν A D fun (ω : Ω) => (C ω, B ω)) :
PMF.condMutualInfo (PMF.map (fun (ω : Ω) => ((C ω, D ω), A ω, B ω)) ν) ≤ PMF.condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) ν)

Conditioning on a variable D independent given (B, C) cannot increase mutual information: I(A; B | C, D) ≤ I(A; B | C).

theorem Cslib.Probability.MutualInformation.condIndep_of_condLaw_eq {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [Finite γ] [Finite α] [Finite β] (ν : PMF Ω) (A : Ω → α) (B : Ω → β) (C : Ω → γ) (h : ∀ (c : γ) (b : β), (c, b) ∈ (PMF.map (fun (ω : Ω) => (C ω, B ω)) ν).support → condLaw ν (fun (ω : Ω) => (C ω, B ω)) A (c, b) = condLaw ν C A c) :
CondIndep ν A B C

Conditional independence from conditional-law invariance: if condLaw ν (C, B) A (c, b) equals condLaw ν C A c on every supported (c, b), then A ⊥ B | C.

theorem Cslib.Probability.MutualInformation.condMutualInfo_map_indep_cond {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} {δ : Type u_5} [Finite γ] [Finite δ] [Finite α] [Finite β] (ν : PMF Ω) (C : Ω → γ) (D : Ω → δ) (A : Ω → α) (B : Ω → β) (hind : PMF.map (fun (ω : Ω) => ((C ω, A ω, B ω), D ω)) ν = (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) ν).bind fun (x : γ × α × β) => PMF.map (fun (x_1 : δ) => (x, x_1)) (PMF.map D ν)) :
PMF.condMutualInfo (PMF.map (fun (ω : Ω) => ((C ω, D ω), A ω, B ω)) ν) = PMF.condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) ν)

Conditioning on an independent variable does not change conditional mutual information.

theorem Cslib.Probability.MutualInformation.condMutualInfo_eq_sum_condMutualInfo {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} {δ : Type u_5} [Fintype δ] [Finite γ] [Finite α] [Finite β] (ν : PMF Ω) (D : Ω → δ) (C : Ω → γ) (A : Ω → α) (B : Ω → β) :
PMF.condMutualInfo (PMF.map (fun (ω : Ω) => ((D ω, C ω), A ω, B ω)) ν) = ∑ d : δ, ((PMF.map D ν) d).toReal * PMF.condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) (PMF.conditionalSnd (PMF.map (fun (ω : Ω) => (D ω, ω)) ν) d))

Conditional mutual information splits over an additional conditioning variable D: I(A; B | (C, D)) = ∑ d, Pr[D = d] · I(A; B | C, D = d).

theorem Cslib.Probability.MutualInformation.condMutualInfo_eq_expected_klDivBits {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [Fintype γ] [Fintype β] [Finite α] (ν : PMF Ω) (C : Ω → γ) (A : Ω → α) (B : Ω → β) :
PMF.condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) ν) = ∑ cb : γ × β, ((PMF.map (fun (ω : Ω) => (C ω, B ω)) ν) cb).toReal * (klDivBits (condLaw ν (fun (ω : Ω) => (C ω, B ω)) A cb) (condLaw ν C A cb.1)).toReal

Conditional mutual information equals expected conditional KL divergence in bits: I(A; B | C) = E_{(C, B)} [ D_2(dist(A | C, B) ‖ dist(A | C)) ].

theorem Cslib.Probability.MutualInformation.expected_tvd_le_sqrt_condMutualInfo {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [Fintype γ] [Fintype β] [Fintype α] (ν : PMF Ω) (C : Ω → γ) (B : Ω → β) (A : Ω → α) :
∑ cb : γ × β, ((PMF.map (fun (ω : Ω) => (C ω, B ω)) ν) cb).toReal * dist (condLaw ν (fun (ω : Ω) => (C ω, B ω)) A cb) (condLaw ν C A cb.1) ≤ √(PMF.condMutualInfo (PMF.map (fun (ω : Ω) => (C ω, A ω, B ω)) ν) / 2)

Jensen + Pinsker + KL-MI Bridge: the expected statistical distance between dist(A | C, B) and dist(A | C) is at most √(I(A; B | C) / 2).

Total Variation Distance Inequalities and Chain Rules #

Two-step weak chain rule for total variation distance on pairs (X, Y): ‖P - Q‖_tvd ≤ ‖P_X - Q_X‖_tvd + E_{x ~ P_X} ‖P_{Y|X=x} - Q_{Y|X=x}‖_tvd.

def Cslib.Probability.MutualInformation.tuplePrefix {n : ℕ} {X : Fin n → Type u_6} (i : Fin n) (x : (j : Fin n) → X j) (j : Fin ↑i) :
X (Fin.castLE ⋯ j)

Prefix projection of an n-tuple up to index i : Fin n.

theorem Cslib.Probability.MutualInformation.tvd_chain_rule {n : ℕ} {X : Fin n → Type u_6} [(i : Fin n) → Fintype (X i)] (μ ν : PMF ((i : Fin n) → X i)) :
dist μ ν ≤ ∑ i : Fin n, ∑ p : (j : Fin ↑i) → X (Fin.castLE ⋯ j), ((PMF.map (tuplePrefix i) μ) p).toReal * dist (condLaw μ (tuplePrefix i) (fun (x : (i : Fin n) → X i) => x i) p) (condLaw ν (tuplePrefix i) (fun (x : (i : Fin n) → X i) => x i) p)

Chain rule for total variation distance on finite n-tuples.

If two joint distributions share the same first marginal, the statistical distance between their second marginals is at most the expected conditional statistical distance.

theorem Cslib.Probability.MutualInformation.dist_bind_middle_eq {α : Type u_2} {β : Type u_3} {γ : Type u_4} [Fintype α] [Fintype β] [Fintype γ] (seed : PMF α) (mid₁ mid₂ : α → PMF β) (tail : α → β → PMF γ) :
dist (seed.bind fun (a : α) => (mid₁ a).bind fun (b : β) => PMF.map (fun (c : γ) => (a, b, c)) (tail a b)) (seed.bind fun (a : α) => (mid₂ a).bind fun (b : β) => PMF.map (fun (c : γ) => (a, b, c)) (tail a b)) = ∑ a : α, (seed a).toReal * dist (mid₁ a) (mid₂ a)

Distance of two staged distributions sharing the same first stage seed and same final kernel tail reduces to the expected distance of the middle stage.

General Symmetry Information Bounds #

def Cslib.Probability.MutualInformation.maskedPrefix {α : Type u_2} {m : ℕ} (x : Fin m → α) (k : Fin m) :
Fin m → Option α

Option-masked prefix of a tuple x : Fin m → α strictly before index k : Fin m.

theorem Cslib.Probability.MutualInformation.sum_condMutualInfo_maskedPrefix {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [Finite γ] [Finite α] [Finite β] {m : ℕ} (ν : PMF Ω) (W : Ω → γ) (X : Ω → Fin m → α) (B : Ω → β) :
∑ k : Fin m, PMF.condMutualInfo (PMF.map (fun (ω : Ω) => ((W ω, maskedPrefix (X ω) k), X ω k, B ω)) ν) = PMF.condMutualInfo (PMF.map (fun (ω : Ω) => (W ω, X ω, B ω)) ν)

Chain rule for conditional mutual information over a finite tuple X : Fin m → α: ∑ k : Fin m, I(X_k; B | (W, X_{< k})) = I(X; B | W).

theorem Cslib.Probability.MutualInformation.condMutualInfo_uniform_prefix_le {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [Finite γ] [Finite α] [Finite β] {m : ℕ} (ν : PMF Ω) (W : Ω → γ) (M : Ω → Fin (m + 1) → α) (B : Ω → β) (K : Ω → Fin (m + 1)) (hK : PMF.IndepUniform ν (fun (ω : Ω) => (W ω, M ω, B ω)) K) :
PMF.condMutualInfo (PMF.map (fun (ω : Ω) => ((K ω, W ω, maskedPrefix (M ω) (K ω)), M ω (K ω), B ω)) ν) ≤ PMF.entropy (PMF.map B ν) / (↑m + 1)

Prefix-Chain-Rule Symmetry Bound: if K : Ω → Fin (m + 1) is uniform and independent of (M, B, W) under ν, then I(M_K; B | K, W, M_{< K}) ≤ H(B) / (m + 1).

theorem Cslib.Probability.MutualInformation.condMutualInfo_uniform_indep_copies_le {Ω : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [Finite γ] [Finite α] [Finite β] {m : ℕ} (ν : PMF Ω) (W : Ω → γ) (X : Ω → Fin (m + 1) → α) (M : Ω → β) (K : Ω → Fin (m + 1)) (hK : PMF.IndepUniform ν (fun (ω : Ω) => (W ω, X ω, M ω)) K) (hind : ∀ (k : Fin (m + 1)), CondIndep ν (fun (ω : Ω) => X ω k) (fun (ω : Ω) => maskedPrefix (X ω) k) W) :
PMF.condMutualInfo (PMF.map (fun (ω : Ω) => ((K ω, W ω), M ω, X ω (K ω))) ν) ≤ PMF.entropy (PMF.map M ν) / (↑m + 1)

Independent-Copies Symmetry Bound: if K : Ω → Fin (m + 1) is uniform and independent of (X, M, W) under ν, and each coordinate X_k is conditionally independent of X_{< k} given W, then I(M; X_K | K, W) ≤ H(M) / (m + 1).