Meaningful classical computation can be done only when we have the ability to act on multiple bits at the same time. We've seen previously that we have gates that can take 1 bit as input and produce 1 bit as output, but we also have gates that can take multiple bits as input and produce multiple bits as output.
The two most common of these gates are the and gates. Just like before, we can represent the way they behave through their truth tables:
A | B | A AND B |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
A | B | A OR B |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
And here's what the circuit symbols look like:
As before, we can chain these gates together visually in a circuit diagram. Now we have 2 qubit gates, we're able to achieve more complex behaviour. Take a look at the circuit below:
Woah, looks crazy right?
This circuit is implementing a famous gate called which is short for eXclusive-OR. This gate outputs a if only one of the inputs is but not both. The truth table is therefore:
A | B | A XOR B |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
I encourage you to work through the diagram above to confirm that this circuit does implement this truth table.
But enough of classical computation already. We're here for quantum!
We can also define multi-qubit operators that act on multiple qubits at once. A common example of this is the gate (short for "Controlled-NOT"). The gate is a two-qubit gate that flips the second qubit only if the first qubit is a 1 and leaves it alone otherwise:
Just like with classical gates, we have a circuit symbol for this:
In this representation the solid circle at the top represents the "control" qubit, and the crossed circle at the bottom represents the "target" qubit that flips if the control qubit is 1. This representation is useful because when we have more complicated circuits with more qubits we are able to more easily choose arbitrary controls and targets.
Previously, we represented our single qubit gates using the outer product. In order to understand how we can use the outer product when dealing with multiple qubits let's look at how the tensor product works here. We'll take an arbitrary 2 outer products tensored together: and see how it behaves on two qubits: :
Comparing the first and last line shows us that
Equipped with this knowledge, we can now represent the gate using outer products:
Using the same result we can factor this into a more useful form:
Another example of a multi-qubit operator is the gate. The gate swaps the values of two qubits:
The circuit symbol for this gate is:
And can be defined similarly:
A quite remarkable result is that the operation can be represented as:
It's quite interesting how by adding and tensoring a few single qubit gates together we can get a multi-qubit gate! The proof of this fact is fairly mechanical, and will be left for the exercises.
Take a look at the circuit above. Did you notice a hidden gate? We use it twice in these locations:
This part of the circuit essentially "copies" the bit so we can use it's value in more than one place. In classical circuits this is often called "fan-out". It begs the question: can we do the same thing with qubits?
We can actually answer this question with a bit of algebra. We'll start by thinking about what this operation might look like if it did exist. We'll define a new operation that behaves like this: . So it is a gate that can take a qubit and a blank qubit and copy the first qubit into the second qubit.
Note that this is not a full definition of the gate because we haven't defined it in terms of 4 basis vectors. Our following proof will show that a gate of this description cannot be fully described as such.
We will prove that this circuit can't exist by proving that this gate doesn't obey linearity. Consider when :
However:
This clearly doesn't equal the result from the previous box and so we have shown that an operator implementing this behaviour doesn't exist. This is an interesting find. Not being able to clone our qubits like classical bits will naturally change the way we build quantum circuits.
It reveals something interesting about how we measure quantum states as well. If we had a qubit in the state , we could clone the qubit 1,000,000 times, measure them all and then use the results to estimate the values of and . However we now know we can't do this. This gives some intuition as to how quantum states are often very "hidden". In quantum systems, the information is contained within the coefficients of the basis states, but these coefficients are impossible to obtain directly. The most interesting quantum algorithms are those that derive clever ways to extract the information from these coefficients.
Verify that the gate defined above does in fact "swap" the qubits even when the qubits are not in a basis state or .
Prove the earlier stated fact:
Verify that the following circuit is equivalent to :