binaryEntropy
defimported Lean
The binary entropy function \[ H(x) \;=\; -x\log_2 x - (1-x)\log_2(1-x), \] using the base-$2$ logarithm, with the convention $0\log_2 0 = 0$ inherited from $\log_2 0 = 0$.
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in open scoped BigOperators in set_option maxHeartbeats 800000 in noncomputable def binaryEntropy (x : ℝ) : ℝ
- Defined in
- TCSlib, `binaryEntropy`
- Lean proof
- By Frederick Dehmel, Hydroxyi (from the file's git history), from github.com/Shilun-Allan-Li/tcslib at
c8a02591b1e5(Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.25.0.binaryEntropy← binaryEntropy (TCSlib/ErrorCorrectingCodes/MRRW.lean:72): verbatim
- Verified
- 07 Oct 2026
- Axioms
- none listed
- Used by 4
- bpe_deviation_probGiven parameters (p : ℝ), hypothesis (hp : 0 < p ∧ p < 1), (k N : ℕ), and (c ε : ℝ), bpe_deviation_prob p hp k N c ε is the real number…
- binaryEntropy_le_iffThe binary entropy function is strictly increasing on [0, 1/2], so for any x, y in [0, 1/2], binaryEntropy x ≤ binaryEntropy y if and only…
- bpe_deviation_prob_nonnegFor any source bias p ∈ (0, 1), step count k, input length N, target constant c, and tolerance ε, the deviation probability…
- dephased_path_entropyFor n : ℕ, q : Fin n → ℝ, and S : Finset (Fin n), dephased_path_entropy n q S is defined as (S.card : ℝ) - (free.card : ℝ) plus the sum…
Lean source view module on GitHub
set_option autoImplicit true in set_option relaxedAutoImplicit true in open scoped BigOperators in set_option maxHeartbeats 800000 in /-- **Definition 3 (binary entropy)** from the source file. `binaryEntropy x = -x · log₂(x) - (1-x) · log₂(1-x)`, with the convention `0 · log₂ 0 = 0` (which holds automatically since `Real.logb 2 0 = 0` in Mathlib). Note: this uses base-2 logarithm (`Real.logb 2`), unlike Mathlib's `Real.binEntropy` which uses natural logarithm. -/ noncomputable def binaryEntropy (x : ℝ) : ℝ := -x * Real.logb 2 x - (1 - x) * Real.logb 2 (1 - x)