Primary decomposition problem Let $T$ be a linear operator on a finite dimensional space $V$, and let $p=p_{1}^{r_{1}} \cdots p_{k}^{r_{k}} $ be the minimal polynomial for $T$, and let $V= W_{1} \oplus\cdots\oplus W_{k}$ be the primary decomposition for $T$, i.e., $W_{j}$ is the null space of $p_{j}(T)^{r_{j}}$. Let $W$ be any subspace of $V$ which is invariant under $T$. Prove that 
$W= (W \cap W_{1})\oplus (W \cap W_{2})\oplus \cdots \oplus (W \cap W_{k})$.
 A: To answer the new question in the OP (thus completing EuYu’s answer) :
Notice first that the nullspace $W_i={\sf Ker}(p_i(T)^{r_i})$ can also be written
as a image space $W_i={\sf Im}(q_i(T))$ where $q_i=\prod_{j\neq i}p_j(T)^{r_j}$.
Indeed, the inclusion ${\sf Im}(q_i(T)) \subseteq W_i$ follows from the
Cayley-Hamilton theorem. Conversely, let $w\in W_i$. The polynomial $p_i^{r_i}$ is coprime to $q_i$. We then have a Bezout identity
$$
(p_i^{r_i})A_i+q_iB_i=1 \tag{1}
$$
for some polynomials $A_i,B_i$. It follows that $w=q_i(T)(B_i(T)w)$, showing
$w\in {\sf Im}(q_i(T))$. In fact, this very argument shows that 
$E_iw=q_i(T)(B_i(T)w)$ for any $w\in V$ at all (not just $w\in W_i$), so that
$E_i=q_i(T)B_i(T)$ is a “polynomial” in $T$. So any $T$-invariant subspace
is automatically $E_i$-invariant also. 
A: Let $E_1,\ \cdots,\ E_k$ be the projections associated with the decomposition. Let $\mathbf{w}\in W$ have the unique representation in terms of the direct sum as
$$\mathbf{w} = \mathbf{w}_1 + \cdots + \mathbf{w}_k$$
We wish to show that $\mathbf{w}_i \in W$. Without loss of generality we work with $\mathbf{w}_1$. Then
$$E_1\mathbf{w} = E_1(\mathbf{w}_1 + \cdots + \mathbf{w}_k) = E_1\mathbf{w}_1 = \mathbf{w}_1$$
Since $W$ is $T$-invariant, it follows that $W$ is also $E_1$-invariant. Therefore $\mathbf{w}_1 = E_1\mathbf{w}\in W$.
Now for each $i$, it follows that $\mathbf{w}_i \in W$ and by assumption, we also have $\mathbf{w}_i\in W_i$. Therefore $\mathbf{w}_i\in W\cap W_i$. We then have
$$W\subseteq (W\cap W_1)\oplus \cdots \oplus (W\cap W_k)$$
On the other hand, we also have
$$(W\cap W_1)\oplus \cdots \oplus (W\cap W_k)\subseteq W$$
This is trivially true by closure of addition. Therefore
$$W = (W\cap W_1)\oplus \cdots \oplus (W\cap W_k)$$
