C^k(U) from CNOTs and single-qubit gates: the control-count recursion #
Category: 1-Mathlib (CSD-free; staged for upstream). BACKLOG #85, part (e3) of R-005
(specs/magic-plan.md, "The split"); it closes the original row #72, whose other pieces are
ControlledGate.lean (#83) and EulerDecomposition.lean with ControlledSingle.lean (#84).
★★ ctrlSetOf_mem_closure: a gate with any number of controls, on any control pattern, is a
product of CNOTs and single-qubit gates. Nielsen–Chuang Figure 4.10, with no work qubits: the
ancilla-free route is forced, because the work-qubit ladder is not a matrix identity (it reproduces
C^k(U) only on the sector where the work qubits are 0, and #73 consumes an exact product).
Two ingredients, and both are new algebra rather than bookkeeping.
The pattern costs nothing. Conjugating by one X on a control qubit flips that control value
(★ xGate_conj_ctrlSet), so only the number of controls matters. The mechanism is that X on
qubit a is a permutation matrix, and multiplying by it relabels (xGate_mul_apply,
mul_xGate_apply).
The recursion needs two target qubits at once. C(V) on the target and C^{k-1}(X) on the last
control act on different qubits, so #84's one-control algebra does not reach it. pairSet is the
family of gates that act by a 4 × 4 block on a pair of qubits — by one block on the labels
matching the pattern on the control set, by another on the rest — and it is closed under products,
blockwise in each branch (★★ pairSet_mul, through a four-element collapse). Every gate of the
recursion is one of them, so ★★ ctrlSetOf_insert reduces to two 4 × 4 identities, which
diagBlock and flipBlock settle in three rewrites: conjugating a block-diagonal gate by the flip
swaps its two blocks, and
diag(1, V) · X · diag(1, V*) · X · diag(V, V) = diag(V* V, V V) = diag(1, U) when V² = U,
while on the labels where the controls do not match the same product is diag(1, V) · diag(1, V*),
the identity. The square root V comes from Euler.exists_sqrt.
flipBit,flipAt,xGate_apply,xGate_mul_apply,mul_xGate_apply, ★xGate_conj_ctrlSet;diagBlock,flipBlock,diagBlock_apply_of_fst_eq,diagBlock_apply_of_fst_ne,flipBlock_apply_of_snd_eq,flipBlock_apply_of_snd_ne,diagBlock_mul,diagBlock_one, ★flipBlock_conj_diagBlock, ★diagBlock_five;pairSet,sum_collapse_pair, ★★pairSet_mul;ctrlSetOf,pairSet_eq_ctrlOf,pairSet_eq_ctrlSetOf_fst,pairSet_eq_ctrlSetOf_snd,pairSet_eq_ctrlSetOf_insert, ★★ctrlSetOf_insert;elementary,xGate_mem_elementary,ctrlOf_mem_closure, ★★ctrlSetOf_mem_closure, ★★ctrlGateOf_mem_closure.
Honest scope #
⚠️ This is an exact product identity, not a gate count: the recursion is proved, and the number of elementary gates it produces is not claimed (that is BACKLOG #74, deliberately not claimed). ⚠️ Nothing here approximates a gate; the single-qubit gates in the product are exact. Approximating them by Clifford+T words is BACKLOG #81.
References: M. A. Nielsen, I. L. Chuang, Quantum Computation and Quantum Information §4.3,
Figures 4.8 and 4.10; specs/magic-plan.md; specs/BACKLOG.md #85, #72, #73;
specs/future-work.md.
The bit flip as a relabelling #
The other bit.
Instances For
The label with the a-th bit flipped.
Equations
- QuantumInfo.Controlled.flipAt a k = Function.update k a (QuantumInfo.Controlled.flipBit (k a))
Instances For
The 4 × 4 blocks #
The block acting on the second qubit by A when the first carries 0 and by B when it
carries 1, never changing the first.
Equations
Instances For
Gates on a pair of qubits #
The gate acting by the 4 × 4 block M on the pair (u, t) of the labels that match pat on
the control set S, and by N on all the others.
Equations
Instances For
Every sum here collapses to the four labels that agree with k away from the pair.
The gates of the recursion are pair gates #
The gate U on qubit j, controlled by the set S on the pattern pat.
Equations
- QuantumInfo.Controlled.ctrlSetOf S j pat U = QuantumInfo.Controlled.ctrlSet S j pat (U 0 0) (U 0 1) (U 1 0) (U 1 1)
Instances For
★★ The control-count recursion (Nielsen–Chuang Figure 4.10, ancilla-free): one more control
costs two one-control gates, two gates with the old control set on the new control qubit, and one
gate with the old control set on the target, with V a square root of U.
Every controlled gate is a product of CNOTs and single-qubit gates #
The induction behind ctrlSetOf_mem_closure, on the number of controls.
★★ A gate with any number of controls, on any control pattern, is a product of CNOTs and
single-qubit gates.
★★ #71's multiply-controlled gate is a product of CNOTs and single-qubit gates — the form
#73 consumes, since the two-level theory of #70 and #71 produces exactly these.