Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The shift circuit maps the pivot word of aaa to the codeword aGaGaG

Proved
OPI.SymEnc.lin_basis

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

lean-formalizationquantum-algorithmstwo-fold-opi-construction

Let K=FqK=\mathbb F_qK=Fq​ be given by a field presentation, each element encoded in LLL qubits. A register RRR consists of mmm blocks R1,…,RmR_1,\dots,R_mR1​,…,Rm​ of LLL qubits (jointly injective); a word d∈Kmd\in K^md∈Km is stored as encW(d)\mathrm{encW}(d)encW(d), block iii holding the encoding of did_idi​. Let G∈Kk×mG\in K^{k\times m}G∈Kk×m and let piv:{1,…,k}→{1,…,m}\mathrm{piv}:\{1,\dots,k\}\to\{1,\dots,m\}piv:{1,…,k}→{1,…,m} be injective with Gj,piv(j′)=[j=j′]G_{j,\mathrm{piv}(j')}=[j=j']Gj,piv(j′)​=[j=j′] (identity on the pivot columns, as for a basis in reduced row-echelon form). For a∈Kka\in K^ka∈Kk, vPiv(a)\mathrm{vPiv}(a)vPiv(a) is the word with aja_jaj​ in position piv(j)\mathrm{piv}(j)piv(j) and 000 elsewhere.

The circuit linCirc\mathrm{linCirc}linCirc performs, for every row jjj and every non-pivot column iii, the shift Ri+=Gji Rpiv(j)R_i \mathrel{+}= G_{ji}\,R_{\mathrm{piv}(j)}Ri​+=Gji​Rpiv(j)​ by table lookups, using a scratch register ZZZ of LLL qubits, ancillas asasas and a flag qubit fff. The layout hypotheses say that for each such pair the wires of Rpiv(j)R_{\mathrm{piv}(j)}Rpiv(j)​, RiR_iRi​, ZZZ, asasas, fff are pairwise distinct, ∣Z∣=L|Z|=L∣Z∣=L, 2L≤∣as∣+22L\le |as|+22L≤∣as∣+2, and no wire of RRR lies in ZZZ, asasas or equals fff.

Statement. For every a∈Kka\in K^ka∈Kk and every vector G0G_0G0​ on the remaining qubits that vanishes unless ZZZ, asasas, fff are all 000, the unitary of the compiled {H,T,CNOT}\{H,T,\mathrm{CNOT}\}{H,T,CNOT} circuit satisfies

UlinCirc(∣encW(vPiv(a))⟩R⊗G0)=∣encW(aG)⟩R⊗G0.U_{\mathrm{linCirc}}\big(|\mathrm{encW}(\mathrm{vPiv}(a))\rangle_R\otimes G_0\big)=|\mathrm{encW}(aG)\rangle_R\otimes G_0 .UlinCirc​(∣encW(vPiv(a))⟩R​⊗G0​)=∣encW(aG)⟩R​⊗G0​.

Here ∣y⟩R⊗G0|y\rangle_R\otimes G_0∣y⟩R​⊗G0​ denotes the vector z↦[z∣R=y] G0(z with R cleared)z\mapsto [z|_R=y]\,G_0(z\text{ with }R\text{ cleared})z↦[z∣R​=y]G0​(z with R cleared).

In the state preparation, a repeat-until-success step puts a uniform a∈Kka\in K^ka∈Kk into the pivot blocks of RRR; this circuit then turns ∑a∣vPiv(a)⟩\sum_a|\mathrm{vPiv}(a)\rangle∑a​∣vPiv(a)⟩ into ∑a∣aG⟩=∑d∈D∣d⟩\sum_a|aG\rangle=\sum_{d\in D}|d\rangle∑a​∣aG⟩=∑d∈D​∣d⟩ when the rows of GGG form a basis of DDD, without a separate coefficient register.

Preamble
import Definitions.Def_TwoFoldOPI_CL_Part02
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 OPI.SymEnc
open QAlgorithms
variable {N : ℕ}
open TwoFoldOPI
variable {F : AvgCaseTI.FieldPres} {n m kd : ℕ}
set_option hygiene false in
local notation "L" => bitsPerSymbol F
variable (Rr : Fin m → (Fin L ↪ Fin n)) (hRd : ∀ i i' j j', Rr i j = Rr i' j' → i = i' ∧ j = j')
  (piv : Fin kd → Fin m) (hpivi : Function.Injective piv)
variable (G : Fin kd → Fin m → F.F) (hpiv : ∀ j j', G j (piv j') = if j = j' then 1 else 0)
  (Z as : List (Fin n)) (f : Fin n)
  (hnd : ∀ p : Fin kd × Fin m, (∀ j', piv j' ≠ p.2) → (List.ofFn (Rr (piv p.1)) ++ List.ofFn (Rr p.2) ++ Z ++ as ++ [f]).Nodup)
  (hZ : L = Z.length) (hlen : L + L ≤ as.length + 2)
  (hsc : ∀ i j, Rr i j ≠ f ∧ (∀ q ∈ Z, Rr i j ≠ q) ∧ ∀ q ∈ as, Rr i j ≠ q)
include hRd hpivi hpiv hnd hZ hlen hsc
Formal statement
theorem OPI.SymEnc.lin_basis (a : Fin kd → F.F) (G0 : Qubits n → ℂ) (hG0 : ∀ z, G0 z ≠ 0 → scrClean Z as f z) :
    (Circuit.unitary (revCirc (linCirc Rr piv G Z as f))).mulVec
        (bfac (wRof (F := F) Rr hRd) (fun y => if y = encW F m (vPiv piv a) then 1 else 0) G0) =
      bfac (wRof (F := F) Rr hRd) (fun y => if y = encW F m (Matrix.vecMul a G) then 1 else 0) G0 := by sorry
Source
Formalization of Theorem 7.4 (algorithmic part), repository https://github.com/sragavan99/lean-prove2me-fills/blob/db81d0d4e3fa008609ed37789a2eb2f6f08ee48d/WorkInProgress/QuantumOPIVariants/OPI/PrepState.lean#L263-L307

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