Question about rank-nullity theorem

Let $T:X\to Y$ be an $\mathbb{R}$-linear map of $\mathbb{R}$-vector spaces $X$ and $Y$ of finite dimension. Let $W\subseteq Y$ be an $\mathbb{R}$-vector subspace such that $\text{Im} \ T$ and $W$ together span $Y$. Let $Z=T^{-1}(W)$. Show that $\text{dim} \ X+\text{dim} \ W=\text{dim} \ Y+\text{dim} \ Z$.

My approach : Clearly $\text{dim} \ X=\text{rank}\ T+\text{nullity}\ T$. Again since $\text{Im} \ T$ and $W$ together span $Y$, we have $\text{rank}\ T+\text{dim}\ W=\text{dim}\ Y$. Adding these two relations we have $\text{dim} \ X+\text{dim} \ W=\text{nullity}\ T+\text{dim}\ Y$. But I have problem to show that $\text{nullity}\ T=\text{dim}\ Z$. Can anyone help me regarding this issue? Thanks in advance.

Solutions Collecting From Web of "Question about rank-nullity theorem"

I’m going to write $r_X(T)$ for rank as a map from $X$ and $n_X(T)$ for its nullity.

  1. We have
    $$ r_X(T) + n_X(T) = \dim{X}, \qquad r_Z(T) + n_Z(T) = \dim{Z} $$
    by the rank-nullity theorem.

  2. Now, look at $T$ acting on $Z$. $T(Z) = T(X) \cap W$, so $r_Z(T)=\dim{(T(X) \cap W)}$.

  3. Inclusion-exclusion on an appropriate basis gives
    $$\dim{Y} = r_X(T) + \dim{W} – \dim{(T(X) \cap W)}.$$

  4. Lastly, $\{0\} \in W$, so $Z$ must include $\ker{T}$, so

Subtracting the two equations from 1. and using 4. gives
$$ r_X(T) – r_Z(T) = \dim{X}-\dim{Z}, $$
while substituting into the one in 3. from 2. gives
$$ \dim{Y} = r_X(T)-r_Z(T) + \dim{W}. $$
The result follows.