Assume that we would like to encode a set of symbol S={s1,s2,...,sn}S = \{ s_1, s_2, ..., s_n \} into binary strings T={t1,t2,...,tn:ti is a 0, 1 sequence of finite length}T = \{ t_1, t_2, ..., t_n : t_i \text{ is a 0, 1 sequence of finite length} \}, such that ∀i≠j\forall i \neq j, tit_i is not a prefix of tjt_j. Denote the length of tit_i as nin_i. Then the Kraft Inequality states that

∑i=1n2−ni≤1 \sum_{i = 1}^n 2^{-n_i} \le 1

For convenience, we write ti≪tjt_i \ll t_j if tit_i is a prefix of tjt_j. Intuitively, we can view a particular sequence ti=ti1ti2...tinit_i = t_i^1t_i^2 ...t_i^{n_i} as the abbreviation of number 0.ti1ti2...tini0.t_i^1t_i^2 ...t_i^{n_i}. The fact that for j≠ij \neq i, neither ti≪tjt_i \ll t_j nor tj≪tit_j \ll t_i implies that tjt_j does not lies in the interval [0.ti1ti2...tini,0.ti1ti2...tini+2−ni)[0.t_i^1t_i^2 ...t_i^{n_i}, 0.t_i^1t_i^2 ...t_i^{n_i} + 2^{-n_i}). As the intervals induced by tit_i's are mutually exclusive, we can easily conclude that

∑i=1n2−ni≤1 \sum_{i = 1}^n 2^{-n_i} \le 1

Indeed, the statement of Kraft Inequality can be made stronger such that the inequality holds as long as {t1,t2,...,tn}\{ t_1, t_2, ..., t_n \} are uniquely decodable. To verify this, note that for any sequence τ∈T∗\tau \in T^* with length kk, there are at most only 2k2^k possible combinations. Therefore,

(∑i=1n2−ni)l=∑k=1l⋅nmaxCk2−k (\sum_{i = 1}^n 2^{-n_i})^l = \sum_{k = 1}^{l \cdot n_{max}} C_k 2^{-k}

where nmax=max⁡{n1,n2,...,}n_{max} = \max\{n_1, n_2, ..., \} and Ck≤2kC_k \le 2^k. Hence

(∑i=1n2−ni)l≤l⋅nmax→∑i=1n2−ni≤l1/l⋅nmax1/l (\sum_{i = 1}^n 2^{-n_i})^l \le l \cdot n_{max} \rightarrow \sum_{i = 1}^n 2^{-n_i} \le l^{1/l} \cdot n_{max}^{1/l}

Taking ll to infty we get the desired result.

An immediately implication is that Entropy is the lower bound of the encode length of a document. To see this, denote the probability of sis_i as pip_i. Then

∑ipilog⁡1pi−∑ipini=∑ipilog⁡1pi⋅12ni≤log⁡∑ipi1pi⋅12ni≤log⁡∑i12ni≤0 \begin{aligned} \sum_{i} p_i \log \frac{1}{p_i} - \sum_{i} p_i n_i &= \sum_{i} p_i \log \frac{1}{p_i} \cdot \frac{1}{2^{n_i} } \\ &\le \log \sum_{i} p_i \frac{1}{p_i} \cdot \frac{1}{2^{n_i} } \\ &\le \log \sum_{i} \frac{1}{2^{n_i} } \\ &\le 0 \end{aligned}