Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

§5, p. 1498 — the 2-parts of all k local orders agree with probability at most 1/2^{k−1}

Proved
ShorAlgorithms.Reduction.card_all_agree_le

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

chinese-remainder-theoremnumber-theoryorder-findingp2o-batch-p200bp2o-gran-per-chapterp2o-plan-paperp2o-v1

Let n>1n > 1n>1 be odd with kkk distinct prime factors p1,…,pkp_1, \dots, p_kp1​,…,pk​, and for a unit xxx modulo nnn let rir_iri​ be the order of x mod piαix \bmod p_i^{\alpha_i}xmodpiαi​​. Then the proportion of units xxx for which ν2(r1)=⋯=ν2(rk)\nu_2(r_1) = \cdots = \nu_2(r_k)ν2​(r1​)=⋯=ν2​(rk​) is at most 1/2k−11/2^{k-1}1/2k−1:

2k−1⋅#{x∈(Z/n)×:ν2(r1)=⋯=ν2(rk)}≤φ(n).2^{k-1} \cdot \#\bigl\{x \in (\mathbb{Z}/n)^\times : \nu_2(r_1) = \cdots = \nu_2(r_k)\bigr\} \le \varphi(n).2k−1⋅#{x∈(Z/n)×:ν2​(r1​)=⋯=ν2​(rk​)}≤φ(n).

By the Chinese remainder theorem a uniform unit modulo nnn corresponds to independent uniform units modulo each piαip_i^{\alpha_i}piαi​​, and each successive 2-part agrees with the previous ones with probability at most 1/21/21/2.

Formalization Note kkk is n.primeFactors.card, which is at least 111 for n>1n > 1n>1, so k - 1 does not truncate. The event is "the 2-adic valuations of localOrder n u p coincide for all p, q ∈ n.primeFactors".

Preamble
import Mathlib
import Definitions.Def_ShorAlgorithms_Reduction_localOrder
Formal statement
namespace ShorAlgorithms.Reduction

/-- Shor (1997), §5, p. 1498: for odd `n > 1` with `k` distinct prime factors, the units `x`
for which the 2-adic valuations of all the local orders `r_p` agree form a proportion at most
`1/2^{k-1}` of the `φ(n)` units mod `n`. -/
theorem card_all_agree_le (n : ℕ) (hodd : Odd n) (hn : 1 < n) :
    2 ^ (n.primeFactors.card - 1) *
        Nat.card {u : (ZMod n)ˣ // ∀ p ∈ n.primeFactors, ∀ q ∈ n.primeFactors,
          padicValNat 2 (localOrder n u p) = padicValNat 2 (localOrder n u q)}
      ≤ Nat.totient n := by sorry

end ShorAlgorithms.Reduction
Source
Shor, Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer, SIAM J. Comput. 26(5) (1997), p. 1498, §5, "Thus each of these powers of 2 has at most a 50% probability of agreeing with the previous ones, so all k of them agree with probability at most 1/2^{k−1}."
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