alphaFeedback

WorksComputer Science

MBUndo: Sound, Automatic, and Efficient Measurement-Based Uncomputation for Quantum Circuits

AI contributions
Not recorded for this paper
View details

Abstract

Quantum programs that use temporary values, known as ancilla qubits, must explicitly uncompute each ancilla back to zero to ensure that the program produces correct outputs. Conventional uncomputation uses unitary quantum gates, whereas leading quantum algorithms now leverage measurement-based uncomputation (MBU), which replaces costly unitary TT gates with cheaper measurements and phase corrections. Current quantum programming frameworks can use measurement to uncompute specific gates such as Toffoli. No automatic transformation, however, accepts an arbitrary circuit whose ancillas are computed and uncomputed via the standard approach and converts the circuit to use MBU@. Researchers instead apply MBU to individual circuit designs by hand, which limits algorithm development and compiler optimization. Such a transformation has not existed due to two fundamental unknowns: where MBU applies and which gates realize MBU for an arbitrary computation. To solve these, we first present a static analysis that identifies, for each ancilla qubit, each circuit position where measurement is sound — subsuming basic assumptions that MBU only applies at the end of a circuit. Next, we present circuit transformations that soundly turn unitary uncomputation gates into efficient phase corrections after measurement — generalizing rewrite rules from prior literature that are either limited to a single gate or not applicable to a general circuit. We present \textsf{MBUndo}, an integrated compiler pass that automatically converts circuits to measurement-based uncomputation. It requires no user annotations other than which qubits are ancillas, the same as needed by existing uncomputation synthesizers, and can enhance their output circuits. We evaluate \textsf{MBUndo} on 22 benchmarks to reveal T gate reductions of >36.5%{>}36.5\% over uncomputation synthesizers.

Introduction

Like classical programs, quantum programs that implement quantum algorithms generate temporary values as part of execution. These values are stored in ancilla qubits alongside the data qubits that store the ultimate output of the computation. Classically, any temporary value can simply be discarded and destroyed once used. But in a quantum program, ancilla qubits are entangled with the data qubits they are computed from, meaning that destroying a temporary value can also corrupt the program state and jeopardize correctness of the program [40 §4].

The remedy for this problem is uncomputation [9], the process of undoing the computation of a temporary value to explicitly return it to zero and thereby eliminate all entanglement with the data qubits. Writing uncomputation by hand is common yet tedious and error-prone for programmers. Thus, researchers have developed techniques to automatically uncompute variables in programming languages [12, 26, 60] or qubits in the quantum circuits to which languages compile [35, 42, 44].

Unitary Uncomputation and Measurement-Based Uncomputation

Whether manual or automatic, uncomputation is typically [12, 26, 42, 44, 60, 67] implemented as a unitary operator — a series of quantum logic gates that do not perform measurement. This approach, which we will call unitary uncomputation, characteristically executes the inverse of every logic gate used to compute each ancilla qubit. Unitary uncomputation executes as many gates as the computation being undone, and thus accounts for up to half the runtime cost of a typical quantum circuit.

