Machine-checked synthesis of arbitrary n-qubit unitaries with fewer CX gates than Block-ZXZ.
The method (paper) inserts a single-qubit pivot gate
g = R_z(α) R_y(β) on the top qubit at each step of the Block-ZXZ recursion,
and chooses α*, β* so that the eigenphases of C(g) admit a balanced split. That zeroes
the final angle φ of the left multiplexor, so one more CX merges at every recursion node:
| recurrence | CX count | |
|---|---|---|
| Block-ZXZ (Krol & Al-Ars 2024) | c_n = 4c_{n-1} + 3·2^{n-1} − 5 |
(22/48)·4^n − (3/2)·2^n + 5/3 |
| pivot (this work) | c_n = 4c_{n-1} + 3·2^{n-1} − 6 |
(21/48)·4^n − (3/2)·2^n + 2 |
This saves (4^{n−2} − 1)/3 CX gates, one per recursion node. The lower bound is ⌈(4^n − 3n − 1)/4⌉
(Shende, Markov & Bullock).
Source: submission/diagram.tex.
The project has three layers, each usable on its own:
| Layer | Path | Role |
|---|---|---|
| Paper | submission/ |
The paper (construction, existence argument and gate count), a self-contained implementation (decomposition.py), the benchmark, and the formalization diagram |
| Numerics | research/ |
Exploratory Python experiments, the implementation-and-experiments supplement, and an explainer video. Plain NumPy/SciPy with no dependency on Lean |
| Formalization | LeanUnitary/ |
Lean 4 proofs of the pivot construction against a fixed circuit model, on Mathlib alone |
The Python code and the Lean library share only the mathematics. The Lean side never runs or imports
the Python, and the Python needs no Lean toolchain. The one point of contact is a cross-check: the
kernel evaluates the CX counts Pivot.count 10 = 457218 and Pivot.zxzCount 10 = 479063, the same
counts the Python implementation measures.
What is formalized. The (21/48)·4^n bound is proved end to end from circuits
(Pivot.Node.pivot_generalBound): the pivot angles exist, the Block-ZXZ factorization and
demultiplexing hold, the final rotation of the left multiplexor vanishes, and both CX gates merge
into the central multiplexor. The only assumptions are the two-qubit base cases (3 CX, and 2 CX up
to a diagonal) and, as in the paper, the case of non-generic nodes. The library contains no sorry.
See LeanUnitary/README.md for the module-by-module
theorems.
The Lean library is a Lake project built on Mathlib:
lake exe cache get # download prebuilt Mathlib files (avoids a multi-hour compile)
lake build # build the libraryThe Python code needs NumPy and SciPy (Matplotlib for the figures, Manim for the video); see the
READMEs in submission/ and research/.
| Path | Purpose |
|---|---|
LeanUnitary.lean |
Lean library root; imports every module in LeanUnitary/ |
LeanUnitary/ |
The formalization (README) |
submission/ |
The paper, its implementation and benchmark, and the formalization diagram (README) |
research/ |
Exploratory experiments, supplement and video (README) |
lakefile.toml, lean-toolchain, lake-manifest.json |
Lean build configuration and pinned versions |
.lake/ |
Build output and downloaded dependencies (git-ignored) |
