In
quantum computing
Quantum computing is a type of computation whose operations can harness the phenomena of quantum mechanics, such as superposition, interference, and entanglement. Devices that perform quantum computations are known as quantum computers. Thou ...
, Grover's algorithm, also known as the quantum search algorithm, refers to a
quantum algorithm
In quantum computing, a quantum algorithm is an algorithm which runs on a realistic model of quantum computation, the most commonly used model being the quantum circuit model of computation. A classical (or non-quantum) algorithm is a finite seq ...
for unstructured search that finds
with high probability the unique input to a
black box
In science, computing, and engineering, a black box is a system which can be viewed in terms of its inputs and outputs (or transfer characteristics), without any knowledge of its internal workings. Its implementation is "opaque" (black). The te ...
function that produces a particular output value, using just
evaluations of the function, where
is the size of the function's
domain
Domain may refer to:
Mathematics
*Domain of a function, the set of input values for which the (total) function is defined
** Domain of definition of a partial function
**Natural domain of a partial function
**Domain of holomorphy of a function
*Do ...
. It was devised by
Lov Grover in 1996.
The analogous problem in classical computation cannot be solved in fewer than
evaluations (because, on average, one has to check half of the domain to get a 50% chance of finding the right input).
Charles H. Bennett, Ethan Bernstein,
Gilles Brassard
Gilles Brassard, is a faculty member of the Université de Montréal, where he has been a Full Professor since 1988 and Canada Research Chair since 2001.
Education and early life
Brassard received a Ph.D. in Computer Science from Cornell Univ ...
, and
Umesh Vazirani proved that any quantum solution to the problem needs to evaluate the function
times, so Grover's algorithm is
asymptotically optimal
In computer science, an algorithm is said to be asymptotically optimal if, roughly speaking, for large inputs it performs at worst a constant factor (independent of the input size) worse than the best possible algorithm. It is a term commonly en ...
.
Since classical algorithms for
NP-complete problems
In computational complexity theory, a problem is NP-complete when:
# it is a problem for which the correctness of each solution can be verified quickly (namely, in polynomial time) and a brute-force search algorithm can find a solution by tryin ...
require exponentially many steps, and Grover's algorithm provides at most a quadratic speedup over the classical solution for unstructured search, this suggests that Grover's algorithm by itself will not provide
polynomial-time solutions for NP-complete problems (as the square root of an exponential function is an exponential, not polynomial, function).
Unlike other quantum algorithms, which may provide exponential speedup over their classical counterparts, Grover's algorithm provides only a quadratic speedup. However, even quadratic speedup is considerable when
is large, and Grover's algorithm can be applied to speed up broad classes of algorithms.
[ Grover's algorithm could brute-force a 128-bit symmetric cryptographic key in roughly 264 iterations, or a 256-bit key in roughly 2128 iterations. As a result, it is sometimes suggested] that symmetric key lengths be doubled to protect against future quantum attacks.
Applications and limitations
Grover's algorithm, along with variants like amplitude amplification Amplitude amplification is a technique in quantum computing which generalizes the idea behind
the Grover's search algorithm, and gives rise to a family of
quantum algorithms.
It was discovered by Gilles Brassard and
Peter Høyer in 1997,
and ind ...
, can be used to speed up a broad range of algorithms. In particular, algorithms for NP-complete problems generally contain exhaustive search as a subroutine, which can be sped up by Grover's algorithm.[ The current best algorithm for ]3SAT
In logic and computer science, the Boolean satisfiability problem (sometimes called propositional satisfiability problem and abbreviated SATISFIABILITY, SAT or B-SAT) is the problem of determining if there exists an interpretation that satisfies ...
is one such example. Generic constraint satisfaction problem
Constraint satisfaction problems (CSPs) are mathematical questions defined as a set of objects whose state must satisfy a number of constraints or limitations. CSPs represent the entities in a problem as a homogeneous collection of finite constr ...
s also see quadratic speedups with Grover. These algorithms do not require that the input be given in the form of an oracle, since Grover's algorithm is being applied with an explicit function, e.g. the function checking that a set of bits satisfies a 3SAT instance.
Grover's algorithm can also give provable speedups for black-box problems in quantum query complexity
In computational complexity the decision tree model is the model of computation in which an algorithm is considered to be basically a decision tree, i.e., a sequence of ''queries'' or ''tests'' that are done adaptively, so the outcome of the previ ...
, including element distinctness and the collision problem (solved with the Brassard–Høyer–Tapp algorithm). In these types of problems, one treats the oracle function ''f'' as a database, and the goal is to use the quantum query to this function as few times as possible.
Cryptography
Grover's algorithm essentially solves the task of ''function inversion''. Roughly speaking, if we have a function that can be evaluated on a quantum computer, Grover's algorithm allows us to calculate when given . Consequently, Grover's algorithm gives broad asymptotic speed-ups to many kinds of brute-force attacks on symmetric-key cryptography
Symmetric-key algorithms are algorithms for cryptography that use the same cryptographic keys for both the encryption of plaintext and the decryption of ciphertext. The keys may be identical, or there may be a simple transformation to go between ...
, including collision attack
In cryptography, a collision attack on a cryptographic hash tries to find two inputs producing the same hash value, i.e. a hash collision. This is in contrast to a preimage attack where a specific target hash value is specified.
There are roug ...
s and pre-image attack
In cryptography, a preimage attack on cryptographic hash functions tries to find a message that has a specific hash value. A cryptographic hash function should resist attacks on its preimage (set of possible inputs).
In the context of attack, the ...
s. However, this may not necessarily be the most efficient algorithm since, for example, the parallel rho algorithm is able to find a collision in SHA2 more efficiently than Grover's algorithm.
Limitations
Grover's original paper described the algorithm as a database search algorithm, and this description is still common. The database in this analogy is a table of all of the function's outputs, indexed by the corresponding input. However, this database is not represented explicitly. Instead, an oracle is invoked to evaluate an item by its index. Reading a full database item by item and converting it into such a representation may take a lot longer than Grover's search. To account for such effects, Grover's algorithm can be viewed as solving an equation or satisfying a constraint. In such applications, the oracle is a way to check the constraint and is not related to the search algorithm. This separation usually prevents algorithmic optimizations, whereas conventional search algorithms often rely on such optimizations and avoid exhaustive search.
The major barrier to instantiating a speedup from Grover's algorithm is that the quadratic speedup achieved is too modest to overcome the large overhead of near-term quantum computers. However, later generations of fault-tolerant
Fault tolerance is the property that enables a system to continue operating properly in the event of the failure of one or more faults within some of its components. If its operating quality decreases at all, the decrease is proportional to the ...
quantum computers with better hardware performance may be able to realize these speedups for practical instances of data.
Problem description
As input for Grover's algorithm, suppose we have a function . In the "unstructured database" analogy, the domain represent indices to a database, and if and only if the data that ''x'' points to satisfies the search criterion. We additionally assume that only one index satisfies , and we call this index ''ω''. Our goal is to identify ''ω''.
We can access ''f'' with a subroutine
In computer programming, a function or subroutine is a sequence of program instructions that performs a specific task, packaged as a unit. This unit can then be used in programs wherever that particular task should be performed.
Functions ma ...
(sometimes called an oracle
An oracle is a person or agency considered to provide wise and insightful counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. As such, it is a form of divination.
Description
The wor ...
) in the form of a unitary operator ''Uω'' that acts as follows:
:
This uses the -dimensional state space
A state space is the set of all possible configurations of a system. It is a useful abstraction for reasoning about the behavior of a given system and is widely used in the fields of artificial intelligence and game theory.
For instance, the t ...
, which is supplied by a register with qubit
In quantum computing, a qubit () or quantum bit is a basic unit of quantum information—the quantum version of the classic binary bit physically realized with a two-state device. A qubit is a two-state (or two-level) quantum-mechanical system, ...
s.
This is often written as
:
Grover's algorithm outputs ''ω'' with probability at least ''1/2'' using applications of ''Uω''. This probability can be made arbitrarily large by running Grover's algorithm multiple times. If one runs Grover's algorithm until ''ω'' is found, the expected number of applications is still , since it will only be run twice on average.
Alternative oracle definition
This section compares the above oracle with an oracle .
''Uω'' is different from the standard quantum oracle for a function ''f''. This standard oracle, denoted here as ''Uf'', uses an ancillary qubit system. The operation then represents an inversion ( NOT gate) on the main system conditioned by the value of ''f''(''x'') from the ancillary system:
:
or briefly,
:
These oracles are typically realized using uncomputation
Uncomputation is a technique, used in reversible circuits, for cleaning up temporary effects on ancilla bits so that they can be re-used.
Uncomputation is a fundamental step in quantum computing
Quantum computing is a type of computation who ...
.
If we are given ''Uf'' as our oracle, then we can also implement ''Uω'', since ''Uω'' is ''Uf'' when the ancillary qubit is in the state :
:
So, Grover's algorithm can be run regardless of which oracle is given.[ If ''Uf'' is given, then we must maintain an additional qubit in the state and apply ''Uf'' in place of ''Uω''.
]
Algorithm
The steps of Grover's algorithm are given as follows:
# Initialize the system to the uniform superposition over all states
# Perform the following "Grover iteration" times:
## Apply the operator
## Apply the ''Grover diffusion'' operator
# Measure the resulting quantum state in the computational basis.
For the correctly chosen value of , the output will be with probability approaching 1 for ''N'' ≫ 1. Analysis shows that this eventual value for satisfies .
Implementing the steps for this algorithm can be done using a number of gates linear in the number of qubits.[ Thus, the gate complexity of this algorithm is , or per iteration.
]
Geometric proof of correctness
There is a geometric interpretation of Grover's algorithm, following from the observation that the quantum state of Grover's algorithm stays in a two-dimensional subspace after each step. Consider the plane spanned by and ; equivalently, the plane spanned by and the perpendicular ket
Kentucky Educational Television (KET) is a state network of PBS member television stations serving the U.S. Commonwealth of Kentucky. It is operated by the Kentucky Authority for Educational Television, an agency of the Kentucky state governm ...
.
Grover's algorithm begins with the initial ket , which lies in the subspace. The operator is a reflection at the hyperplane orthogonal to for vectors in the plane spanned by and , i.e. it acts as a reflection across . This can be seen by writing in the form of a Householder reflection:
:
The operator is a reflection through . Both operators and take states in the plane spanned by and to states in the plane. Therefore, Grover's algorithm stays in this plane for the entire algorithm.
It is straightforward to check that the operator of each Grover iteration step rotates the state vector by an angle of .
So, with enough iterations, one can rotate from the initial state to the desired output state . The initial ket is close to the state orthogonal to :
:
In geometric terms, the angle between and is given by
:
We need to stop when the state vector passes close to ; after this, subsequent iterations rotate the state vector ''away'' from , reducing the probability of obtaining the correct answer. The exact probability of measuring the correct answer is
:
where ''r'' is the (integer) number of Grover iterations. The earliest time that we get a near-optimal measurement is therefore .
Algebraic proof of correctness
To complete the algebraic analysis, we need to find out what happens when we repeatedly apply . A natural way to do this is by eigenvalue analysis of a matrix. Notice that during the entire computation, the state of the algorithm is a linear combination of and . We can write the action of and in the space spanned by as:
: