Documentation

ShannonInfo.FiniteInfoTheory

Finite-discrete Shannon information theory — scaffolding toward Cheng's Theorem 4 #

The information-theoretic core of Cheng, R. (2026) Theorem 4, re-checked in ShannonInfo/ChengCCC.lean. That file machine-checks the misidentification / forgetting lower bounds modulo two named hypotheses — the data-processing inequality (I(T;θ) ≤ C_ctx) and Fano's inequality (P_e ≥ (H(T|θ) − 1)/log(K−1)). Mathlib has no finite-discrete entropy and mutual-information layer (only Real.negMulLog, the binary-entropy function, and topological entropy). It does hold the Kullback–Leibler divergence klDiv with its data-processing inequality for pushforward measures, klDiv_map_le, in Mathlib/InformationTheory/KullbackLeibler/DataProcessing.lean. Discharging the two hypotheses in the discrete form used here builds a small finite-discrete information-theory library, and this file builds it bottom-up.

Status (honest) #

Done here (all sorry-free):

Not done here: the tight Fano constant Real.binEntropy Pe (≤ log 2) in place of log 2; the looser log 2 is all fano'/ChengCCC consume. The tight bound H(X | Y) ≤ h₂(Pe) + Pe log₂ (|α| - 1) is proved in the cslib-frontier library as Cslib.Probability.PMF.conditionalEntropy_le_binEntropy_add_mul_logb, for a deterministic estimator over a joint PMF. ChengCCC's abstract arithmetic skeletons (misid_lower_bound, forgetting_lower_bound) still take Fano/DPI/hCond as explicit hypotheses, but the wiring IS done: cheng_misid_bound_discharged and cheng_forgetting_bound_discharged discharge all three against these theorems for the Markov chain T → c → θ, leaving only the modelling setup (and, for forgetting, Cheng's informal Step-4 link hConn). No sorry is used; missing results are simply absent.

noncomputable def FiniteInfoTheory.entropy {α : Type u_1} [Fintype α] (p : α → ℝ) :

Shannon entropy of a pmf p : α → ℝ in natural-log units: H(p) = ∑ a, negMulLog (p a), where negMulLog x = -x * log x. (Mathlib has Real.negMulLog and its analytic API, but not the random-variable entropy/mutual-information layer this builds toward.)

Equations
Instances For
    theorem FiniteInfoTheory.entropy_nonneg {α : Type u_1} [Fintype α] {p : α → ℝ} (h0 : ∀ (a : α), 0 ≤ p a) (h1 : ∀ (a : α), p a ≤ 1) :

    Entropy is nonnegative for any pmf valued in [0,1] (each summand negMulLog (p a) ≥ 0).

    Mutual information of a joint pmf, and its nonnegativity (finite Gibbs) #

    A joint distribution of two finite random variables is a function μ : α → β → ℝ with μ ≥ 0 and ∑_{a,b} μ(a,b) = 1. Its marginals are μ₁(a) = ∑_b μ(a,b) and μ₂(b) = ∑_a μ(a,b), and the mutual information is the Kullback–Leibler divergence of μ from the product μ₁ ⊗ μ₂.

    noncomputable def FiniteInfoTheory.marg₁ {α : Type u_1} {β : Type u_2} [Fintype β] (μ : α → β → ℝ) (a : α) :

    First marginal μ₁(a) = ∑_b μ(a,b) of a joint pmf μ : α → β → ℝ.

    Equations
    Instances For
      noncomputable def FiniteInfoTheory.marg₂ {α : Type u_1} [Fintype α] {β : Type u_2} (μ : α → β → ℝ) (b : β) :

      Second marginal μ₂(b) = ∑_a μ(a,b) of a joint pmf μ : α → β → ℝ.

      Equations
      Instances For
        noncomputable def FiniteInfoTheory.mutualInfo {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] (μ : α → β → ℝ) :

        Shannon mutual information of a joint pmf μ, in nats: I(μ) = ∑_{a,b} μ(a,b) · log( μ(a,b) / (μ₁(a)·μ₂(b)) ) — the KL divergence D(μ ‖ μ₁ ⊗ μ₂).

        Equations
        Instances For
          theorem FiniteInfoTheory.gibbs_term {x r : ℝ} (hx : 0 ≤ x) (hr : 0 ≤ r) (hxr : 0 < x → 0 < r) :
          x - r ≤ x * Real.log (x / r)

          Per-term Gibbs bound x − r ≤ x · log(x / r), valid for x ≥ 0, r ≥ 0, with the proviso that r > 0 whenever x > 0 (so log is applied to a positive argument where it matters). This is the single analytic fact behind nonnegativity of KL divergence / mutual information.

          theorem FiniteInfoTheory.mutualInfo_nonneg {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] (μ : α → β → ℝ) (hnn : ∀ (a : α) (b : β), 0 ≤ μ a b) (hsum : ∑ a : α, ∑ b : β, μ a b = 1) :

          Mutual information is nonnegative. For any joint pmf μ (nonnegative, summing to 1), I(μ) ≥ 0. Proof: the finite Gibbs/log-sum inequality bounds each summand below by μ(a,b) − μ₁(a)·μ₂(b), whose total is 1 − 1 = 0. This is the discharged nonnegativity half of the data-processing inequality interface required by ChengCCC.

          Entropy form of mutual information (the hCond identity) #

          I(X;Y) = H(X) + H(Y) − H(X,Y) = H(X) − H(X|Y). This discharges the hCond hypothesis of ChengCCC.misid_lower_bound (condEnt = H(T) − I(T;θ), with X = T, Y = θ). The proof splits log(μ/(μ₁μ₂)) = log μ − log μ₁ − log μ₂ on the support and collapses each marginal sum; the only hypothesis is nonnegativity μ ≥ 0 (the identity needs no ∑ μ = 1).

          noncomputable def FiniteInfoTheory.Hjoint {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] (μ : α → β → ℝ) :

          Joint entropy H(X,Y) = ∑_{a,b} negMulLog (μ a b).

          Equations
          Instances For
            noncomputable def FiniteInfoTheory.condEntropy {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] (μ : α → β → ℝ) :

            Conditional entropy H(X | Y) = H(X,Y) − H(Y) (here Y is the second coordinate).

            Equations
            Instances For
              theorem FiniteInfoTheory.mutualInfo_eq_entropy {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] (μ : α → β → ℝ) (hnn : ∀ (a : α) (b : β), 0 ≤ μ a b) :

              Mutual information as a difference of entropies. I(μ) = H(X) + H(Y) − H(X,Y). Needs only nonnegativity of μ (no normalization).

              theorem FiniteInfoTheory.mutualInfo_eq_sub_condEntropy {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] (μ : α → β → ℝ) (hnn : ∀ (a : α) (b : β), 0 ≤ μ a b) :

              Mutual information as entropy minus conditional entropy: I(X;Y) = H(X) − H(X|Y). This is exactly the hCond identity (condEnt = H(T) − I(T;θ) rearranged).

              Conditional mutual information and the data-processing inequality #

              For three finite variables (X,Y,Z) with joint pmf ν : α → β → γ → ℝ, the conditional mutual information I(X;Z | Y) is nonnegative, and vanishes under the Markov condition X → Y → Z (conditional independence of X and Z given Y). These are the ingredients of the data-processing inequality I(X;Z) ≤ I(X;Y) (attempted below). The proofs reuse gibbs_term.

              noncomputable def FiniteInfoTheory.margXY {α : Type u_1} {β : Type u_2} {γ : Type u_3} [Fintype γ] (ν : α → β → γ → ℝ) (a : α) (b : β) :

              p(x,y) = ∑_z ν(x,y,z).

              Equations
              Instances For
                noncomputable def FiniteInfoTheory.margYZ {α : Type u_1} [Fintype α] {β : Type u_2} {γ : Type u_3} (ν : α → β → γ → ℝ) (b : β) (c : γ) :

                p(y,z) = ∑_x ν(x,y,z).

                Equations
                Instances For
                  noncomputable def FiniteInfoTheory.margY {α : Type u_1} [Fintype α] {β : Type u_2} {γ : Type u_3} [Fintype γ] (ν : α → β → γ → ℝ) (b : β) :

                  p(y) = ∑_{x,z} ν(x,y,z).

                  Equations
                  Instances For
                    noncomputable def FiniteInfoTheory.margX {α : Type u_1} {β : Type u_2} [Fintype β] {γ : Type u_3} [Fintype γ] (ν : α → β → γ → ℝ) (a : α) :

                    p(x) = ∑_{y,z} ν(x,y,z).

                    Equations
                    Instances For
                      noncomputable def FiniteInfoTheory.margXZ {α : Type u_1} {β : Type u_2} [Fintype β] {γ : Type u_3} (ν : α → β → γ → ℝ) (a : α) (c : γ) :

                      p(x,z) = ∑_y ν(x,y,z).

                      Equations
                      Instances For
                        noncomputable def FiniteInfoTheory.margZ {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] {γ : Type u_3} (ν : α → β → γ → ℝ) (c : γ) :

                        p(z) = ∑_{x,y} ν(x,y,z).

                        Equations
                        Instances For
                          noncomputable def FiniteInfoTheory.condMutualInfo {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] {γ : Type u_3} [Fintype γ] (ν : α → β → γ → ℝ) :

                          Conditional mutual information I(X;Z | Y) = ∑_{x,y,z} ν·log( ν·p(y) / (p(x,y)·p(y,z)) ).

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            theorem FiniteInfoTheory.condMutualInfo_nonneg {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] {γ : Type u_3} [Fintype γ] (ν : α → β → γ → ℝ) (hnn : ∀ (a : α) (b : β) (c : γ), 0 ≤ ν a b c) (hsum : ∑ a : α, ∑ b : β, ∑ c : γ, ν a b c = 1) :

                            Conditional mutual information is nonnegative, I(X;Z|Y) ≥ 0. Per Y-slice this is a KL divergence; the finite Gibbs bound makes each summand ≥ ν − p(x,y)p(y,z)/p(y), summing to 0.

                            def FiniteInfoTheory.MarkovCI {α : Type u_1} [Fintype α] {β : Type u_2} {γ : Type u_3} [Fintype γ] (ν : α → β → γ → ℝ) :

                            Markov condition X → Y → Z, stated as conditional independence of X and Z given Y: ν(x,y,z)·p(y) = p(x,y)·p(y,z). (Well-posed at p(y)=0: both sides vanish there.)

                            Equations
                            Instances For
                              theorem FiniteInfoTheory.markov_condMutualInfo_zero {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] {γ : Type u_3} [Fintype γ] (ν : α → β → γ → ℝ) (hnn : ∀ (a : α) (b : β) (c : γ), 0 ≤ ν a b c) (hM : MarkovCI ν) :

                              Markov ⟹ I(X;Z|Y) = 0. Under the conditional-independence condition every summand's log-argument is 1, so the conditional mutual information vanishes.

                              theorem FiniteInfoTheory.mi_add_condMutualInfo {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] {γ : Type u_3} [Fintype γ] (ν : α → β → γ → ℝ) (hnn : ∀ (a : α) (b : β) (c : γ), 0 ≤ ν a b c) :
                              mutualInfo (margXY ν) + condMutualInfo ν = ∑ a : α, ∑ b : β, ∑ c : γ, ν a b c * Real.log (ν a b c / (margX ν a * margYZ ν b c))

                              Chain rule, one half: I(X;Y) + I(X;Z|Y) = ∑_{x,y,z} ν·log( ν / (p(x)·p(y,z)) ) = I(X;(Y,Z)). The per-term log identity log(p(x,y)/(p(x)p(y))) + log(ν p(y)/(p(x,y)p(y,z))) = log(ν/(p(x)p(y,z))) holds on the support (and trivially at the zeros). No Markov assumption.

                              noncomputable def FiniteInfoTheory.condMutualInfoZ {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] {γ : Type u_3} [Fintype γ] (ν : α → β → γ → ℝ) :

                              Conditional mutual information I(X;Y | Z) (conditioning on the third variable).

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                theorem FiniteInfoTheory.condMutualInfoZ_nonneg {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] {γ : Type u_3} [Fintype γ] (ν : α → β → γ → ℝ) (hnn : ∀ (a : α) (b : β) (c : γ), 0 ≤ ν a b c) (hsum : ∑ a : α, ∑ b : β, ∑ c : γ, ν a b c = 1) :

                                I(X;Y|Z) ≥ 0 (same finite-Gibbs proof as condMutualInfo_nonneg, conditioning on Z).

                                theorem FiniteInfoTheory.mi_add_condMutualInfoZ {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] {γ : Type u_3} [Fintype γ] (ν : α → β → γ → ℝ) (hnn : ∀ (a : α) (b : β) (c : γ), 0 ≤ ν a b c) :
                                mutualInfo (margXZ ν) + condMutualInfoZ ν = ∑ a : α, ∑ b : β, ∑ c : γ, ν a b c * Real.log (ν a b c / (margX ν a * margYZ ν b c))

                                Chain rule, other half: I(X;Z) + I(X;Y|Z) = ∑_{x,y,z} ν·log( ν / (p(x)·p(y,z)) ), the same I(X;(Y,Z)) as mi_add_condMutualInfo. No Markov assumption.

                                theorem FiniteInfoTheory.data_processing {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] {γ : Type u_3} [Fintype γ] (ν : α → β → γ → ℝ) (hnn : ∀ (a : α) (b : β) (c : γ), 0 ≤ ν a b c) (hsum : ∑ a : α, ∑ b : β, ∑ c : γ, ν a b c = 1) (hM : MarkovCI ν) :

                                Data-processing inequality. For a Markov chain X → Y → Z (conditional independence MarkovCI), I(X;Z) ≤ I(X;Y). Proof: the two chain-rule halves give I(X;Y) + I(X;Z|Y) = I(X;(Y,Z)) = I(X;Z) + I(X;Y|Z); Markov makes I(X;Z|Y) = 0 and I(X;Y|Z) ≥ 0. This discharges hDPI of ChengCCC.misid_lower_bound at the Markov chain T → c → θ (with C_ctx ≥ I(c;θ)).

                                theorem FiniteInfoTheory.data_processing' {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] {γ : Type u_3} [Fintype γ] (ν : α → β → γ → ℝ) (hnn : ∀ (a : α) (b : β) (c : γ), 0 ≤ ν a b c) (hsum : ∑ a : α, ∑ b : β, ∑ c : γ, ν a b c = 1) (hM : MarkovCI ν) :

                                The other DPI direction I(X;Z) ≤ I(Y;Z) under the same Markov chain X → Y → Z. Obtained from data_processing by reindexing the (symmetric) chain as Z → Y → X (ν' z y x = ν x y z) and transporting through mutualInfo_comm. This is the form ChengCCC needs: with the capacity bound I(Y;Z) ≤ C_ctx it gives I(X;Z) ≤ C_ctx (here X = T, Y = c, Z = θ).

                                Fano's inequality #

                                Setup: a finite source X : α with Fintype.card α = K, side information Y : β, joint pmf μ : α → β → ℝ (≥ 0, summing to 1), a decoder g : β → α, and error probability Pe = ∑_{a,b} (if a = g b then 0 else μ a b) (the joint mass off the decoder's guess). Fano bounds the conditional entropy H(X|Y) = condEntropy μ by log 2 + Pe·log(K−1), hence (rearranged) (condEntropy μ − 1)/log(K−1) ≤ Pe — exactly ChengCCC's hFano.

                                theorem FiniteInfoTheory.condEntropy_le_log2 {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] [DecidableEq α] (μ : α → β → ℝ) (g : β → α) (hnn : ∀ (a : α) (b : β), 0 ≤ μ a b) (hsum : ∑ a : α, ∑ b : β, μ a b = 1) (hK : 1 ≤ Fintype.card α) :
                                condEntropy μ ≤ Real.log 2 + (∑ a : α, ∑ b : β, if a = g b then 0 else μ a b) * Real.log (↑(Fintype.card α) - 1)

                                Fano core (in nats): H(X|Y) ≤ log 2 + Pe·log(K−1). Decompose condEntropy μ = ∑_b D_b with D_b = ∑_a negMulLog(μ a b) − negMulLog(p_Y b); split off the decoded symbol g b, bound the remaining K−1 masses by entropy_masses_le and the binary split by negMulLog_add_le. The looser log 2 (vs. the tight binEntropy Pe) avoids Jensen and is all fano'/ChengCCC needs.

                                theorem FiniteInfoTheory.fano' {α : Type u_1} [Fintype α] {β : Type u_2} [Fintype β] [DecidableEq α] (μ : α → β → ℝ) (g : β → α) (hnn : ∀ (a : α) (b : β), 0 ≤ μ a b) (hsum : ∑ a : α, ∑ b : β, μ a b = 1) (hK : 3 ≤ Fintype.card α) :
                                (condEntropy μ - 1) / Real.log (↑(Fintype.card α) - 1) ≤ ∑ a : α, ∑ b : β, if a = g b then 0 else μ a b

                                Fano's inequality (rearranged), the form ChengCCC.misid_lower_bound consumes as hFano. For K = Fintype.card α ≥ 3, (condEntropy μ − 1) / log(K−1) ≤ Pe, with Pe the error probability of the decoder g. Follows from condEntropy_le_log2 and log 2 ≤ 1.