1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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}
|