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:xyxyf(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=0n(012) \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 Hn0nH^{\otimes n}\ket{0}^{\otimes n}. Recordamos que H0=0+12H\ket{0}=\frac{\ket{0}+\ket{1}}{\sqrt{ 2 }}, entonces, como ejemplo tendríamos:

H202=H0H0=(0+12)(0+12)=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

H0H0H0=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í

Hn0n=H0H0=12nx{0,1}nx \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=12nx{0,1}nx(012) \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}nx(012)) \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(012)(1)f(x)x(012) 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=12nx{0,1}n(1)f(x)x(012) \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 HnxH^{\otimes n}\ket{\mathbf{x}} según nuestro circuito. Primero veamos que para un estado base x\ket{x} tendríamos:

Hx=12(0+(1)x1)=12z{0,1}(1)xzz \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):

Hnx=Hn(x1x2xn)=Hx1Hx2Hxn=12(0+(1)x11)12(0+(1)x21)12(0+(1)xn1)=12z1{0,1}(1)x1z1z112z2{0,1}(1)x2z2z212zn{0,1}(1)xnznzn=12nz1z2zn{0,1}n(1)x1z1+x2z2++xnznz1z2zn=12nz{0,1}n(1)xzz \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=(12nx{0,1}n(1)f(x)12nz{0,1}n(1)xzz)(012)=12nz{0,1}n(x{0,1}n(1)f(x)+xz)z(012) \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)+xz 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)+xz=(1)f(x)(1)xz (-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)xz 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)xz=x(1)xz 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)x0=x1=2n \sum_{\mathbf{x}} (-1)^{\mathbf{x} \cdot \mathbf{0}} = \sum_{\mathbf{x}} 1 = 2^n
  • Para z0\mathbf{z} \neq \mathbf{0}:

x(1)xz=0 \sum_{\mathbf{x}} (-1)^{\mathbf{x} \cdot \mathbf{z}} = 0

Por lo tanto, la amplitud es:

A(z)={2nsi z=00si z0 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)xz A(\mathbf{z}) = -\sum_{\mathbf{x}} (-1)^{\mathbf{x} \cdot \mathbf{z}}

Siguiendo el mismo razonamiento:

A(z)={2nsi z=00si z0 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)xz+x:f(x)=1(1)1(1)xz=S0S1 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)xzS_0 = \sum_{\mathbf{x}: f(\mathbf{x})=0} (-1)^{\mathbf{x} \cdot \mathbf{z}}

  • S1=x:f(x)=1(1)xzS_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 2n12^{n-1} cada uno.

  • La suma total S0+S1=x(1)xzS_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=2n1 S_0 + S_1 = 2^{n} \implies S_0 = S_1 = 2^{n-1}

Entonces, A(0)=S0S1=0A(\mathbf{0}) = S_0 - S_1 = 0.

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

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

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

Sin embargo, dado que los valores de (1)xz(-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 z0\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.