summaryrefslogtreecommitdiff
path: root/sources/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 /sources/know/concept/toffoli-gate
parent966048bd3594eac4d3398992c8ad3143e290303b (diff)
Expand knowledge base
Diffstat (limited to 'sources/know/concept/toffoli-gate')
-rw-r--r--sources/know/concept/toffoli-gate/circuit.tex171
1 files changed, 171 insertions, 0 deletions
diff --git a/sources/know/concept/toffoli-gate/circuit.tex b/sources/know/concept/toffoli-gate/circuit.tex
new file mode 100644
index 0000000..af86d7b
--- /dev/null
+++ b/sources/know/concept/toffoli-gate/circuit.tex
@@ -0,0 +1,171 @@
+\documentclass[11pt]{article}
+\usepackage[utf8]{inputenc}
+\usepackage{amsmath}
+\usepackage{amsfonts}
+\usepackage{physics}
+\usepackage{yquant}
+
+
+\begin{document}
+
+\section{Example}
+
+\begin{tikzpicture}
+ \begin{yquant}[operator/separation=5mm]
+ qubit {$A$} A;
+ qubit {$B$} B;
+ qubit {$C$} C;
+
+ zz (A, B);
+ [operator/separation=-5mm]
+ cnot C | B;
+ \end{yquant}
+\end{tikzpicture}
+
+\section{NOT}
+
+\begin{tikzpicture}
+ \begin{yquant}[operator/separation=5mm]
+ qubit {$A$} A;
+ qubit {$1$} B;
+ qubit {$1$} C;
+
+ zz (A, B);
+ [operator/separation=-5mm]
+ cnot C | B;
+ %[value=$\mathrm{NOT}(A) \protect{=} \neg A$]
+ [value=$\mathrm{NOT}(A)$]
+ output C;
+ \end{yquant}
+\end{tikzpicture}
+
+\section{AND}
+
+\begin{tikzpicture}
+ \begin{yquant}[operator/separation=5mm]
+ qubit {$A$} A;
+ qubit {$B$} B;
+ qubit {$0$} C;
+
+ zz (A, B);
+ [operator/separation=-5mm]
+ cnot C | B;
+ %[value=$\mathrm{AND}(A\protect{,} B) \protect{=} A \land B$]
+ [value=$\mathrm{AND}(A\protect{,} B)$]
+ output C;
+ \end{yquant}
+\end{tikzpicture}
+
+\section{NAND}
+
+\begin{tikzpicture}
+ \begin{yquant}[operator/separation=5mm]
+ qubit {$A$} A;
+ qubit {$B$} B;
+ qubit {$1$} C;
+
+ zz (A, B);
+ [operator/separation=-5mm]
+ cnot C | B;
+ %[value=$\mathrm{NAND}(A\protect{,} B) \protect{=} \neg (A \land B)$]
+ [value=$\mathrm{NAND}(A\protect{,} B)$]
+ output C;
+ \end{yquant}
+\end{tikzpicture}
+
+\section{XOR}
+
+\begin{tikzpicture}
+ \begin{yquant}[operator/separation=5mm]
+ qubit {$A$} A;
+ qubit {$1$} B;
+ qubit {$B$} C;
+
+ zz (A, B);
+ [operator/separation=-5mm]
+ cnot C | B;
+ %[value=$\mathrm{XOR}(A\protect{,} B) \protect{=} A \oplus B$]
+ [value=$\mathrm{XOR}(A\protect{,} B)$]
+ output C;
+ \end{yquant}
+\end{tikzpicture}
+
+\section{OR}
+
+\begin{tikzpicture}
+ \begin{yquant}[operator/separation=5mm]
+ qubit {$A$} A;
+ qubit {$1$} I1;
+ qubit {$1$} I2;
+ qubit {$B$} B;
+ qubit {$1$} I3;
+ qubit {$1$} I4;
+ qubit {$1$} I5;
+
+ % NOT A
+ zz (A, I1);
+ [operator/separation=-5mm]
+ cnot I2 | I1;
+ discard A;
+ discard I1;
+ % NOT B
+ zz (B, I3);
+ [operator/separation=-5mm]
+ cnot I4 | I3;
+ discard B;
+ discard I3;
+ % NA AND NB
+ zz (I2, I4);
+ [operator/separation=-5mm]
+ cnot I5 | I4;
+ [value=$\mathrm{NOT}(A)$]
+ output I2;
+ %discard I2;
+ [value=$\mathrm{NOT}(B)$]
+ output I4;
+ %discard I4;
+ %[value=$\mathrm{OR}(A\protect{,} B) \protect{=} A \lor B$]
+ [value=$\mathrm{OR}(A\protect{,} B)$]
+ output I5;
+ \end{yquant}
+\end{tikzpicture}
+
+\subsection{Spacer}
+
+\begin{tikzpicture}
+ \begin{yquant}[operator/separation=5mm]
+ qubit {$A$} A;
+ qubit {$1$} I1;
+ qubit {$1$} I0;
+ qubit {$1$} I2;
+ qubit {$B$} B;
+
+ % NOT A
+ zz (I0, A);
+ [operator/separation=-5mm]
+ cnot I1 | A;
+ [value=$A$]
+ output A;
+ % NOT B
+ zz (I0, B);
+ [operator/separation=-5mm]
+ cnot I2 | B;
+ [value=$B$]
+ output B;
+ % NA AND NB
+ zz (I1, I2);
+ [operator/separation=-5mm]
+ cnot I0 | I1;
+ [value=$\mathrm{NOT}(A)$]
+ output I1;
+ %discard I2;
+ [value=$\mathrm{NOT}(B)$]
+ output I2;
+ %discard I4;
+ %[value=$\mathrm{OR}(A\protect{,} B) \protect{=} A \lor B$]
+ [value=$\mathrm{OR}(A\protect{,} B)$]
+ output I0;
+ \end{yquant}
+\end{tikzpicture}
+
+\end{document}