The measurement-based AND-adder on the full register: the n-fold hybrid amplitude equality #
Category: 3-Local (QM-validity content; no CSD ontology).
MeasurementAdder.lean (#21) re-costs the AND-adder by replacing its 3n reverse-pass Toffolis
with measurement gadgets and proves the Toffoli count; what it left open was the
amplitude-level statement that the hybrid adder, run on the full register, produces the same
data as the unitary adder. This module proves it, with one correction to the picture #21 drew.
The correction. The reverse pass of a carry cell is three Toffolis with the same target,
[CCX a b g, CCX a c g, CCX b c g] reversed, and the ancilla g holds the majority
ab ⊕ ac ⊕ bc — not an AND — when the pass begins. Gidney's single-CZ gadget is correct only on
an AND-shaped ancilla, so replacing each of the three Toffolis by it is not amplitude-exact:
the first replacement, at ancilla maj with corrections for bc, leaves the data-dependent
phase (−1)^{m(ab ⊕ ac)} on the m = 1 branch (naive_cell_gadget_sign_flip exhibits the
sign). The amplitude-exact hybrid replaces the cell's whole reverse block by one
measure-and-correct gadget with a CZ on each of the three input pairs (cellGadget): the
majority ancilla is exactly the parity those corrections cancel. This saves the same 3n
Toffolis with n measurements instead of 3n.
hybridAdd L mo— the forward and sum passes as unitaries, then the measurement-based uncompute passhybridUncompute L mo n(cellsn−1, …, 0, one gadget each, outcomesmo).wellFormed_hybridUncompute— the run is well-formed: when celli's gadget fires, its ancillaG (i+1)holds the majority ofA i, B i, G i(the forward carry invariant, carried through the sum pass and the later cells, which never touch these wires).- ★★
hybridAdd_amplitude— then-fold hybrid amplitude equality: on every basis input with clean ancillas the hybrid adder produces(√2)⁻¹^n • |out⟩, whereoutagrees with the unitary adder's output on every wire except thencarry ancillas (hybridAdd_shadow_data), which hold the outcomes (hybridAdd_shadow_outcome); in particular the sum register holds(A + B) mod 2ⁿ(hybridAdd_sum). By linearity the same holds for any superposition of clean-ancilla inputs (hybridLin_sum). measureUncompute_eq_measureCorrect— the general-wire gadget ofHybridLift.lean, at wires(0,1,2)ofQReg 3with the single correction(0,1), is the operatormeasureUncomputeofMeasurementUncompute.lean(#31): the same Hadamard, projector and CZ, entry for entry.
Honest scope #
The gadget is represented per outcome; the branch amplitude (√2)⁻¹^n says each of the 2ⁿ
outcome strings has probability 2⁻ⁿ, and every branch carries the right data. The Toffoli
count of the hybrid uncompute pass is 0 as before (each gadget is Hadamard, measurement and
Cliffords); its measurement count is n, not the 3n that #21's per-Toffoli bookkeeping
implied. No ECDSA resource-score change is claimed.
The general-wire gadget is #31's gadget #
update w 2 mo on three wires is the literal triple.
The entry identity behind the bridge: the general-wire gadget entry is the product of #31's correction, projector and Hadamard entries.
★ The general-wire gadget is #31's gadget. On QReg 3, the measure-and-correct gadget
on ancilla 2 with the single correction (0, 1) is the operator measureUncompute of
MeasurementUncompute.lean, entry for entry.
Why one gadget per cell: the naive replacement's sign #
The naive replacement is not amplitude-exact. On the four wires a, b, c, g with
a = b = 1, c = 0 and the ancilla g = 1 = maj(a, b, c), the single-CZ gadget for the block
CCX b c g (corrections for b ∧ c = 0 only) flips the sign of the m = 1 branch: the data
survive, but with the relative phase (−1)^{ab ⊕ ac} = −1 against the branches where it does
not fire.
The hybrid adder #
The cell gadget: measure the majority ancilla G (i+1) of cell i and correct with a
CZ on each input pair (A i, B i), (A i, G i), (B i, G i).
Equations
Instances For
The measurement-based uncompute pass over cells k−1, …, 0 (cell k−1 first, as in
the reverse pass), one gadget per cell with outcomes mo.
Equations
- CSD.Empirical.QM.hybridUncompute L mo 0 = []
- CSD.Empirical.QM.hybridUncompute L mo k.succ = CSD.Empirical.QM.cellGadget L k (mo k) :: CSD.Empirical.QM.hybridUncompute L mo k
Instances For
The hybrid adder: the forward and sum passes as unitaries, then the measurement-based
uncompute pass over all n cells.
Equations
Instances For
The uncompute pass writes only the carry ancillas of its cells.
The uncompute pass writes each cell's outcome into its carry ancilla.
majority as a Fin 2 parity of pairwise ANDs, in the recast.
The run is well-formed. If t satisfies the carry invariant (each G (i+1) holds the
majority of A i, B i, G i), then on any register state agreeing with t on the wires of the
cells still to come, the uncompute pass over k ≤ n cells is well-formed: every gadget meets
its majority ancilla, and its corrections avoid it.
The carry invariant after the forward and sum passes #
After the forward and sum passes, each carry ancilla holds the majority of its cell's inputs: the forward carry invariant, untouched by the sum pass.
★★ The n-fold hybrid amplitude equality #
The hybrid run is well-formed on every clean-ancilla basis input.
★★ The n-fold hybrid amplitude equality. On every basis input with clean carry
ancillas, the hybrid adder — forward and sum passes, then one measure-and-correct gadget per
carry cell with outcomes mo — produces (√2)⁻¹^n • |out⟩, out the run's shadow.
The data agree with the unitary adder. On every wire other than the n carry ancillas
G 1, …, G n, the hybrid output is the unitary adder's output: the uncompute pass — unitary or
measured — writes nothing else.
The ancillas hold the outcomes.
The sum is right on every branch. The sum register of the hybrid output holds
(A + B) mod 2ⁿ, exactly as for the unitary adder (andAdd_correct).