diff --git a/LogicAndSetTheory/05_set_theory.tex b/LogicAndSetTheory/05_set_theory.tex index e202a11..5584305 100644 --- a/LogicAndSetTheory/05_set_theory.tex +++ b/LogicAndSetTheory/05_set_theory.tex @@ -628,7 +628,7 @@ \subsection{The universe of sets} \begin{remark} If $x \in V_\alpha$ then $x \subseteq V_\alpha$ by \cref{lem:5-6}. \\ If $x \subseteq V_\alpha$ then $x \in \mathcal{P}(V_\alpha) = V_{\alpha+1}$. - If $\exists \alpha \in ON$ s.t. $x \subset V_\alpha$ define the \vocab{rank} of $x$ to be the least such $\alpha$. + If $\exists \alpha \in ON$ s.t. $x \subseteq V_\alpha$ define the \vocab{rank} of $x$ to be the least such $\alpha$. For example, the rank of $\emptyset$ is 0, the rank of 1 is 1, the rank of $\omega$ is $\omega$, and in general the rank of any ordinal $\alpha$ is $\alpha$. Intuitively, the rank of a set is the time at which it was created. diff --git a/LogicAndSetTheory/logicandsettheory.pdf b/LogicAndSetTheory/logicandsettheory.pdf index c6a2c64..98560ae 100644 Binary files a/LogicAndSetTheory/logicandsettheory.pdf and b/LogicAndSetTheory/logicandsettheory.pdf differ diff --git a/QuantumInfoAndComputing/04_quantum_computation.tex b/QuantumInfoAndComputing/04_quantum_computation.tex index b427625..af1c5ea 100644 --- a/QuantumInfoAndComputing/04_quantum_computation.tex +++ b/QuantumInfoAndComputing/04_quantum_computation.tex @@ -378,7 +378,7 @@ \subsection{Grover's algorithm} Given a black box which computes $I_{x_0}$ for some $x_0 \in B_n$, we wish to determine $x_0$ with the least amount of queries. We will now describe Grover's algorithm. We begin with the equal superposition state $\ket{\psi_0} = \frac{1}{\sqrt{2^n}} \sum_{x \in B_n} \ket{x}$. -Consider \vocab{Grover's iteration operator} $Q = -H_n I_0 H_n I_{x_0}$ where $H_n = H^{\otimes n}$. +Consider \vocab{Grover's iteration operator} $Q = -H_n I_0 H_n I_{x_0} = -I_{\psi_0} I_{x_0}$\footnote{$H_n I_0 H_n = I_{H \ket{0}} = I_{\psi_0}$.} where $H_n = H^{\otimes n}$. Note that $Q$ is real-valued, so acts geometrically on the real-valued vector $\ket{\psi_0}$ in real Euclidean space. It has the following properties. \begin{enumerate} @@ -459,17 +459,19 @@ \subsection{Grover's algorithm for multiple items} Hence, as before, $Q_G$ causes the desired rotation through $2\alpha$ in this plane. The probability of finding a single good item is $\abs{\ip{\psi}{\psi_G}}^2$, as $\ket{\psi} = a \ket{\psi_G} + b \ket{\psi_B}$. -Suppose now that $r$ is unknown. -In this case, we start with $\ket{\psi_0}$ and repeatedly apply $Q$ to rotate $\ket{\psi_0}$ to $\ket{\psi_G}$ as before. -However, we do not know how many iterations of $Q$ to apply, since this depends on $r$. +\begin{aside}{$r$ unknown - Non Examinable} + Suppose now that $r$ is unknown. + In this case, we start with $\ket{\psi_0}$ and repeatedly apply $Q$ to rotate $\ket{\psi_0}$ to $\ket{\psi_G}$ as before. + However, we do not know how many iterations of $Q$ to apply, since this depends on $r$. -If $r \ll N$, we choose $K$ uniformly at random in $\qty(0, \frac{\pi}{4}\sqrt{N})$, and apply $K$ iterations of $Q$. -We measure the final state $\ket{\psi^K}$ to obtain $x$, and check if $f(x) = 1$ or not. -Note that each iteration causes a rotation of $2\alpha$ where $\sin \alpha = \frac{\sqrt{r}}{\sqrt{N}}$ so $2\alpha \approx 2\frac{\sqrt{r}}{\sqrt{N}}$. -Choosing $K$ therefore implicitly chooses a random angle in the range $\qty(0, \frac{\pi}{2} \sqrt{r})$. -Now, if the final rotated state $\ket{\psi}$ makes an angle within $\pm \frac{\pi}{4}$ with $\ket{\psi_0}$, the probability of locating a good item is $\abs{\ip{\psi}{\psi_0}}^2 \geq \cos^2 \frac{\pi}{4} = \frac{1}{2}$. -Since for every quadrant in the plane $\mathcal P_G$, half of the angles are within $\pm \frac{\pi}{4}$ from the $y$-axis, the randomised procedure using $O(\sqrt{N})$ queries will locate a good item with probability approximately $\frac{1}{4}$. -The procedure can then be repeated to reduce the error probability to an acceptable level. + If $r \ll N$, we choose $K$ uniformly at random in $\qty(0, \frac{\pi}{4}\sqrt{N})$, and apply $K$ iterations of $Q$. + We measure the final state $\ket{\psi^K}$ to obtain $x$, and check if $f(x) = 1$ or not. + Note that each iteration causes a rotation of $2\alpha$ where $\sin \alpha = \frac{\sqrt{r}}{\sqrt{N}}$ so $2\alpha \approx 2\frac{\sqrt{r}}{\sqrt{N}}$. + Choosing $K$ therefore implicitly chooses a random angle in the range $\qty(0, \frac{\pi}{2} \sqrt{r})$. + Now, if the final rotated state $\ket{\psi}$ makes an angle within $\pm \frac{\pi}{4}$ with $\ket{\psi_G}$, the probability of locating a good item is $\abs{\ip{\psi}{\psi_G}}^2 \geq \cos^2 \frac{\pi}{4} = \frac{1}{2}$. + Since for every quadrant in the plane $\mathcal P_G$, half of the angles are within $\pm \frac{\pi}{4}$ from the $y$-axis, the randomised procedure using $O(\sqrt{N})$ queries will locate a good item with probability approximately $\frac{1}{4}$. + The procedure can then be repeated to reduce the error probability to an acceptable level. +\end{aside} \subsection{\texorpdfstring{$\mathsf{NP}$}{NP} problems} A \vocab{verifier} $V$ for a language $L$ is a computation with two inputs $w, c$ such that @@ -512,16 +514,16 @@ \subsection{Shor's algorithm} If $b = 1$, then $a, N$ are coprime. \begin{theorem}[Euler's theorem] Let $a, N$ be coprime. - Then there exists $1 < r < N$ such that $a^r \equiv 1$ mod $N$. + Then there exists $1 < r < N$ s.t. $a^r \equiv 1$ mod $N$. A minimal such $r$ is called the \vocab{order} of $a$ modulo $N$. \end{theorem} -Consider the \vocab{modular exponentiation function} $f \colon \mathbb Z \to \faktor{\mathbb Z}{n\mathbb Z}$ such that $f(k) = a^k$ mod $N$. +Consider the \vocab{modular exponentiation function} $f \colon \mathbb Z \to \faktor{\mathbb Z}{N\mathbb Z}$ s.t. $f(k) = a^k$ mod $N$. This function satisfies $f(k_1 + k_2) = f(k_1)f(k_2)$. -$f$ is periodic with period $r$, and is injective within each period. +$f$ is periodic with period $r$, and is injective within each period as $r$ minimal. Suppose that we can find $r$, and suppose $r$ is even. Then $a^r - 1 \equiv (a^{\frac{r}{2}}+1)(a^{\frac{r}{2}}-1) \equiv 0$ mod $N$. -Note that $N \nmid (a^{\frac{r}{2}}-1)$ since $r$ was minimal such that $a^r \equiv 1$ mod $N$. +Note that $N \nmid (a^{\frac{r}{2}}-1)$ since $r$ was minimal s.t. $a^r \equiv 1$ mod $N$. If $N \nmid (a^{\frac{r}{2}}+1)$, then $N$ must have some prime factors in $(a^{\frac{r}{2}}+1)$ and some in $(a^{\frac{r}{2}}-1)$. We can use Euclid's algorithm to compute $\mathrm{gcd}(a^{\frac{r}{2}}+1, N)$ and $\mathrm{gcd}(a^{\frac{r}{2}}-1, N)$, which are factors of $N$. Thus, we find factors of $N$ provided $r$ is even and $a^{\frac{r}{2}} + 1 \not\equiv 0$ mod $N$. @@ -532,7 +534,7 @@ \subsection{Shor's algorithm} $N = 15$ does not divide $50$, so $\gcd(50, N) = 5$ is a factor, and $\gcd(48, 15) = 3$ is a factor. \begin{theorem} Let $N$ be odd and not a prime power. - Then, choosing $a$ uniformly at random such that $\gcd(a,N) = 1$, the probability that $r$ is even and $(a^{\frac{r}{2}} + 1) \not\equiv 0$ mod $N$ is at least $\frac{1}{2}$. + Then, choosing $a$ uniformly at random s.t. $\gcd(a,N) = 1$, the probability that $r$ is even and $(a^{\frac{r}{2}} + 1) \not\equiv 0$ mod $N$ is at least $\frac{1}{2}$. \end{theorem} This implies that if $N$ is odd and not a prime power, we obtain a factor of $N$ with probability at least $\frac{1}{2}$. We repeat this process until the probability of not finding a factor is acceptably low. @@ -549,18 +551,18 @@ \subsection{Shor's algorithm} \item Choose $1 < a < N$ uniformly at random and compute $b = \gcd(a,N)$. If $b > 1$, output $b$ and halt. \item Find the period $r$ of the modular exponentiation function $f(k) = a^k$ mod $N$. - If this fails, return to step (iii). + If this fails, return to step (3). \item If $r$ is even and $(a^{\frac{r}{2}} + 1) \not\equiv 0$ mod $N$, compute $t = \gcd(a^{\frac{r}{2}} + 1, N)$; if $1 < t < N$, output $t$ and halt. - Otherwise, return to step (iii). + Otherwise, return to step (3). \end{enumerate} We now describe the method to compute the period of the modular exponentiation function. -Note that $f \colon \mathbb Z \to \mathbb Z$, not $\mathbb Z_N \to \mathbb Z_M$; we therefore cannot directly use the algorithm discussed previously. +Note that $f \colon \mathbb Z \to \mathbb Z_N$, not $\mathbb Z_N \to \mathbb Z_M$; we therefore cannot directly use the algorithm discussed previously. We must first truncate the domain $\mathbb Z$ to some $\mathbb Z_M$. If $r$ is unknown, $f$ will not necessarily be periodic on $\mathbb Z_M$. However, if $M$ is $O(N^2)$, the single incomplete period has a negligible effect on the periodicity determination. We will define $M = 2^m$ for some $m$ and use $QFT_M$. -Consider a finite domain $D = \qty{0, \dots, 2^m - 1}$, where $m$ is the smallest integer such that $2^m > N^2$. +Consider a finite domain $D = \qty{0, \dots, 2^m - 1}$, where $m$ is the smallest integer s.t. $2^m > N^2$. Suppose $2^m = Br + b$ where $0 \leq b < r$, so $B = \floor*{\frac{2^m}{r}}$. We start with the equal superposition state $\ket{\psi_m} = \frac{1}{\sqrt{2^m}} \sum_{x \in D} \ket{x}$. Consider the quantum oracle $U_f$ corresponding to the modular exponentiation function $f$. @@ -576,7 +578,7 @@ \subsection{Shor's algorithm} If $y = f(x_0)$ for $x_0 < b$, the probability of measuring $y$ is $\frac{B+1}{2^m}$. The post-measurement state of the first register is $\ket{\mathrm{per}} = \frac{1}{\sqrt{B+1}} \sum_{j=0}^B \ket{x_0 + jr}$. -In the case $x_0 \geq b$, we have $\ket{\mathrm{per}} = \frac{1}{\sqrt{B}} \sum_{j=0}^{B-1} \ket{x_0 + jr}$. +In the case $x_0 \geq b$, we have $\ket{\mathrm{per}} = \frac{1}{\sqrt{B}} \sum_{j=0}^{B-1} \ket{x_0 + jr}$ with prob $\frac{B}{2^m}$. In both cases, \[ \ket{\mathrm{per}} = \frac{1}{\sqrt{A}} \sum_{j=0}^{A-1} \ket{x_0 + jr} \] where $A = B+1$ if $y = f(x_0)$ with $x_0 < b$ and $A = B$ if $y = f(x_0)$ with $x_0 \geq b$. @@ -586,32 +588,32 @@ \subsection{Shor's algorithm} &= \frac{1}{\sqrt{A}} \frac{1}{\sqrt{2^n}} \sum_{c=0}^{2^m - 1} \omega^{x_0 c} \underbrace{\qty[\sum_{j = 0}^{A-1} (\omega^{cr})^j]}_{S} \ket{c} \\ \end{align*} where $\omega = 2^{\frac{2\pi i}{M}}$ where $M = 2^m$. -$S$ is a geometric series. +$S$ is a geometric series with $\alpha = \omega^{cr}$. If $\frac{M}{r} \not\in \mathbb Z$, $\alpha^A \neq 1$. We claim that a measurement on $QFT_{2^m} \ket{\mathrm{per}}$ yields an integer $c$ which is close to a multiple of $\frac{M}{r}$ with high probability. Consider $k\frac{2^m}{r}$ for $k = 0, \dots, r-1$. Each of these multiples is within $\frac{1}{2}$ of a unique integer; indeed, $2^m = Br + b$ so $r < 2^m$, giving that $k\frac{2^m}{r}$ cannot be a half integer. -Consider the values of $c$ such that $\abs{c - k \frac{2^m}{r}} < \frac{1}{2}$ for $k = 0, \dots, r-1$. +Consider the values of $c$ s.t. $\abs{c - k \frac{2^m}{r}} < \frac{1}{2}$ for $k = 0, \dots, r-1$. % Note that $\omega^{cr} = 1$ if $e^{\frac{2\pi i cr}{M}} = 1$. \begin{theorem} Suppose that $QFT_{2^m} \ket{\mathrm{per}} = \sum_{c=0}^{2^m - 1} g(c) \ket{c}$, and that we measure the state and receive an outcome $c$. - Let $c_k$ be the unique integer such that $\abs{c_k - k\frac{2^m}{r}} < \frac{1}{2}$. + Let $c_k$ be the unique integer s.t. $\abs{c_k - k\frac{2^m}{r}} < \frac{1}{2}$. Then $\prob{c = c_k} > \frac{\gamma}{r}$ for a fixed constant $\gamma$ (which can be shown to be $\frac{4}{\pi^2}$). Moreover, the probability that $k, r$ are coprime is $\Omega\qty(\frac{1}{\log \log r})$ by the coprimality theorem. \end{theorem} Thus, with $O(\log \log N) > O(\log \log r)$ repetitions, we obtain a good $c$ value with high probability. -Suppose that we measure $c$ such that $\abs{c - k \frac{2^m}{r}} < \frac{1}{2}$, so $\abs{\frac{c}{2^m} - \frac{k}{r}} < \frac{1}{2^{m+1}}$. -Recall that $r < N$ and $m$ is minimal such that $2^m > N^2$. +Suppose that we measure $c$ s.t. $\abs{c - k \frac{2^m}{r}} < \frac{1}{2}$, so $\abs{\frac{c}{2^m} - \frac{k}{r}} < \frac{1}{2^{m+1}}$. +Recall that $r < N$ and $m$ is minimal s.t. $2^m > N^2$. Then $\abs{\frac{c}{2^m} - \frac{k}{r}} < \frac{1}{2N^2}$. Note that $\frac{c}{2^m}$ is known. -We show that there is at most one fraction $\frac{k}{r}$ with denominator $r < N$ such that $\abs{\frac{c}{2^m} - \frac{k}{r}} < \frac{1}{2N^2}$. +We show that there is at most one fraction $\frac{k}{r}$ with denominator $r < N$ s.t. $\abs{\frac{c}{2^m} - \frac{k}{r}} < \frac{1}{2N^2}$. Suppose $\frac{k'}{r'}, \frac{k''}{r''}$ both satisfy this requirement. Then \[ \abs{\frac{k'}{r'} - \frac{k''}{r''}} = \frac{\abs{k'r'' - k''r'}}{r'r''} \geq \frac{1}{r'r''} > \frac{1}{N^2} \] But $\abs{\frac{c}{2^m} - \frac{k'}{r'}}, \abs{\frac{c}{2^m} - \frac{k'}{r'}} < \frac{1}{2N^2}$, contradicting the triangle inequality. -This result is the reason for choosing $m$ minimal such that $2^m > N^2$. +This result is the reason for choosing $m$ minimal s.t. $2^m > N^2$. Therefore, we have with high probability that $\frac{c}{2^m}$ is close to a unique fraction $\frac{k}{r}$. \begin{example} Let $N = 39$ and choose $a = 7$; note that 7 and 39 are coprime. @@ -659,12 +661,12 @@ \subsection{Shor's algorithm} \end{proof} \begin{theorem} Let $x \in \mathbb Q$ with $0 < x < 1$. - Let $\frac{p}{q} \in \mathbb Q$ such that $\abs{x - \frac{p}{q}} < \frac{1}{2q^2}$. + Let $\frac{p}{q} \in \mathbb Q$ s.t. $\abs{x - \frac{p}{q}} < \frac{1}{2q^2}$. Then $\frac{p}{q}$ is a convergent of the continued fraction expansion of $x$. \end{theorem} -In our situation, we have $c$ such that +In our situation, we have $c$ s.t. \[ \abs{\frac{c}{2^m} - \frac{k}{r}} < \frac{1}{2N^2};\quad r < N \] -In particular, $\abs{\frac{c}{2^m} - \frac{k}{r}} < \frac{1}{2r^2}$, and we have seen that there is at most one fraction $\frac{k}{r}$ such that this holds. +In particular, $\abs{\frac{c}{2^m} - \frac{k}{r}} < \frac{1}{2r^2}$, and we have seen that there is at most one fraction $\frac{k}{r}$ s.t. this holds. Note that $0 < c < 2^m$, so $0 < \frac{c}{2^m} < 1$. Hence, $\frac{k}{r}$ is a convergent of $\frac{c}{2^m}$. Note that $2^m > N^2 > 2^{m-1}$, so $c, 2^m$ are $O(m)$-bit integers, and hence the sequence of convergents (and in particular $\frac{k}{r}$) can be computed in $O(m^3)$ time. diff --git a/QuantumInfoAndComputing/qic.pdf b/QuantumInfoAndComputing/qic.pdf index ba403b1..4896176 100644 Binary files a/QuantumInfoAndComputing/qic.pdf and b/QuantumInfoAndComputing/qic.pdf differ