AND gate 2026-10-25
An AND gate computes for bits . It is irreversible when only its one-bit output is retained. The Toffoli gate embeds the operation reversibly as ; setting preserves the inputs while recording their logical conjunction.
Encode as . Four controlled-NOT gates copy the displayed two data parities into initially zero quantum ancillas. No logical amplitude is measured. The error syndromes correspond respectively to no bit flip and bit flips on data qubits . Conditional Toffoli gates, with temporary Pauli X gates implementing zero-valued controls, undo the indicated error. Inverse encoding yields the original logical state and a separate syndrome state. A phase flip has zero bit-flip syndrome and remains as a logical phase error; this three-qubit code is not a general single-qubit-error code.
Every Fredkin gate preserves the Hamming weight of a computational-basis string, so any network of these gates does too. A Toffoli gate maps to and hence cannot equal such a network on the same three wires. Fixed ancillas returned unchanged do not remove the obstruction. Extra encoded outputs or input-dependent garbage change the resource model and do not by themselves implement the same clean coherent three-qubit gate.
Use a classical target bit and initialized auxiliary bits. The NOT gate maps , the CNOT gate maps , and the Toffoli gate maps . They are bijections and are their own inverses. Explicit circuits with their retained input wires are:
  • AND: a Toffoli gate on produces .
  • OR: apply NOT to both controls, a Toffoli gate with target initialized to , then restore both controls. The target becomes .
  • CLONE: a CNOT gate on gives .
  • SWAP: apply , and . The successive pairs are , , then .
