§6, eq. (6.4) — probability of observing with
ProvedShorAlgorithms.DiscreteLog.outcome_prob_eqThroughout, is a prime, is a generator of the multiplicative group (an element of order ), is an integer with and (so is the discrete logarithm of ), and is a power of with .
Measure the final state (6.3) of the discrete-logarithm algorithm, obtained by applying the Fourier transform to each of the first two registers of the state (6.1). For and , the probability of observing with is
This identifies the output distribution with an explicit exponential sum, the starting point for every probability estimate in the analysis.
Formalization Note The congruence is taken in modulo (Int.ModEq), with ranging over ; the prefactor uses computed in . The generator is encoded as orderOf g = p - 1; is given as together with .
import Mathlib import Definitions.Def_ShorAlgorithms_DiscreteLog_outcomeProb
namespace ShorAlgorithms.DiscreteLog
/-- Shor (1997), §6, eq. (6.4), p. 1502: with `p` prime, `g` a generator of `(ℤ/p)ˣ`,
`x = g^r` (`0 ≤ r < p - 1`) and `q = 2^l` with `p < q < 2p`, the probability of observing
`|c, d, y⟩` with `y = g^k` (`0 ≤ k < p - 1`) is
`|(1/((p-1)q)) ∑_{a,b ∈ [0,p-2], a - r b ≡ k (mod p-1)} exp(2πi(ac + bd)/q)|²`. -/
theorem outcome_prob_eq (p : ℕ) [hp : Fact p.Prime] (g : (ZMod p)ˣ) (hg : orderOf g = p - 1)
(r : ℕ) (hr : r < p - 1) (q l : ℕ) (hq : q = 2 ^ l) (hpq : p < q) (hqp : q < 2 * p)
(c d : Fin q) (k : ℕ) (hk : k < p - 1) :
outcomeProb p g (g ^ r) q c d (g ^ k) =
‖(1 / (((p : ℂ) - 1) * (q : ℂ))) *
∑ a ∈ Finset.range (p - 1), ∑ b ∈ Finset.range (p - 1),
if (a : ℤ) - (r : ℤ) * (b : ℤ) ≡ (k : ℤ) [ZMOD ((p : ℤ) - 1)] then
Complex.exp (2 * Real.pi * Complex.I / (q : ℂ) *
((a : ℂ) * ((c : ℕ) : ℂ) + (b : ℂ) * ((d : ℕ) : ℂ)))
else 0‖ ^ 2 := by sorry
end ShorAlgorithms.DiscreteLog
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.