From 45af77f068aaa57c052cd861412d53beecbe5e3b Mon Sep 17 00:00:00 2001 From: Prefetch Date: Fri, 9 Apr 2021 20:44:44 +0200 Subject: Expand knowledge base --- sources/know/concept/toffoli-gate/circuit.tex | 171 ++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 sources/know/concept/toffoli-gate/circuit.tex (limited to 'sources/know/concept/toffoli-gate') 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} -- cgit v1.2.3