Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Grids of two-continuation segments represent a two-branch recursion as a DAG

Proved
OPI.grid_rep

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

lean-formalizationquantum-algorithmstwo-fold-opi-construction

Programs are serialised as first-order DAGs, i.e. lists of nodes, where Rep(D,i,P)\mathrm{Rep}(D,i,P)Rep(D,i,P) says that node iii of the list DDD represents the program PPP: the node has the head of PPP, and its children have smaller indices and represent the subprograms of PPP. A two-continuation segment TTT maps two continuation indices k0,k1k_0,k_1k0​,k1​ and a start position to a list of nodes. It is valid for a binary program transformer F\mathcal FF if, whenever k0,k1k_0,k_1k0​,k1​ represent P0,P1P_0,P_1P0​,P1​ in DDD, appending T(k0,k1,∣D∣)T(k_0,k_1,|D|)T(k0​,k1​,∣D∣) to DDD gives a nonempty block whose last node represents F(P0,P1)\mathcal F(P_0,P_1)F(P0​,P1​). Assume every block of TTT has the same length S≥1S\ge1S≥1.

Let G(r,s)G(r,s)G(r,s) be programs with G(r+1,s)=F(G(r,s),G(r,s+1))G(r+1,s)=\mathcal F(G(r,s),G(r,s+1))G(r+1,s)=F(G(r,s),G(r,s+1)). Level 000 is given: DDD has length BBB, and node lev0(s)\mathrm{lev}_0(s)lev0​(s) represents G(0,s)G(0,s)G(0,s) for s≤Nts\le N_ts≤Nt​. The grid with RRR levels appends, for r<Rr<Rr<R and s≤Nts\le N_ts≤Nt​, the block TTT at position B+(r(Nt+1)+s)SB+(r(N_t+1)+s)SB+(r(Nt​+1)+s)S, with continuations the nodes (r,s)(r,s)(r,s) and (r,s+1)(r,s+1)(r,s+1). The node index of (r+1,s)(r+1,s)(r+1,s) is B+(r(Nt+1)+s)S+S−1B+(r(N_t+1)+s)S+S-1B+(r(Nt​+1)+s)S+S−1. The theorem states that for all RRR, all r≤Rr\le Rr≤R and all sss with s+r≤Nts+r\le N_ts+r≤Nt​,

Rep(D+ ⁣ ⁣+gridR, idx(r,s), G(r,s)).\mathrm{Rep}\bigl(D\mathbin{+\!\!+}\mathrm{grid}_R,\ \mathrm{idx}(r,s),\ G(r,s)\bigr).Rep(D++gridR​, idx(r,s), G(r,s)).

This is used for the majority votes of the gradient preparation, where G(r+1,s)G(r+1,s)G(r+1,s) is a measured test continuing with G(r,s)G(r,s)G(r,s) or G(r,s+1)G(r,s+1)G(r,s+1). Sharing the subprograms gives a DAG with O(Nt2)O(N_t^2)O(Nt2​) blocks instead of a tree of size 2Nt2^{N_t}2Nt​. This keeps the generated program description polynomial.

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
open QAlgorithms QAlgorithms.OPI
variable {N c out : ℕ}
variable (T : ISeg2) (Nt S B : ℕ) (lev0 : ℕ → ℕ) (hS : ∀ k0 k1 st, (T k0 k1 st).length = S)
include hS
Formal statement
theorem OPI.grid_rep (F : Prog N c out → Prog N c out → Prog N c out) (hT : T.Valid F) (hS1 : 1 ≤ S)
    (G : ℕ → ℕ → Prog N c out) (hG : ∀ r s, G (r + 1) s = F (G r s) (G r (s + 1)))
    (D : List INode) (hB : D.length = B) (h0 : ∀ s ≤ Nt, Rep D (lev0 s) (G 0 s)) :
    ∀ R, ∀ r ≤ R, ∀ s, s + r ≤ Nt → Rep (D ++ gridNodes T Nt S B lev0 R) (gidx Nt S B lev0 r s) (G r s) := by sorry
Source
Formalization of Theorem 7.4 (algorithmic part), repository https://github.com/sragavan99/lean-prove2me-fills/blob/db81d0d4e3fa008609ed37789a2eb2f6f08ee48d/WorkInProgress/QuantumOPIVariants/OPI/Grid.lean#L55-L106

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