The Toffoli gate, also known as the Controlled-Controlled NOT gate, is a three-qubit operation defined by:
version 1.0
qubits 4
X q[1] # bring qubit 1 to the |1> state
X q[2] # bring qubit 2 to the |1> state
H q[3] # bring qubit 3 to the|+> state
display #display qubit state
Toffoli q[1], q[2], q[3]
display #display qubit state
Toffoli q[0], q[1], q[3]
display #display qubit state
| q[0] | ||||||
|---|---|---|---|---|---|---|
| q[1] | ||||||
| q[2] | ||||||
| q[3] |
For more information see Toffoli gate on Wikipedia.