documentclass[11pt,fleqn,twoside]{article} \usepackage{cs294} \begin{document} \begin{center} {\Large \bf Lecture 2: } \end{center} \section{Tensor Products} A single quantum bit is a unit vector in the Hilbert space $\C^2$. Now suppose we have two quantum bits. How do we write them together? We need a new Hilbert space which captures the interaction of the two bits. If $V$, $W$ are vector spaces with bases $\{ v_1 \ldots v_n \}$, $\{ w_1 \ldots w_m \}$, the {\it tensor product} $V \tensor W$ of $V$ and $W$ is a $nm$-dimensional vector space which is spanned by elements of the form $v \tensor w$ - called {\it elementary tensors}. These elementary tensors behave bilinearly, that is, we have the relations $$\alpha (v\tensor w) = \alpha v \tensor w + v \tensor \alpha w$$ $$u\tensor v + w\tensor v = (u+w)\tensor v \hskip.5in u\tensor v + u \tensor w = u\tensor (v+w).$$ A basis for the tensor product space consists of the vectors: $\{ v_i \tensor w_j : 1 \leq i \leq n, 1\leq j \leq m \}$, and thus a general element of $V \tensor W$ is of the form $$\sum_{i,j}\alpha_{ij} v_i \tensor w_j$$ This definition extends analogously to tensor products with more than two terms. The tensor product space is also a Hilbert space with the inherited inner product: $$(v \tensor w , v' \tensor w' )= (v,v')(w,w')$$ As it turns out, a two bit system is conveniently represented by a unit vector in the Hilbert space $\C^2 \tensor \C^2$. As I remarked above, $\C^2 \tensor \C^2$ is necessarily isomorphic to $\C^4$ since there is only one complex four dimensional Hilbert space, but as we will see, in the world of quantum mechanics it is convenient to be able to ``construct'' the larger space from the smaller ones. Using Dirac ``ket'' notation, we write the basis of $\C^2 \tensor \C^2$ as $$\{ |0\> \tensor |0\>, |0\> \tensor |1\>, |1\> \tensor |0\>, |1\> \tensor |1\> \}$$ We will often write $|0\> \tensor |0\>$ as $|0\>|0\>$ or $|00\>$. In general, we represent an n-particle system by $n$ copies of $\C^2$ tensored together. We will often write $(\C^2)^{\tensor n} = \C^{2^n}$. So the state of an n-qubit system can be written as \[ |\psi \> = \sum_{x \in \{0,1\}^n} \alpha_x |x\>. \] This means that the state of an n-particle system is represented by a $2^n$ dimensional space! The idea behind quantum computation is to harness the ability of nature to manipulate the exponential number of $\alpha_x$s. \subsection{The Significance of Tensor Products} Classically, if we put together a subsystem that stores $k$ bits of information with one that stores $l$ bits of information, the total capacity of the composite system is $k+l$ bits. From this viewpoint, the situation with quantum systems is extremely paradoxical. We need $k$ complex numbers to describe the state of a k-level quantum system. Now consider a system that consists of a k-level subsystem and an l-level subsystem. To describe the composite system we need $kl$ complex numbers. One might wonder where nature finds the extra storage space when we put these two subsystems together. An extreme case of this phenomenon occurs when we consider an $n$ qubit quantum system. The Hilbert space associated with this system is the n-fold tensor product of ${\C}^2 \equiv {\C}^{2^n}$. Thus nature must ``remember'' of $2^n$ complex numbers to keep track of the state of an $n$ qubit system. For modest values of $n$ of a few hundred, $2^n$ is larger than estimates on the number of elementary particles in the Universe. This is the fundamental property of quantum systems that is used in quantum information processing. Finally, note that when we actually a measure an $n$-qubit quantum state, we see only an $n$-bit string - so we can recover from the system only $n$, rather than $2^n$, bits of information. \subsection{Tensor product of operators} Suppose $\ket{v}$ and $\ket{w}$ are unentangled states on $\C^m$ and $\C^n$, respectively. The state of the combined s ystem is $\ket{v}\tensor \ket{w}$ on $\C^{m n}$. If the unitary operator $A$ is applied to the first subsystem, and $B $ to the second subsystem, the combined state becomes $A\ket{v}\tensor B\ket{w}$. In general, the two subsystems will be entangled with each other, so the combined state is not a tensor-product state. We can still apply $A$ to the first subsystem and $B$ to the second subsystem. This gives the operator $A\tensor B$ o n the combined system, defined on entangled states by linearly extending its action on unentangled states. (For example, $(A \tensor B) (\ket{0} \tensor \ket{0}) = A \ket{0} \tensor B \ket{0}$. $(A \tensor B) (\ket{1} \tensor \ket{1}) = A \ket{1} \tensor B \ket{1}$. Therefore, we define $(A \tensor B) (\tfrac{1}{\sqrt{2}} \ket{00} + \tfrac{1 }{\sqrt{2}} \ket{11})$ to be $\tfrac{1}{\sqrt{2}} (A\tensor B) \ket{00} + \tfrac{1}{\sqrt{2}} (A\tensor B) \ket{11} = \ tfrac{1}{\sqrt{2}} \left( A\ket{0}\tensor B\ket{0} + A\ket{1}\tensor B\ket{1} \right)$.) Let $\ket{e_1},\ldots,\ket{e_m}$ be a basis for the first subsystem, and write $A = \sum_{i,j=1}^{m} a_{ij} \ketbra{e_i }{e_j}$ (the $i$,$j$th element of $A$ is $a_{ij}$). Let $\ket{f_1},\ldots,\ket{f_n}$ be a basis for the second subsyst em, and write $B = \sum_{k,l=1}^{n} b_{kl} \ketbra{f_k}{f_l}$. Then a basis for the combined system is $\ket{e_i}\tens or \ket{f_j}$, for $i=1,\ldots,m$ and $j=1,\ldots,n$. The operator $A \tensor B$ is \bea A \tensor B &=& \left( \sum_{ij} a_{ij} \ketbra{e_i}{e_j} \right) \tensor \left( \sum_{kl} b_{kl} \ketbra{f_k}{f_l} \ri ght) \\ &=& \sum_{ijkl} a_{ij} b_{kl} \ketbra{e_i}{e_j} \tensor \ketbra{f_k}{f_l} \\ &=& \sum_{ijkl} a_{ij} b_{kl} (\ket{e_i}\tensor\ket{f_k})(\bra{e_j}\tensor\bra{f_l}) \enspace . \eea Therefore the $(i,k),(j,l)$th element of $A \tensor B$ is $a_{ij} b_{kl}$. If we order the basis $\ket{e_i}\tensor \ke t{f_j}$ lexicographically, then the matrix for $A \tensor B$ is $$ \left(\begin{matrix} a_{11} B & a_{12} B & \cdots \\ a_{21} B & a_{22} B & \cdots \\ \vdots & \vdots & \ddots \end{matrix}\right) \enspace ; $$ in the $i,j$th subblock, we multiply $a_{ij}$ by the matrix for $B$. \subsection{Another Example: Quantum Teleportation} The \emph{No Cloning Theorem} states that no quantum system can copy a qubit; that is, there is no transform sending $|\psi\> \otimes |0\> \mapsto |\psi\> \otimes |\psi\>$. However, if we are willing to destroy the original, we can transmit a qubit, even to a remote location. Suppose $A$ has access to a quantum state $|\psi\> = a_0|0\> + a_1|1\>$, which she wants to transmit to a remote party $B$. She can accomplish this by transmitting only classical bits of information, provided $A$ and $B$ share the entangled two-qubit state \begin{displaymath} |\phi\> = \frac{1}{\sqrt{2}}(|00\>+|11\>). \end{displaymath} The technique is known as \emph{quantum teleportation.} The basic idea is this. $A$ controls $|\psi\>$ and the first qubit of $|\phi\>$. $A$'s strategy, roughly speaking, is to forcibly entangle $|\psi\>$ with the first qubit $|\phi\>$. $A$ then measures the first qubit of $|\phi\>$, resolving it completely, and hopes this will cause $|\psi\>$ to become entangled with the \emph{second} qubit of $|\phi\>$. Presumably, $B$ could then transfer $|\psi\>$ to the second qubit of $|\phi\>$. As a first try, consider the following diagram. The top line represents $|\psi\>$; the bottom two represent the two qubits of $|\phi\>$. \begin{center} \begin{picture}(200,60) % Three horizontal lines for the qubits \put (0,50){\line(1,0){200}} \put (0,30){\line(1,0){145}} \put (0,10){\line(1,0){200}} % The CNOT gate \put (50,50){\circle*{5}} \put (50,30){\circle{5}} \put (50,30){\line(0,1){20}} % The measurement \put (145,27){\framebox{M}} \end{picture} \end{center} That is, $A$ passes $|\psi\>$ and the first qubit of $|\phi\>$ through a CNOT gate, and then measures the first qubit of $|\phi\>$. Now the input into the system as a whole is \begin{displaymath} |\phi\> \otimes |\psi\> = \sum_{i=0,1} a_i|i\> \otimes \sum_{j=0,1}\frac{1}{\sqrt{2}}|j,j\>. \end{displaymath} After passing through the CNOT gate this becomes \begin{displaymath} \sum_{i,j}a_i\big|i,i\oplus j,j\big\>. \end{displaymath} Now $A$ measures the middle qubit. Suppose it is measured as $l$; then $l = i \oplus j$. The state is now \begin{displaymath} \sum_j a_{j \oplus l}\big|j \oplus l,j\big\>. \end{displaymath} Next, $A$ transmits $l$ to $B$. If $l = 0$, $B$ takes no action, while if $l = 1$, then $B$ performs a bit flip on his qubit (the bottom qubit in the diagram.) A bit flip is just the transformation $\left(\begin{array}{cc}0&1\\1&0\end{array}\right)$. Thus we have \begin{displaymath} \sum_j a_{j \oplus l}\big|j,j\big\>. \end{displaymath} Finally, $B$ does a phase flip on his qubit, yielding \begin{displaymath} \sum_j a_j\big|j,j\big\>. \end{displaymath} This is almost exactly what we want. The only problem is that now, the qubit corresponding to $|\psi\>$ is entangled with $B$'s qubit. The entanglement that was necessary to get the whole process started is now a liability. One way to disentangle them would be for $A$ to measure her remaining qubit. But this would destroy $B$'s qubit as well. The ideal solution would be to send the entangle qubits through a CNOT gate---but $A$ controls the first qubit and $B$ controls the second. This would require quantum communication between $A$ and $B$, which is prohibited. The correct solution is to go back and modify the original diagram, inserting a Hadamard gate and an additional measurement: \begin{center} \begin{picture}(200,60) % Three horizontal lines for the qubits \put (0,50){\line(1,0){95}} \put (0,30){\line(1,0){145}} \put (0,10){\line(1,0){200}} % The CNOT gate \put (50,50){\circle*{5}} \put (50,30){\circle{5}} \put (50,30){\line(0,1){20}} % The measurement \put (145,27){\framebox{M}} % Additional stuff \put (95,47){\framebox{H}} \put (109,50){\line(1,0){36}} \put (145,47){\framebox{M}} \end{picture} \end{center} Now the algorithm proceeds exactly as before. However $A$'s application of the Hadamard gate now induces the transformation \begin{displaymath} \sum_j a_j\big|j,j\big\> \longrightarrow \sum_{ij} a_j(-1)^{ij}\big|i,j\big\>. \end{displaymath} Finally $A$ measures $i$ and sends the measurement to $B$. The state is now: \begin{displaymath} \sum_j a_j(-1)^{ij}|j\>. \end{displaymath} If $i=0$ then we are done; if $i=1$ then $B$ applies a phase flip. In either case the state is now $a_0|0\> + a_1|1\>$. So $A$ has transported the quantum state to $B$ simply by sending two classical bits. \section{Reversible Computation} A quantum circuit accepts a superposition $\left| \phi\right\rangle $\ as input, performs a unitary transformation $U$\ on $\left| \phi\right\rangle $\ by composing elementary gates, and returns a new superposition $U\left( \left| \phi\right\rangle \right) $\ as output. \ Last week we saw two primitives for quantum circuits that will be used extensively in the results to follow. \ Let's briefly review them. The first primitive is a quantum circuit $U_{f}$\ that `pretends' to do classical computation, computing a classical function $f$ defined by a Boolean circuit. \ We constructed $U_{f}$ so that, whenever the input $\left| \phi\right\rangle $ is a basis state, the output $U_{f}\left( \left| \phi\right\rangle \right) $\ is also a basis state. \ Since $U_{f}$ is unitary, it follows that $U_{f}$\ induces a permutation of basis states. Now $f$ is not, in general, a permutation. \ So if we want to compute $f$ quantum-mechanically, we have to do it in a special way. \ As we saw, $U_{f}$ can accept inputs of the form $\left| x\right\rangle \left| y\right\rangle $, where the first register contains an input $x$ to $f$ and the second register contains blank space on which to write the output. \ (Recall that $\left| x\right\rangle \left| y\right\rangle $\ is shorthand for the tensor product $\left| x\right\rangle \otimes\left| y\right\rangle $.) \ The output of $U_{f}$ is then $\left| x\right\rangle \left| y\oplus f\left( x\right) \right\rangle $, where $\oplus$\ denotes bitwise XOR, and one can check that this indeed defines a permutation. \ In particular, when $y=0$, $\left| x\right\rangle \left| 0\right\rangle $\ is mapped onto $\left| x\right\rangle \left| f\left( x\right) \right\rangle $. In general, though, we don't need to feed $U_{f}$ a classical state $\left| x\right\rangle $. \ If we feed $U_{f}$ a superposition% \[% %TCIMACRO{\dsum \limits_{x\in\left\{ 0,1\right\} ^{n}}}% %BeginExpansion {\displaystyle\sum\limits_{x\in\left\{ 0,1\right\} ^{n}}} %EndExpansion \alpha_{x}\left| x\right\rangle \left| 0\right\rangle \] then, by linearity,% \[ U_{f}\bigskip\left( %TCIMACRO{\dsum \limits_{x\in\left\{ 0,1\right\} ^{n}}}% %BeginExpansion {\displaystyle\sum\limits_{x\in\left\{ 0,1\right\} ^{n}}} %EndExpansion \alpha_{x}\left| x\right\rangle \left| 0\right\rangle \right) =% %TCIMACRO{\dsum \limits_{x\in\left\{ 0,1\right\} ^{n}}}% %BeginExpansion {\displaystyle\sum\limits_{x\in\left\{ 0,1\right\} ^{n}}} %EndExpansion \alpha_{x}U_{f}\left( \left| x\right\rangle \left| 0\right\rangle \right) =% %TCIMACRO{\dsum \limits_{x\in\left\{ 0,1\right\} ^{n}}}% %BeginExpansion {\displaystyle\sum\limits_{x\in\left\{ 0,1\right\} ^{n}}} %EndExpansion \alpha_{x}\left| x\right\rangle \left| f\left( x\right) \right\rangle \] and we've computed $f\left( x\right) $\ simultaneously for each basis state $\left| x\right\rangle $\ in the superposition. The second primitive is the Hadamard transform $H$, also called the Fourier transform. \ $H$ is the unitary transformation on one qubit defined by the matrix% \[ \left( \begin{array} [c]{cc}% \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}}\\ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}}% \end{array} \right) . \] In other words, $H$ maps $\left| 0\right\rangle $\ onto $\frac{1}{\sqrt{2}% }\left| 0\right\rangle +\frac{1}{\sqrt{2}}\left| 1\right\rangle $, and $\left| 1\right\rangle $\ onto $\frac{1}{\sqrt{2}}\left| 0\right\rangle -\frac{1}{\sqrt{2}}\left| 1\right\rangle $. \ Given an $n$-qubit system, we'll often want to apply $H$ separately to each of the qubits in turn. \ We call the resulting transformation $H_{2^{n}}=H^{\otimes n}$; it equals $H$ tensored with itself $n$ times. \ For all $n>0$, $H^{\otimes n}$\ can also be defined recursively by the matrix% \[ \left( \begin{array} [c]{cc}% \frac{1}{\sqrt{2}}H^{\otimes n-1} & \frac{1}{\sqrt{2}}H^{\otimes n-1}\\ \frac{1}{\sqrt{2}}H^{\otimes n-1} & -\frac{1}{\sqrt{2}}H^{\otimes n-1}% \end{array} \right) . \] where $H^{\otimes0}=\left( \begin{array} [c]{c}% 1 \end{array} \right) $. \ (Incidentally, it is an exercise to show that for all $n\times n$ matrices $U$ and $V$, if $U$ and $V$ are unitary then the tensor product $U\otimes V$ is also unitary.) \section{The Deutsch-Jozsa Algorithm\label{dj}} The Deutsch-Jozsa algorithm was published in 1992, and provided one of the first formal indications that quantum computers can solve some problems more efficiently than classical ones. Suppose we're given a Boolean function $f:\left\{ 0,1\right\} ^{n}% \rightarrow\left\{ 0,1\right\} $. \ We're promised that $f$ is either identically zero (meaning that $f\left( x\right) =0$ for all inputs $x\in\left\{ 0,1\right\} ^{n}$), or else balanced (meaning that $f(x)=0$\ for precisely half of all inputs $x$, and $f\left( x\right) =1$\ for the other half). \ The challenge is to decide which is the case. \ To do this, we can make queries of the form ``Is $f\left( x\right) $\ equal to $1$?'' for particular values of $x$. \ Our goal is to minimize the number of queries that have to be made. Clearly, a deterministic classical algorithm requires $2^{n-1}+1$\ queries in the worst case: if $2^{n-1}$\ bits have been queried and all turned out to be $0$, we still need to query one more bit to decide whether the function is zero or balanced. On the other hand, the problem admits an efficient randomized algorithm, as follows. \ Choose a value of $x$ uniformly at random; if $f\left( x\right) =1$\ then conclude that $f$ is balanced, otherwise repeat. \ If, after $k$ iterations (for some constant $k$), we still haven't found an $x$ such that $f\left( x\right) =1$, then we halt and conclude that $f$ is zero. \ This algorithm uses only $O\left( 1\right) $\ queries. \ However, has a nonzero probability of error, equal to $2^{-k}$, or slightly less if we choose $x$ values without replacement. \ This is because, even if $f$ is balanced, the randomized algorithm has a nonzero probability of never seeing an $x$ such that $f\left( x\right) =1$. What Deutsch and Jozsa showed is that a quantum computer can decide whether $f$ is balanced, with certainty, using only two queries to $f$. \ What follows is an algorithm to accomplish this. The algorithm uses two quantum registers, the first having $n$ qubits and the second having only one qubit. \ We initialize the system to the basis state $\left| 0\cdots0\right\rangle \left| 0\right\rangle $. \ Then we apply the Hadamard transform $H_{2^{n}}$\ to the first register (or equivalently, the Hadamard transform $H$ to each qubit of the first register separately). \ This results in the superposition% \[ \frac{1}{2^{n/2}}% %TCIMACRO{\dsum \limits_{x\in\left\{ 0,1\right\} ^{n}}}% %BeginExpansion {\displaystyle\sum\limits_{x\in\left\{ 0,1\right\} ^{n}}} %EndExpansion \left| x\right\rangle \left| 0\right\rangle . \] We then compute $f\left( x\right) $\ and store the result in the second register. \ How is this done? \ If $f$ is a black-box oracle, then (by assumption) we don't need to worry about how it's done. \ If, on the other hand, $f$ is given explicitly (say, as a Boolean circuit), then we've seen that we can compute $f$ reversibly using Fredkin gates. \ In either case, the resultant superposition is% \[ \frac{1}{2^{n/2}}% %TCIMACRO{\dsum \limits_{x\in\left\{ 0,1\right\} ^{n}}}% %BeginExpansion {\displaystyle\sum\limits_{x\in\left\{ 0,1\right\} ^{n}}} %EndExpansion \left| x\right\rangle \left| f\left( x\right) \right\rangle . \] Next we apply the one-qubit transformation% \[ \left( \begin{array} [c]{cc}% 1 & 0\\ 0 & -1 \end{array} \right) \] to the second register. \ This transformation, which is easily seen to be unitary, is a ``phase flip'': if $f\left( x\right) =0$\ then it leaves the amplitude of $\left| x\right\rangle \left| f\left( x\right) \right\rangle $\ alone, whereas if $f\left( x\right) =1$\ then it inverts the amplitude. \ So we get% \[ \frac{1}{2^{n/2}}% %TCIMACRO{\dsum \limits_{x\in\left\{ 0,1\right\} ^{n}}}% %BeginExpansion {\displaystyle\sum\limits_{x\in\left\{ 0,1\right\} ^{n}}} %EndExpansion \left( -1\right) ^{f\left( x\right) }\left| x\right\rangle \left| f\left( x\right) \right\rangle . \] At this point we want to erase $f\left( x\right) $ from the second register, to allow for proper interference among the states. \ (What goes wrong if we don't erase $f\left( x\right) $\ is left as an exercise.) \ We can't do this directly, since erasure is not a unitary operation. \ But since we have an oracle for $f$, we can simply compute $f$ a second time and CNOT the result into the second register, so that the bit in that register is $f\left( x\right) \oplus f\left( x\right) =0$. \ Doing so, we obtain% \[ \frac{1}{2^{n/2}}% %TCIMACRO{\dsum \limits_{x\in\left\{ 0,1\right\} ^{n}}}% %BeginExpansion {\displaystyle\sum\limits_{x\in\left\{ 0,1\right\} ^{n}}} %EndExpansion \left( -1\right) ^{f\left( x\right) }\left| x\right\rangle \left| 0\right\rangle . \] The final step is to perform another Hadamard transform $H_{2^{n}}$\ on the first register. \ We could work out the result of this algebraically, but would rather reason about it to obtain more insight. \ We've seen that the Hadamard transform is its own inverse, and that% \[ H_{2^{n}}\left( \left| y\right\rangle \right) =\frac{1}{2^{n/2}}% %TCIMACRO{\dsum \limits_{x\in\left\{ 0,1\right\} ^{n}}}% %BeginExpansion {\displaystyle\sum\limits_{x\in\left\{ 0,1\right\} ^{n}}} %EndExpansion \left( -1\right) ^{y\cdot x}\left| x\right\rangle . \] From these it follows that if $f$ is identically zero, then applying\ $H_{2^{n}}$\ brings us back to $\left| 0\cdots0\right\rangle \left| 0\right\rangle $. \ If, on the other hand, $f$ is balanced, then the state% \[ \frac{1}{2^{n/2}}% %TCIMACRO{\dsum \limits_{x\in\left\{ 0,1\right\} ^{n}}}% %BeginExpansion {\displaystyle\sum\limits_{x\in\left\{ 0,1\right\} ^{n}}} %EndExpansion \left( -1\right) ^{f\left( x\right) }\left| x\right\rangle \] is a linear combination of\ $H_{2^{n}}\left( \left| y\right\rangle \right) $\ for various values of $y$. \ However, none of these values can be $y=0$, since the state is orthogonal to $H_{2^{n}}\left( \left| 0\right\rangle \right) $\ in the vector space $Z_{2}^{n}$\ (the two having inner product $2^{n-1}-2^{n-1}=0$). Therefore, if $f$ is zero, then $x=0$ at the end of the computation, whereas if $f$ is balanced, then $x\neq0$. \ So by observing the $\left| x\right\rangle $\ register, we can decide with certainty whether $f$ is zero or balanced. \ We've done this using two queries to $f$ and $\Theta\left( n\right) $\ steps of computation. \end{document}