Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The quantum program's first-order segment equals the generated segment

Proved
OPI.Gen.quantSeg_G

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

lean-formalizationquantum-algorithmstwo-fold-opi-construction

Setting. An instance xxx of the two-fold OPI problem of Theorem 7.4 consists of a finite field F=Fp[X]/(f)F=\mathbb F_p[X]/(f)F=Fp​[X]/(f) (e=deg⁡fe=\deg fe=degf, q=peq=p^eq=pe, LLL bits per symbol), a length mmm, a matrix HHH with a flag gen\mathrm{gen}gen defining a code CCC, forbidden values β∈Fm\beta\in F^mβ∈Fm and a precision ttt. Let D=C⊥D=C^\perpD=C⊥ and B=t+mL+m+2L+12B=t+mL+m+2L+12B=t+mL+m+2L+12.

Programs are represented by first-order DAGs, which are lists of nodes (tag, fields, children). A segment is a function that, given a continuation node index kkk and a start position sss, returns the list of new nodes to append at positions s,s+1,…s,s+1,\dotss,s+1,…. The quantum program for D≠0D\ne0D=0 is given by the segment quantSeg(x)\mathrm{quantSeg}(x)quantSeg(x). It prepares the phase-gradient state and then runs a retry loop of trials, each consisting of state preparation, trial circuit and measurement. The parameters are fixed: precision and gradient width 2B2B2B; the classical cells used by the gradient preparation, by the trial flag and by the state preparation are all the last memory cell (index mLmLmL); the mLmLmL output bits go to the first mLmLmL memory cells; repeat-until-success cap R=Rpar(x)=2q (t+10+J)R=\mathrm{Rpar}(x)=2q\,(t+10+J)R=Rpar(x)=2q(t+10+J), where JJJ is the number of jobs; t+3t+3t+3 trials; and 2t+6+(2B−1)2t+6+(2B-1)2t+6+(2B−1) majority tests for the gradient.

The generator works only with natural numbers and lists. From the parsed input and an input length nnn it forms u=numsOf(n,parsedOf(x))u=\mathrm{numsOf}(n,\mathrm{parsedOf}(x))u=numsOf(n,parsedOf(x)) and the segment qSegG(u)\mathrm{qSegG}(u)qSegG(u).

Statement. If pe≤np^e\le npe≤n, then

quantSeg(x)=qSegG(numsOf(n,parsedOf(x)))\mathrm{quantSeg}(x)=\mathrm{qSegG}\big(\mathrm{numsOf}(n,\mathrm{parsedOf}(x))\big)quantSeg(x)=qSegG(numsOf(n,parsedOf(x)))

as functions N→N→\mathbb N\to\mathbb N\toN→N→ lists of nodes.

This lemma is used to show that the DAG produced by the generator represents the intended quantum program.

Preamble
import Definitions.Def_TwoFoldOPI_CL_Part05
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.Gen
open QAlgorithms QAlgorithms.OPI TwoFoldOPI Lay TD RRefC FM SymEnc
local notation "vl" => List.map Fin.val
variable (x : Input) (n : ℕ) (hq : x.F.p ^ x.F.f.natDegree ≤ n)
include hq
set_option maxHeartbeats 1000000
Formal statement
theorem OPI.Gen.quantSeg_G :
    quantSeg x.F x.m (2 * Bpar x.t x.m (bitsPerSymbol x.F)) (2 * Bpar x.t x.m (bitsPerSymbol x.F) - 1) x.gen x.H
      (tB_pos x.F x.m x.t) (tB_le x.F x.m x.t) x.β (Fin.last _) (Fin.last _) (Fin.last _) Fin.castSucc
      (Rpar x.F x.m x.gen x.H x.t x.β) (x.t + 3) (2 * x.t + 6 + (2 * Bpar x.t x.m (bitsPerSymbol x.F) - 1)) =
    qSegG (numsOf n (parsedOf x)) := by sorry
Source
Formalization of Theorem 7.4 (algorithmic part), repository https://github.com/sragavan99/lean-prove2me-fills/blob/f7224a159e790347c1a83c5ac23c63e5094a6a2c/WorkInProgress/QuantumOPIVariants/OPI/IRGenRep.lean#L21-L35

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