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 \\textrm{given }x_1,x_2: \\quad f(x_1) = f(x_2) \\\\ \\textrm{it is guaranteed }: \\quad x_1 \\oplus x_2 = b given x1,x2:f(x1)=f(x2)it is guaranteed :x1⊕x2=b
给定函数f(x),如何快速判断其是一对一还是二对一函数?
解法:
Where the query function,
Q
f
\\text{Q}_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
∣x⟩∣a⟩→∣x⟩∣a⊕f(x)⟩
In the specific case that the second register is in the state
∣
0
⟩
=
∣
00
…
0
⟩
|0\\rangle = |00\\dots0\\rangle
∣0⟩=∣00…0⟩ we have:
∣ x ⟩ ∣ 0 ⟩ → ∣ x ⟩ ∣ f ( x ) ⟩ \\lvert x \\rangle \\lvert 0 \\rangle \\rightarrow \\lvert x \\rangle \\lvert f(x) \\rangle ∣x⟩∣0⟩→∣x⟩∣f(x)⟩
算法:
-
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⟩=∣0⟩⊗n∣0⟩⊗n
-
Apply a Hadamard transform to the first register:
∣ ψ 2 ⟩ = 1 2 n ∑ x ∈ { 0 , 1 } n ∣ x ⟩ ∣ 0 ⟩ ⊗ n \\lvert \\psi_2 \\rangle = \\frac{1}{\\sqrt{2^n}} \\sum_{x \\in \\{0,1\\}^{n} } \\lvert x \\rangle\\lvert 0 \\rangle^{\\otimes n} ∣ψ2⟩=2n1x∈{0,1}n∑∣x⟩∣0⟩⊗n
-
Apply the query function Q f : ∣ ψ 3 ⟩ = 1 2 n ∑ x ∈ { 0 , 1 } n ∣ x ⟩ ∣ f ( x ) ⟩ \\text{Q}_f:\\lvert \\psi_3 \\rangle = \\frac{1}{\\sqrt{2^n}} \\sum_{x \\in \\{0,1\\}^{n} } \\lvert x \\rangle \\lvert f(x) \\rangle Qf:∣ψ3⟩=2n1x∈{0,1}n∑∣x⟩∣f(x)⟩
-
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 x⊕b.
Therefore the first register becomes: ∣ ψ 4 ⟩ = 1 2 ( ∣ x ⟩ + ∣ y ⟩ ) \\lvert \\psi_4 \\rangle =\\frac{1}{\\sqrt{2}} \\left( \\lvert x \\rangle + \\lvert y \\rangle \\right) ∣ψ4⟩=21(∣x⟩+∣y⟩)
这里的x和y对应得到同一输出的不同输入,通过x和y表示所有状态的叠加态。 -
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 = \\frac{1}{\\sqrt{2^{n+1}}} \\sum_{z \\in \\{0,1\\}^{n} } \\left[ (-1)^{x \\cdot z} + (-1)^{y \\cdot z} \\right] \\lvert z \\rangle ∣ψ5⟩=2n+11z∈{0,1}n∑[(−1)x⋅z+(−1)y⋅z]∣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)x⋅z=(−1)y⋅zwhich 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)} x⋅z=y⋅zx⋅z=(x⊕b)⋅zx⋅z=x⋅z⊕b⋅zb⋅z=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
以上是关于Simon Algorithm的主要内容,如果未能解决你的问题,请参考以下文章