Toffoli Gate Is Universal

Initializing live version
Download to Desktop

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.

The quantum Toffoli or CCNOT gate has three inputs and three outputs; if the first two qubits are both equal to 1, the gate inverts the third qubit; otherwise, it is left unchanged. The Toffoli gate is a universal logic gate, which means that any classical circuit can be constructed from Toffoli gates. We consider the NOT, AND, NAND and XOR gates and FANOUT, which can be simulated by a single Toffoli gate. (OR requires three Toffoli gates.) The right-hand side of the graphic shows the operation of the Toffoli gate for selected inputs , and . The kets marked in red are involved in the simulation of the classical gate shown on the left.


After selecting which gate to simulate, follow the instructions on the graphic. For example, NOT requires that you set and .


Contributed by: S. M. Blinder (August 27)
Open content licensed under CC BY-NC-SA



[1] G. Fano and S. M. Blinder, Twenty-First Century Quantum Mechanics, Berlin: Springer, 2018 pp. 222ff.

[2] M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed., Cambridge: Cambridge University Press, 2010 pp. 159ff.


Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.