Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The trial circuit as an explicit list of natural-number gate fields

Proved
OPI.Lay.trialCirc_N

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

lean-formalizationquantum-algorithmstwo-fold-opi-construction

Let F=Fp[x]/(f)F = \mathbb{F}_p[x]/(f)F=Fp​[x]/(f) with e=deg⁡fe = \deg fe=degf and LLL bits per field symbol, let H∈Fr×mH \in F^{r\times m}H∈Fr×m and gen∈{true,false}\mathrm{gen} \in \{\mathrm{true}, \mathrm{false}\}gen∈{true,false} describe the code CCC (row space of HHH if gen\mathrm{gen}gen, kernel of HHH otherwise), and let D=C⊥D = C^\perpD=C⊥. Let GGG be the computed basis of DDD (with kDk_DkD​ rows) and bWb_WbW​ the kD2k_D^2kD2​ pairwise Schur products of its rows. For parameters t≥1t \ge 1t≥1, b=b′+1≥tb = b'+1 \ge tb=b′+1≥t, a fixed wire layout (with NNNNNN system wires and its natural-number description XXX) and a target β∈Fm\beta \in F^mβ∈Fm, the trial circuit over {H,T,CNOT}\{H, T, \mathrm{CNOT}\}{H,T,CNOT} is

trialCirc(β)=Decβ  ⋅  Sub  ⋅  Decβ−1,\mathrm{trialCirc}(\beta) = \mathrm{Dec}_\beta \;\cdot\; \mathrm{Sub} \;\cdot\; \mathrm{Dec}_\beta^{-1},trialCirc(β)=Decβ​⋅Sub⋅Decβ−1​,

where Decβ\mathrm{Dec}_\betaDecβ​ is the full decoder circuit (per-coordinate gadgets using the table of x↦βi−xx \mapsto \beta_i - xx↦βi​−x, two QFTq\mathrm{QFT}_qQFTq​ gadgets per coordinate, then the compiled classical relinearization decoder with constants GGG, bWb_WbW​), and Sub\mathrm{Sub}Sub subtracts each decoder output register from the corresponding register RiR_iRi​. Gates are written as lists of naturals ([0,q][0,q][0,q]: HHH, [1,q][1,q][1,q]: TTT, [2,c,t][2,c,t][2,c,t]: CNOT).

Statement. For every Nf≥peN_f \ge p^eNf​≥pe and β∈Fm\beta \in F^mβ∈Fm, the gate-field list of trialCirc(β)\mathrm{trialCirc}(\beta)trialCirc(β) equals

trialCN(D,S)=D ∥ S ∥ flatMap invF (reverse D),\mathrm{trialCN}(\mathcal{D}, \mathcal{S}) = \mathcal{D} \,\|\, \mathcal{S} \,\|\, \mathrm{flatMap}\ \mathrm{invF}\ (\mathrm{reverse}\ \mathcal{D}),trialCN(D,S)=D∥S∥flatMap invF (reverse D),

where invF\mathrm{invF}invF inverts a gate field (T↦T7T \mapsto T^7T↦T7, HHH and CNOT unchanged), D=decCircN(…)\mathcal{D} = \mathrm{decCircN}(\ldots)D=decCircN(…) is the explicit decoder gate list built from the shared QFTq\mathrm{QFT}_qQFTq​ data, the controlled-swap tables, the coordinate data cDataN(X,⋅,i)\mathrm{cDataN}(X, \cdot, i)cDataN(X,⋅,i) for i<mi < mi<m, and the first-order classical decoder clsCN(RSN(X,…),blkN(X,27),offN(X,28),clsTabs(…progI…))\mathrm{clsCN}(\mathrm{RSN}(X,\ldots), \mathrm{blkN}(X,27), \mathrm{offN}(X,28), \mathrm{clsTabs}(\ldots\mathrm{progI}\ldots))clsCN(RSN(X,…),blkN(X,27),offN(X,28),clsTabs(…progI…)), and S=subAllCN(…)\mathcal{S} = \mathrm{subAllCN}(\ldots)S=subAllCN(…) is the explicit subtraction gate list with output registers rsOfN(X,…,outId(i))\mathrm{rsOfN}(X,\ldots,\mathrm{outId}(i))rsOfN(X,…,outId(i)), target registers RrN(X,i)\mathrm{RrN}(X,i)RrN(X,i), layout blocks 12,13,1412, 13, 1412,13,14 and the tables of B↦B∓dec(c)B \mapsto B \mp \mathrm{dec}(c)B↦B∓dec(c).

