Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

§5, eq. (5.13) — at most one fraction with denominator <n< n<n within 1/2q1/2q1/2q of c/qc/qc/q

Proved
ShorAlgorithms.OrderFinding.fraction_unique

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

diophantine-approximationnumber-theoryorder-findingp2o-batch-p200bp2o-gran-per-chapterp2o-plan-paperp2o-v1

Let n,q,cn, q, cn,q,c be natural numbers with n2≤qn^2 \le qn2≤q. If s1s_1s1​ and s2s_2s2​ are rational numbers whose denominators in lowest terms are smaller than nnn and which both satisfy

∣cq−si∣≤12q,i=1,2,\left|\frac{c}{q} - s_i\right| \le \frac{1}{2q}, \qquad i = 1, 2,​qc​−si​​≤2q1​,i=1,2,

then s1=s2s_1 = s_2s1​=s2​.

So the fraction d/rd/rd/r singled out by (5.13) is determined by ccc and qqq alone, which is what makes rounding c/qc/qc/q a well-defined way to recover it.

Formalization Note The paper writes "Because q>n2q > n^2q>n2", but its choice of qqq on p. 1498 only guarantees n2≤qn^2 \le qn2≤q (with equality when nnn is a power of 222). The statement holds under n2≤qn^2 \le qn2≤q, which is the hypothesis used here; this is the stronger theorem. The value ccc is not required to be smaller than qqq.

Preamble
import Mathlib
Formal statement
namespace ShorAlgorithms.OrderFinding

/-- Shor (1997), §5, eq. (5.13), p. 1500: if `n² ≤ q`, there is at most one fraction with
(lowest-terms) denominator smaller than `n` within `1/(2q)` of `c/q`. The page writes
"Because `q > n²`"; the choice of `q` on p. 1498 only gives `n² ≤ q`, and the claim holds
under that weaker hypothesis, which is what is stated here. -/
theorem fraction_unique (n q c : ℕ) (hnq : n ^ 2 ≤ q) (s₁ s₂ : ℚ)
    (h₁ : s₁.den < n) (h₂ : s₂.den < n)
    (hs₁ : |(c : ℚ) / q - s₁| ≤ 1 / (2 * q)) (hs₂ : |(c : ℚ) / q - s₂| ≤ 1 / (2 * q)) :
    s₁ = s₂ := 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, eq. (5.13) and "Because q > n^2, there is at most one fraction d/r with r < n that satisfies the above inequality"
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