Basic Quantum Circuit (1)
Quantum bits (qubits) are a foundational concept in quantum computing, and we've previously touched on them in our post on Quantum Cryptography. In this article, we’ll dive deeper into the nature of qubits and examine how quantum circuits operate, highlighting the fundamental differences from classical computing.
We’ll walk through some of the most important quantum gates, focusing especially on the CNOT (Controlled-NOT) gate. Before introducing the CNOT gate, we need to explore the four fundamental matrices that underlie many quantum operations: the Pauli Matrices.
Outline
- Pauli Matrices
Essential set of matrices that form the basis for single-qubit operations and underpin quantum gate logic. - CNOT Gate
Ttwo-qubit gate enables quantum entanglement and conditional logic, distinguishing quantum circuits from classical ones. - Toffoli Gate
Three-qubit Toffoli (CCNOT) gate, a powerful building block for quantum algorithms and universal quantum computation.
Pauli Matrix
A set of three 2 by 2 complex Hermitian matrices that are fundamental in quantum mechanics and computing.
$$X = \sigma_x = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}, Y = \sigma_y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}, Z = \sigma_z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}$$
- X: bit-flip gate
- Y: bit-phase-flip gate
- Z: phase-flip gate
If apply each to basic quantum bit $\lvert 0 \rangle$ and $\lvert 1 \rangle$, we will got:
$$X\lvert 0 \rangle = \lvert 1 \rangle, X\lvert 1 \rangle = \lvert 0 \rangle$$
$$Y\lvert 0 \rangle = i\lvert 1 \rangle, Y\lvert 1 \rangle = -i\lvert 0 \rangle$$
$$Z\lvert 0 \rangle = \lvert 0 \rangle, Z\lvert 0 \rangle = -\lvert 1 \rangle$$
CNOT Gate
Controlled-NOT (CNOT) gate is a two-qubit gate with one qubit control and one target.
Rule:
- if the control qubit is in the state $\lvert 1 \rangle$, flip target qubit
- if the control qubit is in the state $\lvert 0 \rangle$, do nothing
Therefore, you can easily understand the truth table as follows:
| Control (C) | Target (T) | Output C | Output T |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 |
Mathematically defined as:
$$\text{CNOT} = \lvert 0 \rangle \langle 0 \lvert \otimes I + \lvert 1 \rangle \langle 1 \lvert \otimes X$$
Or with its matrix form as:
$$\text{CNOT} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0\end{bmatrix}$$
CNOT is important because it is an entangling gate, meaning that for such gate you can construct an entangled state:
- Apply $H$ to $\lvert 0 \rangle \lvert 0 \rangle = \lvert 0 \rangle (\lvert 0 \rangle + \lvert 1 \rangle)/\sqrt{2} = \lvert + \rangle \lvert 0 \rangle$
- Apply CNOT to $\lvert + \rangle \lvert 0 \rangle = (\lvert 00 \rangle + \lvert 11 \rangle)/\sqrt{2}$
This result is called Bell state which is the most basic entangled state.
Toffoli Gate
Toffoli gate (CCNOT Gate) is a 3-qubit quantum state that works like a controlled-controlled-NOT gate. It is straightforward to know it owns two control qubits and one target qubit. This simply means if both controlled state are $\lvert 1 \rangle$, then flip the target qubit.
Mathematically defined as:
$$\text{Toffoli}(a,b,c) = \begin{cases}(a,b,c \otimes 1), \text{if} \quad a = 1 \quad \text{and} \quad b = 1 \\ (a,b,c) \quad \text{otherwise}\end{cases}$$
The truth table looks like this:
| Control ($C_1$) | Control ($C_2$) | Target T | Output T |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 0 |
The Toffoli gate, is indeed a pivotal building block in quantum circuits. Here’s how it functions and why it's so critical:
- Crucial for Quantum Error Correction: widely used in quantum error correction codes—such as Shor's code and the surface code—because it allows complex multi-qubit logical operations necessary for detecting and correcting errors without disturbing the encoded quantum information
- Essential in Grover’s Search and Other Algorithms: In Grover’s search algorithm, the Toffoli gate is used to construct the key "oracle" and selective phase inversion operations, making it essential for quantum speedups in searching unsorted databases.
- Compatibility Between Classical and Quantum Logic: Since the Toffoli gate is reversible and can simulate classical computations, it serves as a bridge between quantum and classical circuits. Quantum computers, being a superset of classical computers, leverage gates like Toffoli to natively run classical subroutines within a quantum framework.
In summary, we have explored the fundamental building blocks of quantum computing, from the foundational Pauli matrices through essential gates like the CNOT and Toffoli. These components give us the power to represent, manipulate, and transfer quantum information—laying the groundwork for more sophisticated quantum operations. Before we dive into well-known quantum algorithms in future articles, we'll first look at two important topics: Quantum Wire Swapping and Quantum State Generation.