The n-qubit QFT has an exact circuit of at most n^2 Hadamard, controlled-R_s and swap gates
ProvedQAlgorithms.DeWolf.qft_circuit_exactLet and . The quantum Fourier transform is the unitary matrix with -entry , where and rows and columns are indexed by ; it acts on qubits via the identification with the most significant bit.
Consider the gate set consisting of the Hadamard gate , the controlled- gates () with
and the two-qubit swap gate, each gate placed on any (ordered) choice of distinct qubits. Then there is a quantum circuit on qubits over this gate set whose unitary equals the Fourier transform exactly and which has at most gates:
In particular the QFT can be implemented with elementary gates, exponentially fewer than the steps of the classical FFT. This circuit is the basic building block of phase estimation, period finding and Shor's algorithm.
Formalization Note The gate set is the shared qftGateSet (, controlled- for all , swap); the size of a circuit is its number of gates. The equality is exact matrix equality, not equality up to a global phase. At the statement says the empty circuit implements .
import Definitions.Def_QAlgorithms_Defs_Fourier set_option autoImplicit false
namespace QAlgorithms.DeWolf
/-- de Wolf §4.5, PDF pp.44–45 (unnumbered): the `n`-qubit quantum Fourier transform `F_{2^n}`
(entries `ω_N^{jk}/√N`, `ω_N = e^{2πi/N}`, p.41; most significant bit first, p.44) is implemented
exactly by a circuit of Hadamards, controlled-`R_s` gates and swap gates with at most `n²` gates
("the overall circuit uses at most `n²` gates"), in particular `O(n²)` elementary gates. -/
theorem qft_circuit_exact (n : ℕ) :
∃ c : Circuit qftGateSet n, c.unitary = qftQubits n ∧ c.size ≤ n ^ 2 := by
sorry
end QAlgorithms.DeWolf
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
For every natural number (including ), there exists a circuit on wires over the gate set whose overall matrix equals the -qubit quantum Fourier transform exactly, with no global-phase or approximation slack, and which uses at most gates:
The gate set. consists of exactly three kinds of gates:
- The one-qubit Hadamard
- For each integer , the two-qubit controlled- gate, where
The gate applies to its second qubit when its first qubit is , and the identity otherwise. 3. The two-qubit SWAP gate, which sends .
Circuits. A circuit is a finite list of gates from this set. Each gate is placed on an ordered tuple of distinct wires among the wires. Its matrix acts as the gate on those wires and as the identity on all other wires (it has zero entries wherever the other wires' bits differ). The circuit's matrix is the product of these embedded matrices in list order: the first gate in the list is applied first, so it is the rightmost factor. The size is the length of the list, and SWAP gates are counted.
The target matrix. is the matrix indexed by bit strings . Each bit string is read as an integer with wire as the most significant bit, written . The entries are
Edge cases.
- For , is the matrix , and the bound forces a circuit of size , namely the empty circuit.
- For , at most one gate is allowed.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.