summaryrefslogtreecommitdiff
path: root/content/know/concept/toffoli-gate
diff options
context:
space:
mode:
authorPrefetch2021-04-09 20:44:44 +0200
committerPrefetch2021-04-09 20:44:44 +0200
commit45af77f068aaa57c052cd861412d53beecbe5e3b (patch)
treed3cbd058679bdeb800f6e25afedecbbc8810dffc /content/know/concept/toffoli-gate
parent966048bd3594eac4d3398992c8ad3143e290303b (diff)
Expand knowledge base
Diffstat (limited to 'content/know/concept/toffoli-gate')
-rw-r--r--content/know/concept/toffoli-gate/and.pngbin0 -> 7765 bytes
-rw-r--r--content/know/concept/toffoli-gate/index.pdc93
-rw-r--r--content/know/concept/toffoli-gate/nand.pngbin0 -> 8119 bytes
-rw-r--r--content/know/concept/toffoli-gate/not.pngbin0 -> 6051 bytes
-rw-r--r--content/know/concept/toffoli-gate/or.pngbin0 -> 18615 bytes
-rw-r--r--content/know/concept/toffoli-gate/toffoli.pngbin0 -> 3979 bytes
-rw-r--r--content/know/concept/toffoli-gate/xor.pngbin0 -> 7708 bytes
7 files changed, 93 insertions, 0 deletions
diff --git a/content/know/concept/toffoli-gate/and.png b/content/know/concept/toffoli-gate/and.png
new file mode 100644
index 0000000..c406fda
--- /dev/null
+++ b/content/know/concept/toffoli-gate/and.png
Binary files differ
diff --git a/content/know/concept/toffoli-gate/index.pdc b/content/know/concept/toffoli-gate/index.pdc
new file mode 100644
index 0000000..84e7656
--- /dev/null
+++ b/content/know/concept/toffoli-gate/index.pdc
@@ -0,0 +1,93 @@
+---
+title: "Toffoli gate"
+firstLetter: "T"
+publishDate: 2021-04-09
+categories:
+- Quantum information
+
+date: 2021-04-09T14:44:43+02:00
+draft: false
+markup: pandoc
+---
+
+# Toffoli gate
+
+The **Toffoli gate** or **controlled-controlled-NOT (CCNOT) gate**
+is a logic gate that is *reversible* (no information is lost)
+and *universal* (all reversible logic circuits can be built using Toffoli gates).
+
+It takes three input bits $A$, $B$ and $C$,
+of which it returns $A$ and $B$ unchanged,
+and flips $C$ if both $A$ and $B$ are true.
+In circuit diagrams, its representation is:
+
+<a href="toffoli.png">
+<img src="toffoli.png" style="width:19%;display:block;margin:auto;">
+</a>
+
+This gate is reversible, because $A$ and $B$ are preserved,
+and are all you need to reconstruct to $C$.
+Moreover, this gate is universal,
+because we can make a NAND gate from it:
+
+<a href="nand.png">
+<img src="nand.png" style="width:38%;display:block;margin:auto;">
+</a>
+
+A NAND is enough to implement every conceivable circuit.
+That said, we can efficiently implement NOT, AND, and XOR using a single Toffoli gate too.
+Note that NOT is a special case of NAND:
+
+<a href="not.png">
+<img src="not.png" style="width:32%;display:block;margin:auto;">
+</a>
+
+<a href="and.png">
+<img src="and.png" style="width:35%;display:block;margin:auto;">
+</a>
+
+<a href="xor.png">
+<img src="xor.png" style="width:35%;display:block;margin:auto;">
+</a>
+
+Using these, we can, as an example, make an OR gate
+from three Toffoli gates,
+thanks to the fact that $A \lor B = \neg (\neg A \land \neg B)$,
+i.e. OR is NAND of NOT $A$ and NOT $B$:
+
+<a href="or.png">
+<img src="or.png" style="width:50%;display:block;margin:auto;">
+</a>
+
+Thanks to its reversibility and universality,
+the Toffoli gate is interesting in quantum computing,
+where it is often referred to as the CCNOT gate.
+In the basis $\ket{A} \ket{B} \ket{C}$, its matrix is:
+
+$$\begin{aligned}
+ \boxed{
+ \mathrm{CCNOT} =
+ \begin{bmatrix}
+ 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
+ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
+ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
+ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
+ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\
+ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\
+ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\
+ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0
+ \end{bmatrix}
+ }
+\end{aligned}$$
+
+If we apply this gate to an arbitrary three-qubit state $\ket{\psi}$,
+it swaps the last two coefficients:
+
+$$\begin{aligned}
+ \mathrm{CCNOT} \ket{\psi}
+ &= \mathrm{CCNOT} \big( c_{000} \ket{000} + c_{001} \ket{001} + c_{010} \ket{010} + c_{011} \ket{011} \\
+ &\qquad\qquad\quad\:\; c_{100} \ket{100} + c_{101} \ket{101} + c_{110} \ket{110} + c_{111} \ket{111} \big)
+ \\
+ &= c_{000} \ket{000} + c_{001} \ket{001} + c_{010} \ket{010} + c_{011} \ket{011} \\
+ &\quad\,\, c_{100} \ket{100} + c_{101} \ket{101} + c_{111} \ket{110} + c_{110} \ket{111}
+\end{aligned}$$
diff --git a/content/know/concept/toffoli-gate/nand.png b/content/know/concept/toffoli-gate/nand.png
new file mode 100644
index 0000000..5086537
--- /dev/null
+++ b/content/know/concept/toffoli-gate/nand.png
Binary files differ
diff --git a/content/know/concept/toffoli-gate/not.png b/content/know/concept/toffoli-gate/not.png
new file mode 100644
index 0000000..910cc85
--- /dev/null
+++ b/content/know/concept/toffoli-gate/not.png
Binary files differ
diff --git a/content/know/concept/toffoli-gate/or.png b/content/know/concept/toffoli-gate/or.png
new file mode 100644
index 0000000..8cb8763
--- /dev/null
+++ b/content/know/concept/toffoli-gate/or.png
Binary files differ
diff --git a/content/know/concept/toffoli-gate/toffoli.png b/content/know/concept/toffoli-gate/toffoli.png
new file mode 100644
index 0000000..53f3351
--- /dev/null
+++ b/content/know/concept/toffoli-gate/toffoli.png
Binary files differ
diff --git a/content/know/concept/toffoli-gate/xor.png b/content/know/concept/toffoli-gate/xor.png
new file mode 100644
index 0000000..4cebb3b
--- /dev/null
+++ b/content/know/concept/toffoli-gate/xor.png
Binary files differ