All wire indices and the decoder program are now natural-number data computed from XXX; only some lookup tables are still given by functions on FFF (they are replaced by budgeted twins in a later step). This connects the abstract trial circuit to the gate list output by the generator.

Preamble
import Definitions.Def_TwoFoldOPI_CL_Part04
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.Lay
open QAlgorithms QAlgorithms.OPI TwoFoldOPI SymEnc
local notation "vl" => List.map Fin.val
variable (F : AvgCaseTI.FieldPres) (m t b' : ℕ) {r : ℕ} (gen : Bool) (H : Matrix (Fin r) (Fin m) F.F)
local notation "KD" => kdOf F m gen H
local notation "nJ" => SymEnc.nIds m (kdOf F m gen H) (kdOf F m gen H * kdOf F m gen H)
local notation "PQ" => parOf F m t (b' + 1) (SymEnc.nIds m (kdOf F m gen H) (kdOf F m gen H * kdOf F m gen H))
local notation "XQ" => toN (parOf F m t (b' + 1) (SymEnc.nIds m (kdOf F m gen H) (kdOf F m gen H * kdOf F m gen H)))
local notation "NN" => total (parOf F m t (b' + 1) (SymEnc.nIds m (kdOf F m gen H) (kdOf F m gen H * kdOf F m gen H)))
local notation "BB" => GEP.Bd m (kdOf F m gen H + kdOf F m gen H * kdOf F m gen H)
variable (ht : 1 ≤ t) (htb : t ≤ b' + 1)
set_option maxHeartbeats 1000000
Formal statement
theorem OPI.Lay.trialCirc_N (Nf : ℕ) (hNf : F.p ^ F.f.natDegree ≤ Nf) (β : Fin m → F.F) :
    (trialCirc F m t b' gen H ht htb β).map gfields =
      trialCN
        (decCircN (shOf F NN (b' + 1) t)
          (pgTab (1 + (bitsPerSymbol F + bitsPerSymbol F)) 1 (cswF (bitsPerSymbol F)))
          (pgTab (1 + 2 * bitsPerSymbol F) 1 (cswF (bitsPerSymbol F)))
          ((List.range m).map (fun i => cDataN XQ
            (pgTab (bitsPerSymbol F) 0 (pFun (elemBits F) (fun x => (if h : i < m then β ⟨i, h⟩ else 0) - x))) i))
          (clsCN (RSN XQ m BB nJ) (blkN XQ 27) (offN XQ 28)
            (FM.clsTabs (FM.ctxOf F Nf) (Fq.w F) (bitsPerSymbol F)
              (FM.progI m (KD + KD * KD) KD (fun j o => FM.matI F.f.natDegree KD m (FM.matE F (basisOf gen H).G) j o)
                (RelinProg.a0src m KD (KD * KD))
                (FM.a0opI F.f.natDegree KD (KD * KD) m (FM.matE F (basisOf gen H).G) (FM.matE F (bWof gen H)))))))
        (subAllCN ((List.range m).map (fun i => rsOfN XQ m BB nJ (RelinProg.outId (m := m) (k := KD) (k2 := KD * KD) i)))
          ((List.range m).map (RrN XQ)) (blkN XQ 12) (blkN XQ 13) (offN XQ 14)
          (pgTab (bitsPerSymbol F + bitsPerSymbol F) (bitsPerSymbol F) (fShift F (-1)))
          (pgTab (bitsPerSymbol F + bitsPerSymbol F) (bitsPerSymbol F) (fShift F 1))) := by sorry
Source
Formalization of Theorem 7.4 (algorithmic part), repository https://github.com/sragavan99/lean-prove2me-fills/blob/f7224a159e790347c1a83c5ac23c63e5094a6a2c/WorkInProgress/QuantumOPIVariants/OPI/IRTrialN.lean#L92-L128

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