How to construct a multi-control quantum gate whose control bit relation is XOR?

So far, the control bits of most control gates have an AND relationship. How to construct a quantum gate whose control bits are XOR with the fewest auxiliary qubits? And then generalize it, is it possible to realize multi-control quantum gates of arbitrary control logic with different relationships?

I think what you are asking for is a block unitary matrix. To be concrete I'll discuss a three-qubit case, the generalization is straightforward. Consider $$U=|00\rangle\langle00|\otimes U_{00}+|01\rangle\langle01|\otimes U_{01}+|10\rangle\langle10|\otimes U_{10}+|11\rangle\langle11|\otimes U_{11}$$ or, in matrix representation $$U=\begin{pmatrix}U_{00}&0&0&0\\0&U_{01}&0&0\\0&0&U_{10}&0\\0&0&0&U_{11}\end{pmatrix}$$ where $$U_{00}-U_{11}$$ are $$2\times2$$ matrices.

So, the matrix $$U_{00}$$ is applied to the last qubit if the first two are in the state $$|00\rangle$$, $$U_{01}$$ is applied when the control qubits are in the state $$|01\rangle$$ etc. Using these block unitaries, you can realize your arbitrary control logic.

The case when $$U_{00}=U_{10}=U_{01}=\mathbb{1}$$ and $$U_{11}=V$$ is the standard controlled-$$V$$ on the last qubit.

$$U=\begin{pmatrix}1&0&0&0\\0&1&0&0\\0&0&1&0\\0&0&0&V\end{pmatrix}$$

To insert $$V$$ at another place, say at $$|01\rangle\langle01|$$ you just need to swap $$|01\rangle$$ and $$|11\rangle$$. This is easy, since $$|01\rangle=X_0 |11\rangle$$. Explicitly, start with a standard $$C^2V=|11\rangle\langle11|\otimes V+(1-|11\rangle\langle11|)\otimes 1$$ and conjugate it with $$X_0$$ to get $$X_0C^2VX_0=|01\rangle\langle01|\otimes V+(1-|01\rangle\langle01|)\otimes 1=\begin{pmatrix}1&0&0&0\\0&V&0&0\\0&0&1&0\\0&0&0&1\end{pmatrix}$$

General block unitary can be constructed as a product of these simpler ones with only a single control state. This method uses no extra ancilla qubits. Note however that it may be very inefficient in terms of depth/gate counts.

• It's really cool theory, and the whole thing looks very straightforward and concise. I don't know if there is any relevant literature for this theory. The direct construction of the U operator you discussed opened my mind, and I will also think about the idea in practice, which may be a useful research. Also Qiskit seems to be able to set the Uniray matrix directly, I will do a verification on it. Jul 27 at 8:23