Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

§5, eq. (5.11) — each state ∣c,xk⟩|c, x^k\rangle∣c,xk⟩ with ∣{rc}q∣≤r/2|\{rc\}_q| \le r/2∣{rc}q​∣≤r/2 has probability ≥1/3r2\ge 1/3r^2≥1/3r2

Proved
ShorAlgorithms.OrderFinding.outcome_prob_ge

by mikedeng1 · Sep 29, 2026 · Mathlib 0df444a (Lean v4.33.1)

order-findingp2o-batch-p200bp2o-gran-per-chapterp2o-plan-paperp2o-v1probabilityquantum-algorithms

There is a threshold NNN such that the following holds for every n≥Nn \ge Nn≥N. Let xxx be coprime to nnn with multiplicative order rrr modulo nnn, let q=2lq = 2^lq=2l satisfy n2≤q<2n2n^2 \le q < 2n^2n2≤q<2n2, let 0≤c<q0 \le c < q0≤c<q and 0≤k<r0 \le k < r0≤k<r, and suppose there is an integer ddd with

−r2≤rc−dq≤r2.-\frac{r}{2} \le rc - dq \le \frac{r}{2}.−2r​≤rc−dq≤2r​.

Then the probability of observing ∣c,xk mod n⟩|c, x^k \bmod n\rangle∣c,xkmodn⟩ in the final state (5.4) is at least

13r2.\frac{1}{3r^2}.3r21​.

The hypothesis is the paper's condition (5.12), equivalently (5.11), −r/2≤{rc}q≤r/2-r/2 \le \{rc\}_q \le r/2−r/2≤{rc}q​≤r/2, where {rc}q\{rc\}_q{rc}q​ is the residue of rcrcrc modulo qqq in (−q/2,q/2](-q/2, q/2](−q/2,q/2]. This per-state bound is what the count of good outcomes turns into the success probability φ(r)/3r\varphi(r)/3rφ(r)/3r.

Formalization Note The threshold NNN is quantified before nnn, xxx, qqq, ccc and kkk, so it is uniform in all of them, as in the paper's "for sufficiently large nnn". The condition is stated in the form (5.12) with an integer ddd, which avoids defining the symmetric residue; the two forms are equivalent because r/2<q/2r/2 < q/2r/2<q/2.

Preamble
import Mathlib
import Definitions.Def_ShorAlgorithms_OrderFinding_outcomeProb
Formal statement
namespace ShorAlgorithms.OrderFinding

/-- Shor (1997), §5, eqs. (5.11)–(5.12), p. 1500. For all sufficiently large `n` (the threshold
`N` is uniform in `x`, `q`, `c`, `k`): if `x` is coprime to `n` with order `r`, `q = 2^l` with
`n² ≤ q < 2n²`, `0 ≤ k < r`, and there is an integer `d` with `-r/2 ≤ rc - dq ≤ r/2`
(equivalently `-r/2 ≤ {rc}_q ≤ r/2`), then the probability of observing `|c, x^k (mod n)⟩`
is at least `1/(3r²)`. -/
theorem outcome_prob_ge : ∃ N : ℕ, ∀ n : ℕ, N ≤ n → ∀ x : ℕ, Nat.Coprime x n →
    ∀ q l : ℕ, q = 2 ^ l → n ^ 2 ≤ q → q < 2 * n ^ 2 →
    ∀ c : Fin q, ∀ k : ℕ, k < orderOf (x : ZMod n) →
    (∃ d : ℤ,
        -((orderOf (x : ZMod n) : ℝ) / 2) ≤
          (orderOf (x : ZMod n) : ℝ) * ((c : ℕ) : ℝ) - (d : ℝ) * (q : ℝ) ∧
        (orderOf (x : ZMod n) : ℝ) * ((c : ℕ) : ℝ) - (d : ℝ) * (q : ℝ) ≤
          (orderOf (x : ZMod n) : ℝ) / 2) →
    1 / (3 * (orderOf (x : ZMod n) : ℝ) ^ 2) ≤ outcomeProb n x q c ((x : ZMod n) ^ k) := by sorry

end ShorAlgorithms.OrderFinding
Source
Shor, Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer, SIAM J. Comput. 26(5) (1997), p. 1500, §5, eqs. (5.11)–(5.12) and "so is at least 1/3r^2 for sufficiently large n"
Human review
  • Endorsed by Shuze Chen · Oct 1, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Oct 1, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me