These maps also give the truth tables for all input combinations. AND and OR are not themselves reversible maps if the inputs are discarded; the retained inputs are what make their implementations reversible. Classical CLONE copies a known orthogonal computational basis alphabet; the no-cloning theorem forbids interpreting it as a copier of arbitrary quantum superpositions.
A Boolean circuit can express any finite Boolean function using AND, OR and NOT. Replace its operations by the reversible versions, keeping inputs and intermediate bits. Copy the final output into a fresh answer register with CNOT gates, then run the entire computing network backward. Intermediate auxiliary bits return to zero, yielding
This compute-copy-uncompute construction proves universality in the usual model with initialized auxiliary bits. If is a reversible permutation, compute , use a reversible implementation of to clear , and swap registers, leaving with clean auxiliaries. The ancillary-resource qualification matters; a blanket claim about all permutations on an arbitrary fixed number of unassisted wires has parity restrictions.
Figure 1.
Reversible Boolean constructions and a one-query Deutsch algorithm
. Original circuits for AND, OR, copying a classical bit and SWAP, with retained inputs and initialized targets shown explicitly. The lower panels show two classical oracle queries for the truth table and the phase-kickback quantum network that obtains only its parity in one query. Circuit operations run from left to right. Details.
Control all three CNOTs of the SWAP gate decomposition by qubit 1. This gives, in temporal order,
When the first qubit is 0, all three Toffoli gates do nothing. When it is 1, the three lower-wire CNOTs implement SWAP gate. The middle panel of the original diagram shows this controlled network.
Only one Toffoli gate is actually needed. An equivalent circuit is
For input , the first gate forms on wire 2. The second changes wire 3 to , and the final gate gives wire 2 the value . For this is ; for it is . The last panel displays the circuit.
The Hamming-weight obstruction to Fredkin-only Toffoli synthesis means that a network of Fredkin gates alone cannot implement a Toffoli gate on the same three wires: each Fredkin gate preserves computational-basis Hamming weight, whereas Toffoli gate maps to . The same obstruction holds if fixed ancillary bits must be returned unchanged. Conservative classical computation can use extra encoded wires and input-dependent garbage, but that is not an ancilla-free coherent three-qubit Toffoli gate operation. The resources and output encoding would need to be specified before making a different universality claim.
Allow clean workspace bits, as in standard reversible computation. Boolean algebra expresses any Boolean function as XORs of ANDs and constants. A Toffoli gate maps to , so an initially zero target computes an AND without erasing the inputs. A CNOT gate accumulates XORs, and a NOT gate supplies complemented bits or constants. Intermediate products can be computed into workspace, XORed into an output, and then uncomputed by reversing the workspace computation. This realizes the reversible embedding for any Boolean function and, with reversible clean-up, universal reversible classical computation.
The Fredkin transformation has control and targets . A network of three gates, shown in i, is
where the sequence is executed left to right. After the first gate ; after the second ; and the last gives . If , ; if , . Thus the circuit is exactly a Fredkin gate.
The workspace qualification matters for the unrestricted universality claim. On four or more wires, every embedded NOT, CNOT and Toffoli gate is an even permutation of all computational states. Without ancillary wires they cannot implement, for example, a permutation swapping just and while fixing the other four-bit strings. Clean ancillas remove this obstruction on the designated input subspace.
An AND gate maps four possible pairs to one bit and loses information, so it is not reversible. A reversible embedding retains both inputs and uses a target bit:
This is the Toffoli gate; initializing computes while preserving enough information to invert the operation.
Classical reversible gates on one or two bits alone cannot synthesize every such operation. Every permutation of two bits is an invertible affine map over the finite field : there are of them, exactly the permutations. Their extensions to a larger register and their compositions remain affine. The nonlinear term in the Toffoli gate therefore cannot be generated. Three-bit reversible gates remove this obstruction, with ancillary bits initialized appropriately.
There is no conflict with quantum universality: one- and two-qubit gates may pass through quantum superpositions and use relative phases at intermediate steps. They are not restricted to permutations of computational basis states at every step. For example the Hadamard gate, T gate and CNOT gate can decompose a Toffoli gate exactly. Thus the classical affine obstruction does not apply to their intermediate unitary operators.
Use the Hilbert-Schmidt inner product normalized by the dimension: . The identity and the three Pauli matrices are Hermitian, each has square , and each nonidentity Pauli matrix has zero trace. For distinct nonidentity indices, the Pauli matrix multiplication law gives , which is traceless. Therefore
There are four such orthonormal operators, and the complex vector space of two-by-two matrices has dimension four. Hence they form an orthonormal basis. Taking the inner product of any with each basis element proves, for arbitrary complex and not just Hermitian ones,
For example, if , its four coefficients are , , , and , respectively.
For the joint error, regard the two prescribed basis outputs as the columns of an environment-valued linear map. Its coefficient array in the usual output-row, input-column convention is
The source's other array is arranged as a column of the images of basis kets; it must not be mistaken for this coefficient array acting on an amplitude column. Applying the just-proved Pauli matrix expansion componentwise in any environment orthonormal basis gives the Pauli decomposition of a qubit-environment isometry:
To check the potentially delicate sign of the Pauli Y gate coefficient, use and . The four terms then give
Linearity proves the expansion for every input pure state. The environment coefficient vectors need not be normalized or mutually orthogonal. Consequently this expansion includes coherent combinations of Pauli errors, rather than asserting that every quantum channel is a probabilistic Pauli channel.
For the recovery probability, use the usual independent-use interpretation of the given phase-flip channel: each of the three transmitted qubits has a Pauli Z gate error independently with probability . The phase-flip repetition code uses logical codewords and . The decoding Hadamard gates convert physical phase flips to bit flips because . We can then analyze the two decoding controlled-NOT gates and the final Toffoli gate directly, rather than assuming a recovery rule.
Let be the error bits after this basis conversion. For a logical basis input , the three data bits before inverse encoding are . The two controlled-NOT gates produce
The Toffoli gate flips the first wire when both of the last two bits are one. Its residual error is
The last two wires carry an error syndrome independent of . Thus this transformation preserves the amplitudes of an arbitrary superposition: zero or one phase error returns the original unknown qubit, while two or three phase errors leave the logical Pauli X gate applied to it. The probability of universally successful recovery is therefore
Equivalently, the decoded quantum channel is , with logical failure of the three-qubit phase-flip repetition code . For , the failure probability is below , since . A special input that is a Pauli X eigenstate is unchanged even by the residual logical error; this does not make the code correct that error on an unknown input. Its squared quantum fidelity with a particular pure input is . If the errors on different channel uses are correlated, the marginal probability alone is insufficient: the general universal success probability is the probability of at most one error.
Number the wires from top to bottom as . The first two controlled-NOT gates encode into the bit-flip repetition code
on data wires . The lower two zero ancillas store an error syndrome. Reading the PDF's four detection CNOTs gives
The syndrome and the data qubit to be flipped are therefore
This is coherent syndrome extraction for the three-qubit repetition code. The recovery Toffoli gates implement these conditions; the intervening Pauli X gates temporarily turn zero-valued controls into one-valued controls and then restore the syndrome wires. Finally, inverse encoding returns the logical state to the top wire and resets data wires 2 and 3 to zero.
For the specified error , the encoded data becomes . Both terms have syndrome , so detection factors out without revealing the logical amplitudes. Recovery flips data wire 1, restoring , and decoding yields
The lower four wires need not all return to zero: their syndrome record is independent of the logical state, which is what the correction requirement needs.
Use a reversible circuit to compute an -bit representation of the angle into a workspace register, with all additional work bits retained:
Write that representation as , with known binary place values (including the fixed scale and any integer bit). On the target, apply a controlled unitary gate controlled by each angle bit . Rotations about the same axis add their angles, so their product is
Finally apply to perform uncomputation. The workspace returns to zero while the control register and rotated target remain unchanged; the construction works coherently on every superposition of .
A polynomial time classical calculation has a polynomial-size reversible circuit with Toffoli gates, and each Toffoli gate has a constant-size decomposition into one-qubit and two-qubit gates. The controlled rotations are themselves two-qubit gates. Thus the total quantum circuit size is . This is the binary-angle implementation of a quantum variable rotation; the stipulated angle precision is understood.
Implement the assumed efficient classical algorithm for as a reversible circuit. On input , it computes an -bit binary expansion of the angle in a work register using Toffoli gates and elementary reversible gates. Write the computed angle as a sum of binary-weighted angles. For each angle bit, apply the corresponding controlled single-qubit rotation to the target. These rotations have the same axis, so their angles add and produce
Finally apply uncomputation to erase the work register. Each Toffoli gate and controlled rotation has a constant-size decomposition into one- and two-qubit gates when arbitrary one-qubit rotations are available. Ignoring the stipulated precision costs, the resulting circuit has size and returns every quantum ancilla to zero.
Write . Since the marked word is , the required oracle is a single Toffoli gate with and as its two controls and the answer qubit as its target:
The target flips exactly when both controls are one, which is exactly when .
Reversible circuit Created 2026-09-25 Updated 2026-10-03
A reversible circuit is composed of bijective gates. The Toffoli gate is universal for reversible Boolean computation when ancillary bits are available.