zoukankan      html  css  js  c++  java
  • Deutsch-Josza 算法

    Deutsch 算法

    已知函数 (f:{0, 1} o {0,1}) ,问是否满足 (f(0)=f(1))

    问题等价于询问 (f(0)odot f(1)=overline{f(0)oplus f(1)}) 的值

    假定量子电路输入为 (left|x,y ight>) ,输出为 (left|x,yoplus f(x) ight>)

    先考虑一个简单的情况:(f(x)=1-x)

    当输入 (left|x,y ight>=left|0,0 ight>) 时,输出 (left|x,yoplus f(x) ight>=left|0,1 ight>)

    当输入 (left|x,y ight>=left|0,1 ight>) 时,输出 (left|x,yoplus f(x) ight>=left|0,0 ight>)

    当输入 (left|x,y ight>=left|1,0 ight>) 时,输出 (left|x,yoplus f(x) ight>=left|1,0 ight>)

    当输入 (left|x,y ight>=left|1,1 ight>) 时,输出 (left|x,yoplus f(x) ight>=left|1,1 ight>)

    现在我们将 (left|x ight>) 处于叠加态,令 (left|x ight>={1over sqrt 2}(left|0 ight>-left|1 ight>)=left|+ ight>)

    此时,(f(left|x ight>)={1over sqrt 2}[f(left|0 ight>)+f(left|1 ight>)]={1over sqrt 2}(left|1 ight>+left|0 ight>)=left|+ ight>)

    故当 (left|y ight>=left|0 ight>)(left|x,yoplus f(x) ight>=left|+ ight>otimes{1over sqrt 2}(left|1 ight>+left|0 ight>)=left|+,+ ight>)

    (left|y ight>=left|1 ight>)(left|x,yoplus f(x) ight>=left|+ ight>otimes{1over sqrt 2}(left|0 ight>+left|1 ight>)=left|+,+ ight>)

    我们令 (left|y ight>) 也处于叠加态 (left|y ight>={1over sqrt 2}(left|0 ight>-left|1 ight>)=left|- ight>)

    (left|x,y ight>={1over 2}(left|00 ight>-left|01 ight>+left|10 ight>-left|11 ight>))

    (left|x,yoplus f(x) ight>={1over 2}(left|01 ight>-left|00 ight>+left|10 ight>-left|11 ight>)=-{1over 2}(left|00 ight>-left|01 ight>-left|10 ight>+left|11 ight>)=-left|-,- ight>)

    于是,我们固定输入 (left|x,y ight>=left|+,- ight>) ,分别考虑 (f(x)) 为以下四种情况时的输出:

    (f(0)=0, f(1)=0Rightarrow left|x,yoplus f(x) ight>=left|+,- ight>)

    (f(0)=0, f(1)=1Rightarrow left|x,yoplus f(x) ight>=left|-,- ight>)

    (f(0)=1, f(1)=0Rightarrow left|x,yoplus f(x) ight>=-left|-,- ight>)

    (f(0)=1, f(1)=1Rightarrow left|x,yoplus f(x) ight>=-left|+,- ight>)

    观察后不难得出,若 (f(0)=f(1)) 则输出时,第一个 qubit (即 (left|x ight>))为 (left|+ ight>)

    故我们在第一个 qubit 处增加一个 Hadamard 门,则可使得 (Hleft|+ ight>=left|0 ight>, Hleft|- ight>=left|1 ight>) 直接表示 (f(0)oplus f(1)) 的结果

    因此,我们直接测量第一个 qubit 即可得到 (f(0)oplus f(1)) 的结果,进而求解问题:是否满足 (f(0)=f(1))


    Deutsch-Josza 算法

    大名鼎鼎的 DJ 算法

    一个比特的数据很难体现出量子算法的优势,现考虑 (n) 个比特:

    已知函数 (f:{0, 1}^n o {0,1}) ,问该函数是常函数还是平衡函数。

    平衡函数:(f(x)) 关于所有 (x) 的结果一半为 (0) ,一半为 (1)

    同上文的思路,我们考虑将 (x) 的值全部置于叠加态 (left|+ ight>)(y) 的值置于叠加态 (left|- ight>)

    则输入为 (left|+ ight>^{otimes n}otimes left|- ight>)

    我们同样考虑输出为 (left|x,yoplus f(x) ight>) ,则:

    (quad left|x,y ight>)

    (displaystyle ={1over sqrt {2^{n+1}}}sum_{x=0}^{2^n-1}left|x ight>otimes (left|0 ight>-left|1 ight>))

    ( herefore left|x,yoplus f(x) ight>)

    (displaystyle ={1over sqrt {2^{n+1}}}sum_{x=0}^{2^n-1}left|x ight>otimes (left|0oplus f(x) ight>-left|1oplus f(x) ight>))

    由于 ((left|0oplus f(x) ight>-left|1oplus f(x) ight>)=egin{cases} left|0 ight>-left|1 ight>qquadqquadqquad ,f(x)=0 \ \ left|1 ight>-left|0 ight>=-(left|0 ight>-left|1 ight>), f(x)=1 end{cases}=(-1)^{f(x)}(left|0 ight>-left|1 ight>))

    代入得到:

    (quadleft|x,yoplus f(x) ight>)

    (displaystyle ={1over sqrt {2^{n+1}}}sum_{x=0}^{2^n-1}(-1)^{f(x)}left|x ight>otimes (left|0 ight>-left|1 ight>))


    这边我们按照上面的步骤,应该再次整理,然后对前 (n) 个 qubit 引入 Hadamard 门

    不过我并没有看懂那个公式

    所以我们考虑分类讨论:

    (f(x)) 为常函数时:

    (quadleft|x,yoplus f(x) ight>)

    (displaystyle ={1over sqrt {2^{n+1}}}sum_{x=0}^{2^n-1}(-1)^{f(x)}left|x ight>otimes (left|0 ight>-left|1 ight>))

    (displaystyle =(-1)^{f(x)}cdot {1over sqrt {2^{n+1}}}sum_{x=0}^{2^n-1}left|x ight>otimes (left|0 ight>-left|1 ight>))

    (displaystyle =(-1)^{f(x)}cdot left|x,y ight>)

    对前 (n) 个 qubit 引入 Hadamard 门后,为 ((-1)^{f(x)}cdot left|0 ight>^{otimes n})

    因此,我们对前 (n) 个 qubit 进行测量,由于 (p(left|0 ight>)=|pm left<0mid 0 ight>|^2=1) ,故测量概率应为 (100\%)

    而当 (f(x)) 为平衡函数时:

    根据公式 (displaystyle left|x,yoplus f(x) ight>={1over sqrt {2^{n+1}}}sum_{x=0}^{2^n-1}(-1)^{f(x)}left|x ight>otimes (left|0 ight>-left|1 ight>))

    并不会化为 (gammaleft|+ ight>^{otimes n}otimes left|- ight>,|gamma|=1) 的形式。

    即对前 (n) 个 qubit 引入 Hadamard 门后,不会化为 (gammaleft|0 ight>^{otimes n},|gamma|=1) 的形式。

    不妨设其量子状态为 (displaystyle otimes_{i=0}^{n-1} (alpha_ileft|0 ight>+eta_ileft|1 ight>),|alpha_i|^2+|eta_i|^2=1)

    则第 (i) 个 qubit 测量时,落在 (left|0 ight>) 的状态仅为 (|alpha_i|^2) ,并不一定是 (100\%)

    由于其不会化为 (gammaleft|0 ight>^{otimes n},|gamma|=1) 的形式,故至少一个 (eta_i eq 0) ,此时 (|alpha_i|^2=1-|eta_i|^2<1)

    因此,若存在某个 qubit 测量时,落在 (left|0 ight>) 的概率不为 (100\%) ,则为平衡函数。


    此时,相信量子计算的优越性已经体现了:

    该问题,使用传统算法,需要遍历所有状态的一半以上,即需要计算 ((2^{n-1}+1)) 次函数值。

    而使用量子计算,可以把所有状态叠一起算,值需要计算 (1) 次函数值,直接实现并行计算的效果。


    附录

    那个我当时看不懂的公式如下:

    (ecause left|x,yoplus f(x) ight>)

    (displaystyle ={1over sqrt {2^{n+1}}}sum_{x=0}^{2^n-1}(-1)^{f(x)}left|x ight>otimes (left|0 ight>-left|1 ight>))

    对前 (n) 个 qubit 引入 Hadamard 门,其状态如下:

    (quad left|psi ight>)

    (displaystyle ={1over 2^n}sum_{x=0}^{2^n-1}(-1)^{f(x)}[sum_{z=0}^{2^n-1}(-1)^{xcdot z}left|z ight>])

    (displaystyle ={1over 2^n}sum_{z=0}^{2^n-1}[sum_{x=0}^{2^n-1}(-1)^{f(x)}cdot (-1)^{xcdot z}]left|z ight>)

    其中 (displaystyle xcdot z=sum_{i=0}^{n-1}x_icdot z_i=x_0z_0+x_1z_1+cdots+x_{n-1}z_{n-1})

    解释一下公式:我们设使用了 (H^{otimes n}) 以后,(displaystyle H^{otimes n}:left|x ight> o{1over sqrt {2^n}}sum_{z=0}^{2^n-1}alpha_zleft|z ight>)

    现在考虑如何求解 (alpha_z)

    (left|x ight>) 的某一位 (x_i=0) 时,根据 (Hleft|x_i ight>=left|+ ight>={1over sqrt 2}({left|0 ight>+left|1 ight>})),对 (z) 的所有取值产生的所有影响都是乘 (1)

    (left|x ight>) 的某一位 (x_i=1) 时,根据 (Hleft|x_i ight>=left|- ight>={1over sqrt 2}({left|0 ight>-left|1 ight>})),对 (z_i=1) 的取值产生的影响是乘 ((-1)) ,对 (z_i=0) 的取值产生的影响是乘 (1)

    综合考虑一下:当且仅当 (x_i=1wedge z_i=1) 时,产生的影响是乘 ((-1)) ,否则都是乘 (1) ;即影响为乘上 ((-1)^{x_icdot z_i})

    因此考虑所有位置,则 (displaystyle alpha_z=prod_{i=0}^{n-1}(-1)^{x_icdot z_i}=(-1)^{displaystyle sum_{i=0}^{n-1}x_icdot z_i})

    (displaystyle sum_{i=0}^{n-1}x_icdot z_i) 类似向量内积,故直接简记为 (xcdot z)

    故直接将结果代入 (left|psi ight>) 即得到 (displaystyle ={1over 2^n}sum_{x=0}^{2^n-1}(-1)^{f(x)}[sum_{z=0}^{2^n-1}(-1)^{xcdot z}left|z ight>])

    对前 (n) 个 qubit 测量时,(displaystyle p(left|0 ight>^{otimes n})=|{1over 2^n}sum_{x=0}^{2^n-1}(-1)^{f(x)}|^2)

    只有 (z=0)((left<0 ight|^{otimes n})cdot left|z ight>=1) ,否则均正交,为 (0)
    故对被求和式代入 (z=0)(displaystyle {1over 2^n}sum_{x=0}^{2^n-1}(-1)^{f(x)}cdot (-1)^{xcdot z}={1over 2^n}sum_{x=0}^{2^n-1}(-1)^{f(x)}cdot (-1)^{xcdot z}={1over 2^n}sum_{x=0}^{2^n-1}(-1)^{f(x)})

    当且仅当 (f(x)) 为常函数时,测量概率为 (1) ;否则均是小于 (1) 的。

    并且根据题意,若 (f(x)) 不为常函数时,一定为平衡函数,故一半的 (f(x)=1) ,一半的 (f(x)=0)

    因此一半的 ((-1)^{f(x)}=-1) ,一半的 ((-1)^{f(x)}=1) , 相加后即为 (0)

    因此,平衡函数的测量概率应为 (0)

    所以只要测量到某个 qubit 为 (0) 即可直接断定不是常函数,理论上不用多次测量

  • 相关阅读:
    vbox增加磁盘
    PMP第五版第一次考试相关提醒
    PMP学习系列7:PMBOK(5th)第五章:项目范围管理
    PMP学习系列6:PMBOK(5th)第四章-项目整合管理
    Readlist & AIM1
    如何高校管理你的时间
    PMP学习系列5:PMBOK(5th)第三章-项目管理过程
    PMP学习系列4:PMBOK(5th)第二章-组织影响和项目生命周期
    沃顿商学院最受欢迎的谈判课
    PMP学习系列3:PMBOK(5th)第一章-引言
  • 原文地址:https://www.cnblogs.com/JustinRochester/p/14842877.html
Copyright © 2011-2022 走看看