Amplitude encoding of a complex vector to error ϵ with Õ(d) gates from {H, T, CX}
ProvedQAlgorithms.Nannicini.ampEncoding_gateComplexityFor a nonzero vector let and
be its amplitude encoding on qubits, where is the -bit binary expansion of (most significant bit first) and the basis states with have amplitude . Circuits are built from the universal gate set , and their size is their number of gates.
There are constants and such that for every , every nonzero and every there exist a number of ancilla qubits and a circuit on qubits with
The circuit may depend on (it is produced from the classical description of ); the constants do not depend on , or . This is the gate cost of loading a classical vector into the amplitudes of a quantum state in the standard circuit model, against which the QRAM speedup of §5.3 is measured.
Formalization Note with polylogarithmic dependence on (as the source's proof says) is written as times a power of . The error is the Euclidean distance of the produced state from with the ancillas back in . The statement covers every nonzero , which includes every finite-precision description.
import Definitions.Def_QAlgorithms_Defs_GradientMethods import Definitions.Def_QAlgorithms_Nannicini_Ch05c_Model set_option autoImplicit false
namespace QAlgorithms.Nannicini
/-- Nannicini p.126, Corollary 5.37: "Given a classical description of `x ∈ ℂ^d` in finite
precision, there is a circuit that implements the mapping `|0⟩ → |amp(x)⟩` with error at most
`ϵ` with gate complexity `Õ(d)`."
The circuit is built from the classical data `x` (Rem. 5.35), over the gate set `{H, T, CX}` of
Thm. 1.43, on the `n = ⌈log d⌉` qubits of `|amp(x)⟩` plus `w` ancillas that start in `|0⟩`.
"Error at most `ϵ`" is the Euclidean distance between the produced state and
`|amp(x)⟩ ⊗ |0^w⟩` (§1.3.6). `Õ(d)` with the dependence on `ϵ` polylogarithmic (p.127) is
`C · d · (log(2 + d) + log(2 + 1/ϵ))^c` with constants `C > 0`, `c` chosen before `d`, `x`, `ϵ`.
The statement is for every nonzero `x ∈ ℂ^d`, which contains every finite-precision input. -/
theorem ampEncoding_gateComplexity :
∃ C : ℝ, 0 < C ∧ ∃ c : ℕ, ∀ (d : ℕ) (x : Fin d → ℂ), x ≠ 0 → ∀ ε : ℝ, 0 < ε →
∃ (w : ℕ) (circ : Circuit htcxGateSet (Nat.clog 2 d + w)),
(circ.size : ℝ) ≤ C * d * (Real.log (2 + d) + Real.log (2 + 1 / ε)) ^ c ∧
‖act circ.unitary (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
The gate set. Circuits use the gate set consisting of exactly three gates:
- the Hadamard gate ;
- the gate ;
- the CNOT gate, with first qubit as control.
and other inverses are not included.
A circuit on wires is a finite list of such gates. Each gate is placed on an ordered tuple of distinct wires, the gates are applied in list order, and the circuit acts as the identity on the wires a gate does not touch. Its unitary is the product of the embedded gate matrices, first gate rightmost. Its size is the number of gates in the list.
Notation.
- is the natural logarithm.
- is the least with , so when .
- For a bit string , is its integer value, most significant bit first.
Claim. There exist a real constant and a natural number (possibly ) with the following property. For every natural number , every nonzero complex vector (indexed ), and every real , there exist:
- a number of ancilla wires, which may depend on , and , and
- a circuit over this gate set on wires,
such that two conditions hold.
- Size bound.
- Accuracy. In Euclidean norm,
- is the circuit's unitary.
- is the all-zeros basis state.
- The target state is , where the ancilla state occupies the last wires.
- is the -qubit state on the first wires with amplitude on basis string equal to
- The target has amplitude on every basis state whose last bits are not all .
- The comparison is exact in the global phase: no phase factor is allowed.
Edge cases.
- . The only vector in is , so the hypothesis cannot be satisfied and this case holds vacuously.
- . Here , and is the scalar , a unit complex number. The circuit must then approximate on the ancilla wires alone.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.