Deutsch–Jozsa

El algoritmo de Deutsch–Jozsa resuelve el problema que es una generalización del problema anterior. Ahora tenemos una función

f:{0,1}n→{0,1} f:\left\{ 0,1 \right\} ^{n} \rightarrow \left\{ 0,1 \right\}

Aquí {0,1}n\left\{ 0,1 \right\}^{n} es el conjunto de todos los posibles vectores binarios de longitud nn. Nos interesa la misma pregunta, saber si nuestra función es balanceada o constante.

Es decir, si f(x)f(x) es lo mismo para toda xx, o si f(x)=0f(x)=0 para la mitad de entradas y f(x)=1f(x)=1 para la otra mitad.

Pensemos en el caso más simple, veamos qué pasa con el entero más pequeño que no sea 1.

f:{0,1}2→{0,1} f:\left\{ 0,1 \right\}^{2}\rightarrow \left\{ 0,1 \right\}

Nuestras posibles entradas son {00}\left\{ 00 \right\}, {01}\left\{ 01 \right\}, {10}\left\{ 10 \right\}, {11}\left\{ 11 \right\}.

Observamos que tenemos 222^{2} posibles entradas; el peor de los casos es que nuestras primeras dos entradas, supongamos, sin pérdida de generalidad, que {00}\left\{ 00 \right\} y {01}\left\{ 01 \right\}, nos devuelven 00. Aquí aún no podríamos decir con certeza que la función es constante porque podría ser que nuestra tercer entrada nos de 11. Entonces, en el peor de los caos tendríamos que hacer (numero de mitad de entradas + 1)\text{(numero de mitad de entradas + 1)} evaluaciones.

De nuevo, tomando ventaja de la superposición cuántica y la interferencia, el algoritmo de Deutsch–Jozsa nos dice si ff es constante o balanceada haciendo una única pregunta/evaluación.

Análogamente tendríamos que definir la operación cuántica:

Uf:∣x⟩∣y⟩→∣x⟩∣y⊕f(x)⟩ U_{f}:\ket{\mathbf{x}}\ket{y} \rightarrow \ket{\mathbf{x}}\ket{y \oplus f(x)}

donde x\mathbf{x} ahora es una cadena de nn-bits.

Ahora, donde antes teníamos que: algoritmo

Ahora tendremos: dj

Por lo tanto, empezamos en el estado

∣ψ0⟩=∣0⟩⊗n(∣0⟩−∣1⟩2) \ket{\psi_{0}}=\ket{0} ^{\otimes n}\left( \frac{\ket{0}-\ket{1}}{\sqrt{ 2 }} \right)

lo primero que tenemos que ver es qué pasa cuando hacemos H⊗n∣0⟩⊗nH^{\otimes n}\ket{0}^{\otimes n}. Recordamos que H∣0⟩=∣0⟩+∣1⟩2H\ket{0}=\frac{\ket{0}+\ket{1}}{\sqrt{ 2 }}, entonces, como ejemplo tendríamos:

H⊗2∣0⟩⊗2=H∣0⟩H∣0⟩=(∣0⟩+∣1⟩2)⊗(∣0⟩+∣1⟩2)=12(∣0⟩+∣1⟩)⊗(∣0⟩+∣1⟩)=12(∣00⟩+∣01⟩+∣10⟩+∣11⟩) \begin{aligned} H^{\otimes_{2}}\ket{0}^{\otimes_{2}} &= H\ket{0} H\ket{0} \\ &=\left( \frac{\ket{0}+\ket{1}}{\sqrt{ 2 }} \right)\otimes \left( \frac{\ket{0}+\ket{1}}{\sqrt{ 2 }} \right) \\ &= \frac{1}{2}(\ket{0}+\ket{1} )\otimes(\ket{0}+\ket{1} ) \\ &= \frac{1}{2}(\ket{00}+\ket{01}+\ket{10}+\ket{11} ) \end{aligned}

como podemos ver, son todas las posibles combinaciones de dos bits.

Si n=3n=3 tendríamos que

H∣0⟩H∣0⟩H∣0⟩=123(∣0⟩+∣1⟩)⊗(∣0⟩+∣1⟩)⊗(∣0⟩+∣1⟩) H\ket{0}H\ket{0}H\ket{0} = \frac{1}{\sqrt{ 2^{3} }}(\ket{0}+\ket{1} )\otimes(\ket{0}+\ket{1} )\otimes(\ket{0}+\ket{1} )

Entonces, tendríamos algo así

