- Source: Quantum counting algorithm
Quantum counting algorithm is a quantum algorithm for efficiently counting the number of solutions for a given search problem.
The algorithm is based on the quantum phase estimation algorithm and on Grover's search algorithm.
Counting problems are common in diverse fields such as statistical estimation, statistical physics, networking, etc.
As for quantum computing, the ability to perform quantum counting efficiently is needed in order to use Grover's search algorithm (because running Grover's search algorithm requires knowing how many solutions exist). Moreover, this algorithm solves the quantum existence problem (namely, deciding whether any solution exists) as a special case.
The algorithm was devised by Gilles Brassard, Peter Høyer and Alain Tapp in 1998.
The problem
Consider a finite set
{
0
,
1
}
n
{\displaystyle \{0,1\}^{n}}
of size
N
=
2
n
{\displaystyle N=2^{n}}
and a set
B
{\displaystyle B}
of "solutions" (that is a subset of
{
0
,
1
}
n
{\displaystyle \{0,1\}^{n}}
). Define:
{
f
:
{
0
,
1
}
n
→
{
0
,
1
}
f
(
x
)
=
{
1
x
∈
B
0
x
∉
B
{\displaystyle {\begin{cases}f:\left\{0,1\right\}^{n}\to \{0,1\}\\f(x)={\begin{cases}1&x\in B\\0&x\notin B\end{cases}}\end{cases}}}
In other words,
f
{\displaystyle f}
is the indicator function of
B
{\displaystyle B}
.
Calculate the number of solutions
M
=
|
f
−
1
(
1
)
|
=
|
B
|
{\displaystyle M=\left\vert f^{-1}(1)\right\vert =\vert B\vert }
.
= Classical solution
=Without any prior knowledge on the set of solutions
B
{\displaystyle B}
(or the structure of the function
f
{\displaystyle f}
), a classical deterministic solution cannot perform better than
Ω
(
N
)
{\displaystyle \Omega (N)}
, because all the
N
{\displaystyle N}
elements of
{
0
,
1
}
n
{\displaystyle \{0,1\}^{n}}
must be inspected (consider a case where the last element to be inspected is a solution).
The algorithm
= Setup
=The input consists of two registers (namely, two parts): the upper
p
{\displaystyle p}
qubits comprise the first register, and the lower
n
{\displaystyle n}
qubits are the second register.
= Create superposition
=The initial state of the system is
|
0
⟩
⊗
p
|
0
⟩
⊗
n
{\displaystyle |0\rangle ^{\otimes p}|0\rangle ^{\otimes n}}
. After applying multiple bit Hadamard gate operation on each of the registers separately, the state of the first register is
1
2
p
/
2
(
|
0
⟩
+
|
1
⟩
)
⊗
p
{\displaystyle {\frac {1}{2^{p/2}}}(|0\rangle +|1\rangle )^{\otimes p}}
and the state of the second register is
1
2
n
/
2
(
|
0
⟩
+
|
1
⟩
)
⊗
n
=
1
N
∑
x
=
0
N
−
1
|
x
⟩
{\displaystyle {\frac {1}{2^{n/2}}}(|0\rangle +|1\rangle )^{\otimes n}={\frac {1}{\sqrt {N}}}\sum _{x=0}^{N-1}|x\rangle }
an equal superposition state in the computational basis.
= Grover operator
=Because the size of the space is
|
{
0
,
1
}
n
|
=
2
n
=
N
{\displaystyle \left\vert \{0,1\}^{n}\right\vert =2^{n}=N}
and the number of solutions is
|
B
|
=
M
{\displaystyle \left\vert B\right\vert =M}
, we can define the normalized states:: 252
|
α
⟩
=
1
N
−
M
∑
x
∉
B
|
x
⟩
,
and
|
β
⟩
=
1
M
∑
x
∈
B
|
x
⟩
.
{\displaystyle |\alpha \rangle ={\frac {1}{\sqrt {N-M}}}\sum _{x\notin B}{|x\rangle },\qquad {\text{and}}\qquad |\beta \rangle ={\frac {1}{\sqrt {M}}}\sum _{x\in B}{|x\rangle }.}
Note that
N
−
M
N
|
α
⟩
+
M
N
|
β
⟩
=
1
N
∑
x
=
0
N
−
1
|
x
⟩
,
{\displaystyle {\sqrt {\frac {N-M}{N}}}|\alpha \rangle +{\sqrt {\frac {M}{N}}}|\beta \rangle ={\frac {1}{\sqrt {N}}}\sum _{x=0}^{N-1}{|x\rangle },}
which is the state of the second register after the Hadamard transform.
Geometric visualization of Grover's algorithm shows that in the two-dimensional space spanned by
|
α
⟩
{\displaystyle |\alpha \rangle }
and
|
β
⟩
{\displaystyle |\beta \rangle }
, the Grover operator is a counterclockwise rotation; hence, it can be expressed as
G
=
[
cos
θ
−
sin
θ
sin
θ
cos
θ
]
{\displaystyle G={\begin{bmatrix}\cos \theta &-\sin \theta \\\sin \theta &\cos \theta \end{bmatrix}}}
in the orthonormal basis
{
|
α
⟩
,
|
β
⟩
}
{\displaystyle \{|\alpha \rangle ,|\beta \rangle \}}
.: 252 : 149
From the properties of rotation matrices we know that
G
{\displaystyle G}
is a unitary matrix with the two eigenvalues
e
±
i
θ
{\displaystyle e^{\pm i\theta }}
.: 253
= Estimating the value of θ
=From here onwards, we follow the quantum phase estimation algorithm scheme: we apply controlled Grover operations followed by inverse quantum Fourier transform; and according to the analysis, we will find the best
p
{\displaystyle p}
-bit approximation to the real number
θ
{\displaystyle \theta }
(belonging to the eigenvalues
e
±
i
θ
{\displaystyle e^{\pm i\theta }}
of the Grover operator) with probability higher than
4
π
2
{\displaystyle {\frac {4}{\pi ^{2}}}}
.: 348 : 157
Note that the second register is actually in a superposition of the eigenvectors of the Grover operator (while in the original quantum phase estimation algorithm, the second register is the required eigenvector). This means that with some probability, we approximate
θ
{\displaystyle \theta }
, and with some probability, we approximate
2
π
−
θ
{\displaystyle 2\pi -\theta }
; those two approximations are equivalent.: 224–225
= Analysis
=Assuming that the size
N
{\displaystyle N}
of the space is at least twice the number of solutions (namely, assuming that
M
≤
N
2
{\displaystyle M\leq {\tfrac {N}{2}}}
), a result of the analysis of Grover's algorithm is:: 254
sin
θ
2
=
M
N
.
{\displaystyle \sin {\frac {\theta }{2}}={\sqrt {\frac {M}{N}}}.}
Thus, if we find
θ
{\displaystyle \theta }
, we can also find the value of
M
{\displaystyle M}
(because
N
{\displaystyle N}
is known).
The error
|
Δ
M
|
N
=
|
sin
2
(
θ
+
Δ
θ
2
)
−
sin
2
(
θ
2
)
|
{\displaystyle {\frac {\vert \Delta M\vert }{N}}=\left\vert \sin ^{2}\left({\frac {\theta +\Delta \theta }{2}}\right)-\sin ^{2}\left({\frac {\theta }{2}}\right)\right\vert }
is determined by the error within estimation of the value of
θ
{\displaystyle \theta }
. The quantum phase estimation algorithm finds, with high probability, the best
p
{\displaystyle p}
-bit approximation of
θ
{\displaystyle \theta }
; this means that if
p
{\displaystyle p}
is large enough, we will have
Δ
θ
≈
0
{\displaystyle \Delta \theta \approx 0}
, hence
|
Δ
M
|
≈
0
{\displaystyle \vert \Delta M\vert \approx 0}
.: 263
Uses
= Grover's search algorithm for an initially-unknown number of solutions
=In Grover's search algorithm, the number of iterations that should be done is
π
4
N
M
{\displaystyle {\frac {\pi }{4}}{\sqrt {\frac {N}{M}}}}
.: 254 : 150
Thus, if
N
{\displaystyle N}
is known and
M
{\displaystyle M}
is calculated by the quantum counting algorithm, the number of iterations for Grover's algorithm is easily calculated.
= Speeding up NP-complete problems
=The quantum counting algorithm can be used to speed up solution to problems which are NP-complete.
An example of an NP-complete problem is the Hamiltonian cycle problem, which is the problem of determining whether a graph
G
=
(
V
,
E
)
{\displaystyle G=(V,E)}
has a Hamiltonian cycle.
A simple solution to the Hamiltonian cycle problem is checking, for each ordering of the vertices of
G
{\displaystyle G}
, whether it is a Hamiltonian cycle or not. Searching through all the possible orderings of the graph's vertices can be done with quantum counting followed by Grover's algorithm, achieving a speedup of the square root, similar to Grover's algorithm.: 264 This approach finds a Hamiltonian cycle (if exists); for determining whether a Hamiltonian cycle exists, the quantum counting algorithm itself is sufficient (and even the quantum existence algorithm, described below, is sufficient).
= Quantum existence problem
=Quantum existence problem is a special case of quantum counting where we do not want to calculate the value of
M
{\displaystyle M}
, but we only wish to know whether
M
≠
0
{\displaystyle M\neq 0}
or not.: 147
A trivial solution to this problem is directly using the quantum counting algorithm: the algorithm yields
M
{\displaystyle M}
, so by checking whether
M
≠
0
{\displaystyle M\neq 0}
we get the answer to the existence problem. This approach involves some overhead information because we are not interested in the value of
M
{\displaystyle M}
. Quantum phase estimation can be optimized to eliminate this overhead.: 148
If you are not interested in the control of error probability then using a setup with small number of qubits in the upper register will not produce an accurate estimation of the value of
θ
{\displaystyle \theta }
, but will suffice to determine whether
M
{\displaystyle M}
equals zero or not.: 263
= Quantum relation testing problem
=Quantum relation testing
Q
R
T
(
v
a
l
u
e
,
r
e
l
a
t
i
o
n
)
{\displaystyle QRT(value,relation)}
. is an extension of quantum existence testing, it decides whether at least one entry can be found in the data base which fulfils the relation to a certain reference value. E.g.
Q
R
T
(
5
,
>
)
{\displaystyle QRT(5,>)}
gives back YES if the data base contains any value larger than 5 else it returns NO. Quantum relation testing combined with classical logarithmic search forms an efficient quantum min/max searching algorithm. : 152
See also
Quantum phase estimation algorithm
Grover's algorithm
Counting problem (complexity)
References
Kata Kunci Pencarian:
- Daftar algoritme
- Quantum counting algorithm
- Quantum algorithm
- Quantum phase estimation algorithm
- Grover's algorithm
- Shor's algorithm
- Post-quantum cryptography
- Variational quantum eigensolver
- Deutsch–Jozsa algorithm
- HHL algorithm
- Quantum optimization algorithms