# How to derive Dirac's spin exchange operator?

According to Wiki, the spin exchange operator is $$P_{12}=\frac{1}{2}(1+\vec\sigma_1\otimes\vec\sigma_2),$$ and i can verify that this is true by acting it to a 2-spin system.

But i don't know how this can be derived. My attempt: $$P=\langle\uparrow|\downarrow\rangle\otimes \langle\downarrow|\uparrow\rangle +\langle\downarrow|\uparrow\rangle\otimes\langle\uparrow|\downarrow\rangle+ +\langle\uparrow|\uparrow\rangle\otimes\langle\uparrow|\uparrow\rangle +\langle\downarrow|\downarrow\rangle\otimes\langle\downarrow|\downarrow\rangle.$$ Using some matrix calculation i get $$P=\left(\begin{array} &1&0&0&0\\ 0&0&1&0\\ 0&1&0&0\\ 0&0&0&1 \end{array}\right)$$ and this do equal the first equation, but how could one come that up?

i) if one of the spins is up and the other is down, take the down up and the up down. So this is achieved by a term like $$\sigma_1^{+}\sigma_2^{-} + \sigma_1^{-}\sigma_2^{+}$$. Note that acting with this on a state where both spins are identical will lead to zero, which is good for us -- it won't get us into trouble in the case that they are equal.
ii) if both spins are identical, just leave it be, which we can write as $$1$$. But we want it to operate only if they are equal. So let's subtract $$1$$ in case they are not equal, which means that $$\sigma_1^z\sigma_2^z=-1$$. Then we write this part as $$(1+\sigma_1^z\sigma_2^z)/2$$ which does the trick.
Now we just have to add everything up, and as $$\sigma^{\pm} = (\sigma^x \pm i\sigma^y)/2$$, you get the expression you wanted.