Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer 3: The Success Probability of Quantum Order FindingResearch Paper
Motivation
The security of the RSA cryptosystem rests on the assumed difficulty of factoring large integers, and the best known classical algorithms for factoring run in super-polynomial time. In 1994 Peter Shor showed that a quantum computer can factor an -digit integer in time polynomial in (Shor, SIAM J. Comput. 1997; conference version FOCS 1994). The algorithm has two parts. A classical reduction, due to Miller (1976), turns factoring into order finding: given coprime to , find the least with . The quantum part solves order finding.
This mission formalizes the quantum part as Shor analyzes it in §5 of the journal paper: the construction of the quantum state, the probability of each measurement outcome, and the classical post-processing that reads off the measured value. The paper's claim is that one run of this procedure returns with probability at least .
Timeline:
- 1976: Miller reduces factoring to order finding (with randomization).
- 1985–1994: Deutsch, Bernstein–Vazirani and Simon give the quantum Fourier sampling ideas the algorithm builds on.
- 1994: Shor's FOCS paper introduces the factoring and discrete logarithm algorithms.
- 1997: the SIAM J. Comput. version gives the analysis formalized here, with the power of in .
Setting
Fix an integer and an integer coprime to . Its order is the least with ; since is a unit, . Let be the power of with .
A quantum state on two registers, the first holding and the second a residue , is a complex vector indexed by the basis states . Measuring it returns with probability .
The Fourier matrix is the matrix with entries , with rows indexing inputs and columns outputs. The algorithm
- prepares (eq. (5.2)),
- applies to the first register, obtaining (eq. (5.4)),
- measures, obtaining some ,
- rounds to the nearest fraction with denominator smaller than .
The observed gives us if some fraction with lowest-terms denominator below is within of , and every such fraction has lowest-terms denominator exactly . In the Lean development these objects are preFourierState, finalState, outcomeProb and yieldsOrder, in the namespace ShorAlgorithms.OrderFinding, and the shared definition ShorAlgorithms.Shared.fourierMatrix.
Formalization targets
Goal: success probability at least
For all sufficiently large , with , and as above,
where is the state (5.4). The threshold on is uniform in and ; it is the paper's "for sufficiently large " from the per-state bound.
Milestones
- Eqs. (5.5)–(5.6). For , the probability of equals .
- Eq. (5.11). For past a threshold, every with for some integer has probability at least .
- Eq. (5.13). If , at most one fraction with denominator below lies within of .
- p. 1500. Such a fraction is a convergent of the continued fraction of .
- p. 1501. At least values of are within of some with ; with the distinct values of this gives at least states , and each such gives us .
Significance
The goal is the quantitative statement behind "order finding is in bounded-error quantum polynomial time": since for a constant (Hardy and Wright, Thm. 328), repetitions find with high probability, and Miller's reduction then factors . Without the bound, the algorithm is a procedure with no guarantee.
The result is proved, in the paper and in textbooks (Nielsen and Chuang, 2000, §5.3), usually with a phase-estimation analysis rather than Shor's direct count. What this mission adds is a machine-checked proof of Shor's own argument, with his choice of and his constants, starting from the state built by applying to (5.2). Formal proofs of idealized versions exist elsewhere, for instance in the exact-period model where divides and the output is uniform on peaks, but that model removes the approximation that the bound is about. Legendre's theorem on continued fractions is already on the platform (FamousTheorems.legendre_continued_fraction_theorem) and is included as a reference item.
Difficulty
The obvious route is to compute the output distribution in closed form. That works only when divides ; here is a power of and is arbitrary, so the amplitudes are geometric sums of terms whose phases do not cancel exactly. The per-state bound requires a lower bound on such a sum that is uniform in , and , with error terms of order controlled against a main term of order . The constant leaves only a small margin below the limiting value , so the errors must be bounded explicitly, not merely shown to vanish.
The second difficulty is the counting: distinct coprime numerators must give distinct outcomes in , and each good must determine uniquely, which uses and .
Formalization scope
Conventions the statements commit to:
- States are functions
Fin q × ZMod n → ℂ; the matrix convention is row = input, so applying to the first register gives the amplitude at . - The final state is built by applying to the state (5.2); the closed forms (5.5) and (5.6) are theorems, not definitions. No normalization hypothesis is assumed.
- Probabilities are squared moduli; the probability of the event " gives us " sums over all , which is exact because that are not powers of have probability zero.
- is a natural number with ; is
orderOf (x : ZMod n). enters through the three hypotheses , , , not through a function of . - Fractions are rationals, and "in lowest terms" is
Rat.den. - Thresholds "for sufficiently large " are , with quantified before , , and .
- Condition (5.11) is stated in its equivalent form (5.12), with an integer .
- Printed slip. Eq. (5.13)'s justification says "Because ", but was chosen with , and when is a power of . The uniqueness claim holds under , and that is what is stated.
Typing the closed form (5.4)–(5.6) in as the definition of the final state would make milestone 1 trivial and hide whether the probability model is the paper's; the definitions exclude this by construction.
Not stated: the polynomial running time of any step, the repetition count (no explicit constant), the reversible modular exponentiation of §3, and the post-processing heuristics on p. 1501. Needed infrastructure: bounds on geometric exponential sums, Euler's totient, Diophantine approximation by fractions with bounded denominator, and Mathlib's continued fractions. Lemmas on geometric sums of roots of unity and on the order of units mod are reusable in the companion discrete logarithm mission.
Selected references
- P. W. Shor, Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer, SIAM J. Comput. 26(5):1484–1509, 1997. https://doi.org/10.1137/S0097539795293172
- P. W. Shor, Algorithms for quantum computation: discrete logarithms and factoring, Proc. 35th FOCS, 1994. https://doi.org/10.1109/SFCS.1994.365700
- G. L. Miller, Riemann's hypothesis and tests for primality, J. Comput. System Sci. 13(3):300–317, 1976. https://doi.org/10.1016/S0022-0000(76)80043-8
- G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, 5th ed., Oxford, 1979 (Ch. X, continued fractions; Thm. 328).
- M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, Cambridge, 2000. https://doi.org/10.1017/CBO9780511976667