The code-distribution correspondence starts from the Kraft inequality. For codeword lengths put
Conversely, a probability mass function determines ideal lengths , up to integer rounding. For the source law ,
using nonnegativity of Kullback-Leibler divergence and .