logo

Toffoli/CCNOT Gate

Toffoli/CCNOT Gate

Definition1

The following vector-valued Boolean function is called a Toffoli gate.

T:{0,1}3{0,1}3 T : \left\{ 0, 1 \right\}^{3} \to \left\{ 0, 1 \right\}^{3}

T(a,b,c)=(a,b,(ab)c) T (a, b, c) = (a, b, (a \land b) \oplus c)

  • The CCNOT\text{CCNOT} gate is also known as.

Description

In the Toffoli gate, if the first two inputs are both 11, the third input is inverted. In all other cases, the input and output are the same. The specific calculation is as follows.

T(0,0,0)=(0,0,(00)0)=(0,0,00)=(0,0,0)T(0,0,1)=(0,0,(00)1)=(0,0,01)=(0,0,1)T(0,1,0)=(0,1,(01)0)=(0,1,00)=(0,1,0)T(0,1,1)=(0,1,(01)1)=(0,1,01)=(0,1,1)T(1,0,0)=(1,0,(10)0)=(1,0,00)=(1,0,0)T(1,0,1)=(1,0,(10)1)=(1,0,01)=(1,0,1)T(1,1,0)=(1,1,(11)0)=(1,1,10)=(1,1,1)T(1,1,1)=(1,1,(11)1)=(1,1,11)=(1,1,0) \begin{align*} T (0,0,0) &= (0, 0, (0 \land 0) \oplus 0) = (0, 0, 0 \oplus 0) = (0, 0, 0) \\ T (0,0,1) &= (0, 0, (0 \land 0) \oplus 1) = (0, 0, 0 \oplus 1) = (0, 0, 1) \\ T (0,1,0) &= (0, 1, (0 \land 1) \oplus 0) = (0, 1, 0 \oplus 0) = (0, 1, 0) \\ T (0,1,1) &= (0, 1, (0 \land 1) \oplus 1) = (0, 1, 0 \oplus 1) = (0, 1, 1) \\ T (1,0,0) &= (1, 0, (1 \land 0) \oplus 0) = (1, 0, 0 \oplus 0) = (1, 0, 0) \\ T (1,0,1) &= (1, 0, (1 \land 0) \oplus 1) = (1, 0, 0 \oplus 1) = (1, 0, 1) \\ T (1,1,0) &= (1, 1, (1 \land 1) \oplus 0) = (1, 1, 1 \oplus 0) = (1, 1, 1) \\ T (1,1,1) &= (1, 1, (1 \land 1) \oplus 1) = (1, 1, 1 \oplus 1) = (1, 1, 0) \\ \end{align*}

From the table above, it’s easy to see that TT is a reversible function and that applying TT twice composes to an identity function.

Id=TT \operatorname{Id} = T \circ T

Furthermore, since {T}\left\{ T \right\} is functionally complete, TT is a universal gate.

부울 함수기호진리표
TT
입력출력
aabbccaabb(ab)c(a \land b) \oplus c
000000000000
000011000011
001100001100
001111001111
110000110000
110011110011
111100111111
111111111100

Theorem

(Assuming unrestricted use of projection and injection), the Toffoli gate TT is a universal gate. In other words, {T}\left\{ T \right\} is functionally complete.

Proof

Theorem

If duplication functions are allowed, {}\left\{ \uparrow \right\} is functionally complete. In other words, the NAND\text{NAND} gate \uparrow is a universal gate.

According to the theorem above, showing that projection, injection, and TT can be used appropriately to express the duplication function cl\text{cl} and the NAND\text{NAND} gate completes the proof.

  • Duplication Function

    cl=p1Tı2ȷ1 \operatorname{cl} = p_{1} \circ T \circ \imath_{2} \circ \jmath_{1}

    Holds. First, calculating Tı2ȷ1(a)T \circ \imath_{2} \circ \jmath_{1} (a) gives the following.

    Tı2ȷ1(a)=Tı2(a,1)=T(a,1,0) T \circ \imath_{2} \circ \jmath_{1} (a) = T \circ \imath_{2} (a, 1) = T (a, 1, 0)

    Here, if a=1a = 1, then T(1,1,0)=(1,1,1)T(1, 1, 0) = (1, 1, 1); if a=0a = 0, then T(0,1,0)=(0,1,0)T(0, 1, 0) = (0, 1, 0), so the following holds.

    T(a,1,0)=(a,1,a) T(a, 1, 0) = (a, 1, a)

    Therefore, by taking p1p_{1},

    p1Tı2ȷ1(a)=p1(a,1,a)=(a,a)=cl(a) p_{1} \circ T \circ \imath_{2} \circ \jmath_{1} (a) = p_{1} (a, 1, a) = (a, a) = \operatorname{cl}(a)

  • NAND\text{NAND} Gate

    p0p1Tȷ2=p0p1Tȷ2(a,b)=ab p_{0} \circ p_{1} \circ T \circ \jmath_{2} = \uparrow \\ p_{0} \circ p_{1} \circ T \circ \jmath_{2} (a, b) = a \uparrow b

    Holds. Calculating in order gives the following.

    p0p1Tȷ2(a,b)=p0p1T(a,b,1)=p0p1(a,b,(ab)1)=p0(a,(ab)1)=(ab)1=¬(ab)=ab \begin{align*} p_{0} \circ p_{1} \circ T \circ \jmath_{2} (a, b) &= p_{0} \circ p_{1} \circ T (a, b, 1) \\ &= p_{0} \circ p_{1} (a, b, (a \land b) \oplus 1) \\ &= p_{0} (a, (a \land b) \oplus 1) \\ &= (a \land b) \oplus 1 \\ &= \lnot(a \land b) = a \uparrow b \end{align*}

    The last line holds due to the properties of the XOR\text{XOR} gate.


  1. Kim Young-hoon and Heo Jae-seong, Quantum Information Theory (2020), pp. 89-93 ↩︎