Measurement-based uncomputation (MBU) is an alternative to unitary uncomputation introduced by Gidney [ [21, 22] that can be far cheaper. Figure 1a depicts a unitary uncomputation circuit and the MBU it is equivalent to. Both circuits start with an ancilla aa holding a temporary f(x)f(x), computed from data qubits xx, that is no longer needed. The starting program state is ∑xαx∣x⟩∣f(x)⟩\sum_x \alpha_x \lvert x\rangle\lvert f(x)\rangle, which uncomputation must transform to ∑xαx∣x⟩∣0⟩a\sum_x \alpha_x |x\rangle|0\rangle_a, zeroing the ancilla while leaving the data qubits unaffected. To do so, unitary uncomputation runs the inverse of the circuit that computed f(x)f(x). This operation, denoted ⊕f(x)\oplus f(x), repeats the cost of the original computation of f(x)f(x).

Equivalence specifications of unitary uncomputation and measurement-based uncomputation

Figure 1. (a) MBU of an ancilla holding f(x)f(x), as in Gidney [ [22]. (b) MBU of a Toffoli, as in Gidney [ [21]. Equivalence specifications of unitary uncomputation and measurement-based uncomputation (MBU).

By contrast, MBU cleans up the ancilla aa by performing a destructive XX-basis measurement — it applies a Hadamard gate and then measures aa in the computational basis. This HH gate transforms the state into 12(∑xαx∣x⟩∣0⟩a+∑xαx(−1)f(x)∣x⟩∣1⟩a)\frac{1}{\sqrt{2}}\left(\sum_x \alpha_x |x\rangle|0\rangle_a + \sum_x \alpha_x(-1)^{f(x)} |x\rangle|1\rangle_a\right), so measuring aa yields 0 or 1 with equal probability. Upon outcome 0, the state collapses to ∑xαx∣x⟩∣0⟩a\sum_x \alpha_x |x\rangle|0\rangle_a, which is already the desired state. Upon outcome 1, the state collapses to ∑xαx(−1)f(x)∣x⟩∣1⟩a\sum_x \alpha_x(-1)^{f(x)} |x\rangle|1\rangle_a, where the ancilla can be safely reset to zero, but the data qubits retain an unwanted phase (−1)f(x)(-1)^{f(x)} that depends on xx. MBU thus concludes with a phase correction, controlled on xx and outcome 1, to cancel this phase.

To see why MBU is often cheaper than unitary uncomputation, consider its simplest and best-known instantiation, which is for a Toffoli gate — the quantum analogue of AND. Figure 1b shows how when an ancilla holds x1x2=x1∧x2x_1x_2 = x_1 \land x_2, unitary uncomputation executes a Toffoli gate controlled on x1x_1 and x2x_2 (⊕\oplus and Toffoli are self-inverse). MBU instead performs an XX-basis measurement and then a single controlled-ZZ (CZ) gate, when the outcome is 1, to cancel the phase (−1)x1x2(-1)^{x_1x_2}.

MBU is cheaper here because on a fault-tolerant quantum computer, a Toffoli gate costs much more than the measurement, HH, and CZ gates that replace it. Toffoli is not a Clifford gate, meaning that realizing it on a quantum error-correcting code requires decomposing Toffoli into elementary gates including the TT gate, which is a major architectural bottleneck on hardware Beverland et al. [11]. Even after recent advances that substantially reduce the cost of TT gates, each TT gate is still expected to have cost equivalent to multiple lattice surgery operations on the surface code Gidney et al. [24], whereas Clifford gates and single-qubit measurements frequently require none Litinski [34]. One Toffoli gate costs between four to seven TT gates, depending on the decomposition Jones [29]; Selinger [51]. Hadamard and CZ gates are Clifford gates, which cost zero TT gates.

Moreover, the CZ gate is needed only half of the time, since with probability 12\frac{1}{2} the measurement yields 0 and the uncomputation is complete. By applying MBU to an adder circuit, each of whose ancillas is computed by a Toffoli, Gidney [ [21] halves the TT count of quantum addition.

Automating Measurement-Based Uncomputation Soundly and Efficiently

To date, researchers have applied MBU to individual circuit designs Gidney [23]; Khattar et al. [30]; Yao et al. [65], including by generalizing Gidney’s rule (Figure 1b) to multiply-controlled-XX gates Amy and Ross [5]. Quantum programming frameworks such as Q# Svore et al. [56], Qualtran Harrigan et al. [25], and Qrisp Seidel et al. [50] automate MBU for Toffoli gates, via an AND primitive whose uncomputation is optimized as in Figure 1b for this three-qubit case.

But to date, no automatic transformation can take an arbitrary circuit, whose ancillas have been computed and uncomputed via the standard approach, and converts its unitary uncomputation into MBU. Such a transformation generalizes the benefit of MBU to circuits beyond those specifically designed and constructed to use it. In particular, it further enhances the value of existing synthesis methods for unitary uncomputation Liu et al. [35]; Paradis et al. [42, 44]; Venev et al. [60]. Making this transformation possible requires answering two fundamental questions:

Where does MBU apply? In complex circuits, either designed by hand or produced by uncomputation synthesizers, a physical ancilla wire is typically reused for several logical temporaries, each computed and uncomputed in turn, corresponding to multiple logical ancilla lifetimes. For example, given a 12-bit multiplier, the uncomputation synthesizer Unqomp [42] maps 144 ancilla lifetimes onto 23 physical ancilla wires. Each lifetime ends with the uncomputation of its temporary, so a wire offers several MBU opportunities rather than one. Correctly exploiting these opportunities requires reconstructing the lifetimes of each physical wire from an input circuit.

How is MBU realized in gates? Figure 1a specifies that MBU needs to realize (−1)f(x)(-1)^{f(x)}, but not how it can do so. For circuits [21, 65] where f(x)f(x) is computed by one gate, one can apply Gidney’s rule in Figure 1b. When f(x)f(x) needs many gates, Luongo et al. [ [37], Fig. 24 propose a different rule, shown in Figure 2. This rule, which we will call monolithic MBU, treats the unitary uncomputation circuit for f(x)f(x) as an opaque block. In Figure 2, the block corresponds to the ⊕f(x)\oplus f(x) component from Figure 1a. Instead of unconditionally executing this block, the rule performs an XX-basis measurement and then conditionally executes the block. When the XX-basis measurement of the ancilla yields 1, an HH gate brings the ancilla to ∣−⟩\lvert-\rangle, the block kicks back the phase correction (−1)f(x)(-1)^{f(x)} onto the data qubits, and subsequent HH and XX gates restore the ancilla to ∣0⟩\lvert0\rangle.

Monolithic MBU circuit

Figure 2. Monolithic MBU of an ancilla holding f(x)f(x).

Monolithic MBU has numerous shortcomings. First, only half the time does Figure 2 reduce the cost of the circuit at all. Unlike Gidney’s rule, it cannot exploit the structure of f(x)f(x) to synthesize a phase correction that always has lower TT cost. Second, Figure 2 is only sound if the ⊕f(x)\oplus f(x) block exists as a contiguous unit within the circuit, not interspersed with gates that affect other qubits. If the block included gates that modify the data xx, then Figure 2 would corrupt the data. And if f(x)f(x) is stored in multiple ancillas, Figure 2 fails to uncompute all but one. Both cases arise in practice.

This Work. In this paper, we answer the two fundamental questions above and establish the first automatic transformation from an arbitrary quantum circuit containing unitary uncomputation into one that uses measurement-based uncomputation and derives its performance benefits.

We answer the question of where to perform MBU in a circuit by presenting a static analysis that recovers the lifetimes of every ancilla via a symbolic execution tracking the basis value on each qubit. Using the analysis results, we answer how to realize MBU by incrementally constructing two circuit transformations to replace unitary uncomputation with MBU for each ancilla lifetime.

The first, endpoint MBU, directly automates the rule of Gidney [ [21] as generalized by Amy and Ross [ [5]. It converts the last uncomputation gate within each ancilla lifetime into a measurement and an appropriate phase correction gate. The second transformation, interval MBU, further turns a multi-gate unitary uncomputation for each ancilla into an efficient sequence of phase correction gates. Unlike the monolithic MBU of Luongo et al. [ [37], it replaces unitary uncomputation while guaranteeing soundness and minimizing TT-gate cost. In § 2, we walk through examples to illustrate the challenges and insights behind the static analysis and both transformations.

We integrate our analyses and transformations into a tool, MBUndo, that programmers can use to automatically convert circuits to correct and efficient measurement-based uncomputation. MBUndo requires no user annotations on input circuits other than which qubits are ancillas – the same as required by existing uncomputation synthesizers such as Unqomp [42] and Recomp [44] – and can operate as a compiler pass on their output circuits.

We evaluate MBUndo using 22 benchmarks drawn from uncomputation synthesizers and quantum algorithms. Endpoint MBU reduces TT gates over Recomp by 36.5% in geomean. Interval MBU further reduces TT gates by another 2.3 to 18.4 percentage points for benchmarks containing multi-gate uncomputation. Moreover, MBUndo automatically matches 3 of 4 evaluated specialized MBU circuits from prior literature, and processes each benchmark within 43 ms on a laptop.

Contributions. In this work, we present the following contributions:

  • § 3: A static analysis to identify the multiple logical lifetimes that exist on each physical ancilla in a circuit, maximizing opportunities to introduce measurement-based uncomputation.

  • § 4.1: Endpoint MBU, a simple transformation that soundly automates the rule of Gidney [ [21] by converting the last uncomputation gate in each ancilla lifetime into a measurement.

  • § 4.2: Interval MBU, a more advanced transformation that further converts a multi-gate unitary uncomputation for each ancilla into an efficient sequence of phase correction gates.

  • § 5: MBUndo, a tool that integrates the analyses and transformations into a compiler pass that automatically enhances the output circuits of existing uncomputation synthesizers.

  • § 6: An empirical evaluation of MBUndo’s performance on 22 benchmarks against uncomputation synthesizers, MBU circuits from prior work, and state-of-the-art circuit optimizers.

This work introduces into quantum compilers a powerful technique previously accessible only to expert circuit designers. As quantum programs become more complex and fault-tolerant devices come online, our contributions lower the barrier to practically executing them on hardware.

Overview and Examples

In this section, we explain the problem of transforming unitary uncomputation into measurement-based uncomputation. Using several example circuits, we illustrate the static analysis to determine ancilla lifetimes (§ 2.1) and the endpoint MBU transformation that soundly converts the final uncomputation gate in every ancilla lifetime to measurement (§ 2.2). We present the limitations of this method and associated challenges. Then, we present the interval MBU transformation that converts complex gate sequences to MBU (§ 2.3). We deliberately keep all examples simple, but they preview the structure of the practical applications that we evaluate in § 6.

Static Analysis for Ancilla Lifetimes: Discovering MBU Opportunities

We consider the circuit in Figure 3, which implements one round of a Feistel cipher [6], the structure underlying block ciphers such as DES. Given a function FF, a round mixes half of its state into the other, mapping (y,t)(y,t) to (t⊕F,y)(t \oplus F,y). In this circuit, F=y⊕xy⊕xyzF = y \oplus xy \oplus xyz, and the implementation uses an ancilla wire aa as temporary scratch space to compute FF.

Example circuit demonstrating lifetime analysis

Figure 3. First lifetime of aa, holding q=x′t′q = x' t'. Second lifetime of aa, holding p=x′z′t′p = x' z' t'. Fig. 3. Example circuit demonstrating lifetime analysis. Left: the input circuit, with aa’s symbolic values and lifetimes inferred by our backward symbolic execution. Right: how symbolic values of yy, tt, and aa are updated.

Converting this circuit to MBU requires replacing with measurements the multiply-controlled X (CkX\mathrm{C}^{k}\mathrm{X}; generalized Toffoli) gates that uncompute aa back to zero. The rule of Gidney [ [21] applies

to the final gate 8: its output leaves aa as zero, matching the rule in Figure 1b so that gate 8 can be soundly replaced by a measurement followed by an appropriate controlled-phase gate.

Lifetimes. Given the circuit as written, Gidney’s rule replaces gate 8 only. A second opportunity for MBU hides in the fact that Figure 3 uses aa to store two distinct temporaries in turn. Specifically, gate 1 computes q=x∧y=xyq=x\land y=xy into aa, gate 3 uncomputes q=xyq=xy, gate 4 computes p=xyzp=xyz, and gate 8 uncomputes p=x′z′t′p=x'z't' (a different formula because yy is modified in the output).

Identifying that gate 3 also leaves aa as zero yields a second candidate for MBU, but this fact is invisible in Figure 3. Thus, in § 3 we present a static analysis that, given a circuit, soundly identifies MBU candidates for each distinct lifetime of a temporary value on each ancilla wire. This analysis requires no programmer input aside from which wires are zero when the circuit ends, i.e., which wires are ancillas. From this information, it performs a backward symbolic execution to find a conservative set of positions where ancillas are cleaned up to zero and are thus eligible for MBU.

Efficient Symbolic Values. To avoid the exponential blowup of explicit quantum states, our static analysis tracks the value of each qubit as a symbolic value, a Boolean function of data qubits. We define a symbolic value as a set of atoms joined by XOR (⊕\oplus). The empty set represents 0, and a cheap symmetric difference of sets joins two values. Each atom is either a symbol for an unknown Boolean or a product of multiple symbolic values via ∧\land. Our design is more compact than algebraic normal form (ANF) [69] as used by prior symbolic executors for quantum circuits [14]. It exploits usual algebraic laws of ⊕\oplus and ∧\land, such as s⊕s=0s\oplus s=0 and s∧s=ss=ss\land s=ss=s, but not the general distributivity of ∧\land over ⊕\oplus. Its number of atoms is linear in the number of gates, whereas ANF expands (x⊕y)(z⊕w)↦xz⊕xw⊕yz⊕yw(x\oplus y)(z\oplus w)\mapsto xz\oplus xw\oplus yz\oplus yw and is exponentially large in general.

Symbolic Execution. Our analysis starts from the end of the circuit, where the symbolic value of every ancilla is 0 and every data qubit has a fresh symbol for its unknown output (e.g., y′y' and t′t' for yy and tt). It processes each gate from right to left. For a CkXC^kX gate, it XORs the product of symbolic values of the controls into the target; for a phase gate (ZZ, SS, TT), it leaves symbolic values unchanged; and for a basis-changing gate such as HH, it conservatively replaces the target with a fresh symbol. Finally, the analysis delimits each lifetime of an ancilla by where its symbolic value is 0.

For the example, Figure 3 lists the symbolic values after each analysis step. Gate 8 XORs its controls xx, zz, and tt into aa, which then stores the atom p=x′z′t′p=x'z't'. The CNOT gates 7 and 6 on yy and tt yield t=t′⊕y′t=t'\oplus y' and then y=t′y=t'. Gate 5 XORs a=pa=p into tt. Gate 4 XORs its controls xx, yy, and zz into aa, since y=t′y=t', xyz=x′t′z′=pxyz=x't'z'=p and the state of aa becomes a=p⊕p=0a=p\oplus p=0. The analysis thus identifies a lifetime spanning gates 4–8, and continues on to identify a second lifetime from gates 1–3.

Result. Our static analysis soundly identifies, given an arbitrary circuit annotated only by which qubits are ancillas, a conservative set of lifetimes of distinct temporary values on each ancilla that each expose an opportunity for MBU to the transformations we present in the next section. Beyond the small example in Figure 3, our analysis can scalably handle more complex circuits. For instance, Figure 4 shows the 14 distinct lifetimes identified by our analysis on the polynomial Pauli rotation benchmark circuit constructed by Paradis et al. [ [42] in order to evaluate Unqomp.

Polynomial Pauli rotation circuit with five data qubits and two ancilla wires

Figure 4. The 14 ancilla lifetimes identified by our static analysis on the polynomial Pauli rotation circuit on five data qubits and two ancilla wires with uncomputation synthesized by Unqomp [42].

Endpoint MBU: Soundly Applying Gidney’s Rule to Final Gates

Given lifetimes of each ancilla, one direct next step is to use Gidney’s rule at the end of each lifetime, as done manually by Gidney [ [21]; Yao et al. [ [65]. In § 4.1, we describe endpoint MBU, a circuit transformation that automates this rule in a simple and sound way. Figure 5 shows its result on the Feistel example from Figure 3, whose two unitary uncomputation gates are in purple.

Endpoint MBU applied to the circuit of Fig. 3

Figure 5. First lifetime of aa. Second lifetime of aa. Purple: unitary uncomputation. Brown: phase correction. Endpoint MBU applied to the circuit of Fig. 3. Left: the input circuit. Right: the transformed circuit.

Endpoint MBU converts the last gate of each lifetime into a measurement and phase correction. Amy and Ross [ [5] define the appropriate correction for any CkXC^{k}X gate, which generalizes Figure 1b into the correction Ck−1ZC^{k-1}Z gate over the kk controls. The k=2k=2 case corresponds to Figure 1b, whereas in general, MBU uses one control fewer than the unitary uncomputation gate being replaced.

This transformation reduces the circuit’s TT count when it replaces CkXC^{k}X with Ck−1ZC^{k-1}Z gates. In Figure 5, the purple uncomputation gates CCX (gate 3) and CCCX (gate 8) are replaced by XX-basis measurements followed by CZ and CCZ corrections in brown. CZ is Clifford and thus costs no TT gates, while CCZ differs from CCX only by Hadamard conjugation on its target and can therefore use the same decomposition as CCX, with equal TT count [51]. Even in the worst case when m1=m2=1m_1=m_2=1, both corrections together cost no more than the original CCX uncomputation gate alone, thereby eliminating the entire TT cost of the CCCX unitary uncomputation gate.

Limitations. Endpoint MBU is most effective when each lifetime is uncomputed by a single gate, like the single Toffoli in Figure 1b. But in more complex circuits, an ancilla is often uncomputed by a sequence of gates, and uncomputing one ancilla can require using another as a control.

Figure 6 depicts a circuit for t↦t⊕Ft \mapsto t \oplus F where F=x∨y∨zF=x \lor y \lor z, accumulated from three sub-cases F=x⊕xyˉ⊕xˉyˉzF=x \oplus x\bar{y} \oplus\bar{x}\bar{y}z. Gates 1–6 compute FF into the ancilla bb, where the ancilla aa holds xˉ\bar{x} (gate 3) and then xˉyˉ\bar{x}\bar{y} (gate 5). Gate 7 adds FF to tt, and gates 8–13 uncompute bb and aa. The top right of Figure 6 shows the result of endpoint MBU, which replaces one CNOT per lifetime: gate 13 by measuring bb and correcting Z(x)mbZ(x)^{m_b}, and gate 11 by measuring aa and correcting Z(x)maZ(x)^{m_a}. But since gates 13 and 11 are Clifford, the result saves zero TT gates, while the Toffoli gates 8, 9, and 10 remain.

Circuit that computes three-bit OR, showing endpoint and monolithic MBU transformations

Figure 6. A circuit that computes three-bit OR, for which endpoint MBU (top right) yields zero TT-gate savings, while monolithic MBU [37] (bottom) yields unsound and overall inefficient results.

Challenges to Generalization. Efficiently handling ancillas uncomputed by multiple gates or gates that depend on other ancillas requires a more generalized rule for MBU. The candidate in literature is the rule of Luongo et al. [ [37], which we presented in Figure 2 under the name monolithic MBU. The bottom of Figure 6 applies this rule to the three-bit OR circuit, revealing two fundamental issues:

  • Unsoundness. Monolithic MBU conditionally applies the gates of unitary uncomputation, which in Figure 6 are gates 8–13 in purple. This is unsound when the circuit intersperses modification of the data (gate 2) with computation of the ancillas. Indeed, xx is left flipped with 12\frac{1}{2} probability. Moreover, monolithic MBU measures only one ancilla but conditionally corrects all ancillas. In Figure 6, the result is that the unmeasured ancilla aa is left in a garbled nonzero state. And if it measured aa, then the phase correction would be wrong for bb as gates 8 and 10 depend on aa.

  • Inefficiency. Monolithic MBU never decreases the TT cost of phase correction. Therefore, with 12\frac{1}{2} probability, gates 8–13 execute in full and cost as much as the unitary uncomputation.

Interval MBU: Soundly and Efficiently Transforming Gate Sequences

In Section 4.2, we present interval MBU, the first circuit transformation that soundly and efficiently converts general sequences of multiple unitary uncomputation gates on multiple ancillas into MBU. We demonstrate its key insights in Figure 7 using the three-bit OR circuit from Figure 6.

Interval MBU applied to the three-bit OR circuit

Figure 7. Interval MBU applied to the three-bit OR circuit of Figure 6. Top: the isolated lifetimes of uses (•) and writes (⊕) of aa and bb; each ancilla is measured right after its last use, and the following writes form its interval. Bottom: the resulting circuit, in which each ⊕-gate of its interval is turned into a ZZ-rotation gate.

Fundamentally, monolithic MBU fails because viewing unitary uncomputation as a contiguous block leads to that block entangling the measured ancilla with every other qubit it touches. Instead of marking such blocks, interval MBU considers the lifetime of an ancilla in isolation from the rest of the circuit. Figure 7 depicts these isolated lifetimes of aa and bb derived from the input circuit.

Given the isolated lifetime of an ancilla, any dependencies on other ancillas and data qubits can be considered independently of the decisions on this ancilla. Interval MBU is a policy for where to measure the ancilla and how to correct for the effect of each gate after the measurement:

Measure After Last Use. To find the earliest point to measure an ancilla, one idea is to identify the start of unitary uncomputation for that ancilla, which in Figure 6 is the first purple ⊕\oplus in its lifetime, located at gate 8 for bb and gate 9 for aa. But this choice is unsound: measuring aa at gate 9 destroys its value, and prevents gate 10 from continuing the uncomputation of bb using aa as a control.

Instead, the safe time to measure is right after the last gate that uses the ancilla in its isolated lifetime in Figure 7 — reads it as a control ∙\bullet (ZZ) or applies a gate other than ⊕\oplus (XX) such as HH to it. We call the suffix of an ancilla’s lifetime after its last use, which only contains ⊕\oplus-gates, its interval. For bb, the last use is gate 7 and the interval is the gates 8, 10, and 13; for aa, the last use is gate 10, and the interval consists of gate 11. After its last use, the only remaining operations on an ancilla are writes by ⊕\oplus-gates that restore it to zero, so measuring it cannot disturb any other qubit.

Correct in Place. Interval MBU measures bb at the start of its interval, after gate 7, and synthesizes the phase correction for each gate in a simple way. Each ⊕\oplus constituting the interval disappears from the circuit, leaving a (potentially controlled) ZZ gate spanning its old control qubits and classically controlled by the measurement outcome mbm_b — like in endpoint MBU, but sound for a sequence of gates by the interval guarantee. Nothing else in the circuit changes, including irrelevant intervening gates such as gates 9 and 12 that do not touch bb. The bottom of Figure 7 presents the result.

Result. Interval MBU effectively reduces the TT cost of the three-bit OR circuit. Whereas endpoint MBU replaces gates 11 and 13, interval MBU replaces gates 8, 10, 11, and 13 and retains only gate 9 for uncomputation. Counting seven TT gates per Toffoli, unitary uncomputation (gates 8–13) costs 3×7=213 \times7 = 21 TT gates, endpoint MBU replaces only CNOTs and thus costs the same, and interval MBU leaves a single Toffoli, or 7 TT gates, with all phase corrections being Clifford CZ or ZZ gates.

Static Analysis for Ancilla Lifetimes

In this section, we formalize MBUndo’s static analysis for ancilla lifetimes — the backward symbolic execution introduced informally in § 2.1. The input of the analysis is a circuit C=g1⋯gnC = g_1 \cdots g_n over unitary gates gig_i and a set QQ of qubits including the subset A⊊QA \subsetneq Q of ancillas, qubits promised to be ∣0⟩|0\rangle at the end of CC. The output is, for every ancilla a∈Aa \in A, the circuit positions where aa is found to hold ∣0⟩|0\rangle, which we call its zero points; they cut the physical wire of the ancilla into lifetimes.

Definitions. The notations used in the analysis are defined below. We refer to the point in the circuit after gate gig_i as position ii, so that position 00 is the beginning of CC and position nn is its end. We write σi\sigma_i for the symbolic state at position ii, which maps each qubit to its symbolic value.

qubitsq,t,c∈Qq,t,c \in Q
ancillasa∈A⊆Qa \in A \subseteq Q
gatesg1⋯gng_1 \cdots g_n
positions0≤i≤n0 \leq i \leq n immediately after gig_i
qubits(gg)the qubits that gg acts on
written(gg)the target qubit(s) of gg
symbolss∈Syms \in\mathrm{Sym}
valuesV,W∈Val=P(Atom)∋∅V,W \in\mathrm{Val} = \mathcal{P}(\mathrm{Atom}) \ni\varnothing
atomsα∈Atom={1}∪Sym∪{pO}\alpha\in\mathrm{Atom} = \{1\} \cup\mathrm{Sym} \cup\{p_O\}
product atomspOp_O, O⊆ValO \subseteq\mathrm{Val}, ∣O∣≥2|O| \geq2
symbolic statesσ:Q→Val\sigma: Q \to\mathrm{Val}, σi\sigma_i at position ii
product tableΠ:P(Val)⇀Atom\Pi: \mathcal{P}(\mathrm{Val}) \rightharpoonup\mathrm{Atom}

caption:

:::

We first present the main algorithm of the backward symbolic execution and its transfer rules, and then detail the symbolic values and how they are updated during the execution.

Alg. 1: Backward symbolic execution.

In: circuit C=g1⋯gnC = g_1 \cdots g_n, ancillas A⊆QA \subseteq Q

Out: Z(a)⊆{0,…,n}\mathcal{Z}(a) \subseteq\{0,\ldots,n\} for each a∈Aa \in A

  1. σ(a)←∅\sigma(a) \leftarrow\varnothing for each a∈Aa \in A;

  2. σ(q)←{fresh⁡()}\sigma(q) \leftarrow\{\operatorname{fresh}()\} for each q∈Q∖Aq \in Q \setminus A;

  3. Z(a)←{n}\mathcal{Z}(a) \leftarrow\{n\} for each a∈Aa \in A;

  4. for i←ni \leftarrow n downto 11 do

  5. σ←Step⁡(σ,gi)\qquad\sigma\leftarrow\operatorname{Step}(\sigma,g_i);

  6. \qquad foreach a∈A∩qubits⁡(gi)a \in A \cap\operatorname{qubits}(g_i) do

  7. \qquad\qquad if σ(a)=∅\sigma(a)=\varnothing then

  8. Z(a)←Z(a)∪{i−1}\qquad\qquad\qquad\mathcal{Z}(a) \leftarrow\mathcal{Z}(a) \cup\{i-1\};

  9. return Z\mathcal{Z};

Main Algorithm. Given input circuit CC and ancillas AA, Algorithm 1 outputs the set Z(a)\mathcal{Z}(a) of zero points of every ancilla aa, the positions where aa is established to hold 00. Conservatively, the gates between two consecutive zero points form a lifetime where aa holds a temporary value. In Figure 3 from the overview, the zero points of aa are 00, 33, and 88, which yield the two shaded lifetimes.

Alg. 1 starts from the end of the circuit CC. By definition of AA, every ancilla holds 00 as denoted by an empty symbolic value ∅\varnothing (line 1), and every data qubit holds an unknown final value denoted by a fresh symbol (line 2). Thus, nn is a zero point of every ancilla (line 3). The main loop (lines 4–8) processes the gates from gng_n down to g1g_1, computing σi−1=Step⁡(σi,gi)\sigma_{i-1} = \operatorname{Step}(\sigma_i,g_i) by the transfer rules that we define below. After each gate gig_i that touches aa, the algorithm examines the value of aa: if σi−1(a)=∅\sigma_{i-1}(a) = \varnothing, then aa is established to hold 0 immediately before gig_i, and position i−1i-1 is recorded as a zero point (lines 6–8).

Transfer Rules. The heart of the algorithm is the Step function, defined as follows:

[XOR]g=XOR⁡(t;ℓ1,…,ℓk)Step⁡(σ,g)=σ[t↦σ(t)△Product⁡(σ(ℓ1),…,σ(ℓk))][Diag]g is diagonalStep⁡(σ,g)=σ[Forget]otherwiseStep⁡(σ,g)=σ[q↦{fresh⁡()}] for each q∈written⁡(g)\begin{aligned} [\mathrm{XOR}]\quad&g = \operatorname{XOR}(t;\ell_1,\ldots,\ell_k) && \operatorname{Step}(\sigma,g) = \sigma[t \mapsto\sigma(t) \mathbin{\triangle} \operatorname{Product}(\sigma(\ell_1),\ldots,\sigma(\ell_k))]\\ [\mathrm{Diag}]\quad&g\text{ is diagonal} && \operatorname{Step}(\sigma,g) = \sigma\\ [\mathrm{Forget}]\quad&\text{otherwise} && \operatorname{Step}(\sigma,g) = \sigma[q \mapsto\{\operatorname{fresh}()\}]\text{ for each }q \in\operatorname{written}(g) \end{aligned}

Rule [XOR] handles a gate XOR⁡(t;ℓ1,…,ℓk)\operatorname{XOR}(t;\ell_1,\ldots,\ell_k), where k≥0k \ge0, that XORs the product of its controls into its target tt and leaves controls unchanged. Such gates include XX and CkXC^kX gates with arbitrary control polarities, which dominate the circuits we study. Each control ℓj\ell_j is either positive cjc_j or negative cˉj\bar{c}_j on a qubit cj≠tc_j \ne t. Here, △\triangle is the symmetric difference of sets, σ(q)\sigma(q) is the symbolic value of qubit qq, and σ(cˉ)=σ(c)△{1}\sigma(\bar{c}) = \sigma(c) \mathbin{\triangle} \{1\} is that of a negative control. Product computes the symbolic value of a product (∧\wedge) of the controls via several △\triangle operations; it is defined below in Alg. 2.

Rule [Diag] handles a diagonal gate, e.g., ZZ, SS, TT, a phase rotation, or any controlled version of these. This rule leaves the state unchanged because diagonal gates change no basis values. Finally, rule [Forget] conservatively handles any other gate, including those that exit the computational basis such as HH and YY rotations, by replacing the value of every qubit it writes by a fresh symbol recording that nothing is known about the value of that qubit before the unknown gate.

The [XOR] rule recognizes gates with one distinguished target qubit and zero or more control qubits, as is the case for Toffoli. Certain other well-known gates such as SWAP can be decomposed into such gates in advance. If such a decomposition is impossible, the [Forget] rule treats the gate conservatively as unknown. For unknown gates, written⁡(g)\operatorname{written}(g) is defined to be equal to qubits⁡(g)\operatorname{qubits}(g).

Symbolic Values and Updates. A symbolic value V∈ValV \in\mathit{Val} is a set of atoms and represents the XOR of its atoms; in particular, ∅\varnothing represents 0. An atom is the constant 1, a symbol ss, or a product atom pO\mathbf{p}_O, the product of a set OO of two or more values built earlier. A symbol, created by fresh⁡()\operatorname{fresh}(), stands for a basis value that the analysis does not know. A valuation function ρ:Sym→{0,1}\rho: \mathit{Sym} \to\{0,1\} assigns values to symbols, and under ρ\rho, atoms α\alpha and values VV denote basis values as follows:

⟦1⟧ρ=1,⟦s⟧ρ=ρ(s),⟦pO⟧ρ=⋀V∈O⟦V⟧ρ,⟦V⟧ρ=⨁α∈V⟦α⟧ρ.\llbracket1\rrbracket_\rho= 1,\qquad \llbracket s\rrbracket_\rho= \rho(s),\qquad \llbracket\mathbf{p}_O\rrbracket_\rho= \bigwedge_{V\in O}\llbracket V\rrbracket_\rho,\qquad \llbracket V\rrbracket_\rho= \bigoplus_{\alpha\in V}\llbracket\alpha\rrbracket_\rho.

Alg. 2: Product(V1,…,Vk)(V_1,\ldots,V_k).

  1. if Vj=∅V_j = \varnothing for some jj then return ∅\varnothing;

  2. O←{Vj∣1≤j≤k, Vj≠{1}}O \gets\{V_j \mid1 \le j \le k,\ V_j \ne\{1\}\};

  3. if O=∅O = \varnothing then return {1}\{1\};

  4. if O={W}O = \{W\} then return WW;

  5. if O={V,W}O = \{V,W\} then return Product⁡2(V,W)\operatorname{Product}_2(V,W);

  6. return {pO}\{\mathbf{p}_O\};

This definition is well-founded because the operands of a product atom are values built earlier in the analysis. When a valuation picks one basis state, a symbolic value gives the basis value of its qubit in that state as a function of the symbols. In particular, ∅\varnothing, the empty XOR, denotes 0 under every valuation, and so the constant 0 needs no atom whereas the constant 1 is the atom 1. This set representation makes the rules, XOR and product, cheap. It also enables a temporary written twice by the same gate to cancel.

Specifically, the XOR of two values is computed by their symmetric difference, V⊕W:=V△WV \oplus W := V \mathbin{\triangle} W, which realizes cancellation s⊕s=0s \oplus s = 0 by removing an atom on both sides. It realizes commutativity and associativity for free, as values are sets. The negation of a value follows as V△{1}V \mathbin{\triangle} \{1\}.

The product of kk values is computed by Alg. 2, which first handles the two constant values ∅\varnothing and {1}\{1\}, i.e., 0 and 1. If some operand is ∅\varnothing, the product is ∅\varnothing (line 1). Operands equal to {1}\{1\} do not change the product and are removed (line 2). If no operand remains, the product is {1}\{1\} (line 3), and if exactly one operand remains, the product is that operand itself (line 4). Duplicate operands collapse automatically because the operands are kept as a set, realizing the law s∧s=ss \wedge s = s.

For two operands, the algorithm calls the subprocedure Product2 (line 5), which is defined in Appendix A. Product2 uses symmetric differences to apply a limited case of distributivity only to the constant 11 of a negative control, ensuring that the representation is small yet precise.

Given three or more operands, none of which is ∅\emptyset or {1}\{1\} at this point, the algorithm performs hash-consing [20] (Ershov 1958) using a global memoization table Π\Pi that associates operand sets OO with product atoms pOp_O. On line 6, Algorithm 2 looks up the operand set in the table Π\Pi. If OO has not been seen, Π\Pi maps a fresh product atom O↦pOO \mapsto p_O and returns it.

Example. The circuit in Figure 8 has ancilla aa. The table lists its symbolic states, where Vx={x′}V_x = \{x'\} and Vy={y′}V_y = \{y'\} are the final values of xx and yy. Gate 7 XORs the value of its negative control, Vy△{1}={y′,1}V_y \mathbin{\triangle} \{1\} = \{y',1\}, into aa. Gate 6 preserves the symbolic state, since TT is diagonal. Gate 5 XORs the same value into aa, which returns to ∅\emptyset. Gate 4 replaces the value of yy by the fresh symbol y′′y''. Gate 3 XORs Product(Vx,{y′′})(V_x,\{y''\}) into aa, which creates the product atom qq for the operand set {Vx,{y′′}}\{V_x,\{y''\}\} and adds it to Π\Pi. Gate 2 preserves the symbolic state, and gate 1 XORs the same product into aa, which is in Π\Pi, so aa becomes ∅\emptyset. The zero points of aa are 0, 4, and 7, and its two lifetimes are 1–3 and 5–7 as shaded.

Circuit with two lifetimes of a and its symbolic states

Figure 8. Circuit with two lifetimes of aa and its symbolic states, where q=p{Vx,{y′′}}q = p_{\{V_x,\{y''\}\}}.

Precision. Values encode commutativity: when Vx={x}V_x = \{x\} and Vy={y}V_y = \{y\}, Product(Vx,Vy)(V_x,V_y) and Product(Vy,Vx)(V_y,V_x) both yield the atom p{Vx,Vy}p_{\{V_x,V_y\}} and their XOR is ∅\emptyset. Meanwhile, Product(Vx,{y,z})(V_x,\{y,z\}) remains as one atom not expanded into xy⊕xzxy \oplus xz, because we perform no distribution of ∧\land over ⊕\oplus beyond the constant 11 and no flattening of nested products. The values thus stay compact, at the price of precision: with Vz={z}V_z = \{z\}, Product(Vx,{y,z})(V_x,\{y,z\}) and {p{Vx,Vy}}△{p{Vx,Vz}}\{p_{\{V_x,V_y\}}\} \mathbin{\triangle} \{p_{\{V_x,V_z\}}\} denote the same function but differ as values. Thus, the analysis may miss a zero point, but never reports a wrong one:

Theorem 3.1 (Soundness). Let ∣Ψi⟩|\Psi_i\rangle be the state of the circuit at position ii on any input for which every ancilla holds ∣0⟩|0\rangle at the end of the circuit. For every ancilla aa and every position i∈Z(a)i \in\mathcal{Z}(a) output by Alg. 1, aa holds ∣0⟩|0\rangle at position ii, i.e., ∣Ψi⟩=∣ψ⟩⊗∣0⟩a|\Psi_i\rangle= |\psi\rangle\otimes|0\rangle_a for some state ∣ψ⟩|\psi\rangle of the other qubits.

Proof Sketch. Appendix B gives the full proof. The key idea is that the symbolic state describes a set of possible computational-basis bit strings as its symbols change. As an invariant, this set contains at least every string with nonzero amplitude in the actual quantum state. If every string this set contains has a given ancilla equal to 0, then that ancilla is also ∣0⟩|0\rangle in the actual state.

Given a bit string bb, we write b(q)b(q) for its bit at qubit qq. We show by induction from position nn down to 0 that every basis state ∣b⟩|b\rangle with nonzero amplitude in ∣Ψi⟩|\Psi_i\rangle is covered by σi\sigma_i: some valuation ρ\rho satisfies b(q)=[σi(q)]ρb(q) = [\sigma_i(q)]_\rho for all q∈Qq \in Q. Then, σi(a)=∅\sigma_i(a) = \emptyset forces b(a)=0b(a) = 0 for every such bb.

At position nn, zero for every a∈Aa \in A and final values for data qubits provide this valuation. At each gate, rule [Xor] inverts the permutation of basis states by an XOR gate, rule [Diag] preserves the valuation, and rule [Forget] removes constraints on valuations on target qubits. □

Theorem 3.2 (Complexity). Define N=∣Q∣+∑i=1n(1+∣qubits(gi)∣)N = |Q| + \sum_{i=1}^{n}(1 + |qubits(g_i)|) as the size of CC. Algorithm 1 runs in expected O(N2)O(N^2) time under standard assumptions on hashing. This complexity is O((n+∣Q∣)2)O((n + |Q|)^2) when the arity of all gates is bounded by a constant, i.e., ∣qubits(gi)∣=O(1)|qubits(g_i)| = O(1) for all ii.

Proof Sketch. Appendix C gives the full proof. Every atom comes from one qubit or by one gate, so there are O(N)O(N) atoms, and every value (set of atoms) has size O(N)O(N). A gate on kk qubits uses O(k+1)O(k+1) set operations on values, which costs O((k+1)N)O((k+1)N) and sums to O(N2)O(N^2) over the circuit. □

Automatic Transformations from Unitary to Measurement-Based Uncomputation

In this section, we present the two circuit transformations of MBUndo, endpoint MBU (§ 4.1) and interval MBU (§ 4.2), which were introduced informally in Sections 2.2 and 2.3.

Endpoint MBU for Final Uncomputation Gates

Endpoint MBU (Algorithm 3) automates the rule of Gidney [ [21] and Amy and Ross [ [5] that applies to any gate g=XOR⁡(a;ℓ1,…,ℓk)g = \operatorname{XOR}(a; \ell_1, \ldots, \ell_k), i.e., a gate such as Toffoli that maps ∣c⟩∣a⟩|c\rangle|a\rangle to ∣c⟩∣a⊕f(c)⟩|c\rangle|a \oplus f(c)\rangle for its controls cic_i or negations in the literals ℓi\ell_i.

Alg. 3 computes the lifetimes of every ancilla aa by Alg. 1 (line 1) and examines the last gate gg of each lifetime (lines 2–3). If gg is an XOR gate with target aa (line 4), Alg. 3 replaces it by an X-basis measurement of aa with outcome mm and a reset of aa to ∣0⟩|0\rangle (line 6) and, when m=1m = 1, a correction of the phase (−1)f(c)(-1)^{f(c)}, which for k≥1k \ge1 corresponds to a Ck−1ZC^{k-1}Z gate on the qubits c1,…,ckc_1, \ldots, c_k of the controls (lines 7–8).

For a negative control cˉj\bar{c}_j, the correction is a Ck−1ZC^{k-1}Z gate conjugated by an XX gate on cjc_j (line 8) to apply the phase when cˉj=1\bar{c}_j = 1, so whether a gate is replaced does not depend on its control polarity. Figure 9 gives an example, where a Toffoli with a negative control on yy is replaced by a CZ⁡(x,y)\operatorname{CZ}(x,y) gate between two XX gates on the negatively controlled yy, which together apply the phase (−1)xyˉ(-1)^{x\bar{y}} when m=1m = 1.

Endpoint MBU on a Toffoli with a negative control on y, using CZ(x, y) conjugated by X(y)

Figure 9. Endpoint MBU on a Toffoli with a negative control on yy, using CZ⁡(x,y)\operatorname{CZ}(x,y) conjugated by X(y)X(y).

Alg. 3: Endpoint MBU.

In: circuit C=g1⋯gnC = g_1 \cdots g_n, ancillas A⊆QA \subseteq Q

Out: circuit CC after endpoint MBU

  1. compute the lifetimes of every a∈Aa \in A by Alg. 1;

  1. foreach lifetime of an ancilla a∈Aa \in A do

  1. g←g \gets the last gate of the lifetime;

  1. if g=XOR⁡(a;ℓ1,…,ℓk)g = \operatorname{XOR}(a; \ell_1, \ldots, \ell_k) then

  1. replace gg in CC by

  1. H(a); m←Measure⁡(a); Reset⁡(a);H(a); \ m \gets\operatorname{Measure}(a); \ \operatorname{Reset}(a);

  1. if m=1m = 1 then

  1. Ck−1Z(c1,…,ck)C^{k-1}Z(c_1, \ldots, c_k) conjugated by XX on the negative controls;

  1. return CC;

Interval MBU for Sequences of Multiple Uncomputation Gates

Instead of the last uncomputation gate, interval MBU (Alg. 4) finds in each lifetime of each ancilla aa a sound interval of gates to replace. Figure 10 depicts interval MBU on the suffix of a lifetime of aa. After computing the lifetimes as Algorithm 3 does (line 1), Algorithm 4 processes each lifetime in three steps: it finds the last use of aa and its interval (lines 3–4), measures aa right after the last use (lines 5–6), and replaces every gate of the interval in place by its phase correction (lines 7–9).

A lifetime of an ancilla and its transformation by Algorithm 4

Figure 10. A lifetime of an ancilla aa (top) and its transformation by Alg. 4 (bottom), with the other qubits represented as a bundle cc. The last use of aa controls WW, and the rr writes of aa after it form the interval.

Last Use and Interval. In its isolated lifetime, aa interacts with two kinds of gates: writes by ⊕\oplus (XX) gates and uses of aa as a control for ∙\bullet (ZZ) or as a subject of non-⊕\oplus gates such as YY or HH. In Figure 10, the last use g∗g^* of aa is as a control for WW. Its interval consists of the rr writes after g∗g^*, which restore aa back to 00 (lines 3–4). The intervening gates U1,…,Ur−1U_1, \ldots, U_{r-1} do not touch aa, and g∗g^* is its last use.

Measurement After Last Use. Alg. 4 measures aa in the XX basis immediately after g∗g^*, with outcome mm, and resets aa to ∣0⟩|0\rangle (lines 5–6). The ancilla cannot be measured any earlier. If aa were measured before g∗g^*, then WW in Figure 10 would instead need to be controlled on all bits that computed aa, which kills any cost savings; the same occurs if g∗g^* were a ZZ or HH gate on aa. After g∗g^*, the only gates on aa are ⊕\oplus-writes that turn into phase corrections. If aa has no use, its interval is its whole lifetime.

In-Place Phase Corrections. Algorithm 4 replaces each ⊕\oplus-gate gg that has controls c1,…,ckc_1, \ldots, c_k in the interval of aa by the correction Ck−1Z(c1,…,ck)C^{k-1}Z(c_1, \ldots, c_k) classically conditioned on mm (lines 7–9). No gate is emitted if k=0k = 0, as that error is an undetectable global phase, and negative controls are conjugated by XX gates. Nothing else changes, in particular U1,…,Ur−1U_1, \ldots, U_{r-1} and all gates before g∗g^* in Figure 10.

Alg. 4: Interval MBU.

In : circuit C=g1⋯gnC = g_1 \cdots g_n, ancillas A⊆QA \subseteq Q

Out : circuit CC after interval MBU

  1. compute the lifetimes of every a∈Aa \in A by Alg. 1;

  2. foreach lifetime of an ancilla a∈Aa \in A do

  3.     g∗←g^{*} \leftarrow the last use of aa in the lifetime;

  4.     interval←\mathit{interval} \leftarrow the XOR gates with target aa after g∗g^{*};

  5.     insert immediately after g∗g^{*}

  6.         H(a)H(a); m←Measure⁡(a)m \leftarrow\operatorname{Measure}(a); Reset⁡(a)\operatorname{Reset}(a);

  7.     foreach g=XOR⁡(a;ℓ1,…,ℓk)g = \operatorname{XOR}(a; \ell_1, \ldots, \ell_k) in interval do

  8.         replace gg in CC by: if m=1m = 1 then

  9.             Ck−1C^{k-1}-Z(c1,…,ck)Z(c_1, \ldots, c_k) conjugated by XX on the negative controls;

  10. return CC;

Theorem 4.1 (Soundness). For every input where every ancilla ends in ∣0⟩\lvert0\rangle and for every measurement outcome, the circuits output by Algs. 3 and 4 produce the same final state as the original circuit.

Proof. Soundness of endpoint MBU follows directly from the rule of Gidney [ [21] in Figure 1b, as generalized to multiply-controlled gates by Amy and Ross [ [5]. Algorithm 3 applies this rule precisely at the end of each lifetime, which satisfies the terminal ∣0⟩a\lvert0\rangle_a condition in Figure 1b.

Soundness of interval MBU follows from a sequence of circuit equivalence rules, illustrated in Figure 11. Briefly, rule (1) follows from X=HZHX = HZH and rule (2) follows from HH=IHH = I. Rule (3) states that performing a unitary gate on a qubit and then (implicitly) measuring the qubit and discarding the outcome is equivalent to measuring the qubit immediately without performing the unitary gate. Rule (4) is the principle of deferred measurement [40].

Circuit equivalence rules

Figure 11. Circuit equivalence rules that demonstrate the soundness of interval MBU. Expressions f1f_1 and f2f_2 are the products of the controls (positive or negative) of two uncomputation gates, so aa holds f=f1⊕f2f = f_1 \oplus f_2 before the interval. The gate UiU_i stands for any intervening gates that do not touch the ancilla aa.

Fix any given lifetime of ancilla aa. As shown in Figure 10, the interval of aa consists of ⊕\oplus-gates with controls from qubits cc and intervening gates UiU_i on cc that do not interact with aa. By repeatedly applying rule (1) and cancelling adjacent Hadamard gates via rule (2), every ⊕\oplus (XX) on aa is replaced with a multiply-controlled-ZZ gate that has ∙\bullet (ZZ) in place of ⊕\oplus on aa. This step corresponds to lines 7–9 in Algorithm 4. Now, each endpoint of the interval has an uncancelled Hadamard gate. Theorem 3.1 guarantees the terminal ∣0⟩\lvert0\rangle condition of rule (3), so by applying rule (3), the final Hadamard gate is replaced with a ZZ-basis measurement-and-reset gate. By repeating rule (4), this measurement commutes backwards through each ∙\bullet on aa by replacing quantum with classical control. The end of this process leaves one Hadamard gate and measurement-and-reset gate at the beginning of the interval — corresponding to lines 3–6 of Alg. 4. These rules do not change the basis state of any qubit other than aa, and the gates they add do not touch any other ancilla between its last use and the end of its lifetime — the same argument repeats for the remaining ancillas. ▫

Theorem 4.2 (Cost). Assuming that a Ck−1ZC^{k-1}Z gate costs no more TT gates than a CkXC^kX gate, for every measurement outcome, the circuits output by Algs. 3 and 4 execute no more TT gates than the original.

Proof. Consider a replaced gate gg, whose TT cost is ee. The MBU transformation removes gg and adds only its phase correction, an HH gate, and a measurement-and-reset gate for the whole interval. Only the correction can have nonzero TT cost. It consists of XX gates and a Ck−1ZC^{k-1}Z gate, which has a TT cost of at most ee by the assumption—which holds for standard decompositions [51]—and it executes only when m=1m=1. Hence, no output executes more TT gates than the original. □

Complexity. Neither transformation increases the asymptotic complexity of the static analysis (Theorem 3.2). Once Alg. 1 has computed the zero points, one pass over the gates of each ancilla finds its lifetimes, their last gates for endpoint MBU, and their last uses and hence their intervals for interval MBU. This takes O(N)O(N) time in total for the size NN of Thm. 3.2. Each replaced gate on k+1k+1 qubits becomes O(k)O(k) gates, namely one Ck−1ZC^{k-1}Z gate and at most 2k2k XX gates. Both transformations thus run in O(N)O(N) time and output a circuit of size O(N)O(N), so the total time of MBUndo stays at the expected O(N2)O(N^2) of Theorem 3.2, which remains dominated by the static analysis.

Implementation

We implement MBUndo as a compiler pass atop Qiskit 2.5.2 [27]. MBUndo takes as input a circuit and a list of ancillas that the circuit uncomputes unitarily. It performs the static analysis of § 3, followed by either the endpoint MBU (§ 4.1) or the interval MBU (§ 4.2) transformation. It then outputs a circuit in which ancillas are uncomputed by measurement.

This design enables MBUndo to be applied as a compilation pass to the output circuits of existing synthesizers for unitary uncomputation, thereby further enhancing their value. In this section, we detail several practical decisions made when implementing the techniques of § 3 and § 4:

Multi-Target Gate Normalization. Before the symbolic execution of § 3, MBUndo ensures that every gate falls into one of the categories handled by the rules of Step. Specifically, a multi-target gate of Qiskit whose definition consists of XOR gates only, e.g., SWAP, the Fredkin gate, and the double-CNOT gate, is decomposed into those XOR gates via its definition. Any other multi-target gate is conservatively treated as an unknown gate, which is handled by the [FORGET] rule.

Skipping Unprofitable Replacements. In its implementation of the transformations of § 4, MBUndo applies a filter to skip unprofitable replacements under the cost model of this paper. In particular, it leaves a lifetime unchanged if its last gate has fewer than two controls (i.e., an X or CNOT gate, which is Clifford) under endpoint MBU, or if its interval is a single such gate under interval MBU, as such a replacement is not profitable in either the TT or the Clifford count.

Relative-Phase Toffoli Gates. It is common for uncomputation synthesizers such as Unqomp [42] and ReQomp [44] to postprocess their output circuits by replacing each compute–uncompute pair of Toffoli gates on an ancilla with a pair of relative-phase Toffoli gates [7, 38], named RCCX in Qiskit. The RCCX gate RR controlled on aa and bb acts on target tt as R∣a,b,t⟩=iab(−1)a⊕b∣a,b,t⊕ab⟩R\lvert a,b,t\rangle=i^{ab}(-1)^{a\oplus b} \lvert a,b,t\oplus ab\rangle. This substitution is sound because RCCX is equal to Toffoli except for a phase that a paired RCCX on the same qubits cancels. It is profitable because an RCCX gate requires 4 TT gates, whereas Toffoli requires 7.

By nature, the RCCX substitution is orthogonal to our subject: turning unitary uncomputation into MBU. The practical wrinkle is that MBU is only conditionally applicable to RCCX gates. As we detail in Appendix § 14, the analogue of Gidney’s rule (Figure 1b) for the RCCX gate is sound under endpoint MBU for one RCCX, but is unsound under interval MBU for multiple RCCX gates.

To sidestep this unsoundness, MBUndo pre-processes its input circuit to restore RCCX pairs to Toffoli pairs, which does not change its semantics (Appendix § 14). After synthesizing MBU, it post-processes its output circuit to re-introduce RCCX in place of Toffoli gates whenever Unqomp or Reqomp would do the same. In brief, MBUndo first replaces every pair of Toffoli gates on an ancilla that the MBU transformation left intact with a pair of RCCX gates. This step mirrors Unqomp and Reqomp, but unlike them it misses the Toffoli gates whose partners were eliminated by MBU. To catch the benefit of RCCX for them as well, MBUndo replaces conservatively each such widowed Toffoli gate whose target is constant with an RCCX gate and a Clifford correction, which is sound by an analogue of Eq. (12) of Amy and Ross [ [5]. Neither pre- nor post-processing affects the asymptotic complexity of MBUndo, and for fairness we apply the above post-processing to every baseline in our evaluation. Overall, this approach matches existing practice, retains the TT-count advantages of RCCX over Toffoli, and enables fair evaluation against existing systems.

Evaluation

In this section, we evaluate the performance of MBUndo via the following research questions:

RQ1. By how much do MBUndo’s automatic transformations, endpoint and interval MBU, reduce the gate costs of the circuits generated by synthesizers for unitary uncomputation?

RQ2. How do the results of MBUndo’s automatic transformations compare against baseline MBU constructions known in the literature for specific circuits?

RQ3. How well does MBUndo scale in compile time when given large circuits?

RQ4. How do gate savings from MBUndo compare against prior optimizers for quantum circuits?

RQ1: Enhancement Over Unitary Uncomputation Synthesizers

RQ1. By how much do MBUndo’s automatic transformations, endpoint and interval MBU, reduce the gate costs of the circuits generated by synthesizers for unitary uncomputation?

Benchmarks. We evaluate on 22 benchmark circuits, drawn from three sources:

  • a) Unitary Uncomputation Circuits. All ten benchmarks evaluated by Reqomp [44], together with all three circuits evaluated by RwUn [35] that assume clean1 ancillas, namely Incrementer, CondCleanMCS, and RiseCondCleanMCS.

  • b) MBU Circuits. Six explicit circuits from the literature, to which MBU has been manually applied: GidneyAdder [21], TableLookup [23], GF8Multiply [30], TwoSidedComparator and VBEModAddition [Luong et al. 2025], and QLZOC [65]. We force MBUndo to rediscover the MBU opportunities in these benchmarks by removing all uncomputation from them and passing them to synthesizers for unitary uncomputation.

  • c) Additional Circuits. Three other benchmarks for which MBU has not been previously explored, in which unitary uncomputation of an ancilla requires a sequence of gates: KeccakChi [4], SpeedySbox [54], and MatrixVectorEq [Pinto 2022].

Methodology. We evaluate against all existing circuit-level uncomputation synthesizers, namely Unqomp [42], Reqomp2 [44], and RwUn [35] with its three clean-ancilla strategies Sequential, Reverse, and Jointly.3 For each benchmark, we run the synthesizer, obtain its output circuit and list of ancillas, and apply MBUndo. Following the methodology of Paradis et al. [ [41, 43], we decompose all CkXC^kX gates in the circuits into Toffoli ladders before synthesizing uncomputation. Uniquely, Reqomp can trade recomputation, i.e., more gates, for fewer ancillas on circuits that have specific dependency structures. We specify the default ancilla budget so that Reqomp does not unnecessarily incur additional gates.

As discussed in § 5, MBUndo applies RCCX post-processing analogous to Unqomp and Reqomp. For clarity, we report gate counts (i) without post-processing after any tool and (ii) with post-processing after each tool. For MBUndo, the worst-case gate counts assume that every phase correction executes, while expected counts use the fact that each measurement has an independent 50% probability of leaving no phase to correct and thus needing zero correction gates. The two usually differ only in Clifford count, as Toffolis require zero TT phase corrections under MBU.

Results. Table 1 reports results against Reqomp, while Appendix § 15 reports the remainder. We focus on Reqomp as it is the only baseline that does not timeout or crash on all 22 benchmarks, and on all but one it matches or outperforms Unqomp and RwUn in TT count. In the analysis below, we first compare endpoint MBU to Reqomp. Then, we compare interval to endpoint MBU on the benchmarks that compute ancillas using multiple gates, making endpoint MBU insufficient.

BenchmarkQALTMReqompEnd. MBUInt. MBUReqompEnd. MBUInt. MBU
End.Int.TTCTTCTTCTTCTTCTTC
Adder3612111111308420231349154266176288132261121244
DeutschJozsa19888811915863106631067111039903990
Grover93202020336479196349196349216359136309136309
IntegerComparator24111161014719910516077125871396312447109
MCX231010101014716877103771038710847834783
MCRY†241111111115417877107771078811244854485
Multiplier249656565770970315548245473440640180438170423
PiecewiseLinearR†1364221361078153093113948331277868132078412687281221
PolynomialPauliR†93454545630780315488315488360510180398180398
WeightedAdder25977747412461499728101872810138321085536890536885
Incrementer125555708735553555405720452045
CondCleanMCS12168939393138916027389987389987951008423776423776
RiseCondCleanMCS1122221011288711587115598651815181
TwoSidedComparator24196979797267435301995290013442202153423901146214810532008
VBEModAddition264132135105134280039722065329013792540160027721180250410822342
TableLookup29147160698401224420834364763480864240714208659
GF8Multiply1233231261531121406387729964945783
KeccakChi40112000200280042002800420014002800160030001600300014002800
SpeedySbox4319116106116310836042366291515542044177622721352200712361832
GidneyAdder38912912912912918062835903199790319331032206151617395161675
QLZOC231631521521522177311911132131111321311265220765718276571827
MatrixVectorEq32112612612612626673304178524851337190915272164102318499591657

Table 1. Gate counts of the circuits produced by Reqomp and by MBUndo when given Reqomp’s output, without and with the RCCX post-processing of § 5. TT and C are the counts of TT and Clifford gates on expectation, rounded to integers. Q and A are the numbers of qubits and of ancillas of Reqomp’s output, which MBUndo does not change. LT is the number of lifetimes identified by our analysis, and M the number of measurement-and-reset gates introduced by endpoint (End.) and interval (Int.) MBU.

Endpoint MBU vs. Reqomp. Figure 12 compares the gate counts of Reqomp and endpoint MBU. Without post-processing, endpoint MBU reduces TT gates over Reqomp by 37.5% and Clifford gates by 26.5% (in expectation) in geomean. After post-processing for both, endpoint MBU reduces TT gates by 36.5% and Clifford by 15.2% (in expectation). The Clifford reduction shrinks because MBU retains Clifford gates in phase corrections even as Reqomp decreases them in RCCX gates.

Two stacked bar charts comparing endpoint MBU with Reqomp, without and with RCCX post-processing

Figure 12. Non-Clifford costs, namely the TT, rotation (R), and measurement-and-reset (M) gates, of circuits produced by endpoint MBU given Reqomp’s output, without (top) and with (bottom) RCCX post-processing. All counts are normalized by the non-Clifford gate count of Reqomp’s output (100%). Lower is better.

The only benchmark on which endpoint MBU performs no transformation is KeccakChi. Its last uncomputation phase in every lifetime is Clifford, which if replaced would save no TT gates but add Clifford corrections. MBUndo filters out such unprofitable candidates (see § 5).

Assuming that uncomputation makes up roughly half of a circuit, MBU should not be expected to reduce gate counts by more than half in general. Figure 12 depicts one exception, Multiplier, where MBUndo’s static analysis detects that certain Toffoli gates in the computation half of the circuit always leave their target as zero, and can thus also be replaced with measurement. MCRY, PiecewiseLinearR, and PolynomialPauliR use non-TT and non-Clifford rotation gates not relevant to uncomputation. MBUndo leaves them alone; we plot them for completeness.

Interval vs. Endpoint. Figure 13 compares the gate counts of interval and endpoint MBU for the 11 benchmarks where they differ, which contain ancillas that are uncomputed by multiple non-Clifford gates. Without post-processing, endpoint MBU reduces the TT and Clifford counts for these circuits by 28.9% and 19.8% over Reqomp, whereas interval MBU reduces them by 50.5% and 38.2%.

Bar charts comparing endpoint and interval MBU gate counts without and with RCCX post-processing

Figure 13. TT, rotation, and measurement gate counts of the circuits produced by endpoint and interval MBU over Reqomp outputs, on the 11 benchmarks whose ancillas are uncomputed by several non-Clifford gates, without (top) and with (bottom) post-processing. All counts are normalized as in Figure 12. Lower is better.

The results of interval and endpoint MBU are close for PiecewiseLinearR because the input to Reqomp accounts for 80.6%, not the typical ∼50%\sim50\%, of the non-Clifford gates of Reqomp’s output. Excluding these, interval MBU eliminates all TT gates in the uncomputation of this circuit.

With RCCX post-processing, endpoint MBU reduces gates by 28.5% and 11.7%, as compared to 36.0% and 18.4% for interval MBU. The gap narrows after post-processing, as RCCX substitution (§ 5) is disproportionately effective for Toffoli gates not at the end of a lifetime. Even when not eliminated, Toffoli gates only cost 4 rather than 7 TT gates when replaced with RCCX. The remaining gap is largest for IntegerComparator (18.4%) and smallest for Multiplier (2.3%).

Over the full set of 22 benchmarks, interval MBU reduces TT gates by 47.9% and Clifford by 35.6% without post-processing, and by 40.0% and 18.7% with post-processing. Both interval and endpoint MBU reduce TT gates by 43.7% on the benchmarks not shown in Figure 13 with post-processing.

Other Synthesizers. The outputs of Unqomp and RwUn exhibit similar behavior (Appendix § 15). Over Unqomp, without post-processing, endpoint and interval MBU reduce TT gates by 38.6% and 48.4% and Clifford by 26.9% and 35.2%, respectively. The three strategies of RwUn succeed on 9, 13,

and 11 benchmarks, respectively, where endpoint MBU reduces TT gates by 18.4%, 17.8%, and 17.9%, and interval MBU by 59.0%, 55.5%, and 47.8%. The same pattern appears with post-processing.

These results are different from RwUn, which rewrites the entire circuit instead of replaying the computation gates — leading to fewer opportunities for endpoint MBU but more for interval MBU. Uniquely, RwUn uncomputes some ancillas via multi-controlled gates whose MBU phase corrections use TT gates. Its expected and worst-case TT counts differ: 216 vs. 282 for MCRY.

RQ2: Comparison with Existing MBU Constructions

RQ2. How do the results of MBUndo’s automatic transformations compare against baseline MBU constructions known in the literature for specific circuits?

Benchmarks. We group the known applications of MBU to individual circuits, to the best of our knowledge, into three categories: (i) circuits that apply Gidney’s rule to uncompute each ancilla computed by a Toffoli gate, including GidneyAdder [21] and QLZOC [65]; (ii) specialized constructions that exploit the structure of a particular computation, including that of TableLookup [23 Sec. 2] and of GF8Multiply [30 Appendix C.3]; and (iii) the monolithic MBU of Luongo et al. [ [37], which applies to an uncomputation block that operates on a single ancilla and neither modifies data qubits nor depends on other ancillas.

Methodology. For categories (i) and (ii), we compare three ways to construct each benchmark: via the unitary uncomputation synthesized by Reqomp, via the output of interval MBU in MBUndo, and via the published circuit. For category (iii), there currently exists no software tool to automatically transform a circuit by monolithic MBU. Instead, we optimistically calculate its best possible performance on the 22 benchmarks from RQ1. Specifically, we compute the number of unitary uncomputation gates for each benchmark by subtracting the number of gates input to Reqomp from the number of gates it outputs. We divide this number by two, as monolithic MBU executes each uncomputation block half the time, and add it to the number of input gates. Throughout this question, to isolate the effect of MBU itself, we apply no RCCX post-processing to any tool.

Results. In Table 2, we present the results for categories (i) and (ii). This table reports only the costs of uncomputation rather than the whole circuit. For category (i), MBUndo reproduces the manual constructions: it removes every TT uncomputation gate, introduces the same measurements, and matches the worst-case Clifford counts, with equal or lower expected Clifford count.

BenchmarkUncomputationTTCM
GidneyAdderReqomp (unitary)90311600
MBUndo (interval)0257.5 (386)129
Gidney [ [21]0321.5 (386)129
QLZOCReqomp (unitary)106412160
MBUndo (interval)0228 (304)152
Yao et al. [ [65]0228 (304)152
GF8MultiplyReqomp (unitary)63750
MBUndo (interval)09 (15)3
Khattar et al. [ [30]07.5 (10)3
TableLookupReqomp (unitary)4486360
MBUndo (interval)182372 (405)43
Gidney [ [23]49127 (151)19

Table 2. Cost of the uncomputation in the circuits of categories (i, above) and (ii, below) through unitary uncomputation, MBUndo, and prior constructions.

For category (ii), on GF8Multiply, MBUndo similarly eliminates all TT gates. On TableLookup, MBUndo obtains 67% of the TT reduction of the specialized design, leaving 182 of 448 gates where the prior work leaves 49. This result is expected, as Gidney [ [23] performs a structural rewrite beyond a general-purpose transformation like MBUndo — measuring the lookup register and correcting the remaining phases with another lookup over a table of only L\sqrt{L} entries for LL addresses.

We present the results for (iii) in Appendix F. MBUndo surpasses the best possible performance of monolithic MBU on all 22 benchmarks, in TT and expected and worst-case Clifford counts. Relative to Reqomp, monolithic MBU reduces TT gates by at most 23.1% (geomean) and Clifford gates by at most 21.4%, whereas interval MBU reduces them by 47.9% and 35.6% (in expectation).

RQ3: Scalability of MBUndo

RQ3. How well does MBUndo scale in compile time when given large circuits?

Methodology. The 22 benchmarks of RQ1 span a variety of sizes, and MBUndo completes each within 43 ms on a laptop. To cover a wider range of sizes, we use the ten benchmarks of Reqomp, each of which is built from a scaling parameter nn, e.g., the number of bits of the operands of Adder. RQ1 evaluates them at the smallest size used by Paradis et al. [ [44], Sec. 6.1; here we evaluate six sizes per benchmark. We report the running time and TT count of MBUndo applying interval MBU to the output of Reqomp, in the same setting of RQ1 with post-processing. We also report running times of Reqomp itself, to compare the time that MBUndo adds on top of its upstream tool.

As another baseline specific to the static analysis of Section 3, we compare against the symbolic executor of Carette et al. [ [14] for simulating quantum circuits over basis states. Like MBUndo, it tracks every qubit as a Boolean function of symbolic variables. However, it represents the function in algebraic normal form (ANF), which applies the full distributivity of ∧\land over ⊕\oplus and can blow up in the size of a symbolic value. To compare the two representations, we run the tool of Carette et al. [ [14] on the outputs of Reqomp for the 15 of the 22 benchmarks of RQ1 that consist of XOR-based gates only (the tool does not support other gates). We obtain the ANF after each write to an ancilla to compare the zero points (see § 3) identified by that tool and by MBUndo.

Results. Figure 14 shows representative timing results on Adder; the other nine circuits (Appendix § 17) exhibit a similar pattern. MBUndo stays efficient even on large circuits: on Adder, its running time grows from 4 milliseconds at n=12n = 12 to 0.10 seconds at n=400n = 400. Over all benchmarks, it takes at most 1.0 second, on the largest instance of PolynomialPauliR. For reference, the upstream tool Reqomp takes 480 seconds to synthesize the uncomputation of Adder with n=400n = 400.

Comparison of MBUndo and Reqomp on Adder with varying bit width n on x-axis

Figure 14. Comparison of MBUndo (—○—) and Reqomp (–□–) on Adder with varying bit width nn on xx-axis.

When run on the 15 RQ1 benchmarks, the symbolic executor of Carette et al. [ [14] times out on five circuits after 1,000 seconds. On the ten benchmarks it completes, it identifies the same zero points as those found by MBUndo’s static analysis. This comparison indicates that MBUndo can precisely identify ancilla lifetimes on the evaluated circuits in time less than prior tools.

RQ4: Comparison with Circuit Optimizers

RQ4. How do gate savings from MBUndo compare against prior optimizers for quantum circuits?

Methodology. MBUndo is designed to reduce the gate cost of circuits that rely on unitary uncomputation. Among existing circuit optimizers, SPARE [52] is most similar in purpose: it targets the compute–use–uncompute structure of ancillas to optimize circuits.

Also relevant are optimizers such as Tzap [2] and Feynman [3] that perform rewrites unrelated to uncomputation such as phase folding. However, these tools currently handle circuits with measurements only by treating every measurement as opaque and ignoring the relationship between measured outcomes and classically controlled gates. This behavior significantly reduces their optimization opportunities on any circuit that uses MBU, so applying them to the outputs of both Reqomp and MBUndo would not compare the two on equal footing.

Instead, we take a conservative approach: give Reqomp the benefit of the optimizer and deny it to MBUndo. We obtain the gate counts of Reqomp followed by the Tzap optimizer with its recommended setting -O3 that includes phase folding to combine and cancel rotation gates. Feynman, which also uses phase folding, never leaves fewer T gates than Tzap on our benchmarks.

We provide to each optimizer the output circuit of Reqomp on the 22 benchmarks of RQ1. We apply the RCCX post-processing of RQ1 to the outputs of Reqomp and MBUndo; Tzap does not output any Toffoli gates to post-process, and SPARE performs its own RCCX post-processing that covers no fewer gates than ours. We give SPARE a time limit of 1,000 seconds per circuit.

Results. Appendix § 18 lists the gate counts and running times of the evaluated optimizers on all benchmarks. SPARE completes 18 of the 22 benchmarks without timing out or crashing. On those 18 cases, SPARE reduces the TT count of Reqomp’s output by 13.8% in geomean. MBUndo using interval MBU reduces the TT count by 41.4% on these 18 benchmarks, and uses fewer TT gates than SPARE on all but PolynomialPauliR, where SPARE trades TT gates for rotation gates. SPARE takes between 2.6 and 879 seconds, whereas MBUndo takes at most 43 milliseconds per circuit.

MBUndo produces fewer TT gates than Reqomp optimized by Tzap on 13 of the 22 benchmarks, even in this disadvantaged setting as explained above. On these 13 benchmarks, MBUndo reduces the TT count of Reqomp’s output by 44.5% in geomean, whereas Tzap reduces it by 10.2%; on the other nine, MBUndo reduces it by 32.8% and Tzap reduces it by 49.2%. These results suggest that transforming unitary uncomputation into MBU can by itself trade blows with a state-of-the-art circuit optimizer. We hope they motivate greater support for dynamic circuits in optimizers, which if combined with MBUndo can yield improvements beyond what either tool achieves alone.

Related Work

Uncomputation. The study of uncomputation originates in reversible computing [9]. For quantum programs, uncomputation has received architectural support [49], automation via type systems in languages [12, 26], and modular synthesis by compilers for languages [60, 62] and circuits [42, 44, 55]. For example, Tiwari et al. [ [59] uncompute ancillas by partial uncomputation when dependencies are cyclic, and RwUn [35] synthesizes uncomputation by rewrite rules that extend to dirty ancillas. All of these prior approaches synthesize circuits through unitary rather than measurement-based uncomputation.

Since its introduction, MBU has been applied by hand to numerous circuit designs [23, 30, 37, 65]. Programming frameworks such as Q# [56], Qualtran [25], and Qrisp [50] incorporate MBU as primitives taken from published circuit designs, and recent work furthers understanding of MBU from an error-correction perspective [28]. Our contribution of MBUndo complements these specific MBU constructions by automatically converting unitary uncomputation in arbitrary circuits to MBU, without requiring a specific circuit structure or uncomputed function.

Our work focuses on saving TT gates and not qubits. A rich body of work studies the time–space trade-offs of re-materializing temporary values, as shown in reversible pebble games [10, 31]. Spooky pebble games [22] similarly arise from MBU, with advantages in minimizing qubits at the cost of more gates [32, 48].

Symbolic Execution. Symbolic representations of quantum states have been applied to debugging [19], verification [Bauer-Marquart et al. 2023], and simulation [15] of quantum programs. Closest to our work, Carette et al. [ [14] simulate Hadamard–Toffoli circuits by tracking the basis value of each qubit as a Boolean formula in algebraic normal form. Our analysis instead tracks basis values conservatively as sets of XOR terms, which keeps them linear in the circuit size (Theorem 3.2) for scalability (§ 6.3). Our symbolic values share the spirit of XOR-AND graphs [39], which represent a Boolean function as a graph of XOR and AND nodes from which a compiler emits a circuit; our values differ in that they are updated gate by gate during symbolic execution, using cheap set operations and hash lookups.

Quantum Languages and Compilation. Other work in the programming languages community has furthered understanding of the implementation [13, 18, 61], compilation [46] (Tarabkha et al. 2025), optimization [16, 53, 63, 64, 68], and verification [1, 33, 36, 45, 57, 66] of quantum programs. MBUndo acts as an additional compilation pass that complements and enhances this work.

Limitations and Future Directions

Language-Level. MBUndo works at the circuit level, where it transforms arbitrary circuits with unitary uncomputation. A natural alternative direction is to automate MBU at the language level. For instance, a language in the spirit of Silq [12] and Qurrts [26] could decide by its type system when a program variable admits MBU, and then synthesize the measurement and phase corrections from a language-level specification of the function.

Architecture-Level. MBUndo measures cost mainly by TT count, the standard metric for fault-tolerant circuits, because TT gates are the major bottleneck on fault-tolerant hardware [11, 24] whereas Clifford gates and measurements are far cheaper [34]. In a concrete setting, the actual cost of each operation may depend on the architecture and its error-correction scheme, both of which are evolving rapidly. Future work could incorporate into the transformations a finer-grained cost model of a concrete architecture, which accounts for the cost of TT gates in terms of the production of magic states, as well as the cost of measurement and of the classical processing it requires such as decoding and feed-forward, to decide where MBU pays off for circuits on a specific architecture and error-correction scheme.

Conclusion

This work initiates the study of automatically and systematically transforming quantum circuits to use measurement-based uncomputation. Our efficient static analysis discovers opportunities for MBU in an input circuit, while our circuit transformations soundly replace unitary uncomputation gates by measurements and phase corrections that can be efficient on fault-tolerant hardware.

In the near term, our work brings the benefit of MBU to a broad class of quantum programs; in particular, it cuts the TT-gate cost of the circuits output by existing uncomputation synthesizers and complements their methods. In the long run, we hope this work motivates compiler techniques for dynamic circuits, which combine unitary gates with measurement and classical feed-forward. Such directions reveal new ways to reduce cost that unitary gate optimization alone cannot reach.

AI Use The ideas of this work and the design of all of its analyses and transformations are due to the authors. The authors used Claude Fable 5.1 by Anthropic to implement the algorithms, to write tests for the implementation and evaluation, and to write scripts for running the experiments.

References

Algorithm for Product of Two Symbolic Values

Alg. 2 delegates the product of exactly two operands VV and WW to Product2, which is defined in Alg. 5. This algorithm distributes the constant 11 out of VV and WW for precision.

To see its correctness, let V′=V∖{1}V' = V \setminus\{1\} and W′=W∖{1}W' = W \setminus\{1\} be the operands without the constant. Since xˉy=xy⊕y\bar{x}y = xy \oplus y and xˉyˉ=xy⊕x⊕y⊕1\bar{x}\bar{y} = xy \oplus x \oplus y \oplus1, the product of VV and WW is the product of V′V' and W′W', XORed with W′W' if VV contains 11, with V′V' if WW does, and with {1}\{1\} if both do (lines 3–5). The product of V′V' and W′W' is looked up in Π\Pi under {V′,W′}\{V', W'\} just like any other product in Alg. 2, or is V′V' itself when V′=W′V' = W' (line 2).

The result of this method is that all four polarity combinations of two controls share one product atom, e.g., Product⁡(Vx△{1},Vy)={p{Vx,Vy}}△Vy\operatorname{Product}(V_x \mathbin{\triangle} \{1\}, V_y) = \{p_{\{V_x,V_y\}}\} \mathbin{\triangle} V_y. This property makes the static analysis more precise on temporaries computed and uncomputed by Toffoli gates, the most common XOR gates, without incurring additional asymptotic cost. For instance, a circuit may compute a temporary by a Toffoli with a negative control xˉ\bar{x} and uncompute it by a Toffoli with the positive control xx followed by a CNOT. Algorithm 5 ensures that these equivalent writes yield the same value.

Alg. 5: Product2(V,W)(V,W).
1V′←V∖{1}, W′←W∖{1}V' \leftarrow V \setminus\{1\},\ W' \leftarrow W \setminus\{1\};
2P←V′P \leftarrow V' if V′=W′V'=W' else P←{Π[{V′,W′}]}P \leftarrow\{\Pi[\{V',W'\}]\};
3if 1∈V1 \in V then P←P△W′P \leftarrow P \mathbin{\triangle} W';
4if 1∈W1 \in W then P←P△V′P \leftarrow P \mathbin{\triangle} V';
5if 1∈V∩W1 \in V \cap W then P←P△{1}P \leftarrow P \mathbin{\triangle} \{1\};
6return PP;

Table 5.

Proof of Theorem 3.1

Proof of Theorem 3.1. The key idea is that the symbolic state may represent extra basis bit strings, but must include every string with nonzero amplitude in the actual state. If an ancilla has the empty symbolic value, all represented strings have that bit equal to 00, so the actual state must also have that ancilla in ∣0⟩\lvert0\rangle and hence unentangled from the other qubits. Fix an input satisfying the final-zero promise on AA. A basis bit string is a map b:Q→{0,1}b : Q \to\{0,1\}, with b(q)b(q) its bit at qubit qq; b∈supp⁡Ψib \in\operatorname{supp}\Psi_i means that ∣b⟩\lvert b\rangle has nonzero amplitude in ∣Ψi⟩\lvert\Psi_i\rangle. We prove the following invariant by backward induction on the position ii:

for every b∈supp⁡Ψi,there exists ρ such that b(q)=⟦σi(q)⟧ρ for all q∈Q.\text{for every } b \in\operatorname{supp}\Psi_i,\quad\text{there exists }\rho\text{ such that }\quad b(q)=\llbracket\sigma_i(q)\rrbracket_\rho\text{ for all }q\in Q.

Such a valuation covers bb in σi\sigma_i: it matches all qubits of bb, although different strings may use different valuations, since the invariant chooses the valuation ρ\rho after the string bb.

Base case. At position nn, every supported string bb has b(a)=0b(a)=0 for all a∈Aa \in A by the promise on AA. This matches σn(a)=∅\sigma_n(a)=\varnothing, which denotes 00 under every valuation. Each data qubit q∉Aq \notin A has its own fresh symbol sqs_q, so setting ρ(sq)=b(q)\rho(s_q)=b(q) gives a valuation covering bb.

Inductive step. Assume the invariant at position ii, and choose any b∈supp⁡Ψi−1b \in\operatorname{supp}\Psi_{i-1}. We construct a valuation covering bb in σi−1=Step⁡(σi,gi)\sigma_{i-1}=\operatorname{Step}(\sigma_i,g_i) for each transfer rule.

[XOR] An XOR gate permutes basis states, so b′=gi(b)b'=g_i(b) belongs to supp⁡Ψi\operatorname{supp}\Psi_i. By the induction hypothesis, some valuation ρ\rho covers b′b'. We first show the symbolic operations realize XOR and product under every valuation:

⟦V△W⟧ρ=⟦V⟧ρ⊕⟦W⟧ρ,⟦Product⁡(V1,…,Vk)⟧ρ=⋀j=1k⟦Vj⟧ρ.\llbracket V \mathbin{\triangle} W\rrbracket_\rho=\llbracket V\rrbracket_\rho\oplus\llbracket W\rrbracket_\rho,\qquad \llbracket\operatorname{Product}(V_1,\ldots,V_k)\rrbracket_\rho=\bigwedge_{j=1}^{k}\llbracket V_j\rrbracket_\rho.

The first identity holds because △\triangle drops exactly the atoms common to VV and WW, which cancel in the XOR. The second holds because every value that Alg. 2 returns denotes the product of its operands: the constants of lines 1 and 3, the sole operand of line 4, the atom pOp_O of line 6, which denotes the product of OO by definition, and the value of Product2 (Appendix § 11); dropping operands equal to {1}\{1\} and duplicates (line 2) uses 1x=x1x=x and xx=xxx=x. For gi=XOR⁡(t;ℓ1,…,ℓk)g_i=\operatorname{XOR}(t;\ell_1,\ldots,\ell_k), the gate leaves the controls unchanged, and XORing into the target is self-inverse. Thus ⟦σi−1(t)⟧ρ=b′(t)⊕⋀j=1kb′(ℓj)=b(t)\llbracket\sigma_{i-1}(t)\rrbracket_\rho=b'(t)\oplus\bigwedge_{j=1}^{k}b'(\ell_j)=b(t) by the two identities, with b′(cˉ)=b′(c)⊕1b'(\bar{c}) = b'(c) \oplus1 for a negative control, as in the symbolic rule. All other bits and symbolic values are unchanged, so ρ\rho covers bb.

[Diag] A diagonal gate multiplies each amplitude by a nonzero phase, so the support is unchanged. As the rule also leaves σ\sigma unchanged, coverage follows from the induction hypothesis.

[Forget] The rule keeps σi(q)\sigma_i(q) for q∉written⁡(gi)q \notin\operatorname{written}(g_i) and gives each q∈written⁡(gi)q \in\operatorname{written}(g_i) a fresh symbol sqs_q, which can be assigned any bit. It thus suffices to find some b′∈supp⁡Ψib' \in\operatorname{supp}\Psi_i that agrees with bb outside written⁡(gi)\operatorname{written}(g_i). Consider the group of all basis states that agree with bb outside written⁡(gi)\operatorname{written}(g_i). By the definition of written⁡(gi)\operatorname{written}(g_i), the gate maps this group into itself, and being unitary, it preserves the total probability of the group. That probability is positive before the gate, as it includes bb, and hence after it, so some member b′b' of the group is in supp⁡Ψi\operatorname{supp}\Psi_i. Choose a valuation covering b′b' by the induction hypothesis and extend it by sq↦b(q)s_q \mapsto b(q) for each q∈written⁡(gi)q \in\operatorname{written}(g_i). The retained values contain no fresh symbol, so they still denote b′(q)=b(q)b'(q)=b(q) for q∉written⁡(gi)q \notin\operatorname{written}(g_i). The resulting valuation covers bb in σi−1\sigma_{i-1}, which completes the induction.

Finally, Alg. 1 records i∈Z(a)i \in Z(a) only when σi(a)=∅\sigma_i(a)=\varnothing, including its initialization at i=ni=n. By the invariant, every b∈supp⁡Ψib \in\operatorname{supp}\Psi_i then satisfies b(a)=⟦∅⟧ρ=0b(a)=\llbracket\varnothing\rrbracket_\rho=0. Hence all amplitudes with a=1a=1 vanish, and ∣Ψi⟩=∣ψ⟩⊗∣0⟩a|\Psi_i\rangle=|\psi\rangle\otimes|0\rangle_a for some state ∣ψ⟩|\psi\rangle of the other qubits, as required. □

Proof of Theorem 3.2

Proof of Theorem 3.2. Let nXORn_{\mathrm{XOR}} be the number of XOR gates and FF the set of gates handled by rule [Forget]. The symbolic execution creates one symbol per data qubit, one symbol per written qubit of each gate in FF, and at most one product atom per XOR gate, whether by the general lookup (Alg. 2, line 6) or by Product2_2 (Alg. 5, line 2), so the number of atoms is

B≤1+∣Q∖A∣+nXOR+∑g∈F∣written⁡(g)∣=O(N),where N=∣Q∣+∑i=1n(1+∣qubits⁡(gi)∣).B \le1 + |Q \setminus A| + n_{\mathrm{XOR}} + \sum_{g \in F} |\operatorname{written}(g)| = O(N), \qquad\text{where } N = |Q| + \sum_{i=1}^{n}(1 + |\operatorname{qubits}(g_i)|).

Every value is a set of at most BB atoms. Processing an XOR gate with kk controls builds at most kk literal values (a negation is a symmetric difference with {1}\{1\}), builds and hashes the operand set (which contains at most kk values of size at most BB), performs at most one table lookup, and performs one symmetric difference on the target, which costs O((k+1)B)O((k+1)B) in total.

With exactly two operands, Product2_2 instead removes the constant 1 from both operands, compares the two results, hashes and looks up the constant-free pair, and performs at most three further symmetric differences, all on values of size at most BB, which costs O(B)O(B), so the bound per XOR gate is unchanged. The other rules cost O(k)O(k) for a gate on kk qubits.

A gate gig_i has at most ∣qubits(gi)∣|qubits(g_i)| controls, so its cost is O((1+∣qubits(gi)∣)⋅B)O((1+|qubits(g_i)|)\cdot B), and summing over the gates gives O(B⋅∑i(1+∣qubits(gi)∣))O(B\cdot\sum_i(1+|qubits(g_i)|)). We have B=O(N)B=O(N) from above, and the sum is at most NN by the definition of NN, so the total is O(N⋅B)=O(N2)O(N\cdot B)=O(N^2) expected time under the usual assumptions on hashing. When the arity of the gates is bounded by a constant cc, i.e., ∣qubits(gi)∣≤c|qubits(g_i)|\le c for all ii, we have N≤∣Q∣(1+c)⋅n=O(n+∣Q∣)N\le|Q|(1+c)\cdot n=O(n+|Q|), and the bound becomes O(n+∣Q∣)2O(n+|Q|)^2. Finally, Alg. 1 adds only a constant work per touched ancilla and a gate, namely the emptiness test of lines 6–8, i.e., O(∑i∣qubits(gi)∣)=O(N)O(\sum_i |qubits(g_i)|)=O(N) in total, which does not affect the bound. □

Handling Relative-Phase Toffoli Gates in MBUndo

This appendix details how MBUndo treats relative-phase Toffoli gates [7, 38], named RCCX in Qiskit (§ 5). Recall that the RCCX gate RR with controls aa and bb acts on its target tt as R∣a,b,t⟩=iab(−1)at∣a,b,t⊕ab⟩R|a,b,t\rangle=i^{ab}(-1)^{at}|a,b,t\oplus ab\rangle, i.e., as a Toffoli gate up to the relative phase iab(−1)ati^{ab}(-1)^{at}. The gate is self-inverse, so a pair of RCCX gates on the same qubits cancels like a pair of Toffoli gates when the controls hold the same values at both gates and the target holds the same value before the second gate as after the first. Uncomputation synthesizers such as Unqomp [42] and Reqomp [44] guarantee this for every Toffoli gate on an ancilla by construction, as they pair each gate that computes an ancilla with one that uncomputes it on the same controls with the same values, and thus substitute RCCX for all of them.

The Obstacle to MBU on a Sequence of RCCX Gates. Consider an ancilla tt that is computed by a sequence of RCCX gates, used, and uncomputed by the same sequence in reverse order. If tt is measured after its use as in interval MBU, the correction that replaces one uncomputing gate R(a,b;t)R(a,b;t) must apply (−1)mab⋅iab⋅(−1)at(-1)^{mab}\cdot i^{ab}\cdot(-1)^{at}, where mm is the measurement outcome, the first factor is the correction for a Toffoli gate (§ 4.2), and the other two factors reproduce the relative phase of RR. The quantum value of tt, however, is no longer available after the measurement. Only when tt is uncomputed by a single gate does tt hold abab before it, so that the remaining phase reduces to (−i)ab(-i)^{ab}, which can be corrected without the value of tt. MBU on one RCCX gate is thus sound, whereas it is unsound for a sequence of RCCX uncomputation gates.

Pre- and Post-Processing. To sidestep this obstacle while keeping the benefit of RCCX, MBUndo applies MBU to Toffoli gates only, with the following pre- and post-processing. The pre-processing restores every pair of RCCX gates in the input circuit to a pair of Toffoli gates. Unlike Unqomp and Reqomp, which can pair every Toffoli gate on an ancilla because their algorithms guarantee its partner by construction, MBUndo must handle input circuits in general and thus pairs gates by the static analysis of § 3: two gates form a pair when the symbolic execution gives the same symbolic values to their controls and target after the earlier gate and before the later gate, which proves that their relative phases cancel. The pairing is thus sound for every input circuit, not only for the outputs of the existing uncomputation synthesizers.

After the transformation of § 4, the post-processing rewrites the output circuit in two steps. First, every pair of Toffoli gates on an ancilla that the transformation left intact, paired as above, is replaced by a pair of RCCX gates. The symbolic execution handles the measurements, resets, and classically controlled gates that the transformation introduces conservatively: a measurement and a classically controlled gate are treated as unknown gates by the [Forget] rule, and a reset sets its qubit to ∅\varnothing. This step alone, however, leaves every Toffoli gate whose partner was replaced by MBU as it is, whereas Unqomp and Reqomp substitute RCCX for both gates of a pair. To retain the benefit of RCCX for such gates as much as possible, the second step rewrites them individually: every remaining Toffoli gate on an ancilla whose partner was replaced by MBU is replaced by an RCCX gate and a Clifford correction, provided that its target has the symbolic value ∅\varnothing (∣0⟩\lvert0\rangle) or {1}\{1\} (∣1⟩\lvert1\rangle), as in Eq. (12) of Amy and Ross [ [5]. For ∣0⟩\lvert0\rangle, the RCCX gate yields iab∣a,b,ab⟩i^{ab}\lvert a,b,ab\rangle, and an S†S^\dagger gate on the target cancels the phase, as it contributes (−i)t=(−i)ab(-i)^t=(-i)^{ab}:

St†R∣a,b,0⟩=(−i)abiab∣a,b,ab⟩=∣a,b,ab⟩.S_t^\dagger R\lvert a,b,0\rangle=(-i)^{ab}i^{ab}\lvert a,b,ab\rangle=\lvert a,b,ab\rangle.

For ∣1⟩\lvert1\rangle, we have R∣a,b,1⟩=iab(−1)a∣a,b,1⊕ab⟩R\lvert a,b,1\rangle=i^{ab}(-1)^a\lvert a,b,1\oplus ab\rangle, and the phase is cancelled by an SS gate on the target, a ZZ gate on aa, and a global phase of −π/2-\pi/2:

e−iπ/2ZaStR∣a,b,1⟩=e−iπ/2(−1)aiabi1⊕ab(−1)a∣a,b,1⊕ab⟩=∣a,b,1⊕ab⟩,e^{-i\pi/2}Z_aS_tR\lvert a,b,1\rangle=e^{-i\pi/2}(-1)^ai^{ab}i^{1\oplus ab}(-1)^a\lvert a,b,1\oplus ab\rangle=\lvert a,b,1\oplus ab\rangle,

as iabi1⊕ab=ii^{ab}i^{1\oplus ab}=i for either value of abab. In both cases, the TT count of the gate drops from 7 to 4, so the TT-count reduction of the RCCX substitution is conservatively retained for the Toffoli gates that lose their partners to MBU. Neither the pre-processing nor the post-processing changes the complexity bound of Theorem 3.2, as both rely on the same symbolic execution.

Complete Results of RQ1

Table 3 lists the complete results of RQ1 (§ 6.1) for all uncomputation synthesizers, without and with the RCCX post-processing of § 5, including the worst-case counts of MBUndo.

BenchmarkSynthesizerPost.LTBaseline TTBaseline CCEndpoint MBU TTEndpoint MBU CCEndpoint MBU MMInterval MBU TTInterval MBU CCInterval MBU MM
AdderUnqompno11308420231 (231)348.5 (354)11154 (154)266 (277)11
yes176288132 (132)260.5 (266)11121 (121)244 (255)11
Reqompno11308420231 (231)348.5 (354)11154 (154)266 (277)11
yes176288132 (132)260.5 (266)11121 (121)244 (255)11
RwUn-SeqTimeout (>1000 s)
RwUn-Revno11385486385 (385)486 (486)0154 (154)238.5 (266)11
yes346458346 (346)458 (458)0121 (121)216.5 (244)11
RwUn-Joinno11385486385 (385)486 (486)0154 (154)238.5 (266)11
yes346458346 (346)458 (458)0121 (121)216.5 (244)11
DeutschJozsaUnqompno811915863 (63)106 (110)863 (63)106 (110)8
yes7111039 (39)90 (94)839 (39)90 (94)8
Reqompno811915863 (63)106 (110)863 (63)106 (110)8
yes7111039 (39)90 (94)839 (39)90 (94)8
RwUn-SeqError
RwUn-RevError
RwUn-JoinError
GroverUnqompno20336479196 (196)349 (359)20196 (196)349 (359)20
yes216359136 (136)309 (319)20136 (136)309 (319)20
Reqompno20336479196 (196)349 (359)20196 (196)349 (359)20
yes216359136 (136)309 (319)20136 (136)309 (319)20
RwUn-SeqError
RwUn-RevError
RwUn-JoinError
IntegerComparatorUnqompno11147215105 (105)176 (179)677 (77)141 (146)10
yes8715563 (63)140 (143)647 (47)125 (130)10
Reqompno11147199105 (105)160 (163)677 (77)125 (130)10
yes8713963 (63)124 (127)647 (47)109 (114)10
RwUn-Seqno36177872036116751 (17332)19244.5 (19941)356961.5 (13846)8294.5 (16450)35
yes177572034216721 (17302)19225.5 (19922)356931.5 (13816)8275.5 (16431)35
RwUn-Revno11147197105 (105)158 (161)677 (77)127 (136)10
yes9915475 (75)139 (142)647 (47)108 (117)10
RwUn-Joinno11147191105 (105)152 (155)677 (77)121 (128)10
yes9914875 (75)133 (136)647 (47)102 (109)10
MCXUnqompno1014716877 (77)103 (108)1077 (77)103 (108)10
yes8710847 (47)83 (88)1047 (47)83 (88)10
Reqompno1014716877 (77)103 (108)1077 (77)103 (108)10
yes8710847 (47)83 (88)1047 (47)83 (88)10
RwUn-Seqno30277231681725.5 (2359)2031.5 (2785)301074.5 (2072)1308 (2498)30
yes273931441695.5 (2329)2011.5 (2765)301044.5 (2042)1288 (2478)30
RwUn-Revno1014716877 (77)103 (108)1077 (77)103 (108)10
yes8710847 (47)83 (88)1047 (47)83 (88)10
RwUn-Joinno1014716877 (77)103 (108)1077 (77)103 (108)10
yes8710847 (47)83 (88)1047 (47)83 (88)10
MCRY†Unqompno1115417877 (77)106.5 (112)1177 (77)106.5 (112)11
yes8811244 (44)84.5 (90)1144 (44)84.5 (90)11
Reqompno1115417877 (77)106.5 (112)1177 (77)106.5 (112)11
yes8811244 (44)84.5 (90)1144 (44)84.5 (90)11
RwUn-Seqno1296342215.5 (282)252 (329)1215.5 (282)252 (329)1
yes296342215.5 (282)252 (329)1215.5 (282)252 (329)1
RwUn-Revno1296342215.5 (282)252 (329)1215.5 (282)252 (329)1
yes296342215.5 (282)252 (329)1215.5 (282)252 (329)1
RwUn-Joinno1296342215.5 (282)252 (329)1215.5 (282)252 (329)1
yes296342215.5 (282)252 (329)1215.5 (282)252 (329)1
MultiplierUnqompno657701010315 (315)587.5 (620)65245 (245)512.5 (550)65
yes440680180 (180)477.5 (510)65170 (170)462.5 (500)65
Reqompno65770970315 (315)547.5 (580)65245 (245)472.5 (510)65
yes440640180 (180)437.5 (470)65170 (170)422.5 (460)65
RwUn-SeqTimeout (>1000 s)
RwUn-RevTimeout (>1000 s)
RwUn-JoinTimeout (>1000 s)
PiecewiseLinearR†Unqompno4410781564931 (931)1427.5 (1438)21833 (833)1311 (1329)36
yes8681354784 (784)1301.5 (1312)21728 (728)1255 (1273)36
Reqompno4210781530931 (931)1393.5 (1404)21833 (833)1277 (1295)36
yes8681320784 (784)1267.5 (1278)21728 (728)1221 (1239)36
BenchmarkSynthesizerPost.LTBaseline TBaseline CEndpoint MBU TEndpoint MBU CEndpoint MBU MInterval MBU TInterval MBU CInterval MBU M
PolynomialPauliR†Unqompno45630780315 (315)487.5 (510)45315 (315)487.5 (510)
yes360510180 (180)397.5 (420)45180 (180)397.5 (510)45
Reqompno45630780315 (315)487.5 (510)45315 (315)487.5 (510)45
yes360510180 (180)397.5 (420)45180 (180)397.5 (510)45
RwUn-SeqError
RwUn-RevError
RwUn-JoinError
WeightedAdderUnqompno9013861699798 (798)1153 (1195)84798 (798)1148 (1195)
yes9121225576 (576)1005 (1047)84576 (576)1000 (1047)84
Reqompno7712461499728 (728)1018 (1055)74728 (728)1013 (1055)74
yes8321085536 (536)890 (927)74536 (536)885 (927)74
RwUn-SeqTimeout (>1000 s)
RwUn-RevTimeout (>1000 s)
RwUn-JoinTimeout (>1000 s)
IncrementerUnqompno5708735 (35)54.5 (57)535 (35)54.5 (57)
yes405720 (20)44.5 (47)520 (20)44.5 (47)5
Reqompno5708735 (35)54.5 (57)535 (35)54.5 (57)5
yes405720 (20)44.5 (47)520 (20)44.5 (47)5
RwUn-Seqno9287033222800 (2807)3253.5 (3266)7658 (1281)896.5 (1737)9
yes285533122785 (2792)3243.5 (3256)7643 (1266)886.5 (1727)9
RwUn-Revno5709470 (70)94 (94)035 (35)57.5 (63)
yes558455 (55)84 (84)020 (20)47.5 (53)5
RwUn-Joinno5709470 (70)94 (94)035 (35)57.5 (63)
yes558455 (55)84 (84)020 (20)47.5 (53)5
CondCleanMCSUnqompError
Reqompno9313891602738 (738)997.5 (1044)93738 (738)997.5 (1044)
yes7951008423 (423)775.5 (822)93423 (423)775.5 (822)93
RwUn-Seqno2410546953720 (4077)4259 (4669)22649 (3979)3041.5 (4571)2
yes410546953720 (4077)4259 (4669)22649 (3979)3041.5 (4571)2
RwUn-Revno2339838873034 (3370)3475 (3861)22302.5 (3286)2644.5 (3777)2
yes339838873034 (3370)3475 (3861)22302.5 (3286)2644.5 (3777)2
RwUn-Joinno2339838873034 (3370)3475 (3861)22302.5 (3286)2644.5 (3777)2
yes339838873034 (3370)3475 (3861)22302.5 (3286)2644.5 (3777)2
RiseCondCleanMCSUnqompError
Reqompno210112887 (87)115 (116)287 (87)115 (116)2
yes598651 (51)81 (82)251 (51)81 (82)2
RwUn-Seqno10766888559.5 (647)670.5 (779)10286.5 (486)370 (618)10
yes727850523.5 (611)636.5 (745)10250.5 (450)336 (584)10
RwUn-Revno2633736608.5 (612)711.5 (717)2241 (395)307 (500)2
yes594698572.5 (576)677.5 (683)2205 (359)273 (466)2
RwUn-Joinno2633736608.5 (612)711.5 (717)2241 (395)307 (500)2
yes594698572.5 (576)677.5 (683)2205 (359)273 (466)2
TwoSidedComparatorUnqompno97267438141995 (1995)3318.5 (3232)971344 (1344)2485.5 (2581)97
yes153426741146 (1146)2431.5 (2480)971053 (1053)2291.5 (2387)97
Reqompno97267435301995 (1995)2989.5 (2948)971344 (1344)2201.5 (2297)97
yes153426741146 (1146)2147.5 (2196)971053 (1053)2007.5 (2103)97
RwUn-SeqTimeout (>1000 s)
RwUn-RevTimeout (>1000 s)
RwUn-JoinTimeout (>1000 s)
VBEModAdditionUnqompError
Reqompno135280039722065 (2065)3289.5 (3342)1051379 (1379)2540 (2656)134
yes160027721180 (1180)2503.5 (2556)1051082 (1082)2342 (2458)134
RwUn-SeqTimeout (>1000 s)
RwUn-Revno136329043872961 (2961)4081.5 (4105)471379 (1379)2344.5 (2580)133
yes280440012490 (2490)3709.5 (3733)471082 (1082)2146.5 (2382)133
RwUn-JoinTimeout (>1000 s)
TableLookupUnqompno718401224420 (420)834 (864)60364 (364)763 (817)69
yes480864240 (240)714 (744)60208 (208)659 (713)69
Reqompno718401224420 (420)834 (864)60364 (364)763 (817)69
yes480864240 (240)714 (744)60208 (208)659 (713)69
RwUn-Seqno42247829722110.5 (2149)2615.5 (2683)40616 (1050)983.5 (1585)41
yes238829122020.5 (2059)2555.5 (2623)40538 (972)931.5 (1533)41
BenchmarkSynthesizerPost.LTBaseline TTBaseline CEndpoint MBU TTEndpoint MBU CEndpoint MBU MInterval MBU TTInterval MBU CInterval MBU M
RwUn-Revno40225427161921.5 (1953)2395.5 (2453)38588 (994)937.5 (1495)39
yes216426561831.5 (1863)2335.5 (2393)38510 (916)885.5 (1443)39
RwUn-Joinno59686999497 (497)823.5 (837)27315 (315)630 (686)59
yes482825350 (350)725.5 (739)27180 (180)540 (596)59
GF8MultiplyUnqompno3126153112 (112)140 (141)284 (84)110 (114)3
yes729964 (64)94 (95)260 (60)88 (92)3
Reqompno3126153112 (112)140 (141)263 (63)87 (93)3
yes729964 (64)94 (95)257 (57)83 (89)3
RwUn-SeqError
RwUn-RevError
RwUn-Joinno3126153112 (112)140 (141)284 (84)110 (114)3
yes729964 (64)94 (95)260 (60)88 (92)3
KeccakChiUnqompno200280046002800 (2800)4600 (4600)01400 (1400)3200 (3400)200
yes160034001600 (1600)3400 (3400)01400 (1400)3200 (3400)200
Reqompno200280042002800 (2800)4200 (4200)01400 (1400)2800 (3000)200
yes160030001600 (1600)3000 (3000)01400 (1400)2800 (3000)200
RwUn-Seqno200280044002800 (2800)4400 (4400)01400 (1400)2900 (3200)200
yes280044002800 (2800)4400 (4400)01400 (1400)2900 (3200)200
RwUn-Revno200280044002800 (2800)4400 (4400)01400 (1400)2900 (3200)200
yes280044002800 (2800)4400 (4400)01400 (1400)2900 (3200)200
RwUn-Joinno200280044002800 (2800)4400 (4400)01400 (1400)2900 (3200)200
yes280044002800 (2800)4400 (4400)01400 (1400)2900 (3200)200
SpeedySboxUnqompno116310836042366 (2366)2915 (2968)1061554 (1554)2044 (2164)116
yes177622721352 (1352)2007 (2060)1061236 (1236)1832 (1952)116
Reqompno116310836042366 (2366)2915 (2968)1061554 (1554)2044 (2164)116
yes177622721352 (1352)2007 (2060)1061236 (1236)1832 (1952)116
RwUn-Seqno124406046922786 (2982)3427 (3728)1141750 (1946)2316 (2700)124
yes278834521736 (1932)2483 (2784)1141432 (1628)2104 (2488)124
RwUn-Revno116585267405110 (5110)6051 (6104)1062198 (2842)2884 (3844)116
yes522261124792 (4792)5839 (5892)1061880 (2524)2672 (3632)116
RwUn-Joinno116310836042366 (2366)2915 (2968)1061554 (1554)2044 (2164)116
yes177622721352 (1352)2007 (2060)1061236 (1236)1832 (1952)116
GidneyAdderUnqompno12918062835903 (903)1996.5 (2061)129903 (903)1932.5 (2061)129
yes10322061516 (516)1738.5 (1803)129516 (516)1674.5 (1803)129
Reqompno12918062835903 (903)1996.5 (2061)129903 (903)1932.5 (2061)129
yes10322061516 (516)1738.5 (1803)129516 (516)1674.5 (1803)129
RwUn-SeqTimeout (>1000>1000 s)
RwUn-Revno129359850122702 (2702)4180 (4244)128903 (903)2125 (2446)129
yes321147542315 (2315)3922 (3986)128516 (516)1867 (2188)129
RwUn-JoinTimeout (>1000>1000 s)
QLZOCUnqompno152217731191113 (1113)2131 (2207)1521113 (1113)2131 (2207)152
yes12652207657 (657)1827 (1903)152657 (657)1827 (1903)152
Reqompno152217731191113 (1113)2131 (2207)1521113 (1113)2131 (2207)152
yes12652207657 (657)1827 (1903)152657 (657)1827 (1903)152
RwUn-SeqTimeout (>1000>1000 s)
RwUn-RevTimeout (>1000>1000 s)
RwUn-JoinTimeout (>1000>1000 s)
MatrixVectorEqUnqompno126266733041785 (1785)2485 (2548)1261337 (1337)1909 (2036)126
yes152721641023 (1023)1849 (1912)126959 (959)1657 (1784)126
Reqompno126266733041785 (1785)2485 (2548)1261337 (1337)1909 (2036)126
yes152721641023 (1023)1849 (1912)126959 (959)1657 (1784)126
RwUn-SeqTimeout (>1000>1000 s)
RwUn-Revno126266733041785 (1785)2485 (2548)1261337 (1337)1909 (2036)126
yes152721641023 (1023)1849 (1912)126959 (959)1657 (1784)126
RwUn-JoinTimeout (>1000>1000 s)

Table 3. Complete results of RQ1.

Complete Results of RQ2

Table 4 lists, for every benchmark of RQ1, the TT and Clifford counts of the circuit of Reqomp, the lowest counts that monolithic MBU [37] can reach as explained in § 6.2, and the counts of the circuit that MBUndo produces from the output of Reqomp with interval MBU.

BenchmarkReqomp inputReqompMonolithic MBU (best case)MBUndo (interval MBU)
TTCCTTCCTT-ΔCC-ΔTT-ΔCC-Δ
Adder15422230842023125.0%32123.6%15450.0%266 (277)36.7%
DeutschJozsa63941191589123.5%12620.3%6347.1%106 (110)32.9%
Grover19631933647926620.8%39916.7%19641.7%349 (359)27.1%
IntegerComparator7711414719911223.8%156.521.4%7747.6%125 (130)37.2%
MCX778814716811223.8%12823.8%7747.6%103 (108)38.7%
MCRY7790154178115.525.0%13424.7%7750.0%106.5 (112)40.2%
Multiplier385530770970577.525.0%75022.7%24568.2%472.5 (510)51.3%
PiecewiseLinearR833120910781530955.511.4%1369.510.5%83322.7%1277 (1295)16.5%
PolynomialPauliR315420630780472.525.0%60023.1%31550.0%487.5 (510)37.5%
WeightedAdder763937124614991004.519.4%121818.7%72841.6%1013 (1055)32.4%
Incrementer3547708752.525.0%6723.0%3550.0%54.5 (57)37.4%
CondCleanMCS682786138916021035.525.4%119425.5%73846.9%997.5 (1044)37.7%
RiseCondCleanMCS87112101128946.9%1206.2%8713.9%115 (116)10.2%
TwoSidedComparator1344191626743530200924.9%272322.9%134449.7%2201.5 (2297)37.6%
VBEModAddition1400211428003972210025.0%304323.4%137950.8%2540 (2656)36.1%
TableLookup420617840122463025.0%920.524.8%36456.7%763 (817)37.7%
GF8Multiply637812615394.525.0%115.524.5%6350.0%87 (93)43.1%
KeccakChi1400240028004200210025.0%330021.4%140050.0%2800 (3000)33.3%
SpeedySbox1554180831083604233125.0%270624.9%155450.0%2044 (2164)43.3%
GidneyAdder9031675180628351354.525.0%225520.5%90350.0%1932.5 (2061)31.8%
QLZOC1113190321773119164524.4%251119.5%111348.9%2131 (2207)31.7%
MatrixVectorEq1337165626673304200224.9%248024.9%133749.9%1909 (2036)42.2%

Table 4. Comparison with monolithic MBU [37] on the output of Reqomp. For each benchmark, the table lists the TT and Clifford counts of the input circuit of Reqomp without uncomputation, of the output circuit of Reqomp, of the best case of monolithic MBU, i.e., with half of the uncomputation gates saved in expectation, and of the circuit of MBUndo with interval MBU (in expectation, with worst case in parentheses where it differs), and the reduction (-Δ) of the latter two relative to the output of Reqomp.

Complete Results of RQ3

Figure 15 shows the results of RQ3 (§ 6.3) on all ten benchmarks of Reqomp, in the format of Figure 14: for each benchmark, the running time and TT count of MBUndo applying interval MBU to the output of Reqomp, and those of Reqomp itself, at six sizes nn.

Running time and $T$ count of MBUndo and Reqomp across ten benchmarks

Figure 15. Running time and TT count of MBUndo and Reqomp on the ten benchmarks of Reqomp at six sizes nn each, where MBUndo is run on top of the output circuit of Reqomp.

Complete Results of RQ4

Table 5 lists, for every benchmark of RQ4 (§ 6.4), the gate counts of the output of Reqomp and of the circuits that SPARE, Feynman, and Tzap produce from it, together with the running time of each tool. The corresponding counts of MBUndo are those of interval MBU with RCCX post-processing.

BenchmarkToolTime (s)TTRCliffordBenchmarkToolTime (s)TTRClifford
AdderReqomp–1760288CondCleanMCSReqomp–79501008
SPARE9.01800264SPAREtimeout (>1000 s)
Feynman0.006880242Feynman0.0267210926
Tzap0.027880176Tzap0.0277210930
DeutschJozsaReqomp–710110RiseCondCleanMCSReqomp–59086
SPARE3.0710111SPAREError
Feynman0.001710108Feynman0.00159086
Tzap0.024710108Tzap0.02559085
GroverReqomp–2160359TwoSidedComparatorReqomp–153402390
SPARE8.12160314SPARE305.8153402488
Feynman0.0051780302Feynman0.08578402107
Tzap0.0261780292Tzap0.02978401873
IntegerComparatorReqomp–870139VBEModAdditionReqomp–160002772
SPARE3.1790137SPARE838.3156703042
Feynman0.001870139Feynman0.105102402516
Tzap0.025870139Tzap0.030101602128
MCXReqomp–870108TableLookupReqomp–4800864
SPARE2.7870108SPARE85.73200589
Feynman0.001870108Feynman0.0152320766
Tzap0.025870108Tzap0.0291720500
MCRYReqomp–882112GF8MultiplyReqomp–72099
SPARE2.7806108SPARE2.684096
Feynman0.001882112Feynman0.00156083
Tzap0.024882116Tzap0.02552083
MultiplierReqomp–4400640KeccakChiReqomp–160003000
SPARE16.72360326SPARETimeout (>1000 s)
Feynman0.0092480568Feynman0.113160003000
Tzap0.0262480448Tzap0.02888203160
PiecewiseLinearRReqomp–8681821320SpeedySboxReqomp–177602272
SPARE173.38301751341SPARE168.3172602208
Feynman0.0365481821255Feynman0.090100801640
Tzap0.0314761681216Tzap0.02995001584
PolynomialPauliRReqomp–36061510GidneyAdderReqomp–103202061
SPARE13.380131260SPARETimeout (>1000 s)
Feynman0.00812061254Feynman0.057103202061
Tzap0.02512031358Tzap0.026103202060
WeightedAdderReqomp–83201085QLZOCReqomp–126502207
SPARE35.783101123SPARE878.7126502511
Feynman0.0226780945Feynman0.070108702029
Tzap0.0276780945Tzap0.027108702028
IncrementerReqomp–40057MatrixVectorEqReqomp–152702164
SPARE3.639054SPARE249.9152702290
Feynman0.00140057Feynman0.077127101908
Tzap0.02440057Tzap0.028127101908

Table 5 (PDF p. 33). Results of the circuit optimizers of RQ4 on the output of Reqomp: running time and the numbers of TT gates, rotation gates (R), and Clifford gates after RCCX post-processing (for SPARE, after its own post-processing). The Reqomp rows characterize the input circuits for the optimizers.

References

  1. [1]Parosh Aziz Abdulla, Yo-Ga Chen, Yu-Fang Chen, Lukáš Holík, Ondřej Lengál, Jyun-Ao Lin, Fang-Yi Lo, and Wei-Lun Tsai. 2025. Verifying Quantum Circuits with Level-Synchronized Tree Automata. In ACM SIGPLAN Symposium on Principles of Programming Languages, 923–953. doi:10.1145/3704868DOI
  2. [2]Aws Albarghouthi. 2026. Linear-Time T-Gate Optimization via Random Abstraction. arXiv:2605.13929 [cs.PL] doi:10.48550/arXiv.2605.13929DOI
  3. [3]Matthew Amy. 2019. Towards Large-scale Functional Verification of Universal Quantum Circuits. In International Conference on Quantum Physics and Logic, Vol. 287. 1–21. doi:10.4204/EPTCS.287.1DOI
  4. [4]Matthew Amy, Olivia Di Matteo, Vlad Gheorghiu, Michele Mosca, Alex Parent, and John Schanck. 2017. Estimating the Cost of Generic Quantum Pre-image Attacks on SHA-2 and SHA-3. In International Conference on Selected Areas in Cryptography. 317–337. doi:10.1007/978-3-319-69453-5_18DOI
  5. [5]Matthew Amy and Neil J. Ross. 2021. Phase-state duality in reversible circuit design. Physical Review A 104, 5 (2021), 052602. doi:10.1103/PhysRevA.104.052602DOI
  6. [6]Manuel Barbosa and Pooya Farshim. 2015. The Related-Key Analysis of Feistel Constructions. In Fast Software Encryption, Vol. 8540. 265–284. doi:10.1007/978-3-662-46706-0_14DOI
  7. [7]Adriano Barenco, Charles H. Bennett, Richard Cleve, David P. DiVincenzo, Norman Margolus, Peter Shor, Tycho Sleator, John A. Smolin, and Harald Weinfurter. 1995. Elementary gates for quantum computation. Physical Review A 52, 5 (1995), 3457–3467. doi:10.1103/PhysRevA.52.3457DOI
  8. [9]Charles H. Bennett. 1973. Logical Reversibility of Computation. IBM Journal of Research and Development 17, 6 (1973), 525–532. doi:10.1147/rd.176.0525DOI
  9. [10]Charles H. Bennett. 1989. Time/Space Trade-Offs for Reversible Computation. SIAM J. Comput. 18, 4 (1989), 766–776. doi:10.1137/0218053DOI
  10. [11]Michael E. Beverland, Prakash Murali, Matthias Troyer, Krysta M. Svore, Torsten Hoefler, Vadym Kluchnikov, Guang Hao Low, Mathias Soeken, Aarthi Sundaram, and Alexander Vashchillo. 2022. Assessing requirements to scale to practical quantum advantage. arXiv:2211.07629 [quant-ph] doi:10.48550/arXiv.2211.07629DOI
  11. [12]Benjamin Bichsel, Maximilian Baader, Timon Gehr, and Martin Vechev. 2020. Silq: a high-level quantum language with safe uncomputation and intuitive semantics. In ACM SIGPLAN Conference on Programming Language Design and Implementation. 286–300. doi:10.1145/3385412.3386007DOI
  12. [13]Anita Buckley, Pavel Chuprikov, Rodrigo Otoni, Robert Soulé, Robert Rand, and Patrick Eugster. 2025. A Language for Quantifying Quantum Network Behavior. In ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications. 2367–2395. doi:10.1145/3763135DOI
  13. [14]Jacques Carette, Gerardo Ortiz, and Amr Sabry. 2023. Symbolic Execution of Hadamard-Toffoli Quantum Circuits. In ACM SIGPLAN International Workshop on Partial Evaluation and Program Manipulation. 14–26. doi:10.1145/3571786.3573018DOI
  14. [15]Tian-Fu Chen, Yu-Fang Chen, Jie-Hong Roland Jiang, Sára Jobranová, and Ondřej Lengál. 2024. Accelerating Quantum Circuit Simulation with Symbolic Execution and Loop Summarization. In IEEE/ACM International Conference on Computer-Aided Design. 1–9. doi:10.1145/3676536.3676711DOI
  15. [16]Yanbin Chen, Christian B. Mendl, and Helmut Seidl. 2026. Dead gate elimination in hybrid quantum-classical programs. J. Comput. Sci. 95 (2026), 102789. doi:10.1016/J.JOCS.2026.102789DOI
  16. [18]Wang Fang, Chris Heunen, and Robin Kaar sgaard. 2026. Hadamard-Pi: Equational Quantum Programming. In ACM SIGPLAN Symposium on Principles of Programming Languages. 117–143. doi:10.1145/3776647DOI
  17. [19]Wang Fang and Mingsheng Ying. 2024. Symbolic Execution for Quantum Error Correction Programs. In ACM SIGPLAN Conference on Programming Language Design and Implementation, Vol. 8. 1040–1065. doi:10.1145/3656419DOI
  18. [20]Jean-Christophe Filliâtre and Sylvain Conchon. 2006. Type-safe modular hash-consing. In ACM SIGPLAN Workshop on ML. 12–19. doi:10.1145/1159876.1159880
  19. [21]Craig Gidney. 2018. Halving the cost of quantum addition. Quantum 2 (2018), 74. doi:10.22331/q-2018-06-18-74DOI
  20. [22]Craig Gidney. 2019a. Spooky Pebble Games and Irreversible Uncomputation. Retrieved October 10, 2026 from https://algassert.com/post/1905
  21. [23]Craig Gidney. 2019b. Windowed quantum arithmetic. arXiv:1905.07682 [quant-ph] doi:10.48550/arXiv.1905.07682DOI
  22. [24]Craig Gidney, Noah Shutty, and Cody Jones. 2024. Magic state cultivation: growing T states as cheap as CNOT gates. arXiv:2409.17595 [quant-ph] doi:10.48550/arXiv.2409.17595DOI
  23. [25]Matthew P. Harrigan, Tanuj Khattar, Charles Yuan, Anurudh Peduri, Noureldin Yosri, Fionn D. Malone, Ryan Babbush, and Nicholas C. Rubin. 2024. Expressing and Analyzing Quantum Algorithms with Qualtran. arXiv:2409.04643 [quant-ph] doi:10.48550/arXiv.2409.04643 Note: The And bloq and its measurement-based adjoint: https://qualtran.readthedocs.io/en/latest/bloqs/ncmt/and_bloq.html.DOI
  24. [26]Kengo Hirata and Chris Heunen. 2025. Qurts: Automatic Quantum Uncomputation by Affine Types with Lifetime. In ACM SIGPLAN Symposium on Principles of Programming Languages. 155–182. doi:10.1145/3704842DOI
  25. [27]Ali Javadi-Abhari, Matthew Treinish, Kevin Krsulich, Christopher J. Wood, Jake Lishman, Julien Gacon, Simon Martiel, Paul D. Nation, Lev S. Bishop, Andrew W. Cross, Blake R. Johnson, and Jay M. Gambetta. 2024. Quantum computing with Qiskit. arXiv:2405.08810 [quant-ph] doi:10.48550/arXiv.2405.08810
  26. [28]Minjun Jeon, Po-Wei Huang, and Zhenyu Cai. 2026. Error Correction for Quantum Uncomputation from an Error Correction Perspective. arXiv:2609.31605 [quant-ph] doi:10.48550/arXiv.2609.31605DOI
  27. [29]Cody Jones. 2013. Low-overhead constructions for the fault-tolerant Toffoli gate. Physical Review A 87, 2 (2013), 022328. doi:10.1103/physreva.87.022328DOI
  28. [30]Tanuj Khattar, Noah Shutty, Craig Gidney, Adam Zalcman, Noureldin Yosri, Dmitri Maslov, Ryan Babbush, and Stephen P. Jordan. 2025. Verifiable Quantum Advantage via Optimized DQI Circuits. arXiv:2510.10967 [quant-ph] doi:10.48550/arXiv.2510.10967DOI
  29. [31]Emanuel Knill. 1995. An analysis of Bennett’s pebble game. arXiv:math/9508218 [math.CO] doi:10.48550/arXiv.math/9508218DOI
  30. [32]Niels Kornerup, Jonathan Sadun, and David Soloveichik. 2025. Tight Bounds on the Spooky Pebble Game: Recycling Qubits with Measurements. Quantum 9 (2025), 1636. doi:10.22331/q-2025-02-18-1636DOI
  31. [33]Kanguk Lee, Jaemin Hong, and Sukyoung Ryu. 2025. Exact Inference for Quantum Circuits: A Testing Oracle for Quantum Software Stacks. In IEEE/ACM International Conference on Automated Software Engineering. 2465–2477. doi:10.1109/ASE63991.2025.002003DOI
  32. [34]Daniel Litinski. 2019. A Game of Surface Codes: Large-Scale Quantum Computing with Lattice Surgery. Quantum 3 (2019), 128. doi:10.22331/q-2019-03-05-128DOI
  33. [35]Chenke Liu, Li Zhou, and Boning Meng. 2026. Quantum Uncomputation of Clean and Dirty Ancilla Qubits. In ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications. 2270–2298. doi:10.1145/3839528DOI
  34. [36]Junyi Liu, Bohua Zhan, Shuling Wang, Shenggang Ying, Tao Liu, Yangjia Li, Mingsheng Ying, and Naijun Zhan. 2019. Formal Verification of Quantum Algorithms Using Quantum Hoare Logic. In International Conference on Computer Aided Verification. 187–207. doi:10.1007/978-3-030-25543-5_12DOI
  35. [37]Alessandro Luongo, Antonio Michele Miti, Varun Narasimachar, and Adithya Sireesh. 2025. Measurement-based uncomputation of quantum circuits for modular arithmetic. In ACM/IEEE Design Automation Conference. 1–7. doi:10.1109/DAC63849.2025.11132981DOI
  36. [38]Dmitri Maslov. 2016. Advantages of using relative-phase Toffoli gates with an application to multiple control Toffoli optimization. Physical Review A 93, 2 (2016), 022311. doi:10.1103/PhysRevA.93.022311DOI
  37. [39]Giulia Meuli, Mathias Soeken, and Giovanni De Micheli. 2022. Xor-And-Inverter Graphs for Quantum Compilation. npj Quantum Information 8, 1 (2022), 7. doi:10.1038/s41534-021-000514-yDOI
  38. [40]Michael A. Nielsen and Isaac L. Chuang. 2010. Quantum Computation and Quantum Information (10th ed.). Cambridge University Press, New York. doi:10.1017/CBO9780511976667
  39. [41]Anouk Paradis, Benjamin Bichsel, Samuel Steffen, and Martin Vechev. 2021a. Unqomp: Replication Package. https://github.com/eth-sri/Unqomp Note: commit 9d7e885; see unqomp/examples/mcx.py and unqomp/ancillaallocation.py.
  40. [42]Anouk Paradis, Benjamin Bichsel, Samuel Steffen, and Martin Vechev. 2021b. Unqomp: Synthesizing Uncomputation in Quantum Circuits. In ACM SIGPLAN Conference on Programming Language Design and Implementation. 222–236. doi:10.1145/3453483.3454040DOI
  41. [43]Anouk Paradis, Benjamin Bichsel, and Martin Vechev. 2022. Reqomp: Implementation. https://github.com/eth-sri/Reqomp Note: commit fd2256e; see reqomp/examples/mcx.py and reqomp/ancilla_circuit.py.
  42. [44]Anouk Paradis, Benjamin Bichsel, and Martin Vechev. 2024. Reqomp: Space-constrained Uncomputation for Quantum Circuits. Quantum 8 (2024), 1258. doi:10.22331/q-2024-02-19-1258DOI
  43. [45]Jennifer Paykin, Robert Rand, and Steve Zdancewic. 2017. QWIRE: A Core Language for Quantum Circuits. In ACM SIGPLAN Symposium on Principles of Programming Languages. 846–858. doi:10.1145/3009837.3009894DOI
  44. [46]Anurudh Peduri, Siddharth Bhat, and Tobias Grosser. 2022. QSSA: An SSA-based IR for Quantum Computing. In ACM SIGPLAN International Conference on Compiler Construction. 2–14. doi:10.1145/3497776.3517772DOI
  45. [48]Arend-Jan Quist and Alfons Laarman. 2023. Optimizing quantum space using spooky pebble games. In International Conference on Reversible Computation. Springer, 134–149. doi:10.1007/978-3-031-38003-10DOI
  46. [49]Ethan Schuchman and T. N. Vijaykumar. 2006. A program transformation and architecture support for quantum uncomputation. In International Conference on Architectural Support for Programming Languages and Operating Systems. 252–263. doi:10.1145/1168857.1168889DOI
  47. [50]Raphael Seidel, Sebastian Bock, René Zander, Matic Petrič, Niklas Steinmann, Nikolay Tcholtchev, and Manfred Hauswirth. 2024. Qrisp: A Framework for Compilable High-Level Programming of Gate-Based Quantum Computers. arXiv:2406.14792 [quant-ph] doi:10.48550/arXiv.2406.14792 Note: Gidney’s temporary AND with measurement-based uncomputation is mcx(..., method="gidney"): https://qrisp.eu/reference/Primitives/generated/qrisp.mcx.html.DOI
  48. [51]Peter Selinger. 2013. Quantum circuits of T-depth one. Physical Review A 87, 4 (2013), 042302. doi:10.1103/physreva.87.042302DOI
  49. [52]Ritvik Sharma and Sara Achour. 2025. Optimizing Ancilla-Based Quantum Circuits with SP. In ACM SIGPLAN Conference on Programming Language Design and Implementation. 176–200. doi:10.1145/3729253DOI
  50. [53]Yunong Shi, Nelson Leung, Pranav Gokhale, Zane Rossi, David L. Schuster, Henry Hoffmann, and Frederic T. Chong. 2019. Optimized Compilation of Aggregated Instructions for Realistic Quantum Computers. In International Conference on Architectural Support for Programming Languages and Operating Systems. 1031–1044. doi:10.1145/3297858.3304018DOI
  51. [54]Gyeongju Song, Youngbae Jang, Hyunjun Kim, Siwoo Eum, Minjoo Sim, Hyunyi Kim, Wookeon Lee, and Hwangjeong Seo. 2022. SPEEDY Quantum Circuit for Grover’s Algorithm. Applied Sciences 12, 14 (2022), 1–14. doi:10.3390/app12146870DOI
  52. [55]Bonan Su, Li Zhou, Yuan Feng, and Mingsheng Ying. 2026. Borrowing Dirty Qubits in Quantum Programs. In ACM International Conference on Architectural Support for Programming Languages and Operating Systems. 274–289. doi:10.1145/3779212.3790134DOI
  53. [56]Krysta M. Svore, Alan Geller, Matthias Troyer, John Azariah, Christopher Granade, Bettina Heim, Vadym Kliuchnikov, Mariia Mykhailova, Andres Paz, and Martin Roetteler. 2018. Q#: Enabling Scalable Quantum Computing and Development with a High-level DSL. In Real World Domain Specific Languages Workshop. 1–10. doi:10.1145/3183895.3183901 Note: The AND operation in the Q# standard library (Std.Intrinsic.AND), whose adjoint is reserved for uncomputation: https://learn.microsoft.com/en-us/qsharp/api/qsharp-lang/std.intrinsic.and.
  54. [57]Runzhou Tao, Yunong Shi, Jianan Yao, Xupeng Li, Ali Javadi-Abhari, Andrew W. Cross, Frederic T. Chong, and Ronghui Gu. 2022. Guallar: Push-button Verification for the Qiskit Quantum Compiler. In ACM SIGPLAN Conference on Programming Language Design and Implementation. 641–656. doi:10.1145/3519939.3523431DOI
  55. [59]Ashutosh Tiwari, Ranjani G. Sundaram, Himanshu Gupta, C.R. Ramakrishnan, and Nengkun Yu. 2025. Uncomputing Ancilla Qubits in Quantum Circuits. In International Conference on Quantum Communications, Networking, and Computing. 379–387. doi:10.1109/QCNC64685.2025.00065DOI
  56. [60]Hristo Venev, Timon Gehr, Dimitar Dimitrov, and Martin Vechev. 2024. Modular Synthesis of Efficient Quantum Uncomputation. In ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications. 2097–2124. doi:10.1145/3689785DOI
  57. [61]Christopher John Wright, Mikel Luján, Pavlos Petoumenos, and John Goodacre. 2024. Quff: A Dynamically Typed Hybrid Quantum-Classical Programming Language. In ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes. 65–81. doi:10.1145/3679007.3685063DOI
  58. [62]Huiling Wu and Yuxin Deng. 2026. ReQC: Compilation of Recursive Quantum Oracles with Recursion-Aware Uncomputation. arXiv:2608.07973 [cs.PL] doi:10.48550/arXiv.2608.07973DOI
  59. [63]Amanda Xu, Abtin Molavi, Lauren Pick, Swamit Tannu, and Aws Albarghouthi. 2023. Synthesizing Quantum-Circuit Optimizers. In ACM SIGPLAN Conference on Programming Language Design and Implementation. 835–859. doi:10.1145/3591254DOI
  60. [64]Mingkuan Xu, Zikun Li, Oded Padon, Sina Lin, Jessica Pointing, Auguste Hirth, Henry Ma, Jens Palsberg, Alex Aiken, Umut A. Acar, and Zhihua Jia. 2022. Quartz: Superoptimization of Quantum Circuits. In ACM SIGPLAN Conference on Programming Language Design and Implementation. 625–640. doi:10.1145/3599339.3523433DOI
  61. [65]Lei-Han Yao, Shang-Wei Lin, Yu-Chung Chen, and Yean-Ru Chen. 2026. A Modular and T-Gate Efficient Architecture for Quantum Leading-Zero/One Counter. arXiv:2604.13943 [quant-ph] doi:10.48550/arXiv.2604.13943DOI
  62. [66]Nengkun Yu and Jens Palsberg. 2021. Quantum Abstract Interpretation. In ACM SIGPLAN Conference on Programming Language Design and Implementation. 542–558. doi:10.1145/3453483.3454061DOI
  63. [67]Charles Yuan and Michael Carbin. 2022. Tower: Data Structures in Quantum Superposition. In ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications. 259–288. doi:10.1145/3563297DOI
  64. [68]Chen Zhang, Haojie Wang, Zixuan Ma, Lei Xie, Zeyu Song, and Jidong Zhai. 2022. UniQ: A Unified Programming Model for Efficient Quantum Circuit Simulation. In International Conference for High Performance Computing, Networking, Storage and Analysis. 1–16. doi:10.1109/SC41404.2022.00054DOI
  65. [69]Ivan I. Zhelgalkin. 1927. On the technique of calculating propositions in symbolic logic. Matematicheskii Sbornik 34, 1 (1927), 9–28.

Paper details

vlnc:W_s3uf4dm6
v1 · latestHistory (1)

published · Fresh — added to the Hub within the last 30 days

added ·

Usage

views · 4

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

CC BY 4.0

Original source

  • Computer Science

Not recorded for this paper · View statement →

Looking for related papers…
Contents