Shor's reduction: a random unit x mod odd n yields a nontrivial factor with probability ≥ 1 − 1/2^{k−1}
ProvedShorAlgorithms.Reduction.factor_prob_geLet be an odd integer with distinct (necessarily odd) prime factors, and let be the number of units modulo . Choose uniformly at random from , let be its multiplicative order, and compute . The procedure yields a nontrivial factor of when is even and . Then
that is, .
This is the classical half of Shor's factoring algorithm: it reduces factoring an odd to finding the order of a random element. The bound is informative exactly when is not a prime power (), where it is at least ; for a prime power () it reads and holds trivially. The paper's remark that "the scheme will work as long as is odd and not a prime power" explains when the bound is useful and is not an extra hypothesis. The constant is sharp: for exactly of the units succeed.
Formalization Note The sample space is the unit group (ZMod n)ˣ, of cardinality ; a non-unit has no multiplicative order and is not sampled (Shor's "choose a random " in "the multiplicative group "). The probability is stated in cleared-denominator form over , with the count taken as Nat.card of the subtype of successful units. n.primeFactors.card is , which is at least for , so k - 1 does not truncate. The success event is the definition successEvent.
import Mathlib import Definitions.Def_ShorAlgorithms_Reduction_successEvent
namespace ShorAlgorithms.Reduction
/-- Shor (1997), §5, p. 1498: for odd `n > 1` with `k` distinct (odd) prime factors, the
procedure applied to a uniformly random unit `x (mod n)` yields a nontrivial factor of `n`
with probability at least `1 - 1/2^{k-1}`; stated as
`(1 - 1/2^{k-1}) · φ(n) ≤ #{x ∈ (ℤ/n)ˣ : success}`. -/
theorem factor_prob_ge (n : ℕ) (hodd : Odd n) (hn : 1 < n) :
(1 - 1 / 2 ^ (n.primeFactors.card - 1) : ℝ) * (Nat.totient n : ℝ)
≤ (Nat.card {u : (ZMod n)ˣ // successEvent n u} : ℝ) := by sorry
end ShorAlgorithms.Reduction
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.