The problem with existing frameworks
When you write a quantum circuit in Qiskit, Cirq, or Q#, the framework trusts you to manage ancilla qubits correctly. An ancilla is a helper qubit — you borrow it, use it to do some work, and return it to |0⟩ so it does not entangle with the rest of the system. If you get the uncomputation wrong, the ancilla becomes dirty: it stays entangled with your system qubits, and your supposedly unitary program silently becomes a mixed channel instead. The circuit compiles, the job runs, and nothing tells you something went wrong. Three bugs cause most of these failures:- Dirty ancillae — an ancilla qubit is not returned to |0⟩ after use, leaving it entangled with system qubits
- Bad uncomputation — the inverse of the compute block is wrong or missing, so the ancilla is not correctly disentangled
- Silent decoherence — a gate that creates superposition is used in a context that requires a permutation gate, turning a unitary channel into a mixed one
How b01t solves this
b01t is a Python DSL built around a closed gate set and a structural discipline for ancilla use. Every@coherent function must route its ancilla operations through three named blocks:
compute— classical-reversible gates only (X, CX, CCX, MCX). These copy system information into the ancilla.phase— diagonal gates only (Z, S, T, CZ, CCZ, MCZ). These apply a phase kickback.uncompute— auto-generated inverse of the compute block.
@coherent program is a proven unitary channel. The proof is machine-checked in Lean 4 and does not rely on simulation. If your program builds without a DSLValidationError, it is safe by construction.
The Hero Theorem in practice
When you call.build_exact() on a @coherent function, b01t constructs an ExactProgram and checks it against the structural rules. If all checks pass, the returned program carries Certification.SAFE — a static certificate that the program is a unitary channel, ancilla-clean, and free from the three bug classes above.
You can inspect the certificate directly:
Catching a real mistake
Here is the bug every quantum programmer writes at least once. The intent is to use an ancilla to apply a phase kickback, but the compute block usesh (Hadamard) instead of a permutation gate:
h is not a permutation gate, it creates superposition in the ancilla. After the uncompute step, the ancilla is still entangled with the system. The program silently computes the wrong thing.
b01t rejects it immediately. The compute block only accepts permutation gates; h is not one of them, so the build fails with a DSLValidationError before any circuit is produced.
Where to go next
Quick Start
Write and certify your first safe quantum program in a few lines of code
Installation
Install b01t and set up your Python environment
Safety model
Understand the Hero Theorem and how certification works
Ancilla discipline
Learn the compute / phase / uncompute pattern in depth