Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 2 (rotation lemma) — r from (45)–(47) is odd, 1 ≤ r ≤ 5/(γθ), and one update fails to keep θmin ≤ θ ≤ θmax with probability < δ

Proved
QApproxCount.Counting.lemma_2

by mikedeng1 · Oct 18, 2026 · Mathlib 0df444a (Lean v4.33.1)

groverhoeffdingp2o-batch-pfp2ap2o-gran-per-chapterp2o-plan-paperp2o-v1rotation-lemma

Let 0<θmin⁡≤θ≤θmax⁡≤0.0020<\theta_{\min}\le\theta\le\theta_{\max}\le0.0020<θmin​≤θ≤θmax​≤0.002 with θmax⁡=(1+γ)θmin⁡\theta_{\max}=(1+\gamma)\theta_{\min}θmax​=(1+γ)θmin​ for some 0<γ≤0.70<\gamma\le0.70<γ≤0.7, let 0<δ<10<\delta<10<δ<1, and let m≥250ln⁡(δ−1)m\ge250\ln(\delta^{-1})m≥250ln(δ−1). Let rrr be computed from θmin⁡,θmax⁡\theta_{\min},\theta_{\max}θmin​,θmax​ alone by eqs. (45)–(47). Then:

  1. rrr is an odd integer with 1≤r≤5γθ1\le r\le\dfrac{5}{\gamma\theta}1≤r≤γθ5​;
  2. toss a coin with bias sin⁡2(rθ)\sin^2(r\theta)sin2(rθ) mmm times and let HHH be the number of heads. If H>0.12mH>0.12mH>0.12m, set θmin⁡:=θmax⁡/(1+0.9γ)\theta_{\min}:=\theta_{\max}/(1+0.9\gamma)θmin​:=θmax​/(1+0.9γ); otherwise set θmax⁡:=(1+0.9γ)θmin⁡\theta_{\max}:=(1+0.9\gamma)\theta_{\min}θmax​:=(1+0.9γ)θmin​. The probability that the new bracket fails to contain θ\thetaθ is less than δ\deltaδ;
  3. the same holds when the test is H≥0.12mH\ge0.12mH≥0.12m instead of H>0.12mH>0.12mH>0.12m.

That is,

Pr⁡[θ∉[θmin⁡′,θmax⁡′]]<δ.\Pr\big[\theta\notin[\theta_{\min}',\theta_{\max}']\big]<\delta .Pr[θ∈/[θmin′​,θmax′​]]<δ.

Each round of step 2 of the algorithm is one application of this lemma: it shrinks the ratio θmax⁡/θmin⁡\theta_{\max}/\theta_{\min}θmax​/θmin​ from 1+γ1+\gamma1+γ to 1+0.9γ1+0.9\gamma1+0.9γ at a cost of O(γ−1θ−1log⁡δ−1)O(\gamma^{-1}\theta^{-1}\log\delta^{-1})O(γ−1θ−1logδ−1) queries.

Formalization Note The lemma's "r∈O(θ−1γ−1)r\in O(\theta^{-1}\gamma^{-1})r∈O(θ−1γ−1)" is pinned to the explicit bound r≤5/(γθ)r\le5/(\gamma\theta)r≤5/(γθ). The paper's proof gives r≤π(1+γ)2/(2γθ)+1<4.6/(γθ)r\le\pi(1+\gamma)^2/(2\gamma\theta)+1<4.6/(\gamma\theta)r≤π(1+γ)2/(2γθ)+1<4.6/(γθ). The hypotheses γ>0\gamma>0γ>0 (eq. (46) divides by Δθ\Delta\thetaΔθ) and δ<1\delta<1δ<1 (otherwise 250ln⁡δ−1≤0250\ln\delta^{-1}\le0250lnδ−1≤0) are implicit in the paper. The lemma's threshold is "more than 12%"; step 2(c) of the algorithm uses "at least 12%". Item 3 reconciles the two, so the lemma applies to the algorithm as printed. rrr is the algorithm's rotR, a function of θmin⁡,θmax⁡\theta_{\min},\theta_{\max}θmin​,θmax​ only.

Preamble
import Mathlib
import Definitions.Def_QApproxCount_Counting_Algorithm
Formal statement
namespace QApproxCount.Counting

/-- Lemma 2 (rotation lemma), p. 8. Let `0 < θmin ≤ θ ≤ θmax ≤ 0.002` with
`θmax = (1 + γ) θmin`, `0 < γ ≤ 0.7`, let `0 < δ < 1`, and let `m ≥ 250 ln(δ⁻¹)` be the number of
tosses. The `r` computed from `θmin, θmax` alone by (45)–(47) (`rotR`) is an odd integer with
`1 ≤ r ≤ 5/(γθ)`, and, for the number of heads `h` in `m` tosses of a coin with bias `sin²(rθ)`,
the update "if the heads are more than 12% (resp. at least 12%, as in step 2(c)) set
`θmin := θmax/(1 + 0.9γ)`, otherwise set `θmax := (1 + 0.9γ) θmin`" leaves `θ` outside the new
bracket with probability less than `δ`, for both thresholds. -/
theorem lemma_2 (θmin θmax θ γ δ : ℝ) (hθmin : 0 < θmin) (hlo : θmin ≤ θ) (hhi : θ ≤ θmax)
    (hθmax : θmax ≤ 0.002) (hmax : θmax = (1 + γ) * θmin) (hγ : 0 < γ) (hγ1 : γ ≤ 0.7)
    (hδ : 0 < δ) (hδ1 : δ < 1) (m : ℕ) (hm : 250 * Real.log δ⁻¹ ≤ (m : ℝ)) :
    Odd (rotR θmin θmax) ∧ 1 ≤ rotR θmin θmax ∧ (rotR θmin θmax : ℝ) ≤ 5 / (γ * θ) ∧
      (coin (Real.sin ((rotR θmin θmax : ℝ) * θ) ^ 2) m).toOuterMeasure
          {h : ℕ | ¬ (if 0.12 * (m : ℝ) < (h : ℝ) then
                        θmax / (1 + 0.9 * γ) ≤ θ ∧ θ ≤ θmax
                      else θmin ≤ θ ∧ θ ≤ (1 + 0.9 * γ) * θmin)} < ENNReal.ofReal δ ∧
      (coin (Real.sin ((rotR θmin θmax : ℝ) * θ) ^ 2) m).toOuterMeasure
          {h : ℕ | ¬ (if 0.12 * (m : ℝ) ≤ (h : ℝ) then
                        θmax / (1 + 0.9 * γ) ≤ θ ∧ θ ≤ θmax
                      else θmin ≤ θ ∧ θ ≤ (1 + 0.9 * γ) * θmin)} < ENNReal.ofReal δ := by sorry

end QApproxCount.Counting
Source
Aaronson & Rall, Quantum Approximate Counting, Simplified, arXiv:1908.10846v6, p. 8, Lemma 2 (proof pp. 9–10); threshold of step 2(c), p. 4
Human review
  • Endorsed by Shuze Chen · Oct 19, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Oct 19, 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