\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}
