Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Appendix A.3: repeated-value implementation of the sparse-access entry oracle (94)

Open
QAlgorithms.Papers.Independent.Extend50.P44.repeatedValueEntryOracle

by Gohan · Oct 29, 2026 · Mathlib 0df444a (Lean v4.33.1)

prove2quantum

Let an explicitly supplied reversible reverse map compute, from row and column indices (i,j)(i,j)(i,j), either an occurrence label (t,m)(t,m)(t,m) or a fixed zero sentinel. Let each of the DDD active table entries have a specified bbb-bit code, with zero codes on all other physical data labels. Require a concrete clean-work arithmetic circuit implementing the reverse map; no efficient inversion is inferred from forward position formulas.

Compute the label, XOR its data code into a general output buffer, and uncompute the label. This unitary implements

∣i,j,y,0⟩⟼∣i,j,y⊕code(Aij),0⟩.|i,j,y,0\rangle\longmapsto |i,j,y\mathbin\oplus\mathrm{code}(A_{ij}),0\rangle.∣i,j,y,0⟩⟼∣i,j,y⊕code(Aij​),0⟩.

It loads DDD items. If the given reverse computation has Toffoli count at most BBB, its compute/uncompute contribution is at most 2B2B2B. Thus any uniform polylogarithmic arithmetic bound is preserved. Finite codes are the prescribed representations, rather than exact binary expressions for arbitrary reals.

Preamble
import Definitions.Def_QAlgorithms_Papers_Independent_Extend50_P44
Formal statement
noncomputable section

namespace QAlgorithms.Papers.Independent.Extend50.P44

open scoped BigOperators ComplexConjugate Matrix

open QAlgorithms.Papers.Independent.Frontier18.P11 (complexMatrix)

open QAlgorithms.Papers.Independent.Information100.P34 (permutationMatrix)

open QAlgorithms.Papers.Independent.Next46.P21 (tCount)

variable {n s d m : ℕ}

local instance : DecidableEq QAlgorithms.Gate := Classical.decEq _

/-- PDF p.26, (93)-(94): repeated-value implementation of the sparse-access
entry oracle. A given cost-bearing reverse-map circuit is required explicitly.
Its compute/uncompute overhead doubles, so any uniform polylogarithmic bound
for that circuit remains such a bound with twice the same constant. Data is
an arbitrary specified b-bit representation, not an exact code of every real. -/
theorem repeatedValueEntryOracle (n d m b work : ℕ)
    (r : (Fin (2 ^ n) × Fin (2 ^ n)) → Option (Fin (2 ^ d) × Fin (2 ^ m)))
    (code : Fin (2 ^ d) → QAlgorithms.Qubits b)
    (active : Finset (Fin (2 ^ d)))
    (hcode : ∀ j, j ∉ active → code j = 0)
    (hrange : ∀ ij l, r ij = some l → l.1 ∈ active)
    (c : List (ArithmeticGate ((n + n + (1 + d + m)) + work)))
    (hc : RealizesMap rowColumnLabelBits rowColumnLabelBits
      (fun x : (Fin (2 ^ n) × Fin (2 ^ n)) × QAlgorithms.Qubits (1 + d + m) =>
        (x.1, x.2 + reverseCode r x.1)) (n + n + (1 + d + m)) work c) :
    entryCircuit r code ∈ Matrix.unitaryGroup _ ℂ ∧
    (∀ (ij : Fin (2 ^ n) × Fin (2 ^ n)) (y : QAlgorithms.Qubits b),
      QAlgorithms.act (entryCircuit r code) (QAlgorithms.ket ((y, ij), 0)) =
        QAlgorithms.ket ((y + (match r ij with | none => 0 | some l => code l.1), ij), 0)) ∧
    loadingCost (baseLoadingSchedule active.card) = active.card ∧
    (∀ bound : ℝ, (toffoliCount c : ℝ) ≤ bound →
      (entryArithmeticCost c : ℝ) ≤ 2 * bound) := by sorry

end QAlgorithms.Papers.Independent.Extend50.P44

