Lean, informalized

Nielsen & Chuang · Chapter 5, The quantum Fourier transform and its applications · p. 239

Exercise 5.24 - Continued fractions and an inverse modulo rr turn two estimates into the exponent ss

Recovering a discrete logarithm from two phase estimates.

Hover over a blue or green term in the text, or a node in the graph, to find it in the other. Select it to read its declaration both in Lean and in words.

The Exercise

The discrete logarithm problem gives an element aa of order rr and a power b=asb = a^s, and asks for the exponent ss, with 0≤s<r0 \le s < r. The quantum algorithm for it ends by measuring two registers, which yields, for some integer ℓ\ell, two real numbers φ1\varphi_1 and φ2\varphi_2 estimating sℓ/rs\ell/r and ℓ/r\ell/r modulo one. The exercise is the classical step that follows, finding ss from φ1\varphi_1, φ2\varphi_2 and rr by continued fractions.

Recovering the Exponent

For a rational number qq and a modulus rr, the numerator recovered from qq is the integer kr(q)=num⁡(qr),k_r(q) = \operatorname{num}(qr),(1)✦ where num⁡(x)\operatorname{num}(x) is the numerator of a rational number xx in lowest terms.

The discrete logarithm recovered from rational numbers q1q_1 and q2q_2, with modulus rr, is the residue modulo rr, between 00 and r−1r - 1, s̃r(q1,q2)=kr(q1)kr(q2)−1mod⁡r,\tilde s_r(q_1, q_2) = k_r(q_1)\, k_r(q_2)^{-1} \bmod r,(2)✦ with kr(q2)−1k_r(q_2)^{-1} the inverse of kr(q2)k_r(q_2) modulo rr.

The Claim

A real number φ\varphi with continued fraction expansion [a0;a1,a2,…][a_0; a_1, a_2, \dots] has, for each nn, an nnth convergent, the rational number cn(φ)=[a0;a1,…,an]c_n(\varphi) = [a_0; a_1, \dots, a_n].

Theorem 1. Let rr be a positive integer, ss an integer with 0≤s<r0 \le s < r, and ℓ\ell an integer coprime to rr; let k1=sℓmod⁡rk_1 = s\ell \bmod r and k2=ℓmod⁡rk_2 = \ell \bmod r, both between 00 and r−1r - 1. Let φ1\varphi_1 and φ2\varphi_2 be real numbers with |φ1−k1/r|<1/(2r2)|\varphi_1 - k_1/r| < 1/(2r^2) and |φ2−k2/r|<1/(2r2)|\varphi_2 - k_2/r| < 1/(2r^2). Then there are indices n1n_1 and n2n_2 with cn1(φ1)=k1r,cn2(φ2)=k2r,s̃r(k1r,k2r)=s.c_{n_1}(\varphi_1) = \frac{k_1}{r}, \qquad c_{n_2}(\varphi_2) = \frac{k_2}{r}, \qquad \tilde s_r\!\left(\frac{k_1}{r}, \frac{k_2}{r}\right) = s.(3)✦

What Is Checked

The claim is stated over the numerator recovery krk_r of (1) and the recovered discrete logarithm s̃r\tilde s_r of (2), evaluated at the exact fractions k1/rk_1/r and k2/rk_2/r, and over the convergents of the continued fractions of the two estimates.