In quantum computing and specifically the quantum circuit model of computation, a quantum logic gate (or simply quantum gate) is a basic quantum circuit operating on a small number of qubits. Quantum logic gates are the building blocks of quantum circuits, like classical logic gates are for conventional digital circuits.
According to quantum mechanics, a quantum system can only either evolve unitarily according to the Schrödinger equation, or be measured (sometimes called "Observed"). Quantum gates describe these unitary transformations, that occur when the system is not being measured. The expression "quantum gate" appears in relation to quantum processors, and in this context they are the logical operations that the quantum computer at the assembly language-level of abstraction (e.g. OpenQASM) can perform on the quantum data (qubits or quantum states) that they process. They can also be whole algorithms (e.g. the Quantum Fourier transform) if such algorithms contain no measurement operations. When the quantum data is measured, it is usually transformed into binary bits, which is then sent to a normal ("classical") computer. The quantum processor behaves like a coprocessor to such classical binary processors.
Unlike many classical logic gates, quantum logic gates are reversible. It is possible to perform classical computing using only reversible gates. For example, the reversible Toffoli gate can implement all Boolean functions, often at the cost of having to use ancilla bits. The Toffoli gate has a direct quantum equivalent, showing that quantum circuits can perform all operations performed by classical circuits.
Quantum gates are unitary operators, and are described as unitary matrices relative to some orthonormal basis. Usually the computational basis is used, which unless comparing it with something, just means that for a d-level quantum system (such as a qubit, a quantum register, or qutrits and qudits) the orthonormal basis vectors are labeled or use binary notation.
History The current notation for quantum gates was developed by many of the founders of quantum information science including Adriano Barenco, Charles Bennett, Richard Cleve, David P. DiVincenzo, Norman Margolus, Peter Shor, Tycho Sleator, John A. Smolin, and Harald Weinfurter, building on notation introduced by Richard Feynman in 1986.
Representation
Quantum logic gates are represented by unitary matrices. A gate that acts on qubits (a register) is represented by a unitary matrix, and the set of all such gates with the group operation of matrix multiplication is the unitary group U(2n). The quantum states that the gates act upon are unit vectors in complex dimensions, with the complex Euclidean norm (the 2-norm). The basis vectors (sometimes called eigenstates) are the possible outcomes if the state of the qubits is measured, and a quantum state is a linear combination of these outcomes. The most common quantum gates operate on vector spaces of one or two qubits, just like the common classical logic gates operate on one or two bits.
Even though the quantum logic gates belong to continuous symmetry groups, real hardware is inexact and thus limited in precision. The application of gates typically introduces errors, and the quantum states' fidelities decrease over time. If error correction is used, the usable gates are further restricted to a finite set. Later in this article, this is ignored as the focus is on the ideal quantum gates' properties.
Quantum states are typically represented by "kets", from a notation known as bra–ket.
The vector representation of a single qubit is
Here, and are the complex probability amplitudes of the qubit. These values determine the probability of measuring a 0 or a 1, when measuring the state of the qubit. See measurement below for details.
The value zero is represented by the ket and the value one is represented by the ket
The tensor product (or Kronecker product) is used to combine quantum states. The combined state for a qubit register is the tensor product of the constituent qubits. The tensor product is denoted by the symbol
The vector representation of two qubits is:
The action of the gate on a specific quantum state is found by multiplying the vector , which represents the state by the matrix representing the gate. The result is a new quantum state
Relation to the time evolution operator The Schrödinger equation describes how quantum systems that are not observed evolve over time and is When the system is in a stable environment, so it has a constant Hamiltonian, the solution to this equation is , where . If the time is always the same it may be omitted for simplicity, and the way quantum states evolve can be described as just as in the above section.
That is, a quantum gate is how a quantum system that is not observed evolves over some specific time, or equivalently, a gate is the unitary time evolution operator acting on a quantum state for a specific duration.
Notable examples
There exists an uncountably infinite number of gates. Some of them have been named by various authors, and below follow some of those most often used in the literature.
Identity gate The identity gate is the identity matrix, usually written as I, and is defined for a single qubit as
where I is basis independent and does not modify the quantum state. The identity gate is most useful when describing mathematically the result of various gate operations or when discussing multi-qubit circuits.
Pauli gates (X,Y,Z)
The Pauli gates are the three Pauli matrices and act on a single qubit. The Pauli X, Y and Z equate, respectively, to a rotation around the x, y and z axes of the Bloch sphere by radians.
The Pauli-X gate is the quantum equivalent of the NOT gate for classical computers with respect to the standard basis which distinguishes the z axis on the Bloch sphere. It is sometimes called a bit-flip as it maps to and to . Similarly, the Pauli-Y maps to and to . Pauli Z leaves the basis state unchanged and maps to Due to this nature, Pauli Z is sometimes called phase-flip.
These matrices are usually represented as
The Pauli matrices are involutory, meaning that the square of a Pauli matrix is the identity matrix.
The Pauli matrices also anti-commute, for example
The matrix exponential of a Pauli matrix is a rotation operator, often written as
Controlled gates
Controlled gates act on 2 or more qubits, where one or more qubits act as a control for some operation. For example, the controlled NOT gate (or CNOT or CX) acts on 2 qubits, and performs the NOT operation on the second qubit only when the first qubit is and otherwise leaves it unchanged. With respect to the basis it is represented by the Hermitian unitary matrix:
The CNOT (or controlled Pauli-X) gate can be described as the gate that maps the basis states , where is XOR.
The CNOT can be expressed in the Pauli basis as:
Being a Hermitian unitary operator, CNOT has the property that and , and is involutory.
More generally if U is a gate that operates on a single qubit with matrix representation
then the controlled-U gate is a gate that operates on two qubits in such a way that the first qubit serves as a control. It maps the basis states as follows.
The matrix representing the controlled U is
When U is one of the Pauli operators, X,Y, Z, the respective terms "controlled-X", "controlled-Y", or "controlled-Z" are sometimes used. Sometimes this is shortened to just CX, CY and CZ.
In general, any single qubit unitary gate can be expressed as , where H is a Hermitian matrix, and then the controlled U is
Control can be extended to gates with arbitrary number of qubits and functions in programming languages. Functions can be conditioned on superposition states.
Classical control
Gates can also be controlled by classical logic. A quantum computer is controlled by a classical computer, and behaves like a coprocessor that receives instructions from the classical computer about what gates to execute on which qubits. Classical control is simply the inclusion, or omission, of gates in the instruction sequence for the quantum computer. Performing measurements in the middle of a quantum circuit, as opposed to the end of it, is difficult and technically challenging because of timing issues and decoherence. Because of this, not all quantum computers support these classical if-statement, where quantum data is converted to bits, which then controls the program flow.
Phase shift gates The phase shift is a family of single-qubit gates that map the basis states and . The probability of measuring a or is unchanged after applying this gate, however it modifies the phase of the quantum state. This is equivalent to tracing a horizontal circle (a line of constant latitude), or a rotation about the z-axis on the Bloch sphere by radians. The phase shift gate is represented by the matrix:
where is the phase shift with the period . Some common examples are the T gate where (historically known as the gate), the phase gate (also known as the S gate, written as S, though S is sometimes used for SWAP gates) where and the Pauli-Z gate where
The phase shift gates are related to each other as follows:
Note that the phase gate is not Hermitian (except for all ). These gates are different from their Hermitian conjugates: . The two adjoint (or conjugate transpose) gates and are sometimes included in instruction sets. Qiskit online documentation. cQASM online documentation.
Hadamard gate The Hadamard or Walsh-Hadamard gate, named after Jacques Hadamard () and Joseph L. Walsh, acts on a single qubit. It maps the basis states and (it creates an equal superposition state if given a computational basis state). The two states and are sometimes written and respectively. The Hadamard gate performs a rotation of about the axis at the Bloch sphere, and is therefore involutory. It is represented by the Hadamard matrix:
If the Hermitian (so ) Hadamard gate is used to perform a change of basis, it flips and . For example, and
Swap gate
The swap gate swaps two qubits. With respect to the basis , , , , it is represented by the matrix
The swap gate can be decomposed into summation form:
Toffoli (CCNOT) gate
The Toffoli gate, named after Tommaso Toffoli and also called the CCNOT gate or Deutsch gate , is a 3-bit gate that is universal for classical computation but not for quantum computation. The quantum Toffoli gate is the same gate, defined for 3 qubits. If we limit ourselves to only accepting input qubits that are and then if the first two bits are in the state it applies a Pauli-X (or NOT) on the third bit, else it does nothing. It is an example of a CC-U (controlled-controlled Unitary) gate. Since it is the quantum analog of a classical gate, it is completely specified by its truth table. The Toffoli gate is universal when combined with the single qubit Hadamard gate.
Truth table Matrix form Input Output 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 0 1 0 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 0
The Toffoli gate is related to the classical AND () and XOR () operations as it performs the mapping on states in the computational basis.
The Toffoli gate can be expressed using Pauli matrices as
Universal quantum gates