§5, eqs. (5.5)–(5.6) — probability of observing
ProvedShorAlgorithms.OrderFinding.outcome_prob_eqLet , let be coprime to with multiplicative order modulo , and let be the power of with . Let and . The probability that measuring the final state (5.4) of the order-finding algorithm gives equals both
The first expression collects the paths that end in the same second-register value; the second rewrites the index set as . The second form is the starting point of the estimate (5.11).
Formalization Note The probability is outcomeProb, the squared modulus of the amplitude of the state built by applying to (5.2). is natural-number division, and the natural-number subtraction is exact because (the order of a unit is at most ). The hypotheses on are the section's standing choice of .
import Mathlib import Definitions.Def_ShorAlgorithms_OrderFinding_outcomeProb
namespace ShorAlgorithms.OrderFinding
/-- Shor (1997), §5, eqs. (5.5)–(5.6), p. 1499. Let `r` be the order of `x` mod `n`, let
`q = 2^l` with `n² ≤ q < 2n²`, and let `0 ≤ k < r`. The probability of observing
`|c, x^k (mod n)⟩` in the final state (5.4) equals
(5.5) `|(1/q) ∑_{a < q, x^a ≡ x^k} exp(2πiac/q)|²`, and also equals
(5.6) `|(1/q) ∑_{b=0}^{⌊(q-k-1)/r⌋} exp(2πi(br+k)c/q)|²`.
`(q - k - 1) / r` is natural-number (floor) division; `k < r < n ≤ q` keeps the subtraction
exact. -/
theorem outcome_prob_eq (n x q l : ℕ) (hx : Nat.Coprime x n)
(hq : q = 2 ^ l) (hnq : n ^ 2 ≤ q) (hq2 : q < 2 * n ^ 2)
(c : Fin q) (k : ℕ) (hk : k < orderOf (x : ZMod n)) :
outcomeProb n x q c ((x : ZMod n) ^ k) =
‖(1 / (q : ℂ)) * ∑ a ∈ (Finset.univ : Finset (Fin q)).filter
(fun a : Fin q => (x : ZMod n) ^ (a : ℕ) = (x : ZMod n) ^ k),
Complex.exp (2 * Real.pi * Complex.I * ((a : ℕ) : ℂ) * ((c : ℕ) : ℂ) / (q : ℂ))‖ ^ 2 ∧
outcomeProb n x q c ((x : ZMod n) ^ k) =
‖(1 / (q : ℂ)) * ∑ b ∈ Finset.range ((q - k - 1) / orderOf (x : ZMod n) + 1),
Complex.exp (2 * Real.pi * Complex.I *
(((b * orderOf (x : ZMod n) + k : ℕ)) : ℂ) * ((c : ℕ) : ℂ) / (q : ℂ))‖ ^ 2 := by sorry
end ShorAlgorithms.OrderFinding
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.