Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Measuring the first register: each ∣ϕj⟩|\phi_j\rangle∣ϕj​⟩ appears with probability 1/r1/r1/r

Proved
ShorWiki.measureFirst_orderFindingOutput

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) and n=⌈log⁡2N⌉n = \lceil\log_2 N\rceiln=⌈log2​N⌉. Let P(k)P(k)P(k) be the probability of outcome kkk when the first register of the order-finding output state (phase estimation applied to ∣0⟩⊗2n∣1⟩|0\rangle^{\otimes 2n}|1\rangle∣0⟩⊗2n∣1⟩) is measured, and let Pj(k)P_j(k)Pj​(k) be the corresponding probability for the output of phase estimation applied to ∣0⟩⊗2n∣ψj⟩|0\rangle^{\otimes 2n}|\psi_j\rangle∣0⟩⊗2n∣ψj​⟩. Then for every kkk,

P(k)=1r∑j=0r−1Pj(k).P(k) = \frac{1}{r}\sum_{j=0}^{r-1} P_j(k).P(k)=r1​j=0∑r−1​Pj​(k).

So the measurement on the actual input ∣1⟩|1\rangle∣1⟩ behaves as if a uniformly random j∈{0,…,r−1}j \in \{0,\dots,r-1\}j∈{0,…,r−1} had been chosen first and phase estimation then run on ∣ψj⟩|\psi_j\rangle∣ψj​⟩.

Preamble
import Mathlib
import Definitions.Def_ShorWiki_Defs

open Matrix Kronecker
Formal statement
namespace ShorWiki

theorem measureFirst_orderFindingOutput (N a : ℕ) (ha : 1 < a) (haN : a < N)
    (hcop : Nat.Coprime a N) (k : Fin (2 ^ (2 * regBits N))) :
    measureFirst (orderFindingOutput N a) k
      = (1 / (ord N a : ℝ)) * ∑ j ∈ Finset.range (ord N a),
          measureFirst (phaseEstimationCircuit N a (regBits N) (2 * regBits N) *ᵥ
            tensorState (ket (2 ^ (2 * regBits N)) 0) (eigState N a (regBits N) j)) k := 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