# Prove expressions for visibilities $\operatorname{Tr}(\rho_a^2\rho_b^2), \operatorname{Tr}[(\rho_a \rho_b)^2]$ in terms of SWAP operations

Given two states $$\rho_a$$ and $$\rho_b$$, and knowing that the SWAP gate swaps two qubits, how can one prove that visibilities

$$v_1=Tr[\rho_a^2 \rho_b^2] = Tr[S_{AB} S_{BC} S_{CD} \rho_a \otimes \rho_a \otimes \rho_b \otimes \rho_b ]$$

$$v_2=Tr[(\rho_a \rho_b)^2] = Tr[S_{BC} S_{CD} S_{AB} S_{BC} S_{AB} \rho_a \otimes \rho_a \otimes \rho_b \otimes \rho_b]$$

Reference: https://arxiv.org/pdf/1501.03099.pdf

Explicitly write out what the trace is supposed to be: $$\text{Tr}(S_{AB}S_{BC}S_{CD}\rho_a\otimes\rho_a\otimes\rho_b\otimes\rho_b)=\sum_{i,j,k,l}\langle ijkl|S_{AB}S_{BC}S_{CD}\rho_a\otimes\rho_a\otimes\rho_b\otimes\rho_b|ijkl\rangle.$$ Now you can apply the swaps to the basis elements $$=\sum_{i,j,k,l}\langle jikl|S_{BC}S_{CD}\rho_a\otimes\rho_a\otimes\rho_b\otimes\rho_b|ijkl\rangle$$ and keep going... $$=\sum_{i,j,k,l}\langle jkli|\rho_a\otimes\rho_a\otimes\rho_b\otimes\rho_b|ijkl\rangle$$ So, this is the same thing as $$\sum_{ijkl}\langle j|\rho_a|i\rangle\langle i|\rho_b|l\rangle\langle l|\rho_b|k\rangle\langle k|\rho_a|j\rangle.$$ It's worth a comment about how I chose the ordering of those terms. I just started with the first index ($$j$$). Because it's closing index was $$i$$, the next term I wrote down started with $$i$$, and so on. Now, knowing the result I want, I'll use the commutativity of multiplication to choose a slightly different order: $$\sum_{ijkl}\langle k|\rho_a|j\rangle\langle j|\rho_a|i\rangle\langle i|\rho_b|l\rangle\langle l|\rho_b|k\rangle.$$ Next, notice that there's lots of completeness relations appearing here: $$\sum_j|j\rangle\langle j|=I$$. Thus, this is the same as $$\sum_k\langle k|\rho_aI\rho_aI\rho_bI\rho_B|k\rangle=\text{Tr}(\rho_a^2\rho_b^2).$$

The other one will work just the same.