end
Source
Block-encoding structured matrices for data input in quantum computing, arXiv:2302.10949v2, PDF p. 26, Appendix A.3: repeated-value implementation of the sparse-access entry oracle (94)
Read-back

What the Lean code literally says, in plain math · gpt-6.1-sol

Let n,d,m,b,workn,d,m,b,\mathrm{work}n,d,m,b,work be arbitrary natural numbers, including zero; let rrr map each pair ij∈{0,…,2n−1}2ij\in\{0,\ldots,2^n-1\}^2ij∈{0,…,2n−1}2 either to no label or to a label ℓ∈{0,…,2d−1}×{0,…,2m−1}\ell\in\{0,\ldots,2^d-1\}\times\{0,\ldots,2^m-1\}ℓ∈{0,…,2d−1}×{0,…,2m−1}; let code\mathrm{code}code assign a Boolean string of length bbb to each first label component; and let active⊆{0,…,2d−1}\mathrm{active}\subseteq\{0,\ldots,2^d-1\}active⊆{0,…,2d−1}. Assume that code(j)\mathrm{code}(j)code(j) is the all-false string whenever j∉activej\notin\mathrm{active}j∈/active, and that r(ij)=ℓr(ij)=\ellr(ij)=ℓ implies ℓ1∈active\ell_1\in\mathrm{active}ℓ1​∈active. Define R(ij)R(ij)R(ij) to be the all-false string of length 1+d+m1+d+m1+d+m when r(ij)r(ij)r(ij) has no label, and otherwise the concatenation of true, the ddd-bit most-significant-first representation of ℓ1\ell_1ℓ1​, and the mmm-bit representation of ℓ2\ell_2ℓ2​. Let ccc be a finite list of arithmetic gates on 2n+1+d+m+work2n+1+d+m+\mathrm{work}2n+1+d+m+work wires, each flipping its target exactly when all its at most two control bits are true, with target excluded from controls. Assume that, for every ijijij and every Boolean string zzz of length 1+d+m1+d+m1+d+m, executing ccc on the concatenation of the two nnn-bit representations in ijijij, then zzz, then work\mathrm{work}work false bits produces the same encoding of (ij,z⊕R(ij))(ij,z\oplus R(ij))(ij,z⊕R(ij)) and returns all work bits to false, where ⊕\oplus⊕ denotes bitwise exclusive-or. On basis labels ((y,ij),z)((y,ij),z)((y,ij),z), define CCC by replacing zzz with z⊕R(ij)z\oplus R(ij)z⊕R(ij), and define VVV by replacing yyy with y⊕v(z)y\oplus v(z)y⊕v(z), where v(z)=0v(z)=0v(z)=0 if the first bit of zzz is false, and otherwise v(z)v(z)v(z) is the code indexed by the next ddd bits; the remaining mmm bits are ignored. Let E=CVCE=CVCE=CVC, using matrices whose entries are 111 exactly at the specified basis transitions and 000 elsewhere. Then EEE is unitary, and its action on every computational basis vector with zero label register is

E ∣((y,ij),0)⟩=∣((y⊕a(ij),ij),0)⟩,a(ij)={0,r(ij) has no label,code(ℓ1),r(ij)=ℓ.E\,|((y,ij),0)\rangle = |((y\oplus a(ij),ij),0)\rangle, \qquad a(ij)= \begin{cases} 0,&r(ij)\text{ has no label},\\ \mathrm{code}(\ell_1),&r(ij)=\ell. \end{cases}E∣((y,ij),0)⟩=∣((y⊕a(ij),ij),0)⟩,a(ij)={0,code(ℓ1​),​r(ij) has no label,r(ij)=ℓ.​

The loading cost, defined as the sum of the singleton schedule [∣active∣][|\mathrm{active}|][∣active∣], equals ∣active∣|\mathrm{active}|∣active∣; and for every real bound BBB, if the number of gates in ccc with exactly two controls is at most BBB, then the number of such gates in ccc followed by its reversal is at most 2B2B2B. No distinctness of code values is assumed. If active\mathrm{active}active is empty, the hypotheses force every code value to be zero and rrr to return no label everywhere.

Human review
  • Endorsed by Shuze Chen · Oct 30, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Gohan · Oct 30, 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