Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

§4, eq. (4.5) — the amplitude of |a⟩ → |b⟩ through the QFT circuit

Proved
ShorAlgorithms.QFT.path_amplitude

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

p2o-batch-p200bp2o-gran-per-chapterp2o-plan-paperp2o-v1quantum-algorithmsquantum-circuitsquantum-fourier-transform

Let l≥0l \ge 0l≥0 and let a=∣al−1…a0⟩a = |a_{l-1} \dots a_0\ranglea=∣al−1​…a0​⟩ and b=∣bl−1…b0⟩b = |b_{l-1} \dots b_0\rangleb=∣bl−1​…b0​⟩ be lll-bit basis states. Run the gate sequence

Rl−1 Sl−2,l−1 Rl−2⋯R1 S0,l−1⋯S0,1 R0R_{l-1}\, S_{l-2,l-1}\, R_{l-2} \cdots R_1\, S_{0,l-1} \cdots S_{0,1}\, R_0Rl−1​Sl−2,l−1​Rl−2​⋯R1​S0,l−1​⋯S0,1​R0​

of Shor's eq. (4.4) on the basis state ∣a⟩|a\rangle∣a⟩, where RjR_jRj​ is the one-bit gate (4.2) on bit jjj and Sj,kS_{j,k}Sj,k​ is the two-bit phase gate (4.3) on bits j<kj < kj<k with angle π/2k−j\pi/2^{k-j}π/2k−j. Then the amplitude of ∣b⟩|b\rangle∣b⟩ in the resulting state is

12l/2exp⁡ ⁣(i(∑0≤j<lπ ajbj+∑0≤j<k<lπ2k−j ajbk)).\frac{1}{2^{l/2}}\exp\!\Big( i \Big( \sum_{0 \le j < l} \pi\, a_j b_j + \sum_{0 \le j < k < l} \frac{\pi}{2^{k-j}}\, a_j b_k \Big) \Big).2l/21​exp(i(0≤j<l∑​πaj​bj​+0≤j<k<l∑​2k−jπ​aj​bk​)).

The factor 2−l/2=q−1/22^{-l/2} = q^{-1/2}2−l/2=q−1/2 collects the factors 1/21/\sqrt21/2​ of the lll gates RjR_jRj​, and the phase is Shor's expression (4.5): RjR_jRj​ contributes π\piπ when aj=bj=1a_j = b_j = 1aj​=bj​=1, and Sj,kS_{j,k}Sj,k​ contributes π/2k−j\pi/2^{k-j}π/2k−j when the input bit aja_jaj​ and the output bit bkb_kbk​ are both 111. That the second sum pairs aja_jaj​ with bkb_kbk​ records the order in which the gates act.

Formalization Note The circuit is run on the basis state ∣a⟩|a\rangle∣a⟩ and the conclusion is the amplitude at bbb. The prefactor is written (2l)−1(\sqrt{2^l})^{-1}(2l​)−1 and k−jk - jk−j is natural-number subtraction under j<kj < kj<k.

Preamble
import Mathlib
import Definitions.Def_ShorAlgorithms_QFT_BitStrings
import Definitions.Def_ShorAlgorithms_QFT_Circuit
Formal statement
namespace ShorAlgorithms.QFT

/-- Shor 1997, §4, eq. (4.5), p. 1496: the amplitude of going from `|a⟩` to `|b⟩` through the
gate sequence (4.4) is `2^{-l/2}` times `exp(i φ)`, where
`φ = ∑_{0 ≤ j < l} π a_j b_j + ∑_{0 ≤ j < k < l} (π / 2^{k-j}) a_j b_k`. -/
theorem path_amplitude (l : ℕ) (a b : Fin l → Fin 2) :
    runCircuit (qftGates l) (basisState a) b =
      ((Real.sqrt (2 ^ l) : ℝ) : ℂ)⁻¹ *
        Complex.exp
          (((∑ j : Fin l, Real.pi * ((a j : ℕ) : ℝ) * ((b j : ℕ) : ℝ)) +
              ∑ j : Fin l, ∑ k : Fin l,
                if j < k then
                  Real.pi / 2 ^ ((k : ℕ) - (j : ℕ)) * ((a j : ℕ) : ℝ) * ((b k : ℕ) : ℝ)
                else 0 : ℝ) * Complex.I) := by sorry

end ShorAlgorithms.QFT
Source
Shor, Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer, SIAM J. Comput. 26(5) (1997), p. 1496, §4, eq. (4.5) ("To show that this operation actually performs a quantum Fourier transform, consider the amplitude of going from |a⟩ …")
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