Unit: Quantum Computing

Lesson Preview

In classical computing, we often use functions that aren't reversible. For example, the AND\text{AND} gate takes two inputs and produces one output: AND(0,0)=0\text{AND}(0,0)=0, AND(0,1)=0\text{AND}(0,1)=0, AND(1,0)=0\text{AND}(1,0)=0, AND(1,1)=1\text{AND}(1,1)=1.

Given the output 00, we can't determine which of the three possible inputs produced it. It could have been (0,0)(0,0), (0,1)(0,1), or (1,0)(1,0). Information has been lost.

Quantum computing, however, requires all operations to be reversible. This is because, as we know, quantum operations must be unitary, and unitary matrices are always invertible.

If we tried to implement a non-reversible function like f(0)=0f(0)=0, f(1)=0f(1)=0 directly as a quantum gate xf(x)|x\rangle \rightarrow |f(x)\rangle, we would map both 0|0\rangle and 1|1\rangle to 0|0\rangle, i.e.

0f(0)=0,1f(1)=0.\begin{align*} \ket{0}&\rightarrow \ket{f(0)} = \ket{0}, \\ \ket{1}&\rightarrow\ket{f(1)} = \ket{0}. \end{align*}

But clearly, this operation is not reversible. From 0\ket{0}, we have no idea whether we started with 0\ket{0} or 1\ket{1} before applying the function. Thus, this isn't a unitary operation (since all unitary operations are reversible), and therefore this is not a valid quantum operation.

QuantumCircuitsClassicalFunctions

The solution is to use an ancilla (also known as auxiliary) qubit and implement the function as:

xyxyf(x).|x\rangle|y\rangle \rightarrow |x\rangle|y \oplus f(x)\rangle.

Here, \oplus denotes addition modulo 2 (XOR\text{XOR}). In addition modulo 2, 00=00\oplus 0 = 0, 01=10\oplus 1 = 1, 10=11\oplus 0 = 1, and 11=01\oplus 1 = 0. This is also referred to as the classical XOR\text{XOR} gate, shorthand for "exclusive or".

This transformation is reversible because applying it twice returns the original state:

xyxyf(x)x(yf(x))f(x)=xy|x\rangle|y\rangle \rightarrow |x\rangle|y \oplus f(x)\rangle \rightarrow |x\rangle|(y \oplus f(x)) \oplus f(x)\rangle = |x\rangle|y\rangle

And, indeed, it can be shown that this transformation is unitary.

QuantumCircuitsClassicalFunctions

To see why it is unitary, note that it acts as a permutation on the computational basis states—each basis state xy|x\rangle|y\rangle maps to exactly one other basis state xyf(x)|x\rangle|y \oplus f(x)\rangle, and different inputs map to different outputs.

...

... continued in the full lesson.

Ready to Start Learning?

Sign up now to access the full Quantum Circuits for Classical Functions lesson and our entire curriculum!