For simplicity we prove the statement using the natural logarithm (ln), since
the particular logarithm we choose only scales the relationship.
Let denote the set of all for which pi is non-zero. Then, since for all x > 0, with equality if and only if x=1, we have:
The last inequality is a consequence of the pi and qi being part of a probability distribution. Therefore, the sum of all values is unity. Specifically, the sum of all non-zero values is also unity, however, some non-zero qi may be excluded since the choice of indices is conditioned upon the pi. Therefore the sum of the qi may be less than unity.
We now have:
Since the pi and qi are probabilities, their logarithms are negative. The negation of the first sum is thus positive, and the un-negated second sum is negative. We may therefore add the negation of the second sum to both sides (a positive number) without changing the inequality to get:
Since the logarithm of zero is negative infinity, restoring the indices for values of pi that are zero requires some care. We notice that:
The quotient of zeros is an indeterminate form. Typically it is defined to be the convergent of asymptotic values in its neigborhood, or, if such a convergent does not exist, a convention convenient to the case at hand is adopted. In this context, the usual convention is to take the indeterminate form to be identically zero. This gives us:
The right hand side does not grow by our convention, and the left hand side does not grow either because zero times anything is zero, or by convention when qi is also zero.
For equality to hold, we require:
for all so that the approximation is exact.
so that equality continues to hold between the third and fourth lines of the proof.