B-V算法
(1) 问题描述
给定布尔函数
f
:
{
0
,
1
}
n
→
0
,
1
f:{\left\{ {0,1} \right\}^n} \to{0,1}
f:{0,1}n→0,1, 函数
f
f
f的值是由输入比特串
x
x
x和确定的比特串
s
s
s做模2意义下的内积:
f
(
x
)
=
x
⋅
s
(
m
o
d
2
)
,
f\left( x \right) = x \cdot s\left( {\bmod 2} \right),
f(x)=x⋅s(mod2),其中
x
⋅
s
=
∑
i
(
x
i
⊕
s
i
)
x \cdot s = \sum\limits_i {\left( {{x_i} \oplus {s_i}} \right)}
x⋅s=i∑(xi⊕si)
前提:可以调用访问函数
f
f
f的黑盒
问题:计算出比特串
s
s
s
经典意义下:
依次输入比特串
x
x
x:
00...00
00...01
00...10
.
.
.
01...00
10...00
\begin{array}{l} 00...00\\ 00...01\\ 00...10\\ ...\\ 01...00\\ 10...00 \end{array}
00...0000...0100...10...01...0010...00
对于第
i
i
i次输入:
000100...00
→
x
⋅
s
(
m
o
d
2
)
=
s
i
000100...00 \to x \cdot s\left( {\bmod 2} \right) = {s_i}
000100...00→x⋅s(mod2)=si
重复该流程
n
n
n次,即可确定比特串
s
s
s,上述方法的查询复杂度为
O
(
n
)
O\left( n \right)
O(n)
(2) 量子算法核心思路:
基础知识: H ⊗ n ∣ s ⟩ = 1 2 n 2 ∑ x ( − 1 ) s ⋅ x ∣ x ⟩ H^{\otimes n}|s\rangle=\frac{1}{2^{\frac{n}{2}}} \sum_{x}(-1)^{s \cdot x}|x\rangle H⊗n∣s⟩=22n1∑x(−1)s⋅x∣x⟩
Step1:制备初始量子比特
∣
Φ
0
⟩
=
∣
0
⟩
⊗
n
\left| {{\Phi _0}} \right\rangle ={\left| 0 \right\rangle ^{ \otimes n}}
∣Φ0⟩=∣0⟩⊗n
Step2:作用
H
⊗
n
{H^{ \otimes n}}
H⊗n,得到量子态
∣
Φ
0
⟩
=
1
2
n
2
∑
x
∣
x
⟩
\left| {{\Phi _0}} \right\rangle = \frac{1}{{{2^{\frac{n}{2}}}}}\sum\limits_x {|x\rangle }
∣Φ0⟩=22n1x∑∣x⟩
Step3:作用量子黑盒
O
f
{O_f}
Of,
O
f
:
∣
x
⟩
→
(
−
1
)
x
⋅
s
∣
x
⟩
{O_f}:\left| x \right\rangle \to {\left( { - 1} \right)^{x \cdot s}}\left| x \right\rangle
Of:∣x⟩→(−1)x⋅s∣x⟩,此时系统状态为
∣
Φ
1
⟩
=
1
2
n
2
∑
x
(
−
1
)
s
⋅
x
∣
x
⟩
\left| {{\Phi _1}} \right\rangle = \frac{1}{{{2^{\frac{n}{2}}}}}\sum\limits_x {{{\left( { - 1} \right)}^{s \cdot x}}|x\rangle }
∣Φ1⟩=22n1x∑(−1)s⋅x∣x⟩
Step4:作用
H
⊗
n
{H^{ \otimes n}}
H⊗n,系统状态变为
∣
s
⟩
|s\rangle
∣s⟩
此时测量量子系统即可得到比特串
s
s
s,该算法的查询复杂为
O
(
1
)
O(1)
O(1)
备注:上述量子黑盒 O f O_f Of的实现方法与Deutsh算法相似,具体方法如下
(1) 制备量子态
∣
Ψ
0
⟩
=
∣
0
⟩
n
∣
1
⟩
\left| {{\Psi _0}} \right\rangle = {\left| 0 \right\rangle ^n}\left| 1 \right\rangle
∣Ψ0⟩=∣0⟩n∣1⟩
(2) 作用
H
⊗
n
{H^{ \otimes n}}
H⊗n,量子系统变为
∣
Ψ
1
⟩
=
1
2
n
2
∑
x
∣
x
⟩
∣
−
⟩
\left| {{\Psi _1}} \right\rangle = \frac{1}{{{2^{\frac{n}{2}}}}}\sum\limits_x {|x\rangle } \left| - \right\rangle
∣Ψ1⟩=22n1x∑∣x⟩∣−⟩
(3) 作用
U
f
:
∣
x
⟩
∣
y
⟩
→
∣
x
⟩
∣
y
⊕
f
(
x
)
⟩
U_f:\left|x\right\rangle\left|y\right\rangle \to\left|x\right\rangle\left|y\oplus f\left( x \right)\right\rangle
Uf:∣x⟩∣y⟩→∣x⟩∣y⊕f(x)⟩,量子系统演变为
∣
Ψ
2
⟩
=
1
2
n
2
∑
x
∣
x
⟩
1
2
1
2
(
∣
0
⊕
f
(
x
)
⟩
−
∣
1
⊕
f
(
x
)
⟩
)
\left| {{\Psi _2}} \right\rangle = \frac{1}{{{2^{\frac{n}{2}}}}}\sum\limits_x {|x\rangle } \frac{1}{{{2^{\frac{1}{2}}}}}\left( {\left| {0 \oplus f\left( x \right)} \right\rangle - \left| {1 \oplus f\left( x \right)} \right\rangle } \right)
∣Ψ2⟩=22n1x∑∣x⟩2211(∣0⊕f(x)⟩−∣1⊕f(x)⟩)
当
f
(
x
)
=
0
{f\left( x \right)}=0
f(x)=0时,
∣
x
⟩
1
2
1
2
(
∣
0
⊕
f
(
x
)
⟩
−
∣
1
⊕
f
(
x
)
⟩
)
=
∣
x
⟩
1
2
1
2
(
∣
0
⟩
−
∣
1
⟩
)
=
∣
x
⟩
∣
−
⟩
\left|x\right\rangle \frac{1}{{{2^{\frac{1}{2}}}}}\left( {\left| {0 \oplus f\left( x \right)} \right\rangle - \left| {1 \oplus f\left( x \right)} \right\rangle } \right) = |x\rangle \frac{1}{{{2^{\frac{1}{2}}}}}\left( {\left| 0 \right\rangle - \left| 1 \right\rangle } \right) = |x\rangle \left| - \right\rangle
∣x⟩2211(∣0⊕f(x)⟩−∣1⊕f(x)⟩)=∣x⟩2211(∣0⟩−∣1⟩)=∣x⟩∣−⟩
当
f
(
x
)
=
1
{f\left( x \right)}=1
f(x)=1时,
∣
x
⟩
1
2
1
2
(
∣
0
⊕
f
(
x
)
⟩
−
∣
1
⊕
f
(
x
)
⟩
)
=
∣
x
⟩
1
2
1
2
(
∣
0
⟩
−
∣
1
⟩
)
=
−
∣
x
⟩
∣
−
⟩
\left|x\right\rangle \frac{1}{{{2^{\frac{1}{2}}}}}\left( {\left| {0 \oplus f\left( x \right)} \right\rangle - \left| {1 \oplus f\left( x \right)} \right\rangle } \right) = |x\rangle \frac{1}{{{2^{\frac{1}{2}}}}}\left( {\left| 0 \right\rangle - \left| 1 \right\rangle } \right) = -|x\rangle \left| - \right\rangle
∣x⟩2211(∣0⊕f(x)⟩−∣1⊕f(x)⟩)=∣x⟩2211(∣0⟩−∣1⟩)=−∣x⟩∣−⟩
不难发现
U
f
U_f
Uf的作用为:
∣
x
⟩
∣
−
⟩
→
(
−
1
)
f
(
x
)
∣
x
⟩
∣
−
⟩
=
(
−
1
)
s
⋅
x
∣
x
⟩
∣
−
⟩
|x\rangle \left| - \right\rangle \to {\left( { - 1} \right)^{f\left( x \right)}}|x\rangle \left| - \right\rangle={\left( { - 1} \right)^{s \cdot x}}|x\rangle \left| - \right\rangle
∣x⟩∣−⟩→(−1)f(x)∣x⟩∣−⟩=(−1)s⋅x∣x⟩∣−⟩
舍弃掉最后一个量子比特(辅助比特)
∣
−
⟩
\left| - \right\rangle
∣−⟩,即实现了Step3中的黑盒
O
f
O_f
Of
参考资料
[1] Bernstein-Vazirani Algorithm 学习笔记
[2] 量子计算【算法篇】第7章 Deutsch-Josza算法及实现
(3) 由 Fourier Sampling 到 Deutsch-Jozsa Algorithm & Bernstein-Vazirani Algorithm