Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Gate list of the compiled classical relinearization decoder in first-order form

Proved
OPI.FM.clsGatesC_FM

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; a field element is stored as a symbol of LLL bits (its eee power-basis coordinates, w=⌈log⁡2p⌉w = \lceil \log_2 p\rceilw=⌈log2​p⌉ bits each, so L=e wL = e\,wL=ew). The classical part of the decoder is a straight-line program decProg(bD,bW)\mathrm{decProg}(b_D, b_W)decProg(bD​,bW​) over FFF (relinearization by Gaussian elimination), whose constants are a basis bDb_DbD​ (kkk rows) of the dual code DDD and the vectors bWb_WbW​ (k2k_2k2​ rows) spanning its Schur square. A layout CCC assigns to every straight-line id xxx a register C.rs(x)C.\mathrm{rs}(x)C.rs(x) of LLL wires, a list of ancilla wires C.asC.\mathrm{as}C.as and a flag wire C.f0C.f_0C.f0​. The reversible circuit clsGates(C,bD,bW)\mathrm{clsGates}(C, b_D, b_W)clsGates(C,bD​,bW​) (X, CNOT, Toffoli) compiles each instruction into a table lookup; revCirc\mathrm{revCirc}revCirc turns it into a circuit over {H,T,CNOT}\{H, T, \mathrm{CNOT}\}{H,T,CNOT}, and gfields\mathrm{gfields}gfields writes each gate as a list of naturals ([0,q][0,q][0,q] for HHH, [1,q][1,q][1,q] for TTT, [2,c,t][2,c,t][2,c,t] for CNOT).

Statement. Let N≥peN \ge p^eN≥pe and let RSRSRS be a list of wire lists with RS[x]RS[x]RS[x] (default [ ][\,][]) equal to the wire indices of C.rs(x)C.\mathrm{rs}(x)C.rs(x) for every xxx. Then the list of gate fields of revCirc(clsGates(C,bD,bW))\mathrm{revCirc}(\mathrm{clsGates}(C,b_D,b_W))revCirc(clsGates(C,bD​,bW​)) equals

clsCN(RS, C.as, C.f0, clsTabs(ctxN,w,L,progI)),\mathrm{clsCN}\big(RS,\ C.\mathrm{as},\ C.f_0,\ \mathrm{clsTabs}(\mathrm{ctx}_N, w, L, \mathrm{progI})\big),clsCN(RS, C.as, C.f0​, clsTabs(ctxN​,w,L,progI)),

where progI\mathrm{progI}progI is the first-order (natural-number) form of the decoder program, with instructions (destination,sources,opcode)(\text{destination}, \text{sources}, \text{opcode})(destination,sources,opcode) and with the matrices bDb_DbD​, bWb_WbW​ given by their coordinate lists; clsTabs\mathrm{clsTabs}clsTabs attaches to each instruction its lookup table over all bit patterns of the source registers, computed in the context ctxN=(p,e,coefficients of f,N)\mathrm{ctx}_N = (p, e, \text{coefficients of } f, N)ctxN​=(p,e,coefficients of f,N) (decode each block to coordinates, apply the opcode, re-encode); and clsCN\mathrm{clsCN}clsCN is the explicit natural-number compilation of table lookups into H/T/CNOTH/T/\mathrm{CNOT}H/T/CNOT gate fields.

This removes every field-valued object from the classical decoder part of the circuit, so this part can be output by the polynomial-time generator, which only manipulates natural numbers.

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.FM
open QAlgorithms OPI.W6
local notation "vl" => List.map Fin.val
open TwoFoldOPI SymEnc GEP RelinProg
variable (F : AvgCaseTI.FieldPres) (N : ℕ)
Formal statement
theorem OPI.FM.clsGatesC_FM (hN : F.p ^ F.f.natDegree ≤ N) {n m k k2 : ℕ}
    {reg : Fin m × Bool × Fin (bitsPerSymbol F) ↪ Fin n}
    (C : ClsLay reg (elemBits F) (decodeElem F) (Fq.decode_elemBits F) k k2)
    (bD : Fin k → Fin m → F.F) (bW : Fin k2 → Fin m → F.F)
    (RS : List (List ℕ)) (hRS : ∀ x, vl (C.rs x) = RS.getD x []) :
    (revCirc (clsGates C bD bW)).map gfields =
      clsCN RS (vl C.as) C.f0.val (clsTabs (ctxOf F N) (Fq.w F) (bitsPerSymbol F)
        (progI m (k + k2) k (fun j o => matI F.f.natDegree k m (matE F bD) j o) (a0src m k k2)
          (a0opI F.f.natDegree k k2 m (matE F bD) (matE F bW)))) := by sorry
Source
Formalization of Theorem 7.4 (algorithmic part), repository https://github.com/sragavan99/lean-prove2me-fills/blob/f7224a159e790347c1a83c5ac23c63e5094a6a2c/WorkInProgress/QuantumOPIVariants/OPI/IRDecCls.lean#L137-L147

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