Documentation

MerLeanBpqc.Definitions.Def_17_BinaryEntropyFunction

Definition 17: Binary Entropy Function #

The binary entropy function H₂ : ℝ → ℝ defined by H₂(δ) = -δ log₂(δ) - (1 - δ) log₂(1 - δ).

Main Results #

Binary Entropy Function #

def binaryEntropy (δ : ) :

The binary entropy function H₂ : ℝ → ℝ defined by H₂(δ) = -δ log₂(δ) - (1 - δ) log₂(1 - δ). For δ ∈ (0, 1), this gives the Shannon entropy of a Bernoulli(δ) distribution measured in bits. Outside (0, 1), the function extends by continuity (with log₂(0) = 0 in Mathlib's convention).

Equations
Instances For

    Key numerical inequality: H₂(11/100) < 1/2 #

    The proof strategy converts the entropy inequality to a product inequality via exponentiation, then verifies the resulting natural number inequality.

    theorem key_nat_ineq :
    100 ^ 100 < 2 ^ 50 * 11 ^ 11 * 89 ^ 89

    The key Nat inequality: 100^100 < 2^50 * 11^11 * 89^89. This is the exponential form of H₂(11/100) < 1/2.

    theorem key_frac_ineq :
    (100 / 11) ^ 11 * (100 / 89) ^ 89 < 2 ^ 50

    (100/11)^11 * (100/89)^89 < 2^50 in ℝ.

    H₂(11/100) < 1/2: the binary entropy function at 11/100 is less than 1/2. The proof converts to the product form using logb, then applies key_frac_ineq.

    Derivative and monotonicity of binary entropy #

    binaryEntropy equals Mathlib's binEntropy divided by log 2.

    theorem hasDerivAt_binaryEntropy {x : } (hx0 : 0 < x) (hx1 : x < 1) :

    H₂ is strictly increasing on (0, 1/2): for 0 < a < b < 1/2, H₂(a) < H₂(b). This follows from H₂'(x) = logb 2 ((1-x)/x) > 0 for x < 1/2.

    theorem binaryEntropy_lt_half {δ : } (hδ0 : 0 < δ) (hδ1 : δ < 11 / 100) :
    binaryEntropy δ < 1 / 2

    H₂(δ) < 1/2 for δ ∈ (0, 11/100). Since H₂ is strictly increasing on (0, 1/2) and 11/100 < 1/2, we have H₂(δ) < H₂(11/100) < 1/2 for δ < 11/100.

    Hamming Ball #

    def hammingBall (n : ) (r : ) :

    The Hamming ball of radius r centered at the origin in 𝔽₂^n: B₀(r) = {v ∈ 𝔽₂^n : wt(v) ≤ r}, where wt is the Hamming weight. This is defined as a Finset of vectors. When r < 0, the ball is empty.

    Equations
    Instances For
      theorem mem_hammingBall {n : } {r : } {v : Fin n𝔽₂} :

      Membership in the Hamming ball: v ∈ B₀(r) iff wt(v) ≤ r.

      theorem hammingBall_empty_of_neg {n : } {r : } (hr : r < 0) :

      The Hamming ball is empty when r < 0.

      theorem hammingBall_nonempty {n : } {r : } (hr : 0 r) :

      The Hamming ball is non-empty when r ≥ 0: the zero vector has weight 0.

      Hamming Ball Bound helpers #

      theorem bernoulli_weight_mono {n : } {δ : } (hδ0 : 0 < δ) (hδ1 : δ 1 / 2) {a k : } (hak : a k) (hkn : k n) :
      δ ^ k * (1 - δ) ^ (n - k) δ ^ a * (1 - δ) ^ (n - a)

      Helper: for 0 < δ ≤ 1/2 and a ≤ k ≤ n, we have δ^a · (1-δ)^(n-a) ≥ δ^k · (1-δ)^(n-k). This is because δ ≤ 1-δ, so replacing a by k (moving weight from 1-δ to δ exponent) decreases the product.

      theorem bernoulli_weight_sum {n : } {δ : } (hδ0 : 0 < δ) (hδ1 : δ 1 / 2) :
      v : Fin n𝔽₂, δ ^ hammingWeight v * (1 - δ) ^ (n - hammingWeight v) = 1

      The total Bernoulli weight over all vectors equals 1: ∑_{v : Fin n → 𝔽₂} δ^(wt v) · (1-δ)^(n - wt v) = 1. This is a consequence of the binomial theorem (δ + (1-δ))^n = 1^n = 1.

      Hamming Ball Bound #

      theorem entropy_logb_ineq {n : } {δ : } (hδ0 : 0 < δ) (hδ1 : δ 1 / 2) {k : } (hkn : k n) (hk : k + 1 δ * n) :
      -(k * Real.logb 2 δ + ↑(n - k) * Real.logb 2 (1 - δ)) binaryEntropy δ * n

      The Hamming ball bound: for positive n and δ ∈ (0, 1/2], the number of binary vectors of length n with Hamming weight at most k satisfies |B₀(k)| ≤ 2^{H₂(δ) · n} whenever k + 1 ≤ δ · n. The proof shows |B₀(k)| · δ^k · (1-δ)^{n-k} ≤ 1 by summing Bernoulli weights, then converts to the entropy form.

      theorem hammingBallBound {n : } (hn : 0 < n) {δ : } (hδ0 : 0 < δ) (hδ1 : δ 1 / 2) {k : } (hk : k + 1 δ * n) :
      (hammingBall n k).card 2 ^ (binaryEntropy δ * n)