# Can any “control-something unitary” be written with control and target spaces flipped?

Consider a simple two-qubit gate such as the CNOT. The typical presentation of this gate is $$\text{CNOT} = |0\rangle\!\langle0|\otimes I + |1\rangle\!\langle1|\otimes X,$$ with $$X$$ the Pauli $$X$$ gate. This gate can also be written reversing the role of control and target, as $$\text{CNOT} = I\otimes |+\rangle\!\langle+| + Z\otimes |-\rangle\!\langle-|.$$ Is this sort of trick a general feature of unitary gates which have a "control-target structure" (that is, unitaries acting on a bipartite space which are block-diagonal in some basis)? More precisely, consider a generic unitary $$\mathcal U:\mathcal H_A\otimes\mathcal H_B\to\mathcal H_A\otimes\mathcal H_B$$ which has the form $$\mathcal U = \sum_i |u_i\rangle\!\langle u_i|\otimes U_i,$$ for some orthonormal set $$\{|u_i\rangle\}_i\in\mathcal H_A$$ and collection of unitaries $$\{U_i\}_i$$.

Is there always a set of orthonormal vectors $$\{|v_j\rangle\}_j\subset\mathcal H_B$$ and collection of unitaries $$\{V_j\}_j$$ such that $$\mathcal U = \sum_j V_j\otimes |v_j\rangle\!\langle v_j|$$ also holds?

This question is closely related to General approach for switching control and target qubit, albeit here I'm focusing on a more general case.

• I don't instantly have a proof (hence this not being an answer), but I believe it's true if and only if you're doing controlled-$U$ where $U^2=I$, which means there's a $V$ such that $VUV^\dagger=X$. – DaftWullie May 11 at 12:58
• @DaftWullie uh, I was actually just realising that it might be more general than that. I think you can do it whenever the $U_i$ are simultaneously diagonalizable, see the answer. I'm not sure about whether this condition is also necessary though. – glS May 11 at 13:21
• D'oh! Of course.... controlled-phase of arbitrary phase is symmetric in control and target – DaftWullie May 11 at 13:40
• @DaftWullie I suppose, in your notation, the condition of simultaneous diagonalisability is equivalent to being able to write the operation on the second rail as some $VDV^\dagger$ with $V$ the unitary switching between computational basis and the eigenbasis common to the $U_i$, and with $D$ a diagonal unitary. Then this amounts to a cPhase plus local operations, and you can move the local operations on the other rail via "phase kickbacks"? – glS May 11 at 13:45
• yes, that's right. – DaftWullie May 11 at 14:39

Something I realised while writing the question:

This is possible whenever the gates $$U_i$$ are simultaneously diagonalisable. Indeed, suppose this is the case, and we can thus write the eigendecompositions of the $$U_i$$ as $$U_i = \sum_j \lambda_{ij} |x_j\rangle\!\langle x_j|,$$ for some basis $$\{|x_j\rangle\}_j$$ (that is equal for all $$i$$), and with $$\{\lambda_{ij}\}_j$$ the eigenvalues of $$U_i$$. These must therefore all be such that $$|\lambda_{ij}|=1$$.

We then have $$\sum_i |u_i\rangle\!\langle u_i| \otimes U_i = \sum_{ij} |u_i\rangle\!\langle u_i| \otimes \lambda_{ij} |x_j\rangle\!\langle x_j| = \sum_j \left(\sum_i \lambda_{ij} |u_i\rangle\!\langle u_i|\right) \otimes |x_j\rangle\!\langle x_j|.$$ We can therefore define $$V_j\equiv \sum_i \lambda_{ij} |u_i\rangle\!\langle u_i|$$, and obtain a new set of unitaries which are "controlled", with the (orthonormal) states $$|x_j\rangle$$ acting as controls.

I'm not sure whether this condition is also necessary though.

Yes, you can always do this. E.g. see this blog post: https://algassert.com/post/1706

Suppose you have two simultaneously diagonalizable unitary operations $$A = \sum_k a_k |\lambda_k\rangle\langle \lambda_k|$$ and $$B = \sum_k b_k |\lambda_k\rangle\langle \lambda_k|$$. For example, if they operate on different qubits then this property is met. Let the "control product" of the two operations be the result of multiplying them in log space (this corresponds to pairwise multiplying the angles of the two operations' eigenvalues, rescaled so that 180 degrees is the identity angle):

$$\text{Control}(A, B) = \exp\left(\frac{\ln(A) \ln(B)}{i \pi}\right)$$

When you set $$A$$ to a Pauli $$Z$$ operation, this corresponds to controlling $$B$$ by $$A$$'s target. E.g. note that $$\text{Control}(Z_1, X_2) = \text{CNOT}_{1,2}$$ and $$\text{Control}(Z_1, Z_2) = \text{CZ}_{1,2}$$. So the control product actually generalizes the notion of controlling to things beyond $$Z$$ controls, since you can set $$A$$ to things besides $$Z$$.

Anyways, note that the definition is completely symmetric. $$\text{Control}(A, B) = \text{Control}(B, A)$$. Therefore there's no fundamental distinction between the control and the target. This is one of the ways to see why phase kickback occurs: the phase kickback from applying $$\text{Control}(Z, U)$$ is due to the Z "being controlled by the U".

• I don't quite follow the notation. What is the gate you are decomposing this way? Are you considering the gate $|0\rangle\!\langle0|\otimes A+|1\rangle\!\langle1|\otimes B$, or are $A,B$ referring to something else? As an example, how would you use this to write a gate such as $|0\rangle\!\langle0|\otimes X+ |1\rangle\!\langle1|\otimes Z$ with the control on the second qubit? – glS May 12 at 6:29
• @gIS I'd write that as $\text{Control}(-Z, X) \cdot \text{Control}(Z, Z)$ or $X \cdot \text{Control}(Z, X \cdot Z)$. – Craig Gidney May 12 at 13:14
• what does that correspond to in an explicit decomposition? I don't really understand your argument. E.g. in the first of the two expressions in your comment, I think I understand why the product of Controls can be thought of as controlled by the first qubit, but how can you interpret that as a controlled-gate with the second qubit as control? $Z$ and $X$ do not commute, so Control(Z,Z) Control(-Z,X) is a product of gates controlled by different things – glS May 12 at 14:04
• @gIS Ah, my mistake, I forgot the indices. The first argument was on one qubit and the second on another. – Craig Gidney May 12 at 14:10
• if you mean $C(-Z_1,X_2) C(Z_1,Z_2)$, sure, I guessed that, but that's not my point. If I understand your notation, $C(-Z_1,X_2)$ amounts to applying $-Z_1$ to the first qubit conditionally to the second qubit being in an eigenvector of $X$. But then $C(Z_1,Z_2)$ is controlled by the second qubit in the $Z$ basis, while $C(-Z_1,X_2)$ by the second qubit in the $X$ basis. So in which basis is the second qubit controlled now? On the other hand the other expression I guess is $X_1 C(Z_1, X_2 Z_2)$? – glS May 12 at 14:17