Amplitude encoding with O(log d) QRAM queries and O(log d (log d + log 1/ϵ)) two-qubit gates after Õ(d) classical preprocessing (corrected)
ProvedQAlgorithms.Nannicini.ampEncoding_qramThis is a corrected form of the QRAM speed-up for amplitude encoding.
QRAM. For words indexed by , the QRAM is the unitary (Definition 5.39). Its size is .
Classical preprocessing. It is a straight-line program over the reals. It reads , and each instruction is one of , the complex argument, or a rational constant. Its cost is its number of instructions. Word of the QRAM is the -bit binary expansion of the integer part of a designated program value.
Circuit. It acts on output qubits plus ancillas, all starting in . It consists of arbitrary two-qubit gates and uncontrolled calls to (or its inverse).
There are constants and such that for every and every there exist , a program , an address map and a circuit , none depending on , with the following properties. Write . Then:
- the QRAM size satisfies , and has at most instructions;
- makes at most QRAM calls and uses at most two-qubit gates;
- for every nonzero , with the QRAM loaded by running on ,
Once the classical data structure has been written, the state can be prepared with exponentially fewer gates than the of Corollary 5.37.
Formalization Note The printed corollary claims gates for every . Its proof, however, fixes the word size , which limits the reachable error. The statement therefore lets , and with it the gate count, grow with . For this is the printed bound. The source does not define its classical cost model; the one used here is fixed in the Lean definitions ArithInstr and arithRun.
import Definitions.Def_QAlgorithms_Defs_GradientMethods import Definitions.Def_QAlgorithms_Nannicini_Ch05c_Model set_option autoImplicit false
namespace QAlgorithms.Nannicini
/-- Corrected statement. Nannicini p.130, Corollary 5.45, as printed: "Given a classical
description of `x ∈ ℂ^d` in finite precision and a QRAM of size `Õ(d)`, there is a circuit that
implements the mapping `|0⟩ → |amp(x)⟩` with error at most `ϵ` using `O(log d)` QRAM queries,
`O(log² d)` additional gates, and `Õ(d)` classical arithmetic operations to initialize the QRAM
data structure."
What was changed. (1) The gate bound `O(log² d)` is replaced by
`O(log d · (log d + log(1/ϵ)))`, and the QRAM size and the classical cost `Õ(d)` may carry
polylogarithmic factors in `1/ϵ`. This is the source's own count on p.130, `O(n)` queries and
`O(nq)` gates with `n = log d` levels and word size `q`, with `q` allowed to grow like
`log d + log(1/ϵ)`; for `ϵ ≥ 1/poly(d)` it is the printed `O(log² d)`. (2) "Classical arithmetic
operations" are counted in the straight-line real-arithmetic model `ArithInstr` (one operation
per `+, −, ×, ÷, √, arccos, arg` or constant); the QRAM is written classically from the
program's values (`qramWords`).
Why. The printed proof fixes `q = O(log d)` independently of `ϵ` ("this already gives precision
exponential in d"), so its `O(log² d)` gates cannot reach an arbitrary error `ϵ`: fixed-point
words of `O(log d)` bits give error at least about `2^{-q}`. The source gives no cost model for
"classical arithmetic operations".
The model. The circuit runs on the `n = ⌈log d⌉` output qubits plus `w` ancillas that start in
`|0⟩`, over arbitrary two-qubit gates (Rem. 5.44: "additional (two-qubit) gates"), and calls the
QRAM `U_QRAM` of Def. 5.39 (address `a` qubits, words of `q` bits), uncontrolled, possibly as its
inverse. The circuit, the program and the addressing do not depend on `x`: `x` enters only through
the QRAM contents (Rem. 5.41). Error is the Euclidean distance from `|amp(x)⟩ ⊗ |0^w⟩`, as in
Cor. 5.37. The constants `C, c` come before `d`, `x`, `ϵ`. -/
theorem ampEncoding_qram :
∃ C : ℝ, 0 < C ∧ ∃ c : ℕ, ∀ d : ℕ, 1 ≤ d → ∀ ε : ℝ, 0 < ε →
∃ (a q w : ℕ) (P : List ArithInstr) (addr : Qubits a → ℕ)
(circ : OracleCircuit twoQubitGateSet (fun _ : Fin 1 => a + q) (Nat.clog 2 d + w)),
(2 : ℝ) ^ a * q ≤ C * d * (Real.log (2 + d) + Real.log (2 + 1 / ε)) ^ c ∧
(P.length : ℝ) ≤ C * d * (Real.log (2 + d) + Real.log (2 + 1 / ε)) ^ c ∧
(circ.queryCount 0 : ℝ) ≤ C * Real.log (2 + d) ∧
(circ.gateCount : ℝ) ≤
C * Real.log (2 + d) * (Real.log (2 + d) + Real.log (2 + 1 / ε)) ∧
(∀ s ∈ circ, uncontrolledStep s) ∧
∀ x : Fin d → ℂ, x ≠ 0 →
‖act (circ.unitary fun _ => qramUnitary a q (qramWords a q P addr x))
(zeroKet (Nat.clog 2 d + w)) -
WithLp.toLp 2 (fun z : Qubits (Nat.clog 2 d + w) =>
if ∀ k : Fin w, z (Fin.natAdd (Nat.clog 2 d) k) = false then
padState (Nat.clog 2 d) (normalizedVec (WithLp.toLp 2 x))
(fun i => z (Fin.castAdd w i))
else 0)‖ ≤ ε := by
sorry
end QAlgorithms.Nannicini
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Undefined names. The statement uses five names that are not in the definition layer shown: ArithInstr, qramUnitary, qramWords, uncontrolledStep and IsQuantumMembershipOracle. The read-back treats them as opaque and names them literally. Everything else is unfolded.
The claim. There exist a real constant and a natural number such that the following holds. For every natural number and every real , there exist:
- natural numbers ;
- a finite list of objects of type
ArithInstr; - a function ;
- an oracle circuit .
The circuit has the following form:
- It acts on wires. Here is the least with , so it is when .
- Its gate set is "all unitary -qubit gates", i.e. every gate with arity whose matrix is unitary.
- It has a single oracle, of arity .
Such a circuit is a finite list of steps, applied head first. Each step is one of two kinds:
- A gate from the gate set, placed on an ordered pair of distinct wires.
- A call to the oracle, possibly its adjoint, possibly controlled on a further wire not among its targets, placed on an ordered tuple of distinct wires.
The data must satisfy the following conditions. All logarithms are natural logarithms. Write
- Data-structure size: .
- Program length: the length of satisfies .
- Queries: the number of oracle-call steps of is at most . Adjoint and controlled calls are counted alike.
- Other gates: the number of gate (non-oracle) steps of is at most .
- Step condition: every step of satisfies the predicate
uncontrolledStep(not shown). - Accuracy: for every nonzero vector , the inequality below holds.
The accuracy inequality is
The symbols in it mean the following:
-
is the product of the step matrices, with the first step rightmost.
- A gate step contributes its matrix acting on its two wires, tensored with the identity elsewhere.
- An oracle step contributes (or ) acting on its wires. In the controlled case, it contributes with the control wire first.
-
is the all-zeros basis vector.
-
is the vector whose amplitude at a bit string is defined by splitting into its first bits and last bits:
- if , the amplitude is , where is the integer with binary expansion (most significant bit first), provided ;
- it is if ;
- it is whenever .
In short, , with zero-padded to length .
Dependencies.
- and depend on and only, not on .
- The only -dependence is through the oracle matrix .
- No property of
qramWordsorqramUnitary(for instance unitarity of ) is asserted here.
Edge cases.
- An oracle step can only exist if .
- has norm . So if happens to be unitary, the accuracy condition is automatic once .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.