Quantum cNOT Gate (Classical XOR Gate)
A "Controlled NOT (cNOT) Gate" flips the 2nd qubit if the 1st qubit is $\left|1\right>$, and returns the 2nd qubit as-is if the 1st qubit is $\left|0\right>$. The 1st qubit is simply not changed.
The net effect of this gate is a classical XOR gate:
- It keeps the 1st qubit unchanged
- It outputs "the 1st qubit XOR the 2nd qubit" as the result of the 2nd qubit
In table form, the function looks like:
$$ \begin{array}{|c|c|} \hline \text{Input} & \text{Output} \\ \hline \begin{array}{cc}0 & 0\end{array} & \begin{array}{cc}0 & 0\end{array} \\ \hline \begin{array}{cc}0 & 1\end{array} & \begin{array}{cc}0 & 1\end{array} \\ \hline \begin{array}{cc}1 & 0\end{array} & \begin{array}{cc}1 & \color{red}{1}\end{array} \\ \hline \begin{array}{cc}1 & 1\end{array} & \begin{array}{cc}1 & \color{red}{0}\end{array} \\ \hline \end{array} $$
Therefore, an input:
$$\alpha\left|00\right>+\beta\left|01\right>+\gamma\left|10\right>+\delta\left|11\right>$$
is mapped to:
$$\alpha\left|00\right>+\beta\left|01\right>+\gamma\left|1\color{red}{1}\right>+\delta\left|1\color{red}{0}\right>$$
Or, in other words:
$$\alpha\left|00\right>+\beta\left|01\right>+\color{red}{\delta}\left|10\right>+\color{red}{\gamma}\left|11\right>$$
In matrix form, we need to find the all the $a_{ij}$'s that satisfy the following:
$$ \begin{pmatrix} a_{11} & a_{12} & a_{13} & a_{14} \\ a_{21} & a_{22} & a_{23} & a_{24} \\ a_{31} & a_{32} & a_{33} & a_{34} \\ a_{41} & a_{42} & a_{43} & a_{44} \\ \end{pmatrix} \cdot \begin{pmatrix} \alpha \\ \beta \\ \gamma \\ \delta \\ \end{pmatrix} = \begin{pmatrix} \alpha \\ \beta \\ \color{red}{\delta} \\ \color{red}{\gamma} \\ \end{pmatrix} $$
It is trivial to find the solution:
$$ \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \color{red}{0} & \color{red}{1} \\ 0 & 0 & \color{red}{1} & \color{red}{0} \\ \end{pmatrix} \cdot \begin{pmatrix} \alpha \\ \beta \\ \gamma \\ \delta \\ \end{pmatrix} = \begin{pmatrix} \alpha \\ \beta \\ \color{red}{\delta} \\ \color{red}{\gamma} \\ \end{pmatrix} $$
Quantum AND Gate?
Similarly, if there exists a gate that mimics the classical AND gate, it should have the following net effect:
- It keeps the 1st qubit unchanged
- It outputs "the 1st qubit AND the 2nd qubit" as the result of the 2nd qubit
In table form, the function looks like:
$$ \begin{array}{|c|c|} \hline \text{Input} & \text{Output} \\ \hline \begin{array}{cc}0 & 0\end{array} & \begin{array}{cc}0 & 0\end{array} \\ \hline \begin{array}{cc}0 & 1\end{array} & \begin{array}{cc}0 & \color{red}{0}\end{array} \\ \hline \begin{array}{cc}1 & 0\end{array} & \begin{array}{cc}1 & 0\end{array} \\ \hline \begin{array}{cc}1 & 1\end{array} & \begin{array}{cc}1 & 1\end{array} \\ \hline \end{array} $$
Therefore, an input:
$$\alpha\left|00\right>+\beta\left|01\right>+\gamma\left|10\right>+\delta\left|11\right>$$
should be mapped to:
$$\alpha\left|00\right>+\beta\left|0\color{red}{0}\right>+\gamma\left|10\right>+\delta\left|11\right>$$
Or, in other words:
$$\color{red}{(\alpha+\beta)}\left|00\right>+\color{red}{0}\left|01\right>+\gamma\left|10\right>+\delta\left|11\right>$$
In matrix form, we need to find the all the $a_{ij}$'s that satisfy the following:
$$ \begin{pmatrix} a_{11} & a_{12} & a_{13} & a_{14} \\ a_{21} & a_{22} & a_{23} & a_{24} \\ a_{31} & a_{32} & a_{33} & a_{34} \\ a_{41} & a_{42} & a_{43} & a_{44} \\ \end{pmatrix} \cdot \begin{pmatrix} \alpha \\ \beta \\ \gamma \\ \delta \\ \end{pmatrix} = \begin{pmatrix} \color{red}{\alpha+\beta} \\ \color{red}{0} \\ \gamma \\ \delta \\ \end{pmatrix} $$
It is trivial to find the solution:
$$ \begin{pmatrix} 1 & \color{red}{1} & 0 & 0 \\ 0 & \color{red}{0} & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{pmatrix} \cdot \begin{pmatrix} \alpha \\ \beta \\ \gamma \\ \delta \\ \end{pmatrix} = \begin{pmatrix} \color{red}{\alpha+\beta} \\ \color{red}{0} \\ \gamma \\ \delta \\ \end{pmatrix} $$
Quantum OR Gate?
Similarly, if there exists a gate that mimics the classical OR gate, it should have the following net effect:
- It keeps the 1st qubit unchanged
- It outputs "the 1st qubit OR the 2nd qubit" as the result of the 2nd qubit
In table form, the function looks like:
$$ \begin{array}{|c|c|} \hline \text{Input} & \text{Output} \\ \hline \begin{array}{cc}0 & 0\end{array} & \begin{array}{cc}0 & 0\end{array} \\ \hline \begin{array}{cc}0 & 1\end{array} & \begin{array}{cc}0 & 1\end{array} \\ \hline \begin{array}{cc}1 & 0\end{array} & \begin{array}{cc}1 & \color{red}{1}\end{array} \\ \hline \begin{array}{cc}1 & 1\end{array} & \begin{array}{cc}1 & 1\end{array} \\ \hline \end{array} $$
Therefore, an input:
$$\alpha\left|00\right>+\beta\left|01\right>+\gamma\left|10\right>+\delta\left|11\right>$$
should be mapped to:
$$\alpha\left|00\right>+\beta\left|01\right>+\gamma\left|1\color{red}{1}\right>+\delta\left|11\right>$$
Or, in other words:
$$\alpha\left|00\right>+\beta\left|01\right>+\color{red}{0}\left|10\right>+\color{red}{(\gamma+\delta)}\left|11\right>$$
In matrix form, we need to find the all the $a_{ij}$'s that satisfy the following:
$$ \begin{pmatrix} a_{11} & a_{12} & a_{13} & a_{14} \\ a_{21} & a_{22} & a_{23} & a_{24} \\ a_{31} & a_{32} & a_{33} & a_{34} \\ a_{41} & a_{42} & a_{43} & a_{44} \\ \end{pmatrix} \cdot \begin{pmatrix} \alpha \\ \beta \\ \gamma \\ \delta \\ \end{pmatrix} = \begin{pmatrix} \alpha \\ \beta \\ \color{red}{0} \\ \color{red}{\gamma+\delta} \\ \end{pmatrix} $$
It is trivial to find the solution:
$$ \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \color{red}{0} & 0 \\ 0 & 0 & \color{red}{1} & 1 \\ \end{pmatrix} \cdot \begin{pmatrix} \alpha \\ \beta \\ \gamma \\ \delta \\ \end{pmatrix} = \begin{pmatrix} \alpha \\ \beta \\ \color{red}{0} \\ \color{red}{\gamma+\delta} \\ \end{pmatrix} $$
However, since:
$$ A = \begin{pmatrix} 1 & \color{red}{1} & 0 & 0 \\ 0 & \color{red}{0} & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{pmatrix} $$
and
$$ B = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \color{red}{0} & 0 \\ 0 & 0 & \color{red}{1} & 1 \\ \end{pmatrix} $$
are not unitary matrices, as shown by $\det(A) = \det(B) = 0 \ne 1$, they could not be implemented directly as a quantum logic gate.
I have read the answer here:
but it is not intuitive enough for me:
- to understand what the final solution is; and
- to visualize how it achieves the same result as the matrix $A$ and $B$ above.
Does anyone have any idea on how to implement "Classical AND" and "Classical OR" with an explanation in matrix form? Thanks!
a AND b
I think. Just set it as0
initially.0 XOR 0
is0
, and0 XOR 1
is1
. That is,c XOR (a AND b) = a AND b
if you takec
as0
. Basically, set the ancillary qubit to $|0\rangle$ initially, and you'll get required output at the third "wire". $\endgroup${a, b, c}
to{a, b, c XOR (a AND b)
. To get back(a AND b)
, we can do aXOR c
to the result. However, since the output is at the wire c, and qubits could not be copied, how could I do aXOR c
after that? Let's say if we set $c=\left|0\right>$, can we use another qubit $d=\left|0\right>$ instead of c, and do aXOR d
to get the same result? $\endgroup$0 XOR x = x
for anyx
. Thank you so much! $\endgroup$