H⊗n∣0⟩⊗n=H∣0⟩⊗⋯⊗H∣0⟩=12n∑x∈{0,1}n∣x⟩ \begin{aligned} H^{\otimes n}\ket{0}^{\otimes n} &= H\ket{0} \otimes \dots \otimes H\ket{0} \\ &= \frac{1}{\sqrt{ 2^{n} }} \sum_{\mathbf{x}\in \left\{ 0,1 \right\}^{n} } \ket{\mathbf{x}} \end{aligned}

Por lo tanto, el siguiente estado al estado inicial sería

∣ψ1⟩=12n∑x∈{0,1}n∣x⟩(∣0⟩−∣1⟩2) \ket{\psi_{1}} = \frac{1}{\sqrt{ 2^{n} }}\sum_{\mathbf{x \in \left\{ 0,1 \right\}^{n} }} \ket{\mathbf{x}} \left( \frac{\ket{0}-\ket{1}}{\sqrt{ 2 }} \right)

y siguiendo con el algoritmo, tendríamos que

∣ψ2⟩=12nUf(∑x∈{0,1}n∣x⟩(∣0⟩−∣1⟩2)) \ket{\psi_{2}}= \frac{1}{\sqrt{ 2^{n} }}U_{f}\left( \sum_{\mathbf{x \in \left\{ 0,1 \right\}^{n} }} \ket{\mathbf{x}} \left( \frac{\ket{0}-\ket{1}}{\sqrt{ 2 }} \right) \right)


En la entrada anterior se vio detenidamente que

Uf:∣x⟩(∣0⟩−∣1⟩2)→(−1)f(x)∣x⟩(∣0⟩−∣1⟩2) U_{f}:\ket{x}\left( \frac{\ket{0}-\ket{1}}{\sqrt{ 2 }} \right) \rightarrow (-1)^{f(x)}\ket{x}\left( \frac{\ket{0}-\ket{1}}{\sqrt{ 2 }} \right)

Por lo anterior, tenemos entonces

∣ψ2⟩=12n∑x∈{0,1}n(−1)f(x)∣x⟩(∣0⟩−∣1⟩2) \ket{\psi_{2}} = \frac{1}{\sqrt{ 2^{n} }}\sum_{\mathbf{x \in \left\{ 0,1 \right\}^{n} }}(-1)^{f(\mathbf{x})}\ket{\mathbf{x}}\left( \frac{\ket{0}-\ket{1}}{\sqrt{ 2 }} \right)

Ahora, tendríamos que aplicar H⊗n∣x⟩H^{\otimes n}\ket{\mathbf{x}} según nuestro circuito. Primero veamos que para un estado base ∣x⟩\ket{x} tendríamos:

H∣x⟩=12(∣0⟩+(−1)x∣1⟩)=12∑z∈{0,1}(−1)xz∣z⟩ \begin{aligned} H\ket{x} &= \frac{1}{\sqrt{ 2 }}(\ket{0} + (-1)^{x}\ket{1} ) \\ &= \frac{1}{\sqrt{ 2 }}\sum_{z \in \left\{ 0,1 \right\} } (-1)^{xz}\ket{z} \end{aligned}

Entonces, tendríamos que (aquí se pone fea la cosa):

H⊗n∣x⟩=H⊗n(∣x1⟩∣x2⟩…∣xn⟩)=H∣x1⟩H∣x2⟩…H∣xn⟩=12(∣0⟩+(−1)x1∣1⟩)12(∣0⟩+(−1)x2∣1⟩)…12(∣0⟩+(−1)xn∣1⟩)=12∑z1∈{0,1}(−1)x1z1∣z1⟩12∑z2∈{0,1}(−1)x2z2∣z2⟩…12∑zn∈{0,1}(−1)xnzn∣zn⟩=12n∑z1z2…zn∈{0,1}n(−1)x1z1+x2z2+⋯+xnzn∣z1⟩∣z2⟩…∣zn⟩=12n∑z∈{0,1}n(−1)x⋅z∣z⟩ \begin{aligned} H^{\otimes n}\ket{\mathbf{x}}&=H^{\otimes n}(\ket{x_{1}}\ket{x_{2}}\dots \ket{x_{n}} ) \\ &= H\ket{x_{1}}H\ket{x_{2}}\dots H\ket{x_{n}} \\ &= \frac{1}{\sqrt{ 2 }}(\ket{0} + (-1)^{x_{1}}\ket{1} )\frac{1}{\sqrt{ 2 }}(\ket{0} + (-1)^{x_{2}}\ket{1} )\dots\frac{1}{\sqrt{ 2 }}(\ket{0} + (-1)^{x_{n}}\ket{1} ) \\ &=\frac{1}{\sqrt{ 2 }}\sum_{z_{1} \in \left\{ 0,1 \right\} } (-1)^{x_{1}z_{1}}\ket{z_{1}} \frac{1}{\sqrt{ 2 }}\sum_{z_{2} \in \left\{ 0,1 \right\} } (-1)^{x_{2}z_{2}}\ket{z_{2}}\dots \frac{1}{\sqrt{ 2 }}\sum_{z_{n} \in \left\{ 0,1 \right\} } (-1)^{x_{n}z_{n}}\ket{z_{n}} \\ &=\frac{1}{\sqrt{ 2^{n} }}\sum_{z_{1}z_{2}\dots z_{n}\in \left\{ 0,1 \right\} ^{n}}(-1)^{x_{1}z_{1}+x_{2}z_{2}+\dots+x_{n}z_{n}}\ket{z_{1}} \ket{z_{2}} \dots \ket{z_{n}} \\ &= \frac{1}{\sqrt{ 2^{n} }}\sum_{\mathbf{z}\in \left\{ 0,1 \right\}^{n} }(-1)^{\mathbf{x}\cdot \mathbf{z}}\ket{\mathbf{z}} \end{aligned}

