A reversible adder has to return its scratch space clean, and the carry-clean ripple-carry design does it with a single spare qubit, which is what makes arithmetic affordable inside a quantum algorithm.
cuccaroAdd_correctQuantum algorithms for factoring and for discrete logarithms spend nearly all of their work on ordinary arithmetic, so the cost of a quantum attack on cryptography is essentially the cost of addition. Addition has to be done reversibly, and the naive way is wasteful: you compute each carry into a fresh spare qubit and never clean it up, so a long computation leaves a trail of rubbish qubits that can neither be reused nor thrown away, since discarding a qubit that's entangled with your data damages the data.
The carry-clean adder solves this by storing the carries inside the register it's going to leave untouched anyway, and then undoing that storage on the way back out. It needs exactly one clean spare qubit, which it returns in its original state, so the adder can be used again immediately with no fresh supply. Two three-gate blocks do the work, one folding the carry forwards and one writing the sum bit while restoring what the first disturbed.
The saving compounds, as multiplication is built from additions and exponentiation from multiplications, so a constant factor in the adder becomes the constant factor of the whole algorithm.
The corpus proves the adder correct for general bit width, in place, and with its ancilla restored, which are three separate statements rather than one. The register holding the first operand ends with the sum modulo the register size, the second operand is returned untouched, the spare qubit returns to its initial value, and wires outside the layout are undisturbed. The derived Toffoli count is two per bit, read off the gate list by the cost model rather than asserted.
The proof is organised as a recursion rather than as a forward and backward chain, which is what makes it an induction on bit count: the adder is the first carry block, then the adder on the high bits with the carry threaded in, then the closing block. That shape made the compute and uncompute correctness a single induction. A second design in the same layer replaces the temporary storage with measurement-based uncomputation, which trades Toffoli gates for measurements, and the hybrid lift proves the two agree on amplitudes, one gadget per carry cell. The honest boundary is that this adder is modular in the register size only, as reduction modulo a general number is a separate construction.
The blocks are maj c b a = [CX a b, CX a c, CCX c b a] and uma c b a = [CCX c b a, CX a c, CX c b], verified on the concrete three-wire state by decide and then lifted to general layouts. cuccaroAdd_correct gives A holding (A + B) mod 2^n, cuccaroAdd_preserves_B and cuccaroAdd_preserves_external give the untouched registers, cuccaroAdd_ancilla_clean gives the restored carry qubit, and cuccaroAdd_toffoli gives 2n Toffoli gates. The recursion cuccaroRec_correct is the induction carrying all of them.
The measurement-based variant is GidneyAdder.lean with the temporary-AND trick, and gidneyHybridAdd_amplitude in HybridLift.lean proves the hybrid circuit reproduces the unitary adder's amplitudes, with one gadget per carry cell rather than one per Toffoli. Modular reduction and the multiplier assembly are separate modules.
Steven Cuccaro, Thomas Draper, Samuel Kutin and David Moulton published the carry-clean ripple-carry adder in 2004, from the IDA Center for Computing Sciences, and it remains the default choice when spare qubits are scarce. Their paper's contribution was arranging the carries so that the uncomputation is free rather than a second pass.
Craig Gidney's 2018 temporary-AND construction takes the other trade, spending measurements and classically controlled corrections to halve the Toffoli count, and the two designs mark the ends of the range that current resource estimates interpolate.
CsdLean4/Mathlib/QuantumInfo/Reversible/CuccaroAdd.leanSource links are pinned to a commit, so they do not drift. The anchors above are checked mechanically against the Lean tree on every build. The mathematics is not, and cannot be: that is a human responsibility and it rests with the author.
Part of Constraint-Surface Dynamics · Formalised in csd-lean4.
Google Analytics counts visits to this page, which stores cookies in your browser. They record how the page was reached, not who you are, and nothing is passed on. Blocking cookies for this site breaks nothing here. Details.