Shor's order-finding subroutine: each is observed with probability and recovered by continued fractions
ProvedShorWiki.order_finding_succeedsLet be integers with , let be the order of modulo , let , and let . Run Shor's order-finding circuit — quantum phase estimation for the modular-multiplication gate with a -qubit first register — on the input , and measure the first register, obtaining an outcome with probability .
Fix and call an outcome optimal for if
i.e. is a nearest integer to . The theorem states:
- the optimal outcomes for are observed with total probability
- for every outcome optimal for , some convergent of the continued fraction expansion of equals in lowest terms.
Summing (1) over the values of , a single run of the subroutine yields, with probability at least , an outcome from which the continued fractions algorithm recovers the reduced fraction for some — and hence the divisor of the order . This is the precise content of the article's claim that phase estimation "gives as output a random integer of the form " and that qubits suffice for the continued fractions algorithm to recover it.
Formalization Note The probability is computed from the explicit circuit defined in ShorWiki_Defs (Hadamard gates, the controlled gates , inverse QFT). The convergents are Mathlib's Real.convergent of the real number , and "recovers and " is expressed as equality of the numerator and denominator of that rational convergent. The value combines the article's two statements "balanced probability to find each " and "".
import Mathlib import Definitions.Def_ShorWiki_Defs open Matrix Kronecker
namespace ShorWiki
theorem order_finding_succeeds (N a : ℕ) (ha : 1 < a) (haN : a < N)
(hcop : Nat.Coprime a N) (j : ℕ) (hj : j < ord N a) :
4 / (Real.pi ^ 2 * ord N a) ≤
(∑ k ∈ Finset.univ.filter (fun k : Fin (2 ^ (2 * regBits N)) =>
|((k : ℕ) : ℝ) / 2 ^ (2 * regBits N) - (j : ℝ) / ord N a|
≤ 1 / 2 ^ (2 * regBits N + 1)),
measureFirst (orderFindingOutput N a) k) ∧
∀ k : Fin (2 ^ (2 * regBits N)),
|((k : ℕ) : ℝ) / 2 ^ (2 * regBits N) - (j : ℝ) / ord N a|
≤ 1 / 2 ^ (2 * regBits N + 1) →
∃ m : ℕ,
(Real.convergent (((k : ℕ) : ℝ) / 2 ^ (2 * regBits N)) m).num
= ((j / Nat.gcd j (ord N a) : ℕ) : ℤ) ∧
(Real.convergent (((k : ℕ) : ℝ) / 2 ^ (2 * regBits N)) m).den
= ord N a / Nat.gcd j (ord N a) := by sorry
end ShorWiki
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.