Confusion about Kraft-McMillan inequality for infinite alphabet

25 Views Asked by At

I was wondering if the Kraft-McMillan inequality continues to hold for codes with infinite alphabets. The reason I'm confused about this is because I was thinking about a code from $\{0,1\}^*$ to $\{0,1\}^*$ (all strings consisting of 0's and 1's of all possible lengths), which simply maps each string to itself. This is obviously a uniquely decodable code. However, it satisfies \begin{equation} \sum\limits_{x \in \{0,1\}^*} 2^{-\ell(x)} = \sum\limits_{k=1}^{\infty} 2^k 2^{-k} = \infty, \end{equation} since there are $2^k$ codewords of length $k$. So the Kraft-McMillan inequality does not hold. Is there an additional condition that needs to be satisfied in order for the inequality to hold for infinite alphabets? Thanks in advance for your response!