Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The gradient algorithm for approximately linear functions

Proved
QAlgorithms.Nannicini.gradientAlg_approxLinear

by Goku · Oct 13, 2026 · Mathlib 0df444a (Lean v4.33.1)

lecture-notesnanniciniquantum-information

This proposition is the gradient algorithm for approximately linear functions.

Let q≥1q \ge 1q≥1 and d≥0d \ge 0d≥0 be integers, b∈Rb \in \mathbb Rb∈R, and g∈Rdg \in \mathbb R^dg∈Rd with ∥g∥∞≤1/3\|g\|_\infty \le 1/3∥g∥∞​≤1/3. Let f:[−12,12]d→Rf : [-\tfrac12,\tfrac12]^d \to \mathbb Rf:[−21​,21​]d→R. Consider the grid

Gq={j2q−12+12q+1:j=0,…,2q−1},G_q = \Big\{ \tfrac{j}{2^q} - \tfrac12 + \tfrac{1}{2^{q+1}} : j = 0,\dots,2^q-1 \Big\},Gq​={2qj​−21​+2q+11​:j=0,…,2q−1},

where ȷ^\hat\jmath^​ denotes the grid point of the qqq-bit string jjj, and let GqdG_q^dGqd​ be the ddd-fold product grid with 2dq2^{dq}2dq points. Algorithm 3 does the following:

  1. It applies H⊗qH^{\otimes q}H⊗q to each of ddd registers of qqq qubits in ∣0⟩|0\rangle∣0⟩.
  2. It applies the phase oracle ∣x⟩↦e2πi2qf(x^)∣x⟩|x\rangle \mapsto e^{2\pi i 2^q f(\hat x)}|x\rangle∣x⟩↦e2πi2qf(x^)∣x⟩.
  3. It applies the inverse QGq†Q_{G_q}^\daggerQGq​†​ of the shifted Fourier transform QGq∣k⟩=2−q/2∑je2πi2qȷ^k^∣j⟩Q_{G_q}|k\rangle = 2^{-q/2}\sum_j e^{2\pi i 2^q \hat\jmath \hat k}|j\rangleQGq​​∣k⟩=2−q/2∑j​e2πi2q^​k^∣j⟩ to each register.
  4. It measures the registers and outputs g~=(k^1,…,k^d)\tilde g = (\hat k_1,\dots,\hat k_d)g~​=(k^1​,…,k^d​).

If

∣f(x)−⟨g,x⟩−b∣≤120π2q|f(x) - \langle g, x\rangle - b| \le \frac{1}{20\pi 2^q}∣f(x)−⟨g,x⟩−b∣≤20π2q1​

holds for at least 99.9%99.9\%99.9% of the points x∈Gqdx \in G_q^dx∈Gqd​, then

Pr⁡(∣g~j−gj∣≤12q)>35for every j=1,…,d.\Pr\Big(|\tilde g_j - g_j| \le \frac{1}{2^q}\Big) > \frac35 \qquad \text{for every } j = 1,\dots,d.Pr(∣g~​j​−gj​∣≤2q1​)>53​for every j=1,…,d.

The result makes the gradient algorithm robust: fff need only be close to linear on most grid points, for instance when fff is evaluated by a circuit that sometimes fails.

Formalization Note fff is taken on all of Rd\mathbb R^dRd, because only its values on the grid enter the algorithm. The fraction condition is stated as the number of good grid points being at least 9991000 2dq\tfrac{999}{1000}\,2^{dq}1000999​2dq.

Preamble
import Definitions.Def_QAlgorithms_Defs_GradientMethods
import Definitions.Def_QAlgorithms_Nannicini_Ch05a_Model
set_option autoImplicit false
Formal statement
namespace QAlgorithms.Nannicini


/-- Nannicini p.110, Proposition 5.6 (based on Lem. 5.1 of Gilyén et al. 2019). Let `q > 0`,
`b ∈ ℝ`, `g ∈ ℝ^d` with `‖g‖_∞ ≤ 1/3`, and `f : [−1/2, 1/2]^d → ℝ` (taken on `ℝ^d`; only its
values on the grid are used). Let `G_q = {j/2^q − 1/2 + 1/2^{q+1} : j = 0, …, 2^q − 1}` (p.109)
and `x̂` the grid point of the register contents `x`. If `|f(x̂) − ⟨g, x̂⟩ − b| ≤ 1/(20π2^q)` for at
least `99.9%` of the `2^{dq}` points `x̂ ∈ G_q^d`, then the output `g̃ = (k̂_1, …, k̂_d)` of the
gradient algorithm (Alg. 3, p.110: `H^{⊗q}` on each of `d` registers in `|0⟩`, the phase oracle
`|x⟩ ↦ e^{2πi 2^q f(x̂)}|x⟩`, `Q_{G_q}†` on each register, measure) satisfies
`Pr(|g̃_j − g_j| ≤ 1/2^q) > 3/5` for every `j = 1, …, d`. -/
theorem gradientAlg_approxLinear (d q : ℕ) (hq : 0 < q) (b : ℝ) (g : Fin d → ℝ)
    (hg : ∀ i, |g i| ≤ 1 / 3) (f : (Fin d → ℝ) → ℝ)
    (hf : (999 / 1000 : ℝ) * (2 : ℝ) ^ (d * q) ≤
      ((Finset.univ.filter fun x : Fin d → Qubits q =>
          |f (fun i => gridPoint q (x i)) - ∑ i, g i * gridPoint q (x i) - b| ≤
            1 / (20 * Real.pi * (2 : ℝ) ^ q)).card : ℝ)) :
    ∀ j : Fin d, 3 / 5 < probEvent (gradientAlgState d q f)
      fun k => |gridPoint q (k j) - g j| ≤ 1 / (2 : ℝ) ^ q := by
  sorry






