Documentation

CsdLean4.Empirical.QM.MeasurementUncompute

Measurement-based AND-uncomputation (Gidney's measure-and-correct gadget) #

Category: 3-Local (QM-validity content; no CSD ontology).

This is the amplitude-model proof-of-concept for measurement-based uncomputation (specs Tier-X measurement-adder fork, stage L5-a). An AND-ancilla holding x ∧ y (computed earlier with a Toffoli, here entangled with the data) is uncomputed without a second Toffoli by Gidney's gadget:

  1. Apply Hadamard H to the ancilla and measure it in the computational basis (= an X-basis measurement of the original ancilla), obtaining outcome m ∈ {0,1} (each prob 1/2). The post-measurement data picks up a phase (-1)^{m·(x∧y)}.
  2. Correction: if m = 1, apply CZ to the data qubits (x,y), multiplying by (-1)^{x∧y}, which cancels the phase.

Net (BOTH outcomes): the data returns to Σ c_{xy}|x,y⟩ and the ancilla is reset to |m⟩ — the AND is uncomputed using only Cliffords (H, CZ) + a measurement, zero Toffoli. That is the ~2× saving versus the unitary AND-uncompute, which costs one Toffoli.

What is proved #

Representation choice #

We use the per-outcome partial-isometry form (not a full CPTP Channel): on the explicit 3-qubit space QReg 3 = EuclideanSpace ℂ (Fin 3 → Fin 2) (qubit 0 = x, 1 = y, 2 = a), each step is a Matrix.toEuclideanLin application — Hadamard on the ancilla (hadA, entries the corpus hadEntry = qmH), the computational projector (projA m), and the conditional CZ on the data (correctionMat m, = qmCZ-phase). This is the cleanest faithful form the amplitude machinery supports; the X-basis phases are why this lives in the amplitude model and NOT the Boolean reversible DSL.

Scope (honest) #

L5-a settled that measurement-based uncomputation is verifiable in Lean in the amplitude model. L5-b (this file) closes the operator↔list gap: gadgetGateList is now proven (definitionally) to be the decomposition of measureUncompute, so the 0-Toffoli cost is a property of the operator, not a hand-written list, and the ~2× saving is stated in the corpus Reversible.Cost model (0 Toffoli + 1 measurement + Cliffords, vs 1 Toffoli for the unitary uncompute). This is a per-AND-uncompute gate-cost statement only. Deferred: L5-c (the Boolean-arithmetic ↔ amplitude bridge — applying this to actual adders, the trusted-base increase, the wall), L5-d (the measurement-based adder + circuit re-cost). No ECDSA resource claim is made here.

@[reducible, inline]

The 3-qubit computational index type (x, y, ancilla a).

Equations
Instances For

    Coordinate primitives for Matrix.toEuclideanLin on QReg 3 #

    A diagonal register operator acts pointwise on amplitudes.

    A register operator applied to a computational basis state reads off the w-th column.

    theorem CSD.Empirical.QM.smul_coord (c : ) (v : QuantumInfo.QReg 3) (z : B3) :
    (c v).ofLp z = c * v.ofLp z

    Coordinatewise scalar multiplication on QReg 3.

    theorem CSD.Empirical.QM.b3_eq_iff (z : B3) (x y m : Fin 2) :
    z = ![x, y, m] z 0 = x z 1 = y z 2 = m

    Pointwise characterisation of a 3-qubit bitstring equality.

    The gadget components (gates on the 3-qubit register) #

    The CZ phase on the data qubits: (-1)^{x∧y} (x∧y = x·y on Fin 2).

    Equations
    Instances For
      noncomputable def CSD.Empirical.QM.hadA :

      Hadamard on the ancilla (qubit 2), identity on the data qubits (0,1). Its qubit-2 block entries are the corpus single-qubit Hadamard entries (hadEntry = qmH).

      Equations
      Instances For
        theorem CSD.Empirical.QM.hadA_apply (z w : B3) :
        hadA z w = if z 0 = w 0 z 1 = w 1 then QuantumInfo.hadEntry (z 2) (w 2) else 0
        noncomputable def CSD.Empirical.QM.projA (m : Fin 2) :

        Computational projector onto ancilla outcome m (the X-basis measurement after the Hadamard).

        Equations
        Instances For
          noncomputable def CSD.Empirical.QM.czXY :

          The CZ on the data qubits as a diagonal register operator: phase (-1)^{x∧y}.

          Equations
          Instances For
            noncomputable def CSD.Empirical.QM.correctionMat (m : Fin 2) :

            The conditional correction: CZ on the data when m = 1, identity when m = 0.

            Equations
            Instances For

              The correction at outcome 1 is exactly the data CZ.

              The correction at outcome 0 is the identity (no Toffoli, no Clifford applied).

              The AND-entangled index ![x, y, x∧y]: data (x,y) with the ancilla carrying the AND.

              Equations
              Instances For
                @[simp]
                theorem CSD.Empirical.QM.andIdx_zero (x y : Fin 2) :
                andIdx x y 0 = x
                @[simp]
                theorem CSD.Empirical.QM.andIdx_one (x y : Fin 2) :
                andIdx x y 1 = y
                @[simp]
                theorem CSD.Empirical.QM.andIdx_two (x y : Fin 2) :
                andIdx x y 2 = x * y

                The gadget and the input/output states #

                The measure-and-correct gadget, per outcome m: Hadamard the ancilla, project onto ancilla = m (the X-basis measurement), then apply the m-conditional CZ correction.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  noncomputable def CSD.Empirical.QM.andInput (c : Fin 2Fin 2) :

                  The AND-entangled input state Σ_{x,y} c_{xy} |x, y, x∧y⟩: a data superposition with the ancilla holding x ∧ y for each branch.

                  Equations
                  Instances For
                    noncomputable def CSD.Empirical.QM.uncomputedData (c : Fin 2Fin 2) (m : Fin 2) :

                    The uncomputed data, ancilla reset to |m⟩: Σ_{x,y} c_{xy} |x, y, m⟩.

                    Equations
                    Instances For

                      Reuse / honesty bridges to the corpus Clifford gates #

                      The ancilla-Hadamard block entries are the corpus single-qubit Hadamard qmH.

                      The data-CZ phase matches the corpus controlled-Z qmCZ on its diagonal (phase flip on |11⟩): the four computational diagonal values agree.

                      Per-component apply lemmas #

                      theorem CSD.Empirical.QM.corr_apply (m : Fin 2) (v : QuantumInfo.QReg 3) (z : B3) :
                      ((Matrix.toEuclideanLin (correctionMat m)) v).ofLp z = (if m = 1 then czPhase (z 0) (z 1) else 1) * v.ofLp z
                      theorem CSD.Empirical.QM.proj_apply (m : Fin 2) (v : QuantumInfo.QReg 3) (z : B3) :
                      ((Matrix.toEuclideanLin (projA m)) v).ofLp z = (if z 2 = m then 1 else 0) * v.ofLp z

                      The m = 0 numeric branch: the Hadamard projects the ancilla onto |0⟩ with amplitude (√2)⁻¹, independent of the data.

                      The genuine phase cancellation (the m = 1 branch): the (-1)^{x∧y} phase picked up by the |1⟩ projection is exactly cancelled by the data CZ, leaving amplitude (√2)⁻¹ for every data branch (x,y). This is ((-1)^{x∧y})² = 1.

                      theorem CSD.Empirical.QM.corr_had_eq (m x y : Fin 2) :
                      (if m = 1 then czPhase x y else 1) * QuantumInfo.hadEntry m (x * y) = (↑2)⁻¹

                      The combined correction × Hadamard-projection amplitude, both outcomes: (√2)⁻¹ for every m and every data branch (x,y). The m = 0 branch is the clean projection (hadEntry_zero_left); the m = 1 branch is the genuine phase cancellation (czPhase_mul_hadEntry).

                      The headline: per-basis correctness (genuine phase cancellation) #

                      Per-basis-state uncompute. For every outcome m and every data basis branch (x,y), the gadget maps the AND-entangled basis state |x, y, x∧y⟩ to (√2)⁻¹ |x, y, m⟩ — data unchanged, ancilla reset, outcome-independent after the m = 1 CZ correction. The m = 1 case is the genuine phase cancellation czPhase x y · hadEntry 1 (x∧y) = (√2)⁻¹.

                      Linearity wrappers #

                      theorem CSD.Empirical.QM.measureUncompute_sum {ι : Type u_1} (s : Finset ι) (f : ιQuantumInfo.QReg 3) (m : Fin 2) :
                      measureUncompute m (∑ is, f i) = is, measureUncompute m (f i)

                      THE headline theorem #

                      measureUncompute_uncomputes (the deliverable). For every measurement outcome m and every data superposition c, the measure-and-correct gadget maps the AND-entangled state Σ c_{xy}|x,y⟩|x∧y⟩ to the uncomputed data with the ancilla reset to |m⟩, Σ c_{xy}|x,y⟩|m⟩, scaled by the outcome amplitude (√2)⁻¹. The result is outcome-independent (the m = 1 CZ correction cancels the (-1)^{x∧y} phase): this is the net "identity-on-data ⊗ ancilla-reset".

                      Non-vacuity: the AND ancilla is genuinely set #

                      Non-vacuity. The AND-entangled input genuinely carries a = x ∧ y: on the |1,1⟩ data branch the ancilla is |1⟩ (the AND is set), so the entangled basis state is distinct from the ancilla-reset state — the uncompute is real work, not a trivial product.

                      Cost: zero Toffoli (the ~2× saving) #

                      An abstract gadget gate label, used only to state the Toffoli-count cost point.

                      Instances For
                        @[instance_reducible]
                        Equations

                        The measure-and-correct gadget's gate list: Hadamard, measurement, conditional CZ — all Cliffords + a measurement, no Toffoli.

                        Equations
                        Instances For

                          The cost point (list form). The measure-and-correct gadget's gate LIST ([H, Meas, CZ]) contains no Toffoli, whereas the unitary AND-uncompute's list contains exactly one — the ~2× (one-Toffoli) saving. This is a count over the gate lists; L5-b (measureUncompute_cost below) upgrades it to a property of the measureUncompute OPERATOR via the link gadgetGateList_denotes_measureUncompute.

                          Interpretation of a gadget gate as a register operator on QReg 3, parameterised by the measurement outcome m: hGatehadA, measGateprojA m, czGatecorrectionMat m (the three Matrix.toEuclideanLin blocks that define measureUncompute). The toffoli label maps to id — it is not part of this gadget's decomposition (it is the unitary route's gate), so it plays no role in gadgetGateList; it is given a denotation only for totality.

                          Equations
                          Instances For

                            Fold a gadget gate list into an operator, applying gates left-to-right (head first).

                            Equations
                            Instances For

                              The operator↔list link (L5-b, the honesty fix). Folding the interpretation of the cost-bearing gate list gadgetGateList = [hGate, measGate, czGate] reproduces the measureUncompute m operator exactly, for every input ψ.

                              This equality is definitional (rfl): measureUncompute m ψ is by definition the composition correctionMat m ∘ projA m ∘ hadA applied to ψ, and denoteGadgetList m gadgetGateList ψ unfolds to that same composition. The point is not a deep proof but to tie the Toffoli-count statement (gadgetGateList_zero_toffoli) to the operator: gadgetGateList is a genuine decomposition of measureUncompute, not a free-standing list.

                              Per-gate fault-tolerant cost in the corpus Reversible.Cost model. Following the corpus convention (Reversible.gateCost: single-qubit Clifford X is free, two-qubit Clifford CX costs one CNOT, CCX costs one Toffoli — the FT-expensive resource), the amplitude gadget gates are billed: hGate (single-qubit Clifford) free; czGate (two-qubit Clifford CZ ≃ CNOT up to single-qubit Cliffords) one CNOT; measGate one measurement; toffoli one Toffoli. No gate here incurs a T-count beyond the Toffoli's own (kept in the toffoli field, Pass-1 model).

                              Equations
                              Instances For

                                The cost as an operator property (L5-b, the ~2× saving). Via the link gadgetGateList_denotes_measureUncompute, the decomposition gadgetGateList of the measureUncompute operator costs, in the corpus Reversible.Cost model:

                                • Toffoli 0 (the FT-expensive resource) — gadgetGateList is Toffoli-free as an operator;
                                • measurement 1 — the single X-basis ancilla measurement;
                                • CNOT 1 — the conditional CZ correction (a two-qubit Clifford, counted but cheap);

                                whereas the unitary AND-uncompute's decomposition unitaryUncomputeGateList costs Toffoli 1. So the measurement-based route saves the Toffoli (0 vs 1) at the cost of one measurement plus Cliffords — the ~2× per-AND-uncompute saving, with the measurement and Cliffords accounted as real but cheap resources and the Toffoli as the FT-expensive one.

                                Honest scope: this is a per-AND-uncompute gate-cost statement. It is not an adder- or circuit-level re-cost (that is L5-d), and it does not yet apply the gadget to Boolean arithmetic (that is L5-c, the amplitude↔Boolean bridge wall).

                                The Toffoli-free property of the operator (L5-b headline). There is a decomposition of the measureUncompute m operator (namely gadgetGateList, by gadgetGateList_denotes_measureUncompute) whose Reversible.Cost Toffoli count is 0. The 0-Toffoli is thus a property of the operator, not of a free-standing gate list.