Theorem 5 (Chain rule for entropy) For discrete random variables \(X\) and \(Y\),
\[H(X, Y) = H(X) + H(Y \mid X).\]
Proof. Use the notation of Definition 8 and Definition 9, with every sum over the pairs with \(p(x, y) > 0\). Since \(p(x, y) = p(x) \, p(y \mid x)\),
\[
\begin{aligned}
H(X, Y)
&= -\sum_{x, y} p(x, y) \log p(x, y) \\
&= -\sum_{x, y} p(x, y) \log \mathopen{}\left[p(x) \, p(y \mid x)\right]\mathclose{} \\
&= -\sum_{x, y} p(x, y) \log p(x)
- \sum_{x, y} p(x, y) \log p(y \mid x) \\
&= -\sum_{x} \log p(x) \sum_{y} p(x, y)
- \sum_{x} p(x) \sum_{y} p(y \mid x) \log p(y \mid x) \\
&= -\sum_{x} p(x) \log p(x)
+ \sum_{x} p(x) \, H(Y \mid X=x) \\
&= H(X) + H(Y \mid X).
\end{aligned}
\]
The fourth line groups the terms by \(x\) and uses \(p(x, y) = p(x) \, p(y \mid x)\) in the second sum; the fifth uses \(\sum_{y} p(x, y) = p(x)\) and the definition of \(H(Y \mid X=x)\).