函数是二对一还是一对一:Simon Algorithm

Posted 元之田

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了函数是二对一还是一对一:Simon Algorithm相关的知识,希望对你有一定的参考价值。

问题:判断一个函数是一对一还是二对一?

  • 一对一,函数的输出由唯一的输入得到。
    f ( 1 ) → 1 , f ( 2 ) → 2 , f ( 3 ) → 3 , f ( 4 ) → 4 f(1) \\rightarrow 1, \\quad f(2) \\rightarrow 2, \\quad f(3) \\rightarrow 3, \\quad f(4) \\rightarrow 4 f(1)1,f(2)2,f(3)3,f(4)4
  • 二对一,函数的输出可由两个不同的输入得到。
    f ( 1 ) → 1 , f ( 2 ) → 2 , f ( 3 ) → 1 , f ( 4 ) → 2 f(1) \\rightarrow 1, \\quad f(2) \\rightarrow 2, \\quad f(3) \\rightarrow 1, \\quad f(4) \\rightarrow 2 f(1)1,f(2)2,f(3)1,f(4)2
    given  x 1 , x 2 : f ( x 1 ) = f ( x 2 ) it is guaranteed  : x 1 ⊕ x 2 = b \\textrmgiven x_1,x_2: \\quad f(x_1) = f(x_2) \\\\ \\textrmit is guaranteed : \\quad x_1 \\oplus x_2 = b given x1,x2:f(x1)=f(x2)it is guaranteed :x1x2=b

给定函数f(x),如何快速判断其是一对一还是二对一函数?

解法:

Where the query function, Q f \\textQ_f Qfacts on two quantum registers as:

∣ x ⟩ ∣ a ⟩ → ∣ x ⟩ ∣ a ⊕ f ( x ) ⟩ \\lvert x \\rangle \\lvert a \\rangle \\rightarrow \\lvert x \\rangle \\lvert a \\oplus f(x) \\rangle xaxaf(x)
In the specific case that the second register is in the state ∣ 0 ⟩ = ∣ 00 … 0 ⟩ |0\\rangle = |00\\dots0\\rangle 0=000 we have:

∣ x ⟩ ∣ 0 ⟩ → ∣ x ⟩ ∣ f ( x ) ⟩ \\lvert x \\rangle \\lvert 0 \\rangle \\rightarrow \\lvert x \\rangle \\lvert f(x) \\rangle x0xf(x)

算法:

  1. Two n-qubit input registers are initialized to the zero state:

    ∣ ψ 1 ⟩ = ∣ 0 ⟩ ⊗ n ∣ 0 ⟩ ⊗ n \\lvert \\psi_1 \\rangle = \\lvert 0 \\rangle^\\otimes n \\lvert 0 \\rangle^\\otimes n ψ1=0n0n

  2. Apply a Hadamard transform to the first register:

    ∣ ψ 2 ⟩ = 1 2 n ∑ x ∈ 0 , 1 n ∣ x ⟩ ∣ 0 ⟩ ⊗ n \\lvert \\psi_2 \\rangle = \\frac1\\sqrt2^n \\sum_x \\in \\0,1\\^n \\lvert x \\rangle\\lvert 0 \\rangle^\\otimes n ψ2=2n 1x0,1nx0n

  3. Apply the query function Q f : ∣ ψ 3 ⟩ = 1 2 n ∑ x ∈ 0 , 1 n ∣ x ⟩ ∣ f ( x ) ⟩ \\textQ_f:\\lvert \\psi_3 \\rangle = \\frac1\\sqrt2^n \\sum_x \\in \\0,1\\^n \\lvert x \\rangle \\lvert f(x) \\rangle Qf:ψ3=2n 1x0,1nxf(x)

  4. Measure the second register. A certain value of f(x) will be observed. Because of the setting of the problem, the observed value f(x) could correspond to two possible inputs: x and y = x ⊕ b x \\oplus b xb.
    Therefore the first register becomes: ∣ ψ 4 ⟩ = 1 2 ( ∣ x ⟩ + ∣ y ⟩ ) \\lvert \\psi_4 \\rangle =\\frac1\\sqrt2 \\left( \\lvert x \\rangle + \\lvert y \\rangle \\right) ψ4=2 1(x+y)
    这里的x和y对应得到同一输出的不同输入,通过x和y表示所有状态的叠加态。

  5. Apply Hadamard on the first register: ∣ ψ 5 ⟩ = 1 2 n + 1 ∑ z ∈ 0 , 1 n [ ( − 1 ) x ⋅ z + ( − 1 ) y ⋅ z ] ∣ z ⟩ \\lvert \\psi_5 \\rangle = \\frac1\\sqrt2^n+1 \\sum_z \\in \\0,1\\^n \\left[ (-1)^x \\cdot z + (-1)^y \\cdot z \\right] \\lvert z \\rangle ψ5=2n+1 1z0,1n[(1)xz+(1)yz]z
    Measuring the first register will give an output only if: ( − 1 ) x ⋅ z = ( − 1 ) y ⋅ z (-1)^x \\cdot z = (-1)^y \\cdot z (1)xz=(1)yz

    which means: x ⋅ z = y ⋅ z x ⋅ z = ( x ⊕ b ) ⋅ z x ⋅ z = x ⋅ z ⊕ b ⋅ z b ⋅ z = 0  (mod 2) x \\cdot z = y \\cdot z \\\\ x \\cdot z = \\left( x \\oplus b \\right) \\cdot z \\\\ x \\cdot z = x \\cdot z \\oplus b \\cdot z \\\\ b \\cdot z = 0 \\text (mod 2) xz=yzxz=(xb)zxz=xzbzbz=0 (mod 2)

6.重复运行算法 ≈ n \\approx n n 次, we will be able to obtain n different values of z and the following system of equation can be written: b ⋅ z 1 = 0

以上是关于函数是二对一还是一对一:Simon Algorithm的主要内容,如果未能解决你的问题,请参考以下文章

Simon Algorithm

某公司的U3D笔试题

javaScriptWebAPI-03

一对一关系还是使用同一张表?

Service 和 DAO 之间的关系应该是一对一还是一对多?

金第123篇 一对一视频录制之btnStartRecording.onclick函数周三