Solution (source code)

= Solution

For a <linear map> $\theta:U\to V$, its <rank of a linear map> is $r(\theta)=\dim\operatorname{im}\theta$, and its <nullity> is $n(\theta)=\dim\ker\theta$. Choose a <basis> $e_1,\ldots,e_s$ of its <kernel> and extend it to a <basis> $e_1,\ldots,e_d$ of $U$. Then $\theta e_{s+1},\ldots,\theta e_d$ span its image. They are linearly independent: a linear combination mapped to zero would belong to the <kernel>, contradicting independence of the extended <basis> unless all its coefficients vanish. Hence $r(\theta)=d-s$, proving
$$
\boxed{r(\theta)+n(\theta)=\dim U.}
$$
For <endomorphisms> of $U$, define $(\theta+\phi)(u)=\theta(u)+\phi(u)$ and $(\theta\phi)(u)=\theta(\phi(u))$. The image of the sum lies in the sum of the two images. Thus
$$
r(\theta+\phi)\le\dim(\operatorname{im}\theta+\operatorname{im}\phi)
\le r(\theta)+r(\phi).
$$
To prove the product inequality, restrict $\phi$ to $K=\ker(\theta\phi)$. This map has <kernel> $\ker\phi$ and image $\operatorname{im}\phi\cap\ker\theta$: every vector in the intersection has a preimage in $K$. Applying the <rank-nullity theorem> to the restricted map gives
$$
n(\theta\phi)=n(\phi)+\dim(\operatorname{im}\phi\cap\ker\theta)
\le n(\phi)+n(\theta).
$$
Now put $d=\dim U$ and $s=r(\theta)+r(\phi)$. If both equalities hold, $r(\theta+\phi)=s\le d$, while $n(\theta\phi)=2d-s\le d$ forces $s\ge d$. Therefore $s=d$, the sum has full <rank>, and the product has <nullity> $d$. The sum is an <isomorphism> and the product is zero.

Conversely, if $\theta\phi=0$, then $\operatorname{im}\phi\subseteq\ker\theta$, giving $s\le d$. If the sum is also an <isomorphism>, its <rank> is $d\le s$. Thus $s=d$, and the two inequalities become equalities. This proves the <equality in the rank-sum and nullity-product inequalities> in both directions.