Toffoli gate (source code)

= Toffoli gate
{c}
{wiki}

The <Toffoli gate> is a reversible three-<qubit> <quantum gate> with two controls and one target. It flips the target only when both controls are $1$.

The <Toffoli gate> maps $|x_1x_2y\rangle$ to $|x_1x_2,y\mathbin\oplus x_1x_2\rangle$.

For a target initially in $|0\rangle$, the output target records the classical AND $x_1x_2$ while both input labels remain available. Applying the <Toffoli gate> again erases that computed target reversibly. The same rule acts linearly on <quantum superpositions>, so it can be used inside a coherent <quantum circuit>. <Qiskit quantum gate documentation by IBM>[IBM Quantum, CCXGate: two controls and target action]{ref}