Por lo tanto, ahora sí ya sabemos que nuestro siguiente estado sería:

∣ψ3⟩=(12n∑x∈{0,1}n(−1)f(x)12n∑z∈{0,1}n(−1)x⋅z∣z⟩)(∣0⟩−∣1⟩2)=12n∑z∈{0,1}n(∑x∈{0,1}n(−1)f(x)+x⋅z)∣z⟩(∣0⟩−∣1⟩2) \begin{aligned} \ket{\psi_{3}} &= \left( \frac{1}{\sqrt{ 2^{n} }}\sum_{\mathbf{x \in \left\{ 0,1 \right\}^{n} }}(-1)^{f(\mathbf{x})}\frac{1}{\sqrt{ 2^{n} }}\sum_{\mathbf{z}\in \left\{ 0,1 \right\}^{n} }(-1)^{\mathbf{x}\cdot \mathbf{z}}\ket{\mathbf{z}} \right) \left( \frac{\ket{0}-\ket{1}}{\sqrt{ 2 }} \right) \\ &= \frac{1}{2^{n}}\sum_{\mathbf{z}\in \left\{ 0, 1 \right\}^{n} }\left( \sum_{\mathbf{x \in \left\{ 0,1 \right\} ^{n}}}(-1)^{f(\mathbf{x})+\mathbf{x\cdot \mathbf{z}}} \right)\ket{\mathbf{z}}\left( \frac{\ket{0}-\ket{1}}{\sqrt{ 2 }} \right) \end{aligned}

Ahora, nuestro objetivo es analizar la amplitud asociada a cada estado base ∣z⟩\ket{\mathbf{z}} y ver cómo depende de si ff es constante o balanceada.

Analizando la suma interna

La amplitud asociada a cada ∣z⟩\ket{\mathbf{z}} viene dada por:

A(z)=∑x∈{0,1}n(−1)f(x)+x⋅z A(\mathbf{z}) = \sum_{\mathbf{x} \in \{0,1\}^n} (-1)^{f(\mathbf{x}) + \mathbf{x} \cdot \mathbf{z}}

Observamos que podemos separar el exponente:

(−1)f(x)+x⋅z=(−1)f(x)⋅(−1)x⋅z (-1)^{f(\mathbf{x}) + \mathbf{x} \cdot \mathbf{z}} = (-1)^{f(\mathbf{x})} \cdot (-1)^{\mathbf{x} \cdot \mathbf{z}}

Por lo tanto, la amplitud es:

A(z)=∑x(−1)f(x)(−1)x⋅z A(\mathbf{z}) = \sum_{\mathbf{x}} (-1)^{f(\mathbf{x})} (-1)^{\mathbf{x} \cdot \mathbf{z}}

Si ff es constante

Si f(x)=0f(\mathbf{x}) = 0 para todo x\mathbf{x}:

  • Entonces, (−1)f(x)=(−1)0=1(-1)^{f(\mathbf{x})} = (-1)^0 = 1.

  • La amplitud se convierte en:

A(z)=∑x1⋅(−1)x⋅z=∑x(−1)x⋅z A(\mathbf{z}) = \sum_{\mathbf{x}} 1 \cdot (-1)^{\mathbf{x} \cdot \mathbf{z}} = \sum_{\mathbf{x}} (-1)^{\mathbf{x} \cdot \mathbf{z}}

Sabemos que:

  • Para z=0\mathbf{z} = \mathbf{0}:

∑x(−1)x⋅0=∑x1=2n \sum_{\mathbf{x}} (-1)^{\mathbf{x} \cdot \mathbf{0}} = \sum_{\mathbf{x}} 1 = 2^n
  • Para z≠0\mathbf{z} \neq \mathbf{0}:

