Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Phase estimation on ∣0⟩⊗2n∣ψj⟩|0\rangle^{\otimes 2n}|\psi_j\rangle∣0⟩⊗2n∣ψj​⟩: output ∣ϕj⟩∣ψj⟩|\phi_j\rangle|\psi_j\rangle∣ϕj​⟩∣ψj​⟩ with pk≥4/π2p_k \ge 4/\pi^2pk​≥4/π2 at the optimal kkk

Proved
ShorWiki.phaseEstimation_eigState

by Lucas · Oct 13, 2026 · Mathlib 0df444a (Lean v4.33.1)

quantum-computingshor-algorithm

Let 1<a<N1 < a < N1<a<N with gcd⁡(a,N)=1\gcd(a,N)=1gcd(a,N)=1, r=ord⁡N(a)r = \operatorname{ord}_N(a)r=ordN​(a), n=⌈log⁡2N⌉n = \lceil\log_2 N\rceiln=⌈log2​N⌉, and 0≤j<r0 \le j < r0≤j<r. Apply the phase estimation circuit for the modular-multiplication gate, with a 2n2n2n-qubit first register, to ∣0⟩⊗2n∣ψj⟩|0\rangle^{\otimes 2n}|\psi_j\rangle∣0⟩⊗2n∣ψj​⟩. Then there is a state ∣ϕj⟩|\phi_j\rangle∣ϕj​⟩ of the first register such that:

  1. the output is the product state ∣ϕj⟩∣ψj⟩|\phi_j\rangle|\psi_j\rangle∣ϕj​⟩∣ψj​⟩;
  2. for every k∈{0,…,22n−1}k \in \{0,\dots,2^{2n}-1\}k∈{0,…,22n−1} with ∣k22n−jr∣≤122n+1\left|\frac{k}{2^{2n}} - \frac{j}{r}\right| \le \frac{1}{2^{2n+1}}​22nk​−rj​​≤22n+11​ (a nearest integer to 22nj/r2^{2n}j/r22nj/r),
pk=∣⟨k∣ϕj⟩∣2≥4π2.p_k = |\langle k|\phi_j\rangle|^2 \ge \frac{4}{\pi^2}.pk​=∣⟨k∣ϕj​⟩∣2≥π24​.

This is the guarantee of quantum phase estimation specialised to the eigenstates of UUU.

Formalization Note The article writes p22nj/rp_{2^{2n}j/r}p22nj/r​, which is meaningful only when 22nj/r2^{2n}j/r22nj/r is an integer; it is formalized as the probability of any nearest integer kkk to 22nj/r2^{2n}j/r22nj/r, the "optimal bitstring" of the section Choosing the size of the first register.

Preamble
import Mathlib
import Definitions.Def_ShorWiki_Defs

open Matrix Kronecker
Formal statement
namespace ShorWiki

theorem phaseEstimation_eigState (N a : ℕ) (ha : 1 < a) (haN : a < N)
    (hcop : Nat.Coprime a N) (j : ℕ) (hj : j < ord N a) :
    ∃ φ : Fin (2 ^ (2 * regBits N)) → ℂ,
      phaseEstimationCircuit N a (regBits N) (2 * regBits N) *ᵥ
          tensorState (ket (2 ^ (2 * regBits N)) 0) (eigState N a (regBits N) j)
        = tensorState φ (eigState N a (regBits N) j) ∧
      ∀ k : Fin (2 ^ (2 * regBits N)),
        |((k : ℕ) : ℝ) / 2 ^ (2 * regBits N) - (j : ℝ) / ord N a|
            ≤ 1 / 2 ^ (2 * regBits N + 1) →
          4 / Real.pi ^ 2 ≤ ‖φ k‖ ^ 2 := by sorry

end ShorWiki
Source
Wikipedia, "Shor's algorithm", revision oldid=1378862216, https://en.wikipedia.org/w/index.php?title=Shor%27s_algorithm&oldid=1378862216, section "Quantum phase estimation" (PDF p. 5)
Human review
  • Endorsed by Shuze Chen · Oct 13, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Lucas · Oct 13, 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