Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The state after all repeat-until-success jobs of the preparation

Proved
OPI.SymEnc.rus_state

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

lean-formalizationquantum-algorithmstwo-fold-opi-construction

Work in the qubit layout of the algorithm: field symbols are written with LLL qubits via the encoding enc\mathrm{enc}enc. The registers are the symbol pairs (Si,Ti)(S_i,T_i)(Si​,Ti​), i≤mi\le mi≤m, the word register R=(R1,…,Rm)R=(R_1,\dots,R_m)R=(R1​,…,Rm​), and the resource registers of the QFT gadgets. Let piv:{1..kD}→{1..m}\mathrm{piv}:\{1..k_D\}\to\{1..m\}piv:{1..kD​}→{1..m} be injective (pivot coordinates). Assume the RRR wires are pairwise distinct and disjoint from the symbol registers and the resource registers, and q≥2q\ge2q≥2.

The preparation runs three kinds of repeat-until-success jobs. On success, each job leaves an unnormalised factor on its register:

  • each pivot register Rpiv(j)R_{\mathrm{piv}(j)}Rpiv(j)​ gets 2−L/22^{-L/2}2−L/2 times the indicator of a valid symbol encoding;
  • each resource register gets 2−k/22^{-k/2}2−k/2 times the indicator of a value <p<p<p;
  • each SiS_iSi​ gets 2−L/22^{-L/2}2−L/2 times the indicator of "valid and ≠βi\ne\beta_i=βi​".

Statement. Applying all these factors to the all-zero state gives

cAll∑a∈FkD∣vPiv(a)⟩R⊗RS(J(⨂i∣Aβi⟩Si∣0⟩Ti)).c_{\mathrm{All}}\sum_{a\in\mathbb F^{k_D}}|\mathrm{vPiv}(a)\rangle_R\otimes \mathrm{RS}\Bigl(J\bigl(\textstyle\bigotimes_i |A_{\beta_i}\rangle_{S_i}|0\rangle_{T_i}\bigr)\Bigr).cAll​a∈FkD​∑​∣vPiv(a)⟩R​⊗RS(J(⨂i​∣Aβi​​⟩Si​​∣0⟩Ti​​)).

Here vPiv(a)\mathrm{vPiv}(a)vPiv(a) is the word with aja_jaj​ at coordinate piv(j)\mathrm{piv}(j)piv(j) and 000 elsewhere, and ∣Aβ⟩=(q−1)−1/2∑y≠β∣y⟩|A_\beta\rangle=(q-1)^{-1/2}\sum_{y\ne\beta}|y\rangle∣Aβ​⟩=(q−1)−1/2∑y=β​∣y⟩. JJJ embeds symbol-level states into qubits, and RS\mathrm{RS}RS places the normalised resource states ∣up⟩|u_p\rangle∣up​⟩ on all resource registers. The scalar is cAll=(2−L/2)kD∏res2−k/2p ⋅(2−L/2q−1)mc_{\mathrm{All}}=(2^{-L/2})^{k_D}\prod_{\text{res}}2^{-k/2}\sqrt p\,\cdot\bigl(2^{-L/2}\sqrt{q-1}\bigr)^mcAll​=(2−L/2)kD​∏res​2−k/2p​⋅(2−L/2q−1​)m.

This identifies the output of the first preparation stage. It is uniform over the pivot coordinates of RRR, which the linear map R↦RGR\mapsto RGR↦RG then turns into the uniform superposition over DDD.

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 TwoFoldOPI
variable {n : ℕ}
variable {F : AvgCaseTI.FieldPres} {m kd : ℕ}
set_option hygiene false in
local notation "L" => bitsPerSymbol F
variable {b t : ℕ} {reg : Fin m × Bool × Fin L ↪ Fin n} (D : RealDec F reg b t)
open Classical
Formal statement
theorem OPI.SymEnc.rus_state (hq : 2 ≤ Fintype.card F.F) (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) (β : Fin m → F.F)
    (hRreg : ∀ i j p, reg p ≠ Rr i j) (hRres : ∀ r ∈ resAll D, ∀ i j, Rr i j ∉ Set.range r.w) :
    bfacL ((allJobs D Rr piv β).map RJob.res) (sysZero n) =
      cAll D kd • ∑ a : Fin kd → F.F, bfac (wRof (F := F) Rr hRd)
        (fun y => if y = encW F m (vPiv piv a) then 1 else 0) (RSall D (J reg (elemBits F) (prodF (gA β)))) := by sorry
Source
Formalization of Theorem 7.4 (algorithmic part), repository https://github.com/sragavan99/lean-prove2me-fills/blob/db81d0d4e3fa008609ed37789a2eb2f6f08ee48d/WorkInProgress/QuantumOPIVariants/OPI/PrepAll.lean#L113-L154

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