∑x(−1)x⋅z=0 \sum_{\mathbf{x}} (-1)^{\mathbf{x} \cdot \mathbf{z}} = 0

Por lo tanto, la amplitud es:

A(z)={2nsi z=00si z≠0 A(\mathbf{z}) = \begin{cases} 2^n & \text{si } \mathbf{z} = \mathbf{0} \\ 0 & \text{si } \mathbf{z} \neq \mathbf{0} \end{cases}

Si f(x)=1f(\mathbf{x}) = 1 para todo x\mathbf{x}:

  • Entonces, (−1)f(x)=(−1)1=−1(-1)^{f(\mathbf{x})} = (-1)^1 = -1.

  • La amplitud se convierte en:

A(z)=−∑x(−1)x⋅z A(\mathbf{z}) = -\sum_{\mathbf{x}} (-1)^{\mathbf{x} \cdot \mathbf{z}}

Siguiendo el mismo razonamiento:

A(z)={−2nsi z=00si z≠0 A(\mathbf{z}) = \begin{cases} -2^n & \text{si } \mathbf{z} = \mathbf{0} \\ 0 & \text{si } \mathbf{z} \neq \mathbf{0} \end{cases}

Entonces en ambos casos, la única amplitud no nula es para z=0\mathbf{z} = \mathbf{0}. Por lo tanto, después de la medición, siempre observaremos el estado ∣0⟩\ket{\mathbf{0}} en los primeros nn qubits si ff es constante.

Si ff es balanceada

Para una función balanceada, hay un número igual de entradas donde f(x)=0f(\mathbf{x}) = 0 y f(x)=1f(\mathbf{x}) = 1.

Dividimos la suma en dos partes:

A(z)=∑x:f(x)=0(−1)0(−1)x⋅z+∑x:f(x)=1(−1)1(−1)x⋅z=S0−S1 A(\mathbf{z}) = \sum_{\mathbf{x}: f(\mathbf{x})=0} (-1)^{0} (-1)^{\mathbf{x} \cdot \mathbf{z}} + \sum_{\mathbf{x}: f(\mathbf{x})=1} (-1)^{1} (-1)^{\mathbf{x} \cdot \mathbf{z}} = S_0 - S_1

Donde:

  • S0=∑x:f(x)=0(−1)x⋅zS_0 = \sum_{\mathbf{x}: f(\mathbf{x})=0} (-1)^{\mathbf{x} \cdot \mathbf{z}}

  • S1=∑x:f(x)=1(−1)x⋅zS_1 = \sum_{\mathbf{x}: f(\mathbf{x})=1} (-1)^{\mathbf{x} \cdot \mathbf{z}}

Como ff es balanceada:

  • El número de términos en S0S_0 y S1S_1 es 2n−12^{n-1} cada uno.

  • La suma total S0+S1=∑x(−1)x⋅zS_0 + S_1 = \sum_{\mathbf{x}} (-1)^{\mathbf{x} \cdot \mathbf{z}}.

Sabemos que:

  • Para z=0\mathbf{z} = \mathbf{0}:

S0+S1=2n ⟹ S0=S1=2n−1 S_0 + S_1 = 2^{n} \implies S_0 = S_1 = 2^{n-1}

Entonces, A(0)=S0−S1=0A(\mathbf{0}) = S_0 - S_1 = 0.

  • Para z≠0\mathbf{z} \neq \mathbf{0}:

S0+S1=0 ⟹ S0=−S1 S_0 + S_1 = 0 \implies S_0 = -S_1

Entonces, A(z)=S0−S1=2S0A(\mathbf{z}) = S_0 - S_1 = 2S_0.

Sin embargo, dado que los valores de (−1)x⋅z(-1)^{\mathbf{x} \cdot \mathbf{z}} se distribuyen uniformemente entre +1+1 y −1-1, la suma S0S_0 será cero o muy cercana a cero (dependiendo de la función específica).

Por lo que las amplitudes A(z)A(\mathbf{z}) son cero para z=0\mathbf{z} = \mathbf{0}, y para z≠0\mathbf{z} \neq \mathbf{0} pueden ser diferentes de cero. Esto significa que, después de la medición, es altamente improbable (o imposible en el caso ideal) observar ∣0⟩\ket{\mathbf{0}} en los primeros nn qubits cuando ff es balanceada.

Interpretación de la medición

Después de la medición:

  • Si obtenemos z=0\mathbf{z} = \mathbf{0} en los primeros nn qubits, concluimos que ff es constante.

  • Si obtenemos cualquier otro valor de z\mathbf{z} distinto de 0\mathbf{0}, concluimos que ff es balanceada.