It is known that a projection operator can be written explicitly as follows:
$$\hat{P} = \sum_{k=1}^n \hat{P_k} = \sum_{k=1}^n | k \rangle\langle k|$$
where $\{|k\rangle$, $k= 1,\ldots,n\}$ are the orthonormal basis.
So it is curious to ask if a projection should always be written as the sum of projection operators to the smaller subspaces, which are orthogonal to each other. This is proved as following.
Given two projection operators $\hat{P_1}$ and $\hat{P_2}$, for the sum $\hat{P} = \hat{P_1} + \hat{P_2}$ to be also a projection operator:
$$(\hat{P_1} + \hat{P_2})^2 = \hat{P_1} + \hat{P_2} \\ \Rightarrow \hat{P_1}^2 + \hat{P_2}^2 + \hat{P_1}\hat{P_2} + \hat{P_2}\hat{P_1} \\ = \hat{P_1} + \hat{P_2} + \hat{P_1}\hat{P_2} + \hat{P_2}\hat{P_1} = \hat{P_1} + \hat{P_2}$$
Therefore we get
$$\hat{P_1}\hat{P_2} + \hat{P_2}\hat{P_1}\tag 1 = 0$$
(1) left-multiplied by $\hat{P_1}$, we get:
$$\hat{P_1}\hat{P_2} + \hat{P_1}\hat{P_2}\hat{P_1} = 0\tag 2$$
(1) right-multiplied by $\hat{P_1}$, we get:
$$\hat{P_1}\hat{P_2}\hat{P_1} + \hat{P_2}\hat{P_1} = 0\tag3$$
(2) - (3) gives:
$$\hat{P_1}\hat{P_2} - \hat{P_2}\hat{P_1} = 0\tag4$$
(1) + (4) eventually gives:
$$\hat{P_1}\hat{P_2} = \hat{P_2}\hat{P_1} = 0\tag5$$
The above proved that equation (5) is the necessary condition for the sum $\hat{P} = \hat{P_1} + \hat{P_2}$ to be also a projection operator. It is straightforward to see that (5) is the sufficient condition, too. So we conclude that:
$$(\hat{P_1} + \hat{P_2})^2 = \hat{P_1} + \hat{P_2} \\ \Longleftrightarrow \hat{P_1}\hat{P_2} = \hat{P_2}\hat{P_1} = 0$$
given two projection operators $\hat{P_1}$ and $\hat{P_2}$.
My question is: what is the general theory/theorem that formally addressed the above question and stated the above result?