Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

A list of controlled modular shifts adds up to one shift by the controlled sum

Proved
OPI.csList_spec

by sragavan · Nov 11, 2026 · Mathlib 0df444a (Lean v4.33.1)

lean-formalizationquantum-algorithmstwo-fold-opi-construction

Work with classical bit configurations z∈{0,1}nz\in\{0,1\}^nz∈{0,1}n. Let BBB be a register of www qubits holding a residue modulo ppp in binary (most significant bit first), with 0<p≤2w0<p\le 2^w0<p≤2w. For s∈Ns\in\mathbb Ns∈N, the modular shift shifts\mathrm{shift}_sshifts​ maps a www-bit string yyy of value v<pv<pv<p to the binary expansion of (v+s) mod p(v+s)\bmod p(v+s)modp, and fixes strings of value ≥p\ge p≥p.

csList(L)\mathrm{csList}(L)csList(L) is a reversible circuit built from a list LLL of pairs (c,k)(c,k)(c,k) (control qubit ccc, amount kkk). For each pair it applies the in-place gadget "if c=1c=1c=1, shift BBB by kkk", implemented by table lookups with a scratch register ZZZ (www qubits), ancillas asasas and a flag fff.

Statement. Assume ∣B∣=∣Z∣=w|B|=|Z|=w∣B∣=∣Z∣=w, 1+w≤∣as∣+21+w\le|as|+21+w≤∣as∣+2, the wires of B,Z,as,fB,Z,as,fB,Z,as,f are pairwise distinct, and no control qubit lies among them. If ZZZ, asasas and fff are 000 in zzz, then

csList(L)(z)=z[B←shifts(z∣B)],s=∑(c,k)∈Lzc k,\mathrm{csList}(L)(z)=z\Big[B\leftarrow \mathrm{shift}_{s}(z|_B)\Big],\qquad s=\sum_{(c,k)\in L} z_c\,k ,csList(L)(z)=z[B←shifts​(z∣B​)],s=(c,k)∈L∑​zc​k,

and all other wires, including the controls and the scratch, are unchanged.

With the controls being the ttt qubits of a register CCC and amounts 2t−1,…,2,12^{t-1},\dots,2,12t−1,…,2,1, the sum sss is the value of CCC. The circuit is then the controlled power ∑ℓ∣ℓ⟩⟨ℓ∣C⊗shiftℓ\sum_\ell|\ell\rangle\langle\ell|_C\otimes \mathrm{shift}^\ell∑ℓ​∣ℓ⟩⟨ℓ∣C​⊗shiftℓ used in phase estimation inside the QFTp\mathrm{QFT}_pQFTp​ gadget.

Preamble
import Definitions.Def_TwoFoldOPI_CL_Part01
import Mathlib
import Definitions.Def_QAlgorithms_Defs_Circuit
import Definitions.Def_QAlgorithms_Defs_GradientMethods
import Definitions.Def_QAlgorithms_Defs_OPIOraclePrograms
import Definitions.Def_QAlgorithms_Defs_OPIUniformity
import Definitions.Def_QAlgorithms_Defs_Fourier
import Definitions.Def_TwoFoldOPI_elemBits
import Definitions.Def_TwoFoldOPI_schurSquare
import Definitions.Def_TwoFoldOPI_schurFailureSum
import Definitions.Def_CodingTheory
import Definitions.Def_OAIThreeMachineSched01
import Definitions.Def_CookLevin_Cost
import Definitions.Def_TwoFoldOPI_codeOf
import Definitions.Def_TwoFoldOPI_solves
import Definitions.Def_TwoFoldOPI_Input
import Definitions.Def_TwoFoldOPI_CLSerializableF
open OPI
open QAlgorithms Matrix
variable {n : ℕ}
Formal statement
theorem OPI.csList_spec (p w : ℕ) (hp : 0 < p) (hpw : p ≤ 2 ^ w) (Bl Z as : List (Fin n))
    (f : Fin n) (hBl : Bl.length = w) (hZ : Z.length = w) (has : 1 + w ≤ as.length + 2)
    (hnd : (Bl ++ Z ++ as ++ [f]).Nodup) :
    ∀ L : List (Fin n × ℕ), (∀ ck ∈ L, ck.1 ∉ Bl ++ Z ++ as ++ [f]) →
    ∀ z : Qubits n, (∀ a ∈ Z ++ as ++ [f], z a = false) →
      revAct (csList p w Bl Z as f L) z =
        writeReg Bl (shiftL p w (L.map fun ck => if z ck.1 then ck.2 else 0).sum (Bl.map z)) z := by sorry
Source
Formalization of Theorem 7.4 (algorithmic part), repository https://github.com/sragavan99/lean-prove2me-fills/blob/db81d0d4e3fa008609ed37789a2eb2f6f08ee48d/WorkInProgress/QuantumOPIVariants/OPI/QPE.lean#L142-L204

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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me