end QAlgorithms.Nannicini
Source
Giacomo Nannicini, Quantum algorithms for optimizers, 2025, v5; notes dated 9 July 2025, PDF p. 110, Proposition 5.6. https://arxiv.org/pdf/2408.07086v5
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

Setup. Let d,qd, qd,q be natural numbers with q>0q > 0q>0. Let b∈Rb \in \mathbb{R}b∈R, let g∈Rdg \in \mathbb{R}^dg∈Rd with ∣gi∣≤1/3|g_i| \le 1/3∣gi​∣≤1/3 for every iii, and let f:Rd→Rf:\mathbb{R}^d\to\mathbb{R}f:Rd→R be arbitrary.

Grid. For a qqq-bit string zzz with integer value [z][z][z] (most significant bit first), the grid point is

p(z)=[z]2q−12+12q+1.p(z) = \frac{[z]}{2^q} - \frac12 + \frac{1}{2^{q+1}}.p(z)=2q[z]​−21​+2q+11​.

These are 2q2^q2q equally spaced points in (−12,12)(-\tfrac12,\tfrac12)(−21​,21​) with spacing 2−q2^{-q}2−q. For a ddd-tuple xxx of qqq-bit strings, write p(x)=(p(x0),…,p(xd−1))p(x) = (p(x_0),\dots,p(x_{d-1}))p(x)=(p(x0​),…,p(xd−1​)).

Hypothesis. At least 9991000⋅2dq\tfrac{999}{1000}\cdot 2^{dq}1000999​⋅2dq of the 2dq2^{dq}2dq tuples xxx satisfy

∣f(p(x))−∑igi p(xi)−b∣≤120π 2q.\Bigl|f(p(x)) - \sum_i g_i\, p(x_i) - b\Bigr| \le \frac{1}{20\pi\, 2^q}.​f(p(x))−i∑​gi​p(xi​)−b​≤20π2q1​.

The state. Let GqG_qGq​ be the 2q×2q2^q\times 2^q2q×2q matrix with entries

(Gq)j,k=e2πi 2q p(j) p(k)2q.(G_q)_{j,k} = \frac{e^{2\pi i\, 2^q\, p(j)\, p(k)}}{\sqrt{2^q}}.(Gq​)j,k​=2q​e2πi2qp(j)p(k)​.

The state Φf\Phi_fΦf​ on ddd blocks of qqq qubits is obtained in three steps:

  1. Apply H⊗qH^{\otimes q}H⊗q to each block of ∣0⋯0⟩|0\cdots0\rangle∣0⋯0⟩. This gives the uniform superposition with amplitudes 2−dq/22^{-dq/2}2−dq/2.
  2. Multiply amplitude xxx by the phase e2πi 2qf(p(x))e^{2\pi i\, 2^q f(p(x))}e2πi2qf(p(x)).
  3. Apply Gq†G_q^\daggerGq†​ (conjugate transpose) to each block.

Conclusion. For every coordinate j∈{0,…,d−1}j \in \{0,\dots,d-1\}j∈{0,…,d−1}, measuring Φf\Phi_fΦf​ in the computational basis gives an outcome k=(k0,…,kd−1)k = (k_0,\dots,k_{d-1})k=(k0​,…,kd−1​) satisfying

∣p(kj)−gj∣≤2−q|p(k_j) - g_j| \le 2^{-q}∣p(kj​)−gj​∣≤2−q

with probability strictly greater than 3/53/53/5.

Edge cases.

  • fff enters only through its values at the grid points.
  • ggg need not lie on the grid.
  • If d=0d = 0d=0, the conclusion is vacuous.
Human review
  • Endorsed by Shuze Chen · Oct 13, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Goku · Oct 13, 2026

    Confirmed by the mission captain (proposal self-audit).

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